Merge "Fix ClipboardService's auto-clearing where wrong uid was being used." into tm-dev am: 253a442943

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18419539

Change-Id: Ieb5578dd7f5553436dbbaf19f6a1fc940461c392
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Gaurav Bhola
2022-05-18 21:20:10 +00:00
committed by Automerger Merge Worker

View File

@@ -380,12 +380,12 @@ public class ClipboardService extends SystemService {
}
checkDataOwner(clip, intendingUid);
synchronized (mLock) {
scheduleAutoClear(userId);
scheduleAutoClear(userId, intendingUid);
setPrimaryClipInternalLocked(clip, intendingUid, sourcePackage);
}
}
private void scheduleAutoClear(@UserIdInt int userId) {
private void scheduleAutoClear(@UserIdInt int userId, int intendingUid) {
final long oldIdentity = Binder.clearCallingIdentity();
try {
if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_CLIPBOARD,
@@ -393,7 +393,7 @@ public class ClipboardService extends SystemService {
mClipboardClearHandler.removeEqualMessages(ClipboardClearHandler.MSG_CLEAR,
userId);
Message clearMessage = Message.obtain(mClipboardClearHandler,
ClipboardClearHandler.MSG_CLEAR, userId, 0, userId);
ClipboardClearHandler.MSG_CLEAR, userId, intendingUid, userId);
mClipboardClearHandler.sendMessageDelayed(clearMessage,
getTimeoutForAutoClear());
}
@@ -446,7 +446,7 @@ public class ClipboardService extends SystemService {
showAccessNotificationLocked(pkg, intendingUid, intendingUserId, clipboard);
notifyTextClassifierLocked(clipboard, pkg, intendingUid);
if (clipboard.primaryClip != null) {
scheduleAutoClear(userId);
scheduleAutoClear(userId, intendingUid);
}
return clipboard.primaryClip;
}
@@ -554,11 +554,12 @@ public class ClipboardService extends SystemService {
switch (msg.what) {
case MSG_CLEAR:
final int userId = msg.arg1;
final int intendingUid = msg.arg2;
synchronized (mLock) {
if (getClipboardLocked(userId).primaryClip != null) {
FrameworkStatsLog.write(FrameworkStatsLog.CLIPBOARD_CLEARED,
FrameworkStatsLog.CLIPBOARD_CLEARED__SOURCE__AUTO_CLEAR);
setPrimaryClipInternalLocked(null, Binder.getCallingUid(), null);
setPrimaryClipInternalLocked(null, intendingUid, null);
}
}
break;