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

Commit 79a14ede authored by Leon Scroggins's avatar Leon Scroggins Committed by Android (Google) Code Review
Browse files

Merge changes from topic...

Merge changes from topic "revert-16527342-revert-16511727-wm_DISPLAY_DECORATION-KXJKEKMWKV-VMUYJOIPFS"

* changes:
  Treat AID_GRAPHICS and AID_SYSTEM as having InternalSystemWindowAccess
  Reland "Allow changing composition from DISPLAY_DECORATION to DEVICE"
  Reland "Add eLayerIsDisplayDecoration flag"
parents ff8c1759 cf7a7b25
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1104,7 +1104,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFlags
    }
    if ((mask & layer_state_t::eLayerOpaque) || (mask & layer_state_t::eLayerHidden) ||
        (mask & layer_state_t::eLayerSecure) || (mask & layer_state_t::eLayerSkipScreenshot) ||
        (mask & layer_state_t::eEnableBackpressure)) {
        (mask & layer_state_t::eEnableBackpressure) ||
        (mask & layer_state_t::eLayerIsDisplayDecoration)) {
        s->what |= layer_state_t::eFlagsChanged;
    }
    s->flags &= ~mask;
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ struct layer_state_t {
        // set. This blocks the client until all the buffers have been presented. If the buffers
        // have presentation timestamps, then we may drop buffers.
        eEnableBackpressure = 0x100, // ENABLE_BACKPRESSURE
        eLayerIsDisplayDecoration = 0x200,  // DISPLAY_DECORATION
    };

    enum {
+3 −0
Original line number Diff line number Diff line
@@ -295,6 +295,9 @@ void BufferLayer::preparePerFrameCompositionState() {
        compositionState->compositionType =
                aidl::android::hardware::graphics::composer3::Composition::SIDEBAND;
        return;
    } else if ((mDrawingState.flags & layer_state_t::eLayerIsDisplayDecoration) != 0) {
        compositionState->compositionType =
                aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION;
    } else {
        // Normal buffer layers
        compositionState->hdrMetadata = mBufferInfo.mHdrMetadata;
+1 −1
Original line number Diff line number Diff line
@@ -685,12 +685,12 @@ void OutputLayer::detectDisallowedCompositionTypeChange(Composition from, Compos

        case Composition::DEVICE:
        case Composition::SOLID_COLOR:
        case Composition::DISPLAY_DECORATION:
            result = (to == Composition::CLIENT);
            break;

        case Composition::CURSOR:
        case Composition::SIDEBAND:
        case Composition::DISPLAY_DECORATION:
            result = (to == Composition::CLIENT || to == Composition::DEVICE);
            break;
    }
+23 −2
Original line number Diff line number Diff line
@@ -269,6 +269,7 @@ bool validateCompositionDataspace(Dataspace dataspace) {
enum Permission {
    ACCESS_SURFACE_FLINGER = 0x1,
    ROTATE_SURFACE_FLINGER = 0x2,
    INTERNAL_SYSTEM_WINDOW = 0x4,
};

struct IdleTimerConfig {
@@ -316,6 +317,7 @@ const String16 sReadFramebuffer("android.permission.READ_FRAME_BUFFER");
const String16 sControlDisplayBrightness("android.permission.CONTROL_DISPLAY_BRIGHTNESS");
const String16 sDump("android.permission.DUMP");
const String16 sCaptureBlackoutContent("android.permission.CAPTURE_BLACKOUT_CONTENT");
const String16 sInternalSystemWindow("android.permission.INTERNAL_SYSTEM_WINDOW");

const char* KERNEL_IDLE_TIMER_PROP = "graphics.display.kernel_idle_timer.enabled";

@@ -358,6 +360,14 @@ bool callingThreadHasRotateSurfaceFlingerAccess() {
            PermissionCache::checkPermission(sRotateSurfaceFlinger, pid, uid);
}

bool callingThreadHasInternalSystemWindowAccess() {
    IPCThreadState* ipc = IPCThreadState::self();
    const int pid = ipc->getCallingPid();
    const int uid = ipc->getCallingUid();
    return uid == AID_GRAPHICS || uid == AID_SYSTEM ||
        PermissionCache::checkPermission(sInternalSystemWindow, pid, uid);
}

SurfaceFlinger::SurfaceFlinger(Factory& factory, SkipInitializationTag)
      : mFactory(factory),
        mPid(getpid()),
@@ -3812,6 +3822,10 @@ status_t SurfaceFlinger::setTransactionState(
        permissions |= Permission::ROTATE_SURFACE_FLINGER;
    }

    if (callingThreadHasInternalSystemWindowAccess()) {
        permissions |= Permission::INTERNAL_SYSTEM_WINDOW;
    }

    if (!(permissions & Permission::ACCESS_SURFACE_FLINGER) &&
        (flags & (eEarlyWakeupStart | eEarlyWakeupEnd))) {
        ALOGE("Only WindowManager is allowed to use eEarlyWakeup[Start|End] flags");
@@ -4149,8 +4163,15 @@ uint32_t SurfaceFlinger::setClientStateLocked(const FrameTimelineInfo& frameTime
            flags |= eTraversalNeeded;
    }
    if (what & layer_state_t::eFlagsChanged) {
        if (layer->setFlags(s.flags, s.mask))
            flags |= eTraversalNeeded;
        auto changedFlags = s.flags;
        if (changedFlags & layer_state_t::eLayerIsDisplayDecoration) {
            if ((permissions & Permission::INTERNAL_SYSTEM_WINDOW) == 0) {
                changedFlags &= ~layer_state_t::eLayerIsDisplayDecoration;
                ALOGE("Attempt to use eLayerIsDisplayDecoration without permission "
                      "INTERNAL_SYSTEM_WINDOW!");
            }
        }
        if (layer->setFlags(changedFlags, s.mask)) flags |= eTraversalNeeded;
    }
    if (what & layer_state_t::eCornerRadiusChanged) {
        if (layer->setCornerRadius(s.cornerRadius))