Adding LauncherApps apis for suspended packages
The suspending app can provide a Bundle of information to be used by the
launcher for handling suspended packages. Added APIs:
- getSuspendedPackageLauncherExtras(String, UserHandle): To retrieve
the launcher extras for the given package and user.
- Callback#onPackagesSuspended(String[], UserHandle, Bundle): A
callback that will be invoked with the package names and the launcher
extras whenever sent packages are suspended.
Test: atest com.android.server.pm.SuspendPackagesTest
Bug: 76119578
Change-Id: I505d134809639a57c3314f994af34d576d905e74
diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java
index dff51f7..c9b78c0 100644
--- a/core/java/android/content/pm/PackageManagerInternal.java
+++ b/core/java/android/content/pm/PackageManagerInternal.java
@@ -26,6 +26,7 @@
import android.content.pm.PackageManager.PackageInfoFlags;
import android.content.pm.PackageManager.ResolveInfoFlags;
import android.os.Bundle;
+import android.os.PersistableBundle;
import android.util.SparseArray;
import java.lang.annotation.Retention;
@@ -188,6 +189,22 @@
@PackageInfoFlags int flags, int filterCallingUid, int userId);
/**
+ * Retrieve launcher extras for a suspended package provided to the system in
+ * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
+ * PersistableBundle, String)}
+ *
+ * @param packageName The package for which to return launcher extras.
+ * @param userId The user for which to check,
+ * @return The launcher extras.
+ *
+ * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
+ * PersistableBundle, String)
+ * @see PackageManager#isPackageSuspended()
+ */
+ public abstract Bundle getSuspendedPackageLauncherExtras(String packageName,
+ int userId);
+
+ /**
* Do a straight uid lookup for the given package/application in the given user.
* @see PackageManager#getPackageUidAsUser(String, int, int)
* @return The app's uid, or < 0 if the package was not found in that user