[Scummvm-git-logs] scummvm branch-2-7 -> e557aa0c509a0ce3db7e02109d816820e002b7f8

antoniou79 noreply at scummvm.org
Wed Mar 1 17:02:33 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f319952991 ANDROID: Simplify Android startup
e557aa0c50 ANDROID: Make Android onCreate more readable


Commit: f319952991e9632495193ee98b465582b3524837
    https://github.com/scummvm/scummvm/commit/f319952991e9632495193ee98b465582b3524837
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-03-01T19:02:12+02:00

Commit Message:
ANDROID: Simplify Android startup

Do not pass arguments to the process but customize the backend instead

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/jni-android.cpp
    backends/platform/android/jni-android.h
    backends/platform/android/org/scummvm/scummvm/ScummVM.java
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java


diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 4f21d14140b..c1ad7d86018 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -483,12 +483,14 @@ void OSystem_Android::initBackend() {
 		ConfMan.setInt("gui_scale", 125); // "Large" (see gui/options.cpp and guiBaseValues[])
 	}
 
-	_savefileManager = new AndroidSaveFileManager(ConfMan.get("path") + "/saves");
+	Common::String basePath = JNI::getScummVMBasePath();
+
+	_savefileManager = new AndroidSaveFileManager(basePath + "/saves");
 	// TODO remove the debug message eventually
 	LOGD("Setting DefaultSaveFileManager path to: %s", ConfMan.get("savepath").c_str());
 
 
-	ConfMan.registerDefault("iconspath", ConfMan.get("path") + "/icons");
+	ConfMan.registerDefault("iconspath", basePath + "/icons");
 	// TODO remove the debug message eventually
 	LOGD("Setting Default Icons and Shaders path to: %s", ConfMan.get("iconspath").c_str());
 
@@ -524,6 +526,10 @@ void OSystem_Android::initBackend() {
 	BaseBackend::initBackend();
 }
 
+Common::String OSystem_Android::getDefaultConfigFileName() {
+	return JNI::getScummVMConfigPath();
+}
+
 bool OSystem_Android::hasFeature(Feature f) {
 	if (f == kFeatureFullscreenMode)
 		return false;
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 432caa3e61d..f980bd0ac08 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -173,6 +173,8 @@ public:
 	Common::KeymapArray getGlobalKeymaps() override;
 	Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() override;
 
+	Common::String getDefaultConfigFileName() override;
+
 	void registerDefaultSettings(const Common::String &target) const override;
 	GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
 	void applyBackendSettings() override;
diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 8893e688633..f87baaf0ca0 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -92,6 +92,8 @@ jmethodID JNI::_MID_showKeyboardControl = 0;
 jmethodID JNI::_MID_getBitmapResource = 0;
 jmethodID JNI::_MID_setTouchMode = 0;
 jmethodID JNI::_MID_getTouchMode = 0;
+jmethodID JNI::_MID_getScummVMBasePath;
+jmethodID JNI::_MID_getScummVMConfigPath;
 jmethodID JNI::_MID_getSysArchives = 0;
 jmethodID JNI::_MID_getAllStorageLocations = 0;
 jmethodID JNI::_MID_initSurface = 0;
@@ -503,9 +505,60 @@ int JNI::getTouchMode() {
 	return mode;
 }
 
+Common::String JNI::getScummVMBasePath() {
+	JNIEnv *env = JNI::getEnv();
+
+	jstring pathObj = (jstring)env->CallObjectMethod(_jobj, _MID_getScummVMBasePath);
+
+	if (env->ExceptionCheck()) {
+		LOGE("Failed to get ScummVM base path");
+
+		env->ExceptionDescribe();
+		env->ExceptionClear();
+
+		return Common::String();
+	}
+
+	Common::String path;
+	const char *pathP = env->GetStringUTFChars(pathObj, 0);
+	if (pathP != 0) {
+		path = Common::String(pathP);
+		env->ReleaseStringUTFChars(pathObj, pathP);
+	}
+	env->DeleteLocalRef(pathObj);
+
+	return path;
+}
+
+Common::String JNI::getScummVMConfigPath() {
+	JNIEnv *env = JNI::getEnv();
+
+	jstring pathObj = (jstring)env->CallObjectMethod(_jobj, _MID_getScummVMConfigPath);
+
+	if (env->ExceptionCheck()) {
+		LOGE("Failed to get ScummVM base path");
+
+		env->ExceptionDescribe();
+		env->ExceptionClear();
+
+		return Common::String();
+	}
+
+	Common::String path;
+	const char *pathP = env->GetStringUTFChars(pathObj, 0);
+	if (pathP != 0) {
+		path = Common::String(pathP);
+		env->ReleaseStringUTFChars(pathObj, pathP);
+	}
+	env->DeleteLocalRef(pathObj);
+
+	return path;
+}
+
+
 // The following adds assets folder to search set.
 // However searching and retrieving from "assets" on Android this is slow
-// so we also make sure to add the "path" directory, with a higher priority
+// so we also make sure to add the base directory, with a higher priority
 // This is done via a call to ScummVMActivity's (java) getSysArchives
 void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
 	JNIEnv *env = JNI::getEnv();
@@ -672,6 +725,8 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
 	FIND_METHOD(, getBitmapResource, "(I)Landroid/graphics/Bitmap;");
 	FIND_METHOD(, setTouchMode, "(I)V");
 	FIND_METHOD(, getTouchMode, "()I");
+	FIND_METHOD(, getScummVMBasePath, "()Ljava/lang/String;");
+	FIND_METHOD(, getScummVMConfigPath, "()Ljava/lang/String;");
 	FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
 	FIND_METHOD(, getAllStorageLocations, "()[Ljava/lang/String;");
 	FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h
index 3f3d75d9a68..00719e5f40e 100644
--- a/backends/platform/android/jni-android.h
+++ b/backends/platform/android/jni-android.h
@@ -88,6 +88,8 @@ public:
 	static void setTouchMode(int touchMode);
 	static int getTouchMode();
 	static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
+	static Common::String getScummVMBasePath();
+	static Common::String getScummVMConfigPath();
 	static jint getAndroidSDKVersionId();
 
 	static inline bool haveSurface();
@@ -137,6 +139,8 @@ private:
 	static jmethodID _MID_getBitmapResource;
 	static jmethodID _MID_setTouchMode;
 	static jmethodID _MID_getTouchMode;
+	static jmethodID _MID_getScummVMBasePath;
+	static jmethodID _MID_getScummVMConfigPath;
 	static jmethodID _MID_getSysArchives;
 	static jmethodID _MID_getAllStorageLocations;
 	static jmethodID _MID_initSurface;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index ba990998cff..0c2064917bf 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -77,6 +77,8 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 	abstract protected Bitmap getBitmapResource(int resource);
 	abstract protected void setTouchMode(int touchMode);
 	abstract protected int getTouchMode();
+	abstract protected String getScummVMBasePath();
+	abstract protected String getScummVMConfigPath();
 	abstract protected String[] getSysArchives();
 	abstract protected String[] getAllStorageLocations();
 	abstract protected String[] getAllStorageLocationsNoPermissionRequest();
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 3f0e72461f2..18cda047260 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -778,6 +778,16 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 			return _events.getTouchMode();
 		}
 
+		@Override
+		protected String getScummVMBasePath() {
+			return _actualScummVMDataDir.getPath();
+		}
+
+		@Override
+		protected String getScummVMConfigPath() {
+			return _configScummvmFile.getPath();
+		}
+
 		@Override
 		protected String[] getSysArchives() {
 			Log.d(ScummVM.LOG_TAG, "Adding to Search Archive: " + _actualScummVMDataDir.getPath());
@@ -944,15 +954,8 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 			// We should have a valid path to a configuration file here
 
 			// Start ScummVM
-//			Log.d(ScummVM.LOG_TAG, "CONFIG: " +  _configScummvmFile.getPath());
-//			Log.d(ScummVM.LOG_TAG, "PATH: " +  _actualScummVMDataDir.getPath());
-
-			// TODO log file setting via "--logfile=" + _usingLogFile.getPath() causes crash
-			//      probably because this option is specific to SDL_BACKEND (see: base/commandLine.cpp)
 			_scummvm.setArgs(new String[]{
-				"ScummVM",
-				"--config=" + _configScummvmFile.getPath(),
-				"--path=" + _actualScummVMDataDir.getPath()
+				"ScummVM"
 			});
 
 			Log.d(ScummVM.LOG_TAG, "Hover available: " + _hoverAvailable);


Commit: e557aa0c509a0ce3db7e02109d816820e002b7f8
    https://github.com/scummvm/scummvm/commit/e557aa0c509a0ce3db7e02109d816820e002b7f8
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-03-01T19:02:23+02:00

Commit Message:
ANDROID: Make Android onCreate more readable

The else clause was not necessary.

Changed paths:
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java


diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 18cda047260..4ecdd043558 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -950,47 +950,48 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 		if (!seekAndInitScummvmConfiguration()) {
 			Log.e(ScummVM.LOG_TAG, "Error while trying to find and/or initialize ScummVM configuration file!");
 			// in fact in all the cases where we return false, we also called finish()
-		} else {
-			// We should have a valid path to a configuration file here
+			return;
+		}
 
-			// Start ScummVM
-			_scummvm.setArgs(new String[]{
-				"ScummVM"
-			});
+		// We should have a valid path to a configuration file here
 
-			Log.d(ScummVM.LOG_TAG, "Hover available: " + _hoverAvailable);
-			_mouseHelper = null;
-			if (_hoverAvailable) {
-				_mouseHelper = new MouseHelper(_scummvm);
-//				_mouseHelper.attach(_main_surface);
-			}
+		// Start ScummVM
+		_scummvm.setArgs(new String[]{
+			"ScummVM"
+		});
 
-			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
-				_events = new ScummVMEventsModern(this, _scummvm, _mouseHelper);
-			} else {
-				_events = new ScummVMEventsBase(this, _scummvm, _mouseHelper);
-			}
+		Log.d(ScummVM.LOG_TAG, "Hover available: " + _hoverAvailable);
+		_mouseHelper = null;
+		if (_hoverAvailable) {
+			_mouseHelper = new MouseHelper(_scummvm);
+			//_mouseHelper.attach(_main_surface);
+		}
 
-			setupTouchModeBtn(_events.getTouchMode());
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
+			_events = new ScummVMEventsModern(this, _scummvm, _mouseHelper);
+		} else {
+			_events = new ScummVMEventsBase(this, _scummvm, _mouseHelper);
+		}
 
-			// On screen button listener
-			//findViewById(R.id.show_keyboard).setOnClickListener(keyboardBtnOnClickListener);
-			_toggleTouchModeKeyboardBtnIcon.setOnClickListener(touchModeKeyboardBtnOnClickListener);
-			_toggleTouchModeKeyboardBtnIcon.setOnLongClickListener(touchModeKeyboardBtnOnLongClickListener);
-			_openMenuBtnIcon.setOnClickListener(menuBtnOnClickListener);
+		setupTouchModeBtn(_events.getTouchMode());
 
-			// Keyboard visibility listener - mainly to hide system UI if keyboard is shown and we return from Suspend to the Activity
-			setKeyboardVisibilityListener(this);
+		// On screen button listener
+		//findViewById(R.id.show_keyboard).setOnClickListener(keyboardBtnOnClickListener);
+		_toggleTouchModeKeyboardBtnIcon.setOnClickListener(touchModeKeyboardBtnOnClickListener);
+		_toggleTouchModeKeyboardBtnIcon.setOnLongClickListener(touchModeKeyboardBtnOnLongClickListener);
+		_openMenuBtnIcon.setOnClickListener(menuBtnOnClickListener);
 
-			_main_surface.setOnKeyListener(_events);
-			_main_surface.setOnTouchListener(_events);
-			if (_mouseHelper != null) {
-				_main_surface.setOnHoverListener(_mouseHelper);
-			}
+		// Keyboard visibility listener - mainly to hide system UI if keyboard is shown and we return from Suspend to the Activity
+		setKeyboardVisibilityListener(this);
 
-			_scummvm_thread = new Thread(_scummvm, "ScummVM");
-			_scummvm_thread.start();
+		_main_surface.setOnKeyListener(_events);
+		_main_surface.setOnTouchListener(_events);
+		if (_mouseHelper != null) {
+			_main_surface.setOnHoverListener(_mouseHelper);
 		}
+
+		_scummvm_thread = new Thread(_scummvm, "ScummVM");
+		_scummvm_thread.start();
 	}
 
 	@Override




More information about the Scummvm-git-logs mailing list