Skip to content

Commit 4e84eba

Browse files
committed
clean dead code and solve warnings
1 parent 3f3e50a commit 4e84eba

48 files changed

Lines changed: 84 additions & 5707 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎app/src/main/AndroidManifest.xml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
android:sharedUserId="android.uid.system">
45

56
<!-- Permissions — same as original DriveHub Dort -->
@@ -13,12 +14,14 @@
1314

1415
<!-- Consommation de donnees : signature|privileged, accessible car l app est signee
1516
avec la cle plateforme. Sans elle, NetworkStatsManager leve une SecurityException. -->
16-
<uses-permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY" />
17+
<uses-permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY"
18+
tools:ignore="ProtectedPermissions" />
1719
<!-- Pilotage des sessions média (piste suivante, lecture/pause). Voie du launcher
1820
d'origine sur les firmwares A9, et seule voie pour CarPlay/Android Auto sur
1921
SWI68/165. signature|privileged : obtenue parce que l'app tourne en
2022
android.uid.system. -->
21-
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
23+
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"
24+
tools:ignore="ProtectedPermissions" />
2225
<!-- Vehicle control permissions (Android Automotive / SAIC) -->
2326
<uses-permission android:name="android.car.permission.CAR_ENERGY" />
2427
<uses-permission android:name="android.car.permission.CAR_POWERTRAIN" />

‎app/src/main/java/com/mg4/control/MG4App.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MG4App : Application() {
3131
}
3232

3333
// ── Migration + initialisation du thème ───────────────────────────────
34-
val prefs = getSharedPreferences("mg4_settings", Context.MODE_PRIVATE)
34+
val prefs = getSharedPreferences("mg4_settings", MODE_PRIVATE)
3535

3636
if (!prefs.contains(ThemeHelper.PREF_THEME_MODE)) {
3737
// Migration depuis l'ancien booléen "dark_theme" (version < 2.x)

‎app/src/main/java/com/mg4/control/MainActivity.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ class MainActivity : AppCompatActivity() {
169169

170170
// ── Navigation vers l'écran par défaut au démarrage ─────────────────────
171171

172-
private fun navigateToDefaultScreen(savedInstanceState: android.os.Bundle?) {
172+
private fun navigateToDefaultScreen(savedInstanceState: Bundle?) {
173173
// Ne naviguer que si c'est un vrai démarrage (pas une rotation / recreate)
174174
if (savedInstanceState != null) return
175-
val prefs = getSharedPreferences("mg4_settings", android.content.Context.MODE_PRIVATE)
175+
val prefs = getSharedPreferences("mg4_settings", MODE_PRIVATE)
176176
when (prefs.getString("default_screen", "dashboard")) {
177177
"profiles" -> navController.navigate(R.id.profileFragment)
178178
"shortcuts" -> navController.navigate(R.id.shortcutsFragment)
@@ -184,7 +184,7 @@ class MainActivity : AppCompatActivity() {
184184

185185
private fun checkForUpdates() {
186186
if (BuildConfig.OFFLINE) return // build offline : aucune vérif réseau
187-
val prefs = getSharedPreferences("mg4_settings", android.content.Context.MODE_PRIVATE)
187+
val prefs = getSharedPreferences("mg4_settings", MODE_PRIVATE)
188188
if (!prefs.getBoolean("auto_check_update", true)) return
189189

190190
UpdateChecker.check(

‎app/src/main/java/com/mg4/control/accessibility/AdvancedShortcuts.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ object AdvancedShortcuts {
122122
else reste.substring(coupure + 1).takeIf { it.isNotEmpty() }
123123
// Le suffixe est cherché par correspondance exacte, sans valeur de repli : une
124124
// clé inconnue doit être IGNORÉE, pas rattachée arbitrairement à un type d'appui.
125-
val press = PressType.values().firstOrNull { partieTouche.endsWith("_${it.key}") }
125+
val press = PressType.entries.firstOrNull { partieTouche.endsWith("_${it.key}") }
126126
?: return@mapNotNull null
127127
val code = partieTouche.removeSuffix("_${press.key}").toIntOrNull()
128128
?: return@mapNotNull null
@@ -209,7 +209,7 @@ object AdvancedShortcuts {
209209
* même le délai d'un renvoi.
210210
*/
211211
fun isClaimedNow(context: Context, keyCode: Int): Boolean =
212-
PressType.values().any { resolve(context, keyCode, it) != null }
212+
PressType.entries.any { resolve(context, keyCode, it) != null }
213213

214214
/**
215215
* Vrai si CETTE TOUCHE porte au moins un raccourci — quel que soit le type d'appui ET quel que

‎app/src/main/java/com/mg4/control/accessibility/KeyCaptureService.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import com.mg4.control.debug.AppLogger
1414
import com.mg4.control.service.MG4ControlService
1515
import com.mg4.control.service.ProfilePickerOverlay
1616
import com.mg4.control.shortcut.PressType
17-
import com.mg4.control.shortcut.ShortcutAction
1817
import com.mg4.control.util.GarageMode
1918
import java.util.concurrent.ConcurrentHashMap
2019
import java.util.concurrent.Executors

‎app/src/main/java/com/mg4/control/api/ExternalApi.kt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,14 @@ object ExternalApi {
177177

178178
// ── Lecture (ContentProvider) ────────────────────────────────────────────
179179

180-
/**
180+
/*
181181
* `content://<applicationId>.state/state` → une ligne, une colonne par valeur.
182182
*
183183
* ⚠️ L'authority suit l'applicationId, elle n'est donc PAS une constante : la variante
184184
* offline s'installe à côté de l'online et deux paquets ne peuvent pas déclarer la même
185185
* (INSTALL_FAILED_CONFLICTING_PROVIDER). Les intégrateurs doivent viser
186186
* `com.mg4.control.state` ou `com.mg4.control.offline.state` selon la variante installée.
187187
*/
188-
fun authority(context: Context): String = context.packageName + ".state"
189188

190189
const val PATH_STATE = "state"
191190

‎app/src/main/java/com/mg4/control/debug/AppLogger.kt‎

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
package com.mg4.control.debug
22

3-
import android.os.Handler
4-
import android.os.Looper
53
import android.util.Log
64
import java.text.SimpleDateFormat
75
import java.util.Date
86
import java.util.Locale
9-
import java.util.concurrent.CopyOnWriteArrayList
107

118
/**
129
* In-app log buffer — mirrors every Log.* call to an in-memory ring buffer
13-
* so the ConsoleFragment can display them without ADB.
10+
* so the Diagnostic report can include them without ADB.
1411
*
1512
* Le buffer est un ArrayDeque sous verrou : la CopyOnWriteArrayList précédente recopiait
1613
* les 400 entrées deux fois par ligne de log, sur le thread appelant — c'est-à-dire
17-
* pendant l'application d'un profil. Les listeners sont notifiés hors du chemin chaud.
14+
* pendant l'application d'un profil.
1815
*/
1916
object AppLogger {
2017

@@ -46,14 +43,6 @@ object AppLogger {
4643
val entries: List<Entry>
4744
get() = synchronized(lock) { buffer.toList() }
4845

49-
private val listeners = CopyOnWriteArrayList<() -> Unit>()
50-
51-
private val mainHandler = Handler(Looper.getMainLooper())
52-
53-
/** Notification déjà programmée : une rafale de logs ne donne qu'un seul réveil UI. */
54-
@Volatile
55-
private var notifyPending = false
56-
5746
// ---- Public log methods (mirror android.util.Log) ----
5847

5948
fun d(tag: String, msg: String) { add(tag, Level.DEBUG, msg); Log.d(tag, msg) }
@@ -66,7 +55,6 @@ object AppLogger {
6655
buffer.clear()
6756
totalCount = 0L
6857
}
69-
notifyListeners()
7058
}
7159

7260
/**
@@ -84,11 +72,6 @@ object AppLogger {
8472
}
8573
}
8674

87-
// ---- Listener for live UI updates ----
88-
89-
fun addListener(l: () -> Unit) { listeners.add(l) }
90-
fun removeListener(l: () -> Unit) { listeners.remove(l) }
91-
9275
// ---- Internal ----
9376

9477
private fun add(tag: String, level: Level, msg: String) {
@@ -99,19 +82,5 @@ object AppLogger {
9982
buffer.addLast(entry)
10083
totalCount++
10184
}
102-
notifyListeners()
103-
}
104-
105-
/**
106-
* Réveille l'UI sur le thread principal, au plus une fois par rafale : la notification
107-
* ne doit pas s'exécuter sur le thread qui journalise.
108-
*/
109-
private fun notifyListeners() {
110-
if (listeners.isEmpty() || notifyPending) return
111-
notifyPending = true
112-
mainHandler.post {
113-
notifyPending = false
114-
listeners.forEach { runCatching { it.invoke() } }
115-
}
11685
}
11786
}

0 commit comments

Comments
 (0)