Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b582a69 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth-OPP: Clean up OPP threads during user turned OFF BT"

parents 87580fa4 7ba5b5c2
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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;
                }

+21 −9
Original line number Diff line number Diff line
@@ -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) {