Android: Don't extract Sys if it already is extracted

This commit is contained in:
JosJuice 2017-09-10 08:43:12 +02:00
parent b3b7aef09a
commit 3262314435
3 changed files with 24 additions and 4 deletions

View File

@ -283,6 +283,8 @@ public final class NativeLibrary
*/ */
public static native String GetVersionString(); public static native String GetVersionString();
public static native String GetGitRevision();
/** /**
* Saves a screen capture of the game * Saves a screen capture of the game
*/ */

View File

@ -9,6 +9,8 @@ package org.dolphinemu.dolphinemu.services;
import android.app.IntentService; import android.app.IntentService;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
@ -74,12 +76,20 @@ public final class DirectoryInitializationService extends IntentService
{ {
File sysDirectory = new File(getFilesDir(), "Sys"); File sysDirectory = new File(getFilesDir(), "Sys");
// Delete the existing extracted Sys directory in case it's from a different version of Dolphin. SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String revision = NativeLibrary.GetGitRevision();
if (!preferences.getString("sysDirectoryVersion", "").equals(revision))
{
// There is no extracted Sys directory, or there is a Sys directory from another
// version of Dolphin that might contain outdated files. Let's (re-)extract Sys.
deleteDirectoryRecursively(sysDirectory); deleteDirectoryRecursively(sysDirectory);
// Extract the Sys directory to app-local internal storage.
copyAssetFolder("Sys", sysDirectory, true); copyAssetFolder("Sys", sysDirectory, true);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("sysDirectoryVersion", revision);
editor.apply();
}
// Let the native code know where the Sys directory is. // Let the native code know where the Sys directory is.
SetSysDirectory(sysDirectory.getPath()); SetSysDirectory(sysDirectory.getPath());
} }

View File

@ -432,6 +432,8 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetPlatform(
jstring jFilename); jstring jFilename);
JNIEXPORT jstring JNICALL JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jobject obj); Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jobject obj);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
jobject obj); jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env,
@ -589,6 +591,12 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersio
return env->NewStringUTF(Common::scm_rev_str.c_str()); return env->NewStringUTF(Common::scm_rev_str.c_str());
} }
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env,
jobject obj)
{
return env->NewStringUTF(Common::scm_rev_git_str.c_str());
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
jobject obj) jobject obj)
{ {