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

Commit b57d03c6 authored by Md Shahriar Hossain Sajib's avatar Md Shahriar Hossain Sajib
Browse files

Enable delays with system properties to make it generic for different environments

Using delay parameters from system properties to make it generic for
different environments

Bug: 199827901
Test: gd/cert/run
Test: IOP and BCST
Tag: #refactor

Change-Id: I293293adb18e03e02b77297cedaf9f0ed627ef06
parent 16bb1bf4
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@ package com.android.bluetooth.btservice;

import android.bluetooth.BluetoothAdapter;
import android.os.Message;
import android.os.SystemProperties;
import android.util.Log;

import com.android.bluetooth.R;
import com.android.bluetooth.telephony.BluetoothInCallService;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -72,6 +72,11 @@ final class AdapterState extends StateMachine {
    static final int BLE_STOP_TIMEOUT = 11;
    static final int BLE_START_TIMEOUT = 12;

    static final String BLE_START_TIMEOUT_DELAY_PROPERTY =
            "ro.bluetooth.ble_start_timeout_delay";
    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 = 1000;
    static final int BREDR_START_TIMEOUT_DELAY = 4000;
@@ -264,7 +269,10 @@ final class AdapterState extends StateMachine {
        @Override
        public void enter() {
            super.enter();
            sendMessageDelayed(BLE_START_TIMEOUT, BLE_START_TIMEOUT_DELAY);
            final int timeoutDelay = SystemProperties.getInt(
                    BLE_START_TIMEOUT_DELAY_PROPERTY, BLE_START_TIMEOUT_DELAY);
            Log.d(TAG, "Start Timeout Delay: " + timeoutDelay);
            sendMessageDelayed(BLE_START_TIMEOUT, timeoutDelay);
            mAdapterService.bringUpBle();
        }

@@ -385,7 +393,10 @@ final class AdapterState extends StateMachine {
        public void enter() {
            super.enter();
            mAdapterService.enableBluetoothInCallService(false);
            sendMessageDelayed(BLE_STOP_TIMEOUT, BLE_STOP_TIMEOUT_DELAY);
            final int timeoutDelay = SystemProperties.getInt(
                    BLE_STOP_TIMEOUT_DELAY_PROPERTY, BLE_STOP_TIMEOUT_DELAY);
            Log.d(TAG, "Stop Timeout Delay: " + timeoutDelay);
            sendMessageDelayed(BLE_STOP_TIMEOUT, timeoutDelay);
            mAdapterService.bringDownBle();
        }