GustavoASantos / Noti

Quick glance, clear progress
https://play.google.com/store/apps/details?id=com.gustavoas.noti
GNU General Public License v3.0
129 stars 16 forks source link

Fix crash when got notification without text #35

Closed ErrrorMaxx closed 7 months ago

ErrrorMaxx commented 7 months ago

Fixes crash when Google Backup is in progress (or any other notification with progress bar but without text is shown):

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
    at com.gustavoas.noti.services.NotificationListenerService.getProgressFromPercentage(NotificationListenerService.kt:216)
    at com.gustavoas.noti.services.NotificationListenerService.onNotificationPosted(NotificationListenerService.kt:75)
    at android.service.notification.NotificationListenerService.onNotificationPosted(NotificationListenerService.java:450)
    at android.service.notification.NotificationListenerService$MyHandler.handleMessage(NotificationListenerService.java:2311)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:204)
    at android.os.Looper.loop(Looper.java:291)
    at android.app.ActivityThread.main(ActivityThread.java:8129)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)

P.S. My device is TECNO Camon 20 Pro 5G, Android 13

GustavoASantos commented 7 months ago

Thanks for contributing! Can you tell me one of those apps where this was happening so I can try to replicate it? When you mention Google Backup, are you referring to Android's Backup in the system settings?

ErrrorMaxx commented 7 months ago

Yes, this is Android's Backup in the settings. I don't know other apps that crashes Noti, but they exists as I noticed crashes in logs long before I compiled debug build and started Backup.

GustavoASantos commented 7 months ago

These crashes were on the most recent version of Noti? And they stopped after adding this fix?

ErrrorMaxx commented 7 months ago

Yes, I tested main branch just before sending PR