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

Commit 772b78a2 authored by Nazanin Bakhshi's avatar Nazanin Bakhshi Committed by android-build-merger
Browse files

Merge "Revert "Store subscriber ID / IMSI into telephony database"" into qt-dev

am: 05c740ec

Change-Id: I708041e0ebcbaf8ca50295da35be877ebd7e6945
parents 28eccc3a 05c740ec
Loading
Loading
Loading
Loading
+2 −17
Original line number Diff line number Diff line
@@ -125,23 +125,8 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
    }

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

    /**
+1 −47
Original line number Diff line number Diff line
@@ -1823,53 +1823,6 @@ 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
     * @return imsi
     */
    public String getImsi(int subId) {
        Cursor cursor = mContext.getContentResolver().query(
                SubscriptionManager.getUriForSubscriptionId(subId), null,
                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?",
                new String[]{String.valueOf(subId)}, null);

        String imsi = null;
        try {
            if (cursor != null) {
                if (cursor.moveToNext()) {
                    imsi = getOptionalStringFromCursor(cursor, SubscriptionManager.IMSI,
                            /*defaultVal*/ null);
                }
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
        return imsi;
    }

    /**
     * Set ISO country code by subscription ID
     * @param iso iso country code associated with the subscription
@@ -2955,6 +2908,7 @@ 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.
+1 −7
Original line number Diff line number Diff line
@@ -452,8 +452,7 @@ public class SubscriptionInfoUpdater extends Handler {
        } else {
            for (SubscriptionInfo sub : subscriptionInfos) {
                int subId = sub.getSubscriptionId();
                TelephonyManager tm = (TelephonyManager)
                        mContext.getSystemService(Context.TELEPHONY_SERVICE);
                TelephonyManager tm = TelephonyManager.getDefault();
                String operator = tm.getSimOperatorNumeric(subId);

                if (!TextUtils.isEmpty(operator)) {
@@ -478,11 +477,6 @@ 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 −2
Original line number Diff line number Diff line
@@ -108,8 +108,7 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + " INTEGER DEFAULT " + SubscriptionManager.PROFILE_CLASS_DEFAULT + ","
                    + SubscriptionManager.SUBSCRIPTION_TYPE + " INTEGER DEFAULT 0,"
                    + SubscriptionManager.WHITE_LISTED_APN_DATA + " INTEGER DEFAULT 0,"
                    + SubscriptionManager.GROUP_OWNER + " TEXT,"
                    + SubscriptionManager.IMSI + " TEXT"
                    + SubscriptionManager.GROUP_OWNER + " TEXT"
                    + ");";
        }

+0 −7
Original line number Diff line number Diff line
@@ -346,13 +346,6 @@ public class PhoneSubInfoControllerTest extends TelephonyTest {
                .getSubscriberIdForSubscriber(1, TAG));
    }

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

    @Test
    @SmallTest
    public void testGetSubscriberIdWithOutPermission() {