Loading api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1206,6 +1206,7 @@ package android.content.pm { public abstract class PackageManager { method public abstract void addOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener); method public abstract boolean arePermissionsIndividuallyControlled(); method public boolean canSuspendPackage(java.lang.String); method public abstract java.util.List<android.content.IntentFilter> getAllIntentFilters(java.lang.String); method public android.content.pm.dex.ArtManager getArtManager(); method public abstract java.lang.String getDefaultBrowserPackageNameAsUser(int); Loading core/java/android/app/ApplicationPackageManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -2276,6 +2276,15 @@ public class ApplicationPackageManager extends PackageManager { } } @Override public boolean canSuspendPackage(String packageName) { try { return mPM.canSuspendPackageForUser(packageName, mContext.getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Override public Bundle getSuspendedPackageAppExtras() { final PersistableBundle extras; Loading core/java/android/content/pm/IPackageManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -276,6 +276,8 @@ interface IPackageManager { in PersistableBundle appExtras, in PersistableBundle launcherExtras, in SuspendDialogInfo dialogInfo, String callingPackage, int userId); boolean canSuspendPackageForUser(String packageName, int userId); boolean isPackageSuspendedForUser(String packageName, int userId); PersistableBundle getSuspendedPackageAppExtras(String packageName, int userId); Loading core/java/android/content/pm/PackageManager.java +24 −0 Original line number Diff line number Diff line Loading @@ -5796,6 +5796,30 @@ public abstract class PackageManager { throw new UnsupportedOperationException("setPackagesSuspended not implemented"); } /** * Returns whether or not a given package can 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. * * @param packageName The package to check. * @return {@code true} if the given package can be suspended, {@code false} otherwise. * @hide */ @SystemApi @RequiresPermission(Manifest.permission.SUSPEND_APPS) public boolean canSuspendPackage(@NonNull String packageName) { throw new UnsupportedOperationException("canSuspendPackage not implemented"); } /** * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) * @param packageName The name of the package to get the suspended status of. Loading services/core/java/com/android/server/pm/PackageManagerService.java +20 −1 Original line number Diff line number Diff line Loading @@ -12937,6 +12937,25 @@ public class PackageManagerService extends IPackageManager.Stub } } @Override public boolean canSuspendPackageForUser(String packageName, int userId) { mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS, "canSuspendPackageForUser"); final int callingUid = Binder.getCallingUid(); if (UserHandle.getUserId(callingUid) != userId) { throw new SecurityException("Calling uid " + callingUid + " cannot query canSuspendPackageForUser for user " + userId); } final long identity = Binder.clearCallingIdentity(); try { synchronized (mPackages) { return canSuspendPackageForUserLocked(packageName, userId); } } finally { Binder.restoreCallingIdentity(identity); } } @GuardedBy("mPackages") private boolean canSuspendPackageForUserLocked(String packageName, int userId) { if (isPackageDeviceAdmin(packageName, userId)) { Loading Loading @@ -13000,7 +13019,7 @@ public class PackageManagerService extends IPackageManager.Stub } if (PLATFORM_PACKAGE_NAME.equals(packageName)) { Slog.w(TAG, "Cannot suspend package: " + packageName); Slog.w(TAG, "Cannot suspend the platform package: " + packageName); return false; } Loading
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1206,6 +1206,7 @@ package android.content.pm { public abstract class PackageManager { method public abstract void addOnPermissionsChangeListener(android.content.pm.PackageManager.OnPermissionsChangedListener); method public abstract boolean arePermissionsIndividuallyControlled(); method public boolean canSuspendPackage(java.lang.String); method public abstract java.util.List<android.content.IntentFilter> getAllIntentFilters(java.lang.String); method public android.content.pm.dex.ArtManager getArtManager(); method public abstract java.lang.String getDefaultBrowserPackageNameAsUser(int); Loading
core/java/android/app/ApplicationPackageManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -2276,6 +2276,15 @@ public class ApplicationPackageManager extends PackageManager { } } @Override public boolean canSuspendPackage(String packageName) { try { return mPM.canSuspendPackageForUser(packageName, mContext.getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Override public Bundle getSuspendedPackageAppExtras() { final PersistableBundle extras; Loading
core/java/android/content/pm/IPackageManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -276,6 +276,8 @@ interface IPackageManager { in PersistableBundle appExtras, in PersistableBundle launcherExtras, in SuspendDialogInfo dialogInfo, String callingPackage, int userId); boolean canSuspendPackageForUser(String packageName, int userId); boolean isPackageSuspendedForUser(String packageName, int userId); PersistableBundle getSuspendedPackageAppExtras(String packageName, int userId); Loading
core/java/android/content/pm/PackageManager.java +24 −0 Original line number Diff line number Diff line Loading @@ -5796,6 +5796,30 @@ public abstract class PackageManager { throw new UnsupportedOperationException("setPackagesSuspended not implemented"); } /** * Returns whether or not a given package can 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. * * @param packageName The package to check. * @return {@code true} if the given package can be suspended, {@code false} otherwise. * @hide */ @SystemApi @RequiresPermission(Manifest.permission.SUSPEND_APPS) public boolean canSuspendPackage(@NonNull String packageName) { throw new UnsupportedOperationException("canSuspendPackage not implemented"); } /** * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) * @param packageName The name of the package to get the suspended status of. Loading
services/core/java/com/android/server/pm/PackageManagerService.java +20 −1 Original line number Diff line number Diff line Loading @@ -12937,6 +12937,25 @@ public class PackageManagerService extends IPackageManager.Stub } } @Override public boolean canSuspendPackageForUser(String packageName, int userId) { mContext.enforceCallingOrSelfPermission(Manifest.permission.SUSPEND_APPS, "canSuspendPackageForUser"); final int callingUid = Binder.getCallingUid(); if (UserHandle.getUserId(callingUid) != userId) { throw new SecurityException("Calling uid " + callingUid + " cannot query canSuspendPackageForUser for user " + userId); } final long identity = Binder.clearCallingIdentity(); try { synchronized (mPackages) { return canSuspendPackageForUserLocked(packageName, userId); } } finally { Binder.restoreCallingIdentity(identity); } } @GuardedBy("mPackages") private boolean canSuspendPackageForUserLocked(String packageName, int userId) { if (isPackageDeviceAdmin(packageName, userId)) { Loading Loading @@ -13000,7 +13019,7 @@ public class PackageManagerService extends IPackageManager.Stub } if (PLATFORM_PACKAGE_NAME.equals(packageName)) { Slog.w(TAG, "Cannot suspend package: " + packageName); Slog.w(TAG, "Cannot suspend the platform package: " + packageName); return false; }