import android.metrics.LogMaker;
import android.os.AsyncTask;
import android.os.Binder;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@GuardedBy("mLock")
boolean isWhitelistedForAugmentedAutofillLocked(@NonNull ComponentName componentName) {
+ if (Build.IS_USER && mMaster.mAugmentedAutofillResolver.isTemporary(mUserId)) {
+ final String serviceName = mMaster.mAugmentedAutofillResolver.getServiceName(mUserId);
+ final ComponentName component = ComponentName.unflattenFromString(serviceName);
+ final String servicePackage = component == null ? null : component.getPackageName();
+ final String packageName = componentName.getPackageName();
+ if (!packageName.equals(servicePackage)) {
+ Slog.w(TAG, "Ignoring package " + packageName + " for augmented autofill while "
+ + "using temporary service " + servicePackage);
+ return false;
+ }
+ }
+
return mAugmentedWhitelistHelper.isWhitelisted(componentName);
}
mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked();
if (mAugmentedAutofillDestroyer == null) {
if (sVerbose) {
- Slog.v(TAG, "canceling session " + id + " when server returned null and there is no"
- + " AugmentedAutofill for user. AutofillableIds: " + autofillableIds);
+ Slog.v(TAG, "canceling session " + id + " when service returned null and it cannot "
+ + "be augmented. AutofillableIds: " + autofillableIds);
}
// Nothing to be done, but need to notify client.
notifyUnavailableToClient(AutofillManager.STATE_FINISHED, autofillableIds);
removeSelf();
} else {
if (sVerbose) {
- Slog.v(TAG, "keeping session " + id + " when server returned null but "
- + "there is an AugmentedAutofill for user. AutofillableIds: "
- + autofillableIds);
+ Slog.v(TAG, "keeping session " + id + " when service returned null but "
+ + "it can be augmented. AutofillableIds: " + autofillableIds);
}
mAugmentedAutofillableIds = autofillableIds;
}
// Check if Smart Suggestions is supported...
final @SmartSuggestionMode int supportedModes = mService
.getSupportedSmartSuggestionModesLocked();
- if (supportedModes == 0) return null;
+ if (supportedModes == 0) {
+ if (sVerbose) Slog.v(TAG, "triggerAugmentedAutofillLocked(): no supported modes");
+ return null;
+ }
// ...then if the service is set for the user
return null;
}
- if (sVerbose) {
- Slog.v(TAG, "calling Augmented Autofill Service ("
- + remoteService.getComponentName().toShortString() + ") on view "
- + mCurrentViewId + " using suggestion mode "
- + getSmartSuggestionModeToString(mode)
- + " when server returned null for session " + this.id);
- }
-
final boolean isWhitelisted = mService
.isWhitelistedForAugmentedAutofillLocked(mComponentName);
if (!isWhitelisted) {
if (sVerbose) {
- Slog.v(TAG, mComponentName.toShortString() + " is not whitelisted for "
- + "augmented autofill");
+ Slog.v(TAG, "triggerAugmentedAutofillLocked(): "
+ + ComponentName.flattenToShortString(mComponentName) + " not whitelisted ");
}
return null;
}
+ if (sVerbose) {
+ Slog.v(TAG, "calling Augmented Autofill Service ("
+ + ComponentName.flattenToShortString(remoteService.getComponentName())
+ + ") on view " + mCurrentViewId + " using suggestion mode "
+ + getSmartSuggestionModeToString(mode)
+ + " when server returned null for session " + this.id);
+ }
+
final ViewState viewState = mViewStates.get(mCurrentViewId);
viewState.setState(ViewState.STATE_TRIGGERED_AUGMENTED_AUTOFILL);
final AutofillValue currentValue = viewState.getCurrentValue();
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ServiceInfo;
import android.os.Binder;
+import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.UserHandle;
}
@GuardedBy("mLock")
+ @Nullable
ContentCaptureOptions getOptionsForPackageLocked(@NonNull String packageName) {
if (!mWhitelistHelper.isWhitelisted(packageName)) {
if (mMaster.verbose) {
final ArraySet<ComponentName> whitelistedComponents = mWhitelistHelper
.getWhitelistedComponents(packageName);
+ if (Build.IS_USER && isTemporaryServiceSetLocked()) {
+ final String servicePackageName = getServicePackageName();
+ if (!packageName.equals(servicePackageName)) {
+ Slog.w(mTag, "Ignoring package " + packageName
+ + " while using temporary service " + servicePackageName);
+ return null;
+ }
+ }
ContentCaptureOptions options = new ContentCaptureOptions(mMaster.mDevCfgLoggingLevel,
mMaster.mDevCfgMaxBufferSize, mMaster.mDevCfgIdleFlushingFrequencyMs,
mMaster.mDevCfgTextChangeFlushingFrequencyMs, mMaster.mDevCfgLogHistorySize,