28
28
import com .google .classyshark .silverghost .translator .apk .ApkTranslator ;
29
29
import com .google .classyshark .silverghost .translator .dex .DexMethodsDumper ;
30
30
import com .google .classyshark .silverghost .translator .dex .DexStringsDumper ;
31
-
32
31
import java .io .File ;
33
32
import java .io .PrintWriter ;
34
33
import java .util .LinkedList ;
35
34
import java .util .List ;
36
35
37
36
/**
38
- * Basic API class with small independent scenarios
37
+ * Basic API class with small independent scenarios
39
38
*/
40
39
public class SilverGhostFacade {
41
40
private SilverGhostFacade () {
@@ -127,7 +126,7 @@ public static void inspectPackages(List<String> args) {
127
126
MethodCountExporter methodCountExporter =
128
127
new TreeMethodCountExporter (new PrintWriter (System .out ));
129
128
if (args .size () > 2 ) {
130
- for (int i = 2 ; i < args .size (); i ++ ) {
129
+ for (int i = 2 ; i < args .size (); i ++) {
131
130
if (args .get (i ).equals ("-flat" )) {
132
131
methodCountExporter = new FlatMethodCountExporter (new PrintWriter (System .out ));
133
132
}
@@ -155,7 +154,8 @@ public static void exportArchive(List<String> args) {
155
154
}
156
155
}
157
156
158
- /** returns true if the apk is multidex
157
+ /**
158
+ * returns true if the apk is multidex
159
159
*
160
160
* @param archiveFile
161
161
* @return
@@ -167,16 +167,47 @@ public static boolean isMultiDex(File archiveFile) {
167
167
List <String > allClassNames = contentReader .getAllClassNames ();
168
168
int numDexes = 0 ;
169
169
170
- for (String classEntry : allClassNames ) {
171
- if (classEntry .endsWith (".dex" )) {
170
+ for (String classEntry : allClassNames ) {
171
+ if (classEntry .endsWith (".dex" )) {
172
172
numDexes ++;
173
173
// 2 dexes or more + optimization
174
- if (numDexes == 2 ) {
174
+ if (numDexes == 2 ) {
175
175
return true ;
176
176
}
177
177
}
178
178
}
179
179
180
180
return false ;
181
181
}
182
+
183
+ /**
184
+ * returns true if the apk is custom dex loading multidex
185
+ *
186
+ * @param archiveFile
187
+ * @return
188
+ */
189
+ public static boolean isCustomMultiDex (File archiveFile ) {
190
+ if (!isMultiDex (archiveFile )) {
191
+ return false ;
192
+ }
193
+
194
+ ContentReader contentReader = new ContentReader (archiveFile );
195
+ contentReader .load ();
196
+
197
+ List <String > allClassNames = contentReader .getAllClassNames ();
198
+ List <String > allDexNames = new LinkedList <>();
199
+
200
+ for (String classEntry : allClassNames ) {
201
+ if (classEntry .endsWith (".dex" )) {
202
+ allDexNames .add (classEntry );
203
+ }
204
+ }
205
+
206
+ for (String classEntry : allDexNames ) {
207
+ if (!classEntry .startsWith ("classes" )) {
208
+ return true ;
209
+ }
210
+ }
211
+ return false ;
212
+ }
182
213
}
0 commit comments