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

Commit 8306c5c5 authored by Chiachang Wang's avatar Chiachang Wang
Browse files

Remove hidden onAvailable callback override

ConnectivityManager will be a part of incoming connectivity
mainline. Settings will no longer to access the hidden usage.
The usage in WifiStatusTracker should only need to do in the
onCapabilitiesChanged but not to refer to a hidden callback.
Replace the usage to remove the hidden dependency.

Bug: 172183305
Test: Verify the behavior works as expected
Change-Id: I1bdc1c88869ebf815117ceccd2b008681e8290c5
parent 84db0743
Loading
Loading
Loading
Loading
+12 −15
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.LinkProperties;
import android.net.Network;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkInfo;
@@ -77,10 +76,13 @@ public class WifiStatusTracker {
            .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR).build();
            .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR).build();
    private final NetworkCallback mNetworkCallback =
    private final NetworkCallback mNetworkCallback =
            new NetworkCallback(NetworkCallback.FLAG_INCLUDE_LOCATION_INFO) {
            new NetworkCallback(NetworkCallback.FLAG_INCLUDE_LOCATION_INFO) {
        // Note: onCapabilitiesChanged is guaranteed to be called "immediately" after onAvailable
        // and onLinkPropertiesChanged.
        @Override
        @Override
        public void onAvailable(
        public void onCapabilitiesChanged(
                Network network, NetworkCapabilities networkCapabilities,
                Network network, NetworkCapabilities networkCapabilities) {
                LinkProperties linkProperties, boolean blocked) {
            if (!mNetworks.contains(network.getNetId())) {
                // New network
                boolean isVcnOverWifi =
                boolean isVcnOverWifi =
                        networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
                        networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
                                && (Utils.tryGetWifiInfoForVcn(networkCapabilities) != null);
                                && (Utils.tryGetWifiInfoForVcn(networkCapabilities) != null);
@@ -91,11 +93,6 @@ public class WifiStatusTracker {
                }
                }
            }
            }


        // Note: onCapabilitiesChanged is guaranteed to be called "immediately" after onAvailable
        // and onLinkPropertiesChanged.
        @Override
        public void onCapabilitiesChanged(
                Network network, NetworkCapabilities networkCapabilities) {
            WifiInfo wifiInfo = null;
            WifiInfo wifiInfo = null;
            if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
            if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
                wifiInfo = Utils.tryGetWifiInfoForVcn(networkCapabilities);
                wifiInfo = Utils.tryGetWifiInfoForVcn(networkCapabilities);