Skip to content

Commit

Permalink
When the VPN is disconnected through another app using VpnService or …
Browse files Browse the repository at this point in the history
…manually by the user

turn off the VPN toggle within Orbot
  • Loading branch information
bitmold committed Jul 27, 2020
1 parent 3b708b4 commit 992b310
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ public void onReceive(Context context, Intent intent) {

break;
}
case ACTION_STOP_VPN: {
mBtnVPN.setChecked(false);
break;
}
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1913,13 +1913,22 @@ Level for onTrimMemory(int): the process had been showing a user interface, and
@Override
public IBinder onBind(Intent intent) {
Log.e( TAG, "onBind" );
handleIntent( intent );
return null;
handleIntent(intent);
return super.onBind(intent); // invoking super class will call onRevoke() when appropriate
}

// system calls this method when VPN disconnects (either by the user or another VPN app)
@Override
public void onRevoke() {
Prefs.putUseVpn(false);
mVpnManager.handleIntent(new Builder(), new Intent(ACTION_STOP_VPN));
// tell UI, if it's open, to update immediately (don't wait for onResume() in Activity...)
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_STOP_VPN));
}

private void handleIntent( Intent intent ) {
if( intent != null && intent.getAction() != null ) {
Log.e( TAG, intent.getAction().toString() );
Log.e( TAG, intent.getAction());
}
}

Expand Down

0 comments on commit 992b310

Please sign in to comment.