Add ColorDisplayManager
Add ColorDisplayManager class, and shift some functionality from
ColorDisplayController
Bug: 111215474
Test: atest FrameworksServicesTest:ColorDisplayServiceTest
Change-Id: Ic38a12e1e0b0619fdad42a89b7ac3e878c8128b2
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 54a140d..dc67b8f 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -35,6 +35,7 @@
import android.content.res.Resources.Theme;
import android.database.sqlite.SQLiteCompatibilityWalFlags;
import android.database.sqlite.SQLiteGlobal;
+import android.hardware.display.ColorDisplayManager;
import android.hardware.display.DisplayManagerInternal;
import android.os.BaseBundle;
import android.os.Binder;
@@ -62,7 +63,6 @@
import android.view.WindowManager;
import com.android.internal.R;
-import com.android.internal.app.ColorDisplayController;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.BinderInternal;
@@ -146,6 +146,7 @@
import java.util.concurrent.Future;
public final class SystemServer {
+
private static final String TAG = "SystemServer";
// Tag for timing measurement of main thread.
@@ -259,9 +260,8 @@
private static final int sMaxBinderThreads = 31;
/**
- * 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.
+ * 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 =
com.android.internal.R.style.Theme_DeviceDefault_System;
@@ -301,8 +301,7 @@
private static native void startSensorService();
/**
- * Start all HIDL services that are run inside the system server. This
- * may take some time.
+ * Start all HIDL services that are run inside the system server. This may take some time.
*/
private static native void startHidlServices();
@@ -338,7 +337,7 @@
//
// Default the timezone property to GMT if not set.
//
- String timezoneProperty = SystemProperties.get("persist.sys.timezone");
+ 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");
@@ -419,7 +418,7 @@
// Prepare the main looper thread (this thread).
android.os.Process.setThreadPriority(
- android.os.Process.THREAD_PRIORITY_FOREGROUND);
+ android.os.Process.THREAD_PRIORITY_FOREGROUND);
android.os.Process.setCanSelfBackground(false);
Looper.prepareMainLooper();
Looper.getMainLooper().setSlowLogThresholdMs(
@@ -524,7 +523,7 @@
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?");
+ "unexpected runtime restart?");
return;
}
}
@@ -557,11 +556,10 @@
}
/**
- * 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.
+ * 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.
*/
private void startBootstrapServices() {
Slog.i(TAG, "Reading configuration...");
@@ -773,8 +771,7 @@
}
/**
- * Starts a miscellaneous grab bag of stuff that has yet to be refactored
- * and organized.
+ * Starts a miscellaneous grab bag of stuff that has yet to be refactored and organized.
*/
private void startOtherServices() {
final Context context = mSystemContext;
@@ -785,7 +782,7 @@
NetworkStatsService networkStats = null;
NetworkPolicyManagerService networkPolicy = null;
ConnectivityService connectivity = null;
- NsdService serviceDiscovery= null;
+ NsdService serviceDiscovery = null;
WindowManagerService wm = null;
SerialService serial = null;
NetworkTimeUpdateService networkTimeUpdater = null;
@@ -971,7 +968,7 @@
} else if (mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
Slog.i(TAG, "No Bluetooth Service (factory test)");
} else if (!context.getPackageManager().hasSystemFeature
- (PackageManager.FEATURE_BLUETOOTH)) {
+ (PackageManager.FEATURE_BLUETOOTH)) {
Slog.i(TAG, "No Bluetooth Service (Bluetooth Hardware Not Present)");
} else {
traceBeginAndSlog("StartBluetoothService");
@@ -1080,7 +1077,7 @@
try {
mSystemServiceManager.startService(LOCK_SETTINGS_SERVICE_CLASS);
lockSettings = ILockSettings.Stub.asInterface(
- ServiceManager.getService("lock_settings"));
+ ServiceManager.getService("lock_settings"));
} catch (Throwable e) {
reportWtf("starting LockSettingsService service", e);
}
@@ -1149,7 +1146,8 @@
if (!disableSystemTextClassifier) {
traceBeginAndSlog("StartTextClassificationManagerService");
- mSystemServiceManager.startService(TextClassificationManagerService.Lifecycle.class);
+ mSystemServiceManager
+ .startService(TextClassificationManagerService.Lifecycle.class);
traceEnd();
}
@@ -1178,41 +1176,41 @@
if (!mOnlyCore) {
if (context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WIFI)) {
+ PackageManager.FEATURE_WIFI)) {
// 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");
+ "com.android.server.wifi.scanner.WifiScanningService");
traceEnd();
}
if (context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WIFI_RTT)) {
+ PackageManager.FEATURE_WIFI_RTT)) {
traceBeginAndSlog("StartRttService");
mSystemServiceManager.startService(
- "com.android.server.wifi.rtt.RttService");
+ "com.android.server.wifi.rtt.RttService");
traceEnd();
}
if (context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WIFI_AWARE)) {
+ PackageManager.FEATURE_WIFI_AWARE)) {
traceBeginAndSlog("StartWifiAware");
mSystemServiceManager.startService(WIFI_AWARE_SERVICE_CLASS);
traceEnd();
}
if (context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WIFI_DIRECT)) {
+ PackageManager.FEATURE_WIFI_DIRECT)) {
traceBeginAndSlog("StartWifiP2P");
mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
traceEnd();
}
if (context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_LOWPAN)) {
+ PackageManager.FEATURE_LOWPAN)) {
traceBeginAndSlog("StartLowpan");
mSystemServiceManager.startService(LOWPAN_SERVICE_CLASS);
traceEnd();
@@ -1220,7 +1218,7 @@
}
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET) ||
- mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
+ mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
traceBeginAndSlog("StartEthernet");
mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS);
traceEnd();
@@ -1229,10 +1227,10 @@
traceBeginAndSlog("StartConnectivityService");
try {
connectivity = new ConnectivityService(
- context, networkManagement, networkStats, networkPolicy);
+ context, networkManagement, networkStats, networkPolicy);
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity,
- /* allowIsolated= */ false,
- DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL);
+ /* allowIsolated= */ false,
+ DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL);
networkStats.bindConnectivityManager(connectivity);
networkPolicy.bindConnectivityManager(connectivity);
} catch (Throwable e) {
@@ -1244,7 +1242,7 @@
try {
serviceDiscovery = NsdService.create(context);
ServiceManager.addService(
- Context.NSD_SERVICE, serviceDiscovery);
+ Context.NSD_SERVICE, serviceDiscovery);
} catch (Throwable e) {
reportWtf("starting Service Discovery Service", e);
}
@@ -1262,7 +1260,7 @@
traceBeginAndSlog("StartUpdateLockService");
try {
ServiceManager.addService(Context.UPDATE_LOCK_SERVICE,
- new UpdateLockService(context));
+ new UpdateLockService(context));
} catch (Throwable e) {
reportWtf("starting UpdateLockService", e);
}
@@ -1370,9 +1368,9 @@
}
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
- || mPackageManager.hasSystemFeature(
- PackageManager.FEATURE_USB_ACCESSORY)
- || isEmulator) {
+ || mPackageManager.hasSystemFeature(
+ PackageManager.FEATURE_USB_ACCESSORY)
+ || isEmulator) {
// Manage USB host and device support
traceBeginAndSlog("StartUsbService");
mSystemServiceManager.startService(USB_SERVICE_CLASS);
@@ -1404,7 +1402,7 @@
try {
hardwarePropertiesService = new HardwarePropertiesManagerService(context);
ServiceManager.addService(Context.HARDWARE_PROPERTIES_SERVICE,
- hardwarePropertiesService);
+ hardwarePropertiesService);
} catch (Throwable e) {
Slog.e(TAG, "Failure starting HardwarePropertiesManagerService", e);
}
@@ -1414,8 +1412,8 @@
mSystemServiceManager.startService(TwilightService.class);
traceEnd();
- if (ColorDisplayController.isAvailable(context)) {
- traceBeginAndSlog("StartNightDisplay");
+ if (ColorDisplayManager.isNightDisplayAvailable(context)) {
+ traceBeginAndSlog("StartColorDisplay");
mSystemServiceManager.startService(ColorDisplayService.class);
traceEnd();
}
@@ -1439,7 +1437,7 @@
}
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS)
- || context.getResources().getBoolean(R.bool.config_enableAppWidgetService)) {
+ || context.getResources().getBoolean(R.bool.config_enableAppWidgetService)) {
traceBeginAndSlog("StartAppWidgetService");
mSystemServiceManager.startService(APPWIDGET_SERVICE_CLASS);
traceEnd();
@@ -1525,7 +1523,7 @@
traceBeginAndSlog("AddGraphicsStatsService");
ServiceManager.addService(GraphicsStatsService.GRAPHICS_STATS_SERVICE,
- new GraphicsStatsService(context));
+ new GraphicsStatsService(context));
traceEnd();
if (CoverageService.ENABLED) {
@@ -1797,7 +1795,7 @@
// propagate to it.
final Configuration config = wm.computeNewConfiguration(DEFAULT_DISPLAY);
DisplayMetrics metrics = new DisplayMetrics();
- WindowManager w = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+ WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
w.getDefaultDisplay().getMetrics(metrics);
context.getResources().updateConfiguration(config, metrics);
@@ -1916,7 +1914,9 @@
traceEnd();
traceBeginAndSlog("MakeNetworkManagementServiceReady");
try {
- if (networkManagementF != null) networkManagementF.systemReady();
+ if (networkManagementF != null) {
+ networkManagementF.systemReady();
+ }
} catch (Throwable e) {
reportWtf("making Network Managment Service ready", e);
}
@@ -1928,21 +1928,27 @@
traceEnd();
traceBeginAndSlog("MakeIpSecServiceReady");
try {
- if (ipSecServiceF != null) ipSecServiceF.systemReady();
+ if (ipSecServiceF != null) {
+ ipSecServiceF.systemReady();
+ }
} catch (Throwable e) {
reportWtf("making IpSec Service ready", e);
}
traceEnd();
traceBeginAndSlog("MakeNetworkStatsServiceReady");
try {
- if (networkStatsF != null) networkStatsF.systemReady();
+ if (networkStatsF != null) {
+ networkStatsF.systemReady();
+ }
} catch (Throwable e) {
reportWtf("making Network Stats Service ready", e);
}
traceEnd();
traceBeginAndSlog("MakeConnectivityServiceReady");
try {
- if (connectivityF != null) connectivityF.systemReady();
+ if (connectivityF != null) {
+ connectivityF.systemReady();
+ }
} catch (Throwable e) {
reportWtf("making Connectivity Service ready", e);
}
@@ -1977,21 +1983,27 @@
traceBeginAndSlog("MakeLocationServiceReady");
try {
- if (locationF != null) locationF.systemRunning();
+ if (locationF != null) {
+ locationF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying Location Service running", e);
}
traceEnd();
traceBeginAndSlog("MakeCountryDetectionServiceReady");
try {
- if (countryDetectorF != null) countryDetectorF.systemRunning();
+ if (countryDetectorF != null) {
+ countryDetectorF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying CountryDetectorService running", e);
}
traceEnd();
traceBeginAndSlog("MakeNetworkTimeUpdateReady");
try {
- if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemRunning();
+ if (networkTimeUpdaterF != null) {
+ networkTimeUpdaterF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying NetworkTimeService running", e);
}
@@ -1999,28 +2011,36 @@
traceBeginAndSlog("MakeInputManagerServiceReady");
try {
// TODO(BT) Pass parameter to input manager
- if (inputManagerF != null) inputManagerF.systemRunning();
+ if (inputManagerF != null) {
+ inputManagerF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying InputManagerService running", e);
}
traceEnd();
traceBeginAndSlog("MakeTelephonyRegistryReady");
try {
- if (telephonyRegistryF != null) telephonyRegistryF.systemRunning();
+ if (telephonyRegistryF != null) {
+ telephonyRegistryF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying TelephonyRegistry running", e);
}
traceEnd();
traceBeginAndSlog("MakeMediaRouterServiceReady");
try {
- if (mediaRouterF != null) mediaRouterF.systemRunning();
+ if (mediaRouterF != null) {
+ mediaRouterF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying MediaRouterService running", e);
}
traceEnd();
traceBeginAndSlog("MakeMmsServiceReady");
try {
- if (mmsServiceF != null) mmsServiceF.systemRunning();
+ if (mmsServiceF != null) {
+ mmsServiceF.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying MmsService running", e);
}
@@ -2032,7 +2052,9 @@
// in the build and should reliably be there.
final IIncidentManager incident = IIncidentManager.Stub.asInterface(
ServiceManager.getService(Context.INCIDENT_SERVICE));
- if (incident != null) incident.systemRunning();
+ if (incident != null) {
+ incident.systemRunning();
+ }
} catch (Throwable e) {
reportWtf("Notifying incident daemon running", e);
}
@@ -2043,7 +2065,7 @@
static final void startSystemUi(Context context, WindowManagerService windowManager) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
- "com.android.systemui.SystemUIService"));
+ "com.android.systemui.SystemUIService"));
intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.SYSTEM);