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

Unverified Commit 181dc307 authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-13.0.0_r11' into staging/lineage-20.0_merge-android-13.0.0_r11

Android 13.0.0 release 11

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCY0jiUgAKCRDorT+BmrEO
# eNpbAJ48ZzgPDc8TcPacMo6VzwdYmchXJgCgildPB/U1nC/NA3fXFIcGO+wNQsU=
# =U18p
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Oct 14 07:15:14 2022 EEST
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 1352 signatures in the past
#      11 months.  Encrypted 4 messages in the past 9 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Linus Tufvesson (3) and others
# Via Android Build Coastguard Worker (281) and others
* tag 'android-13.0.0_r11':
  CE: Pass the fence with the cached client composition buffer
  Fail gracefully when allocating screenshot buffers
  Release RefreshRateOveray's SurfaceControl on the main thread
  Dump IInputProcessor when dump is called
  Reconcile native and Java parcel code for WorkSource.
  SurfaceFlinger: Disable early release optimization
  Allow windowhandles with NO_INPUT_CHANNEL - DO NOT MERGE
  Allow windowhandles with NO_INPUT_CHANNEL - DO NOT MERGE
  Allow windowhandles with NO_INPUT_CHANNEL - DO NOT MERGE
  Revert "Avoid vsync enabled when in DOZE mode (AOD)."
  Initialize DrawingState::trustedOverlay to false in constructor
  Revert "Allow for solid color layers to start some candidate cached sets."
  Revert "SurfaceFlinger: Emit callbacks for non-buffer layer transactions"
  Revert "binder: SharedRefBase uses enable_shared_from_this"

Change-Id: I7a6c400a60c408b80777ff99acc6829f8178bf58
parents 4513d9ac f4552c06
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ static const char* hidl_hal_interfaces_to_dump[] {
/* list of hal interface to dump containing process during native dumps */
static const std::vector<std::string> aidl_interfaces_to_dump {
        "android.hardware.camera.provider.ICameraProvider",
        "android.hardware.input.processor.IInputProcessor",
};

/* list of extra hal interfaces to dump containing process during native dumps */
+2 −1
Original line number Diff line number Diff line
@@ -1232,7 +1232,8 @@ std::optional<base::unique_fd> Output::composeSurfaces(
            ATRACE_NAME("ClientCompositionCacheHit");
            outputCompositionState.reusedClientComposition = true;
            setExpensiveRenderingExpected(false);
            return base::unique_fd();
            // b/239944175 pass the fence associated with the buffer.
            return base::unique_fd(std::move(fd));
        }
        ATRACE_NAME("ClientCompositionCacheMiss");
        mClientCompositionRequestCache->add(tex->getBuffer()->getId(), clientCompositionDisplay,
+34 −17
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

#include <algorithm>

#include "RefreshRateOverlay.h"
#include "BackgroundExecutor.h"
#include "Client.h"
#include "Layer.h"
#include "RefreshRateOverlay.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
@@ -56,6 +57,14 @@ SurfaceComposerClient::Transaction createTransaction(const sp<SurfaceControl>& s

} // namespace

SurfaceControlHolder::~SurfaceControlHolder() {
    // Hand the sp<SurfaceControl> to the helper thread to release the last
    // reference. This makes sure that the SurfaceControl is destructed without
    // SurfaceFlinger::mStateLock held.
    BackgroundExecutor::getInstance().sendCallbacks(
            {[sc = std::move(mSurfaceControl)]() mutable { sc.clear(); }});
}

void RefreshRateOverlay::SevenSegmentDrawer::drawSegment(Segment segment, int left, SkColor color,
                                                         SkCanvas& canvas) {
    const SkRect rect = [&]() {
@@ -210,21 +219,27 @@ auto RefreshRateOverlay::SevenSegmentDrawer::draw(int number, SkColor color,
    return buffers;
}

std::unique_ptr<SurfaceControlHolder> createSurfaceControlHolder() {
    sp<SurfaceControl> surfaceControl =
            SurfaceComposerClient::getDefault()
                    ->createSurface(String8("RefreshRateOverlay"), kBufferWidth, kBufferHeight,
                                    PIXEL_FORMAT_RGBA_8888,
                                    ISurfaceComposerClient::eFXSurfaceBufferState);
    return std::make_unique<SurfaceControlHolder>(std::move(surfaceControl));
}

RefreshRateOverlay::RefreshRateOverlay(FpsRange fpsRange, bool showSpinner)
      : mFpsRange(fpsRange),
        mShowSpinner(showSpinner),
        mSurfaceControl(SurfaceComposerClient::getDefault()
                                ->createSurface(String8("RefreshRateOverlay"), kBufferWidth,
                                                kBufferHeight, PIXEL_FORMAT_RGBA_8888,
                                                ISurfaceComposerClient::eFXSurfaceBufferState)) {
        mSurfaceControl(createSurfaceControlHolder()) {
    if (!mSurfaceControl) {
        ALOGE("%s: Failed to create buffer state layer", __func__);
        return;
    }

    createTransaction(mSurfaceControl)
            .setLayer(mSurfaceControl, INT32_MAX - 2)
            .setTrustedOverlay(mSurfaceControl, true)
    createTransaction(mSurfaceControl->get())
            .setLayer(mSurfaceControl->get(), INT32_MAX - 2)
            .setTrustedOverlay(mSurfaceControl->get(), true)
            .apply();
}

@@ -233,7 +248,7 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps fps) -> const Buffers& {
    if (!mSurfaceControl) return kNoBuffers;

    const auto transformHint =
            static_cast<ui::Transform::RotationFlags>(mSurfaceControl->getTransformHint());
            static_cast<ui::Transform::RotationFlags>(mSurfaceControl->get()->getTransformHint());

    // Tell SurfaceFlinger about the pre-rotation on the buffer.
    const auto transform = [&] {
@@ -247,7 +262,9 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps fps) -> const Buffers& {
        }
    }();

    createTransaction(mSurfaceControl).setTransform(mSurfaceControl, transform).apply();
    createTransaction(mSurfaceControl->get())
            .setTransform(mSurfaceControl->get(), transform)
            .apply();

    BufferCache::const_iterator it = mBufferCache.find({fps.getIntValue(), transformHint});
    if (it == mBufferCache.end()) {
@@ -289,21 +306,21 @@ void RefreshRateOverlay::setViewport(ui::Size viewport) {
    Rect frame((3 * width) >> 4, height >> 5);
    frame.offsetBy(width >> 5, height >> 4);

    createTransaction(mSurfaceControl)
            .setMatrix(mSurfaceControl, frame.getWidth() / static_cast<float>(kBufferWidth), 0, 0,
                       frame.getHeight() / static_cast<float>(kBufferHeight))
            .setPosition(mSurfaceControl, frame.left, frame.top)
    createTransaction(mSurfaceControl->get())
            .setMatrix(mSurfaceControl->get(), frame.getWidth() / static_cast<float>(kBufferWidth),
                       0, 0, frame.getHeight() / static_cast<float>(kBufferHeight))
            .setPosition(mSurfaceControl->get(), frame.left, frame.top)
            .apply();
}

void RefreshRateOverlay::setLayerStack(ui::LayerStack stack) {
    createTransaction(mSurfaceControl).setLayerStack(mSurfaceControl, stack).apply();
    createTransaction(mSurfaceControl->get()).setLayerStack(mSurfaceControl->get(), stack).apply();
}

void RefreshRateOverlay::changeRefreshRate(Fps fps) {
    mCurrentFps = fps;
    const auto buffer = getOrCreateBuffers(fps)[mFrame];
    createTransaction(mSurfaceControl).setBuffer(mSurfaceControl, buffer).apply();
    createTransaction(mSurfaceControl->get()).setBuffer(mSurfaceControl->get(), buffer).apply();
}

void RefreshRateOverlay::animate() {
@@ -312,7 +329,7 @@ void RefreshRateOverlay::animate() {
    const auto& buffers = getOrCreateBuffers(*mCurrentFps);
    mFrame = (mFrame + 1) % buffers.size();
    const auto buffer = buffers[mFrame];
    createTransaction(mSurfaceControl).setBuffer(mSurfaceControl, buffer).apply();
    createTransaction(mSurfaceControl->get()).setBuffer(mSurfaceControl->get(), buffer).apply();
}

} // namespace android
+15 −1
Original line number Diff line number Diff line
@@ -33,6 +33,20 @@ namespace android {

class GraphicBuffer;
class SurfaceControl;
class SurfaceFlinger;

// Helper class to delete the SurfaceControl on a helper thread as
// SurfaceControl assumes its destruction happens without SurfaceFlinger::mStateLock held.
class SurfaceControlHolder {
public:
    explicit SurfaceControlHolder(sp<SurfaceControl> sc) : mSurfaceControl(std::move(sc)){};
    ~SurfaceControlHolder();

    const sp<SurfaceControl>& get() const { return mSurfaceControl; }

private:
    sp<SurfaceControl> mSurfaceControl;
};

class RefreshRateOverlay {
public:
@@ -75,7 +89,7 @@ private:
    const FpsRange mFpsRange; // For color interpolation.
    const bool mShowSpinner;

    const sp<SurfaceControl> mSurfaceControl;
    const std::unique_ptr<SurfaceControlHolder> mSurfaceControl;
};

} // namespace android
+7 −2
Original line number Diff line number Diff line
@@ -6650,8 +6650,13 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenCommon(
                                             1 /* layerCount */, usage, "screenshot");

    const status_t bufferStatus = buffer->initCheck();
    LOG_ALWAYS_FATAL_IF(bufferStatus != OK, "captureScreenCommon: Buffer failed to allocate: %d",
                        bufferStatus);
    if (bufferStatus != OK) {
        // Animations may end up being really janky, but don't crash here.
        // Otherwise an irreponsible process may cause an SF crash by allocating
        // too much.
        ALOGE("%s: Buffer failed to allocate: %d", __func__, bufferStatus);
        return ftl::yield<FenceResult>(base::unexpected(bufferStatus)).share();
    }
    const std::shared_ptr<renderengine::ExternalTexture> texture = std::make_shared<
            renderengine::impl::ExternalTexture>(buffer, getRenderEngine(),
                                                 renderengine::impl::ExternalTexture::Usage::