-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Add new experiment flag `SOLOADER_ENABLE_SYSTEMLOAD_WRAPPER_SOSOURCE` to test the SystemLoadWrapperSoSource. This flag would help reduce the overhead on reading the APK file. The directApk soSource needs to iterate/read the APK(zip) file to calculate the lib and dependency list. Reviewed By: vener91 Differential Revision: D51493295 fbshipit-source-id: e1cac9e012870eb7386a4e40dec7a5cfcaecdc43
- Loading branch information
1 parent
ae5374a
commit 6984ea7
Showing
2 changed files
with
104 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.facebook.soloader; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.StrictMode; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* A {@link SoSource} that uses the system's {@code System.loadLibrary()} method to load a library | ||
*/ | ||
public class SystemLoadWrapperSoSource extends SoSource { | ||
|
||
@SuppressLint("CatchGeneralException") | ||
@Override | ||
public int loadLibrary(String soName, int loadFlags, StrictMode.ThreadPolicy threadPolicy) | ||
throws IOException { | ||
try { | ||
System.loadLibrary(soName.substring("lib".length(), soName.length() - ".so".length())); | ||
} catch (Exception e) { | ||
LogUtil.e(SoLoader.TAG, "Error loading library: " + soName, e); | ||
return LOAD_RESULT_NOT_FOUND; | ||
} | ||
return LOAD_RESULT_LOADED; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public File unpackLibrary(String soName) throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "SystemLoadWrapperSoSource"; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringBuilder() | ||
.append(getName()) | ||
.append("[") | ||
.append(SysUtil.getClassLoaderLdLoadLibrary()) | ||
.append("]") | ||
.toString(); | ||
} | ||
} |