折腾:
【未解决】Mac中用Android Studio打开rctjsa项目并编译apk和实时调试安卓手机小米9
期间,已用Android Studio编译好core RI settings的3个apk了。
现在希望连接到真机上去调试和运行,找出RCS服务没运行的原因。
看看如何Android Studio连接安卓小米9去安装和调试
android studio 连接真机
android studio connect real phone

注意到此处,右上角工具栏中的确已经显示此处的安卓真机 小米9 了
然后想要点击运行,发现此时不是我们要的子模块
切换到RI

点击debug

会触发编译


然后小米9中就可以显示apk的界面了:

然后想要看 logcat的log
点击底部左下角的 logcat:

即可看到log
再去设置过滤 只看当前进程的:
com.gsma.rcs.ri
且level是 Warn:

信息是:
2020-08-04 15:01:06.346 2599-3245/com.gsma.rcs.ri W/com.gsma.rcs.r: Accessing hidden method Lmiui/contentcatcher/sdk/ContentCatcherManager;->unregisterContentInjector(Lmiui/contentcatcher/sdk/Token;)V (greylist, linking, allowed) 2020-08-04 15:01:06.573 2599-2599/com.gsma.rcs.ri W/[CNX][ConnectionManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:10.849 2599-3374/com.gsma.rcs.ri W/[RI][RcsServiceNotifManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:11.579 2599-3383/com.gsma.rcs.ri W/[CNX][ConnectionManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:15.859 2599-3423/com.gsma.rcs.ri W/[RI][RcsServiceNotifManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:16.585 2599-3426/com.gsma.rcs.ri W/[CNX][ConnectionManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:20.868 2599-3436/com.gsma.rcs.ri W/[RI][RcsServiceNotifManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:20.868 2599-3436/com.gsma.rcs.ri E/[RI][RcsServiceNotifManager]: Maximum attempts to connect API is reached 2020-08-04 15:01:21.593 2599-3438/com.gsma.rcs.ri W/[CNX][ConnectionManager]: Cannot connect service API: Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE! 2020-08-04 15:01:21.593 2599-3438/com.gsma.rcs.ri E/[CNX][ConnectionManager]: Maximum attempts to connect API is reached
然后就可以去研究输出错误日志
然后找找代码中的原因了。
然后尝试试试调试,先去打断点
找到了:
【未解决】rcsjta中RCS的RI中各种功能都提示:The service is not available Please retry later
提到的代码:

再去看看:
tools/settings/src/com/gsma/rcs/core/control/CoreControlApplication.java
中的代码
但是突然发现,感觉是不是应该去看
core目录下的代码?

有个startCore
感觉
com/gsma/rcs/service/RcsCoreService.java
更像是启动服务的?
com/gsma/rcs/service/RcsCoreService.java

/** * Start core */ private synchronized void startCore() { Core core = Core.getInstance(); boolean logActivated = sLogger.isActivated(); if (core != null) { if (core.isStopping()) { if (logActivated) { sLogger.debug("The core is stopping, we will restart it when core is stopped"); } core.setListener(this); mRestartCoreRequested = true; } if (core.isStarted()) { // Already started return; } } mRestartCoreRequested = false; com.gsma.services.rcs.contact.ContactUtil contactUtil = com.gsma.services.rcs.contact.ContactUtil .getInstance(this); if (!contactUtil.isMyCountryCodeDefined()) { if (logActivated) { sLogger.debug("Can't instantiate RCS core service, Reason : Country code not defined!"); } stopSelf(); return; } try { core = Core.createCore(mCtx, this, mRcsSettings, mContentResolver, mLocalContentResolver, mContactManager, mMessagingLog, mHistoryLog, mRichCallHistory); InstantMessagingService imService = core.getImService(); RichcallService richCallService = core.getRichcallService(); SipService sipService = core.getSipService(); CapabilityService capabilityService = core.getCapabilityService(); mContactApi = new ContactServiceImpl(mContactManager, mRcsSettings); mCapabilityApi = new CapabilityServiceImpl(capabilityService, mContactManager, mRcsSettings); mChatApi = new ChatServiceImpl(imService, mMessagingLog, mHistoryLog, mRcsSettings, mContactManager); mFtApi = new FileTransferServiceImpl(imService, mChatApi, mMessagingLog, mRcsSettings, mContactManager, mCtx); mVshApi = new VideoSharingServiceImpl(richCallService, mRichCallHistory, mRcsSettings); mIshApi = new ImageSharingServiceImpl(richCallService, mRichCallHistory, mRcsSettings); mGshApi = new GeolocSharingServiceImpl(richCallService, mRichCallHistory, mRcsSettings); mHistoryApi = new HistoryServiceImpl(mCtx); mMmSessionApi = new MultimediaSessionServiceImpl(sipService, mRcsSettings); mUploadApi = new FileUploadServiceImpl(imService, mRcsSettings); Logger.sActivationFlag = mRcsSettings.isTraceActivated(); Logger.traceLevel = mRcsSettings.getTraceLevel(); if (logActivated) { sLogger.info("RCS stack release is ".concat(TerminalInfo.getProductVersion(mCtx))); } core.initialize(); core.startCore(); // Create multimedia directory on sdcard FileFactory.createDirectory(mRcsSettings.getPhotoRootDirectory()); FileFactory.createDirectory(mRcsSettings.getVideoRootDirectory()); FileFactory.createDirectory(mRcsSettings.getAudioRootDirectory()); FileFactory.createDirectory(mRcsSettings.getFileRootDirectory()); String fileIconDirectory = mRcsSettings.getFileIconRootDirectory(); FileFactory.createDirectory(fileIconDirectory); FileFactory.setNoMedia(fileIconDirectory); String sentPhotoDirectory = ContentManager.getSentPhotoRootDirectory(mRcsSettings); FileFactory.createDirectory(sentPhotoDirectory); FileFactory.setNoMedia(sentPhotoDirectory); String sentVideoDirectory = ContentManager.getSentVideoRootDirectory(mRcsSettings); FileFactory.createDirectory(sentVideoDirectory); FileFactory.setNoMedia(sentVideoDirectory); String sentAudioDirectory = ContentManager.getSentAudioRootDirectory(mRcsSettings); FileFactory.createDirectory(sentAudioDirectory); FileFactory.setNoMedia(sentAudioDirectory); String sentFileDirectory = ContentManager.getSentFileRootDirectory(mRcsSettings); FileFactory.createDirectory(sentFileDirectory); FileFactory.setNoMedia(sentFileDirectory); // Init CPU manager mCpuManager = new CpuManager(mRcsSettings); mCpuManager.init(); // Register account changed event receiver if (mAccountChangedReceiver == null) { mAccountChangedReceiver = new AccountChangedReceiver(); // Register account changed broadcast receiver after a timeout of 2s (This is not // done immediately, as we do not want to catch // the removal of the account (creating and removing accounts is done // asynchronously). We can reasonably assume that no // RCS account deletion will be done by user during this amount of time, as he just // started his service. Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { registerReceiver(mAccountChangedReceiver, new IntentFilter( "android.accounts.LOGIN_ACCOUNTS_CHANGED")); } }, 2000); } if (logActivated) { sLogger.info("RCS core service started with success"); } } catch (IOException e) { if (sLogger.isActivated()) { sLogger.debug(e.getMessage()); } } catch (KeyStoreException e) { sLogger.error("Can't instanciate the RCS core service", e); stopSelf(); } }
感觉这部分才是核心代码。
需要去抽空调试看看。
至于该从哪入手去调试,还是回去看看
【基本解决】研究rcsjta中源码中和启动RCS的服务的相关代码和逻辑
找到RCS service真正启动的地方
目前先去:
【未解决】Android Studio真机小米9中调试rcsjta的RI的apk
期间发现需要先去启动core的apk,所以就再去
【未解决】Android Studio真机小米9中调试rcsjta的core的apk