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。
總結
以上是生活随笔為你收集整理的android miui9.0改装条例,安卓的通知适配(更新至9.0)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android电视打印信息解析,液晶电视
- 下一篇: android shell hello