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

Commit 2bf1ec54 authored by Michael Groover's avatar Michael Groover
Browse files

Suppress lint for methods using APIs promoted from system to public

Bug: 259743961
Test: errorprone build
Tag: #compatibility
Change-Id: Idb5c61d5b98e8070017c68cd253ca86649c0df00
Merged-In: Idb5c61d5b98e8070017c68cd253ca86649c0df00
parent 010fdfe9
Loading
Loading
Loading
Loading
+36 −0
Original line number Original line Diff line number Diff line
@@ -44,8 +44,10 @@ import android.bluetooth.BluetoothDevice;
import android.companion.AssociationInfo;
import android.companion.AssociationInfo;
import android.companion.CompanionDeviceManager;
import android.companion.CompanionDeviceManager;
import android.content.AttributionSource;
import android.content.AttributionSource;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.ContentValues;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.location.LocationManager;
@@ -53,6 +55,7 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Binder;
import android.os.Build;
import android.os.Build;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Handler;
import android.os.ParcelUuid;
import android.os.ParcelUuid;
import android.os.PowerExemptionManager;
import android.os.PowerExemptionManager;
import android.os.Process;
import android.os.Process;
@@ -1056,6 +1059,8 @@ public final class Utils {
    /**
    /**
     * Returns bundled broadcast options.
     * Returns bundled broadcast options.
     */
     */
    // TODO(b/193460475): Remove when tooling supports SystemApi to public API.
    @SuppressLint("NewApi")
    public static @NonNull Bundle getTempAllowlistBroadcastOptions() {
    public static @NonNull Bundle getTempAllowlistBroadcastOptions() {
        return getTempBroadcastOptions().toBundle();
        return getTempBroadcastOptions().toBundle();
    }
    }
@@ -1063,6 +1068,8 @@ public final class Utils {
    /**
    /**
     * Returns broadcast options.
     * Returns broadcast options.
     */
     */
    // TODO(b/193460475): Remove when tooling supports SystemApi to public API.
    @SuppressLint("NewApi")
    public static @NonNull BroadcastOptions getTempBroadcastOptions() {
    public static @NonNull BroadcastOptions getTempBroadcastOptions() {
        final BroadcastOptions bOptions = BroadcastOptions.makeBasic();
        final BroadcastOptions bOptions = BroadcastOptions.makeBasic();
        // Use the Bluetooth process identity to pass permission check when reading DeviceConfig
        // Use the Bluetooth process identity to pass permission check when reading DeviceConfig
@@ -1078,6 +1085,35 @@ public final class Utils {
        }
        }
        return bOptions;
        return bOptions;
    }
    }

    /**
     * Sends the {@code intent} as a broadcast in the provided {@code context} to receivers that
     * have been granted the specified {@code receiverPermission} with the {@link BroadcastOptions}
     * {@code options}.
     *
     * @see Context#sendBroadcast(Intent, String, Bundle)
     */
    // TODO(b/193460475): Remove when tooling supports SystemApi to public API.
    @SuppressLint("NewApi")
    public static void sendBroadcast(@NonNull Context context, @NonNull Intent intent,
            @Nullable String receiverPermission, @Nullable Bundle options) {
        context.sendBroadcast(intent, receiverPermission, options);
    }

    /**
     * @see Context#sendOrderedBroadcast(Intent, String, Bundle, BroadcastReceiver, Handler,
     *          int, String, Bundle)
     */
    // TODO(b/193460475): Remove when tooling supports SystemApi to public API.
    @SuppressLint("NewApi")
    public static void sendOrderedBroadcast(@NonNull Context context, @NonNull Intent intent,
            @Nullable String receiverPermission, @Nullable Bundle options,
            @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler,
            int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) {
        context.sendOrderedBroadcast(intent, receiverPermission, options, resultReceiver, scheduler,
                initialCode, initialData, initialExtras);
    }

    /**
    /**
     * Checks that value is present as at least one of the elements of the array.
     * Checks that value is present as at least one of the elements of the array.
     * @param array the array to check in
     * @param array the array to check in
+4 −2
Original line number Original line Diff line number Diff line
@@ -1085,7 +1085,8 @@ public class A2dpService extends ProfileService {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        sendBroadcast(intent, BLUETOOTH_CONNECT, Utils.getTempAllowlistBroadcastOptions());
        Utils.sendBroadcast(this, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
    }
    }


    private void broadcastCodecConfig(BluetoothDevice device, BluetoothCodecStatus codecStatus) {
    private void broadcastCodecConfig(BluetoothDevice device, BluetoothCodecStatus codecStatus) {
@@ -1097,7 +1098,8 @@ public class A2dpService extends ProfileService {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        sendBroadcast(intent, BLUETOOTH_CONNECT, Utils.getTempAllowlistBroadcastOptions());
        Utils.sendBroadcast(this, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
    }
    }


    private class BondStateChangedReceiver extends BroadcastReceiver {
    private class BondStateChangedReceiver extends BroadcastReceiver {
+2 −2
Original line number Original line Diff line number Diff line
@@ -701,7 +701,7 @@ final class A2dpStateMachine extends StateMachine {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        mA2dpService.sendBroadcast(intent, BLUETOOTH_CONNECT,
        Utils.sendBroadcast(mA2dpService, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
                Utils.getTempAllowlistBroadcastOptions());
    }
    }


@@ -713,7 +713,7 @@ final class A2dpStateMachine extends StateMachine {
        intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
        intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
        intent.putExtra(BluetoothProfile.EXTRA_STATE, newState);
        intent.putExtra(BluetoothProfile.EXTRA_STATE, newState);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        mA2dpService.sendBroadcast(intent, BLUETOOTH_CONNECT,
        Utils.sendBroadcast(mA2dpService, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
                Utils.getTempAllowlistBroadcastOptions());
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -310,6 +310,7 @@ public class A2dpSinkStateMachine extends StateMachine {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        mMostRecentState = currentState;
        mMostRecentState = currentState;
        mService.sendBroadcast(intent, BLUETOOTH_CONNECT, Utils.getTempAllowlistBroadcastOptions());
        Utils.sendBroadcast(mService, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
    }
    }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -1320,7 +1320,8 @@ class AvrcpControllerStateMachine extends StateMachine {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        mMostRecentState = currentState;
        mMostRecentState = currentState;
        mService.sendBroadcast(intent, BLUETOOTH_CONNECT, Utils.getTempAllowlistBroadcastOptions());
        Utils.sendBroadcast(mService, intent, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
    }
    }


    private boolean shouldRequestFocus() {
    private boolean shouldRequestFocus() {
Loading