diff options
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppNotification.java | 12 | ||||
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppService.java | 30 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/src/com/android/bluetooth/opp/BluetoothOppNotification.java index ec180e844..161cd576f 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppNotification.java +++ b/src/com/android/bluetooth/opp/BluetoothOppNotification.java @@ -170,6 +170,16 @@ class BluetoothOppNotification { public void btOffNotification() { if (V) Log.v(TAG, "Update Notification while BT is Turning OFF"); synchronized (BluetoothOppNotification.this) { + if (mUpdateNotificationThread != null) { + try { + mUpdateNotificationThread.interrupt(); + mUpdateNotificationThread.join(); + mUpdateNotificationThread = null; + } catch (InterruptedException ie) { + Log.e(TAG, "Notification thread join interrupted"); + } + } + updateActiveNotification(); mInboundUpdateCompleteNotification = true; mOutboundUpdateCompleteNotification = true; @@ -205,7 +215,7 @@ class BluetoothOppNotification { Thread.sleep(BluetoothShare.UI_UPDATE_INTERVAL); } } catch (InterruptedException e) { - if (V) Log.v(TAG, "NotificationThread was interrupted (1), exiting"); + if (V) Log.v(TAG, "NotificationThread sleep is interrupted (1), exiting"); return; } diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java index 3e67f8f97..e0acd273c 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppService.java +++ b/src/com/android/bluetooth/opp/BluetoothOppService.java @@ -416,6 +416,17 @@ public class BluetoothOppService extends Service { break; case BluetoothAdapter.STATE_TURNING_OFF: if (V) Log.v(TAG, "Receiver DISABLED_ACTION "); + + if (mUpdateThread != null) { + try { + mUpdateThread.interrupt(); + mUpdateThread.join(); + mUpdateThread = null; + } catch (InterruptedException ie) { + Log.e(TAG, "OPPService Thread join interrupted"); + } + } + mNotifier.btOffNotification(); //FIX: Don't block main thread /* @@ -600,15 +611,6 @@ public class BluetoothOppService extends Service { cursor.close(); cursor = null; - try { - if (mPowerManager.isScreenOn()) { - Thread.sleep(BluetoothShare.UI_UPDATE_INTERVAL); - } - } catch (InterruptedException e) { - if (V) Log.v(TAG, "OppService UpdateThread was interrupted (1), exiting"); - return; - } - if (V) { if (mServerSession != null) { Log.v(TAG, "Server Session is active"); @@ -622,6 +624,16 @@ public class BluetoothOppService extends Service { Log.v(TAG, "No active Client Session"); } } + + try { + if (((mServerSession != null) || (mTransfer != null)) + && mPowerManager.isScreenOn()) { + Thread.sleep(BluetoothShare.UI_UPDATE_INTERVAL); + } + } catch (InterruptedException e) { + if (V) Log.v(TAG, "OppService Thread sleep is interrupted (1), exiting"); + return; + } } while (mPowerManager.isScreenOn() && ((mServerSession != null) || (mTransfer != null))); synchronized (BluetoothOppService.this) { |