framework/base/core/java/android/service/notification/NotificationListenerService.java
private final class MyHandler extends Handler {
public static final int MSG_ON_NOTIFICATION_POSTED =1;
public static final int MSG_ON_NOTIFICATION_REMOVED =2;
public static final int MSG_ON_LISTENER_CONNECTED =3;
public static final int MSG_ON_NOTIFICATION_RANKING_UPDATE =4;
public static final int MSG_ON_LISTENER_HINTS_CHANGED =5;
public static final int MSG_ON_INTERRUPTION_FILTER_CHANGED =6;
public static final int MSG_ON_NOTIFICATION_CHANNEL_MODIFIED =7;
public static final int MSG_ON_NOTIFICATION_CHANNEL_GROUP_MODIFIED =8;
public static final int MSG_ON_STATUS_BAR_ICON_BEHAVIOR_CHANGED =9;
public MyHandler(Looper looper){super(looper, null, false);}
@Override
public voidhandleMessage(Message msg){if(!isConnected){return;}switch(msg.what){case MSG_ON_NOTIFICATION_POSTED:{
SomeArgs args =(SomeArgs) msg.obj;
StatusBarNotification sbn =(StatusBarNotification) args.arg1;
RankingMap rankingMap =(RankingMap) args.arg2;
args.recycle();onNotificationPosted(sbn, rankingMap);//add------------------------------
String j = sbn.getPackageName();if(j.equals("com.google.android.dialer")|| j.equals("com.google.android.apps.messaging")){
Intent intent = new Intent();
intent.setAction("com.faiot.Scanner.SET_LED");getContext().sendBroadcast(intent);}//end------------------------------}break;case MSG_ON_NOTIFICATION_REMOVED:{
SomeArgs args =(SomeArgs) msg.obj;
StatusBarNotification sbn =(StatusBarNotification) args.arg1;
RankingMap rankingMap =(RankingMap) args.arg2;int reason =(int) args.arg3;
NotificationStats stats =(NotificationStats) args.arg4;
args.recycle();onNotificationRemoved(sbn, rankingMap, stats, reason);//add------------------------------int m =0;
StatusBarNotification[] activeNotifications =getActiveNotifications();for(StatusBarNotification i : activeNotifications){
String j = i.getPackageName();if(j.equals("com.google.android.dialer")|| j.equals("com.google.android.apps.messaging"))
m++;}if(m ==0){
Intent intent = new Intent();
intent.setAction("com.faiot.Scanner.CLEAR_LED");getContext().sendBroadcast(intent);}//aend------------------------------}break;case MSG_ON_LISTENER_CONNECTED:{onListenerConnected();}break;case MSG_ON_NOTIFICATION_RANKING_UPDATE:{
RankingMap rankingMap =(RankingMap) msg.obj;onNotificationRankingUpdate(rankingMap);}break;