android4.0 休眠唤醒会出现之前界面

android4.0 休眠唤醒会出现之前界面,我们通过桌面远程工具可以看到在休眠时候,系统已经进入解锁界面。可是我们唤醒机器的时候,系统会闪一下之前操作的界面,再进入解锁界面。所以判断应该是休眠时候没有把解锁界面写入framebuffer,找到写framebuffer地方:

if (LIKELY(hw.canDraw())) {
        // repaint the framebuffer (if needed)

        const int index = hw.getCurrentBufferIndex();
        GraphicLog& logger(GraphicLog::getInstance());

        logger.log(GraphicLog::SF_REPAINT, index);
        handleRepaint();

        // inform the h/w that we're done compositing
        logger.log(GraphicLog::SF_COMPOSITION_COMPLETE, index);
        hw.compositionComplete();

        logger.log(GraphicLog::SF_SWAP_BUFFERS, index);
        postFramebuffer();

        logger.log(GraphicLog::SF_REPAINT_DONE, index);
    } else {
        // pretend we did the post
        hw.compositionComplete();
        usleep(16667); // 60 fps period
    }

可以看到,是根据hw.canDraw()函数的返回值跳到不同的入口,再找到hw.canDraw()函数的实现:

bool DisplayHardwareBase::canDraw() const
{
    return mScreenAcquired;
}

所以把操作mScreenAcquired的值的相关代码去掉就可以了:

--- a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
@@ -80,11 +80,13 @@ bool DisplayHardwareBase::DisplayEventThread::threadLoop()
     if (err >= 0) {
         sp<SurfaceFlinger> flinger = mFlinger.promote();
         LOGD("About to give-up screen, flinger = %p", flinger.get());
+        /*
         if (flinger != 0) {
             mBarrier.close();
             flinger->screenReleased(0);
             mBarrier.wait();
         }
+        */
     }
     fd = open(kWakeFileName, O_RDONLY, 0);
     do {
@@ -95,8 +97,10 @@ bool DisplayHardwareBase::DisplayEventThread::threadLoop()
     if (err >= 0) {
         sp<SurfaceFlinger> flinger = mFlinger.promote();
         LOGD("Screen about to return, flinger = %p", flinger.get());
+        /*
         if (flinger != 0)
             flinger->screenAcquired(0);
+        */
     }
     return true;
 }

你可能感兴趣的:(android4.0 休眠唤醒会出现之前界面)