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

Commit b630f15f authored by Amith Yamasani's avatar Amith Yamasani
Browse files

PACKAGE_UNSTOPPED broadcast

Send ACTION_PACKAGE_UNSTOPPED broadcast when a
stopped app is started.

Also expose an isPackageStopped() API for apps with package
visibility to query.

Bug: 300349952
Test: atest android.app.cts.ActivityManagerTest

Change-Id: Ibba8907a317401f1a0689914593cb6d61bd2e123
parent 22541cb0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10992,6 +10992,7 @@ package android.content {
    field public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
    field public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
    field public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
    field @FlaggedApi("android.content.pm.stay_stopped") public static final String ACTION_PACKAGE_UNSTOPPED = "android.intent.action.PACKAGE_UNSTOPPED";
    field public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
    field public static final String ACTION_PASTE = "android.intent.action.PASTE";
    field public static final String ACTION_PICK = "android.intent.action.PICK";
@@ -12671,6 +12672,7 @@ package android.content.pm {
    method public boolean isDeviceUpgrading();
    method public abstract boolean isInstantApp();
    method public abstract boolean isInstantApp(@NonNull String);
    method @FlaggedApi("android.content.pm.stay_stopped") public boolean isPackageStopped(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public boolean isPackageSuspended(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public boolean isPackageSuspended();
    method @CheckResult public abstract boolean isPermissionRevokedByPolicy(@NonNull String, @NonNull String);
+11 −0
Original line number Diff line number Diff line
@@ -2954,6 +2954,17 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public boolean isPackageStopped(@NonNull String packageName) throws NameNotFoundException {
        try {
            return mPM.isPackageStoppedForUser(packageName, getUserId());
        } catch (IllegalArgumentException ie) {
            throw new NameNotFoundException(packageName);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    @Override
    public void setApplicationCategoryHint(String packageName, int categoryHint) {
+15 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.Manifest;
import android.accessibilityservice.AccessibilityService;
import android.annotation.AnyRes;
import android.annotation.BroadcastBehavior;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -2788,6 +2789,20 @@ public class Intent implements Parcelable, Cloneable {
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
    /**
     * Broadcast Action: An application package that was previously in the stopped state has been
     * started and is no longer considered stopped.
     * <ul>
     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
     * </ul>
     *
     * <p class="note">This is a protected intent that can only be sent by the system.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @FlaggedApi(android.content.pm.Flags.FLAG_STAY_STOPPED)
    public static final String ACTION_PACKAGE_UNSTOPPED = "android.intent.action.PACKAGE_UNSTOPPED";
    /**
     * Broadcast Action: Sent to the system rollback manager when a package
     * needs to have rollback enabled.
+2 −0
Original line number Diff line number Diff line
@@ -308,6 +308,8 @@ interface IPackageManager {

    boolean isPackageQuarantinedForUser(String packageName, int userId);

    boolean isPackageStoppedForUser(String packageName, int userId);

    Bundle getSuspendedPackageAppExtras(String packageName, int userId);

    /**
+12 −1
Original line number Diff line number Diff line
@@ -9876,6 +9876,18 @@ public abstract class PackageManager {
        throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented");
    }

    /**
     * Query if an app is currently stopped.
     *
     * @return {@code true} if the given package is stopped, {@code false} otherwise
     * @throws NameNotFoundException if the package could not be found.
     * @see ApplicationInfo#FLAG_STOPPED
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_STAY_STOPPED)
    public boolean isPackageStopped(@NonNull String packageName) throws NameNotFoundException {
        throw new UnsupportedOperationException("isPackageStopped not implemented");
    }

    /**
     * Query if an app is currently quarantined.
     *
@@ -9887,7 +9899,6 @@ public abstract class PackageManager {
    public boolean isPackageQuarantined(@NonNull String packageName) throws NameNotFoundException {
        throw new UnsupportedOperationException("isPackageQuarantined not implemented");
    }

    /**
     * Provide a hint of what the {@link ApplicationInfo#category} value should
     * be for the given package.
Loading