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

Commit aa5db2ec authored by Omair Kamil's avatar Omair Kamil
Browse files

Move distance measurement methods into its own binder.

Bug: 358692626
Flag: EXEMPT, mechanical refactor
Test: atest BluetoothInstrumentationTests, atest BumbleBluetoothTests
Change-Id: Icdbb6bf8c23913544e2b7748f948539169d2e545
parent 94c3aee0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ filegroup {
        "android/bluetooth/IBluetoothSocketManager.aidl",
        "android/bluetooth/IBluetoothVolumeControl.aidl",
        "android/bluetooth/IBluetoothVolumeControlCallback.aidl",
        "android/bluetooth/IDistanceMeasurement.aidl",
        "android/bluetooth/IncomingRfcommSocketInfo.aidl",
        "android/bluetooth/le/IAdvertisingSetCallback.aidl",
        "android/bluetooth/le/IDistanceMeasurementCallback.aidl",
+3 −0
Original line number Diff line number Diff line
@@ -347,4 +347,7 @@ interface IBluetooth

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    IBinder getBluetoothAdvertise();

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    IBinder getDistanceMeasurement();
}
+0 −16
Original line number Diff line number Diff line
@@ -20,9 +20,6 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.IBluetoothGattCallback;
import android.bluetooth.IBluetoothGattServerCallback;
import android.bluetooth.le.DistanceMeasurementMethod;
import android.bluetooth.le.DistanceMeasurementParams;
import android.bluetooth.le.IDistanceMeasurementCallback;
import android.content.AttributionSource;
import android.os.ParcelUuid;
/**
@@ -110,17 +107,4 @@ interface IBluetoothGatt {
    void disconnectAll(in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED}, conditional=true)")
    int subrateModeRequest(in int clientIf, in BluetoothDevice device, in int subrateMode, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    List<DistanceMeasurementMethod> getSupportedDistanceMeasurementMethods(in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void startDistanceMeasurement(in ParcelUuid uuid, in DistanceMeasurementParams params, in IDistanceMeasurementCallback callback,
                            in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int stopDistanceMeasurement(in ParcelUuid uuid, in BluetoothDevice device, in int method, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int getChannelSoundingMaxSupportedSecurityLevel(in BluetoothDevice remoteDevice, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int getLocalChannelSoundingMaxSupportedSecurityLevel(in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int[] getChannelSoundingSupportedSecurityLevels(in AttributionSource attributionSource);
}
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright 2025 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 android.bluetooth;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.DistanceMeasurementMethod;
import android.bluetooth.le.DistanceMeasurementParams;
import android.bluetooth.le.IDistanceMeasurementCallback;
import android.content.AttributionSource;
import android.os.ParcelUuid;

/**
 * API for interacting with distance measurement
 * @hide
 */
interface IDistanceMeasurement {
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    List<DistanceMeasurementMethod> getSupportedDistanceMeasurementMethods(in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void startDistanceMeasurement(in ParcelUuid uuid, in DistanceMeasurementParams params, in IDistanceMeasurementCallback callback,
                            in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int stopDistanceMeasurement(in ParcelUuid uuid, in BluetoothDevice device, in int method, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int getChannelSoundingMaxSupportedSecurityLevel(in BluetoothDevice remoteDevice, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int getLocalChannelSoundingMaxSupportedSecurityLevel(in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    int[] getChannelSoundingSupportedSecurityLevels(in AttributionSource attributionSource);
}
+11 −0
Original line number Diff line number Diff line
@@ -4416,6 +4416,12 @@ public class AdapterService extends Service {
            AdapterService service = getService();
            return service == null ? null : service.getBluetoothAdvertise();
        }

        @Override
        public IBinder getDistanceMeasurement() {
            AdapterService service = getService();
            return service == null ? null : service.getDistanceMeasurement();
        }
    }

    /**
@@ -6158,6 +6164,11 @@ public class AdapterService extends Service {
        return mGattService == null ? null : mGattService.getBluetoothAdvertise();
    }

    @Nullable
    IBinder getDistanceMeasurement() {
        return mGattService == null ? null : mGattService.getDistanceMeasurement();
    }

    @RequiresPermission(BLUETOOTH_CONNECT)
    void unregAllGattClient(AttributionSource source) {
        if (mGattService != null) {
Loading