折腾:
【未解决】Android项目rcsjta中如何才能运行到rcs的core的service
期间,去看看几个apk:
研究看看现象。
看看是否,对于rcs的core的service,是否有所启发
刚才试了试,还是可以通过RI中status看到是true的
但是后来发现又不对了:
即使settings中显示已启动
RS的status中是false了:
而前后是经过多次启动和关闭:
然后最后服务状态机就无法正常读取了
后来又去重新init:
也显示已启动了:
但是RI中显示:
API is not compatible
且注意到:
之前就提示的,现在显示的:
Service activated:Failed to read stack started status
TODO:
搜索代码中的:
- API is not compatible
- Service activated:Failed to read stack started status
以及相关何种原因导致的
API is not compatible
res/values/strings.xml
<string name="label_api_not_compatible">API is not compatible</string>
label_api_not_compatible
src/com/gsma/rcs/ri/service/ServiceStatus.java
public class ServiceStatus extends RcsActivity implements RcsServiceListener { public void onCreate(Bundle savedInstanceState) { // Connect API try { mApi.connect(); } catch (RcsPermissionDeniedException e) { mApi = null; showMessageThenExit(R.string.label_api_not_compatible); } }
src/com/gsma/rcs/ri/service/ServiceStatus.java
/** * RCS service up event listener */ private BroadcastReceiver serviceUpListener = new BroadcastReceiver() { @Override public void onReceive(Context context, final Intent intent) { // Retry a connection to the service try { mApi.connect(); } catch (RcsPermissionDeniedException e) { mApi = null; showMessageThenExit(R.string.label_api_not_compatible); } } };
去调试此处的RI看看,是如何运行到这里的
RI 中查看状态,可以进入断点:
继续调试,进入了,看起来最相关的代码:
src/main/java/com/gsma/services/rcs/RcsServiceControl.java
/** * Returns true if the client RCS API and core RCS stack are compatible for the given service. * * @param service the RCS service * @return boolean true if the client RCS stack and RCS API are compatible for the given * service. * @throws RcsGenericException * @hide */ public boolean isCompatible(RcsService service) throws RcsGenericException { String serviceName = service.getClass().getSimpleName(); if (sAccurateLog) { Log.d(LOG_TAG, "isCompatible: Request(" + serviceName + ")"); } Bundle result = queryRcsStackByIntent(generateIsCompatibeIntent(serviceName)); boolean compatible = result.getBoolean(Intents.Service.EXTRA_GET_COMPATIBILITY_RESPONSE, false); if (sAccurateLog) { Log.d(LOG_TAG, "isCompatible: Response(" + serviceName + ") -> " + compatible + " (in " + result.getLong(TIME_SPENT, -1) + "ms)"); } return compatible; }
结果最后调试完毕了,还是没太看出来,为何不兼容
重新调试,好像是:
src/main/java/com/gsma/services/rcs/capability/CapabilityService.java
/** * Connects to the API * * @throws RcsPermissionDeniedException */ public final void connect() throws RcsPermissionDeniedException { if (!sApiCompatible) { try { sApiCompatible = mRcsServiceControl.isCompatible(this); if (!sApiCompatible) { throw new RcsPermissionDeniedException( "The TAPI client version of the capability service is not compatible with the TAPI service implementation version on this device!"); } } catch (RcsServiceException e) { throw new RcsPermissionDeniedException( "The compatibility of TAPI client version with the TAPI service implementation version of this device cannot be checked for the capability service!", e); } } Intent serviceIntent = new Intent(ICapabilityService.class.getName()); serviceIntent.setPackage(RcsServiceControl.RCS_STACK_PACKAGENAME); mCtx.bindService(serviceIntent, apiConnection, 0); }
继续多调试几次看看
是这里:
src/main/java/com/gsma/services/rcs/RcsServiceControl.java
/** * Query RCS stack by sending broadcast intent. * * @param intent Intent * @return the result extra data bundle or null if no response is received due to timeout * @throws RcsGenericException raised if timeout */ private Bundle queryRcsStackByIntent(Intent intent) throws RcsGenericException { Bundle result = broadcastReceiver.getResultExtras(false);
中的:
broadcastReceiver.getResultExtras
报错的。
即:广播intent后,没有返回希望的数据。
所以要再去找:
这个intent具体是谁负责处理的
注意到上面中的action是:
com.gsma.services.rcs.action.GET_COMPATIBILITY
去找找:
GET_COMPATIBILITY
src/main/java/com/gsma/services/rcs/Intents.java
/** * Intent to check if RCS stack is compatible with RCS API */ public static final String ACTION_GET_COMPATIBILITY = "com.gsma.services.rcs.action.GET_COMPATIBILITY";
搜:
ACTION_GET_COMPATIBILITY
src/com/gsma/rcs/service/RcsServiceControlReceiver.java
private class IntentProcessor extends Thread { @Override public void run() { case Intents.Service.ACTION_GET_COMPATIBILITY: String serviceName = mIntent .getStringExtra(Intents.Service.EXTRA_GET_COMPATIBILITY_SERVICE); String codename = mIntent .getStringExtra(Intents.Service.EXTRA_GET_COMPATIBILITY_CODENAME); int version = mIntent.getIntExtra( Intents.Service.EXTRA_GET_COMPATIBILITY_VERSION, INVALID_EXTRA); int increment = mIntent.getIntExtra( Intents.Service.EXTRA_GET_COMPATIBILITY_INCREMENT, INVALID_EXTRA); boolean compatible = isCompatible(serviceName, codename, version, increment); mResult.putBoolean(Intents.Service.EXTRA_GET_COMPATIBILITY_RESPONSE, compatible); if (sAccurateLog && sLogger.isActivated()) { sLogger.debug("isCompatible(" + serviceName + ") -> " + compatible); } break;
此处代码已加了断点了。
但是没有运行到
说明此处程序没有运行?
此处是core的apk 没有运行?
那么去试试:
【未解决】通过调试core加运行RI去研究rcsjta的服务没运行的原因
转载请注明:在路上 » 【记录】研究rcsjta的几个apk的运行现象尝试搞懂rcs的core的service服务相关逻辑