sdk: livedisplay: add a method to determine whether night mode is enabled
LiveDisplayManager.getMode() returns MODE_AUTO when night mode is enabled automatically, so there's no way to determine if night is on when livedisplay changes automatically Change-Id: Ia47fc127232c2bb3b6634b55712060a919f8c9c1 Signed-off-by: Joey <joey@lineageos.org>
This commit is contained in:
@@ -52,4 +52,5 @@ interface ILiveDisplayService {
|
||||
HSIC getPictureAdjustment();
|
||||
HSIC getDefaultPictureAdjustment();
|
||||
boolean setPictureAdjustment(in HSIC adj);
|
||||
boolean isNight();
|
||||
}
|
||||
|
||||
@@ -482,4 +482,19 @@ public class LiveDisplayManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether night mode is enabled (be it automatic or manual)
|
||||
*/
|
||||
public boolean isNightModeEnabled() {
|
||||
// This method might be called before config has been set up
|
||||
// so a NPE would have been thrown, just report night mode is disabled instead
|
||||
try {
|
||||
return getMode() == MODE_NIGHT || sService.isNight();
|
||||
} catch (NullPointerException e) {
|
||||
Log.w(TAG, "Can\'t check whether night mode is enabled because the service isn\'t ready");
|
||||
} catch (RemoteException ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user