diff options
| author | 2016-01-28 21:01:52 +0000 | |
|---|---|---|
| committer | 2016-01-28 21:01:53 +0000 | |
| commit | 30c33e09b641b529bbc6a4034577a8b002c17f5b (patch) | |
| tree | b854e3fbfdef33becefe8d84631e670639fa0f49 | |
| parent | a74cce60721d2d2de04778eabab31a7aef8117d4 (diff) | |
| parent | 44af4828c3fffd7d69074b861b96216eea3eb971 (diff) | |
Merge "RestrictedLockUtils - introduce check for suspended apps"
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java index ad567d31ec37..210682f9cd80 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java @@ -21,6 +21,7 @@ import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.UserInfo; import android.graphics.Color; @@ -227,6 +228,26 @@ public class RestrictedLockUtils { } /** + * Check if an application is suspended. + * + * @return EnforcedAdmin Object containing the enforced admin component and admin user details, + * or {@code null} if the application is not suspended. + */ + public static EnforcedAdmin checkIfApplicationIsSuspended(Context context, String packageName, + int userId) { + IPackageManager ipm = AppGlobals.getPackageManager(); + try { + ApplicationInfo ai = ipm.getApplicationInfo(packageName, 0, userId); + if (ai != null && ((ai.flags & ApplicationInfo.FLAG_SUSPENDED) != 0)) { + return getProfileOrDeviceOwnerOnCallingUser(context); + } + } catch (RemoteException e) { + // Nothing to do + } + return null; + } + + /** * Check if account management for a specific type of account is disabled by admin. * Only a profile or device owner can disable account management. So, we check if account * management is disabled and return profile or device owner on the calling user. |