release: v0.1.5 — test VPN, journal 15 j + verdicts par application, page À propos refondue, Makefile Féalu
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6086e8aeff
commit
790397da0e
15 files changed
+564
-107
No files matched your search
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## v0.1.5 – 2026-09-20
|
||||
|
||||
- Onglet Journal : bouton **Tester le VPN** (10 s) qui monte le tunnel quel que soit le réseau, pour savoir si le VPN peut se monter sur l'appareil ; les erreurs de démarrage du service VPN sont désormais tracées au lieu d'être silencieuses.
|
||||
- Journal : conservé **15 jours** (plafond de 20 000 lignes) ; l'état de l'en-tête (VPN autorisé, tunnel monté, suivi des applications) est aussi écrit dans le journal à chaque changement.
|
||||
- Journal : chaque application utilisée est tracée avec son verdict **réseau** (autorisé / bloqué / libre) et **lancement** (autorisé / bloqué). Nécessite le service d'accessibilité de DataControl.
|
||||
- Page « À propos » refondue : en-tête et sous-onglets (Fonctionnalités, Mode d'emploi, Prérequis, Sécurité, Garanties, Choix techniques, Journal, Auteur) ; le journal des versions est lu depuis le CHANGELOG embarqué.
|
||||
|
||||
## v0.1.4 – 2026-09-20
|
||||
|
||||
- Nouvel onglet **Journal** : état du VPN en direct (autorisé / tunnel monté) et historique horodaté des décisions du pare-feu (réseau détecté, mode appliqué, échec d'établissement du tunnel…), avec Copier / Partager / Effacer.
|
||||
|
||||
@@ -15,38 +15,54 @@ GITEA_REPO_NAME := DataControl
|
||||
GITEA_TOKEN ?= $(shell sed -n 's/^giteaToken=//p' gitea-token.properties 2>/dev/null | tr -d '[:space:]')
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
.PHONY: help build release install push version-bump changelog clean tag _check-token _check-apk publish deploy
|
||||
|
||||
## help: Show this help message
|
||||
help:
|
||||
@echo "DataControl v$(VERSION_NAME) (build $(VERSION_CODE))"
|
||||
@echo ""
|
||||
@echo "Available targets:"
|
||||
@grep -E '^## [a-z]' Makefile | sed 's/## / make /' | column -t -s ':'
|
||||
BOLD := \033[1m
|
||||
DIM := \033[2m
|
||||
CYAN := \033[36m
|
||||
GREEN := \033[32m
|
||||
YELLOW := \033[33m
|
||||
RESET := \033[0m
|
||||
|
||||
help:
|
||||
@printf "\n"
|
||||
@printf " $(BOLD)$(CYAN)DataControl$(RESET) $(DIM)— pare-feu de données mobiles et contrôle parental Android $(RESET)$(DIM)(v$(VERSION_NAME), build $(VERSION_CODE))$(RESET)\n"
|
||||
@printf "\n"
|
||||
@printf " $(BOLD)🔨 Build & installation$(RESET)\n"
|
||||
@printf " $(GREEN)make build$(RESET) 🔨 Construire l'APK debug\n"
|
||||
@printf " $(GREEN)make release$(RESET) 📱 Construire l'APK release et le copier à la racine\n"
|
||||
@printf " $(GREEN)make install$(RESET) 📲 Installer l'APK debug sur l'appareil connecté\n"
|
||||
@printf "\n"
|
||||
@printf " $(BOLD)🚀 Versions & publication$(RESET)\n"
|
||||
@printf " $(GREEN)make version-bump$(RESET) 🔖 Incrémenter versionCode et le patch de versionName\n"
|
||||
@printf " $(GREEN)make changelog$(RESET) 📝 Ajouter au CHANGELOG les commits depuis le dernier tag\n"
|
||||
@printf " $(GREEN)make push$(RESET) 📤 Commit, tag et push de la version courante\n"
|
||||
@printf " $(GREEN)make tag$(RESET) 📌 Créer et pousser le tag git de la version courante\n"
|
||||
@printf " $(GREEN)make publish$(RESET) 🚀 Publier l'APK signé en Release Gitea (idempotent)\n"
|
||||
@printf " $(GREEN)make deploy$(RESET) 🚢 Construire l'APK release puis le publier\n"
|
||||
@printf "\n"
|
||||
@printf " $(BOLD)🧹 Nettoyage$(RESET)\n"
|
||||
@printf " $(GREEN)make clean$(RESET) 🧽 Supprimer les artefacts de build et les APK racine\n"
|
||||
@printf "\n"
|
||||
|
||||
## build: Build debug APK
|
||||
build:
|
||||
@echo "[BUILD] Building debug APK..."
|
||||
@printf "$(YELLOW)🔨 Construction de l'APK debug...$(RESET)\n"
|
||||
$(GRADLEW) assembleDebug
|
||||
@echo "[BUILD] Done: $(APK_DEBUG)"
|
||||
|
||||
## release: Build release APK and copy to project root
|
||||
release:
|
||||
@echo "[RELEASE] Building release APK for v$(VERSION_NAME) ($(VERSION_CODE))..."
|
||||
@printf "$(YELLOW)📱 Construction de l'APK release v$(VERSION_NAME) (build $(VERSION_CODE))...$(RESET)\n"
|
||||
$(GRADLEW) assembleRelease
|
||||
@cp $(APK_RELEASE) $(OUTPUT_APK)
|
||||
@echo "[RELEASE] Done: $(OUTPUT_APK)"
|
||||
|
||||
## install: Install debug APK on connected device
|
||||
install:
|
||||
@echo "[INSTALL] Installing debug APK..."
|
||||
@printf "$(YELLOW)📲 Installation de l'APK debug...$(RESET)\n"
|
||||
$(GRADLEW) installDebug
|
||||
@echo "[INSTALL] Done."
|
||||
|
||||
## push: Git add, commit, tag and push (uses current version)
|
||||
push:
|
||||
@echo "[PUSH] Committing and pushing v$(VERSION_NAME)..."
|
||||
@printf "$(YELLOW)📤 Commit et push de v$(VERSION_NAME)...$(RESET)\n"
|
||||
git add -A
|
||||
git commit -m "Release v$(VERSION_NAME) (build $(VERSION_CODE))"
|
||||
git tag -a "v$(VERSION_NAME)" -m "Release v$(VERSION_NAME)"
|
||||
@@ -54,8 +70,8 @@ push:
|
||||
git push origin "v$(VERSION_NAME)"
|
||||
@echo "[PUSH] Done."
|
||||
|
||||
## tag: Create and push the git tag for the current version
|
||||
tag:
|
||||
@printf "$(YELLOW)📌 Tag git v$(VERSION_NAME)...$(RESET)\n"
|
||||
@if git rev-parse "v$(VERSION_NAME)" >/dev/null 2>&1; then \
|
||||
echo "Tag v$(VERSION_NAME) already exists, skipping"; \
|
||||
else \
|
||||
@@ -76,9 +92,8 @@ _check-apk:
|
||||
@test $(OUTPUT_APK) -nt version.properties || \
|
||||
(echo "$(OUTPUT_APK) is older than version.properties — rerun 'make release'." && exit 1)
|
||||
|
||||
## publish: Publish the signed APK as a Gitea Release (tag + assets, idempotent)
|
||||
publish: _check-apk _check-token tag
|
||||
@echo "Publishing Gitea release v$(VERSION_NAME)…"
|
||||
@printf "$(YELLOW)🚀 Publication de la release Gitea v$(VERSION_NAME)...$(RESET)\n"
|
||||
@EXISTING=$$(curl -s -H "Authorization: token $(GITEA_TOKEN)" \
|
||||
"$(GITEA_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/tags/v$(VERSION_NAME)"); \
|
||||
REL_ID=$$(printf '%s\n' "$$EXISTING" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['id'] if isinstance(d, dict) and 'id' in d else '')" 2>/dev/null); \
|
||||
@@ -113,11 +128,11 @@ publish: _check-apk _check-token tag
|
||||
echo ""; \
|
||||
echo "$(GITEA_URL)/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/tag/v$(VERSION_NAME)"
|
||||
|
||||
## deploy: Build the signed APK then publish (commit source changes first!)
|
||||
deploy: release publish
|
||||
@printf "$(GREEN)🚢 Déploiement terminé.$(RESET)\n"
|
||||
|
||||
## version-bump: Increment versionCode and update versionName patch
|
||||
version-bump:
|
||||
@printf "$(YELLOW)🔖 Incrémentation de la version...$(RESET)\n"
|
||||
@NEW_CODE=$$(( $(VERSION_CODE) + 1 )); \
|
||||
PATCH=$$(echo $(VERSION_NAME) | cut -d. -f3); \
|
||||
MAJOR=$$(echo $(VERSION_NAME) | cut -d. -f1); \
|
||||
@@ -128,9 +143,8 @@ version-bump:
|
||||
sed -i "s/versionCode=.*/versionCode=$${NEW_CODE}/" version.properties; \
|
||||
echo "[VERSION-BUMP] Bumped to $${NEW_VERSION} (build $${NEW_CODE})"
|
||||
|
||||
## changelog: Generate a changelog entry from git log since last tag
|
||||
changelog:
|
||||
@echo "[CHANGELOG] Generating entries since last tag..."
|
||||
@printf "$(YELLOW)📝 Génération du CHANGELOG depuis le dernier tag...$(RESET)\n"
|
||||
@LAST_TAG=$$(git describe --tags --abbrev=0 2>/dev/null || echo ""); \
|
||||
if [ -z "$$LAST_TAG" ]; then \
|
||||
git log --oneline --pretty=format:"- %s" >> CHANGELOG.md; \
|
||||
@@ -141,9 +155,8 @@ changelog:
|
||||
fi; \
|
||||
echo "[CHANGELOG] Done."
|
||||
|
||||
## clean: Clean build artifacts
|
||||
clean:
|
||||
@echo "[CLEAN] Cleaning build artifacts..."
|
||||
@printf "$(YELLOW)🧽 Nettoyage des artefacts de build...$(RESET)\n"
|
||||
$(GRADLEW) clean
|
||||
@rm -f DataControl-*.apk
|
||||
@echo "[CLEAN] Done."
|
||||
@@ -78,6 +78,18 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// CHANGELOG.md est embarqué dans l'APK (assets) : l'onglet Journal de « À propos » le lit à l'exécution.
|
||||
val copyChangelog = tasks.register<Copy>("copyChangelog") {
|
||||
from(rootProject.file("CHANGELOG.md"))
|
||||
into(layout.buildDirectory.dir("generated/changelogAssets"))
|
||||
}
|
||||
android.sourceSets.getByName("main").assets.srcDir(layout.buildDirectory.dir("generated/changelogAssets"))
|
||||
tasks.configureEach {
|
||||
if (name.startsWith("merge") && name.endsWith("Assets") || name.contains("lint", ignoreCase = true)) {
|
||||
dependsOn(copyChangelog)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
|
||||
@@ -12,6 +12,9 @@ import android.provider.Settings
|
||||
import android.telecom.TelecomManager
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import com.jttools.datacontrol.log.AppLog
|
||||
import com.jttools.datacontrol.service.MonitorStateHolder
|
||||
import com.jttools.datacontrol.service.NetworkTransport
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -31,12 +34,14 @@ import javax.inject.Inject
|
||||
class AppGuardService : AccessibilityService() {
|
||||
|
||||
@Inject lateinit var engine: GuardEngine
|
||||
@Inject lateinit var stateHolder: MonitorStateHolder
|
||||
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
private var exempt: Set<String> = emptySet()
|
||||
private var exemptComputedAt = 0L
|
||||
private var currentPkg: String? = null
|
||||
private var lastBlockAt = 0L
|
||||
private var lastLoggedPkg: String? = null
|
||||
|
||||
private val screenReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
@@ -67,25 +72,64 @@ class AppGuardService : AccessibilityService() {
|
||||
val pkg = event.packageName?.toString() ?: return
|
||||
if (pkg in exemptPackages()) {
|
||||
currentPkg = null
|
||||
lastLoggedPkg = null // revenir ensuite dans la même application compte comme une nouvelle utilisation
|
||||
engine.onForeground(null)
|
||||
return
|
||||
}
|
||||
currentPkg = pkg
|
||||
engine.onForeground(pkg)
|
||||
enforce(pkg)
|
||||
val block = engine.check(pkg)
|
||||
if (pkg != lastLoggedPkg) {
|
||||
lastLoggedPkg = pkg
|
||||
logUsage(pkg, block)
|
||||
}
|
||||
if (block != null) enforce(pkg, block)
|
||||
}
|
||||
|
||||
private fun enforce(pkg: String) {
|
||||
val block = engine.check(pkg) ?: return
|
||||
engine.check(pkg)?.let { enforce(pkg, it) }
|
||||
}
|
||||
|
||||
private fun enforce(pkg: String, block: Block) {
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastBlockAt < 2_000) return
|
||||
lastBlockAt = now
|
||||
AppLog.w("Appli", "Lancement BLOQUÉ : ${labelOf(pkg)} ($pkg) — ${block.message}")
|
||||
performGlobalAction(GLOBAL_ACTION_HOME)
|
||||
val label = runCatching {
|
||||
startActivity(BlockedActivity.intent(this, labelOf(pkg), block.message))
|
||||
}
|
||||
|
||||
/** Une ligne de journal par utilisation : réseau et lancement, autorisés ou bloqués. */
|
||||
private fun logUsage(pkg: String, block: Block?) {
|
||||
val (net, netBlocked) = networkVerdict(pkg)
|
||||
val launch = if (block == null) "lancement autorisé" else "lancement BLOQUÉ (${block.message.trimEnd('.')})"
|
||||
val line = "${labelOf(pkg)} ($pkg) — réseau $net · $launch"
|
||||
if (netBlocked || block != null) AppLog.w("Appli", line) else AppLog.i("Appli", line)
|
||||
}
|
||||
|
||||
/** Verdict réseau d'une application d'après l'état réel du pare-feu (mode appliqué + liste blanche). */
|
||||
private fun networkVerdict(pkg: String): Pair<String, Boolean> {
|
||||
val snap = stateHolder.snapshot.value
|
||||
val net = when (snap.transport) {
|
||||
NetworkTransport.CELLULAR -> "4G/5G"
|
||||
NetworkTransport.WIFI -> "Wi-Fi"
|
||||
NetworkTransport.OTHER -> "autre réseau"
|
||||
NetworkTransport.NONE -> "aucun réseau"
|
||||
}
|
||||
if (pkg == packageName) return "AUTORISÉ (DataControl, toujours exempté) [$net]" to false
|
||||
if (!snap.serviceRunning) return "libre (contrôle désactivé) [$net]" to false
|
||||
return when (snap.appliedMode) {
|
||||
"BLOCK_ALL" -> "BLOQUÉ (coupure totale en cours) [$net]" to true
|
||||
"FILTER" ->
|
||||
if (pkg in snap.effectiveWhitelist) "AUTORISÉ (liste blanche) [$net]" to false
|
||||
else "BLOQUÉ (hors liste blanche) [$net]" to true
|
||||
else -> "libre (aucun filtrage sur ce réseau) [$net]" to false
|
||||
}
|
||||
}
|
||||
|
||||
private fun labelOf(pkg: String): String = runCatching {
|
||||
packageManager.getApplicationLabel(packageManager.getApplicationInfo(pkg, 0)).toString()
|
||||
}.getOrDefault(pkg)
|
||||
startActivity(BlockedActivity.intent(this, label, block.message))
|
||||
}
|
||||
|
||||
/** Applications jamais bloquées ni comptées : sans elles l'appareil deviendrait inutilisable. */
|
||||
private fun exemptPackages(): Set<String> {
|
||||
|
||||
@@ -12,30 +12,49 @@ import java.util.Locale
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* Journal de diagnostic : garde les [MAX_LINES] dernières lignes en mémoire et dans un fichier
|
||||
* (survit au redémarrage de l'app), consultable dans l'onglet « Journal ».
|
||||
* Journal de diagnostic : conservé [RETENTION_DAYS] jours (avec un plafond de [MAX_LINES] lignes),
|
||||
* en mémoire et dans un fichier qui survit au redémarrage de l'app. Consultable dans l'onglet « Journal ».
|
||||
*
|
||||
* Format du fichier : une ligne par entrée, `horodatage-ms<TAB>texte affiché`. Le fichier est complété
|
||||
* au fil de l'eau puis réécrit (purgé) de temps en temps, pour ne pas le réécrire à chaque ligne.
|
||||
*/
|
||||
object AppLog {
|
||||
private const val MAX_LINES = 400
|
||||
const val RETENTION_DAYS = 15
|
||||
private const val RETENTION_MS = RETENTION_DAYS * 24L * 3600 * 1000
|
||||
private const val MAX_LINES = 20_000
|
||||
private const val COMPACT_EVERY_PRUNED = 200
|
||||
private const val COMPACT_MIN_INTERVAL_MS = 3600_000L
|
||||
private const val FILE_NAME = "journal.txt"
|
||||
|
||||
private class Entry(val ts: Long, val text: String)
|
||||
|
||||
private val io = Executors.newSingleThreadExecutor()
|
||||
private val fmt = SimpleDateFormat("MM-dd HH:mm:ss", Locale.FRANCE)
|
||||
private val lines = ArrayDeque<String>()
|
||||
private val lines = ArrayDeque<Entry>()
|
||||
private val _entries = MutableStateFlow<List<String>>(emptyList())
|
||||
val entries: StateFlow<List<String>> = _entries.asStateFlow()
|
||||
|
||||
@Volatile private var file: File? = null
|
||||
private var prunedSinceCompact = 0
|
||||
private var lastCompactAt = 0L
|
||||
|
||||
fun init(context: Context) {
|
||||
if (file != null) return
|
||||
val f = File(context.filesDir, FILE_NAME)
|
||||
file = f
|
||||
synchronized(lines) {
|
||||
runCatching { if (f.exists()) lines.addAll(f.readLines().takeLast(MAX_LINES)) }
|
||||
_entries.value = lines.toList()
|
||||
runCatching {
|
||||
if (f.exists()) f.readLines().forEach { raw ->
|
||||
val tab = raw.indexOf('\t')
|
||||
val ts = if (tab > 0) raw.substring(0, tab).toLongOrNull() else null
|
||||
if (ts != null) lines.addLast(Entry(ts, raw.substring(tab + 1)))
|
||||
}
|
||||
i("App", "Journal ouvert")
|
||||
}
|
||||
prune(System.currentTimeMillis())
|
||||
publish()
|
||||
compactLocked()
|
||||
}
|
||||
i("App", "Journal ouvert (conservation : $RETENTION_DAYS jours)")
|
||||
}
|
||||
|
||||
fun i(tag: String, message: String) = add("I", tag, message)
|
||||
@@ -45,23 +64,51 @@ object AppLog {
|
||||
|
||||
private fun add(level: String, tag: String, message: String) {
|
||||
Log.println(when (level) { "E" -> Log.ERROR; "W" -> Log.WARN; else -> Log.INFO }, "DataControl/$tag", message)
|
||||
val line = "${fmt.format(Date())} $level $tag: $message"
|
||||
val now = System.currentTimeMillis()
|
||||
val entry = Entry(now, "${fmt.format(Date(now))} $level $tag: $message")
|
||||
synchronized(lines) {
|
||||
lines.addLast(line)
|
||||
while (lines.size > MAX_LINES) lines.removeFirst()
|
||||
_entries.value = lines.toList()
|
||||
lines.addLast(entry)
|
||||
prune(now)
|
||||
publish()
|
||||
if (prunedSinceCompact >= COMPACT_EVERY_PRUNED && now - lastCompactAt > COMPACT_MIN_INTERVAL_MS) {
|
||||
compactLocked()
|
||||
} else {
|
||||
io.execute { runCatching { file?.appendText("${entry.ts}\t${entry.text}\n") } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Retire les entrées plus vieilles que la rétention et au-delà du plafond. À appeler sous verrou. */
|
||||
private fun prune(now: Long) {
|
||||
while (lines.isNotEmpty() && (now - lines.first().ts > RETENTION_MS || lines.size > MAX_LINES)) {
|
||||
lines.removeFirst()
|
||||
prunedSinceCompact++
|
||||
}
|
||||
}
|
||||
|
||||
private fun publish() {
|
||||
_entries.value = lines.map { it.text }
|
||||
}
|
||||
|
||||
/** Réécrit le fichier avec les seules entrées conservées. À appeler sous verrou. */
|
||||
private fun compactLocked() {
|
||||
prunedSinceCompact = 0
|
||||
lastCompactAt = System.currentTimeMillis()
|
||||
val snapshot = lines.toList()
|
||||
io.execute { runCatching { file?.writeText(snapshot.joinToString("\n")) } }
|
||||
io.execute {
|
||||
runCatching { file?.writeText(snapshot.joinToString("") { "${it.ts}\t${it.text}\n" }) }
|
||||
}
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
synchronized(lines) {
|
||||
lines.clear()
|
||||
_entries.value = emptyList()
|
||||
io.execute { runCatching { file?.writeText("") } }
|
||||
publish()
|
||||
compactLocked()
|
||||
}
|
||||
}
|
||||
|
||||
fun asText(): String = synchronized(lines) { lines.joinToString("\n") }
|
||||
/** Texte à copier/partager : les [maxLines] dernières lignes (le presse-papiers et le partage ont une taille limite). */
|
||||
fun asText(maxLines: Int = 3000): String =
|
||||
synchronized(lines) { lines.takeLast(maxLines).joinToString("\n") { it.text } }
|
||||
}
|
||||
@@ -270,7 +270,10 @@ class DataMonitorService : LifecycleService() {
|
||||
if (!prepared) "données mobiles mais autorisation VPN absente" else if (vpnRevoked) "données mobiles mais VPN révoqué" else "données mobiles : pare-feu attendu"
|
||||
else -> "aucun réseau actif (${latestTransport})"
|
||||
}
|
||||
val diag = "réseau=$latestTransport contrôle=${settings.controlEnabled} vpnAutorisé=$prepared révoqué=$vpnRevoked mode=${lastAppliedMode ?: "—"} → $expected"
|
||||
val guard = com.jttools.datacontrol.guard.AppGuardService.isEnabled(this)
|
||||
val diag = "réseau=$latestTransport contrôle=${settings.controlEnabled} vpnAutorisé=$prepared " +
|
||||
"tunnelMonté=${FirewallVpnService.tunnelActive} accessibilité=$guard révoqué=$vpnRevoked " +
|
||||
"mode=${lastAppliedMode ?: "—"} → $expected"
|
||||
if (diag != lastDiagnostic) {
|
||||
lastDiagnostic = diag
|
||||
AppLog.i("Pare-feu", diag)
|
||||
@@ -309,6 +312,10 @@ class DataMonitorService : LifecycleService() {
|
||||
lastAppliedWhitelist = whitelist
|
||||
lastApplyMillis = System.currentTimeMillis()
|
||||
AppLog.i("Pare-feu", "→ mode $mode (${whitelist.size} app(s) autorisée(s))")
|
||||
stateHolder.update { it.copy(appliedMode = mode.name, effectiveWhitelist = whitelist) }
|
||||
// Une exception ici (démarrage de service de premier plan refusé, par ex.) ne doit ni faire
|
||||
// planter l'application ni rester invisible : elle est tracée dans le journal.
|
||||
try {
|
||||
when (mode) {
|
||||
VpnMode.STOPPED -> ContextCompat.startForegroundService(this, FirewallVpnService.stopIntent(this))
|
||||
VpnMode.FILTER -> ContextCompat.startForegroundService(
|
||||
@@ -318,6 +325,9 @@ class DataMonitorService : LifecycleService() {
|
||||
this, FirewallVpnService.startBlockAllIntent(this)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
AppLog.e("Pare-feu", "Impossible de démarrer FirewallVpnService pour le mode $mode", e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildNotification(snapshot: MonitorSnapshot): Notification {
|
||||
|
||||
@@ -38,7 +38,11 @@ class FirewallVpnService : VpnService() {
|
||||
// cf. DataMonitorService.applyVpnMode) : le système impose un appel à startForeground()
|
||||
// dans les 5 secondes qui suivent, sous peine de crash (ForegroundServiceDidNotStartInTimeException
|
||||
// sur Android 12+), même si le service s'arrête immédiatement après.
|
||||
try {
|
||||
startForeground(NOTIF_ID, buildNotification())
|
||||
} catch (e: Exception) {
|
||||
AppLog.e(TAG, "startForeground() refusé", e)
|
||||
}
|
||||
AppLog.i(TAG, "onStartCommand action=${intent?.action?.substringAfterLast('.') ?: "null (relance système)"}")
|
||||
when (intent?.action) {
|
||||
ACTION_STOP -> {
|
||||
|
||||
@@ -18,7 +18,10 @@ data class MonitorSnapshot(
|
||||
val serviceRunning: Boolean = false,
|
||||
/** Contrôle activé sur données mobiles mais tunnel VPN non monté : les données ne sont PAS filtrées. */
|
||||
val firewallFault: Boolean = false,
|
||||
val transport: NetworkTransport = NetworkTransport.NONE
|
||||
val transport: NetworkTransport = NetworkTransport.NONE,
|
||||
/** Mode réellement appliqué au pare-feu : FILTER, BLOCK_ALL ou STOPPED. */
|
||||
val appliedMode: String = "STOPPED",
|
||||
val effectiveWhitelist: Set<String> = emptySet()
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.jttools.datacontrol.ui.about
|
||||
|
||||
/**
|
||||
* Contenu des sous-onglets de « À propos ». Chaque affirmation a été relevée dans le code, le README
|
||||
* ou le CHANGELOG du dépôt (voir le compte rendu de la refonte) : ne rien ajouter ici qui ne s'y vérifie pas.
|
||||
* Le journal, lui, n'est pas dans ce fichier : il est lu depuis CHANGELOG.md (cf. ChangelogParser).
|
||||
*/
|
||||
data class AboutEntry(val title: String, val body: String)
|
||||
data class AboutSection(val heading: String?, val entries: List<AboutEntry>)
|
||||
|
||||
object AboutContent {
|
||||
|
||||
val features = listOf(
|
||||
AboutSection("Données mobiles", listOf(
|
||||
AboutEntry("Suivi de la consommation", "Mesure les Mo consommés depuis le début du cycle, sans permission spéciale (compteur système TrafficStats)."),
|
||||
AboutEntry("Forfait et coût estimé", "Volume, prix, prix par Mo hors-forfait et date de début se règlent ; le total estimé se met à jour en direct, notification comprise."),
|
||||
AboutEntry("Réinitialisation", "Automatique chaque mois à la date anniversaire, ou manuelle depuis le tableau de bord. La consommation peut aussi être recalée à la main sur le décompte de l'opérateur."),
|
||||
AboutEntry("Liste blanche", "Sur données mobiles, seules les applications cochées ont accès à Internet."),
|
||||
AboutEntry("Filtrage Wi-Fi optionnel", "Le Wi-Fi n'est jamais filtré par défaut ; une liste blanche Wi-Fi distincte peut être activée."),
|
||||
AboutEntry("Coupure cyclique", "Toutes les X minutes (réglable), une coupure totale de 30 secondes s'applique aux données mobiles, liste blanche comprise."),
|
||||
AboutEntry("Notification permanente", "Consommation, état en couleur et total estimé. Une alerte « PARE-FEU INACTIF » s'affiche si les données mobiles ne sont plus filtrées."),
|
||||
AboutEntry("Reprise automatique", "Le suivi redémarre après un redémarrage de l'appareil et est relancé périodiquement si le système l'a arrêté.")
|
||||
)),
|
||||
AboutSection("Protection", listOf(
|
||||
AboutEntry("Mot de passe de verrouillage", "Protège l'accès aux Réglages et la désactivation du contrôle."),
|
||||
AboutEntry("Anti-désinstallation", "DataControl peut devenir administrateur de l'appareil : Android refuse alors de le désinstaller tant que la protection est active."),
|
||||
AboutEntry("Journal de diagnostic", "L'onglet Journal montre l'état du VPN, les décisions du pare-feu et, si le service d'accessibilité est activé, chaque application utilisée avec son verdict réseau et lancement. Conservé 15 jours, avec copie et partage."),
|
||||
AboutEntry("Mise à jour intégrée", "Recherche et installation de la dernière version publiée, depuis l'onglet Journal de cette page.")
|
||||
)),
|
||||
AboutSection("Contrôle parental (avec FamilyControl)", listOf(
|
||||
AboutEntry("Appairage par code", "L'appareil s'associe à l'application parent FamilyControl avec un code d'appairage."),
|
||||
AboutEntry("Suivi à distance", "Batterie, position (arrière-plan compris si autorisé), état du pare-feu, trafic quotidien mobile/Wi-Fi et journal d'événements."),
|
||||
AboutEntry("Accès réseau par application", "Le parent autorise ou bloque Internet application par application, sur données mobiles comme sur Wi-Fi."),
|
||||
AboutEntry("Plages horaires, temps d'écran, applications interdites", "Appliqués par un service d'accessibilité : verrouillage hors plage, limite quotidienne globale ou par application, ajout de temps, lancement refusé."),
|
||||
AboutEntry("Condition", "Ces fonctions n'existent que si l'application a été compilée avec une configuration Firebase et associée à un compte parent.")
|
||||
))
|
||||
)
|
||||
|
||||
val howTo = listOf(
|
||||
"Ouvrez « Réglages » et renseignez le forfait : volume (Mo), prix, prix par Mo hors-forfait, intervalle de coupure. Touchez « Enregistrer ».",
|
||||
"Ouvrez « Liste blanche » et cochez les applications qui doivent garder Internet en données mobiles.",
|
||||
"Dans « Réglages » → « Autorisations », accordez « Pare-feu local (VPN) », « Notifications » et « Optimisation de la batterie ».",
|
||||
"Sur le « Tableau de bord », activez « Activer le contrôle » et acceptez la demande VPN d'Android.",
|
||||
"Coupez le Wi-Fi : l'icône clé du VPN apparaît en données mobiles et la notification affiche l'état.",
|
||||
"Recommandé : définissez un mot de passe dans « Réglages » → « Sécurité »."
|
||||
)
|
||||
|
||||
val everyday = listOf(
|
||||
AboutEntry("Consulter la consommation", "Le Tableau de bord affiche les Mo consommés, le restant, le dépassement et le total estimé."),
|
||||
AboutEntry("Repartir à zéro", "« Réinitialiser le forfait maintenant » sur le Tableau de bord, ou « Consommation actuelle » dans les Réglages pour recaler sur l'opérateur."),
|
||||
AboutEntry("Changer une application autorisée", "Onglet « Liste blanche » : onglets « Données mobiles » et « Wi-Fi », recherche et sélection multiple.")
|
||||
)
|
||||
|
||||
val troubleshooting = listOf(
|
||||
AboutEntry("Je ne vois pas l'icône VPN", "Le pare-feu ne se monte que sur données mobiles, contrôle activé. Sur Wi-Fi, il n'y en a jamais (sauf filtrage Wi-Fi activé). Consultez l'onglet Journal : il donne la raison exacte."),
|
||||
AboutEntry("« PARE-FEU INACTIF » dans la notification", "Les données mobiles ne sont pas filtrées : autorisation VPN retirée ou tunnel non monté. Réactivez le contrôle et lisez le Journal."),
|
||||
AboutEntry("Le contrôle s'est désactivé tout seul", "Un seul VPN peut être actif sous Android : si un autre VPN prend la main, DataControl est révoqué et se désactive."),
|
||||
AboutEntry("Le service d'accessibilité est grisé (Android 13+)", "Ouvrez Infos sur l'application → ⋮ → « Autoriser les paramètres restreints », puis réessayez.")
|
||||
)
|
||||
|
||||
val prerequisites = listOf(
|
||||
AboutSection("Système", listOf(
|
||||
AboutEntry("Android 8.0 ou plus", "Version minimale déclarée par l'application (API 26) ; cible : Android 14 (API 34)."),
|
||||
AboutEntry("Ni root, ni Shizuku", "Le filtrage repose sur le VPN local d'Android."),
|
||||
AboutEntry("Un seul VPN à la fois", "Le pare-feu est incompatible avec un autre VPN actif en même temps.")
|
||||
)),
|
||||
AboutSection("Autorisations", listOf(
|
||||
AboutEntry("VPN (obligatoire)", "Consentement système demandé à l'activation du contrôle."),
|
||||
AboutEntry("Notifications (Android 13+)", "Pour l'état permanent."),
|
||||
AboutEntry("Optimisation de la batterie (recommandé)", "Évite que le système n'arrête la surveillance."),
|
||||
AboutEntry("Liste des applications", "Permission QUERY_ALL_PACKAGES, pour afficher toutes les applications dans la Liste blanche."),
|
||||
AboutEntry("Contrôle parental (facultatif)", "Position (avec « Toujours autoriser » pour l'arrière-plan), administrateur de l'appareil, service d'accessibilité.")
|
||||
)),
|
||||
AboutSection("Réseau", listOf(
|
||||
AboutEntry("Sortant, HTTPS (TCP 443)", "Recherche de mise à jour (git.tuxtech.fr) et, si l'appareil est associé, échanges avec Firebase. Aucun port entrant, aucune redirection de port.")
|
||||
))
|
||||
)
|
||||
|
||||
val security = listOf(
|
||||
AboutSection("Pare-feu", listOf(
|
||||
AboutEntry("Tunnel local sans transfert", "Le VPN ne route ni ne transmet aucun paquet : le trafic des applications non autorisées entre dans le tunnel et y est abandonné."),
|
||||
AboutEntry("IPv4 et IPv6", "Les deux familles d'adresses sont capturées, pour qu'une application bloquée ne contourne pas le pare-feu en IPv6."),
|
||||
AboutEntry("Reprise si le tunnel disparaît", "Si le service VPN est arrêté par le système, le tunnel est remonté automatiquement ; sinon la notification le signale."),
|
||||
AboutEntry("DataControl jamais bloqué", "L'application est toujours exclue du tunnel : la liaison avec le parent ne peut pas être coupée par le pare-feu.")
|
||||
)),
|
||||
AboutSection("Accès à l'application", listOf(
|
||||
AboutEntry("Mot de passe", "Haché en SHA-256 avec un sel aléatoire de 16 octets (SecureRandom), jamais stocké en clair. Limite : un hachage simple, sans étirement de type bcrypt ou Argon2."),
|
||||
AboutEntry("Anti-désinstallation", "Administrateur d'appareil. Limite : la protection peut être retirée depuis les Réglages Android ; si l'appareil est associé, le parent en est alerté. La demande de mot de passe ne s'applique qu'au retrait fait depuis DataControl.")
|
||||
)),
|
||||
AboutSection("Liaison FamilyControl", listOf(
|
||||
AboutEntry("Appairage", "Code aléatoire à durée limitée (10 minutes) créé côté parent. Connexion anonyme Firebase côté appareil, compte e-mail côté parent."),
|
||||
AboutEntry("Règles Firestore", "Fournies avec FamilyControl (firebase/firestore.rules) : l'appareil n'écrit que dans son propre espace et ne peut pas modifier les consignes du parent."),
|
||||
AboutEntry("Service d'accessibilité", "Détecte uniquement l'application au premier plan : la lecture du contenu des écrans est désactivée (canRetrieveWindowContent = false)."),
|
||||
AboutEntry("Applications exemptées", "Lanceur, téléphone, clavier et DataControl ne sont jamais bloqués, pour que l'appareil reste utilisable.")
|
||||
)),
|
||||
AboutSection("Limites connues", listOf(
|
||||
AboutEntry("Signature de l'APK", "Le build release est actuellement signé avec la clé de debug d'Android. Android n'accepte une mise à jour que si elle porte la même signature que l'application installée."),
|
||||
AboutEntry("Téléchargement des mises à jour", "L'APK est récupéré en HTTPS depuis la release Gitea ; aucune empreinte supplémentaire n'est vérifiée par l'application.")
|
||||
))
|
||||
)
|
||||
|
||||
val guarantees = listOf(
|
||||
AboutSection("Vos données", listOf(
|
||||
AboutEntry("Aucune télémétrie", "Le code ne contient ni analytique ni publicité. Les seuls accès réseau sont la recherche de mise à jour et, si l'appareil est associé, Firebase."),
|
||||
AboutEntry("Sans appairage, rien ne sort", "Non associé, l'appareil n'envoie rien ; la recherche de mise à jour ne part que lorsque vous touchez le bouton."),
|
||||
AboutEntry("Le mot de passe reste sur l'appareil", "Il n'est jamais transmis, pas même haché."),
|
||||
AboutEntry("Appareil associé : ce qui est envoyé", "Nom de l'appareil, batterie, position, état du pare-feu et du contrôle, listes d'applications autorisées, consommation du forfait, liste des applications installées, trafic quotidien mobile/Wi-Fi, temps d'écran par application, événements.")
|
||||
)),
|
||||
AboutSection("Ce qui n'est jamais lu", listOf(
|
||||
AboutEntry("Contenu des écrans et messages", "Le service d'accessibilité ne lit pas le contenu des fenêtres."),
|
||||
AboutEntry("Contenu du trafic", "Le VPN ne route rien et n'inspecte aucun paquet.")
|
||||
)),
|
||||
AboutSection("Privilèges et licence", listOf(
|
||||
AboutEntry("Rien d'activé à votre insu", "VPN, position, administrateur d'appareil et accessibilité passent chacun par une autorisation explicite d'Android."),
|
||||
AboutEntry("Licence", "Projet personnel — JT-Tools by Johnny. Le dépôt ne contient pas de fichier de licence : aucun droit de réutilisation n'est accordé par ce texte.")
|
||||
))
|
||||
)
|
||||
|
||||
val choices = listOf(
|
||||
AboutEntry("VpnService plutôt qu'une coupure des données", "Android interdit aux applications normales de couper les données mobiles depuis Android 5. Le VPN local fonctionne sans root ni Shizuku, sur le principe de NetGuard."),
|
||||
AboutEntry("Exclusion d'applications plutôt que relais de paquets", "Les applications autorisées sont exclues du tunnel (addDisallowedApplication) : leur trafic passe normalement, sans passer par l'application."),
|
||||
AboutEntry("TrafficStats plutôt que NetworkStatsManager", "Le compteur système cumulé ne demande aucune permission spéciale. Contrepartie : il repart de zéro au redémarrage, l'application recale alors sa référence."),
|
||||
AboutEntry("Service de premier plan + relance périodique", "Un service permanent et une tâche WorkManager toutes les 15 minutes, car certains systèmes arrêtent agressivement les applications en arrière-plan."),
|
||||
AboutEntry("Kotlin, Jetpack Compose (Material 3), Hilt, DataStore", "Interface déclarative et thème dynamique (Android 12+) ; réglages dans DataStore Preferences."),
|
||||
AboutEntry("HttpURLConnection plutôt qu'un client HTTP tiers", "Seule la mise à jour fait un appel HTTP : pas de dépendance réseau supplémentaire pour cela."),
|
||||
AboutEntry("Firebase sans plugin google-services", "Firestore et l'authentification sont initialisés depuis un fichier local non versionné (firebase.properties). Sans lui, l'application se compile normalement et le contrôle à distance est simplement désactivé."),
|
||||
AboutEntry("Service d'accessibilité plutôt que statistiques d'usage", "Permet de renvoyer à l'accueil et d'afficher un écran de blocage dès qu'une application interdite passe au premier plan."),
|
||||
AboutEntry("Administrateur d'appareil plutôt que Device Owner", "Pas de réinitialisation d'usine ni de branchement à un PC ; en contrepartie, la protection est moins robuste."),
|
||||
AboutEntry("Journal embarqué", "Le journal de diagnostic est conservé 15 jours (20 000 lignes au plus) dans un fichier local ; le changelog de cette page est le CHANGELOG.md du dépôt, embarqué dans l'APK.")
|
||||
)
|
||||
|
||||
const val REPO_URL = "https://git.tuxtech.fr/tuxgyver/DataControl"
|
||||
const val AI_NOTICE = "Application développée avec l'assistance de l'IA sous la direction et supervision de Johnny."
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.jttools.datacontrol.ui.about
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -16,11 +19,15 @@ import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ScrollableTabRow
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@@ -29,6 +36,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -37,6 +45,7 @@ import androidx.core.graphics.drawable.toBitmap
|
||||
import com.jttools.datacontrol.R
|
||||
import com.jttools.datacontrol.data.UpdateManager
|
||||
import kotlinx.coroutines.launch
|
||||
import java.time.LocalDate
|
||||
|
||||
@Composable
|
||||
fun AboutScreen() {
|
||||
@@ -62,43 +71,46 @@ fun AboutScreen() {
|
||||
var busy by remember { mutableStateOf(false) }
|
||||
var progress by remember { mutableIntStateOf(-1) }
|
||||
|
||||
val tabs = listOf(
|
||||
"Fonctionnalités", "Mode d'emploi", "Prérequis", "Sécurité",
|
||||
"Garanties", "Choix techniques", "Journal", "Auteur"
|
||||
)
|
||||
var tab by rememberSaveable { mutableIntStateOf(0) }
|
||||
val changelog = remember { ChangelogParser.load(context) }
|
||||
|
||||
Column(Modifier.fillMaxSize()) {
|
||||
// En-tête toujours visible, quel que soit le sous-onglet.
|
||||
AboutHeader(iconBitmap, versionName)
|
||||
|
||||
ScrollableTabRow(selectedTabIndex = tab, edgePadding = 12.dp) {
|
||||
tabs.forEachIndexed { i, label ->
|
||||
Tab(selected = tab == i, onClick = { tab = i }, text = { Text(label) })
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(1f)
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(20.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(14.dp)
|
||||
) {
|
||||
Text(stringResource(R.string.about_title), style = MaterialTheme.typography.headlineMedium)
|
||||
|
||||
Card(shape = RoundedCornerShape(20.dp), elevation = CardDefaults.cardElevation(2.dp)) {
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||
) {
|
||||
if (iconBitmap != null) {
|
||||
Image(
|
||||
bitmap = iconBitmap,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(72.dp)
|
||||
)
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.app_name),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.about_version, versionName),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
when (tab) {
|
||||
0 -> AboutContent.features.forEach { SectionCard(it) }
|
||||
1 -> {
|
||||
CardBox("Démarrer") {
|
||||
AboutContent.howTo.forEachIndexed { i, step ->
|
||||
Text("${i + 1}. $step", style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
|
||||
CardBox("Au quotidien") { AboutContent.everyday.forEach { EntryRow(it) } }
|
||||
CardBox("Si ça ne marche pas") { AboutContent.troubleshooting.forEach { EntryRow(it) } }
|
||||
}
|
||||
2 -> AboutContent.prerequisites.forEach { SectionCard(it) }
|
||||
3 -> AboutContent.security.forEach { SectionCard(it) }
|
||||
4 -> AboutContent.guarantees.forEach { SectionCard(it) }
|
||||
5 -> CardBox(null) { AboutContent.choices.forEach { EntryRow(it) } }
|
||||
6 -> {
|
||||
Card(shape = RoundedCornerShape(20.dp), elevation = CardDefaults.cardElevation(2.dp)) {
|
||||
Column(Modifier.padding(20.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text(stringResource(R.string.update_section), style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||
@@ -158,36 +170,119 @@ fun AboutScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
Card(shape = RoundedCornerShape(20.dp), elevation = CardDefaults.cardElevation(2.dp)) {
|
||||
Column(Modifier.padding(20.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text(stringResource(R.string.about_section_description), style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||
HorizontalDivider()
|
||||
Text(stringResource(R.string.about_description), style = MaterialTheme.typography.bodyMedium)
|
||||
if (changelog.isEmpty()) {
|
||||
Text("Le journal des versions (CHANGELOG.md) est introuvable dans cette version de l'application.", style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
changelog.forEach { v ->
|
||||
CardBox(v.title) {
|
||||
v.items.forEach { item ->
|
||||
Text(ChangelogParser.styled("• $item"), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7 -> AuthorTab()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Card(shape = RoundedCornerShape(20.dp), elevation = CardDefaults.cardElevation(2.dp)) {
|
||||
Column(Modifier.padding(20.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text(stringResource(R.string.about_section_how), style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||
HorizontalDivider()
|
||||
Text(stringResource(R.string.about_how_it_works), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
|
||||
Card(shape = RoundedCornerShape(20.dp), elevation = CardDefaults.cardElevation(2.dp)) {
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(20.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun AboutHeader(icon: androidx.compose.ui.graphics.ImageBitmap?, versionName: String) {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 10.dp),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
elevation = CardDefaults.cardElevation(2.dp)
|
||||
) {
|
||||
Text(stringResource(R.string.about_author), style = MaterialTheme.typography.bodyMedium)
|
||||
Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(52.dp))
|
||||
Column {
|
||||
Text(stringResource(R.string.app_name), style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold)
|
||||
Text(
|
||||
stringResource(R.string.about_author_value),
|
||||
stringResource(R.string.about_version, versionName),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
"Pare-feu de données mobiles pour Android : seules les applications autorisées accèdent à Internet en 4G/5G, le Wi-Fi reste libre. Pilotable à distance par un parent avec FamilyControl.",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
listOf("Android 8.0+", "Sans root", "VPN local", "Kotlin · Compose", "Projet personnel").forEach { Pill(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Pill(text: String) {
|
||||
Surface(shape = RoundedCornerShape(50), color = MaterialTheme.colorScheme.secondaryContainer) {
|
||||
Text(
|
||||
text,
|
||||
modifier = Modifier.padding(horizontal = 10.dp, vertical = 3.dp),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSecondaryContainer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CardBox(title: String?, content: @Composable () -> Unit) {
|
||||
Card(shape = RoundedCornerShape(20.dp), elevation = CardDefaults.cardElevation(2.dp)) {
|
||||
Column(Modifier.fillMaxWidth().padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
if (title != null) {
|
||||
Text(title, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||
HorizontalDivider()
|
||||
}
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SectionCard(section: AboutSection) =
|
||||
CardBox(section.heading) { section.entries.forEach { EntryRow(it) } }
|
||||
|
||||
@Composable
|
||||
private fun EntryRow(entry: AboutEntry) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Text(entry.title, style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.SemiBold)
|
||||
Text(entry.body, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AuthorTab() {
|
||||
val uriHandler = LocalUriHandler.current
|
||||
CardBox(null) {
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
Text(stringResource(R.string.about_author), style = MaterialTheme.typography.bodyMedium)
|
||||
Text(stringResource(R.string.about_author_value), style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
Text("Dépôt", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
"git.tuxtech.fr/tuxgyver/DataControl",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.clickable { runCatching { uriHandler.openUri(AboutContent.REPO_URL) } }
|
||||
)
|
||||
}
|
||||
Text("© ${LocalDate.now().year} JT-Tools — Johnny", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Card(
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer)
|
||||
) {
|
||||
Text(
|
||||
AboutContent.AI_NOTICE,
|
||||
modifier = Modifier.padding(18.dp),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.jttools.datacontrol.ui.about
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.withStyle
|
||||
|
||||
data class ChangelogVersion(val title: String, val items: List<String>)
|
||||
|
||||
/** Lit CHANGELOG.md (embarqué dans les assets par le build) : versions de la plus récente à la plus ancienne. */
|
||||
object ChangelogParser {
|
||||
fun load(context: Context): List<ChangelogVersion> = runCatching {
|
||||
parse(context.assets.open("CHANGELOG.md").bufferedReader().use { it.readText() })
|
||||
}.getOrDefault(emptyList())
|
||||
|
||||
fun parse(text: String): List<ChangelogVersion> {
|
||||
val out = mutableListOf<ChangelogVersion>()
|
||||
var title: String? = null
|
||||
var items = mutableListOf<String>()
|
||||
fun flush() { title?.let { out += ChangelogVersion(it, items) }; items = mutableListOf() }
|
||||
for (raw in text.lines()) {
|
||||
val line = raw.trim()
|
||||
when {
|
||||
line.startsWith("## ") -> { flush(); title = line.removePrefix("## ").trim() }
|
||||
line.startsWith("- ") && title != null -> items += line.removePrefix("- ").trim()
|
||||
line.isNotEmpty() && title != null && !line.startsWith("#") && items.isNotEmpty() ->
|
||||
items[items.lastIndex] = items.last() + " " + line // ligne de continuation
|
||||
}
|
||||
}
|
||||
flush()
|
||||
return out
|
||||
}
|
||||
|
||||
/** Rend **gras** et `code` du Markdown ; le reste est du texte brut. */
|
||||
fun styled(text: String): AnnotatedString = buildAnnotatedString {
|
||||
var i = 0
|
||||
while (i < text.length) {
|
||||
when {
|
||||
text.startsWith("**", i) -> {
|
||||
val end = text.indexOf("**", i + 2)
|
||||
if (end > 0) { withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append(text.substring(i + 2, end)) }; i = end + 2 } else { append(text[i]); i++ }
|
||||
}
|
||||
text[i] == '`' -> {
|
||||
val end = text.indexOf('`', i + 1)
|
||||
if (end > 0) { withStyle(SpanStyle(fontFamily = FontFamily.Monospace)) { append(text.substring(i + 1, end)) }; i = end + 1 } else { append(text[i]); i++ }
|
||||
}
|
||||
else -> { append(text[i]); i++ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -33,11 +34,14 @@ import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.jttools.datacontrol.log.AppLog
|
||||
import com.jttools.datacontrol.service.FirewallVpnService
|
||||
import com.jttools.datacontrol.ui.SystemActions
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun JournalScreen() {
|
||||
fun JournalScreen(systemActions: SystemActions) {
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val entries by AppLog.entries.collectAsStateWithLifecycle()
|
||||
|
||||
// État en direct du pare-feu, rafraîchi chaque seconde : première chose à regarder si le VPN n'apparaît pas.
|
||||
@@ -63,6 +67,18 @@ fun JournalScreen() {
|
||||
}) { Text("Partager") }
|
||||
OutlinedButton(onClick = { AppLog.clear() }) { Text("Effacer") }
|
||||
}
|
||||
Button(onClick = {
|
||||
scope.launch {
|
||||
if (!FirewallVpnService.isPrepared(context)) {
|
||||
AppLog.i("Test VPN", "autorisation VPN absente : demande à l'utilisateur")
|
||||
systemActions.requestVpnPermission { granted ->
|
||||
AppLog.i("Test VPN", "autorisation VPN ${if (granted) "accordée" else "REFUSÉE"} — relancez le test")
|
||||
}
|
||||
return@launch
|
||||
}
|
||||
runVpnTest(context)
|
||||
}
|
||||
}, modifier = Modifier.fillMaxWidth()) { Text("Tester le VPN (10 s, coupe les autres applications)") }
|
||||
LazyColumn(Modifier.fillMaxWidth().weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
items(entries.asReversed()) { line ->
|
||||
val color = when {
|
||||
@@ -79,5 +95,27 @@ fun JournalScreen() {
|
||||
private fun liveStatus(context: Context): String = buildString {
|
||||
appendLine("VPN autorisé (prepare) : ${FirewallVpnService.isPrepared(context)}")
|
||||
appendLine("Tunnel VPN monté : ${FirewallVpnService.tunnelActive}")
|
||||
appendLine("Suivi des applis (accessibilité) : ${com.jttools.datacontrol.guard.AppGuardService.isEnabled(context)}")
|
||||
appendLine("Conservation du journal : ${AppLog.RETENTION_DAYS} jours")
|
||||
append("Attendu : le tunnel n'est monté QUE sur données mobiles, contrôle activé.")
|
||||
}
|
||||
|
||||
/** Monte le tunnel 10 s quel que soit le réseau : prouve (ou infirme) que le VPN peut se monter sur cet appareil. */
|
||||
private suspend fun runVpnTest(context: Context) {
|
||||
val app = context.applicationContext
|
||||
AppLog.i("Test VPN", "démarrage : demande de montage du tunnel (mode blocage total)")
|
||||
try {
|
||||
androidx.core.content.ContextCompat.startForegroundService(app, FirewallVpnService.startBlockAllIntent(app))
|
||||
} catch (e: Exception) {
|
||||
AppLog.e("Test VPN", "le service VPN n'a pas pu démarrer", e)
|
||||
return
|
||||
}
|
||||
delay(3_000)
|
||||
if (FirewallVpnService.tunnelActive) AppLog.i("Test VPN", "SUCCÈS : tunnel monté — l'icône clé doit être visible")
|
||||
else AppLog.e("Test VPN", "ÉCHEC : tunnel non monté après 3 s (voir les lignes FirewallVpnService ci-dessus)")
|
||||
delay(7_000)
|
||||
runCatching {
|
||||
androidx.core.content.ContextCompat.startForegroundService(app, FirewallVpnService.stopIntent(app))
|
||||
}
|
||||
AppLog.i("Test VPN", "fin du test : tunnel arrêté")
|
||||
}
|
||||
@@ -75,7 +75,7 @@ fun DataControlNavHost(systemActions: SystemActions) {
|
||||
composable(Destination.Dashboard.route) { DashboardScreen(systemActions) }
|
||||
composable(Destination.Settings.route) { SettingsScreen(systemActions) }
|
||||
composable(Destination.Whitelist.route) { WhitelistScreen() }
|
||||
composable(Destination.Journal.route) { JournalScreen() }
|
||||
composable(Destination.Journal.route) { JournalScreen(systemActions) }
|
||||
composable(Destination.About.route) { AboutScreen() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,6 @@
|
||||
<!-- About -->
|
||||
<string name="about_title">À propos</string>
|
||||
<string name="about_version">Version %1$s</string>
|
||||
<string name="about_section_description">Description</string>
|
||||
<string name="about_description">DataControl surveille en arrière-plan la consommation de données mobiles et coupe automatiquement l\'accès à Internet en cas de dépassement du forfait, sans jamais toucher au Wi-Fi.</string>
|
||||
<string name="about_section_how">Fonctionnement</string>
|
||||
<string name="about_how_it_works">Le filtrage repose sur un pare-feu local basé sur VpnService (sans root) : le trafic des applications non autorisées est capturé dans un tunnel VPN local puis silencieusement ignoré, tandis que les applications de la liste blanche continuent de communiquer normalement.</string>
|
||||
<string name="update_section">Mise à jour</string>
|
||||
<string name="update_check">Rechercher une mise à jour</string>
|
||||
<string name="update_checking">Recherche en cours…</string>
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
versionName=0.1.4
|
||||
versionCode=5
|
||||
versionName=0.1.5
|
||||
versionCode=6
|
||||
Reference in new issue
Block a user