2009-03-03 19:31:44 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.server;
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
import android.app.ActivityThread;
|
2013-12-05 16:48:06 -08:00
|
|
|
import android.app.INotificationManager;
|
2014-07-16 19:09:13 -07:00
|
|
|
import android.app.usage.UsageStatsManagerInternal;
|
2010-10-21 11:09:02 -04:00
|
|
|
import android.content.ComponentName;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.content.ContentResolver;
|
|
|
|
import android.content.Context;
|
2010-10-21 11:09:02 -04:00
|
|
|
import android.content.Intent;
|
2013-04-26 12:37:54 -07:00
|
|
|
import android.content.pm.PackageManager;
|
2010-10-04 15:27:22 -04:00
|
|
|
import android.content.res.Configuration;
|
2015-05-06 10:41:43 -07:00
|
|
|
import android.content.res.Resources.Theme;
|
2016-03-09 22:30:56 -07:00
|
|
|
import android.os.BaseBundle;
|
2016-11-04 11:23:46 -06:00
|
|
|
import android.os.Binder;
|
2014-04-09 18:07:19 -07:00
|
|
|
import android.os.Build;
|
2013-04-19 13:25:04 -07:00
|
|
|
import android.os.Environment;
|
2014-01-15 20:40:55 -08:00
|
|
|
import android.os.FactoryTest;
|
2016-01-19 14:22:24 -08:00
|
|
|
import android.os.FileUtils;
|
First checkin of incident reporting.
There are a few major pieces here:
incidentd
---------
This daemon (started by init) runs and accepts incoming requests to take
incident reports. When prompted, it calls into various system services
and fills in an IncidentProto data structure, and then writes the report
into dropbox.
The next steps for incidentd:
- Security review of SELinux policies. These will be a subset of
the dumpstate permissions. Until this is done, incidentd is
not started at boot time.
incident
--------
This shell command calls into incidentd, and can initiate an incident
report and either capture the output or leave for dropbox.
incident_report
---------------
This host side tool can call adb shell with the correct parameters
and also format the incident report as text. This formatting code
was left of the device on purpose. Right now it's pretty small, but
as the number of fields increases, the metadata and code to do the
formatting will start to grow.
The incident_report command also contains a workaround to let it
work before incidentd is turned on by default. Right now, it is
implemented to call adb shell dumpsys <service> --proto directly,
whereas in the future it will go through the full incidentd flow.
incident_section_gen
--------------------
A build-time tool that generates a stripped down set of information
about the fields that are available.
libincident
-----------
This library contains the code to connect to incidentd, and the
meta proto definitions that are used by the framework protos.
The basics are here now, but they are not fully fleshed out yet.
The privacy.proto file contains annotations that can go in the
proto file that we will later use to filter which fields are
uploaded, and which are used by local sources. For example, a
device in a test lab is safe to upload much much more information
than a real user. These will share the same mechanism, but the
user's output will be filtered according to these annotations.
frameworks/core/proto
---------------------
These .proto files contain the definitions of the system's
output. There is one master android.os.IncidentProto file that
is the top level of an incident report, but some other services
(notification, fingerprint, batterystats, etc) will have others
that are used directly by the logging mechanism.
Other files which are shared by several of the services also go
here, such as ComponentName, Locale, Configuration, etc. There
will be many more.
There is also a first iplementation of a dump method handling
--proto in the fingerprint service.
IncidentManager
---------------
The java API to trigger an incident report.
Test: Not written yet
Change-Id: I59568b115ac7fcf73af70c946c95752bf33ae67f
2016-11-21 17:51:35 -08:00
|
|
|
import android.os.IIncidentManager;
|
2010-06-09 15:45:18 -05:00
|
|
|
import android.os.Looper;
|
2016-01-19 14:22:24 -08:00
|
|
|
import android.os.PowerManager;
|
Zygote: Explicitly preload secondary zygote resources.
We now turn on lazy preloading (see companion change 73c7df1bda76a0)
and explicitly preload zygote resources.
To provide the most benefit :
- We start the preload in the system_server, which means the system_server
starts quicker since it has one less preload to wait for. Morever, the
64 bit zygote also starts quicker because it has one less high
priority process to contend with for CPU and I/O.
- We start the preload after the core system services start up, since we
know no 32 bit zygote processes will be requested before that point.
- We start the preload ~1s before the webview factory preparation, to
ensure that it completes before the 32 bit relro process is forked
from the zygote. In the event that it takes too long, the webview
RELRO process will block, but it will do so without holding any locks.
I have not observed this happening in > 200 runs on marlin / sailfish
devices.
This change saves about 500ms in boot times, and sometimes even more.
AFTER:
successive-online : 16970.0,16668.0,16391.0,16498.0,17601.0,16736.0,16609.0,16820.0,16310.0,17557.0,
successive-online_avg : 16816.0
successive-boot : 28750.0,29520.0,29372.0,28424.0,30683.0,28523.0,29766.0,29779.0,29304.0,31607.0,
successive-boot_avg : 29572.8
BEFORE:
successive-online : 16678.0,18105.0,17197.0,16744.0,17453.0,16946.0,18068.0,16719.0,17453.0,16942.0,
successive-online_avg : 17230.5
successive-boot : 30855.0,32069.0,31223.0,30918.0,30284.0,29750.0,31036.0,30778.0,30310.0,30908.0,
successive-boot_avg : 30813.1
Note that successive-online is a little faster, as expected since we do
less work in the 32 bit zygote.
Test: manual, timings from tradefed.
Bug: 34810190
Change-Id: I90207a2706afda163b8134ff2af31f6917f3841b
2017-02-06 20:24:08 +00:00
|
|
|
import android.os.Process;
|
2010-06-09 15:45:18 -05:00
|
|
|
import android.os.RemoteException;
|
|
|
|
import android.os.ServiceManager;
|
2010-09-10 16:03:29 -07:00
|
|
|
import android.os.StrictMode;
|
2010-06-09 15:45:18 -05:00
|
|
|
import android.os.SystemClock;
|
|
|
|
import android.os.SystemProperties;
|
2015-06-30 17:07:32 +09:00
|
|
|
import android.os.Trace;
|
2012-10-19 18:23:52 -07:00
|
|
|
import android.os.UserHandle;
|
2016-11-07 15:41:02 -08:00
|
|
|
import android.os.storage.IStorageManager;
|
2016-11-17 11:44:49 -08:00
|
|
|
import android.util.BootTimingsTraceLog;
|
2010-10-04 15:27:22 -04:00
|
|
|
import android.util.DisplayMetrics;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.util.EventLog;
|
2010-02-26 18:56:32 -08:00
|
|
|
import android.util.Slog;
|
2010-10-12 13:12:18 -07:00
|
|
|
import android.view.WindowManager;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
import com.android.internal.R;
|
2016-06-21 18:24:24 -07:00
|
|
|
import com.android.internal.app.NightDisplayController;
|
2016-11-10 17:58:50 -08:00
|
|
|
import com.android.internal.logging.MetricsLogger;
|
2017-02-15 09:35:38 -05:00
|
|
|
import com.android.internal.notification.SystemNotificationChannels;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.internal.os.BinderInternal;
|
|
|
|
import com.android.internal.os.SamplingProfilerIntegration;
|
2017-03-21 20:33:59 -04:00
|
|
|
import com.android.internal.util.EmergencyAffordanceManager;
|
2017-01-27 11:30:19 -08:00
|
|
|
import com.android.internal.util.ConcurrentUtils;
|
2016-03-09 22:30:56 -07:00
|
|
|
import com.android.internal.widget.ILockSettings;
|
2014-03-17 12:54:03 -07:00
|
|
|
import com.android.server.accessibility.AccessibilityManagerService;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.am.ActivityManagerService;
|
2015-02-06 19:46:04 -05:00
|
|
|
import com.android.server.audio.AudioService;
|
2017-02-21 11:35:10 -08:00
|
|
|
import com.android.server.camera.CameraServiceProxy;
|
2013-11-06 14:54:50 -08:00
|
|
|
import com.android.server.clipboard.ClipboardService;
|
2016-09-09 09:23:47 +09:00
|
|
|
import com.android.server.connectivity.IpConnectivityMetrics;
|
2016-11-11 15:42:50 -08:00
|
|
|
import com.android.server.coverage.CoverageService;
|
2014-04-23 13:46:21 -07:00
|
|
|
import com.android.server.devicepolicy.DevicePolicyManagerService;
|
2012-07-23 19:26:30 -07:00
|
|
|
import com.android.server.display.DisplayManagerService;
|
2016-06-21 18:24:24 -07:00
|
|
|
import com.android.server.display.NightDisplayService;
|
2012-09-25 18:58:48 -07:00
|
|
|
import com.android.server.dreams.DreamManagerService;
|
2016-09-13 16:02:33 -07:00
|
|
|
import com.android.server.emergency.EmergencyAffordanceService;
|
2014-06-06 15:00:49 -07:00
|
|
|
import com.android.server.fingerprint.FingerprintService;
|
2014-04-23 17:57:26 +09:00
|
|
|
import com.android.server.hdmi.HdmiControlService;
|
2012-04-17 16:52:41 -07:00
|
|
|
import com.android.server.input.InputManagerService;
|
2014-06-09 19:50:00 -07:00
|
|
|
import com.android.server.job.JobSchedulerService;
|
2013-12-05 16:48:06 -08:00
|
|
|
import com.android.server.lights.LightsService;
|
2016-03-09 22:30:56 -07:00
|
|
|
import com.android.server.media.MediaResourceMonitorService;
|
2013-11-07 00:30:16 -08:00
|
|
|
import com.android.server.media.MediaRouterService;
|
2014-02-13 14:19:04 -08:00
|
|
|
import com.android.server.media.MediaSessionService;
|
2014-07-08 18:07:36 -07:00
|
|
|
import com.android.server.media.projection.MediaProjectionManagerService;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.net.NetworkPolicyManagerService;
|
2011-05-24 18:39:45 -07:00
|
|
|
import com.android.server.net.NetworkStatsService;
|
2013-12-05 16:48:06 -08:00
|
|
|
import com.android.server.notification.NotificationManagerService;
|
2016-06-02 09:35:31 +02:00
|
|
|
import com.android.server.om.OverlayManagerService;
|
2016-09-09 16:01:32 -07:00
|
|
|
import com.android.server.os.DeviceIdentifiersPolicyService;
|
2012-11-15 14:01:46 -08:00
|
|
|
import com.android.server.os.SchedulingPolicyService;
|
2017-03-15 18:38:57 -07:00
|
|
|
import com.android.server.pm.BackgroundDexOptService;
|
2012-09-12 17:00:34 -07:00
|
|
|
import com.android.server.pm.Installer;
|
2014-02-19 14:31:52 -08:00
|
|
|
import com.android.server.pm.LauncherAppsService;
|
2015-11-10 08:58:14 -08:00
|
|
|
import com.android.server.pm.OtaDexoptService;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.pm.PackageManagerService;
|
2016-03-04 13:39:41 -08:00
|
|
|
import com.android.server.pm.ShortcutService;
|
2012-08-10 17:06:33 -07:00
|
|
|
import com.android.server.pm.UserManagerService;
|
2016-07-18 12:05:30 -07:00
|
|
|
import com.android.server.policy.PhoneWindowManager;
|
2012-06-18 18:29:13 -07:00
|
|
|
import com.android.server.power.PowerManagerService;
|
|
|
|
import com.android.server.power.ShutdownThread;
|
2014-05-24 15:34:37 -07:00
|
|
|
import com.android.server.restrictions.RestrictionsManagerService;
|
2016-06-15 13:19:28 -07:00
|
|
|
import com.android.server.retaildemo.RetailDemoModeService;
|
2016-06-03 11:31:55 -07:00
|
|
|
import com.android.server.security.KeyAttestationApplicationIdProviderService;
|
2017-03-23 15:28:37 +00:00
|
|
|
import com.android.server.security.KeyChainSystemService;
|
2016-01-25 10:33:11 -08:00
|
|
|
import com.android.server.soundtrigger.SoundTriggerService;
|
2013-12-05 16:48:06 -08:00
|
|
|
import com.android.server.statusbar.StatusBarManagerService;
|
|
|
|
import com.android.server.storage.DeviceStorageMonitorService;
|
2014-11-21 15:20:15 -08:00
|
|
|
import com.android.server.telecom.TelecomLoaderService;
|
2016-12-14 15:38:56 +00:00
|
|
|
import com.android.server.text.TextClassificationService;
|
2014-03-27 14:56:59 +01:00
|
|
|
import com.android.server.trust.TrustManagerService;
|
2014-02-20 18:23:25 -08:00
|
|
|
import com.android.server.tv.TvInputManagerService;
|
2016-11-17 11:44:49 -08:00
|
|
|
import com.android.server.tv.TvRemoteService;
|
2013-12-05 16:48:06 -08:00
|
|
|
import com.android.server.twilight.TwilightService;
|
2014-07-16 19:09:13 -07:00
|
|
|
import com.android.server.usage.UsageStatsService;
|
2015-12-04 16:16:31 -08:00
|
|
|
import com.android.server.vr.VrManagerService;
|
2014-05-08 16:07:05 +01:00
|
|
|
import com.android.server.webkit.WebViewUpdateService;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.wm.WindowManagerService;
|
|
|
|
|
|
|
|
import dalvik.system.VMRuntime;
|
|
|
|
|
2016-01-19 14:22:24 -08:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2015-08-11 15:40:34 +01:00
|
|
|
import java.util.Locale;
|
2009-09-04 18:31:17 -07:00
|
|
|
import java.util.Timer;
|
|
|
|
import java.util.TimerTask;
|
2016-12-02 16:24:35 -08:00
|
|
|
import java.util.concurrent.CountDownLatch;
|
2017-01-27 11:30:19 -08:00
|
|
|
import java.util.concurrent.Future;
|
2009-09-04 18:31:17 -07:00
|
|
|
|
2016-10-21 11:55:23 -07:00
|
|
|
import static android.view.Display.DEFAULT_DISPLAY;
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
public final class SystemServer {
|
2009-03-03 19:31:44 -08:00
|
|
|
private static final String TAG = "SystemServer";
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2017-02-01 12:09:58 -08:00
|
|
|
// Tag for timing measurement of main thread.
|
|
|
|
private static final String SYSTEM_SERVER_TIMING_TAG = "SystemServerTiming";
|
|
|
|
// Tag for timing measurement of non-main asynchronous operations.
|
|
|
|
private static final String SYSTEM_SERVER_TIMING_ASYNC_TAG = SYSTEM_SERVER_TIMING_TAG + "Async";
|
|
|
|
|
2016-11-17 11:44:49 -08:00
|
|
|
private static final BootTimingsTraceLog BOOT_TIMINGS_TRACE_LOG
|
2017-02-01 12:09:58 -08:00
|
|
|
= new BootTimingsTraceLog(SYSTEM_SERVER_TIMING_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
|
2016-07-21 15:58:24 -07:00
|
|
|
|
2011-09-19 14:25:28 -07:00
|
|
|
private static final String ENCRYPTING_STATE = "trigger_restart_min_framework";
|
2011-09-23 15:08:24 -07:00
|
|
|
private static final String ENCRYPTED_STATE = "1";
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
private static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr
|
|
|
|
|
|
|
|
// The earliest supported time. We pick one day into 1970, to
|
|
|
|
// give any timezone code room without going into negative time.
|
|
|
|
private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-12-20 13:27:30 -08:00
|
|
|
/*
|
|
|
|
* Implementation class names. TODO: Move them to a codegen class or load
|
|
|
|
* them from the build system somehow.
|
|
|
|
*/
|
|
|
|
private static final String BACKUP_MANAGER_SERVICE_CLASS =
|
2014-02-10 19:47:07 -08:00
|
|
|
"com.android.server.backup.BackupManagerService$Lifecycle";
|
2013-12-20 13:27:30 -08:00
|
|
|
private static final String APPWIDGET_SERVICE_CLASS =
|
|
|
|
"com.android.server.appwidget.AppWidgetService";
|
2014-04-04 18:02:06 -07:00
|
|
|
private static final String VOICE_RECOGNITION_MANAGER_SERVICE_CLASS =
|
|
|
|
"com.android.server.voiceinteraction.VoiceInteractionManagerService";
|
2013-12-20 13:27:30 -08:00
|
|
|
private static final String PRINT_MANAGER_SERVICE_CLASS =
|
|
|
|
"com.android.server.print.PrintManagerService";
|
2017-01-22 13:52:51 -08:00
|
|
|
private static final String COMPANION_DEVICE_MANAGER_SERVICE_CLASS =
|
|
|
|
"com.android.server.print.CompanionDeviceManagerService";
|
2014-02-14 17:19:56 -08:00
|
|
|
private static final String USB_SERVICE_CLASS =
|
|
|
|
"com.android.server.usb.UsbService$Lifecycle";
|
2015-03-27 13:23:41 -07:00
|
|
|
private static final String MIDI_SERVICE_CLASS =
|
|
|
|
"com.android.server.midi.MidiService$Lifecycle";
|
2014-02-19 12:29:58 -08:00
|
|
|
private static final String WIFI_SERVICE_CLASS =
|
|
|
|
"com.android.server.wifi.WifiService";
|
2016-10-26 11:22:06 -07:00
|
|
|
private static final String WIFI_AWARE_SERVICE_CLASS =
|
|
|
|
"com.android.server.wifi.aware.WifiAwareService";
|
2014-02-19 12:29:58 -08:00
|
|
|
private static final String WIFI_P2P_SERVICE_CLASS =
|
|
|
|
"com.android.server.wifi.p2p.WifiP2pService";
|
2014-05-21 16:32:11 -07:00
|
|
|
private static final String ETHERNET_SERVICE_CLASS =
|
|
|
|
"com.android.server.ethernet.EthernetService";
|
2014-06-09 19:50:00 -07:00
|
|
|
private static final String JOB_SCHEDULER_SERVICE_CLASS =
|
|
|
|
"com.android.server.job.JobSchedulerService";
|
2016-01-27 19:05:43 -08:00
|
|
|
private static final String LOCK_SETTINGS_SERVICE_CLASS =
|
|
|
|
"com.android.server.LockSettingsService$Lifecycle";
|
2016-11-07 15:41:02 -08:00
|
|
|
private static final String STORAGE_MANAGER_SERVICE_CLASS =
|
|
|
|
"com.android.server.StorageManagerService$Lifecycle";
|
2017-01-04 11:33:33 -07:00
|
|
|
private static final String STORAGE_STATS_SERVICE_CLASS =
|
|
|
|
"com.android.server.usage.StorageStatsService$Lifecycle";
|
2016-01-09 14:57:45 -07:00
|
|
|
private static final String SEARCH_MANAGER_SERVICE_CLASS =
|
|
|
|
"com.android.server.search.SearchManagerService$Lifecycle";
|
2016-03-25 16:32:10 -07:00
|
|
|
private static final String THERMAL_OBSERVER_CLASS =
|
|
|
|
"com.google.android.clockwork.ThermalObserver";
|
2017-02-21 16:41:43 -08:00
|
|
|
private static final String WEAR_CONNECTIVITY_SERVICE_CLASS =
|
|
|
|
"com.google.android.clockwork.connectivity.WearConnectivityService";
|
2016-04-07 14:01:03 -07:00
|
|
|
private static final String WEAR_TIME_SERVICE_CLASS =
|
|
|
|
"com.google.android.clockwork.time.WearTimeService";
|
2016-04-12 18:23:31 -06:00
|
|
|
private static final String ACCOUNT_SERVICE_CLASS =
|
|
|
|
"com.android.server.accounts.AccountManagerService$Lifecycle";
|
2016-04-04 08:58:04 -06:00
|
|
|
private static final String CONTENT_SERVICE_CLASS =
|
|
|
|
"com.android.server.content.ContentService$Lifecycle";
|
2016-04-12 18:23:31 -06:00
|
|
|
private static final String WALLPAPER_SERVICE_CLASS =
|
|
|
|
"com.android.server.wallpaper.WallpaperManagerService$Lifecycle";
|
2016-10-13 09:02:32 -07:00
|
|
|
private static final String AUTO_FILL_MANAGER_SERVICE_CLASS =
|
2017-03-13 00:21:04 -07:00
|
|
|
"com.android.server.autofill.AutofillManagerService";
|
2016-01-09 14:57:45 -07:00
|
|
|
|
2014-07-01 19:40:41 -07:00
|
|
|
private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
|
2013-12-20 13:27:30 -08:00
|
|
|
|
2016-01-19 14:22:24 -08:00
|
|
|
private static final String UNCRYPT_PACKAGE_FILE = "/cache/recovery/uncrypt_file";
|
|
|
|
private static final String BLOCK_MAP_FILE = "/cache/recovery/block.map";
|
|
|
|
|
2016-04-19 14:14:20 -07:00
|
|
|
// maximum number of binder threads used for system_server
|
|
|
|
// will be higher than the system default
|
|
|
|
private static final int sMaxBinderThreads = 31;
|
|
|
|
|
2015-12-16 15:28:23 -05:00
|
|
|
/**
|
|
|
|
* Default theme used by the system context. This is used to style
|
|
|
|
* system-provided dialogs, such as the Power Off dialog, and other
|
|
|
|
* visual content.
|
|
|
|
*/
|
|
|
|
private static final int DEFAULT_SYSTEM_THEME =
|
2016-06-13 12:48:55 -07:00
|
|
|
com.android.internal.R.style.Theme_DeviceDefault_System;
|
2015-12-16 15:28:23 -05:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
private final int mFactoryTestMode;
|
|
|
|
private Timer mProfilerSnapshotTimer;
|
|
|
|
|
|
|
|
private Context mSystemContext;
|
|
|
|
private SystemServiceManager mSystemServiceManager;
|
|
|
|
|
2014-01-16 22:16:42 -08:00
|
|
|
// TODO: remove all of these references by improving dependency resolution and boot phases
|
|
|
|
private PowerManagerService mPowerManagerService;
|
|
|
|
private ActivityManagerService mActivityManagerService;
|
2015-10-30 19:25:37 +00:00
|
|
|
private WebViewUpdateService mWebViewUpdateService;
|
2014-01-16 22:16:42 -08:00
|
|
|
private DisplayManagerService mDisplayManagerService;
|
2014-06-12 22:38:59 -07:00
|
|
|
private PackageManagerService mPackageManagerService;
|
|
|
|
private PackageManager mPackageManager;
|
2014-01-15 20:40:55 -08:00
|
|
|
private ContentResolver mContentResolver;
|
2016-04-12 18:23:31 -06:00
|
|
|
private EntropyMixer mEntropyMixer;
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
private boolean mOnlyCore;
|
|
|
|
private boolean mFirstBoot;
|
2017-01-06 18:27:05 -08:00
|
|
|
private final boolean mRuntimeRestart;
|
2014-06-12 22:38:59 -07:00
|
|
|
|
2017-02-01 12:09:58 -08:00
|
|
|
private static final String START_SENSOR_SERVICE = "StartSensorService";
|
2017-03-10 13:41:11 -08:00
|
|
|
private static final String START_HIDL_SERVICES = "StartHidlServices";
|
|
|
|
|
|
|
|
|
2017-02-01 12:09:58 -08:00
|
|
|
private Future<?> mSensorServiceStart;
|
Zygote: Explicitly preload secondary zygote resources.
We now turn on lazy preloading (see companion change 73c7df1bda76a0)
and explicitly preload zygote resources.
To provide the most benefit :
- We start the preload in the system_server, which means the system_server
starts quicker since it has one less preload to wait for. Morever, the
64 bit zygote also starts quicker because it has one less high
priority process to contend with for CPU and I/O.
- We start the preload after the core system services start up, since we
know no 32 bit zygote processes will be requested before that point.
- We start the preload ~1s before the webview factory preparation, to
ensure that it completes before the 32 bit relro process is forked
from the zygote. In the event that it takes too long, the webview
RELRO process will block, but it will do so without holding any locks.
I have not observed this happening in > 200 runs on marlin / sailfish
devices.
This change saves about 500ms in boot times, and sometimes even more.
AFTER:
successive-online : 16970.0,16668.0,16391.0,16498.0,17601.0,16736.0,16609.0,16820.0,16310.0,17557.0,
successive-online_avg : 16816.0
successive-boot : 28750.0,29520.0,29372.0,28424.0,30683.0,28523.0,29766.0,29779.0,29304.0,31607.0,
successive-boot_avg : 29572.8
BEFORE:
successive-online : 16678.0,18105.0,17197.0,16744.0,17453.0,16946.0,18068.0,16719.0,17453.0,16942.0,
successive-online_avg : 17230.5
successive-boot : 30855.0,32069.0,31223.0,30918.0,30284.0,29750.0,31036.0,30778.0,30310.0,30908.0,
successive-boot_avg : 30813.1
Note that successive-online is a little faster, as expected since we do
less work in the 32 bit zygote.
Test: manual, timings from tradefed.
Bug: 34810190
Change-Id: I90207a2706afda163b8134ff2af31f6917f3841b
2017-02-06 20:24:08 +00:00
|
|
|
private Future<?> mZygotePreload;
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
/**
|
2017-02-01 12:09:58 -08:00
|
|
|
* Start the sensor service. This is a blocking call and can take time.
|
2014-01-15 20:40:55 -08:00
|
|
|
*/
|
2015-04-30 10:38:13 -07:00
|
|
|
private static native void startSensorService();
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2017-03-10 13:41:11 -08:00
|
|
|
/**
|
|
|
|
* Start all HIDL services that are run inside the system server. This
|
|
|
|
* may take some time.
|
|
|
|
*/
|
|
|
|
private static native void startHidlServices();
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
/**
|
|
|
|
* The main entry point from zygote.
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
|
|
|
new SystemServer().run();
|
2011-08-22 00:26:20 -07:00
|
|
|
}
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
public SystemServer() {
|
2014-06-12 22:38:59 -07:00
|
|
|
// Check for factory test mode.
|
2014-01-15 20:40:55 -08:00
|
|
|
mFactoryTestMode = FactoryTest.getMode();
|
2017-01-06 18:27:05 -08:00
|
|
|
// Remember if it's runtime restart(when sys.boot_completed is already set) or reboot
|
|
|
|
mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed"));
|
2014-01-15 20:40:55 -08:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
private void run() {
|
2015-06-30 17:07:32 +09:00
|
|
|
try {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("InitBeforeStartServices");
|
2015-06-30 17:07:32 +09:00
|
|
|
// If a device's clock is before 1970 (before 0), a lot of
|
|
|
|
// APIs crash dealing with negative numbers, notably
|
|
|
|
// java.io.File#setLastModified, so instead we fake it and
|
|
|
|
// hope that time from cell towers or NTP fixes it shortly.
|
|
|
|
if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
|
|
|
|
Slog.w(TAG, "System clock is before 1970; setting to 1970.");
|
|
|
|
SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2017-03-22 15:13:17 +00:00
|
|
|
//
|
|
|
|
// Default the timezone property to GMT if not set.
|
|
|
|
//
|
|
|
|
String timezoneProperty = SystemProperties.get("persist.sys.timezone");
|
|
|
|
if (timezoneProperty == null || timezoneProperty.isEmpty()) {
|
|
|
|
Slog.w(TAG, "Timezone not set; setting to GMT.");
|
|
|
|
SystemProperties.set("persist.sys.timezone", "GMT");
|
|
|
|
}
|
|
|
|
|
2015-09-02 22:48:13 +09:00
|
|
|
// If the system has "persist.sys.language" and friends set, replace them with
|
|
|
|
// "persist.sys.locale". Note that the default locale at this point is calculated
|
|
|
|
// using the "-Duser.locale" command line flag. That flag is usually populated by
|
|
|
|
// AndroidRuntime using the same set of system properties, but only the system_server
|
|
|
|
// and system apps are allowed to set them.
|
|
|
|
//
|
|
|
|
// NOTE: Most changes made here will need an equivalent change to
|
|
|
|
// core/jni/AndroidRuntime.cpp
|
|
|
|
if (!SystemProperties.get("persist.sys.language").isEmpty()) {
|
|
|
|
final String languageTag = Locale.getDefault().toLanguageTag();
|
|
|
|
|
|
|
|
SystemProperties.set("persist.sys.locale", languageTag);
|
|
|
|
SystemProperties.set("persist.sys.language", "");
|
|
|
|
SystemProperties.set("persist.sys.country", "");
|
|
|
|
SystemProperties.set("persist.sys.localevar", "");
|
|
|
|
}
|
2015-08-11 15:40:34 +01:00
|
|
|
|
2016-11-04 11:23:46 -06:00
|
|
|
// The system server should never make non-oneway calls
|
|
|
|
Binder.setWarnOnBlocking(true);
|
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Here we go!
|
|
|
|
Slog.i(TAG, "Entered the Android system server!");
|
2017-01-06 18:27:05 -08:00
|
|
|
int uptimeMillis = (int) SystemClock.elapsedRealtime();
|
2016-11-10 17:58:50 -08:00
|
|
|
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, uptimeMillis);
|
2017-01-20 18:12:35 -08:00
|
|
|
if (!mRuntimeRestart) {
|
2017-01-06 18:27:05 -08:00
|
|
|
MetricsLogger.histogram(null, "boot_system_server_init", uptimeMillis);
|
2016-11-17 11:44:49 -08:00
|
|
|
}
|
2015-06-30 17:07:32 +09:00
|
|
|
|
|
|
|
// In case the runtime switched since last boot (such as when
|
|
|
|
// the old runtime was removed in an OTA), set the system
|
2017-03-14 10:26:10 -07:00
|
|
|
// property so that it is in sync. We can | xq oqi't do this in
|
2015-06-30 17:07:32 +09:00
|
|
|
// libnativehelper's JniInvocation::Init code where we already
|
|
|
|
// had to fallback to a different runtime because it is
|
|
|
|
// running as root and we need to be the system user to set
|
|
|
|
// the property. http://b/11463182
|
|
|
|
SystemProperties.set("persist.sys.dalvik.vm.lib.2", VMRuntime.getRuntime().vmLibrary());
|
|
|
|
|
|
|
|
// Enable the sampling profiler.
|
|
|
|
if (SamplingProfilerIntegration.isEnabled()) {
|
|
|
|
SamplingProfilerIntegration.start();
|
|
|
|
mProfilerSnapshotTimer = new Timer();
|
|
|
|
mProfilerSnapshotTimer.schedule(new TimerTask() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
SamplingProfilerIntegration.writeSnapshot("system_server", null);
|
|
|
|
}
|
|
|
|
}, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Mmmmmm... more memory!
|
|
|
|
VMRuntime.getRuntime().clearGrowthLimit();
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// The system server has to run all of the time, so it needs to be
|
|
|
|
// as efficient as possible with its memory usage.
|
|
|
|
VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Some devices rely on runtime fingerprint generation, so make sure
|
|
|
|
// we've defined it before booting further.
|
|
|
|
Build.ensureFingerprintProperty();
|
2014-04-09 18:07:19 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Within the system server, it is an error to access Environment paths without
|
|
|
|
// explicitly specifying a user.
|
|
|
|
Environment.setUserRequired(true);
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2016-03-09 22:30:56 -07:00
|
|
|
// Within the system server, any incoming Bundles should be defused
|
|
|
|
// to avoid throwing BadParcelableException.
|
|
|
|
BaseBundle.setShouldDefuse(true);
|
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Ensure binder calls into the system always run at foreground priority.
|
|
|
|
BinderInternal.disableBackgroundScheduling(true);
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2016-04-19 14:14:20 -07:00
|
|
|
// Increase the number of binder threads in system_server
|
|
|
|
BinderInternal.setMaxThreads(sMaxBinderThreads);
|
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Prepare the main looper thread (this thread).
|
|
|
|
android.os.Process.setThreadPriority(
|
2014-01-15 20:40:55 -08:00
|
|
|
android.os.Process.THREAD_PRIORITY_FOREGROUND);
|
2015-06-30 17:07:32 +09:00
|
|
|
android.os.Process.setCanSelfBackground(false);
|
|
|
|
Looper.prepareMainLooper();
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Initialize native services.
|
|
|
|
System.loadLibrary("android_servers");
|
2010-05-28 01:54:03 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Check whether we failed to shut down last time we tried.
|
|
|
|
// This call may not return.
|
|
|
|
performPendingShutdown();
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Initialize the system context.
|
|
|
|
createSystemContext();
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
// Create the system service manager.
|
|
|
|
mSystemServiceManager = new SystemServiceManager(mSystemContext);
|
2017-01-10 18:34:10 -08:00
|
|
|
mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart);
|
2015-06-30 17:07:32 +09:00
|
|
|
LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
|
2016-12-16 16:14:17 -08:00
|
|
|
// Prepare the thread pool for init tasks that can be parallelized
|
|
|
|
SystemServerInitThreadPool.get();
|
2015-06-30 17:07:32 +09:00
|
|
|
} finally {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd(); // InitBeforeStartServices
|
2015-06-30 17:07:32 +09:00
|
|
|
}
|
2014-01-15 20:40:55 -08:00
|
|
|
|
|
|
|
// Start services.
|
|
|
|
try {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartServices");
|
2014-01-15 20:40:55 -08:00
|
|
|
startBootstrapServices();
|
2014-01-16 22:16:42 -08:00
|
|
|
startCoreServices();
|
2014-01-15 20:40:55 -08:00
|
|
|
startOtherServices();
|
Reconcile apps in 2 phases
During boot app data folders are reconciled in 2 phases:
- in the constructor only core apps are reconciled. prepareAppData
for remaining apps is deferred and run on a separate thread (phase 2)
- Phase 2 must finish before third-party apps can start
Also moved GC to final stages of system server init. GC alone takes ~200 ms.
Overall boot time improvement: ~1 second
Before:
02-17 18:33:33 D/BaseBootTest: successive-boot :
28835.0,29638.0,30205.0,29793.0,29752.0,28228.0,30125.0,28983.0,28487.0,28865.0,
02-17 18:33:33 D/BaseBootTest: successive-boot_avg : 29291.1
02-17 18:33:33 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService :
3150.0,3615.0,3515.0,3495.0,3814.0,3158.0,3746.0,3274.0,3222.0,3607.0,
02-17 18:33:33 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService_avg : 3459.6
02-17 18:33:33 D/BaseBootTest: SystemServerTiming_StartServices :
8244.0,8863.0,9035.0,9832.0,8998.0,8096.0,8719.0,8209.0,8279.0,8754.0,
02-17 18:33:33 D/BaseBootTest: SystemServerTiming_StartServices_avg :
8702.9
After:
02-17 17:59:51 D/BaseBootTest: successive-boot :
27711.0,27607.0,28408.0,28968.0,28397.0,28063.0,27885.0,28483.0,27917.0,29317.0,
02-17 17:59:51 D/BaseBootTest: successive-boot_avg : 28275.6
02-17 17:59:51 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService :
2467.0,2489.0,2369.0,2548.0,2647.0,2523.0,2497.0,2553.0,2482.0,2657.0,
02-17 17:59:51 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService_avg : 2523.2
02-17 17:59:51 D/BaseBootTest: SystemServerTiming_StartServices :
7686.0,7538.0,7598.0,7869.0,7884.0,7950.0,7971.0,8370.0,7696.0,7885.0,
02-17 17:59:51 D/BaseBootTest: SystemServerTiming_StartServices_avg :
7844.7
Test: manual
Bug: 28750609
Change-Id: I3543ef577af1365394775318e40907584ddbe950
2017-02-07 11:25:14 -08:00
|
|
|
SystemServerInitThreadPool.shutdown();
|
2014-06-12 22:38:59 -07:00
|
|
|
} catch (Throwable ex) {
|
2014-01-15 20:40:55 -08:00
|
|
|
Slog.e("System", "******************************************");
|
|
|
|
Slog.e("System", "************ Failure starting system services", ex);
|
|
|
|
throw ex;
|
2015-06-30 17:07:32 +09:00
|
|
|
} finally {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-01-15 20:40:55 -08:00
|
|
|
}
|
2010-09-22 10:36:48 -07:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// For debug builds, log event loop stalls to dropbox for analysis.
|
|
|
|
if (StrictMode.conditionallyEnableDebugLogging()) {
|
|
|
|
Slog.i(TAG, "Enabled StrictMode for system server main thread.");
|
|
|
|
}
|
2017-01-20 18:12:35 -08:00
|
|
|
if (!mRuntimeRestart && !isFirstBootOrUpgrade()) {
|
2017-01-17 12:20:36 -08:00
|
|
|
int uptimeMillis = (int) SystemClock.elapsedRealtime();
|
|
|
|
MetricsLogger.histogram(null, "boot_system_server_ready", uptimeMillis);
|
|
|
|
final int MAX_UPTIME_MILLIS = 60 * 1000;
|
|
|
|
if (uptimeMillis > MAX_UPTIME_MILLIS) {
|
2017-02-01 12:09:58 -08:00
|
|
|
Slog.wtf(SYSTEM_SERVER_TIMING_TAG,
|
2017-01-17 12:20:36 -08:00
|
|
|
"SystemServer init took too long. uptimeMillis=" + uptimeMillis);
|
|
|
|
}
|
2017-01-06 18:27:05 -08:00
|
|
|
}
|
2014-01-15 20:40:55 -08:00
|
|
|
|
|
|
|
// Loop forever.
|
|
|
|
Looper.loop();
|
|
|
|
throw new RuntimeException("Main thread loop unexpectedly exited");
|
|
|
|
}
|
|
|
|
|
2017-01-20 18:12:35 -08:00
|
|
|
private boolean isFirstBootOrUpgrade() {
|
|
|
|
return mPackageManagerService.isFirstBoot() || mPackageManagerService.isUpgrade();
|
|
|
|
}
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
private void reportWtf(String msg, Throwable e) {
|
|
|
|
Slog.w(TAG, "***********************************************");
|
2014-10-01 14:59:58 -07:00
|
|
|
Slog.wtf(TAG, "BOOT FAILURE " + msg, e);
|
2014-01-15 20:40:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void performPendingShutdown() {
|
|
|
|
final String shutdownAction = SystemProperties.get(
|
|
|
|
ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
|
|
|
|
if (shutdownAction != null && shutdownAction.length() > 0) {
|
|
|
|
boolean reboot = (shutdownAction.charAt(0) == '1');
|
|
|
|
|
|
|
|
final String reason;
|
|
|
|
if (shutdownAction.length() > 1) {
|
|
|
|
reason = shutdownAction.substring(1, shutdownAction.length());
|
|
|
|
} else {
|
|
|
|
reason = null;
|
2010-09-22 10:36:48 -07:00
|
|
|
}
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2016-01-19 14:22:24 -08:00
|
|
|
// If it's a pending reboot into recovery to apply an update,
|
|
|
|
// always make sure uncrypt gets executed properly when needed.
|
|
|
|
// If '/cache/recovery/block.map' hasn't been created, stop the
|
|
|
|
// reboot which will fail for sure, and get a chance to capture a
|
2015-12-31 07:44:55 -08:00
|
|
|
// bugreport when that's still feasible. (Bug: 26444951)
|
|
|
|
if (PowerManager.REBOOT_RECOVERY_UPDATE.equals(reason)) {
|
2016-01-19 14:22:24 -08:00
|
|
|
File packageFile = new File(UNCRYPT_PACKAGE_FILE);
|
|
|
|
if (packageFile.exists()) {
|
|
|
|
String filename = null;
|
|
|
|
try {
|
|
|
|
filename = FileUtils.readTextFile(packageFile, 0, null);
|
|
|
|
} catch (IOException e) {
|
|
|
|
Slog.e(TAG, "Error reading uncrypt package file", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filename != null && filename.startsWith("/data")) {
|
|
|
|
if (!new File(BLOCK_MAP_FILE).exists()) {
|
|
|
|
Slog.e(TAG, "Can't find block map file, uncrypt failed or " +
|
|
|
|
"unexpected runtime restart?");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-19 01:11:55 +08:00
|
|
|
ShutdownThread.rebootOrShutdown(null, reboot, reason);
|
2010-09-22 10:36:48 -07:00
|
|
|
}
|
2014-01-15 20:40:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void createSystemContext() {
|
|
|
|
ActivityThread activityThread = ActivityThread.systemMain();
|
|
|
|
mSystemContext = activityThread.getSystemContext();
|
2015-12-16 15:28:23 -05:00
|
|
|
mSystemContext.setTheme(DEFAULT_SYSTEM_THEME);
|
2017-03-21 16:56:17 -07:00
|
|
|
|
|
|
|
final Context systemUiContext = activityThread.getSystemUiContext();
|
|
|
|
systemUiContext.setTheme(DEFAULT_SYSTEM_THEME);
|
2014-01-15 20:40:55 -08:00
|
|
|
}
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
/**
|
|
|
|
* Starts the small tangle of critical services that are needed to get
|
|
|
|
* the system off the ground. These services have complex mutual dependencies
|
|
|
|
* which is why we initialize them all in one place here. Unless your service
|
|
|
|
* is also entwined in these dependencies, it should be initialized in one of
|
|
|
|
* the other functions.
|
|
|
|
*/
|
2014-01-15 20:40:55 -08:00
|
|
|
private void startBootstrapServices() {
|
2017-01-30 13:28:25 -08:00
|
|
|
Slog.i(TAG, "Reading configuration...");
|
|
|
|
final String TAG_SYSTEM_CONFIG = "ReadingSystemConfig";
|
|
|
|
traceBeginAndSlog(TAG_SYSTEM_CONFIG);
|
|
|
|
SystemServerInitThreadPool.get().submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG);
|
|
|
|
traceEnd();
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// Wait for installd to finish starting up so that it has a chance to
|
|
|
|
// create critical directories such as /data/user with the appropriate
|
|
|
|
// permissions. We need this to complete before we initialize other services.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartInstaller");
|
2014-11-10 14:23:41 +00:00
|
|
|
Installer installer = mSystemServiceManager.startService(Installer.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-09-22 10:36:48 -07:00
|
|
|
|
2016-09-09 16:01:32 -07:00
|
|
|
// In some cases after launching an app we need to access device identifiers,
|
|
|
|
// therefore register the device identifier policy before the activity manager.
|
|
|
|
traceBeginAndSlog("DeviceIdentifiersPolicyService");
|
|
|
|
mSystemServiceManager.startService(DeviceIdentifiersPolicyService.class);
|
|
|
|
traceEnd();
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// Activity manager runs the show.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartActivityManager");
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService = mSystemServiceManager.startService(
|
|
|
|
ActivityManagerService.Lifecycle.class).getService();
|
2014-04-04 18:02:06 -07:00
|
|
|
mActivityManagerService.setSystemServiceManager(mSystemServiceManager);
|
2014-11-10 14:23:41 +00:00
|
|
|
mActivityManagerService.setInstaller(installer);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
// Power manager needs to be started early because other services need it.
|
|
|
|
// Native daemons may be watching for it to be registered so it must be ready
|
|
|
|
// to handle incoming binder calls immediately (including being able to verify
|
|
|
|
// the permissions for those calls).
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartPowerManager");
|
2014-06-12 22:38:59 -07:00
|
|
|
mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-06-12 22:38:59 -07:00
|
|
|
|
|
|
|
// Now that the power manager has been started, let the activity manager
|
|
|
|
// initialize power management features.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("InitPowerManagement");
|
2014-06-12 22:38:59 -07:00
|
|
|
mActivityManagerService.initPowerManagement();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-06-12 22:38:59 -07:00
|
|
|
|
2017-01-20 10:42:57 -07:00
|
|
|
// Bring up recovery system in case a rescue party needs a reboot
|
|
|
|
if (!SystemProperties.getBoolean("config.disable_noncore", false)) {
|
|
|
|
traceBeginAndSlog("StartRecoverySystemService");
|
|
|
|
mSystemServiceManager.startService(RecoverySystemService.class);
|
|
|
|
traceEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that we have the bare essentials of the OS up and running, take
|
|
|
|
// note that we just booted, which might send out a rescue party if
|
|
|
|
// we're stuck in a runtime restart loop.
|
|
|
|
RescueParty.noteBoot(mSystemContext);
|
|
|
|
|
2015-04-10 20:15:01 -07:00
|
|
|
// Manages LEDs and display backlight so we need it to bring up the display.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartLightsService");
|
2015-04-10 20:15:01 -07:00
|
|
|
mSystemServiceManager.startService(LightsService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-04-10 20:15:01 -07:00
|
|
|
|
2014-01-16 22:16:42 -08:00
|
|
|
// Display manager is needed to provide display metrics before package manager
|
|
|
|
// starts up.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDisplayManager");
|
2014-01-16 22:16:42 -08:00
|
|
|
mDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-06-12 22:38:59 -07:00
|
|
|
|
|
|
|
// We need the default display before we can initialize the package manager.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("WaitForDisplay");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-06-12 22:38:59 -07:00
|
|
|
|
|
|
|
// Only run "core" apps if we're encrypting the device.
|
|
|
|
String cryptState = SystemProperties.get("vold.decrypt");
|
|
|
|
if (ENCRYPTING_STATE.equals(cryptState)) {
|
|
|
|
Slog.w(TAG, "Detected encryption in progress - only parsing core apps");
|
|
|
|
mOnlyCore = true;
|
|
|
|
} else if (ENCRYPTED_STATE.equals(cryptState)) {
|
|
|
|
Slog.w(TAG, "Device encrypted - only parsing core apps");
|
|
|
|
mOnlyCore = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start the package manager.
|
2017-01-06 18:27:05 -08:00
|
|
|
if (!mRuntimeRestart) {
|
|
|
|
MetricsLogger.histogram(null, "boot_package_manager_init_start",
|
|
|
|
(int) SystemClock.elapsedRealtime());
|
|
|
|
}
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartPackageManagerService");
|
2014-11-10 14:23:41 +00:00
|
|
|
mPackageManagerService = PackageManagerService.main(mSystemContext, installer,
|
2014-06-12 22:38:59 -07:00
|
|
|
mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF, mOnlyCore);
|
|
|
|
mFirstBoot = mPackageManagerService.isFirstBoot();
|
|
|
|
mPackageManager = mSystemContext.getPackageManager();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2017-01-20 18:12:35 -08:00
|
|
|
if (!mRuntimeRestart && !isFirstBootOrUpgrade()) {
|
2017-01-06 18:27:05 -08:00
|
|
|
MetricsLogger.histogram(null, "boot_package_manager_init_ready",
|
|
|
|
(int) SystemClock.elapsedRealtime());
|
|
|
|
}
|
2016-02-26 11:25:36 -08:00
|
|
|
// Manages A/B OTA dexopting. This is a bootstrap service as we need it to rename
|
|
|
|
// A/B artifacts after boot, before anything else might touch/need them.
|
|
|
|
// Note: this isn't needed during decryption (we don't have /data anyways).
|
|
|
|
if (!mOnlyCore) {
|
|
|
|
boolean disableOtaDexopt = SystemProperties.getBoolean("config.disable_otadexopt",
|
|
|
|
false);
|
|
|
|
if (!disableOtaDexopt) {
|
|
|
|
traceBeginAndSlog("StartOtaDexOptService");
|
|
|
|
try {
|
|
|
|
OtaDexoptService.main(mSystemContext, mPackageManagerService);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting OtaDexOptService", e);
|
|
|
|
} finally {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-02-26 11:25:36 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartUserManagerService");
|
2016-06-13 12:09:36 -07:00
|
|
|
mSystemServiceManager.startService(UserManagerService.LifeCycle.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-23 17:34:34 -07:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
// Initialize attribute cache used to cache resources from packages.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("InitAttributerCache");
|
2014-06-12 22:38:59 -07:00
|
|
|
AttributeCache.init(mSystemContext);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-06-12 22:38:59 -07:00
|
|
|
|
|
|
|
// Set up the Application instance for the system process and get started.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("SetSystemProcess");
|
2014-06-12 22:38:59 -07:00
|
|
|
mActivityManagerService.setSystemProcess();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-04-30 10:38:13 -07:00
|
|
|
|
2017-04-04 16:32:15 -07:00
|
|
|
// DisplayManagerService needs to setup android.display scheduling related policies
|
|
|
|
// since setSystemProcess() would have overridden policies due to setProcessGroup
|
|
|
|
mDisplayManagerService.setupSchedulerPolicies();
|
|
|
|
|
2016-06-02 09:35:31 +02:00
|
|
|
// Manages Overlay packages
|
|
|
|
traceBeginAndSlog("StartOverlayManagerService");
|
|
|
|
mSystemServiceManager.startService(new OverlayManagerService(mSystemContext, installer));
|
|
|
|
traceEnd();
|
|
|
|
|
2015-04-30 10:38:13 -07:00
|
|
|
// The sensor service needs access to package manager service, app ops
|
|
|
|
// service, and permissions service, therefore we start it after them.
|
2017-02-01 12:09:58 -08:00
|
|
|
// Start sensor service in a separate thread. Completion should be checked
|
|
|
|
// before using it.
|
|
|
|
mSensorServiceStart = SystemServerInitThreadPool.get().submit(() -> {
|
|
|
|
BootTimingsTraceLog traceLog = new BootTimingsTraceLog(
|
|
|
|
SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
|
|
|
|
traceLog.traceBegin(START_SENSOR_SERVICE);
|
|
|
|
startSensorService();
|
|
|
|
traceLog.traceEnd();
|
|
|
|
}, START_SENSOR_SERVICE);
|
2014-01-16 22:16:42 -08:00
|
|
|
}
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
/**
|
|
|
|
* Starts some essential services that are not tangled up in the bootstrap process.
|
|
|
|
*/
|
|
|
|
private void startCoreServices() {
|
2016-08-23 13:39:07 -06:00
|
|
|
// Records errors and logs, for example wtf()
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDropBoxManager");
|
2016-08-23 13:39:07 -06:00
|
|
|
mSystemServiceManager.startService(DropBoxManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-08-23 13:39:07 -06:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartBatteryService");
|
2014-06-13 19:00:36 -07:00
|
|
|
// Tracks the battery level. Requires LightService.
|
|
|
|
mSystemServiceManager.startService(BatteryService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-16 19:09:13 -07:00
|
|
|
|
|
|
|
// Tracks application usage stats.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartUsageService");
|
2014-07-16 19:09:13 -07:00
|
|
|
mSystemServiceManager.startService(UsageStatsService.class);
|
|
|
|
mActivityManagerService.setUsageStatsManager(
|
|
|
|
LocalServices.getService(UsageStatsManagerInternal.class));
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-29 19:14:24 +01:00
|
|
|
|
|
|
|
// Tracks whether the updatable WebView is in a ready state and watches for update installs.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartWebViewUpdateService");
|
2015-10-30 19:25:37 +00:00
|
|
|
mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-06-12 22:38:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts a miscellaneous grab bag of stuff that has yet to be refactored
|
|
|
|
* and organized.
|
|
|
|
*/
|
2014-01-16 22:16:42 -08:00
|
|
|
private void startOtherServices() {
|
2014-01-15 20:40:55 -08:00
|
|
|
final Context context = mSystemContext;
|
2012-04-13 20:38:38 -07:00
|
|
|
VibratorService vibrator = null;
|
2016-11-07 15:41:02 -08:00
|
|
|
IStorageManager storageManager = null;
|
2011-05-19 17:12:49 -07:00
|
|
|
NetworkManagementService networkManagement = null;
|
2017-03-01 18:55:06 -08:00
|
|
|
IpSecService ipSecService = null;
|
2011-05-24 18:39:45 -07:00
|
|
|
NetworkStatsService networkStats = null;
|
2011-05-20 15:29:23 -07:00
|
|
|
NetworkPolicyManagerService networkPolicy = null;
|
2009-08-14 14:18:49 -04:00
|
|
|
ConnectivityService connectivity = null;
|
2014-04-16 17:29:40 -07:00
|
|
|
NetworkScoreService networkScore = null;
|
2012-03-22 17:01:39 -07:00
|
|
|
NsdService serviceDiscovery= null;
|
2009-03-03 19:31:44 -08:00
|
|
|
WindowManagerService wm = null;
|
2011-08-29 20:11:07 -04:00
|
|
|
SerialService serial = null;
|
2010-09-13 16:24:08 -07:00
|
|
|
NetworkTimeUpdateService networkTimeUpdater = null;
|
2012-02-01 15:23:33 -08:00
|
|
|
CommonTimeManagementService commonTimeMgmtService = null;
|
2012-04-17 16:52:41 -07:00
|
|
|
InputManagerService inputManager = null;
|
2012-09-20 10:09:45 -07:00
|
|
|
TelephonyRegistry telephonyRegistry = null;
|
2013-06-26 11:06:51 -07:00
|
|
|
ConsumerIrService consumerIr = null;
|
2014-07-24 12:56:45 -07:00
|
|
|
MmsServiceBroker mmsService = null;
|
2016-02-12 20:38:23 +01:00
|
|
|
HardwarePropertiesManagerService hardwarePropertiesService = null;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false);
|
|
|
|
boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false);
|
|
|
|
boolean disableLocation = SystemProperties.getBoolean("config.disable_location", false);
|
|
|
|
boolean disableSystemUI = SystemProperties.getBoolean("config.disable_systemui", false);
|
|
|
|
boolean disableNonCoreServices = SystemProperties.getBoolean("config.disable_noncore", false);
|
|
|
|
boolean disableNetwork = SystemProperties.getBoolean("config.disable_network", false);
|
2014-10-16 13:31:39 -07:00
|
|
|
boolean disableNetworkTime = SystemProperties.getBoolean("config.disable_networktime", false);
|
2016-02-03 16:57:31 -08:00
|
|
|
boolean disableRtt = SystemProperties.getBoolean("config.disable_rtt", false);
|
2016-03-04 14:50:16 -08:00
|
|
|
boolean disableMediaProjection = SystemProperties.getBoolean("config.disable_mediaproj",
|
|
|
|
false);
|
|
|
|
boolean disableSerial = SystemProperties.getBoolean("config.disable_serial", false);
|
|
|
|
boolean disableSearchManager = SystemProperties.getBoolean("config.disable_searchmanager",
|
|
|
|
false);
|
|
|
|
boolean disableTrustManager = SystemProperties.getBoolean("config.disable_trustmanager",
|
|
|
|
false);
|
2016-09-14 18:14:31 +01:00
|
|
|
boolean disableTextServices = SystemProperties.getBoolean("config.disable_textservices",
|
|
|
|
false);
|
2016-03-04 14:50:16 -08:00
|
|
|
boolean disableSamplingProfiler = SystemProperties.getBoolean("config.disable_samplingprof",
|
|
|
|
false);
|
2016-09-07 13:33:49 -07:00
|
|
|
boolean disableConsumerIr = SystemProperties.getBoolean("config.disable_consumerir", false);
|
2016-09-19 15:10:33 -07:00
|
|
|
boolean disableVrManager = SystemProperties.getBoolean("config.disable_vrmanager", false);
|
2016-09-14 18:14:31 +01:00
|
|
|
boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice",
|
|
|
|
false);
|
2016-09-07 13:33:49 -07:00
|
|
|
|
2017-02-18 20:05:47 +00:00
|
|
|
boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1");
|
|
|
|
|
2017-01-20 10:42:57 -07:00
|
|
|
// For debugging RescueParty
|
|
|
|
if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_system", false)) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
Zygote: Explicitly preload secondary zygote resources.
We now turn on lazy preloading (see companion change 73c7df1bda76a0)
and explicitly preload zygote resources.
To provide the most benefit :
- We start the preload in the system_server, which means the system_server
starts quicker since it has one less preload to wait for. Morever, the
64 bit zygote also starts quicker because it has one less high
priority process to contend with for CPU and I/O.
- We start the preload after the core system services start up, since we
know no 32 bit zygote processes will be requested before that point.
- We start the preload ~1s before the webview factory preparation, to
ensure that it completes before the 32 bit relro process is forked
from the zygote. In the event that it takes too long, the webview
RELRO process will block, but it will do so without holding any locks.
I have not observed this happening in > 200 runs on marlin / sailfish
devices.
This change saves about 500ms in boot times, and sometimes even more.
AFTER:
successive-online : 16970.0,16668.0,16391.0,16498.0,17601.0,16736.0,16609.0,16820.0,16310.0,17557.0,
successive-online_avg : 16816.0
successive-boot : 28750.0,29520.0,29372.0,28424.0,30683.0,28523.0,29766.0,29779.0,29304.0,31607.0,
successive-boot_avg : 29572.8
BEFORE:
successive-online : 16678.0,18105.0,17197.0,16744.0,17453.0,16946.0,18068.0,16719.0,17453.0,16942.0,
successive-online_avg : 17230.5
successive-boot : 30855.0,32069.0,31223.0,30918.0,30284.0,29750.0,31036.0,30778.0,30310.0,30908.0,
successive-boot_avg : 30813.1
Note that successive-online is a little faster, as expected since we do
less work in the 32 bit zygote.
Test: manual, timings from tradefed.
Bug: 34810190
Change-Id: I90207a2706afda163b8134ff2af31f6917f3841b
2017-02-06 20:24:08 +00:00
|
|
|
final String SECONDARY_ZYGOTE_PRELOAD = "SecondaryZygotePreload";
|
|
|
|
// We start the preload ~1s before the webview factory preparation, to
|
|
|
|
// ensure that it completes before the 32 bit relro process is forked
|
|
|
|
// from the zygote. In the event that it takes too long, the webview
|
|
|
|
// RELRO process will block, but it will do so without holding any locks.
|
|
|
|
mZygotePreload = SystemServerInitThreadPool.get().submit(() -> {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, SECONDARY_ZYGOTE_PRELOAD);
|
|
|
|
BootTimingsTraceLog traceLog = new BootTimingsTraceLog(
|
|
|
|
SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
|
|
|
|
traceLog.traceBegin(SECONDARY_ZYGOTE_PRELOAD);
|
|
|
|
if (!Process.zygoteProcess.preloadDefault(Build.SUPPORTED_32_BIT_ABIS[0])) {
|
|
|
|
Slog.e(TAG, "Unable to preload default resources");
|
|
|
|
}
|
|
|
|
traceLog.traceEnd();
|
|
|
|
} catch (Exception ex) {
|
|
|
|
Slog.e(TAG, "Exception preloading default resources", ex);
|
|
|
|
}
|
|
|
|
}, SECONDARY_ZYGOTE_PRELOAD);
|
|
|
|
|
2016-06-03 11:31:55 -07:00
|
|
|
traceBeginAndSlog("StartKeyAttestationApplicationIdProviderService");
|
|
|
|
ServiceManager.addService("sec_key_att_app_id_provider",
|
|
|
|
new KeyAttestationApplicationIdProviderService(context));
|
2016-09-23 10:58:43 -07:00
|
|
|
traceEnd();
|
2016-06-03 11:31:55 -07:00
|
|
|
|
2017-03-23 15:28:37 +00:00
|
|
|
traceBeginAndSlog("StartKeyChainSystemService");
|
|
|
|
mSystemServiceManager.startService(KeyChainSystemService.class);
|
|
|
|
traceEnd();
|
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartSchedulingPolicyService");
|
2013-09-16 10:57:39 -07:00
|
|
|
ServiceManager.addService("scheduling_policy", new SchedulingPolicyService());
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-04-23 15:00:43 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartTelecomLoaderService");
|
2014-11-21 15:20:15 -08:00
|
|
|
mSystemServiceManager.startService(TelecomLoaderService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-11-21 15:20:15 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartTelephonyRegistry");
|
2014-06-12 22:38:59 -07:00
|
|
|
telephonyRegistry = new TelephonyRegistry(context);
|
|
|
|
ServiceManager.addService("telephony.registry", telephonyRegistry);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-02-13 14:39:30 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartEntropyMixer");
|
2016-04-12 18:23:31 -06:00
|
|
|
mEntropyMixer = new EntropyMixer(context);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-03-04 13:05:32 -08:00
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
mContentResolver = context.getContentResolver();
|
|
|
|
|
2016-09-14 18:14:31 +01:00
|
|
|
if (!disableCameraService) {
|
2017-02-21 11:35:10 -08:00
|
|
|
Slog.i(TAG, "Camera Service Proxy");
|
|
|
|
traceBeginAndSlog("StartCameraServiceProxy");
|
|
|
|
mSystemServiceManager.startService(CameraServiceProxy.class);
|
2016-09-25 13:38:46 -07:00
|
|
|
traceEnd();
|
2016-09-14 18:14:31 +01:00
|
|
|
}
|
2015-03-20 22:18:55 -07:00
|
|
|
|
2009-09-29 20:44:30 -07:00
|
|
|
// The AccountManager must come before the ContentService
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartAccountManagerService");
|
2016-04-12 18:23:31 -06:00
|
|
|
mSystemServiceManager.startService(ACCOUNT_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-24 22:48:12 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartContentService");
|
2016-04-04 08:58:04 -06:00
|
|
|
mSystemServiceManager.startService(CONTENT_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("InstallSystemProviders");
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.installSystemProviders();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartVibratorService");
|
2012-04-13 20:38:38 -07:00
|
|
|
vibrator = new VibratorService(context);
|
|
|
|
ServiceManager.addService("vibrator", vibrator);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-18 17:39:46 -07:00
|
|
|
|
2016-09-07 13:33:49 -07:00
|
|
|
if (!disableConsumerIr) {
|
|
|
|
traceBeginAndSlog("StartConsumerIrService");
|
|
|
|
consumerIr = new ConsumerIrService(context);
|
|
|
|
ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr);
|
2016-09-12 21:12:49 -07:00
|
|
|
traceEnd();
|
2016-09-07 13:33:49 -07:00
|
|
|
}
|
2014-01-15 20:40:55 -08:00
|
|
|
|
2016-04-12 18:23:31 -06:00
|
|
|
traceBeginAndSlog("StartAlarmManagerService");
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(AlarmManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("InitWatchdog");
|
2014-01-15 20:40:55 -08:00
|
|
|
final Watchdog watchdog = Watchdog.getInstance();
|
2014-01-16 22:16:42 -08:00
|
|
|
watchdog.init(context, mActivityManagerService);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartInputManagerService");
|
2014-01-16 22:16:42 -08:00
|
|
|
inputManager = new InputManagerService(context);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-09-20 16:48:17 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartWindowManagerService");
|
2017-02-01 12:09:58 -08:00
|
|
|
// WMS needs sensor service ready
|
|
|
|
ConcurrentUtils.waitForFutureNoInterrupt(mSensorServiceStart, START_SENSOR_SERVICE);
|
|
|
|
mSensorServiceStart = null;
|
2014-01-16 22:16:42 -08:00
|
|
|
wm = WindowManagerService.main(context, inputManager,
|
2014-01-15 20:40:55 -08:00
|
|
|
mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL,
|
2016-07-18 12:05:30 -07:00
|
|
|
!mFirstBoot, mOnlyCore, new PhoneWindowManager());
|
2009-03-03 19:31:44 -08:00
|
|
|
ServiceManager.addService(Context.WINDOW_SERVICE, wm);
|
2012-04-17 16:52:41 -07:00
|
|
|
ServiceManager.addService(Context.INPUT_SERVICE, inputManager);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2017-03-20 10:57:44 -07:00
|
|
|
// Start receiving calls from HIDL services. Start in in a separate thread
|
|
|
|
// because it need to connect to SensorManager. This have to start
|
|
|
|
// after START_SENSOR_SERVICE is done.
|
|
|
|
SystemServerInitThreadPool.get().submit(() -> {
|
|
|
|
traceBeginAndSlog(START_HIDL_SERVICES);
|
|
|
|
startHidlServices();
|
|
|
|
traceEnd();
|
|
|
|
}, START_HIDL_SERVICES);
|
|
|
|
|
2016-09-19 15:10:33 -07:00
|
|
|
if (!disableVrManager) {
|
|
|
|
traceBeginAndSlog("StartVrManagerService");
|
|
|
|
mSystemServiceManager.startService(VrManagerService.class);
|
2016-09-20 10:21:27 -07:00
|
|
|
traceEnd();
|
2016-09-19 15:10:33 -07:00
|
|
|
}
|
2015-12-04 16:16:31 -08:00
|
|
|
|
2016-12-07 13:03:17 -08:00
|
|
|
traceBeginAndSlog("SetWindowManagerService");
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.setWindowManager(wm);
|
2016-12-07 13:03:17 -08:00
|
|
|
traceEnd();
|
2012-09-20 16:48:17 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartInputManager");
|
2016-12-07 13:03:17 -08:00
|
|
|
inputManager.setWindowManagerCallbacks(wm.getInputMonitor());
|
2012-09-20 16:48:17 -07:00
|
|
|
inputManager.start();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-09-20 16:48:17 -07:00
|
|
|
|
2014-01-16 22:16:42 -08:00
|
|
|
// TODO: Use service dependencies instead.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("DisplayManagerWindowManagerAndInputReady");
|
2014-01-16 22:16:42 -08:00
|
|
|
mDisplayManagerService.windowManagerAndInputReady();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2017-02-18 20:05:47 +00:00
|
|
|
// Skip Bluetooth if we have an emulator kernel
|
|
|
|
// TODO: Use a more reliable check to see if this product should
|
|
|
|
// support Bluetooth - see bug 988521
|
|
|
|
if (isEmulator) {
|
|
|
|
Slog.i(TAG, "No Bluetooth Service (emulator)");
|
|
|
|
} else if (mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
|
2011-01-17 00:32:33 +01:00
|
|
|
Slog.i(TAG, "No Bluetooth Service (factory test)");
|
2013-04-26 12:37:54 -07:00
|
|
|
} else if (!context.getPackageManager().hasSystemFeature
|
|
|
|
(PackageManager.FEATURE_BLUETOOTH)) {
|
|
|
|
Slog.i(TAG, "No Bluetooth Service (Bluetooth Hardware Not Present)");
|
2013-03-28 18:10:43 -07:00
|
|
|
} else if (disableBluetooth) {
|
|
|
|
Slog.i(TAG, "Bluetooth Service disabled by config");
|
2009-03-03 19:31:44 -08:00
|
|
|
} else {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartBluetoothService");
|
2015-06-26 17:14:35 -07:00
|
|
|
mSystemServiceManager.startService(BluetoothService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2016-02-03 10:39:44 -08:00
|
|
|
|
2016-09-09 09:23:47 +09:00
|
|
|
traceBeginAndSlog("IpConnectivityMetrics");
|
|
|
|
mSystemServiceManager.startService(IpConnectivityMetrics.class);
|
2016-10-18 17:52:30 -07:00
|
|
|
traceEnd();
|
2016-09-09 09:23:47 +09:00
|
|
|
|
2016-04-28 15:26:49 -07:00
|
|
|
traceBeginAndSlog("PinnerService");
|
|
|
|
mSystemServiceManager.startService(PinnerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
} catch (RuntimeException e) {
|
2011-08-22 00:26:20 -07:00
|
|
|
Slog.e("System", "******************************************");
|
|
|
|
Slog.e("System", "************ Failure starting core service", e);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 08:18:45 -07:00
|
|
|
StatusBarManagerService statusBar = null;
|
2013-12-05 16:48:06 -08:00
|
|
|
INotificationManager notification = null;
|
2010-02-22 16:36:44 -05:00
|
|
|
LocationManagerService location = null;
|
2010-07-13 15:32:16 +08:00
|
|
|
CountryDetectorService countryDetector = null;
|
2016-01-27 19:05:43 -08:00
|
|
|
ILockSettings lockSettings = null;
|
2013-11-07 00:30:16 -08:00
|
|
|
MediaRouterService mediaRouter = null;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2011-08-22 00:26:20 -07:00
|
|
|
// Bring up services needed for UI.
|
2014-01-15 20:40:55 -08:00
|
|
|
if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartInputMethodManagerLifecycle");
|
2016-01-21 12:02:58 -08:00
|
|
|
mSystemServiceManager.startService(InputMethodManagerService.Lifecycle.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2011-08-22 00:26:20 -07:00
|
|
|
|
2015-09-02 22:48:13 +09:00
|
|
|
traceBeginAndSlog("StartAccessibilityManagerService");
|
2014-11-25 15:33:26 -08:00
|
|
|
try {
|
|
|
|
ServiceManager.addService(Context.ACCESSIBILITY_SERVICE,
|
|
|
|
new AccessibilityManagerService(context));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Accessibility Manager", e);
|
2011-08-22 00:26:20 -07:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2011-08-22 00:26:20 -07:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakeDisplayReady");
|
2011-08-22 00:26:20 -07:00
|
|
|
try {
|
|
|
|
wm.displayReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making display ready", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2011-08-25 13:30:53 -07:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableStorage &&
|
2017-01-04 11:33:33 -07:00
|
|
|
!"0".equals(SystemProperties.get("system_init.startmountservice"))) {
|
2016-11-07 15:41:02 -08:00
|
|
|
traceBeginAndSlog("StartStorageManagerService");
|
2012-05-17 13:30:28 -07:00
|
|
|
try {
|
|
|
|
/*
|
2016-11-07 15:41:02 -08:00
|
|
|
* NotificationManagerService is dependant on StorageManagerService,
|
|
|
|
* (for media / usb notifications) so we must start StorageManagerService first.
|
2012-05-17 13:30:28 -07:00
|
|
|
*/
|
2016-11-07 15:41:02 -08:00
|
|
|
mSystemServiceManager.startService(STORAGE_MANAGER_SERVICE_CLASS);
|
|
|
|
storageManager = IStorageManager.Stub.asInterface(
|
2015-03-21 20:41:00 -07:00
|
|
|
ServiceManager.getService("mount"));
|
2012-05-17 13:30:28 -07:00
|
|
|
} catch (Throwable e) {
|
2017-01-04 11:33:33 -07:00
|
|
|
reportWtf("starting StorageManagerService", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
|
|
|
|
traceBeginAndSlog("StartStorageStatsService");
|
|
|
|
try {
|
|
|
|
mSystemServiceManager.startService(STORAGE_STATS_SERVICE_CLASS);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting StorageStatsService", e);
|
2012-05-17 13:30:28 -07:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-05-17 13:30:28 -07:00
|
|
|
}
|
2014-11-05 16:54:50 +05:30
|
|
|
}
|
2012-05-17 13:30:28 -07:00
|
|
|
|
2015-03-19 14:37:11 -07:00
|
|
|
// We start this here so that we update our configuration to set watch or television
|
|
|
|
// as appropriate.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartUiModeManager");
|
2015-03-19 14:37:11 -07:00
|
|
|
mSystemServiceManager.startService(UiModeManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-03-19 14:37:11 -07:00
|
|
|
|
2016-06-02 15:31:30 +01:00
|
|
|
if (!mOnlyCore) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("UpdatePackagesIfNeeded");
|
2016-06-02 15:31:30 +01:00
|
|
|
try {
|
|
|
|
mPackageManagerService.updatePackagesIfNeeded();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("update packages", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-11-05 16:54:50 +05:30
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("PerformFstrimIfNeeded");
|
2016-01-20 14:04:40 +00:00
|
|
|
try {
|
2016-03-30 11:45:52 +01:00
|
|
|
mPackageManagerService.performFstrimIfNeeded();
|
2016-01-20 14:04:40 +00:00
|
|
|
} catch (Throwable e) {
|
2016-03-30 11:45:52 +01:00
|
|
|
reportWtf("performing fstrim", e);
|
2016-01-20 14:04:40 +00:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-01-20 14:04:40 +00:00
|
|
|
|
2014-11-05 16:54:50 +05:30
|
|
|
if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartLockSettingsService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
2016-01-27 19:05:43 -08:00
|
|
|
mSystemServiceManager.startService(LOCK_SETTINGS_SERVICE_CLASS);
|
|
|
|
lockSettings = ILockSettings.Stub.asInterface(
|
|
|
|
ServiceManager.getService("lock_settings"));
|
2013-03-28 18:10:43 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting LockSettingsService service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-03-28 11:42:42 -07:00
|
|
|
|
2014-07-01 19:40:41 -07:00
|
|
|
if (!SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("")) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartPersistentDataBlock");
|
2014-07-01 19:40:41 -07:00
|
|
|
mSystemServiceManager.startService(PersistentDataBlockService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2017-02-13 18:12:15 +00:00
|
|
|
|
|
|
|
// Implementation depends on persistent data block
|
|
|
|
traceBeginAndSlog("StartOemLockService");
|
|
|
|
mSystemServiceManager.startService(OemLockService.class);
|
|
|
|
traceEnd();
|
2014-07-01 19:40:41 -07:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDeviceIdleController");
|
2015-04-27 09:47:32 -07:00
|
|
|
mSystemServiceManager.startService(DeviceIdleController.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-04-27 09:47:32 -07:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
// Always start the Device Policy Manager, so that the API is compatible with
|
|
|
|
// API8.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDevicePolicyManager");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(DevicePolicyManagerService.Lifecycle.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-01-12 18:14:19 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableSystemUI) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartStatusBarManagerService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
statusBar = new StatusBarManagerService(context, wm);
|
|
|
|
ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting StatusBarManagerService", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartClipboardService");
|
2016-09-29 12:58:04 -07:00
|
|
|
mSystemServiceManager.startService(ClipboardService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartNetworkManagementService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
networkManagement = NetworkManagementService.create(context);
|
|
|
|
ServiceManager.addService(Context.NETWORKMANAGEMENT_SERVICE, networkManagement);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkManagement Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2017-03-01 18:55:06 -08:00
|
|
|
|
|
|
|
traceBeginAndSlog("StartIpSecService");
|
|
|
|
try {
|
|
|
|
ipSecService = IpSecService.create(context);
|
|
|
|
ServiceManager.addService(Context.IPSEC_SERVICE, ipSecService);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting IpSec Service", e);
|
|
|
|
}
|
2017-04-04 22:00:01 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2016-03-04 14:50:16 -08:00
|
|
|
if (!disableNonCoreServices && !disableTextServices) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartTextServicesManager");
|
2016-03-07 13:41:15 -08:00
|
|
|
mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2011-06-22 16:38:13 +09:00
|
|
|
}
|
|
|
|
|
2016-12-14 15:38:56 +00:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
traceBeginAndSlog("StartTextClassificationService");
|
|
|
|
mSystemServiceManager.startService(TextClassificationService.Lifecycle.class);
|
|
|
|
traceEnd();
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartNetworkScoreService");
|
2014-03-31 19:12:07 -07:00
|
|
|
try {
|
|
|
|
networkScore = new NetworkScoreService(context);
|
|
|
|
ServiceManager.addService(Context.NETWORK_SCORE_SERVICE, networkScore);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Network Score Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-03-31 19:12:07 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartNetworkStatsService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
2016-02-17 13:03:38 -08:00
|
|
|
networkStats = NetworkStatsService.create(context, networkManagement);
|
2013-03-28 18:10:43 -07:00
|
|
|
ServiceManager.addService(Context.NETWORK_STATS_SERVICE, networkStats);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkStats Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2011-05-20 15:29:23 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartNetworkPolicyManagerService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
2016-08-10 13:00:32 -07:00
|
|
|
networkPolicy = new NetworkPolicyManagerService(context,
|
|
|
|
mActivityManagerService, networkStats, networkManagement);
|
2013-03-28 18:10:43 -07:00
|
|
|
ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkPolicy Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-01-26 06:17:26 -08:00
|
|
|
|
2017-01-07 01:59:16 -08:00
|
|
|
// Wifi Service must be started first for wifi-related services.
|
|
|
|
traceBeginAndSlog("StartWifi");
|
|
|
|
mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("StartWifiScanning");
|
|
|
|
mSystemServiceManager.startService(
|
|
|
|
"com.android.server.wifi.scanner.WifiScanningService");
|
|
|
|
traceEnd();
|
|
|
|
|
|
|
|
if (!disableRtt) {
|
|
|
|
traceBeginAndSlog("StartWifiRtt");
|
|
|
|
mSystemServiceManager.startService("com.android.server.wifi.RttService");
|
|
|
|
traceEnd();
|
|
|
|
}
|
|
|
|
|
2016-10-26 11:22:06 -07:00
|
|
|
if (context.getPackageManager().hasSystemFeature(
|
|
|
|
PackageManager.FEATURE_WIFI_AWARE)) {
|
|
|
|
traceBeginAndSlog("StartWifiAware");
|
|
|
|
mSystemServiceManager.startService(WIFI_AWARE_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-09-29 13:49:02 -07:00
|
|
|
} else {
|
2016-10-26 11:22:06 -07:00
|
|
|
Slog.i(TAG, "No Wi-Fi Aware Service (Aware support Not Present)");
|
2015-09-29 13:49:02 -07:00
|
|
|
}
|
2016-05-23 15:12:49 -07:00
|
|
|
|
|
|
|
if (context.getPackageManager().hasSystemFeature(
|
|
|
|
PackageManager.FEATURE_WIFI_DIRECT)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartWifiP2P");
|
2016-05-23 15:12:49 -07:00
|
|
|
mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-05-23 15:12:49 -07:00
|
|
|
}
|
2014-07-25 17:46:14 -07:00
|
|
|
|
2014-11-25 21:52:12 +09:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET) ||
|
|
|
|
mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartEthernet");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-05-21 16:32:11 -07:00
|
|
|
}
|
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartConnectivityService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
connectivity = new ConnectivityService(
|
|
|
|
context, networkManagement, networkStats, networkPolicy);
|
|
|
|
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
|
|
|
|
networkStats.bindConnectivityManager(connectivity);
|
|
|
|
networkPolicy.bindConnectivityManager(connectivity);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Connectivity Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartNsdService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
serviceDiscovery = NsdService.create(context);
|
|
|
|
ServiceManager.addService(
|
|
|
|
Context.NSD_SERVICE, serviceDiscovery);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Service Discovery Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-03-22 17:01:39 -07:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartUpdateLockService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
ServiceManager.addService(Context.UPDATE_LOCK_SERVICE,
|
|
|
|
new UpdateLockService(context));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting UpdateLockService", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-02-23 14:59:36 -08:00
|
|
|
}
|
|
|
|
|
2012-05-17 13:30:28 -07:00
|
|
|
/*
|
2016-11-07 15:41:02 -08:00
|
|
|
* StorageManagerService has a few dependencies: Notification Manager and
|
|
|
|
* AppWidget Provider. Make sure StorageManagerService is completely started
|
2012-05-17 13:30:28 -07:00
|
|
|
* first before continuing.
|
|
|
|
*/
|
2016-11-07 15:41:02 -08:00
|
|
|
if (storageManager != null && !mOnlyCore) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("WaitForAsecScan");
|
2015-03-21 20:41:00 -07:00
|
|
|
try {
|
2016-11-07 15:41:02 -08:00
|
|
|
storageManager.waitForAsecScan();
|
2015-03-21 20:41:00 -07:00
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartNotificationManager");
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(NotificationManagerService.class);
|
2017-02-15 09:35:38 -05:00
|
|
|
SystemNotificationChannels.createAll(context);
|
2013-12-05 16:48:06 -08:00
|
|
|
notification = INotificationManager.Stub.asInterface(
|
|
|
|
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
|
|
|
networkPolicy.bindNotificationManager(notification);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDeviceMonitor");
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(DeviceStorageMonitorService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableLocation) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartLocationManagerService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
location = new LocationManagerService(context);
|
|
|
|
ServiceManager.addService(Context.LOCATION_SERVICE, location);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Location Manager", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartCountryDetectorService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
countryDetector = new CountryDetectorService(context);
|
|
|
|
ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Country Detector", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-07-13 15:32:16 +08:00
|
|
|
}
|
|
|
|
|
2016-03-04 14:50:16 -08:00
|
|
|
if (!disableNonCoreServices && !disableSearchManager) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartSearchManagerService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
2016-01-09 14:57:45 -07:00
|
|
|
mSystemServiceManager.startService(SEARCH_MANAGER_SERVICE_CLASS);
|
2013-03-28 18:10:43 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Search Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices && context.getResources().getBoolean(
|
|
|
|
R.bool.config_enableWallpaperService)) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartWallpaperManagerService");
|
2016-04-12 18:23:31 -06:00
|
|
|
mSystemServiceManager.startService(WALLPAPER_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2015-09-02 22:48:13 +09:00
|
|
|
traceBeginAndSlog("StartAudioService");
|
2015-10-15 17:28:35 -07:00
|
|
|
mSystemServiceManager.startService(AudioService.Lifecycle.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDockObserver");
|
2014-05-29 17:48:33 -07:00
|
|
|
mSystemServiceManager.startService(DockObserver.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-09-25 16:43:01 -07:00
|
|
|
|
2016-03-29 15:26:48 -07:00
|
|
|
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartThermalObserver");
|
2016-03-25 16:32:10 -07:00
|
|
|
mSystemServiceManager.startService(THERMAL_OBSERVER_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-09-25 16:43:01 -07:00
|
|
|
}
|
2009-08-12 15:15:43 -05:00
|
|
|
}
|
|
|
|
|
2015-09-02 22:48:13 +09:00
|
|
|
traceBeginAndSlog("StartWiredAccessoryManager");
|
2015-03-24 12:40:15 -04:00
|
|
|
try {
|
|
|
|
// Listen for wired headset changes
|
|
|
|
inputManager.setWiredAccessoryCallbacks(
|
|
|
|
new WiredAccessoryManager(context, inputManager));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting WiredAccessoryManager", e);
|
2010-10-06 15:23:14 -05:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-10-06 15:23:14 -05:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2015-03-27 13:23:41 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_MIDI)) {
|
|
|
|
// Start MIDI Manager service
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartMidiManager");
|
2015-03-27 13:23:41 -07:00
|
|
|
mSystemServiceManager.startService(MIDI_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-03-27 13:23:41 -07:00
|
|
|
}
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|
|
|
|
|| mPackageManager.hasSystemFeature(
|
|
|
|
PackageManager.FEATURE_USB_ACCESSORY)) {
|
|
|
|
// Manage USB host and device support
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartUsbService");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(USB_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-03-28 18:10:43 -07:00
|
|
|
}
|
2011-08-29 20:11:07 -04:00
|
|
|
|
2016-03-04 14:50:16 -08:00
|
|
|
if (!disableSerial) {
|
|
|
|
traceBeginAndSlog("StartSerialService");
|
|
|
|
try {
|
|
|
|
// Serial port support
|
|
|
|
serial = new SerialService(context);
|
|
|
|
ServiceManager.addService(Context.SERIAL_SERVICE, serial);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
Slog.e(TAG, "Failure starting SerialService", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-03-28 18:10:43 -07:00
|
|
|
}
|
2016-02-12 20:38:23 +01:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartHardwarePropertiesManagerService");
|
2016-02-12 20:38:23 +01:00
|
|
|
try {
|
|
|
|
hardwarePropertiesService = new HardwarePropertiesManagerService(context);
|
|
|
|
ServiceManager.addService(Context.HARDWARE_PROPERTIES_SERVICE,
|
|
|
|
hardwarePropertiesService);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
Slog.e(TAG, "Failure starting HardwarePropertiesManagerService", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-06-23 17:36:36 -04:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartTwilightService");
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(TwilightService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-08-21 22:12:20 -07:00
|
|
|
|
2016-06-21 18:24:24 -07:00
|
|
|
if (NightDisplayController.isAvailable(context)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartNightDisplay");
|
2016-06-21 18:24:24 -07:00
|
|
|
mSystemServiceManager.startService(NightDisplayService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-06-21 18:24:24 -07:00
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartJobScheduler");
|
2014-06-09 19:50:00 -07:00
|
|
|
mSystemServiceManager.startService(JobSchedulerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-05-19 13:46:29 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartSoundTrigger");
|
2016-01-25 10:33:11 -08:00
|
|
|
mSystemServiceManager.startService(SoundTriggerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-01-25 10:33:11 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2016-08-10 17:30:38 -06:00
|
|
|
if (!disableTrustManager) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartTrustManager");
|
2016-08-10 17:30:38 -06:00
|
|
|
mSystemServiceManager.startService(TrustManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-08-10 17:30:38 -06:00
|
|
|
}
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_BACKUP)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartBackupManager");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-03-28 18:10:43 -07:00
|
|
|
}
|
2009-04-29 14:03:25 -07:00
|
|
|
|
2016-03-25 17:24:57 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS)
|
|
|
|
|| context.getResources().getBoolean(R.bool.config_enableAppWidgetService)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartAppWidgerService");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-03-28 18:10:43 -07:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_VOICE_RECOGNIZERS)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartVoiceRecognitionManager");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(VOICE_RECOGNITION_MANAGER_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-04-04 18:02:06 -07:00
|
|
|
}
|
2015-07-21 17:43:53 -07:00
|
|
|
|
|
|
|
if (GestureLauncherService.isGestureLauncherEnabled(context.getResources())) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartGestureLauncher");
|
2015-07-21 17:43:53 -07:00
|
|
|
mSystemServiceManager.startService(GestureLauncherService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-07-21 17:43:53 -07:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartSensorNotification");
|
2016-01-20 00:05:45 -08:00
|
|
|
mSystemServiceManager.startService(SensorNotificationService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
|
|
|
|
|
|
|
traceBeginAndSlog("StartContextHubSystemService");
|
2016-02-11 13:02:05 -08:00
|
|
|
mSystemServiceManager.startService(ContextHubSystemService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-02-19 17:02:21 -08:00
|
|
|
}
|
2010-10-18 15:29:09 -07:00
|
|
|
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartDiskStatsService");
|
2010-03-25 16:20:14 -07:00
|
|
|
try {
|
|
|
|
ServiceManager.addService("diskstats", new DiskStatsService(context));
|
|
|
|
} catch (Throwable e) {
|
2011-08-22 00:26:20 -07:00
|
|
|
reportWtf("starting DiskStats Service", e);
|
2010-03-25 16:20:14 -07:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-05-28 01:54:03 -07:00
|
|
|
|
2016-03-04 14:50:16 -08:00
|
|
|
if (!disableSamplingProfiler) {
|
|
|
|
traceBeginAndSlog("StartSamplingProfilerService");
|
|
|
|
try {
|
|
|
|
// need to add this service even if SamplingProfilerIntegration.isEnabled()
|
|
|
|
// is false, because it is this service that detects system property change and
|
|
|
|
// turns on SamplingProfilerIntegration. Plus, when sampling profiler doesn't work,
|
|
|
|
// there is little overhead for running this service.
|
|
|
|
ServiceManager.addService("samplingprofiler",
|
|
|
|
new SamplingProfilerService(context));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting SamplingProfiler Service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-05-28 01:54:03 -07:00
|
|
|
}
|
2010-08-06 12:06:04 +08:00
|
|
|
|
2014-10-16 13:31:39 -07:00
|
|
|
if (!disableNetwork && !disableNetworkTime) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartNetworkTimeUpdateService");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
networkTimeUpdater = new NetworkTimeUpdateService(context);
|
2016-02-26 16:54:25 -08:00
|
|
|
ServiceManager.addService("network_time_update_service", networkTimeUpdater);
|
2013-03-28 18:10:43 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkTimeUpdate service", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-09-13 16:24:08 -07:00
|
|
|
}
|
2012-02-01 15:23:33 -08:00
|
|
|
|
2015-09-02 22:48:13 +09:00
|
|
|
traceBeginAndSlog("StartCommonTimeManagementService");
|
2015-03-24 12:40:15 -04:00
|
|
|
try {
|
|
|
|
commonTimeMgmtService = new CommonTimeManagementService(context);
|
|
|
|
ServiceManager.addService("commontime_management", commonTimeMgmtService);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting CommonTimeManagementService service", e);
|
2012-02-01 15:23:33 -08:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-05-06 18:32:19 -07:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("CertBlacklister");
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
CertBlacklister blacklister = new CertBlacklister(context);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting CertBlacklister", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-05-06 18:32:19 -07:00
|
|
|
}
|
2013-01-09 18:50:26 -08:00
|
|
|
|
2016-09-13 16:02:33 -07:00
|
|
|
if (!disableNetwork && !disableNonCoreServices && EmergencyAffordanceManager.ENABLED) {
|
2016-12-07 13:03:17 -08:00
|
|
|
// EmergencyMode service
|
|
|
|
traceBeginAndSlog("StartEmergencyAffordanceService");
|
2016-09-13 16:02:33 -07:00
|
|
|
mSystemServiceManager.startService(EmergencyAffordanceService.class);
|
2016-12-07 13:03:17 -08:00
|
|
|
traceEnd();
|
2016-09-13 16:02:33 -07:00
|
|
|
}
|
|
|
|
|
2014-02-24 13:57:53 -08:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
// Dreams (interactive idle-time views, a/k/a screen savers, and doze mode)
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartDreamManager");
|
2014-01-30 23:38:03 -08:00
|
|
|
mSystemServiceManager.startService(DreamManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-01-30 14:33:52 -05:00
|
|
|
}
|
2013-02-13 14:39:30 -08:00
|
|
|
|
2015-03-18 15:24:33 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("AddGraphicsStatsService");
|
2015-03-18 15:24:33 -07:00
|
|
|
ServiceManager.addService(GraphicsStatsService.GRAPHICS_STATS_SERVICE,
|
|
|
|
new GraphicsStatsService(context));
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2015-03-18 15:24:33 -07:00
|
|
|
}
|
|
|
|
|
2016-11-11 15:42:50 -08:00
|
|
|
if (!disableNonCoreServices && CoverageService.ENABLED) {
|
|
|
|
traceBeginAndSlog("AddCoverageService");
|
|
|
|
ServiceManager.addService(CoverageService.COVERAGE_SERVICE, new CoverageService());
|
|
|
|
traceEnd();
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartPrintManager");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-06-11 15:20:06 -07:00
|
|
|
}
|
2013-11-07 00:30:16 -08:00
|
|
|
|
2017-03-10 14:25:58 -08:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_COMPANION_DEVICE_SETUP)) {
|
|
|
|
traceBeginAndSlog("StartCompanionDeviceManager");
|
|
|
|
mSystemServiceManager.startService(COMPANION_DEVICE_MANAGER_SERVICE_CLASS);
|
|
|
|
traceEnd();
|
|
|
|
}
|
2017-01-22 13:52:51 -08:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartRestrictionManager");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(RestrictionsManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-05-24 15:34:37 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartMediaSessionService");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(MediaSessionService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-02-13 14:19:04 -08:00
|
|
|
|
2014-07-10 20:49:27 +09:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_HDMI_CEC)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartHdmiControlService");
|
2014-07-10 20:49:27 +09:00
|
|
|
mSystemServiceManager.startService(HdmiControlService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-10 20:49:27 +09:00
|
|
|
}
|
2014-04-23 17:57:26 +09:00
|
|
|
|
2017-04-05 17:31:01 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_LIVE_TV)
|
|
|
|
|| mPackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartTvInputManager");
|
2014-07-24 16:28:35 +09:00
|
|
|
mSystemServiceManager.startService(TvInputManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-24 16:28:35 +09:00
|
|
|
}
|
2014-02-20 18:23:25 -08:00
|
|
|
|
2016-03-23 18:04:19 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartMediaResourceMonitor");
|
2016-03-23 18:04:19 -07:00
|
|
|
mSystemServiceManager.startService(MediaResourceMonitorService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-03-23 18:04:19 -07:00
|
|
|
}
|
2015-12-14 21:57:34 +09:00
|
|
|
|
2016-01-28 16:53:16 -08:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartTvRemoteService");
|
2016-01-28 16:53:16 -08:00
|
|
|
mSystemServiceManager.startService(TvRemoteService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-01-28 16:53:16 -08:00
|
|
|
}
|
|
|
|
|
2013-11-07 00:30:16 -08:00
|
|
|
if (!disableNonCoreServices) {
|
2015-06-30 17:07:32 +09:00
|
|
|
traceBeginAndSlog("StartMediaRouterService");
|
2013-11-07 00:30:16 -08:00
|
|
|
try {
|
|
|
|
mediaRouter = new MediaRouterService(context);
|
|
|
|
ServiceManager.addService(Context.MEDIA_ROUTER_SERVICE, mediaRouter);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting MediaRouterService", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-03-27 14:56:59 +01:00
|
|
|
|
2016-02-03 14:31:37 -08:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartFingerprintSensor");
|
2016-02-03 14:31:37 -08:00
|
|
|
mSystemServiceManager.startService(FingerprintService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2016-02-03 14:31:37 -08:00
|
|
|
}
|
2014-06-06 15:00:49 -07:00
|
|
|
|
2017-03-15 18:38:57 -07:00
|
|
|
traceBeginAndSlog("StartBackgroundDexOptService");
|
2014-04-28 22:11:01 -07:00
|
|
|
try {
|
2017-03-15 18:38:57 -07:00
|
|
|
BackgroundDexOptService.schedule(context);
|
2014-04-28 22:11:01 -07:00
|
|
|
} catch (Throwable e) {
|
2017-03-15 18:38:57 -07:00
|
|
|
reportWtf("starting StartBackgroundDexOptService", e);
|
2017-01-30 16:34:13 -08:00
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
|
|
|
|
traceBeginAndSlog("StartPruneInstantAppsJobService");
|
|
|
|
try {
|
|
|
|
PruneInstantAppsJobService.schedule(context);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("StartPruneInstantAppsJobService", e);
|
2014-04-28 22:11:01 -07:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2013-11-07 00:30:16 -08:00
|
|
|
}
|
2016-03-08 10:49:47 -08:00
|
|
|
// LauncherAppsService uses ShortcutService.
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartShortcutServiceLifecycle");
|
2016-03-08 10:49:47 -08:00
|
|
|
mSystemServiceManager.startService(ShortcutService.Lifecycle.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-02-19 14:31:52 -08:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartLauncherAppsService");
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(LauncherAppsService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2016-03-04 14:50:16 -08:00
|
|
|
if (!disableNonCoreServices && !disableMediaProjection) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartMediaProjectionManager");
|
2014-07-08 18:07:36 -07:00
|
|
|
mSystemServiceManager.startService(MediaProjectionManagerService.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-08 18:07:36 -07:00
|
|
|
}
|
|
|
|
|
2016-03-29 15:26:48 -07:00
|
|
|
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
|
2017-02-22 15:16:42 -08:00
|
|
|
traceBeginAndSlog("StartWearConnectivityService");
|
2017-02-21 16:41:43 -08:00
|
|
|
mSystemServiceManager.startService(WEAR_CONNECTIVITY_SERVICE_CLASS);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2017-01-16 15:15:25 -08:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
traceBeginAndSlog("StartWearTimeService");
|
|
|
|
mSystemServiceManager.startService(WEAR_TIME_SERVICE_CLASS);
|
|
|
|
traceEnd();
|
|
|
|
}
|
2016-03-29 15:26:48 -07:00
|
|
|
}
|
|
|
|
|
2009-09-28 13:25:46 -07:00
|
|
|
// Before things start rolling, be sure we have decided whether
|
|
|
|
// we are in safe mode.
|
2009-09-02 13:26:28 -07:00
|
|
|
final boolean safeMode = wm.detectSafeMode();
|
2009-09-28 13:25:46 -07:00
|
|
|
if (safeMode) {
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("EnterSafeModeAndDisableJitCompilation");
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.enterSafeMode();
|
2011-01-13 21:08:27 -08:00
|
|
|
// Disable the JIT for the system_server process
|
|
|
|
VMRuntime.getRuntime().disableJitCompilation();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-02-14 16:18:56 -08:00
|
|
|
} else {
|
|
|
|
// Enable the JIT for the system_server process
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartJitCompilation");
|
2010-02-14 16:18:56 -08:00
|
|
|
VMRuntime.getRuntime().startJitCompilation();
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-09-28 13:25:46 -07:00
|
|
|
}
|
2009-12-04 10:31:43 -08:00
|
|
|
|
2014-07-24 12:56:45 -07:00
|
|
|
// MMS service broker
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartMmsService");
|
2014-07-24 12:56:45 -07:00
|
|
|
mmsService = mSystemServiceManager.startService(MmsServiceBroker.class);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2014-07-24 12:56:45 -07:00
|
|
|
|
2016-09-07 11:12:31 -07:00
|
|
|
traceBeginAndSlog("StartRetailDemoModeService");
|
|
|
|
mSystemServiceManager.startService(RetailDemoModeService.class);
|
|
|
|
traceEnd();
|
2016-05-20 14:41:22 -07:00
|
|
|
|
2017-04-12 09:25:20 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOFILL)) {
|
|
|
|
traceBeginAndSlog("StartAutoFillService");
|
|
|
|
mSystemServiceManager.startService(AUTO_FILL_MANAGER_SERVICE_CLASS);
|
|
|
|
traceEnd();
|
|
|
|
}
|
2016-10-13 09:02:32 -07:00
|
|
|
|
2009-09-28 13:25:46 -07:00
|
|
|
// It is now time to start up the app processes...
|
2009-07-08 17:09:14 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakeVibratorServiceReady");
|
2012-04-13 20:38:38 -07:00
|
|
|
try {
|
|
|
|
vibrator.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Vibrator Service ready", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-04-13 20:38:38 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakeLockSettingsServiceReady");
|
2013-03-28 18:10:43 -07:00
|
|
|
if (lockSettings != null) {
|
|
|
|
try {
|
|
|
|
lockSettings.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Lock Settings Service ready", e);
|
|
|
|
}
|
Fixing services start order that impacts ICS - JB upgrade
JB has introduced LockSettingsService. When the phone is
upgrading from ICS, that used another way to store lock
settings, the LockSettingsService needs to import these
settings to store in its database. This happens when the
systemReady() method of this class is called by SystemServer.
The problem resides in the fact that the
DevicePolicyManagerService actually needs to access the
LockSettingsService during its systemReady() initialization,
causing invalid values to be read by it which propagates and
ends up causing a invalid return in the method
isActivePasswordSufficient.
If user had a Google corporate account that enforces password
related policies through Google Apps Device Policy (GADP) app
in ICS, when he upgrades to JB, the GADP will throw a
notification saying that the password doesn't meet the required
policies and needs to be changed, incorrectly, since it wasn't
touched during upgrade.
This fix initializes the LockSettingsService before the
DevicePolicyManagerService, which is the correct way since
the latter uses the first in its initialization. This prevents
this issue to happen, and probably future issues, depending
on the way that LockSettingsService evolves.
Change-Id: I3d4334a8b728f0ad9ae744cece430d15af25a0b7
2012-09-18 18:26:27 -03:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
Fixing services start order that impacts ICS - JB upgrade
JB has introduced LockSettingsService. When the phone is
upgrading from ICS, that used another way to store lock
settings, the LockSettingsService needs to import these
settings to store in its database. This happens when the
systemReady() method of this class is called by SystemServer.
The problem resides in the fact that the
DevicePolicyManagerService actually needs to access the
LockSettingsService during its systemReady() initialization,
causing invalid values to be read by it which propagates and
ends up causing a invalid return in the method
isActivePasswordSufficient.
If user had a Google corporate account that enforces password
related policies through Google Apps Device Policy (GADP) app
in ICS, when he upgrades to JB, the GADP will throw a
notification saying that the password doesn't meet the required
policies and needs to be changed, incorrectly, since it wasn't
touched during upgrade.
This fix initializes the LockSettingsService before the
DevicePolicyManagerService, which is the correct way since
the latter uses the first in its initialization. This prevents
this issue to happen, and probably future issues, depending
on the way that LockSettingsService evolves.
Change-Id: I3d4334a8b728f0ad9ae744cece430d15af25a0b7
2012-09-18 18:26:27 -03:00
|
|
|
|
2013-12-20 13:27:30 -08:00
|
|
|
// Needed by DevicePolicyManager for initialization
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartBootPhaseLockSettingsReady");
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startBootPhase(SystemService.PHASE_LOCK_SETTINGS_READY);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-01-12 18:14:19 -08:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("StartBootPhaseSystemServicesReady");
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-07-08 17:09:14 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakeWindowManagerServiceReady");
|
2011-08-22 00:26:20 -07:00
|
|
|
try {
|
|
|
|
wm.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Window Manager Service ready", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2010-10-04 15:27:22 -04:00
|
|
|
|
2011-01-13 21:08:27 -08:00
|
|
|
if (safeMode) {
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.showSafeModeOverlay();
|
2011-01-13 21:08:27 -08:00
|
|
|
}
|
|
|
|
|
2010-10-04 15:27:22 -04:00
|
|
|
// Update the configuration for this context by hand, because we're going
|
|
|
|
// to start using it before the config change done in wm.systemReady() will
|
|
|
|
// propagate to it.
|
2016-10-21 11:55:23 -07:00
|
|
|
final Configuration config = wm.computeNewConfiguration(DEFAULT_DISPLAY);
|
2010-10-04 15:27:22 -04:00
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
WindowManager w = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
|
|
|
|
w.getDefaultDisplay().getMetrics(metrics);
|
|
|
|
context.getResources().updateConfiguration(config, metrics);
|
|
|
|
|
2015-08-11 17:27:04 -04:00
|
|
|
// The system context's theme may be configuration-dependent.
|
|
|
|
final Theme systemTheme = context.getTheme();
|
|
|
|
if (systemTheme.getChangingConfigurations() != 0) {
|
|
|
|
systemTheme.rebase();
|
|
|
|
}
|
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakePowerManagerServiceReady");
|
2012-08-21 22:14:26 -07:00
|
|
|
try {
|
2014-01-15 20:40:55 -08:00
|
|
|
// TODO: use boot phase
|
2014-06-13 19:00:36 -07:00
|
|
|
mPowerManagerService.systemReady(mActivityManagerService.getAppOpsService());
|
2012-08-21 22:14:26 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Power Manager Service ready", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-08-21 22:14:26 -07:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakePackageManagerServiceReady");
|
2009-03-03 19:31:44 -08:00
|
|
|
try {
|
2014-06-12 22:38:59 -07:00
|
|
|
mPackageManagerService.systemReady();
|
2011-08-22 00:26:20 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Package Manager Service ready", e);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2016-07-21 15:58:24 -07:00
|
|
|
traceBeginAndSlog("MakeDisplayManagerServiceReady");
|
2012-08-28 03:27:37 -07:00
|
|
|
try {
|
2014-01-16 22:16:42 -08:00
|
|
|
// TODO: use boot phase and communicate these flags some other way
|
2014-06-12 22:38:59 -07:00
|
|
|
mDisplayManagerService.systemReady(safeMode, mOnlyCore);
|
2012-08-28 03:27:37 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Display Manager Service ready", e);
|
|
|
|
}
|
2016-07-21 15:58:24 -07:00
|
|
|
traceEnd();
|
2012-08-28 03:27:37 -07:00
|
|
|
|
2015-04-08 13:56:34 +09:00
|
|
|
mSystemServiceManager.setSafeMode(safeMode);
|
|
|
|
|
2009-09-02 13:26:28 -07:00
|
|
|
// These are needed to propagate to the runnable below.
|
2011-06-29 10:45:16 -07:00
|
|
|
final NetworkManagementService networkManagementF = networkManagement;
|
2011-05-24 18:39:45 -07:00
|
|
|
final NetworkStatsService networkStatsF = networkStats;
|
2011-05-20 15:29:23 -07:00
|
|
|
final NetworkPolicyManagerService networkPolicyF = networkPolicy;
|
2009-09-02 13:26:28 -07:00
|
|
|
final ConnectivityService connectivityF = connectivity;
|
2014-04-16 17:29:40 -07:00
|
|
|
final NetworkScoreService networkScoreF = networkScore;
|
2010-02-22 16:36:44 -05:00
|
|
|
final LocationManagerService locationF = location;
|
2010-07-13 15:32:16 +08:00
|
|
|
final CountryDetectorService countryDetectorF = countryDetector;
|
2010-09-13 16:24:08 -07:00
|
|
|
final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater;
|
2012-02-01 15:23:33 -08:00
|
|
|
final CommonTimeManagementService commonTimeMgmtServiceF = commonTimeMgmtService;
|
2012-04-17 16:52:41 -07:00
|
|
|
final InputManagerService inputManagerF = inputManager;
|
2012-09-20 10:09:45 -07:00
|
|
|
final TelephonyRegistry telephonyRegistryF = telephonyRegistry;
|
2013-11-07 00:30:16 -08:00
|
|
|
final MediaRouterService mediaRouterF = mediaRouter;
|
2014-07-24 12:56:45 -07:00
|
|
|
final MmsServiceBroker mmsServiceF = mmsService;
|
2017-03-01 18:55:06 -08:00
|
|
|
final IpSecService ipSecServiceF = ipSecService;
|
2009-12-04 10:31:43 -08:00
|
|
|
|
2009-09-02 13:26:28 -07:00
|
|
|
// We now tell the activity manager it is okay to run third party
|
|
|
|
// code. It will call back into us once it has gotten to the state
|
|
|
|
// where third party code can really run (but before it has actually
|
|
|
|
// started launching the initial applications), for us to complete our
|
|
|
|
// initialization.
|
2016-12-07 13:03:17 -08:00
|
|
|
mActivityManagerService.systemReady(() -> {
|
|
|
|
Slog.i(TAG, "Making services ready");
|
|
|
|
traceBeginAndSlog("StartActivityManagerReadyPhase");
|
|
|
|
mSystemServiceManager.startBootPhase(
|
|
|
|
SystemService.PHASE_ACTIVITY_MANAGER_READY);
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("StartObservingNativeCrashes");
|
|
|
|
try {
|
|
|
|
mActivityManagerService.startObservingNativeCrashes();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("observing native crashes", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
2014-02-21 14:06:47 -08:00
|
|
|
|
2017-01-27 11:30:19 -08:00
|
|
|
// No dependency on Webview preparation in system server. But this should
|
|
|
|
// be completed before allowring 3rd party
|
|
|
|
final String WEBVIEW_PREPARATION = "WebViewFactoryPreparation";
|
|
|
|
Future<?> webviewPrep = null;
|
2016-12-07 13:03:17 -08:00
|
|
|
if (!mOnlyCore) {
|
2017-01-27 11:30:19 -08:00
|
|
|
webviewPrep = SystemServerInitThreadPool.get().submit(() -> {
|
|
|
|
Slog.i(TAG, WEBVIEW_PREPARATION);
|
|
|
|
BootTimingsTraceLog traceLog = new BootTimingsTraceLog(
|
2017-02-01 12:09:58 -08:00
|
|
|
SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
|
2017-01-27 11:30:19 -08:00
|
|
|
traceLog.traceBegin(WEBVIEW_PREPARATION);
|
Zygote: Explicitly preload secondary zygote resources.
We now turn on lazy preloading (see companion change 73c7df1bda76a0)
and explicitly preload zygote resources.
To provide the most benefit :
- We start the preload in the system_server, which means the system_server
starts quicker since it has one less preload to wait for. Morever, the
64 bit zygote also starts quicker because it has one less high
priority process to contend with for CPU and I/O.
- We start the preload after the core system services start up, since we
know no 32 bit zygote processes will be requested before that point.
- We start the preload ~1s before the webview factory preparation, to
ensure that it completes before the 32 bit relro process is forked
from the zygote. In the event that it takes too long, the webview
RELRO process will block, but it will do so without holding any locks.
I have not observed this happening in > 200 runs on marlin / sailfish
devices.
This change saves about 500ms in boot times, and sometimes even more.
AFTER:
successive-online : 16970.0,16668.0,16391.0,16498.0,17601.0,16736.0,16609.0,16820.0,16310.0,17557.0,
successive-online_avg : 16816.0
successive-boot : 28750.0,29520.0,29372.0,28424.0,30683.0,28523.0,29766.0,29779.0,29304.0,31607.0,
successive-boot_avg : 29572.8
BEFORE:
successive-online : 16678.0,18105.0,17197.0,16744.0,17453.0,16946.0,18068.0,16719.0,17453.0,16942.0,
successive-online_avg : 17230.5
successive-boot : 30855.0,32069.0,31223.0,30918.0,30284.0,29750.0,31036.0,30778.0,30310.0,30908.0,
successive-boot_avg : 30813.1
Note that successive-online is a little faster, as expected since we do
less work in the 32 bit zygote.
Test: manual, timings from tradefed.
Bug: 34810190
Change-Id: I90207a2706afda163b8134ff2af31f6917f3841b
2017-02-06 20:24:08 +00:00
|
|
|
ConcurrentUtils.waitForFutureNoInterrupt(mZygotePreload, "Zygote preload");
|
|
|
|
mZygotePreload = null;
|
2017-01-27 11:30:19 -08:00
|
|
|
mWebViewUpdateService.prepareWebViewInSystemServer();
|
|
|
|
traceLog.traceEnd();
|
|
|
|
}, WEBVIEW_PREPARATION);
|
2016-12-07 13:03:17 -08:00
|
|
|
}
|
2014-07-25 18:03:16 +01:00
|
|
|
|
2016-12-07 13:03:17 -08:00
|
|
|
traceBeginAndSlog("StartSystemUI");
|
|
|
|
try {
|
|
|
|
startSystemUi(context);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting System UI", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeNetworkScoreReady");
|
|
|
|
try {
|
|
|
|
if (networkScoreF != null) networkScoreF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Score Service ready", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeNetworkManagementServiceReady");
|
|
|
|
try {
|
|
|
|
if (networkManagementF != null) networkManagementF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Managment Service ready", e);
|
|
|
|
}
|
|
|
|
CountDownLatch networkPolicyInitReadySignal = null;
|
|
|
|
if (networkPolicyF != null) {
|
|
|
|
networkPolicyInitReadySignal = networkPolicyF
|
|
|
|
.networkScoreAndNetworkManagementServiceReady();
|
|
|
|
}
|
|
|
|
traceEnd();
|
2017-04-05 10:15:04 -07:00
|
|
|
traceBeginAndSlog("MakeIpSecServiceReady");
|
|
|
|
try {
|
|
|
|
if (ipSecServiceF != null) ipSecServiceF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making IpSec Service ready", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
2016-12-07 13:03:17 -08:00
|
|
|
traceBeginAndSlog("MakeNetworkStatsServiceReady");
|
|
|
|
try {
|
|
|
|
if (networkStatsF != null) networkStatsF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Stats Service ready", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeConnectivityServiceReady");
|
|
|
|
try {
|
|
|
|
if (connectivityF != null) connectivityF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Connectivity Service ready", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeNetworkPolicyServiceReady");
|
|
|
|
try {
|
2016-12-02 16:24:35 -08:00
|
|
|
if (networkPolicyF != null) {
|
2016-12-07 13:03:17 -08:00
|
|
|
networkPolicyF.systemReady(networkPolicyInitReadySignal);
|
2014-02-21 14:06:47 -08:00
|
|
|
}
|
2016-12-07 13:03:17 -08:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Policy Service ready", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
2014-02-21 14:06:47 -08:00
|
|
|
|
2016-12-07 13:03:17 -08:00
|
|
|
traceBeginAndSlog("StartWatchdog");
|
|
|
|
Watchdog.getInstance().start();
|
|
|
|
traceEnd();
|
2016-03-14 11:17:41 -07:00
|
|
|
|
Reconcile apps in 2 phases
During boot app data folders are reconciled in 2 phases:
- in the constructor only core apps are reconciled. prepareAppData
for remaining apps is deferred and run on a separate thread (phase 2)
- Phase 2 must finish before third-party apps can start
Also moved GC to final stages of system server init. GC alone takes ~200 ms.
Overall boot time improvement: ~1 second
Before:
02-17 18:33:33 D/BaseBootTest: successive-boot :
28835.0,29638.0,30205.0,29793.0,29752.0,28228.0,30125.0,28983.0,28487.0,28865.0,
02-17 18:33:33 D/BaseBootTest: successive-boot_avg : 29291.1
02-17 18:33:33 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService :
3150.0,3615.0,3515.0,3495.0,3814.0,3158.0,3746.0,3274.0,3222.0,3607.0,
02-17 18:33:33 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService_avg : 3459.6
02-17 18:33:33 D/BaseBootTest: SystemServerTiming_StartServices :
8244.0,8863.0,9035.0,9832.0,8998.0,8096.0,8719.0,8209.0,8279.0,8754.0,
02-17 18:33:33 D/BaseBootTest: SystemServerTiming_StartServices_avg :
8702.9
After:
02-17 17:59:51 D/BaseBootTest: successive-boot :
27711.0,27607.0,28408.0,28968.0,28397.0,28063.0,27885.0,28483.0,27917.0,29317.0,
02-17 17:59:51 D/BaseBootTest: successive-boot_avg : 28275.6
02-17 17:59:51 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService :
2467.0,2489.0,2369.0,2548.0,2647.0,2523.0,2497.0,2553.0,2482.0,2657.0,
02-17 17:59:51 D/BaseBootTest:
SystemServerTiming_StartPackageManagerService_avg : 2523.2
02-17 17:59:51 D/BaseBootTest: SystemServerTiming_StartServices :
7686.0,7538.0,7598.0,7869.0,7884.0,7950.0,7971.0,8370.0,7696.0,7885.0,
02-17 17:59:51 D/BaseBootTest: SystemServerTiming_StartServices_avg :
7844.7
Test: manual
Bug: 28750609
Change-Id: I3543ef577af1365394775318e40907584ddbe950
2017-02-07 11:25:14 -08:00
|
|
|
// Wait for all packages to be prepared
|
|
|
|
mPackageManagerService.waitForAppDataPrepared();
|
|
|
|
|
2016-12-07 13:03:17 -08:00
|
|
|
// It is now okay to let the various system services start their
|
|
|
|
// third party code...
|
|
|
|
traceBeginAndSlog("PhaseThirdPartyAppsCanStart");
|
2017-02-01 12:09:58 -08:00
|
|
|
// confirm webview completion before starting 3rd party
|
|
|
|
if (webviewPrep != null) {
|
|
|
|
ConcurrentUtils.waitForFutureNoInterrupt(webviewPrep, WEBVIEW_PREPARATION);
|
|
|
|
}
|
2016-12-07 13:03:17 -08:00
|
|
|
mSystemServiceManager.startBootPhase(
|
|
|
|
SystemService.PHASE_THIRD_PARTY_APPS_CAN_START);
|
|
|
|
traceEnd();
|
2016-07-21 15:58:24 -07:00
|
|
|
|
2016-12-07 13:03:17 -08:00
|
|
|
traceBeginAndSlog("MakeLocationServiceReady");
|
|
|
|
try {
|
|
|
|
if (locationF != null) locationF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying Location Service running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeCountryDetectionServiceReady");
|
|
|
|
try {
|
|
|
|
if (countryDetectorF != null) countryDetectorF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying CountryDetectorService running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeNetworkTimeUpdateReady");
|
|
|
|
try {
|
|
|
|
if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying NetworkTimeService running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeCommonTimeManagementServiceReady");
|
|
|
|
try {
|
|
|
|
if (commonTimeMgmtServiceF != null) {
|
|
|
|
commonTimeMgmtServiceF.systemRunning();
|
First checkin of incident reporting.
There are a few major pieces here:
incidentd
---------
This daemon (started by init) runs and accepts incoming requests to take
incident reports. When prompted, it calls into various system services
and fills in an IncidentProto data structure, and then writes the report
into dropbox.
The next steps for incidentd:
- Security review of SELinux policies. These will be a subset of
the dumpstate permissions. Until this is done, incidentd is
not started at boot time.
incident
--------
This shell command calls into incidentd, and can initiate an incident
report and either capture the output or leave for dropbox.
incident_report
---------------
This host side tool can call adb shell with the correct parameters
and also format the incident report as text. This formatting code
was left of the device on purpose. Right now it's pretty small, but
as the number of fields increases, the metadata and code to do the
formatting will start to grow.
The incident_report command also contains a workaround to let it
work before incidentd is turned on by default. Right now, it is
implemented to call adb shell dumpsys <service> --proto directly,
whereas in the future it will go through the full incidentd flow.
incident_section_gen
--------------------
A build-time tool that generates a stripped down set of information
about the fields that are available.
libincident
-----------
This library contains the code to connect to incidentd, and the
meta proto definitions that are used by the framework protos.
The basics are here now, but they are not fully fleshed out yet.
The privacy.proto file contains annotations that can go in the
proto file that we will later use to filter which fields are
uploaded, and which are used by local sources. For example, a
device in a test lab is safe to upload much much more information
than a real user. These will share the same mechanism, but the
user's output will be filtered according to these annotations.
frameworks/core/proto
---------------------
These .proto files contain the definitions of the system's
output. There is one master android.os.IncidentProto file that
is the top level of an incident report, but some other services
(notification, fingerprint, batterystats, etc) will have others
that are used directly by the logging mechanism.
Other files which are shared by several of the services also go
here, such as ComponentName, Locale, Configuration, etc. There
will be many more.
There is also a first iplementation of a dump method handling
--proto in the fingerprint service.
IncidentManager
---------------
The java API to trigger an incident report.
Test: Not written yet
Change-Id: I59568b115ac7fcf73af70c946c95752bf33ae67f
2016-11-21 17:51:35 -08:00
|
|
|
}
|
2016-12-07 13:03:17 -08:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying CommonTimeManagementService running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeInputManagerServiceReady");
|
|
|
|
try {
|
|
|
|
// TODO(BT) Pass parameter to input manager
|
|
|
|
if (inputManagerF != null) inputManagerF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying InputManagerService running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeTelephonyRegistryReady");
|
|
|
|
try {
|
|
|
|
if (telephonyRegistryF != null) telephonyRegistryF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying TelephonyRegistry running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeMediaRouterServiceReady");
|
|
|
|
try {
|
|
|
|
if (mediaRouterF != null) mediaRouterF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying MediaRouterService running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("MakeMmsServiceReady");
|
|
|
|
try {
|
|
|
|
if (mmsServiceF != null) mmsServiceF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying MmsService running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
First checkin of incident reporting.
There are a few major pieces here:
incidentd
---------
This daemon (started by init) runs and accepts incoming requests to take
incident reports. When prompted, it calls into various system services
and fills in an IncidentProto data structure, and then writes the report
into dropbox.
The next steps for incidentd:
- Security review of SELinux policies. These will be a subset of
the dumpstate permissions. Until this is done, incidentd is
not started at boot time.
incident
--------
This shell command calls into incidentd, and can initiate an incident
report and either capture the output or leave for dropbox.
incident_report
---------------
This host side tool can call adb shell with the correct parameters
and also format the incident report as text. This formatting code
was left of the device on purpose. Right now it's pretty small, but
as the number of fields increases, the metadata and code to do the
formatting will start to grow.
The incident_report command also contains a workaround to let it
work before incidentd is turned on by default. Right now, it is
implemented to call adb shell dumpsys <service> --proto directly,
whereas in the future it will go through the full incidentd flow.
incident_section_gen
--------------------
A build-time tool that generates a stripped down set of information
about the fields that are available.
libincident
-----------
This library contains the code to connect to incidentd, and the
meta proto definitions that are used by the framework protos.
The basics are here now, but they are not fully fleshed out yet.
The privacy.proto file contains annotations that can go in the
proto file that we will later use to filter which fields are
uploaded, and which are used by local sources. For example, a
device in a test lab is safe to upload much much more information
than a real user. These will share the same mechanism, but the
user's output will be filtered according to these annotations.
frameworks/core/proto
---------------------
These .proto files contain the definitions of the system's
output. There is one master android.os.IncidentProto file that
is the top level of an incident report, but some other services
(notification, fingerprint, batterystats, etc) will have others
that are used directly by the logging mechanism.
Other files which are shared by several of the services also go
here, such as ComponentName, Locale, Configuration, etc. There
will be many more.
There is also a first iplementation of a dump method handling
--proto in the fingerprint service.
IncidentManager
---------------
The java API to trigger an incident report.
Test: Not written yet
Change-Id: I59568b115ac7fcf73af70c946c95752bf33ae67f
2016-11-21 17:51:35 -08:00
|
|
|
|
2016-12-07 13:03:17 -08:00
|
|
|
traceBeginAndSlog("MakeNetworkScoreServiceReady");
|
|
|
|
try {
|
|
|
|
if (networkScoreF != null) networkScoreF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying NetworkScoreService running", e);
|
2009-09-02 13:26:28 -07:00
|
|
|
}
|
2016-12-07 13:03:17 -08:00
|
|
|
traceEnd();
|
|
|
|
traceBeginAndSlog("IncidentDaemonReady");
|
|
|
|
try {
|
|
|
|
// TODO: Switch from checkService to getService once it's always
|
|
|
|
// in the build and should reliably be there.
|
|
|
|
final IIncidentManager incident = IIncidentManager.Stub.asInterface(
|
|
|
|
ServiceManager.checkService("incident"));
|
|
|
|
if (incident != null) incident.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying incident daemon running", e);
|
|
|
|
}
|
|
|
|
traceEnd();
|
|
|
|
}, BOOT_TIMINGS_TRACE_LOG);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2010-10-21 11:09:02 -04:00
|
|
|
|
|
|
|
static final void startSystemUi(Context context) {
|
|
|
|
Intent intent = new Intent();
|
|
|
|
intent.setComponent(new ComponentName("com.android.systemui",
|
|
|
|
"com.android.systemui.SystemUIService"));
|
2015-12-21 14:16:43 -07:00
|
|
|
intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
|
2012-11-27 19:12:23 -08:00
|
|
|
//Slog.d(TAG, "Starting service: " + intent);
|
2015-04-28 14:21:43 -07:00
|
|
|
context.startServiceAsUser(intent, UserHandle.SYSTEM);
|
2010-10-21 11:09:02 -04:00
|
|
|
}
|
2015-06-30 17:07:32 +09:00
|
|
|
|
|
|
|
private static void traceBeginAndSlog(String name) {
|
|
|
|
Slog.i(TAG, name);
|
2016-11-17 11:44:49 -08:00
|
|
|
BOOT_TIMINGS_TRACE_LOG.traceBegin(name);
|
2016-07-21 15:58:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void traceEnd() {
|
2016-11-17 11:44:49 -08:00
|
|
|
BOOT_TIMINGS_TRACE_LOG.traceEnd();
|
2015-06-30 17:07:32 +09:00
|
|
|
}
|
2015-11-05 16:54:09 +00:00
|
|
|
}
|