[kde] [Bug 524438] New: [Android][OriginOS] KDE Connect NotificationListener becomes non-live after reconnect

wuya <[email protected]>
Newsgroups gmane.comp.kde.devel.bugs
Message-ID <[email protected]/>
https://bugs.kde.org/show_bug.cgi?id=524438

            Bug ID: 524438
           Summary: [Android][OriginOS] KDE Connect NotificationListener
                    becomes non-live after reconnect
    Classification: I don't know
           Product: kde
      Version First unspecified
       Reported In:
          Platform: Android
                OS: Android 16.x
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

The following are the problems identified after interacting with and performing
practical operations with artificial intelligence, along with suggestions from
the AI, which hopefully will help resolve the notification synchronization
issue:

Title

[Android][OriginOS] KDE Connect NotificationListener becomes non-live after
reconnect

Description
Environment
Phone: iQOO 15
ROM: OriginOS 6
Android: 16
KDE Connect Android: 1.35.13
Package: org.kde.kdeconnect_tp
Desktop KDE Connect: 26.04.2
Desktop OS:Win11 26200.8655
Problem

After KDE Connect disconnects and reconnects to the desktop, KDE Connect may
stop forwarding phone notifications to the desktop.

The notification listener permission is still enabled, but the KDE Connect
notification listener is no longer shown as a live listener.

Re-disabling and re-enabling the notification listener permission immediately
fixes the problem.

1. Normal / working state

When notification synchronization is working correctly, I ran:

rish -c 'settings get secure enabled_notification_listeners'

Output:

org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver

Then:

rish -c 'dumpsys notification | grep -A 10 -B 10
"org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver"'

Relevant output:

Restored without uid:


  Notification listeners:
    Allowed notification listeners:
     
org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver
(user: 0 isPrimary: true)


    Has user set:
      userId=0
value={com.google.android.projection.gearhead/com.google.android.gearhead.notifications.SharedNotificationListenerManager$ListenerService,
org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver,
com.vivo.pushservice/com.vivo.push.util.NotificationMonitor}


    Live notification listeners (22):


    All notification listeners (1) enabled for current profiles:
     
ComponentInfo{org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver}


...


     
ComponentInfo{org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver}
(user 0): android.service.notification.INotificationListener$Stub$Proxy@9aac641

In this state, phone notifications are successfully synchronized to the
desktop.

2. Broken / non-working state

After KDE Connect disconnected and reconnected, notification synchronization
stopped working.

I ran the same command again:

rish -c 'dumpsys notification | grep -A 10 -B 10
"org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver"'

Relevant output:

Restored without uid:


  Notification listeners:
    Allowed notification listeners:
     
org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver
(user: 0 isPrimary: true)


    Has user set:
      userId=0
value={com.google.android.projection.gearhead/com.google.android.gearhead.notifications.SharedNotificationListenerManager$ListenerService,
org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver,
com.vivo.pushservice/com.vivo.push.util.NotificationMonitor}


    Live notification listeners (21):


    All notification listeners (1) enabled for current profiles:
     
ComponentInfo{org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver}


...

In the broken state, the important difference is:

Allowed notification listeners:
  KDE Connect NotificationReceiver

is still present.

And:

All notification listeners enabled for current profiles:
  KDE Connect NotificationReceiver

is also still present.

However, the KDE Connect component is missing from the Live notification
listeners section.

There is no corresponding live entry such as:

ComponentInfo{org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver}
(user 0): android.service.notification.INotificationListener$Stub$Proxy@...

At this point, KDE Connect no longer receives phone notifications.

3. Notification listener permission is still enabled

I also checked:

rish -c 'settings get secure enabled_notification_listeners'

Output:

org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver

So the permission was not removed.

4. Workaround / recovery

I discovered that disabling and re-enabling the notification listener
immediately fixes the problem.

Using Shizuku/Rish:

rish -c 'cmd notification disallow_listener
org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver
0'

Then:

rish -c 'cmd notification allow_listener
org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver
0'

After this, I checked again:

rish -c 'dumpsys notification | grep -A 10 -B 10
"org.kde.kdeconnect_tp/org.kde.kdeconnect.plugins.notifications.NotificationReceiver"'

The KDE Connect NotificationReceiver appeared again in the Live notification
listeners section, and notification synchronization to the desktop started
working immediately.

The same recovery can also be performed manually through the OriginOS
notification listener permission UI:

Disable KDE Connect notification permission
        ↓
Enable KDE Connect notification permission again
        ↓
Notification synchronization works again
5. Current KDE Connect source

Ai checked the current KDE Connect Android master source:

https://github.com/KDE/kdeconnect-android/blob/master/src/main/java/org/kde/kdeconnect/plugins/notifications/NotificationReceiver.java

The relevant implementation currently contains:

@Override
public void onListenerConnected() {
    super.onListenerConnected();


    for (NotificationListener listener : listeners) {
        listener.onListenerConnected(this);
    }


    connected = true;
}


@Override
public void onListenerDisconnected() {
    super.onListenerDisconnected();
    connected = false;
}

There does not appear to be a requestRebind() call in onListenerDisconnected().

6. Expected behavior

When the Android notification listener becomes disconnected after KDE Connect
reconnects, KDE Connect should automatically recover the notification listener.

The user should not have to manually disable and re-enable the notification
listener permission.

7. Additional information

The problem is reproducible on my iQOO 15 / OriginOS.

The most important difference between the working and broken states is:

Working:
Allowed = YES
Enabled = YES
Live = YES


Broken:
Allowed = YES
Enabled = YES
Live = NO

Manually disabling and re-enabling the notification listener restores:

Live = YES

and notification synchronization immediately works again.

-- 
You are receiving this mail because:
You are watching all bug changes.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.