diff options
author | Chris "koying" Browet <cbro@semperpax.com> | 2012-11-11 03:44:29 +0100 |
---|---|---|
committer | Chris "Koying" Browet <cbro@semperpax.com> | 2012-11-29 13:07:29 +0100 |
commit | 28047c7e8ced9a280ff50ae0311e012bc01314e3 (patch) | |
tree | 0d10e7560693947d77ae257088339998b4a71555 | |
parent | e092099fed999044ee44bcbae249926b43c00a44 (diff) |
ADD: [droid] Splashscreen while caching assets
-rw-r--r-- | tools/android/packaging/Makefile | 9 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/AndroidManifest.xml | 51 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/res/drawable/splash.png | bin | 0 -> 23481 bytes | |||
-rw-r--r-- | tools/android/packaging/xbmc/res/layout/activity_splash.xml | 46 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java | 283 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/src/org/xbmc/xbmc/xbmc.java | 2 | ||||
-rw-r--r-- | xbmc/android/activity/Makefile.in | 1 | ||||
-rw-r--r-- | xbmc/android/activity/android_main.cpp | 5 | ||||
-rw-r--r-- | xbmc/android/activity/unzip.cpp | 193 | ||||
-rw-r--r-- | xbmc/android/activity/unzip.h | 22 |
10 files changed, 368 insertions, 244 deletions
diff --git a/tools/android/packaging/Makefile b/tools/android/packaging/Makefile index af6c37488b..40071f80ee 100644 --- a/tools/android/packaging/Makefile +++ b/tools/android/packaging/Makefile @@ -42,8 +42,9 @@ multi: x86 arm package: extras @cp images/xbmcapp-debug-skeleton.apk images/xbmcapp-debug-$(PLATFORM)-unaligned.apk - @javac xbmc/src/org/xbmc/xbmc/xbmc.java - @$(DX) --dex --output=xbmc/classes.dex xbmc/src/org/xbmc/xbmc/ + @javac -classpath $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar:xbmc/obj -d xbmc/obj -sourcepath xbmc/src xbmc/src/*.java + @javac -classpath $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar:xbmc/obj -d xbmc/obj -sourcepath xbmc/src xbmc/src/org/xbmc/xbmc/*.java + @$(DX) --dex --output=xbmc/classes.dex xbmc/obj @cd xbmc; zip -r -q ../images/xbmcapp-debug-$(PLATFORM)-unaligned.apk lib/$(PLATFORM) assets classes.dex @jarsigner -keystore ~/.android/debug.keystore -storepass android images/xbmcapp-debug-$(PLATFORM)-unaligned.apk androiddebugkey @$(SDKROOT)/tools/zipalign -f 4 images/xbmcapp-debug-$(PLATFORM)-unaligned.apk $(XBMCROOT)/xbmcapp-$(PLATFORM)-debug.apk @@ -54,12 +55,13 @@ extras: libs rm -rf xbmc/assets/python2.6/lib/ mkdir -p xbmc/assets xbmc/res xbmc/assets/python2.6/lib/ cp -rfp $(PREFIX)/share/xbmc/* ./xbmc/assets + find `pwd`/xbmc/assets/ -depth -name ".git" -exec rm -rf {} \; find `pwd`/xbmc/assets/system/ -name "*.so" -exec rm {} \; find `pwd`/xbmc/assets/addons/skin.*/media/* -depth -not -iname "Textures.xbt" -exec rm -rf {} \; cp -rfp $(PREFIX)/lib/python2.6 xbmc/assets/python2.6/lib/ cd xbmc/assets/python2.6/lib/python2.6/; rm -rf test config lib-dynload mkdir -p tmp/res; $(AAPT) c -S xbmc/res -C tmp/res; cp -r -n xbmc/res tmp/ || true - $(AAPT) p -f -I $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar -S tmp/res/ -M xbmc/AndroidManifest.xml -F images/xbmcapp-debug-skeleton.apk + $(AAPT) p -f -I $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar -S tmp/res/ -M xbmc/AndroidManifest.xml -F images/xbmcapp-debug-skeleton.apk -J xbmc/src @rm -rf tmp/ libs: $(PREFIX)/lib/xbmc/libxbmc.so @@ -67,7 +69,6 @@ libs: $(PREFIX)/lib/xbmc/libxbmc.so mkdir -p xbmc/lib/$(PLATFORM) images xbmc/assets/python2.6/lib/ xbmc/libs/$(PLATFORM) xbmc/obj/local/$(PLATFORM) cp -fp $(SRCLIBS) xbmc/obj/local/$(PLATFORM)/ cp -fp $(PREFIX)/lib/xbmc/libxbmc.so xbmc/obj/local/$(PLATFORM)/ - find `pwd`/xbmc/assets/ -depth -name ".git" -exec rm -rf {} \; find $(PREFIX)/lib/xbmc/addons -name "*.so" -exec cp -fp {} xbmc/obj/local/$(PLATFORM)/ \; find $(PREFIX)/lib/xbmc/system -name "*.so" -exec cp -fp {} xbmc/obj/local/$(PLATFORM)/ \; cd xbmc/obj/local/$(PLATFORM)/; find . -name "*.so" -not -name "lib*.so" | sed "s/\.\///" | xargs -I@ mv @ lib@ diff --git a/tools/android/packaging/xbmc/AndroidManifest.xml b/tools/android/packaging/xbmc/AndroidManifest.xml index 1e5852e495..505c70f03b 100644 --- a/tools/android/packaging/xbmc/AndroidManifest.xml +++ b/tools/android/packaging/xbmc/AndroidManifest.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <!-- BEGIN_INCLUDE(manifest) --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.xbmc.xbmc" - android:versionCode="1" - android:versionName="1.0"> + package="org.xbmc.xbmc" + android:versionCode="1" + android:versionName="1.0" > <!-- This is the platform API where NativeActivity was introduced. --> <uses-sdk android:minSdkVersion="9" /> @@ -11,28 +11,41 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> - + <uses-permission android:name="android.permission.GET_TASKS" /> + <application android:icon="@drawable/ic_launcher" android:debuggable="true" android:label="@string/app_name" android:hasCode="true"> - - <!-- Our activity is the built-in NativeActivity framework class. - This will take care of integrating with our NDK code. --> - <activity android:name="android.app.NativeActivity" - android:label="XBMC" - android:configChanges="orientation|keyboardHidden" - android:theme="@android:style/Theme.NoTitleBar.Fullscreen" - android:screenOrientation="landscape" - android:finishOnTaskLaunch="true" - android:launchMode="singleInstance"> - <!-- Tell NativeActivity the name of or .so --> - <meta-data android:name="android.app.lib_name" - android:value="xbmc" /> + <activity + android:name=".Splash" + android:configChanges="orientation|keyboardHidden" + android:finishOnTaskLaunch="true" + android:launchMode="singleInstance" + android:screenOrientation="landscape" + android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> + + <!-- + Our activity is the built-in NativeActivity framework class. + This will take care of integrating with our NDK code. + --> + <activity + android:name="android.app.NativeActivity" + android:configChanges="orientation|keyboardHidden" + android:finishOnTaskLaunch="true" + android:label="XBMC" + android:launchMode="singleInstance" + android:screenOrientation="landscape" + android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > + + <!-- Tell NativeActivity the name of or .so --> + <meta-data + android:name="android.app.lib_name" + android:value="xbmc" /> + </activity> </application> -</manifest> -<!-- END_INCLUDE(manifest) --> +</manifest><!-- END_INCLUDE(manifest) --> diff --git a/tools/android/packaging/xbmc/res/drawable/splash.png b/tools/android/packaging/xbmc/res/drawable/splash.png Binary files differnew file mode 100644 index 0000000000..013c95176e --- /dev/null +++ b/tools/android/packaging/xbmc/res/drawable/splash.png diff --git a/tools/android/packaging/xbmc/res/layout/activity_splash.xml b/tools/android/packaging/xbmc/res/layout/activity_splash.xml new file mode 100644 index 0000000000..4bf79f09ce --- /dev/null +++ b/tools/android/packaging/xbmc/res/layout/activity_splash.xml @@ -0,0 +1,46 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/black" > + + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" > + + <ImageView + android:id="@+id/imageView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:adjustViewBounds="true" + android:scaleType="fitXY" + android:src="@drawable/splash" /> + + <ProgressBar + android:id="@+id/progressBar1" + style="?android:attr/progressBarStyleHorizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentRight="true" + android:layout_below="@+id/imageView1" + android:layout_centerHorizontal="true" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginTop="-35dp" /> + + <TextView + android:id="@+id/textView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/imageView1" + android:layout_centerHorizontal="true" + android:layout_marginTop="-60dp" + android:text="" + android:textColor="@android:color/white" + android:textSize="16dp" /> + </RelativeLayout> + +</RelativeLayout>
\ No newline at end of file diff --git a/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java b/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java new file mode 100644 index 0000000000..df832d82e7 --- /dev/null +++ b/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java @@ -0,0 +1,283 @@ +package org.xbmc.xbmc; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import android.os.AsyncTask; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.app.Activity; +import android.app.ActivityManager; +import android.app.ActivityManager.RunningTaskInfo; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.util.Log; +import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.TextView; + +public class Splash extends Activity { + + public enum State { + Uninitialized, Checking, Caching, StartingXBMC + } + + private static final String TAG = "Splash"; + + private String mCpuinfo = ""; + private String mErrorMsg = ""; + + private ProgressBar mProgress = null; + private TextView mTextView = null; + private State mState = State.Uninitialized; + public AlertDialog myAlertDialog; + + public void showErrorDialog(Context context, String title, String message) { + if (myAlertDialog != null && myAlertDialog.isShowing()) + return; + + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(title); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setMessage(Html.fromHtml(message)); + builder.setPositiveButton("Exit", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int arg1) { + dialog.dismiss(); + finish(); + } + }); + builder.setCancelable(false); + myAlertDialog = builder.create(); + myAlertDialog.show(); + + // Make links actually clickable + ((TextView)myAlertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); } + + // Do the Work + class Work extends AsyncTask<Void, Integer, Integer> { + + private Splash mSplash = null; + private int mProgressStatus = 0; + + public Work(Splash splash) { + this.mSplash = splash; + } + + @Override + protected Integer doInBackground(Void... param) { + mState = State.Checking; + publishProgress(0); + + boolean ret = ParseCpuFeature(); + if (!ret) { + mErrorMsg = "Error! Cannot parse CPU features."; + return -1; + } + + ret = CheckCpuFeature("neon"); + if (!ret) { + mErrorMsg = "This XBMC package is not compatible with your device.\nPlease check the <a href=\"http://wiki.xbmc.org/index.php?title=XBMC_for_Android_specific_FAQ\">XBMC Android wiki</a> for more information."; + return -1; + } + + String sPackagePath = mSplash.getPackageResourcePath(); + File fPackagePath = new File(sPackagePath); + File fCacheDir = mSplash.getCacheDir(); + String sApkDir = fCacheDir.getAbsolutePath() + "/apk"; + File fApkDir = new File(sApkDir); + + if (!fApkDir.exists() || fApkDir.lastModified() < fPackagePath.lastModified()) { + fApkDir.mkdirs(); + + // Log.d(TAG, "apk: " + sPackagePath); + // Log.d(TAG, "output: " + sApkDir); + + ZipFile zip; + byte[] buf = new byte[4096]; + int n; + try { + zip = new ZipFile(sPackagePath); + Enumeration<? extends ZipEntry> entries = zip.entries(); + mProgress.setProgress(0); + mProgress.setMax(zip.size()); + + mState = State.Caching; + publishProgress(mProgressStatus); + while (entries.hasMoreElements()) { + // Update the progress bar + publishProgress(++mProgressStatus); + + ZipEntry e = (ZipEntry) entries.nextElement(); + + if (!e.getName().startsWith("assets/")) + continue; + if (e.getName().startsWith("assets/python2.6")) + continue; + + String sFullPath = sApkDir + "/" + e.getName(); + File fFullPath = new File(sFullPath); + if (e.isDirectory()) { + // Log.d(TAG, "creating dir: " + sFullPath); + fFullPath.mkdirs(); + continue; + } + + // Log.d(TAG, + // "time: " + e.getTime() + ";" + // + fFullPath.lastModified()); + + // If file exists and has same time, skip + if (e.getTime() == fFullPath.lastModified()) + continue; + + // Log.d(TAG, "writing: " + sFullPath); + fFullPath.getParentFile().mkdirs(); + + try { + InputStream in = zip.getInputStream(e); + BufferedOutputStream out = new BufferedOutputStream( + new FileOutputStream(sFullPath)); + while ((n = in.read(buf, 0, 4096)) > -1) + out.write(buf, 0, n); + + in.close(); + out.close(); + + // save the zip time. this way we know for certain + // if we + // need to refresh. + fFullPath.setLastModified(e.getTime()); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + + zip.close(); + + fApkDir.setLastModified(fPackagePath.lastModified()); + + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + mErrorMsg = "Cannot find package."; + return -1; + } catch (IOException e) { + e.printStackTrace(); + mErrorMsg = "Cannot read package."; + return -1; + } + } + + mState = State.StartingXBMC; + publishProgress(0); + + return 0; + } + + @Override + protected void onProgressUpdate(Integer... values) { + switch (mState) { + case Checking: + mSplash.mTextView.setText("Checking package validity..."); + mSplash.mProgress.setVisibility(View.INVISIBLE); + break; + case Caching: + mSplash.mTextView.setText("Initializing the Xbmc cache..."); + mSplash.mProgress.setVisibility(View.VISIBLE); + mSplash.mProgress.setProgress(values[0]); + break; + case StartingXBMC: + mSplash.mTextView.setText("Starting XBMC..."); + mSplash.mProgress.setVisibility(View.INVISIBLE); + break; + } + } + + @Override + protected void onPostExecute(Integer result) { + super.onPostExecute(result); + if (result < 0) { + showErrorDialog(mSplash, "Error", mErrorMsg); + return; + } + + startXBMC(); + } + } + + private boolean ParseCpuFeature() { + ProcessBuilder cmd; + + try { + String[] args = { "/system/bin/cat", "/proc/cpuinfo" }; + cmd = new ProcessBuilder(args); + + Process process = cmd.start(); + InputStream in = process.getInputStream(); + byte[] re = new byte[1024]; + while (in.read(re) != -1) { + mCpuinfo = mCpuinfo + new String(re); + } + in.close(); + } catch (IOException ex) { + ex.printStackTrace(); + return false; + } + return true; + } + + private boolean CheckCpuFeature(String feat) { + final Pattern FeaturePattern = Pattern.compile(":.*?\\s" + feat + "(?:\\s|$)"); + Matcher m = FeaturePattern.matcher(mCpuinfo); + return m.find(); + } + + protected void startXBMC() { + // Run XBMC + Intent intent = new Intent(); + intent.setClass(this, android.app.NativeActivity.class); + startActivity(intent); + finish(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Check if XBMC is not already running + ActivityManager activityManager = (ActivityManager) getBaseContext() + .getSystemService(Context.ACTIVITY_SERVICE); + List<RunningTaskInfo> tasks = activityManager + .getRunningTasks(Integer.MAX_VALUE); + for (RunningTaskInfo task : tasks) + if (task.topActivity.toString().equalsIgnoreCase( + "ComponentInfo{org.xbmc.xbmc/android.app.NativeActivity}")) { + // XBMC already running; just activate it + startXBMC(); + return; + } + + setContentView(R.layout.activity_splash); + + mProgress = (ProgressBar) findViewById(R.id.progressBar1); + mTextView = (TextView) findViewById(R.id.textView1); + + new Work(this).execute(); + } + +} diff --git a/tools/android/packaging/xbmc/src/org/xbmc/xbmc/xbmc.java b/tools/android/packaging/xbmc/src/org/xbmc/xbmc/xbmc.java index c086394556..0013512cf9 100644 --- a/tools/android/packaging/xbmc/src/org/xbmc/xbmc/xbmc.java +++ b/tools/android/packaging/xbmc/src/org/xbmc/xbmc/xbmc.java @@ -1 +1,3 @@ +package org.xbmc.xbmc; + class xbmc{}
\ No newline at end of file diff --git a/xbmc/android/activity/Makefile.in b/xbmc/android/activity/Makefile.in index 280c892063..df82dcce38 100644 --- a/xbmc/android/activity/Makefile.in +++ b/xbmc/android/activity/Makefile.in @@ -15,7 +15,6 @@ SRCS += AndroidTouch.cpp SRCS += AndroidMouse.cpp SRCS += GraphicBuffer.cpp SRCS += EventLoop.cpp -SRCS += unzip.cpp SRCS += XBMCApp.cpp OBJS += $(APP_GLUE) $(CPU_OBJ) diff --git a/xbmc/android/activity/android_main.cpp b/xbmc/android/activity/android_main.cpp index 33efe9efa2..c8633117a5 100644 --- a/xbmc/android/activity/android_main.cpp +++ b/xbmc/android/activity/android_main.cpp @@ -27,7 +27,6 @@ #include "EventLoop.h" #include "XBMCApp.h" -#include "unzip.h" void setup_env(struct android_app* state) { @@ -104,10 +103,6 @@ void setup_env(struct android_app* state) setenv("XBMC_TEMP", tempDir, 0); strcat(cacheDir, "/apk"); - - //cache assets from the apk - extract_to_cache(apkPath, cacheDir); - strcat(cacheDir, "/assets"); setenv("XBMC_BIN_HOME", cacheDir, 0); setenv("XBMC_HOME" , cacheDir, 0); diff --git a/xbmc/android/activity/unzip.cpp b/xbmc/android/activity/unzip.cpp deleted file mode 100644 index d07d185b76..0000000000 --- a/xbmc/android/activity/unzip.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2012 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include <errno.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <utime.h> -#include <zip.h> -#include "XBMCApp.h" - -typedef struct stat Stat; - -static int do_mkdir(const char *path) -{ - Stat st; - int status = 0; - - if (stat(path, &st) != 0) - { - /* Directory does not exist */ - if (mkdir(path, 0755) != 0) - status = -1; - } - else if (!S_ISDIR(st.st_mode)) - { - errno = ENOTDIR; - status = -1; - } - - return(status); -} - -int mkpath(const char *path) -{ - char *pp; - char *sp; - int status; - char *copypath = strdup(path); - - status = 0; - pp = copypath; - while (status == 0 && (sp = strchr(pp, '/')) != 0) - { - if (sp != pp) - { - /* Neither root nor double slash in path */ - *sp = '\0'; - status = do_mkdir(copypath); - *sp = '/'; - } - pp = sp + 1; - } - if (status == 0) - status = do_mkdir(path); - free(copypath); - return (status); -} - -int extract_to_cache(const char *archive, const char *cache_path) -{ - struct zip *ziparchive; - struct zip_file *zipfile; - struct zip_stat zipstat; - char buf[4096]; - int err; - int len; - int fd; - int dirname_len; - uint64_t sum; - char *full_path; - char *dir_name; - Stat localfile; - utimbuf modified; - CXBMCApp::android_printf("unzip: Preparing to cache. This could take a while..."); - - if ((ziparchive = zip_open(archive, 0, &err)) == NULL) - { - zip_error_to_str(buf, sizeof(buf), err, errno); - CXBMCApp::android_printf("unzip error: can't open archive %s/n",archive); - return 1; - } - - mkpath(cache_path); - - for (size_t i = 0; i < zip_get_num_entries(ziparchive, 0); i++) - { - if (zip_stat_index(ziparchive, i, 0, &zipstat) != 0) - { - CXBMCApp::android_printf("unzip error: can't open entry: %i/n",i); - continue; - } - - if(strncmp (zipstat.name,"assets/",7) != 0) - continue; - - if(strncmp (zipstat.name,"assets/python2.6",16) == 0) - continue; - - modified.modtime = modified.actime = zipstat.mtime; - - full_path = (char*)malloc( sizeof(char*) * (strlen(cache_path) + 1 + strlen(zipstat.name) + 1)); - sprintf(full_path, "%s/%s",cache_path,zipstat.name); - - if (zipstat.name[strlen(zipstat.name) - 1] == '/') - { - mkpath(full_path); - free(full_path); - continue; - } - - zipfile = zip_fopen_index(ziparchive, i, 0); - if (!zipfile) - { - CXBMCApp::android_printf("unzip error: can't open index"); - free(full_path); - continue; - } - - if (stat(full_path, &localfile) != 0) - { - dirname_len = strrchr(zipstat.name,'/') - zipstat.name; - dir_name = (char*)malloc( sizeof(char*) * (strlen(cache_path) + 1 + dirname_len + 1)); - strncpy(dir_name, full_path, strlen(cache_path) + dirname_len + 1); - dir_name[strlen(cache_path) + dirname_len + 1] = '\0'; - mkpath(dir_name); - free(dir_name); - } - // watch this compare, zipstat.mtime is time_t which is a signed long - else if (localfile.st_mtime == (unsigned long)zipstat.mtime) - { - free(full_path); - continue; - } - - fd = open(full_path, O_RDWR | O_TRUNC | O_CREAT, 0644); - if(fd < 0) - { - CXBMCApp::android_printf("unzip error: could not open %s",full_path); - free(full_path); - continue; - } - - sum = 0; - while (sum != zipstat.size) - { - len = zip_fread(zipfile, buf, 4096); - if (len < 0) - { - CXBMCApp::android_printf("unzip error: no data in %s",full_path); - free(full_path); - continue; - } - write(fd, buf, len); - sum += len; - } - close(fd); - zip_fclose(zipfile); - - if (stat(full_path, &localfile) == 0) - { - // save the zip time. this way we know for certain if we need to refresh. - utime(full_path, &modified); - } - else - { - CXBMCApp::android_printf("unzip error: failed to extract %s",full_path); - } - - free(full_path); - } - - if (zip_close(ziparchive) == -1) - CXBMCApp::android_printf("unzip error: can't close zip archive `%s'/n", archive); - - return 0; -} diff --git a/xbmc/android/activity/unzip.h b/xbmc/android/activity/unzip.h deleted file mode 100644 index f531c00930..0000000000 --- a/xbmc/android/activity/unzip.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -/* - * Copyright (C) 2012 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -int extract_to_cache(const char*, const char*); |