diff options
-rw-r--r-- | aidl/android/gsi/IGsiService.aidl | 56 | ||||
-rw-r--r-- | gsi_service.cpp | 87 | ||||
-rw-r--r-- | gsi_service.h | 12 | ||||
-rw-r--r-- | gsi_tool.cpp | 8 |
4 files changed, 16 insertions, 147 deletions
diff --git a/aidl/android/gsi/IGsiService.aidl b/aidl/android/gsi/IGsiService.aidl index 6ca0af5..34b1441 100644 --- a/aidl/android/gsi/IGsiService.aidl +++ b/aidl/android/gsi/IGsiService.aidl @@ -41,25 +41,6 @@ interface IGsiService { const int INSTALL_ERROR_FILE_SYSTEM_CLUTTERED = 3; /** - * Starts a GSI installation. Use beginGsiInstall() to target external - * media. - * - * If wipeUserData is true, a clean userdata image is always created to the - * desired size. - * - * If wipeUserData is false, a userdata image is only created if one does - * not already exist. If the size is zero, a default size of 8GiB is used. - * If there is an existing image smaller than the desired size, it is - * resized automatically. - * - * @param gsiSize The size of the on-disk GSI image. - * @param userdataSize The desired size of the userdata partition. - * @param wipeUserdata True to wipe destination userdata. - * @return 0 on success, an error code on failure. - */ - int startGsiInstall(long gsiSize, long userdataSize, boolean wipeUserdata); - - /** * Write bytes from a stream to the on-disk GSI. * * @param stream Stream descriptor. @@ -90,7 +71,7 @@ interface IGsiService { * It can still be re-enabled again later with setGsiBootable. * @return INSTALL_* error code. */ - int setGsiBootable(boolean oneShot); + int enableGsi(boolean oneShot); /** * @return True if Gsi is enabled @@ -114,49 +95,22 @@ interface IGsiService { * * @return true on success, false otherwise. */ - boolean removeGsiInstall(); + boolean removeGsi(); /** * Disables a GSI install. The image and userdata will be retained, but can * be re-enabled at any time with setGsiBootable. */ - boolean disableGsiInstall(); - - /** - * Return the size of the userdata partition for an installed GSI. If there - * is no image, 0 is returned. On error, -1 is returned. - */ - long getUserdataImageSize(); - - /** - * Returns true if the gsi is currently running, false otherwise. - */ - boolean isGsiRunning(); + boolean disableGsi(); /** * Returns true if a gsi is installed. */ boolean isGsiInstalled(); - - /* No GSI is installed. */ - const int BOOT_STATUS_NOT_INSTALLED = 0; - /* GSI is installed, but booting is disabled. */ - const int BOOT_STATUS_DISABLED = 1; - /* GSI is installed, but will only boot once. */ - const int BOOT_STATUS_SINGLE_BOOT = 2; - /* GSI is installed and bootable. */ - const int BOOT_STATUS_ENABLED = 3; - /* GSI will be wiped next boot. */ - const int BOOT_STATUS_WILL_WIPE = 4; - /** - * Returns the boot status of a GSI. See the BOOT_STATUS constants in IGsiService. - * - * GSI_STATE_NOT_INSTALLED will be returned if no GSI installation has been - * fully completed. Any other value indicates a GSI is installed. If a GSI - * currently running, DISABLED or SINGLE_BOOT can still be returned. + * Returns true if the gsi is currently running, false otherwise. */ - int getGsiBootStatus(); + boolean isGsiRunning(); /** * If a GSI is installed, returns the directory where the installed images diff --git a/gsi_service.cpp b/gsi_service.cpp index 4caf353..f9805c4 100644 --- a/gsi_service.cpp +++ b/gsi_service.cpp @@ -102,15 +102,6 @@ android::sp<IGsiService> GsiService::Get(Gsid* parent) { if (!status.isOk()) return status; \ } while (0) -binder::Status GsiService::startGsiInstall(int64_t gsiSize, int64_t userdataSize, bool wipeUserdata, - int* _aidl_return) { - GsiInstallParams params; - params.gsiSize = gsiSize; - params.userdataSize = userdataSize; - params.wipeUserdata = wipeUserdata; - return beginGsiInstall(params, _aidl_return); -} - binder::Status GsiService::beginGsiInstall(const GsiInstallParams& given_params, int* _aidl_return) { ENFORCE_SYSTEM; @@ -192,7 +183,7 @@ binder::Status GsiService::commitGsiChunkFromMemory(const std::vector<uint8_t>& return binder::Status::ok(); } -binder::Status GsiService::setGsiBootable(bool one_shot, int* _aidl_return) { +binder::Status GsiService::enableGsi(bool one_shot, int* _aidl_return) { std::lock_guard<std::mutex> guard(parent_->lock()); if (installer_) { @@ -223,7 +214,7 @@ binder::Status GsiService::isGsiEnabled(bool* _aidl_return) { return binder::Status::ok(); } -binder::Status GsiService::removeGsiInstall(bool* _aidl_return) { +binder::Status GsiService::removeGsi(bool* _aidl_return) { ENFORCE_SYSTEM_OR_SHELL; std::lock_guard<std::mutex> guard(parent_->lock()); @@ -244,7 +235,7 @@ binder::Status GsiService::removeGsiInstall(bool* _aidl_return) { return binder::Status::ok(); } -binder::Status GsiService::disableGsiInstall(bool* _aidl_return) { +binder::Status GsiService::disableGsi(bool* _aidl_return) { ENFORCE_SYSTEM_OR_SHELL; std::lock_guard<std::mutex> guard(parent_->lock()); @@ -288,78 +279,6 @@ binder::Status GsiService::cancelGsiInstall(bool* _aidl_return) { return binder::Status::ok(); } -binder::Status GsiService::getGsiBootStatus(int* _aidl_return) { - ENFORCE_SYSTEM_OR_SHELL; - std::lock_guard<std::mutex> guard(parent_->lock()); - - if (!IsGsiInstalled()) { - *_aidl_return = BOOT_STATUS_NOT_INSTALLED; - return binder::Status::ok(); - } - - std::string boot_key; - if (!GetInstallStatus(&boot_key)) { - PLOG(ERROR) << "read " << kDsuInstallStatusFile; - *_aidl_return = BOOT_STATUS_NOT_INSTALLED; - return binder::Status::ok(); - } - - bool single_boot = !access(kDsuOneShotBootFile, F_OK); - - if (boot_key == kInstallStatusWipe) { - // This overrides all other statuses. - *_aidl_return = BOOT_STATUS_WILL_WIPE; - } else if (boot_key == kInstallStatusDisabled) { - // A single-boot GSI will have a "disabled" status, because it's - // disabled immediately upon reading the one_shot_boot file. However, - // we still want to return SINGLE_BOOT, because it makes the - // transition clearer to the user. - if (single_boot) { - *_aidl_return = BOOT_STATUS_SINGLE_BOOT; - } else { - *_aidl_return = BOOT_STATUS_DISABLED; - } - } else if (single_boot) { - *_aidl_return = BOOT_STATUS_SINGLE_BOOT; - } else { - *_aidl_return = BOOT_STATUS_ENABLED; - } - return binder::Status::ok(); -} - -binder::Status GsiService::getUserdataImageSize(int64_t* _aidl_return) { - ENFORCE_SYSTEM; - std::lock_guard<std::mutex> guard(parent_->lock()); - - *_aidl_return = -1; - - if (installer_) { - // Size has already been computed. - *_aidl_return = installer_->userdata_size(); - } else if (IsGsiRunning()) { - // :TODO: libdm - unique_fd fd(open(kUserdataDevice, O_RDONLY | O_NOFOLLOW | O_CLOEXEC)); - if (fd < 0) { - PLOG(ERROR) << "open " << kUserdataDevice; - return binder::Status::ok(); - } - - int64_t size; - if (ioctl(fd, BLKGETSIZE64, &size)) { - PLOG(ERROR) << "BLKGETSIZE64 " << kUserdataDevice; - return binder::Status::ok(); - } - *_aidl_return = size; - } else { - if (auto manager = ImageManager::Open(kDsuMetadataDir, GetInstalledImageDir())) { - if (auto device = MappedDevice::Open(manager.get(), 10s, "userdata_gsi")) { - *_aidl_return = get_block_device_size(device->fd()); - } - } - } - return binder::Status::ok(); -} - binder::Status GsiService::getInstalledGsiImageDir(std::string* _aidl_return) { ENFORCE_SYSTEM; std::lock_guard<std::mutex> guard(parent_->lock()); diff --git a/gsi_service.h b/gsi_service.h index 30ec2d7..00043dd 100644 --- a/gsi_service.h +++ b/gsi_service.h @@ -57,8 +57,6 @@ class GsiService : public BinderService<GsiService>, public BnGsiService { static android::sp<IGsiService> Get(Gsid* parent); - binder::Status startGsiInstall(int64_t gsiSize, int64_t userdataSize, bool wipeUserdata, - int* _aidl_return) override; binder::Status beginGsiInstall(const GsiInstallParams& params, int* _aidl_return) override; binder::Status commitGsiChunkFromStream(const ::android::os::ParcelFileDescriptor& stream, int64_t bytes, bool* _aidl_return) override; @@ -66,15 +64,13 @@ class GsiService : public BinderService<GsiService>, public BnGsiService { binder::Status commitGsiChunkFromMemory(const ::std::vector<uint8_t>& bytes, bool* _aidl_return) override; binder::Status cancelGsiInstall(bool* _aidl_return) override; - binder::Status setGsiBootable(bool oneShot, int* _aidl_return) override; + binder::Status enableGsi(bool oneShot, int* _aidl_return) override; binder::Status isGsiEnabled(bool* _aidl_return) override; - binder::Status removeGsiInstall(bool* _aidl_return) override; - binder::Status disableGsiInstall(bool* _aidl_return) override; - binder::Status isGsiRunning(bool* _aidl_return) override; + binder::Status removeGsi(bool* _aidl_return) override; + binder::Status disableGsi(bool* _aidl_return) override; binder::Status isGsiInstalled(bool* _aidl_return) override; + binder::Status isGsiRunning(bool* _aidl_return) override; binder::Status isGsiInstallInProgress(bool* _aidl_return) override; - binder::Status getUserdataImageSize(int64_t* _aidl_return) override; - binder::Status getGsiBootStatus(int* _aidl_return) override; binder::Status getInstalledGsiImageDir(std::string* _aidl_return) override; binder::Status wipeGsiUserdata(int* _aidl_return) override; binder::Status openImageService(const std::string& prefix, diff --git a/gsi_tool.cpp b/gsi_tool.cpp index 4f885ae..5cfca97 100644 --- a/gsi_tool.cpp +++ b/gsi_tool.cpp @@ -298,7 +298,7 @@ static int Install(sp<IGsiService> gsid, int argc, char** argv) { progress.Finish(); - status = gsid->setGsiBootable(true, &error); + status = gsid->enableGsi(true, &error); if (!status.isOk() || error != IGsiService::INSTALL_OK) { std::cerr << "Could not make live image bootable: " << ErrorMessage(status, error) << "\n"; return EX_SOFTWARE; @@ -321,7 +321,7 @@ static int Wipe(sp<IGsiService> gsid, int argc, char** /* argv */) { return EX_USAGE; } bool ok; - auto status = gsid->removeGsiInstall(&ok); + auto status = gsid->removeGsi(&ok); if (!status.isOk() || !ok) { std::cerr << "Could not remove GSI install: " << ErrorMessage(status) << "\n"; return EX_SOFTWARE; @@ -474,7 +474,7 @@ static int Enable(sp<IGsiService> gsid, int argc, char** argv) { } int error; - auto status = gsid->setGsiBootable(one_shot, &error); + auto status = gsid->enableGsi(one_shot, &error); if (!status.isOk() || error != IGsiService::INSTALL_OK) { std::cerr << "Error re-enabling GSI: " << ErrorMessage(status, error) << "\n"; return EX_SOFTWARE; @@ -497,7 +497,7 @@ static int Disable(sp<IGsiService> gsid, int argc, char** /* argv */) { } bool ok = false; - gsid->disableGsiInstall(&ok); + gsid->disableGsi(&ok); if (!ok) { std::cerr << "Error disabling GSI" << std::endl; return EX_SOFTWARE; |