diff options
Diffstat (limited to 'ipscrambling')
-rw-r--r-- | ipscrambling/README.md | 4 | ||||
-rw-r--r-- | ipscrambling/build.gradle | 2 | ||||
m--------- | ipscrambling/orbotservice | 0 | ||||
-rw-r--r-- | ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt | 2 | ||||
-rw-r--r-- | ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotSupervisor.kt (renamed from ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotServiceSupervisor.kt) | 32 |
5 files changed, 22 insertions, 18 deletions
diff --git a/ipscrambling/README.md b/ipscrambling/README.md index be51828..104060a 100644 --- a/ipscrambling/README.md +++ b/ipscrambling/README.md @@ -8,8 +8,8 @@ Ipscrambling includes a git repo submodules of OrbotService, the module used by Be sure that you have all of the git submodules up-to-date: - git submodule update --init --recursive - +` git submodule update --init --recursive +` You can build the AAR modules : ./gradlew :ipscrambling:orbotservice:assembleRelease diff --git a/ipscrambling/build.gradle b/ipscrambling/build.gradle index 29fed4f..9ff3f8c 100644 --- a/ipscrambling/build.gradle +++ b/ipscrambling/build.gradle @@ -53,6 +53,6 @@ dependencies { libs.pcap4j, libs.timber ) - implementation libs.e.orbotservice + implementation libs.eos.orbotservice implementation project(':core') } diff --git a/ipscrambling/orbotservice b/ipscrambling/orbotservice new file mode 160000 +Subproject 16c61e2f6fcb78c664aa23b9fed24048b52d943 diff --git a/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt index 79aeb05..d9ef0be 100644 --- a/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt +++ b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/KoinModule.kt @@ -21,5 +21,5 @@ import org.koin.core.module.dsl.singleOf import org.koin.dsl.module val ipScramblerModule = module { - singleOf(::OrbotServiceSupervisor) + singleOf(::OrbotSupervisor) } diff --git a/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotServiceSupervisor.kt b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotSupervisor.kt index 8813948..6e0e205 100644 --- a/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotServiceSupervisor.kt +++ b/ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotSupervisor.kt @@ -29,7 +29,8 @@ import android.os.Handler import android.os.Looper import android.os.Message import androidx.localbroadcastmanager.content.LocalBroadcastManager -import foundation.e.advancedprivacy.domain.entities.FeatureServiceState +import foundation.e.advancedprivacy.domain.entities.FeatureState +import foundation.e.advancedprivacy.externalinterfaces.servicesupervisors.FeatureSupervisor import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay @@ -48,12 +49,12 @@ import java.security.InvalidParameterException import java.util.function.Function @SuppressLint("CommitPrefEdits") -class OrbotServiceSupervisor( +class OrbotSupervisor( private val context: Context, private val coroutineScope: CoroutineScope, -) { - private val _state = MutableStateFlow(FeatureServiceState.OFF) - val state: StateFlow<FeatureServiceState> = _state +) : FeatureSupervisor { + private val _state = MutableStateFlow(FeatureState.OFF) + override val state: StateFlow<FeatureState> = _state enum class Status { OFF, ON, STARTING, STOPPING, START_DISABLED @@ -150,17 +151,17 @@ class OrbotServiceSupervisor( private fun updateStatus(status: Status, force: Boolean = false) { if (force || status != currentStatus) { val newState = when (status) { - Status.OFF -> FeatureServiceState.OFF - Status.ON -> FeatureServiceState.ON - Status.STARTING -> FeatureServiceState.STARTING + Status.OFF -> FeatureState.OFF + Status.ON -> FeatureState.ON + Status.STARTING -> FeatureState.STARTING Status.STOPPING, - Status.START_DISABLED -> FeatureServiceState.STOPPING + Status.START_DISABLED -> FeatureState.STOPPING } coroutineScope.launch(Dispatchers.IO) { _state.update { currentState -> - if (newState == FeatureServiceState.OFF && - currentState == FeatureServiceState.STOPPING + if (newState == FeatureState.OFF && + currentState == FeatureState.STOPPING ) { // Wait for orbot to relax before allowing user to reactivate it. delay(1000) @@ -244,17 +245,19 @@ class OrbotServiceSupervisor( OrbotService.shouldBlock = shouldBlock } - fun start(enableNotification: Boolean) { + override fun start(): Boolean { + val enableNotification = OrbotService.shouldBlock != null Prefs.enableNotification(enableNotification) Prefs.putUseVpn(true) Prefs.putStartOnBoot(true) sendIntentToService(OrbotConstants.ACTION_START) sendIntentToService(OrbotConstants.ACTION_START_VPN) + return true } - fun stop() { - if (!isServiceRunning()) return + override fun stop(): Boolean { + if (!isServiceRunning()) return false updateStatus(Status.STOPPING) @@ -267,6 +270,7 @@ class OrbotServiceSupervisor( extra = Bundle().apply { putBoolean(ACTION_STOP_FOREGROUND_TASK, true) } ) stoppingWatchdog(5) + return true } private fun stoppingWatchdog(countDown: Int) { |