Merge "Prevent crash when AutofillManager.isEnabled() is called" into rvc-dev

This commit is contained in:
Joanne Chung
2020-05-08 10:14:55 +00:00
committed by Android (Google) Code Review
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); final SyncResultReceiver receiver = new SyncResultReceiver(SYNC_CALLS_TIMEOUT_MS);
mService.addClient(mServiceClient, client.autofillClientGetComponentName(), mService.addClient(mServiceClient, client.autofillClientGetComponentName(),
userId, receiver); 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; mEnabled = (flags & FLAG_ADD_CLIENT_ENABLED) != 0;
sDebug = (flags & FLAG_ADD_CLIENT_DEBUG) != 0; sDebug = (flags & FLAG_ADD_CLIENT_DEBUG) != 0;
sVerbose = (flags & FLAG_ADD_CLIENT_VERBOSE) != 0; sVerbose = (flags & FLAG_ADD_CLIENT_VERBOSE) != 0;

View File

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