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

Commit 976b34e4 authored by Susheel Yadagiri's avatar Susheel Yadagiri Committed by Gerrit - the friendly Code Review server
Browse files

Pick default interface for upstream.

With multiple upstream interfaces active and connected,
we should choose the default interface for upstream.
CRs-fixed: 461266

Change-Id: Ia3bc32300a1f77f46237994d0e38e9c9886f4bea
parent f3b7c05d
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -190,9 +190,23 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        int ifaceTypes[] = mContext.getResources().getIntArray(
                com.android.internal.R.array.config_tether_upstream_types);
        Collection<Integer> upstreamIfaceTypes = new ArrayList();
        IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
        IConnectivityManager cm = IConnectivityManager.Stub.asInterface(b);
        try {
            int activeNetType = cm.getActiveNetworkInfo().getType();
            for (int i : ifaceTypes) {
                if(i == activeNetType) {
                    upstreamIfaceTypes.add(new Integer(i));
                }
            }
        } catch (Exception e) {
            Log.d(TAG, "Exception adding default nw to upstreamIfaceTypes: " + e);
        }
        for (int i : ifaceTypes) {
            if(!upstreamIfaceTypes.contains(new Integer(i))) {
                upstreamIfaceTypes.add(new Integer(i));
            }
        }

        synchronized (mPublicSync) {
            mTetherableUsbRegexs = tetherableUsbRegexs;