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

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

Make CS.isTetheringSupported dynamic

It used to be set at boot, but that was too quick to pick up carrier
specific resources.  With this change even if you switch sims subequent
checks get the new values.

bug:9865616
Change-Id: I8c270c6b02fc6bdd3c3d76ceea58172df25e058d
parent e0380d8f
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -175,7 +175,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
    private static final int MAX_HOSTROUTE_CYCLE_COUNT = 10;

    private Tethering mTethering;
    private boolean mTetheringConfigValid = false;

    private KeyStore mKeyStore;

@@ -589,10 +588,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        }

        mTethering = new Tethering(mContext, mNetd, statsService, this, mHandler.getLooper());
        mTetheringConfigValid = ((mTethering.getTetherableUsbRegexs().length != 0 ||
                                  mTethering.getTetherableWifiRegexs().length != 0 ||
                                  mTethering.getTetherableBluetoothRegexs().length != 0) &&
                                 mTethering.getUpstreamIfaceTypes().length != 0);

        mVpn = new Vpn(mContext, mVpnCallback, mNetd, this);
        mVpn.startMonitoring(mContext, mTrackerHandler);
@@ -3002,7 +2997,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        int defaultVal = (SystemProperties.get("ro.tether.denied").equals("true") ? 0 : 1);
        boolean tetherEnabledInSettings = (Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.TETHER_SUPPORTED, defaultVal) != 0);
        return tetherEnabledInSettings && mTetheringConfigValid;
        return tetherEnabledInSettings && ((mTethering.getTetherableUsbRegexs().length != 0 ||
                mTethering.getTetherableWifiRegexs().length != 0 ||
                mTethering.getTetherableBluetoothRegexs().length != 0) &&
                mTethering.getUpstreamIfaceTypes().length != 0);
    }

    // An API NetworkStateTrackers can call when they lose their network.
+5 −2
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
        IntentFilter filter = new IntentFilter();
        filter.addAction(UsbManager.ACTION_USB_STATE);
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
        mContext.registerReceiver(mStateReceiver, filter);

        filter = new IntentFilter();
@@ -516,6 +517,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
                    if (VDBG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION");
                    mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED);
                }
            } else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
                updateConfiguration();
            }
        }
    }
@@ -618,7 +621,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
    public int[] getUpstreamIfaceTypes() {
        int values[];
        synchronized (mPublicSync) {
            updateConfiguration();
            updateConfiguration();  // TODO - remove?
            values = new int[mUpstreamIfaceTypes.size()];
            Iterator<Integer> iterator = mUpstreamIfaceTypes.iterator();
            for (int i=0; i < mUpstreamIfaceTypes.size(); i++) {
@@ -1289,7 +1292,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
                int upType = ConnectivityManager.TYPE_NONE;
                String iface = null;

                updateConfiguration();
                updateConfiguration(); // TODO - remove?

                synchronized (mPublicSync) {
                    if (VDBG) {