summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajeev Kumar <rajekumar@google.com>2017-06-23 01:53:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-06-23 01:53:44 +0000
commita9d721df781bf4d195eb52bba1f9a3193f7eaad4 (patch)
tree5c5a0eb1143973362d85340b6520df6cd1769eba
parent8a87856d3aacd5b76d5bfa4300cb0766396e33f6 (diff)
parent541e13c2652badee856aebc448e578a75229661e (diff)
downloadandroid_packages_apps_Trebuchet-a9d721df781bf4d195eb52bba1f9a3193f7eaad4.tar.gz
android_packages_apps_Trebuchet-a9d721df781bf4d195eb52bba1f9a3193f7eaad4.tar.bz2
android_packages_apps_Trebuchet-a9d721df781bf4d195eb52bba1f9a3193f7eaad4.zip
Merge "1. Replace use of java.util.HashSet with android.util.ArraySet in NotificationListener. 2. Make few instance variable final. 3. Fix an unchecked cast." into ub-launcher3-dorval-polish
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 2d9c23e2d..baaa66aea 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -16,8 +16,10 @@
package com.android.launcher3.notification;
+import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationChannel;
+import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -25,16 +27,14 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.support.annotation.Nullable;
import android.text.TextUtils;
+import android.util.ArraySet;
import android.util.Pair;
-
import com.android.launcher3.LauncherModel;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.PackageUserKey;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -44,6 +44,7 @@ import java.util.Set;
* as well and when this service first connects. An instance of NotificationListener,
* and its methods for getting notifications, can be obtained via {@link #getInstanceIfConnected()}.
*/
+@TargetApi(Build.VERSION_CODES.O)
public class NotificationListener extends NotificationListenerService {
private static final int MSG_NOTIFICATION_POSTED = 1;
@@ -57,9 +58,9 @@ public class NotificationListener extends NotificationListenerService {
private final Handler mWorkerHandler;
private final Handler mUiHandler;
- private Ranking mTempRanking = new Ranking();
+ private final Ranking mTempRanking = new Ranking();
- private Handler.Callback mWorkerCallback = new Handler.Callback() {
+ private final Handler.Callback mWorkerCallback = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
switch (message.what) {
@@ -80,7 +81,7 @@ public class NotificationListener extends NotificationListenerService {
}
};
- private Handler.Callback mUiCallback = new Handler.Callback() {
+ private final Handler.Callback mUiCallback = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
switch (message.what) {
@@ -163,9 +164,9 @@ public class NotificationListener extends NotificationListenerService {
* An object containing data to send to MSG_NOTIFICATION_POSTED targets.
*/
private class NotificationPostedMsg {
- PackageUserKey packageUserKey;
- NotificationKeyData notificationKey;
- boolean shouldBeFilteredOut;
+ final PackageUserKey packageUserKey;
+ final NotificationKeyData notificationKey;
+ final boolean shouldBeFilteredOut;
NotificationPostedMsg(StatusBarNotification sbn) {
packageUserKey = PackageUserKey.fromNotification(sbn);
@@ -189,7 +190,8 @@ public class NotificationListener extends NotificationListenerService {
StatusBarNotification[] notifications = NotificationListener.this
.getActiveNotifications(NotificationKeyData.extractKeysOnly(keys)
.toArray(new String[keys.size()]));
- return notifications == null ? Collections.EMPTY_LIST : Arrays.asList(notifications);
+ return notifications == null
+ ? Collections.<StatusBarNotification>emptyList() : Arrays.asList(notifications);
}
/**
@@ -201,7 +203,7 @@ public class NotificationListener extends NotificationListenerService {
private List<StatusBarNotification> filterNotifications(
StatusBarNotification[] notifications) {
if (notifications == null) return null;
- Set<Integer> removedNotifications = new HashSet<>();
+ Set<Integer> removedNotifications = new ArraySet<>();
for (int i = 0; i < notifications.length; i++) {
if (shouldBeFilteredOut(notifications[i])) {
removedNotifications.add(i);