Fix hasEnabledAutofillServices() return wrong value after AutofillServie updated

AutofillManagerService tries to get service impl from the cache, but
the service impl will be deleted from the cache after service is
updated. The service enabled status should not be affect after
updating service. If AutofillManagerService cannot get the service
from the cache, we will get the service instance for an user.

Bug: 152473957
Test: atest CtsAutoFillServiceTestCases
Test: Manual. Install sample app and make sure the value is correct
after update

Change-Id: I0f2c156ccced8c87e0df5b2f9266acfd769a7322
This commit is contained in:
Joanne Chung
2020-05-21 13:55:36 +08:00
parent a4403c2d4a
commit f368dbefae

View File

@@ -1639,12 +1639,8 @@ public final class AutofillManagerService
@NonNull IResultReceiver receiver) {
boolean enabled = false;
synchronized (mLock) {
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
if (service != null) {
enabled = Objects.equals(packageName, service.getServicePackageName());
} else if (sVerbose) {
Slog.v(TAG, "isServiceEnabled(): no service for " + userId);
}
final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
enabled = Objects.equals(packageName, service.getServicePackageName());
}
send(receiver, enabled);
}