Debian Codegraph @

core/java/com/android/internal/inputmethod/ImeTracingClientImpl.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * An implementation of {@link ImeTracing} for non system_server processes.
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 // Intentionally left empty, this is implemented in ImeTracingServerImpl
94 }
95
96 @Override
97 public void startTrace(PrintWriter pw) {
98 }
99
100 @Override
101 public void stopTrace(PrintWriter pw) {
102 }
103 }