Merge "Get current and default brightness configs." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
daec95a7f5
@@ -1233,7 +1233,9 @@ package android.hardware.display {
|
||||
|
||||
public final class DisplayManager {
|
||||
method public java.util.List<android.hardware.display.AmbientBrightnessDayStats> getAmbientBrightnessStats();
|
||||
method public android.hardware.display.BrightnessConfiguration getBrightnessConfiguration();
|
||||
method public java.util.List<android.hardware.display.BrightnessChangeEvent> getBrightnessEvents();
|
||||
method public android.hardware.display.BrightnessConfiguration getDefaultBrightnessConfiguration();
|
||||
method public android.graphics.Point getStableDisplaySize();
|
||||
method public void setBrightnessConfiguration(android.hardware.display.BrightnessConfiguration);
|
||||
}
|
||||
|
||||
@@ -370,7 +370,9 @@ package android.hardware.display {
|
||||
|
||||
public final class DisplayManager {
|
||||
method public java.util.List<android.hardware.display.AmbientBrightnessDayStats> getAmbientBrightnessStats();
|
||||
method public android.hardware.display.BrightnessConfiguration getBrightnessConfiguration();
|
||||
method public java.util.List<android.hardware.display.BrightnessChangeEvent> getBrightnessEvents();
|
||||
method public android.hardware.display.BrightnessConfiguration getDefaultBrightnessConfiguration();
|
||||
method public android.graphics.Point getStableDisplaySize();
|
||||
method public void setBrightnessConfiguration(android.hardware.display.BrightnessConfiguration);
|
||||
}
|
||||
|
||||
@@ -667,6 +667,45 @@ public final class DisplayManager {
|
||||
mGlobal.setBrightnessConfigurationForUser(c, userId, packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global display brightness configuration or the default curve if one hasn't been set.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS)
|
||||
public BrightnessConfiguration getBrightnessConfiguration() {
|
||||
return getBrightnessConfigurationForUser(mContext.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global display brightness configuration or the default curve if one hasn't been set
|
||||
* for a specific user.
|
||||
*
|
||||
* Note this requires the INTERACT_ACROSS_USERS permission if getting the configuration for a
|
||||
* user other than the one you're currently running as.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public BrightnessConfiguration getBrightnessConfigurationForUser(int userId) {
|
||||
return mGlobal.getBrightnessConfigurationForUser(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default global display brightness configuration or null one hasn't
|
||||
* been configured.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS)
|
||||
@Nullable
|
||||
public BrightnessConfiguration getDefaultBrightnessConfiguration() {
|
||||
return mGlobal.getDefaultBrightnessConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporarily sets the brightness of the display.
|
||||
* <p>
|
||||
|
||||
@@ -489,6 +489,32 @@ public final class DisplayManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global brightness configuration for a given user or null if one hasn't been set.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public BrightnessConfiguration getBrightnessConfigurationForUser(int userId) {
|
||||
try {
|
||||
return mDm.getBrightnessConfigurationForUser(userId);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default brightness configuration or null if one hasn't been configured.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public BrightnessConfiguration getDefaultBrightnessConfiguration() {
|
||||
try {
|
||||
return mDm.getDefaultBrightnessConfiguration();
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporarily sets the brightness of the display.
|
||||
* <p>
|
||||
|
||||
@@ -96,6 +96,14 @@ interface IDisplayManager {
|
||||
void setBrightnessConfigurationForUser(in BrightnessConfiguration c, int userId,
|
||||
String packageName);
|
||||
|
||||
// Gets the global brightness configuration for a given user. Requires
|
||||
// CONFIGURE_DISPLAY_BRIGHTNESS, and INTERACT_ACROSS_USER if the user is not
|
||||
// the same as the calling user.
|
||||
BrightnessConfiguration getBrightnessConfigurationForUser(int userId);
|
||||
|
||||
// Gets the default brightness configuration if configured.
|
||||
BrightnessConfiguration getDefaultBrightnessConfiguration();
|
||||
|
||||
// Temporarily sets the display brightness.
|
||||
void setTemporaryBrightness(int brightness);
|
||||
|
||||
|
||||
@@ -282,6 +282,10 @@ class AutomaticBrightnessController {
|
||||
return mBrightnessMapper.isDefaultConfig();
|
||||
}
|
||||
|
||||
public BrightnessConfiguration getDefaultConfig() {
|
||||
return mBrightnessMapper.getDefaultConfig();
|
||||
}
|
||||
|
||||
private boolean setDisplayPolicy(int policy) {
|
||||
if (mDisplayPolicy == policy) {
|
||||
return false;
|
||||
|
||||
@@ -206,6 +206,8 @@ public abstract class BrightnessMappingStrategy {
|
||||
/** @return true if the current brightness config is the default one */
|
||||
public abstract boolean isDefaultConfig();
|
||||
|
||||
public abstract BrightnessConfiguration getDefaultConfig();
|
||||
|
||||
public abstract void dump(PrintWriter pw);
|
||||
|
||||
private static float normalizeAbsoluteBrightness(int brightness) {
|
||||
@@ -405,6 +407,9 @@ public abstract class BrightnessMappingStrategy {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrightnessConfiguration getDefaultConfig() { return null; }
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println("SimpleMappingStrategy");
|
||||
@@ -532,6 +537,9 @@ public abstract class BrightnessMappingStrategy {
|
||||
return mDefaultConfig.equals(mConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrightnessConfiguration getDefaultConfig() { return mDefaultConfig; }
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println("PhysicalMappingStrategy");
|
||||
|
||||
@@ -1877,6 +1877,48 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public BrightnessConfiguration getBrightnessConfigurationForUser(int userId) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS,
|
||||
"Permission required to read the display's brightness configuration");
|
||||
if (userId != UserHandle.getCallingUserId()) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
Manifest.permission.INTERACT_ACROSS_USERS,
|
||||
"Permission required to read the display brightness"
|
||||
+ " configuration of another user");
|
||||
}
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final int userSerial = getUserManager().getUserSerialNumber(userId);
|
||||
synchronized (mSyncRoot) {
|
||||
BrightnessConfiguration config =
|
||||
mPersistentDataStore.getBrightnessConfiguration(userSerial);
|
||||
if (config == null) {
|
||||
config = mDisplayPowerController.getDefaultBrightnessConfiguration();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public BrightnessConfiguration getDefaultBrightnessConfiguration() {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS,
|
||||
"Permission required to read the display's default brightness configuration");
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mSyncRoot) {
|
||||
return mDisplayPowerController.getDefaultBrightnessConfiguration();
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void setTemporaryBrightness(int brightness) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
|
||||
@@ -567,6 +567,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
}
|
||||
}
|
||||
|
||||
public BrightnessConfiguration getDefaultBrightnessConfiguration() {
|
||||
return mAutomaticBrightnessController.getDefaultConfig();
|
||||
}
|
||||
|
||||
private void sendUpdatePowerState() {
|
||||
synchronized (mLock) {
|
||||
sendUpdatePowerStateLocked();
|
||||
|
||||
Reference in New Issue
Block a user