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

Commit d289a223 authored by Prashanth Swaminathan's avatar Prashanth Swaminathan
Browse files

Scale adapter/manager timeouts by hw_multiplier

Slower targets need these timeouts scaled by the
ro.hw_timeout_multiplier to ensure that Bluetooth operations succeed
between adapter state transitions.

Bug: 293932755
Test: atest avd_riscv64_boot_test
Change-Id: Ib3157fb56e03f36c472708813ce04ed0c811c13d
parent 922b7767
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -77,10 +77,14 @@ final class AdapterState extends StateMachine {
    static final String BLE_STOP_TIMEOUT_DELAY_PROPERTY =
            "ro.bluetooth.ble_stop_timeout_delay";

    static final int BLE_START_TIMEOUT_DELAY = 4000;
    static final int BLE_STOP_TIMEOUT_DELAY = 4000;
    static final int BREDR_START_TIMEOUT_DELAY = 4000;
    static final int BREDR_STOP_TIMEOUT_DELAY = 4000;
    static final int BLE_START_TIMEOUT_DELAY =
        4000 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    static final int BLE_STOP_TIMEOUT_DELAY =
        4000 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    static final int BREDR_START_TIMEOUT_DELAY =
        4000 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    static final int BREDR_STOP_TIMEOUT_DELAY =
        4000 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);

    private AdapterService mAdapterService;
    private TurningOnState mTurningOnState = new TurningOnState();
+16 −7
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.DeviceConfig;
@@ -113,10 +114,13 @@ class BluetoothManagerService {
    private static final int CRASH_LOG_MAX_SIZE = 100;

    private static final int DEFAULT_REBIND_COUNT = 3;
    private static final int TIMEOUT_BIND_MS = 3000; // Maximum msec to wait for a bind
    // Maximum msec to wait for a bind
    private static final int TIMEOUT_BIND_MS =
        3000 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);

    // Timeout value for synchronous binder call
    private static final Duration SYNC_CALLS_TIMEOUT = Duration.ofSeconds(3);
    private static final Duration SYNC_CALLS_TIMEOUT =
        Duration.ofSeconds(3 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1));

    /**
     * @return timeout value for synchronous binder call
@@ -126,15 +130,20 @@ class BluetoothManagerService {
    }

    // Maximum msec to wait for service restart
    private static final int SERVICE_RESTART_TIME_MS = 400;
    private static final int SERVICE_RESTART_TIME_MS
        = 400 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    // Maximum msec to wait for restart due to error
    private static final int ERROR_RESTART_TIME_MS = 3000;
    private static final int ERROR_RESTART_TIME_MS
        = 3000 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    // Maximum msec to delay MESSAGE_USER_SWITCHED
    private static final int USER_SWITCHED_TIME_MS = 200;
    private static final int USER_SWITCHED_TIME_MS
        = 200 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    // Delay for the addProxy function in msec
    private static final int ADD_PROXY_DELAY_MS = 100;
    private static final int ADD_PROXY_DELAY_MS
        = 100 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);
    // Delay for retrying enable and disable in msec
    private static final int ENABLE_DISABLE_DELAY_MS = 300;
    private static final int ENABLE_DISABLE_DELAY_MS
        = 300 * SystemProperties.getInt("ro.hw_timeout_multiplier", 1);

    @VisibleForTesting static final int MESSAGE_ENABLE = 1;
    @VisibleForTesting static final int MESSAGE_DISABLE = 2;