| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.internal.inputmethod; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.RemoteException; |
| 22 |
import android.os.ServiceManager.ServiceNotFoundException; |
| 23 |
import android.util.Log; |
| 24 |
import android.util.proto.ProtoOutputStream; |
| 25 |
import android.view.inputmethod.InputMethodManager; |
| 26 |
|
| 27 |
import java.io.PrintWriter; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class ImeTracingClientImpl extends ImeTracing { |
| 33 |
ImeTracingClientImpl() throws ServiceNotFoundException, RemoteException { |
| 34 |
sEnabled = mService.isImeTraceEnabled(); |
| 35 |
} |
| 36 |
|
| 37 |
@Override |
| 38 |
public void addToBuffer(ProtoOutputStream proto, int source) { |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public void triggerClientDump(String where, @NonNull InputMethodManager immInstance, |
| 43 |
@Nullable byte[] icProto) { |
| 44 |
if (!isEnabled() || !isAvailable()) { |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
synchronized (mDumpInProgressLock) { |
| 49 |
if (mDumpInProgress) { |
| 50 |
return; |
| 51 |
} |
| 52 |
mDumpInProgress = true; |
| 53 |
} |
| 54 |
|
| 55 |
try { |
| 56 |
ProtoOutputStream proto = new ProtoOutputStream(); |
| 57 |
immInstance.dumpDebug(proto, icProto); |
| 58 |
sendToService(proto.getBytes(), IME_TRACING_FROM_CLIENT, where); |
| 59 |
} catch (RemoteException e) { |
| 60 |
Log.e(TAG, "Exception while sending ime-related client dump to server", e); |
| 61 |
} finally { |
| 62 |
mDumpInProgress = false; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
@Override |
| 67 |
public void triggerServiceDump(String where, @NonNull ServiceDumper dumper, |
| 68 |
@Nullable byte[] icProto) { |
| 69 |
if (!isEnabled() || !isAvailable()) { |
| 70 |
return; |
| 71 |
} |
| 72 |
|
| 73 |
synchronized (mDumpInProgressLock) { |
| 74 |
if (mDumpInProgress) { |
| 75 |
return; |
| 76 |
} |
| 77 |
mDumpInProgress = true; |
| 78 |
} |
| 79 |
|
| 80 |
try { |
| 81 |
ProtoOutputStream proto = new ProtoOutputStream(); |
| 82 |
dumper.dumpToProto(proto, icProto); |
| 83 |
sendToService(proto.getBytes(), IME_TRACING_FROM_IMS, where); |
| 84 |
} catch (RemoteException e) { |
| 85 |
Log.e(TAG, "Exception while sending ime-related service dump to server", e); |
| 86 |
} finally { |
| 87 |
mDumpInProgress = false; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public void triggerManagerServiceDump(String where) { |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
@Override |
| 97 |
public void startTrace(PrintWriter pw) { |
| 98 |
} |
| 99 |
|
| 100 |
@Override |
| 101 |
public void stopTrace(PrintWriter pw) { |
| 102 |
} |
| 103 |
} |