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/InputClassifier.cpp b/services/inputflinger/InputClassifier.cpp
index a9cbd5a..29d8a0f 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputClassifier.cpp
@@ -345,7 +345,7 @@
// --- InputClassifier ---
-InputClassifier::InputClassifier(const sp<InputListenerInterface>& listener)
+InputClassifier::InputClassifier(InputListenerInterface& listener)
: mListener(listener), mHalDeathRecipient(new HalDeathRecipient(*this)) {}
void InputClassifier::setMotionClassifierEnabled(bool enabled) {
@@ -369,12 +369,12 @@
void InputClassifier::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
// pass through
- mListener->notifyConfigurationChanged(args);
+ mListener.notifyConfigurationChanged(args);
}
void InputClassifier::notifyKey(const NotifyKeyArgs* args) {
// pass through
- mListener->notifyKey(args);
+ mListener.notifyKey(args);
}
void InputClassifier::notifyMotion(const NotifyMotionArgs* args) {
@@ -382,28 +382,28 @@
// MotionClassifier is only used for touch events, for now
const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(*args);
if (!sendToMotionClassifier) {
- mListener->notifyMotion(args);
+ mListener.notifyMotion(args);
return;
}
NotifyMotionArgs newArgs(*args);
newArgs.classification = mMotionClassifier->classify(newArgs);
- mListener->notifyMotion(&newArgs);
+ mListener.notifyMotion(&newArgs);
}
void InputClassifier::notifySensor(const NotifySensorArgs* args) {
// pass through
- mListener->notifySensor(args);
+ mListener.notifySensor(args);
}
void InputClassifier::notifyVibratorState(const NotifyVibratorStateArgs* args) {
// pass through
- mListener->notifyVibratorState(args);
+ mListener.notifyVibratorState(args);
}
void InputClassifier::notifySwitch(const NotifySwitchArgs* args) {
// pass through
- mListener->notifySwitch(args);
+ mListener.notifySwitch(args);
}
void InputClassifier::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
@@ -412,12 +412,12 @@
mMotionClassifier->reset(*args);
}
// continue to next stage
- mListener->notifyDeviceReset(args);
+ mListener.notifyDeviceReset(args);
}
void InputClassifier::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
// pass through
- mListener->notifyPointerCaptureChanged(args);
+ mListener.notifyPointerCaptureChanged(args);
}
void InputClassifier::setMotionClassifier(