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

Commit 4a1e5ba5 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5674462 from d6bdf0be to qt-release

Change-Id: I612d0f49f8cd8a148d728f97708895ee1624f755
parents c92306b7 d6bdf0be
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -125,8 +125,22 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
    }

    public String getSubscriberIdForSubscriber(int subId, String callingPackage) {
        String message = "getSubscriberId";
        if (SubscriptionController.getInstance().isActiveSubId(subId, callingPackage)) {
            return callPhoneMethodForSubIdWithReadSubscriberIdentifiersCheck(subId, callingPackage,
                "getSubscriberId", (phone) -> phone.getSubscriberId());
                    message, (phone) -> phone.getSubscriberId());
        } else {
            if (!TelephonyPermissions.checkCallingOrSelfReadSubscriberIdentifiers(
                    mContext, subId, callingPackage, message)) {
                return null;
            }
            final long identity = Binder.clearCallingIdentity();
            try {
                return SubscriptionController.getInstance().getImsiPrivileged(subId);
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }
    }

    /**
+50 −1
Original line number Diff line number Diff line
@@ -1822,6 +1822,56 @@ public class SubscriptionController extends ISub.Stub {
        return result;
    }

    /**
     * Set IMSI by subscription ID
     * @param imsi IMSI (International Mobile Subscriber Identity)
     * @return the number of records updated
     */
    public int setImsi(String imsi, int subId) {
        if (DBG) logd("[setImsi]+ imsi:" + imsi + " subId:" + subId);
        ContentValues value = new ContentValues(1);
        value.put(SubscriptionManager.IMSI, imsi);

        int result = mContext.getContentResolver().update(
                SubscriptionManager.getUriForSubscriptionId(subId), value, null, null);

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

        notifySubscriptionInfoChanged();

        return result;
    }

    /**
     * Get IMSI by subscription ID
     * For active subIds, this will always return the corresponding imsi
     * For inactive subIds, once they are activated once, even if they are deactivated at the time
     *   of calling this function, the corresponding imsi will be returned
     * When calling this method, the permission check should have already been done to allow
     *   only privileged read
     *
     * @return imsi
     */
    public String getImsiPrivileged(int subId) {
        try (Cursor cursor = mContext.getContentResolver().query(
                SubscriptionManager.CONTENT_URI, null,
                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?",
                new String[] {String.valueOf(subId)}, null)) {
            String imsi = null;
            if (cursor != null) {
                if (cursor.moveToNext()) {
                    imsi = getOptionalStringFromCursor(cursor, SubscriptionManager.IMSI,
                            /*defaultVal*/ null);
                }
            } else {
                logd("getImsiPrivileged: failed to retrieve imsi.");
            }

            return imsi;
        }
    }

    /**
     * Set ISO country code by subscription ID
     * @param iso iso country code associated with the subscription
@@ -2917,7 +2967,6 @@ public class SubscriptionController extends ISub.Stub {
    }

    /**
     *
     * @param groupUuid a UUID assigned to the subscription group.
     * @param callingPackage the package making the IPC.
     * @return if callingPackage has carrier privilege on sublist.
+7 −1
Original line number Diff line number Diff line
@@ -453,7 +453,8 @@ public class SubscriptionInfoUpdater extends Handler {
        } else {
            for (SubscriptionInfo sub : subscriptionInfos) {
                int subId = sub.getSubscriptionId();
                TelephonyManager tm = TelephonyManager.getDefault();
                TelephonyManager tm = (TelephonyManager)
                        mContext.getSystemService(Context.TELEPHONY_SERVICE);
                String operator = tm.getSimOperatorNumeric(subId);

                if (!TextUtils.isEmpty(operator)) {
@@ -478,6 +479,11 @@ public class SubscriptionInfoUpdater extends Handler {
                    SubscriptionController.getInstance().setDisplayNumber(msisdn, subId);
                }

                String imsi = tm.createForSubscriptionId(subId).getSubscriberId();
                if (imsi != null) {
                    SubscriptionController.getInstance().setImsi(imsi, subId);
                }

                String[] ehplmns = records.getEhplmns();
                String[] hplmns = records.getPlmnsFromHplmnActRecord();
                if (ehplmns != null || hplmns != null) {
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + SubscriptionManager.WHITE_LISTED_APN_DATA + " INTEGER DEFAULT 0,"
                    + SubscriptionManager.GROUP_OWNER + " TEXT,"
                    + SubscriptionManager.DATA_ENABLED_OVERRIDE_RULES + " TEXT"
                    + SubscriptionManager.IMSI + " TEXT"
                    + ");";
        }

+9 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ public class PhoneSubInfoControllerTest extends TelephonyTest {
        doReturn(0).when(mSubscriptionController).getPhoneId(eq(0));
        doReturn(1).when(mSubscriptionController).getPhoneId(eq(1));
        doReturn(2).when(mTelephonyManager).getPhoneCount();
        doReturn(true).when(mSubscriptionController).isActiveSubId(0, TAG);
        doReturn(true).when(mSubscriptionController).isActiveSubId(1, TAG);

        mServiceManagerMockedServices.put("isub", mSubscriptionController);
        doReturn(mSubscriptionController).when(mSubscriptionController)
@@ -346,6 +348,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest {
                .getSubscriberIdForSubscriber(1, TAG));
    }

    @Test
    @SmallTest
    public void testGetSubscriberIdWithInactiveSubId() {
        //IMSI
        assertNull(mPhoneSubInfoControllerUT.getSubscriberIdForSubscriber(2, TAG));
    }

    @Test
    @SmallTest
    public void testGetSubscriberIdWithOutPermission() {