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

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

wip trackers control with tunproxy

parent 7931ad65
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ dependencies {
    e30Implementation files('libs/lineage-sdk.jar')

    implementation project(':fakelocation')
    implementation project(':tunproxy')
    implementation 'foundation.e:privacymodule.trackerfilter:2.0.0-dev'
    implementation 'foundation.e:privacymodule.api:1.2.0-dev'
    implementation 'foundation.e:privacymodule.tor:1.0.0-dev'
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ class DependencyContainer(val app: Application) {
    }

    val trackersStateUseCase by lazy {
        TrackersStateUseCase(blockTrackersPrivacyModule, trackTrackersPrivacyModule, permissionsModule, localStateRepository, trackersRepository, appListsRepository, GlobalScope)
        TrackersStateUseCase(blockTrackersPrivacyModule, trackTrackersPrivacyModule, permissionsModule, localStateRepository, trackersRepository, appListsRepository, GlobalScope, context)
    }

    private val fakeLocationStateUseCase by lazy {
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.privacycentralapp.common

import foundation.e.privacycentralapp.BuildConfig

val isStandaloneFlavor = BuildConfig.FLAVOR == "standalone"
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -135,7 +135,8 @@ class IpScramblingStateUseCase(
                InternetPrivacyMode.REAL_IP, InternetPrivacyMode.REAL_IP_LOADING -> {
                    val intent = prepareAndroidVpn()
                    if (intent == null) {
                        ipScramblerModule.start(enableNotification = true,
                        ipScramblerModule.start(
                            enableNotification = true,
                            // TODO 20220728
                            enableDNSTracking = true)
                    }
+14 −1
Original line number Diff line number Diff line
@@ -17,14 +17,20 @@

package foundation.e.privacycentralapp.domain.usecases

import android.content.Context
import android.content.Intent
import foundation.e.privacycentralapp.data.repositories.AppListsRepository
import foundation.e.privacycentralapp.data.repositories.LocalStateRepository
import foundation.e.privacycentralapp.data.repositories.TrackersRepository
import foundation.e.privacymodules.permissions.PermissionsPrivacyModule
import foundation.e.privacymodules.permissions.data.ApplicationDescription
import foundation.e.privacymodules.trackers.DNSBlockerService
import foundation.e.privacymodules.trackers.IBlockTrackersPrivacyModule
import foundation.e.privacymodules.trackers.ITrackTrackersPrivacyModule
import foundation.e.privacymodules.trackers.Tracker
import foundation.e.privacycentralapp.BuildConfig
import foundation.e.privacycentralapp.common.isStandaloneFlavor
import foundation.e.privacymodules.tunproxy.TunProxyVpnService
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
@@ -36,15 +42,22 @@ class TrackersStateUseCase(
    private val localStateRepository: LocalStateRepository,
    private val trackersRepository: TrackersRepository,
    private val appListsRepository: AppListsRepository,
    private val coroutineScope: CoroutineScope
    private val coroutineScope: CoroutineScope,
    private val appContext: Context
) {
    init {
        trackersPrivacyModule.start(trackersRepository.trackers, enableNotification = false)
        coroutineScope.launch {
            localStateRepository.quickPrivacyEnabledFlow.collect { enabled ->
                if (enabled) {
                    if (isStandaloneFlavor && !localStateRepository.isIpScramblingEnabled) {
                        TunProxyVpnService.start(appContext)
                    }
                    blockTrackersPrivacyModule.enableBlocking()
                } else {
                    if (isStandaloneFlavor) {
                        TunProxyVpnService.stop(appContext)
                    }
                    blockTrackersPrivacyModule.disableBlocking()
                }
                updateAllTrackersBlockedState()
Loading