Google Android adventures Entry: CPS and Activities Date: Thu Jan 7 15:43:57 CET 2010 The android application model is designed to limit memory usage. One of the main components visible to the application programmer is the ``swapping out'' of activities. Whenver an application looses focus its onPause() method is called. At this time, all Activity state needs to be saved in a Bundle: it might happen that the process running the VM hosting the Activity gets killed by the low memory killer in case memory is needed elsewhere. If you combine this with the highly a-synchronous nature of the android API, an application written in CPS becomes attractive. The main question is: how to represent tree / graph structures as an Intent? Entry: Building native applications Date: Fri Jan 29 12:48:40 CET 2010 The simplest approach is to add a new application to the main build tree, by adding a directory that contains an Android.mk file in the style of: # See examples: # system/core/sh/Android.mk # system/core/cpio/Android.mk LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ program.c LOCAL_MODULE:= program include $(BUILD_EXECUTABLE) To see what the build actially does, run this: $ make showcommands program target thumb C: program <= program/program.c prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gcc -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/generic/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I program -I out/target/product/generic/obj/EXECUTABLES/program_intermediates -I out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -MD -o out/target/product/generic/obj/EXECUTABLES/program_intermediates/program.o program/program.c target Executable: program (out/target/product/generic/obj/EXECUTABLES/program_intermediates/LINKED/program) prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++ -nostdlib -Bdynamic -Wl,-T,build/core/armelf.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -o out/target/product/generic/obj/EXECUTABLES/program_intermediates/LINKED/program -Lout/target/product/generic/obj/lib -Wl,-rpath-link=out/target/product/generic/obj/lib -lc -lstdc++ -lm out/target/product/generic/obj/lib/crtbegin_dynamic.o out/target/product/generic/obj/EXECUTABLES/program_intermediates/program.o -Wl,--no-undefined /usr/people/beschout.nba/sw/android-google/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/../lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a out/target/product/generic/obj/lib/crtend_android.o target Non-prelinked: program (out/target/product/generic/symbols/system/bin/program) out/host/linux-x86/bin/acp -fpt out/target/product/generic/obj/EXECUTABLES/program_intermediates/LINKED/program out/target/product/generic/symbols/system/bin/program target Strip: program (out/target/product/generic/obj/EXECUTABLES/program_intermediates/program) out/host/linux-x86/bin/soslim --strip --shady --quiet out/target/product/generic/symbols/system/bin/program --outfile out/target/product/generic/obj/EXECUTABLES/program_intermediates/program Install: out/target/product/generic/system/bin/program out/host/linux-x86/bin/acp -fpt out/target/product/generic/obj/EXECUTABLES/program_intermediates/program out/target/product/generic/system/bin/program From this we can distill a Makefile: # This is a small hack to use commands snarfed from the main android # system build to compile native applications. # # To obtain commands: # # - create a symbolic link: ln -s mtsa-watchdog $(ANDROID_SRC) # - make showcommands mtsa-watchdog # - observe commands, and replace .c and .o with parameters to create templates ANDROID_SRC := ~/sw_local/android-google HERE := $(shell pwd) # The commands below simply replace the .o .c and application files # with parameters $(1) $(2) and use the $(call ...) construct to # substitute. # Note: all targets need to use absolute paths. I.e. to manually build targets use: # # make `pwd`/watchdog.o # <1:in> <2:out> android_compile = prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gcc -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/generic/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I program -I out/target/product/generic/obj/EXECUTABLES/program_intermediates -I out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -MD -o $(2) $(1) # <1:in> <2:out> android_link = prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++ -nostdlib -Bdynamic -Wl,-T,build/core/armelf.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -o $(2) -Lout/target/product/generic/obj/lib -Wl,-rpath-link=out/target/product/generic/obj/lib -lc -lstdc++ -lm out/target/product/generic/obj/lib/crtbegin_dynamic.o $(1) -Wl,--no-undefined /usr/people/beschout.nba/sw/android-google/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/../lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a out/target/product/generic/obj/lib/crtend_android.o %.o: %.c cd $(ANDROID_SRC) ; $(call android_compile,$<,$@) %.x: %.o cd $(ANDROID_SRC) ; $(call android_link,$<,$@) .PHONY: all clean TARGETS := $(HERE)/program.x all: $(TARGETS) clean: rm -rf *.o *~ *.d $(TARGETS) Entry: Picking up Date: Fri Apr 26 22:08:11 EDT 2013 Got 2 RepublicWireless (RW) phones: - LG Optimus S[1], rooted, no service. Test device. Qualcomm Snapdragon S1 MSM7627 Single core, 600 MHz 320 x 480 pixels, 3.2" 0.14 GB Flash (up to 32G uSD) - Motorola Defy XT[2], rooted, service. Active phone. Qualcomm Snapdragon S1 MSM7227A Single core, 1000 MHz, ARM Cortex-A5 480 x 854 pixels, 3.7" Adreno 200 (enhanced) GPU 512 MB RAM, 1GB Flash (up to 32G uSD) [1] http://www.phonearena.com/phones/LG-Optimus-S_id4963 [2] http://www.phonearena.com/phones/Motorola-DEFY-XT_id6959 [3] http://en.wikipedia.org/wiki/Snapdragon_%28system_on_chip%29 Entry: Install Debian on android Date: Mon Apr 29 15:53:57 EDT 2013 # workstation: generate "debian" directory. sudo debootstrap --arch=armel --foreign squeeze debian http://http.debian.net/debian # copy "debian" dir to an ext2/ext3 partition on an SD card and run: export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH chroot "debian" /bin/bash -l debootstrap/debootstrap --second-stage Entry: Getting a project to build Date: Wed May 8 23:24:23 EDT 2013 tom@zoo:~/kmook/android$ /opt/xc/android/android-sdk-linux/tools/android update project --path . Error: The project either has no target set or the target is invalid. It's from an old one, set to android-4. Should be 10 (gingerbread 2.3). Entry: Android NDK Date: Tue May 14 15:26:43 EDT 2013 Seems to be a separate install. Can it be installed using the android tool? Doesn't look like it. Seems they actively discourage use: "In general, you should only use the NDK if it is essential to your app -— never because you simply prefer to program in C/C++." [1] http://developer.android.com/tools/sdk/ndk/index.html [2] http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2 Entry: SDL on Android Date: Tue May 14 16:24:54 EDT 2013 The idea is to have an app that runs both on Linux/GLX and Android OpenGL ES. How to proceed? [1] http://www.libsdl.org/tmp/SDL/README.android Entry: Android audio Date: Tue May 14 20:29:40 EDT 2013 Basically, java player thread calls into JNI to get the next batch of samples. [1] https://groups.google.com/forum/?fromgroups=#!msg/android-ndk/n5VIQONagTk/7gAMrRL4tvIJ [2] http://audioprograming.wordpress.com/2012/10/18/a-simple-synth-in-android-step-by-step-guide-using-the-java-sdk/ Entry: Android Audio latency Date: Tue May 14 21:44:22 EDT 2013 It looks like this is not going to be the best platform for writing audio apps.. Min bufsize I get currently is 4800 samples. From [3]: Android 2.3 exposes OpenSL ES 1.0 as part of their NDK. [1] http://stackoverflow.com/questions/14842803/low-latency-audio-playback-on-android [2] http://www.khronos.org/opensles/ [3] http://en.wikipedia.org/wiki/OpenSL_ES Entry: Droid 2 Global - bootloader Date: Fri Jun 21 15:20:14 EDT 2013 Turn on phone with both volume buttons pressed. It comes up with the following on the screen: Bootloader D0.11 Battery OK OK to Program Transfer Mode: USB From dmesg: [2045389.304844] usb 3-3.4.3: new high-speed USB device number 26 using ehci_hcd [2045389.398399] usb 3-3.4.3: New USB device found, idVendor=22b8, idProduct=4280 [2045389.398411] usb 3-3.4.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [2045389.398421] usb 3-3.4.3: Product: S Flash OMAP3630 MI [2045389.398428] usb 3-3.4.3: Manufacturer: Motorola Inc. Some steps for band-unlocking here: http://rootzwiki.com/topic/25828-instruction-files-on-how-to-un-bricked-rooted-and-band-unlock-droid-2-global-with-629-rom/ Arduous process. For now, I think I'm going to downgrade it to 608 so at least I have a rooted phone. system: 4.6.629.A956.Verizon.en.US build: 4.5.1_57_D2GA-59 android: 2.3.4 baseband: N_01.82.00R kernel: 2.6.32.9-g177d714 mcbk83@il93lnxdroid08 #1 ERI: 5 PRL: 53096 Entry: Building Android Date: Mon Jun 24 15:14:29 EDT 2013 [1] http://source.android.com/source/building.html Entry: SCR331 CCID card reader Date: Mon Jun 24 16:00:22 EDT 2013 [2306563.172235] usb 3-3.4.4: new full-speed USB device number 38 using ehci_hcd [2306563.291844] usb 3-3.4.4: New USB device found, idVendor=04e6, idProduct=e001 [2306563.291857] usb 3-3.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=5 [2306563.291867] usb 3-3.4.4: Product: SCRx31 USB Smart Card Reader [2306563.291875] usb 3-3.4.4: Manufacturer: SCM Microsystems Inc. [2306563.291881] usb 3-3.4.4: SerialNumber: 21121250210402 [2306563.377393] WARNING! power/level is deprecated; use power/control instead apt-get install pcsc-tools ~# pcsc_scan Mon Jun 24 15:59:18 2013 Reader 0: SCM Microsystems Inc. SCR 331 [CCID Interface] (21121250210402) 00 00 Card state: Card inserted, ATR: 3B 98 96 00 93 94 03 08 05 03 03 03 ATR: 3B 98 96 00 93 94 03 08 05 03 03 03 + TS = 3B --> Direct Convention + T0 = 98, Y(1): 1001, K: 8 (historical bytes) TA(1) = 96 --> Fi=512, Di=32, 16 cycles/ETU 250000 bits/s at 4 MHz, fMax for Fi = 5 MHz => 312500 bits/s TD(1) = 00 --> Y(i+1) = 0000, Protocol T = 0 ----- + Historical bytes: 93 94 03 08 05 03 03 03 Category indicator byte: 93 (proprietary format) Possibly identified card (using /usr/share/pcsc/smartcard_list.txt): NONE Your card is not present in the database. You can get the latest version of the database from http://ludovic.rousseau.free.fr/softwares/pcsc-tools/smartcard_list.txt or use: wget http://ludovic.rousseau.free.fr/softwares/pcsc-tools/smartcard_list.txt --output-document=/root/.cache/smartcard_list.txt If your ATR is still not in the latest version then please send a mail to containing: - your ATR - a card description (in english) So card gives ATR (answer to reset[1]) but otherwise is not recognized by the scan tool (not a PC/SC[2] card?). Movin forward: osmo-sim-auth[3] might be a good place to start: apt-get install python-pyscard [1] http://en.wikipedia.org/wiki/Answer_to_reset [2] http://en.wikipedia.org/wiki/PC/SC [3] http://openbsc.osmocom.org/trac/wiki/osmo-sim-auth Entry: Root nexus one 2.3.6 GRK39F Date: Mon Jun 24 17:57:10 EDT 2013 fastboot oem unlock https://code.google.com/p/bexboot/ This boot.img can be flashed via fastboot to root a Nexus One with Android 2.3.6 (GRK39F). Note: Your bootloader needs to be unlocked before you can use it! Download bexboot.v2.GRK39F_OTA.zip, create a new folder on your computer and extract the Bexboot zip archive into that folder. Connect your device via USB to your computer. Put your device in USB debugging mode (Settings > Applications > Development > USB Debugging). Put your device in bootloader mode. Therefore open a terminal, cd to the directory where you extracted the files to and type: Windows adb-windows reboot bootloader Mac adb-mac reboot bootloader Linux adb-linux reboot bootloader In bootloader mode, type in the terminal: Windows fastboot-windows flash boot bexboot.v2.img followed by fastboot-windows reboot Mac fastboot-mac flash boot bexboot.v2.img followed by fastboot-mac reboot Linux fastboot-linux flash boot bexboot.v2.img followed by fastboot-linux reboot Entry: Building 2.3.6 GRK39F Date: Wed Jun 26 10:10:54 EDT 2013 I'd like to build binaries that work on the Nexus One with 2.3.6 GRK39F. From [1] it gives the tag to use: GRK39F android-2.3.6_r1 Nexus One, Nexus S Following [2] the version can be checked out as: repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.6_r1 repo sync . build/envsetup.sh lunch full-eng make -j8 Doesn't build. Then I followed the apt-get install from here[3]. [1] http://source.android.com/source/build-numbers.html [2] http://source.android.com/source/downloading.html [3] http://sycurelab.ecs.syr.edu/?p=64