当前位置: 移动技术网 > IT编程>开发语言>Java > android 9.0 收到通知消息亮屏

android 9.0 收到通知消息亮屏

2020年08月14日  | 移动技术网IT编程  | 我要评论
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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网