Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1238ea4 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

/e/ add check running sync action.

(cherry picked from commit 3ef517bd)
parent 05a68401
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
     */
+18 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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
        }
@@ -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);

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