From 2d5878e69b6df009a936ab29710ef00673bb7b0a Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 23 Jan 2020 12:45:10 +0900 Subject: 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, we should do "unique_ptr(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 --- libs/binder/AppOpsManager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libs/binder/AppOpsManager.cpp') 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(), + 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& featureId, const String16& message) { + const std::optional& featureId, const String16& message) { sp 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(), + 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& featureId, + bool startIfModeDefault, const std::optional& featureId, const String16& message) { sp 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()); + finishOp(op, uid, callingPackage, {}); } void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage, - const std::unique_ptr& callingFeatureId) { + const std::optional& callingFeatureId) { sp service = getService(); if (service != nullptr) { service->finishOperation(getClientId(), op, uid, callingPackage, callingFeatureId); -- cgit v1.2.3-59-g8ed1b