Use optional for nullable types

AIDL generates optional<T> for nullable T types for C++, which is more
efficient and idomatic and easy to use.

Bug: 144773267
Test: build/flash/boot
Merged-In: I98549c8614c9152d5d45e2f1f33f2f3c31a9bbbf
Change-Id: I98549c8614c9152d5d45e2f1f33f2f3c31a9bbbf
(cherry picked from commit 0568fd287cfc0affc8e985f21da3793cdda286a3)
This commit is contained in:
Jooyung Han 2020-01-23 13:23:26 +09:00
parent 39969f0288
commit d75a10ac6f
2 changed files with 6 additions and 6 deletions

View file

@ -795,7 +795,7 @@ binder::Status VoldNativeService::lockUserKey(int32_t userId) {
return translateBool(fscrypt_lock_user_key(userId));
}
binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::string>& uuid,
binder::Status VoldNativeService::prepareUserStorage(const std::optional<std::string>& uuid,
int32_t userId, int32_t userSerial,
int32_t flags) {
ENFORCE_SYSTEM_OR_ROOT;
@ -807,7 +807,7 @@ binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::
return translateBool(fscrypt_prepare_user_storage(uuid_, userId, userSerial, flags));
}
binder::Status VoldNativeService::destroyUserStorage(const std::unique_ptr<std::string>& uuid,
binder::Status VoldNativeService::destroyUserStorage(const std::optional<std::string>& uuid,
int32_t userId, int32_t flags) {
ENFORCE_SYSTEM_OR_ROOT;
std::string empty_string = "";
@ -944,9 +944,9 @@ binder::Status VoldNativeService::mountIncFs(
<< result.logFd;
using ParcelFileDescriptor = ::android::os::ParcelFileDescriptor;
using unique_fd = ::android::base::unique_fd;
_aidl_return->cmd = std::make_unique<ParcelFileDescriptor>(unique_fd(result.cmdFd));
_aidl_return->cmd = ParcelFileDescriptor(unique_fd(result.cmdFd));
if (result.logFd >= 0) {
_aidl_return->log = std::make_unique<ParcelFileDescriptor>(unique_fd(result.logFd));
_aidl_return->log = ParcelFileDescriptor(unique_fd(result.logFd));
}
return ok();
}

View file

@ -120,9 +120,9 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
const std::string& secret);
binder::Status lockUserKey(int32_t userId);
binder::Status prepareUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId,
binder::Status prepareUserStorage(const std::optional<std::string>& uuid, int32_t userId,
int32_t userSerial, int32_t flags);
binder::Status destroyUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId,
binder::Status destroyUserStorage(const std::optional<std::string>& uuid, int32_t userId,
int32_t flags);
binder::Status prepareSandboxForApp(const std::string& packageName, int32_t appId,