diff options
| author | Suprabh Shukla <suprabh@google.com> | 2018-12-12 16:01:41 +0000 |
|---|---|---|
| committer | Suprabh Shukla <suprabh@google.com> | 2018-12-18 01:32:00 +0000 |
| commit | 436d093ba3e9e32befeee080041bdf7ddbf8fe13 (patch) | |
| tree | 82b3d3c758d7fcf4257da7cf2b1c9d2e2956fae5 /core/java/android | |
| parent | 8823fa23327e15040188e821bda5f9e07990a943 (diff) | |
Refactoring canSuspendPackage to support batch queries
Taking a list of packages to reduce the number of IPCs the
client has to make.
Test: atest GtsSuspendAppsTestCases:SuspendPackagesTest
Bug: 120908380
Bug: 117968270
Change-Id: Ife7a6acfe2f21e7f4419bcf67630e7b8be50a560
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ApplicationPackageManager.java | 4 | ||||
| -rw-r--r-- | core/java/android/content/pm/IPackageManager.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageManager.java | 21 |
3 files changed, 14 insertions, 13 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 67d9ad6e93c6..e211ddd23a70 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -2275,9 +2275,9 @@ public class ApplicationPackageManager extends PackageManager { } @Override - public boolean canSuspendPackage(String packageName) { + public String[] getUnsuspendablePackages(String[] packageNames) { try { - return mPM.canSuspendPackageForUser(packageName, mContext.getUserId()); + return mPM.getUnsuspendablePackagesForUser(packageNames, mContext.getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index eea2b8873fe7..51f93fe0388a 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -276,7 +276,7 @@ interface IPackageManager { in PersistableBundle appExtras, in PersistableBundle launcherExtras, in SuspendDialogInfo dialogInfo, String callingPackage, int userId); - boolean canSuspendPackageForUser(String packageName, int userId); + String[] getUnsuspendablePackagesForUser(in String[] packageNames, int userId); boolean isPackageSuspendedForUser(String packageName, int userId); diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 34cdfee3f959..eca54e3b651d 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -5916,27 +5916,28 @@ public abstract class PackageManager { } /** - * Returns whether or not a given package can be suspended via a call to {@link + * Returns any packages in a given set of packages that cannot be suspended via a call to {@link * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, * SuspendDialogInfo) setPackagesSuspended}. The platform prevents suspending certain critical * packages to keep the device in a functioning state, e.g. the default dialer. * Apps need to hold {@link Manifest.permission#SUSPEND_APPS SUSPEND_APPS} to call this api. * * <p> - * Note that this set of critical packages can change with time, so <em>a value of {@code true} - * returned by this api does not guarantee that a following call to {@link - * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, - * SuspendDialogInfo) setPackagesSuspended} for the same package will succeed</em>, especially - * if considerable time elapsed between the two calls. + * Note that this set of critical packages can change with time, so even though a package name + * was not returned by this call, it does not guarantee that a subsequent call to + * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, + * SuspendDialogInfo) setPackagesSuspended} for that package will succeed, especially if + * significant time elapsed between the two calls. * - * @param packageName The package to check. - * @return {@code true} if the given package can be suspended, {@code false} otherwise. + * @param packageNames The packages to check. + * @return A list of packages that can not be currently suspended by the system. * @hide */ @SystemApi @RequiresPermission(Manifest.permission.SUSPEND_APPS) - public boolean canSuspendPackage(@NonNull String packageName) { - throw new UnsupportedOperationException("canSuspendPackage not implemented"); + @NonNull + public String[] getUnsuspendablePackages(@NonNull String[] packageNames) { + throw new UnsupportedOperationException("canSuspendPackages not implemented"); } /** |
