Merge "Remove double-posting in DisplayImeController" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3faaf538e9
@@ -47,7 +47,6 @@ import com.android.internal.inputmethod.ResultCallbacks;
|
|||||||
import com.android.internal.view.IInputMethodManager;
|
import com.android.internal.view.IInputMethodManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,7 +208,6 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void insetsChanged(InsetsState insetsState) {
|
protected void insetsChanged(InsetsState insetsState) {
|
||||||
mMainExecutor.execute(() -> {
|
|
||||||
if (mInsetsState.equals(insetsState)) {
|
if (mInsetsState.equals(insetsState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -225,7 +223,6 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
if (DEBUG) Slog.d(TAG, "insetsChanged when IME showing, restart animation");
|
if (DEBUG) Slog.d(TAG, "insetsChanged when IME showing, restart animation");
|
||||||
startAnimation(mImeShowing, true /* forceRestart */);
|
startAnimation(mImeShowing, true /* forceRestart */);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -238,7 +235,6 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (activeControl.getType() == InsetsState.ITYPE_IME) {
|
if (activeControl.getType() == InsetsState.ITYPE_IME) {
|
||||||
mMainExecutor.execute(() -> {
|
|
||||||
final Point lastSurfacePosition = mImeSourceControl != null
|
final Point lastSurfacePosition = mImeSourceControl != null
|
||||||
? mImeSourceControl.getSurfacePosition() : null;
|
? mImeSourceControl.getSurfacePosition() : null;
|
||||||
final boolean positionChanged =
|
final boolean positionChanged =
|
||||||
@@ -258,7 +254,6 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
removeImeSurface();
|
removeImeSurface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,7 +278,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) Slog.d(TAG, "Got showInsets for ime");
|
if (DEBUG) Slog.d(TAG, "Got showInsets for ime");
|
||||||
mMainExecutor.execute(() -> startAnimation(true /* show */, false /* forceRestart */));
|
startAnimation(true /* show */, false /* forceRestart */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -292,7 +287,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) Slog.d(TAG, "Got hideInsets for ime");
|
if (DEBUG) Slog.d(TAG, "Got hideInsets for ime");
|
||||||
mMainExecutor.execute(() -> startAnimation(false /* show */, false /* forceRestart */));
|
startAnimation(false /* show */, false /* forceRestart */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void topFocusedWindowChanged(String packageName) {
|
public void topFocusedWindowChanged(String packageName) {
|
||||||
|
|||||||
@@ -19,11 +19,13 @@ package com.android.wm.shell.common;
|
|||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
import static android.view.InsetsState.ITYPE_IME;
|
import static android.view.InsetsState.ITYPE_IME;
|
||||||
import static android.view.Surface.ROTATION_0;
|
import static android.view.Surface.ROTATION_0;
|
||||||
|
import static android.view.WindowInsets.Type.ime;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||||
|
|
||||||
@@ -40,18 +42,22 @@ import com.android.internal.view.IInputMethodManager;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class DisplayImeControllerTest {
|
public class DisplayImeControllerTest {
|
||||||
|
|
||||||
private SurfaceControl.Transaction mT;
|
private SurfaceControl.Transaction mT;
|
||||||
private DisplayImeController.PerDisplay mPerDisplay;
|
private DisplayImeController.PerDisplay mPerDisplay;
|
||||||
private IInputMethodManager mMock;
|
private IInputMethodManager mMock;
|
||||||
|
private Executor mExecutor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mT = mock(SurfaceControl.Transaction.class);
|
mT = mock(SurfaceControl.Transaction.class);
|
||||||
mMock = mock(IInputMethodManager.class);
|
mMock = mock(IInputMethodManager.class);
|
||||||
mPerDisplay = new DisplayImeController(null, null, Runnable::run, new TransactionPool() {
|
mExecutor = spy(Runnable::run);
|
||||||
|
mPerDisplay = new DisplayImeController(null, null, mExecutor, new TransactionPool() {
|
||||||
@Override
|
@Override
|
||||||
public SurfaceControl.Transaction acquire() {
|
public SurfaceControl.Transaction acquire() {
|
||||||
return mT;
|
return mT;
|
||||||
@@ -70,6 +76,30 @@ public class DisplayImeControllerTest {
|
|||||||
}.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0);
|
}.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void insetsControlChanged_schedulesNoWorkOnExecutor() {
|
||||||
|
mPerDisplay.insetsControlChanged(insetsStateWithIme(false), insetsSourceControl());
|
||||||
|
verifyZeroInteractions(mExecutor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void insetsChanged_schedulesNoWorkOnExecutor() {
|
||||||
|
mPerDisplay.insetsChanged(insetsStateWithIme(false));
|
||||||
|
verifyZeroInteractions(mExecutor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showInsets_schedulesNoWorkOnExecutor() {
|
||||||
|
mPerDisplay.showInsets(ime(), true);
|
||||||
|
verifyZeroInteractions(mExecutor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hideInsets_schedulesNoWorkOnExecutor() {
|
||||||
|
mPerDisplay.hideInsets(ime(), true);
|
||||||
|
verifyZeroInteractions(mExecutor);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reappliesVisibilityToChangedLeash() {
|
public void reappliesVisibilityToChangedLeash() {
|
||||||
verifyZeroInteractions(mT);
|
verifyZeroInteractions(mT);
|
||||||
|
|||||||
Reference in New Issue
Block a user