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
This commit is contained in:
Joanne Chung
2019-12-24 19:27:13 +08:00
parent 97a17d5658
commit 9cfd022783

View File

@@ -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();
}
}
}