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

Commit f02420c5 authored by Benjamin Franz's avatar Benjamin Franz
Browse files

Maybe decrypt user when quiet mode is disabled

When quiet mode is disabled for a user and that user is not currently
decrypted, we show a confirm credentials screen to trigger decryption
of that user. Only if that was successful, do we actually disable quiet
mode.

Bug: 27764124
Change-Id: Ib1f649194d89e225dad62c14f3ddba1fa3d79da2
parent bb9fb194
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package android.os;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.content.pm.UserInfo;
import android.content.IntentSender;
import android.content.RestrictionEntry;
import android.graphics.Bitmap;
import android.os.ParcelFileDescriptor;
@@ -70,6 +71,7 @@ interface IUserManager {
    boolean markGuestForDeletion(int userHandle);
    void setQuietModeEnabled(int userHandle, boolean enableQuietMode);
    boolean isQuietModeEnabled(int userHandle);
    boolean trySetQuietModeDisabled(int userHandle, in IntentSender target);
    void setSeedAccountData(int userHandle, in String accountName,
            in String accountType, in PersistableBundle accountOptions, boolean persist);
    String getSeedAccountName();
+18 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -1690,6 +1691,23 @@ public class UserManager {
        }
    }

    /**
     * Tries disabling quiet mode for a given user. If the user is still locked, we unlock the user
     * first by showing the confirm credentials screen and disable quiet mode upon successful
     * unlocking. If the user is already unlocked, we call through to {@link #setQuietModeEnabled}
     * directly.
     *
     * @return true if the quiet mode was disabled immediately
     * @hide
     */
    public boolean trySetQuietModeDisabled(@UserIdInt int userHandle, IntentSender target) {
        try {
            return mService.trySetQuietModeDisabled(userHandle, target);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * If the target user is a managed profile of the calling user or the caller
     * is itself a managed profile, then this returns a badged copy of the given
+2 −3
Original line number Diff line number Diff line
@@ -107,9 +107,8 @@ public class UnlaunchableAppActivity extends Activity
    @Override
    public void onClick(DialogInterface dialog, int which) {
        if (mReason == UNLAUNCHABLE_REASON_QUIET_MODE && which == DialogInterface.BUTTON_POSITIVE) {
            UserManager.get(this).setQuietModeEnabled(mUserId, false);

            if (mTarget != null) {
            if (UserManager.get(this).trySetQuietModeDisabled(mUserId, mTarget)
                    && mTarget != null) {
                try {
                    startIntentSenderForResult(mTarget, -1, null, 0, 0, 0);
                } catch (IntentSender.SendIntentException e) {
+11 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
package com.android.systemui.statusbar.phone;

import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -57,10 +58,18 @@ public class ManagedProfileController {
        }
    }

    public void setWorkModeEnabled(boolean enabled) {
    public void setWorkModeEnabled(boolean enableWorkMode) {
        synchronized (mProfiles) {
            for (UserInfo ui : mProfiles) {
                mUserManager.setQuietModeEnabled(ui.id, !enabled);
                if (enableWorkMode) {
                    if (!mUserManager.trySetQuietModeDisabled(ui.id, null)) {
                        StatusBarManager statusBarManager = (StatusBarManager) mContext
                                .getSystemService(android.app.Service.STATUS_BAR_SERVICE);
                        statusBarManager.collapsePanels();
                    }
                } else {
                    mUserManager.setQuietModeEnabled(ui.id, true);
                }
            }
        }
    }
+6 −0
Original line number Diff line number Diff line
@@ -702,6 +702,12 @@ public class LockSettingsService extends ILockSettings.Stub {
            }
        };

        // Check if the user is currently in quiet mode and start it otherwise
        if (mUserManager.isQuietModeEnabled(new UserHandle(userId))
                && mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
            mUserManager.setQuietModeEnabled(userId, false);
        }

        try {
            ActivityManagerNative.getDefault().unlockUser(userId, token, secret, listener);
        } catch (RemoteException e) {
Loading