最新消息:20210917 已从crifan.com换到crifan.org

【未解决】rcsjta中研究RCS的core的Service本身相关代码以希望找到为何没启动的原因

Service crifan 326浏览 0评论
折腾:
【未解决】Android项目rcsjta中如何才能运行到rcs的core的service
和:
【未解决】通过调试rcs的core加运行其他几个apk去研究rcsjta的服务没运行的原因
期间,去单独调试RI的Service status中started是false,找找是否有突破口
通过搜代码找到
src/com/gsma/rcs/ri/service/ServiceStatus.java
public class ServiceStatus extends RcsActivity implements RcsServiceListener {

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
。。。
    setContentView(R.layout.service_status);

    mServiceBound = (TextView) findViewById(R.id.service_bound);
    mServiceActivated = (TextView) findViewById(R.id.service_activated);
    mServiceStarted = (TextView) findViewById(R.id.service_started);
很明显是此处的
ServiceStatus的onCreate中的
service_status是整个布局
service_activated是是否激活-》之前已调试得到true,是对的
service_started是 是否启动 -》 之前始终是false,要去找原因
继续找代码
src/com/gsma/rcs/ri/service/ServiceStatus.java
private void displayServiceStarted() {
    try {
        mServiceStarted.setText(Boolean.toString(mRcsServiceControl.isServiceStarted()));
-》
src/main/java/com/gsma/services/rcs/RcsServiceControl.java
public boolean isServiceStarted() throws RcsGenericException {
    if (sAccurateLog) {
        Log.d(LOG_TAG, "isServiceStarted: Request()");
    }
    Bundle result = queryRcsStackByIntent(new Intent(
            Intents.Service.ACTION_GET_SERVICE_STARTING_STATE));
    boolean started = result
            .getBoolean(Intents.Service.EXTRA_GET_SERVICE_STARTING_STATE, false);
    if (sAccurateLog) {
        Log.d(LOG_TAG,
                "isServiceStarted: Response() -> " + started + " (in "
                        + result.getLong(TIME_SPENT, -1) + "ms)");
    }
    return started;
}
很明显:
此处调试早就发现了,多次调用ACTION_GET_SERVICE_STARTING_STATE
但是core中的
src/com/gsma/rcs/service/RcsServiceControlReceiver.java
private class IntentProcessor extends Thread {

public void run() {

case Intents.Service.ACTION_GET_SERVICE_STARTING_STATE:
    Core core = Core.getInstance();
    boolean started = core != null && core.isStarted();
返回的是core.isStarted
但是由于内部
src/com/gsma/rcs/core/Core.java
public boolean isStarted() {
    return mStarted;
}
即:mStarted
始终是空的
表示没有启动
而调试到现在,也始终找不到 到底是哪里,应该是哪里,去启动core的Service
不过对应的代码调用去启动core的Service
倒是研究了很多,但是还是没头绪
也调试了多个apk,也还是无法发现,到底哪里应该去调用此处的core的Service
继续研究RCS的core的service本身相关的代码去找找原因。
继续向前追溯,发现好像是:
src/com/gsma/rcs/service/RcsCoreService.java
private synchronized void startCore() {

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);
。。。


    core.initialize();

    core.startCore();
难道是:
由于country code没定义 或不支持啥的 导致rcs的core的service没启动?
去看看,如何才能调试到此处的startCore
在同文件中
src/com/gsma/rcs/service/RcsCoreService.java
public class RcsCoreService extends Service implements CoreListener {

public void onCreate() {

startCore();
结果问题又来了
又回到了:谁调用了RcsCoreService
结果又是:
launchRcsCoreService
context.startService(new Intent(context, RcsCoreService.class));
而launchRcsCoreService谁调用了?
是有很多个
但是调试了多个apk,都运行不到对应断点,所以才郁闷了。找不到入口
不过注意到调用者,很多都是属于core的子目录下的代码
比如:
rcsjta/core/src/com/gsma/rcs/service/StartService.java
rcsjta/core/src/com/gsma/rcs/provisioning/https/HttpsProvisioningManager.java
那再多试试
调试core + 运行其他的 比如RI,settings
看看能否运行到这里
又去找到了很多的相关代码
包括很靠近顶层的
ImsNetworkInterface
RegistrationManager
等等
去加上断点,调试看看
依旧没运行到断点。
实在不行,难道真的要去:
从core的核心代码去研究看看?
到底是如何触发和启动service的?
/RCS/rcsjta/core/AndroidManifest.xml
去找root的activity?
好像没有
只有service
。。。
<application
    android:icon="@drawable/rcs_icon"
    android:label="@string/rcs_core_application_title">


    <!-- RCS service -->


    <service
        android:name="com.gsma.rcs.service.RcsCoreService"
        android:permission="com.gsma.services.permission.RCS">
        <intent-filter>
            <action android:name="com.gsma.rcs.SERVICE"/>
            <action android:name="com.gsma.services.rcs.contact.IContactService"/>
            <action android:name="com.gsma.services.rcs.capability.ICapabilityService"/>
            <action android:name="com.gsma.services.rcs.chat.IChatService"/>
            <action android:name="com.gsma.services.rcs.filetransfer.IFileTransferService"/>
            <action android:name="com.gsma.services.rcs.sharing.video.IVideoSharingService"/>
            <action android:name="com.gsma.services.rcs.sharing.image.IImageSharingService"/>
            <action android:name="com.gsma.services.rcs.sharing.geoloc.IGeolocSharingService"/>
            <action android:name="com.gsma.services.rcs.history.IHistoryService"/>
            <action android:name="com.gsma.services.rcs.extension.IMultimediaSessionService"/>
            <action android:name="com.gsma.services.rcs.upload.IFileUploadService"/>
        </intent-filter>
    </service>


    <!-- RCS settings application -->


    <activity
        android:name="com.gsma.rcs.provisioning.https.HttpsProvisioningAlertDialog"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:excludeFromRecents="true"
        android:theme="@style/Theme.UserDialog"/>


    <!-- RCS account: authenticator service for user's account information -->


    <service
        android:name="com.gsma.rcs.addressbook.AuthenticationService"
        android:exported="true">
        <intent-filter>
            <action android:name="android.accounts.AccountAuthenticator"/>
        </intent-filter>


        <meta-data
            android:name="android.accounts.AccountAuthenticator"
            android:resource="@xml/rcs_core_authenticator"/>
    </service>
。。。
搜搜看
AndroidManifest.xml application service
AndroidManifest.xml application service root
应用清单概览  |  Android 开发者  |  Android Developers
<service>  |  Android 开发者  |  Android Developers
AndroidManifest.xml文件详解(service)_FireOfStar的专栏-CSDN博客_android:enabled=true
感觉是:
service,是服务,只能被其他人调用启动
突然想起来:
那么settings中,默认启动后,看到RCS Service是已勾选的啊
但是为何没有启动,以及
如何检测出来的-》感觉有必要去深究看看
且感觉上面的:
    <!-- RCS settings application -->

    <activity
        android:name="com.gsma.rcs.provisioning.https.HttpsProvisioningAlertDialog"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:excludeFromRecents="true"
        android:theme="@style/Theme.UserDialog"/>
估计就是:
settings
这个apk,的对应的事情。
那看看如何能检测 以及 是否可以重新触发 去重启rcs的Service
继续研究了EXTRA_SET_ACTIVATION_MODE的代码,感觉是:
activate只是(在条件允许的前提下)去激活
但是不是 start启动
所以现在问题转为:
能最终调用到 start启动core的service的那些类和函数
比如:
rcsjta/core/src/com/gsma/rcs/service/StartService.java
rcsjta/core/src/com/gsma/rcs/provisioning/https/HttpsProvisioningManager.java
src/com/gsma/rcs/service/LauncherUtils.java
src/com/gsma/rcs/addressbook/SetupRcsAccount.java
目前继续找代码,发现一个之前没注意到的
src/com/gsma/rcs/addressbook/AuthenticationService.java
final static class RcsContactsAccountAuthenticator extends AbstractAccountAuthenticator {

    public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
        String authTokenType, String[] requiredFeatures, Bundle options)
        throws NetworkErrorException {

        Intent intent = new Intent(mContext, SetupRcsAccount.class);
        intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
src/com/gsma/rcs/addressbook/AuthenticationService.java
public class AuthenticationService extends Service {
。。。
    public void onCreate() {
        mAuthenticator = new RcsContactsAccountAuthenticator(this);
    }
This class is a Service to authenticate the user’s account information.
用于认证用户账户信息的
AndroidManifest.xml
<!-- RCS account: authenticator service for user's account information -->

<service
    android:name="com.gsma.rcs.addressbook.AuthenticationService"
    android:exported="true">
    <intent-filter>
        <action android:name="android.accounts.AccountAuthenticator"/>
    </intent-filter>


    <meta-data
        android:name="android.accounts.AccountAuthenticator"
        android:resource="@xml/rcs_core_authenticator"/>
</service>
是在manifest中的service,其下有个调用到它的intent-filter中的android.accounts.AccountAuthenticator
但是却找不到android.accounts.AccountAuthenticator
最接近的只有:
src/com/gsma/rcs/addressbook/AuthenticationService.java
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.AccountAuthenticatorResponse;
然后去看看:
final static class RcsContactsAccountAuthenticator extends AbstractAccountAuthenticator {
扩展了AbstractAccountAuthenticator的RcsContactsAccountAuthenticator
src/com/gsma/rcs/addressbook/AuthenticationService.java
public class AuthenticationService extends Service {

    private RcsContactsAccountAuthenticator mAuthenticator;
又回到了:
AuthenticationService
再去找找AccountAuthenticatorResponse
src/com/gsma/rcs/addressbook/SetupRcsAccount.java
public class SetupRcsAccount extends android.accounts.AccountAuthenticatorActivity {
。。。
    public void onCreate(Bundle icicle) {

    if (extras != null) {
        AccountAuthenticatorResponse response = extras
                .getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
再去找:SetupRcsAccount

还是之前代码,
是属于addressbook地址簿的
但是还是没搞懂如何初始化
去调试看看,能否运行到断点
都不行。
去试试:
【未解决】rcsjta中调试core的apk即RCS Provisioning的app中功能和选项以寻找core的service启动逻辑
之后问题转换为:
【已解决】安卓项目rcsjta中core的apk中入口activity或service是什么
然后继续:
【未解决】通过调试rcsjta中core的入口Provisioning去寻找服务启动的逻辑

转载请注明:在路上 » 【未解决】rcsjta中研究RCS的core的Service本身相关代码以希望找到为何没启动的原因

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.176 seconds, using 23.31MB memory