Improve VpnSettings start-up time.

* Changes
  + add orientation and keyboard config change in the manifest file.
  + remove state saving code
  + improve status checking time by doing it in one server connection.
This commit is contained in:
Hung-ying Tyan
2009-07-18 02:55:56 +08:00
parent 628431de91
commit ba127f57ae
3 changed files with 101 additions and 95 deletions

View File

@@ -26,6 +26,7 @@ import android.net.vpn.IVpnService;
import android.net.vpn.VpnManager;
import android.net.vpn.VpnProfile;
import android.net.vpn.VpnState;
import android.os.ConditionVariable;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
@@ -42,7 +43,6 @@ import java.io.IOException;
*/
public class AuthenticationActor implements VpnProfileActor {
private static final String TAG = AuthenticationActor.class.getName();
private static final int ONE_SECOND = 1000; // ms
private Context mContext;
private VpnProfile mProfile;
@@ -175,27 +175,31 @@ public class AuthenticationActor implements VpnProfileActor {
//@Override
public void checkStatus() {
final ConditionVariable cv = new ConditionVariable();
cv.close();
ServiceConnection c = new ServiceConnection() {
public synchronized void onServiceConnected(ComponentName className,
IBinder service) {
cv.open();
try {
IVpnService.Stub.asInterface(service).checkStatus(mProfile);
} catch (RemoteException e) {
Log.e(TAG, "checkStatus()", e);
broadcastConnectivity(VpnState.IDLE);
} finally {
notify();
mContext.unbindService(this);
}
}
public void onServiceDisconnected(ComponentName className) {
// do nothing
cv.open();
broadcastConnectivity(VpnState.IDLE);
mContext.unbindService(this);
}
};
if (bindService(c)) {
// wait for a second, let status propagate
wait(c, ONE_SECOND);
mContext.unbindService(c);
if (!cv.block(1000)) broadcastConnectivity(VpnState.IDLE);
}
}
@@ -211,14 +215,6 @@ public class AuthenticationActor implements VpnProfileActor {
mVpnManager.broadcastConnectivity(mProfile.getName(), s, errorCode);
}
private void wait(Object o, int ms) {
synchronized (o) {
try {
o.wait(ms);
} catch (Exception e) {}
}
}
private void setSavedUsername(String name) throws IOException {
if (!name.equals(mProfile.getSavedUsername())) {
mProfile.setSavedUsername(name);