-
Notifications
You must be signed in to change notification settings - Fork 118
/
pif_manager.py
2286 lines (2037 loc) · 112 KB
/
pif_manager.py
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
#!/usr/bin/env python
# This file is part of PixelFlasher https://github.com/badabing2005/PixelFlasher
#
# Copyright (C) 2024 Badabing2005
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
# for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Also add information on how to contact you by electronic and paper mail.
#
# If your software can interact with users remotely through a computer network,
# you should also make sure that it provides a way for users to get its source.
# For example, if your program is a web application, its interface could
# display a "Source" link that leads users to an archive of the code. There are
# many ways you could offer source, and different solutions will be better for
# different programs; see section 13 for the specific requirements.
#
# You should also get your employer (if you work as a programmer) or school, if
# any, to sign a "copyright disclaimer" for the program, if necessary. For more
# information on this, and how to apply and follow the GNU AGPL, see
# <https://www.gnu.org/licenses/>.
import wx
import wx.stc as stc
import traceback
import images as images
import json
import json5
import re
from datetime import datetime
from runtime import *
from file_editor import FileEditor
# ============================================================================
# Class PifModule
# ============================================================================
class PifModule:
def __init__(self, id, name, version, version_code, format, path, flavor):
self.id = id
self.name = name
self.version = version
self.version_code = version_code
self.format = format
self.path = path
self.flavor = flavor
# ============================================================================
# Class PifManager
# ============================================================================
class PifManager(wx.Dialog):
def __init__(self, *args, parent=None, config=None, **kwargs):
self.config = config
wx.Dialog.__init__(self, parent, *args, **kwargs, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
# Position the dialog 200 px offset horizontally
default_pos = self.GetPosition()
offset_x = default_pos.x + 200
self.SetPosition((offset_x, default_pos.y))
self.config = config
self.SetTitle("Pif Manager")
self.pif_path = None
self.device_pif = ''
self.pi_app = 'gr.nikolasspyr.integritycheck'
# self.launch_method = 'launch-am'
self.launch_method = 'launch'
self.coords = Coords()
self.enable_buttons = False
self.pif_exists = False
self.pif_flavor = 'playintegrityfork_9999999'
self.favorite_pifs = get_favorite_pifs()
self.insync = False
self.pif_format = None
self.keep_unknown = False
self.current_pif_module = {}
self._last_call_was_on_spin = False
# Active pif label
self.active_pif_label = wx.StaticText(parent=self, id=wx.ID_ANY, label=u"Active Pif")
self.active_pif_label.SetToolTip(u"Loaded Pif (from Device)")
font = wx.Font(12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.active_pif_label.SetFont(font)
# Modified status
self.pif_modified_image = wx.StaticBitmap(parent=self)
self.pif_modified_image.SetBitmap(images.alert_gray_24.GetBitmap())
self.pif_modified_image.SetToolTip(u"Active pif is not modified.")
# Save pif
self.save_pif_button = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.save_pif_button.SetBitmap(images.save_24.GetBitmap())
self.save_pif_button.SetToolTip(u"Save Active pif content to a json file on disk.")
# Module version label
self.pif_selection_combo = wx.ComboBox(self, choices=[], style=wx.CB_READONLY)
self.pif_selection_combo.SetToolTip(u"Pif Module")
# Favorite button
self.favorite_pif_button = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.favorite_pif_button.SetBitmap(images.heart_gray_24.GetBitmap())
self.favorite_pif_button.SetToolTip(u"Active pif is not saved in favorites.")
# Combo Box of favorites
pif_labels = [pif["label"] for pif in self.favorite_pifs.values()]
self.pif_combo_box = wx.ComboBox(self, choices=pif_labels, style=wx.CB_READONLY)
# Import button
self.import_pif_button = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.import_pif_button.SetBitmap(images.import_24.GetBitmap())
self.import_pif_button.SetToolTip(u"Select a folder to import pif json files.")
# Active Pif
self.active_pif_stc = stc.StyledTextCtrl(self)
self.active_pif_stc.SetLexer(stc.STC_LEX_JSON)
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_DEFAULT, "fore:#000000")
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_NUMBER, "fore:#007F7F")
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_STRING, "fore:#7F007F")
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_PROPERTYNAME, "fore:#007F00")
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_ESCAPESEQUENCE, "fore:#7F7F00")
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_KEYWORD, "fore:#00007F,bold")
self.active_pif_stc.StyleSetSpec(stc.STC_JSON_OPERATOR, "fore:#7F0000")
self.active_pif_stc.SetCaretForeground(wx.BLACK)
font = wx.Font(9, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.active_pif_stc.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font)
self.active_pif_stc.SetWrapMode(wx.stc.STC_WRAP_NONE)
self.active_pif_stc.SetUseHorizontalScrollBar(True)
self.active_pif_stc.SetTabWidth(4)
self.active_pif_stc.SetIndent(4)
self.active_pif_stc.SetMarginType(1, stc.STC_MARGIN_NUMBER)
self.active_pif_stc.SetMarginWidth(1, 30)
# Console label
self.console_label = wx.StaticText(parent=self, id=wx.ID_ANY, label=u"Output")
self.console_label.SetToolTip(u"Console Output:\nIt could be the json output of processed prop\nor it could be the Play Integrity Check result.\n\nThis is not what currently is on the device.")
font = wx.Font(12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.console_label.SetFont(font)
# Smart Paste Up
self.smart_paste_up = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.smart_paste_up.SetBitmap(images.smart_paste_up_24.GetBitmap())
self.smart_paste_up.SetToolTip(u"Smart Paste:\nSets First API to the set value if it is missing or forced.\nReprocesses the output window content to adapt to current module requirements.\nPastes to Active pif.")
self.smart_paste_up.Enable(False)
# Paste Up
self.paste_up = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.paste_up.SetBitmap(images.paste_up_24.GetBitmap())
self.paste_up.SetToolTip(u"Paste the console window content to Active pif.")
self.paste_up.Enable(False)
# Paste Down
self.paste_down = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.paste_down.SetBitmap(images.paste_down_24.GetBitmap())
self.paste_down.SetToolTip(u"Paste the Active pif to console window.")
self.paste_down.Enable(False)
# Reprocess
self.reprocess = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.reprocess.SetBitmap(images.scan_24.GetBitmap())
self.reprocess.SetToolTip(u"Reprocess current Active Pif window json.\nUseful if you changed module version which might require additional / different fields.")
self.reprocess.Enable(False)
# Reprocess Json File(s)
self.reprocess_json_file = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.reprocess_json_file.SetBitmap(images.json_24.GetBitmap())
self.reprocess_json_file.SetToolTip(u"Reprocess one or many json file(s)\nUseful if you changed module version which might require additional / different fields.\nIf a single file is selected, the new json will output to console output\nHowever if multiple files are selected, the selected file will be updated in place.")
# Env to Json
self.e2j = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.e2j.SetBitmap(images.e2j_24.GetBitmap())
self.e2j.SetToolTip(u"Convert console content from env (key=value) format to json")
# Json to Env
self.j2e = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.j2e.SetBitmap(images.j2e_24.GetBitmap())
self.j2e.SetToolTip(u"Convert console content from json to env (key=value) format")
# Get FP Code
self.get_fp_code = wx.BitmapButton(parent=self, id=wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BU_AUTODRAW)
self.get_fp_code.SetBitmap(images.java_24.GetBitmap())
self.get_fp_code.SetToolTip(u"Process one or many json file(s) to generate the FrameworkPatcher formatted code excerpts.\n")
# Add missing keys checkbox
self.add_missing_keys_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Add missing Keys from device", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.add_missing_keys_checkbox.SetToolTip(u"When Processing or Reprocessing, add missing fields from device.")
# Force First API
self.force_first_api_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Force First API to:", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.force_first_api_checkbox.SetToolTip(f"Forces First API value(s) to")
# Input box for the API value
self.api_value_input = wx.TextCtrl(parent=self, id=wx.ID_ANY, value="25", size=(40, -1))
# sort_keys
self.sort_keys_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Sort Keys", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.sort_keys_checkbox.SetToolTip(f"Sorts json keys")
# keep_unknown
self.keep_unknown_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Keep All keys", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.keep_unknown_checkbox.SetToolTip(f"Does not remove non standard / unrecognized keys")
# add advanced options checkboxes
self.spoofBuild_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Spoof Build", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.spoofBuild_checkbox.SetValue(True)
self.spoofProps_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Spoof Props", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.spoofProvider_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Spoof Provider", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.spoofSignature_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Spoof Signature", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
# Console
self.console_stc = stc.StyledTextCtrl(self)
self.console_stc.SetLexer(stc.STC_LEX_JSON)
self.console_stc.StyleSetSpec(stc.STC_JSON_DEFAULT, "fore:#000000")
self.console_stc.StyleSetSpec(stc.STC_JSON_NUMBER, "fore:#007F7F")
self.console_stc.StyleSetSpec(stc.STC_JSON_STRING, "fore:#7F007F")
self.console_stc.StyleSetSpec(stc.STC_JSON_PROPERTYNAME, "fore:#007F00")
self.console_stc.StyleSetSpec(stc.STC_JSON_ESCAPESEQUENCE, "fore:#7F7F00")
self.console_stc.StyleSetSpec(stc.STC_JSON_KEYWORD, "fore:#00007F,bold")
self.console_stc.StyleSetSpec(stc.STC_JSON_OPERATOR, "fore:#7F0000")
self.console_stc.SetCaretForeground(wx.BLACK)
font = wx.Font(9, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.console_stc.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font)
self.console_stc.SetWrapMode(wx.stc.STC_WRAP_NONE)
self.console_stc.SetUseHorizontalScrollBar(True)
self.console_stc.SetTabWidth(4)
self.console_stc.SetIndent(4)
self.console_stc.SetMarginType(1, stc.STC_MARGIN_NUMBER)
self.console_stc.SetMarginWidth(1, 30)
# Close button
self.close_button = wx.Button(self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0)
# Create print button
self.create_pif_button = wx.Button(self, wx.ID_ANY, u"Create print", wx.DefaultPosition, wx.DefaultSize, 0)
self.create_pif_button.SetToolTip(u"Create pif.json / spoof_build_vars")
self.create_pif_button.Enable(False)
# Push print no validation button
self.push_pif_button = wx.Button(self, wx.ID_ANY, u"Push print, no validation", wx.DefaultPosition, wx.DefaultSize, 0)
self.push_pif_button.SetToolTip(u"Pushes the print as is without performing any validation.\nThis is useful to retain comments.")
self.push_pif_button.Enable(False)
# Reload print button
self.reload_pif_button = wx.Button(self, wx.ID_ANY, u"Reload print", wx.DefaultPosition, wx.DefaultSize, 0)
self.reload_pif_button.SetToolTip(u"Reload pif.json / spoof_build_vars from device.")
self.reload_pif_button.Enable(False)
# Clean DG button
self.cleanup_dg_button = wx.Button(self, wx.ID_ANY, u"Cleanup DG", wx.DefaultPosition, wx.DefaultSize, 0)
self.cleanup_dg_button.SetToolTip(u"Cleanup Droidguard Cache")
self.cleanup_dg_button.Enable(False)
# Push keybox button
self.push_kb_button = wx.Button(self, wx.ID_ANY, u"Push keybox.xml", wx.DefaultPosition, wx.DefaultSize, 0)
self.push_kb_button.SetToolTip(u"Push a valid keybox.xml to device.")
self.push_kb_button.Enable(False)
self.push_kb_button.Show(False)
# Edit Tricky Store Target button
self.edit_ts_target_button = wx.Button(self, wx.ID_ANY, u"Edit TS Target", wx.DefaultPosition, wx.DefaultSize, 0)
self.edit_ts_target_button.SetToolTip(u"Edit Tricky Store target.txt file.")
self.edit_ts_target_button.Enable(False)
self.edit_ts_target_button.Show(False)
# Process build.prop button
self.process_build_prop_button = wx.Button(self, wx.ID_ANY, u"Process build.prop(s)", wx.DefaultPosition, wx.DefaultSize, 0)
self.process_build_prop_button.SetToolTip(u"Process build.prop to extract a compatible print.")
# Process bulk prop
self.process_bulk_prop_button = wx.Button(self, wx.ID_ANY, u"Process bulk props", wx.DefaultPosition, wx.DefaultSize, 0)
self.process_bulk_prop_button.SetToolTip(u"Process a folder containing .prop files and convert then to .json files.")
self.process_bulk_prop_button.Hide()
# Process Image
self.process_img_button = wx.Button(self, wx.ID_ANY, u"Process Image", wx.DefaultPosition, wx.DefaultSize, 0)
self.process_img_button.SetToolTip(u"Process an image and get a print from it.")
self.process_img_button.Hide()
# if self.config.enable_pixel_img_process:
self.process_img_button.Show()
# Check for Auto Push print
self.auto_update_pif_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Auto Update print", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.auto_update_pif_checkbox.SetToolTip(u"After Processing build.props, the print is automatically pushed to the device and the GMS process is killed.")
self.auto_update_pif_checkbox.Enable(False)
# Check for Auto Check Play Integrity
self.auto_check_pi_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Auto Check Play Integrity", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.auto_check_pi_checkbox.SetToolTip(u"After saving (pushing) print, automatically run Play Integrity Check.")
self.auto_check_pi_checkbox.Enable(False)
# option button PI Selection
self.pi_choices = ["Play Integrity API Checker", "Simple Play Integrity Checker", "Android Integrity Checker", "Play Store", "YASNAC"]
self.pi_option = wx.RadioBox(self, choices=self.pi_choices, style=wx.RA_VERTICAL)
# Disable UIAutomator
self.disable_uiautomator_checkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, label=u"Disable UIAutomator", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0)
self.disable_uiautomator_checkbox.SetToolTip(u"Disables UIAutomator\nThis is useful for devices with buggy UIAutomator.\nNOTE: Create the coords.json file manually to make use of automated testing.")
# Play Integrity API Checker button
self.pi_checker_button = wx.Button(self, wx.ID_ANY, u"Play Integrity Check", wx.DefaultPosition, wx.DefaultSize, 0)
self.pi_checker_button.SetToolTip(u"Play Integrity API Checker\nNote: Need to install app from Play store.")
# Get Xiaomi Pif button
self.xiaomi_pif_button = wx.Button(self, wx.ID_ANY, u"Get Xiaomi Pif", wx.DefaultPosition, wx.DefaultSize, 0)
self.xiaomi_pif_button.SetToolTip(u"Get Xiaomi.eu pif\nEasy to start but is not recommended as it gets banned quickly.\nRecommended to find your own.")
# Get TheFreeman193 Pif button
self.freeman_pif_button = wx.Button(self, wx.ID_ANY, u"Get TheFreeman193 Random Pif", wx.DefaultPosition, wx.DefaultSize, 0)
self.freeman_pif_button.SetToolTip(u"Get a random pif from TheFreeman193 repository.\nNote: The pif might or might not work.")
# Get Beta Pif button
self.beta_pif_button = wx.Button(self, wx.ID_ANY, u"Get Pixel Beta Pif", wx.DefaultPosition, wx.DefaultSize, 0)
self.beta_pif_button.SetToolTip(u"Get the latest Pixel beta pif.")
# Make the buttons the same size
button_width = self.pi_option.GetSize()[0] + 10
self.create_pif_button.SetMinSize((button_width, -1))
self.push_pif_button.SetMinSize((button_width, -1))
self.reload_pif_button.SetMinSize((button_width, -1))
self.cleanup_dg_button.SetMinSize((button_width, -1))
self.push_kb_button.SetMinSize((button_width, -1))
self.edit_ts_target_button.SetMinSize((button_width, -1))
self.process_build_prop_button.SetMinSize((button_width, -1))
self.process_bulk_prop_button.SetMinSize((button_width, -1))
self.process_img_button.SetMinSize((button_width, -1))
self.auto_update_pif_checkbox.SetMinSize((button_width, -1))
self.auto_check_pi_checkbox.SetMinSize((button_width, -1))
self.disable_uiautomator_checkbox.SetMinSize((button_width, -1))
self.pi_checker_button.SetMinSize((button_width, -1))
self.xiaomi_pif_button.SetMinSize((button_width, -1))
self.freeman_pif_button.SetMinSize((button_width, -1))
self.beta_pif_button.SetMinSize((button_width, -1))
h_buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
h_buttons_sizer.Add((0, 0), 1, wx.EXPAND, 5)
h_buttons_sizer.Add(self.close_button, 0, wx.ALL, 5)
h_buttons_sizer.Add((0, 0), 1, wx.EXPAND, 5)
# h_api_sizer
h_api_sizer = wx.BoxSizer(wx.HORIZONTAL)
h_api_sizer.Add(self.force_first_api_checkbox, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)
h_api_sizer.Add(self.api_value_input, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
v_buttons_sizer = wx.BoxSizer(wx.VERTICAL)
v_buttons_sizer.Add(self.create_pif_button, 0, wx.TOP | wx.RIGHT, 5)
v_buttons_sizer.Add(self.push_pif_button, 0, wx.TOP | wx.RIGHT, 5)
v_buttons_sizer.Add(self.reload_pif_button, 0, wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
v_buttons_sizer.Add(self.cleanup_dg_button, 0, wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
v_buttons_sizer.Add(self.push_kb_button, 0, wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
v_buttons_sizer.Add(self.edit_ts_target_button, 0, wx.TOP | wx.RIGHT | wx.BOTTOM, 5)
v_buttons_sizer.AddStretchSpacer()
v_buttons_sizer.Add(self.process_build_prop_button, 0, wx.TOP | wx.RIGHT, 5)
v_buttons_sizer.Add(self.process_bulk_prop_button, 0, wx.TOP | wx.RIGHT, 5)
v_buttons_sizer.Add(self.process_img_button, 0, wx.TOP | wx.RIGHT, 5)
v_buttons_sizer.Add(self.auto_update_pif_checkbox, 0, wx.ALL, 5)
v_buttons_sizer.Add(self.auto_check_pi_checkbox, 0, wx.ALL, 5)
v_buttons_sizer.Add(self.pi_option, 0, wx.TOP, 5)
v_buttons_sizer.Add(self.disable_uiautomator_checkbox, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
v_buttons_sizer.Add(self.pi_checker_button, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
v_buttons_sizer.Add(self.xiaomi_pif_button, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
v_buttons_sizer.Add(self.freeman_pif_button, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
v_buttons_sizer.Add(self.beta_pif_button, 0, wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
self.vertical_btn_sizer1 = wx.BoxSizer(wx.VERTICAL)
self.vertical_btn_sizer1.Add(self.paste_up, 0, wx.ALL, 0)
self.vertical_btn_sizer1.AddStretchSpacer()
self.vertical_btn_sizer1.Add(self.paste_down, 0, wx.ALL, 0)
self.vertical_btn_sizer2 = wx.BoxSizer(wx.VERTICAL)
self.vertical_btn_sizer2.Add(self.reprocess_json_file, 1, wx.ALL, 0)
self.vertical_btn_sizer2.Add(self.e2j, 1, wx.ALL, 0)
self.vertical_btn_sizer2.Add(self.j2e, 1, wx.ALL, 0)
self.vertical_btn_sizer2.Add(self.get_fp_code, 1, wx.ALL, 0)
self.vertical_cb_sizer1 = wx.BoxSizer(wx.VERTICAL)
self.vertical_cb_sizer1.Add(self.add_missing_keys_checkbox, 1, wx.ALL, 0)
self.vertical_cb_sizer1.Add(h_api_sizer, 1, wx.ALL, 0)
self.vertical_cb_sizer1.Add(self.sort_keys_checkbox, 1, wx.ALL, 0)
self.vertical_cb_sizer1.Add(self.keep_unknown_checkbox, 1, wx.ALL, 0)
self.vertical_cb_sizer2 = wx.BoxSizer(wx.VERTICAL)
self.vertical_cb_sizer2.Add(self.spoofBuild_checkbox, 1, wx.ALL, 0)
self.vertical_cb_sizer2.Add(self.spoofProps_checkbox, 1, wx.ALL, 0)
self.vertical_cb_sizer2.Add(self.spoofProvider_checkbox, 1, wx.ALL, 0)
self.vertical_cb_sizer2.Add(self.spoofSignature_checkbox, 1, wx.ALL, 0)
console_label_sizer = wx.BoxSizer(wx.HORIZONTAL)
console_label_sizer.AddSpacer(10)
console_label_sizer.Add(self.console_label, 0, wx.ALIGN_BOTTOM)
console_label_sizer.AddSpacer(10)
console_label_sizer.Add(self.smart_paste_up, 0, wx.ALIGN_TOP)
console_label_sizer.AddSpacer(10)
console_label_sizer.Add(self.reprocess, 0, wx.ALIGN_TOP)
console_label_sizer.AddSpacer(10)
console_label_sizer.Add(self.vertical_btn_sizer1, 1, wx.EXPAND)
console_label_sizer.AddSpacer(10)
console_label_sizer.Add(self.vertical_btn_sizer2, 0, wx.EXPAND)
console_label_sizer.AddSpacer(15)
console_label_sizer.Add(self.vertical_cb_sizer1, 0, wx.EXPAND)
console_label_sizer.AddSpacer(15)
console_label_sizer.Add(self.vertical_cb_sizer2, 0, wx.EXPAND)
stc_sizer = wx.BoxSizer(wx.VERTICAL)
stc_sizer.Add(self.active_pif_stc, 1, wx.EXPAND | wx.ALL, 10)
stc_sizer.Add(console_label_sizer, 0, wx.TOP, 10)
stc_sizer.Add(self.console_stc, 1, wx.EXPAND | wx.ALL, 10)
outside_stc_sizer = wx.BoxSizer(wx.HORIZONTAL)
outside_stc_sizer.Add(stc_sizer, 1, wx.EXPAND | wx.ALL, 0)
outside_stc_sizer.Add(v_buttons_sizer, 0, wx.EXPAND | wx.ALL, 0)
active_pif_label_sizer = wx.BoxSizer(wx.HORIZONTAL)
active_pif_label_sizer.AddSpacer(10)
active_pif_label_sizer.Add(self.active_pif_label, 0, wx.ALIGN_CENTER_VERTICAL)
active_pif_label_sizer.AddSpacer(10)
active_pif_label_sizer.Add(self.pif_modified_image, 0, wx.ALIGN_CENTER_VERTICAL)
active_pif_label_sizer.AddSpacer(10)
active_pif_label_sizer.Add(self.save_pif_button, 0, wx.ALIGN_CENTER_VERTICAL)
active_pif_label_sizer.AddSpacer(100)
active_pif_label_sizer.Add(self.pif_selection_combo, 1, wx.EXPAND)
active_pif_label_sizer.AddSpacer(100)
active_pif_label_sizer.Add(self.favorite_pif_button, 0, wx.ALIGN_CENTER_VERTICAL)
active_pif_label_sizer.AddSpacer(10)
active_pif_label_sizer.Add(self.pif_combo_box, 1, wx.EXPAND)
active_pif_label_sizer.AddSpacer(10)
active_pif_label_sizer.Add(self.import_pif_button, 0, wx.ALIGN_CENTER_VERTICAL)
vSizer = wx.BoxSizer(wx.VERTICAL)
vSizer.Add(active_pif_label_sizer, 0, wx.TOP, 10)
vSizer.Add(outside_stc_sizer, 1, wx.EXPAND, 0)
vSizer.Add(h_buttons_sizer, 0, wx.EXPAND, 10)
self.SetSizer(vSizer)
self.SetMinSize((400, 240))
self.Layout()
# Connect Events
self.close_button.Bind(wx.EVT_BUTTON, self.onClose)
self.Bind(wx.EVT_CLOSE, self.onClose)
self.create_pif_button.Bind(wx.EVT_BUTTON, self.CreatePifJson)
self.push_pif_button.Bind(wx.EVT_BUTTON, self.PushPif)
self.reload_pif_button.Bind(wx.EVT_BUTTON, self.LoadReload)
self.cleanup_dg_button.Bind(wx.EVT_BUTTON, self.CleanupDG)
self.push_kb_button.Bind(wx.EVT_BUTTON, self.select_file_and_push)
self.edit_ts_target_button.Bind(wx.EVT_BUTTON, self.edit_ts_target)
self.process_build_prop_button.Bind(wx.EVT_BUTTON, self.ProcessBuildProp)
self.process_bulk_prop_button.Bind(wx.EVT_BUTTON, self.ProcessBuildPropFolder)
self.process_img_button.Bind(wx.EVT_BUTTON, self.ProcessImg)
self.pi_checker_button.Bind(wx.EVT_BUTTON, self.PlayIntegrityCheck)
self.xiaomi_pif_button.Bind(wx.EVT_BUTTON, self.XiaomiPif)
self.freeman_pif_button.Bind(wx.EVT_BUTTON, self.FreemanPif)
self.beta_pif_button.Bind(wx.EVT_BUTTON, self.BetaPif)
self.pi_option.Bind(wx.EVT_RADIOBOX, self.TestSelection)
self.Bind(wx.EVT_SIZE, self.onResize)
self.Bind(wx.EVT_SHOW, self.onShow)
self.smart_paste_up.Bind(wx.EVT_BUTTON, self.SmartPasteUp)
self.paste_up.Bind(wx.EVT_BUTTON, self.PasteUp)
self.paste_down.Bind(wx.EVT_BUTTON, self.PasteDown)
self.reprocess.Bind(wx.EVT_BUTTON, self.ReProcess)
self.reprocess_json_file.Bind(wx.EVT_BUTTON, self.ReProcessJsonFile)
self.get_fp_code.Bind(wx.EVT_BUTTON, self.GetFPCode)
self.e2j.Bind(wx.EVT_BUTTON, self.E2J)
self.j2e.Bind(wx.EVT_BUTTON, self.J2E)
self.save_pif_button.Bind(wx.EVT_BUTTON, self.SavePif)
self.favorite_pif_button.Bind(wx.EVT_BUTTON, self.Favorite)
self.active_pif_stc.Bind(wx.stc.EVT_STC_CHANGE, self.ActivePifStcChange)
self.console_stc.Bind(wx.stc.EVT_STC_CHANGE, self.ConsoleStcChange)
self.pif_selection_combo.Bind(wx.EVT_COMBOBOX, self.onPifSelectionComboBox)
self.pif_combo_box.Bind(wx.EVT_COMBOBOX, self.onPifComboBox)
self.import_pif_button.Bind(wx.EVT_BUTTON, self.ImportFavorites)
self.add_missing_keys_checkbox.Bind(wx.EVT_CHECKBOX, self.onAutoFill)
self.force_first_api_checkbox.Bind(wx.EVT_CHECKBOX, self.onForceFirstAPI)
self.sort_keys_checkbox.Bind(wx.EVT_CHECKBOX, self.onSortKeys)
self.keep_unknown_checkbox.Bind(wx.EVT_CHECKBOX, self.onKeepUnknown)
self.spoofBuild_checkbox.Bind(wx.EVT_CHECKBOX, self.onSpoofBuild)
self.spoofProps_checkbox.Bind(wx.EVT_CHECKBOX, self.onSpoofProps)
self.spoofProvider_checkbox.Bind(wx.EVT_CHECKBOX, self.onSpoofProvider)
self.spoofSignature_checkbox.Bind(wx.EVT_CHECKBOX, self.onSpoofSignature)
self.auto_update_pif_checkbox.Bind(wx.EVT_CHECKBOX, self.onAutoUpdatePif)
self.auto_check_pi_checkbox.Bind(wx.EVT_CHECKBOX, self.onAutoCheckPlayIntegrity)
self.disable_uiautomator_checkbox.Bind(wx.EVT_CHECKBOX, self.onDisableUIAutomator)
self.api_value_input.Bind(wx.EVT_TEXT, self.onApiValueChange)
# init button states
self.init()
# Autosize the dialog
self.active_pif_stc.PostSizeEventToParent()
self.SetSizerAndFit(vSizer)
print("\nOpening Pif Manager ...")
# -----------------------------------------------
# Function onShow
# -----------------------------------------------
def onShow(self, event):
if self.IsShown():
if self.config:
size = (self.config.pif_width, self.config.pif_height)
else:
size=(PIF_WIDTH, PIF_HEIGHT)
self.SetSize(size)
event.Skip()
# -----------------------------------------------
# Function init
# -----------------------------------------------
def init(self, refresh=False):
if self.config.pif:
with contextlib.suppress(KeyError):
self.add_missing_keys_checkbox.SetValue(self.config.pif['auto_fill'])
with contextlib.suppress(KeyError):
self.force_first_api_checkbox.SetValue(self.config.pif['force_first_api'])
with contextlib.suppress(KeyError):
self.first_api_value = self.config.pif['first_api_value_when_forced']
self.force_first_api_checkbox.SetToolTip(f"Forces First API value(s) to {self.first_api_value}")
self.api_value_input.SetValue(str(self.first_api_value))
with contextlib.suppress(KeyError):
self.sort_keys_checkbox.SetValue(self.config.pif['sort_keys'])
with contextlib.suppress(KeyError):
self.keep_unknown_checkbox.SetValue(self.config.pif['keep_unknown'])
with contextlib.suppress(KeyError):
self.spoofBuild_checkbox.SetValue(self.config.pif['spoofBuild'])
with contextlib.suppress(KeyError):
self.spoofProps_checkbox.SetValue(self.config.pif['spoofProps'])
with contextlib.suppress(KeyError):
self.spoofProvider_checkbox.SetValue(self.config.pif['spoofProvider'])
with contextlib.suppress(KeyError):
self.spoofSignature_checkbox.SetValue(self.config.pif['spoofSignature'])
with contextlib.suppress(KeyError):
self.auto_update_pif_checkbox.SetValue(self.config.pif['auto_update_pif_json'])
with contextlib.suppress(KeyError):
self.auto_check_pi_checkbox.SetValue(self.config.pif['auto_check_play_integrity'])
with contextlib.suppress(KeyError):
selected_index = self.config.pif['test_app_index']
self.pi_option.SetSelection(selected_index)
self.pi_selection(self.pi_choices[selected_index])
with contextlib.suppress(KeyError):
self.disable_uiautomator_checkbox.SetValue(self.config.pif['disable_uiautomator'])
if self.config.enable_bulk_prop:
self.process_bulk_prop_button.Show()
self.keep_unknown = self.keep_unknown_checkbox.IsChecked()
self.sort_keys = self.sort_keys_checkbox.IsChecked()
if self.force_first_api_checkbox.IsChecked():
self.first_api = self.first_api_value
else:
self.first_api = None
device = get_phone(True)
if not device:
self.console_stc.SetText("No Device is selected.\nPif Manager features are set to limited mode.")
return
if not device.rooted:
self.console_stc.SetText("Device is not rooted or SU permissions to adb shell is not granted.\nPif Manager features are set to limited mode.")
return
modules = device.get_magisk_detailed_modules(refresh)
self.create_pif_button.Enable(False)
self.push_pif_button.Enable(False)
self.reload_pif_button.Enable(False)
self.push_kb_button.Enable(False)
self.cleanup_dg_button.Enable(False)
self.push_kb_button.Show(False)
self.edit_ts_target_button.Enable(False)
self.edit_ts_target_button.Show(False)
self.auto_update_pif_checkbox.Enable(False)
self.auto_check_pi_checkbox.Enable(False)
self.pi_checker_button.Enable(False)
self.enable_buttons = False
self.pif_selection_combo.Clear()
self.pif_modules = []
if modules:
found_pif_module = False
for module in modules:
if module.state == 'enabled' and ((module.id == "playintegrityfix" and "Play Integrity" in module.name) or module.id == "tricky_store"):
self.pif_format = None
self.pif_path = None
if module.id == "playintegrityfix":
self.pif_format = 'json'
if "Play Integrity Fork" in module.name:
self.pif_path = '/data/adb/modules/playintegrityfix/custom.pif.json'
if int(module.versionCode) > 4000:
print("Advanced props support enabled.")
else:
if module.version in ["PROPS-v2.1", "PROPS-v2.0"]:
self.pif_path = '/data/adb/modules/playintegrityfix/pif.json'
else:
self.pif_path = '/data/adb/pif.json'
if module.id == "tricky_store":
self.pif_format = 'prop'
self.pif_path = '/data/adb/tricky_store/spoof_build_vars'
self.push_kb_button.Enable(True)
self.push_kb_button.Show(True)
self.edit_ts_target_button.Enable(True)
self.edit_ts_target_button.Show(True)
flavor = module.name.replace(" ", "").lower()
self.pif_flavor = f"{flavor}_{module.versionCode}"
self.pif_modules.append(PifModule(module.id, module.name, module.version, module.versionCode, self.pif_format, self.pif_path, self.pif_flavor))
found_pif_module = True
self.create_pif_button.Enable(True)
self.push_pif_button.Enable(True)
self.reload_pif_button.Enable(True)
self.cleanup_dg_button.Enable(True)
self.auto_update_pif_checkbox.Enable(True)
self.auto_check_pi_checkbox.Enable(True)
self.pi_checker_button.Enable(True)
self.enable_buttons = True
module_label = f"{module.name} {module.version} {module.versionCode}"
self.pif_selection_combo.Append(module_label)
if found_pif_module:
# Make the selection in priority order: Play Integrity, Trickystore
for i in range(self.pif_selection_combo.GetCount()):
if "Play Integrity" in self.pif_selection_combo.GetString(i):
self.pif_selection_combo.SetSelection(i)
break
elif "Tricky" in self.pif_selection_combo.GetString(i):
self.pif_selection_combo.SetSelection(i)
# If nothing is selected and there are items, select the first item
if self.pif_selection_combo.GetSelection() == wx.NOT_FOUND and self.pif_selection_combo.GetCount() > 0:
self.pif_selection_combo.SetSelection(0)
# Manually trigger the combo box change event
self.onPifSelectionComboBox(None)
# -----------------------------------------------
# check_pif_json
# -----------------------------------------------
def check_pif_json(self):
device = get_phone(True)
if not device.rooted:
return
# check for presence of pif.json
res,_ = device.check_file(self.pif_path, True)
if res == 1:
self.pif_exists = True
self.reload_pif_button.Enable(True)
self.cleanup_dg_button.Enable(True)
self.create_pif_button.SetLabel("Update print")
self.create_pif_button.SetToolTip(u"Update pif.json / spoof_build_vars.")
else:
self.pif_exists = False
self.create_pif_button.SetLabel("Create print")
self.create_pif_button.SetToolTip(u"Create pif.json / spoof_build_vars.")
# -----------------------------------------------
# onPifComboBox
# -----------------------------------------------
def onPifComboBox(self, event):
selected_index = event.GetSelection()
pif_list = list(self.favorite_pifs.values())
if 0 <= selected_index < len(pif_list):
selected_pif = pif_list[selected_index]
pif_object = selected_pif["pif"]
if self.pif_format == 'prop':
json_string = json.dumps(pif_object, indent=4, sort_keys=self.sort_keys)
self.active_pif_stc.SetText(self.J2P(json_string))
else:
self.active_pif_stc.SetText(json.dumps(pif_object, indent=4))
else:
print("Selected Pif not found, Index out of range")
# -----------------------------------------------
# onPifSelectionComboBox
# -----------------------------------------------
def onPifSelectionComboBox(self, event):
selection_index = self.pif_selection_combo.GetSelection()
if selection_index != wx.NOT_FOUND and self.pif_modules and selection_index < len(self.pif_modules):
selected_module = self.pif_modules[selection_index]
self.current_pif_module = selected_module
self.pif_format = selected_module.format
self.pif_path = selected_module.path
self.pif_flavor = selected_module.flavor
if selected_module.id == "tricky_store":
self.spoofBuild_checkbox.Enable(False)
self.spoofProps_checkbox.Enable(False)
self.spoofProvider_checkbox.Enable(False)
self.spoofSignature_checkbox.Enable(False)
else:
self.spoofBuild_checkbox.Enable(True)
self.spoofProps_checkbox.Enable(True)
self.spoofProvider_checkbox.Enable(True)
self.spoofSignature_checkbox.Enable(True)
selected_label = f"{selected_module.name} {selected_module.version}"
print(f"Selected Module: {selected_label}")
self.LoadReload(None)
# -----------------------------------------------
# TestSelection
# -----------------------------------------------
def TestSelection(self, event):
option = event.GetString()
self.pi_selection(option)
# -----------------------------------------------
# pi_selection
# -----------------------------------------------
def pi_selection(self, selected_option):
if selected_option == "Play Integrity API Checker":
print("Play Integrity API Checker option selected")
self.pi_app = 'gr.nikolasspyr.integritycheck'
# self.launch_method = 'launch-am'
self.launch_method = 'launch'
elif selected_option == "Simple Play Integrity Checker":
print("Simple Play Integrity Checker option selected")
self.pi_app = 'com.henrikherzig.playintegritychecker'
# self.launch_method = 'launch-am'
self.launch_method = 'launch'
elif selected_option == "TB Checker":
print("TB Checker option selected")
self.pi_app = 'krypton.tbsafetychecker'
# self.launch_method = 'launch-am-main'
self.launch_method = 'launch'
elif selected_option == "Android Integrity Checker":
print("Android Integrity Checker option selected")
self.pi_app = 'com.thend.integritychecker'
# self.launch_method = 'launch-am-main'
self.launch_method = 'launch'
elif selected_option == "Play Store":
print("Play Store option selected")
self.pi_app = 'com.android.vending'
self.launch_method = 'launch'
elif selected_option == "YASNAC":
print("YASNAC option selected")
self.pi_app = 'rikka.safetynetchecker'
# self.launch_method = 'launch-am-main'
self.launch_method = 'launch'
print(f"Auto Update print is set to: {selected_option}")
self.config.pif['test_app_index'] = self.pi_option.Selection
# -----------------------------------------------
# __del__
# -----------------------------------------------
def __del__(self):
pass
# -----------------------------------------------
# onClose
# -----------------------------------------------
def onClose(self, e):
dialog_size = self.GetSize()
dialog_x, dialog_y = dialog_size.GetWidth(), dialog_size.GetHeight()
config = get_config()
config.pif_width = dialog_x
config.pif_height = dialog_y
config.pif = self.config.pif
set_config(config)
self.Destroy()
# -----------------------------------------------
# LoadReload
# -----------------------------------------------
def LoadReload(self, e):
try:
device = get_phone(True)
if not device.rooted:
return
self._on_spin('start')
config_path = get_config_path()
self.check_pif_json()
pif_prop = os.path.join(config_path, 'tmp', 'pif.json')
if self.reload_pif_button.Enabled:
# pull the file
res = device.pull_file(remote_file=self.pif_path, local_file=pif_prop, with_su=True, quiet=True)
if res != 0:
print(f"File: {self.pif_path} not found.")
self.active_pif_stc.SetValue("")
# puml("#red:Failed to pull pif.prop from the phone;\n}\n")
self._on_spin('stop')
return
else:
# we need to create one.
with open(pif_prop, 'w') as file:
pass
# get the contents of modified pif.json
encoding = detect_encoding(pif_prop)
with open(pif_prop, 'r', encoding=encoding, errors="replace") as f:
contents = f.read()
self.device_pif = contents
self.active_pif_stc.SetValue(contents)
except Exception as e:
print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Exception during pip Load process.")
traceback.print_exc()
finally:
self._on_spin('stop')
# -----------------------------------------------
# CreatePifJson
# -----------------------------------------------
def CreatePifJson(self, e):
self.create_update_pif(just_push=False)
# -----------------------------------------------
# PushPif
# -----------------------------------------------
def PushPif(self, e):
self.create_update_pif(just_push=True)
# -----------------------------------------------
# CleanupDG
# -----------------------------------------------
def CleanupDG(self, e):
device = get_phone()
if not device or not device.rooted:
return
print("Cleaning up DG Cache ...")
device.delete("/data/data/com.google.android.gms/app_dg_cache", with_su = True, dir = True)
device.delete("/data/data/com.google.android.gms/databases/dg.db*", with_su = True, dir = False)
# -----------------------------------------------
# UpdatePifJson
# -----------------------------------------------
def UpdatePifJson(self, e):
self.create_update_pif()
# -----------------------------------------------
# create_update_pif
# -----------------------------------------------
def create_update_pif(self, just_push=False):
try:
device = get_phone(True)
if not device.rooted:
return
self._on_spin('start')
config_path = get_config_path()
pif_prop = os.path.join(config_path, 'tmp', 'pif.json')
json_data = None
content = self.active_pif_stc.GetValue()
if not just_push:
if self.pif_format == 'prop':
json_data = self.P2J(content)
else:
json_data = content
if json_data:
try:
data = json.loads(json_data)
except Exception:
try:
data = json5.loads(json_data)
except Exception:
print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Not a valid json.")
self._on_spin('stop')
return
else:
print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Not a valid json.")
self._on_spin('stop')
return
# Save the data as normal JSON
with open(pif_prop, 'w', encoding="ISO-8859-1", errors="replace", newline='\n') as f:
if just_push:
with open(pif_prop, 'w', encoding="ISO-8859-1", errors="replace", newline='\n') as f:
f.write(content)
else:
if self.pif_format == 'prop':
f.write(self.J2P(json.dumps(data, indent=4, sort_keys=self.sort_keys)))
else:
json.dump(data, f, indent=4, sort_keys=self.sort_keys)
# push the file
res = device.push_file(pif_prop, self.pif_path, True)
if res != 0:
print("Aborting ...\n")
# puml("#red:Failed to push pif.json from the phone;\n}\n")
self._on_spin('stop')
return -1
if just_push:
self.device_pif = content
else:
self.device_pif = json.dumps(data, indent=4, sort_keys=self.sort_keys)
print("Killing Google GMS ...")
res = device.perform_package_action(pkg='com.google.android.gms.unstable', action='killall')
if res.returncode != 0:
print("Error killing GMS.")
else:
print("Killing Google GMS succeeded.")
if not just_push:
self.check_pif_json()
self.LoadReload(None)
# Auto test Play Integrity
if self.auto_check_pi_checkbox.IsEnabled() and self.auto_check_pi_checkbox.IsChecked():
print("Auto Testing Play Integrity ...")
self.PlayIntegrityCheck(None)
except Exception as e:
print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Exception during pip Create process.")
traceback.print_exc()
finally:
self._on_spin('stop')
# -----------------------------------------------
# get_pi_app_coords
# -----------------------------------------------
def get_pi_app_coords(self, child=None):
try:
device = get_phone()
if not device.rooted:
return
print(f"{datetime.now():%Y-%m-%d %H:%M:%S} Getting coordinates for {self.pi_app}")
# pull view
config_path = get_config_path()
pi_app_xml = os.path.join(config_path, 'tmp', 'pi_app.xml')
if self.pi_app == 'gr.nikolasspyr.integritycheck':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "CHECK", False)
elif self.pi_app == 'com.henrikherzig.playintegritychecker':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Make Play Integrity Request", False)
elif self.pi_app == 'krypton.tbsafetychecker':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Run Play Integrity Check", False)
elif self.pi_app == 'com.thend.integritychecker':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "android.widget.Button", False)
elif self.pi_app == 'rikka.safetynetchecker':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Run SafetyNet Attestation", False)
elif self.pi_app == 'com.android.vending':
if child == 'user':
# This needs custom handling, as there is no identifiable string to look for
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "PixelFlasher_Playstore", True)
if child == 'settings':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Settings", True)
if child == 'general':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "General", True)
if child == 'scroll':
return device.swipe_up()
if child == 'developer_options':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Developer options", True)
if child == 'test':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Check integrity", False)
if child == 'dismiss':
return device.ui_action('/data/local/tmp/pi.xml', pi_app_xml, "Dismiss", False)
except Exception:
traceback.print_exc()
# -----------------------------------------------
# XiaomiPif
# -----------------------------------------------
def XiaomiPif(self, e):
try:
self._on_spin('start')
xiaomi_pif = get_xiaomi_pif()
self.console_stc.SetValue(xiaomi_pif)
except Exception:
traceback.print_exc()
finally:
self._on_spin('stop')
# -----------------------------------------------
# FreemanPif
# -----------------------------------------------
def FreemanPif(self, e):
try:
device = get_phone()
if not device:
abilist = ''
else:
if not device.rooted:
return
self._on_spin('start')
keys = ['ro.product.cpu.abilist', 'ro.product.cpu.abi', 'ro.system.product.cpu.abilist', 'ro.vendor.product.cpu.abilist']
abilist = get_first_match(device.props.property, keys)
freeman_pif = get_freeman_pif(abilist)
self.console_stc.SetValue(freeman_pif)
except Exception:
traceback.print_exc()
finally:
self._on_spin('stop')
# -----------------------------------------------
# BetaPif
# -----------------------------------------------
def BetaPif(self, e):
try:
self._on_spin('start')
wx.CallAfter(self.console_stc.SetValue, f"Getting Pixel beta print ...\nPlease be patient this could take some time ...")
wx.Yield()
device = get_phone()
if wx.GetKeyState(wx.WXK_CONTROL) and wx.GetKeyState(wx.WXK_SHIFT):
device_model = "all"
elif device:
device_model = device.hardware
else:
device_model = "Random"
beta_pif = get_beta_pif(device_model)