1.linuxä¸å
³äºadbå½ä»¤çä¸äºç¥è¯
2.å¦ä½å°åºç¨å®è£
å°/system/appä¸
linuxä¸å ³äºadbå½ä»¤çä¸äºç¥è¯
Android Debug Bridgeï¼ä¸è¬ç®ç§°ä¸ºadbï¼ä¸»è¦åæ¾å¨sdkå®è£ ç®å½ä¸çplatform-toolsæ件夹ä¸ï¼å®æ¯ä¸ä¸ªé常强大çå½ä»¤è¡å·¥å ·ï¼éè¿è¿ä¸ªå·¥å ·ä½ è½å¤ä¸ä½ çandroid设å¤è¿è¡äº¤äºãåæ¶è¿æ¯ä¸ä¸ªå å«äºä»¥ä¸ä¸é¨åçcs模å¼çç¨åºï¼
1) adb client
ããä»å¾ä¸ï¼æ们ç¥éclientæ¯è¿è¡å¨PC端çï¼æ¯å½æ们åèµ·ä¸ä¸ªadbå½ä»¤çæ¶åï¼å°±ä¼å¼å¯ä¸ä¸ªclientç¨åºãå½ç¶ï¼å½æ们å¼å¯DDMSæè ADTçæ¶åï¼ä¹ä¼èªå¨å建clientã
ããå½æ们å¼å¯ä¸ä¸ªclientçæ¶åï¼å®é¦å ä¼å»æ£æµåå°æ¯å¦å·²ç»æä¸ä¸ªserverç¨åºå¨è¿è¡çï¼å¦åä¼å¼å¯ä¸ä¸ªadb-serverè¿ç¨ã
ããææçclienté½æ¯éè¿ç«¯å£ä¸adb-serverè¿è¡éä¿¡çã
2ï¼adb daemonï¼adbdï¼
ããä»å¾ä¸ï¼æ们ç¥édaemonæ¯ä½ä¸ºä¸ä¸ªåå°è¿ç¨è¿è¡å¨æ¨¡æå¨/çå®Android设å¤ä¸çã
ããdaemon使ç¨ç«¯å£çèå´æ¯-ï¼æ¯ä¸ªæ¨¡æå¨/设å¤è¿æ¥å°PC端æ¶ï¼æ»ä¼å¼å¯è¿ä¹ä¸ä¸ªåå°è¿ç¨ï¼å¹¶ä¸ä¸ºå ¶åé äºä¸¤ä¸ªè¿ç»ç端å£ï¼æ¯å¦ï¼
ããããEmulator 1,源支付源码授权 console:
ããããEmulator 1, adb:
ããä¹æ£å 为æ¯ä¸ªè®¾å¤é½åä¸ç»ä¸¤ä¸ªç«¯å£ï¼ä¹å·²adbè¿æ¥ææºçæ大æ°é为ã
ãã说å端å£çä½ç¨ï¼å¨è¿ä¸¤ä¸ªç«¯å£ä¸ï¼å ¶ä¸å¶æ°ç«¯å£æ¯ç¨äºserver ä¸è®¾å¤è¿è¡äº¤äºçï¼å¯ä»¥è®©serverç´æ¥ä»è®¾å¤ä¸è¯»åæ°æ®ï¼èå¥æ°ç«¯å£æ¯ç¨æ¥ä¸è®¾å¤çadbdè¿è¡è¿æ¥éä¿¡çã
2) adb server
ããä»å¾ä¸ï¼æ们åæ ·å¯ä»¥ç¥éï¼serverä¹æ¯ä½ä¸ºä¸ä¸ªåå°çç¨åºè¿è¡å¨PC端çï¼ä»è´è´£ç®¡çclientè¿ç¨ä»¥åadb daemonä¹é´çéä¿¡ã
ããå½ä¸ä¸ªserverå¼å¯çæ¶åï¼ä»ä¼èªå¨ç»å®å¹¶ä¸çå¬ç«¯å£ï¼æ¥æ¶clientéè¿è¯¥ç«¯å£åéè¿æ¥çå½ä»¤ãåæ¶serverè¿ä¼å¯¹-é´çå¥æ°ç«¯å£è¿è¡æ«æï¼è¿è¡å¯¹å·²è¿æ¥è®¾å¤çå®ä½ã
1.2 常ç¨çadbå½ä»¤
é¦å æ们å æ¥ä»ç»ä¸ä¸ï¼adbå½ä»¤ç使ç¨æ ¼å¼å§ï¼
adb [-d|-e|-s ]
adbæ¯å¿ é¡»çï¼æ¥ä¸æ¥æ¹æ¬å·[]éé¢çå 容ä¸æ¯å¿ é¡»çï¼æåææ¯æ们éè¦æ§è¡çå½ä»¤æä½ï¼ä¾å¦ adb -s emulator- install UCBrowser.apk (è¿æ¯å®è£ UCæµè§å¨çææ)
ä¸é¢å ä»ç»ä¸ï¼åé¢å 个åæ°çå«ä¹å§ï¼
ãã-d: 让å¯ä¸è¿æ¥å°è¯¥PC端ççå®å®å设å¤æ§è¡å½ä»¤ï¼å¦æåç°USBä¸è¿æ¥æå¤é¨è®¾å¤ï¼å°ä¼æ¥é
ãã-e: 让å¯ä¸è¿æ¥å°è¯¥PC端ç模æå¨æ§è¡å½ä»¤ï¼å¦æåç°å¼å¯äºå¤ä¸ªæ¨¡æå¨ï¼å°ä¼æ¥é
ãã-sï¼éè¿è®¾å¤çåºåå·è¿è¡æå®è®¾å¤æ§è¡å½ä»¤
å¦æ设å¤åªè¿æ¥æä¸ä¸ªè®¾å¤æè ä¸ä¸ªæ¨¡æå¨çæ¶åï¼å¯ä»¥ä¸ç¨å£°æè¿ä¸ä¸ªåæ°ï¼adbé»è®¤ä¼è®©è¿é¨å¯ä¸è¿æ¥å°ç设å¤è¿è¡å½ä»¤æ§è¡ã
okï¼ä¸é¢å¼å§è®²è§£å¸¸ç¨çå½ä»¤å§ï¼
1) æ¥çå½åPC端è¿æ¥æå¤å°è®¾å¤ï¼
adb devices
ç»ç«¯ä¸çæ§è¡ç»æ为ï¼
ä»ä¸å¾ä¸ï¼æ们çå°äºè®¾å¤æç两ç§ç¶æï¼å ¶å®æ§è¡è¯¥å½ä»¤ï¼å¯è½è¿åçç¶ææä¸ç§ï¼
ããI. device 设å¤å·²ç»æåè¿æ¥å°äºadb-server
ã II. offline 设å¤å¹¶æ²¡æè¿æ¥å°adbæè 没æååº
ã III. no device 并没æ设å¤/模æå¨è¿æ¥
2) æ¥çadbççæ¬
adbãversion
ç»ç«¯ä¸çæ§è¡ç»æ为ï¼
3) ç»è®¾å¤è¿è¡è½¯ä»¶çå®è£
adb -s install
eg:
adb -s eba9 install D://Test.apk
ç»ç«¯ä¸çæ§è¡ç»æ为:
é¤äºä¸é¢è¿ç§æ¹æ³ï¼æ们è¿æå¦å¤ä¸ä¸ªå½ä»¤ï¼
adb -s shell pm install [options]
å ¶ä¸[options]ä¸æ常ç¨çé项æ¯-rï¼ä»£è¡¨çæ¬æ¬¡å®è£ æ¯éæ°å®è£ ï¼ä¼ä¿çç¨æ·æ°æ®ã
4) å¸è½½è®¾å¤ä¸å·²ç»å®è£ ç软件
adb -s uninstall
eg:
adb -s eba9 uninstall cn.uc.test
ç»ç«¯ä¸çæ§è¡ç»æ为:
é¤äºä¸é¢è¿ç§æ¹æ³ï¼æ们è¿æå¦å¤ä¸ä¸ªå½ä»¤ï¼
adb -s uninstall [options]
è¿éçoptionsæ¯-kï¼å ä¸è¯¥åæ°è¡¨æå¸è½½è½¯ä»¶åä¾æ§ä¿çç¨æ·æ°æ®
5) å°æ°æ®ä»è®¾å¤å¤å¶å°PCä¸
adb -s pull
eg:
adb -s eba9 pull /sdcard/stericson-ls D://
ç»ç«¯çæ§è¡ç»æï¼
å¨Dï¼//çä¸æ们ä¹å¯ä»¥åç°stericson-lsæ件
6) 讲æ°æ®ä»PC端å¤å¶å°è®¾å¤ä¸
adb -s push
eg:
adb -s eba9 push d://stericson-ls /sdcard/
ç»ç«¯çæ§è¡ç»æï¼
7) è·åè¿æ¥å°çææºçåºåå·
adb get-serialno
ç»ç«¯çæ§è¡ç»æï¼
8)è·å设å¤çè¿æ¥ç¶æ
adb -s get-state
eg:
adb -s eba9 get-stat
ç»ç«¯çæ§è¡ç»æï¼
9) çå¾ è®¾å¤è¿æ¥æå
adb wait-for-device
该å½ä»¤å°ä¼é»å¡ä¸ç´å°é»è®¤è¿æ¥çé£é¨æºå¨ç¶æå为deviceï¼ä¹å°±æ¯è¿æ¥æåã
) adb-server çå¼å¯ä¸å ³é
adb kill-server
adb start-server
ç»ç«¯çæ§è¡ç»æï¼
ææ¶åæ们å¼å¯serverä¼å¤±è´¥ï¼è¿æ¯å 为æä»¬è£ äºçææºå©æï¼è±è±èæè å ¶ä»è½¯ä»¶èªå¸¦æèªå·±çadbï¼å¯¼è´ç«¯å£å²çªå¼å¯å¤±è´¥ã主è¦å ³æé£äºè½¯ä»¶å¹¶ä¸ææé£äºè½¯ä»¶èªå¸¦çadbè¿ç¨éæ¥å³å¯ã
1.2 ææºæ§è¡Shellå½ä»¤
ä¼æå¨ç¥ï¼Androidçå æ ¸æ¬èº«å°±æ¯Linuxï¼æ以Androidæ¬èº«ä¹æ¯æLinuxå½ä»¤ï¼ä½æ¯å 为æ¯ææºç³»ç»ï¼æ以è¿è¡äºä¸å®çå åï¼é¨åå½ä»¤ä¸æ¯æï¼èä¸æ¯æçé¨åï¼æ们å¯ä»¥éè¿å®è£ busyboxè¿ä¸ªè½¯ä»¶è¿è¡
å¡«è¡¥ã
ä¸é¢æ们讲解ä¸å¦ä½å¨ææºä¸æ§è¡Shellå½ä»¤ï¼
1) æ¯æ¬¡é½å ä¸adb shellæ¥è¿è¡å½ä»¤çåéä¸æ§è¡
adb shell
2) å éè¿adb shellè¿å ¥ææºShellæ§è¡ç¶æï¼ç¶åç´æ¥è¾å ¥Linuxå½ä»¤ï¼å¦å¾ï¼
ãã
1.3 Activity Manager 常ç¨å½ä»¤ä¸åæ°è¯´æ
ä¸è¬æ åµä¸ï¼æ们æ常ç¨å®æ¥è¿è¡appçå¼å¯ï¼å¹¶ä¸ä¼ éä¸å®çåæ°è¿å»,æ¯å¦ï¼
adb shell am start -a android.intent.action.VIEW -n cn.uc.test/.MainActivity -d
å¨è¿éå°±ä¸å太è¿è¯¦ç»åéå¤ç说æäº
1.4 Package Manager 常ç¨å½ä»¤ä¸åæ°è¯´æ
1) 使ä¸ä¸ªapkå¤äºç¦ç¨ç¶æï¼ç¸å½äºå¸è½½äºï¼
disable
å ¶ä¸ PACKAGE_OR_COMPONENTçæ ¼å¼æ¯ package/classï¼ å¦ com.UCMobile/.main.UCMobile
eg:
adb shell su disable com.UCMobile/.main.UCMobile
ç»ç«¯æ§è¡ç»æï¼
åæ¶æ们å¨ææºä¸åç°ï¼UCæµè§å¨çå¾æ ä¸è§äº
2) 让ä¸ä¸ªapkä»ç¦ç¨ç¶ææ¢å¤è¿æ¥
enable
å ¶ä¸ PACKAGE_OR_COMPONENTçæ ¼å¼æ¯ package/classï¼ å¦ com.UCMobile/.main.UCMobile
eg:
adb shell su enable com.UCMobile/.main.UCMobile
ç»ç«¯æ§è¡ç»æï¼
åæ¶æ们ä»ææºä¸åç°ï¼UCæµè§å¨çå¾æ ååæ¥å¦ã
3) æ¥çä¸ä¸ªapkæå¨çè·¯å¾
pm path
eg:
adb shell pm path com.UCMobile
ç»ç«¯æ§è¡ç»æï¼
4) æ¥çææºä¸è£ çææçå
pm list packages
å次ä¸åè¿å¤ç说æ
1.5å ¶ä»å¸¸ç¨çadbå½ä»¤
1) å±å¹å½å
ä¾å¦ï¼å±å¹å¼å§å½å并ä¸å¨åå°/sdcardä¸ï¼åæ¶åå为demo.mp4
adb shell screenrecord /sdcard/demo.mp4
2) å ³é设å¤è¯·æ±ï¼å¼å¯è®¾å¤
adb shell stop
adb shell start
3)设å¤å ³æºä»¥åéå¯
adb reboot
adb shutdown
å¦ä½å°åºç¨å®è£ å°/system/appä¸
å¨ Android ä¸ï¼å¦æè¦ä½¿ç¨ç³»ç»éå¶çæéï¼æ¯å¦ android.permission.WRITE_SECURE_SETTINGSï¼ï¼æ们éè¦æç¨åºå®è£ å° /system/app/ ä¸ã
ä¸é¢ä»¥ SecureSetting.apk 为ä¾ï¼æ¼ç¤ºè¿ä¸ªæä½ãéè¦åå¤ä¸å°å·²ç»è·å¾ Root æéçææºã
1ãéè¿ USB è¿æ¥ææºåçµèã
2ãä½¿ç¨ adb æ§å¶ææºã
æºç æå°ï¼
1. $ adb push SecureSetting.apk /sdcard/ // ä¸ä¼ è¦å®è£ çæ件ï¼ä¸ºå®è£ ååå¤ã
2. $ adb shell
3. $ su // åæ¢å° root ç¨æ·ãå¦æ没æè·å¾ Root æéï¼è¿ä¸æ¥ä¸ä¼æåã
4. # mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system // 让ååºå¯åã
5. # cat /sdcard/SecureSetting.apk > /system/app/SecureSetting.apk // è¿ä¸æ¥å¯ä»¥ç¨ cp å®ç°ï¼ä½ä¸è¬è®¾å¤ä¸æ²¡æå å«è¯¥å½ä»¤ãå¦æä½¿ç¨ mv ä¼åºç°é误ï¼failed on '/sdcard/NetWork.apk' - Cross-device linkã
6. # mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system // è¿åååºå±æ§ï¼åªè¯»ã
7. # exit
8. $ exit
$ adb push SecureSetting.apk /sdcard/ // ä¸ä¼ è¦å®è£ çæ件ï¼ä¸ºå®è£ ååå¤ã
$ adb shell
$ su // åæ¢å° root ç¨æ·ãå¦æ没æè·å¾ Root æéï¼è¿ä¸æ¥ä¸ä¼æåã
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system // 让ååºå¯åã
# cat /sdcard/SecureSetting.apk > /system/app/SecureSetting.apk // è¿ä¸æ¥å¯ä»¥ç¨ cp å®ç°ï¼ä½ä¸è¬è®¾å¤ä¸æ²¡æå å«è¯¥å½ä»¤ãå¦æä½¿ç¨ mv ä¼åºç°é误ï¼failed on '/sdcard/NetWork.apk' - Cross-device linkã
# mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system // è¿åååºå±æ§ï¼åªè¯»ã
# exit
$ exit
éå¯ï¼å¯ä»¥çå° SecureSetting å·²ç»å®è£ 好ã
《全員請上車》外型遭指點 趙正平忍不住爆粗口
《追分成功》夏天珞戲中嗆罵 戲外感愧疚
髮夾彎? 美商務部長:輝達可賣AI晶片給中國
开设寒假返乡校园定制公交专线 温暖学子回家路
浙江培育放心消费商圈485个 清除“霸王条款”179条
「11症狀中4」恐是紅斑性狼瘡! 專家提醒日常照護5重點