Skip to content

Commit 08767b2

Browse files
committed
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.
1 parent 013b3c1 commit 08767b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+558
-676
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ApkInfo.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,10 @@ public boolean hasResources() throws AndrolibException {
109109

110110
public String checkTargetSdkVersionBounds() {
111111
int target = mapSdkShorthandToVersion(getTargetSdkVersion());
112+
int min = getMinSdkVersion() != null ? mapSdkShorthandToVersion(getMinSdkVersion()) : 0;
113+
int max = getMaxSdkVersion() != null ? mapSdkShorthandToVersion(getMaxSdkVersion()) : target;
112114

113-
int min = (getMinSdkVersion() != null) ? mapSdkShorthandToVersion(getMinSdkVersion()) : 0;
114-
int max = (getMaxSdkVersion() != null) ? mapSdkShorthandToVersion(getMaxSdkVersion()) : target;
115-
116-
target = Math.min(max, target);
117-
target = Math.max(min, target);
118-
return Integer.toString(target);
115+
return Integer.toString(Math.max(min, Math.min(max, target)));
119116
}
120117

121118
public String getMinSdkVersion() {

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/Framework.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void install(File frameFile, String tag) throws AndrolibException {
6363
publicizeResources(data, arsc.getFlagsOffsets());
6464

6565
File outFile = new File(getDirectory(),
66-
arsc.getOnePackage().getId() + (tag == null ? "" : '-' + tag) + ".apk");
66+
arsc.getOnePackage().getId() + (tag != null ? "-" + tag : "") + ".apk");
6767

6868
try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(outFile.toPath()))) {
6969
out.setMethod(ZipOutputStream.STORED);

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/ResourcesDecoder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,14 @@ private void generatePublicXml(ResPackage pkg, Directory resDir, XmlSerializer s
239239
serial.startDocument(null, null);
240240
serial.startTag(null, "resources");
241241

242-
for (ResResSpec spec : pkg.listResSpecs()) {
242+
List<ResResSpec> specs = pkg.listResSpecs();
243+
specs.sort(Comparator.comparing(ResResSpec::getId));
244+
245+
for (ResResSpec spec : specs) {
243246
serial.startTag(null, "public");
244247
serial.attribute(null, "type", spec.getType().getName());
245248
serial.attribute(null, "name", spec.getName());
246-
serial.attribute(null, "id", String.format("0x%08x", spec.getId().id));
249+
serial.attribute(null, "id", spec.getId().toString());
247250
serial.endTag(null, "public");
248251
}
249252

0 commit comments

Comments
 (0)