-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhardcode_rules.py
More file actions
49 lines (41 loc) · 1.74 KB
/
Copy pathhardcode_rules.py
File metadata and controls
49 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import re
def is_hardcode_protected(device_id: str, version: str) -> bool:
"""
Checks if a specific firmware version is 'hardcode protected'
(i.e., known to have ARB regardless of undetectable values).
"""
# Nord CE 3 Lite - build numbers >= 1600
if device_id == "oneplus_nord_ce_3_lite" and version:
match = re.search(r'\.(\d{4,})(?:\(|$|_)', version)
if match and int(match.group(1)) >= 1600:
return True
# Nord CE 3 (non-lite) - build numbers >= 1600
if device_id == "oneplus_nord_ce_3" and version:
match = re.search(r'\.(\d{4,})(?:\(|$|_)', version)
if match and int(match.group(1)) >= 1600:
return True
# Nord CE 2 Lite - build numbers >= 2900
if device_id == "oneplus_nord_ce_2_lite" and version:
match = re.search(r'\.(\d{4,})(?:\(|$|_)', version)
if match and int(match.group(1)) >= 2900:
return True
# Nord CE 4 Lite - build numbers > 303
if device_id == "oneplus_nord_ce_4_lite" and version:
match = re.search(r'\.(\d+)(?:\(|$|_)', version)
if match and int(match.group(1)) >= 303:
return True
# OnePlus 9RT - build numbers >= 2702
if device_id == "oneplus_9rt" and version:
match = re.search(r'\.(\d{4,})(?:\(|$|_)', version)
if match and int(match.group(1)) >= 2702:
return True
return False
def version_sort_key(version_str: str) -> tuple:
"""
Extract numeric parts from version string for correct ordering.
Note: Keep this in sync with versionSortKey() in templates/index.html.
"""
if not version_str:
return (0,)
parts = re.findall(r'\d+', version_str)
return tuple(int(p) for p in parts)