Search in sources :

Example 46 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by DirtyUnicorns.

the class RestrictedLockUtils method checkIfRemoteContactSearchDisallowed.

/**
     * @param context
     * @param userId user id of a managed profile.
     * @return is remote contacts search disallowed.
     */
public static EnforcedAdmin checkIfRemoteContactSearchDisallowed(Context context, int userId) {
    DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (dpm == null) {
        return null;
    }
    EnforcedAdmin admin = getProfileOwner(context, userId);
    if (admin == null) {
        return null;
    }
    UserHandle userHandle = UserHandle.of(userId);
    if (dpm.getCrossProfileContactsSearchDisabled(userHandle) && dpm.getCrossProfileCallerIdDisabled(userHandle)) {
        return admin;
    }
    return null;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) UserHandle(android.os.UserHandle)

Example 47 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by DirtyUnicorns.

the class RestrictedLockUtils method checkIfInputMethodDisallowed.

public static EnforcedAdmin checkIfInputMethodDisallowed(Context context, String packageName, int userId) {
    DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (dpm == null) {
        return null;
    }
    EnforcedAdmin admin = getProfileOrDeviceOwner(context, userId);
    boolean permitted = true;
    if (admin != null) {
        permitted = dpm.isInputMethodPermittedByAdmin(admin.component, packageName, userId);
    }
    int managedProfileId = getManagedProfileId(context, userId);
    EnforcedAdmin profileAdmin = getProfileOrDeviceOwner(context, managedProfileId);
    boolean permittedByProfileAdmin = true;
    if (profileAdmin != null) {
        permittedByProfileAdmin = dpm.isInputMethodPermittedByAdmin(profileAdmin.component, packageName, managedProfileId);
    }
    if (!permitted && !permittedByProfileAdmin) {
        return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
    } else if (!permitted) {
        return admin;
    } else if (!permittedByProfileAdmin) {
        return profileAdmin;
    }
    return null;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager)

Example 48 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by DirtyUnicorns.

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 49 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by DirtyUnicorns.

the class RestrictedLockUtils method isAdminInCurrentUserOrProfile.

public static boolean isAdminInCurrentUserOrProfile(Context context, ComponentName admin) {
    DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    UserManager um = UserManager.get(context);
    for (UserInfo userInfo : um.getProfiles(UserHandle.myUserId())) {
        if (dpm.isAdminActiveAsUser(admin, userInfo.id)) {
            return true;
        }
    }
    return false;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 50 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by DirtyUnicorns.

the class RestrictedLockUtils method checkIfAccessibilityServiceDisallowed.

public static EnforcedAdmin checkIfAccessibilityServiceDisallowed(Context context, String packageName, int userId) {
    DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (dpm == null) {
        return null;
    }
    EnforcedAdmin admin = getProfileOrDeviceOwner(context, userId);
    boolean permitted = true;
    if (admin != null) {
        permitted = dpm.isAccessibilityServicePermittedByAdmin(admin.component, packageName, userId);
    }
    int managedProfileId = getManagedProfileId(context, userId);
    EnforcedAdmin profileAdmin = getProfileOrDeviceOwner(context, managedProfileId);
    boolean permittedByProfileAdmin = true;
    if (profileAdmin != null) {
        permittedByProfileAdmin = dpm.isAccessibilityServicePermittedByAdmin(profileAdmin.component, packageName, managedProfileId);
    }
    if (!permitted && !permittedByProfileAdmin) {
        return EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN;
    } else if (!permitted) {
        return admin;
    } else if (!permittedByProfileAdmin) {
        return profileAdmin;
    }
    return null;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager)

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