世界杯主办国

在需求开发中,我们需要做到各种通知的屏蔽,系统的通知,下拉状态栏通知,第三方应用通知,前后台通知。以下是收集所有相关屏蔽和拦截、取消、隐藏,过滤等消息信息的方法尝试,根据不同需要定制修改,相信总有一个是可以做到的。

根据应用包名来实现对特定APP前台通知的屏蔽。通过分析代码,找到关键位置进行修改,测试后确认功能可行。

目前没有找到比较合适的过滤方式,如有些反常的应用却不进行拦截从而正常显示,但是可以拦截掉市面上的大多数应用

方法一:frameworks/base/services/core/java/com/android/server/am/ActiveServices.java 里面的这个方法setServiceForegroundLocked(*)

public void setServiceForegroundLocked(ComponentName className, IBinder token, int id, Notification notification, boolean removeNotification) {

final int userId = UserHandle.getCallingUserId(); final long origId = Binder.clearCallingIdentity(); //*/ if( className.getPackageName().equals("com.sohu.inputmethod.sogou") ){//应用的包名 return; } //*/ try{

***** }finally {

Binder.restoreCallingIdentity(origId); } }

方法二: /SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java

private void addEntry(Entry shadeEntry) {

- boolean isHeadsUped = shouldPeek(shadeEntry); + boolean isHeadsUped = false; if (isHeadsUped) {

&n