From ae25d185d5976f9210f70c02c7951171db3497bb Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 15:29:22 +0100 Subject: BUILD: Add HOSTEXEPRE as prefix for EXECUTABLE the android port needs to link a shared object for scummvm --- Makefile | 2 +- configure | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 844a063f8f..2c1206ae32 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ ZIP ?= zip -q # Misc stuff - you should never have to edit this # ####################################################################### -EXECUTABLE := scummvm$(EXEEXT) +EXECUTABLE := $(EXEPRE)scummvm$(EXEEXT) include $(srcdir)/Makefile.common diff --git a/configure b/configure index b0d02e9609..7423fed563 100755 --- a/configure +++ b/configure @@ -1184,6 +1184,7 @@ fi # Determine extension used for executables # get_system_exe_extension $_host_os +HOSTEXEPRE= HOSTEXEEXT=$_exeext # @@ -3222,6 +3223,7 @@ STATICLIBPATH=$_staticlibpath BACKEND := $_backend MODULES += $MODULES MODULE_DIRS += $MODULE_DIRS +EXEPRE := $HOSTEXEPRE EXEEXT := $HOSTEXEEXT NASM := $NASM NASMFLAGS := $NASMFLAGS -- cgit v1.2.3 From 51a966e9e6f57630e30f3d84a7ef24e6d2f806dd Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 15:23:47 +0100 Subject: ANDROID: Use the official NDK toolchain - use NDK r5b - cleanup --- configure | 66 ++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 7423fed563..41a375e196 100755 --- a/configure +++ b/configure @@ -979,7 +979,7 @@ case $_host in android) _host_os=android _host_cpu=arm - _host_alias=arm-oe-linux-androideabi + _host_alias=arm-linux-androideabi ;; arm-riscos) _host_os=riscos @@ -1208,6 +1208,10 @@ android) echo "Please set ANDROID_SDK in your environment. export ANDROID_SDK=" exit 1 fi + if test -z "$ANDROID_NDK"; then + echo "Please set ANDROID_NDK in your environment. export ANDROID_NDK=" + exit 1 + fi ;; ds | gamecube | wii) if test -z "$DEVKITPRO"; then @@ -1500,7 +1504,13 @@ case $_host_os in add_line_to_config_mk 'AMIGAOS = 1' ;; android) - CXXFLAGS="$CXXFLAGS -Os -msoft-float -mtune=xscale -march=armv5te -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__" + CXXFLAGS="$CXXFLAGS --sysroot=$ANDROID_NDK/platforms/android-4/arch-arm" + CXXFLAGS="$CXXFLAGS -Os -mandroid -msoft-float -mthumb-interwork" + CXXFLAGS="$CXXFLAGS -march=armv5te -mtune=xscale" + # supress 'mangling of 'va_list' has changed in GCC 4.4' + CXXFLAGS="$CXXFLAGS -Wno-psabi" + LDFLAGS="$LDFLAGS --sysroot=$ANDROID_NDK/platforms/android-4/arch-arm" + LDFLAGS="$LDFLAGS -mandroid -mthumb-interwork" add_line_to_config_mk "ANDROID_SDK = $ANDROID_SDK" _unix=yes _seq_midi=no @@ -1649,9 +1659,13 @@ if test -n "$_host"; then echo "Cross-compiling to $_host" case "$_host" in android) - DEFINES="$DEFINES -DANDROID -DUSE_ARM_SMUSH_ASM" + DEFINES="$DEFINES -DANDROID -DANDROID_BACKEND" _unix=yes _need_memalign=yes + # we link a .so as default + LDFLAGS="$LDFLAGS -shared -Wl,-Bsymbolic,--no-undefined" + HOSTEXEPRE=lib + HOSTEXEEXT=.so add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' @@ -1659,6 +1673,7 @@ if test -n "$_host"; then add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1' _backend="android" _port_mk="backends/platform/android/android.mk" + _build_scalers=no _seq_midi=no ;; arm-linux|arm*-linux-gnueabi|arm-*-linux) @@ -2135,6 +2150,32 @@ _def_plugin="/* -> plugins disabled */" if test "$_dynamic_modules" = yes ; then echo_n "Checking whether building plugins is supported... " case $_host_os in + android) +_def_plugin=' +#define PLUGIN_PREFIX "lib" +#define PLUGIN_SUFFIX ".so" +' +# Work around an Android 2.0+ run-time linker bug: +# The linker doesn't actually look in previously +# loaded libraries when trying to resolve symbols - +# effectively turning all dlopen(RTLD_GLOBAL) calls +# into dlopen(RTLD_LOCAL). It *does* look in +# DT_NEEDED libraries, so the workaround is to add an +# (otherwise unnecessary) dependency from plugins back +# to the main libscummvm.so. +_mak_plugins=' +DYNAMIC_MODULES := 1 +PLUGIN_PREFIX := lib +PLUGIN_SUFFIX := .so +PLUGIN_EXTRA_DEPS = libscummvm.so +CXXFLAGS += -DDYNAMIC_MODULES +CXXFLAGS += -fpic +PLUGIN_LDFLAGS += $(LDFLAGS) -L. -lscummvm +PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive +POST_OBJS_FLAGS := -Wl,-no-whole-archive +LIBS += -ldl +' + ;; darwin*) _def_plugin=' #define PLUGIN_PREFIX "" @@ -2217,7 +2258,7 @@ POST_OBJS_FLAGS := -Wl,-no-whole-archive LIBS += -ldl ' ;; - linux*|android) + linux*) _def_plugin=' #define PLUGIN_PREFIX "lib" #define PLUGIN_SUFFIX ".so" @@ -2928,20 +2969,9 @@ case $_backend in # -lgcc is carefully placed here - we want to catch # all toolchain symbols in *our* libraries rather # than pick up anything unhygenic from the Android libs. - LIBS="-Wl,-Bstatic $static_libs -Wl,-Bdynamic -lgcc $system_libs -lstdc++ -llog -lGLESv1_CM" - DEFINES="$DEFINES -D__ANDROID__ -DANDROID_BACKEND -DREDUCE_MEMORY_USAGE" - add_line_to_config_mk 'PLUGIN_LDFLAGS += $(LDFLAGS) -Wl,-shared,-Bsymbolic' - - # Work around an Android 2.0+ run-time linker bug: - # The linker doesn't actually look in previously - # loaded libraries when trying to resolve symbols - - # effectively turning all dlopen(RTLD_GLOBAL) calls - # into dlopen(RTLD_LOCAL). It *does* look in - # DT_NEEDED libraries, so the workaround is to add an - # (otherwise unnecessary) dependency from plugins back - # to the main libscummvm.so. - add_line_to_config_mk 'PLUGIN_LDFLAGS += -Lbuild.tmp -lscummvm' - add_line_to_config_mk 'PLUGIN_EXTRA_DEPS += build.tmp/libscummvm.so' + LIBS="-Wl,-Bstatic $static_libs" + LIBS="$LIBS -Wl,-Bdynamic -lgcc $system_libs -llog -lGLESv1_CM" + DEFINES="$DEFINES -D__ANDROID__ -DREDUCE_MEMORY_USAGE" ;; dc) INCLUDES="$INCLUDES "'-I$(srcdir)/backends/platform/dc -isystem $(ronindir)/include' -- cgit v1.2.3 From 57bc9b3f956674e3aa90ca7c8e5f753b6f9078ea Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 13 Feb 2011 11:28:33 +0100 Subject: ANDROID: Allow monolithic builds to run this gets rid of the "no plugins found, go to market, kthx" message, which doesn't make sense on monolithic builds (market only has ancient apk's anyway) --- backends/platform/android/org/inodes/gus/scummvm/Unpacker.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java b/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java index 7280aac7d4..f1489c4958 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java +++ b/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java @@ -34,7 +34,8 @@ import java.util.zip.ZipFile; import java.util.zip.ZipEntry; public class Unpacker extends Activity { - private final static boolean PLUGINS_ENABLED = true; + // TODO don't hardcode this + private final static boolean PLUGINS_ENABLED = false; private final static String META_NEXT_ACTIVITY = "org.inodes.gus.unpacker.nextActivity"; private ProgressBar mProgress; -- cgit v1.2.3 From 29d1df94db1c2c16646eba116591456fdc0d65a4 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 15:38:42 +0100 Subject: ANDROID: Allow out-of-src-tree builds, cleanup - move all android specific make stuff from module.mk to android.mk - don't create automatically generated files in the source tree - don't fail when building outside of the source tree - clean android build files on "make clean" - cleanup --- .gitignore | 5 +- backends/platform/android/android.mk | 184 ++++++++++++++++++++++++++++------- backends/platform/android/module.mk | 78 +-------------- 3 files changed, 153 insertions(+), 114 deletions(-) diff --git a/.gitignore b/.gitignore index 951ef3978d..74b4cc56f5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,9 +22,6 @@ lib*.a /.project /.cproject -/backends/platform/android/org/inodes/gus/scummvm/R.java -/backends/platform/android/org/inodes/gus/scummvm/Manifest.java - /backends/platform/dc/gui /backends/platform/dc/graphics /backends/platform/dc/sound @@ -142,4 +139,4 @@ _ReSharper*/ #Ignore default Visual Studio build folders [Dd]ebug/ -[Rr]elease/ \ No newline at end of file +[Rr]elease/ diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 95e848e0d9..ea2117c5a3 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -1,59 +1,173 @@ # Android specific build targets -AAPT = aapt -DX = dx -APKBUILDER = apkbuilder -ADB = adb -e -JAVAC ?= javac -JAVACFLAGS = -source 1.5 -target 1.5 +# These must be incremented for each market upload +#ANDROID_VERSIONCODE = 6 Specified in dists/android/AndroidManifest.xml.in +ANDROID_PLUGIN_VERSIONCODE = 6 + +JAVA_FILES = \ + ScummVM.java \ + ScummVMApplication.java \ + ScummVMActivity.java \ + EditableSurfaceView.java \ + Unpacker.java + +JAVA_FILES_PLUGIN = \ + PluginProvider.java + +JAVA_FILES_GEN = \ + Manifest.java \ + R.java + +PATH_DIST = $(srcdir)/dists/android +PATH_RESOURCES = $(PATH_DIST)/res + +RESOURCES = \ + $(PATH_RESOURCES)/values/strings.xml \ + $(PATH_RESOURCES)/layout/main.xml \ + $(PATH_RESOURCES)/layout/splash.xml \ + $(PATH_RESOURCES)/drawable/gradient.xml \ + $(PATH_RESOURCES)/drawable/scummvm.png \ + $(PATH_RESOURCES)/drawable/scummvm_big.png + +PLUGIN_RESOURCES = \ + $(PATH_RESOURCES)/values/strings.xml \ + $(PATH_RESOURCES)/drawable/scummvm.png # FIXME: find/mark plugin entry points and add all this back again: #LDFLAGS += -Wl,--gc-sections #CXXFLAGS += -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -resources.ap_: $(srcdir)/dists/android/AndroidManifest.xml $(RESOURCES) $(ASSETS) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) - $(INSTALL) -d build.tmp/assets/ - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) build.tmp/assets/ - $(AAPT) package -f -M $< -S $(srcdir)/dists/android/res -A build.tmp/assets -I $(ANDROID_JAR8) -F $@ - -build.tmp/%/resources.ap_: build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml build.stage/%/res/drawable/scummvm.png $(ANDROID_JAR8) - $(AAPT) package -f -M $< -S build.stage/$*/res -I $(ANDROID_JAR8) -F $@ - -scummvm.apk: build.tmp/libscummvm.so resources.ap_ classes.dex - # Package installer won't delete old libscummvm.so on upgrade so - # replace it with a zero size file - $(INSTALL) -d build.stage/common/lib/armeabi - touch build.stage/common/lib/armeabi/libscummvm.so - # We now handle the library unpacking ourselves from mylib/ - $(INSTALL) -d build.stage/common/mylib/armeabi - $(INSTALL) -c -m 644 build.tmp/libscummvm.so build.stage/common/mylib/armeabi/ - $(STRIP) build.stage/common/mylib/armeabi/libscummvm.so - # "-nf lib/armeabi/libscummvm.so" builds bogus paths? - $(APKBUILDER) $@ -z resources.ap_ -f classes.dex -rf build.stage/common || { $(RM) $@; exit 1; } - -scummvm-engine-%.apk: plugins/lib%.so build.tmp/%/resources.ap_ build.tmp/plugins/classes.dex - $(INSTALL) -d build.stage/$*/apk/mylib/armeabi/ - $(INSTALL) -c -m 644 plugins/lib$*.so build.stage/$*/apk/mylib/armeabi/ - $(STRIP) build.stage/$*/apk/mylib/armeabi/lib$*.so - $(APKBUILDER) $@ -z build.tmp/$*/resources.ap_ -f build.tmp/plugins/classes.dex -rf build.stage/$*/apk || { $(RM) $@; exit 1; } +AAPT = $(ANDROID_SDK)/platform-tools/aapt +ADB = $(ANDROID_SDK)/platform-tools/adb +DX = $(ANDROID_SDK)/platform-tools/dx +APKBUILDER = $(ANDROID_SDK)/tools/apkbuilder +JAVAC ?= javac +JAVACFLAGS = -source 1.5 -target 1.5 + +# This is a bit silly. I want to compile against the 1.6 android.jar, +# to make the compiler check that I don't use something that requires +# a newer Android. However, in order to use android:installLocation, +# we need to give aapt a version >=8 android.jar - even though the +# result will work ok on 1.5+. +ANDROID_JAR = $(ANDROID_SDK)/platforms/android-4/android.jar +ANDROID_JAR8 = $(ANDROID_SDK)/platforms/android-8/android.jar + +PATH_BUILD = build.tmp +PATH_BUILD_ASSETS = $(PATH_BUILD)/assets +PATH_BUILD_CLASSES_MAIN_TOP = $(PATH_BUILD)/classes.main +PATH_BUILD_CLASSES_PLUGIN_TOP = $(PATH_BUILD)/classes.plugin + +PATH_STAGE_PREFIX = build.stage +PATH_STAGE_MAIN = $(PATH_STAGE_PREFIX).main + +PATH_REL = org/inodes/gus/scummvm +PATH_SRC_TOP = $(srcdir)/backends/platform/android +PATH_SRC = $(PATH_SRC_TOP)/$(PATH_REL) + +PATH_GEN_TOP = $(PATH_BUILD)/java +PATH_GEN = $(PATH_GEN_TOP)/$(PATH_REL) +PATH_CLASSES_MAIN = $(PATH_BUILD_CLASSES_MAIN_TOP)/$(PATH_REL) +PATH_CLASSES_PLUGIN = $(PATH_BUILD_CLASSES_PLUGIN_TOP)/$(PATH_REL) + +FILE_MANIFEST = $(srcdir)/dists/android/AndroidManifest.xml +FILE_DEX = $(PATH_BUILD)/classes.dex +FILE_DEX_PLUGIN = $(PATH_BUILD)/plugins/classes.dex +FILE_RESOURCES = resources.ap_ +FILE_RESOURCES_MAIN = $(PATH_BUILD)/$(FILE_RESOURCES) + +SRC_GEN = $(addprefix $(PATH_GEN)/, $(JAVA_FILES_GEN)) + +CLASSES_MAIN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES:%.java=%.class)) +CLASSES_GEN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES_GEN:%.java=%.class)) +CLASSES_PLUGIN = $(addprefix $(PATH_CLASSES_PLUGIN)/, $(JAVA_FILES_PLUGIN:%.java=%.class)) + +APK_MAIN = scummvm.apk +APK_PLUGINS = $(patsubst plugins/lib%.so, scummvm-engine-%.apk, $(PLUGINS)) + +$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR8) + @$(MKDIR) -p $(PATH_GEN_TOP) + $(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR8) +$(PATH_CLASSES_MAIN)/%.class: $(PATH_GEN)/%.java $(SRC_GEN) + @$(MKDIR) -p $(@D) + $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $< + +$(PATH_CLASSES_MAIN)/%.class: $(PATH_SRC)/%.java $(SRC_GEN) + @$(MKDIR) -p $(@D) + $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP):$(PATH_GEN_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $< + +$(PATH_CLASSES_PLUGIN)/%.class: $(PATH_SRC)/%.java + @$(MKDIR) -p $(@D) + $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_PLUGIN_TOP) -bootclasspath $(ANDROID_JAR) $< + +$(FILE_DEX): $(CLASSES_MAIN) $(CLASSES_GEN) + $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_MAIN_TOP) + +$(FILE_DEX_PLUGIN): $(CLASSES_PLUGIN) + @$(MKDIR) -p $(@D) + $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_PLUGIN_TOP) + +$(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml: $(PATH_DIST)/mkmanifest.pl $(srcdir)/configure $(PATH_DIST)/AndroidManifest.xml + $(PATH_DIST)/mkmanifest.pl --id=$* --configure=$(srcdir)/configure \ + --version-name=$(VERSION) \ + --version-code=$(ANDROID_PLUGIN_VERSIONCODE) \ + --stringres=$(PATH_STAGE_PREFIX).$*/res/values/strings.xml \ + --manifest=$(PATH_BUILD)/$*/AndroidManifest.xml \ + --master-manifest=$(PATH_DIST)/AndroidManifest.xml \ + --unpacklib=mylib/armeabi/lib$*.so + +$(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scummvm.png + @$(MKDIR) -p $(@D) + $(CP) $< $@ + +$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) + $(INSTALL) -d $(PATH_BUILD_ASSETS) + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/ + $(AAPT) package -f -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR8) -F $@ + +$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png $(ANDROID_JAR8) + $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR8) -F $@ + +# Package installer won't delete old libscummvm.so on upgrade so +# replace it with a zero size file +$(APK_MAIN): $(EXECUTABLE) $(FILE_RESOURCES_MAIN) $(FILE_DEX) + $(INSTALL) -d $(PATH_STAGE_MAIN)/common/lib/armeabi + touch $(PATH_STAGE_MAIN)/common/lib/armeabi/libscummvm.so + $(INSTALL) -d $(PATH_STAGE_MAIN)/common/mylib/armeabi + $(INSTALL) -c -m 644 libscummvm.so $(PATH_STAGE_MAIN)/common/mylib/armeabi/ + $(STRIP) $(PATH_STAGE_MAIN)/common/mylib/armeabi/libscummvm.so + $(APKBUILDER) $@ -z $(FILE_RESOURCES_MAIN) -f $(FILE_DEX) -rf $(PATH_STAGE_MAIN)/common || { $(RM) $@; exit 1; } + +scummvm-engine-%.apk: plugins/lib%.so $(PATH_BUILD)/%/$(FILE_RESOURCES) $(FILE_DEX_PLUGIN) + $(INSTALL) -d $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/ + $(INSTALL) -c -m 644 plugins/lib$*.so $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/ + $(STRIP) $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/lib$*.so + $(APKBUILDER) $@ -z $(PATH_BUILD)/$*/$(FILE_RESOURCES) -f $(FILE_DEX_PLUGIN) -rf $(PATH_STAGE_PREFIX).$*/apk || { $(RM) $@; exit 1; } + +all: $(APK_MAIN) $(APK_PLUGINS) + +clean: androidclean + +androidclean: + @$(RM) -rf $(PATH_BUILD) $(PATH_STAGE_PREFIX).* *.apk release + +# remove debugging signature release/%.apk: %.apk @$(MKDIR) -p $(@D) @$(RM) $@ $(CP) $< $@.tmp - # remove debugging signature zip -d $@.tmp META-INF/\* jarsigner $(JARSIGNER_FLAGS) $@.tmp release zipalign 4 $@.tmp $@ $(RM) $@.tmp -androidrelease: release/scummvm.apk $(patsubst plugins/lib%.so,release/scummvm-engine-%.apk,$(PLUGINS)) +androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS)) -androidtest: scummvm.apk scummvm-engine-scumm.apk scummvm-engine-kyra.apk +androidtest: $(APK_MAIN) $(APK_PLUGINS) @set -e; for apk in $^; do \ - echo $(ADB) install -r $$apk; \ $(ADB) install -r $$apk; \ done $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.inodes.gus.scummvm/.Unpacker .PHONY: androidrelease androidtest + diff --git a/backends/platform/android/module.mk b/backends/platform/android/module.mk index b457b388b1..8b120b21ff 100644 --- a/backends/platform/android/module.mk +++ b/backends/platform/android/module.mk @@ -1,84 +1,12 @@ MODULE := backends/platform/android MODULE_OBJS := \ - android.o asset-archive.o video.o + android.o \ + asset-archive.o \ + video.o # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) OBJS := $(MODULE_OBJS) $(OBJS) MODULE_DIRS += $(sort $(dir $(MODULE_OBJS))) -JAVA_SRC = \ - $(MODULE)/org/inodes/gus/scummvm/ScummVM.java \ - $(MODULE)/org/inodes/gus/scummvm/ScummVMApplication.java \ - $(MODULE)/org/inodes/gus/scummvm/ScummVMActivity.java \ - $(MODULE)/org/inodes/gus/scummvm/EditableSurfaceView.java \ - $(MODULE)/org/inodes/gus/scummvm/Unpacker.java \ - $(MODULE)/org/inodes/gus/scummvm/Manifest.java \ - $(MODULE)/org/inodes/gus/scummvm/R.java - -JAVA_PLUGIN_SRC = \ - $(MODULE)/org/inodes/gus/scummvm/PluginProvider.java - -RESOURCES = \ - $(srcdir)/dists/android/res/values/strings.xml \ - $(srcdir)/dists/android/res/layout/main.xml \ - $(srcdir)/dists/android/res/layout/splash.xml \ - $(srcdir)/dists/android/res/drawable/gradient.xml \ - $(srcdir)/dists/android/res/drawable/scummvm.png \ - $(srcdir)/dists/android/res/drawable/scummvm_big.png - -ASSETS = $(DIST_FILES_ENGINEDATA) $(DIST_FILES_THEMES) - -PLUGIN_RESOURCES = \ - $(srcdir)/dists/android/res/values/strings.xml \ - $(srcdir)/dists/android/res/drawable/scummvm.png - -# These must be incremented for each market upload -#ANDROID_VERSIONCODE = 6 Specified in dists/android/AndroidManifest.xml.in -ANDROID_PLUGIN_VERSIONCODE = 6 - -# This is a bit silly. I want to compile against the 1.6 android.jar, -# to make the compiler check that I don't use something that requires -# a newer Android. However, in order to use android:installLocation, -# we need to give aapt a version >=8 android.jar - even though the -# result will work ok on 1.5+. -ANDROID_JAR = $(ANDROID_SDK)/platforms/android-1.5/android.jar -ANDROID_JAR8 = $(ANDROID_SDK)/platforms/android-8/android.jar - -# This library contains scummvm proper -build.tmp/libscummvm.so: $(OBJS) - @$(MKDIR) -p $(@D) - $(QUIET_LINK)$(CXX) -shared $(LDFLAGS) -Wl,-Bsymbolic -Wl,-soname,$(@F) -Wl,--no-undefined -o $@ $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LIBS) - - -backends/platform/android/org/inodes/gus/scummvm/R.java backends/platform/android/org/inodes/gus/scummvm/Manifest.java: $(srcdir)/dists/android/AndroidManifest.xml $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR8) - $(AAPT) package -m -J backends/platform/android -M $< -S $(srcdir)/dists/android/res -I $(ANDROID_JAR8) - -build.tmp/classes/%.class: $(srcdir)/backends/platform/android/%.java $(srcdir)/backends/platform/android/org/inodes/gus/scummvm/R.java - @$(MKDIR) -p $(@D) - $(JAVAC) $(JAVACFLAGS) -cp $(srcdir)/backends/platform/android -d build.tmp/classes -bootclasspath $(ANDROID_JAR) $< - -build.tmp/classes.plugin/%.class: $(srcdir)/backends/platform/android/%.java - @$(MKDIR) -p $(@D) - $(JAVAC) $(JAVACFLAGS) -cp $(srcdir)/backends/platform/android -d build.tmp/classes.plugin -bootclasspath $(ANDROID_JAR) $< - -classes.dex: $(JAVA_SRC:backends/platform/android/%.java=build.tmp/classes/%.class) - $(DX) --dex --output=$@ build.tmp/classes - -build.tmp/plugins/classes.dex: $(JAVA_PLUGIN_SRC:backends/platform/android/%.java=build.tmp/classes.plugin/%.class) - @$(MKDIR) -p $(@D) - $(DX) --dex --output=$@ build.tmp/classes.plugin - -build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml: dists/android/mkmanifest.pl configure dists/android/AndroidManifest.xml - dists/android/mkmanifest.pl --id=$* --configure=configure \ - --version-name=$(VERSION) \ - --version-code=$(ANDROID_PLUGIN_VERSIONCODE) \ - --stringres=build.stage/$*/res/values/strings.xml \ - --manifest=build.tmp/$*/AndroidManifest.xml \ - --master-manifest=dists/android/AndroidManifest.xml \ - --unpacklib=mylib/armeabi/lib$*.so - -build.stage/%/res/drawable/scummvm.png: dists/android/res/drawable/scummvm.png - @$(MKDIR) -p $(@D) - $(CP) $< $@ -- cgit v1.2.3 From 8de5edde9599b6ca00c23e753c00676d7bc9b335 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 16:03:52 +0100 Subject: ANDROID: Protect port files with our define get rid of -DANDROID and -DANDROID_BACKEND --- backends/platform/android/android.cpp | 4 ++-- backends/platform/android/asset-archive.cpp | 2 +- backends/platform/android/asset-archive.h | 2 +- backends/platform/android/video.cpp | 5 +++++ backends/platform/android/video.h | 2 +- configure | 1 - 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index efcee488a5..6502f94408 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -23,14 +23,14 @@ * */ +#if defined(__ANDROID__) + #include "backends/base-backend.h" #include "base/main.h" #include "graphics/surface.h" #include "backends/platform/android/video.h" -#if defined(ANDROID_BACKEND) - #include #include diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp index 20c6a653c0..bd32847f6a 100644 --- a/backends/platform/android/asset-archive.cpp +++ b/backends/platform/android/asset-archive.cpp @@ -23,7 +23,7 @@ * */ -#if defined(ANDROID) +#if defined(__ANDROID__) #include diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h index b3f6993c50..28e48426e9 100644 --- a/backends/platform/android/asset-archive.h +++ b/backends/platform/android/asset-archive.h @@ -23,7 +23,7 @@ * */ -#if defined(ANDROID) +#if defined(__ANDROID__) #include diff --git a/backends/platform/android/video.cpp b/backends/platform/android/video.cpp index 3275335d97..a64e322c95 100644 --- a/backends/platform/android/video.cpp +++ b/backends/platform/android/video.cpp @@ -23,6 +23,8 @@ * */ +#if defined(__ANDROID__) + #include "base/main.h" #include "graphics/surface.h" @@ -352,3 +354,6 @@ void GLESPaletteTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) GLESTexture::drawTexture(x, y, w, h); } + +#endif + diff --git a/backends/platform/android/video.h b/backends/platform/android/video.h index 2ca07e0afd..4b73508907 100644 --- a/backends/platform/android/video.h +++ b/backends/platform/android/video.h @@ -23,7 +23,7 @@ * */ -#if defined(ANDROID) +#if defined(__ANDROID__) #include diff --git a/configure b/configure index 41a375e196..3d8ad18ccd 100755 --- a/configure +++ b/configure @@ -1659,7 +1659,6 @@ if test -n "$_host"; then echo "Cross-compiling to $_host" case "$_host" in android) - DEFINES="$DEFINES -DANDROID -DANDROID_BACKEND" _unix=yes _need_memalign=yes # we link a .so as default -- cgit v1.2.3 From bf237c8d2c270014a95c40b7567db80ed787a67a Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 19:37:17 +0100 Subject: ANDROID: Unify log prefix adb logcat ScummVM:\* \*:S --- backends/platform/android/android.cpp | 8 +++---- .../org/inodes/gus/scummvm/PluginProvider.java | 4 +++- .../android/org/inodes/gus/scummvm/ScummVM.java | 19 +++++++-------- .../org/inodes/gus/scummvm/ScummVMActivity.java | 13 +++++------ .../android/org/inodes/gus/scummvm/Unpacker.java | 27 +++++++++++----------- backends/platform/android/video.cpp | 2 +- 6 files changed, 35 insertions(+), 38 deletions(-) diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 6502f94408..d3b7697e7a 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -1276,17 +1276,15 @@ void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) { switch (type) { case LogMessageType::kDebug: - BaseBackend::logMessage(type, message); + __android_log_write(ANDROID_LOG_DEBUG, LOG_TAG, message); break; case LogMessageType::kWarning: - __android_log_write(ANDROID_LOG_WARN, "ScummVM", message); + __android_log_write(ANDROID_LOG_WARN, LOG_TAG, message); break; case LogMessageType::kError: - // FIXME: From the name it looks like this will also quit the program. - // This shouldn't do that though. - __android_log_assert("Fatal error", "ScummVM", "%s", message); + __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, message); break; } } diff --git a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java b/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java index 840f3440d5..c94ab0a3ff 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java +++ b/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java @@ -13,6 +13,8 @@ import android.util.Log; import java.util.ArrayList; public class PluginProvider extends BroadcastReceiver { + private final static String LOG_TAG = "ScummVM"; + public final static String META_UNPACK_LIB = "org.inodes.gus.scummvm.meta.UNPACK_LIB"; @@ -28,7 +30,7 @@ public class PluginProvider extends BroadcastReceiver { .getReceiverInfo(new ComponentName(context, this.getClass()), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { - Log.e(this.toString(), "Error finding my own info?", e); + Log.e(LOG_TAG, "Error finding my own info?", e); return; } diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java index 6986f3988d..bb4a3dd061 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java +++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java @@ -33,7 +33,7 @@ import java.util.LinkedHashMap; // use the Java versions of most EGL functions :( public class ScummVM implements SurfaceHolder.Callback { - private final static String LOG_TAG = "ScummVM.java"; + protected final static String LOG_TAG = "ScummVM"; private final int AUDIO_FRAME_SIZE = 2 * 2; // bytes. 16bit audio * stereo public static class AudioSetupException extends Exception {} @@ -106,8 +106,7 @@ public class ScummVM implements SurfaceHolder.Callback { try { surfaceLock.acquire(); } catch (InterruptedException e) { - Log.e(this.toString(), - "Interrupted while waiting for surface lock", e); + Log.e(LOG_TAG, "Interrupted while waiting for surface lock", e); } } @@ -151,8 +150,7 @@ public class ScummVM implements SurfaceHolder.Callback { if (value[0] == EGL10.EGL_NONE) Log.d(LOG_TAG, entry.getKey() + ": NONE"); else - Log.d(LOG_TAG, String.format("%s: %d", - entry.getKey(), value[0])); + Log.d(LOG_TAG, String.format("%s: %d", entry.getKey(), value[0])); } } @@ -174,8 +172,7 @@ public class ScummVM implements SurfaceHolder.Callback { num_config); if (false) { - Log.d(LOG_TAG, - String.format("Found %d EGL configurations.", numConfigs)); + Log.d(LOG_TAG, String.format("Found %d EGL configurations.", numConfigs)); for (EGLConfig config : configs) dumpEglConfig(config); } @@ -184,8 +181,7 @@ public class ScummVM implements SurfaceHolder.Callback { // devices so we have to filter/rank the configs again ourselves. eglConfig = chooseEglConfig(configs); if (false) { - Log.d(LOG_TAG, - String.format("Chose EGL config from %d possibilities.", numConfigs)); + Log.d(LOG_TAG, String.format("Chose EGL config from %d possibilities.", numConfigs)); dumpEglConfig(eglConfig); } @@ -199,6 +195,7 @@ public class ScummVM implements SurfaceHolder.Callback { int best = 0; int bestScore = -1; int[] value = new int[1]; + for (int i = 0; i < configs.length; i++) { EGLConfig config = configs[i]; int score = 10000; @@ -255,7 +252,7 @@ public class ScummVM implements SurfaceHolder.Callback { eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, nativeSurface, null); if (eglSurface == EGL10.EGL_NO_SURFACE) - Log.e(LOG_TAG, "CreateWindowSurface failed!"); + Log.e(LOG_TAG, "CreateWindowSurface failed!"); egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); GL10 gl = (GL10)eglContext.getGL(); @@ -396,7 +393,7 @@ public class ScummVM implements SurfaceHolder.Callback { offset += ret; } } catch (InterruptedException e) { - Log.e(this.toString(), "Audio thread interrupted", e); + Log.e(LOG_TAG, "Audio thread interrupted", e); } } } diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java index b37b2b8a52..fae35b6695 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java @@ -73,7 +73,7 @@ public class ScummVMActivity extends Activity { @Override protected void displayMessageOnOSD(String msg) { - Log.i(this.toString(), "OSD: " + msg); + Log.i(LOG_TAG, "OSD: " + msg); Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show(); } @@ -137,6 +137,7 @@ public class ScummVMActivity extends Activity { } SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface); + main_surface.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return onTouchEvent(event); @@ -156,7 +157,7 @@ public class ScummVMActivity extends Activity { try { runScummVM(); } catch (Exception e) { - Log.e("ScummVM", "Fatal error in ScummVM thread", e); + Log.e(ScummVM.LOG_TAG, "Fatal error in ScummVM thread", e); new AlertDialog.Builder(ScummVMActivity.this) .setTitle("Error") .setMessage(e.toString()) @@ -174,8 +175,7 @@ public class ScummVMActivity extends Activity { try { scummvm.waitUntilRunning(); } catch (InterruptedException e) { - Log.e(this.toString(), - "Interrupted while waiting for ScummVM.initBackend", e); + Log.e(ScummVM.LOG_TAG, "Interrupted while waiting for ScummVM.initBackend", e); finish(); } @@ -190,7 +190,7 @@ public class ScummVMActivity extends Activity { "--config=" + getFileStreamPath("scummvmrc").getPath(), "--path=" + Environment.getExternalStorageDirectory().getPath(), "--gui-theme=scummmodern", - "--savepath=" + getDir("saves", 0).getPath(), + "--savepath=" + getDir("saves", 0).getPath() }; int ret = scummvm.scummVMMain(args); @@ -226,8 +226,7 @@ public class ScummVMActivity extends Activity { try { scummvm_thread.join(1000); // 1s timeout } catch (InterruptedException e) { - Log.i(this.toString(), - "Error while joining ScummVM thread", e); + Log.i(ScummVM.LOG_TAG, "Error while joining ScummVM thread", e); } } super.onStop(); diff --git a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java b/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java index f1489c4958..8811b1f3ae 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java +++ b/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java @@ -34,6 +34,7 @@ import java.util.zip.ZipFile; import java.util.zip.ZipEntry; public class Unpacker extends Activity { + protected final static String LOG_TAG = "ScummVM"; // TODO don't hardcode this private final static boolean PLUGINS_ENABLED = false; private final static String META_NEXT_ACTIVITY = @@ -89,11 +90,11 @@ public class Unpacker extends Activity { origIntent.getType()); //intent.fillIn(getIntent(), 0); intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); - Log.i(this.toString(), + Log.i(LOG_TAG, "Starting next activity with intent " + intent); startActivity(intent); } else { - Log.w(this.toString(), + Log.w(LOG_TAG, "Unable to extract a component name from " + nextActivity); } } @@ -129,12 +130,12 @@ public class Unpacker extends Activity { new ZipFile(context.getPackageResourcePath()); job = new UnpackJob(zipfile, new HashSet(1)); } catch (PackageManager.NameNotFoundException e) { - Log.e(this.toString(), "Package " + pkg + + Log.e(LOG_TAG, "Package " + pkg + " not found", e); continue; } catch (IOException e) { // FIXME: show some sort of GUI error dialog - Log.e(this.toString(), + Log.e(LOG_TAG, "Error opening ZIP for package " + pkg, e); continue; } @@ -146,7 +147,7 @@ public class Unpacker extends Activity { // Delete stale filenames from mUnpackDest for (File file: mUnpackDest.listFiles()) { if (!all_files.contains(file.getName())) { - Log.i(this.toString(), + Log.i(LOG_TAG, "Deleting stale cached file " + file); file.delete(); } @@ -178,14 +179,14 @@ public class Unpacker extends Activity { progress += zipentry.getSize(); } else { if (dest.exists()) - Log.d(this.toString(), + Log.d(LOG_TAG, "Replacing " + dest.getPath() + " old.mtime=" + dest.lastModified() + " new.mtime=" + zipentry.getTime() + " old.size=" + dest.length() + " new.size=" + zipentry.getSize()); else - Log.i(this.toString(), + Log.i(LOG_TAG, "Extracting " + zipentry.getName() + " from " + zipfile.getName() + " to " + dest.getPath()); @@ -216,12 +217,12 @@ public class Unpacker extends Activity { zipfile.close(); } catch (IOException e) { // FIXME: show some sort of GUI error dialog - Log.e(this.toString(), "Error unpacking plugin", e); + Log.e(LOG_TAG, "Error unpacking plugin", e); } } if (progress != total_size) - Log.d(this.toString(), "Ended with progress " + progress + + Log.d(LOG_TAG, "Ended with progress " + progress + " != total size " + total_size); setResult(RESULT_OK); @@ -235,7 +236,7 @@ public class Unpacker extends Activity { public void onReceive(Context context, Intent intent) { if (!intent.getAction() .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) { - Log.e(this.toString(), + Log.e(LOG_TAG, "Received unexpected action " + intent.getAction()); return; } @@ -324,7 +325,7 @@ public class Unpacker extends Activity { startActivityForResult(market_intent, REQUEST_MARKET); } catch (ActivityNotFoundException e) { - Log.e(this.toString(), + Log.e(LOG_TAG, "Error starting market", e); } } @@ -352,7 +353,7 @@ public class Unpacker extends Activity { switch (requestCode) { case REQUEST_MARKET: if (resultCode != RESULT_OK) - Log.w(this.toString(), "Market returned " + resultCode); + Log.w(LOG_TAG, "Market returned " + resultCode); tryUnpack(); break; } @@ -364,7 +365,7 @@ public class Unpacker extends Activity { .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); return ai.metaData; } catch (PackageManager.NameNotFoundException e) { - Log.w(this.toString(), "Unable to find my own meta-data", e); + Log.w(LOG_TAG, "Unable to find my own meta-data", e); return new Bundle(); } } diff --git a/backends/platform/android/video.cpp b/backends/platform/android/video.cpp index a64e322c95..e56c0da2af 100644 --- a/backends/platform/android/video.cpp +++ b/backends/platform/android/video.cpp @@ -44,7 +44,7 @@ #define TEXSUBIMAGE_IS_EXPENSIVE 0 #undef LOG_TAG -#define LOG_TAG "ScummVM-video" +#define LOG_TAG "ScummVM" #if 0 #define ENTER(args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, args) -- cgit v1.2.3 From 21c2dda5ba42d65cba71c3f27bb6679ecdd01c9e Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 19:38:15 +0100 Subject: ANDROID: Use and reinit texture on screen changes - EVENT_SCREEN_CHANGED must happen _after_ we have a new surface, not when the the old surface vanishes. fixes port on galaxy tab - textures have to be redefined with glTexImage2D() to make glTexSubImage2D() not fail on screen changes --- backends/platform/android/org/inodes/gus/scummvm/ScummVM.java | 3 +-- backends/platform/android/video.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java index bb4a3dd061..0e905f43a5 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java +++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java @@ -98,11 +98,10 @@ public class ScummVM implements SurfaceHolder.Callback { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // Disabled while I debug GL problems - //pushEvent(new Event(Event.EVENT_SCREEN_CHANGED)); + pushEvent(new Event(Event.EVENT_SCREEN_CHANGED)); } public void surfaceDestroyed(SurfaceHolder holder) { - pushEvent(new Event(Event.EVENT_SCREEN_CHANGED)); try { surfaceLock.acquire(); } catch (InterruptedException e) { diff --git a/backends/platform/android/video.cpp b/backends/platform/android/video.cpp index e56c0da2af..b9c3f9a1f8 100644 --- a/backends/platform/android/video.cpp +++ b/backends/platform/android/video.cpp @@ -135,7 +135,14 @@ GLESTexture::~GLESTexture() { } void GLESTexture::reinitGL() { + glDeleteTextures(1, &_texture_name); glGenTextures(1, &_texture_name); + + // bypass allocBuffer() shortcut to reinit the texture properly + _texture_width = 0; + _texture_height = 0; + + allocBuffer(_surface.w, _surface.h); setDirty(); } -- cgit v1.2.3 From ea2cfc44c0ce91267aa87173cfd02eb1c69d3147 Mon Sep 17 00:00:00 2001 From: dhewg Date: Mon, 14 Feb 2011 17:51:58 +0100 Subject: ANDROID: Fix assert() to log output add bionic replacement __assert2(), so we actually see what's happening --- backends/platform/android/android.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index d3b7697e7a..b59fc76a59 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -73,12 +73,20 @@ #undef JNIEXPORT #define JNIEXPORT __attribute__ ((visibility("default"))) -// This replaces the bionic libc assert message with something that +// This replaces the bionic libc assert functions with something that // actually prints the assertion failure before aborting. -extern "C" -void __assert(const char *file, int line, const char *expr) { - __android_log_assert(expr, LOG_TAG, "%s:%d: Assertion failure: %s", - file, line, expr); +extern "C" { + void __assert(const char *file, int line, const char *expr) { + __android_log_assert(expr, LOG_TAG, + "Assertion failure: '%s' in %s:%d", + expr, file, line); + } + + void __assert2(const char *file, int line, const char *func, const char *expr) { + __android_log_assert(expr, LOG_TAG, + "Assertion failure: '%s' in %s:%d (%s)", + expr, file, line, func); + } } static JavaVM *cached_jvm; -- cgit v1.2.3 From 2586e15e4ea6a365eced1888759630907b6b5870 Mon Sep 17 00:00:00 2001 From: dhewg Date: Mon, 14 Feb 2011 18:48:33 +0100 Subject: ANDROID: Fix JNI calls for the timer thread JNI calls can happen through the timer mechanism (hence from another thread). Attach the timer thread to the VM to prevent assert()s --- backends/platform/android/android.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index b59fc76a59..07fb1d5d98 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -102,10 +102,14 @@ static jfieldID FID_ScummVM_nativeScummVM; static jmethodID MID_Object_wait; JNIEnv* JNU_GetEnv() { - JNIEnv* env; - bool version_unsupported = - cached_jvm->GetEnv((void**)&env, JNI_VERSION_1_2); - assert(! version_unsupported); + JNIEnv* env = 0; + + jint res = cached_jvm->GetEnv((void**)&env, JNI_VERSION_1_2); + if (res != JNI_OK) { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GetEnv() failed: %d", res); + abort(); + } + return env; } @@ -453,6 +457,14 @@ void* OSystem_Android::timerThreadFunc(void* arg) { OSystem_Android* system = (OSystem_Android*)arg; DefaultTimerManager* timer = (DefaultTimerManager*)(system->_timer); + JNIEnv *env = 0; + jint res = cached_jvm->AttachCurrentThread(&env, 0); + + if (res != JNI_OK) { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "AttachCurrentThread() failed: %d", res); + abort(); + } + struct timespec tv; tv.tv_sec = 0; tv.tv_nsec = 100 * 1000 * 1000; // 100ms @@ -462,6 +474,13 @@ void* OSystem_Android::timerThreadFunc(void* arg) { nanosleep(&tv, NULL); } + res = cached_jvm->DetachCurrentThread(); + + if (res != JNI_OK) { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "DetachCurrentThread() failed: %d", res); + abort(); + } + return NULL; } -- cgit v1.2.3