1. Dalvik 和 ART(Android Runtime)
在Dalvik中應用好比是一輛可折疊的自行車,平時是折疊的,只有騎的時候,才需要組裝起來用。
在ART中應用好比是一輛組裝好了的自行車,裝好就可以騎了。
2. Android源碼目錄結構:(一個可以查看Android源代碼網站:http://androidxref.com/)
Makefile
(描述Android各個組件間的聯系並指導它們進行自動化編譯) bionic
(bionic C庫) bootable
(啟動引導相關代碼) build
(系統編譯規則等基礎開發包配置) cts
(Google兼容性測試標准) dalvik
(Dalvik虛擬機) development
(應用程序開發相關) external
(android使用的一些開源模塊) frameworks
(Framework框架核心) hardware
(廠商硬件適配層HAL) out
(編譯完成後的代碼輸出目錄) packages
(應用程序包) prebuilt
(x86和arm架構下預編譯資源) sdk
(sdk及模擬器) system
(底層文件系統庫、應用及組件) vendor
(廠商定制代碼)
3.Android系統目錄 /system
和/data
是開發者特別關心的兩個目錄。
/system
目錄下主要有:/app
,/fonts
,/framework
,/lib
,/media
,/usr
等子目錄
例如,查看系統的屬性信息文件 /system/build.prop
:
shell@falcon_umts:/system $ cat build.prop
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=LMY47M.M003
ro.build.display.id=LMY47M.M003
ro.build.version.incremental=8
ro.build.version.sdk=22
ro.build.version.codename=REL
ro.build.version.all_codenames=REL
ro.build.version.release=5.1
ro.build.date=Wed Aug 19 10:44:57 PDT 2015
ro.build.date.utc=1440006297
ro.build.type=user
ro.build.user=hdsplat
ro.build.host=buildlinux16
ro.build.tags=release-keys
ro.build.flavor=falcon_gpe-user
ro.product.model=XT1032
ro.product.brand=motorola
ro.product.name=falcon_gpe
ro.product.device=falcon_umts
ro.product.board=MSM8226
......
/data
目錄下主要有/app
,/data
,/system
,/misc
等子目錄,其中/data/data
是開發者訪問最多的目錄,這裡包含了app的數據信息、文件信息以及數據庫信息等,以包名的方式來區別不同的應用。
1.adb命令的來源 /system/core/toolbox
和/frameworks/base/cmds
是所有adb命令和shell命令的來源,此處鏈接的是Android 6.0的源碼路徑。
2.常用的android命令 android list avds
列出所有創建的android模擬器
android list devices android list targets
列出我們所有的SDK可用版本
hujiawei-MBPR:hexoblog hujiawei$ android list targets
Available Android targets:
----------
id: 1 or "android-8"
Name: Android 2.2
Type: Platform
API level: 8
Revision: 3
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
Tag/ABIs : default/armeabi
----------
id: 2 or "android-10"
Name: Android 2.3.3
Type: Platform
API level: 10
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
Tag/ABIs : default/armeabi
----------
id: 3 or "android-15"
Name: Android 4.0.3
Type: Platform
API level: 15
Revision: 5
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800
Tag/ABIs : no ABIs.
----------
3.常用的adb命令 adb push <local> <remote>
, adb pull <remote> <local>
(文件傳輸) adb install xxx
, adb uninstall yyy
(apk安裝和卸載) adb usb
, adb tcpip <port>
, adb connect
, adb devices
(連接相關命令) adb start-server
,adb kill-server
,adb reboot
,adb remount
(重新掛載系統分區,使系統分區重新可寫)
adb shell
相關命令: adb shell df
(查看系統盤符) adb shell input keyevent
(模擬按鍵輸入,例如adb shell input keyevent 3
表示按下HOME鍵) adb shell input touchscreen
(模擬觸屏輸入,例如adb shell input touchscreen swipe 18 665 18 350
)
adb shell dumpsys activity activities
(查看activity運行狀態)
hujiawei-MBPR:hexoblog hujiawei$ adb shell dumpsys activity activities
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Display #0 (activities from top to bottom):
Stack #0:
Task id #279
* TaskRecord{2fbcccec #279 A=com.android.launcher U=0 sz=1}
userId=0 effectiveUid=u0a15 mCallingUid=1000 mCallingPackage=android
affinity=com.android.launcher
intent={act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher}
realActivity=com.android.launcher/com.android.launcher2.Launcher
autoRemoveRecents=false isPersistable=true numFullscreen=1 taskType=1 mTaskToReturnTo=0
rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false
Activities=[ActivityRecord{74b834e u0 com.android.launcher/com.android.launcher2.Launcher t279}]
askedCompatMode=false inRecents=true isAvailable=true
lastThumbnail=null lastThumbnailFile=/data/system/recent_images/279_task_thumbnail.png
hasBeenVisible=true firstActiveTime=1448539994507 lastActiveTime=1448539994507 (inactive for 58s)
adb pm xxx
(Package管理信息)
例如,查看所有的packages
hujiawei-MBPR:hexoblog hujiawei$ adb shell pm list packages -f
package:/system/app/YouTube/YouTube.apk=com.google.android.youtube
package:/system/priv-app/TelephonyProvider/TelephonyProvider.apk=com.android.providers.telephony
package:/system/app/MediaShortcuts/MediaShortcuts.apk=com.google.android.gallery3d
package:/data/app/com.support.android.designlibdemo-1/base.apk=com.support.android.designlibdemo
package:/system/priv-app/Velvet/Velvet.apk=com.google.android.googlequicksearchbox
package:/system/priv-app/CalendarProvider/CalendarProvider.apk=com.android.providers.calendar
package:/data/app/com.imooc.animatedselector-1/base.apk=com.imooc.animatedselector
package:/system/priv-app/MediaProvider/MediaProvider.apk=com.android.providers.media
package:/system/priv-app/GoogleOneTimeInitializer/GoogleOneTimeInitializer.apk=com.google.android.onetimeinitializer
package:/data/app/com.wandoujia-1/base.apk=com.wandoujia
package:/system/app/Bug2GoStub/Bug2GoStub.apk=com.motorola.bug2go
package:/data/app/com.sina.weibo.sdk.gensign-1/base.apk=com.sina.weibo.sdk.gensign
package:/data/app/com.sohu.inputmethod.sogou-1/base.apk=com.sohu.inputmethod.sogou
package:/system/priv-app/WallpaperCropper/WallpaperCropper.apk=com.android.wallpapercropper
package:/data/app/com.jredu.netease.news-1/base.apk=com.jredu.netease.news
adb am xxx
(Activity管理信息)
例如,啟動一個activity adb shell am start -n packageName[+className]
hujiawei-MBPR:hexoblog hujiawei$ adb shell am start com.wandoujia
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] pkg=com.wandoujia }
http://xxxxxx/Linuxjc/1134413.html TechArticle