2d5878e69b
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 149be4a25e
)
Exempt-From-Owner-Approval: CP from master
89 lines
2.6 KiB
C++
89 lines
2.6 KiB
C++
/*
|
|
* Copyright (C) 2019 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef ANDROID_INSTALLD_CRATE_INFO_MANAGER_H
|
|
#define ANDROID_INSTALLD_CRATE_INFO_MANAGER_H
|
|
|
|
#ifdef ENABLE_STORAGE_CRATES
|
|
|
|
#include <android/os/storage/CrateMetadata.h>
|
|
#include <cutils/multiuser.h>
|
|
#include <fts.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#ifndef CRATE_DEBUG
|
|
#define CRATE_DEBUG 1
|
|
#endif
|
|
|
|
namespace android {
|
|
namespace installd {
|
|
|
|
using android::os::storage::CrateMetadata;
|
|
|
|
/**
|
|
* The crated folder actually is a folder that is the first level child director. In order to
|
|
* distingish between the crated folder and the other FTSENT*, to define the type "CratedFolder"
|
|
* make the code easy to identify the difference.
|
|
*/
|
|
typedef FTSENT* CratedFolder;
|
|
|
|
/**
|
|
* In order to give the users more fine-grained files controlling, the crate information can help
|
|
* applications' developers to show the more detail information to the users. The crate information
|
|
* include the Label, Expiration etc..
|
|
*/
|
|
class CrateManager {
|
|
public:
|
|
CrateManager(const char* uuid, userid_t userId, const std::string& packageName);
|
|
~CrateManager();
|
|
|
|
void traverseAllCrates(std::function<void(CratedFolder, CrateMetadata&&)>& onCreateCrate);
|
|
|
|
static void traverseChildDir(const std::string& targetDir,
|
|
std::function<void(FTSENT*)>& onVisitChildDir);
|
|
|
|
static void traverseAllPackagesForUser(
|
|
const std::optional<std::string>& uuid,
|
|
userid_t userId,
|
|
std::function<void(FTSENT*)>& onHandlingPackage);
|
|
|
|
#if CRATE_DEBUG
|
|
static void dump(const CrateMetadata& CrateMetadata);
|
|
#endif
|
|
private:
|
|
std::string mRoot;
|
|
std::string mCratedFoldersRoot;
|
|
std::string mPackageName;
|
|
|
|
void createCrate(
|
|
CratedFolder cratedFolder,
|
|
std::function<void(CratedFolder, CrateMetadata&&)>& onCreateCrate);
|
|
};
|
|
|
|
} // namespace installd
|
|
} // namespace android
|
|
|
|
#else // ENABLE_STORAGE_CRATES
|
|
#include <android/os/storage/CrateMetadata.h>
|
|
using android::os::storage::CrateMetadata;
|
|
#endif // ENABLE_STORAGE_CRATES
|
|
|
|
#endif // ANDROID_INSTALLD_CRATE_INFO_MANAGER_H
|