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

Commit 89fc79a6 authored by William Escande's avatar William Escande
Browse files

Framework: Fix & enforce some errorprone

Enforce:
* AndroidFrameworkCompatChange
* AndroidFrameworkRethrowFromSystem
* AndroidFrameworkTargetSdk

Disable AndroidFrameworkEfficientCollections for the same reason as in
the app

Bug: 344658662
Test: m framework-bluetooth
Flag: Exempt following errorprone recommendation
Change-Id: I7a61024da1e7771c667a43018261e01ac5a95b43
parent 9530f374
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -95,7 +95,10 @@ java_sdk_library {
        javacflags: [
            "-Xep:InlineMeSuggester:OFF", // The @InlineMe annotation is not available

            "-Xep:AndroidFrameworkCompatChange:ERROR",
            "-Xep:AndroidFrameworkRequiresPermission:ERROR",
            "-Xep:AndroidFrameworkRethrowFromSystem:ERROR",
            "-Xep:AndroidFrameworkTargetSdk:ERROR",
            "-Xep:AndroidHideInComments:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchFail:ERROR",
@@ -116,8 +119,16 @@ java_sdk_library {
            "-Xep:StringCharset:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnusedVariable:ERROR",

            "-XepExcludedPaths:.*/srcjars/.*", // Exclude generated files
            // After fixing this errorprone, we decided to not merge the change.
            // It is not very readable and the benefits are minimal when looking
            // at the size of the maps used in the Bluetooth application.
            // See https://r.android.com/3200511
            "-Xep:AndroidFrameworkEfficientCollections:OFF",

            // Exclude generated files
            "-XepExcludedPaths:.*/srcjars/.*",
        ],
        enabled: true,
    },
+6 −2
Original line number Diff line number Diff line
@@ -3589,7 +3589,11 @@ public final class BluetoothAdapter {
     *     BluetoothProfile#HEARING_AID} or {@link BluetoothProfile#GATT_SERVER}.
     * @return true on success, false on error
     */
    @SuppressLint({"AndroidFrameworkRequiresPermission", "AndroidFrameworkBluetoothPermission"})
    @SuppressLint({
        "AndroidFrameworkRequiresPermission",
        "AndroidFrameworkBluetoothPermission",
        "AndroidFrameworkCompatChange"
    })
    public boolean getProfileProxy(
            Context context, BluetoothProfile.ServiceListener listener, int profile) {
        if (context == null || listener == null) {
@@ -3617,7 +3621,7 @@ public final class BluetoothAdapter {
        // Preserve legacy compatibility where apps were depending on
        // registerStateChangeCallback() performing a permissions check which
        // has been relaxed in modern platform versions
        if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R
        if (context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.S
                && context.checkSelfPermission(BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Need BLUETOOTH permission");
        }
+6 −3
Original line number Diff line number Diff line
@@ -145,16 +145,19 @@ public final class BluetoothManager {
    @RequiresLegacyBluetoothPermission
    @RequiresBluetoothConnectPermission
    @RequiresPermission(BLUETOOTH_CONNECT)
    @SuppressWarnings("AndroidFrameworkRethrowFromSystem") // iGatt is not system server
    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int profile, int[] states) {
        if (profile != BluetoothProfile.GATT && profile != BluetoothProfile.GATT_SERVER) {
            throw new IllegalArgumentException("Profile not supported: " + profile);
        }

        List<BluetoothDevice> devices = new ArrayList<BluetoothDevice>();
        List<BluetoothDevice> devices = new ArrayList<>();

        try {
        IBluetoothGatt iGatt = mAdapter.getBluetoothGatt();
            if (iGatt == null) return devices;
        if (iGatt == null) {
            return devices;
        }
        try {
            devices =
                    Attributable.setAttributionSource(
                            iGatt.getDevicesMatchingConnectionStates(
+0 −3
Original line number Diff line number Diff line
@@ -192,9 +192,6 @@ public final class BluetoothMapClient implements BluetoothProfile, AutoCloseable
     */
    public static final int RESULT_CANCELED = 2;

    /** @hide */
    private static final int UPLOADING_FEATURE_BITMASK = 0x08;

    /*
     * UNREAD, READ, UNDELETED, DELETED are passed as parameters
     * to setMessageStatus to indicate the messages new state.