Prevent getting data from Clipboard if device is locked
Clipboard should not return data if the device is locked. This CL checks for device locked state before returning values from get/has functions. Test: bit -t CtsContentTestCases:android.content.cts.ClipboardManagerTest Bug: 64934810 Change-Id: Icefac226615fe22a7735dff4ba4c3b528fb2ac12
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.ActivityManager;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipDescription;
|
||||
import android.content.ContentProvider;
|
||||
@@ -304,7 +305,7 @@ public class ClipboardService extends SystemService {
|
||||
public ClipData getPrimaryClip(String pkg) {
|
||||
synchronized (this) {
|
||||
if (!clipboardAccessAllowed(AppOpsManager.OP_READ_CLIPBOARD, pkg,
|
||||
Binder.getCallingUid())) {
|
||||
Binder.getCallingUid()) || isDeviceLocked()) {
|
||||
return null;
|
||||
}
|
||||
addActiveOwnerLocked(Binder.getCallingUid(), pkg);
|
||||
@@ -316,7 +317,7 @@ public class ClipboardService extends SystemService {
|
||||
public ClipDescription getPrimaryClipDescription(String callingPackage) {
|
||||
synchronized (this) {
|
||||
if (!clipboardAccessAllowed(AppOpsManager.OP_READ_CLIPBOARD, callingPackage,
|
||||
Binder.getCallingUid())) {
|
||||
Binder.getCallingUid()) || isDeviceLocked()) {
|
||||
return null;
|
||||
}
|
||||
PerUserClipboard clipboard = getClipboard();
|
||||
@@ -328,7 +329,7 @@ public class ClipboardService extends SystemService {
|
||||
public boolean hasPrimaryClip(String callingPackage) {
|
||||
synchronized (this) {
|
||||
if (!clipboardAccessAllowed(AppOpsManager.OP_READ_CLIPBOARD, callingPackage,
|
||||
Binder.getCallingUid())) {
|
||||
Binder.getCallingUid()) || isDeviceLocked()) {
|
||||
return false;
|
||||
}
|
||||
return getClipboard().primaryClip != null;
|
||||
@@ -355,7 +356,7 @@ public class ClipboardService extends SystemService {
|
||||
public boolean hasClipboardText(String callingPackage) {
|
||||
synchronized (this) {
|
||||
if (!clipboardAccessAllowed(AppOpsManager.OP_READ_CLIPBOARD, callingPackage,
|
||||
Binder.getCallingUid())) {
|
||||
Binder.getCallingUid()) || isDeviceLocked()) {
|
||||
return false;
|
||||
}
|
||||
PerUserClipboard clipboard = getClipboard();
|
||||
@@ -433,6 +434,12 @@ public class ClipboardService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDeviceLocked() {
|
||||
final KeyguardManager keyguardManager = getContext().getSystemService(
|
||||
KeyguardManager.class);
|
||||
return keyguardManager != null && keyguardManager.isDeviceLocked();
|
||||
}
|
||||
|
||||
private final void checkUriOwnerLocked(Uri uri, int uid) {
|
||||
if (!"content".equals(uri.getScheme())) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user