You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
AssetManager: fix open and openNonAsset not throwing exception on error
This commit is contained in:
@@ -24,7 +24,7 @@ JNIEXPORT jlong JNICALL Java_android_content_res_AssetManager_openAsset(JNIEnv *
|
|||||||
|
|
||||||
struct AssetManager *asset_manager = _PTR(_GET_LONG_FIELD(this, "mObject"));
|
struct AssetManager *asset_manager = _PTR(_GET_LONG_FIELD(this, "mObject"));
|
||||||
struct Asset *asset = AssetManager_openNonAsset(asset_manager, file_name, mode);
|
struct Asset *asset = AssetManager_openNonAsset(asset_manager, file_name, mode);
|
||||||
printf("AssetManager_openAsset(%p, %s, %d)\n", asset_manager, file_name, mode);
|
printf("AssetManager_openAsset(%p, %s, %d) returns %p\n", asset_manager, file_name, mode, asset);
|
||||||
|
|
||||||
return _INTPTR(asset);
|
return _INTPTR(asset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,6 +311,8 @@ public final class AssetManager {
|
|||||||
*/
|
*/
|
||||||
public final InputStream open(String fileName, int accessMode) throws IOException {
|
public final InputStream open(String fileName, int accessMode) throws IOException {
|
||||||
long asset = openAsset("assets/" + fileName, accessMode);
|
long asset = openAsset("assets/" + fileName, accessMode);
|
||||||
|
if(asset == 0)
|
||||||
|
throw new FileNotFoundException("file: " + fileName);
|
||||||
return new AssetInputStream(asset);
|
return new AssetInputStream(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +384,8 @@ public final class AssetManager {
|
|||||||
*/
|
*/
|
||||||
public final InputStream openNonAsset(int cookie, String fileName, int accessMode) throws IOException {
|
public final InputStream openNonAsset(int cookie, String fileName, int accessMode) throws IOException {
|
||||||
long asset = openAsset(fileName, accessMode);
|
long asset = openAsset(fileName, accessMode);
|
||||||
|
if(asset == 0)
|
||||||
|
throw new FileNotFoundException("file: " + fileName);
|
||||||
return new AssetInputStream(asset);
|
return new AssetInputStream(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user