Merge "Fix ClipboardService's auto-clearing where wrong uid was being used." into tm-dev
This commit is contained in:
@@ -380,12 +380,12 @@ public class ClipboardService extends SystemService {
|
|||||||
}
|
}
|
||||||
checkDataOwner(clip, intendingUid);
|
checkDataOwner(clip, intendingUid);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
scheduleAutoClear(userId);
|
scheduleAutoClear(userId, intendingUid);
|
||||||
setPrimaryClipInternalLocked(clip, intendingUid, sourcePackage);
|
setPrimaryClipInternalLocked(clip, intendingUid, sourcePackage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleAutoClear(@UserIdInt int userId) {
|
private void scheduleAutoClear(@UserIdInt int userId, int intendingUid) {
|
||||||
final long oldIdentity = Binder.clearCallingIdentity();
|
final long oldIdentity = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_CLIPBOARD,
|
if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_CLIPBOARD,
|
||||||
@@ -393,7 +393,7 @@ public class ClipboardService extends SystemService {
|
|||||||
mClipboardClearHandler.removeEqualMessages(ClipboardClearHandler.MSG_CLEAR,
|
mClipboardClearHandler.removeEqualMessages(ClipboardClearHandler.MSG_CLEAR,
|
||||||
userId);
|
userId);
|
||||||
Message clearMessage = Message.obtain(mClipboardClearHandler,
|
Message clearMessage = Message.obtain(mClipboardClearHandler,
|
||||||
ClipboardClearHandler.MSG_CLEAR, userId, 0, userId);
|
ClipboardClearHandler.MSG_CLEAR, userId, intendingUid, userId);
|
||||||
mClipboardClearHandler.sendMessageDelayed(clearMessage,
|
mClipboardClearHandler.sendMessageDelayed(clearMessage,
|
||||||
getTimeoutForAutoClear());
|
getTimeoutForAutoClear());
|
||||||
}
|
}
|
||||||
@@ -446,7 +446,7 @@ public class ClipboardService extends SystemService {
|
|||||||
showAccessNotificationLocked(pkg, intendingUid, intendingUserId, clipboard);
|
showAccessNotificationLocked(pkg, intendingUid, intendingUserId, clipboard);
|
||||||
notifyTextClassifierLocked(clipboard, pkg, intendingUid);
|
notifyTextClassifierLocked(clipboard, pkg, intendingUid);
|
||||||
if (clipboard.primaryClip != null) {
|
if (clipboard.primaryClip != null) {
|
||||||
scheduleAutoClear(userId);
|
scheduleAutoClear(userId, intendingUid);
|
||||||
}
|
}
|
||||||
return clipboard.primaryClip;
|
return clipboard.primaryClip;
|
||||||
}
|
}
|
||||||
@@ -554,11 +554,12 @@ public class ClipboardService extends SystemService {
|
|||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_CLEAR:
|
case MSG_CLEAR:
|
||||||
final int userId = msg.arg1;
|
final int userId = msg.arg1;
|
||||||
|
final int intendingUid = msg.arg2;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (getClipboardLocked(userId).primaryClip != null) {
|
if (getClipboardLocked(userId).primaryClip != null) {
|
||||||
FrameworkStatsLog.write(FrameworkStatsLog.CLIPBOARD_CLEARED,
|
FrameworkStatsLog.write(FrameworkStatsLog.CLIPBOARD_CLEARED,
|
||||||
FrameworkStatsLog.CLIPBOARD_CLEARED__SOURCE__AUTO_CLEAR);
|
FrameworkStatsLog.CLIPBOARD_CLEARED__SOURCE__AUTO_CLEAR);
|
||||||
setPrimaryClipInternalLocked(null, Binder.getCallingUid(), null);
|
setPrimaryClipInternalLocked(null, intendingUid, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user