forked from DavidPisces/MIUI-Auto-Odex
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathodex.sh
More file actions
554 lines (538 loc) · 23.1 KB
/
odex.sh
File metadata and controls
554 lines (538 loc) · 23.1 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
#!/bin/bash
# MIUI ODEX项目贡献者:柚稚的孩纸(zjw2017) 雄氏老方(DavidPisces) 水龙(Amktiao)
nowversion=4.44
workfile=/storage/emulated/0/MIUI_odex
success_count=0
failed_count=0
now_time=$(date '+%Y%m%d_%H:%M:%S')
echo "- 正在准备环境"
# rm
rm -rf $workfile
rm -rf /data/adb/modules/miuiodex
# mkdir
echo "- 正在创建目录"
mkdir -p /storage/emulated/0/MIUI_odex/log
mkdir -p /storage/emulated/0/MIUI_odex/app
mkdir -p /storage/emulated/0/MIUI_odex/priv-app
mkdir -p /storage/emulated/0/MIUI_odex/product/app
mkdir -p /storage/emulated/0/MIUI_odex/product/priv-app
mkdir -p /storage/emulated/0/MIUI_odex/vendor/app
# log
touch $workfile/log/MIUI_odex_$now_time.log
# clear screen
clear
# choose odex mod
echo "*************************************************"
echo " "
echo " "
echo " MIUI ODEX"
echo " $nowversion"
echo " "
echo "*************************************************"
echo -e "\n- 您希望以什么模式编译Odex\n"
echo "[1] Simple (耗时较少,占用空间少,仅编译重要应用)"
echo "[2] Complete (耗时较长,占用空间大,完整编译)"
echo "[3] Skip ODEX 不进行Odex编译"
echo "[4] Update From Github 从Github更新脚本"
echo "[5] Update From Gitee 从Gitee更新(国内源)"
echo "[6] Quit 退出"
echo -e "\n请输入选项"
read choose_odex
clear
# Update Mode 1
if [ $choose_odex == 4 ] ; then
# Github Raw
echo "- 正在查询Github最新版本,请耐心等待..."
curl -s -o version https://raw.githubusercontent.com/DavidPisces/MIUI-Auto-Odex/master/version
latestversion=$(cat version)
latestshname="odex.sh"
lastname="odex$(cat version).sh"
latesturl="https://raw.githubusercontent.com/DavidPisces/MIUI-Auto-Odex/master/odex.sh"
clear
is_update=$(echo "$latestversion > $nowversion" | bc)
if [ $is_update != 0 ] ; then
echo "! 发现新版本$latestversion,是否更新"
echo " [y] 更新"
echo " [n] 取消"
read choose_update
clear
if [ $choose_update == "y" ] ;then
echo "- 正在下载更新,请耐心等待..."
curl -s -o odex$latestversion.sh $latesturl
clear
if [ $? -eq 0 ]; then
echo "- 新版本已下载完毕,请退出重新运行odex.sh"
rm -rf version
mv "odex$latestversion.sh" "$latestshname"
exit
else
echo "! 下载失败"
fi
else
echo "# 已取消"
rm -rf version
exit
fi
else
echo "- 未发现新版本"
echo " 当前版本:$nowversion"
echo " Github版本:$latestversion"
echo " 是否重新下载?"
echo "[y] 下载"
echo "[n] 取消"
read choose_update
clear
if [ $choose_update == "y" ] ;then
echo "- 正在下载更新,请耐心等待..."
curl -s -o odex$latestversion.sh $latesturl
clear
if [ $? -eq 0 ]; then
echo "- 下载完毕,请退出重新运行odex.sh"
rm -rf version
mv "odex$latestversion.sh" "$latestshname"
exit
else
echo "! 下载失败"
fi
else
echo "# 已取消"
rm -rf version
exit
fi
rm -rf version
exit
fi
fi
# Update Mode 2
if [ $choose_odex == 5 ] ; then
# Gitee Raw
echo "- 正在查询Gitee最新版本,请耐心等待..."
curl -s -o version https://gitee.com/David-GithubClone/MIUI-Auto-Odex/raw/master/version
latestversion=$(cat version)
latestshname="odex.sh"
lastname="odex$(cat version).sh"
latesturl="https://gitee.com/David-GithubClone/MIUI-Auto-Odex/raw/master/odex.sh"
clear
is_update=$(echo "$latestversion > $nowversion" | bc)
if [ $is_update != 0 ] ; then
echo "! 发现新版本$latestversion,是否更新"
echo " [y] 更新"
echo " [n] 取消"
read choose_update
clear
if [ $choose_update == "y" ] ;then
echo "- 正在下载更新,请耐心等待..."
curl -s -o odex$latestversion.sh $latesturl
clear
if [ $? -eq 0 ]; then
echo "- 新版本已下载完毕,请退出重新运行odex.sh"
rm -rf version
mv "odex$latestversion.sh" "$latestshname"
exit
else
echo "! 下载失败"
fi
else
echo "# 已取消"
rm -rf version
exit
fi
else
echo "- 未发现新版本"
echo " 当前版本:$nowversion"
echo " Gitee版本:$latestversion"
echo " 是否下载?"
echo "[y] 下载"
echo "[n] 取消"
read choose_update
clear
if [ $choose_update == "y" ] ;then
echo "- 正在下载更新,请耐心等待..."
curl -s -o odex$latestversion.sh $latesturl
clear
if [ $? -eq 0 ]; then
echo "- 下载完毕,请退出重新运行odex.sh"
rm -rf version
mv "odex$latestversion.sh" "$latestshname"
exit
else
echo "! 下载失败"
fi
else
echo "# 已取消"
rm -rf version
exit
fi
rm -rf version
exit
fi
fi
if [ $choose_odex == 6 ] ; then
echo "- 已退出"
exit
else
# choose dex2oat mod
echo "*************************************************"
echo " "
echo " "
echo " MIUI ODEX"
echo " $nowversion"
echo " "
echo "*************************************************"
echo -e "\n- 您希望以什么模式进行Dex2oat\n"
echo "[1] Speed (快速编译,耗时较短)"
echo "[2] Everything (完整编译,耗时较长)"
echo "[3] 不进行Dex2oat编译"
echo -e "\n请输入选项"
read choose_dex2oat
fi
clear
if [ $choose_odex == 3 ] ; then
echo "- 跳过odex编译,不会生成模块"
odex_module=false
else
if [ $choose_odex == 1 ] ; then
echo "- 正在以Simple(简单)模式编译"
cp -r /system/app/miui $workfile/app
cp -r /system/app/miuisystem $workfile/app
cp -r /system/app/XiaomiServiceFramework $workfile/app
cp -r /system/priv-app/MiuiCamera $workfile/priv-app
cp -r /system/priv-app/MiuiGallery $workfile/priv-app
cp -r /system/priv-app/MiuiHome $workfile/priv-app
cp -r /system/priv-app/MiuiSystemUI $workfile/priv-app
cp -r /system/priv-app/SecurityCenter $workfile/priv-app
cp -r /system/product/priv-app/Settings $workfile/product/priv-app
echo "- 文件复制完成,开始执行"
odex_module=true
else
if [ $choose_odex == 2 ] ;then
echo "- 正在以Complete(完整)模式编译"
# copy files to path
cp -r /system/app/* $workfile/app
cp -r /system/priv-app/* $workfile/priv-app
cp -r /system/product/app/* $workfile/product/app
cp -r /system/product/priv-app/* $workfile/product/priv-app
cp -r /system/vendor/app/* $workfile/vendor/app
echo "- 文件复制完成,开始执行"
odex_module=true
fi
fi
fi
# system/app
dirapp=$(ls -l $workfile/app |awk '/^d/ {print $NF}')
for i in $dirapp
do
cd $workfile/app/$i
# unzip
unzip -q -o *.apk
# whether unzip apk success
if [ $? = 0 ] ; then
echo "- 解包$i成功,开始处理"
rm -rf `find . ! -name '*.dex' `
mkdir -p $workfile/app/$i/oat/arm64
oat=$workfile/app/$i/oat/arm64
count=`ls -l $workfile/app/$i/ | grep "^-" | wc -l`
if [ "$count" -ge "1" ]; then
echo "- 检测到$count个dex文件,开始编译"
echo "! 正在分离$i的odex,请坐和放宽"
if [ "$count" == "1" ]; then
dex2oat --dex-file=$workfile/app/$i/classes.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$oat/$i.odex
fi
if [ "$count" == "2" ]; then
dex2oat --dex-file=$workfile/app/$i/classes.dex --dex-file=$workfile/app/$i/classes2.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$oat/$i.odex
fi
if [ "$count" == "3" ]; then
dex2oat --dex-file=$workfile/app/$i/classes.dex --dex-file=$workfile/app/$i/classes2.dex --dex-file=$workfile/app/$i/classes3.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$oat/$i.odex
fi
if [ "$count" == "4" ]; then
dex2oat --dex-file=$workfile/app/$i/classes.dex --dex-file=$workfile/app/$i/classes2.dex --dex-file=$workfile/app/$i/classes3.dex --dex-file=$workfile/app/$i/classes4.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$oat/$i.odex
fi
if [ "$count" == "5" ]; then
dex2oat --dex-file=$workfile/app/$i/classes.dex --dex-file=$workfile/app/$i/classes2.dex --dex-file=$workfile/app/$i/classes3.dex --dex-file=$workfile/app/$i/classes4.dex --dex-file=$workfile/app/$i/classes5.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$oat/$i.odex
fi
if [ "$count" == "6" ]; then
dex2oat --dex-file=$workfile/app/$i/classes.dex --dex-file=$workfile/app/$i/classes2.dex --dex-file=$workfile/app/$i/classes3.dex --dex-file=$workfile/app/$i/classes4.dex --dex-file=$workfile/app/$i/classes5.dex --dex-file=$workfile/app/$i/classes6.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$oat/$i.odex
fi
rm -rf *.dex
echo "- 已完成对$i的odex分离处理"
let success_count=success_count+1
else
echo "! 未检测到dex文件,跳过编译"
rm -rf $workfile/app/$i
let failed_count=failed_count+1
echo "$i :编译失败,没有dex文件" >> $workfile/log/MIUI_odex_$now_time.log
fi
else
echo "! 解压$i失败,没有apk文件"
rm -rf $workfile/app/$i
echo "$i :编译失败,没有apk文件" >> $workfile/log/MIUI_odex_$now_time.log
let failed_count=failed_count+1
fi
done
# system/priv-app
dirpriv=$(ls -l $workfile/priv-app |awk '/^d/ {print $NF}')
for p in $dirpriv
do
cd $workfile/priv-app/$p
# unzip
unzip -q -o *.apk
# whether unzip apk success
if [ $? = 0 ] ; then
echo "- 解包$p成功,开始处理"
rm -rf `find . ! -name '*.dex' `
mkdir -p $workfile/priv-app/$p/oat/arm64
privoat=$workfile/priv-app/$p/oat/arm64
count=`ls -l $workfile/priv-app/$p/ | grep "^-" | wc -l`
if [ "$count" -ge "1" ]; then
echo "- 检测到$count个dex文件,开始编译"
echo "! 正在分离$p的odex,请坐和放宽"
if [ "$count" == "1" ]; then
dex2oat --dex-file=$workfile/priv-app/$p/classes.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$privoat/$p.odex
fi
if [ "$count" == "2" ]; then
dex2oat --dex-file=$workfile/priv-app/$p/classes.dex --dex-file=$workfile/priv-app/$p/classes2.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$privoat/$p.odex
fi
if [ "$count" == "3" ]; then
dex2oat --dex-file=$workfile/priv-app/$p/classes.dex --dex-file=$workfile/priv-app/$p/classes2.dex --dex-file=$workfile/priv-app/$p/classes3.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$privoat/$p.odex
fi
if [ "$count" == "4" ]; then
dex2oat --dex-file=$workfile/priv-app/$p/classes.dex --dex-file=$workfile/priv-app/$p/classes2.dex --dex-file=$workfile/priv-app/$p/classes3.dex --dex-file=$workfile/priv-app/$p/classes4.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$privoat/$p.odex
fi
if [ "$count" == "5" ]; then
dex2oat --dex-file=$workfile/priv-app/$p/classes.dex --dex-file=$workfile/priv-app/$p/classes2.dex --dex-file=$workfile/priv-app/$p/classes3.dex --dex-file=$workfile/priv-app/$p/classes4.dex --dex-file=$workfile/priv-app/$p/classes5.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$privoat/$p.odex
fi
if [ "$count" == "6" ]; then
dex2oat --dex-file=$workfile/priv-app/$p/classes.dex --dex-file=$workfile/priv-app/$p/classes2.dex --dex-file=$workfile/priv-app/$p/classes3.dex --dex-file=$workfile/priv-app/$p/classes4.dex --dex-file=$workfile/priv-app/$p/classes5.dex --dex-file=$workfile/priv-app/$p/classes6.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$privoat/$p.odex
fi
rm -rf *.dex
echo "- 已完成对$p的odex分离处理"
let success_count=success_count+1
else
echo "! 未检测到dex文件,跳过编译"
rm -rf $workfile/priv-app/$p
let failed_count=failed_count+1
echo "$p :编译失败,没有dex文件" >> $workfile/log/MIUI_odex_$now_time.log
fi
else
echo "! 解压$p失败,没有apk文件"
echo "$p :编译失败,没有apk文件" >> $workfile/log/MIUI_odex_$now_time.log
rm -rf $workfile/priv-app/$p
let failed_count=failed_count+1
fi
done
# system/product/app
productapp=$(ls -l $workfile/product/app |awk '/^d/ {print $NF}')
for a in $productapp
do
cd $workfile/product/app/$a
# unzip
unzip -q -o *.apk
# whether unzip apk success
if [ $? = 0 ] ; then
echo "- 解包$a成功,开始处理"
rm -rf `find . ! -name '*.dex' `
mkdir -p $workfile/product/app/$a/oat/arm64
productappoat=$workfile/product/app/$a/oat/arm64
count=`ls -l $workfile/product/app/$a/ | grep "^-" | wc -l`
if [ "$count" -ge "1" ]; then
echo "- 检测到$count个dex文件,开始编译"
echo "! 正在分离$a的odex,请坐和放宽"
if [ "$count" == "1" ]; then
dex2oat --dex-file=$workfile/product/app/$a/classes.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productappoat/$a.odex
fi
if [ "$count" == "2" ]; then
dex2oat --dex-file=$workfile/product/app/$a/classes.dex --dex-file=$workfile/product/app/$a/classes2.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productappoat/$a.odex
fi
if [ "$count" == "3" ]; then
dex2oat --dex-file=$workfile/product/app/$a/classes.dex --dex-file=$workfile/product/app/$a/classes2.dex --dex-file=$workfile/product/app/$a/classes3.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productappoat/$a.odex
fi
if [ "$count" == "4" ]; then
dex2oat --dex-file=$workfile/product/app/$a/classes.dex --dex-file=$workfile/product/app/$a/classes2.dex --dex-file=$workfile/product/app/$a/classes3.dex --dex-file=$workfile/product/app/$a/classes4.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productappoat/$a.odex
fi
if [ "$count" == "5" ]; then
dex2oat --dex-file=$workfile/product/app/$a/classes.dex --dex-file=$workfile/product/app/$a/classes2.dex --dex-file=$workfile/product/app/$a/classes3.dex --dex-file=$workfile/product/app/$a/classes4.dex --dex-file=$workfile/product/app/$a/classes5.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productappoat/$a.odex
fi
if [ "$count" == "6" ]; then
dex2oat --dex-file=$workfile/product/app/$a/classes.dex --dex-file=$workfile/product/app/$a/classes2.dex --dex-file=$workfile/product/app/$a/classes3.dex --dex-file=$workfile/product/app/$a/classes4.dex --dex-file=$workfile/product/app/$a/classes5.dex --dex-file=$workfile/product/app/$a/classes6.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productappoat/$a.odex
fi
rm -rf *.dex
echo "- 已完成对$a的odex分离处理"
let success_count=success_count+1
else
echo "! 未检测到dex文件,跳过编译"
rm -rf $workfile/product/app/$a
let failed_count=failed_count+1
echo "$a :编译失败,没有dex文件" >> $workfile/log/MIUI_odex_$now_time.log
fi
else
echo "! 解压$a失败,没有apk文件"
rm -rf $workfile/product/app/$a
echo "$a :编译失败,没有apk文件" >> $workfile/log/MIUI_odex_$now_time.log
let failed_count=failed_count+1
fi
done
# system/product/priv-app
productprivapp=$(ls -l $workfile/product/priv-app |awk '/^d/ {print $NF}')
for b in $productprivapp
do
cd $workfile/product/priv-app/$b
# unzip
unzip -q -o *.apk
# whether unzip apk success
if [ $? = 0 ] ; then
echo "- 解包$b成功,开始处理"
rm -rf `find . ! -name '*.dex' `
mkdir -p $workfile/product/priv-app/$b/oat/arm64
productprivappoat=$workfile/product/priv-app/$b/oat/arm64
count=`ls -l $workfile/product/priv-app/$b/ | grep "^-" | wc -l`
if [ "$count" -ge "1" ]; then
echo "- 检测到$count个dex文件,开始编译"
echo "! 正在分离$b的odex,请坐和放宽"
if [ "$count" == "1" ]; then
dex2oat --dex-file=$workfile/product/priv-app/$b/classes.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productprivappoat/$b.odex
fi
if [ "$count" == "2" ]; then
dex2oat --dex-file=$workfile/product/priv-app/$b/classes.dex --dex-file=$workfile/product/priv-app/$b/classes2.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productprivappoat/$b.odex
fi
if [ "$count" == "3" ]; then
dex2oat --dex-file=$workfile/product/priv-app/$b/classes.dex --dex-file=$workfile/product/priv-app/$b/classes2.dex --dex-file=$workfile/product/priv-app/$b/classes3.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productprivappoat/$b.odex
fi
if [ "$count" == "4" ]; then
dex2oat --dex-file=$workfile/product/priv-app/$b/classes.dex --dex-file=$workfile/product/priv-app/$b/classes2.dex --dex-file=$workfile/product/priv-app/$b/classes3.dex --dex-file=$workfile/product/priv-app/$b/classes4.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productprivappoat/$b.odex
fi
if [ "$count" == "5" ]; then
dex2oat --dex-file=$workfile/product/priv-app/$b/classes.dex --dex-file=$workfile/product/priv-app/$b/classes2.dex --dex-file=$workfile/product/priv-app/$b/classes3.dex --dex-file=$workfile/product/priv-app/$b/classes4.dex --dex-file=$workfile/product/priv-app/$b/classes5.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productprivappoat/$b.odex
fi
if [ "$count" == "6" ]; then
dex2oat --dex-file=$workfile/product/priv-app/$b/classes.dex --dex-file=$workfile/product/priv-app/$b/classes2.dex --dex-file=$workfile/product/priv-app/$b/classes3.dex --dex-file=$workfile/product/priv-app/$b/classes4.dex --dex-file=$workfile/product/priv-app/$b/classes5.dex --dex-file=$workfile/product/priv-app/$b/classes6.dex --compiler-filter=everything --instruction-set=arm64 --oat-file=$productprivappoat/$b.odex
fi
rm -rf *.dex
echo "- 已完成对$b的odex分离处理"
let success_count=success_count+1
else
echo "! 未检测到dex文件,跳过编译"
rm -rf $workfile/product/priv-app/$b
let failed_count=failed_count+1
echo "$b :编译失败,没有dex文件" >> $workfile/log/MIUI_odex_$now_time.log
fi
else
echo "! 解压$b失败,没有apk文件"
rm -rf $workfile/product/priv-app/$b
echo "$b :编译失败,没有apk文件" >> $workfile/log/MIUI_odex_$now_time.log
let failed_count=failed_count+1
fi
done
# end
echo "- 共$success_count次成功,$failed_count次失败,请检查对应目录"
if [ $odex_module == true ] ; then
# 生成模块
echo "- 正在制作模块,请坐和放宽"
mkdir -p /data/adb/modules/miuiodex/system
touch /data/adb/modules/miuiodex/module.prop
echo "id=miuiodex" >> /data/adb/modules/miuiodex/module.prop
echo "name=MIUI ODEX" >> /data/adb/modules/miuiodex/module.prop
echo "version=$nowversion" >> /data/adb/modules/miuiodex/module.prop
echo "versionCode=1" >> /data/adb/modules/miuiodex/module.prop
echo "author=柚稚的孩纸&雄式老方" >> /data/adb/modules/miuiodex/module.prop
echo "minMagisk=19000" >> /data/adb/modules/miuiodex/module.prop
model="`grep -n "ro.product.system.model" /system/build.prop | cut -d= -f2`"
ver="`grep -n "ro.miui.ui.version.name" /system/build.prop | cut -dV -f2`"
modelversion="`grep -n "ro.system.build.version.incremental" /system/build.prop | cut -d= -f2`"
time=$(date "+%Y年%m月%d日 %H:%M:%S")
echo -n "description=分离系统软件ODEX,MIUI$ver $modelversion,编译时间$time [Build with $model]" >> /data/adb/modules/miuiodex/module.prop
mv $workfile/* /data/adb/modules/miuiodex/system
if [ $? = 0 ] ; then
mv /data/adb/modules/miuiodex/system/log $workfile
rm -rf /data/adb/modules/miuiodex/system/packagelist
echo "- 模块制作完成,请重启生效"
else
echo "! 模块制作失败"
fi
else
echo "- 未选择编译odex选项,不会生成模块"
fi
if [ $choose_odex == 3 ] ;then
echo "- 不进行ODEX编译"
mkdir -p $workfile/packagelist
touch $workfile/packagelist/packagelist.log
echo "`pm list packages -3`" > $workfile/packagelist/packagelist.log
if [ $choose_dex2oat == 3 ] ; then
echo "不进行Dex2oat"
exit
fi
if [ $choose_dex2oat == 1 ] ; then
# 用户应用
apptotalnumber="`grep -o "package:" $workfile/packagelist/packagelist.log | wc -l`"
appnumber=0
echo "正在以Speed模式优化用户软件"
for item in `pm list packages -3`
do
app=${item:8}
echo "正在优化 -> $app"
cmd package compile -m speed $app
echo "应用优化完成"
let appnumber=appnumber+1
percentage=$((appnumber*100/apptotalnumber))
echo "已完成 $percentage% $appnumber / $apptotalnumber"
done
else
if [ $choose_dex2oat == 2 ] ;then
# 用户应用
apptotalnumber="`grep -o "package:" $workfile/packagelist/packagelist.log | wc -l`"
appnumber=0
echo "正在以Everything模式优化用户软件"
for item in `pm list packages -3`
do
app=${item:8}
echo "正在优化 -> $app"
cmd package compile -m everything $app
echo "应用优化完成"
let appnumber=appnumber+1
percentage=$((appnumber*100/apptotalnumber))
echo "已完成 $percentage% $appnumber / $apptotalnumber"
done
fi
fi
else
mkdir -p $workfile/packagelist
touch $workfile/packagelist/packagelist.log
echo "`pm list packages -3`" > $workfile/packagelist/packagelist.log
if [ $choose_dex2oat == 3 ] ; then
echo "- 不进行Dex2oat"
exit
fi
if [ $choose_dex2oat == 1 ] ; then
# 用户应用
apptotalnumber="`grep -o "package:" $workfile/packagelist/packagelist.log | wc -l`"
appnumber=0
echo "正在以Speed模式优化用户软件"
for item in `pm list packages -3`
do
app=${item:8}
echo "正在优化 -> $app"
cmd package compile -m speed $app
echo "应用优化完成"
let appnumber=appnumber+1
percentage=$((appnumber*100/apptotalnumber))
echo "已完成 $percentage% $appnumber / $apptotalnumber"
done
else
if [ $choose_dex2oat == 2 ] ;then
# 用户应用
apptotalnumber="`grep -o "package:" $workfile/packagelist/packagelist.log | wc -l`"
appnumber=0
echo "正在以Everything模式优化用户软件"
for item in `pm list packages -3`
do
app=${item:8}
echo "正在优化 -> $app"
cmd package compile -m everything $app
echo "应用优化完成"
let appnumber=appnumber+1
percentage=$((appnumber*100/apptotalnumber))
echo "已完成 $percentage% $appnumber / $apptotalnumber"
done
fi
fi
fi
echo "- 完成!"