代码路径:
frameworks/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
在PhoneStatusBar.java文件中addNotification()就是显示通知信息,如果想禁止显示通知就可以在这里添加变量控制返回
private static final boolean NOTIFICATION = false;
public void addNotification(IBinder key, StatusBarNotification notification) {
if (DEBUG) Log.d(TAG, "addNotification score=" + notification.getScore() +" , StatusBarNotification = " + notification +
" , notification icon = " + notification.getNotification().icon);
if(!NOTIFICATION){
return;
}
Entry shadeEntry = createNotificationViews(key, notification);
if (shadeEntry == null) {
return;
}
if (mUseHeadsUp && shouldInterrupt(notification)) {
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
Entry interruptionCandidate = new Entry(key, notification, null);
if (inflateViews(interruptionCandidate, mHeadsUpNotificationView.getHolder())) {
mInterruptingNotificationTime = System.currentTimeMillis();
mInterruptingNotificationEntry = interruptionCandidate;
shadeEntry.setInterruption();
// 1. Populate mHeadsUpNotificationView
mHeadsUpNotificationView.setNotification(mInterruptingNotificationEntry);
// 2. Animate mHeadsUpNotificationView in
mHandler.sendEmptyMessage(MSG_SHOW_HEADS_UP);
// 3. Set alarm to age the notification off
resetHeadsUpDecayTimer();
}
} else if (notification.getNotification().fullScreenIntent != null) {
// Stop screensaver if the notification has a full-screen intent.
// (like an incoming phone call)
awakenDreams();
// not immersive & a full-screen alert should be shown
if (DEBUG) Log.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent");
try {
notification.getNotification().fullScreenIntent.send();
} catch (PendingIntent.CanceledException e) {
}
} else {
// usual case: status bar visible & not immersive
// show the ticker if there isn't already a heads up
if (mInterruptingNotificationEntry == null) {
tick(null, notification, true);
}
}
addNotificationViews(shadeEntry);
// Recalculate the position of the sliding windows and the titles.
setAreThereNotifications();
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
}