diff --git a/Android/jni/Application.mk b/Android/jni/Application.mk index 2885d25d..6e8972fb 100644 --- a/Android/jni/Application.mk +++ b/Android/jni/Application.mk @@ -1,2 +1,3 @@ APP_ABI := armeabi armeabi-v7a ## TODO : x86 APP_PLATFORM := android-23 +APP_STL := gnustl_static diff --git a/Android/jni/apple2ix.mk b/Android/jni/apple2ix.mk index 05014fdd..58247c21 100644 --- a/Android/jni/apple2ix.mk +++ b/Android/jni/apple2ix.mk @@ -7,13 +7,25 @@ PACKAGE_NAME := "apple2ix" COMMON_SOURCES_MK := $(LOCAL_PATH)/sources.mk include $(COMMON_SOURCES_MK) +# ----------------------------------------------------------------------------- +# Breakpad crash reporter ... + +LOCAL_STATIC_LIBRARIES := breakpad_client + +# hmmm, Breakpad's README.ANDROID seems to suggest you shouldn't need to do this kludgery ... +BREAKPAD_SRC_PATH := $(APPLE2_SRC_PATH)/../externals/breakpad/src +BREAKPAD_CFLAGS := -I$(BREAKPAD_SRC_PATH) -I$(APPLE2_SRC_PATH)/common/android/include + # ----------------------------------------------------------------------------- # Android build config +LOCAL_CPP_EXTENSION := .C +LOCAL_CPPFLAGS := -std=gnu++11 + LOCAL_MODULE := libapple2ix -LOCAL_SRC_FILES := +LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/breakpad.C #LOCAL_ARM_MODE := arm -LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) +LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) $(BREAKPAD_CFLAGS) LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS) # Add assembly files first ... mostly for the benefit of the ARM assembler ... @@ -31,4 +43,5 @@ include $(BUILD_SHARED_LIBRARY) # --OR-- Build an executable so native can drive this show #include $(BUILD_EXECUTABLE) +$(call import-module, breakpad/android/google_breakpad) $(call import-module, android/cpufeatures) diff --git a/Android/jni/breakpad b/Android/jni/breakpad new file mode 120000 index 00000000..a9314ff2 --- /dev/null +++ b/Android/jni/breakpad @@ -0,0 +1 @@ +../../externals/breakpad \ No newline at end of file diff --git a/Android/jni/breakpad.mk b/Android/jni/breakpad.mk new file mode 120000 index 00000000..14e0616a --- /dev/null +++ b/Android/jni/breakpad.mk @@ -0,0 +1 @@ +breakpad/android/google_breakpad/Android.mk \ No newline at end of file diff --git a/Android/jni/build.sh b/Android/jni/build.sh index aa0edd70..7fd1c6bf 100755 --- a/Android/jni/build.sh +++ b/Android/jni/build.sh @@ -106,9 +106,9 @@ fi # build native sources if test "x$do_release" = "x1" ; then - ndk-build V=1 # NDK_TOOLCHAIN_VERSION=clang + ndk-build V=1 NDK_MODULE_PATH=. # NDK_TOOLCHAIN_VERSION=clang else - ndk-build V=1 NDK_DEBUG=1 # NDK_TOOLCHAIN_VERSION=clang + ndk-build V=1 NDK_MODULE_PATH=. NDK_DEBUG=1 # NDK_TOOLCHAIN_VERSION=clang fi ret=$? if test "x$ret" != "x0" ; then diff --git a/Android/jni/jnihooks.c b/Android/jni/jnihooks.c index fe818fa0..61f4c006 100644 --- a/Android/jni/jnihooks.c +++ b/Android/jni/jnihooks.c @@ -94,6 +94,14 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jobje return; } + data_dir = strdup(dataDir); + if (initializeCrashHandler) { + initializeCrashHandler(data_dir); + } + + (*env)->ReleaseStringUTFChars(env, j_dataDir, dataDir); + LOG("data_dir : %s", data_dir); + AndroidCpuFamily family = android_getCpuFamily(); uint64_t features = android_getCpuFeatures(); if (family == ANDROID_CPU_FAMILY_X86) { @@ -123,10 +131,6 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jobje } } - data_dir = strdup(dataDir); - (*env)->ReleaseStringUTFChars(env, j_dataDir, dataDir); - LOG("data_dir : %s", data_dir); - android_deviceSampleRateHz = (unsigned long)sampleRate; android_monoBufferSubmitSizeSamples = (unsigned long)monoBufferSize; android_stereoBufferSubmitSizeSamples = (unsigned long)stereoBufferSize; @@ -142,7 +146,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jobje } void Java_org_deadc0de_apple2ix_Apple2Activity_nativeGraphicsChanged(JNIEnv *env, jobject obj, jint width, jint height) { - LOG("%s", ""); + LOG("..."); video_backend->reshape(width, height); } @@ -158,7 +162,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnResume(JNIEnv *env, jobje if (!cpu_isPaused()) { return; } - LOG("%s", ""); + LOG("..."); if (!isSystemResume) { #if TESTING // test driver thread is managing CPU @@ -175,7 +179,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnPause(JNIEnv *env, jobjec if (cpu_isPaused()) { return; } - LOG("%s", ""); + LOG("..."); #if TESTING // test driver thread is managing CPU @@ -210,7 +214,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeRender(JNIEnv *env, jobject } void Java_org_deadc0de_apple2ix_Apple2Activity_nativeReboot(JNIEnv *env, jobject obj) { - LOG("%s", ""); + LOG("..."); cpu65_reboot(); } @@ -220,7 +224,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnQuit(JNIEnv *env, jobject #else shuttingDown = true; - LOG("%s", ""); + LOG("..."); c_eject_6(0); c_eject_6(1); @@ -327,7 +331,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeChooseDisk(JNIEnv *env, job } void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEjectDisk(JNIEnv *env, jobject obj, jboolean driveA) { - LOG("%s", ""); + LOG("..."); c_eject_6(!driveA); } diff --git a/Android/symbols/armeabi-v7a/.blank b/Android/symbols/armeabi-v7a/.blank new file mode 100644 index 00000000..e69de29b diff --git a/Android/symbols/armeabi/.blank b/Android/symbols/armeabi/.blank new file mode 100644 index 00000000..e69de29b diff --git a/Android/symbols/libapple2ix.so/.blank b/Android/symbols/libapple2ix.so/.blank new file mode 100644 index 00000000..e69de29b diff --git a/Android/toolchain_edits/adb_sanitize.c b/Android/toolchain_edits/adb_sanitize.c new file mode 100644 index 00000000..2123ab12 --- /dev/null +++ b/Android/toolchain_edits/adb_sanitize.c @@ -0,0 +1,107 @@ +// +// Sigh ... adb shell changes LF to CRLF in binary streams ... +// +// http://stackoverflow.com/questions/13578416/read-binary-stdout-data-from-adb-shell +// +// Problem: +// ( adb shell run-as com.example.someapp dd if=/data/data/com.example.someapp/some_binfile.bin 2\>/dev/null ) > local_binfile.bin +// +// * Without piping through adb_sanitize you would get a corrupted binary +// +// Fix: +// ( adb shell run-as com.example.someapp dd if=/data/data/com.example.someapp/some_binfile.bin 2\>/dev/null ) | adb_sanitize > local_binfile.bin +// +// Addenda: +// * The only other way to pull stuff from /data/data/... appears to be to use the heavyweight 'adb backup', yuck +// + +#include +#include +#include +#include +#include +#include + +// cribbed from AOSP and modified with usleep() and to also ignore EAGAIN +#undef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(exp) ({ \ + typeof (exp) _rc; \ + do { \ + _rc = (exp); \ + if (_rc == -1 && (errno == EINTR || errno == EAGAIN) ) { \ + usleep(10); \ + } else { \ + break; \ + } \ + } while (1); \ + _rc; }) + +static int _convert_crlf_to_lf(void) { + + const char CR = 0x0d; + const char LF = 0x0a; + + ssize_t inlen = 0; + char inbuf[BUFSIZ]; + char outbuf[BUFSIZ]; + bool sawCR = false; + char *errRd = NULL; + char *errWrt = NULL; + + while ( (inlen = TEMP_FAILURE_RETRY(read(STDIN_FILENO, inbuf, BUFSIZ))) ) { + if (inlen == -1) { + errRd = "error reading from stdin"; + break; + } + + // convert CRLF -> LF + + ssize_t outlen=0; + for (ssize_t i=0; i