tweaselORG / appstraction

An abstraction layer for common instrumentation functions (e.g. installing and starting apps, setting preferences, etc.) on Android and iOS.
MIT License
4 stars 1 forks source link

Android: Also support installing `.apkm` files? #66

Closed baltpeter closed 1 year ago

baltpeter commented 1 year ago

While looking for an .xapk to test #64, I noticed that APKMirror serves split APKs as their own format, .apkm (yay). That used to be some encrypted format but is now also just a ZIP containing the split APKs (https://github.com/illogical-robot/apkmirror-public/issues/119, https://github.com/souramoo/unapkm, https://twitter.com/ArtemR/status/1344427285856751618):

❯ unzip -l com.google.android.youtube_18.14.41-1537084864_3arch_3dpi_15lang_659d725cffe939752cda3644939e0d49_apkmirror.com.apkm
Archive:  com.google.android.youtube_18.14.41-1537084864_3arch_3dpi_15lang_659d725cffe939752cda3644939e0d49_apkmirror.com.apkm
  Length      Date    Time    Name
---------  ---------- -----   ----
     1866  2023-04-14 22:58   META-INF/MANIFEST.MF
     1987  2023-04-14 22:58   META-INF/APKMIRRO.SF
     1442  2023-04-14 22:58   META-INF/APKMIRRO.RSA
      669  2023-04-14 22:58   info.json
     5914  2023-04-14 19:43   icon.png
 23287165  2023-04-14 19:43   base.apk
 18380500  2023-04-14 19:43   split_config.armeabi_v7a.apk
   328089  2023-04-14 19:44   split_config.th.apk
  1949116  2023-04-14 19:44   split_config.xhdpi.apk
  2850175  2023-04-14 22:58   split_config.xxhdpi.apk
   266649  2023-04-14 22:58   split_config.ja.apk
  3181953  2023-04-14 22:58   split_config.xxxhdpi.apk
   254361  2023-04-14 22:58   split_config.de.apk
   348569  2023-04-14 22:58   split_config.hi.apk
 23414399  2023-04-14 22:58   split_config.x86_64.apk
   246169  2023-04-14 22:58   split_config.nl.apk
   237977  2023-04-14 22:58   split_config.in.apk
   307609  2023-04-14 22:58   split_config.ar.apk
   381337  2023-04-14 22:58   split_config.fr.apk
   373145  2023-04-14 22:58   split_config.es.apk
   242073  2023-04-14 22:58   split_config.ms.apk
   250265  2023-04-14 22:58   split_config.it.apk
   303513  2023-04-14 22:58   split_config.ru.apk
   291225  2023-04-14 22:58   split_config.en.apk
   459161  2023-04-14 22:58   split_config.zh.apk
   389529  2023-04-14 22:58   split_config.pt.apk
 23246587  2023-04-14 22:58   split_config.arm64_v8a.apk
       58  2023-04-14 22:58   APKM_installer.url
---------                     -------
101001502                     28 files

Where the info.json looks like this:

{
    "apkm_version": 5,
    "apk_title": "YouTube 18.14.41 (320-640dpi) (Android 8.0+)",
    "app_name": "YouTube",
    "release_version": "18.14.41",
    "variant": "(universal) (320-640dpi) (Android 8.0+)",
    "release_title": "YouTube 18.14.41 (320-640dpi) (Android 8.0+)",
    "versioncode": "1537084864",
    "pname": "com.google.android.youtube",
    "post_date": "2023-04-15 05:57:30",
    "capabilities": [],
    "arches": [
        "arm64-v8a",
        "armeabi-v7a",
        "x86_64"
    ],
    "dpis": [
        "320",
        "480",
        "640"
    ],
    "min_api": "26",
    "accent_color": "ff0000",
    "apk_id": 4675174,
    "release_id": 4675176
}

Apps with .obbs are quite rare and so far I haven't found one that is available on APKMirror (maybe @zner0L has more test cases from #64?), so I don't know whether .apkm files can also contain .obbs.

baltpeter commented 1 year ago

Apps with .obbs are quite rare and so far I haven't found one that is available on APKMirror (maybe @zner0L has more test cases from #64?), so I don't know whether .apkm files can also contain .obbs.

I've found at least one example on an app that should have .obbs but doesn't on APKMirror: com.tencent.ig, version 2.5.0.

APKPure lists that as follows:

image

The first one has a 670 MB main.17325.com.tencent.ig.obb inside.

Meanwhile, on APKMirror, it's a single .apk and only 100 MB.

baltpeter commented 1 year ago

That 100 MB .apk from APKMirror doesn't actually work (unsurprisingly), but I guess that's not really our problem.

Screenshot_20230424-153325_PUBG MOBILE

zner0L commented 1 year ago

I looked at some of my test cases and it seems like APKMirror simply doesn't host apps that rely on .obbs. So it's save to say the .apkm format only contains the split apks.

zner0L commented 1 year ago

Since the issue (https://github.com/illogical-robot/apkmirror-public/issues/119) already mentioned the .apks format of https://github.com/Aefyr/SAI is very similar I took a quick look at it and it is basically the same format. That's great because we get support of those basically for free.

The .apks are basically also a zip file with a slightly different meta format (which is even documented). It only contains the split apks and no .obbs, as the app states itself:

Screenshot_20230503-163257_SAI

I "backuped" the Google Play apk, which looks like this extracted:

❯ unzip -l Google\ Play\ Store_com,android,vending_35,5,16-21\ \[0\]\ \[PR\]\ 527633611.apks
Archive:  Google Play Store_com,android,vending_35,5,16-21 [0] [PR] 527633611.apks
  Length      Date    Time    Name
---------  ---------- -----   ----
      287  05-03-2023 16:33   meta.sai_v2.json
      165  05-03-2023 16:33   meta.sai_v1.json
     8556  05-03-2023 16:33   icon.png
 42892012  05-03-2023 16:33   base.apk
  6902524  05-03-2023 16:33   split_config.arm64_v8a.apk
   434585  05-03-2023 16:33   split_config.en.apk
    16733  05-03-2023 16:33   split_phonesky_data_loader.apk
    86451  05-03-2023 16:33   split_phonesky_data_loader.config.arm64_v8a.apk
---------                     -------
 50341313                     8 files