@@ -63,6 +63,7 @@ private ARSCDecoder(InputStream arscStream, ResTable resTable, boolean storeFlag
63
63
64
64
private ResPackage [] readResourceTable () throws IOException , AndrolibException {
65
65
Set <ResPackage > pkgs = new LinkedHashSet <>();
66
+
66
67
ResTypeSpec typeSpec ;
67
68
68
69
chunkLoop :
@@ -112,10 +113,6 @@ private ResPackage[] readResourceTable() throws IOException, AndrolibException {
112
113
}
113
114
}
114
115
115
- if (mPkg != null && mPkg .getResSpecCount () > 0 ) {
116
- addMissingResSpecs ();
117
- }
118
-
119
116
return pkgs .toArray (new ResPackage [0 ]);
120
117
}
121
118
@@ -245,7 +242,7 @@ private ResTypeSpec readTableSpecType() throws AndrolibException, IOException {
245
242
mHeader .checkForUnreadHeader (mIn );
246
243
247
244
mIn .skipBytes (entryCount * 4 ); // flags
248
- mTypeSpec = new ResTypeSpec (mTypeNames .getString (id - 1 ), mResTable , mPkg , id , entryCount );
245
+ mTypeSpec = new ResTypeSpec (mTypeNames .getString (id - 1 ), id );
249
246
mPkg .addType (mTypeSpec );
250
247
251
248
return mTypeSpec ;
@@ -264,7 +261,6 @@ private ResType readTableType() throws IOException, AndrolibException {
264
261
int entryCount = mIn .readInt ();
265
262
mIn .skipInt (); // entriesStart
266
263
267
- mMissingResSpecMap = new LinkedHashMap <>();
268
264
ResConfigFlags flags = readConfigFlags ();
269
265
270
266
mHeader .checkForUnreadHeader (mIn );
@@ -297,12 +293,11 @@ private ResType readTableType() throws IOException, AndrolibException {
297
293
mType = flags .isInvalid && !mKeepBroken ? null : mPkg .getOrCreateConfig (flags );
298
294
299
295
for (int i : entryOffsetMap .keySet ()) {
296
+ mResId = (mResId & 0xffff0000 ) | i ;
300
297
int offset = entryOffsetMap .get (i );
301
298
if (offset == NO_ENTRY ) {
302
299
continue ;
303
300
}
304
- mMissingResSpecMap .put (i , false );
305
- mResId = (mResId & 0xffff0000 ) | i ;
306
301
307
302
// As seen in some recent APKs - there are more entries reported than can fit in the chunk.
308
303
if (mIn .position () == mHeader .endPosition ) {
@@ -369,14 +364,6 @@ private void readEntry(EntryData entryData) throws AndrolibException {
369
364
ResResSpec spec ;
370
365
if (mPkg .hasResSpec (resId )) {
371
366
spec = mPkg .getResSpec (resId );
372
-
373
- if (spec .isDummyResSpec ()) {
374
- removeResSpec (spec );
375
-
376
- spec = new ResResSpec (resId , mSpecNames .getString (specNamesId ), mPkg , mTypeSpec );
377
- mPkg .addResSpec (spec );
378
- mTypeSpec .addResSpec (spec );
379
- }
380
367
} else {
381
368
spec = new ResResSpec (resId , mSpecNames .getString (specNamesId ), mPkg , mTypeSpec );
382
369
mPkg .addResSpec (spec );
@@ -598,41 +585,6 @@ private void addTypeSpec(ResTypeSpec resTypeSpec) {
598
585
mResTypeSpecs .put (resTypeSpec .getId (), resTypeSpec );
599
586
}
600
587
601
- private void addMissingResSpecs () throws AndrolibException {
602
- int resId = mResId & 0xffff0000 ;
603
-
604
- for (int i : mMissingResSpecMap .keySet ()) {
605
- if (mMissingResSpecMap .get (i )) continue ;
606
-
607
- ResResSpec spec = new ResResSpec (new ResID (resId | i ), "APKTOOL_DUMMY_" + Integer .toHexString (i ), mPkg , mTypeSpec );
608
-
609
- // If we already have this resID don't add it again.
610
- if (! mPkg .hasResSpec (new ResID (resId | i ))) {
611
- mPkg .addResSpec (spec );
612
- mTypeSpec .addResSpec (spec );
613
-
614
- if (mType == null ) {
615
- mType = mPkg .getOrCreateConfig (new ResConfigFlags ());
616
- }
617
-
618
- // We are going to make dummy attributes a null reference (@null) now instead of a boolean false.
619
- // This is because aapt2 is much more strict when it comes to what we can put in an application.
620
- ResValue value = new ResReferenceValue (mPkg , 0 , "" );
621
-
622
- ResResource res = new ResResource (mType , spec , value );
623
- mType .addResource (res );
624
- spec .addResource (res );
625
- }
626
- }
627
- }
628
-
629
- private void removeResSpec (ResResSpec spec ) {
630
- if (mPkg .hasResSpec (spec .getId ())) {
631
- mPkg .removeResSpec (spec );
632
- mTypeSpec .removeResSpec (spec );
633
- }
634
- }
635
-
636
588
private ARSCHeader nextChunk () throws IOException {
637
589
return mHeader = ARSCHeader .read (mIn );
638
590
}
@@ -658,7 +610,6 @@ private void checkChunkType(int expectedType) throws AndrolibException {
658
610
private ResType mType ;
659
611
private int mResId ;
660
612
private int mTypeIdOffset = 0 ;
661
- private HashMap <Integer , Boolean > mMissingResSpecMap ;
662
613
private final HashMap <Integer , ResTypeSpec > mResTypeSpecs = new HashMap <>();
663
614
664
615
private final static short ENTRY_FLAG_COMPLEX = 0x0001 ;
0 commit comments