summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java14
-rw-r--r--tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java7
2 files changed, 12 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 06e009326..3ed56a619 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -3003,21 +3003,24 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
+ private void sendBroadcastMultiplePermissions(Intent intent) {
+ Context context = mContext.createContextAsUser(UserHandle.ALL, 0);
+ context.sendBroadcastMultiplePermissions(intent, RECEIVER_PERMISSIONS_FOR_BROADCAST);
+ }
+
private void sendThisDeviceChangedBroadcast() {
final Intent intent = new Intent(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
intent.putExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE,
eraseOwnDeviceAddress(mThisDevice));
- mContext.sendBroadcastAsUserMultiplePermissions(intent, UserHandle.ALL,
- RECEIVER_PERMISSIONS_FOR_BROADCAST);
+ sendBroadcastMultiplePermissions(intent);
}
private void sendPeersChangedBroadcast() {
final Intent intent = new Intent(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intent.putExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST, new WifiP2pDeviceList(mPeers));
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- mContext.sendBroadcastAsUserMultiplePermissions(intent, UserHandle.ALL,
- RECEIVER_PERMISSIONS_FOR_BROADCAST);
+ sendBroadcastMultiplePermissions(intent);
}
private void sendP2pConnectionChangedBroadcast() {
@@ -3028,8 +3031,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
intent.putExtra(WifiP2pManager.EXTRA_WIFI_P2P_INFO, new WifiP2pInfo(mWifiP2pInfo));
intent.putExtra(WifiP2pManager.EXTRA_NETWORK_INFO, new NetworkInfo(mNetworkInfo));
intent.putExtra(WifiP2pManager.EXTRA_WIFI_P2P_GROUP, eraseOwnDeviceAddress(mGroup));
- mContext.sendBroadcastAsUserMultiplePermissions(intent, UserHandle.ALL,
- RECEIVER_PERMISSIONS_FOR_BROADCAST);
+ sendBroadcastMultiplePermissions(intent);
if (mWifiChannel != null) {
mWifiChannel.sendMessage(WifiP2pServiceImpl.P2P_CONNECTION_CHANGED,
new NetworkInfo(mNetworkInfo));
diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
index e5d1c3e68..95ffbc6c2 100644
--- a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
@@ -150,7 +150,6 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Spy FakeWifiLog mLog;
@Spy MockWifiP2pMonitor mWifiMonitor;
-
private void generatorTestData() {
mTestWifiP2pGroup = new WifiP2pGroup();
mTestWifiP2pGroup.setNetworkName("TestGroupName");
@@ -646,8 +645,8 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
String[] permission_gold = new String[] {android.Manifest.permission.ACCESS_FINE_LOCATION,
android.Manifest.permission.ACCESS_WIFI_STATE};
ArgumentCaptor<String []> permissionCaptor = ArgumentCaptor.forClass(String[].class);
- verify(mContext, atLeastOnce()).sendBroadcastAsUserMultiplePermissions(
- intentCaptor.capture(), eq(UserHandle.ALL), permissionCaptor.capture());
+ verify(mContext, atLeastOnce()).sendBroadcastMultiplePermissions(
+ intentCaptor.capture(), permissionCaptor.capture());
String [] permission = permissionCaptor.getValue();
Arrays.sort(permission);
Arrays.sort(permission_gold);
@@ -769,6 +768,8 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
setUpWifiP2pServiceImpl(true);
mClient1 = new Binder();
mClient2 = new Binder();
+
+ when(mContext.createContextAsUser(any(), anyInt())).thenReturn(mContext);
}
/**