From 9cfd022783de9fe23c29fff50e2bfc79cb4a6a23 Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Tue, 24 Dec 2019 19:27:13 +0800 Subject: [PATCH] Fix onConnet() is called twice for AugmentedAutofillService. When AugmentedAutofillService name changes, onAugmentedServiceNameChanged() tris to updateRemoteAugmentedAutofillService(). In getServiceForUserLocked(), if we can not get the service from mServicesCache, the newServiceLocked() triggers updateRemoteAugmentedAutofillService() which binds the service for the 1st onConnet(). Then getServiceForUserLocked().updateRemoteAugmentedAutofillService() will trigger 2nd onConnet(). This causes augmented cts tests flaky. Due to getServiceForUserLocked() calls updateRemoteAugmentedAutofillService() if we can not get the service from the cache, we can skip call update. Bug: 144294363 Bug: 145136776 Test: atest android.autofillservice.cts.augmented Change-Id: If6505cc05f032da4d20e86b976b7e5862f1b8e8f --- .../android/server/autofill/AutofillManagerService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java index c689ed1c64c7c..03d9626cab91b 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java @@ -288,7 +288,14 @@ public final class AutofillManagerService boolean isTemporary) { mAugmentedAutofillState.setServiceInfo(userId, serviceName, isTemporary); synchronized (mLock) { - getServiceForUserLocked(userId).updateRemoteAugmentedAutofillService(); + final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId); + if (service == null) { + // If we cannot get the service from the services cache, it will call + // updateRemoteAugmentedAutofillService() finally. Skip call this update again. + getServiceForUserLocked(userId); + } else { + service.updateRemoteAugmentedAutofillService(); + } } }