Update bootanim theme flag on ui_night_mode change

In case it becomes inconsistent with mNightMode in
UiModeManagerService in the future

Test: atest google/perf/boottime/boottime-test -v
Bug: 137293865
Change-Id: Ib923a483f0817aa6a75d407bd09c32b960083146
This commit is contained in:
Beverly
2019-07-22 17:15:58 -04:00
committed by Beverly Tai
parent 73057fd3e3
commit 4f2ff8e959

View File

@@ -48,7 +48,6 @@ import android.os.ShellCallback;
import android.os.ShellCommand;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings.Secure;
import android.service.dreams.Sandman;
import android.service.vr.IVrManager;
@@ -218,6 +217,15 @@ final class UiModeManagerService extends SystemService {
}
};
private final ContentObserver mDarkThemeObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
int mode = Secure.getIntForUser(getContext().getContentResolver(), Secure.UI_NIGHT_MODE,
mNightMode, 0);
SystemProperties.set(SYSTEM_PROPERTY_DEVICE_THEME, Integer.toString(mode));
}
};
@Override
public void onSwitchUser(int userHandle) {
super.onSwitchUser(userHandle);
@@ -293,6 +301,9 @@ final class UiModeManagerService extends SystemService {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
context.registerReceiver(new UserSwitchedReceiver(), filter, null, mHandler);
context.getContentResolver().registerContentObserver(Secure.getUriFor(Secure.UI_NIGHT_MODE),
false, mDarkThemeObserver, 0);
}
// Records whether setup wizard has happened or not and adds an observer for this user if not.
@@ -417,11 +428,6 @@ final class UiModeManagerService extends SystemService {
if (!mCarModeEnabled) {
Secure.putIntForUser(getContext().getContentResolver(),
Secure.UI_NIGHT_MODE, mode, user);
if (UserManager.get(getContext()).isPrimaryUser()) {
SystemProperties.set(SYSTEM_PROPERTY_DEVICE_THEME,
Integer.toString(mode));
}
}
mNightMode = mode;