Guard CDS settings against USER_NULL
Bug: 129421955 Test: manual Change-Id: I25b2255d903a5448cfee1e24e03ac75652ce7733
This commit is contained in:
@@ -105,10 +105,12 @@ public final class ColorDisplayService extends SystemService {
|
||||
*/
|
||||
private static final long TRANSITION_DURATION = 3000L;
|
||||
|
||||
private static final int MSG_APPLY_NIGHT_DISPLAY_IMMEDIATE = 0;
|
||||
private static final int MSG_APPLY_NIGHT_DISPLAY_ANIMATED = 1;
|
||||
private static final int MSG_APPLY_GLOBAL_SATURATION = 2;
|
||||
private static final int MSG_APPLY_DISPLAY_WHITE_BALANCE = 3;
|
||||
private static final int MSG_USER_CHANGED = 0;
|
||||
private static final int MSG_SET_UP = 1;
|
||||
private static final int MSG_APPLY_NIGHT_DISPLAY_IMMEDIATE = 2;
|
||||
private static final int MSG_APPLY_NIGHT_DISPLAY_ANIMATED = 3;
|
||||
private static final int MSG_APPLY_GLOBAL_SATURATION = 4;
|
||||
private static final int MSG_APPLY_DISPLAY_WHITE_BALANCE = 5;
|
||||
|
||||
/**
|
||||
* Return value if a setting has not been set.
|
||||
@@ -186,7 +188,7 @@ public final class ColorDisplayService extends SystemService {
|
||||
|
||||
// Register listeners now that boot is complete.
|
||||
if (mCurrentUser != UserHandle.USER_NULL && mUserSetupObserver == null) {
|
||||
setUp();
|
||||
mHandler.sendEmptyMessage(MSG_SET_UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,7 +198,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
super.onStartUser(userHandle);
|
||||
|
||||
if (mCurrentUser == UserHandle.USER_NULL) {
|
||||
onUserChanged(userHandle);
|
||||
final Message message = mHandler.obtainMessage(MSG_USER_CHANGED);
|
||||
message.arg1 = userHandle;
|
||||
mHandler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +208,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
public void onSwitchUser(int userHandle) {
|
||||
super.onSwitchUser(userHandle);
|
||||
|
||||
onUserChanged(userHandle);
|
||||
final Message message = mHandler.obtainMessage(MSG_USER_CHANGED);
|
||||
message.arg1 = userHandle;
|
||||
mHandler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,7 +218,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
super.onStopUser(userHandle);
|
||||
|
||||
if (mCurrentUser == userHandle) {
|
||||
onUserChanged(UserHandle.USER_NULL);
|
||||
final Message message = mHandler.obtainMessage(MSG_USER_CHANGED);
|
||||
message.arg1 = UserHandle.USER_NULL;
|
||||
mHandler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +270,7 @@ public final class ColorDisplayService extends SystemService {
|
||||
|
||||
// Listen for external changes to any of the settings.
|
||||
if (mContentObserver == null) {
|
||||
mContentObserver = new ContentObserver(new Handler(DisplayThread.get().getLooper())) {
|
||||
mContentObserver = new ContentObserver(mHandler) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
super.onChange(selfChange, uri);
|
||||
@@ -467,6 +475,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
* Apply the accessibility daltonizer transform based on the settings value.
|
||||
*/
|
||||
private void onAccessibilityDaltonizerChanged() {
|
||||
if (mCurrentUser == UserHandle.USER_NULL) {
|
||||
return;
|
||||
}
|
||||
final boolean enabled = Secure.getIntForUser(getContext().getContentResolver(),
|
||||
Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0, mCurrentUser) != 0;
|
||||
final int daltonizerMode = enabled ? Secure.getIntForUser(getContext().getContentResolver(),
|
||||
@@ -490,6 +501,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
* Apply the accessibility inversion transform based on the settings value.
|
||||
*/
|
||||
private void onAccessibilityInversionChanged() {
|
||||
if (mCurrentUser == UserHandle.USER_NULL) {
|
||||
return;
|
||||
}
|
||||
final boolean enabled = Secure.getIntForUser(getContext().getContentResolver(),
|
||||
Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0, mCurrentUser) != 0;
|
||||
final DisplayTransformManager dtm = getLocalService(DisplayTransformManager.class);
|
||||
@@ -597,6 +611,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
}
|
||||
|
||||
private boolean isDisplayWhiteBalanceSettingEnabled() {
|
||||
if (mCurrentUser == UserHandle.USER_NULL) {
|
||||
return false;
|
||||
}
|
||||
return Secure.getIntForUser(getContext().getContentResolver(),
|
||||
Secure.DISPLAY_WHITE_BALANCE_ENABLED, 0, mCurrentUser) == 1;
|
||||
}
|
||||
@@ -648,6 +665,9 @@ public final class ColorDisplayService extends SystemService {
|
||||
}
|
||||
|
||||
private int getNightDisplayAutoModeRawInternal() {
|
||||
if (mCurrentUser == UserHandle.USER_NULL) {
|
||||
return NOT_SET;
|
||||
}
|
||||
return Secure
|
||||
.getIntForUser(getContext().getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE,
|
||||
NOT_SET, mCurrentUser);
|
||||
@@ -1245,6 +1265,12 @@ public final class ColorDisplayService extends SystemService {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_USER_CHANGED:
|
||||
onUserChanged(msg.arg1);
|
||||
break;
|
||||
case MSG_SET_UP:
|
||||
setUp();
|
||||
break;
|
||||
case MSG_APPLY_GLOBAL_SATURATION:
|
||||
mGlobalSaturationTintController.setMatrix(msg.arg1);
|
||||
applyTint(mGlobalSaturationTintController, false);
|
||||
|
||||
Reference in New Issue
Block a user