Loading core/java/com/android/server/SystemService.java +23 −0 Original line number Diff line number Diff line Loading @@ -49,9 +49,32 @@ public abstract class SystemService { * Boot Phases */ public static final int PHASE_WAIT_FOR_DEFAULT_DISPLAY = 100; // maybe should be a dependency? /** * After receiving this boot phase, services can obtain lock settings data. */ public static final int PHASE_LOCK_SETTINGS_READY = 480; /** * After receiving this boot phase, services can safely call into core system services * such as the PowerManager or PackageManager. */ public static final int PHASE_SYSTEM_SERVICES_READY = 500; /** * After receiving this boot phase, services can broadcast Intents. */ public static final int PHASE_ACTIVITY_MANAGER_READY = 550; /** * After receiving this boot phase, services can start/bind to third party apps. * Apps will be able to make Binder calls into services at this point. */ public static final int PHASE_THIRD_PARTY_APPS_CAN_START = 600; /** * After receiving this boot phase, services must have finished all boot-related work. */ public static final int PHASE_BOOT_COMPLETE = 1000; private final Context mContext; Loading core/java/com/android/server/SystemServiceManager.java +4 −9 Original line number Diff line number Diff line Loading @@ -45,18 +45,13 @@ public class SystemServiceManager { } /** * Starts a service by name if the class exists, otherwise ignores it. * Starts a service by class name. * * @return The service instance, or null if not found. * @return The service instance. */ @SuppressWarnings("unchecked") public SystemService startServiceIfExists(String className) { try { public SystemService startService(String className) throws ClassNotFoundException { return startService((Class<SystemService>) Class.forName(className)); } catch (ClassNotFoundException cnfe) { Slog.i(TAG, className + " not available, ignoring."); return null; } } /** Loading services/Android.mk +27 −8 Original line number Diff line number Diff line Loading @@ -8,13 +8,23 @@ LOCAL_MODULE := services LOCAL_SRC_FILES := $(call all-java-files-under,java) LOCAL_STATIC_JAVA_LIBRARIES := \ services.core \ services.accessibility \ services.appwidget \ services.backup \ services.devicepolicy \ services.print # Uncomment to enable output of certain warnings (deprecated, unchecked) # LOCAL_JAVACFLAGS := -Xlint # Services that will be built as part of services.jar # These should map to directory names relative to this # Android.mk. services := \ core \ accessibility \ appwidget \ backup \ devicepolicy \ print \ usb # The convention is to name each service module 'services.$(module_name)' LOCAL_STATIC_JAVA_LIBRARIES := $(addprefix services.,$(services)) include $(BUILD_JAVA_LIBRARY) Loading @@ -39,7 +49,16 @@ LOCAL_MODULE:= libandroid_servers include $(BUILD_SHARED_LIBRARY) # ============================================================= ifeq (,$(ONE_SHOT_MAKEFILE)) # A full make is happening, so make everything. include $(call all-makefiles-under,$(LOCAL_PATH)) else # If we ran an mm[m] command, we still want to build the individual # services that we depend on. This differs from the above condition # by only including service makefiles and not any tests or other # modules. include $(patsubst %,$(LOCAL_PATH)/%/Android.mk,$(services)) endif services/java/com/android/server/SystemServer.java +141 −135 Original line number Diff line number Diff line Loading @@ -112,6 +112,8 @@ public final class SystemServer { "com.android.server.appwidget.AppWidgetService"; private static final String PRINT_MANAGER_SERVICE_CLASS = "com.android.server.print.PrintManagerService"; private static final String USB_SERVICE_CLASS = "com.android.server.usb.UsbService$Lifecycle"; private final int mFactoryTestMode; private Timer mProfilerSnapshotTimer; Loading Loading @@ -534,8 +536,7 @@ public final class SystemServer { try { if (pm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) { mSystemServiceManager.startServiceIfExists( DEVICE_POLICY_MANAGER_SERVICE_CLASS); mSystemServiceManager.startService(DEVICE_POLICY_MANAGER_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting DevicePolicyService", e); Loading Loading @@ -761,10 +762,11 @@ public final class SystemServer { if (!disableNonCoreServices) { try { Slog.i(TAG, "USB Service"); if (pm.hasSystemFeature(PackageManager.FEATURE_USB_HOST) || pm.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY)) { // Manage USB host and device support usb = new UsbService(context); ServiceManager.addService(Context.USB_SERVICE, usb); mSystemServiceManager.startService(USB_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting UsbService", e); } Loading @@ -786,7 +788,7 @@ public final class SystemServer { if (!disableNonCoreServices) { try { if (pm.hasSystemFeature(PackageManager.FEATURE_BACKUP)) { mSystemServiceManager.startServiceIfExists(BACKUP_MANAGER_SERVICE_CLASS); mSystemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS); } } catch (Throwable e) { Slog.e(TAG, "Failure starting Backup Service", e); Loading @@ -794,7 +796,7 @@ public final class SystemServer { try { if (pm.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS)) { mSystemServiceManager.startServiceIfExists(APPWIDGET_SERVICE_CLASS); mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting AppWidget Service", e); Loading Loading @@ -880,7 +882,7 @@ public final class SystemServer { try { if (pm.hasSystemFeature(PackageManager.FEATURE_PRINTING)) { mSystemServiceManager.startServiceIfExists(PRINT_MANAGER_SERVICE_CLASS); mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting Print Service", e); Loading Loading @@ -972,7 +974,6 @@ public final class SystemServer { } // These are needed to propagate to the runnable below. final Context contextF = context; final MountService mountServiceF = mountService; final BatteryService batteryF = battery; final NetworkManagementService networkManagementF = networkManagement; Loading @@ -980,7 +981,6 @@ public final class SystemServer { final NetworkPolicyManagerService networkPolicyF = networkPolicy; final ConnectivityService connectivityF = connectivity; final DockObserver dockF = dock; final UsbService usbF = usb; final WallpaperManagerService wallpaperF = wallpaper; final InputMethodManagerService immF = imm; final RecognitionManagerService recognitionF = recognition; Loading @@ -1000,9 +1000,17 @@ public final class SystemServer { // where third party code can really run (but before it has actually // started launching the initial applications), for us to complete our // initialization. final Handler handler = new Handler(); mActivityManagerService.systemReady(new Runnable() { @Override public void run() { // We initiate all boot phases on the SystemServer thread. handler.post(new Runnable() { @Override public void run() { Slog.i(TAG, "Making services ready"); mSystemServiceManager.startBootPhase( SystemService.PHASE_ACTIVITY_MANAGER_READY); try { mActivityManagerService.startObservingNativeCrashes(); Loading @@ -1010,7 +1018,7 @@ public final class SystemServer { reportWtf("observing native crashes", e); } try { startSystemUi(contextF); startSystemUi(context); } catch (Throwable e) { reportWtf("starting System UI", e); } Loading Loading @@ -1049,11 +1057,6 @@ public final class SystemServer { } catch (Throwable e) { reportWtf("making Dock Service ready", e); } try { if (usbF != null) usbF.systemReady(); } catch (Throwable e) { reportWtf("making USB Service ready", e); } try { if (recognitionF != null) recognitionF.systemReady(); } catch (Throwable e) { Loading @@ -1063,7 +1066,8 @@ public final class SystemServer { // It is now okay to let the various system services start their // third party code... mSystemServiceManager.startBootPhase(SystemService.PHASE_THIRD_PARTY_APPS_CAN_START); mSystemServiceManager.startBootPhase( SystemService.PHASE_THIRD_PARTY_APPS_CAN_START); try { if (wallpaperF != null) wallpaperF.systemRunning(); Loading Loading @@ -1091,7 +1095,9 @@ public final class SystemServer { reportWtf("Notifying NetworkTimeService running", e); } try { if (commonTimeMgmtServiceF != null) commonTimeMgmtServiceF.systemRunning(); if (commonTimeMgmtServiceF != null) { commonTimeMgmtServiceF.systemRunning(); } } catch (Throwable e) { reportWtf("Notifying CommonTimeManagementService running", e); } Loading @@ -1112,13 +1118,11 @@ public final class SystemServer { } catch (Throwable e) { reportWtf("Notifying InputManagerService running", e); } try { if (telephonyRegistryF != null) telephonyRegistryF.systemRunning(); } catch (Throwable e) { reportWtf("Notifying TelephonyRegistry running", e); } try { if (mediaRouterF != null) mediaRouterF.systemRunning(); } catch (Throwable e) { Loading @@ -1129,6 +1133,8 @@ public final class SystemServer { } }); } }); } static final void startSystemUi(Context context) { Intent intent = new Intent(); Loading services/usb/Android.mk 0 → 100644 +12 −0 Original line number Diff line number Diff line LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := services.usb LOCAL_SRC_FILES += \ $(call all-java-files-under,java) LOCAL_JAVA_LIBRARIES := services.core include $(BUILD_STATIC_JAVA_LIBRARY) Loading
core/java/com/android/server/SystemService.java +23 −0 Original line number Diff line number Diff line Loading @@ -49,9 +49,32 @@ public abstract class SystemService { * Boot Phases */ public static final int PHASE_WAIT_FOR_DEFAULT_DISPLAY = 100; // maybe should be a dependency? /** * After receiving this boot phase, services can obtain lock settings data. */ public static final int PHASE_LOCK_SETTINGS_READY = 480; /** * After receiving this boot phase, services can safely call into core system services * such as the PowerManager or PackageManager. */ public static final int PHASE_SYSTEM_SERVICES_READY = 500; /** * After receiving this boot phase, services can broadcast Intents. */ public static final int PHASE_ACTIVITY_MANAGER_READY = 550; /** * After receiving this boot phase, services can start/bind to third party apps. * Apps will be able to make Binder calls into services at this point. */ public static final int PHASE_THIRD_PARTY_APPS_CAN_START = 600; /** * After receiving this boot phase, services must have finished all boot-related work. */ public static final int PHASE_BOOT_COMPLETE = 1000; private final Context mContext; Loading
core/java/com/android/server/SystemServiceManager.java +4 −9 Original line number Diff line number Diff line Loading @@ -45,18 +45,13 @@ public class SystemServiceManager { } /** * Starts a service by name if the class exists, otherwise ignores it. * Starts a service by class name. * * @return The service instance, or null if not found. * @return The service instance. */ @SuppressWarnings("unchecked") public SystemService startServiceIfExists(String className) { try { public SystemService startService(String className) throws ClassNotFoundException { return startService((Class<SystemService>) Class.forName(className)); } catch (ClassNotFoundException cnfe) { Slog.i(TAG, className + " not available, ignoring."); return null; } } /** Loading
services/Android.mk +27 −8 Original line number Diff line number Diff line Loading @@ -8,13 +8,23 @@ LOCAL_MODULE := services LOCAL_SRC_FILES := $(call all-java-files-under,java) LOCAL_STATIC_JAVA_LIBRARIES := \ services.core \ services.accessibility \ services.appwidget \ services.backup \ services.devicepolicy \ services.print # Uncomment to enable output of certain warnings (deprecated, unchecked) # LOCAL_JAVACFLAGS := -Xlint # Services that will be built as part of services.jar # These should map to directory names relative to this # Android.mk. services := \ core \ accessibility \ appwidget \ backup \ devicepolicy \ print \ usb # The convention is to name each service module 'services.$(module_name)' LOCAL_STATIC_JAVA_LIBRARIES := $(addprefix services.,$(services)) include $(BUILD_JAVA_LIBRARY) Loading @@ -39,7 +49,16 @@ LOCAL_MODULE:= libandroid_servers include $(BUILD_SHARED_LIBRARY) # ============================================================= ifeq (,$(ONE_SHOT_MAKEFILE)) # A full make is happening, so make everything. include $(call all-makefiles-under,$(LOCAL_PATH)) else # If we ran an mm[m] command, we still want to build the individual # services that we depend on. This differs from the above condition # by only including service makefiles and not any tests or other # modules. include $(patsubst %,$(LOCAL_PATH)/%/Android.mk,$(services)) endif
services/java/com/android/server/SystemServer.java +141 −135 Original line number Diff line number Diff line Loading @@ -112,6 +112,8 @@ public final class SystemServer { "com.android.server.appwidget.AppWidgetService"; private static final String PRINT_MANAGER_SERVICE_CLASS = "com.android.server.print.PrintManagerService"; private static final String USB_SERVICE_CLASS = "com.android.server.usb.UsbService$Lifecycle"; private final int mFactoryTestMode; private Timer mProfilerSnapshotTimer; Loading Loading @@ -534,8 +536,7 @@ public final class SystemServer { try { if (pm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) { mSystemServiceManager.startServiceIfExists( DEVICE_POLICY_MANAGER_SERVICE_CLASS); mSystemServiceManager.startService(DEVICE_POLICY_MANAGER_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting DevicePolicyService", e); Loading Loading @@ -761,10 +762,11 @@ public final class SystemServer { if (!disableNonCoreServices) { try { Slog.i(TAG, "USB Service"); if (pm.hasSystemFeature(PackageManager.FEATURE_USB_HOST) || pm.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY)) { // Manage USB host and device support usb = new UsbService(context); ServiceManager.addService(Context.USB_SERVICE, usb); mSystemServiceManager.startService(USB_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting UsbService", e); } Loading @@ -786,7 +788,7 @@ public final class SystemServer { if (!disableNonCoreServices) { try { if (pm.hasSystemFeature(PackageManager.FEATURE_BACKUP)) { mSystemServiceManager.startServiceIfExists(BACKUP_MANAGER_SERVICE_CLASS); mSystemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS); } } catch (Throwable e) { Slog.e(TAG, "Failure starting Backup Service", e); Loading @@ -794,7 +796,7 @@ public final class SystemServer { try { if (pm.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS)) { mSystemServiceManager.startServiceIfExists(APPWIDGET_SERVICE_CLASS); mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting AppWidget Service", e); Loading Loading @@ -880,7 +882,7 @@ public final class SystemServer { try { if (pm.hasSystemFeature(PackageManager.FEATURE_PRINTING)) { mSystemServiceManager.startServiceIfExists(PRINT_MANAGER_SERVICE_CLASS); mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS); } } catch (Throwable e) { reportWtf("starting Print Service", e); Loading Loading @@ -972,7 +974,6 @@ public final class SystemServer { } // These are needed to propagate to the runnable below. final Context contextF = context; final MountService mountServiceF = mountService; final BatteryService batteryF = battery; final NetworkManagementService networkManagementF = networkManagement; Loading @@ -980,7 +981,6 @@ public final class SystemServer { final NetworkPolicyManagerService networkPolicyF = networkPolicy; final ConnectivityService connectivityF = connectivity; final DockObserver dockF = dock; final UsbService usbF = usb; final WallpaperManagerService wallpaperF = wallpaper; final InputMethodManagerService immF = imm; final RecognitionManagerService recognitionF = recognition; Loading @@ -1000,9 +1000,17 @@ public final class SystemServer { // where third party code can really run (but before it has actually // started launching the initial applications), for us to complete our // initialization. final Handler handler = new Handler(); mActivityManagerService.systemReady(new Runnable() { @Override public void run() { // We initiate all boot phases on the SystemServer thread. handler.post(new Runnable() { @Override public void run() { Slog.i(TAG, "Making services ready"); mSystemServiceManager.startBootPhase( SystemService.PHASE_ACTIVITY_MANAGER_READY); try { mActivityManagerService.startObservingNativeCrashes(); Loading @@ -1010,7 +1018,7 @@ public final class SystemServer { reportWtf("observing native crashes", e); } try { startSystemUi(contextF); startSystemUi(context); } catch (Throwable e) { reportWtf("starting System UI", e); } Loading Loading @@ -1049,11 +1057,6 @@ public final class SystemServer { } catch (Throwable e) { reportWtf("making Dock Service ready", e); } try { if (usbF != null) usbF.systemReady(); } catch (Throwable e) { reportWtf("making USB Service ready", e); } try { if (recognitionF != null) recognitionF.systemReady(); } catch (Throwable e) { Loading @@ -1063,7 +1066,8 @@ public final class SystemServer { // It is now okay to let the various system services start their // third party code... mSystemServiceManager.startBootPhase(SystemService.PHASE_THIRD_PARTY_APPS_CAN_START); mSystemServiceManager.startBootPhase( SystemService.PHASE_THIRD_PARTY_APPS_CAN_START); try { if (wallpaperF != null) wallpaperF.systemRunning(); Loading Loading @@ -1091,7 +1095,9 @@ public final class SystemServer { reportWtf("Notifying NetworkTimeService running", e); } try { if (commonTimeMgmtServiceF != null) commonTimeMgmtServiceF.systemRunning(); if (commonTimeMgmtServiceF != null) { commonTimeMgmtServiceF.systemRunning(); } } catch (Throwable e) { reportWtf("Notifying CommonTimeManagementService running", e); } Loading @@ -1112,13 +1118,11 @@ public final class SystemServer { } catch (Throwable e) { reportWtf("Notifying InputManagerService running", e); } try { if (telephonyRegistryF != null) telephonyRegistryF.systemRunning(); } catch (Throwable e) { reportWtf("Notifying TelephonyRegistry running", e); } try { if (mediaRouterF != null) mediaRouterF.systemRunning(); } catch (Throwable e) { Loading @@ -1129,6 +1133,8 @@ public final class SystemServer { } }); } }); } static final void startSystemUi(Context context) { Intent intent = new Intent(); Loading
services/usb/Android.mk 0 → 100644 +12 −0 Original line number Diff line number Diff line LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := services.usb LOCAL_SRC_FILES += \ $(call all-java-files-under,java) LOCAL_JAVA_LIBRARIES := services.core include $(BUILD_STATIC_JAVA_LIBRARY)