| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.preload.check; |
| 18 |
|
| 19 |
import dalvik.system.DexFile; |
| 20 |
|
| 21 |
import java.util.Collection; |
| 22 |
import java.util.Enumeration; |
| 23 |
import java.util.regex.Matcher; |
| 24 |
import java.util.regex.Pattern; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class NotInitializedRegex { |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public static void main(String[] args) throws Exception { |
| 36 |
Matcher m = Pattern.compile(args[0]).matcher(""); |
| 37 |
boolean requiresMatch = args.length > 1 ? Boolean.parseBoolean(args[1]) : false; |
| 38 |
|
| 39 |
Collection<DexFile> dexFiles = Util.getBootDexFiles(); |
| 40 |
int matched = 0, notMatched = 0; |
| 41 |
for (DexFile dexFile : dexFiles) { |
| 42 |
Enumeration<String> entries = dexFile.entries(); |
| 43 |
while (entries.hasMoreElements()) { |
| 44 |
String entry = entries.nextElement(); |
| 45 |
m.reset(entry); |
| 46 |
if (m.matches()) { |
| 47 |
System.out.println(entry + ": match"); |
| 48 |
matched++; |
| 49 |
check(entry); |
| 50 |
} else { |
| 51 |
System.out.println(entry + ": no match"); |
| 52 |
notMatched++; |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
System.out.println("Matched: " + matched + " Not-Matched: " + notMatched); |
| 57 |
if (requiresMatch && matched == 0) { |
| 58 |
throw new RuntimeException("Did not find match"); |
| 59 |
} |
| 60 |
System.out.println("OK"); |
| 61 |
} |
| 62 |
|
| 63 |
private static void check(String name) { |
| 64 |
Util.assertNotInitialized(name, null); |
| 65 |
} |
| 66 |
} |