Remove RefBase from InputListener interface
We don't need refbase for inputlisteners. Remove it, and switch to
references, which cannot be null. This way, we can avoid dereferencing
the pointers without checking for nullness.
Bug: 198472780
Test: atest inputflinger_tests
Change-Id: I2f469fd268472c7e78d36812353cff5c52a90163
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 22a0b57..fd33df9 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -399,7 +399,7 @@
// Send reset, unless this is the first time the device has been configured,
// in which case the reader will call reset itself after all mappers are ready.
NotifyDeviceResetArgs args(getContext()->getNextId(), when, getDeviceId());
- getListener()->notifyDeviceReset(&args);
+ getListener().notifyDeviceReset(&args);
}
}
@@ -1929,7 +1929,7 @@
NotifyKeyArgs args(getContext()->getNextId(), when, readTime, getDeviceId(),
AINPUT_SOURCE_KEYBOARD, mViewport.displayId, policyFlags, keyEventAction,
keyEventFlags, keyCode, scanCode, metaState, downTime);
- getListener()->notifyKey(&args);
+ getListener().notifyKey(&args);
}
void TouchInputMapper::abortTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags) {
@@ -2621,7 +2621,7 @@
metaState, buttonState, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, 1, &pointerProperties, &pointerCoords,
0, 0, x, y, mPointerGesture.downTime, /* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
// Update state.
@@ -3536,7 +3536,7 @@
&mPointerSimple.lastCoords, mOrientedXPrecision, mOrientedYPrecision,
xCursorPosition, yCursorPosition, mPointerSimple.downTime,
/* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
if (mPointerSimple.hovering && !hovering) {
@@ -3550,7 +3550,7 @@
&mPointerSimple.lastCoords, mOrientedXPrecision, mOrientedYPrecision,
xCursorPosition, yCursorPosition, mPointerSimple.downTime,
/* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
if (down) {
@@ -3566,7 +3566,7 @@
&mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
mOrientedXPrecision, mOrientedYPrecision, xCursorPosition,
yCursorPosition, mPointerSimple.downTime, /* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
// Send move.
@@ -3577,7 +3577,7 @@
&mPointerSimple.currentCoords, mOrientedXPrecision,
mOrientedYPrecision, xCursorPosition, yCursorPosition,
mPointerSimple.downTime, /* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
if (hovering) {
@@ -3592,7 +3592,7 @@
&mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
mOrientedXPrecision, mOrientedYPrecision, xCursorPosition,
yCursorPosition, mPointerSimple.downTime, /* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
// Send hover move.
@@ -3603,7 +3603,7 @@
&mPointerSimple.currentCoords, mOrientedXPrecision,
mOrientedYPrecision, xCursorPosition, yCursorPosition,
mPointerSimple.downTime, /* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
if (mCurrentRawState.rawVScroll || mCurrentRawState.rawHScroll) {
@@ -3625,7 +3625,7 @@
&pointerCoords, mOrientedXPrecision, mOrientedYPrecision,
xCursorPosition, yCursorPosition, mPointerSimple.downTime,
/* videoFrames */ {});
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
// Save state.
@@ -3703,7 +3703,7 @@
MotionClassification::NONE, edgeFlags, pointerCount, pointerProperties,
pointerCoords, xPrecision, yPrecision, xCursorPosition, yCursorPosition,
downTime, std::move(frames));
- getListener()->notifyMotion(&args);
+ getListener().notifyMotion(&args);
}
bool TouchInputMapper::updateMovedPointers(const PointerProperties* inProperties,