平板关机动画显示异常

  由于平板的界面可以自由的旋转,假设默认的lcd是横屏的,旋转到竖屏时,关机动画会先切换到横屏,

然后显示动画。出现了一瞬间界面只有一半的情况,这可能是Android本身的bug。这里的解决方法是当竖

屏的时候,不要切换到横屏显示动画,直接竖屏刷图(并将横屏时的图片旋转90进行显示)。


相应的修改如下  

Index: vendor/qcom/proprietary/qrdplus/Extension/apps/PowerOffHandler/PowerOffHandler.cpp
===================================================================
--- vendor/qcom/proprietary/qrdplus/Extension/apps/PowerOffHandler/PowerOffHandler.cpp	(revision 103)
+++ vendor/qcom/proprietary/qrdplus/Extension/apps/PowerOffHandler/PowerOffHandler.cpp	(working copy)
@@ -22,7 +22,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+//http://blog.csdn.net/baidu_31872269/article/details/53229342
+//http://blog.csdn.net/beibei_hao_csdn/article/details/53259814
 #define LOG_NDEBUG 0
 #define LOG_TAG "PowerOffHandler"
 
@@ -209,6 +210,56 @@
     return NO_ERROR;
 }
 
+
+// 顺时针 90 度
+static int RotationRight90(unsigned char * src, int srcW, int srcH, int channel)
+{
+	int i = 0;
+	int j = 0;
+	int k = 0;
+	unsigned char * tempSrc = NULL;
+	int mSize = srcW * srcH  * channel;
+	tempSrc = (unsigned char *)malloc(sizeof(char) * srcW * srcH * channel);
+	memcpy(tempSrc, src, mSize);
+	for(i = 0; i <=srcH-1 ; i ++)
+	{
+		for(j = 0; j < srcW; j ++)
+		{
+			for(k = 0; k < channel; k ++)
+			{
+				src[((j) * srcH + (srcH - 1 - i)) * channel + k]=tempSrc[(i * srcW + j) * channel + k];
+			}
+		}
+	}
+	free(tempSrc);
+   	return 0;
+}
+
+
+// 逆时针90度
+int RotationLeft90(unsigned char * src, int srcW, int srcH, int channel)
+{
+	int i = 0;
+	int j = 0;
+	int k = 0;
+	unsigned char * tempSrc = NULL;
+	int mSize = srcW * srcH  * channel;
+	tempSrc = (unsigned char *)malloc(sizeof(char) * srcW * srcH * channel);
+	memcpy(tempSrc, src, mSize);
+	for(i = srcH - 1; i >= 0; i --)
+	{
+		for(j = 0; j < srcW; j ++)
+		{
+			for(k = 0; k < channel; k ++)
+			{
+				src[((srcW-1-j)*srcH + i)* channel + k] =  tempSrc[(i * srcW + j) * channel + k];
+			}
+		}
+	}
+    return 0;
+}
+
+
 status_t PowerOffHandler::initTexture(const Animation::Frame& frame) {
     SkBitmap bitmap;
     SkMemoryStream stream(frame.map->getDataPtr(), frame.map->getDataLength());
@@ -229,9 +280,20 @@
     // bitmap will go out of scope when we return from this method.
     bitmap.lockPixels();
 
-    const int w = bitmap.width();
-    const int h = bitmap.height();
+    int w = bitmap.width();
+    int h = bitmap.height();
     const void* p = bitmap.getPixels();
+    if((screenstatus==1)||(screenstatus==3))
+    {
+    	if(screenstatus==1)
+		RotationLeft90((unsigned char *)p,w,h,4);
+    	if(screenstatus==3)
+    		RotationRight90((unsigned char *)p,w,h,4);
+	int tmp;
+    	tmp=w;
+    	w=h;
+    	h=tmp;
+    }
 
     GLint crop[4] = { 0, h, w, -h };
     int tw = 1 << (31 - __builtin_clz(w));
@@ -270,7 +332,6 @@
     }
 
     glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
-
     return NO_ERROR;
 }
 
@@ -289,13 +350,18 @@
     char value[PROPERTY_VALUE_MAX];
     property_get("persist.panel.orientation", value, "0");
     int orient = atoi(value) / 90;
-    if (orient == eOrientation90 || orient == eOrientation270) {
+    //if (orient == eOrientation90 || orient == eOrientation270) {
+    if((dinfo.orientation==1)||(dinfo.orientation==3)){
         int temp = dinfo.h;
         dinfo.h = dinfo.w;
         dinfo.w = temp;
+	screenstatus=dinfo.orientation;
     }
+
     Rect destRect(dinfo.w, dinfo.h);
-    mSession->setDisplayProjection(dtoken, orient, destRect, destRect);
+    if((dinfo.orientation==0)||(dinfo.orientation==2)){
+   	 mSession->setDisplayProjection(dtoken, orient, destRect, destRect);
+    }
     // create the native surface
     sp < SurfaceControl > control = session()->createSurface(
             String8("BootAnimation"), dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
@@ -344,7 +410,6 @@
     // instead of system predefined boot animation files.
     bool encryptedAnimation = atoi(decrypt) != 0
             || !strcmp("trigger_restart_min_framework", decrypt);
-
     ZipFileRO* zipFile = NULL;
     if ((encryptedAnimation
             && (access(getShutDownAnimationFileName(IMG_ENC), R_OK) == 0)
@@ -465,8 +530,16 @@
         char pathType;
         if (sscanf(l, "%d %d %d", &width, &height, &fps) == 3) {
             // ALOGD("> w=%d, h=%d, fps=%d", width, height, fps);
-            animation.width = width;
-            animation.height = height;
+	    if((screenstatus==1)||(screenstatus==3))
+	    {
+		animation.width = height;
+            	animation.height = width;
+	    }
+	    else
+	    {
+            	animation.width = width;
+            	animation.height = height;
+	    }
             animation.fps = fps;
         } else if (sscanf(l, " %c %d %d %s #%6s", &pathType, &count, &pause,
                 path, color) >= 4) {


  另外如果关机的过程中,转动屏幕,界面也会相应的翻转过来,这里只需要不响应重力传感器的动作即可。
frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
找到updateRotationUncheckedLocked方法,加上

if(SystemService.isRunning("poweroffhandler")) {
                 return false;
        }
这里的关机服务是poweroffhandler,有的是bootanim,注意修改。


猜你喜欢

转载自blog.csdn.net/mike8825/article/details/78973440