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

Commit 64a6d862 authored by Pavel Grafov's avatar Pavel Grafov Committed by Android (Google) Code Review
Browse files

Merge "Reland "Update data types to support cross user suspension"" into main

parents 17e24ffc 76c0d3c6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2909,7 +2909,7 @@ public class ApplicationPackageManager extends PackageManager {
        try {
            return mPM.setPackagesSuspendedAsUser(packageNames, suspended, appExtras,
                    launcherExtras, dialogInfo, flags, mContext.getOpPackageName(),
                    getUserId());
                    UserHandle.myUserId() /* suspendingUserId */, getUserId() /* targetUserId */);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+2 −1
Original line number Diff line number Diff line
@@ -300,7 +300,8 @@ interface IPackageManager {

    String[] setPackagesSuspendedAsUser(in String[] packageNames, boolean suspended,
            in PersistableBundle appExtras, in PersistableBundle launcherExtras,
            in SuspendDialogInfo dialogInfo, int flags, String callingPackage, int userId);
            in SuspendDialogInfo dialogInfo, int flags, String suspendingPackage,
            int suspendingUserId, int targetUserId);

    String[] getUnsuspendablePackagesForUser(in String[] packageNames, int userId);

+3 −0
Original line number Diff line number Diff line
@@ -10000,6 +10000,9 @@ public abstract class PackageManager {
     * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or
     * {@link android.Manifest.permission#SUSPEND_APPS}.
     *
     * <p>
     * <strong>Note:</strong>This API doesn't support cross user suspension and should only be used
     * for testing.
     * @param suspendedPackage The package that has been suspended.
     * @return Name of the package that suspended the given package. Returns {@code null} if the
     * given package is not currently suspended and the platform package name - i.e.
+8 −4
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.SuspendDialogInfo;
import android.content.pm.UserPackage;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -308,7 +309,8 @@ public class SuspendedAppActivity extends AlertActivity
                        try {
                            final String[] errored = ipm.setPackagesSuspendedAsUser(
                                    new String[]{mSuspendedPackage}, false, null, null, null, 0,
                                    mSuspendingPackage, mUserId);
                                    mSuspendingPackage, mUserId /* suspendingUserId */,
                                    mUserId /* targetUserId */);
                            if (ArrayUtils.contains(errored, mSuspendedPackage)) {
                                Slog.e(TAG, "Could not unsuspend " + mSuspendedPackage);
                                break;
@@ -350,17 +352,19 @@ public class SuspendedAppActivity extends AlertActivity
    }

    public static Intent createSuspendedAppInterceptIntent(String suspendedPackage,
            String suspendingPackage, SuspendDialogInfo dialogInfo, Bundle options,
            UserPackage suspendingPackage, SuspendDialogInfo dialogInfo, Bundle options,
            IntentSender onUnsuspend, int userId) {
        return new Intent()
        Intent intent = new Intent()
                .setClassName("android", SuspendedAppActivity.class.getName())
                .putExtra(EXTRA_SUSPENDED_PACKAGE, suspendedPackage)
                .putExtra(EXTRA_DIALOG_INFO, dialogInfo)
                .putExtra(EXTRA_SUSPENDING_PACKAGE, suspendingPackage)
                .putExtra(EXTRA_SUSPENDING_PACKAGE,
                        suspendingPackage != null ? suspendingPackage.packageName : null)
                .putExtra(EXTRA_UNSUSPEND_INTENT, onUnsuspend)
                .putExtra(EXTRA_ACTIVITY_OPTIONS, options)
                .putExtra(Intent.EXTRA_USER_ID, userId)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                        | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        return intent;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.content.pm.ServiceInfo;
import android.content.pm.ShortcutServiceInternal;
import android.content.pm.SuspendDialogInfo;
import android.content.pm.UserInfo;
import android.content.pm.UserPackage;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
@@ -559,10 +560,11 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
                onClickIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(appUserId);
            } else if (provider.maskedBySuspendedPackage) {
                showBadge = mUserManager.hasBadge(appUserId);
                final String suspendingPackage = mPackageManagerInternal.getSuspendingPackage(
                final UserPackage suspendingPackage = mPackageManagerInternal.getSuspendingPackage(
                        appInfo.packageName, appUserId);
                // TODO(b/281839596): don't rely on platform always meaning suspended by admin.
                if (PLATFORM_PACKAGE_NAME.equals(suspendingPackage)) {
                if (suspendingPackage != null
                        && PLATFORM_PACKAGE_NAME.equals(suspendingPackage.packageName)) {
                    onClickIntent = mDevicePolicyManagerInternal.createShowAdminSupportIntent(
                            appUserId, true);
                } else {
Loading