-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.bat
2310 lines (2111 loc) · 94.9 KB
/
main.bat
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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@echo off
set arg=%1
set param=%2
title PureSky定制工具 [请勿选中,否则卡住点击鼠标右键或回车或放大缩小窗口]
setlocal enableDelayedExpansion
color 0F
::检查系统架构
if "!PROCESSOR_ARCHITECTURE!" EQU "x86" (
echo.
echo.[%time:~0,8%] 不支持32位系统!
echo.
pause
exit
)
echo.[%time:~0,8%] 系统架构检查通过
echo.[%time:~0,8%] 系统架构检查通过>!diyId!_log.log
::文件自检
if exist bin\checkfile.list (
echo.[%time:~0,8%] 正在检查文件...
echo.[%time:~0,8%] 正在检查文件...>>!diyId!_log.log
for /f %%i in ('type bin\checkfile.list ^|findstr -v "#"') do (
set file=%%i
if exist !file! (
echo.[%time:~0,8%] !file! ... OK
echo.[%time:~0,8%] !file! ... OK >>!diyId!_log.log
) else (
set fileLoss=yes
if exist bin\Windows_NT\x86_64\cecho.exe (
bin\Windows_NT\x86_64\cecho.exe {0C}!file! ... Failed{0F}{\n}
bin\Windows_NT\x86_64\cecho.exe {0C}!file! ... Failed{0F}{\n} >>!diyId!_log.log
bin\Windows_NT\x86_64\cecho.exe {0C}文件丢失: !file!{0F}{\n}
bin\Windows_NT\x86_64\cecho.exe {0C}文件丢失: !file!{0F}{\n} >>!diyId!_log.log
) else (
color 0C
echo.[%time:~0,8%] !file! ...... Failed
echo.[%time:~0,8%] !file! ...... Failed>>!diyId!_log.log
echo.[%time:~0,8%] 文件丢失: !file!
echo.[%time:~0,8%] 文件丢失: !file!>>!diyId!_log.log
)
)
)
if "!fileLoss!" == "yes" (
echo.
echo.[%time:~0,8%] 文件自检不通过,某些文件已经丢失,无法正常运行工具
echo.[%time:~0,8%] 文件自检不通过,某些文件已经丢失,无法正常运行工具>>!diyId!_log.log
echo.
pause
exit
)
) else (
echo.
echo.[%time:~0,8%] 检查文件丢失,请确认工具是否已正常解压
echo.[%time:~0,8%] 检查文件丢失,请确认工具是否已正常解压>>!diyId!_log.log
echo.
pause
exit
)
echo.[%time:~0,8%] 文件自检通过
echo.[%time:~0,8%] 文件自检通过>>!diyId!_log.log
::busybox
if not exist bin\busybox (
echo.[%time:~0,8%] 正在配置Busybox...
echo.[%time:~0,8%] 正在配置Busybox...>>!diyId!_log.log
md bin\busybox
copy bin\Windows_NT\x86_64\busybox.exe bin\busybox\busybox.exe 1>nul 2>nul
for /f %%i in ('bin\busybox\busybox.exe --list ^|findstr -v busybox') do (
echo.[%time:~0,8%] 创建链接:bin\busybox\busybox.exe -^> bin\busybox\%%i.exe
echo.[%time:~0,8%] 创建链接:bin\busybox\busybox.exe -^> bin\busybox\%%i.exe>>!diyId!_log.log
mklink !CD!\bin\busybox\%%i.exe !CD!\bin\busybox\busybox.exe 1>nul 2>nul
)
)
::检查Jre
java -jar bin\apktool\apktool.jar 1>nul 2>nul || (
echo.
echo.[%time:~0,8%] 请先自行安装 java(jre) 环境!
echo.[%time:~0,8%] 请先自行安装 java(jre) 环境!
echo.[%time:~0,8%] 请先自行安装 java(jre) 环境!
echo.[%time:~0,8%] 请先自行安装 java(jre) 环境!>>!diyId!_log.log
echo.
start https://www.java.com/zh-CN/download/
pause
exit
)
echo.[%time:~0,8%] Java检查通过
echo.[%time:~0,8%] Java检查通过>>!diyId!_log.log
::首次打开时弹出
if not exist bin\user.psky (
start bin\更新日志.txt
start bin\文件系统类型一览表(必读).txt
)
::环境变量 - 让命令省去路径
echo.[%time:~0,8%] 设置环境变量...
echo.[%time:~0,8%] 设置环境变量... >>!diyId!_log.log
set PATH=%CD%\bin\busybox;%CD%\bin\Windows_NT\x86_64;%CD%\bin\Windows_NT\x86_64\extra;%PATH%
echo.[%time:~0,8%] 环境变量:
echo.[%time:~0,8%] 环境变量: >>!diyId!_log.log
echo.%PATH% |sed "s/;/\n/g" |sed "s/^/[%time:~0,8%] &/g"
echo.%PATH% |sed "s/;/\n/g" |sed "s/^/[%time:~0,8%] &/g" >>!diyId!_log.log
set RED=call :PRINTRED
set CYAN=call :PRINTCYAN
set GREEN=call :PRINTGREEN
set YELLOW=call :PRINTYELLOW
if "!param!" == "--admin" goto MAIN
if "!arg!" NEQ "--debug" cls
::: 检查盘符剩余空间
set currentDisk=%~d0
!CYAN! 当前路径: !CD!
for /f %%i in ('"wmic LOGICALDISK get freespace,name" ^|findstr !currentDisk! ^|tr -cd 0-9') do (set diskByte=%%i)
for /f %%i in ('echo.!diskByte!/1024/1024/1024 ^|bc') do (set diskGB=%%i)
!CYAN! 当前盘符: !currentDisk! 所剩空间大约为: !diskGB!GB
if "!diskGB!" == "" (
echo.
!RED! 检查磁盘空间出错
echo.
pause
exit
)
if !diskGB! LEQ 15 (
echo.
!RED! 所剩空间不满足制作条件,请清理后再进行
!RED! 所剩空间不满足制作条件,请清理后再进行
!RED! 所剩空间不满足制作条件,请清理后再进行
echo.
pause
exit
)
if !diskGB! LEQ 20 (
!YELLOW! 所剩空间可能不满足制作条件
set /p sureToMake="是否继续?(Y/N)[默认:N]->"
if /i "!sureToMake!" NEQ "y" exit
) else (
!GREEN! 盘符所剩空间满足制作条件
)
::: 测试服务器连接
!CYAN! 正在连接服务器...
curl -sS "https://jk.511i.cn" 1>nul 2>nul
if not errorlevel 0 (
echo.
!RED! 无法连接到"PureSky"服务器,请检查你的网络连接
!RED! 无法连接到"PureSky"服务器,请检查你的网络连接
!RED! 无法连接到"PureSky"服务器,请检查你的网络连接
echo.
pause
exit
) else (
!GREEN! 成功连接服务器
)
::: 检查更新
set toolLocalVersion=V230511Fix
title PureSky定制工具-!toolLocalVersion! [请勿选中,否则卡住点击鼠标右键或回车或放大缩小窗口]
!YELLOW! 正在获取版本信息
for /f %%i in ('curl -skS "xxxx" 2^>nul ^|awk NR^=^=1') do (set toolLatestVersion=%%i)
for /f %%i in ('curl -skS "xxxx" 2^>nul ^|awk NR^=^=2') do (set toolLink=%%i)
!CYAN! 本地版本[!toolLocalVersion!]
!CYAN! 云端版本[!toolLatestVersion!]
if not errorlevel 0 (
echo.
!RED!获取版本信息失败
echo.
!YELLOW! 请更换网络后重试
echo.
pause
exit
)
if "!toolLocalVersion!" NEQ "!toolLatestVersion!" (
!YELLOW! 请下载新版工具:!toolLatestVersion!
!YELLOW! 新版工具链接:!toolLink!
!YELLOW! 链接提取码:g1an
start !toolLink!
pause
exit
) else (
!GREEN! 工具为最新版:!toolLocalVersion!
)
::初始化完成
!YELLOW! ^=^=^=^=^=^=^=^=^=^=^=
!GREEN! 初始化完成
!YELLOW! ^=^=^=^=^=^=^=^=^=^=^=
sleep 1
::: 提示信息
if "!arg!" NEQ "--debug" cls
echo.[%time:~0,8%] ROM制作要求:
!YELLOW! ①制作过程请保持网络连接
!YELLOW! ②制作过程请关闭所有杀毒软件、管家、卫士等
!YELLOW! ③请不要点击窗口(标题最前面不要有"选择"二字),否则请看标题
!GREEN! 官网 https://jk.511i.cn
cecho [%time:~0,8%] {0A}注册 http://jk.511i.cn/?index=register{0F}{\n}
cecho [%time:~0,8%] {0A}卡密购买 http://www.kami.vip/purchasing?link=FTo333{0F}{\n}
echo.
!CYAN! 阅读完要求后按任意键开始
pause >nul
::: 检查登录
:OnLogin
if "!arg!" NEQ "--debug" cls
set myUsername=
set myPassword=
!CYAN! 正在检查登录信息
if exist bin\user.psky (
for /f %%i in ('cat bin/user.psky ^|awk NR^=^=1 ^|base32 -d ^|sed "s/ //g"') do (set myUsername=%%i)
for /f %%i in ('cat bin/user.psky ^|awk NR^=^=2 ^|base32 -d ^|sed "s/ //g"') do (set myPassword=%%i)
!YELLOW! 尝试以本地信息登录[!myUsername!]
for /f %%i in ('curl -skS "xxxx"') do (set loginState=%%i)
if "!loginState!" == "login_successfully" (
echo.!myUsername! |base32 >bin\user.psky
echo.!myPassword! |base32 >>bin\user.psky
!GREEN! 登录成功:!myUsername!
sleep 1
goto MAIN
) else (
del bin\user.psky 1>nul 2>nul
echo.
curl -skS "xxxx"
sleep 1
goto OnLogin
)
) else (
!YELLOW! 本地未保存信息,请登录
set /p myUsername="[%time:~0,8%] 请输入你的账号:"
set /p myPassword="[%time:~0,8%] 请输入你的密码:"
for /f %%i in ('curl -skS "xxxx"') do (set loginState=%%i)
if "!loginState!" == "login_successfully" (
echo.!myUsername! |base32 >bin\user.psky
echo.!myPassword! |base32 >>bin\user.psky
!CYAN! 登录成功:!myUsername!
sleep 1
goto MAIN
) else (
del bin\user.psky 1>nul 2>nul
echo.
curl -skS "xxxx"
sleep 1
goto OnLogin
)
)
::开始
:MAIN
if "!arg!" NEQ "--debug" cls
set myDiyId=
!CYAN! 当前路径:!CD!
!CYAN! 当前用户:!myUsername!
set /p myDiyId="[%time:~0,8%] 请输入你处于排队中的定制号:"
::测试用
for /f %%i in ('echo.!myDiyId! ^|findstr http') do (set tmpLink=%%i)
if "!tmpLink!" neq "" (
echo.DIY_ID=test>bin\diy.psky
set diyId=test
echo.!myDiyId!>>bin\diy.psky
echo.{common}>>bin\diy.psky
goto ANALYSE
)
if "!myDiyId!" == "" goto MAIN
::从官网获取参数
!YELLOW! 正在解析机型和ROM信息...
curl -skS "xxxx" >bin\diy.psky
if not errorlevel 0 (
!RED! 服务器连接失败,将在3秒后重试
sleep 3
goto MAIN
)
for /f "tokens=2 delims==" %%i in ('type bin\diy.psky ^|findstr DIY_ID') do (set diyId=%%i)
if "!diyId!" == "" (
echo.
curl -skS "xxxx" |iconv -f utf8 -t gbk |sed "s/^/[%time:~0,8%] &/g"
echo.
echo.
!RED! 返回信息有误,将在3秒后重试
sleep 3
goto MAIN
)
::分析出ROM机型参数
:ANALYSE
if exist !diyId!_log.log del !diyId!_log.log 1>nul 2>nul
if exist _log.log move _log.log !diyId!_log.log 1>nul 2>nul
for /f %%i in ('type bin\diy.psky ^|findstr http ^|findstr zip') do (set romLink=%%i)
for /f %%i in ('basename !romLink!') do (set romName=%%i)
for /f %%i in ('echo.!romName! ^|cut -d "_" -f 2 ^|sed "s/PRE//"') do (set deviceCode=%%i)
for /f "tokens=3 delims=_" %%i in ('echo.!romName!') do (set romVersion=%%i)
for /f "tokens=4 delims=_" %%i in ('echo.!romName!') do (set romHash=%%i)
for /f %%i in ('echo.!romName! ^|cut -d "_" -f 5 ^|cut -d "." -f 1') do (set androidVersion=%%i)
for /f "tokens=2 delims=_" %%i in ('type bin\puresky\device_info.txt ^|findstr "!deviceCode!_"') do (set deviceName=%%i)
for /f "tokens=3 delims=_" %%i in ('type bin\puresky\device_info.txt ^|findstr "!deviceCode!_"') do (set devicePlatform=%%i)
for /f "tokens=4 delims=_" %%i in ('type bin\puresky\device_info.txt ^|findstr "!deviceCode!_"') do (set deviceArch=%%i)
for /f "tokens=5 delims=_" %%i in ('type bin\puresky\device_info.txt ^|findstr "!deviceCode!_"') do (set flashType=%%i)
if "!deviceName!" == "" set deviceName=!deviceCode!
!GREEN! 机型代号: !deviceCode!
!GREEN! 机型名称: !deviceName!
!GREEN! 分区类型: !deviceArch!
!GREEN! 刷机方式: !flashType!
!GREEN! CPU 厂商: !devicePlatform!
!GREEN! ROM 版本: !romVersion!
!GREEN! 安卓版本: !androidVersion!
!GREEN! 哈希片段: !romHash!
!CYAN! 正在清理文件...
call :CLEANUP
::提交已抓取进度
call :SUBMITPROGRESS 1 抓取
if exist input\!romName! (
!CYAN! 本地存在目标ROM包,正在复制...
cp -rf input/!romName! tmp/
goto EXTRACT
)
::下载ROM
!YELLOW! 本地不存在目标ROM包,将下载ROM包
set dsum=0
call :SUBMITPROGRESS 13 下载
:DOWNLOAD
set /a dsum+=1
call :WRITELOG 下载次数:!dsum!
if "!dsum!" == "1" (!CYAN! 开始下载 !romName!)
!YELLOW! [进度] [- - - - - - - - - - - - - - - - - - - - - - - - --] [ 下载速度 ] [剩余时间]
axel -n 8 -a https://bigota.d.miui.com/!romVersion!/!romName! -o tmp
!CYAN! 正在验证MD5值...
for /f %%i in ('md5sum tmp/!romName! 2^>nul ^|head -c 10') do (set localHash=%%i)
!CYAN! 经检验片段为: !localHash!
if "!localHash!" NEQ "!romHash!" (
!RED! 下载时出现错误,重新下载
goto DOWNLOAD
)
!GREEN! ROM下载完毕
:EXTRACT
!YELLOW! 开始提取文件
call :SUBMITPROGRESS 23 提取
!CYAN! 正在解压ROM包
7z x -y tmp\!romName! -otmp 1>nul 2>nul
set /p delRom="[%time:~0,8%] 是否删除原包?(Y/N)[默认:N]->"
::set delRom=y
if /i "!delRom!" == "y" (
!YELLOW! 删除了原包:!romName!
del tmp\!romName!
) else (
!CYAN! 保留了原包
if not exist input md input
if exist input\!romName! del input\!romName!
move tmp\!romName! input\!romName! 1>nul 2>nul
)
if not exist tmp\payload.bin if not exist tmp\*system* (
echo.
!RED! ROM不符合规范,切勿蒙混过关
echo.
pause
exit
)
call :SUBMITPROGRESS 35 分解
REM 获取super列表以及排除列表
for /f "tokens=2 delims==" %%i in ('type bin\configure.txt ^|findstr super_list') do (set superList=%%i)
for /f "tokens=2 delims==" %%i in ('type bin\configure.txt ^|findstr deny_list') do (set denyList=%%i)
:: payload.bin 或 brotli 全都处理成 xxx.img,在 tmp 下第一级目录
if exist tmp\payload.bin (
!YELLOW! 发现 paylod.bin
move tmp\payload.bin payload.bin 1>nul 2>nul
rd /s /q tmp
md tmp
move payload.bin tmp\payload.bin 1>nul 2>nul
!CYAN! 正在分解 payload.bin
payload-dumper-go -o tmp/images tmp/payload.bin 1>nul 2>nul
if exist tmp\images\boot.img (
!YELLOW! 发现 boot.img
move tmp\images\boot.img tmp\boot.img 1>nul 2>nul
)
if exist tmp\images\init_boot.img (
!YELLOW! 发现 init_boot.img
move tmp\images\init_boot.img tmp\init_boot.img 1>nul 2>nul
)
for %%i in (!superList!) do (
set pname=%%i
if exist tmp\images\!pname!.img (
!GREEN! Super 子分区:!pname!_a
call :WRITELOG logical_partition:!pname!_a detected
move tmp\images\!pname!.img tmp\!pname!.img 1>nul 2>nul
)
)
!GREEN! 分解完毕:payload.bin
if "!deviceArch!" == "" set deviceArch=VAB
del tmp\payload.bin 1>nul 2>nul
) else (
if "!deviceArch!" == "" if exist tmp\dynamic_partitions_op_list set deviceArch=AonlyDynamic
if "!deviceArch!" == "" if not exist tmp\dynamic_partitions_op_list set deviceArch=AonlyStatic
for %%i in (!superList!) do (
set pname=%%i
if exist tmp\!pname!.new.dat.br (
!CYAN! 正在解压 !pname!.new.dat.br...
brotli -d tmp/!pname!.new.dat.br -o tmp/!pname!.new.dat 1>nul 2>nul
!CYAN! 正在分解 !pname!.new.dat...
sdat2img tmp/!pname!.transfer.list tmp/!pname!.new.dat tmp/!pname!.img 1>nul 2>nul
del tmp\!pname!.transfer.list 1>nul 2>nul
del tmp\!pname!.new.dat.br 1>nul 2>nul
del tmp\!pname!.patch.dat 1>nul 2>nul
del tmp\!pname!.new.dat 1>nul 2>nul
if "!flashType!" == "TwoInOne" if "!deviceArch!" == "AonlyDynamic" call :WRITELOG logical_partition:!pname! detected
)
)
)
REM 提取镜像
md tmp\config
md tmp\output
REM 跳过排除列表
for %%i in (!denyList!) do (
set pname=%%i
if exist tmp\%%i.img (
!YELLOW! 分区[!pname!]在排除列表
move tmp\!pname!.img tmp\output\!pname!.img 1>nul 2>nul
)
)
REM 分解镜像
!CYAN! 开始提取镜像
for %%i in (!superList!) do (
set pname=%%i
if exist tmp\!pname!.img (
call :EXTRACTIMG tmp/!pname!.img
)
)
:CHECKNET_FIRST
curl -sS "https://jk.511i.cn" 1>nul 2>nul
if not errorlevel 0 (
!RED! 请检查你的网络连接,请勿断网操作
!YELLOW! 按任意键继续
pause>nul
goto CHECKNET_FIRST
) else (
!GREEN! 网络检验通过
)
:: 开始修改ROM
!YELLOW! 开始修改ROM
call :SUBMITPROGRESS 42 修改
for /f "tokens=2 delims==" %%i in ('type bin\configure.txt ^|findstr default_magisk') do (set defaultMagisk=%%i)
if "!defaultMagisk!" == "" set defaultMagisk=26100
::: 补全上下文
rm -rf config
cat bin/file_config/product_file_contexts_add.txt >>tmp/config/product_file_contexts
cat bin/file_config/product_fs_config_add.txt >>tmp/config/product_fs_config
cat bin/file_config/system_file_contexts_add.txt >>tmp/config/system_file_contexts
cat bin/file_config/system_fs_config_add.txt >>tmp/config/system_fs_config
cat bin/file_config/vendor_file_contexts_add.txt >>tmp/config/vendor_file_contexts
cat bin/file_config/vendor_fs_config_add.txt >>tmp/config/vendor_fs_config
::: 去除杂质
bash bin/puresky/rmc |sed "s/^/[%time:~0,8%] &/g"
rm -rf tmp/system/verity_key
rm -rf tmp/vendor/verity_key
rm -rf tmp/product/verity_key
rm -rf tmp/system/recovery-from-boot.p
rm -rf tmp/vendor/recovery-from-boot.p
rm -rf tmp/product/recovery-from-boot.p
rm -rf tmp/product/media/theme/miui_mod_icons/com.google.android.apps.nbu
rm -rf tmp/product/media/theme/miui_mod_icons/com.google.android.apps.nbu.
rd /s /q \\?\!CD!\tmp\product\media\theme\miui_mod_icons\com.google.android.apps.nbu. 1>nul 2>nul
del /s /q \\?\!CD!\tmp\product\media\theme\miui_mod_icons\com.google.android.apps.nbu. 1>nul 2>nul
rm -rf tmp/product/media/theme/miui_mod_icons/dynamic/com.google.android.apps.nbu
rm -rf tmp/product/media/theme/miui_mod_icons/dynamic/com.google.android.apps.nbu.
rd /s /q \\?\!CD!\tmp\product\media\theme\miui_mod_icons\dynamic\com.google.android.apps.nbu. 1>nul 2>nul
del /s /q \\?\!CD!\tmp\product\media\theme\miui_mod_icons\dynamic\com.google.android.apps.nbu. 1>nul 2>nul
rm -rf tmp/system/system/media/theme/miui_mod_icons/com.google.android.apps.nbu
rm -rf tmp/system/system/media/theme/miui_mod_icons/com.google.android.apps.nbu.
rd /s /q \\?\!CD!\tmp\system\system\media\theme\miui_mod_icons\com.google.android.apps.nbu. 1>nul 2>nul
del /s /q \\?\!CD!\tmp\system\system\media\theme\miui_mod_icons\com.google.android.apps.nbu. 1>nul 2>nul
rm -rf tmp/system/system/media/theme/miui_mod_icons/dynamic/com.google.android.apps.nbu
rm -rf tmp/system/system/media/theme/miui_mod_icons/dynamic/com.google.android.apps.nbu.
rd /s /q \\?\!CD!\tmp\system\system\media\theme\miui_mod_icons\dynamic\com.google.android.apps.nbu. 1>nul 2>nul
del /s /q \\?\!CD!\tmp\system\system\media\theme\miui_mod_icons\dynamic\com.google.android.apps.nbu. 1>nul 2>nul
for /f %%j in ('busybox find tmp/ -maxdepth 2 -type f -name "vbmeta*.img"') do (
set vbtarget=%%j
if "!vbtarget!" NEQ "" (
!YELLOW! Target vbmeta: !vbtarget!
vbmeta-disable-verification !vbtarget! |sed "s/^/[%time:~0,8%] &/g"
)
)
if exist tmp\product\pangu (
!CYAN! 正在修复NFC
bash bin/puresky/fixnfc.sh
rm -rf system_fs_config_pangu
rm -rf system_file_contexts_pangu
)
call :SUBMITPROGRESS 48 修改
for /f %%i in ('type bin\diy.psky ^|findstr common') do (set mode=%%i)
for /f "tokens=*" %%j in ('busybox find tmp/ -type f ^|findstr fstab ^|findstr /v "enableswap _"') do (
set fstabfile=%%j
sed -i "/overlay/d" !fstabfile!
)
REM 修改
if "!mode!" == "{common}" (
!YELLOW! 以常规官改包方案进行修改
if exist tmp\product\media\theme\default cp -rf bin/puresky/com.android.settings tmp/product/media/theme/default/com.android.settings
if exist tmp\system\system\media\theme\default cp -rf bin/puresky/com.android.settings tmp/system/system/media/theme/default/com.android.settings
rm -rf tmp/product/etc/auto-install*
rm -rf tmp/system/system/etc/auto-install*
!CYAN! 正在添加 Magisk-ROOT,版本:!defaultMagisk!
7z x -y bin/Magisk/Magisk!defaultMagisk!.apk -otmp/magisk 1>nul 2>nul
for /f %%i in ('dir /b /s tmp\magisk ^|findstr arm ^|findstr magisk32') do (set magisk32File=%%i)
for /f %%i in ('dir /b /s tmp\magisk ^|findstr arm ^|findstr magisk64') do (set magisk64File=%%i)
for /f %%i in ('dir /b /s tmp\magisk ^|findstr arm64 ^|findstr magiskinit') do (set magiskInitFile=%%i)
if "!magiskInitFile!" equ "" for /f %%i in ('dir /b /s tmp\magisk ^|findstr arm ^|findstr magiskinit') do (set magiskInitFile=%%i)
echo.[%time:~0,8%] magisk32 文件:!magisk32File!
echo.[%time:~0,8%] magisk64 文件:!magisk64File!
echo.[%time:~0,8%] magiskinit 文件:!magiskInitFile!
move tmp\magisk\assets\util_functions.sh !CD!\util_functions.sh 1>nul 2>nul
move !magisk32File! !CD!\magisk32 1>nul 2>nul
move !magisk64File! !CD!\magisk64 1>nul 2>nul
move !magiskInitFile! !CD!\magiskinit 1>nul 2>nul
if exist tmp\magisk\assets\stub.apk move tmp\magisk\assets\stub.apk !CD!\stub.apk 1>nul 2>nul
bash bin/puresky/boot_patch.sh tmp/boot.img
move new-boot.img tmp\output\boot_magisk.img 1>nul 2>nul
move tmp\boot.img tmp\output\boot_official.img 1>nul 2>nul
7z x -y bin\ramdisk\ramdisk.zip !androidVersion!-!deviceCode!-ramdisk.cpio -otmp 1>nul 2>nul
if exist tmp\!androidVersion!-!deviceCode!-ramdisk.cpio (
!CYAN! 正在合并TWRP
magiskboot unpack tmp/output/boot_official.img 1>nul 2>nul
cp -rf tmp/!androidVersion!-!deviceCode!-ramdisk.cpio ramdisk.cpio
rm tmp/!androidVersion!-!deviceCode!-ramdisk.cpio
magiskboot repack tmp/output/boot_official.img 1>nul 2>nul
mv new-boot.img twrp.img
bash bin/puresky/boot_patch.sh twrp.img
rm twrp.img
mv new-boot.img tmp/output/boot_twrp.img
)
if exist tmp\init_boot.img (
!YELLOW! 给 init_boot.img 打补丁
bash bin/puresky/boot_patch.sh tmp/init_boot.img
move new-boot.img tmp\output\init_boot_magisk.img 1>nul 2>nul
move tmp\init_boot.img tmp\output\init_boot_official.img 1>nul 2>nul
)
rm -rf tmp/magisk
rm -rf magisk32 magisk64 magiskinit stub.apk util_functions.sh
!CYAN! 正在去除Data加密
for /f %%i in ('busybox find tmp/ -type f ^|findstr fstab ^|findstr /v "enableswap _"') do (
set fstabfile=%%i
!YELLOW! 分区表目标文件:!fstabfile!
sed -i "s/ro,/ro,noatime,/g" !fstabfile!
sed -i "s/,avb_keys=\/avb\/q-gsi.avbpubkey:\/avb\/r-gsi.avbpubkey:\/avb\/s-gsi.avbpubkey:\/avb\/t-gsi.avbpubkey//g" !fstabfile!
sed -i "s/,avb=vbmeta_system//g" !fstabfile!
sed -i "s/,avb=vbmeta_vendor//g" !fstabfile!
sed -i "s/,avb=vbmeta//g" !fstabfile!
sed -i "s/,avb//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized+wrappedkey_v0//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:aes-256-cts:v2+emmc_optimized+wrappedkey_v0//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:aes-256-cts:v2//g" !fstabfile!
sed -i "s/,metadata_encryption=aes-256-xts:wrappedkey_v0//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:wrappedkey_v0//g" !fstabfile!
sed -i "s/,metadata_encryption=aes-256-xts//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts//g" !fstabfile!
sed -i "s/,fileencryption=ice//g" !fstabfile!
sed -i "s/fileencryption/encryptable/g" !fstabfile!
)
!CYAN! 正在修改全局高刷
bash bin/puresky/mkpk |sed "s/^/[%time:~0,8%] &/g"
!CYAN! 正在修改网速秒刷
bash bin/puresky/mkui 0x3e8 |sed "s/^/[%time:~0,8%] &/g"
!CYAN! 正在添加主题破解
::bash bin/puresky/thememanager
for /f %%i in ('busybox find tmp/ -type f -name "*ThemeManager*.apk"') do (set themeApk=%%i)
!YELLOW! ThemeManager: !themeApk!
if "!androidVersion!" == "13" (
cp -rf bin/apks/MIUIThemeManager_T.apk !themeApk!
) else (
cp -rf bin/apks/MIUIThemeManagre.apk !themeApk!
)
for /f %%j in ('busybox find tmp/ -type f -name init.miui.rc') do (set MiuiInitRC=%%j)
for /f %%j in ('busybox find tmp/ -type f -name init.rc') do (set initRc=%%j)
if "!MiuiInitRC!" neq "" (
sed -i "/on boot/a\ chmod 0731 \/data\/system\/theme" !MiuiInitRC!
)
if "!MiuiInitRC!" equ "" if "!initRc!" neq "" (
sed -i "/on boot/a\ chmod 0731 \/data\/system\/theme" !initRc!
)
cp -rf bin/puresky/busybox tmp/system/system/bin/busybox
for /f %%j in ('type bin\diy.psky ^|findstr erofs2ext4') do (set erofs2ext4=%%j)
if "!erofs2ext4!" == "{erofs2ext4}" (
!CYAN! EROFS文件系统转EXT4
if exist !diyId!_log.log sed -i "s/erofs/ext4/g" !diyId!_log.log
for /f "tokens=*" %%j in ('busybox find tmp/ -type f ^|findstr fstab ^|findstr /v "enableswap _"') do (
set fstabfile=%%j
sed -i "/overlay/d" !fstabfile!
)
)
for /f %%j in ('type bin\diy.psky ^|findstr ext42erofs') do (set ext42erofs=%%j)
if "!ext42erofs!" == "{ext42erofs}" (
!CYAN! EXT4文件系统转EROFS
if exist !diyId!_log.log sed -i "s/ext4/erofs/g" !diyId!_log.log
)
!CYAN! 添加DC调光按钮
for /f %%j in ('busybox find tmp/ -type d ^|findstr device_features ^| awk NR^=^=1') do (set deviceFeature=%%j)
sed -i "s/<bool name=\"dc_backlight_fps_incompatible\">true<\/bool>/<bool name=\"dc_backlight_fps_incompatible\">false<\/bool>/" !deviceFeature!/*.xml
sed -i "s/<bool name=\"support_dc_backlight\">false<\/bool>/<bool name=\"support_dc_backlight\">true<\/bool>/" !deviceFeature!/*.xml
sed -i "s/<bool name=\"support_secret_dc_backlight\">true<\/bool>/<bool name=\"support_secret_dc_backlight\">false<\/bool>/" !deviceFeature!/*.xml
!CYAN! 添加90Hz刷新率按钮(如果支持120)
sed -i "/<item>120<\/item>/a\\t\t<item>90<\/item>" !deviceFeature!/*.xml
for /f %%i in ('echo.!deviceCode! ^|findstr "PHOENIX PICASSO"') do (set K30Device=%%i)
if "!K30Device!" NEQ "" (
if "!androidVersion!" GTR "11" (
!CYAN! 添加添加K30猪鼻孔
for /f %%i in ('busybox find tmp/ -type f -name DevicesOverlay.apk') do (
set DevicesOverlay=%%i
if "!DevicesOverlay!" NEQ "" (
echo. 目标文件:!DevicesOverlay!
cp -r bin/apks/DevicesOverlay.apk !DevicesOverlay!
)
)
)
)
if "!androidVersion!" LSS "13" (
for /f %%i in ('busybox find tmp/ -type f -name "M*PackageInstaller.apk"') do (
set ApkInstaller=%%i
if "!ApkInstaller!" NEQ "" (
!CYAN! 添加旧版应用安装器
echo. 目标文件:!ApkInstaller!
cp -rf bin/apks/MiuiPackageInstaller.apk !ApkInstaller!
) else (
!YELLOW! 找不到安装器位置
)
)
) else (
for /f %%i in ('busybox find tmp/ -type f -name "M*PackageInstaller.apk"') do (
set ApkInstaller=%%i
if "!ApkInstaller!" NEQ "" (
cp -rf bin/apks/MiuiPackageInstaller_T.apk !ApkInstaller!
) else (
!YELLOW! 找不到安装器位置
)
)
)
call :SUBMITPROGRESS 53 修改
!CYAN! 正在修改优化马达效果
sed -i "s/sys.haptic.down.weak=.*/sys.haptic.down.weak=0/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.down.normal=.*/sys.haptic.down.normal=2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.down.strong=.*/sys.haptic.down.strong=5/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.down=.*/sys.haptic.down=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.tap.normal=.*/sys.haptic.tap.normal=0,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.tap.light=.*/sys.haptic.tap.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.flick=.*/sys.haptic.flick=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.flick.light=.*/sys.haptic.flick.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.switch=.*/sys.haptic.switch=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.mesh.heavy=.*/sys.haptic.mesh.heavy=0,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.mesh.normal=.*/sys.haptic.mesh.normal=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.mesh.light=.*/sys.haptic.mesh.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.long.press=.*/sys.haptic.long.press=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.popup.normal=.*/sys.haptic.popup.normal=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.popup.light=.*/sys.haptic.popup.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.pickup=.*/sys.haptic.pickup=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.scroll.edge=.*/sys.haptic.scroll.edge=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.trigger.drawer=.*/sys.haptic.trigger.drawer=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.hold=.*/sys.haptic.hold=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.runin=.*/sys.haptic.runin=13/g" tmp/vendor/build.prop
!CYAN! 添加性能模式开关
sed -i "$a\persist.sys.power.default.powermode=1" tmp/system/system/build.prop
!CYAN! 默认usb调试
sed -i "$a\persist.adb.notify=0" tmp/system/system/build.prop
sed -i "$a\persist.sys.usb.config=mtp,adb" tmp/system/system/build.prop
!YELLOW! 此ROM包为安卓!androidVersion!
if "!androidVersion!" LSS "13" (
!CYAN! 正在精简应用
rm -rf tmp/vendor/data-app/*
rm -rf tmp/product/data-app/*
rm -rf tmp/system/system/app/MSA
rm -rf tmp/system/system/app/mab
rm -rf tmp/system/system/priv-app/MSA
rm -rf tmp/system/system/priv-app/mab
rm -rf tmp/system/system/app/Updater
rm -rf tmp/system/system/app/MiuiUpdater
rm -rf tmp/system/system/priv-app/Updater
rm -rf tmp/system/system/priv-app/MiuiUpdater
rm -rf tmp/system/system/app/MiService
rm -rf tmp/system/system/app/MIService
rm -rf tmp/system/system/priv-app/MiService
rm -rf tmp/system/system/priv-app/MIService
rm -rf tmp/system/system/app/*Hybrid*
rm -rf tmp/system/system/app/AnalyticsCore/*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/01*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/02*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/03*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/04*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/05*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/06*
busybox mkdir tmp/APK
mv tmp/system/system/data-app/*Weather* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*Media* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*SoundRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*ScreenRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*Calculator* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*GoogleContact* tmp/APK/ 1>nul 2>nul
rm -rf tmp/system/system/data-app/*
cp -rf tmp/APK/* tmp/system/system/data-app
rm -rf tmp/APK
if exist tmp\system\system\app\AnalyticsCore cp bin/apks/AnalyticsCore.apk tmp/system/system/app/AnalyticsCore/AnalyticsCore.apk
) else (
!CYAN! 正在精简应用
rm -rf tmp/product/app/MSA
rm -rf tmp/product/app/mab
rm -rf tmp/system/system/app/MSA
rm -rf tmp/system/system/app/mab
rm -rf tmp/product/priv-app/MSA
rm -rf tmp/system/system/priv-app/MSA
rm -rf tmp/product/app/Updater
rm -rf tmp/product/app/MiuiUpdater
rm -rf tmp/product/priv-app/Updater
rm -rf tmp/product/priv-app/MiuiUpdater
rm -rf tmp/product/app/MiService
rm -rf tmp/product/app/MIService
rm -rf tmp/product/priv-app/MiService
rm -rf tmp/product/priv-app/MIService
rm -rf tmp/product/app/*Hybrid*
rm -rf tmp/product/etc/auto-install*
rm -rf tmp/product/app/AnalyticsCore/*
rm -rf tmp/product/media/wallpaper/wallpaper_group/01*
rm -rf tmp/product/media/wallpaper/wallpaper_group/02*
rm -rf tmp/product/media/wallpaper/wallpaper_group/03*
rm -rf tmp/product/media/wallpaper/wallpaper_group/04*
rm -rf tmp/product/media/wallpaper/wallpaper_group/05*
rm -rf tmp/product/media/wallpaper/wallpaper_group/06*
busybox mkdir tmp/APK
mv tmp/product/data-app/*Weather* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*DeskClock* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*Gallery tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*SoundRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*ScreenRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*Calculator* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*Calendar tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*Media* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*GoogleContact* tmp/APK/ 1>nul 2>nul
rm -rf tmp/product/data-app/*
cp -rf tmp/APK/* tmp/product/data-app
rm -rf tmp/APK
if exist tmp\product\app\AnalyticsCore cp bin/apks/AnalyticsCore.apk tmp/product/app/AnalyticsCore/AnalyticsCore.apk
if exist tmp\system\system\app\AnalyticsCore cp bin/apks/AnalyticsCore.apk tmp/system/system/app/AnalyticsCore/AnalyticsCore.apk
)
if exist tmp\system\system\data-app (
md tmp\system\system\data-app\Magisk
cp -rf bin/Magisk/Magisk!defaultMagisk!.apk tmp/system/system/data-app/Magisk/Magisk.apk
) else (
md tmp\product\data-app\Magisk
cp -rf bin/Magisk/Magisk!defaultMagisk!.apk tmp/product/data-app/Magisk/Magisk.apk
)
) else (
!YELLOW! 以定制方案修改ROM
!YELLOW! 此ROM包为安卓!androidVersion!
if "!androidVersion!" LSS "13" (
!CYAN! 正在精简应用
rm -rf tmp/vendor/data-app/*
rm -rf tmp/product/data-app/*
rm -rf tmp/system/system/app/MSA
rm -rf tmp/system/system/app/mab
rm -rf tmp/system/system/priv-app/MSA
rm -rf tmp/system/system/priv-app/mab
rm -rf tmp/system/system/app/Updater
rm -rf tmp/system/system/app/MiuiUpdater
rm -rf tmp/system/system/priv-app/Updater
rm -rf tmp/system/system/priv-app/MiuiUpdater
rm -rf tmp/system/system/app/*Hybrid*
rm -rf tmp/system/system/app/AnalyticsCore/*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/01*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/02*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/03*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/04*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/05*
rm -rf tmp/system/system/media/wallpaper/wallpaper_group/06*
busybox mkdir tmp/APK
mv tmp/system/system/data-app/*Weather* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*Media* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*SoundRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*ScreenRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*Calculator* tmp/APK/ 1>nul 2>nul
mv tmp/system/system/data-app/*GoogleContact* tmp/APK/ 1>nul 2>nul
rm -rf tmp/system/system/data-app/*
cp -rf tmp/APK/* tmp/system/system/data-app
rm -rf tmp/APK
if exist tmp\system\system\app\AnalyticsCore cp bin/apks/AnalyticsCore.apk tmp/system/system/app/AnalyticsCore/AnalyticsCore.apk
) else (
!CYAN! 正在精简应用
rm -rf tmp/product/app/MSA
rm -rf tmp/product/app/mab
rm -rf tmp/system/system/app/MSA
rm -rf tmp/system/system/app/mab
rm -rf tmp/product/priv-app/MSA
rm -rf tmp/system/system/priv-app/MSA
rm -rf tmp/product/app/Updater
rm -rf tmp/product/app/MiuiUpdater
rm -rf tmp/product/priv-app/Updater
rm -rf tmp/product/priv-app/MiuiUpdater
rm -rf tmp/product/app/*Hybrid*
rm -rf tmp/product/etc/auto-install*
rm -rf tmp/product/app/AnalyticsCore/*
rm -rf tmp/product/media/wallpaper/wallpaper_group/01*
rm -rf tmp/product/media/wallpaper/wallpaper_group/02*
rm -rf tmp/product/media/wallpaper/wallpaper_group/03*
rm -rf tmp/product/media/wallpaper/wallpaper_group/04*
rm -rf tmp/product/media/wallpaper/wallpaper_group/05*
rm -rf tmp/product/media/wallpaper/wallpaper_group/06*
busybox mkdir tmp/APK
mv tmp/product/data-app/*Weather* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*Media* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*SoundRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*ScreenRecorder* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*Calculator* tmp/APK/ 1>nul 2>nul
mv tmp/product/data-app/*GoogleContact* tmp/APK/ 1>nul 2>nul
rm -rf tmp/product/data-app/*
cp -rf tmp/APK/* tmp/product/data-app
rm -rf tmp/APK
if exist tmp\product\app\AnalyticsCore cp bin/apks/AnalyticsCore.apk tmp/product/app/AnalyticsCore/AnalyticsCore.apk
)
if exist tmp\product\media\theme\default cp -rf bin/puresky/com.android.settings.diy tmp/product/media/theme/default/com.android.settings
if exist tmp\system\system\media\theme\default cp -rf bin/puresky/com.android.settings.diy tmp/system/system/media/theme/default/com.android.settings
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr custom_version_name') do (set mdfName=%%j)
if "!mdfName!" neq "" (
!CYAN! 正在自定义版本名字
7z x -y bin/puresky/diy.settings -otmp/version 1>nul 2>nul
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr custom_version_name ^|cut -d ":" -f 2 ^|cut -d "}" -f 1') do (set myDiyName=%%j)
echo.[%time:~0,8%] !myDiyName! |iconv -f utf8 -t gbk
sed -i "s/versionName/!myDiyName!/g" tmp/version/theme_values.xml
sed -i "s/versionName/!myDiyName!/g" tmp/version/nightmode/theme_values.xml
cd tmp\version\
7z a -tzip com.android.settings ./ 1>nul 2>nul
cd ..\..\
if exist tmp\product\media\theme\default (
cp -rf tmp/version/com.android.settings tmp/product/media/theme/default/com.android.settings 1>nul 2>nul
)
if exist tmp\system\system\media\theme\default (
cp -rf tmp/version/com.android.settings tmp/system/system/media/theme/default/com.android.settings 1>nul 2>nul
)
rm -rf tmp/version
set mdfName=
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr all_data_app') do (set rmAllData=%%j)
if "!rmAllData!" == "{all_data_app}" (
!CYAN! 正在删除所以可卸载预装(data-app)
rm -rf tmp/vendor/data-app/*
rm -rf tmp/product/data-app/*
rm -rf tmp/system/system/data-app/*
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr unlock_theme') do (set unlock_theme=%%j)
if "!unlock_theme!" == "{unlock_theme}" if "!deviceCode!" neq "ELISH" if "!deviceCode!" neq "NABU" if "!deviceCode!" neq "ENUMA" if "!deviceCode!" neq "DAGU" if "!deviceCode!" neq "YUNLUO" (
!CYAN! 正在添加主题破解
for /f "tokens=*" %%j in ('busybox find tmp/ -type f -name "*ThemeManager*.apk"') do (set ThemeManager=%%j)
if "!androidVersion!" LSS "13" (
cp -rf bin/apks/MIUIThemeManager.apk !ThemeManager!
) else (
REM bash bin/puresky/thememanager
cp -rf bin/apks/MIUIThemeManager_T.apk !ThemeManager!
)
for /f "tokens=*" %%j in ('busybox find tmp/ -type f -name init.miui.rc') do (set MiuiInitRC=%%j)
for /f "tokens=*" %%j in ('busybox find tmp/ -type f -name init.rc') do (set initRc=%%j)
if "!MiuiInitRC!" neq "" (
sed -i "/on boot/a\ chmod 0731 \/data\/system\/theme" !MiuiInitRC!
)
if "!MiuiInitRC!" equ "" if "!initRc!" neq "" (
sed -i "/on boot/a\ chmod 0731 \/data\/system\/theme" !initRc!
)
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr remove_data_encrypt') do (set remove_data_encrypt=%%j)
if "!remove_data_encrypt!" == "{remove_data_encrypt}" (
!CYAN! 正在去除Data加密
for /f "tokens=*" %%j in ('busybox find tmp/ -type f ^|findstr fstab ^|findstr /v "enableswap _"') do (
set fstabfile=%%j
echo.[%time:~0,8%] 分区表目标文件:!fstabfile!
sed -i "s/ro,/ro,noatime,/g" !fstabfile!
sed -i "s/,avb_keys=\/avb\/q-gsi.avbpubkey:\/avb\/r-gsi.avbpubkey:\/avb\/s-gsi.avbpubkey:\/avb\/t-gsi.avbpubkey//g" !fstabfile!
sed -i "s/,avb_keys=\/avb\/q-gsi.avbpubkey:\/avb\/r-gsi.avbpubkey:\/avb\/s-gsi.avbpubkey//g" !fstabfile!
sed -i "s/,avb=vbmeta_system//g" !fstabfile!
sed -i "s/,avb=vbmeta_vendor//g" !fstabfile!
sed -i "s/,avb=vbmeta//g" !fstabfile!
sed -i "s/,avb//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized+wrappedkey_v0//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:aes-256-cts:v2+emmc_optimized+wrappedkey_v0//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:aes-256-cts:v2//g" !fstabfile!
sed -i "s/,metadata_encryption=aes-256-xts:wrappedkey_v0//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts:wrappedkey_v0//g" !fstabfile!
sed -i "s/,metadata_encryption=aes-256-xts//g" !fstabfile!
sed -i "s/,fileencryption=aes-256-xts//g" !fstabfile!
sed -i "s/,fileencryption=ice//g" !fstabfile!
sed -i "s/fileencryption/encryptable/g" !fstabfile!
)
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr erofs2ext4') do (set erofs2ext4=%%j)
if "!erofs2ext4!" == "{erofs2ext4}" (
!CYAN! EROFS文件系统转EXT4
if exist !diyId!_log.log sed -i "s/erofs/ext4/g" !diyId!_log.log
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr ext42erofs') do (set ext42erofs=%%j)
if "!ext42erofs!" == "{ext42erofs}" (
!CYAN! EXT4文件系统转EROFS
if exist !diyId!_log.log sed -i "s/ext4/erofs/g" !diyId!_log.log
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr motor') do (set motor=%%j)
if "!motor!" == "{motor}" (
!CYAN! 正在修改优化马达效果
sed -i "s/sys.haptic.down.weak=.*/sys.haptic.down.weak=0/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.down.normal=.*/sys.haptic.down.normal=2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.down.strong=.*/sys.haptic.down.strong=5/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.down=.*/sys.haptic.down=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.tap.normal=.*/sys.haptic.tap.normal=0,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.tap.light=.*/sys.haptic.tap.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.flick=.*/sys.haptic.flick=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.flick.light=.*/sys.haptic.flick.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.switch=.*/sys.haptic.switch=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.mesh.heavy=.*/sys.haptic.mesh.heavy=0,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.mesh.normal=.*/sys.haptic.mesh.normal=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.mesh.light=.*/sys.haptic.mesh.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.long.press=.*/sys.haptic.long.press=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.popup.normal=.*/sys.haptic.popup.normal=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.popup.light=.*/sys.haptic.popup.light=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.pickup=.*/sys.haptic.pickup=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.scroll.edge=.*/sys.haptic.scroll.edge=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.trigger.drawer=.*/sys.haptic.trigger.drawer=3,1/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.hold=.*/sys.haptic.hold=3,2/g" tmp/vendor/build.prop
sed -i "s/sys.haptic.runin=.*/sys.haptic.runin=13/g" tmp/vendor/build.prop
)
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr magisk') do (set addMagisk=%%j)
if "!addMagisk!" neq "" (
for /f "tokens=*" %%j in ('type bin\diy.psky ^|findstr magisk ^|cut -d "k" -f 2 ^|cut -d "}" -f 1') do (set magiskVersion=%%j)
if "!magiskVersion!" == "" set magiskVersion=26100
!CYAN! 添加Magisk-ROOT,版本:!magiskVersion!
7z x -y bin/Magisk/Magisk!magiskVersion!.apk -otmp/magisk 1>nul 2>nul
for /f "tokens=*" %%i in ('dir /b /s tmp\magisk ^|findstr arm ^|findstr magisk32') do (set magisk32File=%%i)
for /f "tokens=*" %%i in ('dir /b /s tmp\magisk ^|findstr arm ^|findstr magisk64') do (set magisk64File=%%i)
for /f "tokens=*" %%i in ('dir /b /s tmp\magisk ^|findstr arm64 ^|findstr magiskinit') do (set magiskInitFile=%%i)
if "!magiskInitFile!" equ "" for /f "tokens=*" %%i in ('dir /b /s tmp\magisk ^|findstr arm ^|findstr magiskinit') do (set magiskInitFile=%%i)
echo.[%time:~0,8%] magisk32 文件:!magisk32File!
echo.[%time:~0,8%] magisk64 文件:!magisk64File!
echo.[%time:~0,8%] magiskinit 文件:!magiskInitFile!
move tmp\magisk\assets\util_functions.sh !CD!\util_functions.sh 1>nul 2>nul
move !magisk32File! !CD!\magisk32 1>nul 2>nul
move !magisk64File! !CD!\magisk64 1>nul 2>nul
move !magiskInitFile! !CD!\magiskinit 1>nul 2>nul
if exist tmp\magisk\assets\stub.apk move tmp\magisk\assets\stub.apk !CD!\stub.apk 1>nul 2>nul
bash bin/puresky/boot_patch.sh tmp/boot.img
move new-boot.img tmp\output\boot_magisk.img 1>nul 2>nul
move tmp\boot.img tmp\output\boot_official.img 1>nul 2>nul
7z x -y bin\ramdisk\ramdisk.zip !androidVersion!-!deviceCode!-ramdisk.cpio -otmp 1>nul 2>nul
if exist tmp\!androidVersion!-!deviceCode!-ramdisk.cpio (
!CYAN! 正在合并TWRP
magiskboot unpack tmp/output/boot_official.img 1>nul 2>nul
cp -rf tmp/!androidVersion!-!deviceCode!-ramdisk.cpio ramdisk.cpio
rm tmp/!androidVersion!-!deviceCode!-ramdisk.cpio