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

Commit b900f1c0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "unused" am: 42a600e8

parents 97d54377 42a600e8
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
@@ -506,7 +506,11 @@ public class GsmCdmaPhone extends Phone {
                logd("update icc_operator_numeric=" + operatorNumeric);
                logd("update icc_operator_numeric=" + operatorNumeric);
                tm.setSimOperatorNumericForPhone(mPhoneId, operatorNumeric);
                tm.setSimOperatorNumericForPhone(mPhoneId, operatorNumeric);


                if (isSubscriptionManagerServiceEnabled()) {
                    mSubscriptionManagerService.setMccMnc(getSubId(), operatorNumeric);
                } else {
                    SubscriptionController.getInstance().setMccMnc(operatorNumeric, getSubId());
                    SubscriptionController.getInstance().setMccMnc(operatorNumeric, getSubId());
                }


                // Sets iso country property by retrieving from build-time system property
                // Sets iso country property by retrieving from build-time system property
                String iso = "";
                String iso = "";
@@ -518,7 +522,11 @@ public class GsmCdmaPhone extends Phone {


                logd("init: set 'gsm.sim.operator.iso-country' to iso=" + iso);
                logd("init: set 'gsm.sim.operator.iso-country' to iso=" + iso);
                tm.setSimCountryIsoForPhone(mPhoneId, iso);
                tm.setSimCountryIsoForPhone(mPhoneId, iso);
                if (isSubscriptionManagerServiceEnabled()) {
                    mSubscriptionManagerService.setCountryIso(getSubId(), iso);
                } else {
                    SubscriptionController.getInstance().setCountryIso(iso, getSubId());
                    SubscriptionController.getInstance().setCountryIso(iso, getSubId());
                }


                // Updates MCC MNC device configuration information
                // Updates MCC MNC device configuration information
                logd("update mccmnc=" + operatorNumeric);
                logd("update mccmnc=" + operatorNumeric);
@@ -918,14 +926,6 @@ 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()) {
+22 −16
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.Binder;
import android.os.Handler;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.HandlerThread;
@@ -316,6 +315,27 @@ public class SubscriptionManagerService extends ISub.Stub {
        mSubscriptionDatabaseManager.setCarrierId(subId, carrierId);
        mSubscriptionDatabaseManager.setCarrierId(subId, carrierId);
    }
    }


    /**
     * Set MCC/MNC by subscription id.
     *
     * @param mccMnc MCC/MNC associated with the subscription.
     * @param subId The subscription id.
     */
    public void setMccMnc(int subId, @NonNull String mccMnc) {
        mSubscriptionDatabaseManager.setMcc(subId, mccMnc.substring(0, 3));
        mSubscriptionDatabaseManager.setMnc(subId, mccMnc.substring(3));
    }

    /**
     * Set ISO country code by subscription id.
     *
     * @param iso ISO country code associated with the subscription.
     * @param subId The subscription id.
     */
    public void setCountryIso(int subId, @NonNull String iso) {
        mSubscriptionDatabaseManager.setCountryIso(subId, iso);
    }

    /**
    /**
     * @param callingPackage The package making the call.
     * @param callingPackage The package making the call.
     * @param callingFeatureId The feature in the package
     * @param callingFeatureId The feature in the package
@@ -478,20 +498,6 @@ public class SubscriptionManagerService extends ISub.Stub {
                return -1;
                return -1;
            }
            }


            if (subscriptionType != SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM
                    || !mContext.getPackageManager().hasSystemFeature(
                            PackageManager.FEATURE_AUTOMOTIVE)) {
                loge("addSubInfo: remote SIM is only supported when FEATURE_AUTOMOTIVE is "
                        + "enabled.");
                return -1;
            }

            if (slotIndex != SubscriptionManager.SLOT_INDEX_FOR_REMOTE_SIM_SUB) {
                loge("addSubInfo: This API can only be used for remote SIM. slotIndex="
                        + slotIndex);
                return -1;
            }

            iccId = IccUtils.stripTrailingFs(iccId);
            iccId = IccUtils.stripTrailingFs(iccId);
            SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager
            SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager
                    .getSubscriptionInfoInternalByIccId(iccId);
                    .getSubscriptionInfoInternalByIccId(iccId);
@@ -504,7 +510,7 @@ public class SubscriptionManagerService extends ISub.Stub {
                                .setIccId(iccId)
                                .setIccId(iccId)
                                .setSimSlotIndex(slotIndex)
                                .setSimSlotIndex(slotIndex)
                                .setDisplayName(displayName)
                                .setDisplayName(displayName)
                                .setType(SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM)
                                .setType(subscriptionType)
                                .build()
                                .build()
                );
                );
            } else {
            } else {
+63 −10
Original line number Original line Diff line number Diff line
@@ -17,18 +17,21 @@
package com.android.internal.telephony.subscription;
package com.android.internal.telephony.subscription;


import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;
import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_CARRIER_ID2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_CARRIER_NAME1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_CARRIER_NAME1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_COUNTRY_CODE2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_ICCID1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_ICCID1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_MCC2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_MNC2;


import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;


import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;


import android.content.pm.PackageManager;
import android.os.Looper;
import android.os.Looper;
import android.provider.Telephony;
import android.provider.Telephony;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
@@ -88,12 +91,8 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {


    @Test
    @Test
    public void testAddSubInfo() {
    public void testAddSubInfo() {
        doReturn(true).when(mPackageManager).hasSystemFeature(
                PackageManager.FEATURE_AUTOMOTIVE);

        mSubscriptionManagerServiceUT.addSubInfo(FAKE_ICCID1, FAKE_CARRIER_NAME1,
        mSubscriptionManagerServiceUT.addSubInfo(FAKE_ICCID1, FAKE_CARRIER_NAME1,
                SubscriptionManager.SLOT_INDEX_FOR_REMOTE_SIM_SUB,
                0, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
                SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM);
        processAllMessages();
        processAllMessages();


        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
@@ -102,9 +101,63 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                .getSubscriptionInfoInternal(1);
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo.getIccId()).isEqualTo(FAKE_ICCID1);
        assertThat(subInfo.getIccId()).isEqualTo(FAKE_ICCID1);
        assertThat(subInfo.getDisplayName()).isEqualTo(FAKE_CARRIER_NAME1);
        assertThat(subInfo.getDisplayName()).isEqualTo(FAKE_CARRIER_NAME1);
        assertThat(subInfo.getSimSlotIndex()).isEqualTo(
        assertThat(subInfo.getSimSlotIndex()).isEqualTo(0);
                SubscriptionManager.SLOT_INDEX_FOR_REMOTE_SIM_SUB);
        assertThat(subInfo.getSubscriptionType()).isEqualTo(
        assertThat(subInfo.getSubscriptionType()).isEqualTo(
                SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM);
                SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
    }

    @Test
    public void testSetMccMnc() {
        mSubscriptionManagerServiceUT.addSubInfo(FAKE_ICCID1, FAKE_CARRIER_NAME1,
                0, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
        processAllMessages();

        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
        Mockito.clearInvocations(mMockedSubscriptionManagerServiceCallback);
        mSubscriptionManagerServiceUT.setMccMnc(1, FAKE_MCC2 + FAKE_MNC2);
        processAllMessages();

        SubscriptionInfoInternal subInfo = mSubscriptionManagerServiceUT
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo).isNotNull();
        assertThat(subInfo.getMcc()).isEqualTo(FAKE_MCC2);
        assertThat(subInfo.getMnc()).isEqualTo(FAKE_MNC2);
        verify(mMockedSubscriptionManagerServiceCallback, times(2)).onSubscriptionChanged(eq(1));
    }

    @Test
    public void testSetCountryIso() {
        mSubscriptionManagerServiceUT.addSubInfo(FAKE_ICCID1, FAKE_CARRIER_NAME1,
                0, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
        processAllMessages();

        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
        Mockito.clearInvocations(mMockedSubscriptionManagerServiceCallback);
        mSubscriptionManagerServiceUT.setCountryIso(1, FAKE_COUNTRY_CODE2);
        processAllMessages();

        SubscriptionInfoInternal subInfo = mSubscriptionManagerServiceUT
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo).isNotNull();
        assertThat(subInfo.getCountryIso()).isEqualTo(FAKE_COUNTRY_CODE2);
        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
    }

    @Test
    public void testSetCarrierId() {
        mSubscriptionManagerServiceUT.addSubInfo(FAKE_ICCID1, FAKE_CARRIER_NAME1,
                0, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
        processAllMessages();

        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
        Mockito.clearInvocations(mMockedSubscriptionManagerServiceCallback);
        mSubscriptionManagerServiceUT.setCarrierId(1, FAKE_CARRIER_ID2);
        processAllMessages();

        SubscriptionInfoInternal subInfo = mSubscriptionManagerServiceUT
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo).isNotNull();
        assertThat(subInfo.getCarrierId()).isEqualTo(FAKE_CARRIER_ID2);
        verify(mMockedSubscriptionManagerServiceCallback).onSubscriptionChanged(eq(1));
    }
    }
}
}