Merge "Fix null PendingIntent in network listens" into sc-dev am: 4fd9dfef2d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15136918 Change-Id: Ie000ca0d22891120f5dda8a8088596ef84f02005
This commit is contained in:
@@ -7596,9 +7596,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// If apps could file multi-layer requests with PendingIntents, they'd need to know
|
// If apps could file multi-layer requests with PendingIntents, they'd need to know
|
||||||
// which of the layer is satisfied alongside with some ID for the request. Hence, if
|
// which of the layer is satisfied alongside with some ID for the request. Hence, if
|
||||||
// such an API is ever implemented, there is no doubt the right request to send in
|
// such an API is ever implemented, there is no doubt the right request to send in
|
||||||
// EXTRA_NETWORK_REQUEST is mActiveRequest, and whatever ID would be added would need to
|
// EXTRA_NETWORK_REQUEST is the active request, and whatever ID would be added would
|
||||||
// be sent as a separate extra.
|
// need to be sent as a separate extra.
|
||||||
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_REQUEST, nri.getActiveRequest());
|
final NetworkRequest req = nri.isMultilayerRequest()
|
||||||
|
? nri.getActiveRequest()
|
||||||
|
// Non-multilayer listen requests do not have an active request
|
||||||
|
: nri.mRequests.get(0);
|
||||||
|
if (req == null) {
|
||||||
|
Log.wtf(TAG, "No request in NRI " + nri);
|
||||||
|
}
|
||||||
|
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_REQUEST, req);
|
||||||
nri.mPendingIntentSent = true;
|
nri.mPendingIntentSent = true;
|
||||||
sendIntent(nri.mPendingIntent, intent);
|
sendIntent(nri.mPendingIntent, intent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ import static android.system.OsConstants.AF_UNSPEC;
|
|||||||
import static com.android.compatibility.common.util.SystemUtil.callWithShellPermissionIdentity;
|
import static com.android.compatibility.common.util.SystemUtil.callWithShellPermissionIdentity;
|
||||||
import static com.android.compatibility.common.util.SystemUtil.runShellCommand;
|
import static com.android.compatibility.common.util.SystemUtil.runShellCommand;
|
||||||
import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
|
import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
|
||||||
import static com.android.modules.utils.build.SdkLevel.isAtLeastS;
|
|
||||||
import static com.android.networkstack.apishim.ConstantsShim.BLOCKED_REASON_LOCKDOWN_VPN;
|
import static com.android.networkstack.apishim.ConstantsShim.BLOCKED_REASON_LOCKDOWN_VPN;
|
||||||
import static com.android.networkstack.apishim.ConstantsShim.BLOCKED_REASON_NONE;
|
import static com.android.networkstack.apishim.ConstantsShim.BLOCKED_REASON_NONE;
|
||||||
import static com.android.testutils.MiscAsserts.assertThrows;
|
import static com.android.testutils.MiscAsserts.assertThrows;
|
||||||
@@ -958,8 +957,6 @@ public class ConnectivityManagerTest {
|
|||||||
|
|
||||||
private void assertPendingIntentRequestMatches(NetworkRequest broadcasted, NetworkRequest filed,
|
private void assertPendingIntentRequestMatches(NetworkRequest broadcasted, NetworkRequest filed,
|
||||||
boolean useListen) {
|
boolean useListen) {
|
||||||
// TODO: BUG (b/191713869): on S the request extra is null on listens
|
|
||||||
if (isAtLeastS() && useListen && broadcasted == null) return;
|
|
||||||
assertArrayEquals(filed.networkCapabilities.getCapabilities(),
|
assertArrayEquals(filed.networkCapabilities.getCapabilities(),
|
||||||
broadcasted.networkCapabilities.getCapabilities());
|
broadcasted.networkCapabilities.getCapabilities());
|
||||||
// TODO: BUG (b/189868426): this should also apply to listens
|
// TODO: BUG (b/189868426): this should also apply to listens
|
||||||
|
|||||||
Reference in New Issue
Block a user