feat: Fill missing 9patch lines to fix recompile

Somehow Google manages to compile MiuiSystemUI.apk (and a few other APKs I encountered) with a misformed pip_dismiss_scrim.9.png.
Either way, every time I encountered such 9.patch images, the missing lines always indicated a single full div or padding.
Apktool already fills missing padding lines, now it can also fill missing divs.
This commit is contained in:
IgorEisberg 2019-02-10 14:01:26 +02:00 committed by Connor Tumbleson
parent 0efccc2d93
commit 1e68bb0ede
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -65,13 +65,21 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
drawVLine(im2, w + 1, np.padTop + 1, h - np.padBottom);
int[] xDivs = np.xDivs;
for (int i = 0; i < xDivs.length; i += 2) {
drawHLine(im2, 0, xDivs[i] + 1, xDivs[i + 1]);
if (xDivs.length == 0) {
drawHLine(im2, 0, 1, w);
} else {
for (int i = 0; i < xDivs.length; i += 2) {
drawHLine(im2, 0, xDivs[i] + 1, xDivs[i + 1]);
}
}
int[] yDivs = np.yDivs;
for (int i = 0; i < yDivs.length; i += 2) {
drawVLine(im2, 0, yDivs[i] + 1, yDivs[i + 1]);
if (yDivs.length == 0) {
drawVLine(im2, 0, 1, h);
} else {
for (int i = 0; i < yDivs.length; i += 2) {
drawVLine(im2, 0, yDivs[i] + 1, yDivs[i + 1]);
}
}
// Some images additionally use Optical Bounds