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

Unverified Commit 9ccfa22b authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-12.1.0_r11' into staging/lineage-19.1_merge-android-12.1.0_r11

Android 12.1.0 release 11

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCYsXEtwAKCRDorT+BmrEO
# eKEWAJ96Zl/dz96YGO3Ezz2NJ3FXs/R37wCdGOwiUblHSdQkKCRjorHsX2lxMP8=
# =SAi6
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Jul  6 20:21:59 2022 EEST
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 1242 signatures in the past
#      8 months.  Encrypted 4 messages in the past 5 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Ling Ma
# Via Android Build Coastguard Worker
* tag 'android-12.1.0_r11':
  Enforce privileged phone state for getSubscriptionProperty(GROUP_UUID)

Change-Id: I0ffccfe3bbddc58ef1868d1b6aaeffd853ca0fc4
parents a00904af ed011063
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -3237,10 +3237,20 @@ public class SubscriptionController extends ISub.Stub {
    @Override
    public String getSubscriptionProperty(int subId, String propKey, String callingPackage,
            String callingFeatureId) {
        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId, callingPackage,
                callingFeatureId, "getSubscriptionProperty")) {
        switch (propKey) {
            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;
                }
        }

        final long identity = Binder.clearCallingIdentity();
        try {
+31 −0
Original line number Diff line number Diff line
@@ -960,6 +960,37 @@ public class SubscriptionControllerTest extends TelephonyTest {
        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
    @SmallTest
    public void testCreateSubscriptionGroupWithCarrierPrivilegePermission() throws Exception {