-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathutil_functions.sh
2650 lines (2426 loc) · 72.4 KB
/
util_functions.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
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
#!/system/bin/sh
# MagiskHide Props Config
# Copyright (c) 2018-2021 Didgeridoohan @ XDA Developers
# Licence: MIT
ADBPATH=/data/adb
MHPCPATH=$ADBPATH/mhpc
if [ "$INSTFN" ]; then
LOGFILE=$MHPCPATH/propsconf_install.log
else
LOGFILE=$MHPCPATH/propsconf.log
fi
# Checking Magisk Busybox
if [ -z "$INSTFN" ] && [ "$BOOTSTAGE" != "post" -a "$BOOTSTAGE" != "late" ]; then
BBPATH=$ADBPATH/magisk/busybox
if [ -f "$BBPATH" ]; then
for ITEM in $($BBPATH --list | tail -n +3); do
alias $ITEM="$BBPATH $ITEM"
done
fi
if [ -f "$BBPATH" ]; then
echo "" >> $LOGFILE 2>&1
echo -e "$(date +"%Y-%m-%d %H:%M:%S.%3N") - Using $($BBPATH | head -1)." >> $LOGFILE 2>&1
echo "$BBPATH" >> $LOGFILE 2>&1
else
echo "" >> $LOGFILE 2>&1
echo -e "$(date +"%Y-%m-%d %H:%M:%S.%3N") - No Busybox found." >> $LOGFILE 2>&1
fi
fi
# Finding file values, $1=file (with path), $2=string to look for
get_file_value() {
if [ -f "$1" ]; then
echo $(grep $2 $1) | sed "s|.*${2}||" | sed 's|\"||g'
fi
}
# ======================== Variables ========================
MODULESPATH=$ADBPATH/modules
LATEFILE=$MHPCPATH/propsconf_late
if [ -z $SLOT ]; then
CACHELOC=/cache
else
CACHELOC=/data/cache
fi
if [ "$INSTFN" ]; then
# Installation (config.sh)
MODVERSION=$(echo $(get_file_value $TMPDIR/module.prop "version=") | sed 's|-.*||')
POSTPATH=$ADBPATH/post-fs-data.d
SERVICEPATH=$ADBPATH/service.d
POSTFILE=$POSTPATH/propsconf_post
POSTLATEFILE=$POSTPATH/propsconf_late
UPDATELATEFILE=$MHPCPATH/propsconf_late_update
ORIGLATEFILE=$MODPATH/common/propsconf_late
CACHERM="
$CACHELOC/propsconf_postfile.log
$CACHELOC/propsconf.log
$CACHELOC/propsconf_install.log
$CACHELOC/propsconf_last.log
"
SETTINGSLIST="
FINGERPRINTENB
PRINTMODULE
PRINTEDIT
PRINTVEND
PRINTCHK
BASICATTEST
BASICATTLIST
BASICATTCUST
DEVSIM
PROPCOUNT
PROPEDIT
PROPBOOT
REDEBUGGABLE
RESECURE
RETYPE
RETAGS
REBOOTMODE
REMODE
REVENDORMODE
REHWC
REHWCOUNTRY
RESTATE
REVERIFIEDBOOTSTATE
REVENDORVERIFIEDBOOTSTATE
RELOCKED
REVERITYMODE
REBOOTWARRANTY_BIT
REBIT
REVENDORBOOTWARRANTY_BIT
REVENDORWARRANTY_BIT
REVENDORDEVICE_STATE
CUSTOMEDIT
DELEDIT
PRINTSTAGE
PATCHSTAGE
SIMSTAGE
OPTIONSOFTBOOT
PRINTSOFTBOOT
PATCHSOFTBOOT
SIMSOFTBOOT
CUSTOMSOFTBOOT
PROPSOFTBOOT
OPTIONBOOT
OPTIONCOLOUR
OPTIONWEBP
OPTIONWEBU
OPTIONUPDATE
OPTIONBACK
BRANDSET
NAMESET
DEVICESET
RELEASESET
IDSET
INCREMENTALSET
DESCRIPTIONSET
DISPLAYSET
SDKSET
MANUFACTURERSET
MODELSET
PARTPROPSSET
REBOOTCHK
"
PROPSETTINGSLIST="
MODULEFINGERPRINT
SIMBRAND
SIMNAME
SIMDEVICE
SIMRELEASE
SIMID
SIMINCREMENTAL
SIMDESCRIPTION
SIMDISPLAY
SIMSDK
SIMMANUFACTURER
SIMMODEL
CUSTOMPROPS
CUSTOMPROPSPOST
CUSTOMPROPSLATE
CUSTOMPROPSDELAY
DELETEPROPS
"
else
# Placeholder variables
MODVERSIONPH=VER_PLACEHOLDER
BINPH=BIN_PLACEHOLDER
# Log variables
LASTLOGFILE=$MHPCPATH/propsconf_last.log
VLOGFILE=$MHPCPATH/propsconf_verbose.log
VLASTLOGFILE=$MHPCPATH/propsconf_verbose_last.log
TMPLOGLOC=$MHPCPATH/propslogs
TMPLOGLIST="
$MHPCPATH/defaultprops
$CACHELOC/magisk.log
$CACHELOC/magisk.log.bak
$MHPCPATH/propsconf*
$LATEFILE
"
fi
TMPFSMOUNT=$(magisk --path)
MIRRORPATH=$TMPFSMOUNT/.magisk/mirror
SYSTEMFILE=$MODPATH/system.prop
RUNFILE=$MHPCPATH/script_check
UPDATECHECK=""
# Make sure that the terminal app used actually can see resetprop
if [ "$BOOTSTAGE" == "props" ]; then
alias resetprop="$ADBPATH/magisk/magisk resetprop"
fi
# Fingerprint variables
PRINTSLOC=$MODPATH/common/prints.sh
PRINTSTMP=$MHPCPATH/prints.sh
PRINTSWWW="https://raw.githubusercontent.com/Magisk-Modules-Repo/MagiskHide-Props-Config/master/common/prints.sh"
PRINTSDEV="https://raw.githubusercontent.com/Didgeridoohan/Playground/master/prints.sh"
PRINTFILES=$MODPATH/printfiles
CSTMPRINTS=/data/media/0/printslist
CSTMFILE=$PRINTFILES/Custom.sh
EXPORTPATH=/data/media/0/mhpc
EXPORTFILE=$EXPORTPATH/propsconf_conf
# Known modules that edit device fingerprint
USNFLIST="
xiaomi-safetynet-fix
safetynet-fingerprint-fix
VendingVisa
DeviceSpoofingTool4Magisk
universal-safetynet-fix
samodx-safetyskipper
safetypatcher
petnoires-safetyspoofer
VR_Patch
PIXELARITY
"
# Configuration file locations
CONFFILELOC="
/data
$CACHELOC
/data/media/0
"
# Solo-run run options
SOLORUN="
d
f
h
l
r
s
u
"
# MagiskHide props
PROPSLIST="
ro.debuggable
ro.secure
ro.build.type
ro.build.tags
ro.boot.vbmeta.device_state
ro.boot.verifiedbootstate
ro.boot.flash.locked
ro.boot.veritymode
ro.boot.warranty_bit
ro.warranty_bit
ro.vendor.boot.warranty_bit
ro.vendor.warranty_bit
vendor.boot.vbmeta.device_state
"
# Trigger props
TRIGGERPROPS="
ro.bootmode
ro.boot.mode
vendor.boot.mode
ro.boot.hwc
ro.boot.hwcountry
"
# Triggering values
TRIGGERLIST="
ro.bootmode=recovery
ro.boot.mode=recovery
vendor.boot.mode=recovery
ro.boot.hwc=CN
ro.boot.hwcountry=China
"
# Late props
LATEPROPS="
vendor.boot.verifiedbootstate
"
# Partitions used for different props
PARTITIONS="
system
vendor
product
odm
system_ext
"
# Additional fingerprint prop parts
PRINTPROPSPARTS="
bootimage
"
# Print parts
PRINTPARTS="
ro.product.brand
ro.product.name
ro.product.device
ro.build.version.release
ro.build.id
ro.build.version.incremental
"
# Additional SafetyNet props
SNPROPS="
ro.build.version.security_patch
"
# Additional props
ADNPROPS="
ro.build.fingerprint
ro.vendor.build.fingerprint
ro.build.description
"
# Additional simulation props
ADNSIMPROPS1="
ro.build.display.id
ro.build.version.sdk
"
ADNSIMPROPS2="
ro.product.manufacturer
ro.product.model
"
ADNSIMPROPS=$ADNSIMPROPS1$ADNSIMPROPS2
# Android API level
APILVL="
4.2=17
4.3=18
4.4=19
5.0=21
5.1=22
6.0=23
7.0=24
7.1=25
8.0=26
8.1=27
9=28
10=29
11=30
12=31
"
# Values props list
VALPROPSLIST=$PROPSLIST$TRIGGERPROPS$LATEPROPS$PRINTPARTS$SNPROPS$ADNPROPS$ADNSIMPROPS
# Loading module settings
if [ -z "$INSTFN" ]; then
. $LATEFILE
fi
# Add log divider
if [ "$BOOTSTAGE" != "post" ]; then
echo "" >> $LOGFILE
echo "==============================" >> $LOGFILE
fi
# ======================== General functions ========================
# Log functions, $1=Log text
# Print to log
log_handler() {
if [ "$(id -u)" == 0 ] ; then
echo "" >> $LOGFILE 2>&1
echo -e "$(date +"%Y-%m-%d %H:%M:%S.%3N") - $1" >> $LOGFILE 2>&1
fi
}
# Print to log and screen
log_print() {
if [ "$INSTFN" ]; then
ui_print "$1"
else
echo -e "$1"
fi
log_handler "$1"
}
# Print to controll file for boot scripts
log_script_chk() {
log_handler "$1"
echo -e "$(date +"%m-%d-%Y %H:%M:%S") - $1" >> $RUNFILE 2>&1
}
#Divider
DIVIDER="${Y}=====================================${N}"
# Header, $1=header text
menu_header() {
# Don't clear screen if running from adb or if testing flag is active
if [ -z "$ANDROID_SOCKET_adbd" ] && [ "$DEVTESTING" == "false" ]; then
clear
fi
if [ "$MODVERSION" == "VER_PLACEHOLDER" ]; then
VERSIONTXT=""
else
VERSIONTXT=$MODVERSION
fi
echo ""
echo -e "${W}MagiskHide Props Config $VERSIONTXT${N}"
echo -e "${W}by Didgeridoohan @ XDA Developers${N}"
echo ""
echo -e $DIVIDER
echo -e " $1"
echo -e $DIVIDER
}
# Get module version
module_v_ctrl() {
VERSIONCMP=$(echo $MODVERSION | sed 's|v||g' | sed 's|\.||g')
VERSIONTMP=$(echo $(get_file_value $MODPATH/module.prop "version="))
}
# Find prop type, $1=prop name
get_prop_type() {
if [ "$1" == "ro.vendor.build.fingerprint" ]; then
echo "vendprint"
elif [ "$1" == "ro.build.display.id" ]; then
echo "display"
elif [ "$1" == "vendor.boot.mode" ]; then
echo "vendormode"
elif [ "$1" == "vendor.boot.vbmeta.device_state" ]; then
echo "vendordevice_state"
elif [ "$1" == "vendor.boot.verifiedbootstate" ]; then
echo "vendorverifiedbootstate"
elif [ "$1" == "ro.boot.warranty_bit" ]; then
echo "bootwarranty_bit"
elif [ "$1" == "ro.vendor.boot.warranty_bit" ]; then
echo "vendorbootwarranty_bit"
elif [ "$1" == "ro.vendor.warranty_bit" ]; then
echo "vendorwarranty_bit"
else
echo $1 | sed 's|.*\.||' | sed 's|.*\_||'
fi
}
# Get left side of =, $1=string to check
get_eq_left() {
echo $1 | cut -f 1 -d '='
}
# Get right side of =, $1=string to check
get_eq_right() {
echo $1 | cut -f 2- -d '='
}
# Get the list of print version, $1=Fingerprint device info with android versions
get_print_versions() {
echo "$1" | sed 's|.*(||' | sed 's|).*||' | sed 's| \& | |g'
}
# Get Android version with 3 digits for input, $1=version string to convert to three digits
get_android_version() {
VERTMP=$(echo $1 | sed 's|\.||g')
if [ "${#VERTMP}" -lt 3 ]; then
until [ "${#VERTMP}" == 3 ]; do
VERTMP="$(echo ${VERTMP}0)"
done
fi
echo $VERTMP
}
# Get security patch date for current fingerprint, $1=fingerprint string, including appended security patch date
get_sec_patch() {
echo $1 | sed 's|.*\_\_||'
}
# Get the fingerprint for displaying in the ui, $1=fingerprint
get_print_display() {
echo $1 | sed 's|\_\_.*||'
}
# Get prop value for custom props, $1=full prop string with name and value
get_prop_value() {
echo "$(get_eq_right "$1")" | sed 's|_sp_| |g' | sed 's|\;.*$||'
}
# Get delay for custom props, $1=full prop string with name, value and delay. If no delay is set, 0 is returned
get_prop_delay() {
TMPVAL="$(echo "$(get_eq_right "$1")" | sed 's|^.*\;||' | sed 's|\_\_.*$||')"
if [ "$TMPVAL" ]; then
echo "$TMPVAL"
else
echo "0"
fi
}
# Get execution point for custom prop delay, $1=full prop string with name, value and delay
get_prop_delay_exec() {
echo "$(get_eq_right "$1")" | sed 's|^.*\_\_||'
}
# Replace file values, $1=Variable to update, $2=Original variable value, $3=New variable value, $4=File, $5=control option for placeholder replacement
replace_fn() {
if [ "$5" == "placeholder" ]; then
sed -i "s|${1}PH=${2}|${1}=${3}|" $4 >> $LOGFILE 2>&1
else
sed -i "s|${1}=${2}|${1}=${3}|" $4 >> $LOGFILE 2>&1
fi
}
# Format user files to remove Windows file endings, $1=file to format
format_file() {
log_handler "Formating file (${1})."
# Remove Windows line endings
sed -i 's/\r$//' $1
# Check for newline at EOF
if [ ! -z "$(tail -c 1 "$1")" ]; then
echo "" >> $1
fi
}
# Reboot the device
force_reboot() {
RBREASON=""
if [ "$(get_file_value "$TMPFSMOUNT/.magisk/config" "RECOVERYMODE=")" == "true" ]; then
RBREASON="recovery"
fi
echo ""
echo -e "${C}Rebooting...${N}"
log_handler "Rebooting."
[ $(getprop sys.boot_completed) == 1 ] && /system/bin/svc power reboot $RBREASON >> $LOGFILE 2>&1 || /system/bin/reboot $RBREASON >> $LOGFILE 2>&1 || setprop sys.powerctl reboot >> $LOGFILE 2>&1
if [ "$BOOTSTAGE" != "post" -a "$BOOTSTAGE" != "late" ]; then
sleep 15
log_handler "Rebooting failed."
echo ""
echo "That doesn't seem like it worked..."
echo "Please reboot manually."
echo ""
exit 0
fi
}
# Updates placeholders, $1=file, $2=Variable name to replace to, $3=Placeholder name, $4=Value to assign updated variable
placeholder_update() {
log_handler "Checking for ${3} in ${1}."
if [ -f "$1" ]; then
FILEVALUE=$(get_file_value "$1" "${2}PH=")
if [ "$FILEVALUE" ]; then
case $FILEVALUE in
*PLACEHOLDER*) replace_fn $2 $3 $4 $1 "placeholder"
log_handler "Placeholder ${3} updated to ${4} in ${1}."
;;
esac
else
log_handler "No placeholder to update for ${2} in ${1}."
fi
else
log_handler "$1 does not exist."
fi
}
# Check if boot scripts ran during boot
script_ran_check() {
POSTCHECK=0
if [ -f "$RUNFILE" ] && [ "$(grep "post-fs-data.sh module script finished" $RUNFILE)" ]; then
POSTCHECK=1
fi
LATECHECK=0
if [ -f "$RUNFILE" ] && [ "$(grep "service.sh module script finished" $RUNFILE)" ]; then
LATECHECK=1
fi
}
#Save default file values in propsconf_late
default_save(){
#Format the props file
log_handler "Formatting prop file."
sed -i -e "s|\]\:\ \[|=|g;s|^\[||g;s|\]$||g" $MHPCPATH/defaultprops
#Save the props values to $LATEFILE
for ITEM in $VALPROPSLIST; do
TMPPROP=$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]')
ORIGPROP="ORIG${TMPPROP}"
ORIGTMP="$(get_file_value $LATEFILE "${ORIGPROP}=")"
CURRPROP="CURR${TMPPROP}"
CURRTMP="$(get_file_value $MHPCPATH/defaultprops "${ITEM}=")"
replace_fn $ORIGPROP "\"$ORIGTMP\"" "\"$CURRTMP\"" $LATEFILE
done
}
# Check for original prop values
orig_check() {
PROPSTMPLIST=$VALPROPSLIST
ORIGLOAD=0
for PROPTYPE in $PROPSTMPLIST; do
PROP=$(get_prop_type $PROPTYPE)
ORIGPROP=$(echo "ORIG${PROP}" | tr '[:lower:]' '[:upper:]')
ORIGVALUE="$(echo ${ORIGPROP})"
if [ "$ORIGVALUE" ]; then
ORIGLOAD=1
break
fi
done
}
# Load currently set values
curr_values() {
for ITEM in $VALPROPSLIST; do
CURRTMP=$(getprop $ITEM)
TMPPROP=$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]')
eval "CURR${TMPPROP}='$CURRTMP'"
echo "${ITEM}: ${CURRTMP}" >> $LOGFILE 2>&1
done
if [ -z "$CURRFINGERPRINT" ]; then
CURRFINGERPRINT=$(getprop ro.bootimage.build.fingerprint)
if [ -z "$CURRFINGERPRINT" ]; then
CURRFINGERPRINT=$(getprop ro.vendor.build.fingerprint)
fi
echo "ro.build.fingerprint: ${CURRFINGERPRINT}" >> $LOGFILE 2>&1
fi
}
# Run all value loading functions
all_values() {
log_handler "Loading values."
# Currently set values
curr_values
# Module saved values
. $LATEFILE
}
# Run before updated props/settings
before_change() {
if [ -z "$INSTFN" ]; then
echo ""
echo -e "${C}Working. Please wait...${N}"
fi
}
# Run after updated props/settings, $1=header, $2=Run options, $3=Reboot or not
after_change() {
if [ "$2" == "file" ]; then
# Load module settings
. $LATEFILE
elif [ "$2" != "none" ]; then
# Update the reboot variable
replace_fn REBOOTCHK 0 1 $LATEFILE
# Load all values
all_values
# Update the system.prop file
system_prop
if [ "$3" != "noreboot" ] && [ ! "$INSTFN" ]; then
# Ask to reboot
reboot_fn "$1" "$2"
fi
fi
}
# Reboot function, $1=header, $2=Run options
reboot_fn() {
INPUT5=""
while true
do
if [ -z "$INPUT5" ]; then
if [ "$2" == "reboot" ] || [ "$2" == "reset-script" ] || [ "$2" == "update" ]; then
REBOOTTXT=""
else
REBOOTTXT="Reboot - "
fi
menu_header "$REBOOTTXT${C}$1${N}"
echo ""
if [ "$2" != "reset-script" ] && [ "$2" != "reboot" ]; then
if [ "$2" == "update" ]; then
echo "The device fingerprint has been updated."
echo ""
fi
echo "Reboot for changes to take effect."
echo ""
fi
echo -e "Do you want to reboot now (${G}y/n${N})?"
echo ""
if [ "$2" == "p" ] || [ "$2" == "r" ] || [ "$2" == "reset-script" ]; then
echo -en "Enter ${G}y${N}(es) or ${G}n${N}(o): "
INV1=2
else
echo -en "Enter ${G}y${N}(es), ${G}n${N}(o) or ${G}e${N}(xit): "
INV1=3
fi
read -r INPUT5
fi
case "$INPUT5" in
y|Y) force_reboot
;;
n|N)
if [ "$2" == "p" ] || [ "$2" == "r" ] || [ "$2" == "reset-script" ]; then
exit_fn
else
INPUT2=""
INPUT3=""
INPUT4=""
INPUT5=""
INPUT6=""
break
fi
;;
e|E)
if [ "$2" == "p" ] || [ "$2" == "r" ] || [ "$2" == "reset-script" ]; then
invalid_input $INV1 5
else
exit_fn
fi
;;
*) invalid_input $INV1 5
;;
esac
done
}
# Reset module, $1=header, $2=Run options, $3=Reboot or not
reset_fn() {
before_change
cp -af $MODPATH/common/propsconf_late $LATEFILE >> $LOGFILE 2>&1
if [ "$FINGERPRINTENB" ] && [ "$FINGERPRINTENB" != 1 ]; then
replace_fn FINGERPRINTENB 1 $FINGERPRINTENB $LATEFILE
fi
if [ "$2" == "mismatch" ]; then
log_handler "Saving device default values."
default_save
log_handler "Default values saved to $LATEFILE."
fi
log_handler "Settings cleared."
after_change "$1" "$2" "$3"
}
# Checks for configuration file
config_file() {
log_handler "Checking for configuration file."
CONFFILE=""
for ITEM in $CONFFILELOC; do
if [ -s "$ITEM/propsconf_conf" ]; then
CONFFILE="$ITEM/propsconf_conf"
break
fi
if [ "$ITEM" == "/data/media/0" ]; then
until [ -e "$ITEM/testfbe" ]; do
sleep 1
touch $ITEM/testfbe
done
rm -f $ITEM/testfbe >> $LOGFILE 2>&1
if [ -s "$ITEM/propsconf_conf" ]; then
CONFFILE="$ITEM/propsconf_conf"
break
fi
fi
done
if [ "$CONFFILE" ]; then
log_handler "Configuration file detected (${CONFFILE})."
format_file $CONFFILE
# Loads custom variables
. $CONFFILE
module_v_ctrl
if [ "$CONFTRANSF" ] && [ $CONFTRANSF -le $VERSIONCMP ]; then
# Check if vendor fingerprint is set
if [ "$CONFVENDPRINT" == "true" ]; then
log_handler "Using vendor fingerprint"
CONFFINGERPRINT=$(getprop ro.vendor.build.fingerprint)
echo "ro.vendor.build.fingerprint: ${CONFFINGERPRINT}" >> $LOGFILE 2>&1
fi
# Device fingerprint
if [ "$CONFFINGERPRINT" ]; then
if "$CONFFINGERPRINT" != "preserve" ] && [ "$FINGERPRINTENB" == 1 ]; then
change_print "$PROPTYPE" "$TMPPROP" "file"
fi
else
reset_print "$PROPTYPE" "file"
fi
# Updates sensitive props
PROPSTMPLIST="$PROPSLIST$TRIGGERPROPS$LATEPROPS"
for PROPTYPE in $PROPSTMPLIST; do
CONFPROP=$(echo "CONF$(get_prop_type $PROPTYPE)" | tr '[:lower:]' '[:upper:]')
TMPPROP=$(eval "echo \$$CONFPROP")
if [ "$TMPPROP" == "true" ]; then
change_prop "$PROPTYPE" "file"
else
reset_prop "$PROPTYPE" "file"
fi
done
# Updates device simulation options, only if fingerprint editing is enabled
if [ "$PRINTEDIT" == 1 ]; then
# Fingerprint parts
if [ "$CONFDEVSIM" == "true" ]; then
change_dev_sim "Device simulation" "file"
TMPPARTS=$PRINTPARTS$ADNSIMPROPS
for ITEM in $TMPPARTS; do
TMPVAR="CONF$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]')"
if [ $(eval "echo \$$TMPVAR") == "true" ]; then
TMPVAL=1
else
TMPVAL=0
fi
change_sim_prop "Device simulation" "$ITEM" "$TMPVAL" "file"
done
fi
# Device description
if [ "$CONFDESCRIPTION" == "true" ]; then
change_sim_descr "Device simulation" 1 "file"
else
change_sim_descr "Device simulation" 0 "file"
fi
# Partition specific props
if [ "$CONFPARTPROPS" == "true" ]; then
change_sim_partprops "Device simulation" 1 "file"
else
change_sim_partprops "Device simulation" 0 "file"
fi
fi
# Updates boot options for fingerprint and simulation props
if [ "$PRINTEDIT" == 1 ]; then
if [ "$CONFPRINTBOOT" == "default" ]; then
OPTLCHNG=0
TMPTXT="default"
elif [ "$CONFPRINTBOOT" == "post" ]; then
OPTLCHNG=1
TMPTXT="post-fs-data"
elif [ "$CONFPRINTBOOT" == "late" ]; then
OPTLCHNG=2
TMPTXT="late_start service"
fi
replace_fn PRINTSTAGE $PRINTSTAGE $OPTLCHNG $LATEFILE
log_handler "Fingerprint boot stage is ${TMPTXT}."
if [ "$CONFPATCHBOOT" == "default" ]; then
OPTLCHNG=0
TMPTXT="default"
elif [ "$CONFPATCHBOOT" == "post" ]; then
OPTLCHNG=1
TMPTXT="post-fs-data"
elif [ "$CONFPATCHBOOT" == "late" ]; then
OPTLCHNG=2
TMPTXT="late_start service"
fi
replace_fn PATCHSTAGE $PATCHSTAGE $OPTLCHNG $LATEFILE
log_handler "Security patch boot stage is ${TMPTXT}."
fi
if [ "$DEVSIM" == 1 ]; then
if [ "$CONFSIMBOOT" == "default" ]; then
OPTLCHNG=0
TMPTXT="default"
elif [ "$CONFSIMBOOT" == "post" ]; then
OPTLCHNG=1
TMPTXT="post-fs-data"
elif [ "$CONFSIMBOOT" == "late" ]; then
OPTLCHNG=2
TMPTXT="late_start service"
fi
replace_fn SIMSTAGE $SIMSTAGE $OPTLCHNG $LATEFILE
log_handler "Device simulation boot stage is ${TMPTXT}."
fi
# Updates custom props
if [ "$PROPOPTION" != "preserve" ]; then
if [ "$CONFPROPS" ] || [ "$CONFPROPSPOST" ] || [ "$CONFPROPSLATE" ]; then
if [ "$PROPOPTION" == "add" ] || [ "$PROPOPTION" == "replace" ]; then
if [ "$PROPOPTION" == "replace" ]; then
reset_all_custprop "file"
fi
if [ "$CONFPROPS" ]; then
for ITEM in $CONFPROPS; do
set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "default" "file"
done
fi
if [ "$CONFPROPSPOST" ]; then
for ITEM in $CONFPROPSPOST; do
set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "post" "file"
done
fi
if [ "$CONFPROPSLATE" ]; then
for ITEM in $CONFPROPSLATE; do
set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "late" "file"
done
fi
fi
else
reset_all_custprop "file"
fi
fi
# Updates props to delete
if [ "$DELPROPOPTION" != "preserve" ]; then
if [ "$CONFDELPROPS" ]; then
if [ "$DELPROPOPTION" == "add" ] || [ "$DELPROPOPTION" == "replace" ]; then
if [ "$DELPROPOPTION" == "replace" ]; then
reset_all_delprop "file"
fi
for ITEM in $CONFDELPROPS; do
set_delprop "$ITEM" "file"
done
fi
else
reset_all_delprop "file"
fi
fi
# Updates soft boot options
if [ "$CONFOPTIONSOFTBOOT" == true ]; then
OPTLCHNG=1
TMPTXT="enabled"
else
OPTLCHNG=0
TMPTXT="disabled"
fi
replace_fn OPTIONSOFTBOOT $OPTIONSOFTBOOT $OPTLCHNG $LATEFILE
log_handler "Soft reboot option for late_start service boot stage $TMPTXT."
if [ "$CONFPRINTSOFTBOOT" == true ]; then
OPTLCHNG=1
TMPTXT="enabled"
else
OPTLCHNG=0
TMPTXT="disabled"
fi
replace_fn PRINTSOFTBOOT $PRINTSOFTBOOT $OPTLCHNG $LATEFILE
log_handler "Soft reboot option for device fingerprint $TMPTXT."
if [ "$CONFPATCHSOFTBOOT" == true ]; then
OPTLCHNG=1
TMPTXT="enabled"
else
OPTLCHNG=0
TMPTXT="disabled"
fi
replace_fn PATCHSOFTBOOT $PATCHSOFTBOOT $OPTLCHNG $LATEFILE
log_handler "Soft reboot option for security patch date $TMPTXT."
if [ "$CONFSIMSOFTBOOT" == true ]; then
OPTLCHNG=1
TMPTXT="enabled"
else
OPTLCHNG=0
TMPTXT="disabled"
fi
replace_fn SIMSOFTBOOT $SIMSOFTBOOT $OPTLCHNG $LATEFILE
log_handler "Soft reboot option for device simulation $TMPTXT."
if [ "$CONFCUSTOMSOFTBOOT" == true ]; then
OPTLCHNG=1
TMPTXT="enabled"
else
OPTLCHNG=0
TMPTXT="disabled"
fi
replace_fn CUSTOMSOFTBOOT $CUSTOMSOFTBOOT $OPTLCHNG $LATEFILE
log_handler "Soft reboot option for custom props $TMPTXT."
if [ "$CONFPROPSOFTBOOT" == true ]; then
OPTLCHNG=1
TMPTXT="enabled"
else
OPTLCHNG=0
TMPTXT="disabled"
fi
replace_fn PROPSOFTBOOT $PROPSOFTBOOT $OPTLCHNG $LATEFILE
log_handler "Soft reboot option for sensitive props $TMPTXT."
# Updates options
# Boot stage
if [ "$CONFBOOT" == "default" ]; then
OPTLCHNG=0
TMPTXT="default"
elif [ "$CONFBOOT" == "post" ]; then
OPTLCHNG=1
TMPTXT="post-fs-data"
elif [ "$CONFBOOT" == "late" ]; then
OPTLCHNG=2
TMPTXT="late_start service"
fi
replace_fn OPTIONBOOT $OPTIONBOOT $OPTLCHNG $LATEFILE
log_handler "General boot stage is ${TMPTXT}."
# Script colours
if [ "$CONFCOLOUR" == "true" ]; then
OPTCCHNG=1
else
OPTCCHNG=0
fi
replace_fn OPTIONCOLOUR $OPTIONCOLOUR $OPTCCHNG $LATEFILE
log_handler "Colour is set to $CONFCOLOUR."
# Fingerprints list update
if [ "$CONFWEBP" == "true" ]; then
OPTWCHNG=1
else
OPTWCHNG=0
fi
replace_fn OPTIONWEBP $OPTIONWEBP $OPTWCHNG $LATEFILE
log_handler "Automatic fingerprints list update is set to $CONFWEBP."
# Module update check
if [ "$CONFWEBU" == "true" ]; then
OPTWCHNG=1
else
OPTWCHNG=0
fi
replace_fn OPTIONWEBU $OPTIONWEBU $OPTWCHNG $LATEFILE
log_handler "Module update check at start is set to $CONFWEBU."
# Automatic fingerprints update
if [ "$CONFUPDATE" == "true" ]; then
OPTFCHNG=1
else
OPTFCHNG=0
fi
replace_fn OPTIONUPDATE $OPTIONUPDATE $OPTFCHNG $LATEFILE
log_handler "Automatic fingerprint update is set to $CONFUPDATE."
else
log_handler "The configuration file is not compatible with the current module version ($CONFTRANSF vs $VERSIONCMP)."
fi
# Update the system.prop file
system_prop
# Deletes the configuration file
log_handler "Deleting configuration file."
for ITEM in $CONFFILELOC; do
rm -f $ITEM/propsconf_conf >> $LOGFILE 2>&1
done
log_handler "Configuration file import complete."
if [ "$BOOTSTAGE" == "late" ]; then
force_reboot
fi
else
log_handler "No configuration file."
fi
}