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

Commit 44c8a8a1 authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Android (Google) Code Review
Browse files

Merge "Make sure to enable uicc applications when SIM is inserted." into rvc-dev

parents 1b9cd84d ee913ed7
Loading
Loading
Loading
Loading
+17 −3
Original line number Original line Diff line number Diff line
@@ -297,6 +297,9 @@ public class GsmCdmaPhone extends Phone {
                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED),
                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED),
                EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE);
                EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE);


        SubscriptionController.getInstance().registerForUiccAppsEnabled(this,
                EVENT_UICC_APPS_ENABLEMENT_SETTING_CHANGED, null, false);

        loadTtyMode();
        loadTtyMode();
        logd("GsmCdmaPhone: constructor: sub = " + mPhoneId);
        logd("GsmCdmaPhone: constructor: sub = " + mPhoneId);
    }
    }
@@ -344,7 +347,8 @@ public class GsmCdmaPhone extends Phone {
        mCi.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
        mCi.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
        mCi.registerForOn(this, EVENT_RADIO_ON, null);
        mCi.registerForOn(this, EVENT_RADIO_ON, null);
        mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
        mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
        mCi.registerUiccApplicationEnablementChanged(this, EVENT_UICC_APPS_ENABLEMENT_CHANGED,
        mCi.registerUiccApplicationEnablementChanged(this,
                EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED,
                null);
                null);
        mCi.setOnSuppServiceNotification(this, EVENT_SSN, null);
        mCi.setOnSuppServiceNotification(this, EVENT_SSN, null);
        mCi.setOnRegistrationFailed(this, EVENT_REGISTRATION_FAILED, null);
        mCi.setOnRegistrationFailed(this, EVENT_REGISTRATION_FAILED, null);
@@ -943,6 +947,14 @@ public class GsmCdmaPhone extends Phone {
        }
        }
    }
    }


    @Override
    public void dispose() {
        // Note: this API is currently never called. We are defining actions here in case
        // we need to dispose GsmCdmaPhone/Phone object.
        super.dispose();
        SubscriptionController.getInstance().unregisterForUiccAppsEnabled(this);
    }

    @Override
    @Override
    public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) {
    public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) {
        if (isPhoneTypeGsm()) {
        if (isPhoneTypeGsm()) {
@@ -3039,7 +3051,7 @@ public class GsmCdmaPhone extends Phone {
                }
                }
                break;
                break;
            case EVENT_GET_UICC_APPS_ENABLEMENT_DONE:
            case EVENT_GET_UICC_APPS_ENABLEMENT_DONE:
            case EVENT_UICC_APPS_ENABLEMENT_CHANGED: {
            case EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED:
                ar = (AsyncResult) msg.obj;
                ar = (AsyncResult) msg.obj;
                if (ar == null) return;
                if (ar == null) return;
                if (ar.exception != null) {
                if (ar.exception != null) {
@@ -3048,9 +3060,11 @@ public class GsmCdmaPhone extends Phone {
                }
                }


                mUiccApplicationsEnabled = (Boolean) ar.result;
                mUiccApplicationsEnabled = (Boolean) ar.result;
            // Intentional falling through.
            case EVENT_UICC_APPS_ENABLEMENT_SETTING_CHANGED:
                reapplyUiccAppsEnablementIfNeeded();
                reapplyUiccAppsEnablementIfNeeded();
                break;
                break;
            }

            case EVENT_REAPPLY_UICC_APPS_ENABLEMENT_DONE: {
            case EVENT_REAPPLY_UICC_APPS_ENABLEMENT_DONE: {
                ar = (AsyncResult) msg.obj;
                ar = (AsyncResult) msg.obj;
                if (ar == null || ar.exception == null) return;
                if (ar == null || ar.exception == null) return;
+7 −6
Original line number Original line Diff line number Diff line
@@ -205,11 +205,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_GET_AVAILABLE_NETWORKS_DONE    = 51;
    protected static final int EVENT_GET_AVAILABLE_NETWORKS_DONE    = 51;


    private static final int EVENT_ALL_DATA_DISCONNECTED                  = 52;
    private static final int EVENT_ALL_DATA_DISCONNECTED                  = 52;
    protected static final int EVENT_UICC_APPS_ENABLEMENT_CHANGED   = 53;
    protected static final int EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED  = 53;
    protected static final int EVENT_GET_UICC_APPS_ENABLEMENT_DONE  = 54;
    protected static final int EVENT_UICC_APPS_ENABLEMENT_SETTING_CHANGED = 54;
    protected static final int EVENT_REAPPLY_UICC_APPS_ENABLEMENT_DONE = 55;
    protected static final int EVENT_GET_UICC_APPS_ENABLEMENT_DONE        = 55;
    protected static final int EVENT_REGISTRATION_FAILED = 56;
    protected static final int EVENT_REAPPLY_UICC_APPS_ENABLEMENT_DONE    = 56;
    protected static final int EVENT_BARRING_INFO_CHANGED = 57;
    protected static final int EVENT_REGISTRATION_FAILED = 57;
    protected static final int EVENT_BARRING_INFO_CHANGED = 58;


    protected static final int EVENT_LAST = EVENT_BARRING_INFO_CHANGED;
    protected static final int EVENT_LAST = EVENT_BARRING_INFO_CHANGED;


+27 −5
Original line number Original line Diff line number Diff line
@@ -35,7 +35,9 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.net.Uri;
import android.os.Binder;
import android.os.Binder;
import android.os.Handler;
import android.os.ParcelUuid;
import android.os.ParcelUuid;
import android.os.RegistrantList;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.TelephonyServiceManager.ServiceRegisterer;
import android.os.TelephonyServiceManager.ServiceRegisterer;
import android.os.UserHandle;
import android.os.UserHandle;
@@ -263,6 +265,7 @@ public class SubscriptionController extends ISub.Stub {
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private int[] colorArr;
    private int[] colorArr;
    private long mLastISubServiceRegTime;
    private long mLastISubServiceRegTime;
    private RegistrantList mUiccAppsEnableChangeRegList = new RegistrantList();


    // The properties that should be shared and synced across grouped subscriptions.
    // The properties that should be shared and synced across grouped subscriptions.
    private static final Set<String> GROUP_SHARING_PROPERTIES = new HashSet<>(Arrays.asList(
    private static final Set<String> GROUP_SHARING_PROPERTIES = new HashSet<>(Arrays.asList(
@@ -2120,19 +2123,38 @@ public class SubscriptionController extends ISub.Stub {
            // Refresh the Cache of Active Subscription Info List
            // Refresh the Cache of Active Subscription Info List
            refreshCachedActiveSubscriptionInfoList();
            refreshCachedActiveSubscriptionInfoList();


            notifyUiccAppsEnableChanged();
            notifySubscriptionInfoChanged();
            notifySubscriptionInfoChanged();


            if (isActiveSubId(subId)) {
                Phone phone = PhoneFactory.getPhone(getPhoneId(subId));
                phone.enableUiccApplications(enabled, null);
            }

            return result;
            return result;
        } finally {
        } finally {
            Binder.restoreCallingIdentity(identity);
            Binder.restoreCallingIdentity(identity);
        }
        }
    }
    }


    /**
     * Register to change of uicc applications enablement changes.
     * @param notifyNow whether to notify target upon registration.
     */
    public void registerForUiccAppsEnabled(Handler handler, int what, Object object,
            boolean notifyNow) {
        mUiccAppsEnableChangeRegList.addUnique(handler, what, object);
        if (notifyNow) {
            handler.obtainMessage(what, object).sendToTarget();
        }
    }

    /**
     * Unregister to change of uicc applications enablement changes.
     */
    public void unregisterForUiccAppsEnabled(Handler handler) {
        mUiccAppsEnableChangeRegList.remove(handler);
    }

    private void notifyUiccAppsEnableChanged() {
        mUiccAppsEnableChangeRegList.notifyRegistrants();
    }

    /**
    /**
     * Get IMSI by subscription ID
     * Get IMSI by subscription ID
     * For active subIds, this will always return the corresponding imsi
     * For active subIds, this will always return the corresponding imsi
+3 −3
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ import static com.android.internal.telephony.CommandsInterface.CF_ACTION_ENABLE;
import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDITIONAL;
import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDITIONAL;
import static com.android.internal.telephony.Phone.EVENT_ICC_CHANGED;
import static com.android.internal.telephony.Phone.EVENT_ICC_CHANGED;
import static com.android.internal.telephony.Phone.EVENT_SRVCC_STATE_CHANGED;
import static com.android.internal.telephony.Phone.EVENT_SRVCC_STATE_CHANGED;
import static com.android.internal.telephony.Phone.EVENT_UICC_APPS_ENABLEMENT_CHANGED;
import static com.android.internal.telephony.Phone.EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED;
import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;
import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
@@ -1212,7 +1212,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        processAllMessages();
        processAllMessages();
        doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccSlot).getCardState();
        doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccSlot).getCardState();
        Message.obtain(mPhoneUT, EVENT_ICC_CHANGED, null).sendToTarget();
        Message.obtain(mPhoneUT, EVENT_ICC_CHANGED, null).sendToTarget();
        Message.obtain(mPhoneUT, EVENT_UICC_APPS_ENABLEMENT_CHANGED,
        Message.obtain(mPhoneUT, EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED,
                new AsyncResult(null, true, null)).sendToTarget();
                new AsyncResult(null, true, null)).sendToTarget();
        processAllMessages();
        processAllMessages();
        verify(mSubscriptionController, never()).getSubInfoForIccId(any());
        verify(mSubscriptionController, never()).getSubInfoForIccId(any());
@@ -1236,7 +1236,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccSlot).getCardState();
        doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccSlot).getCardState();
        String iccId = "Fake iccId";
        String iccId = "Fake iccId";
        doReturn(iccId).when(mUiccSlot).getIccId();
        doReturn(iccId).when(mUiccSlot).getIccId();
        Message.obtain(mPhoneUT, EVENT_UICC_APPS_ENABLEMENT_CHANGED,
        Message.obtain(mPhoneUT, EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED,
                new AsyncResult(null, false, null)).sendToTarget();
                new AsyncResult(null, false, null)).sendToTarget();
        processAllMessages();
        processAllMessages();