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

Commit 4420c4d2 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13613609 from 3b797e23 to 25Q4-release

Change-Id: I98909c922af84385236cb0b12246f8dbd8b8b768
parents bba58e92 3b797e23
Loading
Loading
Loading
Loading

OWNERS

0 → 100644
+4 −0
Original line number Diff line number Diff line
# See frameworks/base/OWNERS.md
jiyong@google.com #{LAST_RESORT_SUGGESTION}
michaelwr@google.com #{LAST_RESORT_SUGGESTION}
smoreland@google.com #{LAST_RESORT_SUGGESTION}
+14 −1
Original line number Diff line number Diff line
@@ -216,6 +216,11 @@ static const std::string SHUTDOWN_CHECKPOINTS_FILE_PREFIX = "checkpoints-";
// File path to default screenshot image, that used when failed to capture the real screenshot.
static const std::string DEFAULT_SCREENSHOT_PATH = "/system/etc/default_screenshot.png";

// File path of the persistent ring buffer perfetto trace. This always exists when persistent ring
// buffer trace feature is enabled.
static const std::string PREV_BOOT_TRACE_PATH =
    std::string(SYSTEM_TRACE_DIR) + "/prev_boot_dump.trace";

// TODO: temporary variables and functions used during C++ refactoring

#define RETURN_IF_USER_DENIED_CONSENT()                                                        \
@@ -1146,6 +1151,9 @@ static void MaybeAddSystemTraceToZip() {
    // tracing was happening.
    size_t traces_found = android::os::ForEachTrace([&](const std::string& trace_path) {
        ds.AddZipEntry(ZIP_ROOT_DIR + trace_path, trace_path);
        if (trace_path == PREV_BOOT_TRACE_PATH) {
            return;
        }
        android::os::UnlinkAndLogOnError(trace_path);
    });

@@ -3647,7 +3655,12 @@ std::future<std::string> Dumpstate::MaybeSnapshotSystemTraceAsync() {
    }

    // If a stale file exists already, remove it.
    android::os::ForEachTrace([&](const std::string& trace_path) { unlink(trace_path.c_str()); });
    android::os::ForEachTrace([&](const std::string& trace_path) {
        if (trace_path == PREV_BOOT_TRACE_PATH) {
            return;
        }
        unlink(trace_path.c_str());
    });

    MYLOGI("Launching async '%s'", SERIALIZE_PERFETTO_TRACE_TASK.c_str())

+15 −0
Original line number Diff line number Diff line
@@ -7,6 +7,20 @@ package {
    default_applicable_licenses: ["frameworks_native_license"],
}

aconfig_declarations {
    name: "installd_flags",
    package: "android.installd.flags",
    container: "system",
    srcs: [
        "installd_flags.aconfig",
    ],
}

cc_aconfig_library {
    name: "installd_flags_c_lib",
    aconfig_declarations: "installd_flags",
}

cc_defaults {
    name: "installd_defaults",

@@ -50,6 +64,7 @@ cc_defaults {
        "server_configurable_flags",
    ],
    static_libs: [
        "installd_flags_c_lib",
        "libasync_safe",
        "libext2_uuid",
    ],
+8 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@
#include "QuotaUtils.h"
#include "SysTrace.h"

#include <android_installd_flags.h>

#ifndef LOG_TAG
#define LOG_TAG "installd"
#endif
@@ -89,6 +91,7 @@ using android::base::StringPrintf;
using android::base::unique_fd;
using android::os::ParcelFileDescriptor;
using std::endl;
namespace flags = android::installd::flags;

namespace android {
namespace installd {
@@ -882,6 +885,11 @@ binder::Status InstalldNativeService::createAppDataLocked(
            chown_app_profile_dir(packageName, appId, userId);
        }

        if (flags::enable_set_inode_quotas() &&
            !PrepareAppInodeQuota(uuid ? uuid->c_str() : "", uid)) {
            PLOG(ERROR) << "Failed to set hard quota " + path;
        }

        if (!prepare_app_profile_dir(packageName, appId, userId)) {
            return error("Failed to prepare profiles for " + packageName);
        }
+65 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <unordered_map>

#include <sys/quota.h>
#include <sys/statvfs.h>

#include <android-base/logging.h>

@@ -143,5 +144,69 @@ int64_t GetOccupiedSpaceForGid(const std::string& uuid, gid_t gid) {

}

bool PrepareAppInodeQuota(const std::string& uuid, uid_t uid) {
    const std::string device = FindQuotaDeviceForUuid(uuid);
    // Skip when device has no quotas present
    if (device.empty()) {
        return true;
    }

#if APPLY_HARD_QUOTAS
    struct dqblk dq;
    if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device.c_str(), uid, reinterpret_cast<char*>(&dq)) !=
        0) {
        PLOG(WARNING) << "Failed to find quota for " << uid;
        return false;
    }

    if (dq.dqb_ihardlimit == 0) {
        auto path = create_data_path(uuid.empty() ? nullptr : uuid.c_str());
        struct statvfs stat;
        if (statvfs(path.c_str(), &stat) != 0) {
            PLOG(WARNING) << "Failed to statvfs " << path;
            return false;
        }

        dq.dqb_valid |= QIF_ILIMITS;
        // limiting the app to only 50% of the inodes available,
        // reducing the limit will be too restrictive especially for apps with valid use cases
        dq.dqb_ihardlimit = (stat.f_files / 2);

        if (quotactl(QCMD(Q_SETQUOTA, USRQUOTA), device.c_str(), uid,
                     reinterpret_cast<char*>(&dq)) != 0) {
            PLOG(WARNING) << "Failed to set hard quota for " << uid;
            return false;
        } else {
            LOG(DEBUG) << "Applied hard quotas for " << uid;
            return true;
        }
    } else {
        // Hard quota already set; assume it's reasonable
        return true;
    }
#else
    // Hard quotas disabled
    return true;
#endif
}

int64_t GetInodesQuotaHardLimitsForUid(const std::string& uuid, uid_t uid) {
    const std::string device = FindQuotaDeviceForUuid(uuid);
    if (device.empty()) {
        return 0;
    }

    struct dqblk dq;
    if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device.c_str(), uid, reinterpret_cast<char*>(&dq)) !=
        0) {
        if (errno != ESRCH) {
            PLOG(ERROR) << "Failed to quotactl " << device << " for UID " << uid;
        }
        return -1;
    } else {
        return dq.dqb_ihardlimit;
    }
}

}  // namespace installd
}  // namespace android
Loading