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

Commit d2a8cbcb authored by William Escande's avatar William Escande
Browse files

Extract Change-ids from BMS

This allow the platform_compat_config to no longer parse the whole
library.
This follow the pattern used in the Bluetooth app.

Test: No-op change
Bug: 262605980
Change-Id: Ib057df8e0ebdfa50ffeff4896d11920ea2a9f36e
parent 29a86248
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ java_defaults {
        "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
@@ -60,11 +63,11 @@ java_library {
        strict_updatability_linting: true,
    },
    libs: [
        "app-compat-annotations",
        "framework-annotations-lib",
        "framework-bluetooth-pre-jarjar",
        "framework-configinfrastructure",
        "framework-statsd.stubs.module_lib",
        "service-bluetooth.change-ids",
    ],

    static_libs: [
@@ -89,7 +92,6 @@ java_library {
    ],

    libs: [
        "app-compat-annotations",
        "framework-bluetooth.impl",
    ],
    sdk_version: "system_server_current",
@@ -143,8 +145,3 @@ java_library {
        strict_updatability_linting: true,
    },
}

platform_compat_config {
    name: "bluetooth-compat-config",
    src: ":service-bluetooth-pre-jarjar",
}
+34 −0
Original line number Diff line number Diff line
// Copyright 2023 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

java_library {
    name: "service-bluetooth.change-ids",
    defaults: ["service-bluetooth-common-defaults"],
    srcs: [
        "com/android/server/bluetooth/ChangeIds.java",
    ],
    libs: [
        "app-compat-annotations",
    ],
    sdk_version: "system_server_current",
}

platform_compat_config {
    name: "bluetooth-compat-config",
    src: ":service-bluetooth.change-ids",
}
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.bluetooth;

import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;

/**
 * All the {@link ChangeId} used in the Bluetooth service .
 */
class ChangeIds {
    private ChangeIds(){}

    /**
     * Starting with {@link android.os.Build.VERSION_CODES#TIRAMISU}, applications are
     * not allowed to enable/disable Bluetooth.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.TIRAMISU)
    static final long RESTRICT_ENABLE_DISABLE = 218493289L;
}
+1 −10
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.server.bluetooth.BluetoothAirplaneModeListener.APM_USE
import static com.android.server.bluetooth.BluetoothAirplaneModeListener.BLUETOOTH_APM_STATE;
import static com.android.server.bluetooth.BluetoothAirplaneModeListener.NOTIFICATION_NOT_SHOWN;
import static com.android.server.bluetooth.BluetoothAirplaneModeListener.USED;
import static com.android.server.bluetooth.ChangeIds.RESTRICT_ENABLE_DISABLE;

import android.Manifest;
import android.annotation.NonNull;
@@ -51,8 +52,6 @@ import android.bluetooth.IBluetoothManager;
import android.bluetooth.IBluetoothManagerCallback;
import android.bluetooth.IBluetoothProfileServiceConnection;
import android.bluetooth.IBluetoothStateChangeCallback;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.content.AttributionSource;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -200,14 +199,6 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
    private static final int FLAGS_SYSTEM_APP =
            ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;

    /**
     * Starting with {@link android.os.Build.VERSION_CODES#TIRAMISU}, applications are
     * not allowed to enable/disable Bluetooth.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.TIRAMISU)
    static final long RESTRICT_ENABLE_DISABLE = 218493289L;

    private final Context mContext;

    private final UserManager mUserManager;