Fix some envvars on Android

This commit is contained in:
Aaron Culliney 2016-04-12 22:16:01 -07:00
parent db816ad502
commit 9c1cfedf7d
3 changed files with 13 additions and 7 deletions

View File

@ -24,7 +24,6 @@ public class Apple2Preferences {
public final static String TAG = "Apple2Preferences";
public final static String PREFS_JSON_FILE = ".apple2.json";
public final static int DECENT_AMOUNT_OF_CHOICES = 20;
public final static int ALPHA_SLIDER_NUM_CHOICES = DECENT_AMOUNT_OF_CHOICES;
@ -188,8 +187,13 @@ public class Apple2Preferences {
return firstTime;
}
public static String getPrefsFile(Apple2Activity activity) {
String file = System.getenv("APPLE2IX_JSON");
return file == null ? (Apple2Utils.getDataDir(activity) + File.separator + ".apple2.json") : file;
}
public static void load(Apple2Activity activity) {
File prefsFile = new File(Apple2Utils.getDataDir(activity), PREFS_JSON_FILE);
File prefsFile = new File(getPrefsFile(activity));
StringBuilder jsonString = new StringBuilder();
if (!Apple2Utils.readEntireFile(prefsFile, jsonString)) {
@ -211,7 +215,7 @@ public class Apple2Preferences {
// bespoke reset temporary values
Apple2Preferences.setJSONPref(Apple2Preferences.PREF_DOMAIN_TOUCHSCREEN, Apple2Preferences.PREF_CALIBRATING, false);
File prefsFile = new File(Apple2Utils.getDataDir(activity), PREFS_JSON_FILE);
File prefsFile = new File(getPrefsFile(activity));
String jsonString = null;
JSONException ex = null;
try {

View File

@ -163,6 +163,12 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jclas
if (crashHandler && crashHandler->init) {
crashHandler->init(data_dir);
}
char *home = NULL;
ASPRINTF(&home, "HOME=%s", data_dir);
if (home) {
putenv(home);
// leak...
}
(*env)->ReleaseStringUTFChars(env, j_dataDir, dataDir);
LOG("data_dir : %s", data_dir);

View File

@ -47,11 +47,7 @@ void prefs_load(void) {
}
if (!prefsFile) {
#ifdef ANDROID
ASPRINTF(&prefsFile, "%s/.apple2.json", data_dir);
#else
ASPRINTF(&prefsFile, "%s/.apple2.json", getenv("HOME"));
#endif
}
assert(prefsFile);