aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/android')
-rw-r--r--backends/platform/android/android.cpp12
-rw-r--r--backends/platform/android/android.h8
-rw-r--r--backends/platform/android/android.mk200
-rw-r--r--backends/platform/android/asset-archive.cpp3
-rw-r--r--backends/platform/android/jni.cpp46
-rw-r--r--backends/platform/android/jni.h2
-rw-r--r--backends/platform/android/org/scummvm/scummvm/PluginProvider.java63
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVM.java7
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java7
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java31
-rw-r--r--backends/platform/android/org/scummvm/scummvm/Unpacker.java388
11 files changed, 56 insertions, 711 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 3ff1b939ef..798772cc24 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -396,12 +396,6 @@ void OSystem_Android::initBackend() {
EventsBaseBackend::initBackend();
}
-void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const {
- ENTER();
-
- JNI::getPluginDirectories(dirs);
-}
-
bool OSystem_Android::hasFeature(Feature f) {
return (f == kFeatureFullscreenMode ||
f == kFeatureAspectRatioCorrection ||
@@ -600,10 +594,4 @@ Common::String OSystem_Android::getSystemProperty(const char *name) const {
return Common::String(value, len);
}
-#ifdef DYNAMIC_MODULES
-void AndroidPluginProvider::addCustomDirectories(Common::FSList &dirs) const {
- ((OSystem_Android *)g_system)->addPluginDirectories(dirs);
-}
-#endif
-
#endif
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 28016f5e3e..ade84dd42d 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -96,13 +96,6 @@ extern void checkGlError(const char *expr, const char *file, int line);
#define GLTHREADCHECK do { } while (false)
#endif
-#ifdef DYNAMIC_MODULES
-class AndroidPluginProvider : public POSIXPluginProvider {
-protected:
- virtual void addCustomDirectories(Common::FSList &dirs) const;
-};
-#endif
-
class OSystem_Android : public EventsBaseBackend, public PaletteManager {
private:
// passed from the dark side
@@ -177,7 +170,6 @@ public:
virtual ~OSystem_Android();
virtual void initBackend();
- void addPluginDirectories(Common::FSList &dirs) const;
void enableZoning(bool enable) { _enable_zoning = enable; }
virtual bool hasFeature(Feature f);
diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk
index 69aa9d8303..e11ad0724e 100644
--- a/backends/platform/android/android.mk
+++ b/backends/platform/android/android.mk
@@ -2,200 +2,106 @@
# These must be incremented for each market upload
ANDROID_VERSIONCODE = 6
-ANDROID_PLUGIN_VERSIONCODE = 6
-JAVA_FILES = \
- ScummVM.java \
- ScummVMEvents.java \
- ScummVMEventsHoneycomb.java \
- ScummVMApplication.java \
- ScummVMActivity.java \
- EditableSurfaceView.java \
- MouseHelper.java \
- Unpacker.java
+ANDROID_TARGET_VERSION = 14
-JAVA_FILES_PLUGIN = \
- PluginProvider.java
-
-JAVA_FILES_GEN = \
- Manifest.java \
- R.java
+NDK_BUILD = $(ANDROID_NDK)/ndk-build APP_ABI=$(ABI)
+SDK_ANDROID = $(ANDROID_SDK)/tools/android
PATH_DIST = $(srcdir)/dists/android
PATH_RESOURCES = $(PATH_DIST)/res
PORT_DISTFILES = $(PATH_DIST)/README.Android
+DIST_JAVA_SRC_DIR = $(srcdir)/backends/platform/android/org
RESOURCES = \
- $(PATH_RESOURCES)/values/strings.xml \
- $(PATH_RESOURCES)/values/margins.xml \
- $(PATH_RESOURCES)/values-television/margins.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 \
- $(PATH_RESOURCES)/drawable-xhdpi/ouya_icon.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
-
-AAPT = $(ANDROID_SDK)/$(ANDROID_BTOOLS)/aapt
-ADB = $(ANDROID_SDK)/platform-tools/adb
-DX = $(ANDROID_SDK)/$(ANDROID_BTOOLS)/dx
-APKBUILDER = java -Xmx128M -classpath $(ANDROID_SDK)/tools/lib/sdklib.jar com.android.sdklib.build.ApkBuilderMain
-JAVAC ?= javac
-JAVACFLAGS = -source 1.5 -target 1.5
-
-ANDROID_JAR = $(ANDROID_SDK)/platforms/android-14/android.jar
+ $(PATH_BUILD_RES)/values/strings.xml \
+ $(PATH_BUILD_RES)/values-television/margins.xml \
+ $(PATH_BUILD_RES)/layout/main.xml \
+ $(PATH_BUILD_RES)/drawable/scummvm.png \
+ $(PATH_BUILD_RES)/drawable/scummvm_big.png \
+ $(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png
+
+DIST_ANDROID_MK = $(PATH_DIST)/jni/Android.mk
+DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml
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/scummvm/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)
+PATH_BUILD_RES = $(PATH_BUILD)/res
+PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/lib/$(ABI)/libscummvm.so
FILE_MANIFEST_SRC = $(srcdir)/dists/android/AndroidManifest.xml
FILE_MANIFEST = $(PATH_BUILD)/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-debug.apk
+APK_MAIN_RELEASE = ScummVM-release-unsigned.apk
-APK_MAIN = scummvm.apk
-APK_PLUGINS = $(patsubst plugins/lib%.so, scummvm-engine-%.apk, $(PLUGINS))
-
-$(FILE_MANIFEST): $(FILE_MANIFEST_SRC)
+$(FILE_MANIFEST): $(FILE_MANIFEST_SRC) | $(PATH_BUILD)
@$(MKDIR) -p $(@D)
sed "s/@ANDROID_VERSIONCODE@/$(ANDROID_VERSIONCODE)/" < $< > $@
-$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR)
- @$(MKDIR) -p $(PATH_GEN_TOP)
- $(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR)
-
-$(PATH_CLASSES_MAIN)/%.class: $(PATH_GEN)/%.java $(SRC_GEN)
+$(PATH_BUILD)/res/%: $(PATH_DIST)/res/% | $(PATH_BUILD)
@$(MKDIR) -p $(@D)
- $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $<
+ $(CP) $< $@
-$(PATH_CLASSES_MAIN)/%.class: $(PATH_SRC)/%.java $(SRC_GEN)
+$(PATH_BUILD)/libs/%: $(PATH_DIST)/libs/% | $(PATH_BUILD)
@$(MKDIR) -p $(@D)
- $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP):$(PATH_GEN_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $<
+ $(CP) $< $@
-$(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) $<
+$(PATH_BUILD_ASSETS): $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_SHADERS) $(DIST_BUILD_XML) | $(PATH_BUILD)
+ $(INSTALL) -d $(PATH_BUILD_ASSETS)
+ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/
+ $(INSTALL) -d $(PATH_BUILD)/jni
+ $(INSTALL) -c -m 644 $(DIST_ANDROID_MK) $(PATH_BUILD)/jni
+ $(INSTALL) -c -m 644 $(DIST_BUILD_XML) $(PATH_BUILD)
-$(FILE_DEX): $(CLASSES_MAIN) $(CLASSES_GEN)
- $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_MAIN_TOP)
+$(PATH_BUILD): $(DIST_ANDROID_MK)
+ $(MKDIR) -p $(PATH_BUILD) $(PATH_BUILD)/res
+ $(MKDIR) -p $(PATH_BUILD)/libs
-$(FILE_DEX_PLUGIN): $(CLASSES_PLUGIN)
- @$(MKDIR) -p $(@D)
- $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_PLUGIN_TOP)
+$(PATH_BUILD_LIBSCUMMVM): libscummvm.so | $(PATH_BUILD)
+ $(INSTALL) -c -m 644 libscummvm.so $(PATH_BUILD)
+ $(STRIP) $(PATH_BUILD)/libscummvm.so
+ cd $(PATH_BUILD); $(NDK_BUILD)
-$(PATH_BUILD)/%/AndroidManifest.xml: $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $(PATH_DIST)/plugin-manifest.xml
- @$(MKDIR) -p $(@D)
- $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $* $(PATH_DIST)/plugin-manifest.xml $(ANDROID_PLUGIN_VERSIONCODE) $@
+$(PATH_BUILD_RES): $(RESOURCES) | $(PATH_BUILD)
-$(PATH_STAGE_PREFIX).%/res/values/strings.xml: $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $(PATH_DIST)/plugin-manifest.xml
- @$(MKDIR) -p $(@D)
- $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $* $(PATH_DIST)/plugin-strings.xml $(ANDROID_PLUGIN_VERSIONCODE) $@
+setupapk: $(FILE_MANIFEST) $(PATH_BUILD_RES) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD)
+ $(SDK_ANDROID) update project -p $(PATH_BUILD) -t android-$(ANDROID_TARGET_VERSION) -n ScummVM
-$(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scummvm.png
- @$(MKDIR) -p $(@D)
- $(CP) $< $@
+$(APK_MAIN): setupapk | $(PATH_BUILD)
+ (cd $(PATH_BUILD); ant debug -Dsource.dir="$(realpath $(DIST_JAVA_SRC_DIR))")
+ $(CP) $(PATH_BUILD)/bin/ScummVM-debug.apk $@
-$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA)
- $(INSTALL) -d $(PATH_BUILD_ASSETS)
- $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/
- work_dir=`pwd`; \
- for i in $(PATH_BUILD_ASSETS)/*.zip; do \
- echo "recompress $$i"; \
- cd "$$work_dir"; \
- $(RM) -rf $(PATH_BUILD_ASSETS)/tmp; \
- $(MKDIR) $(PATH_BUILD_ASSETS)/tmp; \
- unzip -q $$i -d $(PATH_BUILD_ASSETS)/tmp; \
- cd $(PATH_BUILD_ASSETS)/tmp; \
- zip -r ../`basename $$i` *; \
- done
- @$(RM) -rf $(PATH_BUILD_ASSETS)/tmp
- $(AAPT) package -f -0 zip -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR) -F $@
-
-$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png plugins/lib%.so $(ANDROID_JAR)
- $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR) -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)
+$(APK_MAIN_RELEASE): setupapk | $(PATH_BUILD)
+ (cd $(PATH_BUILD); ant release -Dsource.dir="$(realpath $(DIST_JAVA_SRC_DIR))")
+ $(CP) $(PATH_BUILD)/bin/ScummVM-release-unsigned.apk $@
+
+all: $(APK_MAIN)
clean: androidclean
androidclean:
- @$(RM) -rf $(PATH_BUILD) $(PATH_STAGE_PREFIX).* *.apk release
-
-# remove debugging signature
-release/%.apk: %.apk
- @$(MKDIR) -p $(@D)
- @$(RM) $@
- $(CP) $< $@.tmp
- zip -d $@.tmp META-INF/\*
- jarsigner $(JARSIGNER_FLAGS) $@.tmp release
- zipalign 4 $@.tmp $@
- $(RM) $@.tmp
+ @$(RM) -rf $(PATH_BUILD) *.apk release
-androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS))
+androidrelease: $(APK_MAIN_RELEASE)
androidtestmain: $(APK_MAIN)
$(ADB) install -r $(APK_MAIN)
- $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker
+ $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.ScummVMActivity
-androidtest: $(APK_MAIN) $(APK_PLUGINS)
+androidtest: $(APK_MAIN)
@set -e; for apk in $^; do \
$(ADB) install -r $$apk; \
done
- $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker
+ $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.ScummVMActivity
# used by buildbot!
androiddistdebug: all
$(MKDIR) debug
- $(CP) $(APK_MAIN) $(APK_PLUGINS) debug/
+ $(CP) $(APK_MAIN) debug/
for i in $(DIST_FILES_DOCS) $(PORT_DISTFILES); do \
sed 's/$$/\r/' < $$i > debug/`basename $$i`.txt; \
done
-.PHONY: androidrelease androidtest
+.PHONY: androidrelease androidtest $(PATH_BUILD_SRC)
diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp
index 52c2c084bd..6680081c16 100644
--- a/backends/platform/android/asset-archive.cpp
+++ b/backends/platform/android/asset-archive.cpp
@@ -295,7 +295,6 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
jclass cls = env->GetObjectClass(_assetfd);
MID_close = env->GetMethodID(cls, "close", "()V");
assert(MID_close);
- env->DeleteLocalRef(cls);
jmethodID MID_getStartOffset =
env->GetMethodID(cls, "getStartOffset", "()J");
@@ -321,6 +320,8 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
_fd = env->GetIntField(javafd, FID_descriptor);
env->DeleteLocalRef(javafd);
+
+ env->DeleteLocalRef(cls);
}
AssetFdReadStream::~AssetFdReadStream() {
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 764c84ce1c..22e6a749c2 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -79,7 +79,6 @@ jmethodID JNI::_MID_displayMessageOnOSD = 0;
jmethodID JNI::_MID_setWindowCaption = 0;
jmethodID JNI::_MID_showVirtualKeyboard = 0;
jmethodID JNI::_MID_getSysArchives = 0;
-jmethodID JNI::_MID_getPluginDirectories = 0;
jmethodID JNI::_MID_initSurface = 0;
jmethodID JNI::_MID_deinitSurface = 0;
@@ -293,46 +292,6 @@ void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
}
}
-void JNI::getPluginDirectories(Common::FSList &dirs) {
- JNIEnv *env = JNI::getEnv();
-
- jobjectArray array =
- (jobjectArray)env->CallObjectMethod(_jobj, _MID_getPluginDirectories);
-
- if (env->ExceptionCheck()) {
- LOGE("Error finding plugin directories");
-
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- return;
- }
-
- jsize size = env->GetArrayLength(array);
- for (jsize i = 0; i < size; ++i) {
- jstring path_obj = (jstring)env->GetObjectArrayElement(array, i);
-
- if (path_obj == 0)
- continue;
-
- const char *path = env->GetStringUTFChars(path_obj, 0);
-
- if (path == 0) {
- LOGE("Error getting string characters from plugin directory");
-
- env->ExceptionClear();
- env->DeleteLocalRef(path_obj);
-
- continue;
- }
-
- dirs.push_back(Common::FSNode(path));
-
- env->ReleaseStringUTFChars(path_obj, path);
- env->DeleteLocalRef(path_obj);
- }
-}
-
bool JNI::initSurface() {
JNIEnv *env = JNI::getEnv();
@@ -454,7 +413,6 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V");
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
- FIND_METHOD(, getPluginDirectories, "()[Ljava/lang/String;");
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
FIND_METHOD(, deinitSurface, "()V");
@@ -543,10 +501,6 @@ jint JNI::main(JNIEnv *env, jobject self, jobjectArray args) {
env->DeleteLocalRef(arg);
}
-#ifdef DYNAMIC_MODULES
- PluginManager::instance().addPluginProvider(new AndroidPluginProvider());
-#endif
-
LOGI("Entering scummvm_main with %d args", argc);
res = scummvm_main(argc, argv);
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index 326869b1ee..70feaaf72a 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -55,7 +55,6 @@ public:
static void setReadyForEvents(bool ready);
- static void getPluginDirectories(Common::FSList &dirs);
static void setWindowCaption(const char *caption);
static void getDPI(float *values);
static void displayMessageOnOSD(const char *msg);
@@ -93,7 +92,6 @@ private:
static jmethodID _MID_setWindowCaption;
static jmethodID _MID_showVirtualKeyboard;
static jmethodID _MID_getSysArchives;
- static jmethodID _MID_getPluginDirectories;
static jmethodID _MID_initSurface;
static jmethodID _MID_deinitSurface;
diff --git a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java
deleted file mode 100644
index e27e8d41a8..0000000000
--- a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.scummvm.scummvm;
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Bundle;
-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.scummvm.scummvm.meta.UNPACK_LIB";
-
- public void onReceive(Context context, Intent intent) {
- if (!intent.getAction().equals(ScummVMApplication.ACTION_PLUGIN_QUERY))
- return;
-
- Bundle extras = getResultExtras(true);
-
- final ActivityInfo info;
- final PackageInfo pinfo;
- try {
- info = context.getPackageManager()
- .getReceiverInfo(new ComponentName(context, this.getClass()),
- PackageManager.GET_META_DATA);
- pinfo = context.getPackageManager()
- .getPackageInfo(context.getPackageName(), 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Error finding my own info?", e);
- return;
- }
-
- String host_version = extras.getString(ScummVMApplication.EXTRA_VERSION);
- if (!pinfo.versionName.equals(host_version)) {
- Log.e(LOG_TAG, "Plugin version " + pinfo.versionName + " is not equal to ScummVM version " + host_version);
- return;
- }
-
- String mylib = info.metaData.getString(META_UNPACK_LIB);
- if (mylib != null) {
- ArrayList<String> all_libs =
- extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS);
- all_libs.add(new Uri.Builder()
- .scheme("plugin")
- .authority(context.getPackageName())
- .path(mylib)
- .toString());
-
- extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS,
- all_libs);
- }
-
- setResultExtras(extras);
- }
-}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 5047502e61..3b370a583d 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -54,7 +54,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
abstract protected void getDPI(float[] values);
abstract protected void displayMessageOnOSD(String msg);
abstract protected void setWindowCaption(String caption);
- abstract protected String[] getPluginDirectories();
abstract protected void showVirtualKeyboard(boolean enable);
abstract protected String[] getSysArchives();
@@ -444,10 +443,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
}
}
- File cache_dir = ScummVMApplication.getLastCacheDir();
- String libname = System.mapLibraryName("scummvm");
- File libpath = new File(cache_dir, libname);
-
- System.load(libpath.getPath());
+ System.loadLibrary("scummvm");
}
}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index f4eb7ddd0b..5b2dcae175 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -84,13 +84,6 @@ public class ScummVMActivity extends Activity {
}
@Override
- protected String[] getPluginDirectories() {
- String[] dirs = new String[1];
- dirs[0] = ScummVMApplication.getLastCacheDir().getPath();
- return dirs;
- }
-
- @Override
protected void showVirtualKeyboard(final boolean enable) {
runOnUiThread(new Runnable() {
public void run() {
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java
deleted file mode 100644
index 0adc166222..0000000000
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.scummvm.scummvm;
-
-import android.app.Application;
-
-import java.io.File;
-
-public class ScummVMApplication extends Application {
- public final static String ACTION_PLUGIN_QUERY = "org.scummvm.scummvm.action.PLUGIN_QUERY";
- public final static String EXTRA_UNPACK_LIBS = "org.scummvm.scummvm.extra.UNPACK_LIBS";
- public final static String EXTRA_VERSION = "org.scummvm.scummvm.extra.VERSION";
-
- private static File _cache_dir;
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- // This is still on /data :(
- _cache_dir = getCacheDir();
- // This is mounted noexec :(
- //cache_dir = new File(Environment.getExternalStorageDirectory(),
- // "/.ScummVM.tmp");
- // This is owned by download manager and requires special
- // permissions to access :(
- //cache_dir = Environment.getDownloadCacheDirectory();
- }
-
- public static File getLastCacheDir() {
- return _cache_dir;
- }
-}
diff --git a/backends/platform/android/org/scummvm/scummvm/Unpacker.java b/backends/platform/android/org/scummvm/scummvm/Unpacker.java
deleted file mode 100644
index da76ceb5e5..0000000000
--- a/backends/platform/android/org/scummvm/scummvm/Unpacker.java
+++ /dev/null
@@ -1,388 +0,0 @@
-package org.scummvm.scummvm;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ActivityNotFoundException;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.ContextWrapper;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.ProgressBar;
-
-import java.io.IOException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-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 =
- "org.scummvm.unpacker.nextActivity";
- private ProgressBar mProgress;
- private File mUnpackDest; // location to unpack into
- private AsyncTask<String, Integer, Void> mUnpacker;
- private final static int REQUEST_MARKET = 1;
-
- // Android 3.1+ only
- public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 32;
-
- private static class UnpackJob {
- public ZipFile zipfile;
- public Set<String> paths;
-
- public UnpackJob(ZipFile zipfile, Set<String> paths) {
- this.zipfile = zipfile;
- this.paths = paths;
- }
-
- public long UnpackSize() {
- long size = 0;
- for (String path: paths) {
- ZipEntry entry = zipfile.getEntry(path);
- if (entry != null) size += entry.getSize();
- }
- return size;
- }
- }
-
- private class UnpackTask extends AsyncTask<String, Integer, Void> {
- @Override
- protected void onProgressUpdate(Integer... progress) {
- mProgress.setIndeterminate(false);
- mProgress.setMax(progress[1]);
- mProgress.setProgress(progress[0]);
- mProgress.postInvalidate();
- }
-
- @Override
- protected void onPostExecute(Void result) {
- Bundle md = getMetaData();
- String nextActivity = md.getString(META_NEXT_ACTIVITY);
- if (nextActivity != null) {
- final ComponentName cn =
- ComponentName.unflattenFromString(nextActivity);
- if (cn != null) {
- final Intent origIntent = getIntent();
- Intent intent = new Intent();
- intent.setComponent(cn);
- if (origIntent.getExtras() != null)
- intent.putExtras(origIntent.getExtras());
- intent.putExtra(Intent.EXTRA_INTENT, origIntent);
- intent.setDataAndType(origIntent.getData(),
- origIntent.getType());
- //intent.fillIn(getIntent(), 0);
- intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
- Log.i(LOG_TAG,
- "Starting next activity with intent " + intent);
- startActivity(intent);
- } else {
- Log.w(LOG_TAG,
- "Unable to extract a component name from " + nextActivity);
- }
- }
-
- finish();
- }
-
- @Override
- protected Void doInBackground(String... all_libs) {
- // This will contain all unpack jobs
- Map<String, UnpackJob> unpack_jobs =
- new HashMap<String, UnpackJob>(all_libs.length);
-
- // This will contain all unpack filenames (so we can
- // detect stale files in the unpack directory)
- Set<String> all_files = new HashSet<String>(all_libs.length);
-
- for (String lib: all_libs) {
- final Uri uri = Uri.parse(lib);
- final String pkg = uri.getAuthority();
- final String path = uri.getPath().substring(1); // skip first /
-
- all_files.add(new File(path).getName());
-
- UnpackJob job = unpack_jobs.get(pkg);
- if (job == null) {
- try {
- // getPackageResourcePath is hidden in Context,
- // but exposed in ContextWrapper...
- ContextWrapper context =
- new ContextWrapper(createPackageContext(pkg, 0));
- ZipFile zipfile =
- new ZipFile(context.getPackageResourcePath());
- job = new UnpackJob(zipfile, new HashSet<String>(1));
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Package " + pkg +
- " not found", e);
- continue;
- } catch (IOException e) {
- // FIXME: show some sort of GUI error dialog
- Log.e(LOG_TAG,
- "Error opening ZIP for package " + pkg, e);
- continue;
- }
- unpack_jobs.put(pkg, job);
- }
- job.paths.add(path);
- }
-
- // Delete stale filenames from mUnpackDest
- for (File file: mUnpackDest.listFiles()) {
- if (!all_files.contains(file.getName())) {
- Log.i(LOG_TAG,
- "Deleting stale cached file " + file);
- file.delete();
- }
- }
-
- int total_size = 0;
- for (UnpackJob job: unpack_jobs.values())
- total_size += job.UnpackSize();
-
- publishProgress(0, total_size);
-
- mUnpackDest.mkdirs();
-
- int progress = 0;
-
- for (UnpackJob job: unpack_jobs.values()) {
- try {
- ZipFile zipfile = job.zipfile;
- for (String path: job.paths) {
- ZipEntry zipentry = zipfile.getEntry(path);
- if (zipentry == null)
- throw new FileNotFoundException(
- "Couldn't find " + path + " in zip");
- File dest = new File(mUnpackDest, new File(path).getName());
- if (dest.exists() &&
- dest.lastModified() == zipentry.getTime() &&
- dest.length() == zipentry.getSize()) {
- // Already unpacked
- progress += zipentry.getSize();
- } else {
- if (dest.exists())
- 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(LOG_TAG,
- "Extracting " + zipentry.getName() +
- " from " + zipfile.getName() +
- " to " + dest.getPath());
-
- long next_update = progress;
-
- InputStream in = zipfile.getInputStream(zipentry);
- OutputStream out = new FileOutputStream(dest);
- int len;
- byte[] buffer = new byte[4096];
- while ((len = in.read(buffer)) != -1) {
- out.write(buffer, 0, len);
- progress += len;
- if (progress >= next_update) {
- publishProgress(progress, total_size);
- // Arbitrary limit of 2% update steps
- next_update += total_size / 50;
- }
- }
-
- in.close();
- out.close();
- dest.setLastModified(zipentry.getTime());
- }
- publishProgress(progress, total_size);
- }
-
- zipfile.close();
- } catch (IOException e) {
- // FIXME: show some sort of GUI error dialog
- Log.e(LOG_TAG, "Error unpacking plugin", e);
- }
- }
-
- if (progress != total_size)
- Log.d(LOG_TAG, "Ended with progress " + progress +
- " != total size " + total_size);
-
- setResult(RESULT_OK);
-
- return null;
- }
- }
-
- private class PluginBroadcastReciever extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (!intent.getAction()
- .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) {
- Log.e(LOG_TAG,
- "Received unexpected action " + intent.getAction());
- return;
- }
-
- Bundle extras = getResultExtras(false);
- if (extras == null) {
- // Nothing for us to do.
- Unpacker.this.setResult(RESULT_OK);
- finish();
- }
-
- ArrayList<String> unpack_libs =
- extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS);
-
- if (unpack_libs != null && !unpack_libs.isEmpty()) {
- final String[] libs =
- unpack_libs.toArray(new String[unpack_libs.size()]);
- mUnpacker = new UnpackTask().execute(libs);
- }
- }
- }
-
- private void initPlugins() {
- Bundle extras = new Bundle(1);
-
- ArrayList<String> unpack_libs = new ArrayList<String>(1);
- // This is the common ScummVM code (not really a "plugin" as such)
- unpack_libs.add(new Uri.Builder()
- .scheme("plugin")
- .authority(getPackageName())
- .path("mylib/armeabi/libscummvm.so")
- .toString());
- extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS,
- unpack_libs);
-
- final PackageInfo info;
- try {
- info = getPackageManager().getPackageInfo(getPackageName(), 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Error finding my own info?", e);
- return;
- }
- extras.putString(ScummVMApplication.EXTRA_VERSION, info.versionName);
-
- Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY);
- // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since
- // none of our plugins will ever be running, that is not helpful
- intent.setFlags(FLAG_INCLUDE_STOPPED_PACKAGES);
- sendOrderedBroadcast(intent, Manifest.permission.SCUMMVM_PLUGIN,
- new PluginBroadcastReciever(),
- null, RESULT_OK, null, extras);
- }
-
- @Override
- public void onCreate(Bundle b) {
- super.onCreate(b);
-
- mUnpackDest = ScummVMApplication.getLastCacheDir();
-
- setContentView(R.layout.splash);
- mProgress = (ProgressBar)findViewById(R.id.progress);
-
- setResult(RESULT_CANCELED);
-
- tryUnpack();
- }
-
- private void tryUnpack() {
- Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY);
- List<ResolveInfo> plugins = getPackageManager()
- .queryBroadcastReceivers(intent, 0);
- if (PLUGINS_ENABLED && plugins.isEmpty()) {
- // No plugins installed
- AlertDialog.Builder alert = new AlertDialog.Builder(this)
- .setTitle(R.string.no_plugins_title)
- .setMessage(R.string.no_plugins_found)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- finish();
- }
- })
- .setNegativeButton(R.string.quit,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- finish();
- }
- });
-
- final Uri uri = Uri.parse("market://search?q=ScummVM plugin");
- final Intent market_intent = new Intent(Intent.ACTION_VIEW, uri);
- if (getPackageManager().resolveActivity(market_intent, 0) != null) {
- alert.setPositiveButton(R.string.to_market,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- try {
- startActivityForResult(market_intent,
- REQUEST_MARKET);
- } catch (ActivityNotFoundException e) {
- Log.e(LOG_TAG,
- "Error starting market", e);
- }
- }
- });
- }
-
- alert.show();
-
- } else {
- // Already have at least one plugin installed
- initPlugins();
- }
- }
-
- @Override
- public void onStop() {
- if (mUnpacker != null)
- mUnpacker.cancel(true);
- super.onStop();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode,
- Intent data) {
- switch (requestCode) {
- case REQUEST_MARKET:
- if (resultCode != RESULT_OK)
- Log.w(LOG_TAG, "Market returned " + resultCode);
- tryUnpack();
- break;
- }
- }
-
- private Bundle getMetaData() {
- try {
- ActivityInfo ai = getPackageManager()
- .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
- return ai.metaData;
- } catch (PackageManager.NameNotFoundException e) {
- Log.w(LOG_TAG, "Unable to find my own meta-data", e);
- return new Bundle();
- }
- }
-}