Merge "Create an API for calculating size requirement for compressed APEX" am: e6c4c1e4c5
Original change: https://android-review.googlesource.com/c/platform/system/apex/+/1587493
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I6cf3050f636baffe7315a2b16c5cc666e2c81bc2
diff --git a/apexd/Android.bp b/apexd/Android.bp
index 2e7a2d0..d727e4e 100644
--- a/apexd/Android.bp
+++ b/apexd/Android.bp
@@ -102,6 +102,8 @@
"aidl/android/apex/ApexInfoList.aidl",
"aidl/android/apex/ApexSessionInfo.aidl",
"aidl/android/apex/ApexSessionParams.aidl",
+ "aidl/android/apex/CompressedApexInfo.aidl",
+ "aidl/android/apex/CompressedApexInfoList.aidl",
"aidl/android/apex/IApexService.aidl",
],
local_include_dir: "aidl",
diff --git a/apexd/aidl/android/apex/CompressedApexInfo.aidl b/apexd/aidl/android/apex/CompressedApexInfo.aidl
new file mode 100644
index 0000000..48015bd
--- /dev/null
+++ b/apexd/aidl/android/apex/CompressedApexInfo.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+package android.apex;
+
+parcelable CompressedApexInfo {
+ @utf8InCpp String moduleName;
+ long versionCode;
+ long decompressedSize;
+}
diff --git a/apexd/aidl/android/apex/CompressedApexInfoList.aidl b/apexd/aidl/android/apex/CompressedApexInfoList.aidl
new file mode 100644
index 0000000..e1620bd
--- /dev/null
+++ b/apexd/aidl/android/apex/CompressedApexInfoList.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+package android.apex;
+
+import android.apex.CompressedApexInfo;
+
+parcelable CompressedApexInfoList {
+ CompressedApexInfo[] apexInfos;
+}
diff --git a/apexd/aidl/android/apex/IApexService.aidl b/apexd/aidl/android/apex/IApexService.aidl
index da723e2..ce98f83 100644
--- a/apexd/aidl/android/apex/IApexService.aidl
+++ b/apexd/aidl/android/apex/IApexService.aidl
@@ -20,6 +20,7 @@
import android.apex.ApexInfoList;
import android.apex.ApexSessionInfo;
import android.apex.ApexSessionParams;
+import android.apex.CompressedApexInfoList;
interface IApexService {
void submitStagedSession(in ApexSessionParams params, out ApexInfoList packages);
@@ -132,4 +133,10 @@
* Informs apexd that the boot has completed.
*/
void markBootCompleted();
+
+ /**
+ * Assuming the provided compressed APEX will be installed on next boot,
+ * calculate how much space will be required for decompression
+ */
+ long calculateSizeForCompressedApex(in CompressedApexInfoList compressed_apex_info_list);
}
diff --git a/apexd/apexservice.cpp b/apexd/apexservice.cpp
index c0cb2ff..c61c023 100644
--- a/apexd/apexservice.cpp
+++ b/apexd/apexservice.cpp
@@ -104,6 +104,9 @@
BinderStatus recollectPreinstalledData(
const std::vector<std::string>& paths) override;
BinderStatus markBootCompleted() override;
+ BinderStatus calculateSizeForCompressedApex(
+ const CompressedApexInfoList& compressed_apex_info_list,
+ int64_t* required_size) override;
status_t dump(int fd, const Vector<String16>& args) override;
@@ -219,6 +222,17 @@
return BinderStatus::ok();
}
+BinderStatus ApexService::calculateSizeForCompressedApex(
+ const CompressedApexInfoList& compressed_apex_info_list,
+ int64_t* required_size) {
+ int64_t result = 0;
+ for (const auto& apex_info : compressed_apex_info_list.apexInfos) {
+ result += apex_info.decompressedSize;
+ }
+ *required_size = result;
+ return BinderStatus::ok();
+}
+
static void ClearSessionInfo(ApexSessionInfo* session_info) {
session_info->sessionId = -1;
session_info->isUnknown = false;