diff options
author | Howard Chen <howardsoc@google.com> | 2020-02-26 12:48:41 +0800 |
---|---|---|
committer | Howard Chen <howardsoc@google.com> | 2020-03-04 17:45:25 +0800 |
commit | 0e18806d28f8d8ff72aff4db698afb97f79e3301 (patch) | |
tree | d1fec92b4633593f6cf07274176ec2ced4800499 | |
parent | d39f7d46f1ea805964bf06faf3f5a03d547da0a1 (diff) | |
download | gsid-0e18806d28f8d8ff72aff4db698afb97f79e3301.tar.gz |
Provide oneway method for methods required by system_server
Bug: 149790245
Bug: 149716497
Test: adb shell am start-activity \
-n com.android.dynsystem/com.android.dynsystem.VerificationActivity \
-a android.os.image.action.START_INSTALL \
-d file:///storage/emulated/0/Download/system.raw.gz \
--el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \
--el KEY_USERDATA_SIZE 8589934592
Merged-In: I472566bd84591422ef67c9838b9c94a0a6f1e8aa
Change-Id: I472566bd84591422ef67c9838b9c94a0a6f1e8aa
(cherry picked from commit 7885d3c1167c1ec0230c85e4a78628b7c9f34e59)
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | aidl/android/gsi/IGsiService.aidl | 13 | ||||
-rw-r--r-- | aidl/android/gsi/IGsiServiceCallback.aidl | 22 | ||||
-rw-r--r-- | gsi_service.cpp | 29 | ||||
-rw-r--r-- | gsi_service.h | 3 | ||||
-rw-r--r-- | include/libgsi/libgsi.h | 2 |
6 files changed, 70 insertions, 0 deletions
@@ -127,6 +127,7 @@ filegroup { "aidl/android/gsi/GsiProgress.aidl", "aidl/android/gsi/IGsid.aidl", "aidl/android/gsi/IGsiService.aidl", + "aidl/android/gsi/IGsiServiceCallback.aidl", "aidl/android/gsi/IImageService.aidl", "aidl/android/gsi/IProgressCallback.aidl", "aidl/android/gsi/MappedImage.aidl", diff --git a/aidl/android/gsi/IGsiService.aidl b/aidl/android/gsi/IGsiService.aidl index 65050fe..5503493 100644 --- a/aidl/android/gsi/IGsiService.aidl +++ b/aidl/android/gsi/IGsiService.aidl @@ -18,6 +18,7 @@ package android.gsi; import android.gsi.AvbPublicKey; import android.gsi.GsiProgress; +import android.gsi.IGsiServiceCallback; import android.gsi.IImageService; import android.os.ParcelFileDescriptor; @@ -86,6 +87,12 @@ interface IGsiService { int enableGsi(boolean oneShot, @utf8InCpp String dsuSlot); /** + * Asynchronous enableGsi + * @param result callback for result + */ + oneway void enableGsiAsync(boolean oneShot, @utf8InCpp String dsuSlot, IGsiServiceCallback result); + + /** * @return True if Gsi is enabled */ boolean isGsiEnabled(); @@ -110,6 +117,12 @@ interface IGsiService { boolean removeGsi(); /** + * Asynchronous removeGsi + * @param result callback for result + */ + oneway void removeGsiAsync(IGsiServiceCallback result); + + /** * Disables a GSI install. The image and userdata will be retained, but can * be re-enabled at any time with setGsiBootable. */ diff --git a/aidl/android/gsi/IGsiServiceCallback.aidl b/aidl/android/gsi/IGsiServiceCallback.aidl new file mode 100644 index 0000000..a764ecd --- /dev/null +++ b/aidl/android/gsi/IGsiServiceCallback.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020 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.gsi; + +/** {@hide} */ +oneway interface IGsiServiceCallback { + void onResult(int result); +} diff --git a/gsi_service.cpp b/gsi_service.cpp index 3705c5b..77db54b 100644 --- a/gsi_service.cpp +++ b/gsi_service.cpp @@ -33,6 +33,7 @@ #include <android-base/errors.h> #include <android-base/file.h> #include <android-base/logging.h> +#include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android/gsi/BnImageService.h> @@ -57,6 +58,7 @@ using namespace android::fiemap; using android::base::ReadFileToString; using android::base::ReadFullyAtOffset; using android::base::RemoveFileIfExists; +using android::base::SetProperty; using android::base::StringPrintf; using android::base::unique_fd; using android::base::WriteStringToFd; @@ -278,6 +280,18 @@ binder::Status GsiService::setGsiAshmem(const ::android::os::ParcelFileDescripto return binder::Status::ok(); } +binder::Status GsiService::enableGsiAsync(bool one_shot, const std::string& dsuSlot, + const sp<IGsiServiceCallback>& resultCallback) { + int result; + auto status = enableGsi(one_shot, dsuSlot, &result); + if (!status.isOk()) { + LOG(ERROR) << "Could not enableGsi: " << status.exceptionMessage().string(); + result = IGsiService::INSTALL_ERROR_GENERIC; + } + resultCallback->onResult(result); + return binder::Status::ok(); +} + binder::Status GsiService::enableGsi(bool one_shot, const std::string& dsuSlot, int* _aidl_return) { std::lock_guard<std::mutex> guard(parent_->lock()); @@ -317,6 +331,17 @@ binder::Status GsiService::isGsiEnabled(bool* _aidl_return) { return binder::Status::ok(); } +binder::Status GsiService::removeGsiAsync(const sp<IGsiServiceCallback>& resultCallback) { + bool result; + auto status = removeGsi(&result); + if (!status.isOk()) { + LOG(ERROR) << "Could not removeGsi: " << status.exceptionMessage().string(); + result = IGsiService::INSTALL_ERROR_GENERIC; + } + resultCallback->onResult(result); + return binder::Status::ok(); +} + binder::Status GsiService::removeGsi(bool* _aidl_return) { ENFORCE_SYSTEM_OR_SHELL; std::lock_guard<std::mutex> guard(parent_->lock()); @@ -474,6 +499,7 @@ bool GsiService::CreateInstallStatusFile() { PLOG(ERROR) << "write " << kDsuInstallStatusFile; return false; } + SetProperty(kGsiInstalledProp, "1"); return true; } @@ -904,6 +930,9 @@ bool GsiService::RemoveGsiFiles(const std::string& install_dir) { ok = false; } } + if (ok) { + SetProperty(kGsiInstalledProp, "0"); + } return ok; } diff --git a/gsi_service.h b/gsi_service.h index a853e2b..0f9880c 100644 --- a/gsi_service.h +++ b/gsi_service.h @@ -69,8 +69,11 @@ class GsiService : public BinderService<GsiService>, public BnGsiService { binder::Status commitGsiChunkFromAshmem(int64_t bytes, bool* _aidl_return) override; binder::Status cancelGsiInstall(bool* _aidl_return) override; binder::Status enableGsi(bool oneShot, const std::string& dsuSlot, int* _aidl_return) override; + binder::Status enableGsiAsync(bool oneShot, const ::std::string& dsuSlot, + const sp<IGsiServiceCallback>& resultCallback) override; binder::Status isGsiEnabled(bool* _aidl_return) override; binder::Status removeGsi(bool* _aidl_return) override; + binder::Status removeGsiAsync(const sp<IGsiServiceCallback>& resultCallback) override; binder::Status disableGsi(bool* _aidl_return) override; binder::Status isGsiInstalled(bool* _aidl_return) override; binder::Status isGsiRunning(bool* _aidl_return) override; diff --git a/include/libgsi/libgsi.h b/include/libgsi/libgsi.h index c824c57..fbe2f17 100644 --- a/include/libgsi/libgsi.h +++ b/include/libgsi/libgsi.h @@ -47,6 +47,8 @@ std::string GetDsuSlot(const std::string& install_dir); static constexpr char kGsiBootedProp[] = "ro.gsid.image_running"; +static constexpr char kGsiInstalledProp[] = "gsid.image_installed"; + static constexpr char kDsuPostfix[] = "_gsi"; static constexpr int kMaxBootAttempts = 1; |