From 6266baa5df86ef27c305b36bd495f93904e90526 Mon Sep 17 00:00:00 2001 From: Eran Messeri Date: Thu, 7 May 2020 16:43:09 +0100 Subject: [PATCH] Unlock the work profile for remote input This change addresses the following scenario: * The device has a managed profile. * The managed profile has a separate challenge from the primary profile (i.e. not a unified challenge). * The user gets a notification from the managed profile. * The notification offers the ability to reply from the lockscreen (e.g. reply to a chat message from the managed profile). In that case, the user should be required to unlock both the primary lockscreen and the managed profile lockscreen, before they can use the inline reply feature. But prior to this change, the user is only asked to unlock the primary lockscreen and then can not proceed. Change the code that handles this scenario to differentiate between unlocking the primary user and unlocking the managed profile by evaluating whether the parent user of the managed profile is locked or not. If the work profile is locked but the primary user is not, then the callback to unlock the work profile is called. Testng steps: * Set up a device with a work profile. * Set a separate challenge to the work profile. * Send a Chat or Hangouts message to the account in the work profile. * From the lockscreen, or notification shade, expand the notification and tap reply. * Observe the user has to unlock twice and gets to enter the reply. Test: Manual (See above) Bug: 149218396 Change-Id: Iea13d08b9fc2d541b78c03d7e695461eb57496b9 --- .../NotificationRemoteInputManager.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index 9181c69e3722a..7d169ecf02dec 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -28,6 +28,7 @@ import android.app.RemoteInput; import android.app.RemoteInputHistoryItem; import android.content.Context; import android.content.Intent; +import android.content.pm.UserInfo; import android.net.Uri; import android.os.Handler; import android.os.RemoteException; @@ -401,15 +402,35 @@ public class NotificationRemoteInputManager implements Dumpable { if (!mLockscreenUserManager.shouldAllowLockscreenRemoteInput()) { final int userId = pendingIntent.getCreatorUserHandle().getIdentifier(); + + final boolean isLockedManagedProfile = + mUserManager.getUserInfo(userId).isManagedProfile() + && mKeyguardManager.isDeviceLocked(userId); + + final boolean isParentUserLocked; + if (isLockedManagedProfile) { + final UserInfo profileParent = mUserManager.getProfileParent(userId); + isParentUserLocked = (profileParent != null) + && mKeyguardManager.isDeviceLocked(profileParent.id); + } else { + isParentUserLocked = false; + } + if (mLockscreenUserManager.isLockscreenPublicMode(userId) || mStatusBarStateController.getState() == StatusBarState.KEYGUARD) { - // Even if we don't have security we should go through this flow, otherwise we won't - // go to the shade - mCallback.onLockedRemoteInput(row, view); + // If the parent user is no longer locked, and the user to which the remote input + // is destined is a locked, managed profile, then onLockedWorkRemoteInput should be + // called to unlock it. + if (isLockedManagedProfile && !isParentUserLocked) { + mCallback.onLockedWorkRemoteInput(userId, row, view); + } else { + // Even if we don't have security we should go through this flow, otherwise + // we won't go to the shade. + mCallback.onLockedRemoteInput(row, view); + } return true; } - if (mUserManager.getUserInfo(userId).isManagedProfile() - && mKeyguardManager.isDeviceLocked(userId)) { + if (isLockedManagedProfile) { mCallback.onLockedWorkRemoteInput(userId, row, view); return true; }