-
Notifications
You must be signed in to change notification settings - Fork 48
/
methodtobosp
executable file
·70 lines (59 loc) · 1.75 KB
/
methodtobosp
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
67
68
69
#!/bin/bash
#**************************************************#
#This shell used to call SCheck to replace smali
#**************************************************#
CUR_DIR=$(dirname $0)
SCHECK=$CUR_DIR/SCheck
PRE_DIR=$PWD
PRJ_ROOT=$PWD
function usage()
{
echo "################ USAGE ################"
echo "#"
echo "# methodtobosp smali methodName"
echo "# smali: the target smali, which will be replace to bosp"
echo "# methodName: the method's name"
echo "#"
echo "# ex:"
echo "# methodtobosp services.jar.out/smali/com/android/server/am/ActivityManagerService.smali 'moveTaskToFront(IILandroid/os/Bundle;)V'"
echo "# it will replace the method moveTaskToFront(IILandroid/os/Bundle;)V in services.jar.out/smali/com/android/server/am/ActivityManagerService.smali by autopatch/bosp/services.jar.out/smali/com/android/server/am/ActivityManagerService.smali"
echo "#"
echo "# Attention:"
echo "# The method name should enclose in the quotes."
echo "#"
}
if [ $# -lt 1 ]; then
usage
exit 1
fi
function getPrjRoot()
{
while [ ! -f $PRJ_ROOT/Makefile ] && [ ! -f $PRJ_ROOT/makefile ]
do
PRJ_ROOT=`dirname $PRJ_ROOT`
if [ $PRJ_ROOT == '/' ]; then
echo "Error: can not get the project's root directory!"
echo " make sure you run this command in your device directory"
exit 1
fi
done
if [ ${PRJ_ROOT#$PORT_ROOT*} == $PRJ_ROOT ]; then
echo "Error: you should run 'source ./build/envsetup.sh' in coron first!"
exit 1
fi
}
function main()
{
if [ $# -lt 2 ]; then
usage
exit 1
fi
getPrjRoot
cd $PRJ_ROOT > /dev/null
tmpFile=`mktemp -t methodtobosp.XXXXX`
echo "$2" > $tmpFile
make methodtobosp SMALI_FILE=$1 METHOD=$tmpFile
rm -rf $tmpFile
cd $PRE_DIR > /dev/null
}
main