Loading src/main/java/org/torproject/android/service/OrbotConstants.kt +3 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,9 @@ object OrbotConstants { const val ACTION_UPDATE_ONION_NAMES = "org.torproject.android.intent.action.UPDATE_ONION_NAMES" const val ACTION_CHECK_RUNNING_SYNC: String = "org.torproject.android.intent.action.CHECK_RUNNING_SYNC" const val ACTION_RUNNING_SYNC: String = "org.torproject.android.intent.action.RUNNING_SYNC" /** * Intent send by Orbot with `ON/OFF/STARTING/STOPPING` status */ Loading src/main/java/org/torproject/android/service/OrbotService.java +18 −2 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ public class OrbotService extends VpnService { OrbotVpnManager mVpnManager; Handler mHandler; ActionBroadcastReceiver mActionBroadcastReceiver; private IsServiceRunningBroadcastReceiver mIsServiceRunningBroadcastReceiver; protected String mCurrentStatus = STATUS_OFF; TorControlConnection conn = null; private ServiceConnection torServiceConnection; Loading Loading @@ -212,6 +213,7 @@ public class OrbotService extends VpnService { unregisterReceiver(mActionBroadcastReceiver); unregisterReceiver(mPowerReceiver); mSnowflakeProxyWrapper.stopProxy(); // stop snowflake proxy if its somehow running LocalBroadcastManager.getInstance(this).unregisterReceiver(mIsServiceRunningBroadcastReceiver); } catch (IllegalArgumentException iae) { //not registered yet } Loading Loading @@ -386,6 +388,11 @@ public class OrbotService extends VpnService { mActionBroadcastReceiver = new ActionBroadcastReceiver(); ContextCompat.registerReceiver(this, mActionBroadcastReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED); mIsServiceRunningBroadcastReceiver = new IsServiceRunningBroadcastReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver( mIsServiceRunningBroadcastReceiver, new IntentFilter(ACTION_CHECK_RUNNING_SYNC)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.isNotificationEnabled()) Notifications.createNotificationChannel(this); Loading Loading @@ -1148,4 +1155,13 @@ public class OrbotService extends VpnService { } } } private class IsServiceRunningBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent resIntent = new Intent(ACTION_RUNNING_SYNC); resIntent.putExtra(EXTRA_STATUS, mCurrentStatus); LocalBroadcastManager.getInstance(context).sendBroadcastSync(resIntent); } } } Loading
src/main/java/org/torproject/android/service/OrbotConstants.kt +3 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,9 @@ object OrbotConstants { const val ACTION_UPDATE_ONION_NAMES = "org.torproject.android.intent.action.UPDATE_ONION_NAMES" const val ACTION_CHECK_RUNNING_SYNC: String = "org.torproject.android.intent.action.CHECK_RUNNING_SYNC" const val ACTION_RUNNING_SYNC: String = "org.torproject.android.intent.action.RUNNING_SYNC" /** * Intent send by Orbot with `ON/OFF/STARTING/STOPPING` status */ Loading
src/main/java/org/torproject/android/service/OrbotService.java +18 −2 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ public class OrbotService extends VpnService { OrbotVpnManager mVpnManager; Handler mHandler; ActionBroadcastReceiver mActionBroadcastReceiver; private IsServiceRunningBroadcastReceiver mIsServiceRunningBroadcastReceiver; protected String mCurrentStatus = STATUS_OFF; TorControlConnection conn = null; private ServiceConnection torServiceConnection; Loading Loading @@ -212,6 +213,7 @@ public class OrbotService extends VpnService { unregisterReceiver(mActionBroadcastReceiver); unregisterReceiver(mPowerReceiver); mSnowflakeProxyWrapper.stopProxy(); // stop snowflake proxy if its somehow running LocalBroadcastManager.getInstance(this).unregisterReceiver(mIsServiceRunningBroadcastReceiver); } catch (IllegalArgumentException iae) { //not registered yet } Loading Loading @@ -386,6 +388,11 @@ public class OrbotService extends VpnService { mActionBroadcastReceiver = new ActionBroadcastReceiver(); ContextCompat.registerReceiver(this, mActionBroadcastReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED); mIsServiceRunningBroadcastReceiver = new IsServiceRunningBroadcastReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver( mIsServiceRunningBroadcastReceiver, new IntentFilter(ACTION_CHECK_RUNNING_SYNC)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.isNotificationEnabled()) Notifications.createNotificationChannel(this); Loading Loading @@ -1148,4 +1155,13 @@ public class OrbotService extends VpnService { } } } private class IsServiceRunningBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent resIntent = new Intent(ACTION_RUNNING_SYNC); resIntent.putExtra(EXTRA_STATUS, mCurrentStatus); LocalBroadcastManager.getInstance(context).sendBroadcastSync(resIntent); } } }