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 | |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 19 | import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; |
| 20 | import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; |
| 21 | import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL; |
| 22 | import static android.os.IServiceManager.DUMP_FLAG_PROTO; |
| 23 | import static android.view.Display.DEFAULT_DISPLAY; |
| 24 | |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 25 | import android.annotation.NonNull; |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 26 | import android.app.ActivityThread; |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 27 | import android.app.INotificationManager; |
Adam Lesinski | 0debc9a | 2014-07-16 19:09:13 -0700 | [diff] [blame] | 28 | import android.app.usage.UsageStatsManagerInternal; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 29 | import android.content.ComponentName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.content.ContentResolver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.content.Context; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 32 | import android.content.Intent; |
Jeff Sharkey | b0613dc | 2018-02-27 14:38:04 -0700 | [diff] [blame] | 33 | import android.content.pm.PackageItemInfo; |
Matthew Xie | 1dd01eb3 | 2013-04-26 12:37:54 -0700 | [diff] [blame] | 34 | import android.content.pm.PackageManager; |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 35 | import android.content.res.Configuration; |
Alan Viverette | e54d245 | 2015-05-06 10:41:43 -0700 | [diff] [blame] | 36 | import android.content.res.Resources.Theme; |
Fyodor Kupolov | 7fcd659 | 2017-12-15 11:56:36 -0800 | [diff] [blame] | 37 | import android.database.sqlite.SQLiteCompatibilityWalFlags; |
Makoto Onuki | 50e00c8 | 2018-08-07 15:57:13 -0700 | [diff] [blame] | 38 | import android.database.sqlite.SQLiteGlobal; |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 39 | import android.os.BaseBundle; |
Jeff Sharkey | 0a17db1 | 2016-11-04 11:23:46 -0600 | [diff] [blame] | 40 | import android.os.Binder; |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 41 | import android.os.Build; |
Jeff Sharkey | 48749fc | 2013-04-19 13:25:04 -0700 | [diff] [blame] | 42 | import android.os.Environment; |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 43 | import android.os.FactoryTest; |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 44 | import android.os.FileUtils; |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 45 | import android.os.IIncidentManager; |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 46 | import android.os.Looper; |
Alison Cichowlas | f0afd8c | 2017-07-31 11:24:34 -0400 | [diff] [blame] | 47 | import android.os.Message; |
Fyodor Kupolov | a81b8c0 | 2017-11-13 15:51:03 -0800 | [diff] [blame] | 48 | import android.os.Parcel; |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 49 | import android.os.PowerManager; |
Narayan Kamath | 9778046 | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 50 | import android.os.Process; |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 51 | import android.os.ServiceManager; |
Brad Fitzpatrick | c74a1b44 | 2010-09-10 16:03:29 -0700 | [diff] [blame] | 52 | import android.os.StrictMode; |
Jeff Hamilton | 35eef70 | 2010-06-09 15:45:18 -0500 | [diff] [blame] | 53 | import android.os.SystemClock; |
| 54 | import android.os.SystemProperties; |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 55 | import android.os.Trace; |
Amith Yamasani | cd75706 | 2012-10-19 18:23:52 -0700 | [diff] [blame] | 56 | import android.os.UserHandle; |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 57 | import android.os.storage.IStorageManager; |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 58 | import android.provider.Settings; |
Inseob Kim | c1246e6 | 2018-11-08 13:13:54 +0900 | [diff] [blame] | 59 | import android.sysprop.VoldProperties; |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 60 | import android.text.TextUtils; |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 61 | import android.util.DisplayMetrics; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | import android.util.EventLog; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 63 | import android.util.Slog; |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 64 | import android.util.TimingsTraceLog; |
Brad Fitzpatrick | 5fdc0c7 | 2010-10-12 13:12:18 -0700 | [diff] [blame] | 65 | import android.view.WindowManager; |
Yohei Yukawa | 6048d89 | 2018-12-25 09:57:31 -0800 | [diff] [blame] | 66 | import android.view.inputmethod.InputMethodSystemProperty; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 68 | import com.android.internal.R; |
Fyodor Kupolov | 8d3e82b | 2016-11-10 17:58:50 -0800 | [diff] [blame] | 69 | import com.android.internal.logging.MetricsLogger; |
Geoffrey Pitsch | af759c5 | 2017-02-15 09:35:38 -0500 | [diff] [blame] | 70 | import com.android.internal.notification.SystemNotificationChannels; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 71 | import com.android.internal.os.BinderInternal; |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 72 | import com.android.internal.util.ConcurrentUtils; |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 73 | import com.android.internal.util.EmergencyAffordanceManager; |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 74 | import com.android.internal.widget.ILockSettings; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 75 | import com.android.server.am.ActivityManagerService; |
Makoto Onuki | df7e481 | 2018-09-24 14:31:25 -0700 | [diff] [blame] | 76 | import com.android.server.appbinding.AppBindingService; |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 77 | import com.android.server.audio.AudioService; |
Kevin Chyn | 352adfe | 2018-09-20 22:28:50 -0700 | [diff] [blame] | 78 | import com.android.server.biometrics.BiometricService; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 79 | import com.android.server.biometrics.face.FaceService; |
| 80 | import com.android.server.biometrics.fingerprint.FingerprintService; |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 81 | import com.android.server.biometrics.iris.IrisService; |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 82 | import com.android.server.broadcastradio.BroadcastRadioService; |
Wei Wang | ed7f548 | 2017-02-21 11:35:10 -0800 | [diff] [blame] | 83 | import com.android.server.camera.CameraServiceProxy; |
Amith Yamasani | 30f8eb4 | 2013-11-06 14:54:50 -0800 | [diff] [blame] | 84 | import com.android.server.clipboard.ClipboardService; |
Hugo Benichi | eab511b | 2016-09-09 09:23:47 +0900 | [diff] [blame] | 85 | import com.android.server.connectivity.IpConnectivityMetrics; |
Allen Hair | 1f556e3 | 2016-11-11 15:42:50 -0800 | [diff] [blame] | 86 | import com.android.server.coverage.CoverageService; |
Adam Lesinski | 2c8d67c | 2014-04-23 13:46:21 -0700 | [diff] [blame] | 87 | import com.android.server.devicepolicy.DevicePolicyManagerService; |
Christine Franks | 5397f03 | 2017-11-01 18:35:16 -0700 | [diff] [blame] | 88 | import com.android.server.display.ColorDisplayService; |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 89 | import com.android.server.display.DisplayManagerService; |
Jeff Brown | cef440f | 2012-09-25 18:58:48 -0700 | [diff] [blame] | 90 | import com.android.server.dreams.DreamManagerService; |
Selim Cinek | 705442f | 2016-09-13 16:02:33 -0700 | [diff] [blame] | 91 | import com.android.server.emergency.EmergencyAffordanceService; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 92 | import com.android.server.hdmi.HdmiControlService; |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 93 | import com.android.server.input.InputManagerService; |
Yohei Yukawa | 603f4d0 | 2018-09-11 15:04:58 -0700 | [diff] [blame] | 94 | import com.android.server.inputmethod.InputMethodManagerService; |
Yohei Yukawa | bae5bea | 2018-11-12 15:08:30 -0800 | [diff] [blame] | 95 | import com.android.server.inputmethod.MultiClientInputMethodManagerService; |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 96 | import com.android.server.job.JobSchedulerService; |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 97 | import com.android.server.lights.LightsService; |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 98 | import com.android.server.media.MediaResourceMonitorService; |
Jeff Brown | 69b0716 | 2013-11-07 00:30:16 -0800 | [diff] [blame] | 99 | import com.android.server.media.MediaRouterService; |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 100 | import com.android.server.media.MediaSessionService; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 101 | import com.android.server.media.MediaUpdateService; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 102 | import com.android.server.media.projection.MediaProjectionManagerService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 103 | import com.android.server.net.NetworkPolicyManagerService; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 104 | import com.android.server.net.NetworkStatsService; |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 105 | import com.android.server.net.watchlist.NetworkWatchlistService; |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 106 | import com.android.server.notification.NotificationManagerService; |
Andrew Scull | 5d7027d | 2017-04-12 11:46:27 +0100 | [diff] [blame] | 107 | import com.android.server.oemlock.OemLockService; |
MÃ¥rten Kongstad | 2e0d0f3 | 2016-06-02 09:35:31 +0200 | [diff] [blame] | 108 | import com.android.server.om.OverlayManagerService; |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame^] | 109 | import com.android.server.os.BugreportManagerService; |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 110 | import com.android.server.os.DeviceIdentifiersPolicyService; |
Jeff Sharkey | 7a96c39 | 2012-11-15 14:01:46 -0800 | [diff] [blame] | 111 | import com.android.server.os.SchedulingPolicyService; |
Calin Juravle | 91d40f1 | 2017-03-15 18:38:57 -0700 | [diff] [blame] | 112 | import com.android.server.pm.BackgroundDexOptService; |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 113 | import com.android.server.pm.CrossProfileAppsService; |
Alan Stokes | be9ec97 | 2018-12-10 14:07:47 +0000 | [diff] [blame] | 114 | import com.android.server.pm.DynamicCodeLoggingService; |
Jeff Brown | f69c812 | 2012-09-12 17:00:34 -0700 | [diff] [blame] | 115 | import com.android.server.pm.Installer; |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 116 | import com.android.server.pm.LauncherAppsService; |
Andreas Gampe | a890875 | 2015-11-10 08:58:14 -0800 | [diff] [blame] | 117 | import com.android.server.pm.OtaDexoptService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 118 | import com.android.server.pm.PackageManagerService; |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 119 | import com.android.server.pm.ShortcutService; |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 120 | import com.android.server.pm.UserManagerService; |
Wale Ogunwale | b699ce0 | 2016-07-18 12:05:30 -0700 | [diff] [blame] | 121 | import com.android.server.policy.PhoneWindowManager; |
Jeff Brown | 4f8ecd8 | 2012-06-18 18:29:13 -0700 | [diff] [blame] | 122 | import com.android.server.power.PowerManagerService; |
| 123 | import com.android.server.power.ShutdownThread; |
Wei Wang | bad7c20 | 2018-11-01 11:57:39 -0700 | [diff] [blame] | 124 | import com.android.server.power.ThermalManagerService; |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 125 | import com.android.server.restrictions.RestrictionsManagerService; |
Eugene Susla | 6d492272 | 2018-11-08 16:25:28 -0800 | [diff] [blame] | 126 | import com.android.server.role.RoleManagerService; |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 127 | import com.android.server.rollback.RollbackManagerService; |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 128 | import com.android.server.security.KeyAttestationApplicationIdProviderService; |
Robin Lee | 1393549 | 2017-03-23 15:28:37 +0000 | [diff] [blame] | 129 | import com.android.server.security.KeyChainSystemService; |
Mathew Inwood | 4e2ed6a | 2018-11-26 15:31:16 +0000 | [diff] [blame] | 130 | import com.android.server.signedconfig.SignedConfigService; |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 131 | import com.android.server.soundtrigger.SoundTriggerService; |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 132 | import com.android.server.stats.StatsCompanionService; |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 133 | import com.android.server.statusbar.StatusBarManagerService; |
| 134 | import com.android.server.storage.DeviceStorageMonitorService; |
Santos Cordon | 5d2c1e6 | 2014-11-21 15:20:15 -0800 | [diff] [blame] | 135 | import com.android.server.telecom.TelecomLoaderService; |
Abodunrinwa Toki | d32906c | 2018-01-18 04:34:44 -0800 | [diff] [blame] | 136 | import com.android.server.textclassifier.TextClassificationManagerService; |
Yohei Yukawa | eb1e804 | 2018-09-12 14:02:00 -0700 | [diff] [blame] | 137 | import com.android.server.textservices.TextServicesManagerService; |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 138 | import com.android.server.trust.TrustManagerService; |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 139 | import com.android.server.tv.TvInputManagerService; |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 140 | import com.android.server.tv.TvRemoteService; |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 141 | import com.android.server.twilight.TwilightService; |
Wale Ogunwale | 6d50dcc | 2018-07-21 23:00:40 -0700 | [diff] [blame] | 142 | import com.android.server.uri.UriGrantsManagerService; |
Adam Lesinski | 0debc9a | 2014-07-16 19:09:13 -0700 | [diff] [blame] | 143 | import com.android.server.usage.UsageStatsService; |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 144 | import com.android.server.vr.VrManagerService; |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 145 | import com.android.server.webkit.WebViewUpdateService; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 146 | import com.android.server.wm.ActivityTaskManagerService; |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 147 | import com.android.server.wm.WindowManagerGlobalLock; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 148 | import com.android.server.wm.WindowManagerService; |
Igor Murashkin | 4de1e16 | 2018-11-26 10:33:17 -0800 | [diff] [blame] | 149 | import com.google.android.startop.iorap.IorapForwardingService; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 150 | |
| 151 | import dalvik.system.VMRuntime; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 152 | |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 153 | import java.io.File; |
| 154 | import java.io.IOException; |
Narayan Kamath | bf88205 | 2015-08-11 15:40:34 +0100 | [diff] [blame] | 155 | import java.util.Locale; |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 156 | import java.util.Timer; |
Fyodor Kupolov | 311b9fa | 2016-12-02 16:24:35 -0800 | [diff] [blame] | 157 | import java.util.concurrent.CountDownLatch; |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 158 | import java.util.concurrent.Future; |
Bob Lee | e540833 | 2009-09-04 18:31:17 -0700 | [diff] [blame] | 159 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 160 | public final class SystemServer { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 161 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | private static final String TAG = "SystemServer"; |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 163 | |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 164 | // Tag for timing measurement of main thread. |
| 165 | private static final String SYSTEM_SERVER_TIMING_TAG = "SystemServerTiming"; |
| 166 | // Tag for timing measurement of non-main asynchronous operations. |
| 167 | private static final String SYSTEM_SERVER_TIMING_ASYNC_TAG = SYSTEM_SERVER_TIMING_TAG + "Async"; |
| 168 | |
Fyodor Kupolov | 6e3461b | 2017-08-10 17:00:43 -0700 | [diff] [blame] | 169 | private static final TimingsTraceLog BOOT_TIMINGS_TRACE_LOG |
| 170 | = new TimingsTraceLog(SYSTEM_SERVER_TIMING_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 171 | |
Ben Komalo | 553acf0 | 2011-09-19 14:25:28 -0700 | [diff] [blame] | 172 | private static final String ENCRYPTING_STATE = "trigger_restart_min_framework"; |
Ben Komalo | 3573d40 | 2011-09-23 15:08:24 -0700 | [diff] [blame] | 173 | private static final String ENCRYPTED_STATE = "1"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 175 | private static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr |
| 176 | |
| 177 | // The earliest supported time. We pick one day into 1970, to |
| 178 | // give any timezone code room without going into negative time. |
| 179 | private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | |
Makoto Onuki | 712886f | 2018-04-27 15:22:50 -0700 | [diff] [blame] | 181 | private static final long SLOW_DISPATCH_THRESHOLD_MS = 100; |
| 182 | private static final long SLOW_DELIVERY_THRESHOLD_MS = 200; |
| 183 | |
Amith Yamasani | 817ec49 | 2013-12-20 13:27:30 -0800 | [diff] [blame] | 184 | /* |
| 185 | * Implementation class names. TODO: Move them to a codegen class or load |
| 186 | * them from the build system somehow. |
| 187 | */ |
| 188 | private static final String BACKUP_MANAGER_SERVICE_CLASS = |
Annie Meng | 384230f | 2018-11-28 10:58:08 +0000 | [diff] [blame] | 189 | "com.android.server.backup.BackupManagerService$Lifecycle"; |
Amith Yamasani | 817ec49 | 2013-12-20 13:27:30 -0800 | [diff] [blame] | 190 | private static final String APPWIDGET_SERVICE_CLASS = |
| 191 | "com.android.server.appwidget.AppWidgetService"; |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 192 | private static final String VOICE_RECOGNITION_MANAGER_SERVICE_CLASS = |
| 193 | "com.android.server.voiceinteraction.VoiceInteractionManagerService"; |
Amith Yamasani | 817ec49 | 2013-12-20 13:27:30 -0800 | [diff] [blame] | 194 | private static final String PRINT_MANAGER_SERVICE_CLASS = |
| 195 | "com.android.server.print.PrintManagerService"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 196 | private static final String COMPANION_DEVICE_MANAGER_SERVICE_CLASS = |
Eugene Susla | 0d3dd12 | 2017-04-18 10:56:37 -0700 | [diff] [blame] | 197 | "com.android.server.companion.CompanionDeviceManagerService"; |
Adam Lesinski | 2cb6c60 | 2014-02-14 17:19:56 -0800 | [diff] [blame] | 198 | private static final String USB_SERVICE_CLASS = |
| 199 | "com.android.server.usb.UsbService$Lifecycle"; |
Mike Lockwood | 5781cd5 | 2015-03-27 13:23:41 -0700 | [diff] [blame] | 200 | private static final String MIDI_SERVICE_CLASS = |
| 201 | "com.android.server.midi.MidiService$Lifecycle"; |
Adam Lesinski | f542a33 | 2014-02-19 12:29:58 -0800 | [diff] [blame] | 202 | private static final String WIFI_SERVICE_CLASS = |
| 203 | "com.android.server.wifi.WifiService"; |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 204 | private static final String WIFI_AWARE_SERVICE_CLASS = |
| 205 | "com.android.server.wifi.aware.WifiAwareService"; |
Adam Lesinski | f542a33 | 2014-02-19 12:29:58 -0800 | [diff] [blame] | 206 | private static final String WIFI_P2P_SERVICE_CLASS = |
| 207 | "com.android.server.wifi.p2p.WifiP2pService"; |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 208 | private static final String LOWPAN_SERVICE_CLASS = |
| 209 | "com.android.server.lowpan.LowpanService"; |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 210 | private static final String ETHERNET_SERVICE_CLASS = |
| 211 | "com.android.server.ethernet.EthernetService"; |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 212 | private static final String JOB_SCHEDULER_SERVICE_CLASS = |
| 213 | "com.android.server.job.JobSchedulerService"; |
Jim Miller | 4f93c58 | 2016-01-27 19:05:43 -0800 | [diff] [blame] | 214 | private static final String LOCK_SETTINGS_SERVICE_CLASS = |
Andrew Scull | 507d11c | 2017-05-03 17:19:01 +0100 | [diff] [blame] | 215 | "com.android.server.locksettings.LockSettingsService$Lifecycle"; |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 216 | private static final String STORAGE_MANAGER_SERVICE_CLASS = |
| 217 | "com.android.server.StorageManagerService$Lifecycle"; |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 218 | private static final String STORAGE_STATS_SERVICE_CLASS = |
| 219 | "com.android.server.usage.StorageStatsService$Lifecycle"; |
Jeff Sharkey | 4175be2 | 2016-01-09 14:57:45 -0700 | [diff] [blame] | 220 | private static final String SEARCH_MANAGER_SERVICE_CLASS = |
| 221 | "com.android.server.search.SearchManagerService$Lifecycle"; |
Wei Liu | d699cf8 | 2016-03-25 16:32:10 -0700 | [diff] [blame] | 222 | private static final String THERMAL_OBSERVER_CLASS = |
| 223 | "com.google.android.clockwork.ThermalObserver"; |
Calvin On | 5555bcc | 2017-02-21 16:41:43 -0800 | [diff] [blame] | 224 | private static final String WEAR_CONNECTIVITY_SERVICE_CLASS = |
Calvin On | 3cda1cf | 2018-02-14 13:57:07 -0800 | [diff] [blame] | 225 | "com.android.clockwork.connectivity.WearConnectivityService"; |
Damien Bargiacchi | ae4cb67 | 2018-05-30 13:28:15 -0700 | [diff] [blame] | 226 | private static final String WEAR_POWER_SERVICE_CLASS = |
| 227 | "com.android.clockwork.power.WearPowerService"; |
Chris Phoenix | bc839a3 | 2017-10-21 14:46:15 -0700 | [diff] [blame] | 228 | private static final String WEAR_SIDEKICK_SERVICE_CLASS = |
| 229 | "com.google.android.clockwork.sidekick.SidekickService"; |
Julius D'souza | 069f46c | 2017-03-22 13:27:00 -0700 | [diff] [blame] | 230 | private static final String WEAR_DISPLAY_SERVICE_CLASS = |
| 231 | "com.google.android.clockwork.display.WearDisplayService"; |
Ivan Podogov | f997382 | 2017-05-11 15:51:34 +0100 | [diff] [blame] | 232 | private static final String WEAR_LEFTY_SERVICE_CLASS = |
| 233 | "com.google.android.clockwork.lefty.WearLeftyService"; |
Damien Bargiacchi | 2d92eeb | 2016-04-07 14:01:03 -0700 | [diff] [blame] | 234 | private static final String WEAR_TIME_SERVICE_CLASS = |
| 235 | "com.google.android.clockwork.time.WearTimeService"; |
Michael Kwan | 01ad0aa | 2018-02-28 15:19:04 -0800 | [diff] [blame] | 236 | private static final String WEAR_GLOBAL_ACTIONS_SERVICE_CLASS = |
| 237 | "com.android.clockwork.globalactions.GlobalActionsService"; |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 238 | private static final String ACCOUNT_SERVICE_CLASS = |
| 239 | "com.android.server.accounts.AccountManagerService$Lifecycle"; |
Jeff Sharkey | a3ebfec | 2016-04-04 08:58:04 -0600 | [diff] [blame] | 240 | private static final String CONTENT_SERVICE_CLASS = |
| 241 | "com.android.server.content.ContentService$Lifecycle"; |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 242 | private static final String WALLPAPER_SERVICE_CLASS = |
| 243 | "com.android.server.wallpaper.WallpaperManagerService$Lifecycle"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 244 | private static final String AUTO_FILL_MANAGER_SERVICE_CLASS = |
Svet Ganov | 2f8fb1f | 2017-03-13 00:21:04 -0700 | [diff] [blame] | 245 | "com.android.server.autofill.AutofillManagerService"; |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 246 | private static final String CONTENT_CAPTURE_MANAGER_SERVICE_CLASS = |
| 247 | "com.android.server.contentcapture.ContentCaptureManagerService"; |
Neil Fuller | 328532a | 2017-03-16 18:32:21 +0000 | [diff] [blame] | 248 | private static final String TIME_ZONE_RULES_MANAGER_SERVICE_CLASS = |
| 249 | "com.android.server.timezone.RulesManagerService$Lifecycle"; |
Nick Felker | 1bfe59d | 2017-10-12 13:27:02 -0700 | [diff] [blame] | 250 | private static final String IOT_SERVICE_CLASS = |
Ralph Nathan | 090c2c3 | 2018-04-19 22:19:03 -0700 | [diff] [blame] | 251 | "com.android.things.server.IoTSystemService"; |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 252 | private static final String SLICE_MANAGER_SERVICE_CLASS = |
| 253 | "com.android.server.slice.SliceManagerService$Lifecycle"; |
Steve Paik | 94292a3 | 2018-01-26 17:16:53 -0800 | [diff] [blame] | 254 | private static final String CAR_SERVICE_HELPER_SERVICE_CLASS = |
| 255 | "com.android.internal.car.CarServiceHelperService"; |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 256 | private static final String TIME_DETECTOR_SERVICE_CLASS = |
| 257 | "com.android.server.timedetector.TimeDetectorService$Lifecycle"; |
Neil Fuller | 7fb88c3 | 2018-06-19 12:53:47 +0100 | [diff] [blame] | 258 | private static final String TIME_ZONE_DETECTOR_SERVICE_CLASS = |
| 259 | "com.android.server.timezonedetector.TimeZoneDetectorService$Lifecycle"; |
Rhed Jao | 8a39cef | 2018-07-18 11:43:33 +0800 | [diff] [blame] | 260 | private static final String ACCESSIBILITY_MANAGER_SERVICE_CLASS = |
| 261 | "com.android.server.accessibility.AccessibilityManagerService$Lifecycle"; |
Kenny Root | f74bfde | 2018-01-18 15:42:48 -0800 | [diff] [blame] | 262 | private static final String ADB_SERVICE_CLASS = |
| 263 | "com.android.server.adb.AdbService$Lifecycle"; |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 264 | |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 265 | private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; |
Amith Yamasani | 817ec49 | 2013-12-20 13:27:30 -0800 | [diff] [blame] | 266 | |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 267 | private static final String UNCRYPT_PACKAGE_FILE = "/cache/recovery/uncrypt_file"; |
| 268 | private static final String BLOCK_MAP_FILE = "/cache/recovery/block.map"; |
| 269 | |
Tim Murray | eef4a3d | 2016-04-19 14:14:20 -0700 | [diff] [blame] | 270 | // maximum number of binder threads used for system_server |
| 271 | // will be higher than the system default |
| 272 | private static final int sMaxBinderThreads = 31; |
| 273 | |
Alan Viverette | ba398ea | 2015-12-16 15:28:23 -0500 | [diff] [blame] | 274 | /** |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 275 | * Default theme used by the system context. This is used to style system-provided dialogs, such |
| 276 | * as the Power Off dialog, and other visual content. |
Alan Viverette | ba398ea | 2015-12-16 15:28:23 -0500 | [diff] [blame] | 277 | */ |
| 278 | private static final int DEFAULT_SYSTEM_THEME = |
Michael Kwan | 9c7274c | 2016-06-13 12:48:55 -0700 | [diff] [blame] | 279 | com.android.internal.R.style.Theme_DeviceDefault_System; |
Alan Viverette | ba398ea | 2015-12-16 15:28:23 -0500 | [diff] [blame] | 280 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 281 | private final int mFactoryTestMode; |
| 282 | private Timer mProfilerSnapshotTimer; |
| 283 | |
| 284 | private Context mSystemContext; |
| 285 | private SystemServiceManager mSystemServiceManager; |
| 286 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 287 | // TODO: remove all of these references by improving dependency resolution and boot phases |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 288 | private PowerManagerService mPowerManagerService; |
| 289 | private ActivityManagerService mActivityManagerService; |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 290 | private WindowManagerGlobalLock mWindowManagerGlobalLock; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 291 | private WebViewUpdateService mWebViewUpdateService; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 292 | private DisplayManagerService mDisplayManagerService; |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 293 | private PackageManagerService mPackageManagerService; |
| 294 | private PackageManager mPackageManager; |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 295 | private ContentResolver mContentResolver; |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 296 | private EntropyMixer mEntropyMixer; |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 297 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 298 | private boolean mOnlyCore; |
| 299 | private boolean mFirstBoot; |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 300 | private final boolean mRuntimeRestart; |
Makoto Onuki | e8edbcf | 2018-03-02 16:49:29 -0800 | [diff] [blame] | 301 | private final long mRuntimeStartElapsedTime; |
| 302 | private final long mRuntimeStartUptime; |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 303 | |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 304 | private static final String START_SENSOR_SERVICE = "StartSensorService"; |
Yifan Hong | 26b421f | 2017-03-10 13:41:11 -0800 | [diff] [blame] | 305 | private static final String START_HIDL_SERVICES = "StartHidlServices"; |
| 306 | |
| 307 | |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 308 | private Future<?> mSensorServiceStart; |
Narayan Kamath | 9778046 | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 309 | private Future<?> mZygotePreload; |
| 310 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 311 | /** |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 312 | * Start the sensor service. This is a blocking call and can take time. |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 313 | */ |
Svet Ganov | b9d71a6 | 2015-04-30 10:38:13 -0700 | [diff] [blame] | 314 | private static native void startSensorService(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 315 | |
| 316 | /** |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 317 | * Start all HIDL services that are run inside the system server. This may take some time. |
Yifan Hong | 26b421f | 2017-03-10 13:41:11 -0800 | [diff] [blame] | 318 | */ |
| 319 | private static native void startHidlServices(); |
| 320 | |
| 321 | /** |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 322 | * The main entry point from zygote. |
| 323 | */ |
| 324 | public static void main(String[] args) { |
| 325 | new SystemServer().run(); |
| 326 | } |
| 327 | |
| 328 | public SystemServer() { |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 329 | // Check for factory test mode. |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 330 | mFactoryTestMode = FactoryTest.getMode(); |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 331 | // Remember if it's runtime restart(when sys.boot_completed is already set) or reboot |
| 332 | mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed")); |
Makoto Onuki | e8edbcf | 2018-03-02 16:49:29 -0800 | [diff] [blame] | 333 | |
| 334 | mRuntimeStartElapsedTime = SystemClock.elapsedRealtime(); |
| 335 | mRuntimeStartUptime = SystemClock.uptimeMillis(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | private void run() { |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 339 | try { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 340 | traceBeginAndSlog("InitBeforeStartServices"); |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 341 | // If a device's clock is before 1970 (before 0), a lot of |
| 342 | // APIs crash dealing with negative numbers, notably |
| 343 | // java.io.File#setLastModified, so instead we fake it and |
| 344 | // hope that time from cell towers or NTP fixes it shortly. |
| 345 | if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) { |
| 346 | Slog.w(TAG, "System clock is before 1970; setting to 1970."); |
| 347 | SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME); |
| 348 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 349 | |
Przemyslaw Szczepaniak | fbe00fa | 2017-07-28 13:21:48 +0000 | [diff] [blame] | 350 | // |
| 351 | // Default the timezone property to GMT if not set. |
| 352 | // |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 353 | String timezoneProperty = SystemProperties.get("persist.sys.timezone"); |
Przemyslaw Szczepaniak | fbe00fa | 2017-07-28 13:21:48 +0000 | [diff] [blame] | 354 | if (timezoneProperty == null || timezoneProperty.isEmpty()) { |
| 355 | Slog.w(TAG, "Timezone not set; setting to GMT."); |
| 356 | SystemProperties.set("persist.sys.timezone", "GMT"); |
| 357 | } |
| 358 | |
Yasuhiro Matsuda | ebf9465 | 2015-09-02 22:48:13 +0900 | [diff] [blame] | 359 | // If the system has "persist.sys.language" and friends set, replace them with |
| 360 | // "persist.sys.locale". Note that the default locale at this point is calculated |
| 361 | // using the "-Duser.locale" command line flag. That flag is usually populated by |
| 362 | // AndroidRuntime using the same set of system properties, but only the system_server |
| 363 | // and system apps are allowed to set them. |
| 364 | // |
| 365 | // NOTE: Most changes made here will need an equivalent change to |
| 366 | // core/jni/AndroidRuntime.cpp |
| 367 | if (!SystemProperties.get("persist.sys.language").isEmpty()) { |
| 368 | final String languageTag = Locale.getDefault().toLanguageTag(); |
Narayan Kamath | bf88205 | 2015-08-11 15:40:34 +0100 | [diff] [blame] | 369 | |
Yasuhiro Matsuda | ebf9465 | 2015-09-02 22:48:13 +0900 | [diff] [blame] | 370 | SystemProperties.set("persist.sys.locale", languageTag); |
| 371 | SystemProperties.set("persist.sys.language", ""); |
| 372 | SystemProperties.set("persist.sys.country", ""); |
| 373 | SystemProperties.set("persist.sys.localevar", ""); |
| 374 | } |
Narayan Kamath | bf88205 | 2015-08-11 15:40:34 +0100 | [diff] [blame] | 375 | |
Jeff Sharkey | 0a17db1 | 2016-11-04 11:23:46 -0600 | [diff] [blame] | 376 | // The system server should never make non-oneway calls |
| 377 | Binder.setWarnOnBlocking(true); |
Jeff Sharkey | b0613dc | 2018-02-27 14:38:04 -0700 | [diff] [blame] | 378 | // The system server should always load safe labels |
Philip P. Moltmann | 20dd431 | 2018-10-08 16:56:49 -0700 | [diff] [blame] | 379 | PackageItemInfo.forceSafeLabels(); |
Makoto Onuki | 50e00c8 | 2018-08-07 15:57:13 -0700 | [diff] [blame] | 380 | |
| 381 | // Default to FULL within the system server. |
| 382 | SQLiteGlobal.sDefaultSyncMode = SQLiteGlobal.SYNC_MODE_FULL; |
| 383 | |
Fyodor Kupolov | 7fcd659 | 2017-12-15 11:56:36 -0800 | [diff] [blame] | 384 | // Deactivate SQLiteCompatibilityWalFlags until settings provider is initialized |
| 385 | SQLiteCompatibilityWalFlags.init(null); |
Jeff Sharkey | 0a17db1 | 2016-11-04 11:23:46 -0600 | [diff] [blame] | 386 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 387 | // Here we go! |
| 388 | Slog.i(TAG, "Entered the Android system server!"); |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 389 | int uptimeMillis = (int) SystemClock.elapsedRealtime(); |
Fyodor Kupolov | 8d3e82b | 2016-11-10 17:58:50 -0800 | [diff] [blame] | 390 | EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, uptimeMillis); |
Fyodor Kupolov | 4ba91b9 | 2017-01-20 18:12:35 -0800 | [diff] [blame] | 391 | if (!mRuntimeRestart) { |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 392 | MetricsLogger.histogram(null, "boot_system_server_init", uptimeMillis); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 393 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 394 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 395 | // In case the runtime switched since last boot (such as when |
| 396 | // the old runtime was removed in an OTA), set the system |
Eugene Susla | a38fbf6 | 2017-03-14 10:26:10 -0700 | [diff] [blame] | 397 | // property so that it is in sync. We can | xq oqi't do this in |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 398 | // libnativehelper's JniInvocation::Init code where we already |
| 399 | // had to fallback to a different runtime because it is |
| 400 | // running as root and we need to be the system user to set |
| 401 | // the property. http://b/11463182 |
| 402 | SystemProperties.set("persist.sys.dalvik.vm.lib.2", VMRuntime.getRuntime().vmLibrary()); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 403 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 404 | // Mmmmmm... more memory! |
| 405 | VMRuntime.getRuntime().clearGrowthLimit(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 406 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 407 | // The system server has to run all of the time, so it needs to be |
| 408 | // as efficient as possible with its memory usage. |
| 409 | VMRuntime.getRuntime().setTargetHeapUtilization(0.8f); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 410 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 411 | // Some devices rely on runtime fingerprint generation, so make sure |
| 412 | // we've defined it before booting further. |
| 413 | Build.ensureFingerprintProperty(); |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 414 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 415 | // Within the system server, it is an error to access Environment paths without |
| 416 | // explicitly specifying a user. |
| 417 | Environment.setUserRequired(true); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 418 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 419 | // Within the system server, any incoming Bundles should be defused |
| 420 | // to avoid throwing BadParcelableException. |
| 421 | BaseBundle.setShouldDefuse(true); |
| 422 | |
Fyodor Kupolov | a81b8c0 | 2017-11-13 15:51:03 -0800 | [diff] [blame] | 423 | // Within the system server, when parceling exceptions, include the stack trace |
| 424 | Parcel.setStackTraceParceling(true); |
| 425 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 426 | // Ensure binder calls into the system always run at foreground priority. |
| 427 | BinderInternal.disableBackgroundScheduling(true); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 428 | |
Tim Murray | eef4a3d | 2016-04-19 14:14:20 -0700 | [diff] [blame] | 429 | // Increase the number of binder threads in system_server |
| 430 | BinderInternal.setMaxThreads(sMaxBinderThreads); |
| 431 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 432 | // Prepare the main looper thread (this thread). |
| 433 | android.os.Process.setThreadPriority( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 434 | android.os.Process.THREAD_PRIORITY_FOREGROUND); |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 435 | android.os.Process.setCanSelfBackground(false); |
| 436 | Looper.prepareMainLooper(); |
Makoto Onuki | 712886f | 2018-04-27 15:22:50 -0700 | [diff] [blame] | 437 | Looper.getMainLooper().setSlowLogThresholdMs( |
| 438 | SLOW_DISPATCH_THRESHOLD_MS, SLOW_DELIVERY_THRESHOLD_MS); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 439 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 440 | // Initialize native services. |
| 441 | System.loadLibrary("android_servers"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 442 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 443 | // Check whether we failed to shut down last time we tried. |
| 444 | // This call may not return. |
| 445 | performPendingShutdown(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 446 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 447 | // Initialize the system context. |
| 448 | createSystemContext(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 449 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 450 | // Create the system service manager. |
| 451 | mSystemServiceManager = new SystemServiceManager(mSystemContext); |
Makoto Onuki | e8edbcf | 2018-03-02 16:49:29 -0800 | [diff] [blame] | 452 | mSystemServiceManager.setStartInfo(mRuntimeRestart, |
| 453 | mRuntimeStartElapsedTime, mRuntimeStartUptime); |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 454 | LocalServices.addService(SystemServiceManager.class, mSystemServiceManager); |
Fyodor Kupolov | e29a5a1 | 2016-12-16 16:14:17 -0800 | [diff] [blame] | 455 | // Prepare the thread pool for init tasks that can be parallelized |
| 456 | SystemServerInitThreadPool.get(); |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 457 | } finally { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 458 | traceEnd(); // InitBeforeStartServices |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 459 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 460 | |
| 461 | // Start services. |
| 462 | try { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 463 | traceBeginAndSlog("StartServices"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 464 | startBootstrapServices(); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 465 | startCoreServices(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 466 | startOtherServices(); |
Fyodor Kupolov | cd824ef | 2017-02-07 11:25:14 -0800 | [diff] [blame] | 467 | SystemServerInitThreadPool.shutdown(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 468 | } catch (Throwable ex) { |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 469 | Slog.e("System", "******************************************"); |
| 470 | Slog.e("System", "************ Failure starting system services", ex); |
| 471 | throw ex; |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 472 | } finally { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 473 | traceEnd(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 474 | } |
| 475 | |
Jeff Sharkey | 8918298 | 2017-11-01 19:02:56 -0600 | [diff] [blame] | 476 | StrictMode.initVmDefaults(null); |
| 477 | |
Fyodor Kupolov | 4ba91b9 | 2017-01-20 18:12:35 -0800 | [diff] [blame] | 478 | if (!mRuntimeRestart && !isFirstBootOrUpgrade()) { |
Fyodor Kupolov | 24e12dc | 2017-01-17 12:20:36 -0800 | [diff] [blame] | 479 | int uptimeMillis = (int) SystemClock.elapsedRealtime(); |
| 480 | MetricsLogger.histogram(null, "boot_system_server_ready", uptimeMillis); |
| 481 | final int MAX_UPTIME_MILLIS = 60 * 1000; |
| 482 | if (uptimeMillis > MAX_UPTIME_MILLIS) { |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 483 | Slog.wtf(SYSTEM_SERVER_TIMING_TAG, |
Fyodor Kupolov | 24e12dc | 2017-01-17 12:20:36 -0800 | [diff] [blame] | 484 | "SystemServer init took too long. uptimeMillis=" + uptimeMillis); |
| 485 | } |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 486 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 487 | |
Andreas Gampe | e697a4f | 2018-10-09 10:40:52 -0700 | [diff] [blame] | 488 | // Diagnostic to ensure that the system is in a base healthy state. Done here as a common |
| 489 | // non-zygote process. |
| 490 | if (!VMRuntime.hasBootImageSpaces()) { |
| 491 | Slog.wtf(TAG, "Runtime is not running with a boot image!"); |
| 492 | } |
| 493 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 494 | // Loop forever. |
| 495 | Looper.loop(); |
| 496 | throw new RuntimeException("Main thread loop unexpectedly exited"); |
| 497 | } |
| 498 | |
Fyodor Kupolov | 4ba91b9 | 2017-01-20 18:12:35 -0800 | [diff] [blame] | 499 | private boolean isFirstBootOrUpgrade() { |
| 500 | return mPackageManagerService.isFirstBoot() || mPackageManagerService.isUpgrade(); |
| 501 | } |
| 502 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 503 | private void reportWtf(String msg, Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 504 | Slog.w(TAG, "***********************************************"); |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 505 | Slog.wtf(TAG, "BOOT FAILURE " + msg, e); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 508 | private void performPendingShutdown() { |
| 509 | final String shutdownAction = SystemProperties.get( |
| 510 | ShutdownThread.SHUTDOWN_ACTION_PROPERTY, ""); |
| 511 | if (shutdownAction != null && shutdownAction.length() > 0) { |
| 512 | boolean reboot = (shutdownAction.charAt(0) == '1'); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 513 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 514 | final String reason; |
| 515 | if (shutdownAction.length() > 1) { |
| 516 | reason = shutdownAction.substring(1, shutdownAction.length()); |
| 517 | } else { |
| 518 | reason = null; |
Kenny Root | f547d67 | 2010-09-22 10:36:48 -0700 | [diff] [blame] | 519 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 520 | |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 521 | // If it's a pending reboot into recovery to apply an update, |
| 522 | // always make sure uncrypt gets executed properly when needed. |
| 523 | // If '/cache/recovery/block.map' hasn't been created, stop the |
| 524 | // reboot which will fail for sure, and get a chance to capture a |
Tao Bao | e8a403d57c | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 525 | // bugreport when that's still feasible. (Bug: 26444951) |
Tianjie Xu | 3a66fc4 | 2017-06-09 15:50:14 -0700 | [diff] [blame] | 526 | if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) { |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 527 | File packageFile = new File(UNCRYPT_PACKAGE_FILE); |
| 528 | if (packageFile.exists()) { |
| 529 | String filename = null; |
| 530 | try { |
| 531 | filename = FileUtils.readTextFile(packageFile, 0, null); |
| 532 | } catch (IOException e) { |
| 533 | Slog.e(TAG, "Error reading uncrypt package file", e); |
| 534 | } |
| 535 | |
| 536 | if (filename != null && filename.startsWith("/data")) { |
| 537 | if (!new File(BLOCK_MAP_FILE).exists()) { |
| 538 | Slog.e(TAG, "Can't find block map file, uncrypt failed or " + |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 539 | "unexpected runtime restart?"); |
Tao Bao | 4fd6c26 | 2016-01-19 14:22:24 -0800 | [diff] [blame] | 540 | return; |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | } |
Alison Cichowlas | f0afd8c | 2017-07-31 11:24:34 -0400 | [diff] [blame] | 545 | Runnable runnable = new Runnable() { |
| 546 | @Override |
| 547 | public void run() { |
| 548 | synchronized (this) { |
| 549 | ShutdownThread.rebootOrShutdown(null, reboot, reason); |
| 550 | } |
| 551 | } |
| 552 | }; |
| 553 | |
| 554 | // ShutdownThread must run on a looper capable of displaying the UI. |
| 555 | Message msg = Message.obtain(UiThread.getHandler(), runnable); |
| 556 | msg.setAsynchronous(true); |
| 557 | UiThread.getHandler().sendMessage(msg); |
| 558 | |
Kenny Root | f547d67 | 2010-09-22 10:36:48 -0700 | [diff] [blame] | 559 | } |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 560 | } |
Kenny Root | f547d67 | 2010-09-22 10:36:48 -0700 | [diff] [blame] | 561 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 562 | private void createSystemContext() { |
| 563 | ActivityThread activityThread = ActivityThread.systemMain(); |
| 564 | mSystemContext = activityThread.getSystemContext(); |
Alan Viverette | ba398ea | 2015-12-16 15:28:23 -0500 | [diff] [blame] | 565 | mSystemContext.setTheme(DEFAULT_SYSTEM_THEME); |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 566 | |
| 567 | final Context systemUiContext = activityThread.getSystemUiContext(); |
| 568 | systemUiContext.setTheme(DEFAULT_SYSTEM_THEME); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 569 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 570 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 571 | /** |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 572 | * Starts the small tangle of critical services that are needed to get the system off the |
| 573 | * ground. These services have complex mutual dependencies which is why we initialize them all |
| 574 | * in one place here. Unless your service is also entwined in these dependencies, it should be |
| 575 | * initialized in one of the other functions. |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 576 | */ |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 577 | private void startBootstrapServices() { |
Fyodor Kupolov | b76e0fd | 2017-01-30 13:28:25 -0800 | [diff] [blame] | 578 | Slog.i(TAG, "Reading configuration..."); |
| 579 | final String TAG_SYSTEM_CONFIG = "ReadingSystemConfig"; |
| 580 | traceBeginAndSlog(TAG_SYSTEM_CONFIG); |
| 581 | SystemServerInitThreadPool.get().submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG); |
| 582 | traceEnd(); |
| 583 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 584 | // Wait for installd to finish starting up so that it has a chance to |
| 585 | // create critical directories such as /data/user with the appropriate |
| 586 | // permissions. We need this to complete before we initialize other services. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 587 | traceBeginAndSlog("StartInstaller"); |
Narayan Kamath | 76a748e | 2014-11-10 14:23:41 +0000 | [diff] [blame] | 588 | Installer installer = mSystemServiceManager.startService(Installer.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 589 | traceEnd(); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 590 | |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 591 | // In some cases after launching an app we need to access device identifiers, |
| 592 | // therefore register the device identifier policy before the activity manager. |
| 593 | traceBeginAndSlog("DeviceIdentifiersPolicyService"); |
| 594 | mSystemServiceManager.startService(DeviceIdentifiersPolicyService.class); |
| 595 | traceEnd(); |
| 596 | |
Wale Ogunwale | 6d50dcc | 2018-07-21 23:00:40 -0700 | [diff] [blame] | 597 | // Uri Grants Manager. |
| 598 | traceBeginAndSlog("UriGrantsManagerService"); |
| 599 | mSystemServiceManager.startService(UriGrantsManagerService.Lifecycle.class); |
| 600 | traceEnd(); |
| 601 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 602 | // Activity manager runs the show. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 603 | traceBeginAndSlog("StartActivityManager"); |
Wale Ogunwale | 16e505a | 2018-05-07 15:00:49 -0700 | [diff] [blame] | 604 | // TODO: Might need to move after migration to WM. |
| 605 | ActivityTaskManagerService atm = mSystemServiceManager.startService( |
| 606 | ActivityTaskManagerService.Lifecycle.class).getService(); |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 607 | mActivityManagerService = ActivityManagerService.Lifecycle.startService( |
| 608 | mSystemServiceManager, atm); |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 609 | mActivityManagerService.setSystemServiceManager(mSystemServiceManager); |
Narayan Kamath | 76a748e | 2014-11-10 14:23:41 +0000 | [diff] [blame] | 610 | mActivityManagerService.setInstaller(installer); |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 611 | mWindowManagerGlobalLock = atm.getGlobalLock(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 612 | traceEnd(); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 613 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 614 | // Power manager needs to be started early because other services need it. |
| 615 | // Native daemons may be watching for it to be registered so it must be ready |
| 616 | // to handle incoming binder calls immediately (including being able to verify |
| 617 | // the permissions for those calls). |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 618 | traceBeginAndSlog("StartPowerManager"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 619 | mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 620 | traceEnd(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 621 | |
Wei Wang | bad7c20 | 2018-11-01 11:57:39 -0700 | [diff] [blame] | 622 | traceBeginAndSlog("StartThermalManager"); |
| 623 | mSystemServiceManager.startService(ThermalManagerService.class); |
| 624 | traceEnd(); |
| 625 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 626 | // Now that the power manager has been started, let the activity manager |
| 627 | // initialize power management features. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 628 | traceBeginAndSlog("InitPowerManagement"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 629 | mActivityManagerService.initPowerManagement(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 630 | traceEnd(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 631 | |
Jeff Sharkey | fe6f85c | 2017-01-20 10:42:57 -0700 | [diff] [blame] | 632 | // Bring up recovery system in case a rescue party needs a reboot |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 633 | traceBeginAndSlog("StartRecoverySystemService"); |
| 634 | mSystemServiceManager.startService(RecoverySystemService.class); |
| 635 | traceEnd(); |
Jeff Sharkey | fe6f85c | 2017-01-20 10:42:57 -0700 | [diff] [blame] | 636 | |
| 637 | // Now that we have the bare essentials of the OS up and running, take |
| 638 | // note that we just booted, which might send out a rescue party if |
| 639 | // we're stuck in a runtime restart loop. |
| 640 | RescueParty.noteBoot(mSystemContext); |
| 641 | |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 642 | // Manages LEDs and display backlight so we need it to bring up the display. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 643 | traceBeginAndSlog("StartLightsService"); |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 644 | mSystemServiceManager.startService(LightsService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 645 | traceEnd(); |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 646 | |
Chris Phoenix | bc839a3 | 2017-10-21 14:46:15 -0700 | [diff] [blame] | 647 | traceBeginAndSlog("StartSidekickService"); |
| 648 | // Package manager isn't started yet; need to use SysProp not hardware feature |
| 649 | if (SystemProperties.getBoolean("config.enable_sidekick_graphics", false)) { |
| 650 | mSystemServiceManager.startService(WEAR_SIDEKICK_SERVICE_CLASS); |
| 651 | } |
| 652 | traceEnd(); |
| 653 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 654 | // Display manager is needed to provide display metrics before package manager |
| 655 | // starts up. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 656 | traceBeginAndSlog("StartDisplayManager"); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 657 | mDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 658 | traceEnd(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 659 | |
| 660 | // We need the default display before we can initialize the package manager. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 661 | traceBeginAndSlog("WaitForDisplay"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 662 | mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 663 | traceEnd(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 664 | |
| 665 | // Only run "core" apps if we're encrypting the device. |
Inseob Kim | c1246e6 | 2018-11-08 13:13:54 +0900 | [diff] [blame] | 666 | String cryptState = VoldProperties.decrypt().orElse(""); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 667 | if (ENCRYPTING_STATE.equals(cryptState)) { |
| 668 | Slog.w(TAG, "Detected encryption in progress - only parsing core apps"); |
| 669 | mOnlyCore = true; |
| 670 | } else if (ENCRYPTED_STATE.equals(cryptState)) { |
| 671 | Slog.w(TAG, "Device encrypted - only parsing core apps"); |
| 672 | mOnlyCore = true; |
| 673 | } |
| 674 | |
| 675 | // Start the package manager. |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 676 | if (!mRuntimeRestart) { |
| 677 | MetricsLogger.histogram(null, "boot_package_manager_init_start", |
| 678 | (int) SystemClock.elapsedRealtime()); |
| 679 | } |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 680 | traceBeginAndSlog("StartPackageManagerService"); |
Narayan Kamath | 76a748e | 2014-11-10 14:23:41 +0000 | [diff] [blame] | 681 | mPackageManagerService = PackageManagerService.main(mSystemContext, installer, |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 682 | mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF, mOnlyCore); |
| 683 | mFirstBoot = mPackageManagerService.isFirstBoot(); |
| 684 | mPackageManager = mSystemContext.getPackageManager(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 685 | traceEnd(); |
Fyodor Kupolov | 4ba91b9 | 2017-01-20 18:12:35 -0800 | [diff] [blame] | 686 | if (!mRuntimeRestart && !isFirstBootOrUpgrade()) { |
Fyodor Kupolov | 6733e6c | 2017-01-06 18:27:05 -0800 | [diff] [blame] | 687 | MetricsLogger.histogram(null, "boot_package_manager_init_ready", |
| 688 | (int) SystemClock.elapsedRealtime()); |
| 689 | } |
Andreas Gampe | abcbe2f | 2016-02-26 11:25:36 -0800 | [diff] [blame] | 690 | // Manages A/B OTA dexopting. This is a bootstrap service as we need it to rename |
| 691 | // A/B artifacts after boot, before anything else might touch/need them. |
| 692 | // Note: this isn't needed during decryption (we don't have /data anyways). |
| 693 | if (!mOnlyCore) { |
| 694 | boolean disableOtaDexopt = SystemProperties.getBoolean("config.disable_otadexopt", |
| 695 | false); |
| 696 | if (!disableOtaDexopt) { |
| 697 | traceBeginAndSlog("StartOtaDexOptService"); |
| 698 | try { |
| 699 | OtaDexoptService.main(mSystemContext, mPackageManagerService); |
| 700 | } catch (Throwable e) { |
| 701 | reportWtf("starting OtaDexOptService", e); |
| 702 | } finally { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 703 | traceEnd(); |
Andreas Gampe | abcbe2f | 2016-02-26 11:25:36 -0800 | [diff] [blame] | 704 | } |
| 705 | } |
| 706 | } |
| 707 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 708 | traceBeginAndSlog("StartUserManagerService"); |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 709 | mSystemServiceManager.startService(UserManagerService.LifeCycle.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 710 | traceEnd(); |
Adam Lesinski | 3c15351 | 2014-07-23 17:34:34 -0700 | [diff] [blame] | 711 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 712 | // Initialize attribute cache used to cache resources from packages. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 713 | traceBeginAndSlog("InitAttributerCache"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 714 | AttributeCache.init(mSystemContext); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 715 | traceEnd(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 716 | |
| 717 | // Set up the Application instance for the system process and get started. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 718 | traceBeginAndSlog("SetSystemProcess"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 719 | mActivityManagerService.setSystemProcess(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 720 | traceEnd(); |
Svet Ganov | b9d71a6 | 2015-04-30 10:38:13 -0700 | [diff] [blame] | 721 | |
Joel Fernandes | 2d314e1 | 2017-04-04 16:32:15 -0700 | [diff] [blame] | 722 | // DisplayManagerService needs to setup android.display scheduling related policies |
| 723 | // since setSystemProcess() would have overridden policies due to setProcessGroup |
| 724 | mDisplayManagerService.setupSchedulerPolicies(); |
| 725 | |
MÃ¥rten Kongstad | 2e0d0f3 | 2016-06-02 09:35:31 +0200 | [diff] [blame] | 726 | // Manages Overlay packages |
| 727 | traceBeginAndSlog("StartOverlayManagerService"); |
MÃ¥rten Kongstad | 250cb2b | 2018-11-02 11:01:44 +0100 | [diff] [blame] | 728 | mSystemServiceManager.startService(new OverlayManagerService(mSystemContext, installer)); |
MÃ¥rten Kongstad | 2e0d0f3 | 2016-06-02 09:35:31 +0200 | [diff] [blame] | 729 | traceEnd(); |
| 730 | |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 731 | traceBeginAndSlog("StartSensorPrivacyService"); |
| 732 | mSystemServiceManager.startService(new SensorPrivacyService(mSystemContext)); |
| 733 | traceEnd(); |
| 734 | |
Svet Ganov | b9d71a6 | 2015-04-30 10:38:13 -0700 | [diff] [blame] | 735 | // The sensor service needs access to package manager service, app ops |
| 736 | // service, and permissions service, therefore we start it after them. |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 737 | // Start sensor service in a separate thread. Completion should be checked |
| 738 | // before using it. |
| 739 | mSensorServiceStart = SystemServerInitThreadPool.get().submit(() -> { |
Fyodor Kupolov | 6e3461b | 2017-08-10 17:00:43 -0700 | [diff] [blame] | 740 | TimingsTraceLog traceLog = new TimingsTraceLog( |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 741 | SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); |
| 742 | traceLog.traceBegin(START_SENSOR_SERVICE); |
| 743 | startSensorService(); |
| 744 | traceLog.traceEnd(); |
| 745 | }, START_SENSOR_SERVICE); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 746 | } |
| 747 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 748 | /** |
| 749 | * Starts some essential services that are not tangled up in the bootstrap process. |
| 750 | */ |
| 751 | private void startCoreServices() { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 752 | traceBeginAndSlog("StartBatteryService"); |
Jeff Brown | 2139276 | 2014-06-13 19:00:36 -0700 | [diff] [blame] | 753 | // Tracks the battery level. Requires LightService. |
| 754 | mSystemServiceManager.startService(BatteryService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 755 | traceEnd(); |
Adam Lesinski | 0debc9a | 2014-07-16 19:09:13 -0700 | [diff] [blame] | 756 | |
| 757 | // Tracks application usage stats. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 758 | traceBeginAndSlog("StartUsageService"); |
Adam Lesinski | 0debc9a | 2014-07-16 19:09:13 -0700 | [diff] [blame] | 759 | mSystemServiceManager.startService(UsageStatsService.class); |
| 760 | mActivityManagerService.setUsageStatsManager( |
| 761 | LocalServices.getService(UsageStatsManagerInternal.class)); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 762 | traceEnd(); |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 763 | |
| 764 | // Tracks whether the updatable WebView is in a ready state and watches for update installs. |
Torne (Richard Coles) | ff937ac | 2017-10-02 17:09:32 -0400 | [diff] [blame] | 765 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_WEBVIEW)) { |
| 766 | traceBeginAndSlog("StartWebViewUpdateService"); |
| 767 | mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class); |
| 768 | traceEnd(); |
| 769 | } |
Fyodor Kupolov | ca34851 | 2018-01-10 18:05:53 -0800 | [diff] [blame] | 770 | |
Marcin Oczeretko | c80c81a5 | 2018-08-30 20:15:52 +0100 | [diff] [blame] | 771 | // Tracks and caches the device state. |
| 772 | traceBeginAndSlog("StartCachedDeviceStateService"); |
| 773 | mSystemServiceManager.startService(CachedDeviceStateService.class); |
| 774 | traceEnd(); |
| 775 | |
Fyodor Kupolov | ca34851 | 2018-01-10 18:05:53 -0800 | [diff] [blame] | 776 | // Tracks cpu time spent in binder calls |
| 777 | traceBeginAndSlog("StartBinderCallsStatsService"); |
Olivier Gaillard | 1d7f615 | 2018-07-03 13:57:58 +0100 | [diff] [blame] | 778 | mSystemServiceManager.startService(BinderCallsStatsService.LifeCycle.class); |
Fyodor Kupolov | ca34851 | 2018-01-10 18:05:53 -0800 | [diff] [blame] | 779 | traceEnd(); |
Marcin Oczeretko | d8cc859 | 2018-08-22 16:07:36 +0100 | [diff] [blame] | 780 | |
| 781 | // Tracks time spent in handling messages in handlers. |
| 782 | traceBeginAndSlog("StartLooperStatsService"); |
| 783 | mSystemServiceManager.startService(LooperStatsService.Lifecycle.class); |
| 784 | traceEnd(); |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 785 | |
| 786 | // Manages apk rollbacks. |
| 787 | traceBeginAndSlog("StartRollbackManagerService"); |
Richard Uhler | e95d055 | 2018-12-27 15:03:41 +0000 | [diff] [blame] | 788 | mSystemServiceManager.startService(RollbackManagerService.class); |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 789 | traceEnd(); |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame^] | 790 | |
| 791 | // Service to capture bugreports. |
| 792 | traceBeginAndSlog("StartBugreportManagerService"); |
| 793 | mSystemServiceManager.startService(BugreportManagerService.class); |
| 794 | traceEnd(); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | /** |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 798 | * Starts a miscellaneous grab bag of stuff that has yet to be refactored and organized. |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 799 | */ |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 800 | private void startOtherServices() { |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 801 | final Context context = mSystemContext; |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 802 | VibratorService vibrator = null; |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 803 | IStorageManager storageManager = null; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 804 | NetworkManagementService networkManagement = null; |
Nathan Harold | b728217 | 2017-09-11 19:50:19 -0700 | [diff] [blame] | 805 | IpSecService ipSecService = null; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 806 | NetworkStatsService networkStats = null; |
Jeff Sharkey | a462079 | 2011-05-20 15:29:23 -0700 | [diff] [blame] | 807 | NetworkPolicyManagerService networkPolicy = null; |
Mike Lockwood | 0f79b54 | 2009-08-14 14:18:49 -0400 | [diff] [blame] | 808 | ConnectivityService connectivity = null; |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 809 | NsdService serviceDiscovery = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 810 | WindowManagerService wm = null; |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 811 | SerialService serial = null; |
Amith Yamasani | 6734b9f6 | 2010-09-13 16:24:08 -0700 | [diff] [blame] | 812 | NetworkTimeUpdateService networkTimeUpdater = null; |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 813 | InputManagerService inputManager = null; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 814 | TelephonyRegistry telephonyRegistry = null; |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 815 | ConsumerIrService consumerIr = null; |
Ye Wen | d97e1fd | 2014-07-24 12:56:45 -0700 | [diff] [blame] | 816 | MmsServiceBroker mmsService = null; |
Polina Bondarenko | f8754ac | 2016-02-12 20:38:23 +0100 | [diff] [blame] | 817 | HardwarePropertiesManagerService hardwarePropertiesService = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 818 | |
Abodunrinwa Toki | d32906c | 2018-01-18 04:34:44 -0800 | [diff] [blame] | 819 | boolean disableSystemTextClassifier = SystemProperties.getBoolean( |
| 820 | "config.disable_systemtextclassifier", false); |
Felipe Leme | 29397ce | 2018-11-16 17:30:36 -0800 | [diff] [blame] | 821 | |
Steve Paik | 117fcb0 | 2018-09-13 09:43:54 -0700 | [diff] [blame] | 822 | boolean disableNetworkTime = SystemProperties.getBoolean("config.disable_networktime", |
| 823 | false); |
Ivan Podogov | 8adaec0 | 2016-09-14 18:14:31 +0100 | [diff] [blame] | 824 | boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice", |
| 825 | false); |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 826 | boolean disableSlices = SystemProperties.getBoolean("config.disable_slices", false); |
Ivan Podogov | f997382 | 2017-05-11 15:51:34 +0100 | [diff] [blame] | 827 | boolean enableLeftyService = SystemProperties.getBoolean("config.enable_lefty", false); |
Wei Liu | 09de419 | 2016-09-07 13:33:49 -0700 | [diff] [blame] | 828 | |
Colin Cross | 039deed | 2017-02-18 20:05:47 +0000 | [diff] [blame] | 829 | boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1"); |
| 830 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 831 | boolean isWatch = context.getPackageManager().hasSystemFeature( |
| 832 | PackageManager.FEATURE_WATCH); |
| 833 | |
paulhsia | 0a1b322 | 2018-11-08 18:15:46 +0800 | [diff] [blame] | 834 | boolean isArc = context.getPackageManager().hasSystemFeature( |
| 835 | "org.chromium.arc"); |
| 836 | |
Rick Yiu | b287592 | 2018-09-12 11:07:25 +0000 | [diff] [blame] | 837 | boolean enableVrService = context.getPackageManager().hasSystemFeature( |
| 838 | PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE); |
| 839 | |
Jeff Sharkey | fe6f85c | 2017-01-20 10:42:57 -0700 | [diff] [blame] | 840 | // For debugging RescueParty |
| 841 | if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_system", false)) { |
| 842 | throw new RuntimeException(); |
| 843 | } |
| 844 | |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 845 | try { |
Narayan Kamath | 9778046 | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 846 | final String SECONDARY_ZYGOTE_PRELOAD = "SecondaryZygotePreload"; |
| 847 | // We start the preload ~1s before the webview factory preparation, to |
| 848 | // ensure that it completes before the 32 bit relro process is forked |
| 849 | // from the zygote. In the event that it takes too long, the webview |
| 850 | // RELRO process will block, but it will do so without holding any locks. |
| 851 | mZygotePreload = SystemServerInitThreadPool.get().submit(() -> { |
| 852 | try { |
| 853 | Slog.i(TAG, SECONDARY_ZYGOTE_PRELOAD); |
Fyodor Kupolov | 6e3461b | 2017-08-10 17:00:43 -0700 | [diff] [blame] | 854 | TimingsTraceLog traceLog = new TimingsTraceLog( |
Narayan Kamath | 9778046 | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 855 | SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); |
| 856 | traceLog.traceBegin(SECONDARY_ZYGOTE_PRELOAD); |
| 857 | if (!Process.zygoteProcess.preloadDefault(Build.SUPPORTED_32_BIT_ABIS[0])) { |
| 858 | Slog.e(TAG, "Unable to preload default resources"); |
| 859 | } |
| 860 | traceLog.traceEnd(); |
| 861 | } catch (Exception ex) { |
| 862 | Slog.e(TAG, "Exception preloading default resources", ex); |
| 863 | } |
| 864 | }, SECONDARY_ZYGOTE_PRELOAD); |
| 865 | |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 866 | traceBeginAndSlog("StartKeyAttestationApplicationIdProviderService"); |
| 867 | ServiceManager.addService("sec_key_att_app_id_provider", |
| 868 | new KeyAttestationApplicationIdProviderService(context)); |
Vitalii Tomkiv | ca68aca | 2016-09-23 10:58:43 -0700 | [diff] [blame] | 869 | traceEnd(); |
Janis Danisevskis | 8ff1e19 | 2016-06-03 11:31:55 -0700 | [diff] [blame] | 870 | |
Robin Lee | 1393549 | 2017-03-23 15:28:37 +0000 | [diff] [blame] | 871 | traceBeginAndSlog("StartKeyChainSystemService"); |
| 872 | mSystemServiceManager.startService(KeyChainSystemService.class); |
| 873 | traceEnd(); |
| 874 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 875 | traceBeginAndSlog("StartSchedulingPolicyService"); |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 876 | ServiceManager.addService("scheduling_policy", new SchedulingPolicyService()); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 877 | traceEnd(); |
Glenn Kasten | 07b0465 | 2012-04-23 15:00:43 -0700 | [diff] [blame] | 878 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 879 | traceBeginAndSlog("StartTelecomLoaderService"); |
Santos Cordon | 5d2c1e6 | 2014-11-21 15:20:15 -0800 | [diff] [blame] | 880 | mSystemServiceManager.startService(TelecomLoaderService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 881 | traceEnd(); |
Santos Cordon | 5d2c1e6 | 2014-11-21 15:20:15 -0800 | [diff] [blame] | 882 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 883 | traceBeginAndSlog("StartTelephonyRegistry"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 884 | telephonyRegistry = new TelephonyRegistry(context); |
| 885 | ServiceManager.addService("telephony.registry", telephonyRegistry); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 886 | traceEnd(); |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 887 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 888 | traceBeginAndSlog("StartEntropyMixer"); |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 889 | mEntropyMixer = new EntropyMixer(context); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 890 | traceEnd(); |
Nick Kralevich | 79619dd | 2013-03-04 13:05:32 -0800 | [diff] [blame] | 891 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 892 | mContentResolver = context.getContentResolver(); |
| 893 | |
Fred Quintana | e91ebe2 | 2009-09-29 20:44:30 -0700 | [diff] [blame] | 894 | // The AccountManager must come before the ContentService |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 895 | traceBeginAndSlog("StartAccountManagerService"); |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 896 | mSystemServiceManager.startService(ACCOUNT_SERVICE_CLASS); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 897 | traceEnd(); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 898 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 899 | traceBeginAndSlog("StartContentService"); |
Jeff Sharkey | a3ebfec | 2016-04-04 08:58:04 -0600 | [diff] [blame] | 900 | mSystemServiceManager.startService(CONTENT_SERVICE_CLASS); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 901 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 902 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 903 | traceBeginAndSlog("InstallSystemProviders"); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 904 | mActivityManagerService.installSystemProviders(); |
Fyodor Kupolov | 7fcd659 | 2017-12-15 11:56:36 -0800 | [diff] [blame] | 905 | // Now that SettingsProvider is ready, reactivate SQLiteCompatibilityWalFlags |
| 906 | SQLiteCompatibilityWalFlags.reset(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 907 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 908 | |
Yohei Yukawa | b8bbdaf | 2018-03-14 18:04:52 -0700 | [diff] [blame] | 909 | // Records errors and logs, for example wtf() |
| 910 | // Currently this service indirectly depends on SettingsProvider so do this after |
| 911 | // InstallSystemProviders. |
| 912 | traceBeginAndSlog("StartDropBoxManager"); |
| 913 | mSystemServiceManager.startService(DropBoxManagerService.class); |
| 914 | traceEnd(); |
| 915 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 916 | traceBeginAndSlog("StartVibratorService"); |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 917 | vibrator = new VibratorService(context); |
| 918 | ServiceManager.addService("vibrator", vibrator); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 919 | traceEnd(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 920 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 921 | if (!isWatch) { |
Wei Liu | 09de419 | 2016-09-07 13:33:49 -0700 | [diff] [blame] | 922 | traceBeginAndSlog("StartConsumerIrService"); |
| 923 | consumerIr = new ConsumerIrService(context); |
| 924 | ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr); |
Colin Cross | 7af8c2a | 2016-09-12 21:12:49 -0700 | [diff] [blame] | 925 | traceEnd(); |
Wei Liu | 09de419 | 2016-09-07 13:33:49 -0700 | [diff] [blame] | 926 | } |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 927 | |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 928 | traceBeginAndSlog("StartAlarmManagerService"); |
Suprabh Shukla | 6226c2f | 2018-08-22 18:15:04 -0700 | [diff] [blame] | 929 | mSystemServiceManager.startService(new AlarmManagerService(context)); |
| 930 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 931 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 932 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 933 | traceBeginAndSlog("InitWatchdog"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 934 | final Watchdog watchdog = Watchdog.getInstance(); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 935 | watchdog.init(context, mActivityManagerService); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 936 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 937 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 938 | traceBeginAndSlog("StartInputManagerService"); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 939 | inputManager = new InputManagerService(context); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 940 | traceEnd(); |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 941 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 942 | traceBeginAndSlog("StartWindowManagerService"); |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 943 | // WMS needs sensor service ready |
| 944 | ConcurrentUtils.waitForFutureNoInterrupt(mSensorServiceStart, START_SENSOR_SERVICE); |
| 945 | mSensorServiceStart = null; |
Yohei Yukawa | e24ed79 | 2018-08-28 19:10:32 -0700 | [diff] [blame] | 946 | wm = WindowManagerService.main(context, inputManager, !mFirstBoot, mOnlyCore, |
Yunfan Chen | c2ff6cf | 2018-12-04 16:56:21 -0800 | [diff] [blame] | 947 | new PhoneWindowManager(), mActivityManagerService.mActivityTaskManager); |
Vishnu Nair | e9852f5 | 2017-10-11 18:09:55 -0700 | [diff] [blame] | 948 | ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false, |
Vishnu Nair | e78b01a | 2017-10-26 10:11:54 -0700 | [diff] [blame] | 949 | DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PROTO); |
Vishnu Nair | 3764f4e | 2018-03-02 07:56:44 -0800 | [diff] [blame] | 950 | ServiceManager.addService(Context.INPUT_SERVICE, inputManager, |
| 951 | /* allowIsolated= */ false, DUMP_FLAG_PRIORITY_CRITICAL); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 952 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 953 | |
Bryce Lee | f19cbe2 | 2018-02-02 15:09:21 -0800 | [diff] [blame] | 954 | traceBeginAndSlog("SetWindowManagerService"); |
| 955 | mActivityManagerService.setWindowManager(wm); |
| 956 | traceEnd(); |
| 957 | |
| 958 | traceBeginAndSlog("WindowManagerServiceOnInitReady"); |
| 959 | wm.onInitReady(); |
| 960 | traceEnd(); |
| 961 | |
Yifan Hong | 604c12c | 2017-03-20 10:57:44 -0700 | [diff] [blame] | 962 | // Start receiving calls from HIDL services. Start in in a separate thread |
| 963 | // because it need to connect to SensorManager. This have to start |
| 964 | // after START_SENSOR_SERVICE is done. |
| 965 | SystemServerInitThreadPool.get().submit(() -> { |
Roger 1 Jönsson | 341b2c1 | 2017-05-17 14:21:55 +0200 | [diff] [blame] | 966 | TimingsTraceLog traceLog = new TimingsTraceLog( |
| 967 | SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); |
| 968 | traceLog.traceBegin(START_HIDL_SERVICES); |
Yifan Hong | 604c12c | 2017-03-20 10:57:44 -0700 | [diff] [blame] | 969 | startHidlServices(); |
Roger 1 Jönsson | 341b2c1 | 2017-05-17 14:21:55 +0200 | [diff] [blame] | 970 | traceLog.traceEnd(); |
Yifan Hong | 604c12c | 2017-03-20 10:57:44 -0700 | [diff] [blame] | 971 | }, START_HIDL_SERVICES); |
| 972 | |
Rick Yiu | b287592 | 2018-09-12 11:07:25 +0000 | [diff] [blame] | 973 | if (!isWatch && enableVrService) { |
Wei Liu | ef89d21 | 2016-09-19 15:10:33 -0700 | [diff] [blame] | 974 | traceBeginAndSlog("StartVrManagerService"); |
| 975 | mSystemServiceManager.startService(VrManagerService.class); |
Wei Liu | 03d0a36 | 2016-09-20 10:21:27 -0700 | [diff] [blame] | 976 | traceEnd(); |
Wei Liu | ef89d21 | 2016-09-19 15:10:33 -0700 | [diff] [blame] | 977 | } |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 978 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 979 | traceBeginAndSlog("StartInputManager"); |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 980 | inputManager.setWindowManagerCallbacks(wm.getInputManagerCallback()); |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 981 | inputManager.start(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 982 | traceEnd(); |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 983 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 984 | // TODO: Use service dependencies instead. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 985 | traceBeginAndSlog("DisplayManagerWindowManagerAndInputReady"); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 986 | mDisplayManagerService.windowManagerAndInputReady(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 987 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 988 | |
Colin Cross | 039deed | 2017-02-18 20:05:47 +0000 | [diff] [blame] | 989 | // Skip Bluetooth if we have an emulator kernel |
| 990 | // TODO: Use a more reliable check to see if this product should |
| 991 | // support Bluetooth - see bug 988521 |
| 992 | if (isEmulator) { |
| 993 | Slog.i(TAG, "No Bluetooth Service (emulator)"); |
| 994 | } else if (mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) { |
David 'Digit' Turner | e2a5e86 | 2011-01-17 00:32:33 +0100 | [diff] [blame] | 995 | Slog.i(TAG, "No Bluetooth Service (factory test)"); |
Matthew Xie | 1dd01eb3 | 2013-04-26 12:37:54 -0700 | [diff] [blame] | 996 | } else if (!context.getPackageManager().hasSystemFeature |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 997 | (PackageManager.FEATURE_BLUETOOTH)) { |
Matthew Xie | 1dd01eb3 | 2013-04-26 12:37:54 -0700 | [diff] [blame] | 998 | Slog.i(TAG, "No Bluetooth Service (Bluetooth Hardware Not Present)"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 999 | } else { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1000 | traceBeginAndSlog("StartBluetoothService"); |
Miao Chou | 658bf2f | 2015-06-26 17:14:35 -0700 | [diff] [blame] | 1001 | mSystemServiceManager.startService(BluetoothService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1002 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1003 | } |
Pavel Zhamaitsiak | 02b3e6b | 2016-02-03 10:39:44 -0800 | [diff] [blame] | 1004 | |
Hugo Benichi | eab511b | 2016-09-09 09:23:47 +0900 | [diff] [blame] | 1005 | traceBeginAndSlog("IpConnectivityMetrics"); |
| 1006 | mSystemServiceManager.startService(IpConnectivityMetrics.class); |
Keun-young Park | d340d8a | 2016-10-18 17:52:30 -0700 | [diff] [blame] | 1007 | traceEnd(); |
Hugo Benichi | eab511b | 2016-09-09 09:23:47 +0900 | [diff] [blame] | 1008 | |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 1009 | traceBeginAndSlog("NetworkWatchlistService"); |
| 1010 | mSystemServiceManager.startService(NetworkWatchlistService.Lifecycle.class); |
| 1011 | traceEnd(); |
| 1012 | |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 1013 | traceBeginAndSlog("PinnerService"); |
| 1014 | mSystemServiceManager.startService(PinnerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1015 | traceEnd(); |
Mathew Inwood | 4e2ed6a | 2018-11-26 15:31:16 +0000 | [diff] [blame] | 1016 | |
Igor Murashkin | 4de1e16 | 2018-11-26 10:33:17 -0800 | [diff] [blame] | 1017 | traceBeginAndSlog("IorapForwardingService"); |
| 1018 | mSystemServiceManager.startService(IorapForwardingService.class); |
| 1019 | traceEnd(); |
| 1020 | |
Mathew Inwood | 4e2ed6a | 2018-11-26 15:31:16 +0000 | [diff] [blame] | 1021 | traceBeginAndSlog("SignedConfigService"); |
| 1022 | SignedConfigService.registerUpdateReceiver(mSystemContext); |
| 1023 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1024 | } catch (RuntimeException e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1025 | Slog.e("System", "******************************************"); |
| 1026 | Slog.e("System", "************ Failure starting core service", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1027 | } |
| 1028 | |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 1029 | StatusBarManagerService statusBar = null; |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1030 | INotificationManager notification = null; |
Mike Lockwood | 46db504 | 2010-02-22 16:36:44 -0500 | [diff] [blame] | 1031 | LocationManagerService location = null; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 1032 | CountryDetectorService countryDetector = null; |
Jim Miller | 4f93c58 | 2016-01-27 19:05:43 -0800 | [diff] [blame] | 1033 | ILockSettings lockSettings = null; |
Jeff Brown | 69b0716 | 2013-11-07 00:30:16 -0800 | [diff] [blame] | 1034 | MediaRouterService mediaRouter = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1035 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1036 | // Bring up services needed for UI. |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1037 | if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1038 | traceBeginAndSlog("StartInputMethodManagerLifecycle"); |
Yohei Yukawa | 6048d89 | 2018-12-25 09:57:31 -0800 | [diff] [blame] | 1039 | if (InputMethodSystemProperty.MULTI_CLIENT_IME_ENABLED) { |
Yohei Yukawa | bae5bea | 2018-11-12 15:08:30 -0800 | [diff] [blame] | 1040 | mSystemServiceManager.startService( |
| 1041 | MultiClientInputMethodManagerService.Lifecycle.class); |
| 1042 | } else { |
| 1043 | mSystemServiceManager.startService(InputMethodManagerService.Lifecycle.class); |
| 1044 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1045 | traceEnd(); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1046 | |
Yasuhiro Matsuda | ebf9465 | 2015-09-02 22:48:13 +0900 | [diff] [blame] | 1047 | traceBeginAndSlog("StartAccessibilityManagerService"); |
dcashman | 4e3f5d3 | 2014-11-25 15:33:26 -0800 | [diff] [blame] | 1048 | try { |
Rhed Jao | 8a39cef | 2018-07-18 11:43:33 +0800 | [diff] [blame] | 1049 | mSystemServiceManager.startService(ACCESSIBILITY_MANAGER_SERVICE_CLASS); |
dcashman | 4e3f5d3 | 2014-11-25 15:33:26 -0800 | [diff] [blame] | 1050 | } catch (Throwable e) { |
| 1051 | reportWtf("starting Accessibility Manager", e); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1052 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1053 | traceEnd(); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1056 | traceBeginAndSlog("MakeDisplayReady"); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1057 | try { |
| 1058 | wm.displayReady(); |
| 1059 | } catch (Throwable e) { |
| 1060 | reportWtf("making display ready", e); |
| 1061 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1062 | traceEnd(); |
Dianne Hackborn | 8795b60 | 2011-08-25 13:30:53 -0700 | [diff] [blame] | 1063 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1064 | if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1065 | if (!"0".equals(SystemProperties.get("system_init.startmountservice"))) { |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 1066 | traceBeginAndSlog("StartStorageManagerService"); |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 1067 | try { |
| 1068 | /* |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 1069 | * NotificationManagerService is dependant on StorageManagerService, |
| 1070 | * (for media / usb notifications) so we must start StorageManagerService first. |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 1071 | */ |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 1072 | mSystemServiceManager.startService(STORAGE_MANAGER_SERVICE_CLASS); |
| 1073 | storageManager = IStorageManager.Stub.asInterface( |
Jeff Sharkey | 56e6293 | 2015-03-21 20:41:00 -0700 | [diff] [blame] | 1074 | ServiceManager.getService("mount")); |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 1075 | } catch (Throwable e) { |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 1076 | reportWtf("starting StorageManagerService", e); |
| 1077 | } |
| 1078 | traceEnd(); |
| 1079 | |
| 1080 | traceBeginAndSlog("StartStorageStatsService"); |
| 1081 | try { |
| 1082 | mSystemServiceManager.startService(STORAGE_STATS_SERVICE_CLASS); |
| 1083 | } catch (Throwable e) { |
| 1084 | reportWtf("starting StorageStatsService", e); |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 1085 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1086 | traceEnd(); |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 1087 | } |
padarshr | ada4541 | 2014-11-05 16:54:50 +0530 | [diff] [blame] | 1088 | } |
Kenny Root | 51a573c | 2012-05-17 13:30:28 -0700 | [diff] [blame] | 1089 | |
Adam Lesinski | 05199e8 | 2015-03-19 14:37:11 -0700 | [diff] [blame] | 1090 | // We start this here so that we update our configuration to set watch or television |
| 1091 | // as appropriate. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1092 | traceBeginAndSlog("StartUiModeManager"); |
Adam Lesinski | 05199e8 | 2015-03-19 14:37:11 -0700 | [diff] [blame] | 1093 | mSystemServiceManager.startService(UiModeManagerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1094 | traceEnd(); |
Adam Lesinski | 05199e8 | 2015-03-19 14:37:11 -0700 | [diff] [blame] | 1095 | |
David Brazdil | 89c80bb | 2016-06-02 15:31:30 +0100 | [diff] [blame] | 1096 | if (!mOnlyCore) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1097 | traceBeginAndSlog("UpdatePackagesIfNeeded"); |
David Brazdil | 89c80bb | 2016-06-02 15:31:30 +0100 | [diff] [blame] | 1098 | try { |
| 1099 | mPackageManagerService.updatePackagesIfNeeded(); |
| 1100 | } catch (Throwable e) { |
| 1101 | reportWtf("update packages", e); |
| 1102 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1103 | traceEnd(); |
David Brazdil | f5c444f | 2016-03-30 11:45:52 +0100 | [diff] [blame] | 1104 | } |
David Brazdil | f5c444f | 2016-03-30 11:45:52 +0100 | [diff] [blame] | 1105 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1106 | traceBeginAndSlog("PerformFstrimIfNeeded"); |
padarshr | ada4541 | 2014-11-05 16:54:50 +0530 | [diff] [blame] | 1107 | try { |
Nicolas Geoffray | 27c0737 | 2015-11-05 16:54:09 +0000 | [diff] [blame] | 1108 | mPackageManagerService.performFstrimIfNeeded(); |
padarshr | ada4541 | 2014-11-05 16:54:50 +0530 | [diff] [blame] | 1109 | } catch (Throwable e) { |
Nicolas Geoffray | 27c0737 | 2015-11-05 16:54:09 +0000 | [diff] [blame] | 1110 | reportWtf("performing fstrim", e); |
padarshr | ada4541 | 2014-11-05 16:54:50 +0530 | [diff] [blame] | 1111 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1112 | traceEnd(); |
padarshr | ada4541 | 2014-11-05 16:54:50 +0530 | [diff] [blame] | 1113 | |
padarshr | ada4541 | 2014-11-05 16:54:50 +0530 | [diff] [blame] | 1114 | if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1115 | traceBeginAndSlog("StartLockSettingsService"); |
| 1116 | try { |
| 1117 | mSystemServiceManager.startService(LOCK_SETTINGS_SERVICE_CLASS); |
| 1118 | lockSettings = ILockSettings.Stub.asInterface( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1119 | ServiceManager.getService("lock_settings")); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1120 | } catch (Throwable e) { |
| 1121 | reportWtf("starting LockSettingsService service", e); |
| 1122 | } |
| 1123 | traceEnd(); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1124 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1125 | final boolean hasPdb = !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals(""); |
| 1126 | if (hasPdb) { |
| 1127 | traceBeginAndSlog("StartPersistentDataBlock"); |
| 1128 | mSystemServiceManager.startService(PersistentDataBlockService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1129 | traceEnd(); |
Amith Yamasani | 52c489c | 2012-03-28 11:42:42 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1132 | if (hasPdb || OemLockService.isHalPresent()) { |
| 1133 | // Implementation depends on pdb or the OemLock HAL |
| 1134 | traceBeginAndSlog("StartOemLockService"); |
| 1135 | mSystemServiceManager.startService(OemLockService.class); |
| 1136 | traceEnd(); |
| 1137 | } |
| 1138 | |
| 1139 | traceBeginAndSlog("StartDeviceIdleController"); |
| 1140 | mSystemServiceManager.startService(DeviceIdleController.class); |
| 1141 | traceEnd(); |
| 1142 | |
| 1143 | // Always start the Device Policy Manager, so that the API is compatible with |
| 1144 | // API8. |
| 1145 | traceBeginAndSlog("StartDevicePolicyManager"); |
| 1146 | mSystemServiceManager.startService(DevicePolicyManagerService.Lifecycle.class); |
| 1147 | traceEnd(); |
| 1148 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1149 | if (!isWatch) { |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 1150 | traceBeginAndSlog("StartStatusBarManagerService"); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1151 | try { |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1152 | statusBar = new StatusBarManagerService(context, wm); |
| 1153 | ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar); |
| 1154 | } catch (Throwable e) { |
| 1155 | reportWtf("starting StatusBarManagerService", e); |
| 1156 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1157 | traceEnd(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1158 | } |
| 1159 | |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 1160 | startContentCaptureService(context); |
Felipe Leme | 927fbf0 | 2018-11-12 17:27:23 -0800 | [diff] [blame] | 1161 | |
| 1162 | // NOTE: ClipboardService indirectly depends on IntelligenceService |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1163 | traceBeginAndSlog("StartClipboardService"); |
| 1164 | mSystemServiceManager.startService(ClipboardService.class); |
| 1165 | traceEnd(); |
| 1166 | |
| 1167 | traceBeginAndSlog("StartNetworkManagementService"); |
| 1168 | try { |
| 1169 | networkManagement = NetworkManagementService.create(context); |
| 1170 | ServiceManager.addService(Context.NETWORKMANAGEMENT_SERVICE, networkManagement); |
| 1171 | } catch (Throwable e) { |
| 1172 | reportWtf("starting NetworkManagement Service", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1173 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1174 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1175 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1176 | traceBeginAndSlog("StartIpSecService"); |
| 1177 | try { |
| 1178 | ipSecService = IpSecService.create(context); |
| 1179 | ServiceManager.addService(Context.IPSEC_SERVICE, ipSecService); |
| 1180 | } catch (Throwable e) { |
| 1181 | reportWtf("starting IpSec Service", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1182 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1183 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1184 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1185 | traceBeginAndSlog("StartTextServicesManager"); |
| 1186 | mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class); |
| 1187 | traceEnd(); |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 1188 | |
Abodunrinwa Toki | d32906c | 2018-01-18 04:34:44 -0800 | [diff] [blame] | 1189 | if (!disableSystemTextClassifier) { |
| 1190 | traceBeginAndSlog("StartTextClassificationManagerService"); |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1191 | mSystemServiceManager |
| 1192 | .startService(TextClassificationManagerService.Lifecycle.class); |
Abodunrinwa Toki | d32906c | 2018-01-18 04:34:44 -0800 | [diff] [blame] | 1193 | traceEnd(); |
| 1194 | } |
| 1195 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1196 | traceBeginAndSlog("StartNetworkScoreService"); |
Mehdi Alizadeh | ce2d963 | 2018-03-28 17:34:24 -0700 | [diff] [blame] | 1197 | mSystemServiceManager.startService(NetworkScoreService.Lifecycle.class); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1198 | traceEnd(); |
vandwalle | 7c3606c | 2014-03-31 19:12:07 -0700 | [diff] [blame] | 1199 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1200 | traceBeginAndSlog("StartNetworkStatsService"); |
| 1201 | try { |
| 1202 | networkStats = NetworkStatsService.create(context, networkManagement); |
| 1203 | ServiceManager.addService(Context.NETWORK_STATS_SERVICE, networkStats); |
| 1204 | } catch (Throwable e) { |
| 1205 | reportWtf("starting NetworkStats Service", e); |
| 1206 | } |
| 1207 | traceEnd(); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1208 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1209 | traceBeginAndSlog("StartNetworkPolicyManagerService"); |
| 1210 | try { |
Jeff Sharkey | e0c2995 | 2018-02-20 17:24:55 -0700 | [diff] [blame] | 1211 | networkPolicy = new NetworkPolicyManagerService(context, mActivityManagerService, |
| 1212 | networkManagement); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1213 | ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy); |
| 1214 | } catch (Throwable e) { |
| 1215 | reportWtf("starting NetworkPolicy Service", e); |
| 1216 | } |
| 1217 | traceEnd(); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1218 | |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1219 | if (!mOnlyCore) { |
| 1220 | if (context.getPackageManager().hasSystemFeature( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1221 | PackageManager.FEATURE_WIFI)) { |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1222 | // Wifi Service must be started first for wifi-related services. |
| 1223 | traceBeginAndSlog("StartWifi"); |
| 1224 | mSystemServiceManager.startService(WIFI_SERVICE_CLASS); |
| 1225 | traceEnd(); |
| 1226 | traceBeginAndSlog("StartWifiScanning"); |
| 1227 | mSystemServiceManager.startService( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1228 | "com.android.server.wifi.scanner.WifiScanningService"); |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1229 | traceEnd(); |
| 1230 | } |
Rebecca Silberstein | 9e40b80 | 2017-01-07 01:59:16 -0800 | [diff] [blame] | 1231 | |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1232 | if (context.getPackageManager().hasSystemFeature( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1233 | PackageManager.FEATURE_WIFI_RTT)) { |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1234 | traceBeginAndSlog("StartRttService"); |
| 1235 | mSystemServiceManager.startService( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1236 | "com.android.server.wifi.rtt.RttService"); |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1237 | traceEnd(); |
| 1238 | } |
Wei Liu | 4e62ac5 | 2016-05-23 15:12:49 -0700 | [diff] [blame] | 1239 | |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1240 | if (context.getPackageManager().hasSystemFeature( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1241 | PackageManager.FEATURE_WIFI_AWARE)) { |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1242 | traceBeginAndSlog("StartWifiAware"); |
| 1243 | mSystemServiceManager.startService(WIFI_AWARE_SERVICE_CLASS); |
| 1244 | traceEnd(); |
| 1245 | } |
Vinit Deshpande | c4272f3 | 2014-07-25 17:46:14 -0700 | [diff] [blame] | 1246 | |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1247 | if (context.getPackageManager().hasSystemFeature( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1248 | PackageManager.FEATURE_WIFI_DIRECT)) { |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1249 | traceBeginAndSlog("StartWifiP2P"); |
| 1250 | mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS); |
| 1251 | traceEnd(); |
| 1252 | } |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 1253 | |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1254 | if (context.getPackageManager().hasSystemFeature( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1255 | PackageManager.FEATURE_LOWPAN)) { |
Paul Lawrence | 5427190 | 2018-04-13 12:31:22 -0700 | [diff] [blame] | 1256 | traceBeginAndSlog("StartLowpan"); |
| 1257 | mSystemServiceManager.startService(LOWPAN_SERVICE_CLASS); |
| 1258 | traceEnd(); |
| 1259 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1260 | } |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 1261 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1262 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET) || |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1263 | mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1264 | traceBeginAndSlog("StartEthernet"); |
| 1265 | mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS); |
| 1266 | traceEnd(); |
| 1267 | } |
| 1268 | |
| 1269 | traceBeginAndSlog("StartConnectivityService"); |
| 1270 | try { |
| 1271 | connectivity = new ConnectivityService( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1272 | context, networkManagement, networkStats, networkPolicy); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1273 | ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity, |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1274 | /* allowIsolated= */ false, |
| 1275 | DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1276 | networkStats.bindConnectivityManager(connectivity); |
| 1277 | networkPolicy.bindConnectivityManager(connectivity); |
| 1278 | } catch (Throwable e) { |
| 1279 | reportWtf("starting Connectivity Service", e); |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 1280 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1281 | traceEnd(); |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 1282 | |
Remi NGUYEN VAN | 9ed654f | 2018-12-18 18:24:26 +0900 | [diff] [blame] | 1283 | traceBeginAndSlog("StartNetworkStack"); |
| 1284 | try { |
| 1285 | final android.net.NetworkStack networkStack = |
| 1286 | context.getSystemService(android.net.NetworkStack.class); |
| 1287 | networkStack.start(context); |
| 1288 | } catch (Throwable e) { |
| 1289 | reportWtf("starting Network Stack", e); |
| 1290 | } |
| 1291 | traceEnd(); |
| 1292 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1293 | traceBeginAndSlog("StartNsdService"); |
| 1294 | try { |
| 1295 | serviceDiscovery = NsdService.create(context); |
| 1296 | ServiceManager.addService( |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1297 | Context.NSD_SERVICE, serviceDiscovery); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1298 | } catch (Throwable e) { |
| 1299 | reportWtf("starting Service Discovery Service", e); |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 1300 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1301 | traceEnd(); |
| 1302 | |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 1303 | traceBeginAndSlog("StartSystemUpdateManagerService"); |
| 1304 | try { |
| 1305 | ServiceManager.addService(Context.SYSTEM_UPDATE_SERVICE, |
| 1306 | new SystemUpdateManagerService(context)); |
| 1307 | } catch (Throwable e) { |
| 1308 | reportWtf("starting SystemUpdateManagerService", e); |
| 1309 | } |
| 1310 | traceEnd(); |
| 1311 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1312 | traceBeginAndSlog("StartUpdateLockService"); |
| 1313 | try { |
| 1314 | ServiceManager.addService(Context.UPDATE_LOCK_SERVICE, |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1315 | new UpdateLockService(context)); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1316 | } catch (Throwable e) { |
| 1317 | reportWtf("starting UpdateLockService", e); |
| 1318 | } |
| 1319 | traceEnd(); |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 1320 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1321 | traceBeginAndSlog("StartNotificationManager"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1322 | mSystemServiceManager.startService(NotificationManagerService.class); |
Geoffrey Pitsch | af759c5 | 2017-02-15 09:35:38 -0500 | [diff] [blame] | 1323 | SystemNotificationChannels.createAll(context); |
Adam Lesinski | ef2ea1f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1324 | notification = INotificationManager.Stub.asInterface( |
| 1325 | ServiceManager.getService(Context.NOTIFICATION_SERVICE)); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1326 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1327 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1328 | traceBeginAndSlog("StartDeviceMonitor"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1329 | mSystemServiceManager.startService(DeviceStorageMonitorService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1330 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1331 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1332 | traceBeginAndSlog("StartLocationManagerService"); |
| 1333 | try { |
| 1334 | location = new LocationManagerService(context); |
| 1335 | ServiceManager.addService(Context.LOCATION_SERVICE, location); |
| 1336 | } catch (Throwable e) { |
| 1337 | reportWtf("starting Location Manager", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1338 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1339 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1340 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1341 | traceBeginAndSlog("StartCountryDetectorService"); |
| 1342 | try { |
| 1343 | countryDetector = new CountryDetectorService(context); |
| 1344 | ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector); |
| 1345 | } catch (Throwable e) { |
| 1346 | reportWtf("starting Country Detector", e); |
| 1347 | } |
| 1348 | traceEnd(); |
| 1349 | |
Neil Fuller | 0e44c66 | 2018-06-21 15:16:36 +0100 | [diff] [blame] | 1350 | final boolean useNewTimeServices = true; |
| 1351 | if (useNewTimeServices) { |
| 1352 | traceBeginAndSlog("StartTimeDetectorService"); |
| 1353 | try { |
| 1354 | mSystemServiceManager.startService(TIME_DETECTOR_SERVICE_CLASS); |
| 1355 | } catch (Throwable e) { |
| 1356 | reportWtf("starting StartTimeDetectorService service", e); |
| 1357 | } |
| 1358 | traceEnd(); |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 1359 | |
Neil Fuller | 0e44c66 | 2018-06-21 15:16:36 +0100 | [diff] [blame] | 1360 | traceBeginAndSlog("StartTimeZoneDetectorService"); |
| 1361 | try { |
| 1362 | mSystemServiceManager.startService(TIME_ZONE_DETECTOR_SERVICE_CLASS); |
| 1363 | } catch (Throwable e) { |
| 1364 | reportWtf("starting StartTimeZoneDetectorService service", e); |
| 1365 | } |
| 1366 | traceEnd(); |
Neil Fuller | 7fb88c3 | 2018-06-19 12:53:47 +0100 | [diff] [blame] | 1367 | } |
Neil Fuller | 7fb88c3 | 2018-06-19 12:53:47 +0100 | [diff] [blame] | 1368 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1369 | if (!isWatch) { |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 1370 | traceBeginAndSlog("StartSearchManagerService"); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1371 | try { |
Jeff Sharkey | 4175be2 | 2016-01-09 14:57:45 -0700 | [diff] [blame] | 1372 | mSystemServiceManager.startService(SEARCH_MANAGER_SERVICE_CLASS); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1373 | } catch (Throwable e) { |
| 1374 | reportWtf("starting Search Service", e); |
| 1375 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1376 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1377 | } |
| 1378 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1379 | if (context.getResources().getBoolean(R.bool.config_enableWallpaperService)) { |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 1380 | traceBeginAndSlog("StartWallpaperManagerService"); |
Jeff Sharkey | 1cab76a | 2016-04-12 18:23:31 -0600 | [diff] [blame] | 1381 | mSystemServiceManager.startService(WALLPAPER_SERVICE_CLASS); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1382 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1383 | } |
| 1384 | |
Yasuhiro Matsuda | ebf9465 | 2015-09-02 22:48:13 +0900 | [diff] [blame] | 1385 | traceBeginAndSlog("StartAudioService"); |
paulhsia | 0a1b322 | 2018-11-08 18:15:46 +0800 | [diff] [blame] | 1386 | if (!isArc) { |
| 1387 | mSystemServiceManager.startService(AudioService.Lifecycle.class); |
| 1388 | } else { |
| 1389 | String className = context.getResources() |
| 1390 | .getString(R.string.config_deviceSpecificAudioService); |
| 1391 | try { |
| 1392 | mSystemServiceManager.startService(className + "$Lifecycle"); |
| 1393 | } catch (Throwable e) { |
| 1394 | reportWtf("starting " + className, e); |
| 1395 | } |
| 1396 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1397 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1398 | |
Tomasz Wasilczyk | 05392d6 | 2017-07-10 19:33:22 -0700 | [diff] [blame] | 1399 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_BROADCAST_RADIO)) { |
| 1400 | traceBeginAndSlog("StartBroadcastRadioService"); |
Tomasz Wasilczyk | 6b4b646 | 2017-07-19 10:52:28 -0700 | [diff] [blame] | 1401 | mSystemServiceManager.startService(BroadcastRadioService.class); |
Tomasz Wasilczyk | 347192e | 2017-04-04 11:13:44 -0700 | [diff] [blame] | 1402 | traceEnd(); |
| 1403 | } |
| 1404 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1405 | traceBeginAndSlog("StartDockObserver"); |
| 1406 | mSystemServiceManager.startService(DockObserver.class); |
| 1407 | traceEnd(); |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 1408 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1409 | if (isWatch) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1410 | traceBeginAndSlog("StartThermalObserver"); |
| 1411 | mSystemServiceManager.startService(THERMAL_OBSERVER_CLASS); |
| 1412 | traceEnd(); |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 1413 | } |
| 1414 | |
Yasuhiro Matsuda | ebf9465 | 2015-09-02 22:48:13 +0900 | [diff] [blame] | 1415 | traceBeginAndSlog("StartWiredAccessoryManager"); |
John Spurlock | b4f01b9 | 2015-03-24 12:40:15 -0400 | [diff] [blame] | 1416 | try { |
John Spurlock | b4f01b9 | 2015-03-24 12:40:15 -0400 | [diff] [blame] | 1417 | // Listen for wired headset changes |
| 1418 | inputManager.setWiredAccessoryCallbacks( |
| 1419 | new WiredAccessoryManager(context, inputManager)); |
| 1420 | } catch (Throwable e) { |
| 1421 | reportWtf("starting WiredAccessoryManager", e); |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 1422 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1423 | traceEnd(); |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 1424 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1425 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_MIDI)) { |
| 1426 | // Start MIDI Manager service |
| 1427 | traceBeginAndSlog("StartMidiManager"); |
| 1428 | mSystemServiceManager.startService(MIDI_SERVICE_CLASS); |
| 1429 | traceEnd(); |
| 1430 | } |
Mike Lockwood | 5781cd5 | 2015-03-27 13:23:41 -0700 | [diff] [blame] | 1431 | |
Kenny Root | 4673a1d1 | 2018-12-05 12:20:02 +0900 | [diff] [blame] | 1432 | // Start ADB Debugging Service |
| 1433 | traceBeginAndSlog("StartAdbService"); |
| 1434 | try { |
| 1435 | mSystemServiceManager.startService(ADB_SERVICE_CLASS); |
| 1436 | } catch (Throwable e) { |
| 1437 | Slog.e(TAG, "Failure starting AdbService"); |
| 1438 | } |
| 1439 | traceEnd(); |
| 1440 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1441 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST) |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1442 | || mPackageManager.hasSystemFeature( |
| 1443 | PackageManager.FEATURE_USB_ACCESSORY) |
| 1444 | || isEmulator) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1445 | // Manage USB host and device support |
| 1446 | traceBeginAndSlog("StartUsbService"); |
| 1447 | mSystemServiceManager.startService(USB_SERVICE_CLASS); |
| 1448 | traceEnd(); |
| 1449 | } |
Mike Lockwood | 57c798a | 2010-06-23 17:36:36 -0400 | [diff] [blame] | 1450 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1451 | if (!isWatch) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1452 | traceBeginAndSlog("StartSerialService"); |
Polina Bondarenko | f8754ac | 2016-02-12 20:38:23 +0100 | [diff] [blame] | 1453 | try { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1454 | // Serial port support |
| 1455 | serial = new SerialService(context); |
| 1456 | ServiceManager.addService(Context.SERIAL_SERVICE, serial); |
Polina Bondarenko | f8754ac | 2016-02-12 20:38:23 +0100 | [diff] [blame] | 1457 | } catch (Throwable e) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1458 | Slog.e(TAG, "Failure starting SerialService", e); |
Polina Bondarenko | f8754ac | 2016-02-12 20:38:23 +0100 | [diff] [blame] | 1459 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1460 | traceEnd(); |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 1461 | } |
| 1462 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1463 | traceBeginAndSlog("StartHardwarePropertiesManagerService"); |
| 1464 | try { |
| 1465 | hardwarePropertiesService = new HardwarePropertiesManagerService(context); |
| 1466 | ServiceManager.addService(Context.HARDWARE_PROPERTIES_SERVICE, |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1467 | hardwarePropertiesService); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1468 | } catch (Throwable e) { |
| 1469 | Slog.e(TAG, "Failure starting HardwarePropertiesManagerService", e); |
| 1470 | } |
| 1471 | traceEnd(); |
| 1472 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1473 | traceBeginAndSlog("StartTwilightService"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1474 | mSystemServiceManager.startService(TwilightService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1475 | traceEnd(); |
Jeff Brown | 2416e09 | 2012-08-21 22:12:20 -0700 | [diff] [blame] | 1476 | |
Christine Franks | 17a9bc8 | 2018-12-10 10:19:02 -0800 | [diff] [blame] | 1477 | traceBeginAndSlog("StartColorDisplay"); |
| 1478 | mSystemServiceManager.startService(ColorDisplayService.class); |
| 1479 | traceEnd(); |
Justin Klaassen | 911e889 | 2016-06-21 18:24:24 -0700 | [diff] [blame] | 1480 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1481 | traceBeginAndSlog("StartJobScheduler"); |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 1482 | mSystemServiceManager.startService(JobSchedulerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1483 | traceEnd(); |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 1484 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1485 | traceBeginAndSlog("StartSoundTrigger"); |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 1486 | mSystemServiceManager.startService(SoundTriggerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1487 | traceEnd(); |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 1488 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1489 | traceBeginAndSlog("StartTrustManager"); |
| 1490 | mSystemServiceManager.startService(TrustManagerService.class); |
| 1491 | traceEnd(); |
Jaikumar Ganesh | 7d0548d | 2010-10-18 15:29:09 -0700 | [diff] [blame] | 1492 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1493 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_BACKUP)) { |
| 1494 | traceBeginAndSlog("StartBackupManager"); |
| 1495 | mSystemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS); |
| 1496 | traceEnd(); |
| 1497 | } |
| 1498 | |
| 1499 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS) |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1500 | || context.getResources().getBoolean(R.bool.config_enableAppWidgetService)) { |
Ng Zhi An | da44a06 | 2018-05-09 22:34:53 -0700 | [diff] [blame] | 1501 | traceBeginAndSlog("StartAppWidgetService"); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1502 | mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS); |
| 1503 | traceEnd(); |
| 1504 | } |
| 1505 | |
| 1506 | // We need to always start this service, regardless of whether the |
| 1507 | // FEATURE_VOICE_RECOGNIZERS feature is set, because it needs to take care |
| 1508 | // of initializing various settings. It will internally modify its behavior |
| 1509 | // based on that feature. |
| 1510 | traceBeginAndSlog("StartVoiceRecognitionManager"); |
| 1511 | mSystemServiceManager.startService(VOICE_RECOGNITION_MANAGER_SERVICE_CLASS); |
| 1512 | traceEnd(); |
| 1513 | |
| 1514 | if (GestureLauncherService.isGestureLauncherEnabled(context.getResources())) { |
| 1515 | traceBeginAndSlog("StartGestureLauncher"); |
| 1516 | mSystemServiceManager.startService(GestureLauncherService.class); |
| 1517 | traceEnd(); |
| 1518 | } |
| 1519 | traceBeginAndSlog("StartSensorNotification"); |
| 1520 | mSystemServiceManager.startService(SensorNotificationService.class); |
| 1521 | traceEnd(); |
| 1522 | |
| 1523 | traceBeginAndSlog("StartContextHubSystemService"); |
| 1524 | mSystemServiceManager.startService(ContextHubSystemService.class); |
| 1525 | traceEnd(); |
| 1526 | |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 1527 | traceBeginAndSlog("StartDiskStatsService"); |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 1528 | try { |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 1529 | ServiceManager.addService("diskstats", new DiskStatsService(context)); |
| 1530 | } catch (Throwable e) { |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1531 | reportWtf("starting DiskStats Service", e); |
Dan Egnor | 621bc54 | 2010-03-25 16:20:14 -0700 | [diff] [blame] | 1532 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1533 | traceEnd(); |
Sen Hu | bde7570 | 2010-05-28 01:54:03 -0700 | [diff] [blame] | 1534 | |
Neil Fuller | ab0b81e | 2018-11-20 19:37:22 +0000 | [diff] [blame] | 1535 | traceBeginAndSlog("RuntimeService"); |
| 1536 | try { |
| 1537 | ServiceManager.addService("runtime", new RuntimeService(context)); |
| 1538 | } catch (Throwable e) { |
| 1539 | reportWtf("starting RuntimeService", e); |
| 1540 | } |
| 1541 | traceEnd(); |
| 1542 | |
Neil Fuller | cd1a109 | 2017-09-13 21:59:59 +0100 | [diff] [blame] | 1543 | // timezone.RulesManagerService will prevent a device starting up if the chain of trust |
| 1544 | // required for safe time zone updates might be broken. RuleManagerService cannot do |
| 1545 | // this check when mOnlyCore == true, so we don't enable the service in this case. |
| 1546 | // This service requires that JobSchedulerService is already started when it starts. |
| 1547 | final boolean startRulesManagerService = |
| 1548 | !mOnlyCore && context.getResources().getBoolean( |
| 1549 | R.bool.config_enableUpdateableTimeZoneRules); |
| 1550 | if (startRulesManagerService) { |
| 1551 | traceBeginAndSlog("StartTimeZoneRulesManagerService"); |
| 1552 | mSystemServiceManager.startService(TIME_ZONE_RULES_MANAGER_SERVICE_CLASS); |
| 1553 | traceEnd(); |
| 1554 | } |
| 1555 | |
Steve Paik | 117fcb0 | 2018-09-13 09:43:54 -0700 | [diff] [blame] | 1556 | if (!isWatch && !disableNetworkTime) { |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1557 | traceBeginAndSlog("StartNetworkTimeUpdateService"); |
| 1558 | try { |
Neil Fuller | 0e44c66 | 2018-06-21 15:16:36 +0100 | [diff] [blame] | 1559 | if (useNewTimeServices) { |
| 1560 | networkTimeUpdater = new NewNetworkTimeUpdateService(context); |
| 1561 | } else { |
| 1562 | networkTimeUpdater = new OldNetworkTimeUpdateService(context); |
| 1563 | } |
| 1564 | Slog.d(TAG, "Using networkTimeUpdater class=" + networkTimeUpdater.getClass()); |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1565 | ServiceManager.addService("network_time_update_service", networkTimeUpdater); |
| 1566 | } catch (Throwable e) { |
| 1567 | reportWtf("starting NetworkTimeUpdate service", e); |
| 1568 | } |
| 1569 | traceEnd(); |
Amith Yamasani | 6734b9f6 | 2010-09-13 16:24:08 -0700 | [diff] [blame] | 1570 | } |
John Grossman | c157673 | 2012-02-01 15:23:33 -0800 | [diff] [blame] | 1571 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1572 | traceBeginAndSlog("CertBlacklister"); |
| 1573 | try { |
| 1574 | CertBlacklister blacklister = new CertBlacklister(context); |
| 1575 | } catch (Throwable e) { |
| 1576 | reportWtf("starting CertBlacklister", e); |
Geremy Condra | 3d33c26 | 2012-05-06 18:32:19 -0700 | [diff] [blame] | 1577 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1578 | traceEnd(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1579 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1580 | if (EmergencyAffordanceManager.ENABLED) { |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1581 | // EmergencyMode service |
| 1582 | traceBeginAndSlog("StartEmergencyAffordanceService"); |
Selim Cinek | 705442f | 2016-09-13 16:02:33 -0700 | [diff] [blame] | 1583 | mSystemServiceManager.startService(EmergencyAffordanceService.class); |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1584 | traceEnd(); |
Selim Cinek | 705442f | 2016-09-13 16:02:33 -0700 | [diff] [blame] | 1585 | } |
| 1586 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1587 | // Dreams (interactive idle-time views, a/k/a screen savers, and doze mode) |
| 1588 | traceBeginAndSlog("StartDreamManager"); |
| 1589 | mSystemServiceManager.startService(DreamManagerService.class); |
| 1590 | traceEnd(); |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 1591 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1592 | traceBeginAndSlog("AddGraphicsStatsService"); |
| 1593 | ServiceManager.addService(GraphicsStatsService.GRAPHICS_STATS_SERVICE, |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1594 | new GraphicsStatsService(context)); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1595 | traceEnd(); |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 1596 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1597 | if (CoverageService.ENABLED) { |
Allen Hair | 1f556e3 | 2016-11-11 15:42:50 -0800 | [diff] [blame] | 1598 | traceBeginAndSlog("AddCoverageService"); |
| 1599 | ServiceManager.addService(CoverageService.COVERAGE_SERVICE, new CoverageService()); |
| 1600 | traceEnd(); |
| 1601 | } |
| 1602 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 1603 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1604 | traceBeginAndSlog("StartPrintManager"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 1605 | mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1606 | traceEnd(); |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 1607 | } |
Jeff Brown | 69b0716 | 2013-11-07 00:30:16 -0800 | [diff] [blame] | 1608 | |
Eugene Susla | 7c3eef2 | 2017-03-10 14:25:58 -0800 | [diff] [blame] | 1609 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_COMPANION_DEVICE_SETUP)) { |
| 1610 | traceBeginAndSlog("StartCompanionDeviceManager"); |
| 1611 | mSystemServiceManager.startService(COMPANION_DEVICE_MANAGER_SERVICE_CLASS); |
| 1612 | traceEnd(); |
| 1613 | } |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 1614 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1615 | traceBeginAndSlog("StartRestrictionManager"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 1616 | mSystemServiceManager.startService(RestrictionsManagerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1617 | traceEnd(); |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 1618 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1619 | traceBeginAndSlog("StartMediaSessionService"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 1620 | mSystemServiceManager.startService(MediaSessionService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1621 | traceEnd(); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 1622 | |
Dongwon Kang | 569da9f | 2017-11-06 09:53:52 -0800 | [diff] [blame] | 1623 | traceBeginAndSlog("StartMediaUpdateService"); |
| 1624 | mSystemServiceManager.startService(MediaUpdateService.class); |
| 1625 | traceEnd(); |
| 1626 | |
Yuncheol Heo | a0c4a06 | 2014-07-10 20:49:27 +0900 | [diff] [blame] | 1627 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_HDMI_CEC)) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1628 | traceBeginAndSlog("StartHdmiControlService"); |
Yuncheol Heo | a0c4a06 | 2014-07-10 20:49:27 +0900 | [diff] [blame] | 1629 | mSystemServiceManager.startService(HdmiControlService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1630 | traceEnd(); |
Yuncheol Heo | a0c4a06 | 2014-07-10 20:49:27 +0900 | [diff] [blame] | 1631 | } |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 1632 | |
Conrad Chen | 558acf9 | 2017-04-05 17:31:01 -0700 | [diff] [blame] | 1633 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_LIVE_TV) |
| 1634 | || mPackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1635 | traceBeginAndSlog("StartTvInputManager"); |
Dongwon Kang | 0fdcb74 | 2014-07-24 16:28:35 +0900 | [diff] [blame] | 1636 | mSystemServiceManager.startService(TvInputManagerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1637 | traceEnd(); |
Dongwon Kang | 0fdcb74 | 2014-07-24 16:28:35 +0900 | [diff] [blame] | 1638 | } |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 1639 | |
Dongwon Kang | d8b81b3 | 2016-03-23 18:04:19 -0700 | [diff] [blame] | 1640 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1641 | traceBeginAndSlog("StartMediaResourceMonitor"); |
Dongwon Kang | d8b81b3 | 2016-03-23 18:04:19 -0700 | [diff] [blame] | 1642 | mSystemServiceManager.startService(MediaResourceMonitorService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1643 | traceEnd(); |
Dongwon Kang | d8b81b3 | 2016-03-23 18:04:19 -0700 | [diff] [blame] | 1644 | } |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 1645 | |
Sujith Ramakrishnan | b5b86c1 | 2016-01-28 16:53:16 -0800 | [diff] [blame] | 1646 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1647 | traceBeginAndSlog("StartTvRemoteService"); |
Sujith Ramakrishnan | b5b86c1 | 2016-01-28 16:53:16 -0800 | [diff] [blame] | 1648 | mSystemServiceManager.startService(TvRemoteService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1649 | traceEnd(); |
Sujith Ramakrishnan | b5b86c1 | 2016-01-28 16:53:16 -0800 | [diff] [blame] | 1650 | } |
| 1651 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1652 | traceBeginAndSlog("StartMediaRouterService"); |
| 1653 | try { |
| 1654 | mediaRouter = new MediaRouterService(context); |
| 1655 | ServiceManager.addService(Context.MEDIA_ROUTER_SERVICE, mediaRouter); |
| 1656 | } catch (Throwable e) { |
| 1657 | reportWtf("starting MediaRouterService", e); |
| 1658 | } |
| 1659 | traceEnd(); |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 1660 | |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1661 | final boolean hasFeatureFace |
| 1662 | = mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE); |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 1663 | final boolean hasFeatureIris |
| 1664 | = mPackageManager.hasSystemFeature(PackageManager.FEATURE_IRIS); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1665 | final boolean hasFeatureFingerprint |
| 1666 | = mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT); |
| 1667 | |
| 1668 | if (hasFeatureFace) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1669 | traceBeginAndSlog("StartFaceSensor"); |
| 1670 | mSystemServiceManager.startService(FaceService.class); |
| 1671 | traceEnd(); |
| 1672 | } |
| 1673 | |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 1674 | if (hasFeatureIris) { |
| 1675 | traceBeginAndSlog("StartIrisSensor"); |
| 1676 | mSystemServiceManager.startService(IrisService.class); |
| 1677 | traceEnd(); |
| 1678 | } |
| 1679 | |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1680 | if (hasFeatureFingerprint) { |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1681 | traceBeginAndSlog("StartFingerprintSensor"); |
| 1682 | mSystemServiceManager.startService(FingerprintService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1683 | traceEnd(); |
Jeff Brown | 69b0716 | 2013-11-07 00:30:16 -0800 | [diff] [blame] | 1684 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1685 | |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 1686 | if (hasFeatureFace || hasFeatureIris || hasFeatureFingerprint) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1687 | // Start this service after all biometric services. |
Kevin Chyn | e739daf | 2018-11-06 17:11:06 -0800 | [diff] [blame] | 1688 | traceBeginAndSlog("StartBiometricService"); |
Kevin Chyn | 352adfe | 2018-09-20 22:28:50 -0700 | [diff] [blame] | 1689 | mSystemServiceManager.startService(BiometricService.class); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1690 | traceEnd(); |
| 1691 | } |
| 1692 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1693 | traceBeginAndSlog("StartBackgroundDexOptService"); |
| 1694 | try { |
| 1695 | BackgroundDexOptService.schedule(context); |
| 1696 | } catch (Throwable e) { |
| 1697 | reportWtf("starting StartBackgroundDexOptService", e); |
| 1698 | } |
| 1699 | traceEnd(); |
| 1700 | |
Michael Kwan | 7f70fc7 | 2018-07-20 16:12:19 -0700 | [diff] [blame] | 1701 | if (!isWatch) { |
Alan Stokes | be9ec97 | 2018-12-10 14:07:47 +0000 | [diff] [blame] | 1702 | // We don't run this on watches as there are no plans to use the data logged |
| 1703 | // on watch devices. |
| 1704 | traceBeginAndSlog("StartDynamicCodeLoggingService"); |
| 1705 | try { |
| 1706 | DynamicCodeLoggingService.schedule(context); |
| 1707 | } catch (Throwable e) { |
| 1708 | reportWtf("starting DynamicCodeLoggingService", e); |
| 1709 | } |
| 1710 | traceEnd(); |
| 1711 | } |
| 1712 | |
| 1713 | if (!isWatch) { |
Michael Kwan | 7f70fc7 | 2018-07-20 16:12:19 -0700 | [diff] [blame] | 1714 | traceBeginAndSlog("StartPruneInstantAppsJobService"); |
| 1715 | try { |
| 1716 | PruneInstantAppsJobService.schedule(context); |
| 1717 | } catch (Throwable e) { |
| 1718 | reportWtf("StartPruneInstantAppsJobService", e); |
| 1719 | } |
| 1720 | traceEnd(); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1721 | } |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1722 | |
Makoto Onuki | 5504622 | 2016-03-08 10:49:47 -0800 | [diff] [blame] | 1723 | // LauncherAppsService uses ShortcutService. |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1724 | traceBeginAndSlog("StartShortcutServiceLifecycle"); |
Makoto Onuki | 5504622 | 2016-03-08 10:49:47 -0800 | [diff] [blame] | 1725 | mSystemServiceManager.startService(ShortcutService.Lifecycle.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1726 | traceEnd(); |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 1727 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1728 | traceBeginAndSlog("StartLauncherAppsService"); |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 1729 | mSystemServiceManager.startService(LauncherAppsService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1730 | traceEnd(); |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 1731 | |
| 1732 | traceBeginAndSlog("StartCrossProfileAppsService"); |
| 1733 | mSystemServiceManager.startService(CrossProfileAppsService.class); |
| 1734 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1735 | } |
| 1736 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1737 | if (!isWatch) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1738 | traceBeginAndSlog("StartMediaProjectionManager"); |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1739 | mSystemServiceManager.startService(MediaProjectionManagerService.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1740 | traceEnd(); |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
Erik Wolsheimer | 640734f | 2018-01-29 13:57:44 -0800 | [diff] [blame] | 1743 | if (isWatch) { |
Damien Bargiacchi | ae4cb67 | 2018-05-30 13:28:15 -0700 | [diff] [blame] | 1744 | // Must be started before services that depend it, e.g. WearConnectivityService |
| 1745 | traceBeginAndSlog("StartWearPowerService"); |
| 1746 | mSystemServiceManager.startService(WEAR_POWER_SERVICE_CLASS); |
| 1747 | traceEnd(); |
| 1748 | |
Calvin On | a91e536 | 2017-02-22 15:16:42 -0800 | [diff] [blame] | 1749 | traceBeginAndSlog("StartWearConnectivityService"); |
Calvin On | 5555bcc | 2017-02-21 16:41:43 -0800 | [diff] [blame] | 1750 | mSystemServiceManager.startService(WEAR_CONNECTIVITY_SERVICE_CLASS); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1751 | traceEnd(); |
Zach Johnson | b82f3b0 | 2017-01-16 15:15:25 -0800 | [diff] [blame] | 1752 | |
Damien Bargiacchi | ae4cb67 | 2018-05-30 13:28:15 -0700 | [diff] [blame] | 1753 | traceBeginAndSlog("StartWearDisplayService"); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1754 | mSystemServiceManager.startService(WEAR_DISPLAY_SERVICE_CLASS); |
Damien Bargiacchi | ae4cb67 | 2018-05-30 13:28:15 -0700 | [diff] [blame] | 1755 | traceEnd(); |
| 1756 | |
| 1757 | traceBeginAndSlog("StartWearTimeService"); |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1758 | mSystemServiceManager.startService(WEAR_TIME_SERVICE_CLASS); |
| 1759 | traceEnd(); |
Ivan Podogov | f997382 | 2017-05-11 15:51:34 +0100 | [diff] [blame] | 1760 | |
Narayan Kamath | 1c888f6 | 2017-10-30 14:35:15 +0000 | [diff] [blame] | 1761 | if (enableLeftyService) { |
| 1762 | traceBeginAndSlog("StartWearLeftyService"); |
| 1763 | mSystemServiceManager.startService(WEAR_LEFTY_SERVICE_CLASS); |
| 1764 | traceEnd(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1765 | } |
Michael Kwan | 01ad0aa | 2018-02-28 15:19:04 -0800 | [diff] [blame] | 1766 | |
| 1767 | traceBeginAndSlog("StartWearGlobalActionsService"); |
| 1768 | mSystemServiceManager.startService(WEAR_GLOBAL_ACTIONS_SERVICE_CLASS); |
| 1769 | traceEnd(); |
Wei Liu | 48d3b63 | 2016-03-29 15:26:48 -0700 | [diff] [blame] | 1770 | } |
| 1771 | |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 1772 | if (!disableSlices) { |
| 1773 | traceBeginAndSlog("StartSliceManagerService"); |
| 1774 | mSystemServiceManager.startService(SLICE_MANAGER_SERVICE_CLASS); |
| 1775 | traceEnd(); |
| 1776 | } |
| 1777 | |
Eino-Ville Talvala | e91012b | 2017-07-10 15:27:24 -0700 | [diff] [blame] | 1778 | if (!disableCameraService) { |
| 1779 | traceBeginAndSlog("StartCameraServiceProxy"); |
| 1780 | mSystemServiceManager.startService(CameraServiceProxy.class); |
| 1781 | traceEnd(); |
| 1782 | } |
| 1783 | |
Nick Felker | 1bfe59d | 2017-10-12 13:27:02 -0700 | [diff] [blame] | 1784 | if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_EMBEDDED)) { |
| 1785 | traceBeginAndSlog("StartIoTSystemService"); |
| 1786 | mSystemServiceManager.startService(IOT_SERVICE_CLASS); |
| 1787 | traceEnd(); |
| 1788 | } |
| 1789 | |
Max Bires | ffac772 | 2017-10-23 22:59:10 +0000 | [diff] [blame] | 1790 | // Statsd helper |
| 1791 | traceBeginAndSlog("StartStatsCompanionService"); |
| 1792 | mSystemServiceManager.startService(StatsCompanionService.Lifecycle.class); |
| 1793 | traceEnd(); |
| 1794 | |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 1795 | // Before things start rolling, be sure we have decided whether |
| 1796 | // we are in safe mode. |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 1797 | final boolean safeMode = wm.detectSafeMode(); |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 1798 | if (safeMode) { |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1799 | traceBeginAndSlog("EnterSafeModeAndDisableJitCompilation"); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1800 | mActivityManagerService.enterSafeMode(); |
Jeff Brown | b09abc1 | 2011-01-13 21:08:27 -0800 | [diff] [blame] | 1801 | // Disable the JIT for the system_server process |
| 1802 | VMRuntime.getRuntime().disableJitCompilation(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1803 | traceEnd(); |
Ben Cheng | 6c0afff | 2010-02-14 16:18:56 -0800 | [diff] [blame] | 1804 | } else { |
| 1805 | // Enable the JIT for the system_server process |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1806 | traceBeginAndSlog("StartJitCompilation"); |
Ben Cheng | 6c0afff | 2010-02-14 16:18:56 -0800 | [diff] [blame] | 1807 | VMRuntime.getRuntime().startJitCompilation(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1808 | traceEnd(); |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 1809 | } |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 1810 | |
Ye Wen | d97e1fd | 2014-07-24 12:56:45 -0700 | [diff] [blame] | 1811 | // MMS service broker |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1812 | traceBeginAndSlog("StartMmsService"); |
Ye Wen | d97e1fd | 2014-07-24 12:56:45 -0700 | [diff] [blame] | 1813 | mmsService = mSystemServiceManager.startService(MmsServiceBroker.class); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1814 | traceEnd(); |
Ye Wen | d97e1fd | 2014-07-24 12:56:45 -0700 | [diff] [blame] | 1815 | |
Svet Ganov | 43574b0 | 2017-04-12 09:25:20 -0700 | [diff] [blame] | 1816 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOFILL)) { |
| 1817 | traceBeginAndSlog("StartAutoFillService"); |
| 1818 | mSystemServiceManager.startService(AUTO_FILL_MANAGER_SERVICE_CLASS); |
| 1819 | traceEnd(); |
| 1820 | } |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 1821 | |
Makoto Onuki | df7e481 | 2018-09-24 14:31:25 -0700 | [diff] [blame] | 1822 | traceBeginAndSlog("AppServiceManager"); |
| 1823 | mSystemServiceManager.startService(AppBindingService.Lifecycle.class); |
| 1824 | traceEnd(); |
| 1825 | |
Dianne Hackborn | 6af0d50 | 2009-09-28 13:25:46 -0700 | [diff] [blame] | 1826 | // It is now time to start up the app processes... |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 1827 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1828 | traceBeginAndSlog("MakeVibratorServiceReady"); |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 1829 | try { |
| 1830 | vibrator.systemReady(); |
| 1831 | } catch (Throwable e) { |
| 1832 | reportWtf("making Vibrator Service ready", e); |
| 1833 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1834 | traceEnd(); |
Jeff Brown | 7f6c231 | 2012-04-13 20:38:38 -0700 | [diff] [blame] | 1835 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1836 | traceBeginAndSlog("MakeLockSettingsServiceReady"); |
Dan Morrill | e4d9a01 | 2013-03-28 18:10:43 -0700 | [diff] [blame] | 1837 | if (lockSettings != null) { |
| 1838 | try { |
| 1839 | lockSettings.systemReady(); |
| 1840 | } catch (Throwable e) { |
| 1841 | reportWtf("making Lock Settings Service ready", e); |
| 1842 | } |
Felipe Ramos | f35df5b | 2012-09-18 18:26:27 -0300 | [diff] [blame] | 1843 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1844 | traceEnd(); |
Felipe Ramos | f35df5b | 2012-09-18 18:26:27 -0300 | [diff] [blame] | 1845 | |
Amith Yamasani | 817ec49 | 2013-12-20 13:27:30 -0800 | [diff] [blame] | 1846 | // Needed by DevicePolicyManager for initialization |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1847 | traceBeginAndSlog("StartBootPhaseLockSettingsReady"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1848 | mSystemServiceManager.startBootPhase(SystemService.PHASE_LOCK_SETTINGS_READY); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1849 | traceEnd(); |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1850 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1851 | traceBeginAndSlog("StartBootPhaseSystemServicesReady"); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1852 | mSystemServiceManager.startBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1853 | traceEnd(); |
Joe Onorato | 3027548 | 2009-07-08 17:09:14 -0700 | [diff] [blame] | 1854 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1855 | traceBeginAndSlog("MakeWindowManagerServiceReady"); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1856 | try { |
| 1857 | wm.systemReady(); |
| 1858 | } catch (Throwable e) { |
| 1859 | reportWtf("making Window Manager Service ready", e); |
| 1860 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1861 | traceEnd(); |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 1862 | |
Jeff Brown | b09abc1 | 2011-01-13 21:08:27 -0800 | [diff] [blame] | 1863 | if (safeMode) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1864 | mActivityManagerService.showSafeModeOverlay(); |
Jeff Brown | b09abc1 | 2011-01-13 21:08:27 -0800 | [diff] [blame] | 1865 | } |
| 1866 | |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 1867 | // Update the configuration for this context by hand, because we're going |
| 1868 | // to start using it before the config change done in wm.systemReady() will |
| 1869 | // propagate to it. |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 1870 | final Configuration config = wm.computeNewConfiguration(DEFAULT_DISPLAY); |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 1871 | DisplayMetrics metrics = new DisplayMetrics(); |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1872 | WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); |
Joe Onorato | dc565f4 | 2010-10-04 15:27:22 -0400 | [diff] [blame] | 1873 | w.getDefaultDisplay().getMetrics(metrics); |
| 1874 | context.getResources().updateConfiguration(config, metrics); |
| 1875 | |
Alan Viverette | 395cd01 | 2015-08-11 17:27:04 -0400 | [diff] [blame] | 1876 | // The system context's theme may be configuration-dependent. |
| 1877 | final Theme systemTheme = context.getTheme(); |
| 1878 | if (systemTheme.getChangingConfigurations() != 0) { |
| 1879 | systemTheme.rebase(); |
| 1880 | } |
| 1881 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1882 | traceBeginAndSlog("MakePowerManagerServiceReady"); |
Jeff Brown | aa202a6 | 2012-08-21 22:14:26 -0700 | [diff] [blame] | 1883 | try { |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1884 | // TODO: use boot phase |
Jeff Brown | 2139276 | 2014-06-13 19:00:36 -0700 | [diff] [blame] | 1885 | mPowerManagerService.systemReady(mActivityManagerService.getAppOpsService()); |
Jeff Brown | aa202a6 | 2012-08-21 22:14:26 -0700 | [diff] [blame] | 1886 | } catch (Throwable e) { |
| 1887 | reportWtf("making Power Manager Service ready", e); |
| 1888 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1889 | traceEnd(); |
Jeff Brown | aa202a6 | 2012-08-21 22:14:26 -0700 | [diff] [blame] | 1890 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1891 | traceBeginAndSlog("MakePackageManagerServiceReady"); |
Fyodor Kupolov | c56106a | 2017-10-06 17:02:21 -0700 | [diff] [blame] | 1892 | mPackageManagerService.systemReady(); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1893 | traceEnd(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1894 | |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1895 | traceBeginAndSlog("MakeDisplayManagerServiceReady"); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1896 | try { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1897 | // TODO: use boot phase and communicate these flags some other way |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 1898 | mDisplayManagerService.systemReady(safeMode, mOnlyCore); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1899 | } catch (Throwable e) { |
| 1900 | reportWtf("making Display Manager Service ready", e); |
| 1901 | } |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 1902 | traceEnd(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1903 | |
joonyoung.cho | 2f30cc1 | 2015-04-08 13:56:34 +0900 | [diff] [blame] | 1904 | mSystemServiceManager.setSafeMode(safeMode); |
| 1905 | |
Daichi Hirono | edfcb00 | 2017-10-10 17:22:58 +0900 | [diff] [blame] | 1906 | // Start device specific services |
| 1907 | traceBeginAndSlog("StartDeviceSpecificServices"); |
| 1908 | final String[] classes = mSystemContext.getResources().getStringArray( |
| 1909 | R.array.config_deviceSpecificSystemServices); |
| 1910 | for (final String className : classes) { |
| 1911 | traceBeginAndSlog("StartDeviceSpecificServices " + className); |
| 1912 | try { |
| 1913 | mSystemServiceManager.startService(className); |
| 1914 | } catch (Throwable e) { |
| 1915 | reportWtf("starting " + className, e); |
| 1916 | } |
| 1917 | traceEnd(); |
| 1918 | } |
| 1919 | traceEnd(); |
| 1920 | |
| 1921 | traceBeginAndSlog("StartBootPhaseDeviceSpecificServicesReady"); |
| 1922 | mSystemServiceManager.startBootPhase(SystemService.PHASE_DEVICE_SPECIFIC_SERVICES_READY); |
| 1923 | traceEnd(); |
| 1924 | |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 1925 | // These are needed to propagate to the runnable below. |
Jeff Sharkey | 350083e | 2011-06-29 10:45:16 -0700 | [diff] [blame] | 1926 | final NetworkManagementService networkManagementF = networkManagement; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 1927 | final NetworkStatsService networkStatsF = networkStats; |
Jeff Sharkey | a462079 | 2011-05-20 15:29:23 -0700 | [diff] [blame] | 1928 | final NetworkPolicyManagerService networkPolicyF = networkPolicy; |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 1929 | final ConnectivityService connectivityF = connectivity; |
Mike Lockwood | 46db504 | 2010-02-22 16:36:44 -0500 | [diff] [blame] | 1930 | final LocationManagerService locationF = location; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 1931 | final CountryDetectorService countryDetectorF = countryDetector; |
Amith Yamasani | 6734b9f6 | 2010-09-13 16:24:08 -0700 | [diff] [blame] | 1932 | final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater; |
Jeff Brown | 6ec6f79 | 2012-04-17 16:52:41 -0700 | [diff] [blame] | 1933 | final InputManagerService inputManagerF = inputManager; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1934 | final TelephonyRegistry telephonyRegistryF = telephonyRegistry; |
Jeff Brown | 69b0716 | 2013-11-07 00:30:16 -0800 | [diff] [blame] | 1935 | final MediaRouterService mediaRouterF = mediaRouter; |
Ye Wen | d97e1fd | 2014-07-24 12:56:45 -0700 | [diff] [blame] | 1936 | final MmsServiceBroker mmsServiceF = mmsService; |
Nathan Harold | b728217 | 2017-09-11 19:50:19 -0700 | [diff] [blame] | 1937 | final IpSecService ipSecServiceF = ipSecService; |
Keun-young Park | 4136d2d | 2017-05-08 14:51:59 -0700 | [diff] [blame] | 1938 | final WindowManagerService windowManagerF = wm; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 1939 | |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 1940 | // We now tell the activity manager it is okay to run third party |
| 1941 | // code. It will call back into us once it has gotten to the state |
| 1942 | // where third party code can really run (but before it has actually |
| 1943 | // started launching the initial applications), for us to complete our |
| 1944 | // initialization. |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1945 | mActivityManagerService.systemReady(() -> { |
| 1946 | Slog.i(TAG, "Making services ready"); |
| 1947 | traceBeginAndSlog("StartActivityManagerReadyPhase"); |
| 1948 | mSystemServiceManager.startBootPhase( |
| 1949 | SystemService.PHASE_ACTIVITY_MANAGER_READY); |
| 1950 | traceEnd(); |
| 1951 | traceBeginAndSlog("StartObservingNativeCrashes"); |
| 1952 | try { |
| 1953 | mActivityManagerService.startObservingNativeCrashes(); |
| 1954 | } catch (Throwable e) { |
| 1955 | reportWtf("observing native crashes", e); |
Dianne Hackborn | a34f1ad | 2009-09-02 13:26:28 -0700 | [diff] [blame] | 1956 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1957 | traceEnd(); |
| 1958 | |
Eugene Susla | 6d492272 | 2018-11-08 16:25:28 -0800 | [diff] [blame] | 1959 | // Grants default permissions and defines roles |
| 1960 | traceBeginAndSlog("StartRoleManagerService"); |
| 1961 | mSystemServiceManager.startService(RoleManagerService.class); |
| 1962 | traceEnd(); |
| 1963 | |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 1964 | // No dependency on Webview preparation in system server. But this should |
Torne (Richard Coles) | ff937ac | 2017-10-02 17:09:32 -0400 | [diff] [blame] | 1965 | // be completed before allowing 3rd party |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 1966 | final String WEBVIEW_PREPARATION = "WebViewFactoryPreparation"; |
| 1967 | Future<?> webviewPrep = null; |
Torne (Richard Coles) | ff937ac | 2017-10-02 17:09:32 -0400 | [diff] [blame] | 1968 | if (!mOnlyCore && mWebViewUpdateService != null) { |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 1969 | webviewPrep = SystemServerInitThreadPool.get().submit(() -> { |
| 1970 | Slog.i(TAG, WEBVIEW_PREPARATION); |
Fyodor Kupolov | 6e3461b | 2017-08-10 17:00:43 -0700 | [diff] [blame] | 1971 | TimingsTraceLog traceLog = new TimingsTraceLog( |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 1972 | SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 1973 | traceLog.traceBegin(WEBVIEW_PREPARATION); |
Narayan Kamath | 9778046 | 2017-02-06 20:24:08 +0000 | [diff] [blame] | 1974 | ConcurrentUtils.waitForFutureNoInterrupt(mZygotePreload, "Zygote preload"); |
| 1975 | mZygotePreload = null; |
Keun-young Park | d80e894 | 2017-01-27 11:30:19 -0800 | [diff] [blame] | 1976 | mWebViewUpdateService.prepareWebViewInSystemServer(); |
| 1977 | traceLog.traceEnd(); |
| 1978 | }, WEBVIEW_PREPARATION); |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1979 | } |
| 1980 | |
Keun-young Park | 067cf3e | 2017-06-05 12:20:41 -0700 | [diff] [blame] | 1981 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { |
| 1982 | traceBeginAndSlog("StartCarServiceHelperService"); |
Steve Paik | 94292a3 | 2018-01-26 17:16:53 -0800 | [diff] [blame] | 1983 | mSystemServiceManager.startService(CAR_SERVICE_HELPER_SERVICE_CLASS); |
Keun-young Park | 067cf3e | 2017-06-05 12:20:41 -0700 | [diff] [blame] | 1984 | traceEnd(); |
| 1985 | } |
| 1986 | |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1987 | traceBeginAndSlog("StartSystemUI"); |
| 1988 | try { |
Keun-young Park | 4136d2d | 2017-05-08 14:51:59 -0700 | [diff] [blame] | 1989 | startSystemUi(context, windowManagerF); |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1990 | } catch (Throwable e) { |
| 1991 | reportWtf("starting System UI", e); |
| 1992 | } |
| 1993 | traceEnd(); |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1994 | traceBeginAndSlog("MakeNetworkManagementServiceReady"); |
| 1995 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 1996 | if (networkManagementF != null) { |
| 1997 | networkManagementF.systemReady(); |
| 1998 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 1999 | } catch (Throwable e) { |
| 2000 | reportWtf("making Network Managment Service ready", e); |
| 2001 | } |
| 2002 | CountDownLatch networkPolicyInitReadySignal = null; |
| 2003 | if (networkPolicyF != null) { |
| 2004 | networkPolicyInitReadySignal = networkPolicyF |
| 2005 | .networkScoreAndNetworkManagementServiceReady(); |
| 2006 | } |
| 2007 | traceEnd(); |
Nathan Harold | b728217 | 2017-09-11 19:50:19 -0700 | [diff] [blame] | 2008 | traceBeginAndSlog("MakeIpSecServiceReady"); |
| 2009 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2010 | if (ipSecServiceF != null) { |
| 2011 | ipSecServiceF.systemReady(); |
| 2012 | } |
Nathan Harold | b728217 | 2017-09-11 19:50:19 -0700 | [diff] [blame] | 2013 | } catch (Throwable e) { |
| 2014 | reportWtf("making IpSec Service ready", e); |
| 2015 | } |
| 2016 | traceEnd(); |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2017 | traceBeginAndSlog("MakeNetworkStatsServiceReady"); |
| 2018 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2019 | if (networkStatsF != null) { |
| 2020 | networkStatsF.systemReady(); |
| 2021 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2022 | } catch (Throwable e) { |
| 2023 | reportWtf("making Network Stats Service ready", e); |
| 2024 | } |
| 2025 | traceEnd(); |
| 2026 | traceBeginAndSlog("MakeConnectivityServiceReady"); |
| 2027 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2028 | if (connectivityF != null) { |
| 2029 | connectivityF.systemReady(); |
| 2030 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2031 | } catch (Throwable e) { |
| 2032 | reportWtf("making Connectivity Service ready", e); |
| 2033 | } |
| 2034 | traceEnd(); |
| 2035 | traceBeginAndSlog("MakeNetworkPolicyServiceReady"); |
| 2036 | try { |
| 2037 | if (networkPolicyF != null) { |
| 2038 | networkPolicyF.systemReady(networkPolicyInitReadySignal); |
| 2039 | } |
| 2040 | } catch (Throwable e) { |
| 2041 | reportWtf("making Network Policy Service ready", e); |
| 2042 | } |
| 2043 | traceEnd(); |
| 2044 | |
| 2045 | traceBeginAndSlog("StartWatchdog"); |
| 2046 | Watchdog.getInstance().start(); |
| 2047 | traceEnd(); |
| 2048 | |
Fyodor Kupolov | cd824ef | 2017-02-07 11:25:14 -0800 | [diff] [blame] | 2049 | // Wait for all packages to be prepared |
| 2050 | mPackageManagerService.waitForAppDataPrepared(); |
| 2051 | |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2052 | // It is now okay to let the various system services start their |
| 2053 | // third party code... |
| 2054 | traceBeginAndSlog("PhaseThirdPartyAppsCanStart"); |
Keun-young Park | 9b73a54 | 2017-02-01 12:09:58 -0800 | [diff] [blame] | 2055 | // confirm webview completion before starting 3rd party |
| 2056 | if (webviewPrep != null) { |
| 2057 | ConcurrentUtils.waitForFutureNoInterrupt(webviewPrep, WEBVIEW_PREPARATION); |
| 2058 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2059 | mSystemServiceManager.startBootPhase( |
| 2060 | SystemService.PHASE_THIRD_PARTY_APPS_CAN_START); |
| 2061 | traceEnd(); |
| 2062 | |
| 2063 | traceBeginAndSlog("MakeLocationServiceReady"); |
| 2064 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2065 | if (locationF != null) { |
| 2066 | locationF.systemRunning(); |
| 2067 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2068 | } catch (Throwable e) { |
| 2069 | reportWtf("Notifying Location Service running", e); |
| 2070 | } |
| 2071 | traceEnd(); |
| 2072 | traceBeginAndSlog("MakeCountryDetectionServiceReady"); |
| 2073 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2074 | if (countryDetectorF != null) { |
| 2075 | countryDetectorF.systemRunning(); |
| 2076 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2077 | } catch (Throwable e) { |
| 2078 | reportWtf("Notifying CountryDetectorService running", e); |
| 2079 | } |
| 2080 | traceEnd(); |
| 2081 | traceBeginAndSlog("MakeNetworkTimeUpdateReady"); |
| 2082 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2083 | if (networkTimeUpdaterF != null) { |
| 2084 | networkTimeUpdaterF.systemRunning(); |
| 2085 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2086 | } catch (Throwable e) { |
| 2087 | reportWtf("Notifying NetworkTimeService running", e); |
| 2088 | } |
| 2089 | traceEnd(); |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2090 | traceBeginAndSlog("MakeInputManagerServiceReady"); |
| 2091 | try { |
| 2092 | // TODO(BT) Pass parameter to input manager |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2093 | if (inputManagerF != null) { |
| 2094 | inputManagerF.systemRunning(); |
| 2095 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2096 | } catch (Throwable e) { |
| 2097 | reportWtf("Notifying InputManagerService running", e); |
| 2098 | } |
| 2099 | traceEnd(); |
| 2100 | traceBeginAndSlog("MakeTelephonyRegistryReady"); |
| 2101 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2102 | if (telephonyRegistryF != null) { |
| 2103 | telephonyRegistryF.systemRunning(); |
| 2104 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2105 | } catch (Throwable e) { |
| 2106 | reportWtf("Notifying TelephonyRegistry running", e); |
| 2107 | } |
| 2108 | traceEnd(); |
| 2109 | traceBeginAndSlog("MakeMediaRouterServiceReady"); |
| 2110 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2111 | if (mediaRouterF != null) { |
| 2112 | mediaRouterF.systemRunning(); |
| 2113 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2114 | } catch (Throwable e) { |
| 2115 | reportWtf("Notifying MediaRouterService running", e); |
| 2116 | } |
| 2117 | traceEnd(); |
| 2118 | traceBeginAndSlog("MakeMmsServiceReady"); |
| 2119 | try { |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2120 | if (mmsServiceF != null) { |
| 2121 | mmsServiceF.systemRunning(); |
| 2122 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2123 | } catch (Throwable e) { |
| 2124 | reportWtf("Notifying MmsService running", e); |
| 2125 | } |
| 2126 | traceEnd(); |
| 2127 | |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2128 | traceBeginAndSlog("IncidentDaemonReady"); |
| 2129 | try { |
| 2130 | // TODO: Switch from checkService to getService once it's always |
| 2131 | // in the build and should reliably be there. |
| 2132 | final IIncidentManager incident = IIncidentManager.Stub.asInterface( |
Yi Jin | f32af48 | 2017-08-11 15:00:49 -0700 | [diff] [blame] | 2133 | ServiceManager.getService(Context.INCIDENT_SERVICE)); |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2134 | if (incident != null) { |
| 2135 | incident.systemRunning(); |
| 2136 | } |
Fyodor Kupolov | 6dd2ba2 | 2016-12-07 13:03:17 -0800 | [diff] [blame] | 2137 | } catch (Throwable e) { |
| 2138 | reportWtf("Notifying incident daemon running", e); |
| 2139 | } |
| 2140 | traceEnd(); |
| 2141 | }, BOOT_TIMINGS_TRACE_LOG); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2142 | } |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2143 | |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 2144 | private void startContentCaptureService(@NonNull Context context) { |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 2145 | |
Felipe Leme | d264c72 | 2018-12-17 11:47:14 -0800 | [diff] [blame] | 2146 | // Check if it was explicitly enabled by Settings |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 2147 | final String settings = Settings.Global.getString(context.getContentResolver(), |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 2148 | Settings.Global.CONTENT_CAPTURE_SERVICE_EXPLICITLY_ENABLED); |
Felipe Leme | d264c72 | 2018-12-17 11:47:14 -0800 | [diff] [blame] | 2149 | if (settings == null) { |
| 2150 | // Better be safe than sorry... |
| 2151 | Slog.d(TAG, "ContentCaptureService disabled because its not set by OEM"); |
| 2152 | return; |
| 2153 | } |
| 2154 | switch (settings) { |
Felipe Leme | 6bb8a96 | 2018-12-19 21:00:55 -0800 | [diff] [blame] | 2155 | case "always": |
Felipe Leme | d264c72 | 2018-12-17 11:47:14 -0800 | [diff] [blame] | 2156 | // Should be used only during development |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 2157 | Slog.d(TAG, "ContentCaptureService explicitly enabled by Settings"); |
Felipe Leme | d264c72 | 2018-12-17 11:47:14 -0800 | [diff] [blame] | 2158 | break; |
Felipe Leme | 6bb8a96 | 2018-12-19 21:00:55 -0800 | [diff] [blame] | 2159 | case "default": |
Felipe Leme | d264c72 | 2018-12-17 11:47:14 -0800 | [diff] [blame] | 2160 | // Default case: check if OEM overlaid the resource that defines the service. |
| 2161 | final String serviceName = context.getString( |
| 2162 | com.android.internal.R.string.config_defaultContentCaptureService); |
| 2163 | if (TextUtils.isEmpty(serviceName)) { |
| 2164 | Slog.d(TAG, "ContentCaptureService disabled because resource is not overlaid"); |
| 2165 | return; |
| 2166 | } |
| 2167 | break; |
| 2168 | default: |
| 2169 | // Kill switch for OEMs |
| 2170 | Slog.d(TAG, "ContentCaptureService disabled because its set to: " + settings); |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 2171 | return; |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 2172 | } |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 2173 | traceBeginAndSlog("StartContentCaptureService"); |
| 2174 | mSystemServiceManager.startService(CONTENT_CAPTURE_MANAGER_SERVICE_CLASS); |
Felipe Leme | 658c8e4 | 2018-11-30 12:49:45 -0800 | [diff] [blame] | 2175 | traceEnd(); |
| 2176 | } |
| 2177 | |
Keun-young Park | 4136d2d | 2017-05-08 14:51:59 -0700 | [diff] [blame] | 2178 | static final void startSystemUi(Context context, WindowManagerService windowManager) { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2179 | Intent intent = new Intent(); |
| 2180 | intent.setComponent(new ComponentName("com.android.systemui", |
Christine Franks | ea7d71b | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 2181 | "com.android.systemui.SystemUIService")); |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 2182 | intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING); |
Dianne Hackborn | 40e9f29 | 2012-11-27 19:12:23 -0800 | [diff] [blame] | 2183 | //Slog.d(TAG, "Starting service: " + intent); |
Xiaohui Chen | 70f6c38 | 2015-04-28 14:21:43 -0700 | [diff] [blame] | 2184 | context.startServiceAsUser(intent, UserHandle.SYSTEM); |
Keun-young Park | 4136d2d | 2017-05-08 14:51:59 -0700 | [diff] [blame] | 2185 | windowManager.onSystemUiStarted(); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2186 | } |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 2187 | |
| 2188 | private static void traceBeginAndSlog(String name) { |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 2189 | Slog.i(TAG, name); |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 2190 | BOOT_TIMINGS_TRACE_LOG.traceBegin(name); |
Vitalii Tomkiv | 4887e67 | 2016-07-21 15:58:24 -0700 | [diff] [blame] | 2191 | } |
| 2192 | |
| 2193 | private static void traceEnd() { |
Fyodor Kupolov | 3235e0c | 2016-11-17 11:44:49 -0800 | [diff] [blame] | 2194 | BOOT_TIMINGS_TRACE_LOG.traceEnd(); |
Yasuhiro Matsuda | 1ab43d5 | 2015-06-30 17:07:32 +0900 | [diff] [blame] | 2195 | } |
Nicolas Geoffray | 27c0737 | 2015-11-05 16:54:09 +0000 | [diff] [blame] | 2196 | } |