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

Commit 9eca2b92 authored by android-build-team Robot's avatar android-build-team Robot Committed by android-build-merger
Browse files

Merge "Unsuspending packages on suspending app data clear" into pi-dev

am: 2ba981c6

Change-Id: I9a5ea7f7b5b49ecfb30b32f5ef3043c1f4d2f06b
parents 0e4b1c1b 2ba981c6
Loading
Loading
Loading
Loading
+30 −18
Original line number Original line Diff line number Diff line
@@ -88,11 +88,11 @@ import static android.os.storage.StorageManager.FLAG_STORAGE_CE;
import static android.os.storage.StorageManager.FLAG_STORAGE_DE;
import static android.os.storage.StorageManager.FLAG_STORAGE_DE;
import static android.system.OsConstants.O_CREAT;
import static android.system.OsConstants.O_CREAT;
import static android.system.OsConstants.O_RDWR;
import static android.system.OsConstants.O_RDWR;
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_MANAGED_PROFILE;
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_MANAGED_PROFILE;
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_PARENT;
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_PARENT;
import static com.android.internal.content.NativeLibraryHelper.LIB64_DIR_NAME;
import static com.android.internal.content.NativeLibraryHelper.LIB64_DIR_NAME;
import static com.android.internal.content.NativeLibraryHelper.LIB_DIR_NAME;
import static com.android.internal.content.NativeLibraryHelper.LIB_DIR_NAME;
import static com.android.internal.util.ArrayUtils.appendElement;
import static com.android.internal.util.ArrayUtils.appendInt;
import static com.android.internal.util.ArrayUtils.appendInt;
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSet;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSet;
@@ -275,7 +275,6 @@ import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IMediaContainerService;
import com.android.internal.app.IMediaContainerService;
import com.android.internal.app.ResolverActivity;
import com.android.internal.app.ResolverActivity;
import com.android.internal.app.SuspendedAppActivity;
import com.android.internal.content.NativeLibraryHelper;
import com.android.internal.content.NativeLibraryHelper;
import com.android.internal.content.PackageHelper;
import com.android.internal.content.PackageHelper;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
@@ -411,7 +410,7 @@ public class PackageManagerService extends IPackageManager.Stub
    static final boolean DEBUG_DOMAIN_VERIFICATION = false;
    static final boolean DEBUG_DOMAIN_VERIFICATION = false;
    private static final boolean DEBUG_BACKUP = false;
    private static final boolean DEBUG_BACKUP = false;
    public static final boolean DEBUG_INSTALL = false;
    public static final boolean DEBUG_INSTALL = false;
    public static final boolean DEBUG_REMOVE = true;
    public static final boolean DEBUG_REMOVE = false;
    private static final boolean DEBUG_BROADCASTS = false;
    private static final boolean DEBUG_BROADCASTS = false;
    private static final boolean DEBUG_SHOW_INFO = false;
    private static final boolean DEBUG_SHOW_INFO = false;
    private static final boolean DEBUG_PACKAGE_INFO = false;
    private static final boolean DEBUG_PACKAGE_INFO = false;
@@ -14042,13 +14041,10 @@ public class PackageManagerService extends IPackageManager.Stub
                            + Manifest.permission.MANAGE_USERS);
                            + Manifest.permission.MANAGE_USERS);
        }
        }
        final int callingUid = Binder.getCallingUid();
        final int callingUid = Binder.getCallingUid();
        mPermissionManager.enforceCrossUserPermission(callingUid, userId,
        if (callingUid != Process.ROOT_UID && callingUid != Process.SYSTEM_UID
                true /* requireFullPermission */, true /* checkShell */,
                && getPackageUid(callingPackage, 0, userId) != callingUid) {
                "setPackagesSuspended for user " + userId);
            throw new SecurityException("Calling package " + callingPackage + " in user "
        if (callingUid != Process.ROOT_UID &&
                    + userId + " does not belong to calling uid " + callingUid);
                !UserHandle.isSameApp(getPackageUid(callingPackage, 0, userId), callingUid)) {
            throw new IllegalArgumentException("CallingPackage " + callingPackage + " does not"
                    + " belong to calling app id " + UserHandle.getAppId(callingUid));
        }
        }
        if (!PLATFORM_PACKAGE_NAME.equals(callingPackage)
        if (!PLATFORM_PACKAGE_NAME.equals(callingPackage)
                && mProtectedPackages.getDeviceOwnerOrProfileOwnerPackage(userId) != null) {
                && mProtectedPackages.getDeviceOwnerOrProfileOwnerPackage(userId) != null) {
@@ -14175,9 +14171,19 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        }
    }
    }
    void onSuspendingPackageRemoved(String packageName, int removedForUser) {
    /**
        final int[] userIds = (removedForUser == UserHandle.USER_ALL) ? sUserManager.getUserIds()
     * Immediately unsuspends any packages suspended by the given package. To be called
                : new int[] {removedForUser};
     * when such a package's data is cleared or it is removed from the device.
     *
     * <p><b>Should not be used on a frequent code path</b> as it flushes state to disk
     * synchronously
     *
     * @param packageName The package holding {@link Manifest.permission#SUSPEND_APPS} permission
     * @param affectedUser The user for which the changes are taking place.
     */
    void unsuspendForSuspendingPackage(String packageName, int affectedUser) {
        final int[] userIds = (affectedUser == UserHandle.USER_ALL) ? sUserManager.getUserIds()
                : new int[] {affectedUser};
        for (int userId : userIds) {
        for (int userId : userIds) {
            List<String> affectedPackages = new ArrayList<>();
            List<String> affectedPackages = new ArrayList<>();
            synchronized (mPackages) {
            synchronized (mPackages) {
@@ -14194,6 +14200,8 @@ public class PackageManagerService extends IPackageManager.Stub
                        new String[affectedPackages.size()]);
                        new String[affectedPackages.size()]);
                sendMyPackageSuspendedOrUnsuspended(packageArray, false, null, userId);
                sendMyPackageSuspendedOrUnsuspended(packageArray, false, null, userId);
                sendPackagesSuspendedForUser(packageArray, userId, false, null);
                sendPackagesSuspendedForUser(packageArray, userId, false, null);
                // Write package restrictions immediately to avoid an inconsistent state.
                mSettings.writePackageRestrictionsLPr(userId);
            }
            }
        }
        }
    }
    }
@@ -18769,7 +18777,7 @@ public class PackageManagerService extends IPackageManager.Stub
        final int userId = user == null ? UserHandle.USER_ALL : user.getIdentifier();
        final int userId = user == null ? UserHandle.USER_ALL : user.getIdentifier();
        if (ps.getPermissionsState().hasPermission(Manifest.permission.SUSPEND_APPS, userId)) {
        if (ps.getPermissionsState().hasPermission(Manifest.permission.SUSPEND_APPS, userId)) {
            onSuspendingPackageRemoved(packageName, userId);
            unsuspendForSuspendingPackage(packageName, userId);
        }
        }
@@ -18910,10 +18918,10 @@ public class PackageManagerService extends IPackageManager.Stub
                    true /*notLaunched*/,
                    true /*notLaunched*/,
                    false /*hidden*/,
                    false /*hidden*/,
                    false /*suspended*/,
                    false /*suspended*/,
                    null, /*suspendingPackage*/
                    null /*suspendingPackage*/,
                    null, /*dialogMessage*/
                    null /*dialogMessage*/,
                    null, /*suspendedAppExtras*/
                    null /*suspendedAppExtras*/,
                    null, /*suspendedLauncherExtras*/
                    null /*suspendedLauncherExtras*/,
                    false /*instantApp*/,
                    false /*instantApp*/,
                    false /*virtualPreload*/,
                    false /*virtualPreload*/,
                    null /*lastDisableAppCaller*/,
                    null /*lastDisableAppCaller*/,
@@ -19100,6 +19108,10 @@ public class PackageManagerService extends IPackageManager.Stub
                        if (dsm != null) {
                        if (dsm != null) {
                            dsm.checkMemory();
                            dsm.checkMemory();
                        }
                        }
                        if (checkPermission(Manifest.permission.SUSPEND_APPS, packageName, userId)
                                == PERMISSION_GRANTED) {
                            unsuspendForSuspendingPackage(packageName, userId);
                        }
                    }
                    }
                } else {
                } else {
                    succeeded = false;
                    succeeded = false;
+8 −8
Original line number Original line Diff line number Diff line
@@ -734,10 +734,10 @@ public final class Settings {
                                true /*notLaunched*/,
                                true /*notLaunched*/,
                                false /*hidden*/,
                                false /*hidden*/,
                                false /*suspended*/,
                                false /*suspended*/,
                                null, /*suspendingPackage*/
                                null /*suspendingPackage*/,
                                null, /*dialogMessage*/
                                null /*dialogMessage*/,
                                null, /*suspendedAppExtras*/
                                null /*suspendedAppExtras*/,
                                null, /*suspendedLauncherExtras*/
                                null /*suspendedLauncherExtras*/,
                                instantApp,
                                instantApp,
                                virtualPreload,
                                virtualPreload,
                                null /*lastDisableAppCaller*/,
                                null /*lastDisableAppCaller*/,
@@ -1634,10 +1634,10 @@ public final class Settings {
                                false /*notLaunched*/,
                                false /*notLaunched*/,
                                false /*hidden*/,
                                false /*hidden*/,
                                false /*suspended*/,
                                false /*suspended*/,
                                null, /*suspendingPackage*/
                                null /*suspendingPackage*/,
                                null, /*dialogMessage*/
                                null /*dialogMessage*/,
                                null, /*suspendedAppExtras*/
                                null /*suspendedAppExtras*/,
                                null, /*suspendedLauncherExtras*/
                                null /*suspendedLauncherExtras*/,
                                false /*instantApp*/,
                                false /*instantApp*/,
                                false /*virtualPreload*/,
                                false /*virtualPreload*/,
                                null /*lastDisableAppCaller*/,
                                null /*lastDisableAppCaller*/,
+1 −1
Original line number Original line Diff line number Diff line
@@ -1953,7 +1953,7 @@ public class PermissionManagerService {
                    UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, userId);
                    UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, userId);
        }
        }
        if (userId == UserHandle.getUserId(callingUid)) return;
        if (userId == UserHandle.getUserId(callingUid)) return;
        if (callingUid != Process.SYSTEM_UID && callingUid != 0) {
        if (callingUid != Process.SYSTEM_UID && callingUid != Process.ROOT_UID) {
            if (requireFullPermission) {
            if (requireFullPermission) {
                mContext.enforceCallingOrSelfPermission(
                mContext.enforceCallingOrSelfPermission(
                        android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, message);
                        android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, message);