summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-01-10 06:06:08 -0800
committerRoshan Pius <rpius@google.com>2020-01-10 13:14:38 -0800
commit10100b7c3c9afaf4823894dcb5ce18c8b2e664c1 (patch)
tree30f3b93f1b93e596d377f5b5cc34ae85761a37ab
parentac7ae343e133eb1def86cbbbc3b2ab2c6d4ab3a8 (diff)
WifiServiceImpl: Alternative to @hide FLAG_RECEIVER_INCLUDE_BACKGROUND
Implementing an alternative to sending broadcast with @hide flag FLAG_RECEIVER_INCLUDE_BACKGROUND. Instead of using the flag, find the list of registered broadcast receivers and send them directed broadcasts to wake them up. Bug: 147374337 Test: Performed network reset, ensured that carrier wifi app received the intent. Change-Id: I05b9c50c941631e295461542e7bfe38fd4785708
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index eb8a50227..90f9e8186 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -33,12 +33,14 @@ import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
+import android.content.pm.ResolveInfo;
import android.database.ContentObserver;
import android.net.DhcpInfo;
import android.net.DhcpResults;
@@ -3111,9 +3113,23 @@ public class WifiServiceImpl extends BaseWifiService {
*/
private void notifyFactoryReset() {
Intent intent = new Intent(WifiManager.ACTION_NETWORK_SETTINGS_RESET);
- intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
- mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
- android.Manifest.permission.NETWORK_CARRIER_PROVISIONING);
+
+ // Retrieve list of broadcast receivers for this broadcast & send them directed broadcasts
+ // to wake them up (if they're in background).
+ List<ResolveInfo> resolveInfos =
+ mContext.getPackageManager().queryBroadcastReceiversAsUser(
+ intent, 0,
+ UserHandle.of(mWifiInjector.getWifiPermissionsWrapper().getCurrentUser()));
+ if (resolveInfos == null || resolveInfos.isEmpty()) return; // No need to send broadcast.
+
+ for (ResolveInfo resolveInfo : resolveInfos) {
+ Intent intentToSend = new Intent(intent);
+ intentToSend.setComponent(new ComponentName(
+ resolveInfo.activityInfo.applicationInfo.packageName,
+ resolveInfo.activityInfo.name));
+ mContext.sendBroadcastAsUser(intentToSend, UserHandle.ALL,
+ android.Manifest.permission.NETWORK_CARRIER_PROVISIONING);
+ }
}
@Override