2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import java.util.Arrays;
18 import java.util.HashSet;
22 * Policy that governs which classes are preloaded.
27 * No constructor - use static methods only
32 * This location (in the build system) of the preloaded-classes file.
34 static final String PRELOADED_CLASS_FILE
35 = "frameworks/base/preloaded-classes";
38 * Long running services. These are restricted in their contribution to the
39 * preloader because their launch time is less critical.
41 // TODO: Generate this automatically from package manager.
42 private static final Set<String> SERVICES = new HashSet<String>(Arrays.asList(
44 "com.google.process.content",
45 "android.process.media",
46 "com.android.bluetooth",
47 "com.android.calendar",
48 "com.android.inputmethod.latin",
50 "com.google.android.apps.maps.FriendService", // pre froyo
51 "com.google.android.apps.maps:FriendService", // froyo
52 "com.google.android.apps.maps.LocationFriendService",
53 "com.google.android.deskclock",
54 "com.google.process.gapps",
59 * Classes which we shouldn't load from the Zygote.
61 private static final Set<String> EXCLUDED_CLASSES
62 = new HashSet<String>(Arrays.asList(
64 "android.app.AlarmManager",
65 "android.app.SearchManager",
66 "android.os.FileObserver",
67 "com.android.server.PackageManagerService$AppDirObserver",
70 "android.os.AsyncTask",
71 "android.pim.ContactsAsyncHelper",
72 "android.webkit.WebViewClassic$1",
73 "java.lang.ProcessManager"
77 * Returns true if the given process name is a "long running" process or
80 public static boolean isService(String processName) {
81 return SERVICES.contains(processName);
84 /** Reports if the given class should be preloaded. */
85 public static boolean isPreloadable(LoadedClass clazz) {
86 return clazz.systemClass && !EXCLUDED_CLASSES.contains(clazz.name)
87 && !clazz.name.endsWith("$NoPreloadHolder");