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
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 4288735..3713e87 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -2054,6 +2054,7 @@
     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 @@
 #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 @@
         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 @@
 #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();
 }