Do not update nightmode from settings for car
- Storing is disabled, so restoration should be disabled as well.
- The old behavior is problematic in device like car as car should
stay in night mode even if there is a user switching.
- Add check for both mCarModeEnabled and mCar as mCarModeEnabled
actually means car dock which is not enabled in car env (mCar=true)
Bug: 155167849
Test: run user switching and confirm no night mode change in car
Change-Id: I03a4649ef0848d14b2af3da43178c0dfe3f26a32
Merged-In: I03a4649ef0848d14b2af3da43178c0dfe3f26a32
(cherry picked from commit 1a68753611)
This commit is contained in:
@@ -485,6 +485,9 @@ final class UiModeManagerService extends SystemService {
|
||||
* @return True if the new value is different from the old value. False otherwise.
|
||||
*/
|
||||
private boolean updateNightModeFromSettingsLocked(Context context, Resources res, int userId) {
|
||||
if (mCarModeEnabled || mCar) {
|
||||
return false;
|
||||
}
|
||||
int oldNightMode = mNightMode;
|
||||
if (mSetupWizardComplete) {
|
||||
mNightMode = Secure.getIntForUser(context.getContentResolver(),
|
||||
@@ -1015,7 +1018,7 @@ final class UiModeManagerService extends SystemService {
|
||||
|
||||
private void persistNightMode(int user) {
|
||||
// Only persist setting if not in car mode
|
||||
if (mCarModeEnabled) return;
|
||||
if (mCarModeEnabled || mCar) return;
|
||||
Secure.putIntForUser(getContext().getContentResolver(),
|
||||
Secure.UI_NIGHT_MODE, mNightMode, user);
|
||||
Secure.putLongForUser(getContext().getContentResolver(),
|
||||
@@ -1028,7 +1031,7 @@ final class UiModeManagerService extends SystemService {
|
||||
|
||||
private void persistNightModeOverrides(int user) {
|
||||
// Only persist setting if not in car mode
|
||||
if (mCarModeEnabled) return;
|
||||
if (mCarModeEnabled || mCar) return;
|
||||
Secure.putIntForUser(getContext().getContentResolver(),
|
||||
Secure.UI_NIGHT_MODE_OVERRIDE_ON, mOverrideNightModeOn ? 1 : 0, user);
|
||||
Secure.putIntForUser(getContext().getContentResolver(),
|
||||
@@ -1079,7 +1082,7 @@ final class UiModeManagerService extends SystemService {
|
||||
}
|
||||
|
||||
// Override night mode in power save mode if not in car mode
|
||||
if (mPowerSave && !mCarModeEnabled) {
|
||||
if (mPowerSave && !mCarModeEnabled && !mCar) {
|
||||
uiMode &= ~Configuration.UI_MODE_NIGHT_NO;
|
||||
uiMode |= Configuration.UI_MODE_NIGHT_YES;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user