Merge "Prevent getting data from Clipboard if device is locked" into mnc-dev am: 06183a57a6 am: 028ad8d498 am: 6352ced635 am: 064bfd22be
am: 8393b54d3e
Change-Id: If5b7319d2514ce67467d6092c99a4661155938e0
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.ActivityManagerNative;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipDescription;
|
||||
@@ -255,7 +256,7 @@ public class ClipboardService extends IClipboard.Stub {
|
||||
public ClipData getPrimaryClip(String pkg) {
|
||||
synchronized (this) {
|
||||
if (mAppOps.noteOp(AppOpsManager.OP_READ_CLIPBOARD, Binder.getCallingUid(),
|
||||
pkg) != AppOpsManager.MODE_ALLOWED) {
|
||||
pkg) != AppOpsManager.MODE_ALLOWED || isDeviceLocked()) {
|
||||
return null;
|
||||
}
|
||||
addActiveOwnerLocked(Binder.getCallingUid(), pkg);
|
||||
@@ -266,7 +267,7 @@ public class ClipboardService extends IClipboard.Stub {
|
||||
public ClipDescription getPrimaryClipDescription(String callingPackage) {
|
||||
synchronized (this) {
|
||||
if (mAppOps.checkOp(AppOpsManager.OP_READ_CLIPBOARD, Binder.getCallingUid(),
|
||||
callingPackage) != AppOpsManager.MODE_ALLOWED) {
|
||||
callingPackage) != AppOpsManager.MODE_ALLOWED || isDeviceLocked()) {
|
||||
return null;
|
||||
}
|
||||
PerUserClipboard clipboard = getClipboard();
|
||||
@@ -277,7 +278,7 @@ public class ClipboardService extends IClipboard.Stub {
|
||||
public boolean hasPrimaryClip(String callingPackage) {
|
||||
synchronized (this) {
|
||||
if (mAppOps.checkOp(AppOpsManager.OP_READ_CLIPBOARD, Binder.getCallingUid(),
|
||||
callingPackage) != AppOpsManager.MODE_ALLOWED) {
|
||||
callingPackage) != AppOpsManager.MODE_ALLOWED || isDeviceLocked()) {
|
||||
return false;
|
||||
}
|
||||
return getClipboard().primaryClip != null;
|
||||
@@ -301,7 +302,7 @@ public class ClipboardService extends IClipboard.Stub {
|
||||
public boolean hasClipboardText(String callingPackage) {
|
||||
synchronized (this) {
|
||||
if (mAppOps.checkOp(AppOpsManager.OP_READ_CLIPBOARD, Binder.getCallingUid(),
|
||||
callingPackage) != AppOpsManager.MODE_ALLOWED) {
|
||||
callingPackage) != AppOpsManager.MODE_ALLOWED || isDeviceLocked()) {
|
||||
return false;
|
||||
}
|
||||
PerUserClipboard clipboard = getClipboard();
|
||||
@@ -313,6 +314,11 @@ public class ClipboardService extends IClipboard.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDeviceLocked() {
|
||||
final KeyguardManager keyguardManager = mContext.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