Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Thursday, November 10, 2011

build simulator

build simulator是build一個跑在x86上的android
不過這功能到了後面就沒在maintain了

但還是試了一下
果真要改很多地方

my AOSP codebase
gingerbread-release
GRI40

  1. framework 
    1. strchr return type  : const char *  ->  char *  :   const_cast(strchr(..)) 
      1. media/libmedia/MediaScanner.cpp
      2. media/libstagefright/NuHTTPDataSource.cpp
      3. media/libstagefright/httplive/M3UParser.cpp
      4. media/libstagefright/rtsp/MyHandler.h
      5. media/libstagefright/rtsp/ASessionDescription.cpp
  2. external/gtest
    1. Android.mk : remove external/stlport/stlport in libgtest_includes (stlport wont be built for simulator, so we try not to include stlport's headers )
  3. external/libnfc-nxp
    1. Android.mk 
      1. remove libdl in LOCAL_SHARED_LIBRARIES (libdl wont be build for simulator, and we also need to modify build scripts to make it link against to libdl on my host pc)
      2. remove -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork in LOCAL_CFLAGS
      3. add LOCAL_C_INCLUDES := bionic/libc/kernel/common for libnfc
    2. Linux_x86/phDal4Nfc_i2c.c 
      1. add "#include
    3. Linux_x86/phDal4Nfc.c
      1. add "#include
      2. remove line 664: pthread_setname_np(pthread_self(), "reader");
  4. development/simulator/
    1. app/DeviceWindow.cpp 
      1. line 175: bool hasAlpha = onionSkinImage.HasAlpha(); -> bool hasAlpha = onionSkinImage.GetAlpha() != NULL; 
    2. app/MainFrame.cpp
      1. remove line 239, 280 : menuHelp->AppendSeparator();
  5. build
    1. core/combo/TARGET_linux-x86.mk
      1. TARGET_GLOBAL_LDFLAGS := $(HOST_GLOBAL_LDFLAGS) -m32 -lpthread -ldl -lrt
  6. packages/apps/Nfc
    1. ./jni/com_android_nfc.h
      1. add "#include

although I can build a simulator 
but it still cannot run Android well


[ 11-10 12:25:06 10884 W/Packag]
Exception reading AndroidManifest.xml in /system/framework/framework-res.apk
java.lang.SecurityException: /system/framework/framework-res.apk failed verification of META-INF/CERT.SF
at java.util.jar.JarVerifier.failedVerification(JarVerifier.java:135)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:313)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:265)
at java.util.jar.JarFile.getInputStream(JarFile.java:389)
at android.content.pm.PackageParser.loadCertificates(PackageParser.java:342)
at android.content.pm.PackageParser.collectCertificates(PackageParser.java:485)
at com.android.server.PackageManagerService.collectCertificatesLI(PackageManagerService.java:2570)
at com.android.server.PackageManagerService.scanPackageLI(PackageManagerService.java:2656)
at com.android.server.PackageManagerService.scanDirLI(PackageManagerService.java:2514)
at com.android.server.PackageManagerService.(PackageManagerService.java:930)
at com.android.server.PackageManagerService.main(PackageManagerService.java:694)
at com.android.server.ServerThread.run(SystemServer.java:148)

[ 11-10 12:25:06 10884 E/Packag]
Package android has no certificates at entry AndroidManifest.xml; ignoring!



Friday, November 4, 2011

qemu ram size

在cat /proc/meminfo下 ram總是90多MB
看了一下 qemu的source
原來是在 externel/qemu/android/avd/hardware-properties.ini 設定的
default是 96MB

Friday, July 29, 2011

custom android build.xml

之前要改android的build.xml時
通常先在我自己的build.xml最後那 改 setup import="false"
然後再去把SDK裡的template copy出來
加到build.xml的後面

不過今天發現
可以不用那麼麻煩
import="false"也不用加
只要先把template裡面的你想要改的target  copy出來
貼到你的build.xml上
再自己改想要改的東西  就可以了

inspired by class loading example http://code.google.com/p/android-custom-class-loading-sample/

Wednesday, May 25, 2011

android ndkr5 -no-pic

在ndk groups這篇
http://goo.gl/zOwpr
討論到了在ndkr5的時候
This does not affect anyone using the NDK build system, only people who
want to use the toolchain in standalone mode. 

default是給 -fpic  所以造成了10%~25%的performance loss

而且在講解原因的時候又是很經典的句子
The reason for this is historical, and the C compiler
team has agreed that using  -fpic by default for this config makes sense. 


而最後在cflags加了-fno-pic後也真的提高了performance

Monday, April 25, 2011

override system ld dirs

在mydroid build時
有時會需要link device上的library
(這方法有待商確 畢竟在compile時還是用AOSP上的header file 但至少目前出來的binary可以在device上link)
而需要改變-L的location, 不要讓他去link device的system/lib

在看了android build system裡的code之後
發現可以使用 TARGET_GLOBAL_LD_DIRS 這個var
也就是在自己的Android.mk裡
最後加上下面這行override掉他

TARGET_GLOBAL_LD_DIRS:=-L$(path to the device library)

Friday, April 22, 2011

Argument list too long

最近在Android build code 時會遇到
Argument list too long的問題

後來發現在android build system有個patch了
http://goo.gl/hCv3A


這個問題的背後
在這裡有說
http://goo.gl/LAGrR
http://goo.gl/D30Wq

Wednesday, March 9, 2011

softlink for Android build system

最近試著在mydroid裡 某個folder下用softlink 指到mydroid外的folder
而發現mydroid一直找不到我的這個softlink指的地方
看了看build/底下的code

最後原來是
http://android.git.kernel.org/?p=platform/build.git;a=blob;f=tools/findleaves.py;h=0adf188f9bb5b1e8ced951795cbc8bafdd43cfaf;hb=HEAD#l31

裡的os.walk() default是沒有follow softlink的
http://docs.python.org/library/os.html#os.walk

所以把原本裡的os.walk(rootdir)改成
os.walk(rootdir, TRUE, NONE, TRUE) 就好了

Friday, February 25, 2011

在webview裡用iframe

之前在android上 試著用WebView來load一個我自己的html
而這個html裡面就一個簡單的iframe會去load google.com的page

但發現這個page一直不能被load進iframe
研究了webkit許久後

才發現
http://android.git.kernel.org/?p=platform/external/webkit.git;a=blob;f=WebCore/loader/MainResourceLoader.cpp;h=3e75880483e2a772d05be1a9ab04542c6d53cc34;hb=2943c136f14cf8d0631249dd8764a0b6ab45fb98#l316
是這裡cancel掉

而原因是http-header裡有著
x-frame-options:SAMEORIGIN

而load的page(google.com) 跟原本這個html(我自己的test html)的origin並不一樣(host)
所以造成了iframe裡的google一直load不進來

Thursday, February 17, 2011

Android Webkit enable SVG

想要在android上的webkit enable SVG
看了 http://code.google.com/p/android/issues/detail?id=1376 後

拿裡面這個patch來build
除了要ENABLE_SVG=1 ENABLE_SVG_ANIMATION=1 (也可用在buildspec裡)外
發現一直有compile error,  animateTag undefined之類的

然後把make_names.pl裡面的SVG_FLAGS印出來
發現真的少了ENABLE_SVG_ANIMATION

就在花了很多時間在看是make沒處理好還是perl
怎麼找都找不出問題
最後把他clean後再build一次

就ok了...............................XD

Friday, February 11, 2011

Android webkit裡的GIF Animation

大家一直在吵說android的webkit到底有沒有support animate GIF
有的人說有 有的人說沒有

雖然在config.h 裡  是有define ANDROID_ANIMATED_GIF
但其實關鍵是在ANDROID_LARGE_MEMORY_DEVICE

而這個option只有在比較後面的device 才有enable, 像nexus one
http://android.git.kernel.org/?p=platform/external/webkit.git;a=blob;f=Android.mk;h=21f6cf4e8b7d65479cbeb741f63a17b2d94f8238;hb=HEAD#l242


而android emulator上  並不會enable這個option
參考
http://allstarschh.blogspot.com/2010/11/default-javascript-engine-on-froyo.html

所以就目前Android  2.3上只有在device上才能看到animated GIF emulator上不行

如果一定想要在emulator上跑的話
就要自己enable ANDROID_LARGE_MEMORY_DEVICE 這個option了

Wednesday, January 19, 2011

signing multiple certificates on apk

繼上次更新如何把android裡的key轉成keystore後
http://allstarschh.blogspot.com/2009/08/blog-post.html

這次要來看看 把Apk sign多個certificate的問題

雖然Apk是可以被多個certificate sign的

但是Android Group裡一直不建議用multiple certificates來sign
應該跟指定process(uid)有關就是了


在Android上的document寫
http://neacm.fe.up.pt/docs/android/guide/publishing/app-signing.html


When the system is installing an update to an application, if any of the certificates in the new version match any of the certificates in the old version, then the system allows the update

code就是在
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=services/java/com/android/server/PackageManagerService.java;h=86504a095daf999724611f77ec6ba924dc744d7a;hb=refs/heads/eclair-release#l1349

要注意 s1是新的  s2是本來的
所以新的signature裡 只要有一個跟舊的signature中某一個match
就可以install了


不過這件code到froyo上就改了
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=services/java/com/android/server/PackageManagerService.java;h=b70d69bab7d81c72e9a84a736befeeb455e61609;hb=refs/heads/froyo-release#l1853

變成用HashSet.equals

所以現在變成兩個apk的certificates要完全一樣(不按照順序)才能upgrade了

PS.
要sign multiple certificates的話應該要用jarsigner了
signapk.jar只能用固定的alias
http://android.git.kernel.org/?p=platform/build.git;a=blob;f=tools/signapk/SignApk.java;h=c4d73c8cfba5a7784b4ad9196e4a388ebd8920df;hb=HEAD#l76

Friday, January 14, 2011

ant build to include jars

在android上
用ant build時 他會自動幫你把libs/裡的jar包到dex裡面

可是在最近的sdk Gingerbread一樣用ant build
發現不行了

看一看ant的build  $SDK/tools/ant/main_rules.xml
原來是在 dex-helper裡
apply  dx的tag裡 新的把include jar的tag拿掉了
所以把<fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />加上就好了

不過話說我要用mydroid build時
又發現他的resources.arsc又不一樣了
http://allstarschh.blogspot.com/2010/10/resourcesarsc.html

__aeabi_f2uiz

之前一直遇到jni lib load不起來的問題
一直苦於無法在device上打開linker的log
所以一直不知道到底是什麼原因dlopen會fail掉
而且如果直接把linker換掉
device也就直接爛掉了....

最後只好用肉眼來比較可以load的library跟load 不起來的library
幸好在plt 就看到不一樣了
不能動的lib那多了一個 __aeabi_f2uiz

幸好也有人遇到跟我一樣的問題
而David Tuner剛好也回了他
讓我有個方向來進行
http://groups.google.com/group/android-developers/browse_thread/thread/636d11723aae3117


最後發現 我build的時候 是for emulator的
所以在device上會跑不起來

最後就
source build/envsetup.sh
lunch
然後選要跑的device就解決了aeabi_f2uiz的問題了

2011.11.17
在android-4.0的AOSP裡 libbcc的code
也在RuntimeStub.c看到 他們也遇到 __aeabi_f2uiz missing的問題


 82 #if defined(__arm__)
 83 // NOTE: __aeabi_f2uiz is missing from libgcc which comes with android,
 84 // so here's the workaround.  Remove this when __aeabi_f2uiz is available
 85 // from libgcc.
 86 unsigned int __aeabi_f2uiz(float a)
 87   __attribute__((weak, alias("__fixunssfsi")));
 88 #endi

Wednesday, January 12, 2011

android 上的dynamic linker

之前想在android上的 dynamic linker (/system/bin/linker) 上debug

source 在 bionic/linker
http://android.git.kernel.org/?p=platform/bionic.git;a=tree;f=linker;h=fc0953ae9b536b112c5a8afbfbe4548125123313;hb=HEAD

可是目前不知道如何來enable linker.c裡的debug_verbosity
因為目前發現
並不是新process起來後都會來用linker

現在的猜想是只有在之前的zygote才會來call 這個linker
所以我在之後launch activity 即使有去load自己的jni lib
也都不能看到__linker__init的log

另外也去找了gcc的code
http://android.git.kernel.org/?p=toolchain/gcc.git;a=summary

目前有看到 BIONIC_DYNAMIC_LINKER的code
但這會被包起來 最後應該是接到gcc.c裡的linker_spec裡

不過還要花時間來証實這些事就是了

Friday, January 7, 2011

EventLogTags

在android webkit裡的看到了一個EventLogTags的class
但卻遍尋不著他的source

原來他是從EvnetLogTags.logtags產生的
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/webkit/EventLogTags.logtags;h=082a43734976d1570c4db1315ba12d03f48bc4fc;hb=HEAD

Friday, December 24, 2010

compile with hidden classes on android

in Android SDK (not AOSP)
sometimes you need to use some 'hidden' classes ( with @hide annotations)

here is how I do it with ant build

first you need to get the whole Android framework jars
it's located in 
mydroid/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar

1:
copy it to your project/lib/   
(not libs/,  because ant build will include the jars in libs, but here we just need to use it for symbol resolution)

2: 
customize your ant build.xml
copy the templates from 
  • for cupcake donut
    • platforms/$API_LEVEL/templates/android_rules.xml
  • for eclair froyo
    • platforms/$API_LEVEL/ant/ant_rules_r2.xml
  • gingerbread 
    • tools/ant/main_rules.xml

3.
  add a path before the compile task <compile>
 <path id="boot.class.ref">
        <fileset dir="./lib">
            <include name="*.jar" />
        </fileset>
    </path>

then

add a line after <javac>

<compilerarg value="-Xbootclasspath/p:${toString:boot.class.ref}"/$gt;

here I try to update the boot class path with -Xbootclasspath/p option






Thursday, December 16, 2010

video broadacast on android


http://www.mattakis.hu/blog/kisg/20090708/broadcasting-video-with-android-without-local-files
談論到如何將recorder錄下來的video 藉由socket 送出去
(與onPreviewFrame不同的是  recorder已經把這data encode過了
onPreviewFrame是 raw data)

但其實在Android上 camrecorder 是在stop record之後
才把moov atom送出去
所以即使另一邊用socket來收這個stream
也無法來作streaming play的動作

而在上面那個link的comment 也討論到
即使是把他作成RTP  也還是要產生SDP


PS:
將moov從後面搬到前面的tool MP4BOX
http://gpac.cvs.sourceforge.net/viewvc/gpac/gpac/applications/mp4box/