Merge "Merge "Sets the PlaybackState to STOPPED after initialization." am: d4fdff45a1 am: 807df1ef57 am: 103864f15c am: 2ddfe90464" into qt-dev
am: ddc4bd0b23
Change-Id: I965df3f9f74b762e031137eeee6d205ab954428b
diff --git a/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
index 437ada8..ce31b61 100644
--- a/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
@@ -670,6 +670,15 @@
}
}
+ @Rpc(description = "register a default network callback")
+ public String connectivityRegisterDefaultNetworkCallback() {
+ mNetworkCallback = new NetworkCallback(NetworkCallback.EVENT_AVAILABLE);
+ mManager.registerDefaultNetworkCallback(mNetworkCallback);
+ String key = mNetworkCallback.mId;
+ mNetworkCallbackMap.put(key, mNetworkCallback);
+ return key;
+ }
+
@Rpc(description = "request a network")
public String connectivityRequestNetwork(@RpcParameter(name = "configJson")
JSONObject configJson) throws JSONException {
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/SubscriptionManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/telephony/SubscriptionManagerFacade.java
index 90ae1f5..5e0f256 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/SubscriptionManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/SubscriptionManagerFacade.java
@@ -66,6 +66,11 @@
return SubscriptionManager.getDefaultVoiceSubscriptionId();
}
+ @Rpc(description = "Returns active data subscription ID")
+ public Integer subscriptionGetActiveDataSubscriptionId() {
+ return SubscriptionManager.getActiveDataSubscriptionId();
+ }
+
@Rpc(description = "Set the default voice subscription ID")
public void subscriptionSetDefaultVoiceSubId(
@RpcParameter(name = "subId")
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
index 2631e49..90026d5 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
@@ -35,6 +35,7 @@
import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telephony.AvailableNetworkInfo;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
@@ -67,6 +68,7 @@
import com.googlecode.android_scripting.rpc.RpcParameter;
import java.util.Arrays;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Executor;
@@ -82,6 +84,7 @@
private final EventFacade mEventFacade;
private final TelephonyManager mTelephonyManager;
private final SubscriptionManager mSubscriptionManager;
+ private List<AvailableNetworkInfo> availableNetworkList;
private HashMap<Integer, StateChangeListener> mStateChangeListeners =
new HashMap<Integer, StateChangeListener>();
@@ -742,6 +745,32 @@
return mTelephonyManager.getPreferredOpportunisticDataSubscription();
}
+ @Rpc(description = "Sets preferred opportunistic data subscription Id")
+ public void telephonySetPreferredOpportunisticDataSubscription(
+ @RpcParameter(name = "subId") Integer subId,
+ @RpcParameter(name = "needValidation") Boolean needValidation) {
+ mTelephonyManager.setPreferredOpportunisticDataSubscription(
+ subId, needValidation, null, null);
+ }
+
+ @Rpc(description = "Updates Available Networks")
+ public void telephonyUpdateAvailableNetworks(
+ @RpcParameter(name = "subId") Integer subId) {
+
+ availableNetworkList = new ArrayList<>();
+ List<String> mccmmc = new ArrayList<String>();
+ List<Integer> bands = new ArrayList<Integer>();
+
+ availableNetworkList.add(
+ new AvailableNetworkInfo(
+ subId,
+ AvailableNetworkInfo.PRIORITY_HIGH,
+ mccmmc,
+ bands));
+
+ mTelephonyManager.updateAvailableNetworks(availableNetworkList, null, null);
+ }
+
/**
* Get device phone type for a subscription.
* @param subId the subscriber id
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/HttpFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/HttpFacade.java
index 6f173b5..0d3d887 100644
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/HttpFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/HttpFacade.java
@@ -96,13 +96,19 @@
* Send an http request and get the response.
*
* @param url The url to send request to.
+ * @param timeout Time to load the page
* @return The HttpURLConnection object.
*/
- private HttpURLConnection httpRequest(String url) throws IOException {
+ private HttpURLConnection httpRequest(String url, Integer timeout) throws IOException {
+ if (timeout == null) {
+ timeout = 50000;
+ }
URL targetURL = new URL(url);
HttpURLConnection urlConnection;
try {
urlConnection = (HttpURLConnection) targetURL.openConnection();
+ urlConnection.setConnectTimeout(9000);
+ urlConnection.setReadTimeout(timeout);
urlConnection.connect();
int respCode = urlConnection.getResponseCode();
String respMsg = urlConnection.getResponseMessage();
@@ -132,7 +138,7 @@
public void httpDownloadFile(@RpcParameter(name = "url") String url,
@RpcParameter(name="outPath") @RpcOptional String outPath) throws IOException {
// Create the input stream
- HttpURLConnection urlConnection = httpRequest(url);
+ HttpURLConnection urlConnection = httpRequest(url, null);
// Parse destination path and create the output stream. The function assumes that the path
// is specified relative to the system default Download dir.
File outFile = FileUtils.getExternalDownload();
@@ -179,10 +185,12 @@
}
@Rpc(description = "Make an http request and return the response message.")
- public HttpURLConnection httpPing(@RpcParameter(name = "url") String url) throws IOException {
+ public HttpURLConnection httpPing(
+ @RpcParameter(name = "url") String url,
+ @RpcParameter(name = "timeout") @RpcOptional Integer timeout) throws IOException {
try {
HttpURLConnection urlConnection = null;
- urlConnection = httpRequest(url);
+ urlConnection = httpRequest(url, timeout);
urlConnection.disconnect();
return urlConnection;
} catch (UnknownHostException e) {
@@ -192,7 +200,7 @@
@Rpc(description = "Make an http request and return the response content as a string.")
public String httpRequestString(@RpcParameter(name = "url") String url) throws IOException {
- HttpURLConnection urlConnection = httpRequest(url);
+ HttpURLConnection urlConnection = httpRequest(url, null);
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
String result = inputStreamToString(in);
Log.d("Fetched: " + result);
diff --git a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
index f673f5a..5ee2718 100644
--- a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
+++ b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
@@ -995,6 +995,7 @@
msg.put("dataRoaming", data.getDataRoaming());
msg.put("mcc", data.getMcc());
msg.put("mnc", data.getMnc());
+ msg.put("carrierId", data.getCarrierId());
return msg;
}