Fix VpnSettings.StatusChecker.start()

to avoid multiple threads checking status at the same time.
This commit is contained in:
Hung-ying Tyan
2009-07-13 17:23:32 +08:00
parent 1ddccd07f7
commit fe0b0178cb
2 changed files with 5 additions and 4 deletions

View File

@@ -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);

View File

@@ -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() {