The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server; |
| 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.app.ActivityManagerNative; |
Nick Pelly | f242b7b | 2009-10-08 00:12:45 +0200 | [diff] [blame] | 20 | import android.bluetooth.BluetoothAdapter; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 21 | import android.content.ComponentName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.content.ContentResolver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.content.Context; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 24 | import android.content.Intent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.content.pm.IPackageManager; |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 26 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.media.AudioService; |
Irfan Sheriff | f6d0984 | 2011-08-03 15:37:08 -0700 | [diff] [blame] | 28 | import android.net.wifi.p2p.WifiP2pService; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 29 | import android.os.Handler; |
| 30 | import android.os.HandlerThread; |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 31 | import android.os.Looper; |
| 32 | import android.os.RemoteException; |
| 33 | import android.os.ServiceManager; |
Brad Fitzpatrick | c74a1b44 | 2010-09-10 16:03:29 -0700 | [diff] [blame] | 34 | import android.os.StrictMode; |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 35 | import android.os.SystemClock; |
| 36 | import android.os.SystemProperties; |
Amith Yamasani | cd75706 | 2012-10-19 18:23:52 -0700 | [diff] [blame] | 37 | import android.os.UserHandle; |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 38 | import android.service.dreams.DreamService; |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 39 | import android.util.DisplayMetrics; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | import android.util.EventLog; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 41 | import android.util.Log; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 42 | import android.util.Slog; |
Brad Fitzpatrick | 5fdc0c7 | 2010-10-12 13:12:18 -0700 | [diff] [blame] | 43 | import android.view.WindowManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 45 | import com.android.internal.R; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 46 | import com.android.internal.os.BinderInternal; |
| 47 | import com.android.internal.os.SamplingProfilerIntegration; |
| 48 | import com.android.server.accessibility.AccessibilityManagerService; |
Jeff Sharkey | 7a96c39 | 2012-11-15 14:01:46 -0800 | [diff] [blame] | 49 | import com.android.server.accounts.AccountManagerService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 50 | import com.android.server.am.ActivityManagerService; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 51 | import com.android.server.am.BatteryStatsService; |
Jeff Sharkey | 7a96c39 | 2012-11-15 14:01:46 -0800 | [diff] [blame] | 52 | import com.android.server.content.ContentService; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 53 | import com.android.server.display.DisplayManagerService; |
Jeff Brown | cef440f | 2012-09-25 18:58:48 -0700 | [diff] [blame] | 54 | import com.android.server.dreams.DreamManagerService; |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 55 | import com.android.server.input.InputManagerService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 56 | import com.android.server.net.NetworkPolicyManagerService; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 57 | import com.android.server.net.NetworkStatsService; |
Jeff Sharkey | 7a96c39 | 2012-11-15 14:01:46 -0800 | [diff] [blame] | 58 | import com.android.server.os.SchedulingPolicyService; |
Jeff Brown | f69c812 | 2012-09-12 17:00:34 -0700 | [diff] [blame] | 59 | import com.android.server.pm.Installer; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 60 | import com.android.server.pm.PackageManagerService; |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 61 | import com.android.server.pm.UserManagerService; |
Jeff Brown | 4f8ecd8 | 2012-06-18 18:29:13 -0700 | [diff] [blame] | 62 | import com.android.server.power.PowerManagerService; |
| 63 | import com.android.server.power.ShutdownThread; |
Jeff Sharkey | 7a96c39 | 2012-11-15 14:01:46 -0800 | [diff] [blame] | 64 | import com.android.server.search.SearchManagerService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 65 | import com.android.server.usb.UsbService; |
Irfan Sheriff | d017f35 | 2013-02-20 13:30:44 -0800 | [diff] [blame] | 66 | import com.android.server.wifi.WifiService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 67 | import com.android.server.wm.WindowManagerService; |
| 68 | |
| 69 | import dalvik.system.VMRuntime; |
| 70 | import dalvik.system.Zygote; |
| 71 | |
Dan Egnor | 4410ec8 | 2009-09-11 16:40:01 -0700 | [diff] [blame] | 72 | import java.io.File; |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 73 | import java.util.Timer; |
| 74 | import java.util.TimerTask; |
| 75 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | class ServerThread extends Thread { |
| 77 | private static final String TAG = "SystemServer"; |
Ben Komalo | 553acf0 | 2011-09-19 14:25:28 -0700 | [diff] [blame] | 78 | private static final String ENCRYPTING_STATE = "trigger_restart_min_framework"; |
Ben Komalo | 3573d40 | 2011-09-23 15:08:24 -0700 | [diff] [blame] | 79 | private static final String ENCRYPTED_STATE = "1"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 81 | ContentResolver mContentResolver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 83 | void reportWtf(String msg, Throwable e) { |
| 84 | Slog.w(TAG, "***********************************************"); |
| 85 | Log.wtf(TAG, "BOOT FAILURE " + msg, e); |
| 86 | } |
| 87 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | @Override |
| 89 | public void run() { |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 90 | EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | SystemClock.uptimeMillis()); |
| 92 | |
Vairavan Srinivasan | 04b74ec | 2012-02-02 22:12:19 -0800 | [diff] [blame] | 93 | Looper.prepareMainLooper(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | |
| 95 | android.os.Process.setThreadPriority( |
| 96 | android.os.Process.THREAD_PRIORITY_FOREGROUND); |
| 97 | |
Dianne Hackborn | 887f355 | 2009-12-07 17:59:37 -0800 | [diff] [blame] | 98 | BinderInternal.disableBackgroundScheduling(true); |
Christopher Tate | 160edb3 | 2010-06-30 17:46:30 -0700 | [diff] [blame] | 99 | android.os.Process.setCanSelfBackground(false); |
Sen Hu | bde7570 | 2010-05-28 01:54:03 -0700 | [diff] [blame] | 100 | |
Kenny Root | f547d67 | 2010-09-22 10:36:48 -0700 | [diff] [blame] | 101 | // Check whether we failed to shut down last time we tried. |
| 102 | { |
| 103 | final String shutdownAction = SystemProperties.get( |
| 104 | ShutdownThread.SHUTDOWN_ACTION_PROPERTY, ""); |
| 105 | if (shutdownAction != null && shutdownAction.length() > 0) { |
| 106 | boolean reboot = (shutdownAction.charAt(0) == '1'); |
| 107 | |
| 108 | final String reason; |
| 109 | if (shutdownAction.length() > 1) { |
| 110 | reason = shutdownAction.substring(1, shutdownAction.length()); |
| 111 | } else { |
| 112 | reason = null; |
| 113 | } |
| 114 | |
| 115 | ShutdownThread.rebootOrShutdown(reboot, reason); |
| 116 | } |
| 117 | } |
| 118 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | String factoryTestStr = SystemProperties.get("ro.factorytest"); |
| 120 | int factoryTest = "".equals(factoryTestStr) ? SystemServer.FACTORY_TEST_OFF |
| 121 | : Integer.parseInt(factoryTestStr); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 122 | final boolean headless = "1".equals(SystemProperties.get("ro.config.headless", "0")); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | |
Jeff Brown | f69c812 | 2012-09-12 17:00:34 -0700 | [diff] [blame] | 124 | Installer installer = null; |
Kenny Root | 26ff662 | 2012-07-30 12:58:03 -0700 | [diff] [blame] | 125 | AccountManagerService accountManager = null; |
| 126 | ContentService contentService = null; |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 127 | LightsService lights = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | PowerManagerService power = null; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 129 | DisplayManagerService display = null; |
Mike Lockwood | 07a500f | 2009-08-12 09:56:44 -0400 | [diff] [blame] | 130 | BatteryService battery = null; |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 131 | VibratorService vibrator = null; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 132 | AlarmManagerService alarm = null; |
Jeff Sharkey | b049e21 | 2012-09-07 23:16:01 -0700 | [diff] [blame] | 133 | MountService mountService = null; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 134 | NetworkManagementService networkManagement = null; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 135 | NetworkStatsService networkStats = null; |
Jeff Sharkey | a462079 | 2011-05-20 15:29:23 -0700 | [diff] [blame] | 136 | NetworkPolicyManagerService networkPolicy = null; |
Mike Lockwood | 0f79b54 | 2009-08-14 14:18:49 -0400 | [diff] [blame] | 137 | ConnectivityService connectivity = null; |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 138 | WifiP2pService wifiP2p = null; |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 139 | WifiService wifi = null; |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 140 | NsdService serviceDiscovery= null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | IPackageManager pm = null; |
| 142 | Context context = null; |
| 143 | WindowManagerService wm = null; |
fredc | 0f42037 | 2012-04-12 00:02:00 -0700 | [diff] [blame] | 144 | BluetoothManagerService bluetooth = null; |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 145 | DockObserver dock = null; |
Mike Lockwood | 770126a | 2010-12-09 22:30:37 -0800 | [diff] [blame] | 146 | UsbService usb = null; |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 147 | SerialService serial = null; |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 148 | TwilightService twilight = null; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 149 | UiModeManagerService uiMode = null; |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 150 | RecognitionManagerService recognition = null; |
Amith Yamasani | 6734b9f6 | 2010-09-13 16:24:08 -0700 | [diff] [blame] | 151 | NetworkTimeUpdateService networkTimeUpdater = null; |
John Grossman | c157673 | 2012-02-01 15:23:33 -0800 | [diff] [blame] | 152 | CommonTimeManagementService commonTimeMgmtService = null; |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 153 | InputManagerService inputManager = null; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 154 | TelephonyRegistry telephonyRegistry = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 156 | // Create a shared handler thread for UI within the system server. |
| 157 | // This thread is used by at least the following components: |
| 158 | // - WindowManagerPolicy |
| 159 | // - KeyguardViewManager |
| 160 | // - DisplayManagerService |
| 161 | HandlerThread uiHandlerThread = new HandlerThread("UI"); |
| 162 | uiHandlerThread.start(); |
| 163 | Handler uiHandler = new Handler(uiHandlerThread.getLooper()); |
| 164 | uiHandler.post(new Runnable() { |
| 165 | @Override |
| 166 | public void run() { |
| 167 | //Looper.myLooper().setMessageLogging(new LogPrinter( |
| 168 | // Log.VERBOSE, "WindowManagerPolicy", Log.LOG_ID_SYSTEM)); |
| 169 | android.os.Process.setThreadPriority( |
| 170 | android.os.Process.THREAD_PRIORITY_FOREGROUND); |
| 171 | android.os.Process.setCanSelfBackground(false); |
| 172 | |
| 173 | // For debug builds, log event loop stalls to dropbox for analysis. |
| 174 | if (StrictMode.conditionallyEnableDebugLogging()) { |
| 175 | Slog.i(TAG, "Enabled StrictMode logging for UI Looper"); |
| 176 | } |
| 177 | } |
| 178 | }); |
| 179 | |
| 180 | // Create a handler thread just for the window manager to enjoy. |
| 181 | HandlerThread wmHandlerThread = new HandlerThread("WindowManager"); |
| 182 | wmHandlerThread.start(); |
| 183 | Handler wmHandler = new Handler(wmHandlerThread.getLooper()); |
| 184 | wmHandler.post(new Runnable() { |
| 185 | @Override |
| 186 | public void run() { |
| 187 | //Looper.myLooper().setMessageLogging(new LogPrinter( |
| 188 | // android.util.Log.DEBUG, TAG, android.util.Log.LOG_ID_SYSTEM)); |
| 189 | android.os.Process.setThreadPriority( |
| 190 | android.os.Process.THREAD_PRIORITY_DISPLAY); |
| 191 | android.os.Process.setCanSelfBackground(false); |
| 192 | |
| 193 | // For debug builds, log event loop stalls to dropbox for analysis. |
| 194 | if (StrictMode.conditionallyEnableDebugLogging()) { |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 195 | Slog.i(TAG, "Enabled StrictMode logging for WM Looper"); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | }); |
| 199 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 200 | // bootstrap services |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 201 | boolean onlyCore = false; |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 202 | boolean firstBoot = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 203 | try { |
Jeff Brown | f69c812 | 2012-09-12 17:00:34 -0700 | [diff] [blame] | 204 | // Wait for installd to finished starting up so that it has a chance to |
| 205 | // create critical directories such as /data/user with the appropriate |
| 206 | // permissions. We need this to complete before we initialize other services. |
| 207 | Slog.i(TAG, "Waiting for installd to be ready."); |
| 208 | installer = new Installer(); |
| 209 | installer.ping(); |
| 210 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 211 | Slog.i(TAG, "Power Manager"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | power = new PowerManagerService(); |
| 213 | ServiceManager.addService(Context.POWER_SERVICE, power); |
| 214 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 215 | Slog.i(TAG, "Activity Manager"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 216 | context = ActivityManagerService.main(factoryTest); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 217 | } catch (RuntimeException e) { |
| 218 | Slog.e("System", "******************************************"); |
| 219 | Slog.e("System", "************ Failure starting bootstrap service", e); |
| 220 | } |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 221 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 222 | boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false); |
| 223 | boolean disableMedia = SystemProperties.getBoolean("config.disable_media", false); |
| 224 | boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false); |
| 225 | boolean disableTelephony = SystemProperties.getBoolean("config.disable_telephony", false); |
| 226 | boolean disableLocation = SystemProperties.getBoolean("config.disable_location", false); |
| 227 | boolean disableSystemUI = SystemProperties.getBoolean("config.disable_systemui", false); |
| 228 | boolean disableNonCoreServices = SystemProperties.getBoolean("config.disable_noncore", false); |
| 229 | boolean disableNetwork = SystemProperties.getBoolean("config.disable_network", false); |
| 230 | |
| 231 | try { |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 232 | Slog.i(TAG, "Display Manager"); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 233 | display = new DisplayManagerService(context, wmHandler, uiHandler); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 234 | ServiceManager.addService(Context.DISPLAY_SERVICE, display, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 235 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 236 | Slog.i(TAG, "Telephony Registry"); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 237 | telephonyRegistry = new TelephonyRegistry(context); |
| 238 | ServiceManager.addService("telephony.registry", telephonyRegistry); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 239 | |
Glenn Kasten | 07b0465 | 2012-04-23 15:00:43 -0700 | [diff] [blame] | 240 | Slog.i(TAG, "Scheduling Policy"); |
| 241 | ServiceManager.addService(Context.SCHEDULING_POLICY_SERVICE, |
| 242 | new SchedulingPolicyService()); |
| 243 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 244 | AttributeCache.init(context); |
| 245 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 246 | if (!display.waitForDefaultDisplay()) { |
| 247 | reportWtf("Timeout waiting for default display to be initialized.", |
| 248 | new Throwable()); |
| 249 | } |
| 250 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 251 | Slog.i(TAG, "Package Manager"); |
Ben Komalo | 553acf0 | 2011-09-19 14:25:28 -0700 | [diff] [blame] | 252 | // Only run "core" apps if we're encrypting the device. |
| 253 | String cryptState = SystemProperties.get("vold.decrypt"); |
Ben Komalo | 3573d40 | 2011-09-23 15:08:24 -0700 | [diff] [blame] | 254 | if (ENCRYPTING_STATE.equals(cryptState)) { |
Ben Komalo | 553acf0 | 2011-09-19 14:25:28 -0700 | [diff] [blame] | 255 | Slog.w(TAG, "Detected encryption in progress - only parsing core apps"); |
Ben Komalo | 3573d40 | 2011-09-23 15:08:24 -0700 | [diff] [blame] | 256 | onlyCore = true; |
| 257 | } else if (ENCRYPTED_STATE.equals(cryptState)) { |
| 258 | Slog.w(TAG, "Device encrypted - only parsing core apps"); |
| 259 | onlyCore = true; |
Ben Komalo | 553acf0 | 2011-09-19 14:25:28 -0700 | [diff] [blame] | 260 | } |
Ben Komalo | 3573d40 | 2011-09-23 15:08:24 -0700 | [diff] [blame] | 261 | |
Jeff Brown | f69c812 | 2012-09-12 17:00:34 -0700 | [diff] [blame] | 262 | pm = PackageManagerService.main(context, installer, |
Dianne Hackborn | d2509fd | 2011-09-12 12:29:43 -0700 | [diff] [blame] | 263 | factoryTest != SystemServer.FACTORY_TEST_OFF, |
Ben Komalo | 553acf0 | 2011-09-19 14:25:28 -0700 | [diff] [blame] | 264 | onlyCore); |
Dianne Hackborn | 58f42a5 | 2011-10-10 13:46:34 -0700 | [diff] [blame] | 265 | try { |
| 266 | firstBoot = pm.isFirstBoot(); |
| 267 | } catch (RemoteException e) { |
| 268 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 269 | |
| 270 | ActivityManagerService.setSystemProcess(); |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 271 | |
Nick Kralevich | 79619dd | 2013-03-04 13:05:32 -0800 | [diff] [blame] | 272 | Slog.i(TAG, "Entropy Mixer"); |
| 273 | ServiceManager.addService("entropy", new EntropyMixer(context)); |
| 274 | |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 275 | Slog.i(TAG, "User Service"); |
| 276 | ServiceManager.addService(Context.USER_SERVICE, |
Dianne Hackborn | 4428e17c | 2012-08-24 17:43:05 -0700 | [diff] [blame] | 277 | UserManagerService.getInstance()); |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 278 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 279 | mContentResolver = context.getContentResolver(); |
| 280 | |
Fred Quintana | e91ebe2 | 2009-09-29 20:44:30 -0700 | [diff] [blame] | 281 | // The AccountManager must come before the ContentService |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 282 | try { |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 283 | // TODO: seems like this should be disable-able, but req'd by ContentService |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 284 | Slog.i(TAG, "Account Manager"); |
Kenny Root | 26ff662 | 2012-07-30 12:58:03 -0700 | [diff] [blame] | 285 | accountManager = new AccountManagerService(context); |
| 286 | ServiceManager.addService(Context.ACCOUNT_SERVICE, accountManager); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 287 | } catch (Throwable e) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 288 | Slog.e(TAG, "Failure starting Account Manager", e); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 291 | Slog.i(TAG, "Content Manager"); |
Kenny Root | 26ff662 | 2012-07-30 12:58:03 -0700 | [diff] [blame] | 292 | contentService = ContentService.main(context, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL); |
| 294 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 295 | Slog.i(TAG, "System Content Providers"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 296 | ActivityManagerService.installSystemProviders(); |
| 297 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 298 | Slog.i(TAG, "Lights Service"); |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 299 | lights = new LightsService(context); |
| 300 | |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 301 | Slog.i(TAG, "Battery Service"); |
| 302 | battery = new BatteryService(context, lights); |
| 303 | ServiceManager.addService("battery", battery); |
| 304 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 305 | Slog.i(TAG, "Vibrator Service"); |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 306 | vibrator = new VibratorService(context); |
| 307 | ServiceManager.addService("vibrator", vibrator); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 308 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 309 | // only initialize the power service after we have started the |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 310 | // lights service, content providers and the battery service. |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 311 | power.init(context, lights, ActivityManagerService.self(), battery, |
| 312 | BatteryStatsService.getService(), display); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 313 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 314 | Slog.i(TAG, "Alarm Manager"); |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 315 | alarm = new AlarmManagerService(context); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | ServiceManager.addService(Context.ALARM_SERVICE, alarm); |
| 317 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 318 | Slog.i(TAG, "Init Watchdog"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | Watchdog.getInstance().init(context, battery, power, alarm, |
| 320 | ActivityManagerService.self()); |
| 321 | |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 322 | Slog.i(TAG, "Input Manager"); |
| 323 | inputManager = new InputManagerService(context, wmHandler); |
| 324 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 325 | Slog.i(TAG, "Window Manager"); |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 326 | wm = WindowManagerService.main(context, power, display, inputManager, |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 327 | uiHandler, wmHandler, |
Dianne Hackborn | 58f42a5 | 2011-10-10 13:46:34 -0700 | [diff] [blame] | 328 | factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL, |
Jeff Brown | 780c46f | 2012-06-24 12:15:38 -0700 | [diff] [blame] | 329 | !firstBoot, onlyCore); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | ServiceManager.addService(Context.WINDOW_SERVICE, wm); |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 331 | ServiceManager.addService(Context.INPUT_SERVICE, inputManager); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 333 | ActivityManagerService.self().setWindowManager(wm); |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 334 | |
| 335 | inputManager.setWindowManagerCallbacks(wm.getInputMonitor()); |
| 336 | inputManager.start(); |
| 337 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 338 | display.setWindowManager(wm); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 339 | display.setInputManager(inputManager); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 340 | |
| 341 | // Skip Bluetooth if we have an emulator kernel |
| 342 | // TODO: Use a more reliable check to see if this product should |
| 343 | // support Bluetooth - see bug 988521 |
| 344 | if (SystemProperties.get("ro.kernel.qemu").equals("1")) { |
David 'Digit' Turner | e2a5e86 | 2011-01-17 00:32:33 +0100 | [diff] [blame] | 345 | Slog.i(TAG, "No Bluetooh Service (emulator)"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 346 | } else if (factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL) { |
David 'Digit' Turner | e2a5e86 | 2011-01-17 00:32:33 +0100 | [diff] [blame] | 347 | Slog.i(TAG, "No Bluetooth Service (factory test)"); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 348 | } else if (disableBluetooth) { |
| 349 | Slog.i(TAG, "Bluetooth Service disabled by config"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 350 | } else { |
fredc | 0f42037 | 2012-04-12 00:02:00 -0700 | [diff] [blame] | 351 | Slog.i(TAG, "Bluetooth Manager Service"); |
| 352 | bluetooth = new BluetoothManagerService(context); |
| 353 | ServiceManager.addService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE, bluetooth); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 354 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 355 | } catch (RuntimeException e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 356 | Slog.e("System", "******************************************"); |
| 357 | Slog.e("System", "************ Failure starting core service", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 358 | } |
| 359 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 360 | DevicePolicyManagerService devicePolicy = null; |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 361 | StatusBarManagerService statusBar = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 362 | InputMethodManagerService imm = null; |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 363 | AppWidgetService appWidget = null; |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 364 | NotificationManagerService notification = null; |
Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 365 | WallpaperManagerService wallpaper = null; |
Mike Lockwood | 46db504 | 2010-02-22 16:36:44 -0500 | [diff] [blame] | 366 | LocationManagerService location = null; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 367 | CountryDetectorService countryDetector = null; |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 368 | TextServicesManagerService tsms = null; |
Amith Yamasani | 52c489c | 2012-03-28 11:42:42 -0700 | [diff] [blame] | 369 | LockSettingsService lockSettings = null; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 370 | DreamManagerService dreamy = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 371 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 372 | // Bring up services needed for UI. |
| 373 | if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 374 | //if (!disableNonCoreServices) { // TODO: View depends on these; mock them? |
| 375 | if (true) { |
| 376 | try { |
| 377 | Slog.i(TAG, "Input Method Service"); |
| 378 | imm = new InputMethodManagerService(context, wm); |
| 379 | ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm); |
| 380 | } catch (Throwable e) { |
| 381 | reportWtf("starting Input Manager Service", e); |
| 382 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 383 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 384 | try { |
| 385 | Slog.i(TAG, "Accessibility Manager"); |
| 386 | ServiceManager.addService(Context.ACCESSIBILITY_SERVICE, |
| 387 | new AccessibilityManagerService(context)); |
| 388 | } catch (Throwable e) { |
| 389 | reportWtf("starting Accessibility Manager", e); |
| 390 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 391 | } |
| 392 | } |
| 393 | |
| 394 | try { |
| 395 | wm.displayReady(); |
| 396 | } catch (Throwable e) { |
| 397 | reportWtf("making display ready", e); |
| 398 | } |
Dianne Hackborn | 8795b60 | 2011-08-25 13:30:53 -0700 | [diff] [blame] | 399 | |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 400 | try { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 401 | pm.performBootDexOpt(); |
| 402 | } catch (Throwable e) { |
| 403 | reportWtf("performing boot dexopt", e); |
| 404 | } |
| 405 | |
| 406 | try { |
| 407 | ActivityManagerNative.getDefault().showBootMessage( |
| 408 | context.getResources().getText( |
| 409 | com.android.internal.R.string.android_upgrading_starting_apps), |
| 410 | false); |
| 411 | } catch (RemoteException e) { |
| 412 | } |
| 413 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 415 | if (!disableStorage && |
| 416 | !"0".equals(SystemProperties.get("system_init.startmountservice"))) { |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 417 | try { |
| 418 | /* |
| 419 | * NotificationManagerService is dependant on MountService, |
| 420 | * (for media / usb notifications) so we must start MountService first. |
| 421 | */ |
| 422 | Slog.i(TAG, "Mount Service"); |
| 423 | mountService = new MountService(context); |
| 424 | ServiceManager.addService("mount", mountService); |
| 425 | } catch (Throwable e) { |
| 426 | reportWtf("starting Mount Service", e); |
| 427 | } |
| 428 | } |
| 429 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 430 | if (!disableNonCoreServices) { |
| 431 | try { |
| 432 | Slog.i(TAG, "LockSettingsService"); |
| 433 | lockSettings = new LockSettingsService(context); |
| 434 | ServiceManager.addService("lock_settings", lockSettings); |
| 435 | } catch (Throwable e) { |
| 436 | reportWtf("starting LockSettingsService service", e); |
| 437 | } |
| 438 | |
| 439 | try { |
| 440 | Slog.i(TAG, "Device Policy"); |
| 441 | devicePolicy = new DevicePolicyManagerService(context); |
| 442 | ServiceManager.addService(Context.DEVICE_POLICY_SERVICE, devicePolicy); |
| 443 | } catch (Throwable e) { |
| 444 | reportWtf("starting DevicePolicyService", e); |
| 445 | } |
Amith Yamasani | 52c489c | 2012-03-28 11:42:42 -0700 | [diff] [blame] | 446 | } |
| 447 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 448 | if (!disableSystemUI) { |
| 449 | try { |
| 450 | Slog.i(TAG, "Status Bar"); |
| 451 | statusBar = new StatusBarManagerService(context, wm); |
| 452 | ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar); |
| 453 | } catch (Throwable e) { |
| 454 | reportWtf("starting StatusBarManagerService", e); |
| 455 | } |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 456 | } |
| 457 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 458 | if (!disableNonCoreServices) { |
| 459 | try { |
| 460 | Slog.i(TAG, "Clipboard Service"); |
| 461 | ServiceManager.addService(Context.CLIPBOARD_SERVICE, |
| 462 | new ClipboardService(context)); |
| 463 | } catch (Throwable e) { |
| 464 | reportWtf("starting Clipboard Service", e); |
| 465 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 466 | } |
| 467 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 468 | if (!disableNetwork) { |
| 469 | try { |
| 470 | Slog.i(TAG, "NetworkManagement Service"); |
| 471 | networkManagement = NetworkManagementService.create(context); |
| 472 | ServiceManager.addService(Context.NETWORKMANAGEMENT_SERVICE, networkManagement); |
| 473 | } catch (Throwable e) { |
| 474 | reportWtf("starting NetworkManagement Service", e); |
| 475 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 476 | } |
| 477 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 478 | if (!disableNonCoreServices) { |
| 479 | try { |
| 480 | Slog.i(TAG, "Text Service Manager Service"); |
| 481 | tsms = new TextServicesManagerService(context); |
| 482 | ServiceManager.addService(Context.TEXT_SERVICES_MANAGER_SERVICE, tsms); |
| 483 | } catch (Throwable e) { |
| 484 | reportWtf("starting Text Service Manager Service", e); |
| 485 | } |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 486 | } |
| 487 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 488 | if (!disableNetwork) { |
| 489 | try { |
| 490 | Slog.i(TAG, "NetworkStats Service"); |
| 491 | networkStats = new NetworkStatsService(context, networkManagement, alarm); |
| 492 | ServiceManager.addService(Context.NETWORK_STATS_SERVICE, networkStats); |
| 493 | } catch (Throwable e) { |
| 494 | reportWtf("starting NetworkStats Service", e); |
| 495 | } |
| 496 | |
| 497 | try { |
| 498 | Slog.i(TAG, "NetworkPolicy Service"); |
| 499 | networkPolicy = new NetworkPolicyManagerService( |
| 500 | context, ActivityManagerService.self(), power, |
| 501 | networkStats, networkManagement); |
| 502 | ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy); |
| 503 | } catch (Throwable e) { |
| 504 | reportWtf("starting NetworkPolicy Service", e); |
| 505 | } |
| 506 | |
| 507 | try { |
| 508 | Slog.i(TAG, "Wi-Fi P2pService"); |
| 509 | wifiP2p = new WifiP2pService(context); |
| 510 | ServiceManager.addService(Context.WIFI_P2P_SERVICE, wifiP2p); |
| 511 | } catch (Throwable e) { |
| 512 | reportWtf("starting Wi-Fi P2pService", e); |
| 513 | } |
| 514 | |
| 515 | try { |
| 516 | Slog.i(TAG, "Wi-Fi Service"); |
| 517 | wifi = new WifiService(context); |
| 518 | ServiceManager.addService(Context.WIFI_SERVICE, wifi); |
| 519 | } catch (Throwable e) { |
| 520 | reportWtf("starting Wi-Fi Service", e); |
| 521 | } |
| 522 | |
| 523 | try { |
| 524 | Slog.i(TAG, "Connectivity Service"); |
| 525 | connectivity = new ConnectivityService( |
| 526 | context, networkManagement, networkStats, networkPolicy); |
| 527 | ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity); |
| 528 | networkStats.bindConnectivityManager(connectivity); |
| 529 | networkPolicy.bindConnectivityManager(connectivity); |
| 530 | wifi.checkAndStartWifi(); |
| 531 | wifiP2p.connectivityServiceReady(); |
| 532 | } catch (Throwable e) { |
| 533 | reportWtf("starting Connectivity Service", e); |
| 534 | } |
| 535 | |
| 536 | try { |
| 537 | Slog.i(TAG, "Network Service Discovery Service"); |
| 538 | serviceDiscovery = NsdService.create(context); |
| 539 | ServiceManager.addService( |
| 540 | Context.NSD_SERVICE, serviceDiscovery); |
| 541 | } catch (Throwable e) { |
| 542 | reportWtf("starting Service Discovery Service", e); |
| 543 | } |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 544 | } |
| 545 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 546 | if (!disableNonCoreServices) { |
| 547 | try { |
| 548 | Slog.i(TAG, "UpdateLock Service"); |
| 549 | ServiceManager.addService(Context.UPDATE_LOCK_SERVICE, |
| 550 | new UpdateLockService(context)); |
| 551 | } catch (Throwable e) { |
| 552 | reportWtf("starting UpdateLockService", e); |
| 553 | } |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 554 | } |
| 555 | |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 556 | /* |
| 557 | * MountService has a few dependencies: Notification Manager and |
| 558 | * AppWidget Provider. Make sure MountService is completely started |
| 559 | * first before continuing. |
| 560 | */ |
| 561 | if (mountService != null) { |
| 562 | mountService.waitForAsecScan(); |
San Mehat | 1bf3f8b | 2010-02-03 14:43:09 -0800 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | try { |
Kenny Root | 26ff662 | 2012-07-30 12:58:03 -0700 | [diff] [blame] | 566 | if (accountManager != null) |
| 567 | accountManager.systemReady(); |
| 568 | } catch (Throwable e) { |
| 569 | reportWtf("making Account Manager Service ready", e); |
| 570 | } |
| 571 | |
| 572 | try { |
| 573 | if (contentService != null) |
| 574 | contentService.systemReady(); |
| 575 | } catch (Throwable e) { |
| 576 | reportWtf("making Content Service ready", e); |
| 577 | } |
| 578 | |
| 579 | try { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 580 | Slog.i(TAG, "Notification Manager"); |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 581 | notification = new NotificationManagerService(context, statusBar, lights); |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 582 | ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification); |
Jeff Sharkey | 497e443 | 2011-06-14 17:27:29 -0700 | [diff] [blame] | 583 | networkPolicy.bindNotificationManager(notification); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 584 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 585 | reportWtf("starting Notification Manager", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | try { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 589 | Slog.i(TAG, "Device Storage Monitor"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 590 | ServiceManager.addService(DeviceStorageMonitorService.SERVICE, |
| 591 | new DeviceStorageMonitorService(context)); |
| 592 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 593 | reportWtf("starting DeviceStorageMonitor service", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 594 | } |
| 595 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 596 | if (!disableLocation) { |
| 597 | try { |
| 598 | Slog.i(TAG, "Location Manager"); |
| 599 | location = new LocationManagerService(context); |
| 600 | ServiceManager.addService(Context.LOCATION_SERVICE, location); |
| 601 | } catch (Throwable e) { |
| 602 | reportWtf("starting Location Manager", e); |
| 603 | } |
| 604 | |
| 605 | try { |
| 606 | Slog.i(TAG, "Country Detector"); |
| 607 | countryDetector = new CountryDetectorService(context); |
| 608 | ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector); |
| 609 | } catch (Throwable e) { |
| 610 | reportWtf("starting Country Detector", e); |
| 611 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 612 | } |
| 613 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 614 | if (!disableNonCoreServices) { |
| 615 | try { |
| 616 | Slog.i(TAG, "Search Service"); |
| 617 | ServiceManager.addService(Context.SEARCH_SERVICE, |
| 618 | new SearchManagerService(context)); |
| 619 | } catch (Throwable e) { |
| 620 | reportWtf("starting Search Service", e); |
| 621 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 622 | } |
| 623 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 624 | try { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 625 | Slog.i(TAG, "DropBox Service"); |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 626 | ServiceManager.addService(Context.DROPBOX_SERVICE, |
Dan Egnor | f18a01c | 2009-11-12 11:32:50 -0800 | [diff] [blame] | 627 | new DropBoxManagerService(context, new File("/data/system/dropbox"))); |
Dan Egnor | 4410ec8 | 2009-09-11 16:40:01 -0700 | [diff] [blame] | 628 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 629 | reportWtf("starting DropBoxManagerService", e); |
Dan Egnor | 4410ec8 | 2009-09-11 16:40:01 -0700 | [diff] [blame] | 630 | } |
| 631 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 632 | if (!disableNonCoreServices && context.getResources().getBoolean( |
| 633 | R.bool.config_enableWallpaperService)) { |
Mike Lockwood | c067c9c | 2011-10-31 12:50:12 -0400 | [diff] [blame] | 634 | try { |
| 635 | Slog.i(TAG, "Wallpaper Service"); |
| 636 | if (!headless) { |
| 637 | wallpaper = new WallpaperManagerService(context); |
| 638 | ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper); |
| 639 | } |
| 640 | } catch (Throwable e) { |
| 641 | reportWtf("starting Wallpaper Service", e); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 642 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 643 | } |
| 644 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 645 | if (!disableMedia && !"0".equals(SystemProperties.get("system_init.startaudioservice"))) { |
Mike Lockwood | cba928c | 2011-08-17 15:58:52 -0700 | [diff] [blame] | 646 | try { |
| 647 | Slog.i(TAG, "Audio Service"); |
| 648 | ServiceManager.addService(Context.AUDIO_SERVICE, new AudioService(context)); |
| 649 | } catch (Throwable e) { |
| 650 | reportWtf("starting Audio Service", e); |
| 651 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 652 | } |
| 653 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 654 | if (!disableNonCoreServices) { |
| 655 | try { |
| 656 | Slog.i(TAG, "Dock Observer"); |
| 657 | // Listen for dock station changes |
| 658 | dock = new DockObserver(context); |
| 659 | } catch (Throwable e) { |
| 660 | reportWtf("starting DockObserver", e); |
| 661 | } |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 662 | } |
| 663 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 664 | if (!disableMedia) { |
| 665 | try { |
| 666 | Slog.i(TAG, "Wired Accessory Manager"); |
| 667 | // Listen for wired headset changes |
| 668 | inputManager.setWiredAccessoryCallbacks( |
| 669 | new WiredAccessoryManager(context, inputManager)); |
| 670 | } catch (Throwable e) { |
| 671 | reportWtf("starting WiredAccessoryManager", e); |
| 672 | } |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 673 | } |
| 674 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 675 | if (!disableNonCoreServices) { |
| 676 | try { |
| 677 | Slog.i(TAG, "USB Service"); |
| 678 | // Manage USB host and device support |
| 679 | usb = new UsbService(context); |
| 680 | ServiceManager.addService(Context.USB_SERVICE, usb); |
| 681 | } catch (Throwable e) { |
| 682 | reportWtf("starting UsbService", e); |
| 683 | } |
Mike Lockwood | 57c798a | 2010-06-23 17:36:36 -0400 | [diff] [blame] | 684 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 685 | try { |
| 686 | Slog.i(TAG, "Serial Service"); |
| 687 | // Serial port support |
| 688 | serial = new SerialService(context); |
| 689 | ServiceManager.addService(Context.SERIAL_SERVICE, serial); |
| 690 | } catch (Throwable e) { |
| 691 | Slog.e(TAG, "Failure starting SerialService", e); |
| 692 | } |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | try { |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 696 | Slog.i(TAG, "Twilight Service"); |
| 697 | twilight = new TwilightService(context); |
| 698 | } catch (Throwable e) { |
| 699 | reportWtf("starting TwilightService", e); |
| 700 | } |
| 701 | |
| 702 | try { |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 703 | Slog.i(TAG, "UI Mode Manager Service"); |
Mike Lockwood | 57c798a | 2010-06-23 17:36:36 -0400 | [diff] [blame] | 704 | // Listen for UI mode changes |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 705 | uiMode = new UiModeManagerService(context, twilight); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 706 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 707 | reportWtf("starting UiModeManagerService", e); |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 708 | } |
| 709 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 710 | if (!disableNonCoreServices) { |
| 711 | try { |
| 712 | Slog.i(TAG, "Backup Service"); |
| 713 | ServiceManager.addService(Context.BACKUP_SERVICE, |
| 714 | new BackupManagerService(context)); |
| 715 | } catch (Throwable e) { |
| 716 | Slog.e(TAG, "Failure starting Backup Service", e); |
| 717 | } |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 718 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 719 | try { |
| 720 | Slog.i(TAG, "AppWidget Service"); |
| 721 | appWidget = new AppWidgetService(context); |
| 722 | ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget); |
| 723 | } catch (Throwable e) { |
| 724 | reportWtf("starting AppWidget Service", e); |
| 725 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 726 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 727 | try { |
| 728 | Slog.i(TAG, "Recognition Service"); |
| 729 | recognition = new RecognitionManagerService(context); |
| 730 | } catch (Throwable e) { |
| 731 | reportWtf("starting Recognition Service", e); |
| 732 | } |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 733 | } |
Jaikumar Ganesh | 7d0548d | 2010-10-18 15:29:09 -0700 | [diff] [blame] | 734 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 735 | try { |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 736 | Slog.i(TAG, "DiskStats Service"); |
| 737 | ServiceManager.addService("diskstats", new DiskStatsService(context)); |
| 738 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 739 | reportWtf("starting DiskStats Service", e); |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 740 | } |
Sen Hu | bde7570 | 2010-05-28 01:54:03 -0700 | [diff] [blame] | 741 | |
| 742 | try { |
| 743 | // need to add this service even if SamplingProfilerIntegration.isEnabled() |
| 744 | // is false, because it is this service that detects system property change and |
| 745 | // turns on SamplingProfilerIntegration. Plus, when sampling profiler doesn't work, |
| 746 | // there is little overhead for running this service. |
| 747 | Slog.i(TAG, "SamplingProfiler Service"); |
| 748 | ServiceManager.addService("samplingprofiler", |
| 749 | new SamplingProfilerService(context)); |
| 750 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 751 | reportWtf("starting SamplingProfiler Service", e); |
Sen Hu | bde7570 | 2010-05-28 01:54:03 -0700 | [diff] [blame] | 752 | } |
Chung-yih Wang | 024d596 | 2010-08-06 12:06:04 +0800 | [diff] [blame] | 753 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 754 | if (!disableNetwork) { |
| 755 | try { |
| 756 | Slog.i(TAG, "NetworkTimeUpdateService"); |
| 757 | networkTimeUpdater = new NetworkTimeUpdateService(context); |
| 758 | } catch (Throwable e) { |
| 759 | reportWtf("starting NetworkTimeUpdate service", e); |
| 760 | } |
Amith Yamasani | 6734b9f6 | 2010-09-13 16:24:08 -0700 | [diff] [blame] | 761 | } |
John Grossman | c157673 | 2012-02-01 15:23:33 -0800 | [diff] [blame] | 762 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 763 | if (!disableMedia) { |
| 764 | try { |
| 765 | Slog.i(TAG, "CommonTimeManagementService"); |
| 766 | commonTimeMgmtService = new CommonTimeManagementService(context); |
| 767 | ServiceManager.addService("commontime_management", commonTimeMgmtService); |
| 768 | } catch (Throwable e) { |
| 769 | reportWtf("starting CommonTimeManagementService service", e); |
| 770 | } |
John Grossman | c157673 | 2012-02-01 15:23:33 -0800 | [diff] [blame] | 771 | } |
Geremy Condra | 3d33c26 | 2012-05-06 18:32:19 -0700 | [diff] [blame] | 772 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 773 | if (!disableNetwork) { |
| 774 | try { |
| 775 | Slog.i(TAG, "CertBlacklister"); |
| 776 | CertBlacklister blacklister = new CertBlacklister(context); |
| 777 | } catch (Throwable e) { |
| 778 | reportWtf("starting CertBlacklister", e); |
| 779 | } |
Geremy Condra | 3d33c26 | 2012-05-06 18:32:19 -0700 | [diff] [blame] | 780 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 781 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 782 | if (!disableNonCoreServices && |
| 783 | context.getResources().getBoolean(R.bool.config_dreamsSupported)) { |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 784 | try { |
| 785 | Slog.i(TAG, "Dreams Service"); |
| 786 | // Dreams (interactive idle-time views, a/k/a screen savers) |
Jeff Brown | 62c82e4 | 2012-09-26 01:30:41 -0700 | [diff] [blame] | 787 | dreamy = new DreamManagerService(context, wmHandler); |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 788 | ServiceManager.addService(DreamService.DREAM_SERVICE, dreamy); |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 789 | } catch (Throwable e) { |
| 790 | reportWtf("starting DreamManagerService", e); |
| 791 | } |
| 792 | } |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 793 | |
| 794 | try { |
| 795 | Slog.i(TAG, "IdleMaintenanceService"); |
| 796 | new IdleMaintenanceService(context); |
| 797 | } catch (Throwable e) { |
| 798 | reportWtf("starting IdleMaintenanceService", e); |
| 799 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 800 | } |
| 801 | |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 802 | // Before things start rolling, be sure we have decided whether |
| 803 | // we are in safe mode. |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 804 | final boolean safeMode = wm.detectSafeMode(); |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 805 | if (safeMode) { |
Jeff Brown | b09abc1 | 2011-01-13 21:08:27 -0800 | [diff] [blame] | 806 | ActivityManagerService.self().enterSafeMode(); |
| 807 | // Post the safe mode state in the Zygote class |
| 808 | Zygote.systemInSafeMode = true; |
| 809 | // Disable the JIT for the system_server process |
| 810 | VMRuntime.getRuntime().disableJitCompilation(); |
Ben Cheng | 6c0afff | 2010-02-14 16:18:56 -0800 | [diff] [blame] | 811 | } else { |
| 812 | // Enable the JIT for the system_server process |
| 813 | VMRuntime.getRuntime().startJitCompilation(); |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 814 | } |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 815 | |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 816 | // It is now time to start up the app processes... |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 817 | |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 818 | try { |
| 819 | vibrator.systemReady(); |
| 820 | } catch (Throwable e) { |
| 821 | reportWtf("making Vibrator Service ready", e); |
| 822 | } |
| 823 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 824 | if (lockSettings != null) { |
| 825 | try { |
| 826 | lockSettings.systemReady(); |
| 827 | } catch (Throwable e) { |
| 828 | reportWtf("making Lock Settings Service ready", e); |
| 829 | } |
Felipe Ramos | f35df5b | 2012-09-18 18:26:27 -0300 | [diff] [blame] | 830 | } |
| 831 | |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 832 | if (devicePolicy != null) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 833 | try { |
| 834 | devicePolicy.systemReady(); |
| 835 | } catch (Throwable e) { |
| 836 | reportWtf("making Device Policy Service ready", e); |
| 837 | } |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 838 | } |
| 839 | |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 840 | if (notification != null) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 841 | try { |
| 842 | notification.systemReady(); |
| 843 | } catch (Throwable e) { |
| 844 | reportWtf("making Notification Service ready", e); |
| 845 | } |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 846 | } |
| 847 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 848 | try { |
| 849 | wm.systemReady(); |
| 850 | } catch (Throwable e) { |
| 851 | reportWtf("making Window Manager Service ready", e); |
| 852 | } |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 853 | |
Jeff Brown | b09abc1 | 2011-01-13 21:08:27 -0800 | [diff] [blame] | 854 | if (safeMode) { |
| 855 | ActivityManagerService.self().showSafeModeOverlay(); |
| 856 | } |
| 857 | |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 858 | // Update the configuration for this context by hand, because we're going |
| 859 | // to start using it before the config change done in wm.systemReady() will |
| 860 | // propagate to it. |
| 861 | Configuration config = wm.computeNewConfiguration(); |
| 862 | DisplayMetrics metrics = new DisplayMetrics(); |
| 863 | WindowManager w = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 864 | w.getDefaultDisplay().getMetrics(metrics); |
| 865 | context.getResources().updateConfiguration(config, metrics); |
| 866 | |
Jeff Brown | aa202a6 | 2012-08-21 22:14:26 -0700 | [diff] [blame] | 867 | try { |
Jeff Brown | 62c82e4 | 2012-09-26 01:30:41 -0700 | [diff] [blame] | 868 | power.systemReady(twilight, dreamy); |
Jeff Brown | aa202a6 | 2012-08-21 22:14:26 -0700 | [diff] [blame] | 869 | } catch (Throwable e) { |
| 870 | reportWtf("making Power Manager Service ready", e); |
| 871 | } |
| 872 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 873 | try { |
| 874 | pm.systemReady(); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 875 | } catch (Throwable e) { |
| 876 | reportWtf("making Package Manager Service ready", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 877 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 878 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 879 | try { |
| 880 | display.systemReady(safeMode, onlyCore); |
| 881 | } catch (Throwable e) { |
| 882 | reportWtf("making Display Manager Service ready", e); |
| 883 | } |
| 884 | |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 885 | // These are needed to propagate to the runnable below. |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 886 | final Context contextF = context; |
Jeff Sharkey | b049e21 | 2012-09-07 23:16:01 -0700 | [diff] [blame] | 887 | final MountService mountServiceF = mountService; |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 888 | final BatteryService batteryF = battery; |
Jeff Sharkey | 350083e | 2011-06-29 10:45:16 -0700 | [diff] [blame] | 889 | final NetworkManagementService networkManagementF = networkManagement; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 890 | final NetworkStatsService networkStatsF = networkStats; |
Jeff Sharkey | a462079 | 2011-05-20 15:29:23 -0700 | [diff] [blame] | 891 | final NetworkPolicyManagerService networkPolicyF = networkPolicy; |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 892 | final ConnectivityService connectivityF = connectivity; |
| 893 | final DockObserver dockF = dock; |
Mike Lockwood | 770126a | 2010-12-09 22:30:37 -0800 | [diff] [blame] | 894 | final UsbService usbF = usb; |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 895 | final TwilightService twilightF = twilight; |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 896 | final UiModeManagerService uiModeF = uiMode; |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 897 | final AppWidgetService appWidgetF = appWidget; |
| 898 | final WallpaperManagerService wallpaperF = wallpaper; |
| 899 | final InputMethodManagerService immF = imm; |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 900 | final RecognitionManagerService recognitionF = recognition; |
Mike Lockwood | 46db504 | 2010-02-22 16:36:44 -0500 | [diff] [blame] | 901 | final LocationManagerService locationF = location; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 902 | final CountryDetectorService countryDetectorF = countryDetector; |
Amith Yamasani | 6734b9f6 | 2010-09-13 16:24:08 -0700 | [diff] [blame] | 903 | final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater; |
John Grossman | c157673 | 2012-02-01 15:23:33 -0800 | [diff] [blame] | 904 | final CommonTimeManagementService commonTimeMgmtServiceF = commonTimeMgmtService; |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 905 | final TextServicesManagerService textServiceManagerServiceF = tsms; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 906 | final StatusBarManagerService statusBarF = statusBar; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 907 | final DreamManagerService dreamyF = dreamy; |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 908 | final InputManagerService inputManagerF = inputManager; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 909 | final TelephonyRegistry telephonyRegistryF = telephonyRegistry; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 910 | |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 911 | // We now tell the activity manager it is okay to run third party |
| 912 | // code. It will call back into us once it has gotten to the state |
| 913 | // where third party code can really run (but before it has actually |
| 914 | // started launching the initial applications), for us to complete our |
| 915 | // initialization. |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 916 | ActivityManagerService.self().systemReady(new Runnable() { |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 917 | public void run() { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 918 | Slog.i(TAG, "Making services ready"); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 919 | |
Christopher Tate | 58d380d | 2013-03-19 13:10:03 -0700 | [diff] [blame] | 920 | try { |
| 921 | ActivityManagerService.self().startObservingNativeCrashes(); |
| 922 | } catch (Throwable e) { |
| 923 | reportWtf("observing native crashes", e); |
| 924 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 925 | if (!headless) { |
| 926 | startSystemUi(contextF); |
| 927 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 928 | try { |
Jeff Sharkey | b049e21 | 2012-09-07 23:16:01 -0700 | [diff] [blame] | 929 | if (mountServiceF != null) mountServiceF.systemReady(); |
| 930 | } catch (Throwable e) { |
| 931 | reportWtf("making Mount Service ready", e); |
| 932 | } |
| 933 | try { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 934 | if (batteryF != null) batteryF.systemReady(); |
| 935 | } catch (Throwable e) { |
| 936 | reportWtf("making Battery Service ready", e); |
| 937 | } |
| 938 | try { |
| 939 | if (networkManagementF != null) networkManagementF.systemReady(); |
| 940 | } catch (Throwable e) { |
| 941 | reportWtf("making Network Managment Service ready", e); |
| 942 | } |
| 943 | try { |
| 944 | if (networkStatsF != null) networkStatsF.systemReady(); |
| 945 | } catch (Throwable e) { |
| 946 | reportWtf("making Network Stats Service ready", e); |
| 947 | } |
| 948 | try { |
| 949 | if (networkPolicyF != null) networkPolicyF.systemReady(); |
| 950 | } catch (Throwable e) { |
| 951 | reportWtf("making Network Policy Service ready", e); |
| 952 | } |
| 953 | try { |
| 954 | if (connectivityF != null) connectivityF.systemReady(); |
| 955 | } catch (Throwable e) { |
| 956 | reportWtf("making Connectivity Service ready", e); |
| 957 | } |
| 958 | try { |
| 959 | if (dockF != null) dockF.systemReady(); |
| 960 | } catch (Throwable e) { |
| 961 | reportWtf("making Dock Service ready", e); |
| 962 | } |
| 963 | try { |
| 964 | if (usbF != null) usbF.systemReady(); |
| 965 | } catch (Throwable e) { |
| 966 | reportWtf("making USB Service ready", e); |
| 967 | } |
| 968 | try { |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 969 | if (twilightF != null) twilightF.systemReady(); |
| 970 | } catch (Throwable e) { |
| 971 | reportWtf("makin Twilight Service ready", e); |
| 972 | } |
| 973 | try { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 974 | if (uiModeF != null) uiModeF.systemReady(); |
| 975 | } catch (Throwable e) { |
| 976 | reportWtf("making UI Mode Service ready", e); |
| 977 | } |
| 978 | try { |
| 979 | if (recognitionF != null) recognitionF.systemReady(); |
| 980 | } catch (Throwable e) { |
| 981 | reportWtf("making Recognition Service ready", e); |
| 982 | } |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 983 | Watchdog.getInstance().start(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 984 | |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 985 | // It is now okay to let the various system services start their |
| 986 | // third party code... |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 987 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 988 | try { |
| 989 | if (appWidgetF != null) appWidgetF.systemReady(safeMode); |
| 990 | } catch (Throwable e) { |
| 991 | reportWtf("making App Widget Service ready", e); |
| 992 | } |
| 993 | try { |
| 994 | if (wallpaperF != null) wallpaperF.systemReady(); |
| 995 | } catch (Throwable e) { |
| 996 | reportWtf("making Wallpaper Service ready", e); |
| 997 | } |
| 998 | try { |
| 999 | if (immF != null) immF.systemReady(statusBarF); |
| 1000 | } catch (Throwable e) { |
| 1001 | reportWtf("making Input Method Service ready", e); |
| 1002 | } |
| 1003 | try { |
| 1004 | if (locationF != null) locationF.systemReady(); |
| 1005 | } catch (Throwable e) { |
| 1006 | reportWtf("making Location Service ready", e); |
| 1007 | } |
| 1008 | try { |
| 1009 | if (countryDetectorF != null) countryDetectorF.systemReady(); |
| 1010 | } catch (Throwable e) { |
| 1011 | reportWtf("making Country Detector Service ready", e); |
| 1012 | } |
| 1013 | try { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1014 | if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemReady(); |
| 1015 | } catch (Throwable e) { |
| 1016 | reportWtf("making Network Time Service ready", e); |
| 1017 | } |
| 1018 | try { |
John Grossman | c157673 | 2012-02-01 15:23:33 -0800 | [diff] [blame] | 1019 | if (commonTimeMgmtServiceF != null) commonTimeMgmtServiceF.systemReady(); |
| 1020 | } catch (Throwable e) { |
| 1021 | reportWtf("making Common time management service ready", e); |
| 1022 | } |
| 1023 | try { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1024 | if (textServiceManagerServiceF != null) textServiceManagerServiceF.systemReady(); |
| 1025 | } catch (Throwable e) { |
| 1026 | reportWtf("making Text Services Manager Service ready", e); |
| 1027 | } |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1028 | try { |
| 1029 | if (dreamyF != null) dreamyF.systemReady(); |
| 1030 | } catch (Throwable e) { |
| 1031 | reportWtf("making DreamManagerService ready", e); |
| 1032 | } |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 1033 | try { |
Matthew Xie | 9631314 | 2012-06-29 16:57:31 -0700 | [diff] [blame] | 1034 | // TODO(BT) Pass parameter to input manager |
| 1035 | if (inputManagerF != null) inputManagerF.systemReady(); |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 1036 | } catch (Throwable e) { |
| 1037 | reportWtf("making InputManagerService ready", e); |
| 1038 | } |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame^] | 1039 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1040 | try { |
| 1041 | if (telephonyRegistryF != null) telephonyRegistryF.systemReady(); |
| 1042 | } catch (Throwable e) { |
| 1043 | reportWtf("making TelephonyRegistry ready", e); |
| 1044 | } |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 1045 | } |
| 1046 | }); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 1047 | |
Brad Fitzpatrick | 1e02d36 | 2010-09-10 09:19:50 -0700 | [diff] [blame] | 1048 | // For debug builds, log event loop stalls to dropbox for analysis. |
Brad Fitzpatrick | 50d66f9 | 2010-09-13 21:29:05 -0700 | [diff] [blame] | 1049 | if (StrictMode.conditionallyEnableDebugLogging()) { |
| 1050 | Slog.i(TAG, "Enabled StrictMode for system server main thread."); |
Brad Fitzpatrick | 1e02d36 | 2010-09-10 09:19:50 -0700 | [diff] [blame] | 1051 | } |
| 1052 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1053 | Looper.loop(); |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1054 | Slog.d(TAG, "System ServerThread is exiting!"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1055 | } |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1056 | |
| 1057 | static final void startSystemUi(Context context) { |
| 1058 | Intent intent = new Intent(); |
| 1059 | intent.setComponent(new ComponentName("com.android.systemui", |
| 1060 | "com.android.systemui.SystemUIService")); |
Dianne Hackborn | 40e9f29 | 2012-11-27 19:12:23 -0800 | [diff] [blame] | 1061 | //Slog.d(TAG, "Starting service: " + intent); |
Amith Yamasani | cd75706 | 2012-10-19 18:23:52 -0700 | [diff] [blame] | 1062 | context.startServiceAsUser(intent, UserHandle.OWNER); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1063 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1064 | } |
| 1065 | |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 1066 | public class SystemServer { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1067 | private static final String TAG = "SystemServer"; |
| 1068 | |
| 1069 | public static final int FACTORY_TEST_OFF = 0; |
| 1070 | public static final int FACTORY_TEST_LOW_LEVEL = 1; |
| 1071 | public static final int FACTORY_TEST_HIGH_LEVEL = 2; |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 1072 | |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 1073 | static Timer timer; |
| 1074 | static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr |
| 1075 | |
Brad Fitzpatrick | 6bb7a4a | 2010-10-11 13:41:10 -0700 | [diff] [blame] | 1076 | // The earliest supported time. We pick one day into 1970, to |
| 1077 | // give any timezone code room without going into negative time. |
| 1078 | private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000; |
| 1079 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 1080 | /** |
| 1081 | * This method is called from Zygote to initialize the system. This will cause the native |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1082 | * services (SurfaceFlinger, AudioFlinger, etc..) to be started. After that it will call back |
| 1083 | * up into init2() to start the Android services. |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 1084 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1085 | native public static void init1(String[] args); |
| 1086 | |
| 1087 | public static void main(String[] args) { |
Brad Fitzpatrick | 6bb7a4a | 2010-10-11 13:41:10 -0700 | [diff] [blame] | 1088 | if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) { |
Brad Fitzpatrick | 35ca9d8 | 2010-10-11 11:52:49 -0700 | [diff] [blame] | 1089 | // If a device's clock is before 1970 (before 0), a lot of |
| 1090 | // APIs crash dealing with negative numbers, notably |
| 1091 | // java.io.File#setLastModified, so instead we fake it and |
| 1092 | // hope that time from cell towers or NTP fixes it |
| 1093 | // shortly. |
| 1094 | Slog.w(TAG, "System clock is before 1970; setting to 1970."); |
Brad Fitzpatrick | 6bb7a4a | 2010-10-11 13:41:10 -0700 | [diff] [blame] | 1095 | SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME); |
Brad Fitzpatrick | 35ca9d8 | 2010-10-11 11:52:49 -0700 | [diff] [blame] | 1096 | } |
| 1097 | |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 1098 | if (SamplingProfilerIntegration.isEnabled()) { |
| 1099 | SamplingProfilerIntegration.start(); |
| 1100 | timer = new Timer(); |
| 1101 | timer.schedule(new TimerTask() { |
| 1102 | @Override |
| 1103 | public void run() { |
Sen Hu | bde7570 | 2010-05-28 01:54:03 -0700 | [diff] [blame] | 1104 | SamplingProfilerIntegration.writeSnapshot("system_server", null); |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 1105 | } |
| 1106 | }, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL); |
| 1107 | } |
| 1108 | |
Dianne Hackborn | ac1471a | 2011-02-03 13:46:06 -0800 | [diff] [blame] | 1109 | // Mmmmmm... more memory! |
| 1110 | dalvik.system.VMRuntime.getRuntime().clearGrowthLimit(); |
| 1111 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1112 | // The system server has to run all of the time, so it needs to be |
| 1113 | // as efficient as possible with its memory usage. |
| 1114 | VMRuntime.getRuntime().setTargetHeapUtilization(0.8f); |
Sen Hu | bde7570 | 2010-05-28 01:54:03 -0700 | [diff] [blame] | 1115 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1116 | System.loadLibrary("android_servers"); |
| 1117 | init1(args); |
| 1118 | } |
| 1119 | |
| 1120 | public static final void init2() { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1121 | Slog.i(TAG, "Entered the Android system server!"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1122 | Thread thr = new ServerThread(); |
| 1123 | thr.setName("android.server.ServerThread"); |
| 1124 | thr.start(); |
| 1125 | } |
| 1126 | } |