Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2691c0d0 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Address comments on onBlockedStatusChanged(Network, int) CL.

Test: m
Bug: 165835257
Change-Id: I6d3007a1eac54ee6650b350aee56ed398a2c950d
parent 31e7ebdd
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -921,6 +921,7 @@ public class ConnectivityManager {
            BLOCKED_REASON_DOZE,
            BLOCKED_REASON_DOZE,
            BLOCKED_REASON_APP_STANDBY,
            BLOCKED_REASON_APP_STANDBY,
            BLOCKED_REASON_RESTRICTED_MODE,
            BLOCKED_REASON_RESTRICTED_MODE,
            BLOCKED_REASON_LOCKDOWN_VPN,
            BLOCKED_METERED_REASON_DATA_SAVER,
            BLOCKED_METERED_REASON_DATA_SAVER,
            BLOCKED_METERED_REASON_USER_RESTRICTED,
            BLOCKED_METERED_REASON_USER_RESTRICTED,
            BLOCKED_METERED_REASON_ADMIN_DISABLED,
            BLOCKED_METERED_REASON_ADMIN_DISABLED,
@@ -3659,7 +3660,8 @@ public class ConnectivityManager {
        public void onBlockedStatusChanged(@NonNull Network network, boolean blocked) {}
        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,
         * If a NetworkCallback object implements this method,
         * {@link #onBlockedStatusChanged(Network, boolean)} will not be called.
         * {@link #onBlockedStatusChanged(Network, boolean)} will not be called.
+5 −5
Original line number Original line Diff line number Diff line
@@ -1551,16 +1551,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
        mNetworkInfoBlockingLogs.log(action + " " + uid);
        mNetworkInfoBlockingLogs.log(action + " " + uid);
    }
    }


    private void maybeLogBlockedStatusChanged(NetworkRequestInfo nri, Network net,
    private void maybeLogBlockedStatusChanged(NetworkRequestInfo nri, Network net, int blocked) {
            boolean blocked) {
        if (nri == null || net == null || !LOGD_BLOCKED_NETWORKINFO) {
        if (nri == null || net == null || !LOGD_BLOCKED_NETWORKINFO) {
            return;
            return;
        }
        }
        final String action = blocked ? "BLOCKED" : "UNBLOCKED";
        final String action = (blocked != 0) ? "BLOCKED" : "UNBLOCKED";
        final int requestId = nri.getActiveRequest() != null
        final int requestId = nri.getActiveRequest() != null
                ? nri.getActiveRequest().requestId : nri.mRequests.get(0).requestId;
                ? nri.getActiveRequest().requestId : nri.mRequests.get(0).requestId;
        mNetworkInfoBlockingLogs.log(String.format(
        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;
                break;
            }
            }
            case ConnectivityManager.CALLBACK_BLK_CHANGED: {
            case ConnectivityManager.CALLBACK_BLK_CHANGED: {
                maybeLogBlockedStatusChanged(nri, networkAgent.network, arg1 != 0);
                maybeLogBlockedStatusChanged(nri, networkAgent.network, arg1);
                msg.arg1 = arg1;
                msg.arg1 = arg1;
                break;
                break;
            }
            }