Merge "Add isSaturationActivated"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ade169ae15
@@ -364,6 +364,17 @@ public final class ColorDisplayManager {
|
||||
return mManager.setSaturationLevel(saturationLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not a non-default saturation level is currently applied to the display.
|
||||
*
|
||||
* @return {@code true} if the display is not at full saturation
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS)
|
||||
public boolean isSaturationActivated() {
|
||||
return mManager.isSaturationActivated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the level of color saturation to apply to a specific app.
|
||||
*
|
||||
@@ -588,6 +599,14 @@ public final class ColorDisplayManager {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSaturationActivated() {
|
||||
try {
|
||||
return mCdm.isSaturationActivated();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
boolean setAppSaturationLevel(String packageName, int saturationLevel) {
|
||||
try {
|
||||
return mCdm.setAppSaturationLevel(packageName, saturationLevel);
|
||||
|
||||
@@ -24,6 +24,7 @@ interface IColorDisplayManager {
|
||||
|
||||
boolean setSaturationLevel(int saturationLevel);
|
||||
boolean setAppSaturationLevel(String packageName, int saturationLevel);
|
||||
boolean isSaturationActivated();
|
||||
|
||||
int getTransformCapabilities();
|
||||
|
||||
|
||||
@@ -387,8 +387,10 @@ public final class ColorDisplayService extends SystemService {
|
||||
Slog.d(TAG, "Setting saturation level: " + saturationLevel);
|
||||
|
||||
if (saturationLevel == 100) {
|
||||
setActivated(false);
|
||||
Matrix.setIdentityM(mMatrixGlobalSaturation, 0);
|
||||
} else {
|
||||
setActivated(true);
|
||||
float saturation = saturationLevel * 0.1f;
|
||||
float desaturation = 1.0f - saturation;
|
||||
float[] luminance = {0.231f * desaturation, 0.715f * desaturation,
|
||||
@@ -674,6 +676,10 @@ public final class ColorDisplayService extends SystemService {
|
||||
if (mDisplayWhiteBalanceTintController.isAvailable(getContext())) {
|
||||
mDisplayWhiteBalanceTintController.endAnimator();
|
||||
}
|
||||
|
||||
if (mGlobalSaturationTintController.isAvailable(getContext())) {
|
||||
mGlobalSaturationTintController.setActivated(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void onNightDisplayAutoModeChanged(int autoMode) {
|
||||
@@ -1670,6 +1676,20 @@ public final class ColorDisplayService extends SystemService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaturationActivated() {
|
||||
getContext().enforceCallingPermission(
|
||||
Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS,
|
||||
"Permission required to get display saturation level");
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return !mGlobalSaturationTintController.isActivatedStateNotSet()
|
||||
&& mGlobalSaturationTintController.isActivated();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setAppSaturationLevel(String packageName, int level) {
|
||||
getContext().enforceCallingPermission(
|
||||
|
||||
Reference in New Issue
Block a user