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

Commit 82d6d337 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Some networks may have null ifaces, I guess?" into lmp-dev

parents a3dabf0f 9da2f1e0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.net;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.ProxyInfo;
import android.os.Parcelable;
import android.os.Parcel;
@@ -124,7 +125,7 @@ public final class LinkProperties implements Parcelable {
     *
     * @return The interface name set for this link or {@code null}.
     */
    public String getInterfaceName() {
    public @Nullable String getInterfaceName() {
        return mIfaceName;
    }

+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.util.LogWriter;
@@ -3744,6 +3745,7 @@ public final class BatteryStatsImpl extends BatteryStats {
    }

    public void noteNetworkInterfaceTypeLocked(String iface, int networkType) {
        if (TextUtils.isEmpty(iface)) return;
        if (ConnectivityManager.isNetworkTypeMobile(networkType)) {
            mMobileIfaces = includeInStringArray(mMobileIfaces, iface);
            if (DEBUG) Slog.d(TAG, "Note mobile iface " + iface + ": " + mMobileIfaces);
+10 −6
Original line number Diff line number Diff line
@@ -1060,16 +1060,19 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state);

                final String baseIface = state.linkProperties.getInterfaceName();
                if (baseIface != null) {
                    connIdents.add(Pair.create(baseIface, ident));
                    if (powerSave) {
                        connIfaces.add(baseIface);
                    }
                }

                // Stacked interfaces are considered to have same identity as
                // their parent network.
                final List<LinkProperties> stackedLinks = state.linkProperties.getStackedLinks();
                for (LinkProperties stackedLink : stackedLinks) {
                    final String stackedIface = stackedLink.getInterfaceName();
                    if (stackedIface != null) {
                        connIdents.add(Pair.create(stackedIface, ident));
                        if (powerSave) {
                            connIfaces.add(stackedIface);
@@ -1077,6 +1080,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                    }
                }
            }
        }

        // Apply policies against all connected interfaces found above
        mNetworkRules.clear();
+11 −8
Original line number Diff line number Diff line
@@ -896,11 +896,13 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
                // Traffic occurring on the base interface is always counted for
                // both total usage and UID details.
                final String baseIface = state.linkProperties.getInterfaceName();
                if (baseIface != null) {
                    findOrCreateNetworkIdentitySet(mActiveIfaces, baseIface).add(ident);
                    findOrCreateNetworkIdentitySet(mActiveUidIfaces, baseIface).add(ident);
                    if (isMobile) {
                        mobileIfaces.add(baseIface);
                    }
                }

                // Traffic occurring on stacked interfaces is usually clatd,
                // which is already accounted against its final egress interface
@@ -909,6 +911,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
                final List<LinkProperties> stackedLinks = state.linkProperties.getStackedLinks();
                for (LinkProperties stackedLink : stackedLinks) {
                    final String stackedIface = stackedLink.getInterfaceName();
                    if (stackedIface != null) {
                        findOrCreateNetworkIdentitySet(mActiveUidIfaces, stackedIface).add(ident);
                        if (isMobile) {
                            mobileIfaces.add(stackedIface);
@@ -916,8 +919,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
                    }
                }
            }
        }

        mobileIfaces.remove(null);
        mMobileIfaces = mobileIfaces.toArray(new String[mobileIfaces.size()]);
    }