2014年10月24日 星期五

Run AOSP in Nexus devices

1. Download AOSP 
2. Download driver from Google's Nexus driver page.
3. unzip those drivers and put *.sh to root folder of AOSP
4. run each *.sh. Should get extract files to ./vendor
5.
$ source ./build/envsetup.sh
6. lunch. then choose flavor. (aosp_hammerhead-userdebug)
$ lunch
7. go to root folder of AOSP then make -j4
$ make -j4
8. Device goes to ‘’fast boot” mode. 
$ adb reboot bootloader
9. Go to ./out/target/product/hammerhead
$ cd ./out/target/product/hammerhead

10. flash real devices
$ fastboot -w flashall

2014年9月25日 星期四

AOSP Keys convert to Eclipse KeyStore

 AOSP put keys in build/target/product/security 

testkey -- a generic key for packages that do not otherwise specify a key.
platform -- a test key for packages that are part of the core platform.
shared -- a test key for things that are shared in the home/contacts process.

media -- a test key for packages that are part of the media/download system.

Example of "Platform"
javakeystore(jks)算是pkcs12的部分
但由於jkssunproprietaryformat
所以openssl沒法處理jks 要先把他轉成pkcs12再用keytool來轉

首先要先把 private key (pkcs8) DER format轉成PEM format
#openssl pkcs8 -inform DER -nocrypt -in platform.pk8 -out platform.pem


然後要把private key public key 轉成pkcs12. 輸入之後會跳出提示"輸入密碼"
#openssl pkcs12 -export -in platform.x509.pem -inkey platform.pem -out platform.pkcs12


最後用keytool把他轉成jks. 如不輸入 "srcstorepass"或"deststorepass" 輸入之後會跳出提示"輸入密碼"
#keytool -importkeystore -srckeystore platform.pkcs12 -srcstoretype pkcs12   -destkeystore platform.jks -deststoretype JKS [-srcstorepass PASSWORD -deststorepass PASSWORD]


verify that the key has been added to the keystore.
#keytool -list -v -keystore .keystore



ref: ALLSTART's BLOG

2014年8月27日 星期三

Android setting file


Android launch by default app
/data/system/users/0/package-restrictions.xml

Map Uid and permission

/data/system/package.xml

2014年5月8日 星期四

Android partition backup

Partition info can be found in "/dev/block/...". But it is not readable, most of devices have readable info in "/dev/block/platform/msm_sdcc.1/by-name".

Backup:
dd if=/dev/block/platform/msm_sdcc.1/by-name/recovery of=/sdcard/Backup/recovery-backup.img

Restore:
dd if=/dev/zero of=/dev/block/platform/msm_sdcc.1/by-name/recovery
dd if=/sdcard/Backup/recovery-backup.img of=/dev/block/platform/msm_sdcc.1/by-name/recovery

2014年3月27日 星期四

Compile APK with static java lib or java lib in AOSP

1. Create a folder("Myproject") under ANDROID_ROOT/packages/apps/
2. Before compile APK. Make sure compile all reference library first.
3.1 Part of make file example with local_java_library
 
     LOCAL_JAVA_LIBRARIES := com.sample.mylocallib

3.2 Part of make file example with local_static_java_library
   
    LOCAL_STATIC_JAVA_LIBRARIES := com.sample.mystaticlib
    LOCAL_PROGUARD_ENABLED := disabled

4. Proguard will remove unreferenced code by default. So if APK want keep all code, it may need to set proguard disabled. Or enable proguard and keep class in proguard setting
 
     Make file example:
     LOCAL_PROGUARD_ENABLED := custom
     LOCAL_PROGUARD_FLAG_FILES := proguard.flags

     proguard.flags example:
     -keep class com.sample.mystaticlib.** { *; }
     -keep interface com.sample.mystaticlib.interface.** { *; }

5. If get error "can't find xxxx/classes.jar" when compile APK. It may add classpath in make file
   
   Make file example:
    LOCAL_CLASSPATH := out/target/common/obj/JAVA_LIBRARIES/libmyinterface_intermediates/classes.jar

create static JAVA lib jar for other APK reference

static_java_library 和 java_library不同點:
1. java_library 編譯完會output到 ANDROID_ROOT/out/target/product/generic/system/framework,而static_java_library不會。
2. 當APK reference到java_library時,不會把jar source編譯進APK。但是static_java_library會編譯進去, 所以執行該APK的機器不需要有static_java_library存在。
3. 編譯兩種library的方法一樣,只差在make file

Make file example:

ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
LOCAL_PATH := $(call my-dir)
# the library
# ============================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_MODULE_TAGS := optional
# This is the target being built.
LOCAL_MODULE:= com.mylib.staticlibrary
include $(BUILD_STATIC_JAVA_LIBRARY)
# the documentation
# ============================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files) $(call all-subdir-html-files)
LOCAL_MODULE:= mystaticlibraryDoc
LOCAL_DROIDDOC_OPTIONS := com.mylib.staticlibrary
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_DROIDDOC_USE_STANDARD_DOCLET := true
include $(BUILD_DROIDDOC)
endif # JAVA_SUPPORT

2014年3月14日 星期五

custom JAVA library JAR in Android devices

Use custom library JAR in Android devices(Kitkat)
1. Create "MySystemLib"folder under AOSP_ROOT/device/sample/frameworks/MySystemLib
2. Put JAR source code in  AOSP_ROOT/device/sample/frameworks//MySystemLib
    Should include forder "java", Android.mk, com.my.internal.lib.xml
 
    Android.mk:
ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
            $(call all-subdir-java-files)
LOCAL_MODULE_TAGS := optional
# This is the target being built.
LOCAL_MODULE:= com.my.internal.lib
include $(BUILD_JAVA_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files) $(call all-subdir-html-files)
LOCAL_MODULE:= LauncherFacadeInterface
LOCAL_DROIDDOC_OPTIONS := com.sprint.internal.idinterface
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_DROIDDOC_USE_STANDARD_DOCLET := true
include $(BUILD_DROIDDOC)
endif # JAVA_SUPPORT

3. "make  com.my.internal.lib" or "mm -B"
4.  com.my.internal.lib.jar is generated in 'out/target/product/generic/system/framework'
5. Put com.my.internal.lib.jar  in /system/framework in android devices
6. Put com.my.internal.lib.xml in /system/framework/etc/permission in android devices
7.  Reboot device to refresh system lib
8. Declare lib in manifest.xml
   
            android:name="com.my.internal.lib"
             />