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

Commit 6a751b96 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge "ErrorProne: AdapterService" am: c3ed8646

parents 9ca91c97 c3ed8646
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -471,10 +471,16 @@ public class AdapterService extends Service {
    private final AdapterServiceHandler mHandler = new AdapterServiceHandler();

    @Override
    @RequiresPermission(value = android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
    @RequiresPermission(
            allOf = {
                android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                android.Manifest.permission.READ_DEVICE_CONFIG,
            },
            anyOf = {
                android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                android.Manifest.permission.INTERACT_ACROSS_USERS,
                android.Manifest.permission.CREATE_USERS,
                android.Manifest.permission.MANAGE_USERS
                android.Manifest.permission.MANAGE_USERS,
    })
    public void onCreate() {
        super.onCreate();
@@ -4132,7 +4138,7 @@ public class AdapterService extends Service {
        }
    }

    private class CallerInfo {
    private static class CallerInfo {
        public String callerPackageName;
        public UserHandle user;
    }
@@ -4688,7 +4694,7 @@ public class AdapterService extends Service {
     * Get UUIDs for service supported by a remote device
     *
     * @param device the remote device that we want to get UUIDs from
     * @return
     * @return the uuids of the remote device
     */
    @VisibleForTesting
    public ParcelUuid[] getRemoteUuids(BluetoothDevice device) {
@@ -4707,7 +4713,7 @@ public class AdapterService extends Service {
     * Converts HCI disconnect reasons to Android disconnect reasons.
     * <p>
     * The HCI Error Codes used for ACL disconnect reasons propagated up from native code were
     * copied from: {@link system/bt/stack/include/hci_error_code.h}.
     * copied from: packages/modules/Bluetooth/system/stack/include/hci_error_code.h
     * <p>
     * These error codes are specified and described in Bluetooth Core Spec v5.1, Vol 2, Part D.
     *
@@ -4916,11 +4922,15 @@ public class AdapterService extends Service {
        readEnergyInfo();

        synchronized (mEnergyInfoLock) {
            long now = System.currentTimeMillis();
            final long deadline = now + CONTROLLER_ENERGY_UPDATE_TIMEOUT_MILLIS;
            while (now < deadline) {
                try {
                mEnergyInfoLock.wait(CONTROLLER_ENERGY_UPDATE_TIMEOUT_MILLIS);
                    mEnergyInfoLock.wait(deadline - now);
                    break;
                } catch (InterruptedException e) {
                // Just continue, the energy data may be stale but we won't miss anything next time
                // we query.
                    now = System.currentTimeMillis();
                }
            }

            final BluetoothActivityEnergyInfo info =
@@ -4997,6 +5007,7 @@ public class AdapterService extends Service {
    // This function is called from JNI. It allows native code to set a single wake
    // alarm. If an alarm is already pending and a new request comes in, the alarm
    // will be rescheduled (i.e. the previously set alarm will be cancelled).
    @RequiresPermission(android.Manifest.permission.SCHEDULE_EXACT_ALARM)
    private boolean setWakeAlarm(long delayMillis, boolean shouldWake) {
        synchronized (this) {
            if (mPendingAlarm != null) {
@@ -5303,6 +5314,7 @@ public class AdapterService extends Service {
            "INIT_logging_debug_disabled_for_tags";
    private static final String BTAA_HCI_LOG_FLAG = "INIT_btaa_hci";

    @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG)
    private String[] getInitFlags() {
        ArrayList<String> initFlags = new ArrayList<>();
        if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, GD_CORE_FLAG, false)) {
@@ -5531,6 +5543,7 @@ public class AdapterService extends Service {
        private static final long DEFAULT_SCAN_TIMEOUT_MILLIS = 30 * MINUTE_IN_MILLIS;
        private static final int DEFAULT_SCAN_UPGRADE_DURATION_MILLIS = (int) SECOND_IN_MILLIS * 6;

        @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG)
        public void start() {
            DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_BLUETOOTH,
                    BackgroundThread.getExecutor(), this);