android miui9.0改装条例,安卓的通知适配(更新至9.0)

有的手机在添加channel后仍然无法弹出通知。追踪logcat发现有这么一句:

E/NotificationService: Suppressing notification from package by user request.

用户请求抑制此通知?追踪notify源码找到NotificationManagerService的enqueueNotificationInternal(......)方法:

void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,final int callingPid, final String tag, final int id, final Notification notification,int incomingUserId) {

...

if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r)) {return;}

...

mHandler.post(new EnqueueNotificationRunnable(userId, r));

}

private boolean checkDisqualifyingFeatures(int userId, int callingUid, int id, String tag,NotificationRecord r) {

...// blocked apps

if (isBlocked(r, mUsageStats)) {return false;}

return true;

}

protected boolean isBlocked(NotificationRecord r, NotificationUsageStats usageStats) {

final String pkg = r.sbn.getPackageName();

final int callingUid = r.sbn.getUid();

final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid);

if (isPackageSuspended) {

Slog.e(TAG, "Suppressing notification from package due to package suspended by administrator.");

usageStats.registerSuspendedByAdmin(r);

return isPackageSuspended;

}

final boolean isBlocked = mRankingHelper.getImportance(pkg, callingUid) == NotificationManager.IMPORTANCE_NONE

|| r.getChannel().getImportance() == NotificationManager.IMPORTANCE_NONE;

if (isBlocked) {

Slog.e(TAG, "Suppressing notification from package by user request.");

usageStats.registerBlocked(r);

}

return isBlocked;

}

最终的isBlocked判断条件满足,导致notify操作被中断return。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值