-
Notifications
You must be signed in to change notification settings - Fork 16
/
android-svc.sh
executable file
·98 lines (94 loc) · 3.73 KB
/
android-svc.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
#ANDROID_SVC_LIB_BEGIN
if [ -f "${PREFIX}/lib/android-svc-lib.sh" ]; then
source "${PREFIX}/lib/android-svc-lib.sh"
elif [ -f "./android-svc-lib.sh" ]; then
source ./android-svc-lib.sh
else
>&2 echo "ERROR: 'android-svc-lib.sh' is missing!"
exit 1
fi
#ANDROID_SVC_LIB_END
if [ "$1" == "help" ] || [ "$1" == "--help" ]; then
echo "USAGE:"
echo ""
echo "android-svc [options] download"
echo "Description: Enable offline usage by downloading required Android source code files for the current device."
echo "Example: android-svc download"
echo ""
echo "android-svc [options] call 'SERVICE_PACKAGE_NAME.METHOD_NAME(arguments)'"
echo "Description: Call a service method."
echo "Example: android-svc call 'com.android.internal.telephony.ITelephony.dial(\"555-0199\")'"
echo ""
echo "android-svc [options] convert 'SERVICE_PACKAGE_NAME.METHOD_NAME(arguments)'"
echo "Description: Convert a service method call to a bash command. THE RESULTING COMMAND WILL ONLY WORK FOR THE EXACT ANDROID VERSION OF YOUR DEVICE!"
echo "Example: android-svc convert 'com.android.internal.telephony.ITelephony.dial(\"555-0199\")'"
echo ""
echo "android-svc [options] list-packages"
echo "Description: List all service package names."
echo "Example: android-svc list-packages"
echo ""
echo "android-svc [options] list-methods SERVICE_PACKAGE_NAME"
echo "Description: List all methods for a service package."
echo "Example: android-svc list-methods android.content.pm.IPackageManager"
echo ""
echo "android-svc [options] method-signature SERVICE_PACKAGE_NAME.METHOD_NAME"
echo "Description: Get method-signature for a specific method."
echo "Example: android-svc method-signature android.media.IAudioService.isMasterMute"
echo ""
echo "Supported options are --adb or --adb=<device-id>"
echo "(You only need this in order to use this from a Linux machine via ADB.)"
echo ""
echo "android-svc help"
echo "Description: Print this message."
echo "Example: android-svc help"
exit 0
elif [ "$1" == "version" ] || [ "$1" == "--version" ]; then
echo "$g_ANDROID_SVC_LIB_VERSION"
exit 0
elif [[ "$1" == "--adb="* ]]; then
SetShellType "adb"
SetAdbDevice "$(echo "$1" | cut -d'=' -f2)"
command="$2"
commandParam1="$3"
elif [ "$1" == "--adb" ]; then
SetShellType "adb"
command="$2"
commandParam1="$3"
else
command="$1"
commandParam1="$2"
fi
Init
if [ "$command" == "call" ]; then
CallServiceMethod "$commandParam1"
elif [ "$command" == "convert" ]; then
ConvertServiceCallToShellCommand "$commandParam1"
elif [ "$command" == "list-packages" ]; then
GetServicePackageNames
elif [ "$command" == "list-methods" ]; then
if [[ $commandParam1 == *"."* ]]; then # A service package name was given
servicePackageName="$commandParam1"
else # A service code name was given
servicePackageName="$(GetServicePackageName "$l_serviceCodeName")"
fi
methodSignatures="$(GetMethodSignaturesForPackage "${servicePackageName}")"
if test -t 1; then
echo -e "$(AidlSyntaxHighlight "${methodSignatures}")"
else
echo "${methodSignatures}"
fi
elif [ "$command" == "method-signature" ]; then
methodName=$(echo "$commandParam1" | rev | cut -d'.' -f 1 | rev)
servicePackageName=$(echo "$commandParam1" | rev | cut -d"." -f2- | rev)
methodSignature="$(GetMethodSignature "${servicePackageName}" "${methodName}")"
if test -t 1; then
echo -e "$(AidlSyntaxHighlight "${methodSignature}")"
else
echo "${methodSignature}"
fi
elif [ "$command" == "download" ]; then
DownloadSourceFiles "${g_aidlFileList}" "${g_aidlFileCache}"
else
Exit 1 "Command not found!"
fi