# Android 5.X与Android4.X版本机器人动画的区别以及制作动画的方法

+关注继续查看

https://source.android.com/devices/tech/ota/device_code

Recovery UI images

Android 5.x

The recovery user interface consists images. Ideally, users never interact with the UI: During a normal update, the phone boots into recovery, fills the installation progress bar, and boots back into the new system without input from the user. In the event of a system update problem, the only user action that can be taken is to call customer care.

An image-only interface obviates the need for localization. However, as of Android 5.x the update can display a string of text (e.g. "Installing system update...") along with the image. For details, see Localized recovery text.

The installing animation is represented as a single PNG image with different frames of the animation interlaced by row (which is why Figure 2 appears squished). For example, for a 200x200 seven-frame animation, create a single 200x1400 image where first frame is rows 0, 7, 14, 21, ...; the second frame is rows 1, 8, 15, 22, ...; etc. The combined image includes a text chunk that indicates the number of animation frames and the number of frames per second (FPS). The tool bootable/recovery/interlace-frames.py takes a set of input frames and combines them into the necessary composite image used by recovery.
efault images are available in different densities and are located inbootable/recovery/res\$DENSITY/images (e.g., bootable/recovery/res-hdpi/images). To use a static image during installation, you need only provide the icon_installing.png image and set the number of frames in the animation to 0 (the error icon is not animated; it is always a static image).

Android 4.x and earlier
The Android 4.x and earlier recovery UI uses the error image (shown above) and the installing animation plus several overlay images:

During installation, the on-screen display is constructed by drawing the icon_installing.png image, then drawing one of the overlay frames on top of it at the proper offset. Here, a red box is superimposed to highlight where the overlay is placed on top of the base image:

Subsequent frames are displayed by drawing only the next overlay image atop what's already there; the base image is not redrawn.

The number of frames in the animation, desired speed, and x- and y-offsets of the overlay relative to the base are set by member variables of the ScreenRecoveryUI class. When using custom images instead of default images, override the Init() method in your subclass to change these values for your custom images (for details, see ScreenRecoveryUI). The script bootable/recovery/make-overlay.py can assist in converting a set of image frames to the "base image + overlay images" form needed by recovery, including computing of the necessary offsets.

Default images are located in bootable/recovery/res/images. To use a static image during installation, you need only provide the icon_installing.png image and set the number of frames in the animation to 0 (the error icon is not animated; it is always a static image).

# 替换recovery动画图片

int res_create_surface(const char* name, gr_surface* pSurface) {
printf("qiushao: res_create_surface: /res/images/%s.png\n", name);
...
int color_type = info_ptr->color_type;
int bit_depth = info_ptr->bit_depth;
int channels = info_ptr->channels;
...
size_t width = info_ptr->width;
size_t height = info_ptr->height;
size_t stride = (color_type == PNG_COLOR_TYPE_GRAY ? 1 : 4) * width;
size_t pixelSize = stride * height;

...

printf("qiushao: color_type = %d\n", color_type);
printf("qiushao: bit_depth = %d\n", bit_depth);
printf("qiushao: channels = %d\n", channels);
printf("qiushao: width = %lu\n", width);
printf("qiushao: height = %lu\n", height);
printf("qiushao: stride = %lu\n", stride);
printf("qiushao: alpha = %d\n", alpha);

unsigned int y;
if (channels == 3 || (channels == 1 && !alpha)) {
printf("qiushao: channels == 3 || (channels == 1 && !alpha)\n");
for (y = 0; y < height; ++y) {
unsigned char* pRow = pData + y * stride;

int x;
for(x = width - 1; x >= 0; x--) {
int sx = x * 3;
int dx = x * 4;
unsigned char r = pRow[sx];
unsigned char g = pRow[sx + 1];
unsigned char b = pRow[sx + 2];
unsigned char a = 0xff;
pRow[dx    ] = r; // r
pRow[dx + 1] = g; // g
pRow[dx + 2] = b; // b
pRow[dx + 3] = a;
}
}
} else {
printf("qiushao: channels != 3 && (channels == 1 && !alpha)\n");
for (y = 0; y < height; ++y) {
unsigned char* pRow = pData + y * stride;
}
}

*pSurface = (gr_surface) surface;

# 替换recovery动画图片

Android View动画和属性动画
Android View动画和属性动画
0 0

0 0
Android自定义控件(三)——贝济埃曲线与水波纹动画

0 0
Android自定义控件(二)——支付宝支付成功动画

0 0
android图片切换ImageSwichter的动画切换效果
android图片切换ImageSwichter的动画切换效果
0 0
Android 带伸缩动画的布局
Android 带伸缩动画的布局
0 0
Android进阶设计 | 使用揭露动画（Reveal Effect）做一个丝滑的Activity转场动画
Android进阶设计 | 使用揭露动画（Reveal Effect）做一个丝滑的Activity转场动画
0 0
Android动画基础详析 | 概述、逐帧动画、视图动画（附诸多实际运行效果动图）
Android动画基础详析 | 概述、逐帧动画、视图动画（附诸多实际运行效果动图）
0 0
Android动画基础详析 | 属性动画基础及ValueAnimator
Android动画基础详析 | 属性动画基础及ValueAnimator
0 0
+关注
morixinguan
ITGEGE在线教育嵌入式开发讲师。 CSDN博客专家、CSDN-Linux特邀编辑、CSDN博乐、CSDN学院讲师，目前从事嵌入式开发领域，从事与单片机，Linux，android相关的产品开发。

Android组件化实现

Android插件化：从入门到放弃