Merge pie-platform-release to aosp-master - DO NOT MERGE
Change-Id: Ida4dda1d324b0a1b2268dbb64632f15e5bf6f3fc
diff --git a/OWNERS b/OWNERS
index 9733b29..e2c58d8 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,3 @@
-aqj@google.com
-benoitlamarche@google.com
-jplesot@google.com
-yroussel@google.com
+ager@google.com
+sgjesse@google.com
+jvg@google.com
diff --git a/build.gradle b/build.gradle
index e35adf7..c30a000 100644
--- a/build.gradle
+++ b/build.gradle
@@ -42,7 +42,7 @@
} else {
gradle.ext.currentSdk = 'current'
ext.buildToolsVersion = '26.0.0'
- project.ext.androidJar = files("${project.rootDir}/../../prebuilts/sdk/current/android.jar")
+ project.ext.androidJar = files("${project.rootDir}/../../prebuilts/sdk/current/public/android.jar")
File props = file("local.properties")
props.write "android.dir=../../"
}
diff --git a/instrumentation/Android.bp b/instrumentation/Android.bp
new file mode 100644
index 0000000..e342fa9
--- /dev/null
+++ b/instrumentation/Android.bp
@@ -0,0 +1,47 @@
+// Copyright (C) 2013 The Android Open Source Project
+//
+// 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.
+
+genrule {
+ name: "android-support-multidex-instrumentation-version",
+ // use srcs as dependencies, otherwise, this module won't be re-run
+ // during incremental build.
+ srcs: [
+ "src/**/*.java",
+ ],
+ cmd: "echo \"git.version=`cd frameworks/multidex/instrumentation; git log --format=\"%H\" -n 1 || " +
+ "(echo git hash not available; exit 0)`\" > $(genDir)/android-support-multidex-instrumentation.version.txt",
+ out: [
+ "android-support-multidex-instrumentation.version.txt",
+ ],
+}
+
+java_library_static {
+ name: "android-support-multidex-instrumentation",
+ sdk_version: "4",
+ srcs: [
+ "src/**/*.java",
+ ],
+ java_resources: [
+ ":android-support-multidex-instrumentation-version",
+ ],
+ static_libs: [
+ "android-support-multidex",
+ ],
+ product_variables: {
+ unbundled_build: {
+ // Don't build the library in unbundled branches.
+ enabled: false,
+ },
+ },
+}
diff --git a/instrumentation/Android.mk b/instrumentation/Android.mk
deleted file mode 100644
index ec50b8c..0000000
--- a/instrumentation/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# 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 := android-support-multidex-instrumentation
-LOCAL_JAVA_LIBRARIES := android-support-multidex
-LOCAL_SDK_VERSION := 4
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-
-ASMDI_GIT_VERSION_TAG := `cd $(LOCAL_PATH); git log --format="%H" -n 1 || (echo git hash not available; exit 0)`
-
-ASMDI_VERSION_INTERMEDIATE = $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/$(LOCAL_MODULE).version.txt
-$(ASMDI_VERSION_INTERMEDIATE):
- $(hide) mkdir -p $(dir $@)
- $(hide) echo "git.version=$(ASMDI_GIT_VERSION_TAG)" > $@
-
-LOCAL_JAVA_RESOURCE_FILES := $(ASMDI_VERSION_INTERMEDIATE)
-
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/library/Android.bp b/library/Android.bp
new file mode 100644
index 0000000..6ba5804
--- /dev/null
+++ b/library/Android.bp
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// 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.
+
+genrule {
+ name: "android-support-multidex-version",
+ tools: [
+ "soong_zip",
+ ],
+ // use srcs as dependencies, otherwise, this module won't be re-run
+ // during incremental build.
+ srcs: [
+ "src/**/*.java",
+ ],
+ cmd: "echo \"git.version=`cd frameworks/multidex/library; git log --format=\"%H\" -n 1 || " +
+ "(echo git hash not available; exit 0)`\" > $(genDir)/android-support-multidex.version.txt",
+ out: [
+ "android-support-multidex.version.txt",
+ ],
+}
+
+java_library_static {
+ name: "android-support-multidex",
+ sdk_version: "15",
+ min_sdk_version: "4",
+ srcs: [
+ "src/**/*.java",
+ ],
+ java_resources: [
+ ":android-support-multidex-version",
+ ],
+ product_variables: {
+ unbundled_build: {
+ // Don't build the library in unbundled branches.
+ enabled: false,
+ },
+ },
+}
diff --git a/library/Android.mk b/library/Android.mk
deleted file mode 100644
index b38620e..0000000
--- a/library/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# 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 := android-support-multidex
-LOCAL_SDK_VERSION := 4
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-ASMD_GIT_VERSION_TAG := `cd $(LOCAL_PATH); git log --format="%H" -n 1 || (echo git hash not available; exit 0)`
-
-ASMD_VERSION_INTERMEDIATE = $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/$(LOCAL_MODULE).version.txt
-$(ASMD_VERSION_INTERMEDIATE):
- $(hide) mkdir -p $(dir $@)
- $(hide) echo "git.version=$(ASMD_GIT_VERSION_TAG)" > $@
-
-LOCAL_JAVA_RESOURCE_FILES := $(ASMD_VERSION_INTERMEDIATE)
-
-LOCAL_JACK_FLAGS:=--import-meta $(LOCAL_PATH)/jack-meta
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(wildcard $(LOCAL_PATH)/jack-meta/*)
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/library/build.gradle b/library/build.gradle
index 83cbd27..1f17008 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -36,7 +36,7 @@
}
android {
- compileSdkVersion 4
+ compileSdkVersion gradle.currentSdk
defaultConfig {
minSdkVersion 4
diff --git a/library/src/androidx/multidex/MultiDex.java b/library/src/androidx/multidex/MultiDex.java
index 69ff889..30cb886 100644
--- a/library/src/androidx/multidex/MultiDex.java
+++ b/library/src/androidx/multidex/MultiDex.java
@@ -22,7 +22,9 @@
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.util.Log;
+
import dalvik.system.DexFile;
+
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
@@ -218,28 +220,11 @@
+ System.getProperty("java.vm.version") + "\"");
}
- /* The patched class loader is expected to be a descendant of
- * dalvik.system.BaseDexClassLoader. We modify its
- * dalvik.system.DexPathList pathList field to append additional DEX
- * file entries.
+ /* The patched class loader is expected to be a ClassLoader capable of loading DEX
+ * bytecode. We modify its pathList field to append additional DEX file entries.
*/
- ClassLoader loader;
- try {
- loader = mainContext.getClassLoader();
- } catch (RuntimeException e) {
- /* Ignore those exceptions so that we don't break tests relying on Context like
- * a android.test.mock.MockContext or a android.content.ContextWrapper with a
- * null base Context.
- */
- Log.w(TAG, "Failure while trying to obtain Context class loader. " +
- "Must be running in test mode. Skip patching.", e);
- return;
- }
+ ClassLoader loader = getDexClassloader(mainContext);
if (loader == null) {
- // Note, the context class loader is null when running Robolectric tests.
- Log.e(TAG,
- "Context class loader is null. Must be running in test mode. "
- + "Skip patching.");
return;
}
@@ -286,6 +271,38 @@
}
}
+ /**
+ * Returns a {@link Classloader} from the {@link Context} that is capable of reading dex
+ * bytecode or null if the Classloader is not dex-capable e.g: when running on a JVM testing
+ * environment such as Robolectric.
+ */
+ private static ClassLoader getDexClassloader(Context context) {
+ ClassLoader loader;
+ try {
+ loader = context.getClassLoader();
+ } catch (RuntimeException e) {
+ /* Ignore those exceptions so that we don't break tests relying on Context like
+ * a android.test.mock.MockContext or a android.content.ContextWrapper with a
+ * null base Context.
+ */
+ Log.w(TAG, "Failure while trying to obtain Context class loader. "
+ + "Must be running in test mode. Skip patching.", e);
+ return null;
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ if (loader instanceof dalvik.system.BaseDexClassLoader) {
+ return loader;
+ }
+ } else if (loader instanceof dalvik.system.DexClassLoader
+ || loader instanceof dalvik.system.PathClassLoader) {
+ return loader;
+ }
+ Log.e(TAG, "Context class loader is null or not dex-capable. "
+ + "Must be running in test mode. Skip patching.");
+ return null;
+ }
+
private static ApplicationInfo getApplicationInfo(Context context) {
try {
/* Due to package install races it is possible for a process to be started from an old