Gracefully handle missing directories.
Bug: 10295932 Change-Id: I9d18682d0ba57bf7f77d043ee8dab286ee80ba2a
This commit is contained in:
@@ -175,16 +175,20 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,
|
||||
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
|
||||
|
||||
mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),
|
||||
getFilesDir().getAbsolutePath(), getObbDir().getAbsolutePath(),
|
||||
getExternalFilesDir(null).getAbsolutePath(),
|
||||
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
|
||||
|
||||
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),
|
||||
getAbsolutePath(getExternalFilesDir(null)),
|
||||
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
|
||||
|
||||
if (mNativeHandle == 0) {
|
||||
throw new IllegalArgumentException("Unable to load native library: " + path);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
private static String getAbsolutePath(File file) {
|
||||
return (file != null) ? file.getAbsolutePath() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mDestroyed = true;
|
||||
|
||||
@@ -306,19 +306,23 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName
|
||||
code->internalDataPath = code->internalDataPathObj.string();
|
||||
env->ReleaseStringUTFChars(internalDataDir, dirStr);
|
||||
|
||||
dirStr = env->GetStringUTFChars(externalDataDir, NULL);
|
||||
code->externalDataPathObj = dirStr;
|
||||
if (externalDataDir != NULL) {
|
||||
dirStr = env->GetStringUTFChars(externalDataDir, NULL);
|
||||
code->externalDataPathObj = dirStr;
|
||||
env->ReleaseStringUTFChars(externalDataDir, dirStr);
|
||||
}
|
||||
code->externalDataPath = code->externalDataPathObj.string();
|
||||
env->ReleaseStringUTFChars(externalDataDir, dirStr);
|
||||
|
||||
code->sdkVersion = sdkVersion;
|
||||
|
||||
code->assetManager = assetManagerForJavaObject(env, jAssetMgr);
|
||||
|
||||
dirStr = env->GetStringUTFChars(obbDir, NULL);
|
||||
code->obbPathObj = dirStr;
|
||||
if (obbDir != NULL) {
|
||||
dirStr = env->GetStringUTFChars(obbDir, NULL);
|
||||
code->obbPathObj = dirStr;
|
||||
env->ReleaseStringUTFChars(obbDir, dirStr);
|
||||
}
|
||||
code->obbPath = code->obbPathObj.string();
|
||||
env->ReleaseStringUTFChars(obbDir, dirStr);
|
||||
|
||||
jbyte* rawSavedState = NULL;
|
||||
jsize rawSavedSize = 0;
|
||||
|
||||
Reference in New Issue
Block a user