Skip to content

Commit

Permalink
Support multiple resource tables with same package
Browse files Browse the repository at this point in the history
In order to support APK split features, the resource
table needs to support loading multiple resource
tables with the same package but potentially new set
of type IDs.

This adds some complexity as the type ID space changes
from dense and ordered to potentially sparse.

A ByteBucketArray is used to store the type IDs in
a memory efficient way that allows for fast retrieval.

In addition, the IDMAP format has changed. We no longer
need random access to the type data, since we store the
types differently. However, random access to entries of
a given type is still required.

Change-Id: If6f5be680b405b368941d9c1f2b5d2ddca964160
  • Loading branch information
Adam Lesinski committed Jun 18, 2014
1 parent c802c8c commit f90f2f8
Show file tree
Hide file tree
Showing 32 changed files with 2,940 additions and 1,244 deletions.
2 changes: 1 addition & 1 deletion cmds/idmap/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace {

uint32_t cached_target_crc, cached_overlay_crc;
String8 cached_target_path, cached_overlay_path;
if (!ResTable::getIdmapInfo(buf, N, &cached_target_crc, &cached_overlay_crc,
if (!ResTable::getIdmapInfo(buf, N, NULL, &cached_target_crc, &cached_overlay_crc,
&cached_target_path, &cached_overlay_path)) {
return true;
}
Expand Down
42 changes: 24 additions & 18 deletions cmds/idmap/idmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,32 @@ EXAMPLES \n\
Display an idmap file: \n\
\n\
$ adb shell idmap --inspect /data/resource-cache/vendor@overlay@overlay.apk@idmap \n\
SECTION ENTRY VALUE OFFSET COMMENT \n\
IDMAP HEADER magic 0x706d6469 0x0 \n\
base crc 0x484aa77f 0x1 \n\
overlay crc 0x03c66fa5 0x2 \n\
base path .......... 0x03-0x42 /system/app/target.apk \n\
overlay path .......... 0x43-0x82 /vendor/overlay/overlay.apk \n\
DATA HEADER types count 0x00000003 0x83 \n\
padding 0x00000000 0x84 \n\
type offset 0x00000004 0x85 absolute offset 0x87, xml \n\
type offset 0x00000007 0x86 absolute offset 0x8a, string \n\
DATA BLOCK entry count 0x00000001 0x87 \n\
entry offset 0x00000000 0x88 \n\
entry 0x7f020000 0x89 xml/integer \n\
DATA BLOCK entry count 0x00000002 0x8a \n\
entry offset 0x00000000 0x8b \n\
entry 0x7f030000 0x8c string/str \n\
entry 0x7f030001 0x8d string/str2 \n\
SECTION ENTRY VALUE COMMENT \n\
IDMAP HEADER magic 0x706d6469 \n\
base crc 0xb65a383f \n\
overlay crc 0x7b9675e8 \n\
base path .......... /path/to/target.apk \n\
overlay path .......... /path/to/overlay.apk \n\
DATA HEADER target pkg 0x0000007f \n\
types count 0x00000003 \n\
DATA BLOCK target type 0x00000002 \n\
overlay type 0x00000002 \n\
entry count 0x00000001 \n\
entry offset 0x00000000 \n\
entry 0x00000000 drawable/drawable \n\
DATA BLOCK target type 0x00000003 \n\
overlay type 0x00000003 \n\
entry count 0x00000001 \n\
entry offset 0x00000000 \n\
entry 0x00000000 xml/integer \n\
DATA BLOCK target type 0x00000004 \n\
overlay type 0x00000004 \n\
entry count 0x00000001 \n\
entry offset 0x00000000 \n\
entry 0x00000000 raw/lorem_ipsum \n\
\n\
In this example, the overlay package provides three alternative resource values:\n\
xml/integer, string/str and string/str2.\n\
drawable/drawable, xml/integer, and raw/lorem_ipsum \n\
\n\
NOTES \n\
This tool and its expected invocation from installd is modelled on dexopt.";
Expand Down

0 comments on commit f90f2f8

Please sign in to comment.