import android.util.ArraySet;
import android.util.Slog;
import android.util.SparseArray;
+import android.util.SparseBooleanArray;
import android.view.contentcapture.ContentCaptureCondition;
import android.view.contentcapture.DataRemovalRequest;
+ " for user " + mUserId);
}
mMaster.mGlobalContentCaptureOptions.setWhitelist(mUserId, packages, activities);
+
+ // Must disable session that are not the whitelist anymore...
+ final int numSessions = mSessions.size();
+ if (numSessions <= 0) return;
+
+ // ...but without holding the lock on mGlobalContentCaptureOptions
+ final SparseBooleanArray blacklistedSessions = new SparseBooleanArray(numSessions);
+
+ for (int i = 0; i < numSessions; i++) {
+ final ContentCaptureServerSession session = mSessions.valueAt(i);
+ final boolean whitelisted = mMaster.mGlobalContentCaptureOptions
+ .isWhitelisted(mUserId, session.appComponentName);
+ if (!whitelisted) {
+ final int sessionId = mSessions.keyAt(i);
+ if (mMaster.debug) {
+ Slog.d(TAG, "marking session " + sessionId + " (" + session.appComponentName
+ + ") for un-whitelisting");
+ }
+ blacklistedSessions.append(sessionId, true);
+ }
+ }
+ final int numBlacklisted = blacklistedSessions.size();
+
+ if (numBlacklisted <= 0) return;
+
+ synchronized (mLock) {
+ for (int i = 0; i < numBlacklisted; i++) {
+ final int sessionId = blacklistedSessions.keyAt(i);
+ if (mMaster.debug) Slog.d(TAG, "un-whitelisting " + sessionId);
+ final ContentCaptureServerSession session = mSessions.get(sessionId);
+ session.setContentCaptureEnabledLocked(false);
+ }
+ }
}
@Override
private final Object mLock;
+ public final ComponentName appComponentName;
+
ContentCaptureServerSession(@NonNull Object lock, @NonNull IBinder activityToken,
@NonNull ContentCapturePerUserService service, @NonNull ComponentName appComponentName,
@NonNull IResultReceiver sessionStateReceiver, int taskId, int displayId, int sessionId,
Preconditions.checkArgument(sessionId != NO_SESSION_ID);
mLock = lock;
mActivityToken = activityToken;
+ this.appComponentName = appComponentName;
mService = service;
mId = sessionId;
mUid = uid;
pw.print(prefix); pw.print("uid: "); pw.print(mUid); pw.println();
pw.print(prefix); pw.print("context: "); mContentCaptureContext.dump(pw); pw.println();
pw.print(prefix); pw.print("activity token: "); pw.println(mActivityToken);
+ pw.print(prefix); pw.print("app component: "); pw.println(appComponentName);
pw.print(prefix); pw.print("has autofill callback: ");
}