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

Commit 34a25050 authored by William Escande's avatar William Escande
Browse files

SystemServer: Sanitize build rules

Move optimization to pre-jarjar to prevent build warning
Uniformize bp in SystemServer to have common pattern
Share build flags with tests

Update proguard to allow for optimization

Bug: 288450479
Bug: 321804999
Test: mmm packages/modules/Bluetooth/service
Change-Id: I0492696b963a604029d3e38cc1ea649f704fd84d
parent ff68f67e
Loading
Loading
Loading
Loading
+52 −49
Original line number Diff line number Diff line
@@ -16,27 +16,8 @@ package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

filegroup {
    name: "services.bluetooth-sources",
    srcs: [
        ":statslog-bluetooth-java-gen",
        "src/**/*.java",
        "src/AdapterState.kt",
        "src/AutoOnFeature.kt",
        "src/Log.kt",
        "src/RadioModeListener.kt",
        "src/airplane/ModeListener.kt",
        "src/com/**/*.kt",
        "src/satellite/ModeListener.kt",
    ],
    visibility: [":__subpackages__"],
}

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

    name: "service-bluetooth-buildflags",
    errorprone: {
        javacflags: [
            "-Xep:AlreadyChecked:ERROR",
@@ -49,8 +30,6 @@ java_defaults {
        ],
    },

    sdk_version: "system_server_current",

    lint: {
        error_checks: [
            "ExtraText",
@@ -68,6 +47,26 @@ java_defaults {
        "-Werror",
    ],

    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",
    defaults: ["service-bluetooth-buildflags"],
    installable: false,
    srcs: [
        ":statslog-bluetooth-java-gen",
        "src/**/*.java",
        "src/AdapterState.kt",
        "src/AutoOnFeature.kt",
        "src/Log.kt",
        "src/RadioModeListener.kt",
        "src/airplane/ModeListener.kt",
        "src/com/**/*.kt",
        "src/satellite/ModeListener.kt",
    ],

    libs: [
        "framework-annotations-lib",
        "framework-bluetooth-pre-jarjar",
@@ -88,14 +87,26 @@ java_defaults {
        "modules-utils-shell-command-handler",
    ],

    lint: {
        baseline_filename: "lint-baseline.xml",
    },

    optimize: {
        enabled: true,
        shrink: true,
        proguard_flags_files: ["proguard.flags"],
    },

    sdk_version: "system_server_current",
    min_sdk_version: "Tiramisu",
    apex_available: ["com.android.btservices"],
    visibility: [":__subpackages__"],
}

// service-bluetooth static library
// ==============================================================
// Apply jarjaring before using library in the apex
java_library {
    name: "service-bluetooth",
    defaults: ["service-bluetooth-pre-jarjar"],
    static_libs: ["service-bluetooth-pre-jarjar"],
    installable: true,

    jarjar_rules: ":bluetooth-jarjar-rules",
@@ -105,56 +116,48 @@ java_library {
        shrink: true,
        proguard_flags_files: ["proguard.flags"],
    },
    visibility: [
        "//packages/modules/Bluetooth/apex",
    ],
    apex_available: [
        "com.android.btservices",

    libs: [
        "framework-bluetooth",
    ],

    min_sdk_version: "Tiramisu",
    lint: {
        baseline_filename: "lint-baseline.xml",
    },
    apex_available: ["com.android.btservices"],
    visibility: ["//packages/modules/Bluetooth/apex"],
}

java_library {
    name: "bluetooth-manager-service-proto-java-gen",
    srcs: [":srcs_bluetooth_manager_service_proto"],
    installable: false,

    proto: {
        type: "stream",
        include_dirs: [
            "external/protobuf/src",
        ],
        include_dirs: ["external/protobuf/src"],
    },
    srcs: [
        ":srcs_bluetooth_manager_service_proto",
    ],

    sdk_version: "system_server_current",
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
    apex_available: ["com.android.btservices"],
}

java_library {
    name: "bluetooth-nano-protos",
    srcs: [":system-messages-proto-src"],
    installable: false,

    proto: {
        type: "nano",
    },
    srcs: [
        ":system-messages-proto-src",
    ],

    libs: ["libprotobuf-java-nano"],
    lint: {
        strict_updatability_linting: true,

    },

    sdk_version: "system_current",
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
    apex_available: ["com.android.btservices"],
}

android_robolectric_test {
+3 −7
Original line number Diff line number Diff line
@@ -10,17 +10,13 @@ package {
// AIDL interface used in service-bluetooth
java_library {
    name: "service-bluetooth-binder-aidl",
    visibility: ["//packages/modules/Bluetooth:__subpackages__"],
    srcs: [
        "android/bluetooth/IBluetoothManager.aidl",
        "android/bluetooth/IBluetoothManagerCallback.aidl",
    ],
    libs: [
        "framework-annotations-lib",
    ],
    libs: ["framework-annotations-lib"],
    sdk_version: "module_current",
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
    apex_available: ["com.android.btservices"],
    visibility: ["//packages/modules/Bluetooth:__subpackages__"],
}
+5 −10
Original line number Diff line number Diff line
@@ -18,17 +18,12 @@ package {

java_library {
    name: "service-bluetooth.change-ids",
    srcs: [
        "com/android/server/bluetooth/ChangeIds.java",
    ],
    libs: [
        "app-compat-annotations",
    ],
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
    srcs: ["com/android/server/bluetooth/ChangeIds.java"],
    libs: ["app-compat-annotations"],
    sdk_version: "system_server_current",
    min_sdk_version: "Tiramisu",
    apex_available: ["com.android.btservices"],
    visibility: ["//packages/modules/Bluetooth/service:__subpackages__"],
}

platform_compat_config {
+9 −9
Original line number Diff line number Diff line
@@ -19,13 +19,7 @@ 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",

    defaults: ["service-bluetooth-buildflags"],
    srcs: [
        "src/**/*.java",
        "src/**/*.kt",
@@ -39,6 +33,10 @@ android_test {
        "mockito-target-extended-minus-junit4",
        "platform-compat-test-rules",
        "platform-test-annotations",

        // Linking source to test the working copy, not the on-device copy.
        // Use 'pre-jarjar' so that we can reference symbols before renaming.
        "service-bluetooth-pre-jarjar",
        "truth",
    ],

@@ -46,6 +44,8 @@ android_test {
        "android.test.base",
        "android.test.mock",
        "android.test.runner",
        "framework-bluetooth-pre-jarjar",
        "service-bluetooth.change-ids",
    ],
    jni_libs: [
        // these are needed for Extended Mockito
@@ -53,10 +53,10 @@ android_test {
        "libstaticjvmtiagent",
    ],

    min_sdk_version: "Tiramisu",

    test_suites: [
        "general-tests",
        "mts-bluetooth",
    ],

    min_sdk_version: "Tiramisu",
}