-
Notifications
You must be signed in to change notification settings - Fork 7
/
adb_get_pid_from_sharedso.sh
executable file
·67 lines (60 loc) · 1.55 KB
/
adb_get_pid_from_sharedso.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
function try_to_root_device(){
echo "wait device...."
echo ===================================================================================
adb wait-for-device
echo ===find adb devices=====
adb devices
sleep 1
echo =========try to root now===========================================================
adb shell setprop ro.debuggable 1
echo =========plug out usb and then plugn in===========================================
adb root
echo =========plug out usb and then plugn in===========================================
sleep 1
}
function print_usage(){
echo Usage:
echo "eg:"
echo "$0 shared_lib_name"
}
function check_parameter_number(){
if [ $# -eq 1 ]
then
echo "Find one paramter..."
echo "grep so = $1"
else
echo "ERR:need one paramter..."
print_usage
exit 0
fi
}
function get_device_proc_data(){
echo "wait device...."
adb wait-for-device
adb shell " ls -d proc/*/" > /tmp/adb_device_proc_data.log
}
function handle_data(){
n=$(awk 'END{print NR}' /tmp/adb_device_proc_data.log)
for i in `seq $n`
do
#echo $i
hande_line=$i
#echo "hande_line=$hande_line"
sed -n "$hande_line""p" /tmp/adb_device_proc_data.log > /tmp/tmp_handle.log
#sed 's/^M//g' /tmp/tmp_handle.log
sed -i "s/$(echo -e '\015')//g" /tmp/tmp_handle.log
out=`cat -v /tmp/tmp_handle.log`
out_s=$out"maps"
echo $out_s
echo "wait device...."
adb wait-for-device
adb shell "cat $out_s" > /tmp/tmp_maps.log
grep $1 /tmp/tmp_maps.log
done
}
##############################shell start here##########
check_parameter_number $@
try_to_root_device $@
get_device_proc_data $@
handle_data $@