Skip to content

Commit f8a4189

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Mark some functions in InputReader code as const" into main
2 parents 406adf0 + c19c66a commit f8a4189

14 files changed

Lines changed: 24 additions & 21 deletions

services/inputflinger/reader/InputReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ EventHubInterface* InputReader::ContextImpl::getEventHub() {
10851085
return mReader->mEventHub.get();
10861086
}
10871087

1088-
int32_t InputReader::ContextImpl::getNextId() {
1088+
int32_t InputReader::ContextImpl::getNextId() const {
10891089
return mIdGenerator.nextId();
10901090
}
10911091

services/inputflinger/reader/include/InputReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class InputReader : public InputReaderInterface {
154154
REQUIRES(mReader->mLock) override;
155155
InputReaderPolicyInterface* getPolicy() REQUIRES(mReader->mLock) override;
156156
EventHubInterface* getEventHub() REQUIRES(mReader->mLock) override;
157-
int32_t getNextId() NO_THREAD_SAFETY_ANALYSIS override;
157+
int32_t getNextId() const NO_THREAD_SAFETY_ANALYSIS override;
158158
void updateLedMetaState(int32_t metaState) REQUIRES(mReader->mLock) override;
159159
int32_t getLedMetaState() REQUIRES(mReader->mLock) REQUIRES(mLock) override;
160160
void setPreventingTouchpadTaps(bool prevent) REQUIRES(mReader->mLock)

services/inputflinger/reader/include/InputReaderContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class InputReaderContext {
5555
virtual InputReaderPolicyInterface* getPolicy() = 0;
5656
virtual EventHubInterface* getEventHub() = 0;
5757

58-
virtual int32_t getNextId() = 0;
58+
virtual int32_t getNextId() const = 0;
5959

6060
virtual void updateLedMetaState(int32_t metaState) = 0;
6161
virtual int32_t getLedMetaState() = 0;

services/inputflinger/reader/mapper/CursorInputMapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int32_t CursorInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCod
419419
}
420420
}
421421

422-
std::optional<ui::LogicalDisplayId> CursorInputMapper::getAssociatedDisplayId() {
422+
std::optional<ui::LogicalDisplayId> CursorInputMapper::getAssociatedDisplayId() const {
423423
return mDisplayId;
424424
}
425425

services/inputflinger/reader/mapper/CursorInputMapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CursorInputMapper : public InputMapper {
6363

6464
virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode) override;
6565

66-
virtual std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() override;
66+
virtual std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() const override;
6767

6868
private:
6969
// Amount that trackball needs to move in order to generate a key event.

services/inputflinger/reader/mapper/InputMapper.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ class InputMapper {
6666

6767
virtual ~InputMapper();
6868

69-
inline int32_t getDeviceId() { return mDeviceContext.getId(); }
69+
inline int32_t getDeviceId() const { return mDeviceContext.getId(); }
7070
inline InputDeviceContext& getDeviceContext() { return mDeviceContext; }
7171
inline InputDeviceContext& getDeviceContext() const { return mDeviceContext; };
7272
inline const std::string getDeviceName() const { return mDeviceContext.getName(); }
7373
inline InputReaderContext* getContext() { return mDeviceContext.getContext(); }
74+
inline const InputReaderContext* getContext() const { return mDeviceContext.getContext(); }
7475
inline InputReaderPolicyInterface* getPolicy() { return getContext()->getPolicy(); }
7576

7677
virtual uint32_t getSources() const = 0;
@@ -114,7 +115,9 @@ class InputMapper {
114115

115116
[[nodiscard]] virtual std::list<NotifyArgs> updateExternalStylusState(const StylusState& state);
116117

117-
virtual std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() { return std::nullopt; }
118+
virtual std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() const {
119+
return std::nullopt;
120+
}
118121
virtual void updateLedState(bool reset) {}
119122

120123
virtual std::optional<HardwareProperties> getTouchpadHardwareProperties();

services/inputflinger/reader/mapper/KeyboardInputMapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ uint32_t KeyboardInputMapper::getSources() const {
104104
return mMapperSource;
105105
}
106106

107-
ui::Rotation KeyboardInputMapper::getOrientation() {
107+
ui::Rotation KeyboardInputMapper::getOrientation() const {
108108
if (mViewport) {
109109
return mViewport->orientation;
110110
}
111111
return ui::ROTATION_0;
112112
}
113113

114-
ui::LogicalDisplayId KeyboardInputMapper::getDisplayId() {
114+
ui::LogicalDisplayId KeyboardInputMapper::getDisplayId() const {
115115
if (mViewport) {
116116
return mViewport->displayId;
117117
}
@@ -471,7 +471,7 @@ void KeyboardInputMapper::updateLedStateForModifier(LedState& ledState, int32_t
471471
}
472472
}
473473

474-
std::optional<ui::LogicalDisplayId> KeyboardInputMapper::getAssociatedDisplayId() {
474+
std::optional<ui::LogicalDisplayId> KeyboardInputMapper::getAssociatedDisplayId() const {
475475
if (mViewport) {
476476
return std::make_optional(mViewport->displayId);
477477
}

services/inputflinger/reader/mapper/KeyboardInputMapper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class KeyboardInputMapper : public InputMapper {
4747
int32_t getKeyCodeForKeyLocation(int32_t locationKeyCode) const override;
4848

4949
int32_t getMetaState() override;
50-
std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() override;
50+
std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() const override;
5151
void updateLedState(bool reset) override;
5252

5353
private:
@@ -96,8 +96,8 @@ class KeyboardInputMapper : public InputMapper {
9696
void configureParameters();
9797
void dumpParameters(std::string& dump) const;
9898

99-
ui::Rotation getOrientation();
100-
ui::LogicalDisplayId getDisplayId();
99+
ui::Rotation getOrientation() const;
100+
ui::LogicalDisplayId getDisplayId() const;
101101

102102
[[nodiscard]] std::list<NotifyArgs> processKey(nsecs_t when, nsecs_t readTime, bool down,
103103
int32_t scanCode, int32_t usageCode);

services/inputflinger/reader/mapper/TouchInputMapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,7 +3666,7 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion(
36663666
int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState,
36673667
int32_t edgeFlags, const PropertiesArray& properties, const CoordsArray& coords,
36683668
const IdToIndexArray& idToIndex, BitSet32 idBits, int32_t changedId, float xPrecision,
3669-
float yPrecision, nsecs_t downTime, MotionClassification classification) {
3669+
float yPrecision, nsecs_t downTime, MotionClassification classification) const {
36703670
std::vector<PointerCoords> pointerCoords;
36713671
std::vector<PointerProperties> pointerProperties;
36723672
uint32_t pointerCount = 0;
@@ -3992,7 +3992,7 @@ bool TouchInputMapper::markSupportedKeyCodes(uint32_t sourceMask,
39923992
return true;
39933993
}
39943994

3995-
std::optional<ui::LogicalDisplayId> TouchInputMapper::getAssociatedDisplayId() {
3995+
std::optional<ui::LogicalDisplayId> TouchInputMapper::getAssociatedDisplayId() const {
39963996
return mParameters.hasAssociatedDisplay ? std::make_optional(mViewport.displayId)
39973997
: std::nullopt;
39983998
}

services/inputflinger/reader/mapper/TouchInputMapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class TouchInputMapper : public InputMapper {
185185
[[nodiscard]] std::list<NotifyArgs> timeoutExpired(nsecs_t when) override;
186186
[[nodiscard]] std::list<NotifyArgs> updateExternalStylusState(
187187
const StylusState& state) override;
188-
std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() override;
188+
std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() const override;
189189

190190
protected:
191191
CursorButtonAccumulator mCursorButtonAccumulator;
@@ -840,7 +840,7 @@ class TouchInputMapper : public InputMapper {
840840
int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState,
841841
int32_t edgeFlags, const PropertiesArray& properties, const CoordsArray& coords,
842842
const IdToIndexArray& idToIndex, BitSet32 idBits, int32_t changedId, float xPrecision,
843-
float yPrecision, nsecs_t downTime, MotionClassification classification);
843+
float yPrecision, nsecs_t downTime, MotionClassification classification) const;
844844

845845
// Returns if this touch device is a touch screen with an associated display.
846846
bool isTouchScreen();

0 commit comments

Comments
 (0)