From d9bd75935391a801c8bfd0db3e729b6c35da258d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Gregorczyk?= Date: Wed, 24 Apr 2024 04:17:16 -0700 Subject: [PATCH] Do not load libraries from base.apk implicitly Summary: Implicit dependency loading needs more work. Reviewed By: adicatana Differential Revision: D56475101 fbshipit-source-id: 5b76a4c1a6bcdff3d4f9c6715377e342755192ca --- ...Loads.java => DirectSplitSoSourceLoadByName.java} | 12 ++++-------- ...ntrol.java => DirectSplitSoSourceLoadByPath.java} | 6 +++--- java/com/facebook/soloader/SoLoader.java | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) rename java/com/facebook/soloader/{DirectSplitSoSourceWithImplicitLoads.java => DirectSplitSoSourceLoadByName.java} (73%) rename java/com/facebook/soloader/{DirectSplitSoSourceWithStrictPathControl.java => DirectSplitSoSourceLoadByPath.java} (85%) diff --git a/java/com/facebook/soloader/DirectSplitSoSourceWithImplicitLoads.java b/java/com/facebook/soloader/DirectSplitSoSourceLoadByName.java similarity index 73% rename from java/com/facebook/soloader/DirectSplitSoSourceWithImplicitLoads.java rename to java/com/facebook/soloader/DirectSplitSoSourceLoadByName.java index 391e401..17f0a1d 100644 --- a/java/com/facebook/soloader/DirectSplitSoSourceWithImplicitLoads.java +++ b/java/com/facebook/soloader/DirectSplitSoSourceLoadByName.java @@ -19,30 +19,26 @@ import android.annotation.SuppressLint; import android.content.Context; -public class DirectSplitSoSourceWithImplicitLoads extends DirectSplitSoSource +public class DirectSplitSoSourceLoadByName extends DirectSplitSoSource implements RecoverableSoSource { - public DirectSplitSoSourceWithImplicitLoads(String splitName) { + public DirectSplitSoSourceLoadByName(String splitName) { super(splitName); } @Override @SuppressLint("MissingSoLoaderLibrary") protected int loadLibraryImpl(String soName, int loadFlags) { - if ((loadFlags & LOAD_FLAG_ALLOW_IMPLICIT_PROVISION) != 0) { - return LOAD_RESULT_IMPLICITLY_PROVIDED; - } - System.loadLibrary(soName.substring(3, soName.length() - 3)); return LOAD_RESULT_LOADED; } @Override public String getName() { - return "DirectSplitSoSourceWithImplicitLoads"; + return "DirectSplitSoSourceLoadByName"; } @Override public SoSource recover(Context context) { - return new DirectSplitSoSourceWithStrictPathControl(mSplitName, mManifest, mLibs); + return new DirectSplitSoSourceLoadByPath(mSplitName, mManifest, mLibs); } } diff --git a/java/com/facebook/soloader/DirectSplitSoSourceWithStrictPathControl.java b/java/com/facebook/soloader/DirectSplitSoSourceLoadByPath.java similarity index 85% rename from java/com/facebook/soloader/DirectSplitSoSourceWithStrictPathControl.java rename to java/com/facebook/soloader/DirectSplitSoSourceLoadByPath.java index 4e112d4..3c15d84 100644 --- a/java/com/facebook/soloader/DirectSplitSoSourceWithStrictPathControl.java +++ b/java/com/facebook/soloader/DirectSplitSoSourceLoadByPath.java @@ -20,8 +20,8 @@ import java.util.Set; import javax.annotation.Nullable; -public class DirectSplitSoSourceWithStrictPathControl extends DirectSplitSoSource { - public DirectSplitSoSourceWithStrictPathControl( +public class DirectSplitSoSourceLoadByPath extends DirectSplitSoSource { + public DirectSplitSoSourceLoadByPath( String splitName, @Nullable Manifest manifest, @Nullable Set libs) { super(splitName, manifest, libs); } @@ -35,6 +35,6 @@ protected int loadLibraryImpl(String soName, int loadFlags) { @Override public String getName() { - return "DirectSplitSoSourceWithStrictPathControl"; + return "DirectSplitSoSourceLoadByPath"; } } diff --git a/java/com/facebook/soloader/SoLoader.java b/java/com/facebook/soloader/SoLoader.java index 22c80e1..8aca9ea 100644 --- a/java/com/facebook/soloader/SoLoader.java +++ b/java/com/facebook/soloader/SoLoader.java @@ -356,7 +356,7 @@ private static void initSoSources(Context context, int flags) throws IOException addSystemLoadWrapperSoSource(context, soSources); } else if (isEnabledBaseApkSplitSource) { addSystemLibSoSource(soSources); - soSources.add(0, new DirectSplitSoSourceWithImplicitLoads("base")); + soSources.add(0, new DirectSplitSoSourceLoadByName("base")); } else { addSystemLibSoSource(soSources);