(@Nullable Context context, int flags)
| 377 | } |
| 378 | |
| 379 | private static void initSoSources(@Nullable Context context, int flags) throws IOException { |
| 380 | if (sSoSources != null) { |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | sSoSourcesLock.writeLock().lock(); |
| 385 | try { |
| 386 | // Double check that sSoSources wasn't initialized while waiting for the lock. |
| 387 | if (sSoSources != null) { |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | sFlags = flags; |
| 392 | |
| 393 | ArrayList<SoSource> soSources = new ArrayList<>(); |
| 394 | final boolean isEnabledSystemLoadWrapper = |
| 395 | (flags & SOLOADER_ENABLE_SYSTEMLOAD_WRAPPER_SOSOURCE) != 0; |
| 396 | final boolean isEnabledBaseApkSplitSource = |
| 397 | (flags & SOLOADER_ENABLE_BASE_APK_SPLIT_SOURCE) != 0; |
| 398 | if (isEnabledSystemLoadWrapper) { |
| 399 | addSystemLoadWrapperSoSource(context, soSources); |
| 400 | } else if (isEnabledBaseApkSplitSource) { |
| 401 | addSystemLibSoSource(soSources); |
| 402 | soSources.add(0, new DirectSplitSoSource("base")); |
| 403 | } else { |
| 404 | addSystemLibSoSource(soSources); |
| 405 | |
| 406 | // We can only proceed forward if we have a Context. The prominent case |
| 407 | // where we don't have a Context is barebones dalvikvm instantiations. In |
| 408 | // that case, the caller is responsible for providing a correct LD_LIBRARY_PATH. |
| 409 | |
| 410 | if (context != null) { |
| 411 | // Prepend our own SoSource for our own DSOs. |
| 412 | |
| 413 | if ((flags & SOLOADER_ENABLE_EXOPACKAGE) != 0) { |
| 414 | // Even for an exopackage, there might be some native libraries |
| 415 | // packaged directly in the application (e.g. ASAN libraries alongside |
| 416 | // a wrap.sh script [1]), so make sure we can load them. |
| 417 | // [1] https://developer.android.com/ndk/guides/wrap-script |
| 418 | addApplicationSoSource(soSources, getApplicationSoSourceFlags()); |
| 419 | LogUtil.d(TAG, "Adding exo package source: " + SO_STORE_NAME_MAIN); |
| 420 | soSources.add(0, new ExoSoSource(context, SO_STORE_NAME_MAIN)); |
| 421 | } else { |
| 422 | if (SysUtil.isSupportedDirectLoad(context, sAppType)) { |
| 423 | addDirectApkSoSource(context, soSources); |
| 424 | } |
| 425 | addApplicationSoSource(soSources, getApplicationSoSourceFlags()); |
| 426 | addBackupSoSource( |
| 427 | context, |
| 428 | soSources, |
| 429 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.N |
| 430 | && (flags & SOLOADER_IMPLICIT_DEPENDENCIES_TEST) != 0); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | SoSource[] finalSoSources = soSources.toArray(new SoSource[soSources.size()]); |
| 436 | int prepareFlags = makePrepareFlags(); |
no test coverage detected