From 53be7f4db497a05256407bd4c499a8fafc8e095d 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 Change-Id: I90cf2ce1193c479179687d71a5c1416f6cdf0b16 --- cmds/idmap2/idmap2d/Idmap2Service.cpp | 6 +++--- cmds/idmap2/idmap2d/Idmap2Service.h | 4 ++-- services/incremental/IncrementalService.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 4aabf8399a253..33c88808247c7 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 94d2af49260cf..047353f52590f 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" @@ -46,7 +46,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) override; + std::optional* _aidl_return) override; }; } // namespace android::os diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index 414c66c866db3..77e35207b6ac6 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -1013,7 +1013,7 @@ bool IncrementalService::prepareDataLoader(IncrementalService::IncFsMount& ifs, return false; } FileSystemControlParcel fsControlParcel; - fsControlParcel.incremental = std::make_unique(); + fsControlParcel.incremental = IncrementalFileSystemControlParcel(); fsControlParcel.incremental->cmd.reset(base::unique_fd(::dup(ifs.control.cmd))); fsControlParcel.incremental->pendingReads.reset( base::unique_fd(::dup(ifs.control.pendingReads)));