从Android 5.0开始,如果notification priority设置为HIGH, MAX, 或者fullscreenIntent不为空,在非锁屏界面收到notification时屏幕上方会显示一个小悬浮窗口提醒用户,方便用户在不退出当前浏览界面的前提下快速响应该notification,即Heads-Up Notification(简称HUN)。如下图:
2. 如需禁止某个应用notification以HUN方式显示,可在baseStatusbar.java中根据需求客制化interrupt值。
例如,要禁止来电以Heads-Up Notification方式显示,可修改如下:
L版本中, 来电直接显示来电界面, 而不是 show Notification(HeadsUp view)
[SOLUTION]
HeadsUp 是 google 在 L 版本上面 PhoneStatusBar 中新增的功能.
而在未锁屏时来电就是通过这种方式来显示的. 从而替代了全屏显示来电界面的方式.
如果客户还是倾向于全屏显示来电界面. 则可以通过如下方式来单独关闭通话的 HeadsUp 功能.
File: frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBar.java
/// M: turn off HeadsUp for dialer. @{
private final String PACKAGES_DIALER = "com.android.dialer";
/// @}
@Override
public void addNotification(StatusBarNotification notification, RankingMap ranking) {
/// M: turn off HeadsUp for dialer. @{
boolean belongsToDialer = PACKAGES_DIALER.equals(notification.getPackageName());
if (DEBUG) {
Log.d(TAG, "addNotification key=" + notification.getKey() +
", package=" + notification.getPackageName());
}
if (!belongsToDialer &&
/// @}
mUseHeadsUp && shouldInterrupt(notification)) {
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
Entry interruptionCandidate = new Entry(notification, null);
ViewGroup holder = mHeadsUpNotificationView.getHolder();
if (inflateViewsForHeadsUp(interruptionCandidate, holder)) {
// 1. Populate mHeadsUpNotificationView
mHeadsUpNotificationView.showNotification(interruptionCandidate);
// do not show the notification in the shade, yet.
return;
}
}
.................................;
}