DO NOT MERGE Update current user for passwordEntry and restart input on user switch.
This prevents IME not working due to the passwordEntry input field drawn for a wrong user or due to having an invalid token. Test: Manual Bug: 168825956 Change-Id: I28e38a523e67011df680c9dfb21907047c0e3278
This commit is contained in:
@@ -21,10 +21,13 @@ import android.car.user.CarUserManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewRootImpl;
|
import android.view.ViewRootImpl;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -61,7 +64,7 @@ import dagger.Lazy;
|
|||||||
public class CarKeyguardViewController extends OverlayViewController implements
|
public class CarKeyguardViewController extends OverlayViewController implements
|
||||||
KeyguardViewController {
|
KeyguardViewController {
|
||||||
private static final String TAG = "CarKeyguardViewController";
|
private static final String TAG = "CarKeyguardViewController";
|
||||||
private static final boolean DEBUG = true;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
@@ -75,9 +78,10 @@ public class CarKeyguardViewController extends OverlayViewController implements
|
|||||||
private final DismissCallbackRegistry mDismissCallbackRegistry;
|
private final DismissCallbackRegistry mDismissCallbackRegistry;
|
||||||
private final ViewMediatorCallback mViewMediatorCallback;
|
private final ViewMediatorCallback mViewMediatorCallback;
|
||||||
private final CarNavigationBarController mCarNavigationBarController;
|
private final CarNavigationBarController mCarNavigationBarController;
|
||||||
|
private final InputMethodManager mInputMethodManager;
|
||||||
// Needed to instantiate mBouncer.
|
// Needed to instantiate mBouncer.
|
||||||
private final KeyguardBouncer.BouncerExpansionCallback
|
private final KeyguardBouncer.BouncerExpansionCallback mExpansionCallback =
|
||||||
mExpansionCallback = new KeyguardBouncer.BouncerExpansionCallback() {
|
new KeyguardBouncer.BouncerExpansionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onFullyShown() {
|
public void onFullyShown() {
|
||||||
}
|
}
|
||||||
@@ -96,7 +100,8 @@ public class CarKeyguardViewController extends OverlayViewController implements
|
|||||||
};
|
};
|
||||||
private final CarUserManager.UserLifecycleListener mUserLifecycleListener = (e) -> {
|
private final CarUserManager.UserLifecycleListener mUserLifecycleListener = (e) -> {
|
||||||
if (e.getEventType() == CarUserManager.USER_LIFECYCLE_EVENT_TYPE_SWITCHING) {
|
if (e.getEventType() == CarUserManager.USER_LIFECYCLE_EVENT_TYPE_SWITCHING) {
|
||||||
revealKeyguardIfBouncerPrepared();
|
UserHandle currentUser = e.getUserHandle();
|
||||||
|
revealKeyguardIfBouncerPrepared(currentUser);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,6 +141,8 @@ public class CarKeyguardViewController extends OverlayViewController implements
|
|||||||
mDismissCallbackRegistry = dismissCallbackRegistry;
|
mDismissCallbackRegistry = dismissCallbackRegistry;
|
||||||
mViewMediatorCallback = viewMediatorCallback;
|
mViewMediatorCallback = viewMediatorCallback;
|
||||||
mCarNavigationBarController = carNavigationBarController;
|
mCarNavigationBarController = carNavigationBarController;
|
||||||
|
// TODO(b/169280588): Inject InputMethodManager instead.
|
||||||
|
mInputMethodManager = mContext.getSystemService(InputMethodManager.class);
|
||||||
|
|
||||||
registerUserSwitchedListener();
|
registerUserSwitchedListener();
|
||||||
}
|
}
|
||||||
@@ -376,7 +383,7 @@ public class CarKeyguardViewController extends OverlayViewController implements
|
|||||||
mBouncer = keyguardBouncer;
|
mBouncer = keyguardBouncer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void revealKeyguardIfBouncerPrepared() {
|
private void revealKeyguardIfBouncerPrepared(UserHandle currentUser) {
|
||||||
int reattemptDelayMillis = 50;
|
int reattemptDelayMillis = 50;
|
||||||
Runnable revealKeyguard = () -> {
|
Runnable revealKeyguard = () -> {
|
||||||
if (mBouncer == null) {
|
if (mBouncer == null) {
|
||||||
@@ -388,17 +395,29 @@ public class CarKeyguardViewController extends OverlayViewController implements
|
|||||||
}
|
}
|
||||||
if (!mBouncer.inTransit() || !mBouncer.isSecure()) {
|
if (!mBouncer.inTransit() || !mBouncer.isSecure()) {
|
||||||
getLayout().setVisibility(View.VISIBLE);
|
getLayout().setVisibility(View.VISIBLE);
|
||||||
|
updateCurrentUserForPasswordEntry(currentUser);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "revealKeyguardIfBouncerPrepared: Bouncer is not prepared "
|
Log.d(TAG, "revealKeyguardIfBouncerPrepared: Bouncer is not prepared "
|
||||||
+ "yet so reattempting after " + reattemptDelayMillis + "ms.");
|
+ "yet so reattempting after " + reattemptDelayMillis + "ms.");
|
||||||
}
|
}
|
||||||
mHandler.postDelayed(this::revealKeyguardIfBouncerPrepared, reattemptDelayMillis);
|
mHandler.postDelayed(() -> revealKeyguardIfBouncerPrepared(currentUser),
|
||||||
|
reattemptDelayMillis);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mHandler.post(revealKeyguard);
|
mHandler.post(revealKeyguard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCurrentUserForPasswordEntry(UserHandle currentUser) {
|
||||||
|
EditText passwordEntry = getLayout().findViewById(R.id.passwordEntry);
|
||||||
|
if (passwordEntry != null) {
|
||||||
|
mHandler.post(() -> {
|
||||||
|
mInputMethodManager.restartInput(passwordEntry);
|
||||||
|
passwordEntry.setTextOperationUser(currentUser);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyKeyguardUpdateMonitor() {
|
private void notifyKeyguardUpdateMonitor() {
|
||||||
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(mShowing);
|
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(mShowing);
|
||||||
if (mBouncer != null) {
|
if (mBouncer != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user