This repository has been archived by the owner on Jul 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
deodex.sh
executable file
·93 lines (87 loc) · 2.35 KB
/
deodex.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
#!/bin/bash
SAVEIFS=$IFS
IFS=$'\n'
rootDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
triage="$rootDir/triage"
# Initialize
chmod -R a+x "$rootDir/tools"
source "$rootDir/tools/tools.sh"
checkJava
checkZpln
# Parse options
while getopts "d:hgzl:f:" opt; do
case "$opt" in
d)
if [[ ! -d "$OPTARG" ]]; then
echo "Error: Folder \"$OPTARG\" does not exist"
abort
fi
triage="$OPTARG"
;;
f)
processDir="$triage/$OPTARG"
if [[ -d "$processDir" ]]; then
odexCount="$(find $processDir -type f -name '*.odex' | wc -l | tr -d ' ')"
if [[ "$odexCount" == "0" ]]; then
echo "Error: No odex files found in $OPTARG."
abort
fi
processDirList=("$OPTARG")
else
echo "Error: $triage/$OPTARG does not exist."
abort
fi
;;
h)
show_help
;;
g)
show_api
;;
z)
zpln_all
;;
l)
api="$OPTARG"
;;
\?)
echo "Error: Invalid option -$OPTARG."
echo
show_help
;;
:)
echo "Error: Option -$OPTARG requires an argument."
echo
show_help
;;
esac
done
# Build bootclasspath
[[ $api == 0 ]] && echo "Error: Please specify a valid API level." && abort
if [ "$api" -lt "20" ]; then
bootclasspath="$triage/framework"
echo "Please remember to copy your bootclass files to $triage/framework!"
else
[ -d "$triage/framework/arm64" ] && arch="arm64"
bootclasspath="$triage/framework/$arch"
echo "Please remember to copy /system/framework/$arch to $triage/framework!"
fi
# Begin
if [[ "$api" == "21" ]] || [[ "$api" == "22" ]]; then
echo "Deoptimizing boot.oat..."
error=0
rm $triage/oat2dex.log
deoptBoot
[[ "$error" != "0" ]] && abort
fi
for folder in ${processDirList[@]}; do
baseDir="$triage/$folder"
odexCount="$(find $baseDir -type f -name '*.odex' | wc -l | tr -d ' ')"
if [[ "$odexCount" == "0" ]]; then
echo "No apps to deodex in /$folder"
else
echo -e "\nDeodexing /$folder"
deodexDir "$folder"
fi
done
quit