Merge "Remote mCurClientInKeyguard dependency in IMMS"
This commit is contained in:
@@ -97,6 +97,7 @@ import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
import android.view.WindowInsetsController.Behavior;
|
||||
import android.view.WindowManager;
|
||||
@@ -901,7 +902,17 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
||||
if (displayId != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0;
|
||||
boolean imeVisibleOnShade = mStatusBarOptionalLazy.get().map(statusBar -> {
|
||||
View shadeWindowView = statusBar.getNotificationShadeWindowView();
|
||||
return shadeWindowView.isAttachedToWindow()
|
||||
&& shadeWindowView.getRootWindowInsets().isVisible(WindowInsets.Type.ime());
|
||||
}).orElse(false);
|
||||
boolean isKeyguardShowing = mStatusBarOptionalLazy.get().map(
|
||||
StatusBar::isKeyguardShowing).orElse(false);
|
||||
boolean imeShown = imeVisibleOnShade
|
||||
|| (!isKeyguardShowing && (vis & InputMethodService.IME_VISIBLE) != 0);
|
||||
showImeSwitcher = imeShown && showImeSwitcher;
|
||||
|
||||
int hints = Utilities.calculateBackDispositionHints(mNavigationIconHints, backDisposition,
|
||||
imeShown, showImeSwitcher);
|
||||
if (hints == mNavigationIconHints) return;
|
||||
|
||||
@@ -23,17 +23,20 @@ import static android.inputmethodservice.InputMethodService.IME_INVISIBLE;
|
||||
import static android.inputmethodservice.InputMethodService.IME_VISIBLE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
||||
import static android.view.WindowInsets.Type.ime;
|
||||
|
||||
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS;
|
||||
import static com.android.systemui.navigationbar.NavigationBar.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -57,6 +60,7 @@ import android.view.Display;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowMetrics;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
@@ -83,6 +87,7 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.phone.AutoHideController;
|
||||
import com.android.systemui.statusbar.phone.LightBarController;
|
||||
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
|
||||
import com.android.systemui.statusbar.phone.ShadeController;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
@@ -148,6 +153,8 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
private InputMethodManager mInputMethodManager;
|
||||
@Mock
|
||||
private AssistManager mAssistManager;
|
||||
@Mock
|
||||
private StatusBar mStatusBar;
|
||||
|
||||
@Rule
|
||||
public final LeakCheckedTest.SysuiLeakCheck mLeakCheck = new LeakCheckedTest.SysuiLeakCheck();
|
||||
@@ -255,6 +262,11 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
// Create default & external NavBar fragment.
|
||||
NavigationBar defaultNavBar = mNavigationBar;
|
||||
NavigationBar externalNavBar = mExternalDisplayNavigationBar;
|
||||
NotificationShadeWindowView mockShadeWindowView = mock(NotificationShadeWindowView.class);
|
||||
WindowInsets windowInsets = new WindowInsets.Builder().setVisible(ime(), false).build();
|
||||
doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets();
|
||||
doReturn(mockShadeWindowView).when(mStatusBar).getNotificationShadeWindowView();
|
||||
doReturn(true).when(mockShadeWindowView).isAttachedToWindow();
|
||||
doNothing().when(defaultNavBar).checkNavBarModes();
|
||||
doNothing().when(externalNavBar).checkNavBarModes();
|
||||
defaultNavBar.createView(null);
|
||||
@@ -280,6 +292,40 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
assertFalse((defaultNavBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetImeWindowStatusWhenKeyguardLockingAndImeInsetsChange() {
|
||||
NotificationShadeWindowView mockShadeWindowView = mock(NotificationShadeWindowView.class);
|
||||
doReturn(mockShadeWindowView).when(mStatusBar).getNotificationShadeWindowView();
|
||||
doReturn(true).when(mockShadeWindowView).isAttachedToWindow();
|
||||
doNothing().when(mNavigationBar).checkNavBarModes();
|
||||
mNavigationBar.createView(null);
|
||||
WindowInsets windowInsets = new WindowInsets.Builder().setVisible(ime(), false).build();
|
||||
doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets();
|
||||
|
||||
// Verify navbar altered back icon when an app is showing IME
|
||||
mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, null, IME_VISIBLE,
|
||||
BACK_DISPOSITION_DEFAULT, true);
|
||||
assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
|
||||
assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
|
||||
|
||||
// Verify navbar didn't alter and showing back icon when the keyguard is showing without
|
||||
// requesting IME insets visible.
|
||||
doReturn(true).when(mStatusBar).isKeyguardShowing();
|
||||
mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, null, IME_VISIBLE,
|
||||
BACK_DISPOSITION_DEFAULT, true);
|
||||
assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
|
||||
assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
|
||||
|
||||
// Verify navbar altered and showing back icon when the keyguard is showing and
|
||||
// requesting IME insets visible.
|
||||
windowInsets = new WindowInsets.Builder().setVisible(ime(), true).build();
|
||||
doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets();
|
||||
mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, null, IME_VISIBLE,
|
||||
BACK_DISPOSITION_DEFAULT, true);
|
||||
assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0);
|
||||
assertTrue((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_IME_SHOWN) != 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testA11yEventAfterDetach() {
|
||||
View v = mNavigationBar.createView(null);
|
||||
@@ -313,7 +359,7 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
Optional.of(mock(Pip.class)),
|
||||
Optional.of(mock(LegacySplitScreen.class)),
|
||||
Optional.of(mock(Recents.class)),
|
||||
() -> Optional.of(mock(StatusBar.class)),
|
||||
() -> Optional.of(mStatusBar),
|
||||
mock(ShadeController.class),
|
||||
mock(NotificationRemoteInputManager.class),
|
||||
mock(NotificationShadeDepthController.class),
|
||||
|
||||
@@ -548,9 +548,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
*/
|
||||
private InputMethodSubtype mCurrentSubtype;
|
||||
|
||||
// Was the keyguard locked when this client became current?
|
||||
private boolean mCurClientInKeyguard;
|
||||
|
||||
/**
|
||||
* {@code true} if the IME has not been mostly hidden via {@link android.view.InsetsController}
|
||||
*/
|
||||
@@ -2390,14 +2387,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mImeHiddenByDisplayPolicy = false;
|
||||
|
||||
if (mCurClient != cs) {
|
||||
// Was the keyguard locked when switching over to the new client?
|
||||
mCurClientInKeyguard = isKeyguardLocked();
|
||||
// If the client is changing, we need to switch over to the new
|
||||
// one.
|
||||
unbindCurrentClientLocked(UnbindReason.SWITCH_CLIENT);
|
||||
if (DEBUG) Slog.v(TAG, "switching to client: client="
|
||||
+ cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard);
|
||||
|
||||
// If the screen is on, inform the new client it is active
|
||||
if (mIsInteractive) {
|
||||
scheduleSetActiveToClient(cs, true /* active */, false /* fullscreen */,
|
||||
@@ -2905,10 +2897,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
// all updateSystemUi happens on system previlege.
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
// apply policy for binder calls
|
||||
if (vis != 0 && isKeyguardLocked() && !mCurClientInKeyguard) {
|
||||
vis = 0;
|
||||
}
|
||||
if (!mCurPerceptible) {
|
||||
vis &= ~InputMethodService.IME_VISIBLE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user