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

Commit fe0b0178 authored by Hung-ying Tyan's avatar Hung-ying Tyan
Browse files

Fix VpnSettings.StatusChecker.start()

to avoid multiple threads checking status at the same time.
parent 1ddccd07
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -195,9 +195,9 @@ public class AuthenticationActor implements VpnProfileActor {
        if (bindService(c)) {
            // wait for a second, let status propagate
            wait(c, ONE_SECOND);
        }
            mContext.unbindService(c);
        }
    }

    private boolean bindService(ServiceConnection c) {
        return mVpnManager.bindVpnService(c);
+4 −3
Original line number Diff line number Diff line
@@ -932,7 +932,7 @@ public class VpnSettings extends PreferenceActivity implements
    // managing status check in a background thread
    private class StatusChecker {
        private Set<VpnProfile> mQueue = new HashSet<VpnProfile>();
        private boolean mPaused;
        private boolean mPaused = true;
        private ConditionVariable mThreadCv = new ConditionVariable();

        void onPause() {
@@ -941,7 +941,6 @@ public class VpnSettings extends PreferenceActivity implements
        }

        synchronized void onResume() {
            mPaused = false;
            start();
        }

@@ -961,7 +960,9 @@ public class VpnSettings extends PreferenceActivity implements
            return p;
        }

        private void start() {
        private synchronized void start() {
            if (!mPaused) return;
            mPaused = false;
            mThreadCv.close();
            new Thread(new Runnable() {
                public void run() {