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

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

Snap for 5187456 from b923f2d7 to qt-release

Change-Id: I788081f43d28c36f51de7d2a92d070df55b16198
parents 7babab7b b923f2d7
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -139,7 +139,16 @@ cc_binary {
    srcs: ["otapreopt_chroot.cpp"],
    srcs: ["otapreopt_chroot.cpp"],
    shared_libs: [
    shared_libs: [
        "libbase",
        "libbase",
        "libjsoncpp",
        "liblog",
        "liblog",
        "libselinux",
        "libziparchive",
    ],
    static_libs: [
        "libapex",
        "libapexd",
        "libavb",
        "libdm",
    ],
    ],
}
}


+42 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#include <fcntl.h>
#include <fcntl.h>
#include <linux/unistd.h>
#include <linux/unistd.h>
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/wait.h>


#include <sstream>
#include <sstream>
@@ -24,6 +25,9 @@
#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 <selinux/android.h>

#include <apexd.h>


#include "installd_constants.h"
#include "installd_constants.h"
#include "otapreopt_utils.h"
#include "otapreopt_utils.h"
@@ -138,6 +142,32 @@ static int otapreopt_chroot(const int argc, char **arg) {
      UNUSED(product_result);
      UNUSED(product_result);
    }
    }


    // Setup APEX mount point and its security context.
    // The logic here is similar to the one in system/core/rootdir/init.rc:
    //
    //   mount tmpfs tmpfs /apex nodev noexec nosuid
    //   chmod 0755 /apex
    //   chown root root /apex
    //   restorecon /apex
    //
    if (mount("tmpfs", "/postinstall/apex", "tmpfs", MS_NODEV | MS_NOEXEC | MS_NOSUID, nullptr)
        != 0) {
      PLOG(ERROR) << "Failed to mount tmpfs in /postinstall/apex";
      exit(209);
    }
    if (chmod("/postinstall/apex", 0755) != 0) {
      PLOG(ERROR) << "Failed to chmod /postinstall/apex to 0755";
      exit(210);
    }
    if (chown("/postinstall/apex", 0, 0) != 0) {
      PLOG(ERROR) << "Failed to chown /postinstall/apex to root:root";
      exit(211);
    }
    if (selinux_android_restorecon("/postinstall/apex", 0) < 0) {
      PLOG(ERROR) << "Failed to restorecon /postinstall/apex";
      exit(212);
    }

    // Chdir into /postinstall.
    // Chdir into /postinstall.
    if (chdir("/postinstall") != 0) {
    if (chdir("/postinstall") != 0) {
        PLOG(ERROR) << "Unable to chdir into /postinstall.";
        PLOG(ERROR) << "Unable to chdir into /postinstall.";
@@ -155,6 +185,18 @@ static int otapreopt_chroot(const int argc, char **arg) {
        exit(205);
        exit(205);
    }
    }


    // Try to mount APEX packages in "/apex" in the chroot dir. We need at least
    // the Android Runtime APEX, as it is required by otapreopt to run dex2oat.
    {
      // The logic here is (partially) copied and adapted from
      // system/apex/apexd/apexd_main.cpp.

      // Only scan the APEX directory under /system (within the chroot dir).
      // Note that this leaves around the loop devices created and used by
      // libapexd's code, but this is fine, as we expect to reboot soon after.
      apex::scanPackagesDirAndActivate(apex::kApexPackageSystemDir);
    }

    // Now go on and run otapreopt.
    // Now go on and run otapreopt.


    // Incoming:  cmd + status-fd + target-slot + cmd... + null      | Incoming | = argc + 1
    // Incoming:  cmd + status-fd + target-slot + cmd... + null      | Incoming | = argc + 1
+20 −20
Original line number Original line Diff line number Diff line
@@ -376,23 +376,23 @@ void ListCommand::postprocess() {
    }
    }


    mServicesTable.setDescription(
    mServicesTable.setDescription(
            "All binderized services (registered services through hwservicemanager)");
            "| All binderized services (registered with hwservicemanager)");
    mPassthroughRefTable.setDescription(
    mPassthroughRefTable.setDescription(
            "All interfaces that getService() has ever return as a passthrough interface;\n"
            "| All interfaces that getService() has ever returned as a passthrough interface;\n"
            "PIDs / processes shown below might be inaccurate because the process\n"
            "| PIDs / processes shown below might be inaccurate because the process\n"
            "might have relinquished the interface or might have died.\n"
            "| might have relinquished the interface or might have died.\n"
            "The Server / Server CMD column can be ignored.\n"
            "| The Server / Server CMD column can be ignored.\n"
            "The Clients / Clients CMD column shows all process that have ever dlopen'ed \n"
            "| The Clients / Clients CMD column shows all process that have ever dlopen'ed \n"
            "the library and successfully fetched the passthrough implementation.");
            "| the library and successfully fetched the passthrough implementation.");
    mImplementationsTable.setDescription(
    mImplementationsTable.setDescription(
            "All available passthrough implementations (all -impl.so files).\n"
            "| All available passthrough implementations (all -impl.so files).\n"
            "These may return subclasses through their respective HIDL_FETCH_I* functions.");
            "| These may return subclasses through their respective HIDL_FETCH_I* functions.");
    mManifestHalsTable.setDescription(
    mManifestHalsTable.setDescription(
            "All HALs that are in VINTF manifest.");
            "| All HALs that are in VINTF manifest.");
    mLazyHalsTable.setDescription(
    mLazyHalsTable.setDescription(
            "All HALs that are declared in VINTF manifest:\n"
            "| All HALs that are declared in VINTF manifest:\n"
            "   - as hwbinder HALs but are not registered to hwservicemanager, and\n"
            "|    - as hwbinder HALs but are not registered to hwservicemanager, and\n"
            "   - as hwbinder/passthrough HALs with no implementation.");
            "|    - as hwbinder/passthrough HALs with no implementation.");
}
}


bool ListCommand::addEntryWithInstance(const TableEntry& entry,
bool ListCommand::addEntryWithInstance(const TableEntry& entry,
@@ -972,10 +972,10 @@ void ListCommand::registerAllOptions() {
        thiz->mSelectedColumns.push_back(TableColumnType::VINTF);
        thiz->mSelectedColumns.push_back(TableColumnType::VINTF);
        return OK;
        return OK;
    }, "print VINTF info. This column contains a comma-separated list of:\n"
    }, "print VINTF info. This column contains a comma-separated list of:\n"
       "    - DM: device manifest\n"
       "    - DM: if the HAL is in the device manifest\n"
       "    - DC: device compatibility matrix\n"
       "    - DC: if the HAL is in the device compatibility matrix\n"
       "    - FM: framework manifest\n"
       "    - FM: if the HAL is in the framework manifest\n"
       "    - FC: framework compatibility matrix"});
       "    - FC: if the HAL is in the framework compatibility matrix"});
    mOptions.push_back({'S', "service-status", no_argument, v++, [](ListCommand* thiz, const char*) {
    mOptions.push_back({'S', "service-status", no_argument, v++, [](ListCommand* thiz, const char*) {
        thiz->mSelectedColumns.push_back(TableColumnType::SERVICE_STATUS);
        thiz->mSelectedColumns.push_back(TableColumnType::SERVICE_STATUS);
        return OK;
        return OK;
@@ -1054,7 +1054,7 @@ void ListCommand::registerAllOptions() {
        return OK;
        return OK;
    }, "comma-separated list of one or more sections.\nThe output is restricted to the selected "
    }, "comma-separated list of one or more sections.\nThe output is restricted to the selected "
       "section(s). Valid options\nare: (b|binderized), (c|passthrough_clients), (l|"
       "section(s). Valid options\nare: (b|binderized), (c|passthrough_clients), (l|"
       "passthrough_libs), and (v|vintf).\nDefault is `bcl`."});
       "passthrough_libs), (v|vintf), and (z|lazy).\nDefault is `bcl`."});
}
}


// Create 'longopts' argument to getopt_long. Caller is responsible for maintaining
// Create 'longopts' argument to getopt_long. Caller is responsible for maintaining
@@ -1150,7 +1150,7 @@ Status ListCommand::parseArgs(const Arg &arg) {
    }
    }


    if (mSelectedColumns.empty()) {
    if (mSelectedColumns.empty()) {
        mSelectedColumns = {TableColumnType::RELEASED,
        mSelectedColumns = {TableColumnType::VINTF, TableColumnType::RELEASED,
                            TableColumnType::INTERFACE_NAME, TableColumnType::THREADS,
                            TableColumnType::INTERFACE_NAME, TableColumnType::THREADS,
                            TableColumnType::SERVER_PID, TableColumnType::CLIENT_PIDS};
                            TableColumnType::SERVER_PID, TableColumnType::CLIENT_PIDS};
    }
    }
@@ -1210,7 +1210,7 @@ void ListCommand::usage() const {
    err() << "list:" << std::endl
    err() << "list:" << std::endl
          << "    lshal" << std::endl
          << "    lshal" << std::endl
          << "    lshal list" << std::endl
          << "    lshal list" << std::endl
          << "        List all hals with default ordering and columns (`lshal list -liepc`)" << std::endl
          << "        List all hals with default ordering and columns (`lshal list -Vliepc`)" << std::endl
          << "    lshal list [-h|--help]" << std::endl
          << "    lshal list [-h|--help]" << std::endl
          << "        -h, --help: Print help message for list (`lshal help list`)" << std::endl
          << "        -h, --help: Print help message for list (`lshal help list`)" << std::endl
          << "    lshal [list] [OPTIONS...]" << std::endl;
          << "    lshal [list] [OPTIONS...]" << std::endl;
+28 −0
Original line number Original line Diff line number Diff line
// 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
//
//      https://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.

cc_binary {
    name: "rss_hwm_reset",

    srcs: [
        "rss_hwm_reset.cc",
    ],

    shared_libs: [
        "libbase",
        "liblog",
    ],

    init_rc: ["rss_hwm_reset.rc"],
}
+72 −0
Original line number Original line Diff line number Diff line
/*
 * 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
 *
 *      https://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.
 */

 /*
  * rss_hwm_reset clears the RSS high-water mark counters for all currently
  * running processes. It writes "5" to /proc/PID/clear_refs for every PID.
  *
  * It runs in its own process becuase dac_override capability is required
  * in order to write to other processes' clear_refs.
  *
  * It is invoked from a system service by flipping sys.rss_hwm_reset.on
  * property to "1".
  */

#define LOG_TAG "rss_hwm_reset"

#include <dirent.h>

#include <string>

#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <log/log.h>

namespace {
// Resets RSS HWM counter for the selected process by writing 5 to
// /proc/PID/clear_refs.
void reset_rss_hwm(const char* pid) {
    std::string clear_refs_path =
            ::android::base::StringPrintf("/proc/%s/clear_refs", pid);
    ::android::base::WriteStringToFile("5", clear_refs_path);
}
}

// Clears RSS HWM counters for all currently running processes.
int main(int /* argc */, char** /* argv[] */) {
    DIR* dirp = opendir("/proc");
    if (dirp == nullptr) {
        ALOGE("unable to read /proc");
        return 1;
    }
    struct dirent* entry;
    while ((entry = readdir(dirp)) != nullptr) {
        // Skip entries that are not directories.
        if (entry->d_type != DT_DIR) continue;
        // Skip entries that do not contain only numbers.
        const char* pid = entry->d_name;
        while (*pid) {
            if (*pid < '0' || *pid > '9') break;
            pid++;
        }
        if (*pid != 0) continue;

        pid = entry->d_name;
        reset_rss_hwm(pid);
    }
    closedir(dirp);
    return 0;
}
Loading