summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-03-23 02:34:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-03-23 02:34:25 +0000
commit78e74aeca6010d58e75959c6703bdbff35c2b943 (patch)
tree2114c4e43635c7ac22b7b2bf603aebc7e0f7d98d
parent721df801027bd061c68be0545bfbc3f2e33141d7 (diff)
parent6430cbc8697e68aa558c3e0ab67f5ae89a171d9b (diff)
Merge "Restricts ContentCapture and AugmentedAutofill when using temporary services."
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java13
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java34
-rw-r--r--services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java10
3 files changed, 41 insertions, 16 deletions
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index 89c404307202..ff284dcabfd0 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -40,6 +40,7 @@ import android.graphics.Rect;
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;
@@ -1212,6 +1213,18 @@ final class AutofillManagerServiceImpl
@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);
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index ac8f61b50192..c62794d3e3d2 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -2659,17 +2659,16 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
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;
}
@@ -2687,7 +2686,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// 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
@@ -2712,14 +2714,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
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);
@@ -2733,12 +2727,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
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();
diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java
index b27554a4cb18..f3814c65d4f4 100644
--- a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java
+++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java
@@ -40,6 +40,7 @@ import android.content.pm.PackageManager;
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;
@@ -455,6 +456,7 @@ final class ContentCapturePerUserService
}
@GuardedBy("mLock")
+ @Nullable
ContentCaptureOptions getOptionsForPackageLocked(@NonNull String packageName) {
if (!mWhitelistHelper.isWhitelisted(packageName)) {
if (mMaster.verbose) {
@@ -465,6 +467,14 @@ final class ContentCapturePerUserService
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,