Address comments on onBlockedStatusChanged(Network, int) CL.

Test: m
Bug: 165835257
Change-Id: I6d3007a1eac54ee6650b350aee56ed398a2c950d
This commit is contained in:
Lorenzo Colitti
2021-03-25 23:17:36 +09:00
parent 8539ed6fd2
commit a37eaff1ea
2 changed files with 8 additions and 6 deletions

View File

@@ -921,6 +921,7 @@ public class ConnectivityManager {
BLOCKED_REASON_DOZE,
BLOCKED_REASON_APP_STANDBY,
BLOCKED_REASON_RESTRICTED_MODE,
BLOCKED_REASON_LOCKDOWN_VPN,
BLOCKED_METERED_REASON_DATA_SAVER,
BLOCKED_METERED_REASON_USER_RESTRICTED,
BLOCKED_METERED_REASON_ADMIN_DISABLED,
@@ -3659,7 +3660,8 @@ public class ConnectivityManager {
public void onBlockedStatusChanged(@NonNull Network network, boolean blocked) {}
/**
* Called when access to the specified network is blocked or unblocked.
* Called when access to the specified network is blocked or unblocked, or the reason for
* access being blocked changes.
*
* If a NetworkCallback object implements this method,
* {@link #onBlockedStatusChanged(Network, boolean)} will not be called.

View File

@@ -1551,16 +1551,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
mNetworkInfoBlockingLogs.log(action + " " + uid);
}
private void maybeLogBlockedStatusChanged(NetworkRequestInfo nri, Network net,
boolean blocked) {
private void maybeLogBlockedStatusChanged(NetworkRequestInfo nri, Network net, int blocked) {
if (nri == null || net == null || !LOGD_BLOCKED_NETWORKINFO) {
return;
}
final String action = blocked ? "BLOCKED" : "UNBLOCKED";
final String action = (blocked != 0) ? "BLOCKED" : "UNBLOCKED";
final int requestId = nri.getActiveRequest() != null
? nri.getActiveRequest().requestId : nri.mRequests.get(0).requestId;
mNetworkInfoBlockingLogs.log(String.format(
"%s %d(%d) on netId %d", action, nri.mAsUid, requestId, net.getNetId()));
"%s %d(%d) on netId %d: %s", action, nri.mAsUid, requestId, net.getNetId(),
blockedReasonsToString(blocked)));
}
/**
@@ -7348,7 +7348,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
break;
}
case ConnectivityManager.CALLBACK_BLK_CHANGED: {
maybeLogBlockedStatusChanged(nri, networkAgent.network, arg1 != 0);
maybeLogBlockedStatusChanged(nri, networkAgent.network, arg1);
msg.arg1 = arg1;
break;
}