Merge changes from topic "dmd_log_and_fix_sc-dev" into sc-dev am: 8241f19a03
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13416448 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I67ade48b4618088f6911dc1b0884091fc185cf97
This commit is contained in:
@@ -1538,6 +1538,14 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setDisplayModeDirectorLoggingEnabled(boolean enabled) {
|
||||||
|
synchronized (mSyncRoot) {
|
||||||
|
if (mDisplayModeDirector != null) {
|
||||||
|
mDisplayModeDirector.setLoggingEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setAmbientColorTemperatureOverride(float cct) {
|
void setAmbientColorTemperatureOverride(float cct) {
|
||||||
synchronized (mSyncRoot) {
|
synchronized (mSyncRoot) {
|
||||||
final DisplayPowerController displayPowerController = mDisplayPowerControllers.get(
|
final DisplayPowerController displayPowerController = mDisplayPowerControllers.get(
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ class DisplayManagerShellCommand extends ShellCommand {
|
|||||||
return setDisplayWhiteBalanceLoggingEnabled(true);
|
return setDisplayWhiteBalanceLoggingEnabled(true);
|
||||||
case "dwb-logging-disable":
|
case "dwb-logging-disable":
|
||||||
return setDisplayWhiteBalanceLoggingEnabled(false);
|
return setDisplayWhiteBalanceLoggingEnabled(false);
|
||||||
|
case "dmd-logging-enable":
|
||||||
|
return setDisplayModeDirectorLoggingEnabled(true);
|
||||||
|
case "dmd-logging-disable":
|
||||||
|
return setDisplayModeDirectorLoggingEnabled(false);
|
||||||
case "dwb-set-cct":
|
case "dwb-set-cct":
|
||||||
return setAmbientColorTemperatureOverride();
|
return setAmbientColorTemperatureOverride();
|
||||||
case "set-fold":
|
case "set-fold":
|
||||||
@@ -82,6 +86,10 @@ class DisplayManagerShellCommand extends ShellCommand {
|
|||||||
pw.println(" Enable display white-balance logging.");
|
pw.println(" Enable display white-balance logging.");
|
||||||
pw.println(" dwb-logging-disable");
|
pw.println(" dwb-logging-disable");
|
||||||
pw.println(" Disable display white-balance logging.");
|
pw.println(" Disable display white-balance logging.");
|
||||||
|
pw.println(" dmd-logging-enable");
|
||||||
|
pw.println(" Enable display mode director logging.");
|
||||||
|
pw.println(" dmd-logging-disable");
|
||||||
|
pw.println(" Disable display mode director logging.");
|
||||||
pw.println(" dwb-set-cct CCT");
|
pw.println(" dwb-set-cct CCT");
|
||||||
pw.println(" Sets the ambient color temperature override to CCT (use -1 to disable).");
|
pw.println(" Sets the ambient color temperature override to CCT (use -1 to disable).");
|
||||||
pw.println(" set-fold [fold|unfold|reset]");
|
pw.println(" set-fold [fold|unfold|reset]");
|
||||||
@@ -136,6 +144,11 @@ class DisplayManagerShellCommand extends ShellCommand {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int setDisplayModeDirectorLoggingEnabled(boolean enabled) {
|
||||||
|
mService.setDisplayModeDirectorLoggingEnabled(enabled);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private int setAmbientColorTemperatureOverride() {
|
private int setAmbientColorTemperatureOverride() {
|
||||||
String cctText = getNextArg();
|
String cctText = getNextArg();
|
||||||
if (cctText == null) {
|
if (cctText == null) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
public class DisplayModeDirector {
|
public class DisplayModeDirector {
|
||||||
private static final String TAG = "DisplayModeDirector";
|
private static final String TAG = "DisplayModeDirector";
|
||||||
private static final boolean DEBUG = false;
|
private boolean mLoggingEnabled;
|
||||||
|
|
||||||
private static final int MSG_REFRESH_RATE_RANGE_CHANGED = 1;
|
private static final int MSG_REFRESH_RATE_RANGE_CHANGED = 1;
|
||||||
private static final int MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED = 2;
|
private static final int MSG_LOW_BRIGHTNESS_THRESHOLDS_CHANGED = 2;
|
||||||
@@ -155,6 +155,14 @@ public class DisplayModeDirector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLoggingEnabled(boolean loggingEnabled) {
|
||||||
|
if (mLoggingEnabled == loggingEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLoggingEnabled = loggingEnabled;
|
||||||
|
mBrightnessObserver.setLoggingEnabled(loggingEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private SparseArray<Vote> getVotesLocked(int displayId) {
|
private SparseArray<Vote> getVotesLocked(int displayId) {
|
||||||
SparseArray<Vote> displayVotes = mVotesByDisplay.get(displayId);
|
SparseArray<Vote> displayVotes = mVotesByDisplay.get(displayId);
|
||||||
@@ -269,7 +277,7 @@ public class DisplayModeDirector {
|
|||||||
|
|
||||||
availableModes = filterModes(modes, primarySummary);
|
availableModes = filterModes(modes, primarySummary);
|
||||||
if (availableModes.length > 0) {
|
if (availableModes.length > 0) {
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.w(TAG, "Found available modes=" + Arrays.toString(availableModes)
|
Slog.w(TAG, "Found available modes=" + Arrays.toString(availableModes)
|
||||||
+ " with lowest priority considered "
|
+ " with lowest priority considered "
|
||||||
+ Vote.priorityToString(lowestConsideredPriority)
|
+ Vote.priorityToString(lowestConsideredPriority)
|
||||||
@@ -282,7 +290,7 @@ public class DisplayModeDirector {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.w(TAG, "Couldn't find available modes with lowest priority set to "
|
Slog.w(TAG, "Couldn't find available modes with lowest priority set to "
|
||||||
+ Vote.priorityToString(lowestConsideredPriority)
|
+ Vote.priorityToString(lowestConsideredPriority)
|
||||||
+ " and with the following constraints: "
|
+ " and with the following constraints: "
|
||||||
@@ -307,7 +315,7 @@ public class DisplayModeDirector {
|
|||||||
Math.min(appRequestSummary.minRefreshRate, primarySummary.minRefreshRate);
|
Math.min(appRequestSummary.minRefreshRate, primarySummary.minRefreshRate);
|
||||||
appRequestSummary.maxRefreshRate =
|
appRequestSummary.maxRefreshRate =
|
||||||
Math.max(appRequestSummary.maxRefreshRate, primarySummary.maxRefreshRate);
|
Math.max(appRequestSummary.maxRefreshRate, primarySummary.maxRefreshRate);
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.i(TAG,
|
Slog.i(TAG,
|
||||||
String.format("App request range: [%.0f %.0f]",
|
String.format("App request range: [%.0f %.0f]",
|
||||||
appRequestSummary.minRefreshRate,
|
appRequestSummary.minRefreshRate,
|
||||||
@@ -357,7 +365,7 @@ public class DisplayModeDirector {
|
|||||||
for (Display.Mode mode : supportedModes) {
|
for (Display.Mode mode : supportedModes) {
|
||||||
if (mode.getPhysicalWidth() != summary.width
|
if (mode.getPhysicalWidth() != summary.width
|
||||||
|| mode.getPhysicalHeight() != summary.height) {
|
|| mode.getPhysicalHeight() != summary.height) {
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.w(TAG, "Discarding mode " + mode.getModeId() + ", wrong size"
|
Slog.w(TAG, "Discarding mode " + mode.getModeId() + ", wrong size"
|
||||||
+ ": desiredWidth=" + summary.width
|
+ ": desiredWidth=" + summary.width
|
||||||
+ ": desiredHeight=" + summary.height
|
+ ": desiredHeight=" + summary.height
|
||||||
@@ -372,7 +380,7 @@ public class DisplayModeDirector {
|
|||||||
// comparison.
|
// comparison.
|
||||||
if (refreshRate < (summary.minRefreshRate - FLOAT_TOLERANCE)
|
if (refreshRate < (summary.minRefreshRate - FLOAT_TOLERANCE)
|
||||||
|| refreshRate > (summary.maxRefreshRate + FLOAT_TOLERANCE)) {
|
|| refreshRate > (summary.maxRefreshRate + FLOAT_TOLERANCE)) {
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.w(TAG, "Discarding mode " + mode.getModeId()
|
Slog.w(TAG, "Discarding mode " + mode.getModeId()
|
||||||
+ ", outside refresh rate bounds"
|
+ ", outside refresh rate bounds"
|
||||||
+ ": minRefreshRate=" + summary.minRefreshRate
|
+ ": minRefreshRate=" + summary.minRefreshRate
|
||||||
@@ -516,7 +524,7 @@ public class DisplayModeDirector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateVoteLocked(int displayId, int priority, Vote vote) {
|
private void updateVoteLocked(int displayId, int priority, Vote vote) {
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.i(TAG, "updateVoteLocked(displayId=" + displayId
|
Slog.i(TAG, "updateVoteLocked(displayId=" + displayId
|
||||||
+ ", priority=" + Vote.priorityToString(priority)
|
+ ", priority=" + Vote.priorityToString(priority)
|
||||||
+ ", vote=" + vote + ")");
|
+ ", vote=" + vote + ")");
|
||||||
@@ -537,7 +545,7 @@ public class DisplayModeDirector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (votes.size() == 0) {
|
if (votes.size() == 0) {
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.i(TAG, "No votes left for display " + displayId + ", removing.");
|
Slog.i(TAG, "No votes left for display " + displayId + ", removing.");
|
||||||
}
|
}
|
||||||
mVotesByDisplay.remove(displayId);
|
mVotesByDisplay.remove(displayId);
|
||||||
@@ -1287,6 +1295,7 @@ public class DisplayModeDirector {
|
|||||||
private boolean mShouldObserveAmbientLowChange;
|
private boolean mShouldObserveAmbientLowChange;
|
||||||
private boolean mShouldObserveDisplayHighChange;
|
private boolean mShouldObserveDisplayHighChange;
|
||||||
private boolean mShouldObserveAmbientHighChange;
|
private boolean mShouldObserveAmbientHighChange;
|
||||||
|
private boolean mLoggingEnabled;
|
||||||
|
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private Sensor mLightSensor;
|
private Sensor mLightSensor;
|
||||||
@@ -1303,7 +1312,6 @@ public class DisplayModeDirector {
|
|||||||
// changeable and low power mode off. After initialization, these states will
|
// changeable and low power mode off. After initialization, these states will
|
||||||
// be updated from the same handler thread.
|
// be updated from the same handler thread.
|
||||||
private int mDefaultDisplayState = Display.STATE_UNKNOWN;
|
private int mDefaultDisplayState = Display.STATE_UNKNOWN;
|
||||||
private boolean mIsDeviceActive = false;
|
|
||||||
private boolean mRefreshRateChangeable = false;
|
private boolean mRefreshRateChangeable = false;
|
||||||
private boolean mLowPowerModeEnabled = false;
|
private boolean mLowPowerModeEnabled = false;
|
||||||
|
|
||||||
@@ -1415,6 +1423,14 @@ public class DisplayModeDirector {
|
|||||||
mDeviceConfigDisplaySettings.startListening();
|
mDeviceConfigDisplaySettings.startListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLoggingEnabled(boolean loggingEnabled) {
|
||||||
|
if (mLoggingEnabled == loggingEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLoggingEnabled = loggingEnabled;
|
||||||
|
mLightSensorListener.setLoggingEnabled(loggingEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
public void onRefreshRateSettingChangedLocked(float min, float max) {
|
public void onRefreshRateSettingChangedLocked(float min, float max) {
|
||||||
boolean changeable = (max - min > 1f && max > 60f);
|
boolean changeable = (max - min > 1f && max > 60f);
|
||||||
if (mRefreshRateChangeable != changeable) {
|
if (mRefreshRateChangeable != changeable) {
|
||||||
@@ -1485,7 +1501,6 @@ public class DisplayModeDirector {
|
|||||||
pw.println(" mAmbientLux: " + mAmbientLux);
|
pw.println(" mAmbientLux: " + mAmbientLux);
|
||||||
pw.println(" mBrightness: " + mBrightness);
|
pw.println(" mBrightness: " + mBrightness);
|
||||||
pw.println(" mDefaultDisplayState: " + mDefaultDisplayState);
|
pw.println(" mDefaultDisplayState: " + mDefaultDisplayState);
|
||||||
pw.println(" mIsDeviceActive: " + mIsDeviceActive);
|
|
||||||
pw.println(" mLowPowerModeEnabled: " + mLowPowerModeEnabled);
|
pw.println(" mLowPowerModeEnabled: " + mLowPowerModeEnabled);
|
||||||
pw.println(" mRefreshRateChangeable: " + mRefreshRateChangeable);
|
pw.println(" mRefreshRateChangeable: " + mRefreshRateChangeable);
|
||||||
pw.println(" mShouldObserveDisplayLowChange: " + mShouldObserveDisplayLowChange);
|
pw.println(" mShouldObserveDisplayLowChange: " + mShouldObserveDisplayLowChange);
|
||||||
@@ -1691,7 +1706,7 @@ public class DisplayModeDirector {
|
|||||||
vote = Vote.forRefreshRates(mRefreshRateInHighZone, mRefreshRateInHighZone);
|
vote = Vote.forRefreshRates(mRefreshRateInHighZone, mRefreshRateInHighZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.d(TAG, "Display brightness " + mBrightness + ", ambient lux " + mAmbientLux
|
Slog.d(TAG, "Display brightness " + mBrightness + ", ambient lux " + mAmbientLux
|
||||||
+ ", Vote " + vote);
|
+ ", Vote " + vote);
|
||||||
}
|
}
|
||||||
@@ -1720,6 +1735,11 @@ public class DisplayModeDirector {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setDefaultDisplayState(int state) {
|
public void setDefaultDisplayState(int state) {
|
||||||
|
if (mLoggingEnabled) {
|
||||||
|
Slog.d(TAG, "setDefaultDisplayState: mDefaultDisplayState = "
|
||||||
|
+ mDefaultDisplayState + ", state = " + state);
|
||||||
|
}
|
||||||
|
|
||||||
if (mDefaultDisplayState != state) {
|
if (mDefaultDisplayState != state) {
|
||||||
mDefaultDisplayState = state;
|
mDefaultDisplayState = state;
|
||||||
updateSensorStatus();
|
updateSensorStatus();
|
||||||
@@ -1731,36 +1751,58 @@ public class DisplayModeDirector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mLoggingEnabled) {
|
||||||
|
Slog.d(TAG, "updateSensorStatus: mShouldObserveAmbientLowChange = "
|
||||||
|
+ mShouldObserveAmbientLowChange + ", mShouldObserveAmbientHighChange = "
|
||||||
|
+ mShouldObserveAmbientHighChange);
|
||||||
|
Slog.d(TAG, "updateSensorStatus: mLowPowerModeEnabled = "
|
||||||
|
+ mLowPowerModeEnabled + ", mRefreshRateChangeable = "
|
||||||
|
+ mRefreshRateChangeable);
|
||||||
|
}
|
||||||
|
|
||||||
if ((mShouldObserveAmbientLowChange || mShouldObserveAmbientHighChange)
|
if ((mShouldObserveAmbientLowChange || mShouldObserveAmbientHighChange)
|
||||||
&& isDeviceActive() && !mLowPowerModeEnabled && mRefreshRateChangeable) {
|
&& isDeviceActive() && !mLowPowerModeEnabled && mRefreshRateChangeable) {
|
||||||
mSensorManager.registerListener(mLightSensorListener,
|
mSensorManager.registerListener(mLightSensorListener,
|
||||||
mLightSensor, LIGHT_SENSOR_RATE_MS * 1000, mHandler);
|
mLightSensor, LIGHT_SENSOR_RATE_MS * 1000, mHandler);
|
||||||
|
if (mLoggingEnabled) {
|
||||||
|
Slog.d(TAG, "updateSensorStatus: registerListener");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mLightSensorListener.removeCallbacks();
|
mLightSensorListener.removeCallbacks();
|
||||||
mSensorManager.unregisterListener(mLightSensorListener);
|
mSensorManager.unregisterListener(mLightSensorListener);
|
||||||
|
if (mLoggingEnabled) {
|
||||||
|
Slog.d(TAG, "updateSensorStatus: unregisterListener");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDeviceActive() {
|
private boolean isDeviceActive() {
|
||||||
mIsDeviceActive = mInjector.isDeviceInteractive(mContext);
|
return mDefaultDisplayState == Display.STATE_ON;
|
||||||
return (mDefaultDisplayState == Display.STATE_ON)
|
|
||||||
&& mIsDeviceActive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class LightSensorEventListener implements SensorEventListener {
|
private final class LightSensorEventListener implements SensorEventListener {
|
||||||
final private static int INJECT_EVENTS_INTERVAL_MS = LIGHT_SENSOR_RATE_MS;
|
final private static int INJECT_EVENTS_INTERVAL_MS = LIGHT_SENSOR_RATE_MS;
|
||||||
private float mLastSensorData;
|
private float mLastSensorData;
|
||||||
private long mTimestamp;
|
private long mTimestamp;
|
||||||
|
private boolean mLoggingEnabled;
|
||||||
|
|
||||||
public void dumpLocked(PrintWriter pw) {
|
public void dumpLocked(PrintWriter pw) {
|
||||||
pw.println(" mLastSensorData: " + mLastSensorData);
|
pw.println(" mLastSensorData: " + mLastSensorData);
|
||||||
pw.println(" mTimestamp: " + formatTimestamp(mTimestamp));
|
pw.println(" mTimestamp: " + formatTimestamp(mTimestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLoggingEnabled(boolean loggingEnabled) {
|
||||||
|
if (mLoggingEnabled == loggingEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLoggingEnabled = loggingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
mLastSensorData = event.values[0];
|
mLastSensorData = event.values[0];
|
||||||
if (DEBUG) {
|
if (mLoggingEnabled) {
|
||||||
Slog.d(TAG, "On sensor changed: " + mLastSensorData);
|
Slog.d(TAG, "On sensor changed: " + mLastSensorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2009,8 +2051,6 @@ public class DisplayModeDirector {
|
|||||||
|
|
||||||
void registerPeakRefreshRateObserver(@NonNull ContentResolver cr,
|
void registerPeakRefreshRateObserver(@NonNull ContentResolver cr,
|
||||||
@NonNull ContentObserver observer);
|
@NonNull ContentObserver observer);
|
||||||
|
|
||||||
boolean isDeviceInteractive(@NonNull Context context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -2041,11 +2081,6 @@ public class DisplayModeDirector {
|
|||||||
cr.registerContentObserver(PEAK_REFRESH_RATE_URI, false /*notifyDescendants*/,
|
cr.registerContentObserver(PEAK_REFRESH_RATE_URI, false /*notifyDescendants*/,
|
||||||
observer, UserHandle.USER_SYSTEM);
|
observer, UserHandle.USER_SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDeviceInteractive(@NonNull Context ctx) {
|
|
||||||
return ctx.getSystemService(PowerManager.class).isInteractive();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -818,10 +818,5 @@ public class DisplayModeDirectorTest {
|
|||||||
PEAK_REFRESH_RATE_URI);
|
PEAK_REFRESH_RATE_URI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDeviceInteractive(@NonNull Context context) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user