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

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

Snap for 8414751 from 5a896f35 to tm-release

Change-Id: Ie00c934b1da94fbf0a9170067f6e223f0fa1daa0
parents c65ceabc 5a896f35
Loading
Loading
Loading
Loading
+10 −19
Original line number Diff line number Diff line
@@ -633,7 +633,7 @@ static void chown_app_profile_dir(const std::string &packageName, int32_t appId,
}

static binder::Status createAppDataDirs(const std::string& path, int32_t uid, int32_t gid,
                                        int32_t* previousUid, int32_t cacheGid,
                                        int32_t previousUid, int32_t cacheGid,
                                        const std::string& seInfo, mode_t targetMode,
                                        long projectIdApp, long projectIdCache) {
    struct stat st{};
@@ -645,14 +645,8 @@ static binder::Status createAppDataDirs(const std::string& path, int32_t uid, in
    bool code_cache_exists = (access(code_cache_path.c_str(), F_OK) == 0);

    if (parent_dir_exists) {
        if (*previousUid < 0) {
            // If previousAppId is -1 in CreateAppDataArgs, we will assume the current owner
            // of the directory as previousUid. This is required because it is not always possible
            // to chown app data during app upgrade (e.g. secondary users' CE storage not unlocked)
            *previousUid = st.st_uid;
        }
        if (*previousUid != uid) {
            if (!chown_app_dir(path, uid, *previousUid, cacheGid)) {
        if (previousUid > 0 && previousUid != uid) {
            if (!chown_app_dir(path, uid, previousUid, cacheGid)) {
                return error("Failed to chown " + path);
            }
        }
@@ -702,12 +696,9 @@ binder::Status InstalldNativeService::createAppDataLocked(

    int32_t uid = multiuser_get_uid(userId, appId);

    // If previousAppId < 0, we will use the existing app data owner as previousAppUid
    // If previousAppId == 0, we use uid as previousUid (no data migration will happen)
    // if previousAppId > 0, an app is upgrading and changing its app ID
    int32_t previousUid = previousAppId > 0
        ? (int32_t) multiuser_get_uid(userId, previousAppId)
        : (previousAppId == 0 ? uid : -1);
    // If previousAppId > 0, an app is changing its app ID
    int32_t previousUid =
            previousAppId > 0 ? (int32_t)multiuser_get_uid(userId, previousAppId) : -1;

    int32_t cacheGid = multiuser_get_cache_gid(userId, appId);
    mode_t targetMode = targetSdkVersion >= MIN_RESTRICTED_HOME_SDK_VERSION ? 0700 : 0751;
@@ -723,7 +714,7 @@ binder::Status InstalldNativeService::createAppDataLocked(
    if (flags & FLAG_STORAGE_CE) {
        auto path = create_data_user_ce_package_path(uuid_, userId, pkgname);

        auto status = createAppDataDirs(path, uid, uid, &previousUid, cacheGid, seInfo, targetMode,
        auto status = createAppDataDirs(path, uid, uid, previousUid, cacheGid, seInfo, targetMode,
                                        projectIdApp, projectIdCache);
        if (!status.isOk()) {
            return status;
@@ -749,12 +740,12 @@ binder::Status InstalldNativeService::createAppDataLocked(
    if (flags & FLAG_STORAGE_DE) {
        auto path = create_data_user_de_package_path(uuid_, userId, pkgname);

        auto status = createAppDataDirs(path, uid, uid, &previousUid, cacheGid, seInfo, targetMode,
        auto status = createAppDataDirs(path, uid, uid, previousUid, cacheGid, seInfo, targetMode,
                                        projectIdApp, projectIdCache);
        if (!status.isOk()) {
            return status;
        }
        if (previousUid != uid) {
        if (previousUid > 0 && previousUid != uid) {
            chown_app_profile_dir(packageName, appId, userId);
        }

@@ -954,7 +945,7 @@ binder::Status InstalldNativeService::reconcileSdkData(const std::optional<std::
            long projectIdApp = get_project_id(appUid, PROJECT_ID_APP_START);
            long projectIdCache = get_project_id(appUid, PROJECT_ID_APP_CACHE_START);
            auto status =
                    createAppDataDirs(path, sandboxUid, AID_NOBODY, &previousSandboxUid, cacheGid,
                    createAppDataDirs(path, sandboxUid, AID_NOBODY, previousSandboxUid, cacheGid,
                                      seInfo, 0700 | S_ISGID, projectIdApp, projectIdCache);
            if (!status.isOk()) {
                res = status;
+14 −0
Original line number Diff line number Diff line
@@ -575,6 +575,20 @@ struct DeathRecipientVtable {
    cookie_decr_refcount: unsafe extern "C" fn(*mut c_void),
}

/// # Safety
///
/// A `DeathRecipient` is a wrapper around `AIBinder_DeathRecipient` and a pointer
/// to a `Fn` which is `Sync` and `Send` (the cookie field). As
/// `AIBinder_DeathRecipient` is threadsafe, this structure is too.
unsafe impl Send for DeathRecipient {}

/// # Safety
///
/// A `DeathRecipient` is a wrapper around `AIBinder_DeathRecipient` and a pointer
/// to a `Fn` which is `Sync` and `Send` (the cookie field). As
/// `AIBinder_DeathRecipient` is threadsafe, this structure is too.
unsafe impl Sync for DeathRecipient {}

impl DeathRecipient {
    /// Create a new death recipient that will call the given callback when its
    /// associated object dies.
+0 −3
Original line number Diff line number Diff line
@@ -22,9 +22,6 @@
namespace android::compositionengine::impl {

struct GpuCompositionResult {
    // True if composition strategy was predicted successfully.
    bool succeeded = false;

    // Composition ready fence.
    base::unique_fd fence{};

+12 −0
Original line number Diff line number Diff line
@@ -148,6 +148,18 @@ struct OutputCompositionState {
    // This is slightly distinct from nits, in that nits cannot be passed to hw composer.
    std::optional<float> displayBrightness = std::nullopt;

    enum class CompositionStrategyPredictionState : uint32_t {
        // Composition strategy prediction did not run for this frame.
        DISABLED = 0,
        // Composition strategy predicted successfully for this frame.
        SUCCESS = 1,
        // Composition strategy prediction failed for this frame.
        FAIL = 2,
    };

    CompositionStrategyPredictionState strategyPrediction =
            CompositionStrategyPredictionState::DISABLED;

    // Debugging
    void dump(std::string& result) const;
};
+8 −5
Original line number Diff line number Diff line
@@ -58,7 +58,8 @@ namespace android::compositionengine {
Output::~Output() = default;

namespace impl {

using CompositionStrategyPredictionState =
        OutputCompositionState::CompositionStrategyPredictionState;
namespace {

template <typename T>
@@ -970,6 +971,7 @@ void Output::prepareFrame() {
    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
    bool success = chooseCompositionStrategy(&changes);
    resetCompositionStrategy();
    outputState.strategyPrediction = CompositionStrategyPredictionState::DISABLED;
    outputState.previousDeviceRequestedChanges = changes;
    outputState.previousDeviceRequestedSuccess = success;
    if (success) {
@@ -1012,7 +1014,8 @@ GpuCompositionResult Output::prepareFrameAsync(const CompositionRefreshArgs& ref

    auto chooseCompositionSuccess = hwcResult.get();
    const bool predictionSucceeded = dequeueSucceeded && changes == previousChanges;
    compositionResult.succeeded = predictionSucceeded;
    state.strategyPrediction = predictionSucceeded ? CompositionStrategyPredictionState::SUCCESS
                                                   : CompositionStrategyPredictionState::FAIL;
    if (!predictionSucceeded) {
        ATRACE_NAME("CompositionStrategyPredictionMiss");
        resetCompositionStrategy();
@@ -1056,15 +1059,15 @@ void Output::devOptRepaintFlash(const compositionengine::CompositionRefreshArgs&
void Output::finishFrame(const CompositionRefreshArgs& refreshArgs, GpuCompositionResult&& result) {
    ATRACE_CALL();
    ALOGV(__FUNCTION__);

    if (!getState().isEnabled) {
    const auto& outputState = getState();
    if (!outputState.isEnabled) {
        return;
    }

    std::optional<base::unique_fd> optReadyFence;
    std::shared_ptr<renderengine::ExternalTexture> buffer;
    base::unique_fd bufferFence;
    if (result.succeeded) {
    if (outputState.strategyPrediction == CompositionStrategyPredictionState::SUCCESS) {
        optReadyFence = std::move(result.fence);
    } else {
        if (result.bufferAvailable()) {
Loading