From f8704c368e0fee0c7cf7e294d109dece6b72e832 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Fri, 5 Dec 2014 13:26:41 -0500 Subject: Allow interact-users-full access to scan results Allow callers that hold INTERACT_ACROSS_USERS_FULL access to scan results even if they aren't on the current user. Bug: 16559573 Change-Id: I27fae71b3cdc1c084777242f21fe4bb692ab7135 --- service/java/com/android/server/wifi/WifiServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index bcaab925a..8066b4c4b 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -508,13 +508,14 @@ public final class WifiServiceImpl extends IWifiManager.Stub { if (mBatchedScanSupported == false) return new ArrayList(); int uid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); + boolean hasInteractUsersFull = checkInteractAcrossUsersFull(); long ident = Binder.clearCallingIdentity(); try { if (mAppOps.noteOp(AppOpsManager.OP_WIFI_SCAN, uid, callingPackage) != AppOpsManager.MODE_ALLOWED) { return new ArrayList(); } - if (!isCurrentProfile(userId)) { + if (!isCurrentProfile(userId) && !hasInteractUsersFull) { return new ArrayList(); } return mWifiStateMachine.syncGetBatchedScanResultsList(); @@ -974,13 +975,14 @@ public final class WifiServiceImpl extends IWifiManager.Stub { enforceAccessPermission(); int userId = UserHandle.getCallingUserId(); int uid = Binder.getCallingUid(); + boolean hasInteractUsersFull = checkInteractAcrossUsersFull(); long ident = Binder.clearCallingIdentity(); try { if (mAppOps.noteOp(AppOpsManager.OP_WIFI_SCAN, uid, callingPackage) != AppOpsManager.MODE_ALLOWED) { return new ArrayList(); } - if (!isCurrentProfile(userId)) { + if (!isCurrentProfile(userId) && !hasInteractUsersFull) { return new ArrayList(); } return mWifiStateMachine.syncGetScanResultsList(); @@ -989,6 +991,15 @@ public final class WifiServiceImpl extends IWifiManager.Stub { } } + /** + * Returns true if the caller holds INTERACT_ACROSS_USERS_FULL. + */ + private boolean checkInteractAcrossUsersFull() { + return mContext.checkCallingOrSelfPermission( + android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) + == PackageManager.PERMISSION_GRANTED; + } + /** * Returns true if the calling user is the current one or a profile of the * current user.. -- cgit v1.2.3