summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Jeppsson <mathias.jeppsson@sonyericsson.com>2011-04-26 14:04:48 +0200
committerJohan Redestig <johan.redestig@sonyericsson.com>2011-04-26 14:05:01 +0200
commit7d6a3299b58c5b53de4016a2e199974b94ae90df (patch)
treefa56f0e608b54959c051a53907da9368252222b3
parent138654ff978d6fc784003f87dfb5fda46a6a3703 (diff)
downloadandroid_packages_apps_Bluetooth-7d6a3299b58c5b53de4016a2e199974b94ae90df.tar.gz
android_packages_apps_Bluetooth-7d6a3299b58c5b53de4016a2e199974b94ae90df.tar.bz2
android_packages_apps_Bluetooth-7d6a3299b58c5b53de4016a2e199974b94ae90df.zip
Fixing crash in BluetoothPbapService.
If Bluetooth is turned off while there is an PBAP connect request pending, the status bar notification or yes/no activity will not disappear. If user selects yes, an intent will start PbapService again. PbapService will try to make the device trusted. As this instance of PbapService don't have any connected device, crash will occur. Make sure status bar notification or yes/no activity disappears, by sending timeout intent when Bluetooth is turned off. Also, PbapReceiver should not forward any intents except STATE_ON if Bluetooth is off as this will start the PbapService. Change-Id: Iee4f95ab2de34db6e00ff9b1fd7f8677947b8f4f
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapReceiver.java6
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapService.java9
2 files changed, 14 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapReceiver.java b/src/com/android/bluetooth/pbap/BluetoothPbapReceiver.java
index b4503766a..55cb66c8e 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapReceiver.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapReceiver.java
@@ -61,6 +61,12 @@ public class BluetoothPbapReceiver extends BroadcastReceiver {
|| (state == BluetoothAdapter.STATE_TURNING_OFF)) {
startService = false;
}
+ } else {
+ // Don't forward intent unless device has bluetooth and bluetooth is enabled.
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ if (adapter == null || !adapter.isEnabled()) {
+ startService = false;
+ }
}
if (startService) {
context.startService(in);
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
index 3b1216e6f..a7225b260 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
@@ -245,10 +245,17 @@ public class BluetoothPbapService extends Service {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
boolean removeTimeoutMsg = true;
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
- removeTimeoutMsg = false;
if (state == BluetoothAdapter.STATE_OFF) {
+ // Send any pending timeout now, as this service will be destroyed.
+ if (mSessionStatusHandler.hasMessages(USER_TIMEOUT)) {
+ Intent timeoutIntent = new Intent(USER_CONFIRM_TIMEOUT_ACTION);
+ sendBroadcast(timeoutIntent);
+ removePbapNotification(NOTIFICATION_ID_ACCESS);
+ }
// Release all resources
closeService();
+ } else {
+ removeTimeoutMsg = false;
}
} else if (action.equals(ACCESS_ALLOWED_ACTION)) {
if (intent.getBooleanExtra(EXTRA_ALWAYS_ALLOWED, false)) {