Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59d7c92c authored by Shriram Ganesh's avatar Shriram Ganesh Committed by Etan Cohen
Browse files

IMS: Update data rat in IMS phone service state.

Keep the data rat information in Ims phone servicestate updated
with that from default phone.
This makes sure applications can query correct data RAT when
default phone is not registered to voice and ims is in service.

Bug: 22123213
Change-Id: I8161a43efe9408572d41d7a0a320972873a7e60c
parent e589ac93
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public class ImsPhone extends ImsPhoneBase {
    protected static final int EVENT_GET_CALL_BARRING_DONE          = EVENT_LAST + 2;
    protected static final int EVENT_SET_CALL_WAITING_DONE          = EVENT_LAST + 3;
    protected static final int EVENT_GET_CALL_WAITING_DONE          = EVENT_LAST + 4;
    protected static final int EVENT_DEFAULT_PHONE_DATA_STATE_CHANGED  = EVENT_LAST + 5;

    public static final String CS_FALLBACK = "cs_fallback";

@@ -187,12 +188,29 @@ public class ImsPhone extends ImsPhoneBase {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
        mWakeLock.setReferenceCounted(false);

        if (mDefaultPhone.getServiceStateTracker() != null) {
            mDefaultPhone.getServiceStateTracker()
                    .registerForDataRegStateOrRatChanged(this,
                    EVENT_DEFAULT_PHONE_DATA_STATE_CHANGED, null);
        }
        updateDataServiceState();
    }

    public void updateParentPhone(PhoneBase parentPhone) {
        // synchronization is managed at the PhoneBase scope (which calls this function)
        if (mDefaultPhone != null && mDefaultPhone.getServiceStateTracker() != null) {
            mDefaultPhone.getServiceStateTracker().
                    unregisterForDataRegStateOrRatChanged(this);
        }
        mDefaultPhone = parentPhone;
        mPhoneId = mDefaultPhone.getPhoneId();
        if (mDefaultPhone.getServiceStateTracker() != null) {
            mDefaultPhone.getServiceStateTracker()
                    .registerForDataRegStateOrRatChanged(this,
                    EVENT_DEFAULT_PHONE_DATA_STATE_CHANGED, null);
        }
        updateDataServiceState();

        // When the parent phone is updated, we need to notify listeners of the cached video
        // capability.
@@ -209,6 +227,10 @@ public class ImsPhone extends ImsPhoneBase {
        mCT.dispose();

        //Force all referenced classes to unregister their former registered events
        if (mDefaultPhone != null && mDefaultPhone.getServiceStateTracker() != null) {
            mDefaultPhone.getServiceStateTracker().
                    unregisterForDataRegStateOrRatChanged(this);
        }
    }

    @Override
@@ -228,6 +250,7 @@ public class ImsPhone extends ImsPhoneBase {

    /* package */ void setServiceState(int state) {
        mSS.setState(state);
        updateDataServiceState();
    }

    @Override
@@ -1113,6 +1136,16 @@ public class ImsPhone extends ImsPhoneBase {
        }
    }

    private void updateDataServiceState() {
        if (mSS != null && mDefaultPhone.getServiceStateTracker() != null
                && mDefaultPhone.getServiceStateTracker().mSS != null) {
            ServiceState ss = mDefaultPhone.getServiceStateTracker().mSS;
            mSS.setDataRegState(ss.getDataRegState());
            mSS.setRilDataRadioTechnology(ss.getRilDataRadioTechnology());
            Rlog.d(LOG_TAG, "updateDataServiceState: defSs = " + ss + " imsSs = " + mSS);
        }
    }

    @Override
    public void handleMessage (Message msg) {
        AsyncResult ar = (AsyncResult) msg.obj;
@@ -1155,6 +1188,11 @@ public class ImsPhone extends ImsPhoneBase {
                sendResponse((Message) ar.userObj, null, ar.exception);
                break;

             case EVENT_DEFAULT_PHONE_DATA_STATE_CHANGED:
                 if (DBG) Rlog.d(LOG_TAG, "EVENT_DEFAULT_PHONE_DATA_STATE_CHANGED");
                 updateDataServiceState();
                 break;

             default:
                 super.handleMessage(msg);
                 break;