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

Commit 03026cb8 authored by Suprabh Shukla's avatar Suprabh Shukla Committed by android-build-merger
Browse files

Merge "Review of suspend/unsuspend APIs" into pi-dev

am: 2188383b

Change-Id: Ied0b92474f80760f084fd749587fce0953c8469b
parents f0134aad 2188383b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10956,7 +10956,7 @@ package android.content.pm {
    method public abstract void onPackageRemoved(java.lang.String, android.os.UserHandle);
    method public abstract void onPackagesAvailable(java.lang.String[], android.os.UserHandle, boolean);
    method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
    method public void onPackagesSuspended(java.lang.String[], android.os.Bundle, android.os.UserHandle);
    method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle, android.os.Bundle);
    method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
    method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
    method public void onShortcutsChanged(java.lang.String, java.util.List<android.content.pm.ShortcutInfo>, android.os.UserHandle);
+1 −1
Original line number Diff line number Diff line
@@ -1030,7 +1030,7 @@ package android.content.pm {
    method public abstract void grantRuntimePermission(java.lang.String, java.lang.String, android.os.UserHandle);
    method public abstract int installExistingPackage(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract int installExistingPackage(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method public boolean isPackageSuspended(java.lang.String);
    method public boolean isPackageSuspended(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public java.util.List<android.content.pm.ResolveInfo> queryBroadcastReceiversAsUser(android.content.Intent, int, android.os.UserHandle);
    method public abstract void registerDexModule(java.lang.String, android.content.pm.PackageManager.DexModuleRegisterCallback);
    method public abstract void removeOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener);
+6 −2
Original line number Diff line number Diff line
@@ -2187,8 +2187,12 @@ public class ApplicationPackageManager extends PackageManager {

    /** @hide */
    @Override
    public boolean isPackageSuspended(String packageName) {
    public boolean isPackageSuspended(String packageName) throws NameNotFoundException {
        try {
            return isPackageSuspendedForUser(packageName, mContext.getUserId());
        } catch (IllegalArgumentException ie) {
            throw new NameNotFoundException(packageName);
        }
    }

    @Override
+13 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.ResultReceiver;
import android.os.ShellCommand;
@@ -1814,8 +1815,12 @@ public class Intent implements Parcelable, Cloneable {
    public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";

    /**
     * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent with
     * {@link #ACTION_MY_PACKAGE_SUSPENDED}.
     * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
     * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
     *
     * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
     * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
     * This is meant to enable the suspended app to better handle the state of being suspended.
     *
     * @see #ACTION_MY_PACKAGE_SUSPENDED
     * @see #ACTION_MY_PACKAGE_UNSUSPENDED
@@ -2284,6 +2289,10 @@ public class Intent implements Parcelable, Cloneable {
    /**
     * Activity Action: Started to show more details about why an application was suspended.
     *
     * <p>Whenever the system detects an activity launch for a suspended app, it shows a dialog to
     * the user to inform them of the state and present them an affordance to start this activity
     * action to show more details about the reason for suspension.
     *
     * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
     * handling this intent and protect it with
     * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
@@ -2293,6 +2302,8 @@ public class Intent implements Parcelable, Cloneable {
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
     *
     * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
     * PersistableBundle, String)
     * @see PackageManager#isPackageSuspended()
     * @see #ACTION_PACKAGES_SUSPENDED
     *
+16 −8
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ public class LauncherApps {
         * an applicaton.
         *
         * <p>Note: On devices running {@link android.os.Build.VERSION_CODES#P Android P} or higher,
         * any apps that override {@link #onPackagesSuspended(String[], Bundle, UserHandle)} will
         * any apps that override {@link #onPackagesSuspended(String[], UserHandle, Bundle)} will
         * not receive this callback.
         *
         * @param packageNames The names of the packages that have just been
@@ -226,15 +226,20 @@ public class LauncherApps {
         * Indicates that one or more packages have been suspended. A device administrator or an app
         * with {@code android.permission.SUSPEND_APPS} can do this.
         *
         * <p>A suspending app with the permission {@code android.permission.SUSPEND_APPS} can
         * optionally provide a {@link Bundle} of extra information that it deems helpful for the
         * launcher to handle the suspended state of these packages. The contents of this
         * {@link Bundle} supposed to be a contract between the suspending app and the launcher.
         *
         * @param packageNames The names of the packages that have just been suspended.
         * @param launcherExtras A {@link Bundle} of extras for the launcher.
         * @param user the user for which the given packages were suspended.
         *
         * @param launcherExtras A {@link Bundle} of extras for the launcher, if provided to the
         *                      system, {@code null} otherwise.
         * @see PackageManager#isPackageSuspended()
         * @see #getSuspendedPackageLauncherExtras(String, UserHandle)
         */
        public void onPackagesSuspended(String[] packageNames, @Nullable Bundle launcherExtras,
                UserHandle user) {
        public void onPackagesSuspended(String[] packageNames, UserHandle user,
                @Nullable Bundle launcherExtras) {
            onPackagesSuspended(packageNames, user);
        }

@@ -662,6 +667,9 @@ public class LauncherApps {
     * {@code PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
     * PersistableBundle, String)}.
     *
     * <p>The contents of this {@link Bundle} are supposed to be a contract between the suspending
     * app and the launcher.
     *
     * <p>Note: This just returns whatever extras were provided to the system, <em>which might
     * even be {@code null}.</em>
     *
@@ -670,7 +678,7 @@ public class LauncherApps {
     * @return A {@link Bundle} of launcher extras. Or {@code null} if the package is not currently
     *         suspended.
     *
     * @see Callback#onPackagesSuspended(String[], Bundle, UserHandle)
     * @see Callback#onPackagesSuspended(String[], UserHandle, Bundle)
     * @see PackageManager#isPackageSuspended()
     */
    public @Nullable Bundle getSuspendedPackageLauncherExtras(String packageName, UserHandle user) {
@@ -1298,8 +1306,8 @@ public class LauncherApps {
                    mCallback.onPackagesUnavailable(info.packageNames, info.user, info.replacing);
                    break;
                case MSG_SUSPENDED:
                    mCallback.onPackagesSuspended(info.packageNames, info.launcherExtras,
                            info.user);
                    mCallback.onPackagesSuspended(info.packageNames, info.user, info.launcherExtras
                    );
                    break;
                case MSG_UNSUSPENDED:
                    mCallback.onPackagesUnsuspended(info.packageNames, info.user);
Loading