Search in sources :

Example 71 with DevicePolicyManager

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;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ComponentName(android.content.ComponentName)

Example 72 with DevicePolicyManager

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());
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ComponentName(android.content.ComponentName)

Example 73 with DevicePolicyManager

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;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) RemoteException(android.os.RemoteException)

Example 74 with DevicePolicyManager

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);
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 75 with DevicePolicyManager

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);
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) RemoteException(android.os.RemoteException)

Aggregations

DevicePolicyManager (android.app.admin.DevicePolicyManager)159 ComponentName (android.content.ComponentName)45 UserManager (android.os.UserManager)29 UserInfo (android.content.pm.UserInfo)25 RemoteException (android.os.RemoteException)24 LockPatternUtils (com.android.internal.widget.LockPatternUtils)19 Intent (android.content.Intent)18 PackageManager (android.content.pm.PackageManager)14 PersistableBundle (android.os.PersistableBundle)8 PendingIntent (android.app.PendingIntent)6 IBinder (android.os.IBinder)6 UserHandle (android.os.UserHandle)6 IPackageManager (android.content.pm.IPackageManager)5 Uri (android.net.Uri)5 VrManagerInternal (com.android.server.vr.VrManagerInternal)5 ResolveInfo (android.content.pm.ResolveInfo)4 Point (android.graphics.Point)4 Binder (android.os.Binder)4 KeyStore (android.security.KeyStore)4 ArraySet (android.util.ArraySet)4