Merge "Category message is sufficient for message notif" into pi-dev
am: b24d84b222
Change-Id: I5502cade1ec859215f76d29966f0663f387cc433
This commit is contained in:
@@ -26,7 +26,6 @@ import android.os.Looper;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -47,6 +46,18 @@ public class NotificationMessagingUtil {
|
|||||||
Settings.Secure.getUriFor(DEFAULT_SMS_APP_SETTING), false, mSmsContentObserver);
|
Settings.Secure.getUriFor(DEFAULT_SMS_APP_SETTING), false, mSmsContentObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isImportantMessaging(StatusBarNotification sbn, int importance) {
|
||||||
|
if (importance < NotificationManager.IMPORTANCE_LOW) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasMessagingStyle(sbn) || (isCategoryMessage(sbn) && isDefaultMessagingApp(sbn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMessaging(StatusBarNotification sbn) {
|
||||||
|
return hasMessagingStyle(sbn) || isDefaultMessagingApp(sbn) || isCategoryMessage(sbn);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private boolean isDefaultMessagingApp(StatusBarNotification sbn) {
|
private boolean isDefaultMessagingApp(StatusBarNotification sbn) {
|
||||||
final int userId = sbn.getUserId();
|
final int userId = sbn.getUserId();
|
||||||
@@ -73,25 +84,12 @@ public class NotificationMessagingUtil {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public boolean isImportantMessaging(StatusBarNotification sbn, int importance) {
|
private boolean hasMessagingStyle(StatusBarNotification sbn) {
|
||||||
if (importance < NotificationManager.IMPORTANCE_LOW) {
|
Class<? extends Notification.Style> style = sbn.getNotification().getNotificationStyle();
|
||||||
return false;
|
return Notification.MessagingStyle.class.equals(style);
|
||||||
}
|
|
||||||
|
|
||||||
return isMessaging(sbn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMessaging(StatusBarNotification sbn) {
|
private boolean isCategoryMessage(StatusBarNotification sbn) {
|
||||||
Class<? extends Notification.Style> style = sbn.getNotification().getNotificationStyle();
|
return Notification.CATEGORY_MESSAGE.equals(sbn.getNotification().category);
|
||||||
if (Notification.MessagingStyle.class.equals(style)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Notification.CATEGORY_MESSAGE.equals(sbn.getNotification().category)
|
|
||||||
&& isDefaultMessagingApp(sbn)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user