diff options
author | Glenn Maynard <glenn@zewt.org> | 2011-09-03 14:31:39 -0400 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2012-01-25 18:42:08 +0000 |
commit | bf2ebd16544b1b4b4065b44568007e339f3e8f27 (patch) | |
tree | 2884dbb9f7b93e79af850585b8ad2e24976462fc | |
parent | 30085ba1cf5da20ecf14c82df3d5d5b423c741b6 (diff) | |
download | frameworks_base-bf2ebd16544b1b4b4065b44568007e339f3e8f27.zip frameworks_base-bf2ebd16544b1b4b4065b44568007e339f3e8f27.tar.gz frameworks_base-bf2ebd16544b1b4b4065b44568007e339f3e8f27.tar.bz2 |
Allow reducing the BT connection delay.
By default, a four-second delay is imposed on some devices between
setting up HFP and A2DP. This makes Bluetooth initialization take
much longer than it needs to for many devices. This delay is very
annoying; slow Bluetooth connections often mean the user is sitting
around, waiting for it to complete.
Allow disabling this delay if the user's devices don't need it. I've
assumed that some devices do (it's there for a reason), so the default
is unchanged.
Change-Id: Ibfa0a76b4907cb76ad754c09d15e21b5f8b278cd
Signed-off-by: Glenn Maynard <glenn@zewt.org>
-rw-r--r-- | core/java/android/bluetooth/BluetoothDeviceProfileState.java | 13 | ||||
-rw-r--r-- | core/java/android/provider/Settings.java | 6 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java index 69710d9..afbfb79 100644 --- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java +++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java @@ -25,6 +25,7 @@ import android.content.IntentFilter; import android.os.Message; import android.os.PowerManager; import android.os.SystemClock; +import android.provider.Settings; import android.server.BluetoothA2dpService; import android.server.BluetoothService; import android.util.Log; @@ -83,6 +84,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine private static final int AUTO_CONNECT_DELAY = 6000; // 6 secs private static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs + private static final int CONNECT_OTHER_PROFILES_DELAY_FAST = 100; // 100ms private static final int CONNECTION_ACCESS_REQUEST_EXPIRY_TIMEOUT = 7000; // 7 secs private static final int CONNECTION_ACCESS_UNDEFINED = -1; private static final long INIT_INCOMING_REJECT_TIMER = 1000; // 1 sec @@ -824,7 +826,16 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine i.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); i.putExtra(ACTION_CONNECT_TYPE, type); PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, 0); - mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + CONNECT_OTHER_PROFILES_DELAY, pi); + + long delayTime = CONNECT_OTHER_PROFILES_DELAY; + + // Many devices don't need the long delay. + if (Settings.System.getInt(mContext.getContentResolver(), + Settings.System.BLUETOOTH_FAST_CONNECT, 0) != 0) { + delayTime = CONNECT_OTHER_PROFILES_DELAY_FAST; + } + + mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delayTime, pi); } private int getTrust() { diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 840cfa9..e8706fc 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1204,6 +1204,12 @@ public final class Settings { public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios"; /** + * Whether Bluetooth fast connections are enabled. + * @hide + */ + public static final String BLUETOOTH_FAST_CONNECT = "bluetooth_fast_connect"; + + /** * The policy for deciding when Wi-Fi should go to sleep (which will in * turn switch to using the mobile data as an Internet connection). * <p> |