b/2310373 Show pairing dialogs if the device has been scanning for bt devices recently.

Change-Id: Iec9eb37a5e79b63cc3cf226e2ead6d9ed06d56a6
This commit is contained in:
Michael Chan
2010-03-02 15:04:27 -08:00
parent 385a9e52be
commit 76098b7f7a
6 changed files with 75 additions and 10 deletions

View File

@@ -72,6 +72,9 @@ public class LocalBluetoothManager {
// of raising notifications
private static long GRACE_PERIOD_TO_SHOW_DIALOGS_IN_FOREGROUND = 60 * 1000;
public static final String SHARED_PREFERENCES_KEY_DISCOVERING_TIMESTAMP =
"last_discovering_time";
private static final String SHARED_PREFERENCES_KEY_LAST_SELECTED_DEVICE =
"last_selected_device";
@@ -314,7 +317,7 @@ public class LocalBluetoothManager {
long currentTimeMillis = System.currentTimeMillis();
SharedPreferences sharedPreferences = getSharedPreferences();
// If the device was in discoverable mode recently
// If the device was in discoverABLE mode recently
long lastDiscoverableEndTime = sharedPreferences.getLong(
BluetoothDiscoverableEnabler.SHARED_PREFERENCES_KEY_DISCOVERABLE_END_TIMESTAMP, 0);
if ((lastDiscoverableEndTime + GRACE_PERIOD_TO_SHOW_DIALOGS_IN_FOREGROUND)
@@ -322,6 +325,14 @@ public class LocalBluetoothManager {
return true;
}
// If the device was discoverING recently
if (mAdapter != null && mAdapter.isDiscovering()) {
return true;
} else if ((sharedPreferences.getLong(SHARED_PREFERENCES_KEY_DISCOVERING_TIMESTAMP, 0) +
GRACE_PERIOD_TO_SHOW_DIALOGS_IN_FOREGROUND) > currentTimeMillis) {
return true;
}
// If the device was picked in the device picker recently
if (deviceAddress != null) {
String lastSelectedDevice = sharedPreferences.getString(