From 9c019cf9867d0ff25cace820ed1870f0d5241368 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 5 Feb 2021 17:13:44 -0800 Subject: [PATCH] Simplify IMMS#dump() with ArrayUtils.contains() This is a follow up CL to our previous CL [1], which enabled IME tracing result to be automatically included into the bugreport. Checking whether args contain "--proto" or not is something we can achieve with ArrayUtils.contains() as a one-liner. Let's do so in favor of simplicity. This is a mechanical refactoring hence there should be no behavior change. This is a preparation to fix another unintentional behavior change (Bug 177462676), which was also accidentally introduced in the same CL. [1]: Ie87eb8423e2bb70f28c330983d45b95e2e07062d ac24994aaa5bd1f70608cb8c72b93b5ae00d90eb Bug: 154348613 Bug: 167948910 Bug: 177462676 Test: Manually done as follows. 1. adb shell ime tracing start 2. adb logcat -s imeTracing:* Make sure IME tracing started. 3. adb shell am start -a android.intent.action.DIAL 4. adb bugreport bugreport.zip 5. adb logcat -s imeTracing:* Make sure IME tracing is stopped then restarted. 6. unzip -v bugreport.zip | grep ime_trace_clients.pb Make sure "ime_trace_clients.pb" is included. Change-Id: I057fba86b4ab7d2de1725e73d5a39bb88ee35414 --- .../server/inputmethod/InputMethodManagerService.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 323178edcc693..a172691c5925b 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -178,6 +178,7 @@ import com.android.internal.os.BackgroundThread; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; import com.android.internal.os.TransferPipe; +import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.internal.view.IInlineSuggestionsRequestCallback; import com.android.internal.view.IInlineSuggestionsResponseCallback; @@ -5229,15 +5230,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; - boolean asProto = false; - for (int argIndex = 0; argIndex < args.length; argIndex++) { - if (args[argIndex].equals(PROTO_ARG)) { - asProto = true; - break; - } - } - - if (asProto) { + if (ArrayUtils.contains(args, PROTO_ARG)) { final ImeTracing imeTracing = ImeTracing.getInstance(); if (imeTracing.isEnabled()) { imeTracing.stopTrace(null, false /* writeToFile */);