Merge "Add MUTABLE flag when creating PendingIntent" am: f754671f07
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1598634 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I7260575a7b680dbe09599aba59ef597ed42d387b
This commit is contained in:
@@ -570,17 +570,23 @@ public class ConnectivityManagerTest {
|
|||||||
|
|
||||||
// Create a ConnectivityActionReceiver that has an IntentFilter for our locally defined
|
// Create a ConnectivityActionReceiver that has an IntentFilter for our locally defined
|
||||||
// action, NETWORK_CALLBACK_ACTION.
|
// action, NETWORK_CALLBACK_ACTION.
|
||||||
IntentFilter filter = new IntentFilter();
|
final IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(NETWORK_CALLBACK_ACTION);
|
filter.addAction(NETWORK_CALLBACK_ACTION);
|
||||||
|
|
||||||
ConnectivityActionReceiver receiver = new ConnectivityActionReceiver(
|
final ConnectivityActionReceiver receiver = new ConnectivityActionReceiver(
|
||||||
mCm, ConnectivityManager.TYPE_WIFI, NetworkInfo.State.CONNECTED);
|
mCm, ConnectivityManager.TYPE_WIFI, NetworkInfo.State.CONNECTED);
|
||||||
mContext.registerReceiver(receiver, filter);
|
mContext.registerReceiver(receiver, filter);
|
||||||
|
|
||||||
// Create a broadcast PendingIntent for NETWORK_CALLBACK_ACTION.
|
// Create a broadcast PendingIntent for NETWORK_CALLBACK_ACTION.
|
||||||
Intent intent = new Intent(NETWORK_CALLBACK_ACTION);
|
final Intent intent = new Intent(NETWORK_CALLBACK_ACTION)
|
||||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(
|
.setPackage(mContext.getPackageName());
|
||||||
mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
// While ConnectivityService would put extra info such as network or request id before
|
||||||
|
// broadcasting the inner intent. The MUTABLE flag needs to be added accordingly.
|
||||||
|
// TODO: replace with PendingIntent.FLAG_MUTABLE when this code compiles against S+ or
|
||||||
|
// shims.
|
||||||
|
final int pendingIntentFlagMutable = 1 << 25;
|
||||||
|
final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0 /*requestCode*/,
|
||||||
|
intent, PendingIntent.FLAG_CANCEL_CURRENT | pendingIntentFlagMutable);
|
||||||
|
|
||||||
// We will register for a WIFI network being available or lost.
|
// We will register for a WIFI network being available or lost.
|
||||||
mCm.registerNetworkCallback(makeWifiNetworkRequest(), pendingIntent);
|
mCm.registerNetworkCallback(makeWifiNetworkRequest(), pendingIntent);
|
||||||
|
|||||||
Reference in New Issue
Block a user