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

Commit 0ff974ff authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge "BluetoothManager: override context deviceId" into main am: c8d07146

parents fbc85d3b c8d07146
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@ java_defaults {
    name: "BluetoothShimsDefaults",
    libs: [
        "androidx.annotation_annotation",
    ],
    static_libs : [
        "modules-utils-build_system"
        "modules-utils-build",
    ],
    apex_available: [
        "com.android.btservices",
@@ -40,7 +38,7 @@ java_library {
        "BluetoothShimsDefaults",
    ],
    srcs: ["common/**/*.java"],
    sdk_version: "system_current",
    sdk_version: "module_current",
    visibility: ["//visibility:private"],
}

@@ -70,10 +68,10 @@ java_library {
        "34/**/*.java",
    ],
    libs: [
        "BluetoothShimsCommon",
        "BluetoothApi33Shims",
        "BluetoothShimsCommon",
    ],
    sdk_version: "module_current",
    sdk_version: "module_34",
    visibility: ["//visibility:private"],
}

@@ -83,9 +81,9 @@ java_library {
        "BluetoothShimsDefaults",
    ],
    static_libs: [
        "BluetoothShimsCommon",
        "BluetoothApi33Shims",
        "BluetoothApi34Shims",
        "BluetoothShimsCommon",
    ],
    visibility: [
        "//packages/modules/Bluetooth/android/app",
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ java_defaults {
    static_libs: [
        "PlatformProperties",
        "bluetooth_flags_java_lib",
        "modules-utils-build",
        "modules-utils-expresslog",
        "service-bluetooth-binder-aidl",
    ],
+12 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.bluetooth;

import static com.android.modules.utils.build.SdkLevel.isAtLeastU;

import android.annotation.RequiresFeature;
import android.annotation.RequiresNoPermission;
import android.annotation.RequiresPermission;
@@ -56,14 +58,20 @@ public final class BluetoothManager {

    /** @hide */
    public BluetoothManager(Context context) {
        mAdapter = BluetoothAdapter.createAdapter(context.getAttributionSource());
        if (com.android.bluetooth.flags.Flags.overrideContextToSpecifyDeviceId() && isAtLeastU()) {
            // Pin the context DeviceId prevent the associated attribution source to be obsolete
            // TODO: b/343739429 -- pass the context to BluetoothAdapter constructor instead
            mContext = context.createDeviceContext(Context.DEVICE_ID_DEFAULT);
        } else {
            mContext = context;
        }
        mAdapter = BluetoothAdapter.createAdapter(mContext.getAttributionSource());
    }

    /**
     * Get the BLUETOOTH Adapter for this device.
     * Get the BluetoothAdapter for this device.
     *
     * @return the BLUETOOTH Adapter
     * @return the BluetoothAdapter
     */
    @RequiresNoPermission
    public BluetoothAdapter getAdapter() {