Merge "Replace InputManager.getInstance() with getSystemService() from context"

This commit is contained in:
Asmita Poddar
2023-02-22 09:10:33 +00:00
committed by Android (Google) Code Review
10 changed files with 15 additions and 14 deletions

View File

@@ -403,7 +403,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
InputDevice.SOURCE_KEYBOARD);
ev.setDisplayId(mContext.getDisplay().getDisplayId());
if (!InputManager.getInstance()
if (!mContext.getSystemService(InputManager.class)
.injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC)) {
Log.e(TAG, "Inject input event fail");
}

View File

@@ -64,8 +64,8 @@ class BubblesNavBarGestureTracker {
stopInternal();
mInputMonitor = InputManager.getInstance().monitorGestureInput(GESTURE_MONITOR,
mContext.getDisplayId());
mInputMonitor = mContext.getSystemService(InputManager.class)
.monitorGestureInput(GESTURE_MONITOR, mContext.getDisplayId());
InputChannel inputChannel = mInputMonitor.getInputChannel();
BubblesNavBarMotionEventHandler motionEventHandler =

View File

@@ -228,7 +228,7 @@ public class PipResizeGestureHandler {
if (mIsEnabled) {
// Register input event receiver
mInputMonitor = InputManager.getInstance().monitorGestureInput(
mInputMonitor = mContext.getSystemService(InputManager.class).monitorGestureInput(
"pip-resize", mDisplayId);
try {
mMainExecutor.executeBlocking(() -> {

View File

@@ -505,7 +505,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
}
private void createInputChannel(int displayId) {
final InputManager inputManager = InputManager.getInstance();
final InputManager inputManager = mContext.getSystemService(InputManager.class);
final InputMonitor inputMonitor =
mInputMonitorFactory.create(inputManager, mContext);
final EventReceiver eventReceiver = new EventReceiver(inputMonitor,

View File

@@ -65,7 +65,7 @@ class TaskOperations {
InputDevice.SOURCE_KEYBOARD);
ev.setDisplayId(mContext.getDisplay().getDisplayId());
if (!InputManager.getInstance()
if (!mContext.getSystemService(InputManager.class)
.injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC)) {
Log.e(TAG, "Inject input event fail");
}

View File

@@ -58,13 +58,13 @@ import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.StatusBarWindowCallback;
import com.android.systemui.util.Assert;
import dagger.Lazy;
import java.util.Locale;
import java.util.Optional;
import javax.inject.Inject;
import dagger.Lazy;
/**
* Class to register system actions with accessibility framework.
*/
@@ -473,7 +473,7 @@ public class SystemActions implements CoreStartable {
KeyEvent event = KeyEvent.obtain(downTime, time, action, keyCode, 0, 0,
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_FROM_SYSTEM,
InputDevice.SOURCE_KEYBOARD, null);
InputManager.getInstance()
mContext.getSystemService(InputManager.class)
.injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
event.recycle();
}

View File

@@ -580,7 +580,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
}
// Register input event receiver
mInputMonitor = InputManager.getInstance().monitorGestureInput(
mInputMonitor = mContext.getSystemService(InputManager.class).monitorGestureInput(
"edge-swipe", mDisplayId);
mInputEventReceiver = new InputChannelCompat.InputEventReceiver(
mInputMonitor.getInputChannel(), Looper.getMainLooper(),
@@ -1039,7 +1039,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
InputDevice.SOURCE_KEYBOARD);
ev.setDisplayId(mContext.getDisplay().getDisplayId());
return InputManager.getInstance()
return mContext.getSystemService(InputManager.class)
.injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
}

View File

@@ -356,7 +356,7 @@ public final class KeyboardShortcuts {
* Keyboard with its default map.
*/
private void retrieveKeyCharacterMap(int deviceId) {
final InputManager inputManager = InputManager.getInstance();
final InputManager inputManager = mContext.getSystemService(InputManager.class);
mBackupKeyCharacterMap = inputManager.getInputDevice(-1).getKeyCharacterMap();
if (deviceId != -1) {
final InputDevice inputDevice = inputManager.getInputDevice(deviceId);

View File

@@ -335,7 +335,7 @@ public class SystemActionPerformer {
KeyEvent event = KeyEvent.obtain(downTime, time, action, keyCode, 0, 0,
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_FROM_SYSTEM,
InputDevice.SOURCE_KEYBOARD, null);
InputManager.getInstance()
mContext.getSystemService(InputManager.class)
.injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
event.recycle();
}

View File

@@ -7357,7 +7357,8 @@ public class WindowManagerService extends IWindowManager.Stub
ProtoLog.w(WM_ERROR, "unable to restore pointer icon");
}
} else {
InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_DEFAULT);
mContext.getSystemService(InputManager.class)
.setPointerIconType(PointerIcon.TYPE_DEFAULT);
}
}