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

Commit 2c8f9086 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5286292 from c0f4a2ed to qt-release

Change-Id: I6e7cade4fe065a3939df4dbdad663d5c41f1b57c
parents 68026219 c0f4a2ed
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -231,16 +231,16 @@ cc_binary {
}

// OTA slot script
cc_prebuilt_binary {
sh_binary {
    name: "otapreopt_slot",
    srcs: ["otapreopt_slot.sh"],
    src: "otapreopt_slot.sh",
    init_rc: ["otapreopt.rc"],
}

// OTA postinstall script
cc_prebuilt_binary {
sh_binary {
    name: "otapreopt_script",
    srcs: ["otapreopt_script.sh"],
    src: "otapreopt_script.sh",
    // Let this depend on otapreopt, the chroot tool and the slot script,
    // so we just have to mention one in a configuration.
    required: [
+71 −0
Original line number Diff line number Diff line
@@ -41,6 +41,23 @@ using android::base::StringPrintf;
namespace android {
namespace installd {

// Configuration for bind-mounted Bionic artifacts.

static constexpr const char* kLinkerMountPoint = "/bionic/bin/linker";
static constexpr const char* kRuntimeLinkerPath = "/apex/com.android.runtime/bin/linker";

static constexpr const char* kBionicLibsMountPointDir = "/bionic/lib/";
static constexpr const char* kRuntimeBionicLibsDir = "/apex/com.android.runtime/lib/bionic/";

static constexpr const char* kLinkerMountPoint64 = "/bionic/bin/linker64";
static constexpr const char* kRuntimeLinkerPath64 = "/apex/com.android.runtime/bin/linker64";

static constexpr const char* kBionicLibsMountPointDir64 = "/bionic/lib64/";
static constexpr const char* kRuntimeBionicLibsDir64 = "/apex/com.android.runtime/lib64/bionic/";

static const std::vector<std::string> kBionicLibFileNames = {"libc.so", "libm.so", "libdl.so"};


static void CloseDescriptor(int fd) {
    if (fd >= 0) {
        int result = close(fd);
@@ -79,6 +96,43 @@ static void DeactivateApexPackages(const std::vector<apex::ApexFile>& active_pac
    }
}

// Copied from system/core/init/mount_namespace.cpp.
static bool BindMount(const std::string& source, const std::string& mount_point,
                      bool recursive = false) {
    unsigned long mountflags = MS_BIND;
    if (recursive) {
        mountflags |= MS_REC;
    }
    if (mount(source.c_str(), mount_point.c_str(), nullptr, mountflags, nullptr) == -1) {
        PLOG(ERROR) << "Could not bind-mount " << source << " to " << mount_point;
        return false;
    }
    return true;
}

// Copied from system/core/init/mount_namespace.cpp and and adjusted (bind
// mounts are not made private, as the /postinstall is already private (see
// `android::installd::otapreopt_chroot`).
static bool BindMountBionic(const std::string& linker_source, const std::string& lib_dir_source,
                            const std::string& linker_mount_point,
                            const std::string& lib_mount_dir) {
    if (access(linker_source.c_str(), F_OK) != 0) {
        PLOG(INFO) << linker_source << " does not exist. Skipping mounting Bionic there.";
        return true;
    }
    if (!BindMount(linker_source, linker_mount_point)) {
        return false;
    }
    for (const auto& libname : kBionicLibFileNames) {
        std::string mount_point = lib_mount_dir + libname;
        std::string source = lib_dir_source + libname;
        if (!BindMount(source, mount_point)) {
            return false;
        }
    }
    return true;
}

// Entry for otapreopt_chroot. Expected parameters are:
//   [cmd] [status-fd] [target-slot] "dexopt" [dexopt-params]
// The file descriptor denoted by status-fd will be closed. The rest of the parameters will
@@ -222,6 +276,23 @@ static int otapreopt_chroot(const int argc, char **arg) {
    // the Android Runtime APEX, as it is required by otapreopt to run dex2oat.
    std::vector<apex::ApexFile> active_packages = ActivateApexPackages();

    // Bind-mount Bionic artifacts from the Runtime APEX.
    // This logic is copied and adapted from system/core/init/mount_namespace.cpp.
    if (!BindMountBionic(kRuntimeLinkerPath, kRuntimeBionicLibsDir, kLinkerMountPoint,
                         kBionicLibsMountPointDir)) {
        LOG(ERROR) << "Failed to mount 32-bit Bionic artifacts from the Runtime APEX.";
        // Clean up and exit.
        DeactivateApexPackages(active_packages);
        exit(215);
    }
    if (!BindMountBionic(kRuntimeLinkerPath64, kRuntimeBionicLibsDir64, kLinkerMountPoint64,
                         kBionicLibsMountPointDir64)) {
        LOG(ERROR) << "Failed to mount 64-bit Bionic artifacts from the Runtime APEX.";
        // Clean up and exit.
        DeactivateApexPackages(active_packages);
        exit(216);
    }

    // Now go on and run otapreopt.

    // Incoming:  cmd + status-fd + target-slot + cmd...      | Incoming | = argc
+9 −14
Original line number Diff line number Diff line
@@ -451,12 +451,12 @@ TEST_F(ServiceTest, SnapshotAppData_WrongVolumeUuid) {
TEST_F(ServiceTest, CreateAppDataSnapshot_ClearsCache) {
  auto fake_package_ce_path = create_data_user_ce_package_path("TEST", 0, "com.foo");
  auto fake_package_de_path = create_data_user_de_package_path("TEST", 0, "com.foo");
  auto fake_package_ce_cache_path = read_path_inode(fake_package_ce_path,
      "cache", kXattrInodeCache);
  auto fake_package_ce_code_cache_path = read_path_inode(fake_package_ce_path,
      "code_cache", kXattrInodeCache);
  auto fake_package_ce_cache_path = fake_package_ce_path + "/cache";
  auto fake_package_ce_code_cache_path = fake_package_ce_path + "/code_cache";
  auto fake_package_de_cache_path = fake_package_de_path + "/cache";
  auto fake_package_de_code_cache_path = fake_package_de_path + "/code_cache";
  auto rollback_ce_dir = create_data_misc_ce_rollback_path("TEST", 0);
  auto rollback_de_dir = create_data_misc_de_rollback_path("TEST", 0);

  ASSERT_TRUE(mkdirs(fake_package_ce_path, 700));
  ASSERT_TRUE(mkdirs(fake_package_de_path, 700));
@@ -464,20 +464,15 @@ TEST_F(ServiceTest, CreateAppDataSnapshot_ClearsCache) {
  ASSERT_TRUE(mkdirs(fake_package_ce_code_cache_path, 700));
  ASSERT_TRUE(mkdirs(fake_package_de_cache_path, 700));
  ASSERT_TRUE(mkdirs(fake_package_de_code_cache_path, 700));
  ASSERT_TRUE(mkdirs(rollback_ce_dir, 700));
  ASSERT_TRUE(mkdirs(rollback_de_dir, 700));

  auto deleter = [&fake_package_ce_path, &fake_package_de_path,
          &fake_package_ce_cache_path, &fake_package_ce_code_cache_path,
          &fake_package_de_cache_path, &fake_package_de_code_cache_path]() {
          &rollback_ce_dir, &rollback_de_dir]() {
      delete_dir_contents(fake_package_ce_path, true);
      delete_dir_contents(fake_package_de_path, true);
      delete_dir_contents(fake_package_ce_cache_path, true);
      delete_dir_contents(fake_package_ce_code_cache_path, true);
      delete_dir_contents(fake_package_de_cache_path, true);
      delete_dir_contents(fake_package_de_code_cache_path, true);
      rmdir(fake_package_ce_cache_path.c_str());
      rmdir(fake_package_ce_code_cache_path.c_str());
      rmdir(fake_package_de_cache_path.c_str());
      rmdir(fake_package_de_code_cache_path.c_str());
      delete_dir_contents_and_dir(rollback_ce_dir, true);
      delete_dir_contents_and_dir(rollback_de_dir, true);
  };
  auto scope_guard = android::base::make_scope_guard(deleter);

+0 −21
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2018 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.
  -->

<!-- This is the standard set of features for a biometric fingerprint sensor. -->
<permissions>
    <feature name="android.hardware.biometrics.fingerprint" />
</permissions>
+4 −1
Original line number Diff line number Diff line
@@ -181,7 +181,10 @@ static void release_object(const sp<ProcessState>& proc,
                if ((outAshmemSize != nullptr) && ashmem_valid(obj.handle)) {
                    int size = ashmem_get_size_region(obj.handle);
                    if (size > 0) {
                        *outAshmemSize -= size;
                        // ashmem size might have changed since last time it was accounted for, e.g.
                        // in acquire_object(). Value of *outAshmemSize is not critical since we are
                        // releasing the object anyway. Check for integer overflow condition.
                        *outAshmemSize -= std::min(*outAshmemSize, static_cast<size_t>(size));
                    }
                }

Loading