Bug 391059 - SharePlugin Notification Stuck
Summary: SharePlugin Notification Stuck
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (show other bugs)
Version: unspecified
Platform: Neon Android 7.x
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-25 18:59 UTC by Kai Dombrowe
Modified: 2018-03-03 14:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Dombrowe 2018-02-25 18:59:10 UTC
KDE-Connect-Android Version: 1.7.1

The SharePlugin notification is stuck ~95% of the time on my device.
The file transfer itself is successful.
The only way to get rid of the notification is to kill kde-connect.

The SharePlugin calls NotificationHelper.notifyCompat too often.
Android ignores than the final call to that function.
Logcat output: 
multiple lines of
org.kde.kdeconnect_tp W/NotificationManager: notify: id corrupted: sent -834788870, got back 0


The bug is in the SharePlugin.receiveFile function:

if (progressPercentage != prevProgressPercentage) {
    prevProgressPercentage = progressPercentage;

    notification.setProgress((int) progressPercentage);
    notification.show();
}


A possible fix is to only update the progress every 100ms:

long lastUpdate = 0;
if (progressPercentage != prevProgressPercentage && System.currentTimeMillis() - lastUpdate > 100) {
    prevProgressPercentage = progressPercentage;
    lastUpdate = System.currentTimeMillis();

    notification.setProgress((int) progressPercentage);
    notification.show();
}


I tested it and it works now on my Honor 7X with Android 7.
And thanks for an awesome app :)
Comment 1 Nicolas Fella 2018-03-02 14:35:21 UTC
Since you already figured out how to fix the issue it would be great if you uploded your patch on Phabricator so we can discuss it.

In case you don't know how to do that, don't be afraid. See https://community.kde.org/Infrastructure/Phabricator for instructions
Comment 2 Nicolas Fella 2018-03-03 14:17:39 UTC
Git commit 0b0b90f778fc53a8513480a233b3f9de96637d76 by Nicolas Fella, on behalf of Kai Dombrowe.
Committed on 03/03/2018 at 14:17.
Pushed by nicolasfella into branch 'master'.

Fix stuck notifications in the share plugin

Summary:
Android has a rate limit for updating notifications which was reduced
from 50 to 10 updates/sec since Nougat.
The share plugin updates the progress every time the percentage changes.
The final notification update which makes the notification removable,
is ignored if this happens more than 10 times in a second.
This patch reduces the progress updates to a maximum of 10 times per second.

Reviewers: #kde_connect, nicolasfella

Reviewed By: #kde_connect, nicolasfella

Subscribers: nicolasfella, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D10976

M  +5    -1    src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java

https://commits.kde.org/kdeconnect-android/0b0b90f778fc53a8513480a233b3f9de96637d76