From 51ee4d88fd0555a945a24b1ab3beba2ffdc79c06 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Sat, 4 May 2019 08:29:14 +0200 Subject: [PATCH 1/2] handle silent delete/delete-all push notifications do not ignore talk messages (will only be sent if no talk app is installed) exclude generated Parcelable Signed-off-by: tobiasKaminsky --- spotbugs-filter.xml | 19 ++++++++++--------- .../datamodel/DecryptedPushMessage.java | 5 +++++ .../android/jobs/NotificationJob.java | 13 ++++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/spotbugs-filter.xml b/spotbugs-filter.xml index d919024401..b37c066a69 100644 --- a/spotbugs-filter.xml +++ b/spotbugs-filter.xml @@ -1,27 +1,28 @@ - - - + - + - + + + + - - + + - + @@ -30,5 +31,5 @@ - + diff --git a/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java b/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java index 961eca9756..8499ab0061 100644 --- a/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java +++ b/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java @@ -20,6 +20,8 @@ package com.owncloud.android.datamodel; +import com.google.gson.annotations.SerializedName; + import org.parceler.Parcel; import lombok.AllArgsConstructor; @@ -41,4 +43,7 @@ public class DecryptedPushMessage { public String subject; public String id; public int nid; + public boolean delete; + @SerializedName("delete-all") + public boolean deleteAll; } diff --git a/src/main/java/com/owncloud/android/jobs/NotificationJob.java b/src/main/java/com/owncloud/android/jobs/NotificationJob.java index ef6c85da3f..7e0ccd7698 100644 --- a/src/main/java/com/owncloud/android/jobs/NotificationJob.java +++ b/src/main/java/com/owncloud/android/jobs/NotificationJob.java @@ -95,9 +95,7 @@ public class NotificationJob extends Job { private static final String KEY_NOTIFICATION_ACTION_TYPE = "KEY_NOTIFICATION_ACTION_TYPE"; private static final String PUSH_NOTIFICATION_ID = "PUSH_NOTIFICATION_ID"; private static final String NUMERIC_NOTIFICATION_ID = "NUMERIC_NOTIFICATION_ID"; - private static final String APP_SPREED = "spreed"; - private SecureRandom randomId = new SecureRandom(); private Context context; private UserAccountManager accountManager; @@ -110,6 +108,7 @@ public class NotificationJob extends Job { @Override protected Result onRunJob(@NonNull Params params) { context = getContext(); + NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); PersistableBundleCompat persistableBundleCompat = getParams().getExtras(); String subject = persistableBundleCompat.getString(KEY_NOTIFICATION_SUBJECT, ""); String signature = persistableBundleCompat.getString(KEY_NOTIFICATION_SIGNATURE, ""); @@ -135,8 +134,11 @@ public class NotificationJob extends Job { DecryptedPushMessage decryptedPushMessage = gson.fromJson(new String(decryptedSubject), DecryptedPushMessage.class); - // We ignore Spreed messages for now - if (!APP_SPREED.equals(decryptedPushMessage.getApp())) { + if (decryptedPushMessage.delete) { + notificationManager.cancel(decryptedPushMessage.nid); + } else if (decryptedPushMessage.deleteAll) { + notificationManager.cancelAll(); + } else { fetchCompleteNotification(signatureVerification.getAccount(), decryptedPushMessage); } } @@ -152,6 +154,7 @@ public class NotificationJob extends Job { } private void sendNotification(Notification notification, Account account) { + SecureRandom randomId = new SecureRandom(); RichObject file = notification.subjectRichParameters.get("file"); Intent intent; @@ -234,7 +237,7 @@ public class NotificationJob extends Job { .setContentIntent(pendingIntent).build()); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); - notificationManager.notify(pushNotificationId, notificationBuilder.build()); + notificationManager.notify(notification.getNotificationId(), notificationBuilder.build()); } private void fetchCompleteNotification(Account account, DecryptedPushMessage decryptedPushMessage) { From 6074c9320504b1ea1214e16447149e9416caf66d Mon Sep 17 00:00:00 2001 From: nextcloud-android-bot Date: Thu, 23 May 2019 09:00:17 +0000 Subject: [PATCH 2/2] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: nextcloud-android-bot --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 1fde7522a7..59b8937b62 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -434 \ No newline at end of file +424 \ No newline at end of file