diff options
author | 2020-01-23 12:45:10 +0900 | |
---|---|---|
committer | 2020-02-26 04:00:15 +0000 | |
commit | 2d5878e69b6df009a936ab29710ef00673bb7b0a (patch) | |
tree | 1892ed9c2d147f7af66051d9792bb50b675ebce7 /libs/binder/AppOpsManager.cpp | |
parent | 331af0119f577cfe409be88363b0ff7864ec3d60 (diff) |
Use std::optional for @nullable (AIDL)
Previously, nullable types were mapped to std::unique_ptr for C++
backend. But std::unique_ptr typically involves unnecessary alloc/dealloc.
For example, if nullable string is represented in unique_ptr<string>, we
should do "unique_ptr<string>(new string(value))" to set a value.
To avoid breaking all hand-written parcelables, only new read/write
functions are added to Parcel class and they are used only by
aidl-generated code and their implementations.
Bug: 144773267
Test: build/flash/boot
atest --test-mapping frameworks/native/libs/binder
Merged-In: I2c801e3b69f2f8ccf44267f15cbf79e1d8fbf19e
Change-Id: I2c801e3b69f2f8ccf44267f15cbf79e1d8fbf19e
(cherry picked from commit 149be4a25ef423491c73dfc7bfd95e8177e9b4f8)
Exempt-From-Owner-Approval: CP from master
Diffstat (limited to 'libs/binder/AppOpsManager.cpp')
-rw-r--r-- | libs/binder/AppOpsManager.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp index aeca12b582..4ab144bdf1 100644 --- a/libs/binder/AppOpsManager.cpp +++ b/libs/binder/AppOpsManager.cpp @@ -115,12 +115,12 @@ int32_t AppOpsManager::checkAudioOpNoThrow(int32_t op, int32_t usage, int32_t ui } int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) { - return noteOp(op, uid, callingPackage, std::unique_ptr<String16>(), + return noteOp(op, uid, callingPackage, {}, String16("Legacy AppOpsManager.noteOp call")); } int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage, - const std::unique_ptr<String16>& featureId, const String16& message) { + const std::optional<String16>& featureId, const String16& message) { sp<IAppOpsService> service = getService(); int32_t mode = service != nullptr ? service->noteOperation(op, uid, callingPackage, featureId, shouldCollectNotes(op), @@ -132,12 +132,12 @@ int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPa int32_t AppOpsManager::startOpNoThrow(int32_t op, int32_t uid, const String16& callingPackage, bool startIfModeDefault) { - return startOpNoThrow(op, uid, callingPackage, startIfModeDefault, std::unique_ptr<String16>(), + return startOpNoThrow(op, uid, callingPackage, startIfModeDefault, {}, String16("Legacy AppOpsManager.startOpNoThrow call")); } int32_t AppOpsManager::startOpNoThrow(int32_t op, int32_t uid, const String16& callingPackage, - bool startIfModeDefault, const std::unique_ptr<String16>& featureId, + bool startIfModeDefault, const std::optional<String16>& featureId, const String16& message) { sp<IAppOpsService> service = getService(); int32_t mode = service != nullptr @@ -149,11 +149,11 @@ int32_t AppOpsManager::startOpNoThrow(int32_t op, int32_t uid, const String16& c } void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) { - finishOp(op, uid, callingPackage, std::unique_ptr<String16>()); + finishOp(op, uid, callingPackage, {}); } void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage, - const std::unique_ptr<String16>& callingFeatureId) { + const std::optional<String16>& callingFeatureId) { sp<IAppOpsService> service = getService(); if (service != nullptr) { service->finishOperation(getClientId(), op, uid, callingPackage, callingFeatureId); |