Merge "ConnectivityManagerFacade: Add startTethering" into nyc-dev
diff --git a/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
index 594c934..dec75ea 100644
--- a/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
@@ -401,6 +401,21 @@
return TelephonyConstants.PacketKeepaliveCallbackInvalid;
}
+ /**
+ * Callbacks used in ConnectivityManager to confirm tethering has started/failed.
+ */
+ class OnStartTetheringCallback extends ConnectivityManager.OnStartTetheringCallback {
+ @Override
+ public void onTetheringStarted() {
+ mEventFacade.postEvent(TelephonyConstants.TetheringStartedCallback, null);
+ }
+
+ @Override
+ public void onTetheringFailed() {
+ mEventFacade.postEvent(TelephonyConstants.TetheringFailedCallback, null);
+ }
+ }
+
private final ConnectivityManager mManager;
private final Service mService;
private final Context mContext;
@@ -714,6 +729,20 @@
return mManager.isTetheringSupported();
}
+ @Rpc(description = "Call to start tethering with a provisioning check if needed")
+ public void connectivityStartTethering(@RpcParameter(name = "type") Integer type,
+ @RpcParameter(name = "showProvisioningUi") Boolean showProvisioningUi) {
+ Log.d("startTethering for type: " + type + " showProvUi: " + showProvisioningUi);
+ OnStartTetheringCallback tetherCallback = new OnStartTetheringCallback();
+ mManager.startTethering(type, showProvisioningUi, tetherCallback);
+ }
+
+ @Rpc(description = "Call to stop tethering")
+ public void connectivityStopTethering(@RpcParameter(name = "type") Integer type) {
+ Log.d("stopTethering for type: " + type);
+ mManager.stopTethering(type);
+ }
+
@Override
public void shutdown() {
connectivityStopTrackingConnectivityStateChange();
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java
index 519ad9b..a899e11 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java
@@ -361,7 +361,7 @@
/**
* Constant for Network Call Back
- * **/
+ */
public static final String EventNetworkCallback = "NetworkCallback";
/*Sub-Event Names*/
@@ -377,8 +377,14 @@
public static final String NetworkCallbackInvalid = "Invalid";
/**
+ * Constants for OnStartTetheringCallback
+ */
+ public static final String TetheringStartedCallback = "ConnectivityManagerOnTetheringStarted";
+ public static final String TetheringFailedCallback = "ConnectivityManagerOnTetheringFailed";
+
+ /**
* Constant for Signal Strength fields
- * **/
+ */
public static class SignalStrengthContainer {
public static final String SIGNAL_STRENGTH_GSM = "gsmSignalStrength";
public static final String SIGNAL_STRENGTH_GSM_DBM = "gsmDbm";