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

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

Snap for 11232546 from 9f0be410 to 24Q2-release

Change-Id: I5807ddedb7031e9aacac079096e5e247327547c8
parents 43b48dfa 9f0be410
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ namespace android {
static const char* kReturnStrings[] = {
        "BR_ERROR",
        "BR_OK",
    "BR_TRANSACTION",
        "BR_TRANSACTION/BR_TRANSACTION_SEC_CTX",
        "BR_REPLY",
        "BR_ACQUIRE_RESULT",
        "BR_DEAD_REPLY",
@@ -88,7 +88,7 @@ static const char *kReturnStrings[] = {
        "BR_FAILED_REPLY",
        "BR_FROZEN_REPLY",
        "BR_ONEWAY_SPAM_SUSPECT",
    "BR_TRANSACTION_SEC_CTX",
        "BR_TRANSACTION_PENDING_FROZEN",
};

static const char *kCommandStrings[] = {
+0 −1
Original line number Diff line number Diff line
@@ -423,7 +423,6 @@ cc_defaults {
        "libhidlbase",
        "liblog",
        "libnativewindow",
        "libselinux",
        "libsync",
        "libui",
        "libutils",
+8 −45
Original line number Diff line number Diff line
@@ -38,43 +38,10 @@
#include <private/gui/BufferQueueThreadState.h>
#if !defined(__ANDROID_VNDK__) && !defined(NO_BINDER)
#include <binder/PermissionCache.h>
#include <selinux/android.h>
#include <selinux/selinux.h>
#endif

#include <system/window.h>

namespace {
#if !defined(__ANDROID_VNDK__) && !defined(NO_BINDER)
int selinux_log_suppress_callback(int, const char*, ...) { // NOLINT
    // DO NOTHING
    return 0;
}

bool hasAccessToPermissionService() {
    char* ctx;

    if (getcon(&ctx) == -1) {
        // Failed to get current selinux context
        return false;
    }

    union selinux_callback cb;

    cb.func_log = selinux_log_suppress_callback;
    selinux_set_callback(SELINUX_CB_LOG, cb);

    bool hasAccess = selinux_check_access(ctx, "u:object_r:permission_service:s0",
                                          "service_manager", "find", NULL) == 0;
    freecon(ctx);
    cb.func_log = hasAccess ? selinux_log_callback : selinux_vendor_log_callback;
    selinux_set_callback(SELINUX_CB_LOG, cb);

    return hasAccess;
}
#endif
} // namespace

namespace android {

// Macros for include BufferQueueCore information in log messages
@@ -843,10 +810,7 @@ status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResul
    const uid_t uid = BufferQueueThreadState::getCallingUid();
#if !defined(__ANDROID_VNDK__) && !defined(NO_BINDER)
    // permission check can't be done for vendors as vendors have no access to
    // the PermissionController. We need to do a runtime check as well, since
    // the system variant of libgui can be loaded in a vendor process. For eg:
    // if a HAL uses an llndk library that depends on libgui (libmediandk etc).
    if (hasAccessToPermissionService()) {
    // the PermissionController.
    const pid_t pid = BufferQueueThreadState::getCallingPid();
    if ((uid != shellUid) &&
        !PermissionCache::checkPermission(String16("android.permission.DUMP"), pid, uid)) {
@@ -855,7 +819,6 @@ status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResul
                                pid, uid);
        denied = true;
    }
    }
#else
    if (uid != shellUid) {
        denied = true;
+34 −3
Original line number Diff line number Diff line
@@ -190,8 +190,12 @@ bool LayerHierarchy::hasRelZLoop(uint32_t& outInvalidRelativeRoot) const {
    return outInvalidRelativeRoot != UNASSIGNED_LAYER_ID;
}

LayerHierarchyBuilder::LayerHierarchyBuilder(
        const std::vector<std::unique_ptr<RequestedLayerState>>& layers) {
void LayerHierarchyBuilder::init(const std::vector<std::unique_ptr<RequestedLayerState>>& layers) {
    mLayerIdToHierarchy.clear();
    mHierarchies.clear();
    mRoot = nullptr;
    mOffscreenRoot = nullptr;

    mHierarchies.reserve(layers.size());
    mLayerIdToHierarchy.reserve(layers.size());
    for (auto& layer : layers) {
@@ -202,6 +206,7 @@ LayerHierarchyBuilder::LayerHierarchyBuilder(
        onLayerAdded(layer.get());
    }
    detachHierarchyFromRelativeParent(&mOffscreenRoot);
    mInitialized = true;
}

void LayerHierarchyBuilder::attachToParent(LayerHierarchy* hierarchy) {
@@ -332,7 +337,7 @@ void LayerHierarchyBuilder::updateMirrorLayer(RequestedLayerState* layer) {
    }
}

void LayerHierarchyBuilder::update(
void LayerHierarchyBuilder::doUpdate(
        const std::vector<std::unique_ptr<RequestedLayerState>>& layers,
        const std::vector<std::unique_ptr<RequestedLayerState>>& destroyedLayers) {
    // rebuild map
@@ -381,6 +386,32 @@ void LayerHierarchyBuilder::update(
    attachHierarchyToRelativeParent(&mRoot);
}

void LayerHierarchyBuilder::update(LayerLifecycleManager& layerLifecycleManager) {
    if (!mInitialized) {
        ATRACE_NAME("LayerHierarchyBuilder:init");
        init(layerLifecycleManager.getLayers());
    } else if (layerLifecycleManager.getGlobalChanges().test(
                       RequestedLayerState::Changes::Hierarchy)) {
        ATRACE_NAME("LayerHierarchyBuilder:update");
        doUpdate(layerLifecycleManager.getLayers(), layerLifecycleManager.getDestroyedLayers());
    } else {
        return; // nothing to do
    }

    uint32_t invalidRelativeRoot;
    bool hasRelZLoop = mRoot.hasRelZLoop(invalidRelativeRoot);
    while (hasRelZLoop) {
        ATRACE_NAME("FixRelZLoop");
        TransactionTraceWriter::getInstance().invoke("relz_loop_detected",
                                                     /*overwrite=*/false);
        layerLifecycleManager.fixRelativeZLoop(invalidRelativeRoot);
        // reinitialize the hierarchy with the updated layer data
        init(layerLifecycleManager.getLayers());
        // check if we have any remaining loops
        hasRelZLoop = mRoot.hasRelZLoop(invalidRelativeRoot);
    }
}

const LayerHierarchy& LayerHierarchyBuilder::getHierarchy() const {
    return mRoot;
}
+8 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include "FrontEnd/LayerCreationArgs.h"
#include "FrontEnd/LayerLifecycleManager.h"
#include "RequestedLayerState.h"
#include "ftl/small_vector.h"

@@ -197,9 +198,8 @@ private:
// hierarchy from a list of RequestedLayerState and associated change flags.
class LayerHierarchyBuilder {
public:
    LayerHierarchyBuilder(const std::vector<std::unique_ptr<RequestedLayerState>>&);
    void update(const std::vector<std::unique_ptr<RequestedLayerState>>& layers,
                const std::vector<std::unique_ptr<RequestedLayerState>>& destroyedLayers);
    LayerHierarchyBuilder() = default;
    void update(LayerLifecycleManager& layerLifecycleManager);
    LayerHierarchy getPartialHierarchy(uint32_t, bool childrenOnly) const;
    const LayerHierarchy& getHierarchy() const;
    const LayerHierarchy& getOffscreenHierarchy() const;
@@ -213,14 +213,18 @@ private:
    void detachFromRelativeParent(LayerHierarchy*);
    void attachHierarchyToRelativeParent(LayerHierarchy*);
    void detachHierarchyFromRelativeParent(LayerHierarchy*);

    void init(const std::vector<std::unique_ptr<RequestedLayerState>>&);
    void doUpdate(const std::vector<std::unique_ptr<RequestedLayerState>>& layers,
                  const std::vector<std::unique_ptr<RequestedLayerState>>& destroyedLayers);
    void onLayerDestroyed(RequestedLayerState* layer);
    void updateMirrorLayer(RequestedLayerState* layer);
    LayerHierarchy* getHierarchyFromId(uint32_t layerId, bool crashOnFailure = true);

    std::unordered_map<uint32_t, LayerHierarchy*> mLayerIdToHierarchy;
    std::vector<std::unique_ptr<LayerHierarchy>> mHierarchies;
    LayerHierarchy mRoot{nullptr};
    LayerHierarchy mOffscreenRoot{nullptr};
    bool mInitialized = false;
};

} // namespace android::surfaceflinger::frontend
Loading