Merge "Move color modes to ColorDisplayService"
This commit is contained in:
committed by
Android (Google) Code Review
commit
69aab0df31
@@ -23,12 +23,14 @@ import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.metrics.LogMaker;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.ServiceManager.ServiceNotFoundException;
|
||||
import android.provider.Settings.Secure;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
@@ -123,6 +125,42 @@ public final class ColorDisplayManager {
|
||||
@SystemApi
|
||||
public static final int AUTO_MODE_TWILIGHT = 2;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({COLOR_MODE_NATURAL, COLOR_MODE_BOOSTED, COLOR_MODE_SATURATED, COLOR_MODE_AUTOMATIC})
|
||||
public @interface ColorMode {}
|
||||
|
||||
/**
|
||||
* Color mode with natural colors.
|
||||
*
|
||||
* @hide
|
||||
* @see #setColorMode(int)
|
||||
*/
|
||||
public static final int COLOR_MODE_NATURAL = 0;
|
||||
/**
|
||||
* Color mode with boosted colors.
|
||||
*
|
||||
* @hide
|
||||
* @see #setColorMode(int)
|
||||
*/
|
||||
public static final int COLOR_MODE_BOOSTED = 1;
|
||||
/**
|
||||
* Color mode with saturated colors.
|
||||
*
|
||||
* @hide
|
||||
* @see #setColorMode(int)
|
||||
*/
|
||||
public static final int COLOR_MODE_SATURATED = 2;
|
||||
/**
|
||||
* Color mode with automatic colors.
|
||||
*
|
||||
* @hide
|
||||
* @see #setColorMode(int)
|
||||
*/
|
||||
public static final int COLOR_MODE_AUTOMATIC = 3;
|
||||
|
||||
private final ColorDisplayManagerInternal mManager;
|
||||
private MetricsLogger mMetricsLogger;
|
||||
|
||||
@@ -285,6 +323,24 @@ public final class ColorDisplayManager {
|
||||
return mManager.setNightDisplayCustomEndTime(new Time(endTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current display color mode.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setColorMode(int colorMode) {
|
||||
mManager.setColorMode(colorMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current display color mode.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public int getColorMode() {
|
||||
return mManager.getColorMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the device has a wide color gamut display.
|
||||
*
|
||||
@@ -384,6 +440,18 @@ public final class ColorDisplayManager {
|
||||
return mManager.getTransformCapabilities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether accessibility transforms are currently enabled, which determines whether
|
||||
* color modes are currently configurable for this device.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean areAccessibilityTransformsEnabled(Context context) {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
return Secure.getInt(cr, Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0) == 1
|
||||
|| Secure.getInt(cr, Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0) == 1;
|
||||
}
|
||||
|
||||
private MetricsLogger getMetricsLogger() {
|
||||
if (mMetricsLogger == null) {
|
||||
mMetricsLogger = new MetricsLogger();
|
||||
@@ -528,6 +596,22 @@ public final class ColorDisplayManager {
|
||||
}
|
||||
}
|
||||
|
||||
int getColorMode() {
|
||||
try {
|
||||
return mCdm.getColorMode();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
void setColorMode(int colorMode) {
|
||||
try {
|
||||
mCdm.setColorMode(colorMode);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
int getTransformCapabilities() {
|
||||
try {
|
||||
return mCdm.getTransformCapabilities();
|
||||
|
||||
@@ -38,4 +38,7 @@ interface IColorDisplayManager {
|
||||
boolean setNightDisplayCustomStartTime(in Time time);
|
||||
Time getNightDisplayCustomEndTime();
|
||||
boolean setNightDisplayCustomEndTime(in Time time);
|
||||
|
||||
int getColorMode();
|
||||
void setColorMode(int colorMode);
|
||||
}
|
||||
@@ -59,6 +59,7 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.location.LocationManager;
|
||||
import android.media.AudioFormat;
|
||||
import android.net.ConnectivityManager;
|
||||
@@ -89,7 +90,6 @@ import android.util.MemoryIntArray;
|
||||
import android.view.inputmethod.InputMethodSystemProperty;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.widget.ILockSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -3239,8 +3239,8 @@ public final class Settings {
|
||||
|
||||
private static final Validator DISPLAY_COLOR_MODE_VALIDATOR =
|
||||
new SettingsValidators.InclusiveIntegerRangeValidator(
|
||||
ColorDisplayController.COLOR_MODE_NATURAL,
|
||||
ColorDisplayController.COLOR_MODE_AUTOMATIC);
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL,
|
||||
ColorDisplayManager.COLOR_MODE_AUTOMATIC);
|
||||
|
||||
/**
|
||||
* The amount of time in milliseconds before the device goes to sleep or begins
|
||||
|
||||
Reference in New Issue
Block a user