目录
Rahul Dandamudi

Compress native libs and support direct-boot extraction

Summary: Clawmagotchi ships 38.58 MiB of native libraries. Deflating all 103 lib/**/*.so entries reduces the release ingestion artifact from 51.03 MiB to 28.85 MiB, a 43.5% reduction.

This change:

  • removes uncompress_libs_postprocessor;
  • sets mos_default_native_config = False, because compressed libraries cannot use MOS direct loading;
  • keeps enable_libalign = True so the ingestion alias still selects the signed, postprocessed artifact; and
  • opts Clawmagotchi into SoLoader’s backup source.

Clawmagotchi is a preinstalled, direct-boot-aware HOME app. It is not installed under /data/app, and the wearable application framework normally disables the SoLoader backup source for system apps. Without the explicit opt-in, the process cannot load its compressed JNI libraries.

The SoLoader behavior is isolated behind a new opt-in flag. When enabled, SoLoader constructs BackupSoSource with an explicit store path under the device-protected context. A package-private BackupSoSource overload accepts that path and preserves it during recovery. Existing constructors and UnpackingSoSource path selection are unchanged, so other apps retain their current extraction behavior.

The opt-in also enables SOLOADER_ALLOW_ASYNC_INIT. Library extraction remains complete before SoLoader.init() returns, while the expensive fsync and clean-state write finish on SoLoader’s background sync thread.

The AOSP counterpart is D120455457. It opts this non-GMS product prebuilt out of the presigned-preprocessed check that otherwise rejects compressed JNI. The first compressed prebuilt and that AOSP flag must be integrated together:

Prebuilt Skip flag Result
Uncompressed Absent Pass
Uncompressed Present Fail as unnecessary
Compressed Absent Fail for compressed JNI
Compressed Present Pass

The storage tradeoff is intentional. The release APK saves about 22.18 MiB in the image and in distribution, while the extracted native cache occupies 38.80 MiB in userdata. The benefit is image and download size, not total device storage.

Coop-docs: no change (internal packaging and native-library loading; no observable screen, navigation, capability, content-description, or logging behavior).

Reviewed By: akashkalimiliMeta

Differential Revision: D120355062

fbshipit-source-id: b0dde2d11fec5b2e8d702c0f79cb5d85ecbc1d94

1个月前561次提交

SoLoader

Build CI License Maven Central

SoLoader is a native code loader for Android. It takes care of unpacking your native libraries and recursively loads dependencies on Android API 23 and earlier, since those old OS versions do not support all of that functionality out of box.

Requirements

SoLoader is useful for applications running on Android API 23 and earlier. SoLoader should not be used on Android API 24 and above unless the app is delivered as Exopackage, requires Android Native Library Merging or uses Superpack compression.

Including SoLoader in your apps

You can use prebuilt aars or fetch SoLoader from Maven repository by adding the following to your build.gradle file:

implementation 'com.facebook.soloader:soloader:0.13.0+'

Building from source

To build SoLoader from source you’ll need Buck. Once you have Buck installed execute following commands from the project root directory:

  buck fetch //...
  buck build :soloader

The build command generates buck-out/gen/soloader.aar file.

Join our community

Please use our issues page to let us know of any problems. See the CONTRIBUTING file for how to help out.

License

SoLoader is Apache-2.0-licensed.

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号