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

Commit 5e364b45 authored by William Escande's avatar William Escande
Browse files

Fwk: Address most of AndroidLint WrongConstant

Bug: 289445022
Test: m Bluetooth
Flag: Exempt lint only
Change-Id: I7834577f5be76a501b6129e76fdcf905831dff97
parent 58a0fb33
Loading
Loading
Loading
Loading
+19 −80
Original line number Diff line number Diff line
@@ -267,6 +267,7 @@ public final class BluetoothAdapter {
            value = {
                BluetoothStatusCodes.SUCCESS,
                BluetoothStatusCodes.ERROR_TIMEOUT,
                BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
                BluetoothStatusCodes.RFCOMM_LISTENER_START_FAILED_UUID_IN_USE,
                BluetoothStatusCodes.RFCOMM_LISTENER_OPERATION_FAILED_NO_MATCHING_SERVICE_RECORD,
                BluetoothStatusCodes.RFCOMM_LISTENER_OPERATION_FAILED_DIFFERENT_APP,
@@ -1816,11 +1817,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public boolean clearBluetooth() {
        mServiceLock.readLock().lock();
        try {
@@ -1848,11 +1845,7 @@ public final class BluetoothAdapter {
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public boolean factoryReset() {
        return clearBluetooth();
    }
@@ -1989,13 +1982,8 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothScanPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_SCAN,
                BLUETOOTH_PRIVILEGED,
            })
    @ScanModeStatusCode
    public int setScanMode(@ScanMode int mode) {
    @RequiresPermission(allOf = {BLUETOOTH_SCAN, BLUETOOTH_PRIVILEGED})
    public @ScanModeStatusCode int setScanMode(@ScanMode int mode) {
        if (getState() != STATE_ON) {
            return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
        }
@@ -2059,13 +2047,8 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothScanPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_SCAN,
                BLUETOOTH_PRIVILEGED,
            })
    @ScanModeStatusCode
    public int setDiscoverableTimeout(@NonNull Duration timeout) {
    @RequiresPermission(allOf = {BLUETOOTH_SCAN, BLUETOOTH_PRIVILEGED})
    public @ScanModeStatusCode int setDiscoverableTimeout(@NonNull Duration timeout) {
        if (getState() != STATE_ON) {
            return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
        }
@@ -2096,11 +2079,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public long getDiscoveryEndMillis() {
        mServiceLock.readLock().lock();
        try {
@@ -2252,12 +2231,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
                MODIFY_PHONE_STATE,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED, MODIFY_PHONE_STATE})
    public boolean removeActiveDevice(@ActiveDeviceUse int profiles) {
        if (profiles != ACTIVE_DEVICE_AUDIO
                && profiles != ACTIVE_DEVICE_PHONE_CALL
@@ -2300,12 +2274,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
                MODIFY_PHONE_STATE,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED, MODIFY_PHONE_STATE})
    public boolean setActiveDevice(@NonNull BluetoothDevice device, @ActiveDeviceUse int profiles) {
        if (device == null) {
            Log.e(TAG, "setActiveDevice: Null device passed as parameter");
@@ -2844,11 +2813,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public void requestControllerActivityEnergyInfo(
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OnBluetoothActivityEnergyInfoCallback callback) {
@@ -2882,11 +2847,7 @@ public final class BluetoothAdapter {
    @SystemApi
    @RequiresLegacyBluetoothAdminPermission
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public @NonNull List<BluetoothDevice> getMostRecentlyConnectedDevices() {
        if (getState() != STATE_ON) {
            return Collections.emptyList();
@@ -2951,11 +2912,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public @NonNull List<Integer> getSupportedProfiles() {
        final ArrayList<Integer> supportedProfiles = new ArrayList<Integer>();

@@ -3246,8 +3203,7 @@ public final class BluetoothAdapter {
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    @RfcommListenerResult
    public int startRfcommServer(
    public @RfcommListenerResult int startRfcommServer(
            @NonNull String name, @NonNull UUID uuid, @NonNull PendingIntent pendingIntent) {
        if (!pendingIntent.isImmutable()) {
            throw new IllegalArgumentException("The provided PendingIntent is not immutable");
@@ -3278,13 +3234,8 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RfcommListenerResult
    public int stopRfcommServer(@NonNull UUID uuid) {
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public @RfcommListenerResult int stopRfcommServer(@NonNull UUID uuid) {
        mServiceLock.readLock().lock();
        try {
            if (mService != null) {
@@ -3314,11 +3265,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public @NonNull BluetoothSocket retrieveConnectedRfcommSocket(@NonNull UUID uuid) {
        IncomingRfcommSocketInfo socketInfo = null;

@@ -4053,11 +4000,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothConnectPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_CONNECT,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED})
    public void generateLocalOobData(
            @Transport int transport,
            @NonNull @CallbackExecutor Executor executor,
@@ -5508,11 +5451,7 @@ public final class BluetoothAdapter {
     */
    @SystemApi
    @RequiresBluetoothScanPermission
    @RequiresPermission(
            allOf = {
                BLUETOOTH_SCAN,
                BLUETOOTH_PRIVILEGED,
            })
    @RequiresPermission(allOf = {BLUETOOTH_SCAN, BLUETOOTH_PRIVILEGED})
    @GetOffloadedTransportDiscoveryDataScanSupportedReturnValues
    public int getOffloadedTransportDiscoveryDataScanSupported() {
        if (!getLeAccess()) {
+1 −1
Original line number Diff line number Diff line
@@ -780,7 +780,7 @@ public final class BluetoothCodecConfig implements Parcelable {
        return sameAudioFeedingParameters(
                new BluetoothCodecConfig(
                        mCodecType, /* priority */
                        0,
                        CODEC_PRIORITY_DEFAULT,
                        sampleRate,
                        bitsPerSample,
                        channelMode,
+5 −6
Original line number Diff line number Diff line
@@ -163,11 +163,11 @@ public class BluetoothGattCharacteristic implements Parcelable {
    protected int mKeySize = 16;

    /**
     * Write type for this characteristic. See WRITE_TYPE_* constants.
     * Write type for this characteristic.
     *
     * @hide
     */
    protected int mWriteType;
    protected @WriteType int mWriteType;

    /**
     * Back-reference to the service this characteristic belongs to.
@@ -392,7 +392,7 @@ public class BluetoothGattCharacteristic implements Parcelable {
     *
     * @return Write type for this characteristic
     */
    public int getWriteType() {
    public @WriteType int getWriteType() {
        return mWriteType;
    }

@@ -403,10 +403,9 @@ public class BluetoothGattCharacteristic implements Parcelable {
     * BluetoothGatt#writeCharacteristic(BluetoothGattCharacteristic, byte[], int)} function write
     * this characteristic.
     *
     * @param writeType The write type to for this characteristic. Can be one of: {@link
     *     #WRITE_TYPE_DEFAULT}, {@link #WRITE_TYPE_NO_RESPONSE} or {@link #WRITE_TYPE_SIGNED}.
     * @param writeType The write type to for this characteristic.
     */
    public void setWriteType(int writeType) {
    public void setWriteType(@WriteType int writeType) {
        mWriteType = writeType;
    }

+3 −6
Original line number Diff line number Diff line
@@ -100,8 +100,7 @@ public final class BluetoothHearingAid implements BluetoothProfile {
         * @hide
         */
        @SystemApi
        @DeviceMode
        public int getDeviceMode() {
        public @DeviceMode int getDeviceMode() {
            if (VDBG) Log.v(TAG, "getDeviceMode()");
            return (mCapability >> 1) & 1;
        }
@@ -117,8 +116,7 @@ public final class BluetoothHearingAid implements BluetoothProfile {
         * @hide
         */
        @SystemApi
        @DeviceSide
        public int getDeviceSide() {
        public @DeviceSide int getDeviceSide() {
            if (VDBG) Log.v(TAG, "getDeviceSide()");
            return mCapability & 1;
        }
@@ -693,8 +691,7 @@ public final class BluetoothHearingAid implements BluetoothProfile {
    @RequiresLegacyBluetoothPermission
    @RequiresBluetoothConnectPermission
    @RequiresPermission(BLUETOOTH_CONNECT)
    @DeviceSide
    public int getDeviceSide(@NonNull BluetoothDevice device) {
    public @DeviceSide int getDeviceSide(@NonNull BluetoothDevice device) {
        if (VDBG) Log.v(TAG, "getDeviceSide(" + device + ")");
        verifyDeviceNotNull(device, "getDeviceSide");
        final IBluetoothHearingAid service = getService();
+3 −3
Original line number Diff line number Diff line
@@ -295,8 +295,7 @@ public final class BluetoothQualityReport implements Parcelable {
     * @hide
     */
    @SystemApi
    @QualityReportId
    public int getQualityReportId() {
    public @QualityReportId int getQualityReportId() {
        return mBqrCommon.getQualityReportId();
    }

@@ -661,7 +660,7 @@ public final class BluetoothQualityReport implements Parcelable {
        private static final String TAG = BluetoothQualityReport.TAG + ".BqrCommon";
        static final int BQR_COMMON_LEN = 55;

        private int mQualityReportId;
        private @QualityReportId int mQualityReportId;
        private int mPacketType;
        private int mConnectionHandle;
        private int mConnectionRole;
@@ -749,6 +748,7 @@ public final class BluetoothQualityReport implements Parcelable {
            mCalFailedItemCount = in.readInt();
        }

        @QualityReportId
        int getQualityReportId() {
            return mQualityReportId;
        }
Loading