Android System Programming Tips and Tricks系统编程技巧(46P).ppt
《Android System Programming Tips and Tricks系统编程技巧(46P).ppt》由会员分享,可在线阅读,更多相关《Android System Programming Tips and Tricks系统编程技巧(46P).ppt(46页珍藏版)》请在三一办公上搜索。
1、4/11/11,Android System ProgrammingTips and Tricks,4/11/11,Overview,Intro to AndroidWorking with SourceInteracting with the TargetDebug and Trace toolsPerformance toolsRandom thoughts on AndroidResources,4/11/11,Intro to Android,Google runtime on top of Linux,ObligatoryArchitecturediagram:,4/11/11,An
2、droid device proliferation,4/11/11,Working With Source,4/11/11,Working with Source,GitRepoBuild SystemBuilding fastAdding a program to the build,4/11/11,Git,Android open source project uses gitYou need to learn to use git well,reallyNeed to know how to do a git rebase especially for kernel patchesgi
3、t rebase-iKernel patch rebase needed for moving kernel versions,porting work,etc.Lots of online resourcesRecommended online book:http:/progit.org/book/,4/11/11,Repo,Export REPO_TRACE=1 is handy to see what git commands are happeningRepo tricksRepo forall-c git diff Repo forall-c echo$REPO_PATH;git r
4、emote-vUse to see upstream remotes from which to compare and merge with.Repo manifest-r-o my-tag-file.xmlMake a repository snapshot manifest,4/11/11,Build system,Lots of interesting stuff in build/envsetup.shhelpchoosecombo/lunchjgrep/cgrepgodirInteresting make targets:showcommands psuedo-target to
5、show build commandssdk can build the SDK from scratch,4/11/11,Fast building,Parallel make threadsmake-j6Use 2 more than your number of CPUs(include hyperthreaded CPUs)Compiled output cacheccache is in/prebuilt areaexport USE_CCACHE=1Great for rebuilds(21 minutes on my desktop)Make only a specific mo
6、dulemm build only the module(s)in the current directory(and below)I usually combine with a custom install script,which copies from out/target/product/,4/11/11,Adding a program to the build,Make a directory under externale.g./external/myprogramCreate your C/cpp files.Create Android.mk as clone of ext
7、ernal/ping/Android.mkChange the names ping.c and ping to match your C/cpp files and program nameAdd the directory name in ANDROID/build/core/main.mk after external/zlib as external/myprogramMake from the root of the source tree,4/11/11,Interacting with the Target,4/11/11,Interacting with the Target,
8、Android has some very nice integration engineeringTools discussedFastbootADBUseful development configurations,4/11/11,Fastboot,“fastboot”is a both tool and a bootloader protocolRequired by Google for certified devicesWould be really nice to adopt as an industry standarde.g.maybe support fastboot in
9、U-BootFastboot operationsInstall kernelInstall new flash imageBoot directly from hostVery useful for test automation,4/11/11,ADB,Android Debug BridgeTool for all kinds of target interactions(install,logging,remote shell,file copy)shell push/pullLogcatInstall/uninstallPrint this and keep it under you
10、r pillow.http:/,4/11/11,ADB(cont.),Can work over network,instead of USBUseful if you run build inside virtual machine on hoste.g.I build on Ubuntu 8.04 on Fedora 12(64-bit)hostIts simple:export ADBHOST=192.168.2.1For some reason,I have to kill the server after rebooting targetadb kill-serverCalling
11、adb will re-spawn the server automatically,4/11/11,Development configurations,Power control,Target,Host,USB,Network,kernel,root fs,data,flash,Functionality testing,Target,Integration and Performance testing,4/11/11,Trace and Debug Tools,4/11/11,Trace and Debug tools,LoggingKernel log(dmesg)LogcatStd
12、io redirectionStraceBootchartDumpsysDDMSgdb,4/11/11,Kernel log,Its there,use dmesg to access after bootTurn on PRINTK_TIMES for timestampsIncrease buffer size:CONFIG_LOG_BUF_SHIFTCan emit messages into log by writing to/dev/kmsgVery handy to synchronize with kernel messages,4/11/11,Logcat,Logging sy
13、stem in kernelIntegrated throughout Android system(C+and Java access)Increase logging levelsFlags to control logging level in code(DEBUG emits more?)Different logs(main,event,etc.)Event is funky,is coded for sizeSee jamboree presentation on log info http:/(Presentation by Tetsuyuki Kobayashi),4/11/1
14、1,Logcat,Use from host to redirect to a fileTo get main log info,use:e.g.adb logcat v time d*:V test.logTo get info from events log,use-b:e.g.adb logcat b events v time d|grep bootFilter using:Can use ANDROID_LOG_TAGS environment variableI wrote my own logdelta tool,to see time between eventsSee htt
15、p:/elinux.org/Improving_Android_Boot_Time#logdelta,4/11/11,Logging system overview diagram,*Shameless ripoff of Tetsuyuki Kobayashi,4/11/11,Logcat results(events),I/boot_progress_start(754):12559I/boot_progress_preload_start(754):17879I/boot_progress_preload_end(754):28546I/boot_progress_system_run(
16、768):29230I/boot_progress_pms_start(768):29697I/boot_progress_pms_system_scan_start(768):30117I/boot_progress_pms_data_scan_start(768):44171I/boot_progress_pms_scan_end(768):50006I/boot_progress_pms_ready(768):50505I/boot_progress_ams_ready(768):53166I/boot_progress_enable_screen(768):56793,4/11/11,
17、Stdio redirection,You can send stdout and stderr to the log:logwrapper myprogramRedirecting Dalvik output:Redirecting C/cpp output:Myprogram|xargs logAssumes you have busybox xargs installed,#stop#setprop log.redirect-stdio true#start,4/11/11,Strace,Shows system calls for a process(or set of process
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Android System Programming Tips and Tricks系统编程技巧46P Tricks 系统 编程 技巧 46

链接地址:https://www.31ppt.com/p-2817674.html