觸摸屏 adb調試


 

1、adb shell cat /proc/kmsg

這條命令肯定是要放在第一位的,可以打印內核信息,對應於驅動程序中的printk語句。
如果出現以下提示,說明權限不夠,可以通過adb root獲取root權限。

/system/bin/sh: cat: /proc/kmsg: Permission denied

另外,也可以將kmsg的內容重定向寫入一個log文件中。可以依次執行下面命令

adb shell
cat /proc/kmsg > /mnt/sdcard/log

可將kmsg的內容重定向到 /mnt/sdcard/ 路徑下的log文件。

2、adb pull

當我們將log保存在 /mnt/sdcard/ 路徑下的時候,可以通過adb pull命令取出來放到指定路徑。

adb pull /mnt/sdcard/log C:\Users\Administrator\Desktop

有的樣機會提示不可讀寫,那么可以在pull或者push之前加上adb remount的命令。

3、adb push

如果我們某個APP應用需要某個.so文件,那么可以通過adb push將指定的.so文件推送到指定的路徑。

adb push C:\Users\Administrator\Desktop\sensors.sc8830.so /system/lib/hw

 

 

adb push C:\Users\Administrator\Desktop\sensors.sc8830.so /system/lib/hw

4、查看tp驅動是否加載成功

tp驅動實際上是i2c設備驅動,通過查看i2c設備節點可以查看到驅動的相關信息。

adb shell
ll /sys/bus/i2c/drivers

如果像是列表中有對應名字的目錄,那說明驅動加載成功。此時可以進入到對應的目錄中list可以查看當前驅動的信息。如下:
驅動信息

從上面的信息中可以知道當前設備是掛接到i2c-0上面,其i2c的設備地址是0x20(七位地址),驅動的名字為”tcm1680”。

5、調試觸摸tp有無反應

使用adb shell getevent 指令,如果手指觸摸tp,會有相應的event打印出來,如下面的格式:

/dev/input/event5: 0003 0039 00000053
/dev/input/event5: 0003 0039 00000000
/dev/input/event5: 0003 0035 00000228
/dev/input/event5: 0003 0036 00000159
/dev/input/event5: 0000 0000 00000000
/dev/input/event4: 0003 0002 fffffc0d
/dev/input/event4: 0000 0000 00000000
/dev/input/event5: 0003 0036 00000157
/dev/input/event5: 0000 0000 00000000
/dev/input/event5: 0003 0035 00000229
/dev/input/event5: 0003 0036 00000155
/dev/input/event5: 0000 0000 00000000
/dev/input/event5: 0003 0035 0000022a
/dev/input/event5: 0003 0036 00000153
/dev/input/event5: 0000 0000 00000000
/dev/input/event5: 0003 0035 0000022b
/dev/input/event5: 0003 0036 00000151
/dev/input/event5: 0000 0000 00000000

這就是說明tp已經有反應了,進一步說明tp驅動加載成功且中斷以及i2c都正常。

6、使用adb shell getevent指令

該指令有如下用法:

Usage: getevent [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]
-t: show time stamps
-n: don’t print newlines
-s: print switch states for given bits
-S: print all switch states
-v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64)
-d: show HID descriptor, if available
-p: show possible events (errs, dev, name, pos. events)
-i: show all device info and possible events
-l: label event types and names in plain text
-q: quiet (clear verbosity mask)
-c: print given number of events then exit
-r: print rate events are received

7、查看當前的input設備

在驅動程序中我們都要注冊一個input設備,可以通過以下指令查看所有的input設備,並看是否注冊成功:

adb shell getevent -i

執行結果為:

add device 1: /dev/input/event5
bus: 0018
vendor dead
product beef
version 0101
name: “chm_ts”
location: “input/ts”
id: “”
version: 1.0.1
events:
ABS (0003): 002f : value 0, min 0, max 10, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 200, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 480, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
add device 2: /dev/input/event4
bus: 0018
vendor 0000
product 0000
version 0000
name: “mir3da”
location: “”
id: “”
version: 1.0.1
events:
ABS (0003): 0000 : value 28, min -16384, max 16383, fuzz 0, flat 0, resolution 0
0001 : value 71, min -16384, max 16383, fuzz 0, flat 0, resolution 0
0002 : value -1012, min -16384, max 16383, fuzz 0, flat 0, resolution 0
input props:

add device 3: /dev/input/event3
bus: 0019
vendor 0001
product 0001
version 0100
name: “sunxi-keyboard”
location: “sunxikbd/input0”
id: “”
version: 1.0.1
events:
KEY (0001): 001c 0066 0072 0073 008b
input props:

add device 4: /dev/input/event0
bus: 0019
vendor 0001
product 0001
version 0100
name: “axp22-supplyer”
location: “m1kbd/input2”
id: “”
version: 1.0.1
events:
KEY (0001): 0074
input props:

add device 5: /dev/input/event2
bus: 0019
vendor 0001
product 0001
version 0100
name: “sunxi-ths”
location: “sunxiths/input0”
id: “”
version: 1.0.1
events:
ABS (0003): 0028 : value 0, min -50, max 180, fuzz 0, flat 0, resolution 0
input props:

add device 6: /dev/input/event1
bus: 0019
vendor 0001
product ffff
version 0100
name: “headset”
location: “headset/input0”
id: “”
version: 1.0.1
events:
KEY (0001): 0072 0073 00e2
input props:

could not get driver version for /dev/input/mice, Not a typewriter

其中/dev/input/event5是我們注冊的input設備,名字為”chm_ts”,其中

ABS (0003): 002f : value 0, min 0, max 10, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 200, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 480, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0

這里面的內容對應於驅動中申請input設備對其初始化的內容,包括:
最大支持手指數 ABS_MT_TRACKING_ID 為 10;
手指壓力范圍 ABS_MT_TOUCH_MAJOR 為 255;
手指按壓寬度 ABS_MT_WIDTH_MAJOR 為 200;
X方向的最大觸摸范圍 ABS_MT_POSITION_X 為 800;
Y方向的最大觸摸范圍 ABS_MT_POSITION_Y 為 480;

8、查看報點率

這個問題一般是客戶比較關注了,報點率決定了觸摸的響應速度,報點率過低直接會影響到體驗。可通過以下指令查看報點率:

adb shell getevent -r /dev/input/event5

9、查看詳細的報點

adb shell getevent -l /dev/input/event5

假設我手指連續在(0xd8, 16f)即(216, 367)坐標附近觸摸三次,得到的信息如下:
報點坐標

可見,一次觸摸抬起的動作對應的報告格式是:
EV_ABS ABS_MT_TRACKING_ID
當前觸摸的ID,這個會一直累加上去的;

EV_ABS ABS_MT_POSITION_X
EV_ABS ABS_MT_POSITION_Y
當前觸摸的X和Y的坐標;

EV_KEY BTN_TOUCH
標記是按下或者抬起的動作;

EV_SYN SYN_REPORT
標記一次上報結束;

EV_ABS ABS_MT_TRACKING_ID
如果這個值為0xffffffff,那么說明當前是抬起動作,后面跟上的BTN_TOUCH要為UP;

EV_KEY BTN_TOUCH
標記是按下或者抬起的動作;

EV_SYN SYN_REPORT
標記一次上報結束;

10、sendevent

sendevent的作用與getevent相反,可以往input設備中寫入值。
網上有很多用例,不過需要注意的是一定要符合input上報的協議才能成功。

11、發送特定按鍵的信息

手機上通常有幾個特定的功能按鍵,比如返回鍵、home鍵、設置鍵等。可以使用

adb shell input keyevent key_code

進行特殊的操作,比如輸入下面的指令就相當於按下返回鍵

adb shell input keyevent 3

具體的key_code可以參照以下兩篇文章:
ADB Shell Input Events
KeyEvent

12、setenforce

在調試展訊平台的tp驅動,有時候我們調試用的APK無法正常使用,內核會有如下提示信息:

<36>[ 93.437866] c0 type=1400 audit(1325376121.928:24): avc: denied { write } for pid=2502 comm=”com.chm.tstools” name
=”chm_ts” dev=”proc” ino=4026533105 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=0

即當前應用程序”com.chm.tstools”無法往名為”chm_ts”的proc設備節點上寫入數據,因此可見是一個權限的為。可以使用以下命令解決:

adb shell setenforce 0

13、查看虛擬按鍵的坐標

Android framework中,對於虛擬按鍵的處理實際上是將驅動中上報的坐標判斷是否在按鍵區域中的坐標范圍之內,如果在那范圍內,那么就當做按鍵處理。
在 /sys/board_properties/ 目錄下,會有一個設備文件,這個設備文件的內容里面包含按鍵的信息。

adb shell cat /sys/board_properties/virtualkeys.focaltech_ts

我手上的一台展訊平台樣機,不包含按鍵區域的分辨率是480x800,采用的是focaltech的觸控IC。上述命令得到的結果如下:

0x01:139:80:900:80:65:0x01:172:240:900:80:65:0x01:158:400:900:80:65

里面各個參數的意義如下:

0x01: A version code. Must always be 0x01.
139: The Linux key code of the virtual key.
80: The X pixel coordinate of the center of the virtual key.
900: The Y pixel coordinate of the center of the virtual key.
80: The width of the virtual key in pixels.
65: The height of the virtual key in pixels.

具體的內容可以參照Android tp的虛擬按鍵(virtual key)處理

14、輸入配置文件

有時候在調試tp驅動碰到這么一種情況,就是觸摸的時候屏幕上一直有個小白點,且滑動的時候看起來像是滑動觸摸板,怎么解釋呢?就是tp驅動上報應該按照絕對坐標的方式而不是觸摸板按照相對坐標的方式上報的。此時可以懷疑是idc文件沒有添加。
可以在 /system/usr/idc 目錄下添加一個與input設備同樣名字的idc文件。

15、屏幕截圖

如果有screencap命令,則可以使用該命令截圖

adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png d:/screenshot.png


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM