From f452968ae8f26a1d7ee062f4f63447c99671a6d7 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 23 Jan 2020 13:29:22 +0900 Subject: [PATCH] Use optional for nullable types AIDL generates optional for nullable T types for C++, which is more efficient and idomatic and easy to use. Bug: 144773267 Test: build/flash/boot Merged-In: I90cf2ce1193c479179687d71a5c1416f6cdf0b16 Change-Id: I90cf2ce1193c479179687d71a5c1416f6cdf0b16 (cherry picked from commit ff7f4279bd7fa33577f5f4d46aa9de322fb625d4) Exempt-From-Owner-Approval: CP from master --- cmds/idmap2/idmap2d/Idmap2Service.cpp | 6 +++--- cmds/idmap2/idmap2d/Idmap2Service.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 8ee79f61520aa..d7237763a2e51 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -113,10 +113,10 @@ Status Idmap2Service::verifyIdmap(const std::string& overlay_apk_path, Status Idmap2Service::createIdmap(const std::string& target_apk_path, const std::string& overlay_apk_path, int32_t fulfilled_policies, bool enforce_overlayable, int32_t user_id ATTRIBUTE_UNUSED, - std::unique_ptr* _aidl_return) { + std::optional* _aidl_return) { assert(_aidl_return); SYSTRACE << "Idmap2Service::createIdmap " << target_apk_path << " " << overlay_apk_path; - _aidl_return->reset(nullptr); + _aidl_return->reset(); const PolicyBitmask policy_bitmask = ConvertAidlArgToPolicyBitmask(fulfilled_policies); @@ -155,7 +155,7 @@ Status Idmap2Service::createIdmap(const std::string& target_apk_path, return error("failed to write to idmap path " + idmap_path); } - *_aidl_return = std::make_unique(idmap_path); + *_aidl_return = idmap_path; return ok(); } diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h index 1aab0598449bd..73a236a961af6 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.h +++ b/cmds/idmap2/idmap2d/Idmap2Service.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include "android/os/BnIdmap2.h" @@ -45,7 +45,7 @@ class Idmap2Service : public BinderService, public BnIdmap2 { binder::Status createIdmap(const std::string& target_apk_path, const std::string& overlay_apk_path, int32_t fulfilled_policies, bool enforce_overlayable, int32_t user_id, - std::unique_ptr* _aidl_return); + std::optional* _aidl_return); }; } // namespace android::os