Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 14 - compact resource entries #3366

Closed
3 tasks done
iBotPeaches opened this issue Oct 4, 2023 · 1 comment · Fixed by #3372
Closed
3 tasks done

Android 14 - compact resource entries #3366

iBotPeaches opened this issue Oct 4, 2023 · 1 comment · Fixed by #3372
Milestone

Comments

@iBotPeaches
Copy link
Owner

iBotPeaches commented Oct 4, 2023

Steps

  • Docs
  • Sample
  • Patch

aosp-mirror/platform_frameworks_base@368cd19



    enum {
        // If set, this is a complex entry, holding a set of name/value
        // mappings.  It is followed by an array of ResTable_map structures.
        FLAG_COMPLEX = 0x0001,
        // If set, this resource has been declared public, so libraries
        // are allowed to reference it.
        FLAG_PUBLIC = 0x0002,
        // If set, this is a weak resource and may be overriden by strong
        // resources of the same name/type. This is only useful during
        // linking with other resource tables.
        FLAG_WEAK = 0x0004,
        // If set, this is a compact entry with data type and value directly
        // encoded in the this entry, see ResTable_entry::compact
        FLAG_COMPACT = 0x0008,
    };
    /* A compact entry is indicated by FLAG_COMPACT, with flags at the same
     * offset as a normal entry. This is only for simple data values where
     *
     * - size for entry or value can be inferred (both being 8 bytes).
     * - key index is encoded in 16-bit
     * - dataType is encoded as the higher 8-bit of flags
     * - data is encoded directly in this entry
     */
    struct Compact {
        uint16_t key;
        uint16_t flags;
        uint32_t data;
    } compact;
@iBotPeaches iBotPeaches changed the title [BUG] Android 14 - compact resource entries Android 14 - compact resource entries Oct 4, 2023
@iBotPeaches iBotPeaches added this to the v2.9.1 milestone Oct 4, 2023
@iBotPeaches
Copy link
Owner Author

➜  Issue3366 git:(master) ✗ ./build.sh                                                                   
note: including /home/ibotpeaches/.local/share/apktool/framework/1.apk.
note: linking package 'com.ibotpeaches.issue3366' using package ID 7f.
note: merging archive compiled.zip.
note: collapsing resource versions for minimum SDK 34.
AndroidManifest.xml: note: writing to archive (keep_raw_values=false).
note: writing AndroidManifest.xml to archive.
note: writing resources.arsc to archive.
➜  Issue3366 git:(master) 
➜  Issue3366 git:(master) ✗ /home/ibotpeaches/Android/Sdk/build-tools/34.0.0/aapt2 d chunks issue3366.apk
[ResTable_header] chunkSize: 552 headerSize: 12 Package count: 1
  [RES_STRING_POOL_TYPE] chunkSize: 44 headerSize: 28
  #0 : Issue3366
  [ResTable_package] chunkSize: 496 headerSize: 288 id: 0x7fname: com.ibotpeaches.issue3366 typeStrings: 288 lastPublicType: 0 keyStrings: 336 lastPublicKey: 0 typeIdOffset: 0
    [RES_STRING_POOL_TYPE] chunkSize: 48 headerSize: 28
    #0 : string
    [RES_STRING_POOL_TYPE] chunkSize: 44 headerSize: 28
    #0 : app_name
    [RES_TABLE_TYPE_SPEC_TYPE] chunkSize: 20 headerSize: 16
    [ResTable_type] chunkSize: 96 headerSize: 84 id: 0x01 name: string flags: 0x02 entryCount: 1 entryStart: 88 config: 
      [ResTable_entry_compact] id: 0x0000 name: app_name keyIndex: 0 size: 8 flags: 0x0308
        [Res_value] size: 8 dataType: 0x03 data: 0x00000000 ("Issue3366")
[End]

issue3366.apk.zip, with source here: iBotPeaches/TestApks@e99f9c3

As expected

➜  Issue3366 git:(master) ✗ apktool d issue3366.apk 
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
I: Using Apktool v2.8.1-85-00c7eeeb-SNAPSHOT on issue3366.apk
I: Loading resource table...
W: Please report this application to Apktool for a fix: https://github.com/iBotPeaches/Apktool/issues/3367
Exception in thread "main" brut.androlib.exceptions.AndrolibException: Unexpected TYPE_FLAG_OFFSET16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant