A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

android: Get the port up and running again

The build system needed fixes because the tools paths changed and one tool that
we used (apkbuilder) was removed entirely. Recent NDKs don't ship gcc 4.4.3
anymore, therefore switch to 4.6. The code itself needed a fix for a jni
reference bug that was uncovered by KitKat.

The port now builds with latest sdk (r22) and ndk (r9d).

Change-Id: Id74fa54ba93bbb0ee30373fbe79e92c5ff03201d

+60 -52
+1
android/.classpath
··· 4 4 <classpathentry kind="src" path="src"/> 5 5 <classpathentry kind="src" path="gen"/> 6 6 <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> 7 + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> 7 8 <classpathentry kind="output" path="bin/classes"/> 8 9 </classpath>
+6 -6
android/android.make
··· 28 28 .PHONY: apk classes clean dex dirs libs jar 29 29 30 30 # API version 31 - ANDROID_PLATFORM_VERSION=16 31 + ANDROID_PLATFORM_VERSION=19 32 32 ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION) 33 33 34 34 # android tools 35 - AAPT=$(ANDROID_SDK_PATH)/platform-tools/aapt 36 - DX=$(ANDROID_SDK_PATH)/platform-tools/dx 37 - APKBUILDER=$(ANDROID_SDK_PATH)/tools/apkbuilder 35 + BUILD_TOOLS_VERSION=19.0.3 36 + AAPT=$(ANDROID_SDK_PATH)/build-tools/$(BUILD_TOOLS_VERSION)/aapt 37 + DX=$(ANDROID_SDK_PATH)/build-tools/$(BUILD_TOOLS_VERSION)/dx 38 38 ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign 39 39 KEYSTORE=$(HOME)/.android/debug.keystore 40 40 ADB=$(ANDROID_SDK_PATH)/platform-tools/adb 41 + BUILDAPK=$(ANDROID_DIR)/buildapk.sh 41 42 42 43 CLASSPATH := $(BUILDDIR)/bin/classes 43 44 ··· 130 131 libs: $(DIRS) $(LIBS) 131 132 132 133 $(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS) 133 - $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \ 134 - -u -z $(AP_) -f $(DEX) -nf $(BUILDDIR)/libs 134 + $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(BUILDAPK) $(BUILDDIR) $(notdir $@) $(BUILD_TOOLS_VERSION) 135 135 136 136 $(KEYSTORE): 137 137 $(SILENT)mkdir -p $(HOME)/.android
+19
android/buildapk.sh
··· 1 + #!/bin/sh 2 + 3 + BUILDDIR=$1 4 + APK=$2 5 + SDKV=$3 6 + 7 + [ -z $ANDROID_SDK_PATH ] && exit 1 8 + [ -z $BUILDDIR ] && exit 1 9 + [ -d $BUILDDIR ] || exit 1 10 + 11 + # need to cd into the bin dir and create a symlink to the libraries 12 + # so that aapt puts the libraries with the correct prefix into the apk 13 + cd $BUILDDIR/bin 14 + ln -nfs $BUILDDIR/libs lib 15 + cp resources.ap_ $APK 16 + $ANDROID_SDK_PATH/build-tools/$SDKV/aapt add $APK classes.dex > /dev/null 17 + $ANDROID_SDK_PATH/build-tools/$SDKV/aapt add $APK lib/*/* > /dev/null 18 + 19 + exit 0
+1 -1
android/project.properties
··· 8 8 # project structure. 9 9 10 10 # Project target. 11 - target=android-16 11 + target=android-19
+2 -8
android/src/org/rockbox/RockboxFramebuffer.java
··· 57 57 setEnabled(false); 58 58 } 59 59 60 - /* second stage init; called from Rockbox with information about the 61 - * display framebuffer */ 62 - private void initialize(int lcd_width, int lcd_height) 63 - { 64 - btm = Bitmap.createBitmap(lcd_width, lcd_height, Bitmap.Config.RGB_565); 65 - setEnabled(true); 66 - } 67 - 68 60 private void update(ByteBuffer framebuffer) 69 61 { 70 62 SurfaceHolder holder = getHolder(); ··· 138 130 public native void surfaceDestroyed(SurfaceHolder holder); 139 131 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) 140 132 { 133 + btm = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); 134 + setEnabled(true); 141 135 } 142 136 }
+29 -33
firmware/target/hosted/android/lcd-android.c
··· 34 34 static jobject RockboxFramebuffer_instance; 35 35 static jmethodID java_lcd_update; 36 36 static jmethodID java_lcd_update_rect; 37 - static jmethodID java_lcd_init; 38 37 39 38 static jclass AndroidRect_class; 40 39 static jmethodID AndroidRect_constructor; ··· 42 41 static int dpi; 43 42 static int scroll_threshold; 44 43 static bool display_on; 44 + static bool connected; 45 45 46 46 /* this might actually be called before lcd_init_device() or even main(), so 47 47 * be sure to only access static storage initalized at library loading, ··· 49 49 static void connect_with_java(JNIEnv* env, jobject fb_instance) 50 50 { 51 51 JNIEnv e = *env; 52 - static bool have_class; 53 52 54 - if (!have_class) 55 - { 56 - jclass fb_class = e->GetObjectClass(env, fb_instance); 57 - /* cache update functions */ 58 - java_lcd_update = e->GetMethodID(env, fb_class, 59 - "update", 60 - "(Ljava/nio/ByteBuffer;)V"); 61 - java_lcd_update_rect = e->GetMethodID(env, fb_class, 62 - "update", 63 - "(Ljava/nio/ByteBuffer;" 64 - "Landroid/graphics/Rect;)V"); 65 - jmethodID get_dpi = e->GetMethodID(env, fb_class, 66 - "getDpi", "()I"); 67 - jmethodID thresh = e->GetMethodID(env, fb_class, 68 - "getScrollThreshold", "()I"); 69 - /* these don't change with new instances so call them now */ 70 - dpi = e->CallIntMethod(env, fb_instance, get_dpi); 71 - scroll_threshold = e->CallIntMethod(env, fb_instance, thresh); 72 - 73 - java_lcd_init = e->GetMethodID(env, fb_class, 74 - "initialize", "(II)V"); 75 - AndroidRect_class = e->FindClass(env, "android/graphics/Rect"); 76 - AndroidRect_constructor = e->GetMethodID(env, AndroidRect_class, 77 - "<init>", "(IIII)V"); 78 - have_class = true; 79 - } 53 + jclass fb_class = e->GetObjectClass(env, fb_instance); 54 + /* cache update functions */ 55 + java_lcd_update = e->GetMethodID(env, fb_class, 56 + "update", 57 + "(Ljava/nio/ByteBuffer;)V"); 58 + java_lcd_update_rect = e->GetMethodID(env, fb_class, 59 + "update", 60 + "(Ljava/nio/ByteBuffer;" 61 + "Landroid/graphics/Rect;)V"); 62 + jmethodID get_dpi = e->GetMethodID(env, fb_class, 63 + "getDpi", "()I"); 64 + jmethodID thresh = e->GetMethodID(env, fb_class, 65 + "getScrollThreshold", "()I"); 66 + /* these don't change with new instances so call them now */ 67 + dpi = e->CallIntMethod(env, fb_instance, get_dpi); 68 + scroll_threshold = e->CallIntMethod(env, fb_instance, thresh); 80 69 81 - /* we need to setup parts for the java object every time */ 82 - (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, 83 - (jint)LCD_WIDTH, (jint)LCD_HEIGHT); 70 + AndroidRect_constructor = e->GetMethodID(env, AndroidRect_class, 71 + "<init>", "(IIII)V"); 84 72 } 85 73 86 74 /* ··· 132 120 jobject surfaceholder) 133 121 { 134 122 (void)surfaceholder; 123 + jclass rect; 135 124 136 125 /* Update RockboxFramebuffer_instance */ 137 126 RockboxFramebuffer_instance = (*env)->NewGlobalRef(env, this); 138 - 127 + rect = (*env)->FindClass(env, "android/graphics/Rect"); 128 + AndroidRect_class = (*env)->NewGlobalRef(env, rect); 139 129 /* possibly a new instance - reconnect */ 140 - connect_with_java(env, this); 130 + if (!connected) 131 + { 132 + connect_with_java(env, this); 133 + connected = true; 134 + } 141 135 display_on = true; 142 136 143 137 /* need to wait for button_queue to be valid to post to */ ··· 163 157 164 158 (*e)->DeleteGlobalRef(e, RockboxFramebuffer_instance); 165 159 RockboxFramebuffer_instance = NULL; 160 + (*e)->DeleteGlobalRef(e, AndroidRect_class); 161 + AndroidRect_class = NULL; 166 162 } 167 163 168 164 bool lcd_active(void)
+2 -4
tools/configure
··· 673 673 LDOPTS="$LDOPTS -Wl,-soname,librockbox.so -shared -ldl -llog" 674 674 GLOBAL_LDOPTS="-Wl,-z,defs -Wl,-z,noexecstack -shared" 675 675 ANDROID_ARCH=$1 # for android.make too 676 + gccchoice="4.6" 676 677 # arch dependant stuff 677 678 case $ANDROID_ARCH in 678 679 armeabi) 679 680 endian="little" 680 - gccchoice="4.4.3" 681 681 gcctarget="arm-linux-androideabi-" 682 682 # sigaltstack is not available in pre-android-9, however asm 683 683 # threads work fine so far ··· 688 688 ;; 689 689 mips) 690 690 endian="little" 691 - gccchoice="4.4.3" 692 691 gcctarget="mipsel-linux-android-" 693 692 thread_support="HAVE_SIGALTSTACK_THREADS" 694 693 GCCOPTS="$GCCOPTS -march=mips32 -mtune=r4600 -mno-mips16 -mno-long-calls -fomit-frame-pointer \ ··· 696 695 LDOPTS="$LDOPTS --sysroot=$ANDROID_NDK_PATH/platforms/android-14/arch-mips" 697 696 ;; 698 697 x86) 699 - endian=little 700 - gccchoice="4.4.3" 698 + endian="little" 701 699 gcctarget="i686-linux-android-" 702 700 gccdir=x86-$gccchoice 703 701 thread_support="HAVE_SIGALTSTACK_THREADS"