blob: 49ed63dd4c589b531aef576c5dda4fa6fecc5dd6 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package com.android.server;
18
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019import android.app.ActivityManagerNative;
Jeff Brown6f357d32014-01-15 20:40:55 -080020import android.app.ActivityThread;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -080021import android.app.IAlarmManager;
22import android.app.INotificationManager;
Nick Pellyf242b7b2009-10-08 00:12:45 +020023import android.bluetooth.BluetoothAdapter;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040024import android.content.ComponentName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.content.ContentResolver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.content.Context;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040027import android.content.Intent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.content.pm.IPackageManager;
Matthew Xie1dd01eb32013-04-26 12:37:54 -070029import android.content.pm.PackageManager;
Joe Onoratodc565f42010-10-04 15:27:22 -040030import android.content.res.Configuration;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.media.AudioService;
Jeff Sharkey48749fc2013-04-19 13:25:04 -070032import android.os.Environment;
Jeff Brown6f357d32014-01-15 20:40:55 -080033import android.os.FactoryTest;
Jeff Brownbd6e1502012-08-28 03:27:37 -070034import android.os.Handler;
Amith Yamasani817ec492013-12-20 13:27:30 -080035import android.os.IBinder;
Jeff Brown6f357d32014-01-15 20:40:55 -080036import android.os.IPowerManager;
Jeff Hamilton35eef702010-06-09 15:45:18 -050037import android.os.Looper;
38import android.os.RemoteException;
39import android.os.ServiceManager;
Brad Fitzpatrickc74a1b442010-09-10 16:03:29 -070040import android.os.StrictMode;
Jeff Hamilton35eef702010-06-09 15:45:18 -050041import android.os.SystemClock;
42import android.os.SystemProperties;
Amith Yamasanicd757062012-10-19 18:23:52 -070043import android.os.UserHandle;
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -070044import android.service.dreams.DreamService;
Joe Onoratodc565f42010-10-04 15:27:22 -040045import android.util.DisplayMetrics;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046import android.util.EventLog;
Dianne Hackborn661cd522011-08-22 00:26:20 -070047import android.util.Log;
Joe Onorato8a9b2202010-02-26 18:56:32 -080048import android.util.Slog;
Brad Fitzpatrick5fdc0c72010-10-12 13:12:18 -070049import android.view.WindowManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050
Dan Morrille4d9a012013-03-28 18:10:43 -070051import com.android.internal.R;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070052import com.android.internal.os.BinderInternal;
53import com.android.internal.os.SamplingProfilerIntegration;
Jeff Sharkey7a96c392012-11-15 14:01:46 -080054import com.android.server.accounts.AccountManagerService;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070055import com.android.server.am.ActivityManagerService;
Jeff Brown96307042012-07-27 15:51:34 -070056import com.android.server.am.BatteryStatsService;
Amith Yamasani30f8eb42013-11-06 14:54:50 -080057import com.android.server.clipboard.ClipboardService;
Jeff Sharkey7a96c392012-11-15 14:01:46 -080058import com.android.server.content.ContentService;
Jeff Brownfa25bf52012-07-23 19:26:30 -070059import com.android.server.display.DisplayManagerService;
Jeff Browncef440f2012-09-25 18:58:48 -070060import com.android.server.dreams.DreamManagerService;
Jeff Brown6ec6f792012-04-17 16:52:41 -070061import com.android.server.input.InputManagerService;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -080062import com.android.server.lights.LightsManager;
63import com.android.server.lights.LightsService;
Jeff Brown69b07162013-11-07 00:30:16 -080064import com.android.server.media.MediaRouterService;
RoboErik01fe6612014-02-13 14:19:04 -080065import com.android.server.media.MediaSessionService;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070066import com.android.server.net.NetworkPolicyManagerService;
Jeff Sharkey75279902011-05-24 18:39:45 -070067import com.android.server.net.NetworkStatsService;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -080068import com.android.server.notification.NotificationManagerService;
Jeff Sharkey7a96c392012-11-15 14:01:46 -080069import com.android.server.os.SchedulingPolicyService;
Jeff Brownf69c8122012-09-12 17:00:34 -070070import com.android.server.pm.Installer;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070071import com.android.server.pm.PackageManagerService;
Amith Yamasani258848d2012-08-10 17:06:33 -070072import com.android.server.pm.UserManagerService;
Jeff Brown4f8ecd82012-06-18 18:29:13 -070073import com.android.server.power.PowerManagerService;
74import com.android.server.power.ShutdownThread;
Jeff Sharkey7a96c392012-11-15 14:01:46 -080075import com.android.server.search.SearchManagerService;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -080076import com.android.server.statusbar.StatusBarManagerService;
77import com.android.server.storage.DeviceStorageMonitorService;
78import com.android.server.twilight.TwilightManager;
79import com.android.server.twilight.TwilightService;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070080import com.android.server.usb.UsbService;
Amith Yamasani30f8eb42013-11-06 14:54:50 -080081import com.android.server.wallpaper.WallpaperManagerService;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070082import com.android.server.wm.WindowManagerService;
83
84import dalvik.system.VMRuntime;
85import dalvik.system.Zygote;
86
Dan Egnor4410ec82009-09-11 16:40:01 -070087import java.io.File;
Bob Leee5408332009-09-04 18:31:17 -070088import java.util.Timer;
89import java.util.TimerTask;
90
Jeff Brown6f357d32014-01-15 20:40:55 -080091public final class SystemServer {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 private static final String TAG = "SystemServer";
Jeff Brown6f357d32014-01-15 20:40:55 -080093
Ben Komalo553acf02011-09-19 14:25:28 -070094 private static final String ENCRYPTING_STATE = "trigger_restart_min_framework";
Ben Komalo3573d402011-09-23 15:08:24 -070095 private static final String ENCRYPTED_STATE = "1";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096
Jeff Brown6f357d32014-01-15 20:40:55 -080097 private static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr
98
99 // The earliest supported time. We pick one day into 1970, to
100 // give any timezone code room without going into negative time.
101 private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102
Amith Yamasani817ec492013-12-20 13:27:30 -0800103 /*
104 * Implementation class names. TODO: Move them to a codegen class or load
105 * them from the build system somehow.
106 */
107 private static final String BACKUP_MANAGER_SERVICE_CLASS =
Jeff Brownb880d882014-02-10 19:47:07 -0800108 "com.android.server.backup.BackupManagerService$Lifecycle";
Amith Yamasani817ec492013-12-20 13:27:30 -0800109 private static final String DEVICE_POLICY_MANAGER_SERVICE_CLASS =
Jeff Brownb880d882014-02-10 19:47:07 -0800110 "com.android.server.devicepolicy.DevicePolicyManagerService$Lifecycle";
Amith Yamasani817ec492013-12-20 13:27:30 -0800111 private static final String APPWIDGET_SERVICE_CLASS =
112 "com.android.server.appwidget.AppWidgetService";
113 private static final String PRINT_MANAGER_SERVICE_CLASS =
114 "com.android.server.print.PrintManagerService";
115
Jeff Brown6f357d32014-01-15 20:40:55 -0800116 private final int mFactoryTestMode;
117 private Timer mProfilerSnapshotTimer;
118
119 private Context mSystemContext;
120 private SystemServiceManager mSystemServiceManager;
121
Jeff Brown4ccb8232014-01-16 22:16:42 -0800122 // TODO: remove all of these references by improving dependency resolution and boot phases
123 private Installer mInstaller;
124 private PowerManagerService mPowerManagerService;
125 private ActivityManagerService mActivityManagerService;
126 private DisplayManagerService mDisplayManagerService;
Jeff Brown6f357d32014-01-15 20:40:55 -0800127 private ContentResolver mContentResolver;
128
129 /**
130 * Called to initialize native system services.
131 */
132 private static native void nativeInit();
133
134 /**
135 * The main entry point from zygote.
136 */
137 public static void main(String[] args) {
138 new SystemServer().run();
139 }
140
141 public SystemServer() {
142 mFactoryTestMode = FactoryTest.getMode();
143 }
144
145 private void run() {
146 // If a device's clock is before 1970 (before 0), a lot of
147 // APIs crash dealing with negative numbers, notably
148 // java.io.File#setLastModified, so instead we fake it and
149 // hope that time from cell towers or NTP fixes it shortly.
150 if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
151 Slog.w(TAG, "System clock is before 1970; setting to 1970.");
152 SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
153 }
154
155 // Here we go!
156 Slog.i(TAG, "Entered the Android system server!");
157 EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, SystemClock.uptimeMillis());
158
159 // In case the runtime switched since last boot (such as when
160 // the old runtime was removed in an OTA), set the system
161 // property so that it is in sync. We can't do this in
162 // libnativehelper's JniInvocation::Init code where we already
163 // had to fallback to a different runtime because it is
164 // running as root and we need to be the system user to set
165 // the property. http://b/11463182
Brian Carlstromfdb98d42014-01-30 13:14:01 -0800166 SystemProperties.set("persist.sys.dalvik.vm.lib.1", VMRuntime.getRuntime().vmLibrary());
Jeff Brown6f357d32014-01-15 20:40:55 -0800167
168 // Enable the sampling profiler.
169 if (SamplingProfilerIntegration.isEnabled()) {
170 SamplingProfilerIntegration.start();
171 mProfilerSnapshotTimer = new Timer();
172 mProfilerSnapshotTimer.schedule(new TimerTask() {
173 @Override
174 public void run() {
175 SamplingProfilerIntegration.writeSnapshot("system_server", null);
176 }
177 }, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL);
178 }
179
180 // Mmmmmm... more memory!
181 VMRuntime.getRuntime().clearGrowthLimit();
182
183 // The system server has to run all of the time, so it needs to be
184 // as efficient as possible with its memory usage.
185 VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);
186
187 // Within the system server, it is an error to access Environment paths without
188 // explicitly specifying a user.
189 Environment.setUserRequired(true);
190
191 // Ensure binder calls into the system always run at foreground priority.
192 BinderInternal.disableBackgroundScheduling(true);
193
194 // Prepare the main looper thread (this thread).
195 android.os.Process.setThreadPriority(
196 android.os.Process.THREAD_PRIORITY_FOREGROUND);
197 android.os.Process.setCanSelfBackground(false);
198 Looper.prepareMainLooper();
199
200 // Initialize native services.
201 System.loadLibrary("android_servers");
202 nativeInit();
203
204 // Check whether we failed to shut down last time we tried.
205 // This call may not return.
206 performPendingShutdown();
207
208 // Initialize the system context.
209 createSystemContext();
210
211 // Create the system service manager.
212 mSystemServiceManager = new SystemServiceManager(mSystemContext);
Jeff Brownb880d882014-02-10 19:47:07 -0800213 LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
Jeff Brown6f357d32014-01-15 20:40:55 -0800214
215 // Start services.
216 try {
217 startBootstrapServices();
Jeff Brown4ccb8232014-01-16 22:16:42 -0800218 startCoreServices();
Jeff Brown6f357d32014-01-15 20:40:55 -0800219 startOtherServices();
220 } catch (RuntimeException ex) {
221 Slog.e("System", "******************************************");
222 Slog.e("System", "************ Failure starting system services", ex);
223 throw ex;
224 }
225
226 // For debug builds, log event loop stalls to dropbox for analysis.
227 if (StrictMode.conditionallyEnableDebugLogging()) {
228 Slog.i(TAG, "Enabled StrictMode for system server main thread.");
229 }
230
231 // Loop forever.
232 Looper.loop();
233 throw new RuntimeException("Main thread loop unexpectedly exited");
234 }
235
236 private void reportWtf(String msg, Throwable e) {
Dianne Hackborn661cd522011-08-22 00:26:20 -0700237 Slog.w(TAG, "***********************************************");
238 Log.wtf(TAG, "BOOT FAILURE " + msg, e);
239 }
240
Jeff Brown6f357d32014-01-15 20:40:55 -0800241 private void performPendingShutdown() {
242 final String shutdownAction = SystemProperties.get(
243 ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
244 if (shutdownAction != null && shutdownAction.length() > 0) {
245 boolean reboot = (shutdownAction.charAt(0) == '1');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800246
Jeff Brown6f357d32014-01-15 20:40:55 -0800247 final String reason;
248 if (shutdownAction.length() > 1) {
249 reason = shutdownAction.substring(1, shutdownAction.length());
250 } else {
251 reason = null;
Kenny Rootf547d672010-09-22 10:36:48 -0700252 }
Jeff Brown6f357d32014-01-15 20:40:55 -0800253
254 ShutdownThread.rebootOrShutdown(reboot, reason);
Kenny Rootf547d672010-09-22 10:36:48 -0700255 }
Jeff Brown6f357d32014-01-15 20:40:55 -0800256 }
Kenny Rootf547d672010-09-22 10:36:48 -0700257
Jeff Brown6f357d32014-01-15 20:40:55 -0800258 private void createSystemContext() {
259 ActivityThread activityThread = ActivityThread.systemMain();
260 mSystemContext = activityThread.getSystemContext();
261 mSystemContext.setTheme(android.R.style.Theme_Holo);
262 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263
Jeff Brown6f357d32014-01-15 20:40:55 -0800264 private void startBootstrapServices() {
265 // Wait for installd to finish starting up so that it has a chance to
266 // create critical directories such as /data/user with the appropriate
267 // permissions. We need this to complete before we initialize other services.
268 mInstaller = mSystemServiceManager.startService(Installer.class);
269
270 // Power manager needs to be started early because other services need it.
271 // TODO: The conversion to the new pattern is incomplete. We need to switch
272 // the power manager's dependencies over then we can use boot phases to arrange
273 // initialization order and remove the mPowerManagerService field.
274 mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);
275
276 // Activity manager runs the show.
Jeff Brown4ccb8232014-01-16 22:16:42 -0800277 mActivityManagerService = mSystemServiceManager.startService(
278 ActivityManagerService.Lifecycle.class).getService();
279 }
280
281 private void startCoreServices() {
282 // Display manager is needed to provide display metrics before package manager
283 // starts up.
284 mDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class);
Jeff Brown6f357d32014-01-15 20:40:55 -0800285 }
286
287 private void startOtherServices() {
Jeff Brown6f357d32014-01-15 20:40:55 -0800288 final Context context = mSystemContext;
Kenny Root26ff6622012-07-30 12:58:03 -0700289 AccountManagerService accountManager = null;
290 ContentService contentService = null;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800291 LightsManager lights = null;
Mike Lockwood07a500f2009-08-12 09:56:44 -0400292 BatteryService battery = null;
Jeff Brown7f6c2312012-04-13 20:38:38 -0700293 VibratorService vibrator = null;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800294 IAlarmManager alarm = null;
Jeff Sharkeyb049e212012-09-07 23:16:01 -0700295 MountService mountService = null;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -0700296 NetworkManagementService networkManagement = null;
Jeff Sharkey75279902011-05-24 18:39:45 -0700297 NetworkStatsService networkStats = null;
Jeff Sharkeya4620792011-05-20 15:29:23 -0700298 NetworkPolicyManagerService networkPolicy = null;
Mike Lockwood0f79b542009-08-14 14:18:49 -0400299 ConnectivityService connectivity = null;
Irfan Sheriff7d024d32012-03-22 17:01:39 -0700300 NsdService serviceDiscovery= null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800301 IPackageManager pm = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 WindowManagerService wm = null;
fredc0f420372012-04-12 00:02:00 -0700303 BluetoothManagerService bluetooth = null;
Dan Murphyc9f4eaf2009-08-12 15:15:43 -0500304 DockObserver dock = null;
Mike Lockwood770126a2010-12-09 22:30:37 -0800305 UsbService usb = null;
Mike Lockwoodb01e8bf2011-08-29 20:11:07 -0400306 SerialService serial = null;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800307 TwilightManager twilight = null;
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800308 RecognitionManagerService recognition = null;
Amith Yamasani6734b9f2010-09-13 16:24:08 -0700309 NetworkTimeUpdateService networkTimeUpdater = null;
John Grossmanc1576732012-02-01 15:23:33 -0800310 CommonTimeManagementService commonTimeMgmtService = null;
Jeff Brown6ec6f792012-04-17 16:52:41 -0700311 InputManagerService inputManager = null;
Wink Savillea12a7b32012-09-20 10:09:45 -0700312 TelephonyRegistry telephonyRegistry = null;
Erik Gilling51e95df2013-06-26 11:06:51 -0700313 ConsumerIrService consumerIr = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314
Jeff Brownbd6e1502012-08-28 03:27:37 -0700315 boolean onlyCore = false;
Dan Morrille4d9a012013-03-28 18:10:43 -0700316 boolean firstBoot = false;
Dan Morrille4d9a012013-03-28 18:10:43 -0700317 boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false);
318 boolean disableMedia = SystemProperties.getBoolean("config.disable_media", false);
319 boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false);
320 boolean disableTelephony = SystemProperties.getBoolean("config.disable_telephony", false);
321 boolean disableLocation = SystemProperties.getBoolean("config.disable_location", false);
322 boolean disableSystemUI = SystemProperties.getBoolean("config.disable_systemui", false);
323 boolean disableNonCoreServices = SystemProperties.getBoolean("config.disable_noncore", false);
324 boolean disableNetwork = SystemProperties.getBoolean("config.disable_network", false);
325
326 try {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800327 Slog.i(TAG, "Telephony Registry");
Wink Savillea12a7b32012-09-20 10:09:45 -0700328 telephonyRegistry = new TelephonyRegistry(context);
329 ServiceManager.addService("telephony.registry", telephonyRegistry);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330
Glenn Kasten07b04652012-04-23 15:00:43 -0700331 Slog.i(TAG, "Scheduling Policy");
Dianne Hackborn35f72be2013-09-16 10:57:39 -0700332 ServiceManager.addService("scheduling_policy", new SchedulingPolicyService());
Glenn Kasten07b04652012-04-23 15:00:43 -0700333
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800334 AttributeCache.init(context);
335
Jeff Brown4ccb8232014-01-16 22:16:42 -0800336 // We need the default display before we can initialize the package manager.
337 mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700338
Joe Onorato8a9b2202010-02-26 18:56:32 -0800339 Slog.i(TAG, "Package Manager");
Ben Komalo553acf02011-09-19 14:25:28 -0700340 // Only run "core" apps if we're encrypting the device.
341 String cryptState = SystemProperties.get("vold.decrypt");
Ben Komalo3573d402011-09-23 15:08:24 -0700342 if (ENCRYPTING_STATE.equals(cryptState)) {
Ben Komalo553acf02011-09-19 14:25:28 -0700343 Slog.w(TAG, "Detected encryption in progress - only parsing core apps");
Ben Komalo3573d402011-09-23 15:08:24 -0700344 onlyCore = true;
345 } else if (ENCRYPTED_STATE.equals(cryptState)) {
346 Slog.w(TAG, "Device encrypted - only parsing core apps");
347 onlyCore = true;
Ben Komalo553acf02011-09-19 14:25:28 -0700348 }
Ben Komalo3573d402011-09-23 15:08:24 -0700349
Jeff Brown6f357d32014-01-15 20:40:55 -0800350 pm = PackageManagerService.main(context, mInstaller,
351 mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF,
Ben Komalo553acf02011-09-19 14:25:28 -0700352 onlyCore);
Dianne Hackborn58f42a52011-10-10 13:46:34 -0700353 try {
354 firstBoot = pm.isFirstBoot();
355 } catch (RemoteException e) {
356 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357
Jeff Brown4ccb8232014-01-16 22:16:42 -0800358 mActivityManagerService.setSystemProcess();
Svetoslavb3038ec2013-02-13 14:39:30 -0800359
Nick Kralevich79619dd2013-03-04 13:05:32 -0800360 Slog.i(TAG, "Entropy Mixer");
361 ServiceManager.addService("entropy", new EntropyMixer(context));
362
Amith Yamasani258848d2012-08-10 17:06:33 -0700363 Slog.i(TAG, "User Service");
364 ServiceManager.addService(Context.USER_SERVICE,
Dianne Hackborn4428e172012-08-24 17:43:05 -0700365 UserManagerService.getInstance());
Amith Yamasani258848d2012-08-10 17:06:33 -0700366
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 mContentResolver = context.getContentResolver();
368
Fred Quintanae91ebe22009-09-29 20:44:30 -0700369 // The AccountManager must come before the ContentService
Fred Quintana60307342009-03-24 22:48:12 -0700370 try {
Dan Morrille4d9a012013-03-28 18:10:43 -0700371 // TODO: seems like this should be disable-able, but req'd by ContentService
Joe Onorato8a9b2202010-02-26 18:56:32 -0800372 Slog.i(TAG, "Account Manager");
Kenny Root26ff6622012-07-30 12:58:03 -0700373 accountManager = new AccountManagerService(context);
374 ServiceManager.addService(Context.ACCOUNT_SERVICE, accountManager);
Fred Quintana60307342009-03-24 22:48:12 -0700375 } catch (Throwable e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800376 Slog.e(TAG, "Failure starting Account Manager", e);
Fred Quintana60307342009-03-24 22:48:12 -0700377 }
378
Joe Onorato8a9b2202010-02-26 18:56:32 -0800379 Slog.i(TAG, "Content Manager");
Kenny Root26ff6622012-07-30 12:58:03 -0700380 contentService = ContentService.main(context,
Jeff Brown6f357d32014-01-15 20:40:55 -0800381 mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800382
Joe Onorato8a9b2202010-02-26 18:56:32 -0800383 Slog.i(TAG, "System Content Providers");
Jeff Brown4ccb8232014-01-16 22:16:42 -0800384 mActivityManagerService.installSystemProviders();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800385
Jeff Brown6f357d32014-01-15 20:40:55 -0800386 mSystemServiceManager.startService(LightsService.class);
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800387 lights = LocalServices.getService(LightsManager.class);
Mike Lockwood3a322132009-11-24 00:30:52 -0500388
Joe Onoratode1b3592010-10-25 20:36:47 -0700389 Slog.i(TAG, "Battery Service");
390 battery = new BatteryService(context, lights);
391 ServiceManager.addService("battery", battery);
392
Joe Onorato8a9b2202010-02-26 18:56:32 -0800393 Slog.i(TAG, "Vibrator Service");
Jeff Brown7f6c2312012-04-13 20:38:38 -0700394 vibrator = new VibratorService(context);
395 ServiceManager.addService("vibrator", vibrator);
The Android Open Source Project10592532009-03-18 17:39:46 -0700396
Jeff Brown6f357d32014-01-15 20:40:55 -0800397 // TODO: use boot phase
398 // only initialize the power service after we have started the
399 // lights service, content providers and the battery service.
400 mPowerManagerService.init(lights, battery,
401 BatteryStatsService.getService(),
Jeff Brown4ccb8232014-01-16 22:16:42 -0800402 mActivityManagerService.getAppOpsService());
Jeff Brown6f357d32014-01-15 20:40:55 -0800403
Erik Gilling51e95df2013-06-26 11:06:51 -0700404 Slog.i(TAG, "Consumer IR Service");
405 consumerIr = new ConsumerIrService(context);
406 ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr);
407
Jeff Brown6f357d32014-01-15 20:40:55 -0800408 mSystemServiceManager.startService(AlarmManagerService.class);
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800409 alarm = IAlarmManager.Stub.asInterface(
410 ServiceManager.getService(Context.ALARM_SERVICE));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411
Joe Onorato8a9b2202010-02-26 18:56:32 -0800412 Slog.i(TAG, "Init Watchdog");
Jeff Brown6f357d32014-01-15 20:40:55 -0800413 final Watchdog watchdog = Watchdog.getInstance();
Jeff Brown4ccb8232014-01-16 22:16:42 -0800414 watchdog.init(context, mActivityManagerService);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800415
Jeff Browna9d131c2012-09-20 16:48:17 -0700416 Slog.i(TAG, "Input Manager");
Jeff Brown4ccb8232014-01-16 22:16:42 -0800417 inputManager = new InputManagerService(context);
Jeff Browna9d131c2012-09-20 16:48:17 -0700418
Joe Onorato8a9b2202010-02-26 18:56:32 -0800419 Slog.i(TAG, "Window Manager");
Jeff Brown4ccb8232014-01-16 22:16:42 -0800420 wm = WindowManagerService.main(context, inputManager,
Jeff Brown6f357d32014-01-15 20:40:55 -0800421 mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL,
Jeff Brown780c46f2012-06-24 12:15:38 -0700422 !firstBoot, onlyCore);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 ServiceManager.addService(Context.WINDOW_SERVICE, wm);
Jeff Brown6ec6f792012-04-17 16:52:41 -0700424 ServiceManager.addService(Context.INPUT_SERVICE, inputManager);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425
Jeff Brown4ccb8232014-01-16 22:16:42 -0800426 mActivityManagerService.setWindowManager(wm);
Jeff Browna9d131c2012-09-20 16:48:17 -0700427
428 inputManager.setWindowManagerCallbacks(wm.getInputMonitor());
429 inputManager.start();
430
Jeff Brown4ccb8232014-01-16 22:16:42 -0800431 // TODO: Use service dependencies instead.
432 mDisplayManagerService.windowManagerAndInputReady();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800433
434 // Skip Bluetooth if we have an emulator kernel
435 // TODO: Use a more reliable check to see if this product should
436 // support Bluetooth - see bug 988521
437 if (SystemProperties.get("ro.kernel.qemu").equals("1")) {
David 'Digit' Turnere2a5e862011-01-17 00:32:33 +0100438 Slog.i(TAG, "No Bluetooh Service (emulator)");
Jeff Brown6f357d32014-01-15 20:40:55 -0800439 } else if (mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
David 'Digit' Turnere2a5e862011-01-17 00:32:33 +0100440 Slog.i(TAG, "No Bluetooth Service (factory test)");
Matthew Xie1dd01eb32013-04-26 12:37:54 -0700441 } else if (!context.getPackageManager().hasSystemFeature
442 (PackageManager.FEATURE_BLUETOOTH)) {
443 Slog.i(TAG, "No Bluetooth Service (Bluetooth Hardware Not Present)");
Dan Morrille4d9a012013-03-28 18:10:43 -0700444 } else if (disableBluetooth) {
445 Slog.i(TAG, "Bluetooth Service disabled by config");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 } else {
fredc0f420372012-04-12 00:02:00 -0700447 Slog.i(TAG, "Bluetooth Manager Service");
448 bluetooth = new BluetoothManagerService(context);
449 ServiceManager.addService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE, bluetooth);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800450 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800451 } catch (RuntimeException e) {
Dianne Hackborn661cd522011-08-22 00:26:20 -0700452 Slog.e("System", "******************************************");
453 Slog.e("System", "************ Failure starting core service", e);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800454 }
455
Joe Onorato089de882010-04-12 08:18:45 -0700456 StatusBarManagerService statusBar = null;
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800457 INotificationManager notification = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458 InputMethodManagerService imm = null;
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700459 WallpaperManagerService wallpaper = null;
Mike Lockwood46db5042010-02-22 16:36:44 -0500460 LocationManagerService location = null;
Bai Taoa58a8752010-07-13 15:32:16 +0800461 CountryDetectorService countryDetector = null;
satok988323c2011-06-22 16:38:13 +0900462 TextServicesManagerService tsms = null;
Amith Yamasani52c489c2012-03-28 11:42:42 -0700463 LockSettingsService lockSettings = null;
Daniel Sandler7d276c32012-01-30 14:33:52 -0500464 DreamManagerService dreamy = null;
Romain Guy3b748a42013-04-17 18:54:38 -0700465 AssetAtlasService atlas = null;
Jeff Brown69b07162013-11-07 00:30:16 -0800466 MediaRouterService mediaRouter = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800467
Dianne Hackborn661cd522011-08-22 00:26:20 -0700468 // Bring up services needed for UI.
Jeff Brown6f357d32014-01-15 20:40:55 -0800469 if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
Dan Morrille4d9a012013-03-28 18:10:43 -0700470 //if (!disableNonCoreServices) { // TODO: View depends on these; mock them?
471 if (true) {
472 try {
473 Slog.i(TAG, "Input Method Service");
474 imm = new InputMethodManagerService(context, wm);
475 ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
476 } catch (Throwable e) {
477 reportWtf("starting Input Manager Service", e);
478 }
Dianne Hackborn661cd522011-08-22 00:26:20 -0700479
Dan Morrille4d9a012013-03-28 18:10:43 -0700480 try {
481 Slog.i(TAG, "Accessibility Manager");
Adam Lesinski898c13d2014-01-28 15:34:50 -0800482 ServiceManager.addService(Context.ACCESSIBILITY_SERVICE, (IBinder)
483 getClass().getClassLoader().loadClass("com.android.server.accessibility.AccessibilityManagerService").getConstructor(Context.class).newInstance(context));
Dan Morrille4d9a012013-03-28 18:10:43 -0700484 } catch (Throwable e) {
485 reportWtf("starting Accessibility Manager", e);
486 }
Dianne Hackborn661cd522011-08-22 00:26:20 -0700487 }
488 }
489
490 try {
491 wm.displayReady();
492 } catch (Throwable e) {
493 reportWtf("making display ready", e);
494 }
Dianne Hackborn8795b602011-08-25 13:30:53 -0700495
Dianne Hackborn295e3c22011-08-25 13:19:08 -0700496 try {
Dianne Hackborn661cd522011-08-22 00:26:20 -0700497 pm.performBootDexOpt();
498 } catch (Throwable e) {
499 reportWtf("performing boot dexopt", e);
500 }
501
502 try {
503 ActivityManagerNative.getDefault().showBootMessage(
504 context.getResources().getText(
505 com.android.internal.R.string.android_upgrading_starting_apps),
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800506 false);
Dianne Hackborn661cd522011-08-22 00:26:20 -0700507 } catch (RemoteException e) {
508 }
509
Jeff Brown6f357d32014-01-15 20:40:55 -0800510 if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
Dan Morrille4d9a012013-03-28 18:10:43 -0700511 if (!disableStorage &&
512 !"0".equals(SystemProperties.get("system_init.startmountservice"))) {
Kenny Root51a573c2012-05-17 13:30:28 -0700513 try {
514 /*
515 * NotificationManagerService is dependant on MountService,
516 * (for media / usb notifications) so we must start MountService first.
517 */
518 Slog.i(TAG, "Mount Service");
519 mountService = new MountService(context);
520 ServiceManager.addService("mount", mountService);
521 } catch (Throwable e) {
522 reportWtf("starting Mount Service", e);
523 }
524 }
525
Dan Morrille4d9a012013-03-28 18:10:43 -0700526 if (!disableNonCoreServices) {
527 try {
528 Slog.i(TAG, "LockSettingsService");
529 lockSettings = new LockSettingsService(context);
530 ServiceManager.addService("lock_settings", lockSettings);
531 } catch (Throwable e) {
532 reportWtf("starting LockSettingsService service", e);
533 }
534
535 try {
Adam Lesinski898c13d2014-01-28 15:34:50 -0800536 if (pm.hasSystemFeature("android.software.device_admin")) {
537 mSystemServiceManager.startServiceIfExists(
538 DEVICE_POLICY_MANAGER_SERVICE_CLASS);
539 }
Dan Morrille4d9a012013-03-28 18:10:43 -0700540 } catch (Throwable e) {
541 reportWtf("starting DevicePolicyService", e);
542 }
Amith Yamasani52c489c2012-03-28 11:42:42 -0700543 }
544
Dan Morrille4d9a012013-03-28 18:10:43 -0700545 if (!disableSystemUI) {
546 try {
547 Slog.i(TAG, "Status Bar");
548 statusBar = new StatusBarManagerService(context, wm);
549 ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);
550 } catch (Throwable e) {
551 reportWtf("starting StatusBarManagerService", e);
552 }
Dianne Hackbornd6847842010-01-12 18:14:19 -0800553 }
554
Dan Morrille4d9a012013-03-28 18:10:43 -0700555 if (!disableNonCoreServices) {
556 try {
557 Slog.i(TAG, "Clipboard Service");
558 ServiceManager.addService(Context.CLIPBOARD_SERVICE,
559 new ClipboardService(context));
560 } catch (Throwable e) {
561 reportWtf("starting Clipboard Service", e);
562 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800563 }
564
Dan Morrille4d9a012013-03-28 18:10:43 -0700565 if (!disableNetwork) {
566 try {
567 Slog.i(TAG, "NetworkManagement Service");
568 networkManagement = NetworkManagementService.create(context);
569 ServiceManager.addService(Context.NETWORKMANAGEMENT_SERVICE, networkManagement);
570 } catch (Throwable e) {
571 reportWtf("starting NetworkManagement Service", e);
572 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 }
574
Dan Morrille4d9a012013-03-28 18:10:43 -0700575 if (!disableNonCoreServices) {
576 try {
577 Slog.i(TAG, "Text Service Manager Service");
578 tsms = new TextServicesManagerService(context);
579 ServiceManager.addService(Context.TEXT_SERVICES_MANAGER_SERVICE, tsms);
580 } catch (Throwable e) {
581 reportWtf("starting Text Service Manager Service", e);
582 }
San Mehatd1df8ac2010-01-26 06:17:26 -0800583 }
584
Dan Morrille4d9a012013-03-28 18:10:43 -0700585 if (!disableNetwork) {
586 try {
587 Slog.i(TAG, "NetworkStats Service");
588 networkStats = new NetworkStatsService(context, networkManagement, alarm);
589 ServiceManager.addService(Context.NETWORK_STATS_SERVICE, networkStats);
590 } catch (Throwable e) {
591 reportWtf("starting NetworkStats Service", e);
592 }
593
594 try {
595 Slog.i(TAG, "NetworkPolicy Service");
596 networkPolicy = new NetworkPolicyManagerService(
Jeff Brown4ccb8232014-01-16 22:16:42 -0800597 context, mActivityManagerService,
Jeff Brown6f357d32014-01-15 20:40:55 -0800598 (IPowerManager)ServiceManager.getService(Context.POWER_SERVICE),
Dan Morrille4d9a012013-03-28 18:10:43 -0700599 networkStats, networkManagement);
600 ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy);
601 } catch (Throwable e) {
602 reportWtf("starting NetworkPolicy Service", e);
603 }
604
Vinit Deshpande3ffa1a82014-01-08 02:55:29 +0000605 try {
Dan Morrille4d9a012013-03-28 18:10:43 -0700606 Slog.i(TAG, "Wi-Fi P2pService");
Jeff Brown265e87b2014-01-16 14:12:54 -0800607 mSystemServiceManager.startServiceIfExists(
608 "com.android.server.wifi.p2p.WifiP2pService");
Dan Morrille4d9a012013-03-28 18:10:43 -0700609 } catch (Throwable e) {
610 reportWtf("starting Wi-Fi P2pService", e);
611 }
612
Vinit Deshpande3ffa1a82014-01-08 02:55:29 +0000613 try {
Dan Morrille4d9a012013-03-28 18:10:43 -0700614 Slog.i(TAG, "Wi-Fi Service");
Jeff Brown265e87b2014-01-16 14:12:54 -0800615 mSystemServiceManager.startServiceIfExists(
616 "com.android.server.wifi.WifiService");
Dan Morrille4d9a012013-03-28 18:10:43 -0700617 } catch (Throwable e) {
618 reportWtf("starting Wi-Fi Service", e);
619 }
620
621 try {
622 Slog.i(TAG, "Connectivity Service");
623 connectivity = new ConnectivityService(
624 context, networkManagement, networkStats, networkPolicy);
625 ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
626 networkStats.bindConnectivityManager(connectivity);
627 networkPolicy.bindConnectivityManager(connectivity);
Dan Morrille4d9a012013-03-28 18:10:43 -0700628 } catch (Throwable e) {
629 reportWtf("starting Connectivity Service", e);
630 }
631
632 try {
633 Slog.i(TAG, "Network Service Discovery Service");
634 serviceDiscovery = NsdService.create(context);
635 ServiceManager.addService(
636 Context.NSD_SERVICE, serviceDiscovery);
637 } catch (Throwable e) {
638 reportWtf("starting Service Discovery Service", e);
639 }
satok988323c2011-06-22 16:38:13 +0900640 }
641
Dan Morrille4d9a012013-03-28 18:10:43 -0700642 if (!disableNonCoreServices) {
643 try {
644 Slog.i(TAG, "UpdateLock Service");
645 ServiceManager.addService(Context.UPDATE_LOCK_SERVICE,
646 new UpdateLockService(context));
647 } catch (Throwable e) {
648 reportWtf("starting UpdateLockService", e);
649 }
Christopher Tate8662cab52012-02-23 14:59:36 -0800650 }
651
Kenny Root51a573c2012-05-17 13:30:28 -0700652 /*
653 * MountService has a few dependencies: Notification Manager and
654 * AppWidget Provider. Make sure MountService is completely started
655 * first before continuing.
656 */
Ken Sumrall025adc42013-06-05 22:08:12 -0700657 if (mountService != null && !onlyCore) {
Kenny Root51a573c2012-05-17 13:30:28 -0700658 mountService.waitForAsecScan();
San Mehat1bf3f8b2010-02-03 14:43:09 -0800659 }
660
661 try {
Kenny Root26ff6622012-07-30 12:58:03 -0700662 if (accountManager != null)
663 accountManager.systemReady();
664 } catch (Throwable e) {
665 reportWtf("making Account Manager Service ready", e);
666 }
667
668 try {
669 if (contentService != null)
670 contentService.systemReady();
671 } catch (Throwable e) {
672 reportWtf("making Content Service ready", e);
673 }
674
Jeff Brown6f357d32014-01-15 20:40:55 -0800675 mSystemServiceManager.startService(NotificationManagerService.class);
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800676 notification = INotificationManager.Stub.asInterface(
677 ServiceManager.getService(Context.NOTIFICATION_SERVICE));
678 networkPolicy.bindNotificationManager(notification);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800679
Jeff Brown6f357d32014-01-15 20:40:55 -0800680 mSystemServiceManager.startService(DeviceStorageMonitorService.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800681
Dan Morrille4d9a012013-03-28 18:10:43 -0700682 if (!disableLocation) {
683 try {
684 Slog.i(TAG, "Location Manager");
685 location = new LocationManagerService(context);
686 ServiceManager.addService(Context.LOCATION_SERVICE, location);
687 } catch (Throwable e) {
688 reportWtf("starting Location Manager", e);
689 }
690
691 try {
692 Slog.i(TAG, "Country Detector");
693 countryDetector = new CountryDetectorService(context);
694 ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector);
695 } catch (Throwable e) {
696 reportWtf("starting Country Detector", e);
697 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800698 }
699
Dan Morrille4d9a012013-03-28 18:10:43 -0700700 if (!disableNonCoreServices) {
701 try {
702 Slog.i(TAG, "Search Service");
703 ServiceManager.addService(Context.SEARCH_SERVICE,
704 new SearchManagerService(context));
705 } catch (Throwable e) {
706 reportWtf("starting Search Service", e);
707 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800708 }
709
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800710 try {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800711 Slog.i(TAG, "DropBox Service");
Dan Egnor95240272009-10-27 18:23:39 -0700712 ServiceManager.addService(Context.DROPBOX_SERVICE,
Dan Egnorf18a01c2009-11-12 11:32:50 -0800713 new DropBoxManagerService(context, new File("/data/system/dropbox")));
Dan Egnor4410ec82009-09-11 16:40:01 -0700714 } catch (Throwable e) {
Dianne Hackborn661cd522011-08-22 00:26:20 -0700715 reportWtf("starting DropBoxManagerService", e);
Dan Egnor4410ec82009-09-11 16:40:01 -0700716 }
717
Dan Morrille4d9a012013-03-28 18:10:43 -0700718 if (!disableNonCoreServices && context.getResources().getBoolean(
719 R.bool.config_enableWallpaperService)) {
Mike Lockwoodc067c9c2011-10-31 12:50:12 -0400720 try {
721 Slog.i(TAG, "Wallpaper Service");
Mike Lockwooded8902d2013-11-15 11:01:47 -0800722 wallpaper = new WallpaperManagerService(context);
723 ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper);
Mike Lockwoodc067c9c2011-10-31 12:50:12 -0400724 } catch (Throwable e) {
725 reportWtf("starting Wallpaper Service", e);
Mike Lockwood3a74bd32011-08-12 13:55:22 -0700726 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800727 }
728
Dan Morrille4d9a012013-03-28 18:10:43 -0700729 if (!disableMedia && !"0".equals(SystemProperties.get("system_init.startaudioservice"))) {
Mike Lockwoodcba928c2011-08-17 15:58:52 -0700730 try {
731 Slog.i(TAG, "Audio Service");
732 ServiceManager.addService(Context.AUDIO_SERVICE, new AudioService(context));
733 } catch (Throwable e) {
734 reportWtf("starting Audio Service", e);
735 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800736 }
737
Dan Morrille4d9a012013-03-28 18:10:43 -0700738 if (!disableNonCoreServices) {
739 try {
740 Slog.i(TAG, "Dock Observer");
741 // Listen for dock station changes
742 dock = new DockObserver(context);
743 } catch (Throwable e) {
744 reportWtf("starting DockObserver", e);
745 }
Dan Murphyc9f4eaf2009-08-12 15:15:43 -0500746 }
747
Dan Morrille4d9a012013-03-28 18:10:43 -0700748 if (!disableMedia) {
749 try {
750 Slog.i(TAG, "Wired Accessory Manager");
751 // Listen for wired headset changes
752 inputManager.setWiredAccessoryCallbacks(
753 new WiredAccessoryManager(context, inputManager));
754 } catch (Throwable e) {
755 reportWtf("starting WiredAccessoryManager", e);
756 }
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500757 }
758
Dan Morrille4d9a012013-03-28 18:10:43 -0700759 if (!disableNonCoreServices) {
760 try {
761 Slog.i(TAG, "USB Service");
762 // Manage USB host and device support
763 usb = new UsbService(context);
764 ServiceManager.addService(Context.USB_SERVICE, usb);
765 } catch (Throwable e) {
766 reportWtf("starting UsbService", e);
767 }
Mike Lockwood57c798a2010-06-23 17:36:36 -0400768
Dan Morrille4d9a012013-03-28 18:10:43 -0700769 try {
770 Slog.i(TAG, "Serial Service");
771 // Serial port support
772 serial = new SerialService(context);
773 ServiceManager.addService(Context.SERIAL_SERVICE, serial);
774 } catch (Throwable e) {
775 Slog.e(TAG, "Failure starting SerialService", e);
776 }
Mike Lockwoodb01e8bf2011-08-29 20:11:07 -0400777 }
778
Jeff Brown6f357d32014-01-15 20:40:55 -0800779 mSystemServiceManager.startService(TwilightService.class);
Adam Lesinskief2ea1f2013-12-05 16:48:06 -0800780 twilight = LocalServices.getService(TwilightManager.class);
Jeff Brown2416e092012-08-21 22:12:20 -0700781
Jeff Brown6f357d32014-01-15 20:40:55 -0800782 mSystemServiceManager.startService(UiModeManagerService.class);
Dianne Hackborn7299c412010-03-04 18:41:49 -0800783
Dan Morrille4d9a012013-03-28 18:10:43 -0700784 if (!disableNonCoreServices) {
785 try {
Adam Lesinski898c13d2014-01-28 15:34:50 -0800786 if (pm.hasSystemFeature("android.software.backup")) {
787 mSystemServiceManager.startServiceIfExists(BACKUP_MANAGER_SERVICE_CLASS);
788 }
Dan Morrille4d9a012013-03-28 18:10:43 -0700789 } catch (Throwable e) {
790 Slog.e(TAG, "Failure starting Backup Service", e);
791 }
Christopher Tate487529a2009-04-29 14:03:25 -0700792
Dan Morrille4d9a012013-03-28 18:10:43 -0700793 try {
Adam Lesinski898c13d2014-01-28 15:34:50 -0800794 if (pm.hasSystemFeature("android.software.app_widgets")) {
795 mSystemServiceManager.startServiceIfExists(APPWIDGET_SERVICE_CLASS);
796 }
Dan Morrille4d9a012013-03-28 18:10:43 -0700797 } catch (Throwable e) {
798 reportWtf("starting AppWidget Service", e);
799 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800800
Dan Morrille4d9a012013-03-28 18:10:43 -0700801 try {
802 Slog.i(TAG, "Recognition Service");
803 recognition = new RecognitionManagerService(context);
804 } catch (Throwable e) {
805 reportWtf("starting Recognition Service", e);
806 }
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800807 }
Jaikumar Ganesh7d0548d2010-10-18 15:29:09 -0700808
Nick Pelly038cabe2010-09-23 16:12:11 -0700809 try {
Dan Egnor621bc542010-03-25 16:20:14 -0700810 Slog.i(TAG, "DiskStats Service");
811 ServiceManager.addService("diskstats", new DiskStatsService(context));
812 } catch (Throwable e) {
Dianne Hackborn661cd522011-08-22 00:26:20 -0700813 reportWtf("starting DiskStats Service", e);
Dan Egnor621bc542010-03-25 16:20:14 -0700814 }
Sen Hubde75702010-05-28 01:54:03 -0700815
816 try {
817 // need to add this service even if SamplingProfilerIntegration.isEnabled()
818 // is false, because it is this service that detects system property change and
819 // turns on SamplingProfilerIntegration. Plus, when sampling profiler doesn't work,
820 // there is little overhead for running this service.
821 Slog.i(TAG, "SamplingProfiler Service");
822 ServiceManager.addService("samplingprofiler",
823 new SamplingProfilerService(context));
824 } catch (Throwable e) {
Dianne Hackborn661cd522011-08-22 00:26:20 -0700825 reportWtf("starting SamplingProfiler Service", e);
Sen Hubde75702010-05-28 01:54:03 -0700826 }
Chung-yih Wang024d5962010-08-06 12:06:04 +0800827
Dan Morrille4d9a012013-03-28 18:10:43 -0700828 if (!disableNetwork) {
829 try {
830 Slog.i(TAG, "NetworkTimeUpdateService");
831 networkTimeUpdater = new NetworkTimeUpdateService(context);
832 } catch (Throwable e) {
833 reportWtf("starting NetworkTimeUpdate service", e);
834 }
Amith Yamasani6734b9f2010-09-13 16:24:08 -0700835 }
John Grossmanc1576732012-02-01 15:23:33 -0800836
Dan Morrille4d9a012013-03-28 18:10:43 -0700837 if (!disableMedia) {
838 try {
839 Slog.i(TAG, "CommonTimeManagementService");
840 commonTimeMgmtService = new CommonTimeManagementService(context);
841 ServiceManager.addService("commontime_management", commonTimeMgmtService);
842 } catch (Throwable e) {
843 reportWtf("starting CommonTimeManagementService service", e);
844 }
John Grossmanc1576732012-02-01 15:23:33 -0800845 }
Geremy Condra3d33c262012-05-06 18:32:19 -0700846
Dan Morrille4d9a012013-03-28 18:10:43 -0700847 if (!disableNetwork) {
848 try {
849 Slog.i(TAG, "CertBlacklister");
850 CertBlacklister blacklister = new CertBlacklister(context);
851 } catch (Throwable e) {
852 reportWtf("starting CertBlacklister", e);
853 }
Geremy Condra3d33c262012-05-06 18:32:19 -0700854 }
Jim Miller5ecd8112013-01-09 18:50:26 -0800855
Adam Lesinski898c13d2014-01-28 15:34:50 -0800856 if (!disableNonCoreServices &&
Dan Morrille4d9a012013-03-28 18:10:43 -0700857 context.getResources().getBoolean(R.bool.config_dreamsSupported)) {
Daniel Sandler7d276c32012-01-30 14:33:52 -0500858 try {
859 Slog.i(TAG, "Dreams Service");
860 // Dreams (interactive idle-time views, a/k/a screen savers)
Jeff Brown4ccb8232014-01-16 22:16:42 -0800861 dreamy = new DreamManagerService(context);
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -0700862 ServiceManager.addService(DreamService.DREAM_SERVICE, dreamy);
Daniel Sandler7d276c32012-01-30 14:33:52 -0500863 } catch (Throwable e) {
864 reportWtf("starting DreamManagerService", e);
865 }
866 }
Svetoslavb3038ec2013-02-13 14:39:30 -0800867
Romain Guy3b748a42013-04-17 18:54:38 -0700868 if (!disableNonCoreServices) {
869 try {
870 Slog.i(TAG, "Assets Atlas Service");
871 atlas = new AssetAtlasService(context);
872 ServiceManager.addService(AssetAtlasService.ASSET_ATLAS_SERVICE, atlas);
873 } catch (Throwable e) {
874 reportWtf("starting AssetAtlasService", e);
875 }
876 }
877
Svetoslavb3038ec2013-02-13 14:39:30 -0800878 try {
879 Slog.i(TAG, "IdleMaintenanceService");
Svetoslav6a08a122013-05-03 11:24:26 -0700880 new IdleMaintenanceService(context, battery);
Svetoslavb3038ec2013-02-13 14:39:30 -0800881 } catch (Throwable e) {
882 reportWtf("starting IdleMaintenanceService", e);
883 }
Svetoslav Ganov4b9a4d12013-06-11 15:20:06 -0700884
885 try {
Adam Lesinski898c13d2014-01-28 15:34:50 -0800886 if (pm.hasSystemFeature("android.software.print")) {
887 mSystemServiceManager.startServiceIfExists(PRINT_MANAGER_SERVICE_CLASS);
888 }
Svetoslav Ganov4b9a4d12013-06-11 15:20:06 -0700889 } catch (Throwable e) {
890 reportWtf("starting Print Service", e);
891 }
Jeff Brown69b07162013-11-07 00:30:16 -0800892
RoboErik01fe6612014-02-13 14:19:04 -0800893 try {
894 Slog.i(TAG, "MediaSessionService");
895 mSystemServiceManager.startService(MediaSessionService.class);
896 } catch (Throwable e) {
897 reportWtf("starting MediaSessionService", e);
898 }
899
Jeff Brown69b07162013-11-07 00:30:16 -0800900 if (!disableNonCoreServices) {
901 try {
902 Slog.i(TAG, "Media Router Service");
903 mediaRouter = new MediaRouterService(context);
904 ServiceManager.addService(Context.MEDIA_ROUTER_SERVICE, mediaRouter);
905 } catch (Throwable e) {
906 reportWtf("starting MediaRouterService", e);
907 }
908 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800909 }
910
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700911 // Before things start rolling, be sure we have decided whether
912 // we are in safe mode.
Dianne Hackborna34f1ad2009-09-02 13:26:28 -0700913 final boolean safeMode = wm.detectSafeMode();
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700914 if (safeMode) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800915 mActivityManagerService.enterSafeMode();
Jeff Brownb09abc12011-01-13 21:08:27 -0800916 // Post the safe mode state in the Zygote class
917 Zygote.systemInSafeMode = true;
918 // Disable the JIT for the system_server process
919 VMRuntime.getRuntime().disableJitCompilation();
Ben Cheng6c0afff2010-02-14 16:18:56 -0800920 } else {
921 // Enable the JIT for the system_server process
922 VMRuntime.getRuntime().startJitCompilation();
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700923 }
Doug Zongkerab5c49c2009-12-04 10:31:43 -0800924
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700925 // It is now time to start up the app processes...
Joe Onorato30275482009-07-08 17:09:14 -0700926
Jeff Brown7f6c2312012-04-13 20:38:38 -0700927 try {
928 vibrator.systemReady();
929 } catch (Throwable e) {
930 reportWtf("making Vibrator Service ready", e);
931 }
932
Dan Morrille4d9a012013-03-28 18:10:43 -0700933 if (lockSettings != null) {
934 try {
935 lockSettings.systemReady();
936 } catch (Throwable e) {
937 reportWtf("making Lock Settings Service ready", e);
938 }
Felipe Ramosf35df5b2012-09-18 18:26:27 -0300939 }
940
Amith Yamasani817ec492013-12-20 13:27:30 -0800941 // Needed by DevicePolicyManager for initialization
Jeff Brown6f357d32014-01-15 20:40:55 -0800942 mSystemServiceManager.startBootPhase(SystemService.PHASE_LOCK_SETTINGS_READY);
Dianne Hackbornd6847842010-01-12 18:14:19 -0800943
Jeff Brown6f357d32014-01-15 20:40:55 -0800944 mSystemServiceManager.startBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);
Joe Onorato30275482009-07-08 17:09:14 -0700945
Dianne Hackborn661cd522011-08-22 00:26:20 -0700946 try {
947 wm.systemReady();
948 } catch (Throwable e) {
949 reportWtf("making Window Manager Service ready", e);
950 }
Joe Onoratodc565f42010-10-04 15:27:22 -0400951
Jeff Brownb09abc12011-01-13 21:08:27 -0800952 if (safeMode) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800953 mActivityManagerService.showSafeModeOverlay();
Jeff Brownb09abc12011-01-13 21:08:27 -0800954 }
955
Joe Onoratodc565f42010-10-04 15:27:22 -0400956 // Update the configuration for this context by hand, because we're going
957 // to start using it before the config change done in wm.systemReady() will
958 // propagate to it.
959 Configuration config = wm.computeNewConfiguration();
960 DisplayMetrics metrics = new DisplayMetrics();
961 WindowManager w = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
962 w.getDefaultDisplay().getMetrics(metrics);
963 context.getResources().updateConfiguration(config, metrics);
964
Jeff Brownaa202a62012-08-21 22:14:26 -0700965 try {
Jeff Brown6f357d32014-01-15 20:40:55 -0800966 // TODO: use boot phase
967 mPowerManagerService.systemReady(twilight, dreamy);
Jeff Brownaa202a62012-08-21 22:14:26 -0700968 } catch (Throwable e) {
969 reportWtf("making Power Manager Service ready", e);
970 }
971
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800972 try {
973 pm.systemReady();
Dianne Hackborn661cd522011-08-22 00:26:20 -0700974 } catch (Throwable e) {
975 reportWtf("making Package Manager Service ready", e);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800976 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800977
Jeff Brownbd6e1502012-08-28 03:27:37 -0700978 try {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800979 // TODO: use boot phase and communicate these flags some other way
980 mDisplayManagerService.systemReady(safeMode, onlyCore);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700981 } catch (Throwable e) {
982 reportWtf("making Display Manager Service ready", e);
983 }
984
Dianne Hackborna34f1ad2009-09-02 13:26:28 -0700985 // These are needed to propagate to the runnable below.
Joe Onoratof3c3c4f2010-10-21 11:09:02 -0400986 final Context contextF = context;
Jeff Sharkeyb049e212012-09-07 23:16:01 -0700987 final MountService mountServiceF = mountService;
Dianne Hackborna34f1ad2009-09-02 13:26:28 -0700988 final BatteryService batteryF = battery;
Jeff Sharkey350083e2011-06-29 10:45:16 -0700989 final NetworkManagementService networkManagementF = networkManagement;
Jeff Sharkey75279902011-05-24 18:39:45 -0700990 final NetworkStatsService networkStatsF = networkStats;
Jeff Sharkeya4620792011-05-20 15:29:23 -0700991 final NetworkPolicyManagerService networkPolicyF = networkPolicy;
Dianne Hackborna34f1ad2009-09-02 13:26:28 -0700992 final ConnectivityService connectivityF = connectivity;
993 final DockObserver dockF = dock;
Mike Lockwood770126a2010-12-09 22:30:37 -0800994 final UsbService usbF = usb;
Dianne Hackborna34f1ad2009-09-02 13:26:28 -0700995 final WallpaperManagerService wallpaperF = wallpaper;
996 final InputMethodManagerService immF = imm;
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800997 final RecognitionManagerService recognitionF = recognition;
Mike Lockwood46db5042010-02-22 16:36:44 -0500998 final LocationManagerService locationF = location;
Bai Taoa58a8752010-07-13 15:32:16 +0800999 final CountryDetectorService countryDetectorF = countryDetector;
Amith Yamasani6734b9f2010-09-13 16:24:08 -07001000 final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater;
John Grossmanc1576732012-02-01 15:23:33 -08001001 final CommonTimeManagementService commonTimeMgmtServiceF = commonTimeMgmtService;
satok988323c2011-06-22 16:38:13 +09001002 final TextServicesManagerService textServiceManagerServiceF = tsms;
Dianne Hackborn661cd522011-08-22 00:26:20 -07001003 final StatusBarManagerService statusBarF = statusBar;
Daniel Sandler7d276c32012-01-30 14:33:52 -05001004 final DreamManagerService dreamyF = dreamy;
Romain Guy3b748a42013-04-17 18:54:38 -07001005 final AssetAtlasService atlasF = atlas;
Jeff Brown6ec6f792012-04-17 16:52:41 -07001006 final InputManagerService inputManagerF = inputManager;
Wink Savillea12a7b32012-09-20 10:09:45 -07001007 final TelephonyRegistry telephonyRegistryF = telephonyRegistry;
Jeff Brown69b07162013-11-07 00:30:16 -08001008 final MediaRouterService mediaRouterF = mediaRouter;
Doug Zongkerab5c49c2009-12-04 10:31:43 -08001009
Dianne Hackborna34f1ad2009-09-02 13:26:28 -07001010 // We now tell the activity manager it is okay to run third party
1011 // code. It will call back into us once it has gotten to the state
1012 // where third party code can really run (but before it has actually
1013 // started launching the initial applications), for us to complete our
1014 // initialization.
Jeff Brown4ccb8232014-01-16 22:16:42 -08001015 mActivityManagerService.systemReady(new Runnable() {
Dianne Hackborna34f1ad2009-09-02 13:26:28 -07001016 public void run() {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001017 Slog.i(TAG, "Making services ready");
Doug Zongkerab5c49c2009-12-04 10:31:43 -08001018
Christopher Tate58d380d2013-03-19 13:10:03 -07001019 try {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001020 mActivityManagerService.startObservingNativeCrashes();
Christopher Tate58d380d2013-03-19 13:10:03 -07001021 } catch (Throwable e) {
1022 reportWtf("observing native crashes", e);
1023 }
Amith Yamasanib6fda092013-11-14 19:24:44 -08001024 try {
1025 startSystemUi(contextF);
1026 } catch (Throwable e) {
1027 reportWtf("starting System UI", e);
1028 }
Dianne Hackborn661cd522011-08-22 00:26:20 -07001029 try {
Jeff Sharkeyb049e212012-09-07 23:16:01 -07001030 if (mountServiceF != null) mountServiceF.systemReady();
1031 } catch (Throwable e) {
1032 reportWtf("making Mount Service ready", e);
1033 }
1034 try {
Dianne Hackborn661cd522011-08-22 00:26:20 -07001035 if (batteryF != null) batteryF.systemReady();
1036 } catch (Throwable e) {
1037 reportWtf("making Battery Service ready", e);
1038 }
1039 try {
1040 if (networkManagementF != null) networkManagementF.systemReady();
1041 } catch (Throwable e) {
1042 reportWtf("making Network Managment Service ready", e);
1043 }
1044 try {
1045 if (networkStatsF != null) networkStatsF.systemReady();
1046 } catch (Throwable e) {
1047 reportWtf("making Network Stats Service ready", e);
1048 }
1049 try {
1050 if (networkPolicyF != null) networkPolicyF.systemReady();
1051 } catch (Throwable e) {
1052 reportWtf("making Network Policy Service ready", e);
1053 }
1054 try {
1055 if (connectivityF != null) connectivityF.systemReady();
1056 } catch (Throwable e) {
1057 reportWtf("making Connectivity Service ready", e);
1058 }
1059 try {
1060 if (dockF != null) dockF.systemReady();
1061 } catch (Throwable e) {
1062 reportWtf("making Dock Service ready", e);
1063 }
1064 try {
1065 if (usbF != null) usbF.systemReady();
1066 } catch (Throwable e) {
1067 reportWtf("making USB Service ready", e);
1068 }
1069 try {
Dianne Hackborn661cd522011-08-22 00:26:20 -07001070 if (recognitionF != null) recognitionF.systemReady();
1071 } catch (Throwable e) {
1072 reportWtf("making Recognition Service ready", e);
1073 }
Dianne Hackborna34f1ad2009-09-02 13:26:28 -07001074 Watchdog.getInstance().start();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001075
Dianne Hackborna34f1ad2009-09-02 13:26:28 -07001076 // It is now okay to let the various system services start their
1077 // third party code...
Jeff Brown6f357d32014-01-15 20:40:55 -08001078 mSystemServiceManager.startBootPhase(SystemService.PHASE_THIRD_PARTY_APPS_CAN_START);
Doug Zongkerab5c49c2009-12-04 10:31:43 -08001079
Dianne Hackborn661cd522011-08-22 00:26:20 -07001080 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001081 if (wallpaperF != null) wallpaperF.systemRunning();
Dianne Hackborn661cd522011-08-22 00:26:20 -07001082 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001083 reportWtf("Notifying WallpaperService running", e);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001084 }
1085 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001086 if (immF != null) immF.systemRunning(statusBarF);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001087 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001088 reportWtf("Notifying InputMethodService running", e);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001089 }
1090 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001091 if (locationF != null) locationF.systemRunning();
Dianne Hackborn661cd522011-08-22 00:26:20 -07001092 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001093 reportWtf("Notifying Location Service running", e);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001094 }
1095 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001096 if (countryDetectorF != null) countryDetectorF.systemRunning();
Dianne Hackborn661cd522011-08-22 00:26:20 -07001097 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001098 reportWtf("Notifying CountryDetectorService running", e);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001099 }
1100 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001101 if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemRunning();
Dianne Hackborn661cd522011-08-22 00:26:20 -07001102 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001103 reportWtf("Notifying NetworkTimeService running", e);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001104 }
1105 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001106 if (commonTimeMgmtServiceF != null) commonTimeMgmtServiceF.systemRunning();
John Grossmanc1576732012-02-01 15:23:33 -08001107 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001108 reportWtf("Notifying CommonTimeManagementService running", e);
John Grossmanc1576732012-02-01 15:23:33 -08001109 }
1110 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001111 if (textServiceManagerServiceF != null)
1112 textServiceManagerServiceF.systemRunning();
Dianne Hackborn661cd522011-08-22 00:26:20 -07001113 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001114 reportWtf("Notifying TextServicesManagerService running", e);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001115 }
Daniel Sandler7d276c32012-01-30 14:33:52 -05001116 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001117 if (dreamyF != null) dreamyF.systemRunning();
Daniel Sandler7d276c32012-01-30 14:33:52 -05001118 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001119 reportWtf("Notifying DreamManagerService running", e);
Daniel Sandler7d276c32012-01-30 14:33:52 -05001120 }
Jeff Brown6ec6f792012-04-17 16:52:41 -07001121 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001122 if (atlasF != null) atlasF.systemRunning();
Romain Guy3b748a42013-04-17 18:54:38 -07001123 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001124 reportWtf("Notifying AssetAtlasService running", e);
Romain Guy3b748a42013-04-17 18:54:38 -07001125 }
1126 try {
Matthew Xie96313142012-06-29 16:57:31 -07001127 // TODO(BT) Pass parameter to input manager
Svetoslav Ganova0027152013-06-25 14:59:53 -07001128 if (inputManagerF != null) inputManagerF.systemRunning();
Jeff Brown6ec6f792012-04-17 16:52:41 -07001129 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001130 reportWtf("Notifying InputManagerService running", e);
Jeff Brown6ec6f792012-04-17 16:52:41 -07001131 }
Dan Morrille4d9a012013-03-28 18:10:43 -07001132
Wink Savillea12a7b32012-09-20 10:09:45 -07001133 try {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001134 if (telephonyRegistryF != null) telephonyRegistryF.systemRunning();
Wink Savillea12a7b32012-09-20 10:09:45 -07001135 } catch (Throwable e) {
Svetoslav Ganova0027152013-06-25 14:59:53 -07001136 reportWtf("Notifying TelephonyRegistry running", e);
1137 }
1138
1139 try {
Jeff Brown69b07162013-11-07 00:30:16 -08001140 if (mediaRouterF != null) mediaRouterF.systemRunning();
1141 } catch (Throwable e) {
1142 reportWtf("Notifying MediaRouterService running", e);
1143 }
Adam Lesinskief2ea1f2013-12-05 16:48:06 -08001144
Jeff Brown6f357d32014-01-15 20:40:55 -08001145 mSystemServiceManager.startBootPhase(SystemService.PHASE_BOOT_COMPLETE);
Dianne Hackborna34f1ad2009-09-02 13:26:28 -07001146 }
1147 });
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001148 }
Joe Onoratof3c3c4f2010-10-21 11:09:02 -04001149
1150 static final void startSystemUi(Context context) {
1151 Intent intent = new Intent();
1152 intent.setComponent(new ComponentName("com.android.systemui",
1153 "com.android.systemui.SystemUIService"));
Dianne Hackborn40e9f292012-11-27 19:12:23 -08001154 //Slog.d(TAG, "Starting service: " + intent);
Amith Yamasanicd757062012-10-19 18:23:52 -07001155 context.startServiceAsUser(intent, UserHandle.OWNER);
Joe Onoratof3c3c4f2010-10-21 11:09:02 -04001156 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001157}