Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46333ca6 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by android-build-merger
Browse files

Merge "Merge "Avoid triggering support dialog in non-current user." into...

Merge "Merge "Avoid triggering support dialog in non-current user." into nyc-dev am: 5548733e am: 8ebc6e80" into nyc-mr1-dev-plus-aosp
am: c56c3217

* commit 'c56c3217':
  Avoid triggering support dialog in non-current user.

Change-Id: Ia9e7deb6bbd314d64ac2551241a73fbaad38b793
parents 4a1cee40 c56c3217
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -616,11 +616,12 @@ public class RestrictedLockUtils {
     */
    public static void sendShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
        final Intent intent = getShowAdminSupportDetailsIntent(context, admin);
        int adminUserId = UserHandle.myUserId();
        if (admin.userId != UserHandle.USER_NULL) {
            adminUserId = admin.userId;
        int targetUserId = UserHandle.myUserId();
        if (admin != null && admin.userId != UserHandle.USER_NULL
                && isCurrentUserOrProfile(context, admin.userId)) {
            targetUserId = admin.userId;
        }
        context.startActivityAsUser(intent, new UserHandle(adminUserId));
        context.startActivityAsUser(intent, new UserHandle(targetUserId));
    }

    public static Intent getShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
@@ -638,6 +639,28 @@ public class RestrictedLockUtils {
        return intent;
    }

    public static boolean isCurrentUserOrProfile(Context context, int userId) {
        UserManager um = UserManager.get(context);
        for (UserInfo userInfo : um.getProfiles(UserHandle.myUserId())) {
            if (userInfo.id == userId) {
                return true;
            }
        }
        return false;
    }

    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;
    }

    public static void setTextViewPadlock(Context context,
            TextView textView, boolean showPadlock) {
        final SpannableStringBuilder sb = new SpannableStringBuilder(textView.getText());