From 2e1870c23b57e158503d7624ffc2b6d62cc2db29 Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Tue, 26 May 2020 21:27:45 +0800 Subject: [PATCH] Add log to help debug bind TCS twice. In b/156555486, we find two consecutive requests may cause bind TCS twice. It is wired mBinding is false here, it should be true when TCMS binds the TCS for 1st request. The only possibility is that willBind is false or onServiceDisconnected, onBindingDied or onNullBinding was called to set mService null and mBinding false. The test fail cannot be reproduce locally with many tries. Add log to help debug the same bug next time. Bug: 156555486 Test: Hard to see the fail case, see local added normal log Change-Id: I04600b00322ef2dcc2162770672c797d42f5e98c --- .../textclassifier/TextClassificationManagerService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java b/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java index e675f4e8a46cf..56e013d737acf 100644 --- a/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java +++ b/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java @@ -883,6 +883,9 @@ public final class TextClassificationManagerService extends ITextClassifierServi Slog.d(LOG_TAG, "Binding to " + serviceIntent.getComponent()); willBind = mContext.bindServiceAsUser( serviceIntent, mConnection, mBindServiceFlags, UserHandle.of(mUserId)); + if (!willBind) { + Slog.e(LOG_TAG, "Could not bind to " + componentName); + } mBinding = willBind; } finally { Binder.restoreCallingIdentity(identity); @@ -955,16 +958,19 @@ public final class TextClassificationManagerService extends ITextClassifierServi @Override public void onServiceDisconnected(ComponentName name) { + Slog.i(LOG_TAG, "onServiceDisconnected called with " + name); cleanupService(); } @Override public void onBindingDied(ComponentName name) { + Slog.i(LOG_TAG, "onBindingDied called with " + name); cleanupService(); } @Override public void onNullBinding(ComponentName name) { + Slog.i(LOG_TAG, "onNullBinding called with " + name); cleanupService(); }