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

Commit 5cf049b5 authored by Chen Xu's avatar Chen Xu Committed by android-build-merger
Browse files

Merge "add carrier id in subscriptionInfo"

am: 9d717e45

Change-Id: Id9f3f5ec590ccde4d1dac10cd45a35348a874ef8
parents 4f1938af 9d717e45
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -384,6 +384,7 @@ public class CarrierResolver extends Handler {
            cv.put(CarrierId.CARRIER_NAME, mCarrierName);
            cv.put(CarrierId.CARRIER_NAME, mCarrierName);
            mContext.getContentResolver().update(
            mContext.getContentResolver().update(
                    Telephony.CarrierId.getUriForSubscriptionId(mPhone.getSubId()), cv, null, null);
                    Telephony.CarrierId.getUriForSubscriptionId(mPhone.getSubId()), cv, null, null);
            SubscriptionController.getInstance().setCarrierId(mCarrierId, mPhone.getSubId());
        }
        }


        update = false;
        update = false;
+40 −4
Original line number Original line Diff line number Diff line
@@ -309,6 +309,8 @@ public class SubscriptionController extends ISub.Stub {
                SubscriptionManager.ISO_COUNTRY_CODE));
                SubscriptionManager.ISO_COUNTRY_CODE));
        boolean isEmbedded = cursor.getInt(cursor.getColumnIndexOrThrow(
        boolean isEmbedded = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.IS_EMBEDDED)) == 1;
                SubscriptionManager.IS_EMBEDDED)) == 1;
        int carrierId = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.CARRIER_ID));
        UiccAccessRule[] accessRules;
        UiccAccessRule[] accessRules;
        if (isEmbedded) {
        if (isEmbedded) {
            accessRules = UiccAccessRule.decodeRules(cursor.getBlob(
            accessRules = UiccAccessRule.decodeRules(cursor.getBlob(
@@ -327,9 +329,10 @@ public class SubscriptionController extends ISub.Stub {
            String iccIdToPrint = SubscriptionInfo.givePrintableIccid(iccId);
            String iccIdToPrint = SubscriptionInfo.givePrintableIccid(iccId);
            String cardIdToPrint = SubscriptionInfo.givePrintableIccid(cardId);
            String cardIdToPrint = SubscriptionInfo.givePrintableIccid(cardId);
            logd("[getSubInfoRecord] id:" + id + " iccid:" + iccIdToPrint + " simSlotIndex:"
            logd("[getSubInfoRecord] id:" + id + " iccid:" + iccIdToPrint + " simSlotIndex:"
                    + simSlotIndex + " displayName:" + displayName + " nameSource:" + nameSource
                    + simSlotIndex + " carrierid:" + carrierId + " displayName:" + displayName
                    + " iconTint:" + iconTint + " dataRoaming:" + dataRoaming
                    + " nameSource:" + nameSource + " iconTint:" + iconTint
                    + " mcc:" + mcc + " mnc:" + mnc + " countIso:" + countryIso + " isEmbedded:"
                    + " dataRoaming:" + dataRoaming + " mcc:" + mcc + " mnc:" + mnc
                    + " countIso:" + countryIso + " isEmbedded:"
                    + isEmbedded + " accessRules:" + Arrays.toString(accessRules)
                    + isEmbedded + " accessRules:" + Arrays.toString(accessRules)
                    + " cardId:" + cardIdToPrint + " isOpportunistic:" + isOpportunistic
                    + " cardId:" + cardIdToPrint + " isOpportunistic:" + isOpportunistic
                    + " groupUUID:" + groupUUID + " isMetered:" + isMetered);
                    + " groupUUID:" + groupUUID + " isMetered:" + isMetered);
@@ -342,7 +345,7 @@ public class SubscriptionController extends ISub.Stub {
        }
        }
        return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
        return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
                nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
                nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
                isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered);
                isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered, carrierId);
    }
    }


    /**
    /**
@@ -1341,6 +1344,39 @@ public class SubscriptionController extends ISub.Stub {
        }
        }
    }
    }


    /**
     * Set carrier id by subId
     * @param carrierId the subscription carrier id.
     * @param subId the unique SubInfoRecord index in database
     * @return the number of records updated
     *
     * @see TelephonyManager#getSimCarrierId()
     */
    public int setCarrierId(int carrierId, int subId) {
        if (DBG) logd("[setCarrierId]+ carrierId:" + carrierId + " subId:" + subId);

        enforceModifyPhoneState("setCarrierId");

        // Now that all security checks passes, perform the operation as ourselves.
        final long identity = Binder.clearCallingIdentity();
        try {
            validateSubId(subId);
            ContentValues value = new ContentValues(1);
            value.put(SubscriptionManager.CARRIER_ID, carrierId);
            int result = mContext.getContentResolver().update(
                    SubscriptionManager.getUriForSubscriptionId(subId), value, null, null);

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

            notifySubscriptionInfoChanged();

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

    /**
    /**
     * Set MCC/MNC by subscription ID
     * Set MCC/MNC by subscription ID
     * @param mccMnc MCC/MNC associated with the subscription
     * @param mccMnc MCC/MNC associated with the subscription
+2 −1
Original line number Original line Diff line number Diff line
@@ -99,7 +99,8 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + SubscriptionManager.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0,"
                    + SubscriptionManager.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0,"
                    + SubscriptionManager.GROUP_UUID + " TEXT,"
                    + SubscriptionManager.GROUP_UUID + " TEXT,"
                    + SubscriptionManager.IS_METERED + " INTEGER DEFAULT 1,"
                    + SubscriptionManager.IS_METERED + " INTEGER DEFAULT 1,"
                    + SubscriptionManager.ISO_COUNTRY_CODE + " TEXT"
                    + SubscriptionManager.ISO_COUNTRY_CODE + " TEXT,"
                    + SubscriptionManager.CARRIER_ID + " INTEGER DEFAULT -1"
                    + ");";
                    + ");";
        }
        }


+18 −0
Original line number Original line Diff line number Diff line
@@ -251,6 +251,24 @@ public class SubscriptionControllerTest extends TelephonyTest {
                captorIntent.getValue().getAction());
                captorIntent.getValue().getAction());
    }
    }


    @Test @SmallTest
    public void testSetGetCarrierId() {
        testInsertSim();
        int carrierId = 1234;
        mSubscriptionControllerUT.setCarrierId(carrierId, 1);

        SubscriptionInfo subInfo = mSubscriptionControllerUT
                .getActiveSubscriptionInfo(1, mCallingPackage);
        assertNotNull(subInfo);
        assertEquals(carrierId, subInfo.getCarrierId());

         /* verify broadcast intent */
        ArgumentCaptor<Intent> captorIntent = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, atLeast(1)).sendBroadcast(captorIntent.capture());
        assertEquals(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED,
                captorIntent.getValue().getAction());
    }

    @Test
    @Test
    @SmallTest
    @SmallTest
    public void testSetDefaultDataSubId() throws Exception {
    public void testSetDefaultDataSubId() throws Exception {