Commit f6d568b
authored
refactor: Config/Tests/misc rework (#3746)
* refactor: Config/Tests/misc rework
Config is now propagated to ResValue instead of being a globally
accessible instance that gets set each time a new Config is instantiated.
The old way violted every principle of an instance and even a singleton.
This caused working with Tests extremely error-prone, because the Config
had to be carefully reset to default for each Test to get the expected
behavior, and ResValue was only aware of the global instance.
Now, only Main and BaseTest are calling new Config().
BaseTest provides a fresh Config for every Test which turns the boilerplate
into something shorter, predictable and more robust.
Config class is now encapsulated to give control over the values passed
to it. Having both publically-modifyable fields and setters with the
verfications was more of a dirty hack than proper coding principles.
General-purpose XML utilities extracted from ResXmlUtils into XmlUtils
in the brut.xml library. It contains Document creation, parsing and saving.
In addition, it has a generic evaluateXPath method that's now used more
widely wherever manual looping over nodes was used, like in some tests.
ResXmlUtils reworked and cleaned, now takes advantage of XmlUtils.
ResXmlUtils only retains methods relevant specifically to resource XMLs
and Android Manifest.
Minor tweaks and code cleanup in various classed like ApktoolProperties
and the main work classes (Framework, ApkDecoder, ApkBuilder, etc.),
as well as utility classes like AaptInvoker and OS.
Fixed locks being held by certain ExtFiles to zips with loaded Directory,
which prevented proper temp file cleanup during Test stage.
ExternalEntityTest resources ("doctype") moved to aapt1 as it's an
aapt1-only test.
Overall, mainly a code refactor with no end-user changes,
to make development less prone to errors.
* fix framework parent check
* make sure frameworkDirectory is never null
* make sure frameworkDirectory is never null
* style
* retrieve Config only in ResBagValue and misc tweaks
We actually don't need to pass Config explicitly to all ResValue subtypes.
It's only needed by 3 subtypes of ResBagValue, so we get the Config
via ResBagValue's mParent.getPackage().getConfig().
Encapsulate ResConfigFlags.
Encapsulate ResID and make it a numeric and comparable type.
Sort resource specs by resource ID in generatePublicXml.
Duo is redundant, replace with Apache Common's Pair.
ResIdValue is redundant, it's never actually instantiated.
Tweak equals and hashCode overrides to standard formats.
Misc style and variable name tweaks.
* redundant explicit toString calls
* Objects.hash is safer1 parent 70a99d2 commit f6d568b
File tree
115 files changed
+2664
-3233
lines changed- brut.apktool
- apktool-cli/src/main/java/brut/apktool
- apktool-lib/src
- main/java
- android/util
- brut/androlib
- apk
- res
- data
- value
- decoder
- xml
- src
- test
- java/brut/androlib
- aapt1
- aapt2
- apk
- decode
- encoders
- res
- decoder
- src
- util
- resources/aapt1/doctype
- brut.j.dir/src/main/java/brut/directory
- brut.j.util/src/main/java/brut/util
- brut.j.xml/src/main/java/brut
- xmlpull
- xml
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
115 files changed
+2664
-3233
lines changedLines changed: 38 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | | - | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
76 | | - | |
77 | | - | |
| 74 | + | |
| 75 | + | |
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
| |||
96 | 94 | | |
97 | 95 | | |
98 | 96 | | |
99 | | - | |
| 97 | + | |
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
| |||
145 | 143 | | |
146 | 144 | | |
147 | 145 | | |
148 | | - | |
| 146 | + | |
149 | 147 | | |
150 | 148 | | |
151 | | - | |
| 149 | + | |
152 | 150 | | |
153 | 151 | | |
154 | | - | |
| 152 | + | |
155 | 153 | | |
156 | 154 | | |
157 | | - | |
| 155 | + | |
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
| |||
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
169 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
176 | | - | |
| 178 | + | |
177 | 179 | | |
178 | 180 | | |
179 | | - | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
191 | | - | |
| 193 | + | |
192 | 194 | | |
193 | 195 | | |
194 | | - | |
| 196 | + | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| |||
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
269 | | - | |
| 271 | + | |
270 | 272 | | |
271 | 273 | | |
272 | | - | |
| 274 | + | |
273 | 275 | | |
274 | 276 | | |
275 | | - | |
| 277 | + | |
276 | 278 | | |
277 | 279 | | |
278 | | - | |
| 280 | + | |
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
| |||
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
287 | | - | |
288 | | - | |
| 289 | + | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | | - | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | | - | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | | - | |
| 309 | + | |
309 | 310 | | |
310 | 311 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 312 | + | |
319 | 313 | | |
320 | 314 | | |
321 | 315 | | |
322 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
323 | 320 | | |
324 | 321 | | |
325 | 322 | | |
326 | 323 | | |
327 | 324 | | |
328 | 325 | | |
329 | 326 | | |
330 | | - | |
| 327 | + | |
331 | 328 | | |
332 | 329 | | |
333 | 330 | | |
334 | | - | |
| 331 | + | |
335 | 332 | | |
336 | 333 | | |
337 | 334 | | |
| |||
341 | 338 | | |
342 | 339 | | |
343 | 340 | | |
344 | | - | |
| 341 | + | |
345 | 342 | | |
346 | | - | |
| 343 | + | |
347 | 344 | | |
348 | 345 | | |
349 | 346 | | |
| |||
638 | 635 | | |
639 | 636 | | |
640 | 637 | | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
646 | 643 | | |
647 | 644 | | |
648 | 645 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
0 commit comments