android 9.0 收到通知消息亮屏
程序员文章站
2022-06-22 17:25:24
1.接收到短信亮屏源码位置 :/vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/transaction/MessagingNotification.javaprivate static void updateNotification(...//sOpMessagingNotification.onUpdateNotification(isNew);wakeUpScreen(context);}/...
1.接收到短信亮屏
- 源码位置 :/vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/transaction/MessagingNotification.java
private static void updateNotification(
...
//sOpMessagingNotification.onUpdateNotification(isNew);
wakeUpScreen(context);
}
/**
* M: Wake up screen
* @param context
*/
private static void wakeUpScreen(Context context) {
...
// 去掉在插入耳机的状况下才会唤醒判断
// if (hasInsertedHeadSet || headsetIsOn) {
}
2.收到任何消息都亮屏
- 源码位置:vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
// add Wake up screen
private PowerManager.WakeLock wakeLock;
private void wakeUpScreen() {
if (wakeLock== null){
wakeLock= mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, TAG);
wakeLock.setReferenceCounted(false);
}
if (!mPowerManager.isScreenOn()) {
wakeLock.acquire(3000);
Log.d(TAG, "notification turn screen on");
}
}
}
//end
在addNotificationViews和updateNotificationInternal里面添加如下亮屏请求,当来了一条新通知或者更新一条通知的时候都会走到这两个逻辑
protected void addNotificationViews(NotificationData.Entry entry){
if (entry == null) {
return;
}
// Add the expanded view and icon.
mNotificationData.add(entry);
tagForeground(entry.notification);
updateNotifications();
+ wakeUpScreen();
}
private void updateNotificationInternal(StatusBarNotification notification,
NotificationListenerService.RankingMap ranking) throws InflationException {
...
updateHeadsUp(key, entry, shouldPeek, alertAgain);
updateNotifications();
+ wakeUpScreen(); // add
}
本文地址:https://blog.csdn.net/wxd_csdn_2016/article/details/107978255