|
12 | 12 | import com.reandroid.arsc.chunk.xml.ResXmlAttribute; |
13 | 13 | import com.reandroid.arsc.chunk.xml.ResXmlDocument; |
14 | 14 | import com.reandroid.arsc.chunk.xml.ResXmlElement; |
| 15 | +import com.reandroid.arsc.coder.CoderDimension; |
15 | 16 | import com.reandroid.arsc.coder.EncodeResult; |
16 | 17 | import com.reandroid.arsc.coder.ValueCoder; |
17 | 18 | import com.reandroid.arsc.io.BlockReader; |
|
40 | 41 |
|
41 | 42 | @FixMethodOrder(MethodSorters.NAME_ASCENDING) |
42 | 43 | public class ApkModuleTest { |
| 44 | + |
| 45 | + public static final boolean TEST_WITH_MULTI_LAYOUT_DEX_V041 = true; |
| 46 | + |
43 | 47 | private static ApkModule last_apkModule; |
44 | 48 | @Test |
45 | 49 | public void a_testApkModule() throws IOException { |
@@ -91,7 +95,10 @@ public ApkModule createApkModule() throws IOException { |
91 | 95 | String appClass = manifestBlock.getApplicationClassName(); |
92 | 96 | String mainActivity = manifestBlock.getMainActivityClassName(); |
93 | 97 |
|
94 | | - DexFile dexFile = SampleDexFileCreator.createApplicationClass(appClass, mainActivity, mainActivityLayoutId); |
| 98 | + DexFile dexFile = SampleDexFileCreator.createApplicationClass( |
| 99 | + TEST_WITH_MULTI_LAYOUT_DEX_V041, |
| 100 | + appClass, mainActivity, mainActivityLayoutId); |
| 101 | + |
95 | 102 | byte[] bytes = dexFile.getBytes(); |
96 | 103 | apkModule.add(new ByteInputSource(bytes, "classes.dex")); |
97 | 104 | apkModule.getUncompressedFiles().addPath(apkModule.getZipEntryMap()); |
@@ -120,6 +127,9 @@ private int createMainActivityContentViewXml(ApkModule apkModule){ |
120 | 127 | attribute = root.getOrCreateAndroidAttribute("orientation", 0x010100c4); |
121 | 128 | attribute.setTypeAndData(ValueType.DEC, 1); // vertical |
122 | 129 |
|
| 130 | + attribute = root.getOrCreateAndroidAttribute("padding", 0x010100d5); |
| 131 | + attribute.setValue(CoderDimension.INS.encode("20.0dp")); |
| 132 | + |
123 | 133 | ResXmlElement textView = root.newElement("TextView"); |
124 | 134 | attribute = textView.getOrCreateAndroidAttribute("layout_width", 0x010100f4); |
125 | 135 | attribute.setTypeAndData(ValueType.DEC, -1); // wrap_content |
@@ -462,13 +472,17 @@ private AndroidManifestBlock createManifest() throws IOException { |
462 | 472 |
|
463 | 473 | manifestBlock.setCompileSdkVersion(frameworkApk.getVersionCode()); |
464 | 474 | manifestBlock.setCompileSdkVersionCodename(frameworkApk.getVersionName()); |
465 | | - manifestBlock.setCompileSdk(AndroidApiLevel.O); |
| 475 | + AndroidApiLevel apiLevel = AndroidApiLevel.O; |
| 476 | + if (TEST_WITH_MULTI_LAYOUT_DEX_V041) { |
| 477 | + apiLevel = AndroidApiLevel.VANILLA_ICE_CREAM; |
| 478 | + } |
| 479 | + manifestBlock.setCompileSdk(apiLevel); |
466 | 480 |
|
467 | 481 | manifestBlock.setPlatformBuildVersionCode(frameworkApk.getVersionCode()); |
468 | 482 | manifestBlock.setPlatformBuildVersionName(frameworkApk.getVersionName()); |
469 | | - manifestBlock.setPlatformBuild(AndroidApiLevel.O); |
470 | | - manifestBlock.setMinSdkVersion(AndroidApiLevel.O.getApi()); |
471 | | - manifestBlock.setTargetSdkVersion(AndroidApiLevel.O.getApi()); |
| 483 | + manifestBlock.setPlatformBuild(apiLevel); |
| 484 | + manifestBlock.setMinSdkVersion(apiLevel.getApi()); |
| 485 | + manifestBlock.setTargetSdkVersion(apiLevel.getApi()); |
472 | 486 |
|
473 | 487 | manifestBlock.addUsesPermission("android.permission.INTERNET"); |
474 | 488 | manifestBlock.addUsesPermission("android.permission.READ_EXTERNAL_STORAGE"); |
|
0 commit comments