Skip to content

Commit 3f9cfb5

Browse files
committed
Fix delete notification issue
1 parent c2a90f5 commit 3f9cfb5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ android {
4141
else -> 0
4242
}
4343

44-
val vCode = 433
44+
val vCode = 436
4545
versionCode = vCode - singleAbiNum
46-
versionName = "2.1.16"
46+
versionName = "2.1.17"
4747

4848
ndk {
4949
//noinspection ChromeOsAbiSupport

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181

182182
<service
183183
android:name=".services.PNotificationListenerService"
184-
android:exported="true"
184+
android:exported="false"
185185
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
186186
<intent-filter>
187187
<action android:name="android.service.notification.NotificationListenerService" />

app/src/main/java/com/ismartcoding/plain/services/PNotificationListenerService.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ class PNotificationListenerService : NotificationListenerService() {
129129
LogCat.w("PNotificationListenerService: not connected, ignoring cancel request")
130130
return@receiveEventHandler
131131
}
132+
if (!Permission.NOTIFICATION_LISTENER.can(applicationContext)) {
133+
LogCat.w("PNotificationListenerService: permission not granted, ignoring cancel request")
134+
isConnected = false
135+
return@receiveEventHandler
136+
}
132137

133138
try {
134139
if (event.ids.size == TempData.notifications.size) {
@@ -166,6 +171,11 @@ class PNotificationListenerService : NotificationListenerService() {
166171
} catch (ex: Exception) {
167172
LogCat.e("Error cleaning up events: ${ex.message}")
168173
}
174+
try {
175+
requestRebind(ComponentName(applicationContext, PNotificationListenerService::class.java))
176+
} catch (ex: Exception) {
177+
LogCat.e("Error requesting rebind: ${ex.message}")
178+
}
169179
}
170180

171181
companion object {

0 commit comments

Comments
 (0)