Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 7ebecd04 authored by Yumi Yukimura's avatar Yumi Yukimura Committed by Michael Bestas
Browse files

recovery: Add support for choosing update from virtiofs

Change-Id: Ia6c62d09a0777799e882ae2d4e4348784584f54f
parent 1b8b1977
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ cc_library_static {
    srcs: [
        "adb_install.cpp",
        "fuse_install.cpp",
        "virtiofs_install.cpp",
        "install.cpp",
        "snapshot_utils.cpp",
        "wipe_data.cpp",
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ static void SetSdcardUpdateBootloaderMessage() {
}

// Returns the selected filename, or an empty string.
static std::string BrowseDirectory(const std::string& path, Device* device, RecoveryUI* ui) {
std::string BrowseDirectory(const std::string& path, Device* device, RecoveryUI* ui) {
  std::unique_ptr<DIR, decltype(&closedir)> d(opendir(path.c_str()), closedir);
  if (!d) {
    PLOG(ERROR) << "error opening " << path;
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@

using android::volmgr::VolumeInfo;

std::string BrowseDirectory(const std::string& path, Device* device, RecoveryUI* ui);

// Starts FUSE with the package from |path| as the data source. And installs the package from
// |FUSE_SIDELOAD_HOST_PATHNAME|. The |path| can point to the location of a package zip file or a
// block map file with the prefix '@'; e.g. /sdcard/package.zip, @/cache/recovery/block.map.
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

#pragma once

#include "install/install.h"
#include "recovery_ui/device.h"
#include "recovery_ui/ui.h"

InstallResult ApplyFromVirtiofs(Device* device);

// Returns true on success, or false on failure.
bool InitializeVirtiofs();
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

#include "install/fuse_install.h"
#include "install/virtiofs_install.h"

#include <string>

#include "install/install.h"
#include "recovery_utils/roots.h"

static constexpr const char* VIRTIOFS_MOUNTPOINT = "/mnt/vendor/shared";

InstallResult ApplyFromVirtiofs(Device* device) {
  auto ui = device->GetUI();

  std::string path = BrowseDirectory(VIRTIOFS_MOUNTPOINT, device, ui);
  if (path.empty()) {
    return INSTALL_NONE;
  }

  ui->Print("\n-- Install %s ...\n", path.c_str());

  auto package =
      Package::CreateFilePackage(path, std::bind(&RecoveryUI::SetProgress, ui,
                                                 std::placeholders::_1));
  if (package == nullptr) {
    ui->Print("Failed to open package %s\n", path.c_str());
    return INSTALL_ERROR;
  }

  auto result = InstallPackage(package.get(), path, false, 0 /* retry_count */,
                               device);
  return result;
}

bool InitializeVirtiofs() {
  if (volume_for_mount_point(VIRTIOFS_MOUNTPOINT)) {
    if (ensure_path_mounted(VIRTIOFS_MOUNTPOINT) == 0) {
      return true;
    }
  }
  return false;
}
Loading