Fix VpnSettings.StatusChecker.start()
to avoid multiple threads checking status at the same time.
This commit is contained in:
@@ -195,8 +195,8 @@ public class AuthenticationActor implements VpnProfileActor {
|
||||
if (bindService(c)) {
|
||||
// wait for a second, let status propagate
|
||||
wait(c, ONE_SECOND);
|
||||
mContext.unbindService(c);
|
||||
}
|
||||
mContext.unbindService(c);
|
||||
}
|
||||
|
||||
private boolean bindService(ServiceConnection c) {
|
||||
|
@@ -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() {
|
||||
|
Reference in New Issue
Block a user