summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuK1337 <priv.luk@gmail.com>2020-05-31 01:20:54 +0200
committerLuK1337 <priv.luk@gmail.com>2020-05-31 13:26:23 +0200
commitc0c464768cf6e8b822891d7456aaf1f01a3ad67c (patch)
treea74e46b80b0dac79782fa4e5fa82c0b065037124
parent5946f790a9517e854728563852bdebc9bbc5f65a (diff)
downloadandroid_packages_apps_Eleven-lineage-17.1.tar.gz
android_packages_apps_Eleven-lineage-17.1.tar.bz2
android_packages_apps_Eleven-lineage-17.1.zip
Eleven: Use constant notification idlineage-17.1
* `int notificationId = hashCode();` returns different value every time updateNotification() is called thus it'd end up creating multiple notifications. Change-Id: I36b3db279f58d5e9ea6ab8846db70eb0ae820e7a
-rw-r--r--src/org/lineageos/eleven/MusicPlaybackService.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/org/lineageos/eleven/MusicPlaybackService.java b/src/org/lineageos/eleven/MusicPlaybackService.java
index e784aa5..9b9f7c4 100644
--- a/src/org/lineageos/eleven/MusicPlaybackService.java
+++ b/src/org/lineageos/eleven/MusicPlaybackService.java
@@ -457,6 +457,8 @@ public class MusicPlaybackService extends Service
private int mNotifyMode = NOTIFY_MODE_NONE;
private long mNotificationPostTime = 0;
+ private static final int NOTIFICATION_ID = 0x1337;
+
private static final int NOTIFY_MODE_NONE = 0;
private static final int NOTIFY_MODE_FOREGROUND = 1;
private static final int NOTIFY_MODE_BACKGROUND = 2;
@@ -909,20 +911,19 @@ public class MusicPlaybackService extends Service
newNotifyMode = NOTIFY_MODE_NONE;
}
- int notificationId = hashCode();
if (mNotifyMode != newNotifyMode) {
if (mNotifyMode == NOTIFY_MODE_FOREGROUND) {
stopForeground(newNotifyMode == NOTIFY_MODE_NONE);
} else if (newNotifyMode == NOTIFY_MODE_NONE) {
- mNotificationManager.cancel(notificationId);
+ mNotificationManager.cancel(NOTIFICATION_ID);
mNotificationPostTime = 0;
}
}
if (newNotifyMode == NOTIFY_MODE_FOREGROUND) {
- startForeground(notificationId, buildNotification());
+ startForeground(NOTIFICATION_ID, buildNotification());
} else if (newNotifyMode == NOTIFY_MODE_BACKGROUND) {
- mNotificationManager.notify(notificationId, buildNotification());
+ mNotificationManager.notify(NOTIFICATION_ID, buildNotification());
}
mNotifyMode = newNotifyMode;
@@ -930,7 +931,7 @@ public class MusicPlaybackService extends Service
private void cancelNotification() {
stopForeground(true);
- mNotificationManager.cancel(hashCode());
+ mNotificationManager.cancel(NOTIFICATION_ID);
mNotificationPostTime = 0;
mNotifyMode = NOTIFY_MODE_NONE;
}