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

Commit 7613f83f authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Merge "Dynamically allocate/de-allocate objects upon multi-SIM onfig changes."

am: 72ce02c1

Change-Id: I4ca21a3f7138d47ddcbf367f3629f3bc1000c16f
parents cdaea57d 72ce02c1
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
import android.os.ParcelUuid;
@@ -79,6 +80,7 @@ public class MultiSimSettingController extends Handler {
    private static final int EVENT_SUBSCRIPTION_GROUP_CHANGED        = 5;
    private static final int EVENT_DEFAULT_DATA_SUBSCRIPTION_CHANGED = 6;
    private static final int EVENT_CARRIER_CONFIG_CHANGED            = 7;
    private static final int EVENT_MULTI_SIM_CONFIG_CHANGED          = 8;

    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"PRIMARY_SUB_"},
@@ -188,6 +190,9 @@ public class MultiSimSettingController extends Handler {
        mCarrierConfigLoadedSubIds = new int[phoneCount];
        Arrays.fill(mCarrierConfigLoadedSubIds, SubscriptionManager.INVALID_SUBSCRIPTION_ID);

        PhoneConfigurationManager.registerForMultiSimConfigChange(
                this, EVENT_MULTI_SIM_CONFIG_CHANGED, null);

        context.registerReceiver(mIntentReceiver, new IntentFilter(
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
    }
@@ -268,6 +273,9 @@ public class MultiSimSettingController extends Handler {
                int subId = msg.arg2;
                onCarrierConfigChanged(phoneId, subId);
                break;
            case EVENT_MULTI_SIM_CONFIG_CHANGED:
                int activeModems = (int) ((AsyncResult) msg.obj).result;
                onMultiSimConfigChanged(activeModems);
        }
    }

@@ -358,6 +366,14 @@ public class MultiSimSettingController extends Handler {
        return true;
    }

    private void onMultiSimConfigChanged(int activeModems) {
        // Clear mCarrierConfigLoadedSubIds. Other actions will responds to active
        // subscription change.
        for (int phoneId = activeModems; phoneId < mCarrierConfigLoadedSubIds.length; phoneId++) {
            mCarrierConfigLoadedSubIds[phoneId] = INVALID_SUBSCRIPTION_ID;
        }
    }

    /**
     * Wait for subInfo initialization (after boot up) and carrier config load for all active
     * subscriptions before re-evaluate multi SIM settings.
+4 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.telephony.RadioAccessFamily;
import android.telephony.Rlog;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;

@@ -151,7 +152,7 @@ public class ProxyController {
    public void registerForAllDataDisconnected(int subId, Handler h, int what) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getSupportedModemCount()) {
        if (SubscriptionManager.isValidPhoneId(phoneId)) {
            mPhones[phoneId].registerForAllDataDisconnected(h, what);
        }
    }
@@ -159,7 +160,7 @@ public class ProxyController {
    public void unregisterForAllDataDisconnected(int subId, Handler h) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getSupportedModemCount()) {
        if (SubscriptionManager.isValidPhoneId(phoneId)) {
            mPhones[phoneId].unregisterForAllDataDisconnected(h);
        }
    }
@@ -168,7 +169,7 @@ public class ProxyController {
    public boolean areAllDataDisconnected(int subId) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getSupportedModemCount()) {
        if (SubscriptionManager.isValidPhoneId(phoneId)) {
            return mPhones[phoneId].areAllDataDisconnected();
        } else {
            // if we can't find a phone for the given subId, it is disconnected.
+4 −9
Original line number Diff line number Diff line
@@ -1332,17 +1332,12 @@ public class SubscriptionController extends ISub.Stub {
        if (DBG) logdl("[clearSubInfoRecord]+ iccId:" + " slotIndex:" + slotIndex);

        // update simInfo db with invalid slot index
        List<SubscriptionInfo> oldSubInfo = getSubInfoUsingSlotIndexPrivileged(slotIndex);
        ContentResolver resolver = mContext.getContentResolver();
        ContentValues value = new ContentValues(1);
        value.put(SubscriptionManager.SIM_SLOT_INDEX,
                SubscriptionManager.INVALID_SIM_SLOT_INDEX);
        if (oldSubInfo != null) {
            for (int i = 0; i < oldSubInfo.size(); i++) {
                resolver.update(SubscriptionManager.getUriForSubscriptionId(
                        oldSubInfo.get(i).getSubscriptionId()), value, null, null);
            }
        }
        value.put(SubscriptionManager.SIM_SLOT_INDEX, SubscriptionManager.INVALID_SIM_SLOT_INDEX);
        String where = "(" + SubscriptionManager.SIM_SLOT_INDEX + "=" + slotIndex + ")";
        resolver.update(SubscriptionManager.CONTENT_URI, value, where, null);

        // Refresh the Cache of Active Subscription Info List
        refreshCachedActiveSubscriptionInfoList();

+23 −5
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ import java.util.List;
public class SubscriptionInfoUpdater extends Handler {
    private static final String LOG_TAG = "SubscriptionInfoUpdater";
    @UnsupportedAppUsage
    private static final int PROJECT_SIM_NUM = TelephonyManager.getDefault()
    private static final int SUPPORTED_MODEM_COUNT = TelephonyManager.getDefault()
            .getSupportedModemCount();

    private static final boolean DBG = true;
@@ -92,6 +92,7 @@ public class SubscriptionInfoUpdater extends Handler {
    private static final int EVENT_SIM_READY = 10;
    private static final int EVENT_SIM_IMSI = 11;
    private static final int EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS = 12;
    private static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 13;

    private static final String ICCID_STRING_FOR_NO_SIM = "";

@@ -105,9 +106,9 @@ public class SubscriptionInfoUpdater extends Handler {
    private static Context sContext = null;
    @UnsupportedAppUsage

    private static String[] sIccId = new String[PROJECT_SIM_NUM];
    private static int[] sSimCardState = new int[PROJECT_SIM_NUM];
    private static int[] sSimApplicationState = new int[PROJECT_SIM_NUM];
    private static String[] sIccId = new String[SUPPORTED_MODEM_COUNT];
    private static int[] sSimCardState = new int[SUPPORTED_MODEM_COUNT];
    private static int[] sSimApplicationState = new int[SUPPORTED_MODEM_COUNT];
    private static boolean sIsSubInfoInitialized = false;
    private SubscriptionManager mSubscriptionManager = null;
    private EuiccManager mEuiccManager;
@@ -153,6 +154,9 @@ public class SubscriptionInfoUpdater extends Handler {

        mCarrierServiceBindHelper = new CarrierServiceBindHelper(sContext);
        initializeCarrierApps();

        PhoneConfigurationManager.registerForMultiSimConfigChange(
                this, EVENT_MULTI_SIM_CONFIG_CHANGED, null);
    }

    private void initializeCarrierApps() {
@@ -222,7 +226,7 @@ public class SubscriptionInfoUpdater extends Handler {

    @UnsupportedAppUsage
    private boolean isAllIccIdQueryDone() {
        for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
        for (int i = 0; i < TelephonyManager.getDefault().getActiveModemCount(); i++) {
            UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i);
            int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i);
            if  (sIccId[i] == null || slot == null || !slot.isActive()) {
@@ -334,11 +338,25 @@ public class SubscriptionInfoUpdater extends Handler {
                });
                break;

            case EVENT_MULTI_SIM_CONFIG_CHANGED:
                onMultiSimConfigChanged();
            default:
                logd("Unknown msg:" + msg.what);
        }
    }

    private void onMultiSimConfigChanged() {
        int activeModemCount = ((TelephonyManager) sContext.getSystemService(
                Context.TELEPHONY_SERVICE)).getActiveModemCount();
        // For inactive modems, reset its states.
        for (int phoneId = activeModemCount; phoneId < SUPPORTED_MODEM_COUNT; phoneId++) {
            SubscriptionController.getInstance().clearSubInfoRecord(phoneId);
            sIccId[phoneId] = null;
            sSimCardState[phoneId] = TelephonyManager.SIM_STATE_UNKNOWN;
            sSimApplicationState[phoneId] = TelephonyManager.SIM_STATE_UNKNOWN;
        }
    }

    private int getCardIdFromPhoneId(int phoneId) {
        UiccController uiccController = UiccController.getInstance();
        UiccCard card = uiccController.getUiccCardForPhone(phoneId);
+5 −0
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@ public interface AppInterface {
     */
    void onCmdResponse(CatResponseMessage resMsg);

    /**
     * Dispose when the service is not longer needed.
     */
    void dispose();

    /*
     * Enumeration for representing "Type of Command" of proactive commands.
     * Those are the only commands which are supported by the Telephony. Any app
Loading