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

Unverified Commit ba7508fb authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-14.0.0_r17' into staging/lineage-21.0_merge-android-14.0.0_r17

Android 14.0.0 Release 17 (UQ1A.231205.015)

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCZXDPLwAKCRDorT+BmrEO
# eELBAKCOkePTxOpkQ6eD4moS9Wgm9rFA3wCfT0Vrobqezf2y51WdwztGcoD48FY=
# =DNkW
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Dec  6 21:44:47 2023 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 2182 signatures in the past
#      2 years.  Encrypted 4 messages in the past 23 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Siarhei Vishniakou (25) and others
# Via Automerger Merge Worker (790) and others
* tag 'android-14.0.0_r17': (181 commits)
  Make screenshots leaving the device more consistent.
  EGL: Close Multifile Blobcache files after mapping
  SF: Fix mode setting for UDFPS with disabled AOD
  Stylus fusion: Use SOURCE_BLUETOOTH_STYLUS dynamically for events
  Update WindowInfosListenerUtils to use 5s timeout
  Don't dim screenshots when there's no HDR on-screen.
  Prevent the refresh rate changed frequently when small dirty
  Metrics collector: Log a separate bus for USI styluses
  Don't look through the buffer cache in protected contexts
  Fix nullptr dereference when reporting hung transaction
  Add binder check for getConsumerName.
  sm: disableBackgroundScheduling
  VRR: Allowlist for small area detection
  Improve updateInputFlinger performance
  Revert "Improve updateInputFlinger performance"
  Improve updateInputFlinger performance
  SF: Suppress frame rate when small area updating
  Update LayerVector if the mirrorRoot is already inside
  Modify shader includes to match with vendor code
  Override VelocityTracker strategy for non-differential axes only
  ...

Change-Id: I6fd148edc4ed0f4f8b8bebea758c8fcd1437c092
parents dac2b8cb e623496c
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,14 @@ license {
    ],
    ],
}
}


cc_library_headers {
    name: "native_headers",
    host_supported: true,
    export_include_dirs: [
        "include/",
    ],
}

ndk_headers {
ndk_headers {
    name: "libandroid_headers",
    name: "libandroid_headers",
    from: "include/android",
    from: "include/android",
+13 −0
Original line number Original line Diff line number Diff line
@@ -207,6 +207,9 @@ std::string PropertiesHelper::build_type_ = "";
int PropertiesHelper::dry_run_ = -1;
int PropertiesHelper::dry_run_ = -1;
int PropertiesHelper::unroot_ = -1;
int PropertiesHelper::unroot_ = -1;
int PropertiesHelper::parallel_run_ = -1;
int PropertiesHelper::parallel_run_ = -1;
#if !defined(__ANDROID_VNDK__)
int PropertiesHelper::strict_run_ = -1;
#endif


bool PropertiesHelper::IsUserBuild() {
bool PropertiesHelper::IsUserBuild() {
    if (build_type_.empty()) {
    if (build_type_.empty()) {
@@ -237,6 +240,16 @@ bool PropertiesHelper::IsParallelRun() {
    return parallel_run_ == 1;
    return parallel_run_ == 1;
}
}


#if !defined(__ANDROID_VNDK__)
bool PropertiesHelper::IsStrictRun() {
    if (strict_run_ == -1) {
        // Defaults to using stricter timeouts.
        strict_run_ = android::base::GetBoolProperty("dumpstate.strict_run", true) ? 1 : 0;
    }
    return strict_run_ == 1;
}
#endif

int DumpFileToFd(int out_fd, const std::string& title, const std::string& path) {
int DumpFileToFd(int out_fd, const std::string& title, const std::string& path) {
    android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC)));
    android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC)));
    if (fd.get() < 0) {
    if (fd.get() < 0) {
+12 −0
Original line number Original line Diff line number Diff line
@@ -193,11 +193,23 @@ class PropertiesHelper {
     */
     */
    static bool IsParallelRun();
    static bool IsParallelRun();


    /*
     * Strict-run mode is determined by the `dumpstate.strict_run` sysprop which
     * will default to true. This results in shortened timeouts for flaky
     * sections.
     */
#if !defined(__ANDROID_VNDK__)
    static bool IsStrictRun();
#endif

  private:
  private:
    static std::string build_type_;
    static std::string build_type_;
    static int dry_run_;
    static int dry_run_;
    static int unroot_;
    static int unroot_;
    static int parallel_run_;
    static int parallel_run_;
#if !defined(__ANDROID_VNDK__)
    static int strict_run_;
#endif
};
};


/*
/*
+14 −4
Original line number Original line Diff line number Diff line
@@ -822,9 +822,12 @@ void Dumpstate::PrintHeader() const {
    RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"},
    RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"},
                   CommandOptions::WithTimeout(1).Always().Build());
                   CommandOptions::WithTimeout(1).Always().Build());
    printf("Bugreport format version: %s\n", version_.c_str());
    printf("Bugreport format version: %s\n", version_.c_str());
    printf("Dumpstate info: id=%d pid=%d dry_run=%d parallel_run=%d args=%s bugreport_mode=%s\n",
    printf(
        "Dumpstate info: id=%d pid=%d dry_run=%d parallel_run=%d strict_run=%d args=%s "
        "bugreport_mode=%s\n",
        id_, pid_, PropertiesHelper::IsDryRun(), PropertiesHelper::IsParallelRun(),
        id_, pid_, PropertiesHelper::IsDryRun(), PropertiesHelper::IsParallelRun(),
           options_->args.c_str(), options_->bugreport_mode_string.c_str());
        PropertiesHelper::IsStrictRun(), options_->args.c_str(),
        options_->bugreport_mode_string.c_str());
    printf("\n");
    printf("\n");
}
}


@@ -1046,7 +1049,8 @@ static void DumpIncidentReport() {
        MYLOGE("Could not open %s to dump incident report.\n", path.c_str());
        MYLOGE("Could not open %s to dump incident report.\n", path.c_str());
        return;
        return;
    }
    }
    RunCommandToFd(fd, "", {"incident", "-u"}, CommandOptions::WithTimeout(20).Build());
    RunCommandToFd(fd, "", {"incident", "-u"},
                   CommandOptions::WithTimeout(PropertiesHelper::IsStrictRun() ? 20 : 120).Build());
    bool empty = 0 == lseek(fd, 0, SEEK_END);
    bool empty = 0 == lseek(fd, 0, SEEK_END);
    if (!empty) {
    if (!empty) {
        // Use a different name from "incident.proto"
        // Use a different name from "incident.proto"
@@ -3127,6 +3131,12 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
        MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n");
        MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n");
    }
    }


    if (PropertiesHelper::IsStrictRun()) {
        MYLOGI(
            "Running on strict-run mode, which has shorter timeouts "
            "(to disable, call 'setprop dumpstate.strict_run false')\n");
    }

    MYLOGI("dumpstate info: id=%d, args='%s', bugreport_mode= %s bugreport format version: %s\n",
    MYLOGI("dumpstate info: id=%d, args='%s', bugreport_mode= %s bugreport format version: %s\n",
           id_, options_->args.c_str(), options_->bugreport_mode_string.c_str(), version_.c_str());
           id_, options_->args.c_str(), options_->bugreport_mode_string.c_str(), version_.c_str());


+75 −47
Original line number Original line Diff line number Diff line
@@ -19,9 +19,12 @@
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/wait.h>
#include <unistd.h>


#include <algorithm>
#include <array>
#include <array>
#include <fstream>
#include <fstream>
#include <iostream>
#include <sstream>
#include <sstream>


#include <android-base/file.h>
#include <android-base/file.h>
@@ -29,6 +32,7 @@
#include <android-base/macros.h>
#include <android-base/macros.h>
#include <android-base/scopeguard.h>
#include <android-base/scopeguard.h>
#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <android-base/unique_fd.h>
#include <libdm/dm.h>
#include <libdm/dm.h>
#include <selinux/android.h>
#include <selinux/android.h>
@@ -37,7 +41,7 @@
#include "otapreopt_utils.h"
#include "otapreopt_utils.h"


#ifndef LOG_TAG
#ifndef LOG_TAG
#define LOG_TAG "otapreopt"
#define LOG_TAG "otapreopt_chroot"
#endif
#endif


using android::base::StringPrintf;
using android::base::StringPrintf;
@@ -49,20 +53,22 @@ namespace installd {
// so just try the possibilities one by one.
// so just try the possibilities one by one.
static constexpr std::array kTryMountFsTypes = {"ext4", "erofs"};
static constexpr std::array kTryMountFsTypes = {"ext4", "erofs"};


static void CloseDescriptor(int fd) {
    if (fd >= 0) {
        int result = close(fd);
        UNUSED(result);  // Ignore result. Printing to logcat will open a new descriptor
                         // that we do *not* want.
    }
}

static void CloseDescriptor(const char* descriptor_string) {
static void CloseDescriptor(const char* descriptor_string) {
    int fd = -1;
    int fd = -1;
    std::istringstream stream(descriptor_string);
    std::istringstream stream(descriptor_string);
    stream >> fd;
    stream >> fd;
    if (!stream.fail()) {
    if (!stream.fail()) {
        CloseDescriptor(fd);
        if (fd >= 0) {
            if (close(fd) < 0) {
                PLOG(ERROR) << "Failed to close " << fd;
            }
        }
    }
}

static void SetCloseOnExec(int fd) {
    if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
        PLOG(ERROR) << "Failed to set FD_CLOEXEC on " << fd;
    }
    }
}
}


@@ -129,24 +135,39 @@ static void TryExtraMount(const char* name, const char* slot, const char* target
}
}


// Entry for otapreopt_chroot. Expected parameters are:
// 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
//   [cmd] [status-fd] [target-slot-suffix]
// be passed on to otapreopt in the chroot.
//
// The file descriptor denoted by status-fd will be closed. Dexopt commands on
// the form
//
//   "dexopt" [dexopt-params]
//
// are then read from stdin until EOF and passed on to /system/bin/otapreopt one
// by one. After each call a line with the current command count is written to
// stdout and flushed.
static int otapreopt_chroot(const int argc, char **arg) {
static int otapreopt_chroot(const int argc, char **arg) {
    // Validate arguments
    // Validate arguments
    // We need the command, status channel and target slot, at a minimum.
    if (argc == 2 && std::string_view(arg[1]) == "--version") {
    if(argc < 3) {
        // Accept a single --version flag, to allow the script to tell this binary
        PLOG(ERROR) << "Not enough arguments.";
        // from the earlier one.
        std::cout << "2" << std::endl;
        return 0;
    }
    if (argc != 3) {
        LOG(ERROR) << "Wrong number of arguments: " << argc;
        exit(208);
        exit(208);
    }
    }
    // Close all file descriptors. They are coming from the caller, we do not want to pass them
    const char* status_fd = arg[1];
    // on across our fork/exec into a different domain.
    const char* slot_suffix = arg[2];
    // 1) Default descriptors.

    CloseDescriptor(STDIN_FILENO);
    // Set O_CLOEXEC on standard fds. They are coming from the caller, we do not
    CloseDescriptor(STDOUT_FILENO);
    // want to pass them on across our fork/exec into a different domain.
    CloseDescriptor(STDERR_FILENO);
    SetCloseOnExec(STDIN_FILENO);
    // 2) The status channel.
    SetCloseOnExec(STDOUT_FILENO);
    CloseDescriptor(arg[1]);
    SetCloseOnExec(STDERR_FILENO);
    // Close the status channel.
    CloseDescriptor(status_fd);


    // We need to run the otapreopt tool from the postinstall partition. As such, set up a
    // We need to run the otapreopt tool from the postinstall partition. As such, set up a
    // mount namespace and change root.
    // mount namespace and change root.
@@ -185,20 +206,20 @@ static int otapreopt_chroot(const int argc, char **arg) {
    //  2) We're in a mount namespace here, so when we die, this will be cleaned up.
    //  2) We're in a mount namespace here, so when we die, this will be cleaned up.
    //  3) Ignore errors. Printing anything at this stage will open a file descriptor
    //  3) Ignore errors. Printing anything at this stage will open a file descriptor
    //     for logging.
    //     for logging.
    if (!ValidateTargetSlotSuffix(arg[2])) {
    if (!ValidateTargetSlotSuffix(slot_suffix)) {
        LOG(ERROR) << "Target slot suffix not legal: " << arg[2];
        LOG(ERROR) << "Target slot suffix not legal: " << slot_suffix;
        exit(207);
        exit(207);
    }
    }
    TryExtraMount("vendor", arg[2], "/postinstall/vendor");
    TryExtraMount("vendor", slot_suffix, "/postinstall/vendor");


    // Try to mount the product partition. update_engine doesn't do this for us, but we
    // Try to mount the product partition. update_engine doesn't do this for us, but we
    // want it for product APKs. Same notes as vendor above.
    // want it for product APKs. Same notes as vendor above.
    TryExtraMount("product", arg[2], "/postinstall/product");
    TryExtraMount("product", slot_suffix, "/postinstall/product");


    // Try to mount the system_ext partition. update_engine doesn't do this for
    // Try to mount the system_ext partition. update_engine doesn't do this for
    // us, but we want it for system_ext APKs. Same notes as vendor and product
    // us, but we want it for system_ext APKs. Same notes as vendor and product
    // above.
    // above.
    TryExtraMount("system_ext", arg[2], "/postinstall/system_ext");
    TryExtraMount("system_ext", slot_suffix, "/postinstall/system_ext");


    constexpr const char* kPostInstallLinkerconfig = "/postinstall/linkerconfig";
    constexpr const char* kPostInstallLinkerconfig = "/postinstall/linkerconfig";
    // Try to mount /postinstall/linkerconfig. we will set it up after performing the chroot
    // Try to mount /postinstall/linkerconfig. we will set it up after performing the chroot
@@ -329,19 +350,25 @@ static int otapreopt_chroot(const int argc, char **arg) {
        exit(218);
        exit(218);
    }
    }


    // Now go on and run otapreopt.
    // Now go on and read dexopt lines from stdin and pass them on to otapreopt.


    // Incoming:  cmd + status-fd + target-slot + cmd...      | Incoming | = argc
    int count = 1;
    // Outgoing:  cmd             + target-slot + cmd...      | Outgoing | = argc - 1
    for (std::array<char, 1000> linebuf;
    std::vector<std::string> cmd;
         std::cin.clear(), std::cin.getline(&linebuf[0], linebuf.size()); ++count) {
    cmd.reserve(argc);
        // Subtract one from gcount() since getline() counts the newline.
    cmd.push_back("/system/bin/otapreopt");
        std::string line(&linebuf[0], std::cin.gcount() - 1);


    // The first parameter is the status file descriptor, skip.
        if (std::cin.fail()) {
    for (size_t i = 2; i < static_cast<size_t>(argc); ++i) {
            LOG(ERROR) << "Command exceeds max length " << linebuf.size() << " - skipped: " << line;
        cmd.push_back(arg[i]);
            continue;
        }
        }


        std::vector<std::string> tokenized_line = android::base::Tokenize(line, " ");
        std::vector<std::string> cmd{"/system/bin/otapreopt", slot_suffix};
        std::move(tokenized_line.begin(), tokenized_line.end(), std::back_inserter(cmd));

        LOG(INFO) << "Command " << count << ": " << android::base::Join(cmd, " ");

        // Fork and execute otapreopt in its own process.
        // Fork and execute otapreopt in its own process.
        std::string error_msg;
        std::string error_msg;
        bool exec_result = Exec(cmd, &error_msg);
        bool exec_result = Exec(cmd, &error_msg);
@@ -349,10 +376,11 @@ static int otapreopt_chroot(const int argc, char **arg) {
            LOG(ERROR) << "Running otapreopt failed: " << error_msg;
            LOG(ERROR) << "Running otapreopt failed: " << error_msg;
        }
        }


    if (!exec_result) {
        // Print the count to stdout and flush to indicate progress.
        exit(213);
        std::cout << count << std::endl;
    }
    }


    LOG(INFO) << "No more dexopt commands";
    return 0;
    return 0;
}
}


Loading