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:
Wilson Wu
2021-01-28 17:15:21 +08:00
parent 3b414eb10b
commit fa01bf30ba
2 changed files with 12 additions and 5 deletions

View File

@@ -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());
}