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

Commit f9ca3610 authored by rambowang's avatar rambowang Committed by Rambo Wang
Browse files

Check phone or system process in PMS with multiple-user-aware way

This CL checks phone or system process by the help of
TelephonyPermission.isSystemOrPhone which works not only for system user
but also secondary users in which 1000/1001 is the app id instead of
UID.

Bug: 328511085
Test: atest PackageManagerServiceTest
Flag: com.android.internal.telephony.flags.support_phone_uid_check_for_multiuser
Change-Id: I936c16b63924452cd68b4a38a8ce3369c7913d87
parent ef2629a5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ import com.android.internal.pm.pkg.component.ParsedInstrumentation;
import com.android.internal.pm.pkg.component.ParsedMainComponent;
import com.android.internal.pm.pkg.parsing.ParsingPackageUtils;
import com.android.internal.telephony.CarrierAppUtils;
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.CollectionUtils;
import com.android.internal.util.ConcurrentUtils;
@@ -4492,8 +4493,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    void setSystemAppHiddenUntilInstalled(@NonNull Computer snapshot, String packageName,
            boolean hidden) {
        final int callingUid = Binder.getCallingUid();
        final boolean calledFromSystemOrPhone = callingUid == Process.PHONE_UID
                || callingUid == Process.SYSTEM_UID;
        final boolean calledFromSystemOrPhone = TelephonyPermissions.isSystemOrPhone(callingUid);
        if (!calledFromSystemOrPhone) {
            mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS,
                    "setSystemAppHiddenUntilInstalled");
+2 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import android.util.proto.ProtoOutputStream;

import com.android.internal.content.InstallLocationUtils;
import com.android.internal.content.NativeLibraryHelper;
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.HexDump;
@@ -356,7 +357,7 @@ public class PackageManagerServiceUtils {
     * If not, throws a {@link SecurityException}.
     */
    public static void enforceSystemOrPhoneCaller(String methodName, int callingUid) {
        if (callingUid != Process.PHONE_UID && callingUid != Process.SYSTEM_UID) {
        if (!TelephonyPermissions.isSystemOrPhone(callingUid)) {
            throw new SecurityException(
                    "Cannot call " + methodName + " from UID " + callingUid);
        }