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

Commit ccf83af1 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Fix tethering upstream determination.

Used to use iface names, but on mobile ifaces are multipurpose.
Refined to use ConnectivityService types.
bug:4530116

Change-Id: Iaa632d5f540d27ffff683bd7d94f8004bf422e71
parent 48294b0d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -163,6 +163,12 @@ public class ConnectivityManager
     */
    public static final String EXTRA_ERRORED_TETHER = "erroredArray";

    /**
     * The absence of APN..
     * @hide
     */
    public static final int TYPE_NONE        = -1;

    /**
     * The Default Mobile data connection.  When active, all data traffic
     * will use this connection by default.
+8 −11
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@
    <!-- This string array should be overridden by the device to present a list of network
         attributes.  This is used by the connectivity manager to decide which networks can coexist
         based on the hardware -->
    <!-- An Array of "[Connection name],[ConnectivityManager connection type],
    <!-- An Array of "[Connection name],[ConnectivityManager.TYPE_xxxx],
         [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet]  -->
    <!-- the 5th element "resore-time" indicates the number of milliseconds to delay
         before automatically restore the default connection.  Set -1 if the connection
@@ -154,16 +154,13 @@
    <string-array translatable="false" name="config_tether_dhcp_range">
    </string-array>

    <!-- Regex array of allowable upstream ifaces for tethering - for example if you want
         tethering on a new interface called "foo2" add <item>"foo\\d"</item> to the array -->
    <string-array translatable="false" name="config_tether_upstream_regexs">
    </string-array>

    <!-- Boolean indicating if we require the use of DUN on mobile for tethering.
         Note that this defaults to false so that if you move to a carrier that
         hasn't configured anything tethering will still work.  If you'd rather
         make the device untetherable on unconfigured devices, set to true -->
    <bool translatable="false" name="config_tether_dun_required">false</bool>
    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->
    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->
    <integer-array translatable="false" name="config_tether_upstream_types">
        <item>1</item>
        <item>4</item>
    </integer-array>

    <!-- String containing the apn value for tethering.  May be overriden by secure settings
         TETHER_DUN_APN.  Value is a comma separated series of strings:
+2 −18
Original line number Diff line number Diff line
@@ -431,12 +431,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        }

        mTethering = new Tethering(mContext, mHandler.getLooper());
        mTetheringConfigValid = (((mNetTrackers[ConnectivityManager.TYPE_MOBILE_DUN] != null) ||
                                  !mTethering.isDunRequired()) &&
                                 (mTethering.getTetherableUsbRegexs().length != 0 ||
        mTetheringConfigValid = ((mTethering.getTetherableUsbRegexs().length != 0 ||
                                  mTethering.getTetherableWifiRegexs().length != 0 ||
                                  mTethering.getTetherableBluetoothRegexs().length != 0) &&
                                 mTethering.getUpstreamIfaceRegexs().length != 0);
                                 mTethering.getUpstreamIfaceTypes().length != 0);

        if (DBG) {
            mInetLog = new ArrayList();
@@ -1400,12 +1398,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
            } else {
                addPrivateDnsRoutes(mNetTrackers[netType]);
            }

            /** Notify TetheringService if interface name has been changed. */
            if (TextUtils.equals(mNetTrackers[netType].getNetworkInfo().getReason(),
                                 Phone.REASON_LINK_PROPERTIES_CHANGED)) {
                handleTetherIfaceChange(netType);
            }
        } else {
            if (mNetConfigs[netType].isDefault()) {
                removeDefaultRoute(mNetTrackers[netType]);
@@ -2253,14 +2245,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        }
    }

    private void handleTetherIfaceChange(int type) {
        String iface = mNetTrackers[type].getLinkProperties().getInterfaceName();

        if (isTetheringSupported()) {
            mTethering.handleTetherIfaceChange(iface);
        }
    }

    private void log(String s) {
        Slog.d(TAG, s);
    }
+115 −139

File changed.

Preview size limit exceeded, changes collapsed.