diff options
author | 2020-02-11 19:08:43 +0800 | |
---|---|---|
committer | 2020-02-17 12:28:52 +0800 | |
commit | 4df87f6585a480b8f15eae69baa178c85114fbf1 (patch) | |
tree | 56aa27f6e633d0f1400b6ef103df287b0a7e1a33 | |
parent | b0d738af0fe2874416cecac9eb7f931d01a12a31 (diff) |
Disable storage crates functionalities
The Storage Crates functionalities is disable by default. In order to
make installd to grow smoothly, the crate function should not add into
installd until it addes more tests such as benchmark and memory regression
tests.
Test: make -j installd && \
grep crates $OUT/system/bin/installd ; \
if [ $? -eq 0 ] ; \
then \
echo "include crate" ; \
else \
echo "not include crate " ; \
fi
Test: #should skip the test
adb root; \
adb shell setprop fw.storage_crates true \
atest CtsOsTestCases:android.os.storage.cts.StorageCrateTest \
CtsOsTestCases:android.os.storage.cts.StorageStatsManagerTest \
CtsOsTestCases:android.os.storage.cts.CrateInfoTest
Test: #should test fail because installd disable the functionalities
adb root; \
adb shell "setprop fw.storage_crates ''" \
atest CtsOsTestCases:android.os.storage.cts.StorageCrateTest \
CtsOsTestCases:android.os.storage.cts.StorageStatsManagerTest \
CtsOsTestCases:android.os.storage.cts.CrateInfoTest
Bug: 148179319
Change-Id: I1fd142c9c9e5d7e133ebd994f4645966ee432916
-rw-r--r-- | cmds/installd/CrateManager.cpp | 4 | ||||
-rw-r--r-- | cmds/installd/CrateManager.h | 7 | ||||
-rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 18 |
3 files changed, 29 insertions, 0 deletions
diff --git a/cmds/installd/CrateManager.cpp b/cmds/installd/CrateManager.cpp index 344aefbcbe..6e079ebbf3 100644 --- a/cmds/installd/CrateManager.cpp +++ b/cmds/installd/CrateManager.cpp @@ -16,6 +16,8 @@ #include "CrateManager.h" +#ifdef ENABLE_STORAGE_CRATES + #include <android-base/logging.h> #include <android-base/stringprintf.h> #include <android/log.h> @@ -127,3 +129,5 @@ void CrateManager::dump(std::unique_ptr<CrateMetadata>& CrateMetadata) { } // namespace installd } // namespace android + +#endif // ENABLE_STORAGE_CRATES
\ No newline at end of file diff --git a/cmds/installd/CrateManager.h b/cmds/installd/CrateManager.h index 1776622d6a..4332d4cbc9 100644 --- a/cmds/installd/CrateManager.h +++ b/cmds/installd/CrateManager.h @@ -17,6 +17,8 @@ #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> @@ -79,4 +81,9 @@ private: } // 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 diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 42887359d1..3713e8732b 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -2054,6 +2054,7 @@ binder::Status InstalldNativeService::getAppCrates( for (const auto& packageName : packageNames) { CHECK_ARGUMENT_PACKAGE_NAME(packageName); } +#ifdef ENABLE_STORAGE_CRATES std::lock_guard<std::recursive_mutex> lock(mLock); auto retVector = std::make_unique<std::vector<std::unique_ptr<CrateMetadata>>>(); @@ -2083,6 +2084,14 @@ binder::Status InstalldNativeService::getAppCrates( #endif *_aidl_return = std::move(retVector); +#else // ENABLE_STORAGE_CRATES + *_aidl_return = nullptr; + + /* prevent compile warning fail */ + if (userId < 0) { + return error(); + } +#endif // ENABLE_STORAGE_CRATES return ok(); } @@ -2091,6 +2100,7 @@ binder::Status InstalldNativeService::getUserCrates( std::unique_ptr<std::vector<std::unique_ptr<CrateMetadata>>>* _aidl_return) { ENFORCE_UID(AID_SYSTEM); CHECK_ARGUMENT_UUID(uuid); +#ifdef ENABLE_STORAGE_CRATES std::lock_guard<std::recursive_mutex> lock(mLock); const char* uuid_ = uuid ? uuid->c_str() : nullptr; @@ -2118,6 +2128,14 @@ binder::Status InstalldNativeService::getUserCrates( #endif *_aidl_return = std::move(retVector); +#else // ENABLE_STORAGE_CRATES + *_aidl_return = nullptr; + + /* prevent compile warning fail */ + if (userId < 0) { + return error(); + } +#endif // ENABLE_STORAGE_CRATES return ok(); } |