diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-02-11 08:33:50 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-02-11 08:33:50 +0000 |
commit | cab8617b8ccea3a99b1ee15e15915c512a10c738 (patch) | |
tree | 48d07ae2e7f69eadd4e7cd8c7d20c4ea6b37bda1 /services | |
parent | 33fa09b1ffe8d14d146de4b2632103d831ff8988 (diff) | |
parent | 25df673b849de374cf1de40250dfd8a48b7ac28b (diff) | |
download | frameworks_base-cab8617b8ccea3a99b1ee15e15915c512a10c738.zip frameworks_base-cab8617b8ccea3a99b1ee15e15915c512a10c738.tar.gz frameworks_base-cab8617b8ccea3a99b1ee15e15915c512a10c738.tar.bz2 |
am 25df673b: am 1b51c9cb: Merge "Make SystemService constructor take a Context." into klp-modular-dev
* commit '25df673b849de374cf1de40250dfd8a48b7ac28b':
Make SystemService constructor take a Context.
Diffstat (limited to 'services')
17 files changed, 100 insertions, 129 deletions
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java index 3378e3d..e208677 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<AppWidgetServiceImpl> mAppWidgetServices; + final SparseArray<AppWidgetServiceImpl> 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 1e7c18a..7aff444 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -277,6 +277,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 db2c94a..0000000 --- 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 eb347bb..5d86b38 100644 --- a/services/core/java/com/android/server/AlarmManagerService.java +++ b/services/core/java/com/android/server/AlarmManagerService.java @@ -334,6 +334,10 @@ class AlarmManagerService extends SystemService { static final BatchTimeOrder sBatchOrder = new BatchTimeOrder(); final ArrayList<Batch> mAlarmBatches = new ArrayList<Batch>(); + 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 de912dc..ad693d0 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 c73ca1a..7b2fc50 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1881,11 +1881,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 d5ee838..6be6405 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,7 +208,9 @@ 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(); @@ -216,11 +218,6 @@ public final class DisplayManagerService extends SystemService { } @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 3d22370..94cf668 100644 --- a/services/core/java/com/android/server/lights/LightsService.java +++ b/services/core/java/com/android/server/lights/LightsService.java @@ -157,8 +157,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++) { @@ -183,6 +184,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 e4ea033..01175bb 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 e2ff146..6185e50 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 b9ecde1..b2344e68 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"); @@ -391,11 +393,6 @@ public final class PowerManagerService extends com.android.server.SystemService } @Override - public void onCreate(Context context) { - mContext = context; - } - - @Override public void onStart() { publishBinderService(Context.POWER_SERVICE, new BinderService()); publishLocalService(PowerManagerInternal.class, new LocalService()); diff --git a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java index 8805084..43a99e0 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 8feb97b..a71961c 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 5a964ad..bb96544 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 android.app.Activity; import android.app.ActivityManagerNative; @@ -138,6 +139,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 160aa39..0000000 --- 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 9bc2201..85e5e23 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -104,9 +104,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 = @@ -209,6 +209,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 7438297..f7bec6e 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); |