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;
|
|
|
|
|
|
|
|
import android.app.ActivityManagerNative;
|
2014-01-15 20:40:55 -08:00
|
|
|
import android.app.ActivityThread;
|
2013-12-05 16:48:06 -08:00
|
|
|
import android.app.IAlarmManager;
|
|
|
|
import android.app.INotificationManager;
|
2014-07-16 19:09:13 -07:00
|
|
|
import android.app.usage.UsageStatsManagerInternal;
|
2009-10-08 00:12:45 +02:00
|
|
|
import android.bluetooth.BluetoothAdapter;
|
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;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.content.pm.IPackageManager;
|
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;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.media.AudioService;
|
2014-05-30 16:57:43 -07:00
|
|
|
import android.media.tv.TvInputManager;
|
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;
|
2012-08-28 03:27:37 -07:00
|
|
|
import android.os.Handler;
|
2013-12-20 13:27:30 -08:00
|
|
|
import android.os.IBinder;
|
2014-01-15 20:40:55 -08:00
|
|
|
import android.os.IPowerManager;
|
2010-06-09 15:45:18 -05:00
|
|
|
import android.os.Looper;
|
|
|
|
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;
|
2012-10-19 18:23:52 -07:00
|
|
|
import android.os.UserHandle;
|
2012-09-28 16:31:34 -07:00
|
|
|
import android.service.dreams.DreamService;
|
2010-10-04 15:27:22 -04:00
|
|
|
import android.util.DisplayMetrics;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.util.EventLog;
|
2011-08-22 00:26:20 -07:00
|
|
|
import android.util.Log;
|
2010-02-26 18:56:32 -08:00
|
|
|
import android.util.Slog;
|
2010-10-12 13:12:18 -07:00
|
|
|
import android.view.WindowManager;
|
2014-05-08 16:07:05 +01:00
|
|
|
import android.webkit.WebViewFactory;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
import com.android.internal.R;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.internal.os.BinderInternal;
|
2014-03-31 13:41:26 +01:00
|
|
|
import com.android.internal.os.Zygote;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.internal.os.SamplingProfilerIntegration;
|
2014-03-17 12:54:03 -07:00
|
|
|
import com.android.server.accessibility.AccessibilityManagerService;
|
2012-11-15 14:01:46 -08:00
|
|
|
import com.android.server.accounts.AccountManagerService;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.am.ActivityManagerService;
|
Power manager rewrite.
The major goal of this rewrite is to make it easier to implement
power management policies correctly. According, the new
implementation primarily uses state-based rather than event-based
triggers for applying changes to the current power state.
For example, when an application requests that the proximity
sensor be used to manage the screen state (by way of a wake lock),
the power manager makes note of the fact that the set of
wake locks changed. Then it executes a common update function
that recalculates the entire state, first looking at wake locks,
then considering user activity, and eventually determining whether
the screen should be turned on or off. At this point it may
make a request to a component called the DisplayPowerController
to asynchronously update the display's powe state. Likewise,
DisplayPowerController makes note of the updated power request
and schedules its own update function to figure out what needs
to be changed.
The big benefit of this approach is that it's easy to mutate
multiple properties of the power state simultaneously then
apply their joint effects together all at once. Transitions
between states are detected and resolved by the update in
a consistent manner.
The new power manager service has is implemented as a set of
loosely coupled components. For the most part, information
only flows one way through these components (by issuing a
request to that component) although some components support
sending a message back to indicate when the work has been
completed. For example, the DisplayPowerController posts
a callback runnable asynchronously to tell the PowerManagerService
when the display is ready. An important feature of this
approach is that each component neatly encapsulates its
state and maintains its own invariants. Moreover, we do
not need to worry about deadlocks or awkward mutual exclusion
semantics because most of the requests are asynchronous.
The benefits of this design are especially apparent in
the implementation of the screen on / off and brightness
control animations which are able to take advantage of
framework features like properties, ObjectAnimator
and Choreographer.
The screen on / off animation is now the responsibility
of the power manager (instead of surface flinger). This change
makes it much easier to ensure that the animation is properly
coordinated with other power state changes and eliminates
the cause of race conditions in the older implementation.
The because of the userActivity() function has been changed
so that it never wakes the device from sleep. This change
removes ambiguity around forcing or disabling user activity
for various purposes. To wake the device, use wakeUp().
To put it to sleep, use goToSleep(). Simple.
The power manager service interface and API has been significantly
simplified and consolidated. Also fixed some inconsistencies
related to how the minimum and maximum screen brightness setting
was presented in brightness control widgets and enforced behind
the scenes.
At present the following features are implemented:
- Wake locks.
- User activity.
- Wake up / go to sleep.
- Power state broadcasts.
- Battery stats and event log notifications.
- Dreams.
- Proximity screen off.
- Animated screen on / off transitions.
- Auto-dimming.
- Auto-brightness control for the screen backlight with
different timeouts for ramping up versus ramping down.
- Auto-on when plugged or unplugged.
- Stay on when plugged.
- Device administration maximum user activity timeout.
- Application controlled brightness via window manager.
The following features are not yet implemented:
- Reduced user activity timeout for the key guard.
- Reduced user activity timeout for the phone application.
- Coordinating screen on barriers with the window manager.
- Preventing auto-rotation during power state changes.
- Auto-brightness adjustment setting (feature was disabled
in previous version of the power manager service pending
an improved UI design so leaving it out for now).
- Interpolated brightness control (a proposed new scheme
for more compactly specifying auto-brightness levels
in config.xml).
- Button / keyboard backlight control.
- Change window manager to associated WorkSource with
KEEP_SCREEN_ON_FLAG wake lock instead of talking
directly to the battery stats service.
- Optionally support animating screen brightness when
turning on/off instead of playing electron beam animation
(config_animateScreenLights).
Change-Id: I1d7a52e98f0449f76d70bf421f6a7f245957d1d7
2012-07-27 15:51:34 -07:00
|
|
|
import com.android.server.am.BatteryStatsService;
|
2013-11-06 14:54:50 -08:00
|
|
|
import com.android.server.clipboard.ClipboardService;
|
2012-11-15 14:01:46 -08:00
|
|
|
import com.android.server.content.ContentService;
|
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;
|
2012-09-25 18:58:48 -07:00
|
|
|
import com.android.server.dreams.DreamManagerService;
|
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.LightsManager;
|
|
|
|
import com.android.server.lights.LightsService;
|
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;
|
2012-11-15 14:01:46 -08:00
|
|
|
import com.android.server.os.SchedulingPolicyService;
|
2014-04-28 22:11:01 -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;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.pm.PackageManagerService;
|
2012-08-10 17:06:33 -07:00
|
|
|
import com.android.server.pm.UserManagerService;
|
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;
|
2012-11-15 14:01:46 -08:00
|
|
|
import com.android.server.search.SearchManagerService;
|
2013-12-05 16:48:06 -08:00
|
|
|
import com.android.server.statusbar.StatusBarManagerService;
|
|
|
|
import com.android.server.storage.DeviceStorageMonitorService;
|
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;
|
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;
|
2011-05-19 17:12:49 -07:00
|
|
|
import com.android.server.usb.UsbService;
|
2013-11-06 14:54:50 -08:00
|
|
|
import com.android.server.wallpaper.WallpaperManagerService;
|
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;
|
|
|
|
|
2009-09-11 16:40:01 -07:00
|
|
|
import java.io.File;
|
2009-09-04 18:31:17 -07:00
|
|
|
import java.util.Timer;
|
|
|
|
import java.util.TimerTask;
|
|
|
|
|
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
|
|
|
|
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";
|
2014-02-14 17:19:56 -08:00
|
|
|
private static final String USB_SERVICE_CLASS =
|
|
|
|
"com.android.server.usb.UsbService$Lifecycle";
|
2014-02-19 12:29:58 -08:00
|
|
|
private static final String WIFI_SERVICE_CLASS =
|
|
|
|
"com.android.server.wifi.WifiService";
|
2014-04-10 11:45:42 -07:00
|
|
|
private static final String WIFI_PASSPOINT_SERVICE_CLASS =
|
2014-05-30 18:54:55 -07:00
|
|
|
"com.android.server.wifi.passpoint.WifiPasspointService";
|
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";
|
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
|
|
|
|
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 Installer mInstaller;
|
|
|
|
private PowerManagerService mPowerManagerService;
|
|
|
|
private ActivityManagerService mActivityManagerService;
|
|
|
|
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;
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
private boolean mOnlyCore;
|
|
|
|
private boolean mFirstBoot;
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
/**
|
|
|
|
* Called to initialize native system services.
|
|
|
|
*/
|
|
|
|
private static native void nativeInit();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
private void run() {
|
|
|
|
// 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
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// Here we go!
|
|
|
|
Slog.i(TAG, "Entered the Android system server!");
|
|
|
|
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, SystemClock.uptimeMillis());
|
|
|
|
|
|
|
|
// In case the runtime switched since last boot (such as when
|
|
|
|
// the old runtime was removed in an OTA), set the system
|
|
|
|
// property so that it is in sync. We can't do this in
|
|
|
|
// 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
|
2014-05-28 14:31:47 -07:00
|
|
|
SystemProperties.set("persist.sys.dalvik.vm.lib.2", VMRuntime.getRuntime().vmLibrary());
|
2014-01-15 20:40:55 -08:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// Mmmmmm... more memory!
|
|
|
|
VMRuntime.getRuntime().clearGrowthLimit();
|
|
|
|
|
|
|
|
// 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-04-09 18:07:19 -07:00
|
|
|
// Some devices rely on runtime fingerprint generation, so make sure
|
|
|
|
// we've defined it before booting further.
|
|
|
|
Build.ensureFingerprintProperty();
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// Within the system server, it is an error to access Environment paths without
|
|
|
|
// explicitly specifying a user.
|
|
|
|
Environment.setUserRequired(true);
|
|
|
|
|
|
|
|
// Ensure binder calls into the system always run at foreground priority.
|
2009-12-07 17:59:37 -08:00
|
|
|
BinderInternal.disableBackgroundScheduling(true);
|
2014-01-15 20:40:55 -08:00
|
|
|
|
|
|
|
// Prepare the main looper thread (this thread).
|
|
|
|
android.os.Process.setThreadPriority(
|
|
|
|
android.os.Process.THREAD_PRIORITY_FOREGROUND);
|
2010-06-30 17:46:30 -07:00
|
|
|
android.os.Process.setCanSelfBackground(false);
|
2014-01-15 20:40:55 -08:00
|
|
|
Looper.prepareMainLooper();
|
|
|
|
|
|
|
|
// Initialize native services.
|
|
|
|
System.loadLibrary("android_servers");
|
|
|
|
nativeInit();
|
2010-05-28 01:54:03 -07:00
|
|
|
|
2010-09-22 10:36:48 -07:00
|
|
|
// Check whether we failed to shut down last time we tried.
|
2014-01-15 20:40:55 -08:00
|
|
|
// This call may not return.
|
|
|
|
performPendingShutdown();
|
|
|
|
|
|
|
|
// Initialize the system context.
|
|
|
|
createSystemContext();
|
|
|
|
|
|
|
|
// Create the system service manager.
|
|
|
|
mSystemServiceManager = new SystemServiceManager(mSystemContext);
|
2014-02-10 19:47:07 -08:00
|
|
|
LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
|
2014-01-15 20:40:55 -08:00
|
|
|
|
|
|
|
// Start services.
|
|
|
|
try {
|
|
|
|
startBootstrapServices();
|
2014-01-16 22:16:42 -08:00
|
|
|
startCoreServices();
|
2014-01-15 20:40:55 -08:00
|
|
|
startOtherServices();
|
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;
|
|
|
|
}
|
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.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop forever.
|
|
|
|
Looper.loop();
|
|
|
|
throw new RuntimeException("Main thread loop unexpectedly exited");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void reportWtf(String msg, Throwable e) {
|
|
|
|
Slog.w(TAG, "***********************************************");
|
|
|
|
Log.wtf(TAG, "BOOT FAILURE " + msg, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ShutdownThread.rebootOrShutdown(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();
|
2014-04-01 14:57:39 -07:00
|
|
|
mSystemContext.setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
|
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() {
|
|
|
|
// 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.
|
|
|
|
mInstaller = mSystemServiceManager.startService(Installer.class);
|
2010-09-22 10:36:48 -07:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
// Activity manager runs the show.
|
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-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).
|
|
|
|
mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);
|
|
|
|
|
|
|
|
// Now that the power manager has been started, let the activity manager
|
|
|
|
// initialize power management features.
|
|
|
|
mActivityManagerService.initPowerManagement();
|
|
|
|
|
2014-01-16 22:16:42 -08:00
|
|
|
// Display manager is needed to provide display metrics before package manager
|
|
|
|
// starts up.
|
|
|
|
mDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class);
|
2014-06-12 22:38:59 -07:00
|
|
|
|
|
|
|
// We need the default display before we can initialize the package manager.
|
|
|
|
mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
Slog.i(TAG, "Package Manager");
|
|
|
|
mPackageManagerService = PackageManagerService.main(mSystemContext, mInstaller,
|
|
|
|
mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF, mOnlyCore);
|
|
|
|
mFirstBoot = mPackageManagerService.isFirstBoot();
|
|
|
|
mPackageManager = mSystemContext.getPackageManager();
|
|
|
|
|
2014-07-23 17:34:34 -07:00
|
|
|
Slog.i(TAG, "User Service");
|
|
|
|
ServiceManager.addService(Context.USER_SERVICE, UserManagerService.getInstance());
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
// Initialize attribute cache used to cache resources from packages.
|
|
|
|
AttributeCache.init(mSystemContext);
|
|
|
|
|
|
|
|
// Set up the Application instance for the system process and get started.
|
|
|
|
mActivityManagerService.setSystemProcess();
|
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() {
|
|
|
|
// Manages LEDs and display backlight.
|
|
|
|
mSystemServiceManager.startService(LightsService.class);
|
|
|
|
|
2014-06-13 19:00:36 -07:00
|
|
|
// Tracks the battery level. Requires LightService.
|
|
|
|
mSystemServiceManager.startService(BatteryService.class);
|
2014-07-16 19:09:13 -07:00
|
|
|
|
|
|
|
// Tracks application usage stats.
|
|
|
|
mSystemServiceManager.startService(UsageStatsService.class);
|
|
|
|
mActivityManagerService.setUsageStatsManager(
|
|
|
|
LocalServices.getService(UsageStatsManagerInternal.class));
|
2014-07-29 19:14:24 +01:00
|
|
|
|
|
|
|
// Tracks whether the updatable WebView is in a ready state and watches for update installs.
|
|
|
|
mSystemServiceManager.startService(WebViewUpdateService.class);
|
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-07-30 12:58:03 -07:00
|
|
|
AccountManagerService accountManager = null;
|
|
|
|
ContentService contentService = null;
|
2012-04-13 20:38:38 -07:00
|
|
|
VibratorService vibrator = null;
|
2013-12-05 16:48:06 -08:00
|
|
|
IAlarmManager alarm = null;
|
2012-09-07 23:16:01 -07:00
|
|
|
MountService mountService = null;
|
2011-05-19 17:12:49 -07:00
|
|
|
NetworkManagementService networkManagement = 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;
|
2012-04-12 00:02:00 -07:00
|
|
|
BluetoothManagerService bluetooth = null;
|
2010-12-09 22:30:37 -08:00
|
|
|
UsbService usb = 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-05-06 10:49:04 -07:00
|
|
|
AudioService audioService = null;
|
2014-07-24 12:56:45 -07:00
|
|
|
MmsServiceBroker mmsService = 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 disableMedia = SystemProperties.getBoolean("config.disable_media", false);
|
|
|
|
boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false);
|
|
|
|
boolean disableTelephony = SystemProperties.getBoolean("config.disable_telephony", 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-06-10 14:51:30 +09:00
|
|
|
boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1");
|
2013-03-28 18:10:43 -07:00
|
|
|
|
|
|
|
try {
|
2014-06-30 14:43:28 -07:00
|
|
|
Slog.i(TAG, "Reading configuration...");
|
|
|
|
SystemConfig.getInstance();
|
|
|
|
|
2012-04-23 15:00:43 -07:00
|
|
|
Slog.i(TAG, "Scheduling Policy");
|
2013-09-16 10:57:39 -07:00
|
|
|
ServiceManager.addService("scheduling_policy", new SchedulingPolicyService());
|
2012-04-23 15:00:43 -07:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
Slog.i(TAG, "Telephony Registry");
|
|
|
|
telephonyRegistry = new TelephonyRegistry(context);
|
|
|
|
ServiceManager.addService("telephony.registry", telephonyRegistry);
|
2013-02-13 14:39:30 -08:00
|
|
|
|
2013-03-04 13:05:32 -08:00
|
|
|
Slog.i(TAG, "Entropy Mixer");
|
|
|
|
ServiceManager.addService("entropy", new EntropyMixer(context));
|
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
mContentResolver = context.getContentResolver();
|
|
|
|
|
2009-09-29 20:44:30 -07:00
|
|
|
// The AccountManager must come before the ContentService
|
2009-03-24 22:48:12 -07:00
|
|
|
try {
|
2013-03-28 18:10:43 -07:00
|
|
|
// TODO: seems like this should be disable-able, but req'd by ContentService
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "Account Manager");
|
2012-07-30 12:58:03 -07:00
|
|
|
accountManager = new AccountManagerService(context);
|
|
|
|
ServiceManager.addService(Context.ACCOUNT_SERVICE, accountManager);
|
2009-03-24 22:48:12 -07:00
|
|
|
} catch (Throwable e) {
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.e(TAG, "Failure starting Account Manager", e);
|
2009-03-24 22:48:12 -07:00
|
|
|
}
|
|
|
|
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "Content Manager");
|
2012-07-30 12:58:03 -07:00
|
|
|
contentService = ContentService.main(context,
|
2014-01-15 20:40:55 -08:00
|
|
|
mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL);
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "System Content Providers");
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.installSystemProviders();
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "Vibrator Service");
|
2012-04-13 20:38:38 -07:00
|
|
|
vibrator = new VibratorService(context);
|
|
|
|
ServiceManager.addService("vibrator", vibrator);
|
2009-03-18 17:39:46 -07:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
Slog.i(TAG, "Consumer IR Service");
|
|
|
|
consumerIr = new ConsumerIrService(context);
|
|
|
|
ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr);
|
|
|
|
|
|
|
|
mSystemServiceManager.startService(AlarmManagerService.class);
|
2013-12-05 16:48:06 -08:00
|
|
|
alarm = IAlarmManager.Stub.asInterface(
|
|
|
|
ServiceManager.getService(Context.ALARM_SERVICE));
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "Init Watchdog");
|
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);
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2012-09-20 16:48:17 -07:00
|
|
|
Slog.i(TAG, "Input Manager");
|
2014-01-16 22:16:42 -08:00
|
|
|
inputManager = new InputManagerService(context);
|
2012-09-20 16:48:17 -07:00
|
|
|
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "Window Manager");
|
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,
|
2014-06-12 22:38:59 -07:00
|
|
|
!mFirstBoot, mOnlyCore);
|
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);
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.setWindowManager(wm);
|
2012-09-20 16:48:17 -07:00
|
|
|
|
|
|
|
inputManager.setWindowManagerCallbacks(wm.getInputMonitor());
|
|
|
|
inputManager.start();
|
|
|
|
|
2014-01-16 22:16:42 -08:00
|
|
|
// TODO: Use service dependencies instead.
|
|
|
|
mDisplayManagerService.windowManagerAndInputReady();
|
2009-03-03 19:31:44 -08: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
|
2014-06-10 14:51:30 +09:00
|
|
|
if (isEmulator) {
|
2011-01-17 00:32:33 +01:00
|
|
|
Slog.i(TAG, "No Bluetooh Service (emulator)");
|
2014-01-15 20:40:55 -08:00
|
|
|
} 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 {
|
2012-04-12 00:02:00 -07:00
|
|
|
Slog.i(TAG, "Bluetooth Manager Service");
|
|
|
|
bluetooth = new BluetoothManagerService(context);
|
|
|
|
ServiceManager.addService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE, bluetooth);
|
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;
|
2009-03-03 19:31:44 -08:00
|
|
|
InputMethodManagerService imm = null;
|
2009-08-13 10:20:21 -07:00
|
|
|
WallpaperManagerService wallpaper = null;
|
2010-02-22 16:36:44 -05:00
|
|
|
LocationManagerService location = null;
|
2010-07-13 15:32:16 +08:00
|
|
|
CountryDetectorService countryDetector = null;
|
2011-06-22 16:38:13 +09:00
|
|
|
TextServicesManagerService tsms = null;
|
2012-03-28 11:42:42 -07:00
|
|
|
LockSettingsService lockSettings = null;
|
Pack preloaded framework assets in a texture atlas
When the Android runtime starts, the system preloads a series of assets
in the Zygote process. These assets are shared across all processes.
Unfortunately, each one of these assets is later uploaded in its own
OpenGL texture, once per process. This wastes memory and generates
unnecessary OpenGL state changes.
This CL introduces an asset server that provides an atlas to all processes.
Note: bitmaps used by skia shaders are *not* sampled from the atlas.
It's an uncommon use case and would require extra texture transforms
in the GL shaders.
WHAT IS THE ASSETS ATLAS
The "assets atlas" is a single, shareable graphic buffer that contains
all the system's preloaded bitmap drawables (this includes 9-patches.)
The atlas is made of two distinct objects: the graphic buffer that
contains the actual pixels and the map which indicates where each
preloaded bitmap can be found in the atlas (essentially a pair of
x and y coordinates.)
HOW IS THE ASSETS ATLAS GENERATED
Because we need to support a wide variety of devices and because it
is easy to change the list of preloaded drawables, the atlas is
generated at runtime, during the startup phase of the system process.
There are several steps that lead to the atlas generation:
1. If the device is booting for the first time, or if the device was
updated, we need to find the best atlas configuration. To do so,
the atlas service tries a number of width, height and algorithm
variations that allows us to pack as many assets as possible while
using as little memory as possible. Once a best configuration is found,
it gets written to disk in /data/system/framework_atlas
2. Given a best configuration (algorithm variant, dimensions and
number of bitmaps that can be packed in the atlas), the atlas service
packs all the preloaded bitmaps into a single graphic buffer object.
3. The packing is done using Skia in a temporary native bitmap. The
Skia bitmap is then copied into the graphic buffer using OpenGL ES
to benefit from texture swizzling.
HOW PROCESSES USE THE ATLAS
Whenever a process' hardware renderer initializes its EGL context,
it queries the atlas service for the graphic buffer and the map.
It is important to remember that both the context and the map will
be valid for the lifetime of the hardware renderer (if the system
process goes down, all apps get killed as well.)
Every time the hardware renderer needs to render a bitmap, it first
checks whether the bitmap can be found in the assets atlas. When
the bitmap is part of the atlas, texture coordinates are remapped
appropriately before rendering.
Change-Id: I8eaecf53e7f6a33d90da3d0047c5ceec89ea3af0
2013-04-17 18:54:38 -07:00
|
|
|
AssetAtlasService atlas = 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) {
|
2013-03-28 18:10:43 -07:00
|
|
|
//if (!disableNonCoreServices) { // TODO: View depends on these; mock them?
|
|
|
|
if (true) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Input Method Service");
|
|
|
|
imm = new InputMethodManagerService(context, wm);
|
|
|
|
ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Input Manager Service", e);
|
|
|
|
}
|
2011-08-22 00:26:20 -07:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Accessibility Manager");
|
2014-03-17 12:54:03 -07:00
|
|
|
ServiceManager.addService(Context.ACCESSIBILITY_SERVICE,
|
|
|
|
new AccessibilityManagerService(context));
|
2013-03-28 18:10:43 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Accessibility Manager", e);
|
|
|
|
}
|
2011-08-22 00:26:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
wm.displayReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making display ready", e);
|
|
|
|
}
|
2011-08-25 13:30:53 -07:00
|
|
|
|
2011-08-22 00:26:20 -07:00
|
|
|
try {
|
2014-06-12 22:38:59 -07:00
|
|
|
mPackageManagerService.performBootDexOpt();
|
2011-08-22 00:26:20 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("performing boot dexopt", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
ActivityManagerNative.getDefault().showBootMessage(
|
|
|
|
context.getResources().getText(
|
|
|
|
com.android.internal.R.string.android_upgrading_starting_apps),
|
2013-12-05 16:48:06 -08:00
|
|
|
false);
|
2011-08-22 00:26:20 -07:00
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
|
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 &&
|
|
|
|
!"0".equals(SystemProperties.get("system_init.startmountservice"))) {
|
2012-05-17 13:30:28 -07:00
|
|
|
try {
|
|
|
|
/*
|
|
|
|
* NotificationManagerService is dependant on MountService,
|
|
|
|
* (for media / usb notifications) so we must start MountService first.
|
|
|
|
*/
|
|
|
|
Slog.i(TAG, "Mount Service");
|
|
|
|
mountService = new MountService(context);
|
|
|
|
ServiceManager.addService("mount", mountService);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Mount Service", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "LockSettingsService");
|
|
|
|
lockSettings = new LockSettingsService(context);
|
|
|
|
ServiceManager.addService("lock_settings", lockSettings);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting LockSettingsService service", e);
|
|
|
|
}
|
2012-03-28 11:42:42 -07:00
|
|
|
|
2014-07-01 19:40:41 -07:00
|
|
|
if (!SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("")) {
|
|
|
|
mSystemServiceManager.startService(PersistentDataBlockService.class);
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
// Always start the Device Policy Manager, so that the API is compatible with
|
|
|
|
// API8.
|
|
|
|
mSystemServiceManager.startService(DevicePolicyManagerService.Lifecycle.class);
|
2010-01-12 18:14:19 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableSystemUI) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Status Bar");
|
|
|
|
statusBar = new StatusBarManagerService(context, wm);
|
|
|
|
ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting StatusBarManagerService", e);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Clipboard Service");
|
|
|
|
ServiceManager.addService(Context.CLIPBOARD_SERVICE,
|
|
|
|
new ClipboardService(context));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Clipboard Service", e);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "NetworkManagement Service");
|
|
|
|
networkManagement = NetworkManagementService.create(context);
|
|
|
|
ServiceManager.addService(Context.NETWORKMANAGEMENT_SERVICE, networkManagement);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkManagement Service", e);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Text Service Manager Service");
|
|
|
|
tsms = new TextServicesManagerService(context);
|
|
|
|
ServiceManager.addService(Context.TEXT_SERVICES_MANAGER_SERVICE, tsms);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Text Service Manager Service", e);
|
|
|
|
}
|
2011-06-22 16:38:13 +09:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
2014-03-31 19:12:07 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Network Score Service");
|
|
|
|
networkScore = new NetworkScoreService(context);
|
|
|
|
ServiceManager.addService(Context.NETWORK_SCORE_SERVICE, networkScore);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Network Score Service", e);
|
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "NetworkStats Service");
|
|
|
|
networkStats = new NetworkStatsService(context, networkManagement, alarm);
|
|
|
|
ServiceManager.addService(Context.NETWORK_STATS_SERVICE, networkStats);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkStats Service", e);
|
|
|
|
}
|
2011-05-20 15:29:23 -07:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "NetworkPolicy Service");
|
|
|
|
networkPolicy = new NetworkPolicyManagerService(
|
2014-01-16 22:16:42 -08:00
|
|
|
context, mActivityManagerService,
|
2014-01-15 20:40:55 -08:00
|
|
|
(IPowerManager)ServiceManager.getService(Context.POWER_SERVICE),
|
2013-03-28 18:10:43 -07:00
|
|
|
networkStats, networkManagement);
|
|
|
|
ServiceManager.addService(Context.NETWORK_POLICY_SERVICE, networkPolicy);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkPolicy Service", e);
|
|
|
|
}
|
2010-01-26 06:17:26 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
|
|
|
|
mSystemServiceManager.startService(WIFI_PASSPOINT_SERVICE_CLASS);
|
|
|
|
mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
|
|
|
|
mSystemServiceManager.startService(
|
2014-05-07 21:09:11 -07:00
|
|
|
"com.android.server.wifi.WifiScanningService");
|
|
|
|
|
2014-07-25 17:46:14 -07:00
|
|
|
mSystemServiceManager.startService("com.android.server.wifi.RttService");
|
|
|
|
|
2014-07-04 17:15:54 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET)) {
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS);
|
2014-05-21 16:32:11 -07:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Connectivity Service");
|
|
|
|
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);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Network Service Discovery Service");
|
|
|
|
serviceDiscovery = NsdService.create(context);
|
|
|
|
ServiceManager.addService(
|
|
|
|
Context.NSD_SERVICE, serviceDiscovery);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Service Discovery Service", e);
|
|
|
|
}
|
2012-03-22 17:01:39 -07:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "UpdateLock Service");
|
|
|
|
ServiceManager.addService(Context.UPDATE_LOCK_SERVICE,
|
|
|
|
new UpdateLockService(context));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting UpdateLockService", e);
|
|
|
|
}
|
2012-02-23 14:59:36 -08:00
|
|
|
}
|
|
|
|
|
2012-05-17 13:30:28 -07:00
|
|
|
/*
|
|
|
|
* MountService has a few dependencies: Notification Manager and
|
|
|
|
* AppWidget Provider. Make sure MountService is completely started
|
|
|
|
* first before continuing.
|
|
|
|
*/
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mountService != null && !mOnlyCore) {
|
2012-05-17 13:30:28 -07:00
|
|
|
mountService.waitForAsecScan();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2012-07-30 12:58:03 -07:00
|
|
|
try {
|
|
|
|
if (accountManager != null)
|
|
|
|
accountManager.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Account Manager Service ready", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (contentService != null)
|
|
|
|
contentService.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Content Service ready", e);
|
|
|
|
}
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(NotificationManagerService.class);
|
2013-12-05 16:48:06 -08:00
|
|
|
notification = INotificationManager.Stub.asInterface(
|
|
|
|
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
|
|
|
networkPolicy.bindNotificationManager(notification);
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(DeviceStorageMonitorService.class);
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableLocation) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Location Manager");
|
|
|
|
location = new LocationManagerService(context);
|
|
|
|
ServiceManager.addService(Context.LOCATION_SERVICE, location);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Location Manager", e);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Country Detector");
|
|
|
|
countryDetector = new CountryDetectorService(context);
|
|
|
|
ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Country Detector", e);
|
|
|
|
}
|
2010-07-13 15:32:16 +08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Search Service");
|
|
|
|
ServiceManager.addService(Context.SEARCH_SERVICE,
|
|
|
|
new SearchManagerService(context));
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Search Service", e);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2009-09-11 16:40:01 -07:00
|
|
|
try {
|
2010-02-26 18:56:32 -08:00
|
|
|
Slog.i(TAG, "DropBox Service");
|
2009-10-27 18:23:39 -07:00
|
|
|
ServiceManager.addService(Context.DROPBOX_SERVICE,
|
2009-11-12 11:32:50 -08:00
|
|
|
new DropBoxManagerService(context, new File("/data/system/dropbox")));
|
2009-09-11 16:40:01 -07:00
|
|
|
} catch (Throwable e) {
|
2011-08-22 00:26:20 -07:00
|
|
|
reportWtf("starting DropBoxManagerService", e);
|
2009-09-11 16:40:01 -07:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices && context.getResources().getBoolean(
|
|
|
|
R.bool.config_enableWallpaperService)) {
|
2011-10-31 12:50:12 -04:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Wallpaper Service");
|
2013-11-15 11:01:47 -08:00
|
|
|
wallpaper = new WallpaperManagerService(context);
|
|
|
|
ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper);
|
2011-10-31 12:50:12 -04:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Wallpaper Service", e);
|
2011-08-12 13:55:22 -07:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableMedia && !"0".equals(SystemProperties.get("system_init.startaudioservice"))) {
|
2011-08-17 15:58:52 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Audio Service");
|
2014-05-06 10:49:04 -07:00
|
|
|
audioService = new AudioService(context);
|
|
|
|
ServiceManager.addService(Context.AUDIO_SERVICE, audioService);
|
2011-08-17 15:58:52 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting Audio Service", e);
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2014-05-29 17:48:33 -07:00
|
|
|
mSystemServiceManager.startService(DockObserver.class);
|
2009-08-12 15:15:43 -05:00
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableMedia) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Wired Accessory Manager");
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
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
|
|
|
|
mSystemServiceManager.startService(USB_SERVICE_CLASS);
|
2013-03-28 18:10:43 -07:00
|
|
|
}
|
2011-08-29 20:11:07 -04:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Serial Service");
|
|
|
|
// Serial port support
|
|
|
|
serial = new SerialService(context);
|
|
|
|
ServiceManager.addService(Context.SERIAL_SERVICE, serial);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
Slog.e(TAG, "Failure starting SerialService", e);
|
|
|
|
}
|
2010-06-23 17:36:36 -04:00
|
|
|
}
|
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(TwilightService.class);
|
2012-08-21 22:12:20 -07:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startService(UiModeManagerService.class);
|
2010-03-04 18:41:49 -08:00
|
|
|
|
2014-06-09 19:50:00 -07:00
|
|
|
mSystemServiceManager.startService(JobSchedulerService.class);
|
2014-05-19 13:46:29 -07:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNonCoreServices) {
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_BACKUP)) {
|
|
|
|
mSystemServiceManager.startService(BACKUP_MANAGER_SERVICE_CLASS);
|
2013-03-28 18:10:43 -07:00
|
|
|
}
|
2009-04-29 14:03:25 -07:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS)) {
|
|
|
|
mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS);
|
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)) {
|
|
|
|
mSystemServiceManager.startService(VOICE_RECOGNITION_MANAGER_SERVICE_CLASS);
|
2014-04-04 18:02:06 -07:00
|
|
|
}
|
2010-02-19 17:02:21 -08:00
|
|
|
}
|
2010-10-18 15:29:09 -07:00
|
|
|
|
2010-03-25 16:20:14 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "DiskStats Service");
|
|
|
|
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
|
|
|
}
|
2010-05-28 01:54:03 -07:00
|
|
|
|
|
|
|
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.
|
|
|
|
Slog.i(TAG, "SamplingProfiler Service");
|
|
|
|
ServiceManager.addService("samplingprofiler",
|
|
|
|
new SamplingProfilerService(context));
|
|
|
|
} catch (Throwable e) {
|
2011-08-22 00:26:20 -07:00
|
|
|
reportWtf("starting SamplingProfiler Service", e);
|
2010-05-28 01:54:03 -07:00
|
|
|
}
|
2010-08-06 12:06:04 +08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "NetworkTimeUpdateService");
|
|
|
|
networkTimeUpdater = new NetworkTimeUpdateService(context);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting NetworkTimeUpdate service", e);
|
|
|
|
}
|
2010-09-13 16:24:08 -07:00
|
|
|
}
|
2012-02-01 15:23:33 -08:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableMedia) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "CommonTimeManagementService");
|
|
|
|
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
|
|
|
}
|
2012-05-06 18:32:19 -07:00
|
|
|
|
2013-03-28 18:10:43 -07:00
|
|
|
if (!disableNetwork) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "CertBlacklister");
|
|
|
|
CertBlacklister blacklister = new CertBlacklister(context);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting CertBlacklister", e);
|
|
|
|
}
|
2012-05-06 18:32:19 -07:00
|
|
|
}
|
2013-01-09 18:50:26 -08:00
|
|
|
|
2014-02-24 13:57:53 -08:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
// Dreams (interactive idle-time views, a/k/a screen savers, and doze mode)
|
2014-01-30 23:38:03 -08:00
|
|
|
mSystemServiceManager.startService(DreamManagerService.class);
|
2012-01-30 14:33:52 -05:00
|
|
|
}
|
2013-02-13 14:39:30 -08:00
|
|
|
|
Pack preloaded framework assets in a texture atlas
When the Android runtime starts, the system preloads a series of assets
in the Zygote process. These assets are shared across all processes.
Unfortunately, each one of these assets is later uploaded in its own
OpenGL texture, once per process. This wastes memory and generates
unnecessary OpenGL state changes.
This CL introduces an asset server that provides an atlas to all processes.
Note: bitmaps used by skia shaders are *not* sampled from the atlas.
It's an uncommon use case and would require extra texture transforms
in the GL shaders.
WHAT IS THE ASSETS ATLAS
The "assets atlas" is a single, shareable graphic buffer that contains
all the system's preloaded bitmap drawables (this includes 9-patches.)
The atlas is made of two distinct objects: the graphic buffer that
contains the actual pixels and the map which indicates where each
preloaded bitmap can be found in the atlas (essentially a pair of
x and y coordinates.)
HOW IS THE ASSETS ATLAS GENERATED
Because we need to support a wide variety of devices and because it
is easy to change the list of preloaded drawables, the atlas is
generated at runtime, during the startup phase of the system process.
There are several steps that lead to the atlas generation:
1. If the device is booting for the first time, or if the device was
updated, we need to find the best atlas configuration. To do so,
the atlas service tries a number of width, height and algorithm
variations that allows us to pack as many assets as possible while
using as little memory as possible. Once a best configuration is found,
it gets written to disk in /data/system/framework_atlas
2. Given a best configuration (algorithm variant, dimensions and
number of bitmaps that can be packed in the atlas), the atlas service
packs all the preloaded bitmaps into a single graphic buffer object.
3. The packing is done using Skia in a temporary native bitmap. The
Skia bitmap is then copied into the graphic buffer using OpenGL ES
to benefit from texture swizzling.
HOW PROCESSES USE THE ATLAS
Whenever a process' hardware renderer initializes its EGL context,
it queries the atlas service for the graphic buffer and the map.
It is important to remember that both the context and the map will
be valid for the lifetime of the hardware renderer (if the system
process goes down, all apps get killed as well.)
Every time the hardware renderer needs to render a bitmap, it first
checks whether the bitmap can be found in the assets atlas. When
the bitmap is part of the atlas, texture coordinates are remapped
appropriately before rendering.
Change-Id: I8eaecf53e7f6a33d90da3d0047c5ceec89ea3af0
2013-04-17 18:54:38 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Assets Atlas Service");
|
|
|
|
atlas = new AssetAtlasService(context);
|
|
|
|
ServiceManager.addService(AssetAtlasService.ASSET_ATLAS_SERVICE, atlas);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting AssetAtlasService", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)) {
|
|
|
|
mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS);
|
2013-06-11 15:20:06 -07:00
|
|
|
}
|
2013-11-07 00:30:16 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(RestrictionsManagerService.class);
|
2014-05-24 15:34:37 -07:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(MediaSessionService.class);
|
2014-02-13 14:19:04 -08:00
|
|
|
|
2014-07-10 20:49:27 +09:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_HDMI_CEC)) {
|
|
|
|
mSystemServiceManager.startService(HdmiControlService.class);
|
|
|
|
}
|
2014-04-23 17:57:26 +09:00
|
|
|
|
2014-07-24 16:28:35 +09:00
|
|
|
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
|
|
|
|
mSystemServiceManager.startService(TvInputManagerService.class);
|
|
|
|
}
|
2014-02-20 18:23:25 -08:00
|
|
|
|
2013-11-07 00:30:16 -08:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
try {
|
|
|
|
Slog.i(TAG, "Media Router Service");
|
|
|
|
mediaRouter = new MediaRouterService(context);
|
|
|
|
ServiceManager.addService(Context.MEDIA_ROUTER_SERVICE, mediaRouter);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting MediaRouterService", e);
|
|
|
|
}
|
2014-03-27 14:56:59 +01:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(TrustManagerService.class);
|
2014-05-07 15:21:14 -07:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(FingerprintService.class);
|
2014-06-06 15:00:49 -07:00
|
|
|
|
2014-04-28 22:11:01 -07:00
|
|
|
try {
|
|
|
|
Slog.i(TAG, "BackgroundDexOptService");
|
2014-06-16 15:51:39 -07:00
|
|
|
BackgroundDexOptService.schedule(context);
|
2014-04-28 22:11:01 -07:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting BackgroundDexOptService", e);
|
|
|
|
}
|
2014-06-06 15:00:49 -07:00
|
|
|
|
2013-11-07 00:30:16 -08:00
|
|
|
}
|
2014-02-19 14:31:52 -08:00
|
|
|
|
2014-06-12 22:38:59 -07:00
|
|
|
mSystemServiceManager.startService(LauncherAppsService.class);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2014-07-08 18:07:36 -07:00
|
|
|
if (!disableNonCoreServices) {
|
|
|
|
mSystemServiceManager.startService(MediaProjectionManagerService.class);
|
|
|
|
}
|
|
|
|
|
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) {
|
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();
|
2010-02-14 16:18:56 -08:00
|
|
|
} else {
|
|
|
|
// Enable the JIT for the system_server process
|
|
|
|
VMRuntime.getRuntime().startJitCompilation();
|
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
|
|
|
|
mmsService = mSystemServiceManager.startService(MmsServiceBroker.class);
|
|
|
|
|
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
|
|
|
|
2012-04-13 20:38:38 -07:00
|
|
|
try {
|
|
|
|
vibrator.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Vibrator Service ready", e);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-12-20 13:27:30 -08:00
|
|
|
// Needed by DevicePolicyManager for initialization
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startBootPhase(SystemService.PHASE_LOCK_SETTINGS_READY);
|
2010-01-12 18:14:19 -08:00
|
|
|
|
2014-01-15 20:40:55 -08:00
|
|
|
mSystemServiceManager.startBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);
|
2009-07-08 17:09:14 -07:00
|
|
|
|
2011-08-22 00:26:20 -07:00
|
|
|
try {
|
|
|
|
wm.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Window Manager Service ready", e);
|
|
|
|
}
|
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.
|
|
|
|
Configuration config = wm.computeNewConfiguration();
|
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
WindowManager w = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
|
|
|
|
w.getDefaultDisplay().getMetrics(metrics);
|
|
|
|
context.getResources().updateConfiguration(config, metrics);
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-09-02 13:26:28 -07:00
|
|
|
// These are needed to propagate to the runnable below.
|
2012-09-07 23:16:01 -07:00
|
|
|
final MountService mountServiceF = mountService;
|
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;
|
2009-09-02 13:26:28 -07:00
|
|
|
final WallpaperManagerService wallpaperF = wallpaper;
|
|
|
|
final InputMethodManagerService immF = imm;
|
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;
|
2011-06-22 16:38:13 +09:00
|
|
|
final TextServicesManagerService textServiceManagerServiceF = tsms;
|
2011-08-22 00:26:20 -07:00
|
|
|
final StatusBarManagerService statusBarF = statusBar;
|
Pack preloaded framework assets in a texture atlas
When the Android runtime starts, the system preloads a series of assets
in the Zygote process. These assets are shared across all processes.
Unfortunately, each one of these assets is later uploaded in its own
OpenGL texture, once per process. This wastes memory and generates
unnecessary OpenGL state changes.
This CL introduces an asset server that provides an atlas to all processes.
Note: bitmaps used by skia shaders are *not* sampled from the atlas.
It's an uncommon use case and would require extra texture transforms
in the GL shaders.
WHAT IS THE ASSETS ATLAS
The "assets atlas" is a single, shareable graphic buffer that contains
all the system's preloaded bitmap drawables (this includes 9-patches.)
The atlas is made of two distinct objects: the graphic buffer that
contains the actual pixels and the map which indicates where each
preloaded bitmap can be found in the atlas (essentially a pair of
x and y coordinates.)
HOW IS THE ASSETS ATLAS GENERATED
Because we need to support a wide variety of devices and because it
is easy to change the list of preloaded drawables, the atlas is
generated at runtime, during the startup phase of the system process.
There are several steps that lead to the atlas generation:
1. If the device is booting for the first time, or if the device was
updated, we need to find the best atlas configuration. To do so,
the atlas service tries a number of width, height and algorithm
variations that allows us to pack as many assets as possible while
using as little memory as possible. Once a best configuration is found,
it gets written to disk in /data/system/framework_atlas
2. Given a best configuration (algorithm variant, dimensions and
number of bitmaps that can be packed in the atlas), the atlas service
packs all the preloaded bitmaps into a single graphic buffer object.
3. The packing is done using Skia in a temporary native bitmap. The
Skia bitmap is then copied into the graphic buffer using OpenGL ES
to benefit from texture swizzling.
HOW PROCESSES USE THE ATLAS
Whenever a process' hardware renderer initializes its EGL context,
it queries the atlas service for the graphic buffer and the map.
It is important to remember that both the context and the map will
be valid for the lifetime of the hardware renderer (if the system
process goes down, all apps get killed as well.)
Every time the hardware renderer needs to render a bitmap, it first
checks whether the bitmap can be found in the assets atlas. When
the bitmap is part of the atlas, texture coordinates are remapped
appropriately before rendering.
Change-Id: I8eaecf53e7f6a33d90da3d0047c5ceec89ea3af0
2013-04-17 18:54:38 -07:00
|
|
|
final AssetAtlasService atlasF = atlas;
|
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-05-06 10:49:04 -07:00
|
|
|
final AudioService audioServiceF = audioService;
|
2014-07-24 12:56:45 -07:00
|
|
|
final MmsServiceBroker mmsServiceF = mmsService;
|
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.
|
2014-01-16 22:16:42 -08:00
|
|
|
mActivityManagerService.systemReady(new Runnable() {
|
2014-02-14 17:19:56 -08:00
|
|
|
@Override
|
2009-09-02 13:26:28 -07:00
|
|
|
public void run() {
|
2014-02-21 14:06:47 -08:00
|
|
|
Slog.i(TAG, "Making services ready");
|
|
|
|
mSystemServiceManager.startBootPhase(
|
|
|
|
SystemService.PHASE_ACTIVITY_MANAGER_READY);
|
|
|
|
|
|
|
|
try {
|
|
|
|
mActivityManagerService.startObservingNativeCrashes();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("observing native crashes", e);
|
|
|
|
}
|
2014-07-25 18:03:16 +01:00
|
|
|
|
|
|
|
Slog.i(TAG, "WebViewFactory preparation");
|
|
|
|
WebViewFactory.prepareWebViewInSystemServer();
|
|
|
|
|
2014-02-21 14:06:47 -08:00
|
|
|
try {
|
|
|
|
startSystemUi(context);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("starting System UI", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (mountServiceF != null) mountServiceF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Mount Service ready", e);
|
|
|
|
}
|
2014-04-16 17:29:40 -07:00
|
|
|
try {
|
|
|
|
if (networkScoreF != null) networkScoreF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Score Service ready", e);
|
|
|
|
}
|
2014-02-21 14:06:47 -08:00
|
|
|
try {
|
|
|
|
if (networkManagementF != null) networkManagementF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Managment Service ready", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (networkStatsF != null) networkStatsF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Stats Service ready", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (networkPolicyF != null) networkPolicyF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Network Policy Service ready", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (connectivityF != null) connectivityF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("making Connectivity Service ready", e);
|
|
|
|
}
|
2014-05-06 10:49:04 -07:00
|
|
|
try {
|
|
|
|
if (audioServiceF != null) audioServiceF.systemReady();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying AudioService running", e);
|
|
|
|
}
|
2014-02-21 14:06:47 -08:00
|
|
|
Watchdog.getInstance().start();
|
|
|
|
|
|
|
|
// It is now okay to let the various system services start their
|
|
|
|
// third party code...
|
|
|
|
mSystemServiceManager.startBootPhase(
|
|
|
|
SystemService.PHASE_THIRD_PARTY_APPS_CAN_START);
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (wallpaperF != null) wallpaperF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying WallpaperService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (immF != null) immF.systemRunning(statusBarF);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying InputMethodService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (locationF != null) locationF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying Location Service running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (countryDetectorF != null) countryDetectorF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying CountryDetectorService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying NetworkTimeService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (commonTimeMgmtServiceF != null) {
|
|
|
|
commonTimeMgmtServiceF.systemRunning();
|
2014-02-14 17:19:56 -08:00
|
|
|
}
|
2014-02-21 14:06:47 -08:00
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying CommonTimeManagementService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (textServiceManagerServiceF != null)
|
|
|
|
textServiceManagerServiceF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying TextServicesManagerService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (atlasF != null) atlasF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying AssetAtlasService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
// TODO(BT) Pass parameter to input manager
|
|
|
|
if (inputManagerF != null) inputManagerF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying InputManagerService running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (telephonyRegistryF != null) telephonyRegistryF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying TelephonyRegistry running", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (mediaRouterF != null) mediaRouterF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying MediaRouterService running", e);
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:56:45 -07:00
|
|
|
try {
|
|
|
|
if (mmsServiceF != null) mmsServiceF.systemRunning();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
reportWtf("Notifying MmsService running", e);
|
|
|
|
}
|
2009-09-02 13:26:28 -07:00
|
|
|
}
|
|
|
|
});
|
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"));
|
2012-11-27 19:12:23 -08:00
|
|
|
//Slog.d(TAG, "Starting service: " + intent);
|
2012-10-19 18:23:52 -07:00
|
|
|
context.startServiceAsUser(intent, UserHandle.OWNER);
|
2010-10-21 11:09:02 -04:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|