Snap for 7599941 from 52e499548038bbb599151aece9c2b0b33e9d5125 to sc-release
Change-Id: I12d1971ddd1a2258d77921fe1f58d202344a05f6
diff --git a/apex/Android.bp b/apex/Android.bp
index d7bc426..3401244 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -16,10 +16,23 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-apex {
+soong_config_module_type_import {
+ from: "packages/modules/common/Android.bp",
+ module_types: [
+ "module_apex",
+ ],
+}
+
+module_apex {
name: "com.android.os.statsd",
defaults: ["com.android.os.statsd-defaults"],
manifest: "apex_manifest.json",
+ enabled: false,
+ soong_config_variables: {
+ module_build_from_source: {
+ enabled: true,
+ },
+ },
}
apex_defaults {
diff --git a/apex/testing/Android.bp b/apex/testing/Android.bp
index e521326..5c2291a 100644
--- a/apex/testing/Android.bp
+++ b/apex/testing/Android.bp
@@ -16,7 +16,14 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-apex_test {
+soong_config_module_type_import {
+ from: "packages/modules/common/Android.bp",
+ module_types: [
+ "module_apex_test",
+ ],
+}
+
+module_apex_test {
name: "test_com.android.os.statsd",
visibility: [
"//system/apex/tests",
@@ -26,4 +33,10 @@
file_contexts: ":com.android.os.statsd-file_contexts",
// Test APEX, should never be installed
installable: false,
+ enabled: false,
+ soong_config_variables: {
+ module_build_from_source: {
+ enabled: true,
+ },
+ },
}
diff --git a/service/Android.bp b/service/Android.bp
index f31674f..96308af 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -16,6 +16,13 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
+soong_config_module_type_import {
+ from: "packages/modules/common/Android.bp",
+ module_types: [
+ "module_java_library",
+ ],
+}
+
filegroup {
name: "service-statsd-sources",
srcs: [
@@ -23,7 +30,7 @@
],
}
-java_library {
+module_java_library {
name: "service-statsd",
srcs: [ ":service-statsd-sources" ],
sdk_version: "system_server_current",
@@ -40,4 +47,10 @@
"test_com.android.os.statsd",
],
min_sdk_version: "30",
+ enabled: false,
+ soong_config_variables: {
+ module_build_from_source: {
+ enabled: true,
+ },
+ },
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 90f659b..532ce63 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -19,7 +19,10 @@
java_test_host {
name: "CtsStatsdHostTestCases",
- srcs: ["src/**/*.java"],
+ srcs: [
+ "src/**/*.java",
+ ":apex-info-list",
+ ],
// tag this module as a cts test artifact
test_suites: [
diff --git a/tests/src/android/cts/statsd/apex/BootstrapApexTests.java b/tests/src/android/cts/statsd/apex/BootstrapApexTests.java
index 647a9e3..3bacb2e 100644
--- a/tests/src/android/cts/statsd/apex/BootstrapApexTests.java
+++ b/tests/src/android/cts/statsd/apex/BootstrapApexTests.java
@@ -19,17 +19,13 @@
import static com.google.common.truth.Truth.assertThat;
import android.cts.statsd.atom.BaseTestCase;
+import com.android.apex.ApexInfo;
+import com.android.apex.XmlParser;
import com.android.compatibility.common.util.ApiLevelUtil;
import com.android.tradefed.log.LogUtil;
-import java.io.StringReader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.junit.Before;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
/**
* Verify statsd is not in the bootstrap apexes
@@ -45,35 +41,32 @@
|| ApiLevelUtil.codenameEquals(getDevice(), codename);
}
+ // TODO: use InstallUtilsHost#isApexUpdateSupported after migrating to JUnit4
+ private final boolean isApexUpdateSupported() throws Exception {
+ return getDevice().getBooleanProperty("ro.apex.updatable", false);
+ }
+
+ private List<ApexInfo> readBootstrapApexes() throws Exception {
+ File file = getDevice().pullFile(BOOTSTRAP_APEX_FILE);
+ try (FileInputStream stream = new FileInputStream(file)) {
+ return XmlParser.readApexInfoList(stream).getApexInfo();
+ }
+ }
+
public void testStatsdNotPresent() throws Exception {
if (!sdkLevelAtLeast(31, "S")) {
return;
}
- String adbCommand = "cat " + BOOTSTRAP_APEX_FILE;
- String fileContents = getDevice().executeShellCommand(adbCommand);
-
- LogUtil.CLog.d(TAG + " Received the following file: " + fileContents);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document xml = builder.parse(new InputSource(new StringReader(fileContents)));
-
- NodeList apexInfoList = xml.getElementsByTagName("apex-info-list");
- assertThat(apexInfoList.getLength()).isEqualTo(1);
- NodeList apexInfoNodes = apexInfoList.item(0).getChildNodes();
- assertThat(apexInfoNodes.getLength()).isGreaterThan(0);
-
- int numApexes = 0;
- for (int i = 0; i < apexInfoNodes.getLength(); i++) {
- Node apexInfoNode = apexInfoNodes.item(i);
- String name = apexInfoNode.getNodeName();
- if (name.equals("apex-info")) {
- numApexes++;
- NamedNodeMap attr = apexInfoNode.getAttributes();
- Node moduleName = attr.getNamedItem("moduleName");
- assertThat(moduleName).isNotNull();
- assertThat(moduleName.getNodeValue()).isNotEqualTo("com.android.os.statsd");
- }
+ if (!isApexUpdateSupported()) {
+ return;
}
- assertThat(numApexes).isGreaterThan(0);
+
+ List<ApexInfo> apexInfoList = readBootstrapApexes();
+ LogUtil.CLog.d(TAG + " Received " + apexInfoList.size() + " apexes in bootstrap apexes");
+ assertThat(apexInfoList.size()).isGreaterThan(0);
+ for (ApexInfo apexInfo : apexInfoList) {
+ LogUtil.CLog.d(TAG + " APEX name is " + apexInfo.getModuleName());
+ assertThat(apexInfo.getModuleName()).isNotEqualTo("com.android.os.statsd");
+ }
}
}