Move KeyCharacterMap from RefBase to shared_ptr.
Move KeyCharacterMap from RefBase and make it shared_ptr in EventHub
device when loaded from file.
A shared_ptr of KeyCharacterMap is returned by EventHub getKeyCharacterMap
to be shared in InputdeviceInfo.
Remove extra KeyCharacterMap in EventHub to save memory sapce.
Bug: 160010896
Test: atest inputflinger, atest libinput_tests
Change-Id: Ibb317ea0684e6af6e7a6d808f816fc4a05c7b421
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index c7685b7..60638ca 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -108,11 +108,11 @@
inline void setKeyboardType(int32_t keyboardType) { mKeyboardType = keyboardType; }
inline int32_t getKeyboardType() const { return mKeyboardType; }
- inline void setKeyCharacterMap(const sp<KeyCharacterMap>& value) {
+ inline void setKeyCharacterMap(const std::shared_ptr<KeyCharacterMap> value) {
mKeyCharacterMap = value;
}
- inline sp<KeyCharacterMap> getKeyCharacterMap() const {
+ inline const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap() const {
return mKeyCharacterMap;
}
@@ -136,7 +136,7 @@
bool mHasMic;
uint32_t mSources;
int32_t mKeyboardType;
- sp<KeyCharacterMap> mKeyCharacterMap;
+ std::shared_ptr<KeyCharacterMap> mKeyCharacterMap;
bool mHasVibrator;
bool mHasButtonUnderPad;