Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22601e68 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Do not apply jarjar rules on intermediate libs

Using jarjar on intermediate libraries causes issues when they are
combined with other libraries that use different jarjar rules, as the
resulting binary may contain multiple incompatible copies of the
classes. Instead, jarjar should be used on the final artifact, after
combining the libraries.

Ensure NetworkStackJarJarRules is not applied on intermediate libraries
like NetworkStackTestsLib, or NetworkStackIntegrationTestsLib, but
instead apply it on NetworkStackIntegrationTests or
NetworkStackCoverageTests.

Bug: 192535368
Test: atest TetheringCoverageTests TetheringIntegrationTests \
          CtsTetheringTest
Change-Id: Ifbbe7b2969db080e3daac240bd31297a6fd0150c
parent 0a9a3bf7
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -286,6 +286,7 @@ filegroup {
    visibility: [
    visibility: [
        "//packages/modules/NetworkStack/tests/unit",
        "//packages/modules/NetworkStack/tests/unit",
        "//packages/modules/NetworkStack/tests/integration",
        "//packages/modules/NetworkStack/tests/integration",
        "//packages/modules/Connectivity/tests:__subpackages__",
        "//packages/modules/Connectivity/Tethering/tests/integration",
        "//packages/modules/Connectivity/Tethering/tests/integration",
    ]
    ]
}
}
+4 −16
Original line number Original line Diff line number Diff line
@@ -50,7 +50,6 @@ java_defaults {
        "android.test.base",
        "android.test.base",
        "android.test.mock",
        "android.test.mock",
    ],
    ],
    jarjar_rules: ":NetworkStackJarJarRules",
    visibility: ["//visibility:private"],
    visibility: ["//visibility:private"],
}
}


@@ -73,6 +72,7 @@ android_test {
    test_suites: ["device-tests"],
    test_suites: ["device-tests"],
    min_sdk_version: "29",
    min_sdk_version: "29",
    target_sdk_version: "30",
    target_sdk_version: "30",
    jarjar_rules: ":NetworkStackJarJarRules",
}
}


// Network stack next integration tests.
// Network stack next integration tests.
@@ -88,21 +88,7 @@ android_test {
    certificate: "networkstack",
    certificate: "networkstack",
    platform_apis: true,
    platform_apis: true,
    test_suites: ["device-tests"],
    test_suites: ["device-tests"],
}

// The static lib needs to be jarjared by each module so they do not conflict with each other
// (e.g. wifi, system server, network stack need to use different package names when including it).
// Apply NetworkStack jarjar rules to the tests as well so classes in NetworkStaticLibTests have the
// same package names as in module code.
android_library {
    name: "NetworkStackStaticLibTestsLib",
    platform_apis: true,
    min_sdk_version: "29",
    jarjar_rules: ":NetworkStackJarJarRules",
    jarjar_rules: ":NetworkStackJarJarRules",
    static_libs: [
        "NetworkStaticLibTestsLib",
        "NetdStaticLibTestsLib",
    ],
}
}


// Special version of the network stack tests that includes all tests necessary for code coverage
// Special version of the network stack tests that includes all tests necessary for code coverage
@@ -120,8 +106,10 @@ android_test {
        "modules-utils-native-coverage-listener",
        "modules-utils-native-coverage-listener",
        "NetworkStackTestsLib",
        "NetworkStackTestsLib",
        "NetworkStackIntegrationTestsLib",
        "NetworkStackIntegrationTestsLib",
        "NetworkStackStaticLibTestsLib",
        "NetworkStaticLibTestsLib",
        "NetdStaticLibTestsLib",
    ],
    ],
    compile_multilib: "both",
    compile_multilib: "both",
    manifest: "AndroidManifest_coverage.xml",
    manifest: "AndroidManifest_coverage.xml",
    jarjar_rules: ":NetworkStackJarJarRules",
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -44,7 +44,6 @@ java_defaults {
        "libnetworkstackutilsjni",
        "libnetworkstackutilsjni",
    ],
    ],
    jni_uses_sdk_apis: true,
    jni_uses_sdk_apis: true,
    jarjar_rules: ":NetworkStackJarJarRules",
}
}


// Tests for NetworkStackNext.
// Tests for NetworkStackNext.
@@ -58,6 +57,7 @@ android_test {
    defaults: ["NetworkStackTestsDefaults"],
    defaults: ["NetworkStackTestsDefaults"],
    static_libs: ["NetworkStackApiCurrentLib"],
    static_libs: ["NetworkStackApiCurrentLib"],
    compile_multilib: "both", // Workaround for b/147785146 for mainline-presubmit
    compile_multilib: "both", // Workaround for b/147785146 for mainline-presubmit
    jarjar_rules: ":NetworkStackJarJarRules",
}
}


// Library containing the unit tests. This is used by the coverage test target to pull in the
// Library containing the unit tests. This is used by the coverage test target to pull in the
@@ -84,6 +84,7 @@ android_test {
    defaults: ["NetworkStackTestsDefaults"],
    defaults: ["NetworkStackTestsDefaults"],
    static_libs: ["NetworkStackApiStableLib"],
    static_libs: ["NetworkStackApiStableLib"],
    compile_multilib: "both",
    compile_multilib: "both",
    jarjar_rules: ":NetworkStackJarJarRules",
}
}


// Additional dependencies of libnetworkstackutilsjni that are not provided by the system when
// Additional dependencies of libnetworkstackutilsjni that are not provided by the system when