Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1385263
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4833
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2016-05-31 13:40:10

写在前面:

    若能直译,不会意译,意译不成,为了选择不误导他人也会漏译无伤大雅的部分,英语是硬伤,如果有误译,请路过的朋友帮忙指正,以免误导更多的朋友。


    RecoveryUI除了之前提到的标题、选项菜单、提示性文字还有另外的一个重要的成员图片。在正常的更新过程中,用户看到的仅仅是图片(这里指的标准的OTA升级流程,如开机进入recovery模式、安装更新时进度条发生变化,最后再开机进入正常模式),而且在这个过程,用户是没有机会与RecoveryUI进行交互的。但是一旦在更新过程中出现了异常,用户所能做的就是打个电话给售后了。

    在Android5.x的更新过程中我们是可以看到文字信息的(例如,Installing system update...),只是这些文字信息依旧是用图片来展示的。详细信息请移步下面的Localized recovery text.

Android5.x

    在Android5.xRecoveryUI中主要使用两种类型的图片:错误型图片和安装型图片,如下:



1. icon_error.png


2. icon_installing.png

 

    我们看到的安装更新的动画其实是一个PNG图片和帧动画组成的。我们可以使用bootable/recovery/interlace-frames.py来进行合成。

    默认情况下图片的显示是支持不同分辨率的,如bootable/reovery/res-$DENSITY/images(bootable/recovery/res-hdpi/images)。有点类似于我们编写apk中的图片资源通过不同目录来支持不同的分辨率。如果在安装更新的过程中我们只需要展示一个静态的图片,我们只需要提供一张静态的图片然后设置animation的帧为0即可。此外错误型图片一般来说不是以动画的方式来展示的, 仅仅是一个静态图片。

Android4.x和早期的版本

    下面这组图片大家是很熟悉的,在Android4.x及其早起的版本同样是使用两种类型的图片:错误型和安装型。

 



3. icon_installing.png



4. icon-installing_overlay01.png



5. icon_installing_overlay07.png

 

    从上面的几张图片中我们可以知道在安装过程中我们所看到的动画其实是由上面的图片叠加合成的,如下:


 

6. Installing animation frame 1 (icon_installing.png + icon_installing_overlay01.png)



7. Installing animation frame 7 (icon_installing.png + icon_installing_overlay07.png)

 

上面的图片我们可以使用bootable/recovery/make-overlay.py来实现这种效果。

 

这些图片默认存放的位置在bootable/recovery/res/images

 

Recovery本地化文本显示

 

Recovery本地化文本显示指的就是根据不同用户所使用的语言环境显示文本,例如英文环境下系统更新的提示语是”Installing system update...”,中文环境下为”正在安装系统更新...”.

Android5.x中文本是通过图片的方式来展示的。当设备启动进入recovery模式的时候,户当前的语言环境或作为命令行参数传递给recovery系统。不同区域语言环境都有对应的文本描述图片。例如:


8. Localized text for recovery messages

 

    在recovery模式下可以显示下面这些信息:


  • l Installing system update...
  • l Error!
  • l Erasing...(When doing a data wipe/factory reset)
  • l No command (when a user boots into recovery manually)


    我们可以使用development/tools/recovery_110/目录下的应用程序来合成这些图片。如果想了解如何使用此App,可以参考development/tools/recovery_110n/src/com/android/recovery_110n/Main.。

    当用户手动进入recovery模式是,这些文本可能是不可见的,此外请不要使用敏感词汇。

 

进度条

    在recovery模式下我们所看到的进度条实际上是有两个相同尺寸的图片合成的,如下:

9. progress_empty.png


10. progress_fill.png

 

Figure 11. Progress bar at 1%>


Figure 12. Progress bar at 10%


Figure 13. Progress bar at 50%

 

    这些图片存放在device/yoyodyne/tardis/recovery/res/iamges目录下。

 

无显示设备

    并不是所有的设备都有显示屏幕的。那么此时我们就需要开展大量的定制工作,不再仅仅是创建ScreenRecoveryUI,我们可以直接继承RecoveryUI来实现相关的功能。

    我们可以通过查看bootable/recovery/ui.h来查看RecoveryUI中的声明来确定自己那些函数是必须支持的。RecoveryUI是一个抽象类,一些函数是抽象函数,在使用相关功能的过程中我们必须药实现这些抽象函数。关于一些按键相关的已经实现了的函数,我们可以通过复写来实现定制,例如我们的设备没有那么多的按键等等。


原文如下:


Recovery UI images



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.

Android 5.x

The Android 5.x recovery UI uses two main images: the error image and the installing animation.

image shown during ota error

Figure 1. icon_error.png

image shown during ota install

Figure 2. icon_installing.png

The installing animation is represented as a single PNG image with different frames of the animation interlaced by row. For example, for a 7-frame animation that is 200x200, 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. The tool bootable/recovery/interlace-frames.py takes a set of input frames and combines them into the necessary composite image used by recovery.

Default images are available in different densities and are located in bootable/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:

image shown during ota install

Figure 3. icon_installing.png

image shown as firstoverlay

Figure 4. icon-installing_overlay01.png

image shown as seventhoverlay

Figure 5. icon_installing_overlay07.png

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:

composite image ofinstall plus first overlay

Figure 6. Installing animation frame 1 (icon_installing.png + icon_installing_overlay01.png)

composite image ofinstall plus seventh overlay

Figure 7. Installing animation frame 7 (icon_installing.png + icon_installing_overlay07.png)

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, seeScreenRecoveryUI). 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).

Localized recovery text

Android 5.x displays a string of text (e.g., "Installing system update...") along with the image. When the main system boots into recovery it passes the user's current locale as a command-line option to recovery. For each message to display, recovery includes a second composite image with pre-rendered text strings for that message in each locale.

Sample image of recovery text strings:

image of recovery text

Figure 8. Localized text for recovery messages

Recovery text can display the following messages:

  • Installing system update...
  • Error!
  • Erasing... (when doing a data wipe/factory reset)
  • No command (when a user boots into recovery manually)

The Android app in development/tools/recovery_l10/ renders localizations of a message and creates the composite image. For details on using this app, refer to the comments in development/tools/recovery_l10n/ src/com/android/recovery_l10n/Main.java.

When a user boots into recovery manually, the locale might not be available and no text is displayed. Do not make the text messages critical to the recovery process.

Note: The hidden interface that displays log messages and allows the user to select actions from the menu is available only in English.

Progress bars


Progress bars can appear below the main image (or animation). The progress bar is made by combining two input images, which must be of the same size:

empty progress bar

Figure 9. progress_empty.png

full progress bar

Figure 10. progress_fill.png

The left end of the fill image is displayed next to the right end of the empty image to make the progress bar. The position of the boundary between the two images is changed to indicate the progress. For example, with the above pairs of input images, display:

progress bar at 1%

Figure 11. Progress bar at 1%>

progress bar at 10%

Figure 12. Progress bar at 10%

progress bar at 50%

Figure 13. Progress bar at 50%

You can provide device-specific versions of these images by placing them into (in this example)device/yoyodyne/tardis/recovery/res/images . Filenames must match the ones listed above; when a file is found in that directory, the build system uses it in preference to the corresponding default image. Only PNGs in RGB or RGBA format with 8-bit color depth are supported.

Note: In Android 5.x, if the locale is known to recovery and is a right-to-left (RTL) language (Arabic, Hebrew, etc.), the progress bar fills from right to left.

Devices without screens


Not all Android devices have screens. If your device is a headless appliance or has an audio-only interface, you may need to do more extensive customization of recovery UI. Instead of creating a subclass of ScreenRecoveryUI, subclass its parent class RecoveryUI directly.

RecoveryUI has methods for handling a lower-level UI operations such as "toggle the display," "update the progress bar," "show the menu," "change the menu selection," etc. You can override these to provide an appropriate interface for your device. Maybe your device has LEDs where you can use different colors or patterns of flashing to indicate state, or maybe you can play audio. (Perhaps you don't want to support a menu or the "text display" mode at all; you can prevent accessing them with CheckKey() and HandleMenuKey() implementations that never toggle the display on or select a menu item. In this case, many of the RecoveryUI methods you need to provide can just be empty stubs.)

See bootable/recovery/ui.h for the declaration of RecoveryUI to see what methods you must support. RecoveryUI is abstract—some methods are pure virtual and must be provided by subclasses—but it does contain the code to do processing of key inputs. You can override that too, if your device doesn't have keys or you want to process them differently.


阅读(1064) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~