diff options
author | 2023-10-23 07:22:01 -0700 | |
---|---|---|
committer | 2023-10-24 07:19:10 -0700 | |
commit | c62948ec5d29035a930c174f2105e8c76581629a (patch) | |
tree | b245fb0a9e70cac723d8f21d9242e7fd2eddc1c4 /libs/input/KeyCharacterMap.cpp | |
parent | a5ac1e549a5439470971536015aa286eb0e293e3 (diff) |
Return unique_ptr from readFromParcel
When KeyCharacterMap is read from parcel, there's no need to force the
caller to store the object in a shared pointer. We can return a
unique_ptr first, and let the caller decide on how exactly that lifetime
should be managed.
Bug: 274058082
Test: presubmit
Change-Id: I8c5ec1e32a9304f6ad186bc0279f4c7bcbab77d8
Diffstat (limited to 'libs/input/KeyCharacterMap.cpp')
-rw-r--r-- | libs/input/KeyCharacterMap.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp index a4cd239a92..e2feabcbbe 100644 --- a/libs/input/KeyCharacterMap.cpp +++ b/libs/input/KeyCharacterMap.cpp @@ -613,14 +613,14 @@ void KeyCharacterMap::addLockedMetaKey(Vector<KeyEvent>& outEvents, } #ifdef __linux__ -std::shared_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) { +std::unique_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return nullptr; } std::string loadFileName = parcel->readCString(); - std::shared_ptr<KeyCharacterMap> map = - std::shared_ptr<KeyCharacterMap>(new KeyCharacterMap(loadFileName)); + std::unique_ptr<KeyCharacterMap> map = + std::make_unique<KeyCharacterMap>(KeyCharacterMap(loadFileName)); map->mType = static_cast<KeyCharacterMap::KeyboardType>(parcel->readInt32()); map->mLayoutOverlayApplied = parcel->readBool(); size_t numKeys = parcel->readInt32(); |