Android ressource and overlay upload

17
Android resource and overlay study

Transcript of Android ressource and overlay upload

Page 1: Android ressource and overlay   upload

Android resource and overlay study

Page 2: Android ressource and overlay   upload

2

Agenda

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

Page 3: Android ressource and overlay   upload

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

Page 4: Android ressource and overlay   upload

4

Compile resource

Aapt tool is used to compile the resource

Res/values will be compiled into Resources.arsc

Page 5: Android ressource and overlay   upload

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

Page 6: Android ressource and overlay   upload

6

Compile resource

• The structure of every binary xml

Every xml will be compiled into a binary xml

Page 7: Android ressource and overlay   upload

7

Compile resource

• The structure of Resources.arsc

Page 8: Android ressource and overlay   upload

8

Scan package

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

Page 9: Android ressource and overlay   upload

9

Init resource

Only the string pool will be loaded into java layer

Page 10: Android ressource and overlay   upload

10

Resource structure

Page 11: Android ressource and overlay   upload

11

Load resource

Load the best matching resource in APK or overlay APK

Page 12: Android ressource and overlay   upload

12

Overlay mechanism

Static overlayDynamic overlay

Page 13: Android ressource and overlay   upload

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.

Page 14: Android ressource and overlay   upload

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@[email protected]@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.

Page 15: Android ressource and overlay   upload

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.

Page 16: Android ressource and overlay   upload

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.

Page 17: Android ressource and overlay   upload

17

Reference

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

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