Merge "Prevent crash when AutofillManager.isEnabled() is called" into rvc-dev am: cdbd09bbcf am: aef6672fe9 am: 64f8a5e3ae

Change-Id: I4018cd07fd1da716cbe42ed009248bc908af9cd5
This commit is contained in:
Joanne Chung
2020-05-08 11:00:27 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 2 deletions

View File

@@ -1894,7 +1894,13 @@ public final class AutofillManager {
final SyncResultReceiver receiver = new SyncResultReceiver(SYNC_CALLS_TIMEOUT_MS);
mService.addClient(mServiceClient, client.autofillClientGetComponentName(),
userId, receiver);
final int flags = receiver.getIntResult();
int flags = 0;
try {
flags = receiver.getIntResult();
} catch (SyncResultReceiver.TimeoutException e) {
Log.w(TAG, "Failed to initialize autofill: " + e);
return;
}
mEnabled = (flags & FLAG_ADD_CLIENT_ENABLED) != 0;
sDebug = (flags & FLAG_ADD_CLIENT_DEBUG) != 0;
sVerbose = (flags & FLAG_ADD_CLIENT_VERBOSE) != 0;

View File

@@ -260,7 +260,7 @@ final class AutofillManagerServiceImpl
if (isEnabledLocked()) return FLAG_ADD_CLIENT_ENABLED;
// Check if it's enabled for augmented autofill
if (isAugmentedAutofillServiceAvailableLocked()
if (componentName != null && isAugmentedAutofillServiceAvailableLocked()
&& isWhitelistedForAugmentedAutofillLocked(componentName)) {
return FLAG_ADD_CLIENT_ENABLED_FOR_AUGMENTED_AUTOFILL_ONLY;
}