Handle pointer location setting in InputSettingsObserver

We got a report that the pointer location developer option is not
being properly set per user; testing it confirmed that show
touches worked as expected while pointer location did not. After
investigating, the pointer location setting was being applied in
`WindowManagerService`, which generally deals with global settings,
while all the input settings are handled in `InputSettingsObserver`.

This CL moves the handling of the pointer location setting to
`InputSettingsObserver`, which seems more natural.

Test: confirmed that pointer location is now properly set on all users
Bug: 288023565
Change-Id: Ic2ecd890bd32e60a2fae4d5d40d4ff8f785ee3cc
This commit is contained in:
Josep del Rio
2023-06-21 13:27:26 +00:00
committed by Josep del Río
parent bce8f1329e
commit 6413ad2c2e
4 changed files with 31 additions and 24 deletions

View File

@@ -2799,6 +2799,11 @@ public class InputManagerService extends IInputManager.Stub
*/
void notifyConfigurationChanged();
/**
* This callback is invoked when the pointer location changes.
*/
void notifyPointerLocationChanged(boolean pointerLocationEnabled);
/**
* This callback is invoked when the camera lens cover switch changes state.
* @param whenNanos the time when the change occurred
@@ -3381,6 +3386,10 @@ public class InputManagerService extends IInputManager.Stub
}
}
void updatePointerLocationEnabled(boolean enabled) {
mWindowManagerCallbacks.notifyPointerLocationChanged(enabled);
}
void updateFocusEventDebugViewEnabled(boolean enabled) {
FocusEventDebugView view;
synchronized (mFocusEventDebugViewLock) {

View File

@@ -67,6 +67,8 @@ class InputSettingsObserver extends ContentObserver {
(reason) -> updateTouchpadRightClickZoneEnabled()),
Map.entry(Settings.System.getUriFor(Settings.System.SHOW_TOUCHES),
(reason) -> updateShowTouches()),
Map.entry(Settings.System.getUriFor(Settings.System.POINTER_LOCATION),
(reason) -> updatePointerLocation()),
Map.entry(
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON),
(reason) -> updateAccessibilityLargePointer()),
@@ -149,6 +151,11 @@ class InputSettingsObserver extends ContentObserver {
mNative.setShowTouches(getBoolean(Settings.System.SHOW_TOUCHES, false));
}
private void updatePointerLocation() {
mService.updatePointerLocationEnabled(
getBoolean(Settings.System.POINTER_LOCATION, false));
}
private void updateShowKeyPresses() {
mService.updateFocusEventDebugViewEnabled(
getBoolean(Settings.System.SHOW_KEY_PRESSES, false));

View File

@@ -128,6 +128,21 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal
}
}
/** Notifies that the pointer location configuration has changed. */
@Override
public void notifyPointerLocationChanged(boolean pointerLocationEnabled) {
if (mService.mPointerLocationEnabled == pointerLocationEnabled) {
return;
}
synchronized (mService.mGlobalLock) {
mService.mPointerLocationEnabled = pointerLocationEnabled;
mService.mRoot.forAllDisplayPolicies(
p -> p.setPointerLocationEnabled(mService.mPointerLocationEnabled)
);
}
}
/** Notifies that the lid switch changed state. */
@Override
public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {

View File

@@ -763,8 +763,6 @@ public class WindowManagerService extends IWindowManager.Stub
Settings.Secure.getUriFor(Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS);
private final Uri mPolicyControlUri =
Settings.Global.getUriFor(Settings.Global.POLICY_CONTROL);
private final Uri mPointerLocationUri =
Settings.System.getUriFor(Settings.System.POINTER_LOCATION);
private final Uri mForceDesktopModeOnExternalDisplaysUri = Settings.Global.getUriFor(
Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS);
private final Uri mFreeformWindowUri = Settings.Global.getUriFor(
@@ -792,7 +790,6 @@ public class WindowManagerService extends IWindowManager.Stub
resolver.registerContentObserver(mImmersiveModeConfirmationsUri, false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(mPolicyControlUri, false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(mPointerLocationUri, false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(mForceDesktopModeOnExternalDisplaysUri, false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(mFreeformWindowUri, false, this, UserHandle.USER_ALL);
@@ -816,11 +813,6 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
if (mPointerLocationUri.equals(uri)) {
updatePointerLocation();
return;
}
if (mForceDesktopModeOnExternalDisplaysUri.equals(uri)) {
updateForceDesktopModeOnExternalDisplays();
return;
@@ -869,7 +861,6 @@ public class WindowManagerService extends IWindowManager.Stub
void loadSettings() {
updateSystemUiSettings(false /* handleChange */);
updatePointerLocation();
updateMaximumObscuringOpacityForTouch();
}
@@ -900,21 +891,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
void updatePointerLocation() {
ContentResolver resolver = mContext.getContentResolver();
final boolean enablePointerLocation = Settings.System.getIntForUser(resolver,
Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT) != 0;
if (mPointerLocationEnabled == enablePointerLocation) {
return;
}
mPointerLocationEnabled = enablePointerLocation;
synchronized (mGlobalLock) {
mRoot.forAllDisplayPolicies(
p -> p.setPointerLocationEnabled(mPointerLocationEnabled));
}
}
void updateForceDesktopModeOnExternalDisplays() {
ContentResolver resolver = mContext.getContentResolver();
final boolean enableForceDesktopMode = Settings.Global.getInt(resolver,