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

Commit ce6478a8 authored by Rambo Wang's avatar Rambo Wang
Browse files

Check system and phone UID in multiple-user-aware way

This CL calls UserHandle.isSameApp to make sure the UID check with
Process.SYSTEM_UID and PHONE_UID are multiple-user-aware.

The logic to directly compare UID with PROCESS.XXX_UID only works for
system user. For secondary users, system/phone processes may run with UID prefixed with user id.

UserHandle.isSameApp helps to correctly detect the system/phone process by comparing only the App id part.

Bug: 328511085
Test: atest framewoksTelephonyTests
Flag: com.android.internal.telephony.flags.support_phone_uid_check_for_multiuser
Change-Id: I2b466b4e190c18dc57187a547d1ba62459348946
parent a111d5ed
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -4498,10 +4498,17 @@ public class SubscriptionManagerService extends ISub.Stub {
     */
    @NonNull
    private String getCallingPackage() {
        if (Flags.supportPhoneUidCheckForMultiuser()) {
            if (UserHandle.isSameApp(Binder.getCallingUid(), Process.PHONE_UID)) {
                // Too many packages running with phone uid. Just return one here.
                return "com.android.phone";
            }
        } else {
            if (Binder.getCallingUid() == Process.PHONE_UID) {
                // Too many packages running with phone uid. Just return one here.
                return "com.android.phone";
            }
        }
        return Arrays.toString(mContext.getPackageManager().getPackagesForUid(
                Binder.getCallingUid()));
    }