Snap for 5798008 from f2a1090bdef20bef21bf050b55570cadc2547aaf to sdk-release
Change-Id: I90f6f47779dac691b69aeceb9874a0b1fd632cae
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index b23c878..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-## Copyright (C) 2016 Google, Inc.
-#
-## Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# # You may obtain a copy of the License at:
-#
-## http://www.apache.org/licenses/LICENSE-2.0
-#
-## Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# # limitations under the License.
-#
-
-include $(call all-subdir-makefiles)
diff --git a/Common/Android.bp b/Common/Android.bp
new file mode 100644
index 0000000..4fc52b3
--- /dev/null
+++ b/Common/Android.bp
@@ -0,0 +1,37 @@
+//
+// Copyright (C) 2017 Google, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+java_library {
+ name: "sl4a.Common",
+ owner: "google",
+
+ static_libs: [
+ "guava",
+ "android-common",
+ "sl4a.Utils",
+ "junit",
+ ],
+
+ libs: [
+ "telephony-common",
+ "ims-common",
+ ],
+
+ srcs: [
+ "src/com/googlecode/android_scripting/**/*.java",
+ "src/org/apache/commons/codec/**/*.java",
+ ],
+}
diff --git a/Common/Android.mk b/Common/Android.mk
deleted file mode 100644
index 18e93c3..0000000
--- a/Common/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2017 Google, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-
-LOCAL_MODULE := sl4a.Common
-LOCAL_MODULE_OWNER := google
-
-LOCAL_STATIC_JAVA_LIBRARIES := guava android-common sl4a.Utils junit
-LOCAL_JAVA_LIBRARIES := telephony-common
-LOCAL_JAVA_LIBRARIES += ims-common
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src/com/googlecode/android_scripting)
-LOCAL_SRC_FILES += $(call all-java-files-under, src/org/apache/commons/codec)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/ConnectivityManagerFacade.java
index 22f241e..5c8e1fa 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/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/InterpreterForAndroid/Android.bp b/InterpreterForAndroid/Android.bp
new file mode 100644
index 0000000..452b65d
--- /dev/null
+++ b/InterpreterForAndroid/Android.bp
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2017 Google, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+java_library {
+ name: "sl4a.InterpreterForAndroid",
+ owner: "google",
+ static_libs: [
+ "guava",
+ "android-common",
+ "sl4a.Utils",
+
+ //"android-support-v4",
+ ],
+
+ srcs: ["src/com/googlecode/android_scripting/**/*.java"],
+}
diff --git a/InterpreterForAndroid/Android.mk b/InterpreterForAndroid/Android.mk
deleted file mode 100644
index 8df90e1..0000000
--- a/InterpreterForAndroid/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2017 Google, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-
-LOCAL_MODULE := sl4a.InterpreterForAndroid
-LOCAL_MODULE_OWNER := google
-LOCAL_STATIC_JAVA_LIBRARIES := guava android-common sl4a.Utils
-#LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
-LOCAL_SRC_FILES := $(call all-java-files-under, src/com/googlecode/android_scripting)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/ScriptingLayer/Android.bp b/ScriptingLayer/Android.bp
new file mode 100644
index 0000000..cf65c2e
--- /dev/null
+++ b/ScriptingLayer/Android.bp
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2016 Google, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+java_library {
+ name: "sl4a.ScriptingLayer",
+ owner: "google",
+
+ static_libs: [
+ "guava",
+ "android-common",
+
+ "sl4a.Utils",
+ "sl4a.Common",
+ ],
+
+ srcs: ["src/com/googlecode/android_scripting/**/*.java"],
+}
diff --git a/ScriptingLayer/Android.mk b/ScriptingLayer/Android.mk
deleted file mode 100644
index 2871eff..0000000
--- a/ScriptingLayer/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2016 Google, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-
-LOCAL_MODULE := sl4a.ScriptingLayer
-LOCAL_MODULE_OWNER := google
-
-LOCAL_STATIC_JAVA_LIBRARIES := guava android-common
-LOCAL_STATIC_JAVA_LIBRARIES += sl4a.Utils sl4a.Common
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src/com/googlecode/android_scripting)
-
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/ScriptingLayerForAndroid/Android.bp b/ScriptingLayerForAndroid/Android.bp
new file mode 100644
index 0000000..0c66e15
--- /dev/null
+++ b/ScriptingLayerForAndroid/Android.bp
@@ -0,0 +1,64 @@
+//
+// Copyright (C) 2016 Google, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+ name: "sl4a",
+
+ test_suites: [
+ "pts",
+ "device-tests",
+ ],
+
+ platform_apis: true,
+ owner: "google",
+ dex_preopt: {
+ enabled: false,
+ },
+
+ certificate: "platform",
+
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+
+ aaptflags: ["--auto-add-overlay"],
+
+ compile_multilib: "both",
+
+ static_libs: [
+ "guava",
+ "android-common",
+ "sl4a.locale_platform",
+ "android-support-v4",
+
+ "sl4a.Utils",
+ "sl4a.Common",
+
+ "sl4a.InterpreterForAndroid",
+ "sl4a.ScriptingLayer",
+ ],
+
+ privileged: true,
+ optimize: {
+ enabled: false,
+ },
+
+ jni_libs: ["libcom_googlecode_android_scripting_Exec"],
+}
+
+java_import {
+ name: "sl4a.locale_platform",
+ jars: ["libs/locale_platform.jar"],
+}
diff --git a/ScriptingLayerForAndroid/Android.mk b/ScriptingLayerForAndroid/Android.mk
deleted file mode 100644
index 7539f72..0000000
--- a/ScriptingLayerForAndroid/Android.mk
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (C) 2016 Google, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_COMPATIBILITY_SUITE := pts device-tests
-LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PACKAGE_NAME := sl4a
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_MODULE_OWNER := google
-LOCAL_DEX_PREOPT := false
-
-LOCAL_CERTIFICATE := platform
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_AAPT_FLAGS := --auto-add-overlay
-
-LOCAL_MULTILIB := both
-
-# Builds on the Data Partition
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := guava android-common locale_platform android-support-v4
-LOCAL_STATIC_JAVA_LIBRARIES += sl4a.Utils sl4a.Common
-LOCAL_STATIC_JAVA_LIBRARIES += sl4a.InterpreterForAndroid sl4a.ScriptingLayer
-
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_PROGUARD_ENABLED := disabled
-
-
-LOCAL_JNI_SHARED_LIBRARIES := libcom_googlecode_android_scripting_Exec
-
-include $(BUILD_PACKAGE)
-
-include $(CLEAR_VARS)
-LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := locale_platform:libs/locale_platform.jar
-include $(BUILD_MULTI_PREBUILT)
diff --git a/Utils/Android.bp b/Utils/Android.bp
new file mode 100644
index 0000000..d48d317
--- /dev/null
+++ b/Utils/Android.bp
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2016 Google, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+java_library {
+ name: "sl4a.Utils",
+ owner: "google",
+ static_libs: [
+ "guava",
+ "android-common",
+ ],
+ srcs: ["src/**/*.java"],
+}
diff --git a/Utils/Android.mk b/Utils/Android.mk
deleted file mode 100644
index 5417389..0000000
--- a/Utils/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2016 Google, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-
-LOCAL_MODULE := sl4a.Utils
-LOCAL_MODULE_OWNER := google
-LOCAL_STATIC_JAVA_LIBRARIES := guava android-common
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)