diff options
Diffstat (limited to 'packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java')
-rw-r--r-- | packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java b/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java index 617875e..32b8e51 100644 --- a/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java +++ b/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java @@ -27,7 +27,6 @@ import android.net.vpn.VpnManager; import android.net.vpn.VpnProfile; import android.net.vpn.VpnState; import android.os.IBinder; -import android.util.Log; import java.io.IOException; @@ -55,6 +54,12 @@ public class VpnServiceBinder extends Service { } }; + public void onStart (Intent intent, int startId) { + super.onStart(intent, startId); + setForeground(true); + android.util.Log.d("VpnServiceBinder", "becomes a foreground service"); + } + public IBinder onBind(Intent intent) { return mBinder; } @@ -62,21 +67,13 @@ public class VpnServiceBinder extends Service { private synchronized boolean connect( VpnProfile p, String username, String password) { if (mService != null) return false; - try { - mService = createService(p); - mService.onConnect(username, password); - return true; - } catch (Throwable e) { - Log.e(TAG, "connect()", e); - if (mService != null) mService.onError(); - return false; - } + mService = createService(p); + return mService.onConnect(username, password); } private synchronized void checkStatus(VpnProfile p) { - if (mService == null) broadcastConnectivity(p.getName(), VpnState.IDLE); - - if (!p.getName().equals(mService.mProfile.getName())) { + if ((mService == null) + || (!p.getName().equals(mService.mProfile.getName()))) { broadcastConnectivity(p.getName(), VpnState.IDLE); } else { broadcastConnectivity(p.getName(), mService.getState()); |