mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
Do not start Tor or notifications for offline flavor
- Skip `TorManager.init()` and `stats.createNotificationChannel()` in Amber.onCreate() for the offline flavor — no relay connections means no need for notification channels or Tor initialisation - Guard `stats.updateNotification()` in `reconnect()` behind the same offline check to avoid accessing uninitialised lateinit vars - Add an early-return guard in `AmberRelayStats.updateNotification()` so any call path that reaches it from relay listeners is also safe https://claude.ai/code/session_014Zqb1AEPPF2RrzmEyPnmei
This commit is contained in:
@@ -227,8 +227,10 @@ class Amber :
|
||||
|
||||
instance = this
|
||||
|
||||
stats.createNotificationChannel()
|
||||
TorManager.init(this)
|
||||
if (!BuildFlavorChecker.isOfflineFlavor()) {
|
||||
stats.createNotificationChannel()
|
||||
TorManager.init(this)
|
||||
}
|
||||
|
||||
isStartingAppState.value = true
|
||||
isStartingApp.value = true
|
||||
@@ -371,7 +373,9 @@ class Amber :
|
||||
client.connect()
|
||||
}
|
||||
client.reconnect(wasActive)
|
||||
stats.updateNotification()
|
||||
if (!BuildFlavorChecker.isOfflineFlavor()) {
|
||||
stats.updateNotification()
|
||||
}
|
||||
}
|
||||
|
||||
fun getDatabase(npub: String): AppDatabase {
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.core.app.NotificationChannelGroupCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import com.greenart7c3.nostrsigner.BuildFlavorChecker
|
||||
import com.greenart7c3.nostrsigner.MainActivity
|
||||
import com.greenart7c3.nostrsigner.R
|
||||
import com.greenart7c3.nostrsigner.service.KillSwitchReceiver
|
||||
@@ -215,6 +216,7 @@ class AmberRelayStats(
|
||||
}
|
||||
|
||||
fun updateNotification() {
|
||||
if (BuildFlavorChecker.isOfflineFlavor()) return
|
||||
val notificationManager = NotificationManagerCompat.from(appContext)
|
||||
if (ActivityCompat.checkSelfPermission(appContext, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
||||
createNotification(
|
||||
|
||||
Reference in New Issue
Block a user