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

Commit 006c111a authored by William Escande's avatar William Escande
Browse files

SystemServer: Align timeout with stack timeout

The Bluetooth stack is starting with a 4second timeout, we should align
the timer in the system server to match
(See com.android.bluetooth.btservice.AdapterState.java)

Bug: 342484285
Test: None
Flag: Exempt increasing timeout only
Change-Id: Icb8ef5ba574fe52436195f695864b3b6f94b351d
parent b388022d
Loading
Loading
Loading
Loading
+12 −23
Original line number Diff line number Diff line
@@ -127,36 +127,25 @@ class BluetoothManagerService {
    private static final int ACTIVE_LOG_MAX_SIZE = 20;
    private static final int CRASH_LOG_MAX_SIZE = 100;

    // See android.os.Build.HW_TIMEOUT_MULTIPLIER. This should not be set on real hw
    private static final int HW_MULTIPLIER = SystemProperties.getInt("ro.hw_timeout_multiplier", 1);

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

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

    /**
     * @return timeout value for synchronous binder call
     */
    private static Duration getSyncTimeout() {
        return SYNC_CALLS_TIMEOUT;
    }
    private static final Duration STATE_TIMEOUT = Duration.ofSeconds(4 * HW_MULTIPLIER);

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

    @VisibleForTesting static final int MESSAGE_ENABLE = 1;
    @VisibleForTesting static final int MESSAGE_DISABLE = 2;
@@ -2147,11 +2136,11 @@ class BluetoothManagerService {
    }

    boolean waitForManagerState(int state) {
        return mState.waitForState(getSyncTimeout(), state);
        return mState.waitForState(STATE_TIMEOUT, state);
    }

    private boolean waitForState(int... states) {
        return mState.waitForState(getSyncTimeout(), states);
        return mState.waitForState(STATE_TIMEOUT, states);
    }

    private void sendDisableMsg(int reason) {