From 6f9d732a12ca5dd84fafcf5fdb510b878bffe237 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Tue, 23 Jun 2020 16:19:55 +0800 Subject: p2p: when location mode is off, send restricted broadcast to the settings only Bug: 159368772 Test: atest FrameworksWifiTests Change-Id: Iae35daed6ede28a79064d41c499aeb8e02212ee6 --- .../java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index 56cdba83d..61e6c16bc 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -158,6 +158,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { android.Manifest.permission.ACCESS_WIFI_STATE }; + private static final String[] RECEIVER_PERMISSIONS_FOR_BROADCAST_LOCATION_OFF = { + android.Manifest.permission.NETWORK_SETTINGS, + android.Manifest.permission.ACCESS_FINE_LOCATION, + android.Manifest.permission.ACCESS_WIFI_STATE + }; + // Maximum number of bytes allowed for a network name, i.e. SSID. private static final int MAX_NETWORK_NAME_BYTES = 32; // Minimum number of bytes for a network name, i.e. DIRECT-xy. @@ -3085,8 +3091,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { private void sendBroadcastMultiplePermissions(Intent intent) { Context context = mContext.createContextAsUser(UserHandle.ALL, 0); + String[] permissions = RECEIVER_PERMISSIONS_FOR_BROADCAST; + if (!mWifiPermissionsUtil.isLocationModeEnabled()) { + permissions = RECEIVER_PERMISSIONS_FOR_BROADCAST_LOCATION_OFF; + } context.sendBroadcastWithMultiplePermissions( - intent, RECEIVER_PERMISSIONS_FOR_BROADCAST); + intent, permissions); } private void sendThisDeviceChangedBroadcast() { -- cgit v1.2.3