diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-12-06 18:53:10 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-12-06 18:53:10 -0800 |
commit | 2b582a6914f8e13a261b5a66567517ac62074f74 (patch) | |
tree | b7714bdcc95f4cb5f2c19203068c0d2778032ac8 | |
parent | 87580fa4b4c3d7f13407d87c2b926a475978fd7a (diff) | |
parent | 7ba5b5c222f68871f9d398360159397c69657aa8 (diff) | |
download | android_packages_apps_Bluetooth-2b582a6914f8e13a261b5a66567517ac62074f74.tar.gz android_packages_apps_Bluetooth-2b582a6914f8e13a261b5a66567517ac62074f74.tar.bz2 android_packages_apps_Bluetooth-2b582a6914f8e13a261b5a66567517ac62074f74.zip |
Merge "Bluetooth-OPP: Clean up OPP threads during user turned OFF BT"
-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) { |