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

Commit f81bf7fa authored by Benjamin Franz's avatar Benjamin Franz
Browse files

Silently ignore force stop API for protected packages

Bug: 75997475
Test: manual
Change-Id: I804aafe2404eeaac732fed51cf6d3d2e45a3b5bb
parent 1bc47a4c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -269,6 +269,12 @@ public abstract class PackageManagerInternal {
     */
    public abstract boolean isPackageDataProtected(int userId, String packageName);

    /**
     * Returns {@code true} if a given package's state is protected, e.g. it cannot be force
     * stopped, suspended, disabled or hidden. Otherwise, returns {@code false}.
     */
    public abstract boolean isPackageStateProtected(String packageName, int userId);

    /**
     * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns
     * {@code false}.
+7 −0
Original line number Diff line number Diff line
@@ -6708,6 +6708,13 @@ public class ActivityManagerService extends IActivityManager.Stub
                int[] users = userId == UserHandle.USER_ALL
                        ? mUserController.getUsers() : new int[] { userId };
                for (int user : users) {
                    if (getPackageManagerInternalLocked().isPackageStateProtected(
                            packageName, user)) {
                        Slog.w(TAG, "Ignoring request to force stop protected package "
                                + packageName + " u" + user);
                        return;
                    }
                    int pkgUid = -1;
                    try {
                        pkgUid = pm.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING,
+5 −0
Original line number Diff line number Diff line
@@ -23841,6 +23841,11 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
            return mProtectedPackages.isPackageDataProtected(userId, packageName);
        }
        @Override
        public boolean isPackageStateProtected(String packageName, int userId) {
            return mProtectedPackages.isPackageStateProtected(userId, packageName);
        }
        @Override
        public boolean isPackageEphemeral(int userId, String packageName) {
            synchronized (mPackages) {