forked from dsixda/Android-Kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo_deodex_folder
More file actions
executable file
·210 lines (161 loc) · 3.85 KB
/
do_deodex_folder
File metadata and controls
executable file
·210 lines (161 loc) · 3.85 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
############################################################################
#
# Copyright (c) 2013 - dsixda ([email protected])
#
# Android Kitchen is 100% free. This script file is intended for personal
# and/or educational use only. It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################
#
# This script has two parameters:
#
# $1 = folder(s) to deodex under /system (mandatory)
# e.g. framework
# e.g. "framework app"
# $2 = whether to enable logging (y or n) (optional)
#
dir_list=$1
do_log=$2
if [ "$dir_list" == "" ]
then
echo "No folders for deodexing specified!"
exit 0
fi
base_dir=`pwd`
api_level=`scripts/get_api_level`
cd WORKING_*
num_odex_fr=`find system/framework | grep -c "\.odex$"`
num_odex_app=`find system/app | grep -c "\.odex$"`
#
# Create log file
#
if [ "$do_log" == "" ]
then
echo
echo -n "Enable logging to file (y/n)? (default: y): "
read do_log
fi
if [ "$do_log" != "n" ]
then
do_log=y
else
do_log=n
fi
date_str=`date '+%m%d%y_%H%M%S'`
log_file=deodex_$date_str.log
cd ..
version=`scripts/get_smali_version`
cd WORKING_*
if [ "$do_log" == "y" ]
then
echo
echo "Creating log file $log_file ..."
echo "" >> ../$log_file
echo "smali/baksmali version: $version" >> ../$log_file
fi
#
# Go through each folder specified
#
for folder in ${dir_list[@]}
do
if [ "$do_log" == "y" ]
then
echo "" >> ../$log_file
echo "Folder: $folder" >> ../$log_file
echo "-------------------" >> ../$log_file
fi
if [ $folder == framework ]
then
num_odex_folder=$num_odex_fr
elif [ $folder == app ]
then
num_odex_folder=$num_odex_app
else
echo
echo "Error: Folder $folder not valid!"
if [ "$do_log" == "y" ]
then
echo "Invalid folder" >> ../$log_file
fi
continue
fi
count=0
found_error=0
path=system/$folder
echo
echo
echo "Going into $path ..."
echo
cd $path
grep_cmd=`find . | grep "\.odex$" | sed 's/.\///g' | sort -f`
if [ "$grep_cmd" == "" ]
then
echo "Nothing found under $path!"
if [ "$do_log" == "y" ]
then
echo "Nothing here" >> ../../../$log_file
fi
else
#
# Finally, deodex each file
#
cp -f ../../../tools/deodex_files/baksmali-$version.jar baksmali.jar
cp -f ../../../tools/deodex_files/smali-$version.jar smali.jar
for odex_file in $grep_cmd
do
count=$(($count+1))
echo
echo "NOW AT FILE $count OF $num_odex_folder IN $path: $odex_file"
while [ -e $odex_file ]
do
../../../scripts/do_deodex_file $api_level $odex_file ../framework
if [ -e $odex_file ]
then
if [ -e $odex_file ]
then
echo "ERROR: Aborting $odex_file"
found_error=1
if [ "$do_log" == "y" ]
then
echo "* ERROR: Aborting $odex_file!" >> ../../../$log_file
fi
break
elif [ ! -e $odex_file ]
then
if [ "$do_log" == "y" ]
then
echo "$odex_file successfully deodexed" >> ../../../$log_file
fi
break
fi
else
if [ "$do_log" == "y" ]
then
echo "$odex_file successfully deodexed" >> ../../../$log_file
fi
fi
done
done
rm -f baksmali.jar
rm -f smali.jar
echo
echo "Finished $path"
if [ "$found_error" == "1" ]
then
echo
echo "WARNING: Could not deodex the following (you can try to deodex these files again):"
echo `ls *.odex`
echo
cd ../..
break
fi
fi
cd ../..
done
if [ "$do_log" == "y" ]
then
echo
echo "A summary of the deodexing has been logged in $log_file"
fi
cd $base_dir