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

Commit 2452bc34 authored by Chalard Jean's avatar Chalard Jean Committed by Chiachang Wang
Browse files

Signal the suspended state with NetworkCapabilities

...instead of the deprecated NetworkInfo.
Also stop calling the no-op setIsAvailable.

Bug: 138306002
Test: FrameworksTelephonyTests
Change-Id: If626d1ebcbec87a6131ec79f5882f4e6408f74e6
Merged-In: If626d1ebcbec87a6131ec79f5882f4e6408f74e6
parent 88cbeede
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -609,7 +609,6 @@ public class DataConnection extends StateMachine {
        mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_MOBILE,
                networkType, NETWORK_TYPE, TelephonyManager.getNetworkTypeName(networkType));
        mNetworkInfo.setRoaming(ss.getDataRoaming());
        mNetworkInfo.setIsAvailable(true);

        addState(mDefaultState);
            addState(mInactiveState, mDefaultState);
@@ -1212,6 +1211,11 @@ public class DataConnection extends StateMachine {
    }

    /**
     * Get the network capabilities for this data connection.
     *
     * Note that this method reads fields from mNetworkInfo, so its output is only as fresh
     * as mNetworkInfo. Call updateNetworkInfoSuspendState before calling this.
     *
     * @return the {@link NetworkCapabilities} of this data connection.
     */
    public NetworkCapabilities getNetworkCapabilities() {
@@ -1352,6 +1356,10 @@ public class DataConnection extends StateMachine {
            result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
        }

        final boolean suspended =
                mNetworkInfo.getDetailedState() == NetworkInfo.DetailedState.SUSPENDED;
        result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED, !suspended);

        return result;
    }