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 GetGitRevision();
/**
* Saves a screen capture of the game
*/

View File

@ -9,6 +9,8 @@ package org.dolphinemu.dolphinemu.services;
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import org.dolphinemu.dolphinemu.NativeLibrary;
@ -74,11 +76,19 @@ public final class DirectoryInitializationService extends IntentService
{
File sysDirectory = new File(getFilesDir(), "Sys");
// Delete the existing extracted Sys directory in case it's from a different version of Dolphin.
deleteDirectoryRecursively(sysDirectory);
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);
copyAssetFolder("Sys", sysDirectory, true);
// Extract the Sys directory to app-local internal storage.
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.
SetSysDirectory(sysDirectory.getPath());