Loading core/res/res/values/config.xml +9 −1 Original line number Diff line number Diff line Loading @@ -498,6 +498,14 @@ <item>0</item> </integer-array> <!-- When true, the tethering upstream network follows the current default Internet network (except when the current default network is mobile, in which case a DUN network will be used if required). When true, overrides the config_tether_upstream_types setting above. --> <bool translatable="false" name="config_tether_upstream_automatic">false</bool> <!-- If the DUN connection for this CDMA device supports more than just DUN --> <!-- traffic you should list them here. --> <!-- If this device is not CDMA this is ignored. If this list is empty on --> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1828,6 +1828,7 @@ <java-symbol type="array" name="config_tether_bluetooth_regexs" /> <java-symbol type="array" name="config_tether_dhcp_range" /> <java-symbol type="array" name="config_tether_upstream_types" /> <java-symbol type="bool" name="config_tether_upstream_automatic" /> <java-symbol type="array" name="config_tether_apndata" /> <java-symbol type="array" name="config_tether_usb_regexs" /> <java-symbol type="array" name="config_tether_wifi_regexs" /> Loading services/core/java/com/android/server/ConnectivityService.java +5 −1 Original line number Diff line number Diff line Loading @@ -925,6 +925,10 @@ public class ConnectivityService extends IConnectivityManager.Stub public boolean isTetheringSupported() { return ConnectivityService.this.isTetheringSupported(); } @Override public NetworkRequest getDefaultNetworkRequest() { return mDefaultRequest; } }; return new Tethering(mContext, mNetd, mStatsService, mPolicyManager, IoThread.get().getLooper(), new MockableSystemProperties(), Loading @@ -942,7 +946,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private NetworkRequest createDefaultInternetRequestForTransport( int transportType, NetworkRequest.Type type) { NetworkCapabilities netCap = new NetworkCapabilities(); final NetworkCapabilities netCap = new NetworkCapabilities(); netCap.addCapability(NET_CAPABILITY_INTERNET); netCap.addCapability(NET_CAPABILITY_NOT_RESTRICTED); if (transportType > -1) { Loading services/core/java/com/android/server/connectivity/Tethering.java +7 −15 Original line number Diff line number Diff line Loading @@ -1350,8 +1350,11 @@ public class Tethering extends BaseNetworkObserver { // do not currently know how to watch for changes in DUN settings. maybeUpdateConfiguration(); final NetworkState ns = mUpstreamNetworkMonitor.selectPreferredUpstreamType( mConfig.preferredUpstreamIfaceTypes); final TetheringConfiguration config = mConfig; final NetworkState ns = (config.chooseUpstreamAutomatically) ? mUpstreamNetworkMonitor.getCurrentPreferredUpstream() : mUpstreamNetworkMonitor.selectPreferredUpstreamType( config.preferredUpstreamIfaceTypes); if (ns == null) { if (tryCell) { mUpstreamNetworkMonitor.registerMobileNetworkRequest(); Loading Loading @@ -1380,9 +1383,7 @@ public class Tethering extends BaseNetworkObserver { } notifyDownstreamsOfNewUpstreamIface(ifaces); if (ns != null && pertainsToCurrentUpstream(ns)) { // If we already have NetworkState for this network examine // it immediately, because there likely will be no second // EVENT_ON_AVAILABLE (it was already received). // If we already have NetworkState for this network update it immediately. handleNewUpstreamNetworkState(ns); } else if (mCurrentUpstreamIfaceSet == null) { // There are no available upstream networks. Loading Loading @@ -1498,15 +1499,6 @@ public class Tethering extends BaseNetworkObserver { } switch (arg1) { case UpstreamNetworkMonitor.EVENT_ON_AVAILABLE: // The default network changed, or DUN connected // before this callback was processed. Updates // for the current NetworkCapabilities and // LinkProperties have been requested (default // request) or are being sent shortly (DUN). Do // nothing until they arrive; if no updates // arrive there's nothing to do. break; case UpstreamNetworkMonitor.EVENT_ON_CAPABILITIES: handleNewUpstreamNetworkState(ns); break; Loading Loading @@ -1539,7 +1531,7 @@ public class Tethering extends BaseNetworkObserver { } mSimChange.startListening(); mUpstreamNetworkMonitor.start(); mUpstreamNetworkMonitor.start(mDeps.getDefaultNetworkRequest()); // TODO: De-duplicate with updateUpstreamWanted() below. if (upstreamWanted()) { Loading services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static com.android.internal.R.array.config_tether_dhcp_range; import static com.android.internal.R.array.config_tether_usb_regexs; import static com.android.internal.R.array.config_tether_upstream_types; import static com.android.internal.R.array.config_tether_wifi_regexs; import static com.android.internal.R.bool.config_tether_upstream_automatic; import static com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui; import android.content.Context; Loading Loading @@ -86,6 +87,7 @@ public class TetheringConfiguration { public final String[] tetherableBluetoothRegexs; public final int dunCheck; public final boolean isDunRequired; public final boolean chooseUpstreamAutomatically; public final Collection<Integer> preferredUpstreamIfaceTypes; public final String[] dhcpRanges; public final String[] defaultIPv4DNS; Loading @@ -106,6 +108,7 @@ public class TetheringConfiguration { dunCheck = checkDunRequired(ctx); configLog.log("DUN check returned: " + dunCheckString(dunCheck)); chooseUpstreamAutomatically = getResourceBoolean(ctx, config_tether_upstream_automatic); preferredUpstreamIfaceTypes = getUpstreamIfaceTypes(ctx, dunCheck); isDunRequired = preferredUpstreamIfaceTypes.contains(TYPE_MOBILE_DUN); Loading Loading @@ -142,6 +145,8 @@ public class TetheringConfiguration { pw.print("isDunRequired: "); pw.println(isDunRequired); pw.print("chooseUpstreamAutomatically: "); pw.println(chooseUpstreamAutomatically); dumpStringArray(pw, "preferredUpstreamIfaceTypes", preferredUpstreamNames(preferredUpstreamIfaceTypes)); Loading @@ -160,6 +165,7 @@ public class TetheringConfiguration { sj.add(String.format("tetherableBluetoothRegexs:%s", makeString(tetherableBluetoothRegexs))); sj.add(String.format("isDunRequired:%s", isDunRequired)); sj.add(String.format("chooseUpstreamAutomatically:%s", chooseUpstreamAutomatically)); sj.add(String.format("preferredUpstreamIfaceTypes:%s", makeString(preferredUpstreamNames(preferredUpstreamIfaceTypes)))); sj.add(String.format("provisioningApp:%s", makeString(provisioningApp))); Loading Loading @@ -286,6 +292,14 @@ public class TetheringConfiguration { } } private static boolean getResourceBoolean(Context ctx, int resId) { try { return ctx.getResources().getBoolean(resId); } catch (Resources.NotFoundException e404) { return false; } } private static String[] getResourceStringArray(Context ctx, int resId) { try { final String[] strArray = ctx.getResources().getStringArray(resId); Loading Loading
core/res/res/values/config.xml +9 −1 Original line number Diff line number Diff line Loading @@ -498,6 +498,14 @@ <item>0</item> </integer-array> <!-- When true, the tethering upstream network follows the current default Internet network (except when the current default network is mobile, in which case a DUN network will be used if required). When true, overrides the config_tether_upstream_types setting above. --> <bool translatable="false" name="config_tether_upstream_automatic">false</bool> <!-- If the DUN connection for this CDMA device supports more than just DUN --> <!-- traffic you should list them here. --> <!-- If this device is not CDMA this is ignored. If this list is empty on --> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1828,6 +1828,7 @@ <java-symbol type="array" name="config_tether_bluetooth_regexs" /> <java-symbol type="array" name="config_tether_dhcp_range" /> <java-symbol type="array" name="config_tether_upstream_types" /> <java-symbol type="bool" name="config_tether_upstream_automatic" /> <java-symbol type="array" name="config_tether_apndata" /> <java-symbol type="array" name="config_tether_usb_regexs" /> <java-symbol type="array" name="config_tether_wifi_regexs" /> Loading
services/core/java/com/android/server/ConnectivityService.java +5 −1 Original line number Diff line number Diff line Loading @@ -925,6 +925,10 @@ public class ConnectivityService extends IConnectivityManager.Stub public boolean isTetheringSupported() { return ConnectivityService.this.isTetheringSupported(); } @Override public NetworkRequest getDefaultNetworkRequest() { return mDefaultRequest; } }; return new Tethering(mContext, mNetd, mStatsService, mPolicyManager, IoThread.get().getLooper(), new MockableSystemProperties(), Loading @@ -942,7 +946,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private NetworkRequest createDefaultInternetRequestForTransport( int transportType, NetworkRequest.Type type) { NetworkCapabilities netCap = new NetworkCapabilities(); final NetworkCapabilities netCap = new NetworkCapabilities(); netCap.addCapability(NET_CAPABILITY_INTERNET); netCap.addCapability(NET_CAPABILITY_NOT_RESTRICTED); if (transportType > -1) { Loading
services/core/java/com/android/server/connectivity/Tethering.java +7 −15 Original line number Diff line number Diff line Loading @@ -1350,8 +1350,11 @@ public class Tethering extends BaseNetworkObserver { // do not currently know how to watch for changes in DUN settings. maybeUpdateConfiguration(); final NetworkState ns = mUpstreamNetworkMonitor.selectPreferredUpstreamType( mConfig.preferredUpstreamIfaceTypes); final TetheringConfiguration config = mConfig; final NetworkState ns = (config.chooseUpstreamAutomatically) ? mUpstreamNetworkMonitor.getCurrentPreferredUpstream() : mUpstreamNetworkMonitor.selectPreferredUpstreamType( config.preferredUpstreamIfaceTypes); if (ns == null) { if (tryCell) { mUpstreamNetworkMonitor.registerMobileNetworkRequest(); Loading Loading @@ -1380,9 +1383,7 @@ public class Tethering extends BaseNetworkObserver { } notifyDownstreamsOfNewUpstreamIface(ifaces); if (ns != null && pertainsToCurrentUpstream(ns)) { // If we already have NetworkState for this network examine // it immediately, because there likely will be no second // EVENT_ON_AVAILABLE (it was already received). // If we already have NetworkState for this network update it immediately. handleNewUpstreamNetworkState(ns); } else if (mCurrentUpstreamIfaceSet == null) { // There are no available upstream networks. Loading Loading @@ -1498,15 +1499,6 @@ public class Tethering extends BaseNetworkObserver { } switch (arg1) { case UpstreamNetworkMonitor.EVENT_ON_AVAILABLE: // The default network changed, or DUN connected // before this callback was processed. Updates // for the current NetworkCapabilities and // LinkProperties have been requested (default // request) or are being sent shortly (DUN). Do // nothing until they arrive; if no updates // arrive there's nothing to do. break; case UpstreamNetworkMonitor.EVENT_ON_CAPABILITIES: handleNewUpstreamNetworkState(ns); break; Loading Loading @@ -1539,7 +1531,7 @@ public class Tethering extends BaseNetworkObserver { } mSimChange.startListening(); mUpstreamNetworkMonitor.start(); mUpstreamNetworkMonitor.start(mDeps.getDefaultNetworkRequest()); // TODO: De-duplicate with updateUpstreamWanted() below. if (upstreamWanted()) { Loading
services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static com.android.internal.R.array.config_tether_dhcp_range; import static com.android.internal.R.array.config_tether_usb_regexs; import static com.android.internal.R.array.config_tether_upstream_types; import static com.android.internal.R.array.config_tether_wifi_regexs; import static com.android.internal.R.bool.config_tether_upstream_automatic; import static com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui; import android.content.Context; Loading Loading @@ -86,6 +87,7 @@ public class TetheringConfiguration { public final String[] tetherableBluetoothRegexs; public final int dunCheck; public final boolean isDunRequired; public final boolean chooseUpstreamAutomatically; public final Collection<Integer> preferredUpstreamIfaceTypes; public final String[] dhcpRanges; public final String[] defaultIPv4DNS; Loading @@ -106,6 +108,7 @@ public class TetheringConfiguration { dunCheck = checkDunRequired(ctx); configLog.log("DUN check returned: " + dunCheckString(dunCheck)); chooseUpstreamAutomatically = getResourceBoolean(ctx, config_tether_upstream_automatic); preferredUpstreamIfaceTypes = getUpstreamIfaceTypes(ctx, dunCheck); isDunRequired = preferredUpstreamIfaceTypes.contains(TYPE_MOBILE_DUN); Loading Loading @@ -142,6 +145,8 @@ public class TetheringConfiguration { pw.print("isDunRequired: "); pw.println(isDunRequired); pw.print("chooseUpstreamAutomatically: "); pw.println(chooseUpstreamAutomatically); dumpStringArray(pw, "preferredUpstreamIfaceTypes", preferredUpstreamNames(preferredUpstreamIfaceTypes)); Loading @@ -160,6 +165,7 @@ public class TetheringConfiguration { sj.add(String.format("tetherableBluetoothRegexs:%s", makeString(tetherableBluetoothRegexs))); sj.add(String.format("isDunRequired:%s", isDunRequired)); sj.add(String.format("chooseUpstreamAutomatically:%s", chooseUpstreamAutomatically)); sj.add(String.format("preferredUpstreamIfaceTypes:%s", makeString(preferredUpstreamNames(preferredUpstreamIfaceTypes)))); sj.add(String.format("provisioningApp:%s", makeString(provisioningApp))); Loading Loading @@ -286,6 +292,14 @@ public class TetheringConfiguration { } } private static boolean getResourceBoolean(Context ctx, int resId) { try { return ctx.getResources().getBoolean(resId); } catch (Resources.NotFoundException e404) { return false; } } private static String[] getResourceStringArray(Context ctx, int resId) { try { final String[] strArray = ctx.getResources().getStringArray(resId); Loading