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

Commit fa42d932 authored by Liang Li's avatar Liang Li Committed by Jayden Kim
Browse files

Read socket offload capabilities from bluetooth low power proccesor

Bug: 342012881
Bug: 367419086
Test: atest CtsBluetoothTestCases
Change-Id: I581435207c9716ccdbedc3dbd77f81845d244a87
parent ea59bfab
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -338,4 +338,7 @@ interface IBluetooth

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    oneway void killBluetoothProcess();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    boolean isLeCocSocketOffloadSupported(in AttributionSource source);
}
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public final class AbstractionLayer {
    static final int BT_PROPERTY_REMOTE_ASHA_CAPABILITY = 0X15;
    static final int BT_PROPERTY_REMOTE_ASHA_TRUNCATED_HISYNCID = 0X16;
    static final int BT_PROPERTY_REMOTE_MODEL_NUM = 0x17;
    static final int BT_PROPERTY_LPP_OFFLOAD_FEATURES = 0x1B;

    public static final int BT_DEVICE_TYPE_BREDR = 0x01;
    public static final int BT_DEVICE_TYPE_BLE = 0x02;
+27 −0
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ class AdapterProperties {
    private boolean mIsLeIsochronousBroadcasterSupported;
    private boolean mIsLeChannelSoundingSupported;

    private int mNumberOfSupportedOffloadedLeCocSockets;

    // Lock for all getters and setters.
    // If finer grained locking is needer, more locks
    // can be added here.
@@ -908,6 +910,10 @@ class AdapterProperties {
                        updateDynamicAudioBufferSupport(val);
                        break;

                    case AbstractionLayer.BT_PROPERTY_LPP_OFFLOAD_FEATURES:
                        updateLppOffloadFeatureSupport(val);
                        break;

                    default:
                        Log.e(TAG, "Property change not handled in Java land:" + type);
                }
@@ -1022,6 +1028,27 @@ class AdapterProperties {
        mBufferConstraintList.complete(bufferConstraintList);
    }

    /**
     * @return the mNumberOfSupportedOffloadedLeCocSockets
     */
    int getNumberOfSupportedOffloadedLeCocSockets() {
        return mNumberOfSupportedOffloadedLeCocSockets;
    }

    private void updateLppOffloadFeatureSupport(byte[] val) {
        if (val.length < 1) {
            Log.e(TAG, "BT_PROPERTY_LPP_OFFLOAD_FEATURES: invalid value length");
            return;
        }
        mNumberOfSupportedOffloadedLeCocSockets = (0xFF & ((int) val[0]));

        Log.d(
                TAG,
                "BT_PROPERTY_LPP_OFFLOAD_FEATURES: update from Offload HAL"
                        + " mNumberOfSupportedOffloadedLeCocSockets = "
                        + mNumberOfSupportedOffloadedLeCocSockets);
    }

    void onBluetoothReady() {
        debugLog(
                "onBluetoothReady, state="
+21 −0
Original line number Diff line number Diff line
@@ -4387,6 +4387,16 @@ public class AdapterService extends Service {
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);
            return service.mDatabaseManager.isMicrophonePreferredForCalls(device);
        }

        @Override
        public boolean isLeCocSocketOffloadSupported(AttributionSource source) {
            AdapterService service = getService();
            if (service == null) {
                return false;
            }
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);
            return service.isLeCocSocketOffloadSupported();
        }
    }

    /**
@@ -7156,4 +7166,15 @@ public class AdapterService extends Service {
            Log.e(TAG, "Error happened while removing contents: ", e);
        }
    }

    /** Get the number of the supported offloaded LE COC sockets. */
    public int getNumberOfSupportedOffloadedLeCocSockets() {
        return mAdapterProperties.getNumberOfSupportedOffloadedLeCocSockets();
    }

    /** Check if the offloaded LE COC socket is supported. */
    public boolean isLeCocSocketOffloadSupported() {
        int val = getNumberOfSupportedOffloadedLeCocSockets();
        return val > 0;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ package android.bluetooth {
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isAutoOnSupported();
    method public boolean isBleScanAlwaysAvailable();
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int isDistanceMeasurementSupported();
    method @FlaggedApi("com.android.bluetooth.flags.socket_settings_api") @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isLeCocSocketOffloadSupported();
    method public boolean isLeEnabled();
    method @NonNull public static String nameForState(int);
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int notifyActiveDeviceChangeApplied(@NonNull android.bluetooth.BluetoothDevice);
Loading