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

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

Merge "Suspending app can customize intercepting dialog"

parents f1246180 389cb6f5
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -1151,7 +1151,8 @@ package android.content.pm {
    method public abstract void revokeRuntimePermission(java.lang.String, java.lang.String, android.os.UserHandle);
    method public abstract boolean setDefaultBrowserPackageNameAsUser(java.lang.String, int);
    method public void setHarmfulAppWarning(java.lang.String, java.lang.CharSequence);
    method public java.lang.String[] setPackagesSuspended(java.lang.String[], boolean, android.os.PersistableBundle, android.os.PersistableBundle, java.lang.String);
    method public deprecated java.lang.String[] setPackagesSuspended(java.lang.String[], boolean, android.os.PersistableBundle, android.os.PersistableBundle, java.lang.String);
    method public java.lang.String[] setPackagesSuspended(java.lang.String[], boolean, android.os.PersistableBundle, android.os.PersistableBundle, android.content.pm.SuspendDialogInfo);
    method public abstract void setUpdateAvailable(java.lang.String, boolean);
    method public abstract boolean updateIntentVerificationStatusAsUser(java.lang.String, int, int);
    method public abstract void updatePermissionFlags(java.lang.String, java.lang.String, int, int, android.os.UserHandle);
@@ -1245,6 +1246,22 @@ package android.content.pm {
    field public int requestRes;
  }

  public final class SuspendDialogInfo implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.content.pm.SuspendDialogInfo> CREATOR;
  }

  public static final class SuspendDialogInfo.Builder {
    ctor public SuspendDialogInfo.Builder();
    method public android.content.pm.SuspendDialogInfo build();
    method public android.content.pm.SuspendDialogInfo.Builder setIcon(int);
    method public android.content.pm.SuspendDialogInfo.Builder setMessage(java.lang.String);
    method public android.content.pm.SuspendDialogInfo.Builder setMessage(int);
    method public android.content.pm.SuspendDialogInfo.Builder setNeutralButtonText(int);
    method public android.content.pm.SuspendDialogInfo.Builder setTitle(int);
  }

}

package android.content.pm.dex {
+13 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.SharedLibraryInfo;
import android.content.pm.SuspendDialogInfo;
import android.content.pm.VerifierDeviceIdentity;
import android.content.pm.VersionedPackage;
import android.content.pm.dex.ArtManager;
@@ -85,6 +86,7 @@ import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.system.StructStat;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.IconDrawableFactory;
import android.util.LauncherIcons;
@@ -2255,9 +2257,19 @@ public class ApplicationPackageManager extends PackageManager {
    public String[] setPackagesSuspended(String[] packageNames, boolean suspended,
            PersistableBundle appExtras, PersistableBundle launcherExtras,
            String dialogMessage) {
        final SuspendDialogInfo dialogInfo = !TextUtils.isEmpty(dialogMessage)
                ? new SuspendDialogInfo.Builder().setMessage(dialogMessage).build()
                : null;
        return setPackagesSuspended(packageNames, suspended, appExtras, launcherExtras, dialogInfo);
    }

    @Override
    public String[] setPackagesSuspended(String[] packageNames, boolean suspended,
            PersistableBundle appExtras, PersistableBundle launcherExtras,
            SuspendDialogInfo dialogInfo) {
        try {
            return mPM.setPackagesSuspendedAsUser(packageNames, suspended, appExtras,
                    launcherExtras, dialogMessage, mContext.getOpPackageName(),
                    launcherExtras, dialogInfo, mContext.getOpPackageName(),
                    getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+2 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.SuspendDialogInfo;
import android.content.pm.UserInfo;
import android.content.pm.VerifierDeviceIdentity;
import android.content.pm.VersionedPackage;
@@ -273,7 +274,7 @@ interface IPackageManager {

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

    boolean isPackageSuspendedForUser(String packageName, int userId);

+65 −4
Original line number Diff line number Diff line
@@ -5664,7 +5664,7 @@ public abstract class PackageManager {
     * {@link Manifest.permission#MANAGE_USERS} to use this api.</p>
     *
     * @param packageNames The names of the packages to set the suspended status.
     * @param suspended If set to {@code true} than the packages will be suspended, if set to
     * @param suspended If set to {@code true}, the packages will be suspended, if set to
     * {@code false}, the packages will be unsuspended.
     * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
     *                  which will be shared with the apps being suspended. Ignored if
@@ -5676,15 +5676,76 @@ public abstract class PackageManager {
     *                      suspended app.
     *
     * @return an array of package names for which the suspended status could not be set as
     * requested in this method.
     * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
     *
     * @deprecated use {@link #setPackagesSuspended(String[], boolean, PersistableBundle,
     * PersistableBundle, android.content.pm.SuspendDialogInfo)} instead.
     *
     * @hide
     */
    @SystemApi
    @Deprecated
    @RequiresPermission(Manifest.permission.SUSPEND_APPS)
    @Nullable
    public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
            @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
            @Nullable String dialogMessage) {
        throw new UnsupportedOperationException("setPackagesSuspended not implemented");
    }

    /**
     * Puts the given packages in a suspended state, where attempts at starting activities are
     * denied.
     *
     * <p>The suspended application's notifications and all of its windows will be hidden, any
     * of its started activities will be stopped and it won't be able to ring the device.
     * It doesn't remove the data or the actual package file.
     *
     * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app
     * is suspended will be shown instead.
     * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object
     * to this api. This dialog will have a button that starts the
     * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an
     * activity which handles this action.
     *
     * <p>The packages being suspended must already be installed. If a package is uninstalled, it
     * will no longer be suspended.
     *
     * <p>Optionally, the suspending app can provide extra information in the form of
     * {@link PersistableBundle} objects to be shared with the apps being suspended and the
     * launcher to support customization that they might need to handle the suspended state.
     *
     * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this api.
     *
     * @param packageNames The names of the packages to set the suspended status.
     * @param suspended If set to {@code true}, the packages will be suspended, if set to
     * {@code false}, the packages will be unsuspended.
     * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
     *                  which will be shared with the apps being suspended. Ignored if
     *                  {@code suspended} is false.
     * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
     *                       provide which will be shared with the launcher. Ignored if
     *                       {@code suspended} is false.
     * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that
     *                   should be shown to the user when they try to launch a suspended app.
     *                   Ignored if {@code suspended} is false.
     *
     * @return an array of package names for which the suspended status could not be set as
     * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
     *
     * @see #isPackageSuspended
     * @see SuspendDialogInfo
     * @see SuspendDialogInfo.Builder
     * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.SUSPEND_APPS)
    public String[] setPackagesSuspended(String[] packageNames, boolean suspended,
    @Nullable
    public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
            @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
            String dialogMessage) {
            @Nullable SuspendDialogInfo dialogInfo) {
        throw new UnsupportedOperationException("setPackagesSuspended not implemented");
    }

+5 −4
Original line number Diff line number Diff line
@@ -267,14 +267,15 @@ public abstract class PackageManagerInternal {
    public abstract String getSuspendingPackage(String suspendedPackage, int userId);

    /**
     * Get the dialog message to be shown to the user when they try to launch a suspended
     * application.
     * Get the information describing the dialog to be shown to the user when they try to launch a
     * suspended application.
     *
     * @param suspendedPackage The package that has been suspended.
     * @param userId The user for which to check.
     * @return The dialog message to be shown to the user.
     * @return A {@link SuspendDialogInfo} object describing the dialog to be shown.
     */
    public abstract String getSuspendedDialogMessage(String suspendedPackage, int userId);
    @Nullable
    public abstract SuspendDialogInfo getSuspendedDialogInfo(String suspendedPackage, int userId);

    /**
     * Do a straight uid lookup for the given package/application in the given user.
Loading