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

Commit 675308ad authored by William Escande's avatar William Escande
Browse files

remove service-bluetooth-common-defaults

Linking directly the source file to the test instead of the pre-jarjar
library allow test to build kotlin and to have access to internal method

Bug: 262605980
Test: m ServiceBluetoothTests
Test: atest ServiceBluetoothTests
Change-Id: I3d67a822fd00a94a51b97a46735d9c02c9ec0f2e
parent fa5022b7
Loading
Loading
Loading
Loading
+20 −34
Original line number Diff line number Diff line
@@ -23,15 +23,16 @@ filegroup {
        "src/**/*.java",
        "src/**/*.kt",
    ],
    visibility: [
        "//frameworks/base/services",
        "//frameworks/base/services/core",
    ],
    visibility: [":__subpackages__"],
}

// pre-jarjar version of service-bluetooth that builds against pre-jarjar version of framework-bluetooth
java_defaults {
    name: "service-bluetooth-common-defaults",
    defaults: ["bluetooth-module-sdk-version-defaults"],
    name: "service-bluetooth-pre-jarjar",
    srcs: [
        ":services.bluetooth-sources",
    ],

    errorprone: {
        javacflags: [
            "-Xep:AlreadyChecked:ERROR",
@@ -46,23 +47,6 @@ java_defaults {
            enabled: false,
        },
    },
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
    defaults_visibility: [
        ":__subpackages__",
    ],
}

// pre-jarjar version of service-bluetooth that builds against pre-jarjar version of framework-bluetooth
java_library {
    name: "service-bluetooth-pre-jarjar",
    installable: false,
    defaults: ["service-bluetooth-common-defaults"],
    srcs: [
        ":services.bluetooth-sources",
    ],

    sdk_version: "system_server_current",

@@ -85,23 +69,20 @@ java_library {
        "bluetooth-proto-enums-java-gen",
        "modules-utils-shell-command-handler",
    ],

    visibility: [":__subpackages__"],
}

// service-bluetooth static library
// ==============================================================
java_library {
    name: "service-bluetooth",
    defaults: ["service-bluetooth-common-defaults"],
    defaults: ["service-bluetooth-pre-jarjar"],
    installable: true,
    static_libs: [
        "androidx.appcompat_appcompat",
        "service-bluetooth-pre-jarjar",
    ],

    libs: [
        "framework-bluetooth.impl",
    ],
    sdk_version: "system_server_current",

    jarjar_rules: ":bluetooth-jarjar-rules",

@@ -113,6 +94,10 @@ java_library {
    visibility: [
        "//packages/modules/Bluetooth/apex",
    ],
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
}

java_library {
@@ -136,8 +121,7 @@ java_library {

java_library {
    name: "bluetooth-nano-protos",
    sdk_version: "system_current",
    min_sdk_version: "Tiramisu",
    installable: false,
    proto: {
        type: "nano",
    },
@@ -145,10 +129,12 @@ java_library {
        ":system-messages-proto-src",
    ],
    libs: ["libprotobuf-java-nano"],
    apex_available: [
        "com.android.btservices",
    ],
    lint: {
        strict_updatability_linting: true,
    },
    sdk_version: "system_current",
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
}
+7 −19
Original line number Diff line number Diff line
@@ -20,50 +20,38 @@ package {
android_test {
    name: "ServiceBluetoothTests",

    // Linking source to test the working copy, not the on-device copy.
    // Use 'pre-jarjar' so that we can reference symbols before renaming.
    // Then apply the same common jarjar_rules
    defaults: ["service-bluetooth-pre-jarjar"],
    jarjar_rules: ":bluetooth-jarjar-rules",

    srcs: [
        "src/**/*.java",
        "src/**/*.kt",
    ],

    dxflags: ["--multi-dex"],

    java_version: "1.9",

    static_libs: [
        "androidx.test.rules",
        "frameworks-base-testutils",
        "kotlinx_coroutines_test",
        "libprotobuf-java-nano",
        "mockito-target-extended-minus-junit4",
        "platform-compat-test-rules",
        "platform-test-annotations",
        "service-bluetooth.change-ids",
        "truth-prebuilt",

        // Statically link service-bluetooth-pre-jarjar since we want to test the working copy of
        // service-bluetooth, not the on-device copy.
        // Use pre-jarjar version so that we can reference symbols before they are renamed.
        // Then, the jarjar_rules here will perform the rename for the entire APK
        // i.e. service-bluetooth + test code
        "service-bluetooth-pre-jarjar",
    ],

    jarjar_rules: ":bluetooth-jarjar-rules",

    libs: [
        "android.test.base",
        "android.test.mock",
        "android.test.runner",
        "framework-bluetooth-pre-jarjar",
    ],

    jni_libs: [
        // these are needed for Extended Mockito
        "libbluetooth_jni",
        "libdexmakerjvmtiagent",
        "libstaticjvmtiagent",
    ],
    compile_multilib: "both",
    certificate: ":com.android.bluetooth.certificate",

    min_sdk_version: "Tiramisu",

+3 −2
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.server.bluetooth;
import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
import static android.Manifest.permission.LOCAL_MAC_ADDRESS;
import static android.Manifest.permission.LOG_COMPAT_CHANGE;
import static android.Manifest.permission.READ_COMPAT_CHANGE_CONFIG;

import static com.google.common.truth.Truth.assertThat;

@@ -78,6 +76,9 @@ import java.util.function.BooleanSupplier;
@RunWith(AndroidJUnit4.class)
public class BluetoothServiceBinderTest {
    private static final String TAG = BluetoothServiceBinderTest.class.getSimpleName();
    private static final String LOG_COMPAT_CHANGE = "android.permission.LOG_COMPAT_CHANGE";
    private static final String READ_COMPAT_CHANGE_CONFIG =
            "android.permission.READ_COMPAT_CHANGE_CONFIG";

    @Rule public MockitoRule mockito = MockitoJUnit.rule().strictness(STRICT_STUBS);

+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ public class BluetoothShellCommandTest {
        verify(mBinder).enable(any());
    }

    class TestPrivilegedCmd extends BluetoothCommand {
    static class TestPrivilegedCmd extends BluetoothCommand {
        TestPrivilegedCmd() {
            super(true, TestPrivilegedCmd.class.getSimpleName());
        }