Apply ResultCallback to DevelopmentTiles
In CL[1], the startImeTrace and stopImeTrace apply the ResultCallback mechanism. Change corresponding API usages in DevelopmentTiles. We are also working on getting rid of direct dependecy on IInputMethodManager from Settings.(see b/175742251) [1]: I3eafbc28ed3acf3ba859885bf201cb06b3149b94 Bug: 163453493 Test: make RunSettingsRoboTests ROBOTEST_FILTER="WinscopeTraceTest" Test: 1) Enable the Winscope Trace tile 2) Do some actions like open keyboard 3) Disable the Winscope Trace tile 4) Grad a bugreport and verify trace on go/Winscope Change-Id: I6733e8b500f5e02d4e14cde4ab7a46f4f716f5d0
This commit is contained in:
@@ -265,6 +265,7 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
@VisibleForTesting
|
||||
boolean isImeTraceEnabled() {
|
||||
try {
|
||||
// TODO(b/175742251): Get rid of dependency on IInputMethodManager
|
||||
final Completable.Boolean value = Completable.createBoolean();
|
||||
mInputMethodManager.isImeTraceEnabled(ResultCallbacks.of(value));
|
||||
return Completable.getResult(value);
|
||||
@@ -327,13 +328,16 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
}
|
||||
}
|
||||
|
||||
private void setImeTraceEnabled(boolean isEnabled) {
|
||||
protected void setImeTraceEnabled(boolean isEnabled) {
|
||||
try {
|
||||
// TODO(b/175742251): Get rid of dependency on IInputMethodManager
|
||||
final Completable.Void value = Completable.createVoid();
|
||||
if (isEnabled) {
|
||||
mInputMethodManager.startImeTrace();
|
||||
mInputMethodManager.startImeTrace(ResultCallbacks.of(value));
|
||||
} else {
|
||||
mInputMethodManager.stopImeTrace();
|
||||
mInputMethodManager.stopImeTrace(ResultCallbacks.of(value));
|
||||
}
|
||||
Completable.getResult(value);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Could not set ime trace status." + e.toString());
|
||||
}
|
||||
|
@@ -24,8 +24,10 @@ import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeT
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -72,6 +74,7 @@ public class WinscopeTraceTest {
|
||||
// default ImeTraceEnabled value, prevent tests from actually calling into IMM and
|
||||
// await the result forever.
|
||||
doReturn(false).when(mWinscopeTrace).isImeTraceEnabled();
|
||||
doNothing().when(mWinscopeTrace).setImeTraceEnabled(anyBoolean());
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mWindowManager", mWindowManager);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mInputMethodManager", mInputMethodManager);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mSurfaceFlinger", mSurfaceFlinger);
|
||||
@@ -182,7 +185,7 @@ public class WinscopeTraceTest {
|
||||
@Test
|
||||
public void setIsEnableTrue_shouldEnableImeTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(true);
|
||||
verify(mInputMethodManager).startImeTrace();
|
||||
verify(mWinscopeTrace).setImeTraceEnabled(eq(true));
|
||||
verifyNoMoreInteractions(mInputMethodManager);
|
||||
}
|
||||
|
||||
@@ -210,7 +213,7 @@ public class WinscopeTraceTest {
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void setIsEnableFalse_shouldDisableImeTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(false);
|
||||
verify(mInputMethodManager).stopImeTrace();
|
||||
verify(mWinscopeTrace).setImeTraceEnabled(eq(false));
|
||||
verifyNoMoreInteractions(mInputMethodManager);
|
||||
verify(mToast).show();
|
||||
}
|
||||
|
Reference in New Issue
Block a user