summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tony Mak <tonymak@google.com> 2020-03-30 20:41:09 +0100
committer Tony Mak <tonymak@google.com> 2020-03-31 14:47:29 +0100
commit2f76d97976ca3f52cd7ffcf3d672370b75f924d8 (patch)
tree2bb7ed2c5f45adb21aa736a82deccdaaf776b60a
parent884aa6afe156ec88cfc89e9d5dac4480223c9495 (diff)
Do not use BIND_RESTRICT_ASSOCIATIONS when binding TextClassifierService
The intention was to restrict AiAi, rather than every TextClassifierService. Note that AiAi is still restricted because of the allow-association configs in config.xml. Test: Patch ag/10873984. Select seme text and then run "dumpsys activity allowed-associations" Before the change, extservices is in the output. After the change, extservices is no longer in the output. Test: Run a sample app that sends a broadcast to com.google.android.as/com.google.android.apps.miphone.aiai.reflection.broadcastreceiver.AppInstallBroadcastReceiver Make sure the association restriction is still in place. BUG: 152840827 Change-Id: I491be5971e58f967fe3bd6ffdf34126d0644e4fa
-rw-r--r--services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java b/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java
index 0d16fccc81fd..9a5b020a6b7c 100644
--- a/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java
+++ b/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java
@@ -772,6 +772,8 @@ public final class TextClassificationManagerService extends ITextClassifierServi
@NonNull
final TextClassifierServiceConnection mConnection;
final boolean mIsTrusted;
+ @Context.BindServiceFlags
+ final int mBindServiceFlags;
@NonNull
@GuardedBy("mLock")
final Queue<PendingRequest> mPendingRequests = new ArrayDeque<>();
@@ -786,11 +788,22 @@ public final class TextClassificationManagerService extends ITextClassifierServi
@GuardedBy("mLock")
int mBoundServiceUid = Process.INVALID_UID;
- private ServiceState(@UserIdInt int userId, String packageName, boolean isTrusted) {
+ private ServiceState(
+ @UserIdInt int userId, @NonNull String packageName, boolean isTrusted) {
mUserId = userId;
mPackageName = packageName;
mConnection = new TextClassifierServiceConnection(mUserId);
mIsTrusted = isTrusted;
+ mBindServiceFlags = createBindServiceFlags(packageName);
+ }
+
+ @Context.BindServiceFlags
+ private int createBindServiceFlags(@NonNull String packageName) {
+ int flags = Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE;
+ if (!packageName.equals(mDefaultTextClassifierPackage)) {
+ flags |= Context.BIND_RESTRICT_ASSOCIATIONS;
+ }
+ return flags;
}
@GuardedBy("mLock")
@@ -858,10 +871,7 @@ public final class TextClassificationManagerService extends ITextClassifierServi
.setComponent(componentName);
Slog.d(LOG_TAG, "Binding to " + serviceIntent.getComponent());
willBind = mContext.bindServiceAsUser(
- serviceIntent, mConnection,
- Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_RESTRICT_ASSOCIATIONS,
- UserHandle.of(mUserId));
+ serviceIntent, mConnection, mBindServiceFlags, UserHandle.of(mUserId));
mBinding = willBind;
} finally {
Binder.restoreCallingIdentity(identity);
@@ -884,6 +894,7 @@ public final class TextClassificationManagerService extends ITextClassifierServi
pw.printPair("packageName", mPackageName);
pw.printPair("boundComponentName", mBoundComponentName);
pw.printPair("isTrusted", mIsTrusted);
+ pw.printPair("bindServiceFlags", mBindServiceFlags);
pw.printPair("boundServiceUid", mBoundServiceUid);
pw.printPair("binding", mBinding);
pw.printPair("numberRequests", mPendingRequests.size());