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

Commit 9798fcd0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topics "ota-apex-list", "otapreopt-linkerconfig" am:...

Merge changes from topics "ota-apex-list", "otapreopt-linkerconfig" am: 8a3d4d4e am: 0719cf54 am: 50bbce6f

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1619561

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I659f3c3a4d7caf817c0a3845cfd4f78ab2f31aef
parents 2d4a9cd1 50bbce6f
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -20,15 +20,19 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/wait.h>


#include <fstream>
#include <sstream>
#include <sstream>


#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <libdm/dm.h>
#include <libdm/dm.h>
#include <selinux/android.h>
#include <selinux/android.h>


#include <apex_file_repository.h>
#include <apex_file_repository.h>
#include <apex_constants.h>
#include <apexd.h>
#include <apexd.h>


#include "installd_constants.h"
#include "installd_constants.h"
@@ -77,6 +81,22 @@ static std::vector<apex::ApexFile> ActivateApexPackages() {
    return apex::GetActivePackages();
    return apex::GetActivePackages();
}
}


static void CreateApexInfoList(const std::vector<apex::ApexFile>& apex_files) {
    // Setup the apex-info-list.xml file
    const std::string apex_info_file = std::string(apex::kApexRoot) + "/" + apex::kApexInfoList;
    std::fstream xml(apex_info_file.c_str(), std::ios::out | std::ios::trunc);
    if (!xml.is_open()) {
        PLOG(ERROR) << "Failed to open " << apex_info_file;
        exit(216);
    }

    // we do not care about inactive apexs
    std::vector<apex::ApexFile> inactive;
    apex::CollectApexInfoList(xml, apex_files, inactive);
    xml.flush();
    xml.close();
}

static void DeactivateApexPackages(const std::vector<apex::ApexFile>& active_packages) {
static void DeactivateApexPackages(const std::vector<apex::ApexFile>& active_packages) {
    for (const apex::ApexFile& apex_file : active_packages) {
    for (const apex::ApexFile& apex_file : active_packages) {
        const std::string& package_path = apex_file.GetPath();
        const std::string& package_path = apex_file.GetPath();
@@ -250,6 +270,7 @@ static int otapreopt_chroot(const int argc, char **arg) {
    // Try to mount APEX packages in "/apex" in the chroot dir. We need at least
    // Try to mount APEX packages in "/apex" in the chroot dir. We need at least
    // the ART APEX, as it is required by otapreopt to run dex2oat.
    // the ART APEX, as it is required by otapreopt to run dex2oat.
    std::vector<apex::ApexFile> active_packages = ActivateApexPackages();
    std::vector<apex::ApexFile> active_packages = ActivateApexPackages();
    CreateApexInfoList(active_packages);


    // Check that an ART APEX has been activated; clean up and exit
    // Check that an ART APEX has been activated; clean up and exit
    // early otherwise.
    // early otherwise.