summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorSohani Rao <sohanirao@google.com>2016-09-29 16:17:31 -0700
committerSohani Rao <sohanirao@google.com>2016-11-14 10:21:01 -0800
commitf42abad834d95e716d8e423bcfc0d17bce90d021 (patch)
tree4fbf84a575f8f32552fcdd8ce86bf32874b9b0d9 /service
parentb88000ed5302860e71e32646695daf661f56d927 (diff)
Permissions check for Wifi Display configuration
Wifi Display is configured using the AIDL call setMiracastMode() and using a message over the async channel SET_WFD_INFO. Enforce permissions on the calling uid before updating the config Bug: 18668877 Test: Unit tests Change-Id: Idd08e1f769f2fa37596cbec67fbf92919c4fd67b Merged-In: Idd08e1f769f2fa37596cbec67fbf92919c4fd67b
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java44
1 files changed, 39 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index e3e56c8d3..e27b473a3 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -84,6 +84,7 @@ import com.android.server.wifi.WifiNative;
import com.android.server.wifi.WifiStateMachine;
import com.android.server.wifi.util.WifiAsyncChannel;
import com.android.server.wifi.util.WifiPermissionsUtil;
+import com.android.server.wifi.util.WifiPermissionsWrapper;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -117,6 +118,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
private P2pStateMachine mP2pStateMachine;
private AsyncChannel mReplyChannel = new WifiAsyncChannel(TAG);
private AsyncChannel mWifiChannel;
+ private WifiInjector mWifiInjector;
private static final Boolean JOIN_GROUP = true;
private static final Boolean FORM_GROUP = false;
@@ -496,10 +498,29 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
@Override
public void setMiracastMode(int mode) {
enforceConnectivityInternalPermission();
+ checkConfigureWifiDisplayPermission();
mP2pStateMachine.sendMessage(SET_MIRACAST_MODE, mode);
}
@Override
+ public void checkConfigureWifiDisplayPermission() {
+ if (!getWfdPermission(Binder.getCallingUid())) {
+ throw new SecurityException("Wifi Display Permission denied for uid = "
+ + Binder.getCallingUid());
+ }
+ }
+
+ private boolean getWfdPermission(int uid) {
+ if (mWifiInjector == null) {
+ mWifiInjector = WifiInjector.getInstance();
+ }
+ WifiPermissionsWrapper wifiPermissionsWrapper = mWifiInjector.getWifiPermissionsWrapper();
+ return wifiPermissionsWrapper.getUidPermission(
+ android.Manifest.permission.CONFIGURE_WIFI_DISPLAY, uid)
+ != PackageManager.PERMISSION_DENIED;
+ }
+
+ @Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
!= PackageManager.PERMISSION_GRANTED) {
@@ -780,8 +801,13 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pManager.BUSY);
break;
case WifiP2pManager.SET_WFD_INFO:
- replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
- WifiP2pManager.BUSY);
+ if (!getWfdPermission(message.sendingUid)) {
+ replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
+ WifiP2pManager.ERROR);
+ } else {
+ replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
+ WifiP2pManager.BUSY);
+ }
break;
case WifiP2pManager.REQUEST_PEERS:
replyToMessage(message, WifiP2pManager.RESPONSE_PEERS,
@@ -940,8 +966,13 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pManager.P2P_UNSUPPORTED);
break;
case WifiP2pManager.SET_WFD_INFO:
- replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
- WifiP2pManager.P2P_UNSUPPORTED);
+ if (!getWfdPermission(message.sendingUid)) {
+ replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
+ WifiP2pManager.ERROR);
+ } else {
+ replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
+ WifiP2pManager.P2P_UNSUPPORTED);
+ }
break;
case WifiP2pManager.START_WPS:
replyToMessage(message, WifiP2pManager.START_WPS_FAILED,
@@ -1103,7 +1134,10 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiP2pManager.SET_WFD_INFO:
{
WifiP2pWfdInfo d = (WifiP2pWfdInfo) message.obj;
- if (d != null && setWfdInfo(d)) {
+ if (!getWfdPermission(message.sendingUid)) {
+ replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,
+ WifiP2pManager.ERROR);
+ } else if (d != null && setWfdInfo(d)) {
replyToMessage(message, WifiP2pManager.SET_WFD_INFO_SUCCEEDED);
} else {
replyToMessage(message, WifiP2pManager.SET_WFD_INFO_FAILED,