Prevent crash when AutofillManager.isEnabled() is called
If we cannot get flag information from the AutofillManagerService after the timeout, we should not crash the process, we need to handle the enabled information properly. Also fix NPE because of null component name while calling AutofillManagerServiceImpl.isWhitelistedForAugmentedAutofillLocked(). Bug: 151273845 Test: atest CtsAutoFillServiceTestCases Test: manual. Copy the text from Messenger and paste on search bar, no crash occurred and can paste text correctly. Change-Id: I8d7ca35226052944fd68fef60a013a65a7fb57c1
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user