@Override Collection<Path> getAllAssetDirs() { ArrayList<Path> paths = new ArrayList<>(); for (AssetPath assetPath : cppAssetManager.getAssetPaths()) { if (Files.isRegularFile(assetPath.file)) { paths.add(Fs.forJar(assetPath.file).getPath("assets")); } else { paths.add(assetPath.file); } } return paths; }
public static FileSystem forJar(URL url) { return forJar(Paths.get(toUri(url))); }
@Nonnull private ResourcePath createRuntimeSdkResourcePath() { try { FileSystem zipFs = Fs.forJar(sdk.getJarPath()); Class<?> androidRClass = getRobolectricClassLoader().loadClass("android.R"); Class<?> androidInternalRClass = getRobolectricClassLoader().loadClass("com.android.internal.R"); // TODO: verify these can be loaded via raw-res path return new ResourcePath( androidRClass, zipFs.getPath("raw-res/res"), zipFs.getPath("raw-res/assets"), androidInternalRClass); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
@Override Collection<Path> getAllAssetDirs() { ApkAssets[] apkAssetsArray = reflector(_AssetManager28_.class, realAssetManager).getApkAssets(); ArrayList<Path> assetDirs = new ArrayList<>(); for (ApkAssets apkAssets : apkAssetsArray) { long apk_assets_native_ptr = ((ShadowArscApkAssets9) Shadow.extract(apkAssets)).getNativePtr(); CppApkAssets cppApkAssets = Registries.NATIVE_APK_ASSETS_REGISTRY.getNativeObject(apk_assets_native_ptr); if (new File(cppApkAssets.GetPath()).isFile()) { assetDirs.add(Fs.forJar(Paths.get(cppApkAssets.GetPath())).getPath("assets")); } else { assetDirs.add(Paths.get(cppApkAssets.GetPath())); } } return assetDirs; }