Make IInputMethodManager to oneway (11/N)
Comply following methods to IVoidResultCallback to emulate
current behavior and apply them to one-way.
-. startProtoDump
-. startImeTrace
-. stopImeTrace
Bug: 163453493
Test: atest CtsInputMethodTestCases
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: I3eafbc28ed3acf3ba859885bf201cb06b3149b94
This commit is contained in:
@@ -28,6 +28,8 @@ import android.util.Log;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.android.internal.inputmethod.Completable;
|
||||
import com.android.internal.inputmethod.ResultCallbacks;
|
||||
import com.android.internal.view.IInputMethodManager;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -91,7 +93,9 @@ public abstract class ImeTracing {
|
||||
* @param where
|
||||
*/
|
||||
public void sendToService(byte[] protoDump, int source, String where) throws RemoteException {
|
||||
mService.startProtoDump(protoDump, source, where);
|
||||
final Completable.Void value = Completable.createVoid();
|
||||
mService.startProtoDump(protoDump, source, where, ResultCallbacks.of(value));
|
||||
Completable.getResult(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,11 +91,12 @@ interface IInputMethodManager {
|
||||
/** Remove the IME surface. Requires passing the currently focused window. */
|
||||
oneway void removeImeSurfaceFromWindow(in IBinder windowToken,
|
||||
in IVoidResultCallback resultCallback);
|
||||
void startProtoDump(in byte[] protoDump, int source, String where);
|
||||
oneway void startProtoDump(in byte[] protoDump, int source, String where,
|
||||
in IVoidResultCallback resultCallback);
|
||||
oneway void isImeTraceEnabled(in IBooleanResultCallback resultCallback);
|
||||
|
||||
// Starts an ime trace.
|
||||
void startImeTrace();
|
||||
oneway void startImeTrace(in IVoidResultCallback resultCallback);
|
||||
// Stops an ime trace.
|
||||
void stopImeTrace();
|
||||
oneway void stopImeTrace(in IVoidResultCallback resultCallback);
|
||||
}
|
||||
|
||||
@@ -4131,48 +4131,52 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
@BinderThread
|
||||
@Override
|
||||
@GuardedBy("mMethodMap")
|
||||
public void startProtoDump(byte[] protoDump, int source, String where) {
|
||||
if (protoDump == null && source != IME_TRACING_FROM_IMMS) {
|
||||
// Dump not triggered from IMMS, but no proto information provided.
|
||||
return;
|
||||
}
|
||||
ImeTracing tracingInstance = ImeTracing.getInstance();
|
||||
if (!tracingInstance.isAvailable() || !tracingInstance.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProtoOutputStream proto = new ProtoOutputStream();
|
||||
switch (source) {
|
||||
case ImeTracing.IME_TRACING_FROM_CLIENT:
|
||||
final long client_token = proto.start(InputMethodClientsTraceFileProto.ENTRY);
|
||||
proto.write(InputMethodClientsTraceProto.ELAPSED_REALTIME_NANOS,
|
||||
SystemClock.elapsedRealtimeNanos());
|
||||
proto.write(InputMethodClientsTraceProto.WHERE, where);
|
||||
proto.write(InputMethodClientsTraceProto.CLIENT, protoDump);
|
||||
proto.end(client_token);
|
||||
break;
|
||||
case ImeTracing.IME_TRACING_FROM_IMS:
|
||||
final long service_token = proto.start(InputMethodServiceTraceFileProto.ENTRY);
|
||||
proto.write(InputMethodServiceTraceProto.ELAPSED_REALTIME_NANOS,
|
||||
SystemClock.elapsedRealtimeNanos());
|
||||
proto.write(InputMethodServiceTraceProto.WHERE, where);
|
||||
proto.write(InputMethodServiceTraceProto.INPUT_METHOD_SERVICE, protoDump);
|
||||
proto.end(service_token);
|
||||
break;
|
||||
case IME_TRACING_FROM_IMMS:
|
||||
final long managerservice_token =
|
||||
proto.start(InputMethodManagerServiceTraceFileProto.ENTRY);
|
||||
proto.write(InputMethodManagerServiceTraceProto.ELAPSED_REALTIME_NANOS,
|
||||
SystemClock.elapsedRealtimeNanos());
|
||||
proto.write(InputMethodManagerServiceTraceProto.WHERE, where);
|
||||
dumpDebug(proto, InputMethodManagerServiceTraceProto.INPUT_METHOD_MANAGER_SERVICE);
|
||||
proto.end(managerservice_token);
|
||||
break;
|
||||
default:
|
||||
// Dump triggered by a source not recognised.
|
||||
public void startProtoDump(byte[] protoDump, int source, String where,
|
||||
IVoidResultCallback resultCallback) {
|
||||
CallbackUtils.onResult(resultCallback, () -> {
|
||||
if (protoDump == null && source != IME_TRACING_FROM_IMMS) {
|
||||
// Dump not triggered from IMMS, but no proto information provided.
|
||||
return;
|
||||
}
|
||||
tracingInstance.addToBuffer(proto, source);
|
||||
}
|
||||
ImeTracing tracingInstance = ImeTracing.getInstance();
|
||||
if (!tracingInstance.isAvailable() || !tracingInstance.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProtoOutputStream proto = new ProtoOutputStream();
|
||||
switch (source) {
|
||||
case ImeTracing.IME_TRACING_FROM_CLIENT:
|
||||
final long client_token = proto.start(InputMethodClientsTraceFileProto.ENTRY);
|
||||
proto.write(InputMethodClientsTraceProto.ELAPSED_REALTIME_NANOS,
|
||||
SystemClock.elapsedRealtimeNanos());
|
||||
proto.write(InputMethodClientsTraceProto.WHERE, where);
|
||||
proto.write(InputMethodClientsTraceProto.CLIENT, protoDump);
|
||||
proto.end(client_token);
|
||||
break;
|
||||
case ImeTracing.IME_TRACING_FROM_IMS:
|
||||
final long service_token = proto.start(InputMethodServiceTraceFileProto.ENTRY);
|
||||
proto.write(InputMethodServiceTraceProto.ELAPSED_REALTIME_NANOS,
|
||||
SystemClock.elapsedRealtimeNanos());
|
||||
proto.write(InputMethodServiceTraceProto.WHERE, where);
|
||||
proto.write(InputMethodServiceTraceProto.INPUT_METHOD_SERVICE, protoDump);
|
||||
proto.end(service_token);
|
||||
break;
|
||||
case IME_TRACING_FROM_IMMS:
|
||||
final long managerservice_token =
|
||||
proto.start(InputMethodManagerServiceTraceFileProto.ENTRY);
|
||||
proto.write(InputMethodManagerServiceTraceProto.ELAPSED_REALTIME_NANOS,
|
||||
SystemClock.elapsedRealtimeNanos());
|
||||
proto.write(InputMethodManagerServiceTraceProto.WHERE, where);
|
||||
dumpDebug(proto,
|
||||
InputMethodManagerServiceTraceProto.INPUT_METHOD_MANAGER_SERVICE);
|
||||
proto.end(managerservice_token);
|
||||
break;
|
||||
default:
|
||||
// Dump triggered by a source not recognised.
|
||||
return;
|
||||
}
|
||||
tracingInstance.addToBuffer(proto, source);
|
||||
});
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
@@ -4183,40 +4187,44 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void startImeTrace() {
|
||||
ImeTracing.getInstance().startTrace(null /* printwriter */);
|
||||
ArrayMap<IBinder, ClientState> clients;
|
||||
synchronized (mMethodMap) {
|
||||
clients = new ArrayMap<>(mClients);
|
||||
}
|
||||
for (ClientState state : clients.values()) {
|
||||
if (state != null) {
|
||||
try {
|
||||
state.client.setImeTraceEnabled(true /* enabled */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Error while trying to enable ime trace on client window", e);
|
||||
public void startImeTrace(IVoidResultCallback resultCallback) {
|
||||
CallbackUtils.onResult(resultCallback, () -> {
|
||||
ImeTracing.getInstance().startTrace(null /* printwriter */);
|
||||
ArrayMap<IBinder, ClientState> clients;
|
||||
synchronized (mMethodMap) {
|
||||
clients = new ArrayMap<>(mClients);
|
||||
}
|
||||
for (ClientState state : clients.values()) {
|
||||
if (state != null) {
|
||||
try {
|
||||
state.client.setImeTraceEnabled(true /* enabled */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Error while trying to enable ime trace on client window", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void stopImeTrace() {
|
||||
ImeTracing.getInstance().stopTrace(null /* printwriter */);
|
||||
ArrayMap<IBinder, ClientState> clients;
|
||||
synchronized (mMethodMap) {
|
||||
clients = new ArrayMap<>(mClients);
|
||||
}
|
||||
for (ClientState state : clients.values()) {
|
||||
if (state != null) {
|
||||
try {
|
||||
state.client.setImeTraceEnabled(false /* enabled */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Error while trying to disable ime trace on client window", e);
|
||||
public void stopImeTrace(IVoidResultCallback resultCallback) {
|
||||
CallbackUtils.onResult(resultCallback, () -> {
|
||||
ImeTracing.getInstance().stopTrace(null /* printwriter */);
|
||||
ArrayMap<IBinder, ClientState> clients;
|
||||
synchronized (mMethodMap) {
|
||||
clients = new ArrayMap<>(mClients);
|
||||
}
|
||||
for (ClientState state : clients.values()) {
|
||||
if (state != null) {
|
||||
try {
|
||||
state.client.setImeTraceEnabled(false /* enabled */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Error while trying to disable ime trace on client window", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
|
||||
@@ -1868,7 +1868,9 @@ public final class MultiClientInputMethodManagerService {
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void startProtoDump(byte[] clientProtoDump, int source, String where) {
|
||||
public void startProtoDump(byte[] clientProtoDump, int source, String where,
|
||||
IVoidResultCallback resultCallback) {
|
||||
CallbackUtils.onResult(resultCallback, () -> { });
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
@@ -1879,12 +1881,14 @@ public final class MultiClientInputMethodManagerService {
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void startImeTrace() {
|
||||
public void startImeTrace(IVoidResultCallback resultCallback) {
|
||||
CallbackUtils.onResult(resultCallback, () -> { });
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void stopImeTrace() {
|
||||
public void stopImeTrace(IVoidResultCallback resultCallback) {
|
||||
CallbackUtils.onResult(resultCallback, () -> { });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user