|
9 | 9 | """
|
10 | 10 |
|
11 | 11 | # pylint: disable=too-many-instance-attributes
|
| 12 | +import re |
12 | 13 | from datetime import datetime
|
13 | 14 | from pathlib import Path
|
14 | 15 | from shutil import rmtree, make_archive, copy2
|
@@ -58,8 +59,9 @@ def __init__(self, input_file, _extract_mode, out_dir=""):
|
58 | 59 | self.extract_mode = self.get_extract_mode(_extract_mode)
|
59 | 60 | self.update_script = ''
|
60 | 61 | self.is_android_one = False
|
61 |
| - self.firmware_excluded_files = ['dtbo', 'logo', 'splash', 'vbmeta', 'boot', 'system', |
62 |
| - 'vendor', 'product', 'odm'] |
| 62 | + self.firmware_excluded_files = ['dtbo', 'logo', 'splash', 'vbmeta', 'boot.img', 'system', |
| 63 | + 'vendor', 'product', 'odm', 'exaid', |
| 64 | + 'dynamic_partitions_op_list'] |
63 | 65 | self.extractor = ZipExtractor(self.input_file, self._tmp_dir)
|
64 | 66 | self.init()
|
65 | 67 |
|
@@ -149,9 +151,8 @@ def get_files_list(self) -> List[str]:
|
149 | 151 | and (i.endswith('updater-script') or i.endswith('update-binary'))
|
150 | 152 | ) or all(n not in i for n in self.firmware_excluded_files)] \
|
151 | 153 | if self.type is ZipTypes.qcom \
|
152 |
| - else [n for n in self.extractor.files if 'system' not in n and 'vendor' not in n |
153 |
| - and 'product' not in n and 'boot.img' not in n |
154 |
| - and 'file_contexts' not in n] |
| 154 | + else [n for n in self.extractor.files if all( |
| 155 | + file not in n for file in self.firmware_excluded_files + ['file_contexts'])] |
155 | 156 | if self.extract_mode is ProcessTypes.non_arb_firmware:
|
156 | 157 | return [n for n in self.extractor.files if 'dspso.bin' in n
|
157 | 158 | or n.startswith('firmware-update/BTFM.bin')
|
@@ -180,13 +181,11 @@ def get_updater_script_lines(self) -> str:
|
180 | 181 | if self.extract_mode is ProcessTypes.firmware:
|
181 | 182 | lines = [line for line in original_updater_script if "getprop" in line
|
182 | 183 | or "Target" in line
|
183 |
| - or "firmware-update" in line and "dtbo.img" not in line |
184 |
| - and "vbmeta" not in line and "splash" not in line |
185 |
| - and "logo" not in line] \ |
| 184 | + or "firmware-update" in line and ("ro.product" in line or all( |
| 185 | + file not in line for file in self.firmware_excluded_files))] \ |
186 | 186 | if self.type is ZipTypes.qcom \
|
187 |
| - else [line for line in original_updater_script if "system" not in line |
188 |
| - and "vendor" not in line and 'boot.img' not in line |
189 |
| - and "dtbo.img" not in line and "vbmeta" not in line] |
| 187 | + else [line for line in original_updater_script if "ro.product" in line or |
| 188 | + all(file not in line for file in self.firmware_excluded_files)] |
190 | 189 | elif self.extract_mode is ProcessTypes.non_arb_firmware:
|
191 | 190 | lines = [line for line in original_updater_script if "getprop" in line
|
192 | 191 | or "Target" in line
|
@@ -240,6 +239,13 @@ def generate_updater_script(self):
|
240 | 239 | self.update_script = updater_script
|
241 | 240 | with open(f"{str(self._flashing_script_dir)}/updater-script", "w") as out:
|
242 | 241 | out.write(updater_script)
|
| 242 | + # Use modified dynamic_partitions_op_list with resize vendor line only |
| 243 | + if self.extract_mode is ProcessTypes.vendor and "dynamic_partitions_op_list" in updater_script: |
| 244 | + original_dynamic_partitions_list = Path(self._tmp_dir / 'dynamic_partitions_op_list').read_text() |
| 245 | + vendor_resize = re.search(r'(resize vendor .*$)', original_dynamic_partitions_list, re.M) |
| 246 | + if vendor_resize: |
| 247 | + with open(f"{str(self._tmp_dir)}/dynamic_partitions_op_list", "w") as out: |
| 248 | + out.write(vendor_resize.group(1)) |
243 | 249 |
|
244 | 250 | # def generate_update_binary(self):
|
245 | 251 | # """
|
|
0 commit comments