use of android.app.admin.DevicePolicyManager in project android_frameworks_base by crdroidandroid.
the class RestrictedLockUtils method getDeviceOwner.
public static EnforcedAdmin getDeviceOwner(Context context) {
final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (dpm == null) {
return null;
}
ComponentName adminComponent = dpm.getDeviceOwnerComponentOnAnyUser();
if (adminComponent != null) {
return new EnforcedAdmin(adminComponent, dpm.getDeviceOwnerUserId());
}
return null;
}
use of android.app.admin.DevicePolicyManager in project android_frameworks_base by crdroidandroid.
the class RestrictedLockUtils method checkIfAutoTimeRequired.
/**
* Checks if {@link android.app.admin.DevicePolicyManager#setAutoTimeRequired} is enforced
* on the device.
*
* @return EnforcedAdmin Object containing the device owner component and
* userId the device owner is running as, or {@code null} setAutoTimeRequired is not enforced.
*/
public static EnforcedAdmin checkIfAutoTimeRequired(Context context) {
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (dpm == null || !dpm.getAutoTimeRequired()) {
return null;
}
ComponentName adminComponent = dpm.getDeviceOwnerComponentOnCallingUser();
return new EnforcedAdmin(adminComponent, UserHandle.myUserId());
}
use of android.app.admin.DevicePolicyManager in project android_frameworks_base by crdroidandroid.
the class KeyguardBottomAreaView method isCameraDisabledByDpm.
private boolean isCameraDisabledByDpm() {
final DevicePolicyManager dpm = (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
if (dpm != null && mPhoneStatusBar != null) {
try {
final int userId = ActivityManagerNative.getDefault().getCurrentUser().id;
final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);
final boolean disabledBecauseKeyguardSecure = (disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0 && mPhoneStatusBar.isKeyguardSecure();
return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure;
} catch (RemoteException e) {
Log.e(TAG, "Can't get userId", e);
}
}
return false;
}
use of android.app.admin.DevicePolicyManager in project android_frameworks_base by crdroidandroid.
the class KeyguardUpdateMonitor method scheduleStrongAuthTimeout.
private void scheduleStrongAuthTimeout() {
final DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
long when = SystemClock.elapsedRealtime() + dpm.getRequiredStrongAuthTimeout(null, sCurrentUser);
Intent intent = new Intent(ACTION_STRONG_AUTH_TIMEOUT);
intent.putExtra(USER_ID, sCurrentUser);
PendingIntent sender = PendingIntent.getBroadcast(mContext, sCurrentUser, intent, PendingIntent.FLAG_CANCEL_CURRENT);
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, when, sender);
notifyStrongAuthStateChanged(sCurrentUser);
}
use of android.app.admin.DevicePolicyManager in project android_frameworks_base by crdroidandroid.
the class LockPatternUtils method saveLockPattern.
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
* @param savedPattern The previously saved pattern, converted to String format
* @param userId the user whose pattern is to be saved.
*/
public void saveLockPattern(List<LockPatternView.Cell> pattern, String savedPattern, int userId) {
try {
if (pattern == null || pattern.size() < MIN_LOCK_PATTERN_SIZE) {
throw new IllegalArgumentException("pattern must not be null and at least " + MIN_LOCK_PATTERN_SIZE + " dots long.");
}
setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId);
getLockSettings().setLockPattern(patternToString(pattern, userId), savedPattern, userId);
DevicePolicyManager dpm = getDevicePolicyManager();
// Update the device encryption password.
if (userId == UserHandle.USER_SYSTEM && LockPatternUtils.isDeviceEncryptionEnabled()) {
if (!shouldEncryptWithCredentials(true)) {
clearEncryptionPassword();
} else {
String stringPattern = patternToString(pattern, userId);
updateEncryptionPassword(StorageManager.CRYPT_TYPE_PATTERN, stringPattern);
}
}
setBoolean(PATTERN_EVER_CHOSEN_KEY, true, userId);
onAfterChangingPassword(userId);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't save lock pattern " + re);
}
}
Aggregations