现象就是,客户在开关机测试过程中,有一定的概率出现黑屏, 大约1分钟左右,黑屏后,系统能恢复,自动再进入Launcher,工作正常。

 

反复查看日志后,发现了一条线索。

**** 正常
    01-01 08:00:04.979 D/SurfaceFlinger( 1092): captureScreen: supportWidth = 3840, supportHeight = 2160, maxLayerZ = -1
    01-01 08:00:05.489 D/SurfaceFlinger( 1092): captureScreen: get mCaptureData success !!!!!!!!!!!!!!!!!

**** error
    01-01 08:00:04.799 D/SurfaceFlinger( 1091): captureScreen: supportWidth = 3840, supportHeight = 2160, maxLayerZ = -1
    01-01 08:01:38.859 W/CameraBase( 1091): An error occurred while connecting to camera: 6
    01-01 08:01:38.859 D/SurfaceFlinger( 1091): captureScreen: camera connect fail

出错的时侯, SurfaceFlinger 的 captureScreen 是失败的,而且 卡了大约 30s钟。 于是尝试着加了下面这个patch, 问题就解决了。

 

--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -413,6 +413,8 @@ void SurfaceFlinger::bootFinished()
     // formerly we would just kill the process, but we now ask it to exit so it
     // can choose where to stop the animation.
     property_set("service.bootanim.exit", "1");
+
+    mBootFinished = true;
 }
 
 void SurfaceFlinger::deleteTextureAsync(uint32_t texture) {
@@ -4034,6 +4036,9 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
     if (CC_UNLIKELY(producer == 0))
         return BAD_VALUE;
 
+    if (mBootFinished == false)
+    return NO_ERROR;
+
     // if we have secure windows on this display, never allow the screen capture
     // unless the producer interface is local (i.e.: we can take a screenshot for
     // ourselves).

 

主要原因是:SurfaceFlinger 在初始化结束前,没法正常提供 captureScreen 服务。 因为方案厂商的定制,在启动过程中,会导致某些apk被暂停,而执行captureScreen,或者其它原因,导致captureScreen被调用了。

用户评论:
发表评论: (限500字)

注册 忘记密码 登录