-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfix_java.py
More file actions
40 lines (32 loc) · 1.83 KB
/
fix_java.py
File metadata and controls
40 lines (32 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import re
path = r'C:\Users\vishw\all_tools\app_mod\HSPatcher\src\in\startv\hspatcher\MainActivity.java'
with open(path, 'r', encoding='utf-8') as f:
content = f.read()
# Remove the entire TRAFFIC MONITORING section (from the comment to APP BACKUP comment)
pattern = r' // ======================== TRAFFIC MONITORING & BLOCKING TOGGLE ========================.*?// ======================== APP BACKUP ========================'
replacement = ' // ======================== APP BACKUP ========================'
content = re.sub(pattern, replacement, content, flags=re.DOTALL)
# Remove SharedPreferences import if not used elsewhere
content = content.replace('import android.content.SharedPreferences;\n', '')
# Remove btnTrafficToggle field declaration
content = content.replace(' private Button btnTrafficToggle, btnBackup, btnSigner;\n', ' private Button btnBackup, btnSigner;\n')
# Remove trafficMonitorEnabled field
content = content.replace(' private boolean trafficMonitorEnabled = true;\n', '')
# Remove traffic toggle button binding and click listener
content = content.replace(
' btnTrafficToggle = findViewById(R.id.btn_traffic_toggle);\n', '')
content = content.replace(
' btnTrafficToggle.setOnClickListener(v -> onTrafficToggleClick());\n', '')
content = content.replace(
' // Initialize traffic toggle state\n initTrafficToggleState();\n\n', '')
with open(path, 'w', encoding='utf-8') as f:
f.write(content)
# Verify no traffic references remain
remaining = [line for i, line in enumerate(content.split('\n'))
if 'traffic' in line.lower() or 'TrafficToggle' in line]
if remaining:
print(f'WARNING: {len(remaining)} traffic references still remain:')
for r in remaining:
print(f' {r.strip()}')
else:
print('Java cleaned up - all traffic toggle code removed')