Merge "Prevent getting data from Clipboard if device is locked" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
846a46043c
@@ -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