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

Commit df7ce9f5 authored by Bill Yi's avatar Bill Yi
Browse files

Merge SQ3A.220705.003 to aosp-master - DO NOT MERGE

Merged-In: I1503d7bb31d682e4f4ef8d39b25512e77856f986
Merged-In: I0c415e08a09e289fd798f30f18b1c22cfa10b820
Change-Id: Iddd3d380fb81e83cdf5b9ee56b4111152c06d13a
parents 20aa9d24 ed011063
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -3262,10 +3262,20 @@ public class SubscriptionController extends ISub.Stub {
    @Override
    @Override
    public String getSubscriptionProperty(int subId, String propKey, String callingPackage,
    public String getSubscriptionProperty(int subId, String propKey, String callingPackage,
            String callingFeatureId) {
            String callingFeatureId) {
        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId, callingPackage,
        switch (propKey) {
                callingFeatureId, "getSubscriptionProperty")) {
            case SubscriptionManager.GROUP_UUID:
                if (mContext.checkCallingOrSelfPermission(
                        Manifest.permission.READ_PRIVILEGED_PHONE_STATE) != PERMISSION_GRANTED) {
                    EventLog.writeEvent(0x534e4554, "213457638", Binder.getCallingUid());
                    return null;
                }
                break;
            default:
                if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId,
                        callingPackage, callingFeatureId, "getSubscriptionProperty")) {
                    return null;
                    return null;
                }
                }
        }


        final long identity = Binder.clearCallingIdentity();
        final long identity = Binder.clearCallingIdentity();
        try {
        try {
+31 −0
Original line number Original line Diff line number Diff line
@@ -971,6 +971,37 @@ public class SubscriptionControllerTest extends TelephonyTest {
        assertNotEquals(groupId, newGroupId);
        assertNotEquals(groupId, newGroupId);
    }
    }


    @Test
    @SmallTest
    public void testGetSubscriptionProperty() throws Exception {
        testInsertSim();
        ContentValues values = new ContentValues();
        values.put(SubscriptionManager.GROUP_UUID, 1);
        mFakeTelephonyProvider.update(SubscriptionManager.CONTENT_URI, values,
                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=" + 1, null);

        mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL);
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);

        // should succeed with read phone state permission
        String prop = mSubscriptionControllerUT.getSubscriptionProperty(1,
                SubscriptionManager.CB_EXTREME_THREAT_ALERT, mContext.getOpPackageName(),
                mContext.getAttributionTag());

        assertNotEquals(null, prop);

        // group UUID requires privileged phone state permission
        prop = mSubscriptionControllerUT.getSubscriptionProperty(1, SubscriptionManager.GROUP_UUID,
                    mContext.getOpPackageName(), mContext.getAttributionTag());
        assertEquals(null, prop);

        // group UUID should succeed once privileged phone state permission is granted
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
        prop = mSubscriptionControllerUT.getSubscriptionProperty(1, SubscriptionManager.GROUP_UUID,
                mContext.getOpPackageName(), mContext.getAttributionTag());
        assertNotEquals(null, prop);
    }

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