summaryrefslogtreecommitdiff
path: root/tools/preload/Policy.java
diff options
context:
space:
mode:
Diffstat (limited to 'tools/preload/Policy.java')
-rw-r--r--tools/preload/Policy.java89
1 files changed, 29 insertions, 60 deletions
diff --git a/tools/preload/Policy.java b/tools/preload/Policy.java
index 554966b88731..7a190ac273d4 100644
--- a/tools/preload/Policy.java
+++ b/tools/preload/Policy.java
@@ -19,52 +19,43 @@ import java.util.HashSet;
import java.util.Set;
/**
- * This is not instantiated - we just provide data for other classes to use
+ * Policy that governs which classes are preloaded.
*/
public class Policy {
-
- /**
- * This location (in the build system) of the preloaded-classes file.
- */
- private static final String PRELOADED_CLASS_FILE = "frameworks/base/preloaded-classes";
-
+
/**
- * The internal process name of the system process. Note, this also shows up as
- * "system_process", e.g. in ddms.
+ * No constructor - use static methods only
*/
- private static final String SYSTEM_SERVER_PROCESS_NAME = "system_server";
+ private Policy() {}
- /**
- * Names of non-application processes - these will not be checked for preloaded classes.
- *
- * TODO: Replace this hardcoded list with a walk up the parent chain looking for zygote.
+ /**
+ * This location (in the build system) of the preloaded-classes file.
*/
- private static final Set<String> NOT_FROM_ZYGOTE = new HashSet<String>(Arrays.asList(
- "zygote",
- "dexopt",
- "unknown",
- SYSTEM_SERVER_PROCESS_NAME,
- "com.android.development",
- "app_process" // am & other shell commands
- ));
+ static final String PRELOADED_CLASS_FILE
+ = "frameworks/base/preloaded-classes";
- /**
- * Long running services. These are restricted in their contribution to the preloader
- * because their launch time is less critical.
+ /**
+ * Long running services. These are restricted in their contribution to the
+ * preloader because their launch time is less critical.
*/
+ // TODO: Generate this automatically from package manager.
private static final Set<String> SERVICES = new HashSet<String>(Arrays.asList(
- SYSTEM_SERVER_PROCESS_NAME,
- "com.android.acore",
- // Commented out to make sure DefaultTimeZones gets preloaded.
- // "com.android.phone",
- "com.google.process.content",
- "android.process.media"
+ "system_server",
+ "com.google.process.content",
+ "android.process.media",
+ "com.android.phone",
+ "com.google.android.apps.maps.FriendService",
+ "com.google.android.apps.maps.LocationFriendService",
+ "com.google.android.googleapps",
+ "com.google.process.gapps",
+ "android.tts"
));
/**
* Classes which we shouldn't load from the Zygote.
*/
- private static final Set<String> EXCLUDED_CLASSES = new HashSet<String>(Arrays.asList(
+ private static final Set<String> EXCLUDED_CLASSES
+ = new HashSet<String>(Arrays.asList(
// Binders
"android.app.AlarmManager",
"android.app.SearchManager",
@@ -75,40 +66,18 @@ public class Policy {
"android.os.AsyncTask",
"android.pim.ContactsAsyncHelper",
"java.lang.ProcessManager"
-
));
/**
- * No constructor - use static methods only
- */
- private Policy() {}
-
- /**
- * Returns the path/file name of the preloaded classes file that will be written
- * by WritePreloadedClassFile.
- */
- public static String getPreloadedClassFileName() {
- return PRELOADED_CLASS_FILE;
- }
-
- /**
- * Reports if a given process name was created from zygote
- */
- public static boolean isFromZygote(String processName) {
- return !NOT_FROM_ZYGOTE.contains(processName);
- }
-
- /**
- * Reports if the given process name is a "long running" process or service
+ * Returns true if the given process name is a "long running" process or
+ * service.
*/
public static boolean isService(String processName) {
return SERVICES.contains(processName);
}
-
- /**
- * Reports if the given class should never be preloaded
- */
- public static boolean isPreloadableClass(String className) {
- return !EXCLUDED_CLASSES.contains(className);
+
+ /**Reports if the given class should be preloaded. */
+ public static boolean isPreloadable(LoadedClass clazz) {
+ return clazz.systemClass && !EXCLUDED_CLASSES.contains(clazz.name);
}
}