From b880d880c6cd989eacc28c365fc9a41d31900da1 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Mon, 10 Feb 2014 19:47:07 -0800 Subject: Make SystemService constructor take a Context. This change simplifies the process of initializing a SystemService by folding the onCreate() step back into the constructor. It removes some ambuiguity about what work should happen in the constructor and should make it possible for services to retain most of their final fields after refactoring into the new pattern. Change-Id: I25f41af0321bc01898658ab44b369f9c5d16800b --- core/java/com/android/server/SystemService.java | 59 +++++++++------ .../com/android/server/SystemServiceManager.java | 86 ++++++++++------------ .../android/server/appwidget/AppWidgetService.java | 10 +-- .../server/backup/BackupManagerService.java | 14 ++++ .../server/backup/BackupManagerSystemService.java | 36 --------- .../com/android/server/AlarmManagerService.java | 4 + .../com/android/server/UiModeManagerService.java | 4 + .../android/server/am/ActivityManagerService.java | 8 +- .../server/display/DisplayManagerService.java | 11 +-- .../com/android/server/lights/LightsService.java | 6 +- .../notification/NotificationManagerService.java | 4 + .../core/java/com/android/server/pm/Installer.java | 5 ++ .../android/server/power/PowerManagerService.java | 11 +-- .../storage/DeviceStorageMonitorService.java | 32 ++++---- .../android/server/twilight/TwilightService.java | 4 + .../devicepolicy/DevicePolicyManagerService.java | 21 ++++++ .../DevicePolicyManagerSystemService.java | 46 ------------ services/java/com/android/server/SystemServer.java | 5 +- .../android/server/print/PrintManagerService.java | 8 +- 19 files changed, 177 insertions(+), 197 deletions(-) delete mode 100644 services/backup/java/com/android/server/backup/BackupManagerSystemService.java delete mode 100644 services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerSystemService.java diff --git a/core/java/com/android/server/SystemService.java b/core/java/com/android/server/SystemService.java index d69293ac6ac0..0c89f9482615 100644 --- a/core/java/com/android/server/SystemService.java +++ b/core/java/com/android/server/SystemService.java @@ -23,24 +23,24 @@ import android.os.ServiceManager; /** * The base class for services running in the system process. Override and implement * the lifecycle event callback methods as needed. - * + *

* The lifecycle of a SystemService: - * - * {@link #onCreate(android.content.Context)} is called to initialize the - * service. - * - * {@link #onStart()} is called to get the service running. It is common - * for services to publish their Binder interface at this point. All required - * dependencies are also assumed to be ready to use. - * - * Then {@link #onBootPhase(int)} is called as many times as there are boot phases + *

+ * NOTE: All lifecycle methods are called from the system server's main looper thread. + *

* * {@hide} */ @@ -54,17 +54,34 @@ public abstract class SystemService { public static final int PHASE_THIRD_PARTY_APPS_CAN_START = 600; public static final int PHASE_BOOT_COMPLETE = 1000; - private SystemServiceManager mManager; - private Context mContext; + private final Context mContext; - final void init(Context context, SystemServiceManager manager) { + /** + * Initializes the system service. + *

+ * Subclasses must define a single argument constructor that accepts the context + * and passes it to super. + *

+ * + * @param context The system server context. + */ + public SystemService(Context context) { mContext = context; - mManager = manager; - onCreate(context); } + /** + * Gets the system context. + */ + public final Context getContext() { + return mContext; + } + + /** + * Returns true if the system is running in safe mode. + * TODO: we should define in which phase this becomes valid + */ public final boolean isSafeMode() { - return mManager.isSafeMode(); + return getManager().isSafeMode(); } /** @@ -126,8 +143,8 @@ public abstract class SystemService { return LocalServices.getService(type); } - public final Context getContext() { - return mContext; + private SystemServiceManager getManager() { + return LocalServices.getService(SystemServiceManager.class); } // /** diff --git a/core/java/com/android/server/SystemServiceManager.java b/core/java/com/android/server/SystemServiceManager.java index 06ad7f4c1e40..6c853be81cdd 100644 --- a/core/java/com/android/server/SystemServiceManager.java +++ b/core/java/com/android/server/SystemServiceManager.java @@ -17,14 +17,15 @@ package com.android.server; import android.content.Context; -import android.util.Log; import android.util.Slog; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; /** * Manages creating, starting, and other lifecycle events of - * {@link com.android.server.SystemService}s. + * {@link com.android.server.SystemService system services}. * * {@hide} */ @@ -68,24 +69,43 @@ public class SystemServiceManager { */ @SuppressWarnings("unchecked") public T startService(Class serviceClass) { - final T serviceInstance = (T)createInstance(serviceClass); + final String name = serviceClass.getName(); + Slog.i(TAG, "Starting " + name); + + // Create the service. + if (!SystemService.class.isAssignableFrom(serviceClass)) { + throw new RuntimeException("Failed to create " + name + + ": service must extend " + SystemService.class.getName()); + } + final T service; try { - Slog.i(TAG, "Creating " + serviceClass.getSimpleName()); - serviceInstance.init(mContext, this); - } catch (Throwable e) { - throw new RuntimeException("Failed to create service " + serviceClass.getName(), e); + Constructor constructor = serviceClass.getConstructor(Context.class); + service = constructor.newInstance(mContext); + } catch (InstantiationException ex) { + throw new RuntimeException("Failed to create service " + name + + ": service could not be instantiated", ex); + } catch (IllegalAccessException ex) { + throw new RuntimeException("Failed to create service " + name + + ": service must have a public constructor with a Context argument", ex); + } catch (NoSuchMethodException ex) { + throw new RuntimeException("Failed to create service " + name + + ": service must have a public constructor with a Context argument", ex); + } catch (InvocationTargetException ex) { + throw new RuntimeException("Failed to create service " + name + + ": service constructor threw an exception", ex); } - mServices.add(serviceInstance); + // Register it. + mServices.add(service); + // Start it. try { - Slog.i(TAG, "Starting " + serviceClass.getSimpleName()); - serviceInstance.onStart(); - } catch (Throwable e) { - throw new RuntimeException("Failed to start service " + serviceClass.getName(), e); + service.onStart(); + } catch (RuntimeException ex) { + throw new RuntimeException("Failed to start service " + name + + ": onStart threw an exception", ex); } - - return serviceInstance; + return service; } /** @@ -107,9 +127,11 @@ public class SystemServiceManager { final SystemService service = mServices.get(i); try { service.onBootPhase(mCurrentPhase); - } catch (Throwable e) { - reportWtf("Service " + service.getClass().getName() + - " threw an Exception processing boot phase " + mCurrentPhase, e); + } catch (Exception ex) { + throw new RuntimeException("Failed to boot service " + + service.getClass().getName() + + ": onBootPhase threw an exception during phase " + + mCurrentPhase, ex); } } } @@ -144,34 +166,4 @@ public class SystemServiceManager { Slog.e(TAG, builder.toString()); } - - private SystemService createInstance(Class clazz) { - // Make sure it's a type we expect - if (!SystemService.class.isAssignableFrom(clazz)) { - reportWtf("Class " + clazz.getName() + " does not extend " + - SystemService.class.getName()); - } - - try { - return (SystemService) clazz.newInstance(); - } catch (InstantiationException e) { - reportWtf("Class " + clazz.getName() + " is abstract", e); - } catch (IllegalAccessException e) { - reportWtf("Class " + clazz.getName() + - " must have a public no-arg constructor", e); - } - return null; - } - - private static void reportWtf(String message) { - reportWtf(message, null); - } - - private static void reportWtf(String message, Throwable e) { - Slog.i(TAG, "******************************"); - Log.wtf(TAG, message, e); - - // Make sure we die - throw new RuntimeException(message, e); - } } diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java index 3378e3da00a1..e20867762daa 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java @@ -53,13 +53,13 @@ public class AppWidgetService extends SystemService { static final String TAG = "AppWidgetService"; - Context mContext; - Handler mSaveStateHandler; + final Context mContext; + final Handler mSaveStateHandler; - SparseArray mAppWidgetServices; + final SparseArray mAppWidgetServices; - @Override - public void onCreate(Context context) { + public AppWidgetService(Context context) { + super(context); mContext = context; mSaveStateHandler = BackgroundThread.getHandler(); diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index c6dc5e63b7b4..ca2f7b1c46e6 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -274,6 +274,20 @@ public class BackupManagerService extends IBackupManager.Stub { // Watch the device provisioning operation during setup ContentObserver mProvisionedObserver; + public static final class Lifecycle extends SystemService { + private final BackupManagerService mService; + + public Lifecycle(Context context) { + super(context); + mService = new BackupManagerService(context); + } + + @Override + public void onStart() { + publishBinderService(Context.BACKUP_SERVICE, mService); + } + } + class ProvisionedObserver extends ContentObserver { public ProvisionedObserver(Handler handler) { super(handler); diff --git a/services/backup/java/com/android/server/backup/BackupManagerSystemService.java b/services/backup/java/com/android/server/backup/BackupManagerSystemService.java deleted file mode 100644 index db2c94a9c2c4..000000000000 --- a/services/backup/java/com/android/server/backup/BackupManagerSystemService.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.backup; - -import android.content.Context; - -import com.android.server.SystemService; - -public class BackupManagerSystemService extends SystemService { - private BackupManagerService mBackupManagerImpl; - - @Override - public void onCreate(Context context) { - mBackupManagerImpl = new BackupManagerService(context); - } - - @Override - public void onStart() { - publishBinderService(Context.BACKUP_SERVICE, mBackupManagerImpl); - } -} - diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java index 3cdf170494d4..96063d577526 100644 --- a/services/core/java/com/android/server/AlarmManagerService.java +++ b/services/core/java/com/android/server/AlarmManagerService.java @@ -319,6 +319,10 @@ class AlarmManagerService extends SystemService { static final BatchTimeOrder sBatchOrder = new BatchTimeOrder(); final ArrayList mAlarmBatches = new ArrayList(); + public AlarmManagerService(Context context) { + super(context); + } + static long convertToElapsed(long when, int type) { final boolean isRtc = (type == RTC || type == RTC_WAKEUP); if (isRtc) { diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index de912dcc1332..ad693d00248d 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -88,6 +88,10 @@ final class UiModeManagerService extends SystemService { private PowerManager.WakeLock mWakeLock; + public UiModeManagerService(Context context) { + super(context); + } + private static Intent buildHomeIntent(String category) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(category); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 74e18c002d00..46891f5920a4 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1866,11 +1866,11 @@ public final class ActivityManagerService extends ActivityManagerNative } } - public static class Lifecycle extends SystemService { - private ActivityManagerService mService; + public static final class Lifecycle extends SystemService { + private final ActivityManagerService mService; - @Override - public void onCreate(Context context) { + public Lifecycle(Context context) { + super(context); mService = new ActivityManagerService(context); } diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java index d5ee83869eb2..6be6405daa4d 100644 --- a/services/core/java/com/android/server/display/DisplayManagerService.java +++ b/services/core/java/com/android/server/display/DisplayManagerService.java @@ -124,7 +124,7 @@ public final class DisplayManagerService extends SystemService { private static final int DISPLAY_BLANK_STATE_BLANKED = 1; private static final int DISPLAY_BLANK_STATE_UNBLANKED = 2; - private Context mContext; + private final Context mContext; private final DisplayManagerHandler mHandler; private final Handler mUiHandler; private final DisplayAdapterListener mDisplayAdapterListener; @@ -208,18 +208,15 @@ public final class DisplayManagerService extends SystemService { private final DisplayViewport mTempDefaultViewport = new DisplayViewport(); private final DisplayViewport mTempExternalTouchViewport = new DisplayViewport(); - public DisplayManagerService() { + public DisplayManagerService(Context context) { + super(context); + mContext = context; mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper()); mUiHandler = UiThread.getHandler(); mDisplayAdapterListener = new DisplayAdapterListener(); mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false); } - @Override - public void onCreate(Context context) { - mContext = context; - } - @Override public void onStart() { mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER); diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java index 62dc0901bb45..62c0ec9a2ce0 100644 --- a/services/core/java/com/android/server/lights/LightsService.java +++ b/services/core/java/com/android/server/lights/LightsService.java @@ -156,8 +156,9 @@ public class LightsService extends SystemService { } }; - @Override - public void onCreate(Context context) { + public LightsService(Context context) { + super(context); + mNativePointer = init_native(); for (int i = 0; i < LightsManager.LIGHT_ID_COUNT; i++) { @@ -182,6 +183,7 @@ public class LightsService extends SystemService { } }; + @Override protected void finalize() throws Throwable { finalize_native(mNativePointer); super.finalize(); diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index db4cf31d7dad..6ee89891a84b 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1118,6 +1118,10 @@ public class NotificationManagerService extends SystemService { return out; } + public NotificationManagerService(Context context) { + super(context); + } + @Override public void onStart() { mAm = ActivityManagerNative.getDefault(); diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java index e2ff146afcfb..6185e5010466 100644 --- a/services/core/java/com/android/server/pm/Installer.java +++ b/services/core/java/com/android/server/pm/Installer.java @@ -18,6 +18,7 @@ package com.android.server.pm; import com.android.server.SystemService; +import android.content.Context; import android.content.pm.PackageStats; import android.net.LocalSocket; import android.net.LocalSocketAddress; @@ -39,6 +40,10 @@ public final class Installer extends SystemService { byte buf[] = new byte[1024]; int buflen = 0; + public Installer(Context context) { + super(context); + } + @Override public void onStart() { Slog.i(TAG, "Waiting for installd to be ready."); diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 94876bb651c2..9606baa8d1f5 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -168,7 +168,7 @@ public final class PowerManagerService extends com.android.server.SystemService // effectively and terminate the dream. private static final int DREAM_BATTERY_LEVEL_DRAIN_CUTOFF = 5; - private Context mContext; + private final Context mContext; private LightsManager mLightsManager; private BatteryService mBatteryService; private DisplayManagerInternal mDisplayManagerInternal; @@ -374,7 +374,9 @@ public final class PowerManagerService extends com.android.server.SystemService private static native void nativeSetInteractive(boolean enable); private static native void nativeSetAutoSuspend(boolean enable); - public PowerManagerService() { + public PowerManagerService(Context context) { + super(context); + mContext = context; synchronized (mLock) { mWakeLockSuspendBlocker = createSuspendBlockerLocked("PowerManagerService.WakeLocks"); mDisplaySuspendBlocker = createSuspendBlockerLocked("PowerManagerService.Display"); @@ -390,11 +392,6 @@ public final class PowerManagerService extends com.android.server.SystemService nativeSetPowerState(true, true); } - @Override - public void onCreate(Context context) { - mContext = context; - } - @Override public void onStart() { publishBinderService(Context.POWER_SERVICE, new BinderService()); diff --git a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java index 88050841698f..43a99e082295 100644 --- a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java +++ b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java @@ -89,11 +89,11 @@ public class DeviceStorageMonitorService extends SystemService { private long mLastReportedFreeMemTime; boolean mLowMemFlag=false; private boolean mMemFullFlag=false; - private ContentResolver mResolver; - private long mTotalMemory; // on /data - private StatFs mDataFileStats; - private StatFs mSystemFileStats; - private StatFs mCacheFileStats; + private final ContentResolver mResolver; + private final long mTotalMemory; // on /data + private final StatFs mDataFileStats; + private final StatFs mSystemFileStats; + private final StatFs mCacheFileStats; private static final File DATA_PATH = Environment.getDataDirectory(); private static final File SYSTEM_PATH = Environment.getRootDirectory(); @@ -102,10 +102,10 @@ public class DeviceStorageMonitorService extends SystemService { private long mThreadStartTime = -1; boolean mClearSucceeded = false; boolean mClearingCache; - private Intent mStorageLowIntent; - private Intent mStorageOkIntent; - private Intent mStorageFullIntent; - private Intent mStorageNotFullIntent; + private final Intent mStorageLowIntent; + private final Intent mStorageOkIntent; + private final Intent mStorageFullIntent; + private final Intent mStorageNotFullIntent; private CachePackageDataObserver mClearCacheObserver; private CacheFileDeletedObserver mCacheFileDeletedObserver; private static final int _TRUE = 1; @@ -134,7 +134,7 @@ public class DeviceStorageMonitorService extends SystemService { * Handler that checks the amount of disk space on the device and sends a * notification if the device runs low on disk space */ - private Handler mHandler = new Handler() { + private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { //don't handle an invalid message @@ -310,12 +310,8 @@ public class DeviceStorageMonitorService extends SystemService { delay); } - /** - * Constructor to run service. initializes the disk space threshold value - * and posts an empty message to kickstart the process. - */ - @Override - public void onCreate(Context context) { + public DeviceStorageMonitorService(Context context) { + super(context); mLastReportedFreeMemTime = 0; mResolver = context.getContentResolver(); //create StatFs object @@ -335,6 +331,10 @@ public class DeviceStorageMonitorService extends SystemService { mStorageNotFullIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); } + /** + * Initializes the disk space threshold value and posts an empty message to + * kickstart the process. + */ @Override public void onStart() { // cache storage thresholds diff --git a/services/core/java/com/android/server/twilight/TwilightService.java b/services/core/java/com/android/server/twilight/TwilightService.java index 8feb97b36f46..a71961c8fe9b 100644 --- a/services/core/java/com/android/server/twilight/TwilightService.java +++ b/services/core/java/com/android/server/twilight/TwilightService.java @@ -65,6 +65,10 @@ public final class TwilightService extends SystemService { TwilightState mTwilightState; + public TwilightService(Context context) { + super(context); + } + @Override public void onStart() { mAlarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index af362467aa84..296d852248d1 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -25,6 +25,7 @@ import com.android.internal.util.JournaledFile; import com.android.internal.util.XmlUtils; import com.android.internal.widget.LockPatternUtils; import com.android.org.conscrypt.TrustedCertificateStore; +import com.android.server.SystemService; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -149,6 +150,26 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { */ private boolean mHasFeature; + public static final class Lifecycle extends SystemService { + private DevicePolicyManagerService mService; + + public Lifecycle(Context context) { + super(context); + mService = new DevicePolicyManagerService(context); + } + + @Override + public void onStart() { + publishBinderService(Context.DEVICE_POLICY_SERVICE, mService); + } + + @Override + public void onBootPhase(int phase) { + if (phase == PHASE_LOCK_SETTINGS_READY) { + mService.systemReady(); + } + } + } public static class DevicePolicyData { int mActivePasswordQuality = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; int mActivePasswordLength = 0; diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerSystemService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerSystemService.java deleted file mode 100644 index 160aa3954d7f..000000000000 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerSystemService.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.devicepolicy; - -import android.content.Context; - -import com.android.server.SystemService; - -/** - * SystemService wrapper for the DevicePolicyManager implementation. Publishes - * Context.DEVICE_POLICY_SERVICE. - */ -public final class DevicePolicyManagerSystemService extends SystemService { - private DevicePolicyManagerService mDevicePolicyManagerImpl; - - @Override - public void onCreate(Context context) { - mDevicePolicyManagerImpl = new DevicePolicyManagerService(context); - } - - @Override - public void onStart() { - publishBinderService(Context.DEVICE_POLICY_SERVICE, mDevicePolicyManagerImpl); - } - - @Override - public void onBootPhase(int phase) { - if (phase == PHASE_LOCK_SETTINGS_READY) { - mDevicePolicyManagerImpl.systemReady(); - } - } -} \ No newline at end of file diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 269c056f088e..f941ffeb502a 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -106,9 +106,9 @@ public final class SystemServer { * them from the build system somehow. */ private static final String BACKUP_MANAGER_SERVICE_CLASS = - "com.android.server.backup.BackupManagerSystemService"; + "com.android.server.backup.BackupManagerService$Lifecycle"; private static final String DEVICE_POLICY_MANAGER_SERVICE_CLASS = - "com.android.server.devicepolicy.DevicePolicyManagerSystemService"; + "com.android.server.devicepolicy.DevicePolicyManagerService$Lifecycle"; private static final String APPWIDGET_SERVICE_CLASS = "com.android.server.appwidget.AppWidgetService"; private static final String PRINT_MANAGER_SERVICE_CLASS = @@ -211,6 +211,7 @@ public final class SystemServer { // Create the system service manager. mSystemServiceManager = new SystemServiceManager(mSystemContext); + LocalServices.addService(SystemServiceManager.class, mSystemServiceManager); // Start services. try { diff --git a/services/print/java/com/android/server/print/PrintManagerService.java b/services/print/java/com/android/server/print/PrintManagerService.java index 1e35678f3753..c6fdbe5c90c8 100644 --- a/services/print/java/com/android/server/print/PrintManagerService.java +++ b/services/print/java/com/android/server/print/PrintManagerService.java @@ -66,13 +66,13 @@ import java.util.Set; */ public final class PrintManagerService extends SystemService { + private final PrintManagerImpl mPrintManagerImpl; - private PrintManagerImpl mPrintManagerImpl; - - @Override - public void onCreate(Context context) { + public PrintManagerService(Context context) { + super(context); mPrintManagerImpl = new PrintManagerImpl(context); } + @Override public void onStart() { publishBinderService(Context.PRINT_SERVICE, mPrintManagerImpl); -- cgit v1.2.3-59-g8ed1b