Commit 3365abc9 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Allow overriding library resolution in feed v2

This should fix the crash seen with isolated splits. Isolated split
class loaders are not able to load native libraries due to
b/b/171269960, so the paths must be resolved manually. This will have a
corresponding change in the internal repo.

Bug: 1143321
Change-Id: I58f4e496417248ad38b388a4e45fafb3843226bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2515439
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823666}
parent f7b93e95
......@@ -216,10 +216,16 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
implements ProcessScopeDependencyProvider {
private Context mContext;
private ImageFetchClient mImageFetchClient;
private LibraryResolver mLibraryResolver;
FeedProcessScopeDependencyProvider() {
mContext = createFeedContext(ContextUtils.getApplicationContext());
mImageFetchClient = new FeedImageFetchClient();
if (BundleUtils.isIsolatedSplitInstalled(mContext, FEED_SPLIT_NAME)) {
mLibraryResolver = (libName) -> {
return BundleUtils.getNativeLibraryPath(libName);
};
}
}
@Override
......@@ -283,6 +289,11 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
}
PostTask.postDelayedTask(traits, task, delayMs);
}
@Override
public LibraryResolver getLibraryResolver() {
return mLibraryResolver;
}
}
/**
......
......@@ -12,6 +12,14 @@ import androidx.annotation.Nullable;
* Provides application-level dependencies for an external surface.
*/
public interface ProcessScopeDependencyProvider {
/**
* Resolves a library name such as "foo" to an absolute path. The library name should be in the
* same format given to System.loadLibrary().
*/
public interface LibraryResolver {
String resolvePath(String libName);
}
/** @return the context associated with the application. */
@Nullable
default Context getContext() {
......@@ -63,4 +71,13 @@ public interface ProcessScopeDependencyProvider {
* @param delayMs The delay before executing the task in milliseconds.
*/
default void postTask(int taskType, Runnable task, long delayMs) {}
/**
* Returns a LibraryResolver to be used for resolving native library paths. If null is
* returned, the default library loading mechanism should be used.
*/
@Nullable
default LibraryResolver getLibraryResolver() {
return null;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment