Loading core/java/android/net/ConnectivityManager.java +43 −2 Original line number Diff line number Diff line Loading @@ -125,13 +125,21 @@ public class ConnectivityManager /** * @hide * gives a String[] */ public static final String EXTRA_AVAILABLE_TETHER_COUNT = "availableCount"; public static final String EXTRA_AVAILABLE_TETHER = "availableArray"; /** * @hide * gives a String[] */ public static final String EXTRA_ACTIVE_TETHER_COUNT = "activeCount"; public static final String EXTRA_ACTIVE_TETHER = "activeArray"; /** * @hide * gives a String[] */ public static final String EXTRA_ERRORED_TETHER = "erroredArray"; /** * The Default Mobile data connection. When active, all data traffic Loading Loading @@ -400,4 +408,37 @@ public class ConnectivityManager return false; } } /** * {@hide} */ public boolean isTetheringSupported() { try { return mService.isTetheringSupported(); } catch (RemoteException e) { return false; } } /** * {@hide} */ public String[] getTetherableUsbRegexs() { try { return mService.getTetherableUsbRegexs(); } catch (RemoteException e) { return new String[0]; } } /** * {@hide} */ public String[] getTetherableWifiRegexs() { try { return mService.getTetherableWifiRegexs(); } catch (RemoteException e) { return new String[0]; } } } core/java/android/net/IConnectivityManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -55,7 +55,13 @@ interface IConnectivityManager boolean untether(String iface); boolean isTetheringSupported(); String[] getTetherableIfaces(); String[] getTetheredIfaces(); String[] getTetherableUsbRegexs(); String[] getTetherableWifiRegexs(); } core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -2209,6 +2209,12 @@ public final class Settings { */ public static final String NETWORK_PREFERENCE = "network_preference"; /** * Used to disable Tethering on a device - defaults to true * @hide */ public static final String TETHER_SUPPORTED = "tether_supported"; /** * No longer supported. */ Loading core/java/com/android/internal/app/TetherActivity.java +44 −18 Original line number Diff line number Diff line Loading @@ -32,16 +32,19 @@ import android.widget.Toast; import android.util.Log; /** * This activity is shown to the user for him/her to connect/disconnect a Tether * connection. It will display notification when a suitable connection is made * to allow the tether to be setup. A second notification will be show when a * tether is active, allowing the user to manage tethered connections. * This activity is shown to the user in two cases: when a connection is possible via * a usb tether and when any type of tether is connected. In the connecting case * It allows them to start a USB tether. In the Tethered/disconnecting case it * will disconnect all tethers. */ public class TetherActivity extends AlertActivity implements DialogInterface.OnClickListener { private static final int POSITIVE_BUTTON = AlertDialog.BUTTON1; // count of the number of tethered connections at activity create time. private int mTethered; /* Used to detect when the USB cable is unplugged, so we can call finish() */ private BroadcastReceiver mTetherReceiver = new BroadcastReceiver() { @Override Loading @@ -52,8 +55,6 @@ public class TetherActivity extends AlertActivity implements } }; private boolean mWantTethering; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -61,17 +62,18 @@ public class TetherActivity extends AlertActivity implements // determine if we advertise tethering or untethering ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.getTetheredIfaces().length > 0) { mWantTethering = false; } else if (cm.getTetherableIfaces().length > 0) { mWantTethering = true; } else { mTethered = cm.getTetheredIfaces().length; int tetherable = cm.getTetherableIfaces().length; if ((mTethered == 0) && (tetherable == 0)) { finish(); return; } // Set up the "dialog" if (mWantTethering == true) { // Set up the dialog // if we have a tethered connection we put up a "Do you want to Disconect" dialog // otherwise we must have a tetherable interface (else we'd return above) // and so we want to put up the "do you want to connect" dialog if (mTethered == 0) { mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb; mAlertParams.mTitle = getString(com.android.internal.R.string.tether_title); mAlertParams.mMessage = getString(com.android.internal.R.string.tether_message); Loading Loading @@ -114,17 +116,36 @@ public class TetherActivity extends AlertActivity implements * {@inheritDoc} */ public void onClick(DialogInterface dialog, int which) { boolean error = false; if (which == POSITIVE_BUTTON) { ConnectivityManager connManager = ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); // start/stop tethering if (mWantTethering) { if (!connManager.tether("ppp0")) { String[] tethered = cm.getTetheredIfaces(); if (tethered.length == 0) { String[] tetherable = cm.getTetherableIfaces(); String[] usbRegexs = cm.getTetherableUsbRegexs(); for (String t : tetherable) { for (String r : usbRegexs) { if (t.matches(r)) { if (!cm.tether(t)) error = true; break; } } } if (error) { showTetheringError(); } } else { if (!connManager.untether("ppp0")) { for (String t : tethered) { if (!cm.untether("ppp0")) { error = true; } } if (error) { showUnTetheringError(); } } Loading @@ -134,8 +155,13 @@ public class TetherActivity extends AlertActivity implements } private void handleTetherStateChanged(Intent intent) { // determine if we advertise tethering or untethering ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); if (mTethered != cm.getTetheredIfaces().length) { finish(); } } private void showTetheringError() { Toast.makeText(this, com.android.internal.R.string.tether_error_message, Loading core/java/com/android/internal/util/HierarchicalStateMachine.java +1 −1 Original line number Diff line number Diff line Loading @@ -1021,7 +1021,7 @@ public class HierarchicalStateMachine { * @param msg that couldn't be handled. */ protected void unhandledMessage(Message msg) { Log.e(TAG, "unhandledMessage: msg.what=" + msg.what); Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what); } /** Loading Loading
core/java/android/net/ConnectivityManager.java +43 −2 Original line number Diff line number Diff line Loading @@ -125,13 +125,21 @@ public class ConnectivityManager /** * @hide * gives a String[] */ public static final String EXTRA_AVAILABLE_TETHER_COUNT = "availableCount"; public static final String EXTRA_AVAILABLE_TETHER = "availableArray"; /** * @hide * gives a String[] */ public static final String EXTRA_ACTIVE_TETHER_COUNT = "activeCount"; public static final String EXTRA_ACTIVE_TETHER = "activeArray"; /** * @hide * gives a String[] */ public static final String EXTRA_ERRORED_TETHER = "erroredArray"; /** * The Default Mobile data connection. When active, all data traffic Loading Loading @@ -400,4 +408,37 @@ public class ConnectivityManager return false; } } /** * {@hide} */ public boolean isTetheringSupported() { try { return mService.isTetheringSupported(); } catch (RemoteException e) { return false; } } /** * {@hide} */ public String[] getTetherableUsbRegexs() { try { return mService.getTetherableUsbRegexs(); } catch (RemoteException e) { return new String[0]; } } /** * {@hide} */ public String[] getTetherableWifiRegexs() { try { return mService.getTetherableWifiRegexs(); } catch (RemoteException e) { return new String[0]; } } }
core/java/android/net/IConnectivityManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -55,7 +55,13 @@ interface IConnectivityManager boolean untether(String iface); boolean isTetheringSupported(); String[] getTetherableIfaces(); String[] getTetheredIfaces(); String[] getTetherableUsbRegexs(); String[] getTetherableWifiRegexs(); }
core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -2209,6 +2209,12 @@ public final class Settings { */ public static final String NETWORK_PREFERENCE = "network_preference"; /** * Used to disable Tethering on a device - defaults to true * @hide */ public static final String TETHER_SUPPORTED = "tether_supported"; /** * No longer supported. */ Loading
core/java/com/android/internal/app/TetherActivity.java +44 −18 Original line number Diff line number Diff line Loading @@ -32,16 +32,19 @@ import android.widget.Toast; import android.util.Log; /** * This activity is shown to the user for him/her to connect/disconnect a Tether * connection. It will display notification when a suitable connection is made * to allow the tether to be setup. A second notification will be show when a * tether is active, allowing the user to manage tethered connections. * This activity is shown to the user in two cases: when a connection is possible via * a usb tether and when any type of tether is connected. In the connecting case * It allows them to start a USB tether. In the Tethered/disconnecting case it * will disconnect all tethers. */ public class TetherActivity extends AlertActivity implements DialogInterface.OnClickListener { private static final int POSITIVE_BUTTON = AlertDialog.BUTTON1; // count of the number of tethered connections at activity create time. private int mTethered; /* Used to detect when the USB cable is unplugged, so we can call finish() */ private BroadcastReceiver mTetherReceiver = new BroadcastReceiver() { @Override Loading @@ -52,8 +55,6 @@ public class TetherActivity extends AlertActivity implements } }; private boolean mWantTethering; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -61,17 +62,18 @@ public class TetherActivity extends AlertActivity implements // determine if we advertise tethering or untethering ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.getTetheredIfaces().length > 0) { mWantTethering = false; } else if (cm.getTetherableIfaces().length > 0) { mWantTethering = true; } else { mTethered = cm.getTetheredIfaces().length; int tetherable = cm.getTetherableIfaces().length; if ((mTethered == 0) && (tetherable == 0)) { finish(); return; } // Set up the "dialog" if (mWantTethering == true) { // Set up the dialog // if we have a tethered connection we put up a "Do you want to Disconect" dialog // otherwise we must have a tetherable interface (else we'd return above) // and so we want to put up the "do you want to connect" dialog if (mTethered == 0) { mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb; mAlertParams.mTitle = getString(com.android.internal.R.string.tether_title); mAlertParams.mMessage = getString(com.android.internal.R.string.tether_message); Loading Loading @@ -114,17 +116,36 @@ public class TetherActivity extends AlertActivity implements * {@inheritDoc} */ public void onClick(DialogInterface dialog, int which) { boolean error = false; if (which == POSITIVE_BUTTON) { ConnectivityManager connManager = ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); // start/stop tethering if (mWantTethering) { if (!connManager.tether("ppp0")) { String[] tethered = cm.getTetheredIfaces(); if (tethered.length == 0) { String[] tetherable = cm.getTetherableIfaces(); String[] usbRegexs = cm.getTetherableUsbRegexs(); for (String t : tetherable) { for (String r : usbRegexs) { if (t.matches(r)) { if (!cm.tether(t)) error = true; break; } } } if (error) { showTetheringError(); } } else { if (!connManager.untether("ppp0")) { for (String t : tethered) { if (!cm.untether("ppp0")) { error = true; } } if (error) { showUnTetheringError(); } } Loading @@ -134,8 +155,13 @@ public class TetherActivity extends AlertActivity implements } private void handleTetherStateChanged(Intent intent) { // determine if we advertise tethering or untethering ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); if (mTethered != cm.getTetheredIfaces().length) { finish(); } } private void showTetheringError() { Toast.makeText(this, com.android.internal.R.string.tether_error_message, Loading
core/java/com/android/internal/util/HierarchicalStateMachine.java +1 −1 Original line number Diff line number Diff line Loading @@ -1021,7 +1021,7 @@ public class HierarchicalStateMachine { * @param msg that couldn't be handled. */ protected void unhandledMessage(Message msg) { Log.e(TAG, "unhandledMessage: msg.what=" + msg.what); Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what); } /** Loading