Skip to content

Commit

Permalink
android hack for native file operation ( for sdlpal#86 ); obsolete co…
Browse files Browse the repository at this point in the history
…de/settings cleanup
  • Loading branch information
palxex committed May 31, 2018
1 parent 79c6a4c commit ce58bcb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/cpp/Application.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APP_STL := stlport_static
APP_STL := c++_static
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-9
20 changes: 20 additions & 0 deletions android/app/src/main/java/com/sdlpal/sdlpal/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,31 @@ public void onStart() {
}
}

private boolean traverseDirectory(String path) {
File dir = new File(path);
boolean iteration = true;
if (dir.exists()) {
File[] files = dir.listFiles();
if (files.length == 0) {
return true;
} else {
for (File file: files) {
iteration = iteration & (file.isDirectory() ? traverseDirectory(file.getAbsolutePath()) : file.exists());
}
}
}
return iteration;
}

public void StartGame() {
String dataPath = getApplicationContext().getFilesDir().getPath();
String cachePath = getApplicationContext().getCacheDir().getPath();
String sdcardState = Environment.getExternalStorageState();
String sdlpalPath = Environment.getExternalStorageDirectory().getPath() + "/sdlpal/";

// hack; on LOS14.1, everytime after rebooted, native file operation will not work until java code accessed same file once, even permission granted.
traverseDirectory(sdlpalPath);

String extPath = getApplicationContext().getExternalFilesDir(null).getPath();
File extFolder = new File(sdlpalPath);
if( !extFolder.exists() )
Expand Down
2 changes: 0 additions & 2 deletions palcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ PAL_LoadConfig(
MUSICTYPE eCDType = MUSIC_OGG;
OPLCORE_TYPE eOPLCore = OPLCORE_DBFLT;
OPLCHIP_TYPE eOPLChip = OPLCHIP_OPL2;
INT dwAspectX = -1;
INT dwAspectY = -1;
static const SCREENLAYOUT screen_layout = {
// Equipment Screen
.EquipImageBox = PAL_XY(8, 8),
Expand Down

0 comments on commit ce58bcb

Please sign in to comment.