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

Commit ff493c4f authored by lucaslin's avatar lucaslin Committed by Lucas Lin
Browse files

Don't use @hide API - ConnectivityManager#getNetworkTypeName()

To prevent calling @hide API, print definition of network type
directly instead of calling @hide API.

Bug: 172183305
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Test: Setup a platform VPN and enable VPN always-on, then check
      the log.
Change-Id: I807e90537f706face51c5cc221490ea742d22a0e
parent 464bc344
Loading
Loading
Loading
Loading
+4 −6
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.server.net;
package com.android.server.net;


import static android.net.ConnectivityManager.TYPE_NONE;
import static android.provider.Settings.ACTION_VPN_SETTINGS;
import static android.provider.Settings.ACTION_VPN_SETTINGS;


import static com.android.server.connectivity.NetworkNotificationManager.NOTIFICATION_CHANNEL_VPN;
import static com.android.server.connectivity.NetworkNotificationManager.NOTIFICATION_CHANNEL_VPN;
@@ -27,7 +28,6 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.LinkAddress;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.LinkProperties;
import android.net.NetworkInfo;
import android.net.NetworkInfo;
@@ -125,12 +125,11 @@ public class LockdownVpnTracker {
        final boolean egressChanged = egressProp == null
        final boolean egressChanged = egressProp == null
                || !TextUtils.equals(mAcceptedEgressIface, egressProp.getInterfaceName());
                || !TextUtils.equals(mAcceptedEgressIface, egressProp.getInterfaceName());


        final String egressTypeName = (egressInfo == null) ?
        final int egressType = (egressInfo == null) ? TYPE_NONE : egressInfo.getType();
                null : ConnectivityManager.getNetworkTypeName(egressInfo.getType());
        final String egressIface = (egressProp == null) ?
        final String egressIface = (egressProp == null) ?
                null : egressProp.getInterfaceName();
                null : egressProp.getInterfaceName();
        Slog.d(TAG, "handleStateChanged: egress=" + egressTypeName +
        Slog.d(TAG, "handleStateChanged: egress=" + egressType
                " " + mAcceptedEgressIface + "->" + egressIface);
                + " " + mAcceptedEgressIface + "->" + egressIface);


        if (egressDisconnected || egressChanged) {
        if (egressDisconnected || egressChanged) {
            mAcceptedEgressIface = null;
            mAcceptedEgressIface = null;
@@ -141,7 +140,6 @@ public class LockdownVpnTracker {
            return;
            return;
        }
        }


        final int egressType = egressInfo.getType();
        if (vpnInfo.getDetailedState() == DetailedState.FAILED) {
        if (vpnInfo.getDetailedState() == DetailedState.FAILED) {
            EventLogTags.writeLockdownVpnError(egressType);
            EventLogTags.writeLockdownVpnError(egressType);
        }
        }