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;
}
/**
+ * 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.