Merge "Do not use BIND_RESTRICT_ASSOCIATIONS when binding TextClassifierService" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
47300548b7
@@ -772,6 +772,8 @@ public final class TextClassificationManagerService extends ITextClassifierServi
|
|||||||
@NonNull
|
@NonNull
|
||||||
final TextClassifierServiceConnection mConnection;
|
final TextClassifierServiceConnection mConnection;
|
||||||
final boolean mIsTrusted;
|
final boolean mIsTrusted;
|
||||||
|
@Context.BindServiceFlags
|
||||||
|
final int mBindServiceFlags;
|
||||||
@NonNull
|
@NonNull
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
final Queue<PendingRequest> mPendingRequests = new ArrayDeque<>();
|
final Queue<PendingRequest> mPendingRequests = new ArrayDeque<>();
|
||||||
@@ -786,11 +788,22 @@ public final class TextClassificationManagerService extends ITextClassifierServi
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
int mBoundServiceUid = Process.INVALID_UID;
|
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;
|
mUserId = userId;
|
||||||
mPackageName = packageName;
|
mPackageName = packageName;
|
||||||
mConnection = new TextClassifierServiceConnection(mUserId);
|
mConnection = new TextClassifierServiceConnection(mUserId);
|
||||||
mIsTrusted = isTrusted;
|
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")
|
@GuardedBy("mLock")
|
||||||
@@ -858,10 +871,7 @@ public final class TextClassificationManagerService extends ITextClassifierServi
|
|||||||
.setComponent(componentName);
|
.setComponent(componentName);
|
||||||
Slog.d(LOG_TAG, "Binding to " + serviceIntent.getComponent());
|
Slog.d(LOG_TAG, "Binding to " + serviceIntent.getComponent());
|
||||||
willBind = mContext.bindServiceAsUser(
|
willBind = mContext.bindServiceAsUser(
|
||||||
serviceIntent, mConnection,
|
serviceIntent, mConnection, mBindServiceFlags, UserHandle.of(mUserId));
|
||||||
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
|
|
||||||
| Context.BIND_RESTRICT_ASSOCIATIONS,
|
|
||||||
UserHandle.of(mUserId));
|
|
||||||
mBinding = willBind;
|
mBinding = willBind;
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
@@ -884,6 +894,7 @@ public final class TextClassificationManagerService extends ITextClassifierServi
|
|||||||
pw.printPair("packageName", mPackageName);
|
pw.printPair("packageName", mPackageName);
|
||||||
pw.printPair("boundComponentName", mBoundComponentName);
|
pw.printPair("boundComponentName", mBoundComponentName);
|
||||||
pw.printPair("isTrusted", mIsTrusted);
|
pw.printPair("isTrusted", mIsTrusted);
|
||||||
|
pw.printPair("bindServiceFlags", mBindServiceFlags);
|
||||||
pw.printPair("boundServiceUid", mBoundServiceUid);
|
pw.printPair("boundServiceUid", mBoundServiceUid);
|
||||||
pw.printPair("binding", mBinding);
|
pw.printPair("binding", mBinding);
|
||||||
pw.printPair("numberRequests", mPendingRequests.size());
|
pw.printPair("numberRequests", mPendingRequests.size());
|
||||||
|
|||||||
Reference in New Issue
Block a user