public class RestrictedLockUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RestrictedLockUtils.EnforcedAdmin |
Constructor and Description |
---|
RestrictedLockUtils() |
Modifier and Type | Method and Description |
---|---|
static RestrictedLockUtils.EnforcedAdmin |
checkIfAccessibilityServiceDisallowed(Context context,
String packageName,
int userId) |
static RestrictedLockUtils.EnforcedAdmin |
checkIfAccountManagementDisabled(Context context,
String accountType,
int userId)
Check if account management for a specific type of account is disabled by admin.
|
static RestrictedLockUtils.EnforcedAdmin |
checkIfApplicationIsSuspended(Context context,
String packageName,
int userId)
Check if an application is suspended.
|
static RestrictedLockUtils.EnforcedAdmin |
checkIfAutoTimeRequired(Context context)
Checks if
DevicePolicyManager.setAutoTimeRequired(android.content.ComponentName, boolean) is enforced
on the device. |
static RestrictedLockUtils.EnforcedAdmin |
checkIfInputMethodDisallowed(Context context,
String packageName,
int userId) |
static RestrictedLockUtils.EnforcedAdmin |
checkIfKeyguardFeaturesDisabled(Context context,
int keyguardFeatures,
int userId)
Checks if keyguard features are disabled by policy.
|
static RestrictedLockUtils.EnforcedAdmin |
checkIfMaximumTimeToLockIsSet(Context context)
Checks if any admin has set maximum time to lock.
|
static RestrictedLockUtils.EnforcedAdmin |
checkIfPasswordQualityIsSet(Context context,
int userId)
Checks if an admin has enforced minimum password quality requirements on the given user.
|
static RestrictedLockUtils.EnforcedAdmin |
checkIfRemoteContactSearchDisallowed(Context context,
int userId) |
static RestrictedLockUtils.EnforcedAdmin |
checkIfRestrictionEnforced(Context context,
String userRestriction,
int userId)
Checks if a restriction is enforced on a user and returns the enforced admin and
admin userId.
|
static RestrictedLockUtils.EnforcedAdmin |
checkIfUninstallBlocked(Context context,
String packageName,
int userId) |
static RestrictedLockUtils.EnforcedAdmin |
getDeviceOwner(Context context) |
static RestrictedLockUtils.EnforcedAdmin |
getProfileOrDeviceOwner(Context context,
int userId) |
static Drawable |
getRestrictedPadlock(Context context) |
static Intent |
getShowAdminSupportDetailsIntent(Context context,
RestrictedLockUtils.EnforcedAdmin admin) |
static boolean |
hasBaseUserRestriction(Context context,
String userRestriction,
int userId) |
static boolean |
isAdminInCurrentUserOrProfile(Context context,
ComponentName admin) |
static boolean |
isCurrentUserOrProfile(Context context,
int userId) |
static void |
sendShowAdminSupportDetailsIntent(Context context,
RestrictedLockUtils.EnforcedAdmin admin)
Send the intent to trigger the
android.settings.ShowAdminSupportDetailsDialog . |
static void |
setMenuItemAsDisabledByAdmin(Context context,
MenuItem item,
RestrictedLockUtils.EnforcedAdmin admin)
Set the menu item as disabled by admin by adding a restricted padlock at the end of the
text and set the click listener which will send an intent to show the admin support details
dialog.
|
static void |
setTextViewAsDisabledByAdmin(Context context,
TextView textView,
boolean disabled)
Takes a
TextView and applies an alpha so that the text looks like
disabled and appends a padlock to the text. |
static void |
setTextViewPadlock(Context context,
TextView textView,
boolean showPadlock) |
public static Drawable getRestrictedPadlock(Context context)
public static RestrictedLockUtils.EnforcedAdmin checkIfRestrictionEnforced(Context context, String userRestriction, int userId)
userRestriction
- Restriction to checkuserId
- User which we need to check if restriction is enforced on.null
If the restriction is not set. If the restriction is set by both device owner
and profile owner, then the admin component will be set to null
and userId to
UserHandle.USER_NULL
.public static boolean hasBaseUserRestriction(Context context, String userRestriction, int userId)
public static RestrictedLockUtils.EnforcedAdmin checkIfKeyguardFeaturesDisabled(Context context, int keyguardFeatures, int userId)
keyguardFeatures
- Could be any of keyguard features that can be
disabled by DevicePolicyManager.setKeyguardDisabledFeatures(android.content.ComponentName, int)
.null
If the notification features are not disabled. If the restriction is set by
multiple admins, then the admin component will be set to null
and userId to
UserHandle.USER_NULL
.public static RestrictedLockUtils.EnforcedAdmin checkIfUninstallBlocked(Context context, String packageName, int userId)
public static RestrictedLockUtils.EnforcedAdmin checkIfApplicationIsSuspended(Context context, String packageName, int userId)
null
if the application is not suspended.public static RestrictedLockUtils.EnforcedAdmin checkIfInputMethodDisallowed(Context context, String packageName, int userId)
public static RestrictedLockUtils.EnforcedAdmin checkIfRemoteContactSearchDisallowed(Context context, int userId)
context
- userId
- user id of a managed profile.public static RestrictedLockUtils.EnforcedAdmin checkIfAccessibilityServiceDisallowed(Context context, String packageName, int userId)
public static RestrictedLockUtils.EnforcedAdmin checkIfAccountManagementDisabled(Context context, String accountType, int userId)
null
if the account management is not disabled.public static RestrictedLockUtils.EnforcedAdmin checkIfAutoTimeRequired(Context context)
DevicePolicyManager.setAutoTimeRequired(android.content.ComponentName, boolean)
is enforced
on the device.null
setAutoTimeRequired is not enforced.public static RestrictedLockUtils.EnforcedAdmin checkIfPasswordQualityIsSet(Context context, int userId)
null
if no quality requirements are set. If the requirements are set by
multiple device admins, then the admin component will be set to null
and userId to
UserHandle.USER_NULL
.public static RestrictedLockUtils.EnforcedAdmin checkIfMaximumTimeToLockIsSet(Context context)
null
if no admin has set this restriction. If multiple admins has set this, then
the admin component will be set to null
and userId to UserHandle.USER_NULL
public static RestrictedLockUtils.EnforcedAdmin getProfileOrDeviceOwner(Context context, int userId)
public static RestrictedLockUtils.EnforcedAdmin getDeviceOwner(Context context)
public static void setMenuItemAsDisabledByAdmin(Context context, MenuItem item, RestrictedLockUtils.EnforcedAdmin admin)
public static void sendShowAdminSupportDetailsIntent(Context context, RestrictedLockUtils.EnforcedAdmin admin)
android.settings.ShowAdminSupportDetailsDialog
.public static Intent getShowAdminSupportDetailsIntent(Context context, RestrictedLockUtils.EnforcedAdmin admin)
public static boolean isCurrentUserOrProfile(Context context, int userId)
public static boolean isAdminInCurrentUserOrProfile(Context context, ComponentName admin)
public static void setTextViewPadlock(Context context, TextView textView, boolean showPadlock)
public static void setTextViewAsDisabledByAdmin(Context context, TextView textView, boolean disabled)
TextView
and applies an alpha so that the text looks like
disabled and appends a padlock to the text. This assumes that there are no
ForegroundColorSpans and RestrictedLockImageSpans used on the TextView.