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

Commit ca869aaa authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check phone or system process in PMS with multiple-user-aware way" into main

parents 4bd40640 a856e583
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -186,7 +186,6 @@ import com.android.internal.pm.pkg.component.ParsedInstrumentation;
import com.android.internal.pm.pkg.component.ParsedMainComponent;
import com.android.internal.pm.pkg.component.ParsedMainComponent;
import com.android.internal.pm.pkg.parsing.ParsingPackageUtils;
import com.android.internal.pm.pkg.parsing.ParsingPackageUtils;
import com.android.internal.telephony.CarrierAppUtils;
import com.android.internal.telephony.CarrierAppUtils;
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.CollectionUtils;
import com.android.internal.util.CollectionUtils;
import com.android.internal.util.ConcurrentUtils;
import com.android.internal.util.ConcurrentUtils;
@@ -4493,7 +4492,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    void setSystemAppHiddenUntilInstalled(@NonNull Computer snapshot, String packageName,
    void setSystemAppHiddenUntilInstalled(@NonNull Computer snapshot, String packageName,
            boolean hidden) {
            boolean hidden) {
        final int callingUid = Binder.getCallingUid();
        final int callingUid = Binder.getCallingUid();
        final boolean calledFromSystemOrPhone = TelephonyPermissions.isSystemOrPhone(callingUid);
        final boolean calledFromSystemOrPhone = isSystemOrPhone(callingUid);
        if (!calledFromSystemOrPhone) {
        if (!calledFromSystemOrPhone) {
            mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS,
            mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS,
                    "setSystemAppHiddenUntilInstalled");
                    "setSystemAppHiddenUntilInstalled");
@@ -4518,8 +4517,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    boolean setSystemAppInstallState(@NonNull Computer snapshot, String packageName,
    boolean setSystemAppInstallState(@NonNull Computer snapshot, String packageName,
            boolean installed, int userId) {
            boolean installed, int userId) {
        final int callingUid = Binder.getCallingUid();
        final int callingUid = Binder.getCallingUid();
        final boolean calledFromSystemOrPhone = callingUid == Process.PHONE_UID
        final boolean calledFromSystemOrPhone = isSystemOrPhone(callingUid);
                || callingUid == Process.SYSTEM_UID;
        if (!calledFromSystemOrPhone) {
        if (!calledFromSystemOrPhone) {
            mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS,
            mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS,
                    "setSystemAppHiddenUntilInstalled");
                    "setSystemAppHiddenUntilInstalled");
@@ -8123,4 +8121,9 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                PackageManager.VERSION_CODE_HIGHEST, UserHandle.USER_SYSTEM,
                PackageManager.VERSION_CODE_HIGHEST, UserHandle.USER_SYSTEM,
                PackageManager.DELETE_ALL_USERS, true /*removedBySystem*/);
                PackageManager.DELETE_ALL_USERS, true /*removedBySystem*/);
    }
    }

    private static boolean isSystemOrPhone(int uid) {
        return UserHandle.isSameApp(uid, Process.SYSTEM_UID)
                || UserHandle.isSameApp(uid, Process.PHONE_UID);
    }
}
}