Fixed augmented autofill workflow so it's bound right away when main service is disabled.

Test: manual verification
Test: atest AugmentedLoginActivityTest CtsAutoFillServiceTestCases:android.autofillservice.cts.augmented.DisableAutofillTest
Fixes: 123100813

Change-Id: Ibf95c83346c0df21afa6a6f9f6e10357a9b61478
This commit is contained in:
Felipe Leme
2019-03-22 17:07:49 -07:00
parent 465c591191
commit d6a30c8b0c
3 changed files with 46 additions and 11 deletions

View File

@@ -198,6 +198,11 @@ public final class AutofillManagerService
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.registerReceiver(mBroadcastReceiver, filter, null, FgThread.getHandler());
mAugmentedAutofillResolver = new FrameworkResourcesServiceNameResolver(getContext(),
com.android.internal.R.string.config_defaultAugmentedAutofillService);
mAugmentedAutofillResolver.setOnTemporaryServiceNameChangedCallback(
(u, s) -> getServiceForUserLocked(u).updateRemoteAugmentedAutofillService());
if (mSupportedSmartSuggestionModes != AutofillManager.FLAG_SMART_SUGGESTION_OFF) {
// Must eager load the services so they bind to the augmented autofill service
final UserManager um = getContext().getSystemService(UserManager.class);
@@ -207,11 +212,6 @@ public final class AutofillManagerService
getServiceForUserLocked(userId);
}
}
mAugmentedAutofillResolver = new FrameworkResourcesServiceNameResolver(getContext(),
com.android.internal.R.string.config_defaultAugmentedAutofillService);
mAugmentedAutofillResolver.setOnTemporaryServiceNameChangedCallback(
(u, s) -> getServiceForUserLocked(u).updateRemoteAugmentedAutofillService());
}
@Override // from AbstractMasterSystemService

View File

@@ -246,7 +246,8 @@ final class AutofillManagerServiceImpl
if (isEnabledLocked()) return FLAG_ADD_CLIENT_ENABLED;
// Check if it's enabled for augmented autofill
if (isSetupCompletedLocked() && isWhitelistedForAugmentedAutofillLocked(componentName)) {
if (isAugmentedAutofillServiceAvailableLocked()
&& isWhitelistedForAugmentedAutofillLocked(componentName)) {
return FLAG_ADD_CLIENT_ENABLED_FOR_AUGMENTED_AUTOFILL_ONLY;
}
@@ -1149,12 +1150,30 @@ final class AutofillManagerServiceImpl
mRemoteAugmentedAutofillServiceInfo = null;
}
if (isEnabledLocked()) {
final boolean available = isAugmentedAutofillServiceAvailableLocked();
if (sVerbose) Slog.v(TAG, "updateRemoteAugmentedAutofillService(): " + available);
if (available) {
mRemoteAugmentedAutofillService = getRemoteAugmentedAutofillServiceLocked();
}
}
}
private boolean isAugmentedAutofillServiceAvailableLocked() {
if (mMaster.verbose) {
Slog.v(TAG, "isAugmentedAutofillService(): "
+ "setupCompleted=" + isSetupCompletedLocked()
+ ", disabled=" + isDisabledByUserRestrictionsLocked()
+ ", augmentedService="
+ mMaster.mAugmentedAutofillResolver.getServiceName(mUserId));
}
if (!isSetupCompletedLocked() || isDisabledByUserRestrictionsLocked()
|| mMaster.mAugmentedAutofillResolver.getServiceName(mUserId) == null) {
return false;
}
return true;
}
/**
* Sets which packages and activities can trigger augmented autofill.
*

View File

@@ -112,6 +112,13 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst
return mSetupComplete && mServiceInfo != null && !mDisabled;
}
/**
* Gets whether the service is disabled by {@link UserManager} restrictions.
*/
protected final boolean isDisabledByUserRestrictionsLocked() {
return mDisabled;
}
/**
* Updates the state of this service.
*
@@ -136,7 +143,9 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst
+ ", disabled=" + disabled + ", mDisabled=" + mDisabled);
}
mSetupComplete = isSetupCompletedLocked();
final String setupComplete = Settings.Secure.getStringForUser(
getContext().getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, mUserId);
mSetupComplete = "1".equals(setupComplete);
mDisabled = disabled;
updateServiceInfoLocked();
@@ -234,6 +243,15 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst
mMaster.mServiceNameResolver.resetTemporaryService(mUserId);
}
/**
* Gets the {@link ServiceInfo} of the remote service this service binds to, or {@code null}
* if the service is disabled.
*/
@Nullable
public final ServiceInfo getServiceInfo() {
return mServiceInfo;
}
/**
* Gets the {@link ComponentName} of the remote service this service binds to, or {@code null}
* if the service is disabled.
@@ -311,9 +329,7 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst
* Gets whether the device already finished setup.
*/
protected final boolean isSetupCompletedLocked() {
final String setupComplete = Settings.Secure.getStringForUser(
getContext().getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, mUserId);
return "1".equals(setupComplete);
return mSetupComplete;
}
/**