summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiyamed Sinir <siyamed@google.com>2017-09-06 15:15:44 -0700
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-09-21 20:30:58 +0000
commit2e4b1923efbe0064e55dd671b764af7869d13332 (patch)
tree01d62119191a29bfb2b53a265aa73d7b1ca82d79
parentce8518bd2be0a496a5c4725bae461234fa98bddd (diff)
downloadbase-2e4b1923efbe0064e55dd671b764af7869d13332.tar.gz
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 (cherry picked from commit 93d77b07c34077b6c403c459b7bb75933446a502)
-rw-r--r--services/core/java/com/android/server/clipboard/ClipboardService.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java
index db72c5e4cbab..efc930ebf8ea 100644
--- a/services/core/java/com/android/server/clipboard/ClipboardService.java
+++ b/services/core/java/com/android/server/clipboard/ClipboardService.java
@@ -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;