am 8d059ac5: Merge "Fix Tethering settings." into ics-mr0
* commit '8d059ac5b186547a86bb92678c7d1cb13fd8ce1c': Fix Tethering settings.
This commit is contained in:
@@ -160,13 +160,24 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
mDhcpRange = DHCP_DEFAULT_RANGE;
|
mDhcpRange = DHCP_DEFAULT_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mTetherableUsbRegexs = context.getResources().getStringArray(
|
// load device config info
|
||||||
|
updateConfiguration();
|
||||||
|
|
||||||
|
// TODO - remove and rely on real notifications of the current iface
|
||||||
|
mDnsServers = new String[2];
|
||||||
|
mDnsServers[0] = DNS_DEFAULT_SERVER1;
|
||||||
|
mDnsServers[1] = DNS_DEFAULT_SERVER2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateConfiguration() {
|
||||||
|
mTetherableUsbRegexs = mContext.getResources().getStringArray(
|
||||||
com.android.internal.R.array.config_tether_usb_regexs);
|
com.android.internal.R.array.config_tether_usb_regexs);
|
||||||
mTetherableWifiRegexs = context.getResources().getStringArray(
|
mTetherableWifiRegexs = mContext.getResources().getStringArray(
|
||||||
com.android.internal.R.array.config_tether_wifi_regexs);
|
com.android.internal.R.array.config_tether_wifi_regexs);
|
||||||
mTetherableBluetoothRegexs = context.getResources().getStringArray(
|
mTetherableBluetoothRegexs = mContext.getResources().getStringArray(
|
||||||
com.android.internal.R.array.config_tether_bluetooth_regexs);
|
com.android.internal.R.array.config_tether_bluetooth_regexs);
|
||||||
int ifaceTypes[] = context.getResources().getIntArray(
|
|
||||||
|
int ifaceTypes[] = mContext.getResources().getIntArray(
|
||||||
com.android.internal.R.array.config_tether_upstream_types);
|
com.android.internal.R.array.config_tether_upstream_types);
|
||||||
mUpstreamIfaceTypes = new ArrayList();
|
mUpstreamIfaceTypes = new ArrayList();
|
||||||
for (int i : ifaceTypes) {
|
for (int i : ifaceTypes) {
|
||||||
@@ -175,11 +186,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
|
|
||||||
// check if the upstream type list needs to be modified due to secure-settings
|
// check if the upstream type list needs to be modified due to secure-settings
|
||||||
checkDunRequired();
|
checkDunRequired();
|
||||||
|
|
||||||
// TODO - remove and rely on real notifications of the current iface
|
|
||||||
mDnsServers = new String[2];
|
|
||||||
mDnsServers[0] = DNS_DEFAULT_SERVER1;
|
|
||||||
mDnsServers[1] = DNS_DEFAULT_SERVER2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interfaceStatusChanged(String iface, boolean up) {
|
public void interfaceStatusChanged(String iface, boolean up) {
|
||||||
@@ -575,6 +581,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int[] getUpstreamIfaceTypes() {
|
public int[] getUpstreamIfaceTypes() {
|
||||||
|
updateConfiguration();
|
||||||
int values[] = new int[mUpstreamIfaceTypes.size()];
|
int values[] = new int[mUpstreamIfaceTypes.size()];
|
||||||
Iterator<Integer> iterator = mUpstreamIfaceTypes.iterator();
|
Iterator<Integer> iterator = mUpstreamIfaceTypes.iterator();
|
||||||
for (int i=0; i < mUpstreamIfaceTypes.size(); i++) {
|
for (int i=0; i < mUpstreamIfaceTypes.size(); i++) {
|
||||||
@@ -584,11 +591,13 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkDunRequired() {
|
public void checkDunRequired() {
|
||||||
int requiredApn = ((Settings.Secure.getInt(mContext.getContentResolver(),
|
int secureSetting = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.TETHER_DUN_REQUIRED, 0) == 1) ?
|
Settings.Secure.TETHER_DUN_REQUIRED, 2);
|
||||||
ConnectivityManager.TYPE_MOBILE_DUN :
|
// 2 = not set, 0 = DUN not required, 1 = DUN required
|
||||||
ConnectivityManager.TYPE_MOBILE_HIPRI);
|
if (secureSetting != 2) {
|
||||||
if (mPreferredUpstreamMobileApn != requiredApn) {
|
int requiredApn = (secureSetting == 1 ?
|
||||||
|
ConnectivityManager.TYPE_MOBILE_DUN :
|
||||||
|
ConnectivityManager.TYPE_MOBILE_HIPRI);
|
||||||
if (requiredApn == ConnectivityManager.TYPE_MOBILE_DUN) {
|
if (requiredApn == ConnectivityManager.TYPE_MOBILE_DUN) {
|
||||||
while (mUpstreamIfaceTypes.contains(MOBILE_TYPE)) {
|
while (mUpstreamIfaceTypes.contains(MOBILE_TYPE)) {
|
||||||
mUpstreamIfaceTypes.remove(MOBILE_TYPE);
|
mUpstreamIfaceTypes.remove(MOBILE_TYPE);
|
||||||
@@ -610,7 +619,11 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
mUpstreamIfaceTypes.add(HIPRI_TYPE);
|
mUpstreamIfaceTypes.add(HIPRI_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mPreferredUpstreamMobileApn = requiredApn;
|
}
|
||||||
|
if (mUpstreamIfaceTypes.contains(DUN_TYPE)) {
|
||||||
|
mPreferredUpstreamMobileApn = ConnectivityManager.TYPE_MOBILE_DUN;
|
||||||
|
} else {
|
||||||
|
mPreferredUpstreamMobileApn = ConnectivityManager.TYPE_MOBILE_HIPRI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1251,6 +1264,15 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
int upType = ConnectivityManager.TYPE_NONE;
|
int upType = ConnectivityManager.TYPE_NONE;
|
||||||
String iface = null;
|
String iface = null;
|
||||||
|
|
||||||
|
updateConfiguration();
|
||||||
|
|
||||||
|
if (VDBG) {
|
||||||
|
Log.d(TAG, "chooseUpstreamType has upstream iface types:");
|
||||||
|
for (Integer netType : mUpstreamIfaceTypes) {
|
||||||
|
Log.d(TAG, " " + netType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Integer netType : mUpstreamIfaceTypes) {
|
for (Integer netType : mUpstreamIfaceTypes) {
|
||||||
NetworkInfo info = null;
|
NetworkInfo info = null;
|
||||||
try {
|
try {
|
||||||
@@ -1314,7 +1336,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
boolean retValue = true;
|
boolean retValue = true;
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_MODE_REQUESTED:
|
case CMD_TETHER_MODE_REQUESTED:
|
||||||
checkDunRequired();
|
|
||||||
TetherInterfaceSM who = (TetherInterfaceSM)message.obj;
|
TetherInterfaceSM who = (TetherInterfaceSM)message.obj;
|
||||||
if (VDBG) Log.d(TAG, "Tether Mode requested by " + who.toString());
|
if (VDBG) Log.d(TAG, "Tether Mode requested by " + who.toString());
|
||||||
mNotifyList.add(who);
|
mNotifyList.add(who);
|
||||||
@@ -1487,6 +1508,11 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pw.println("mUpstreamIfaceTypes: ");
|
||||||
|
for (Integer netType : mUpstreamIfaceTypes) {
|
||||||
|
pw.println(" " + netType);
|
||||||
|
}
|
||||||
|
|
||||||
pw.println();
|
pw.println();
|
||||||
pw.println("Tether state:");
|
pw.println("Tether state:");
|
||||||
synchronized (mIfaces) {
|
synchronized (mIfaces) {
|
||||||
|
|||||||
Reference in New Issue
Block a user