From ff831c8e8dff31c14b418cce9cfd238f46f5152f Mon Sep 17 00:00:00 2001 From: David Su Date: Mon, 28 Sep 2020 19:55:29 -0700 Subject: WifiConfigManager: protect CONFIGURED_NETWORKS_CHANGED_ACTION with permissions Guard with ACCESS_WIFI_STATE & ACCESS_FINE_LOCATION permissions. Bug: 158874479 Bug: 159373687 Test: presubmit unit tests Test: Verify Settings still works correctly. Change-Id: I88d93006ff379105e13e1b339ec51757a56ac863 Merged-In: I657063f68701d57cfeb3765dfbab25ba50ef7b97 --- service/java/com/android/server/wifi/WifiConfigManager.java | 8 +++++++- .../src/com/android/server/wifi/WifiConfigManagerTest.java | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 7dc938b34..c06e80239 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -657,7 +657,13 @@ public class WifiConfigManager { maskPasswordsInWifiConfiguration(broadcastNetwork); intent.putExtra(WifiManager.EXTRA_WIFI_CONFIGURATION, broadcastNetwork); intent.putExtra(WifiManager.EXTRA_CHANGE_REASON, reason); - mContext.sendBroadcastAsUser(intent, UserHandle.ALL); + mContext.sendBroadcastAsUserMultiplePermissions( + intent, + UserHandle.ALL, + new String[]{ + android.Manifest.permission.ACCESS_WIFI_STATE, + android.Manifest.permission.ACCESS_FINE_LOCATION, + }); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index a4bc61aa1..ca1b4a07c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -3844,8 +3844,8 @@ public class WifiConfigManagerTest { private int verifyNetworkInBroadcastAndReturnReason(WifiConfiguration configuration) { ArgumentCaptor intentCaptor = ArgumentCaptor.forClass(Intent.class); ArgumentCaptor userHandleCaptor = ArgumentCaptor.forClass(UserHandle.class); - mContextConfigStoreMockOrder.verify(mContext) - .sendBroadcastAsUser(intentCaptor.capture(), userHandleCaptor.capture()); + mContextConfigStoreMockOrder.verify(mContext).sendBroadcastAsUserMultiplePermissions( + intentCaptor.capture(), userHandleCaptor.capture(), any()); assertEquals(userHandleCaptor.getValue(), UserHandle.ALL); Intent intent = intentCaptor.getValue(); -- cgit v1.2.3