From 3f4be750248b5e163297cd34958077eb872b10f4 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 17 Apr 2012 07:25:20 +0200 Subject: android: Bring back broken unzip progress dialog. Change-Id: I7c788f4fcbdf15aa4955f3970db045b47207f8de --- android/src/org/rockbox/RockboxActivity.java | 10 +++++++--- android/src/org/rockbox/RockboxService.java | 23 +++++++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'android') diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index 166d69ebe0..0e2daa76fb 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java @@ -45,8 +45,8 @@ public class RockboxActivity extends Activity Intent intent = new Intent(this, RockboxService.class); intent.setAction(Intent.ACTION_MAIN); intent.putExtra("callback", new ResultReceiver(new Handler(getMainLooper())) { + private boolean unzip = false; private ProgressDialog loadingdialog; - private void createProgressDialog() { loadingdialog = new ProgressDialog(RockboxActivity.this); @@ -64,16 +64,21 @@ public class RockboxActivity extends Activity case RockboxService.RESULT_INVOKING_MAIN: if (loadingdialog != null) loadingdialog.dismiss(); + setContentView(new RockboxFramebuffer(RockboxActivity.this)); break; case RockboxService.RESULT_LIB_LOAD_PROGRESS: if (loadingdialog == null) createProgressDialog(); - loadingdialog.setIndeterminate(false); loadingdialog.setMax(resultData.getInt("max", 100)); loadingdialog.setProgress(resultData.getInt("value", 0)); break; + case RockboxService.RESULT_LIB_LOADED: + unzip = resultData.getBoolean("unzip"); + break; case RockboxService.RESULT_SERVICE_RUNNING: + if (!unzip) /* defer to RESULT_INVOKING_MAIN */ + setContentView(new RockboxFramebuffer(RockboxActivity.this)); setServiceActivity(true); break; case RockboxService.RESULT_ERROR_OCCURED: @@ -85,7 +90,6 @@ public class RockboxActivity extends Activity } } }); - setContentView(new RockboxFramebuffer(this)); startService(intent); } diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index c07ed9d328..e38ff350a3 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java @@ -121,7 +121,6 @@ public class RockboxService extends Service if (!rockbox_running) startService(); - putResult(RESULT_LIB_LOADED); if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { @@ -163,12 +162,6 @@ public class RockboxService extends Service String rockboxCreditsPath = "/data/data/org.rockbox/app_rockbox/rockbox/rocks/viewers"; String rockboxSdDirPath = "/sdcard/rockbox"; - /* load library before unzipping which may take a while */ - synchronized (lock) { - System.loadLibrary("rockbox"); - lock.notify(); - } - /* the following block unzips libmisc.so, which contains the files * we ship, such as themes. It's needed to put it into a .so file * because there's no other way to ship files and have access @@ -178,7 +171,21 @@ public class RockboxService extends Service /* use arbitrary file to determine whether extracting is needed */ File arbitraryFile = new File(rockboxCreditsPath, "credits.rock"); File rockboxInfoFile = new File(rockboxSdDirPath, "rockbox-info.txt"); - if (!arbitraryFile.exists() || (libMisc.lastModified() > arbitraryFile.lastModified())) + /* unzip newer or doesnt exist */ + boolean doExtract = !arbitraryFile.exists() + || (libMisc.lastModified() > arbitraryFile.lastModified()); + + /* load library before unzipping which may take a while + * but at least tell if unzipping is going to be done before*/ + synchronized (lock) { + Bundle bdata = new Bundle(); + bdata.putBoolean("unzip", doExtract); + System.loadLibrary("rockbox"); + putResult(RESULT_LIB_LOADED, bdata); + lock.notify(); + } + + if (doExtract) { boolean extractToSd = false; if(rockboxInfoFile.exists()) { -- cgit v1.2.3