这个问题是由于原生系统设计上存在缺陷。在 NotificationManagerService.java 中,处理通知发布时,有个函数
int buzzBeepBlinkLocked(NotificationRecord record)
此函数会检测通知是否能发出提示音或振动。
if (hasAudibleAlert && !shouldMuteNotificationLocked(record)) {if (!sentAccessibilityEvent) {sendAccessibilityEvent(notification, Sbn().getPackageName());sentAccessibilityEvent = true;}if (DBG) Slog.v(TAG, "Interrupting!");if (hasValidSound) {if (isInCall()) {playInCallNotification();beep = true;} else {// 播放通知音beep = playSound(record, soundUri);}if(beep) {mSoundNotificationKey = key;}}
出现问题时,shouldMuteNotificationLocked 判断异常,无法进入播放提示音。
boolean shouldMuteNotificationLocked(final NotificationRecord record) {... ...// muted by listenerfinal String disableEffects = disableNotificationEffects(record);if (disableEffects != null) {aceDisableEffects(record, disableEffects);return true;}
跟踪代码,disableNotificationEffects 返回不为空,这个函数中设置了几种情况,每种不同的禁止提示音的,对应返回不同的字符串。
private String disableNotificationEffects(NotificationRecord record) {if (mDisableNotificationEffects) {return "booleanState";}if ((mListenerHints & HINT_HOST_DISABLE_EFFECTS) != 0) {return "listenerHints";}if (record != null && AudioAttributes() != null) {if ((mListenerHints & HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0) {if (AudioAttributes().getUsage()!= AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {return "listenerNoti";}}if ((mListenerHints & HINT_HOST_DISABLE_CALL_EFFECTS) != 0) {if (AudioAttributes().getUsage()== AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {return "listenerCall";}}}if (mCallState != TelephonyManager.CALL_STATE_IDLE && !mZenModeHelper.isCall(record)) {return "callState";}return null; };
第一次开机无声,就是由于这里的 mDisableNotificationEffects 值不对,被禁止。这个值在NMS服务初始化时有个判断如下。
if (0 == Int(getContext().getContentResolver(),Settings.Global.DEVICE_PROVISIONED, 0)) {mDisableNotificationEffects = true; }
DEVICE_PROVISIONED 这个属性值是开机向导里面会去设置的,但是我们这个NMS系统服务会先于开机向导启动,所以 mDisableNotificationEffects 默认就被置为true了,导致第一次开机无声。
本文发布于:2024-02-02 04:59:33,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170682117441505.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |