Add jarjar rules for telephony tests
The rules combine the base telephony jarjar rules, and test-only jarjar
rules. Test-only rules take precedence as jarjar only applies the first
matching rule to any class.
Includes a rule to rename the NetworkFactory in services.jar, as the
base jarjar rules would otherwise attempt to rename it to the same
package as the one in telephony-common, and cause conflicts.
This is only necessary for telephony tests because telephony has jarjar
rules for NetworkFactory, because it puts telephony-common on the
bootclasspath.
Test: atest FrameworksTelephonyTests
Bug: 138306002
Change-Id: Ia7b80233a2934b285beb4684c3cac2e32521f6d4
Merged-In: Ia7b80233a2934b285beb4684c3cac2e32521f6d4
(clean cherry-pick from internal branch)
diff --git a/tests/telephonytests/Android.bp b/tests/telephonytests/Android.bp
index eba61c8..41f34c2 100644
--- a/tests/telephonytests/Android.bp
+++ b/tests/telephonytests/Android.bp
@@ -26,10 +26,22 @@
],
platform_apis: true,
- jarjar_rules: ":jarjar-rules-shared",
+ jarjar_rules: ":jarjar-rules-telephony-tests",
test_suites: [
"mts",
"device-tests",
],
}
+
+genrule {
+ name: "jarjar-rules-telephony-tests",
+ srcs: [
+ // Order matters: test rules override the base ones
+ "jarjar-rules-tests.txt",
+ ":jarjar-rules-shared",
+ ],
+ out: ["jarjar-rules-telephony-tests-combined.txt"],
+ cmd: "cat $(in) > $(out)",
+ visibility: ["//visibility:private"],
+}
diff --git a/tests/telephonytests/jarjar-rules-tests.txt b/tests/telephonytests/jarjar-rules-tests.txt
new file mode 100644
index 0000000..91b5b32
--- /dev/null
+++ b/tests/telephonytests/jarjar-rules-tests.txt
@@ -0,0 +1,6 @@
+# NetworkFactory is included in telephony-common and services.net
+# Rename the non-jarjared, services.net version to avoid conflicts.
+# This causes two NetworkFactory classes to appear in the test package (one used
+# by services-net and one by telephony-common), similarly to what happens on a
+# real device, except that in the test they have different package names.
+rule android.net.NetworkFactory* android.net.services.NetworkFactory@1