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

Commit 827a391f authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

Fix isServiceRunning detector.

parent 352502f4
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ configure(project(':orbotservice')) {
                groupId 'foundation.e'
                //You can either define these here or get them from project conf elsewhere
                artifactId 'orbotservice'
                version '0.2.0-orbot.16.4.1'
                version '0.2.1-orbot.16.4.1'
                artifact "$buildDir/outputs/aar/orbotservice-release.aar" //aar artifact you want to publish

                //generate pom nodes for dependencies
Compare 5ed9da74 to 9075c529
Original line number Diff line number Diff line
Subproject commit 5ed9da74785e3764563a67114e339cd51414453b
Subproject commit 9075c52977ef98350923ed6de2ea58764faf6746
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ android {
        targetSdkVersion 30

        versionCode 7
        versionName "0.2.0"
        versionName "0.2.1"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
@@ -53,7 +53,7 @@ dependencies {
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"

    implementation 'foundation.e:orbotservice:0.2.0-orbot.16.4.1'
    implementation 'foundation.e:orbotservice:0.2.1-orbot.16.4.1'
    //implementation project(':orbotservice')
}

+21 −3
Original line number Diff line number Diff line
@@ -65,6 +65,18 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule {
    private val localBroadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
        override fun onReceive(context: Context, intent: Intent) {
            val action = intent.action ?: return
            if (action == TorServiceConstants.ACTION_RUNNING_SYNC) {
                try {
                    intent.getStringExtra(TorServiceConstants.EXTRA_STATUS)?.let {
                        val newStatus = Status.valueOf(it)
                        currentStatus = newStatus
                    }
                } catch (e: Exception) {
                    Log.e(TAG, "Can't parse Orbot service status.")
                }
                return
            }

            val msg = messageHandler.obtainMessage()
            msg.obj = action
            msg.data = intent.extras
@@ -135,6 +147,10 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule {
            localBroadcastReceiver,
            IntentFilter(TorServiceConstants.LOCAL_ACTION_PORTS)
        )
        lbm.registerReceiver(
            localBroadcastReceiver,
            IntentFilter(TorServiceConstants.ACTION_RUNNING_SYNC)
        )

        Prefs.getSharedPrefs(context).edit()
            .putInt(VpnPrefs.PREFS_DNS_PORT, TorServiceConstants.TOR_DNS_PORT_DEFAULT)
@@ -151,9 +167,11 @@ class IpScramblerModule(private val context: Context): IIpScramblerModule {
    }

    private fun isServiceRunning(): Boolean {
        // Check if the service is working, by looking at the presence of the notification
        val notificationManager = context.getSystemService(NOTIFICATION_SERVICE) as NotificationManager?
        return notificationManager?.activeNotifications?.find { it.id == ORBOT_SERVICE_NOTIFY_ID_COPY } != null
        // Reset status, and then ask to refresh it synchronously.
        currentStatus = Status.OFF
        LocalBroadcastManager.getInstance(context)
            .sendBroadcastSync(Intent(TorServiceConstants.ACTION_CHECK_RUNNING_SYNC))
        return currentStatus != Status.OFF
    }

    private fun newLog(message: String) {