android ressource and overlay upload

Post on 12-Apr-2017

147 Views

Category:

Engineering

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Android resource and overlay study

2

Agenda

• Compile resource.• Init resource.• Load resource.• Overlay mechanism.

3

What is resource in Android

Android resources makes it easy to update various characteristics of your application without modifying code.

Resource typeAssetsRes

Animator Anim Color Drawable Layout Menu Raw Values xml

4

Compile resource

Aapt tool is used to compile the resource

Res/values will be compiled into Resources.arsc

5

Compile resource

• No modification The resource files under assets and res/raw. The Bitmap files under drawable directory.(*.png,*.bmp,*.jpg)• Every resource(excepts assets) will be assigned a

identical ID.• Resources.arsc is created to store the resource

index.• R.java is created to store the resource ID constant.• Other xml files(includes of AndroidManifests.xml)

will be compiled into binary xml file.

Every resource(excepts assets) will be assigned a identical ID

6

Compile resource

• The structure of every binary xml

Every xml will be compiled into a binary xml

7

Compile resource

• The structure of Resources.arsc

8

Scan package

A Idmap file will be created if it is a overlay package

9

Init resource

Only the string pool will be loaded into java layer

10

Resource structure

11

Load resource

Load the best matching resource in APK or overlay APK

12

Overlay mechanism

Static overlayDynamic overlay

13

Overlay mechanism - Static overlayOverlay resource is placed under device/intel/***

PRODUCT_PACKAGE_OVERLAYS := DEVICE_PACKAGE_OVERLAYS :=

The overlay directory list will be used by the aapt tool.

14

Overlay mechanism - Dynamic overlay Create the pure overlay package using AAPT with the –o argument. <overlay targetPackage="com.target.package" priority="1234"/>

A idmap file of every overlay apk is created when it is scanned. The idmap file is used to map the resId original package in to the resId in overlay apk. It is stored under "/data/resource-cache/“ and named @vendor@intel@overlay@settings@settings.apk@idmap. ( vendor/intel/overlay/settings/settings.apk)

Load the idmap into Header in ResTable when the resource is loaded. two variable is added in Header for idmap. resourceIDMap resourceIDMapSize

Query the resource id from all packages according to the priority below. High priority overlay apk -> low priority overlay apk -> original apk

It only can be used to replace the existing resource but no can be used to add a new resource.

15

Conclusion

Dynamic overlay is used to change the existing resource without compilation.

It is not suitable for our requirement, Don’t port the patch of Sony from Google.

16

Conclusion

static overlay. How to resolve the compile issue when we do

pdk rebase.(Some new resource is added in aosp) Keep AOSP clean and add all new resources into overlay directory. Add a argument named when we use AAPT tool.

LOCAL_AAPT_FLAGS += --auto-add-overlay

How to enable overlay directory in different platform(ARM and emulator)

Add DEVICE_PACKAGE_OVERLAYS in the mk for platform Add the resource into overlay dir.

17

Reference

https://android-review.googlesource.com/#/c/46739/

http://developer.android.com/reference/android/content/res/Resources.html

top related