Tuesday, December 20, 2011

Add external lib in Android.mk

1. add LOCAL_STATIC_JAVA_LIBRARIES += jar'sFileName . This line must be added above "include $(BUILD_PACKAGE)"

2. add LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := pathtoyourlib.jar This line must be added after "include $(BUILD_PACKAGE)"

3. add include $(BUILD_MULTI_PREBUILT)


then compile it

Wednesday, November 16, 2011

android remove preload app

get root permission

check which is target APK
pm path com.xxx.packagename

remount partition to let permission to be read/write
mount -o remount,rw -t yaffs2 /dev/block/mtdblk3 /system

we need get partition info from
cat /proc/mounts

Monday, November 14, 2011

android keycode

utf area code
android/external/icu4c/data/unidata/Blocks.txt

Friday, October 28, 2011

access UI thread

Some ways to access ui thread from other thread

1.Activity.runOnUiThread(Runnable)
2.View.post(Runnable)
3.View.postDelayed(Runnable, long)
4.Handler
when start service, we can use handler+message to access UI thread. Create a Handler in UI thread, and register this Handler in service. Send message to Handler in service, so we can access UI thread by Handler.

5.AsyncTask

Make sure that you access the Android UI toolkit only on the UI thread. 另外service也是run在UI thread之中,所以可以access UI.

service life cycle
1. if start service by Context.startService().
onCreate()->onStartCommand()->onDestroy(). 直到呼叫Context.stopService or stopSelf(). 如果多次呼叫startService. 只要呼叫一次stopService, 則所有呼叫的service都會停止。但service所create的thread不會停止,記得要在onDestroy中停止自己create的thread。

2. if start service by Context.bindService()
onCreate()(只有第一次啟動該service時才會呼叫)-> onDestroy()

Thursday, October 13, 2011

Android Log

main log $adb shell logcat -b main -v threadtime
system log $ adb shell logcat -b system -d *:i
kernel log $ adb shell dmesg (or adb shell cat /proc/kmsg)


system app
/system/app
user app(internal storage)
/data/app
user app(external)
/mnt/asec
/mnt/secure/asec

set system log level per application

       adb shell setprop log.tag.XXXX VERBOSE

Tuesday, September 6, 2011

complie Android source to emulator

依照android source的指示, 但安裝所需套件時, 參考以下套件
Ubuntu Linux (32-bit x86):
sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

Ubuntu Linux (64-bit x86):
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

java5 is for Froyo, java6 is for gingerbread
complie完之後,if we want to run emulator. 在environment path中加上"ANDROID_PRODUCT_OUT=target/product/generic"
and exec "./out/host/linux-x86/bin/emulator"

if use gcc4.6 to compile Donut, also need to change some things.reference Here
change ./frameworks/base/libs/utils/Android.mk
from
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
to
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

change ./development/emulator/qtools/Android.mk
from
common_cflags := -O0 -g
to
common_cflags := -O0 -g -Wwrite-strings -fpermissive

Change ./frameworks/base/tools/localize/Android.mk
from
LOCAL_LDLIBS += -lrt
to
LOCAL_LDLIBS += -lrt -lpthread

change frameworks/base/tools/appt/Android.mk
from
LOCAL_LDLIBS += -lrt
to
LOCAL_LDLIBS += -lrt -lpthread

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] :0:0: note: this is the location of the previous definition cc1plus: all warnings being treated as errors make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1 To fix this, refer to this patch. https://github.com/CyanogenMod/android_build/commit/e9cbfa60c8dd60d04570d8bf7bd0d54a4304baf5 It will patch line 61 in build/core/combo/HOST_linux-x86.mk as following. -HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1 change external/mesa3d/src/glsl/linker.cpp Adding a "#include
from
unsigned output_index = offsetof(VertexOutput,varyings) / sizeof(Vector4); /*VERT_RESULT_VAR0*/;
to
unsigned output_index = offsetof(VertexOutput,varyings) / sizeof(Vector4); /*VERT_RESULT_VAR0;*/


make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1
change external/oprofile/libpp/format_output.h
from
mutable counts_t & counts;
to
counts_t & counts;

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error change external/gtest/include/gtest/internal/gtest-param-util.h
add
#include <cstddef>

make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
change external/llvm/llvm-host-build.mk
add
LOCAL_LDLIBS := -lpthread -ldl

查看編譯版本等資訊
getprop




on Mac OS
Mac OS:10.6.6(snow leopard)
xCode: 
4.3.3 (10G)
macport:for snow leopard
gmake:3.81

download and install package by step on Android source website.
1. need HFS+ disk format and disk size is suppose be bigger 25G.
2. download xCode.(4.2G). Build Android needs macOS.sdk 10.6. If download xCode4.5, it will not include MacOS10.6. It still need to download old version xCode to get 10.6SDK.
3. setup macport and install some packages (see Android source doc)
4. change gmake version to 3.81
5. Download source code in HFS disk
6. change JDK1.5, snow leopard uses 1.6 by default.
7. Change the gcc alias. This is needed by Qemu.

sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.0 /usr/bin/gcc
8. To fix this error go to “external/qemu/” and open Makefile.Android file and edit the following line
MY_CC := $(HOST_CC)
to
MY_CC := gcc
9.

Thursday, September 1, 2011

samsung device

unlock MSL: http://www.instinct-samsung.com/how-to/msl-%28merged%29/

remove UICCcheck
mv Android.mk Android.mk.bak(let builder ignore this app)
remove system/app/xxUICCxx.apk