From 5f3f8e3b33edbe29510330b9fe2a0bd40c0d2e11 Mon Sep 17 00:00:00 2001 From: James Sanford Date: Sat, 3 Nov 2012 12:14:30 -0700 Subject: [PATCH] Better user experience, force filesystem sync before starting. We write a large file to disk and then go to read it back. This was causing a multi second delay in the UI until the data had been flushed to disk. Now, we call sync() before claiming that the assets are ready to be used. --- jni/android_driver.c | 6 ++++++ src/com/froop/app/kegs/AssetImages.java | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/jni/android_driver.c b/jni/android_driver.c index f63f804..5e1b1cd 100644 --- a/jni/android_driver.c +++ b/jni/android_driver.c @@ -262,6 +262,12 @@ void android_config_init(char *output, int maxlen) { (*g_env)->DeleteLocalRef(g_env, config_path); } +JNIEXPORT void JNICALL +Java_com_froop_app_kegs_AssetImages_nativeSync( JNIEnv* env, jobject thiz) { + sync(); + sync(); +} + // Instead of 'KegsView$KegsThread', the $ is encoded as _00024. // (not any more, but it was KegsView_00024KegsThread_mainLoop) JNIEXPORT void JNICALL diff --git a/src/com/froop/app/kegs/AssetImages.java b/src/com/froop/app/kegs/AssetImages.java index a1ae910..dc7a13b 100644 --- a/src/com/froop/app/kegs/AssetImages.java +++ b/src/com/froop/app/kegs/AssetImages.java @@ -46,6 +46,7 @@ class AssetImages extends AsyncTask { mConfigFile.ensureAssetCopied(mConfigFile.getImagePath(), "System 6 Shareware.zip", "System 6.hdv"); // TODO: could check to make sure they actually exist now. + nativeSync(); return true; } @@ -56,4 +57,7 @@ class AssetImages extends AsyncTask { protected void onPostExecute(final Boolean result) { mNotify.onAssetsReady(result); } + + // See jni/android_driver.c:nativeSync() + private native void nativeSync(); }