-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regressions towards apktool.yml generation (#3172)
* fix: prevent blowing out minSdkVersion * fix: correct naming regression with apk name and sdk info * chore: comment for why we double up minSdkVersion * fix: deprecate compressionType * test: assert apktool format isn't regressed
- Loading branch information
1 parent
ab40693
commit ca07a0a
Showing
4 changed files
with
112 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
brut.apktool/apktool-lib/src/test/java/brut/androlib/yaml/ConsistentPropertyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com> | ||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package brut.androlib.yaml; | ||
|
||
import brut.androlib.BaseTest; | ||
import brut.androlib.TestUtils; | ||
import brut.androlib.apk.ApkInfo; | ||
import brut.common.BrutException; | ||
import brut.directory.ExtFile; | ||
import brut.util.OS; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import java.io.File; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ConsistentPropertyTest extends BaseTest { | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
TestUtils.cleanFrameworkFile(); | ||
|
||
sTmpDir = new ExtFile(OS.createTempDirectory()); | ||
sTestNewDir = new ExtFile(sTmpDir, "yaml"); | ||
LOGGER.info("Unpacking yaml files..."); | ||
TestUtils.copyResourceDir(ConsistentPropertyTest.class, "decode/yaml/", sTestNewDir); | ||
} | ||
|
||
@Test | ||
public void testAssertingAllKnownApkInfoProperties() throws BrutException { | ||
ApkInfo apkInfo = ApkInfo.load(new File(sTestNewDir, "basic")); | ||
|
||
assertEquals("2.8.0", apkInfo.version); | ||
assertEquals("basic.apk", apkInfo.getApkFileName()); | ||
assertFalse(apkInfo.isFrameworkApk); | ||
assertEquals(1, apkInfo.usesFramework.ids.size()); | ||
assertEquals("tag", apkInfo.usesFramework.tag); | ||
assertEquals("4", apkInfo.getMinSdkVersion()); | ||
assertEquals("22", apkInfo.getTargetSdkVersion()); | ||
assertEquals("30", apkInfo.getMaxSdkVersion()); | ||
assertEquals("127", apkInfo.packageInfo.forcedPackageId); | ||
assertEquals("com.test.basic", apkInfo.packageInfo.renameManifestPackage); | ||
assertEquals("71", apkInfo.versionInfo.versionCode); | ||
assertEquals("1.0.70", apkInfo.versionInfo.versionName); | ||
assertFalse(apkInfo.resourcesAreCompressed); | ||
assertFalse(apkInfo.sharedLibrary); | ||
assertTrue(apkInfo.sparseResources); | ||
assertEquals(1, apkInfo.unknownFiles.size()); | ||
assertEquals(2, apkInfo.doNotCompress.size()); | ||
assertFalse(apkInfo.compressionType); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
brut.apktool/apktool-lib/src/test/resources/decode/yaml/basic/apktool.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
!!brut.androlib.meta.MetaInfo | ||
apkFileName: basic.apk | ||
compressionType: false | ||
doNotCompress: | ||
- resources.arsc | ||
- png | ||
isFrameworkApk: false | ||
packageInfo: | ||
forcedPackageId: '127' | ||
renameManifestPackage: 'com.test.basic' | ||
sdkInfo: | ||
minSdkVersion: '4' | ||
maxSdkVersion: '30' | ||
targetSdkVersion: '22' | ||
sharedLibrary: false | ||
sparseResources: true | ||
unknownFiles: | ||
hidden.file: 1 | ||
usesFramework: | ||
ids: | ||
- 1 | ||
tag: 'tag' | ||
version: 2.8.0 | ||
versionInfo: | ||
versionCode: '71' | ||
versionName: 1.0.70 |