Improved error log in case it is 'expected'

This commit is contained in:
Sylvain Berfini 2023-05-22 09:41:23 +02:00
parent 666a4f1ad0
commit 41f6139137
2 changed files with 10 additions and 2 deletions

View file

@ -34,7 +34,8 @@ class CoreService : CoreService() {
} }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.i("[Service] Ensuring Core exists") Log.i("[Service] Starting, ensuring Core exists")
if (corePreferences.keepServiceAlive) { if (corePreferences.keepServiceAlive) {
Log.i("[Service] Starting as foreground to keep app alive in background") Log.i("[Service] Starting as foreground to keep app alive in background")
if (!ensureCoreExists( if (!ensureCoreExists(

View file

@ -320,9 +320,16 @@ class NotificationsManager(private val context: Context) {
try { try {
notificationManager.notify(tag, id, notification) notificationManager.notify(tag, id, notification)
} catch (iae: IllegalArgumentException) { } catch (iae: IllegalArgumentException) {
if (service == null && tag == null) {
// We can't notify using CallStyle if there isn't a foreground service running
Log.w(
"[Notifications Manager] Foreground service hasn't started yet, can't display a CallStyle notification until then: $iae"
)
} else {
Log.e("[Notifications Manager] Exception occurred: $iae") Log.e("[Notifications Manager] Exception occurred: $iae")
} }
} }
}
fun cancel(id: Int, tag: String? = null) { fun cancel(id: Int, tag: String? = null) {
Log.i("[Notifications Manager] Canceling [$id] with tag [$tag]") Log.i("[Notifications Manager] Canceling [$id] with tag [$tag]")