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

Commit 859e8244 authored by Malcolm Chen's avatar Malcolm Chen
Browse files

Update ProxyController to be compatible with dynamic ss <-> ds switch

Bug: 142514392
Test: manual and unittest
Change-Id: I13ff9bb0f29c3a93090bd670f54d4693254d68a5
parent 4d7c0316
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class PhoneFactory {

                sPhoneSwitcher = PhoneSwitcher.make(maxActivePhones, sContext, Looper.myLooper());

                sProxyController = ProxyController.getInstance(context, sPhones, sPhoneSwitcher);
                sProxyController = ProxyController.getInstance(context);

                sIntentBroadcaster = IntentBroadcaster.getInstance(context);

+3 −6
Original line number Diff line number Diff line
@@ -42,14 +42,11 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
    private static final boolean DBG = true;
    private static final boolean VDBG = false; // STOPSHIP if true

    @UnsupportedAppUsage
    private final Phone[] mPhone;
    @UnsupportedAppUsage
    private final Context mContext;
    private final AppOpsManager mAppOps;

    public PhoneSubInfoController(Context context, Phone[] phone) {
        mPhone = phone;
    public PhoneSubInfoController(Context context) {
        if (ServiceManager.getService("iphonesubinfo") == null) {
            ServiceManager.addService("iphonesubinfo", this);
        }
@@ -221,7 +218,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
            phoneId = 0;
        }
        return mPhone[phoneId];
        return PhoneFactory.getPhone(phoneId);
    }

    /**
@@ -465,7 +462,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
            phoneId = 0;
        }
        final Phone phone = mPhone[phoneId];
        final Phone phone = PhoneFactory.getPhone(phoneId);
        if (phone == null) {
            return null;
        }
+43 −9
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony;

import static java.util.Arrays.copyOf;

import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
@@ -30,6 +32,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.ims.RcsMessageController;

import java.util.ArrayList;
@@ -45,6 +48,8 @@ public class ProxyController {
    private static final int EVENT_APPLY_RC_RESPONSE        = 3;
    private static final int EVENT_FINISH_RC_RESPONSE       = 4;
    private static final int EVENT_TIMEOUT                  = 5;
    @VisibleForTesting
    public static final int EVENT_MULTI_SIM_CONFIG_CHANGED  = 6;

    private static final int SET_RC_STATUS_IDLE             = 0;
    private static final int SET_RC_STATUS_STARTING         = 1;
@@ -105,9 +110,9 @@ public class ProxyController {


    //***** Class Methods
    public static ProxyController getInstance(Context context, Phone[] phone, PhoneSwitcher ps) {
    public static ProxyController getInstance(Context context) {
        if (sProxyController == null) {
            sProxyController = new ProxyController(context, phone, ps);
            sProxyController = new ProxyController(context);
        }
        return sProxyController;
    }
@@ -117,17 +122,17 @@ public class ProxyController {
        return sProxyController;
    }

    private ProxyController(Context context, Phone[] phone, PhoneSwitcher phoneSwitcher) {
    private ProxyController(Context context) {
        logd("Constructor - Enter");

        mContext = context;
        mPhones = phone;
        mPhoneSwitcher = phoneSwitcher;
        mPhones = PhoneFactory.getPhones();
        mPhoneSwitcher = PhoneSwitcher.getInstance();

        RcsMessageController.init(context);

        mUiccPhoneBookController = new UiccPhoneBookController(mPhones);
        mPhoneSubInfoController = new PhoneSubInfoController(mContext, mPhones);
        mUiccPhoneBookController = new UiccPhoneBookController();
        mPhoneSubInfoController = new PhoneSubInfoController(mContext);
        mSmsController = new SmsController(mContext);
        mSetRadioAccessFamilyStatus = new int[mPhones.length];
        mNewRadioAccessFamily = new int[mPhones.length];
@@ -146,6 +151,9 @@ public class ProxyController {
            mPhones[i].registerForRadioCapabilityChanged(
                    mHandler, EVENT_NOTIFICATION_RC_CHANGED, null);
        }

        PhoneConfigurationManager.registerForMultiSimConfigChange(
                mHandler, EVENT_MULTI_SIM_CONFIG_CHANGED, null);
        logd("Constructor - Exit");
    }

@@ -291,7 +299,8 @@ public class ProxyController {
        return true;
    }

    private Handler mHandler = new Handler() {
    @VisibleForTesting
    public final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            logd("handleMessage msg.what=" + msg.what);
@@ -316,12 +325,37 @@ public class ProxyController {
                    onTimeoutRadioCapability(msg);
                    break;

                case EVENT_MULTI_SIM_CONFIG_CHANGED:
                    onMultiSimConfigChanged();
                    break;

                default:
                    break;
            }
        }
    };

    private void onMultiSimConfigChanged() {
        int oldPhoneCount = mPhones.length;
        mPhones = PhoneFactory.getPhones();

        // Re-size arrays.
        mSetRadioAccessFamilyStatus = copyOf(mSetRadioAccessFamilyStatus, mPhones.length);
        mNewRadioAccessFamily = copyOf(mNewRadioAccessFamily, mPhones.length);
        mOldRadioAccessFamily = copyOf(mOldRadioAccessFamily, mPhones.length);
        mCurrentLogicalModemIds = copyOf(mCurrentLogicalModemIds, mPhones.length);
        mNewLogicalModemIds = copyOf(mNewLogicalModemIds, mPhones.length);

        // Clear to be sure we're in the initial state
        clearTransaction();

        // Register radio cap change for new phones.
        for (int i = oldPhoneCount; i < mPhones.length; i++) {
            mPhones[i].registerForRadioCapabilityChanged(
                    mHandler, EVENT_NOTIFICATION_RC_CHANGED, null);
        }
    }

    /**
     * Handle START response
     * @param msg obj field isa RadioCapability
+2 −7
Original line number Diff line number Diff line
@@ -25,22 +25,17 @@ import android.telephony.Rlog;
import com.android.internal.telephony.IIccPhoneBook;
import com.android.internal.telephony.uicc.AdnRecord;

import java.lang.ArrayIndexOutOfBoundsException;
import java.lang.NullPointerException;
import java.util.List;

public class UiccPhoneBookController extends IIccPhoneBook.Stub {
    private static final String TAG = "UiccPhoneBookController";
    @UnsupportedAppUsage
    private Phone[] mPhone;

    /* only one UiccPhoneBookController exists */
    @UnsupportedAppUsage
    public UiccPhoneBookController(Phone[] phone) {
    public UiccPhoneBookController() {
        if (ServiceManager.getService("simphonebook") == null) {
               ServiceManager.addService("simphonebook", this);
        }
        mPhone = phone;
    }

    @Override
@@ -139,7 +134,7 @@ public class UiccPhoneBookController extends IIccPhoneBook.Stub {

        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);
        try {
            return mPhone[phoneId].getIccPhoneBookInterfaceManager();
            return PhoneFactory.getPhone(phoneId).getIccPhoneBookInterfaceManager();
        } catch (NullPointerException e) {
            Rlog.e(TAG, "Exception is :"+e.toString()+" For subscription :"+subId );
            e.printStackTrace(); //To print stack trace
+2 −2
Original line number Diff line number Diff line
@@ -66,8 +66,8 @@ public class PhoneSubInfoControllerTest extends TelephonyTest {

        mAppOsMgr = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);

        mPhoneSubInfoControllerUT = new PhoneSubInfoController(mContext,
                new Phone[]{mPhone, mSecondPhone});
        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[]{mPhone, mSecondPhone});
        mPhoneSubInfoControllerUT = new PhoneSubInfoController(mContext);

        setupMocksForTelephonyPermissions();
        // TelephonyPermissions will query the READ_DEVICE_IDENTIFIERS op from AppOpManager to
Loading