mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-05 17:45:52 +01:00
aapt2: add test to confirm pkgId of 0x80
This commit is contained in:
parent
722870e6b9
commit
a693f316e0
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Copyright (C) 2017 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2017 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
|
||||
*
|
||||
* http://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.aapt2;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.res.data.ResTable;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NonStandardPkgIdTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTmpDir.deleteOnExit();
|
||||
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "pkgid8-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "pkgid8-new");
|
||||
LOGGER.info("Unpacking pkgid8...");
|
||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "brut/apktool/aapt2/pkgid8/", sTestOrigDir);
|
||||
|
||||
ApkOptions apkOptions = new ApkOptions();
|
||||
apkOptions.useAapt2 = true;
|
||||
apkOptions.verbose = true;
|
||||
|
||||
LOGGER.info("Building pkgid8.apk...");
|
||||
File testApk = new File(sTmpDir, "pkgid8.apk");
|
||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
||||
|
||||
LOGGER.info("Decoding pkgid8.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
mResTable = apkDecoder.getResTable();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesStringsTest() throws BrutException {
|
||||
compareValuesFiles("values/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmManifestStructureTest() throws BrutException {
|
||||
compareXmlFiles("AndroidManifest.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmResourcesAreFromPkgId8() throws AndrolibException {
|
||||
assertEquals(0x80, mResTable.getPackageId());
|
||||
|
||||
assertEquals(0x80, mResTable.getResSpec(0x80020000).getPackage().getId());
|
||||
assertEquals(0x80, mResTable.getResSpec(0x80020001).getPackage().getId());
|
||||
assertEquals(0x80, mResTable.getResSpec(0x80030000).getPackage().getId());
|
||||
}
|
||||
|
||||
private static ResTable mResTable;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="brut.apktool.aapt2.pkgid8"
|
||||
featureName="feature">
|
||||
</manifest>
|
@ -0,0 +1,12 @@
|
||||
version: 2.0.0
|
||||
apkFileName: pkgid8.apk
|
||||
isFrameworkApk: false
|
||||
usesFramework:
|
||||
ids:
|
||||
- 1
|
||||
packageInfo:
|
||||
forcedPackageId: '128'
|
||||
versionInfo:
|
||||
versionCode: '1'
|
||||
versionName: '1.0'
|
||||
compressionType: false
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<integer name="foo3">117</integer>
|
||||
</resources>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<public type="string" name="foo1" id="0x80020000" />
|
||||
<public type="string" name="foo2" id="0x80020001" />
|
||||
<public type="integer" name="foo3" id="0x80030000" />
|
||||
</resources>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="foo1">foo</string>
|
||||
<string name="foo2">bar</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user