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

Commit d576a239 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "update the API about the channel sounding security levels" into main

parents 9bf35901 ff16a0d1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -192,4 +192,6 @@ interface IBluetoothGatt {
    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);
}
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.bluetooth.btservice.AdapterService;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -202,6 +203,11 @@ public class DistanceMeasurementManager {
        return ChannelSoundingParams.CS_SECURITY_LEVEL_ONE;
    }

    Set<Integer> getChannelSoundingSupportedSecurityLevels() {
        // TODO(b/378685103): get it from the HAL when level 4 is supported and HAL v2 is available.
        return Set.of(ChannelSoundingParams.CS_SECURITY_LEVEL_ONE);
    }

    private synchronized int stopRssiTracker(UUID uuid, String identityAddress, boolean timeout) {
        CopyOnWriteArraySet<DistanceMeasurementTracker> set = mRssiTrackers.get(identityAddress);
        if (set == null) {
+24 −0
Original line number Diff line number Diff line
@@ -1266,6 +1266,26 @@ public class GattService extends ProfileService {
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);
            return service.getLocalChannelSoundingMaxSupportedSecurityLevel();
        }

        @Override
        public int[] getChannelSoundingSupportedSecurityLevels(
                AttributionSource attributionSource) {
            GattService service = getService();

            if (service == null
                    || !callerIsSystemOrActiveOrManagedUser(
                            service, TAG, "GattService getChannelSoundingSupportedSecurityLevels")
                    || !Utils.checkConnectPermissionForDataDelivery(
                            service,
                            attributionSource,
                            "GattService getChannelSoundingSupportedSecurityLevels")) {
                return new int[0];
            }
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);
            return service.getChannelSoundingSupportedSecurityLevels().stream()
                    .mapToInt(i -> i)
                    .toArray();
        }
    }
    ;

@@ -2097,6 +2117,10 @@ public class GattService extends ProfileService {
        return mDistanceMeasurementManager.getLocalChannelSoundingMaxSupportedSecurityLevel();
    }

    Set<Integer> getChannelSoundingSupportedSecurityLevels() {
        return mDistanceMeasurementManager.getChannelSoundingSupportedSecurityLevels();
    }

    /**************************************************************************
     * GATT Service functions - CLIENT
     *************************************************************************/
+3 −2
Original line number Diff line number Diff line
@@ -1304,8 +1304,9 @@ package android.bluetooth.le {
  }

  public final class DistanceMeasurementManager {
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int getChannelSoundingMaxSupportedSecurityLevel(@NonNull android.bluetooth.BluetoothDevice);
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int getLocalChannelSoundingMaxSupportedSecurityLevel();
    method @Deprecated @FlaggedApi("com.android.bluetooth.flags.channel_sounding_25q2_apis") @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int getChannelSoundingMaxSupportedSecurityLevel(@NonNull android.bluetooth.BluetoothDevice);
    method @FlaggedApi("com.android.bluetooth.flags.channel_sounding_25q2_apis") @NonNull @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public java.util.Set<java.lang.Integer> getChannelSoundingSupportedSecurityLevels();
    method @Deprecated @FlaggedApi("com.android.bluetooth.flags.channel_sounding_25q2_apis") @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int getLocalChannelSoundingMaxSupportedSecurityLevel();
    method @NonNull @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public java.util.List<android.bluetooth.le.DistanceMeasurementMethod> getSupportedMethods();
    method @Nullable @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public android.os.CancellationSignal startMeasurementSession(@NonNull android.bluetooth.le.DistanceMeasurementParams, @NonNull java.util.concurrent.Executor, @NonNull android.bluetooth.le.DistanceMeasurementSession.Callback);
  }
+3 −0
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * The {@link ChannelSoundingParams} provide a way to adjust distance measurement preferences for
@@ -51,6 +53,7 @@ public final class ChannelSoundingParams implements Parcelable {
    @interface LocationType {}

    /** @hide */
    @Target(ElementType.TYPE_USE)
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(
            value = {
Loading