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

Commit ec44865a authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Merge "Hide touch indicators on mirrored displays if a secure window is present" into main

parents d955927b 80fd68a0
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -272,7 +272,10 @@ void PointerController::setSpots(const PointerCoords* spotCoords, const uint32_t
    if (it == mLocked.spotControllers.end()) {
        mLocked.spotControllers.try_emplace(displayId, displayId, mContext);
    }
    mLocked.spotControllers.at(displayId).setSpots(outSpotCoords.data(), spotIdToIndex, spotIdBits);
    bool skipScreenshot = mLocked.displaysToSkipScreenshot.find(displayId) !=
            mLocked.displaysToSkipScreenshot.end();
    mLocked.spotControllers.at(displayId).setSpots(outSpotCoords.data(), spotIdToIndex, spotIdBits,
                                                   skipScreenshot);
}

void PointerController::clearSpots() {
@@ -352,6 +355,17 @@ void PointerController::setCustomPointerIcon(const SpriteIcon& icon) {
    mCursorController.setCustomPointerIcon(icon);
}

void PointerController::setSkipScreenshot(int32_t displayId, bool skip) {
    if (!mEnabled) return;

    std::scoped_lock lock(getLock());
    if (skip) {
        mLocked.displaysToSkipScreenshot.insert(displayId);
    } else {
        mLocked.displaysToSkipScreenshot.erase(displayId);
    }
}

void PointerController::doInactivityTimeout() {
    fade(Transition::GRADUAL);
}
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public:
    void clearSpots() override;
    void updatePointerIcon(PointerIconStyle iconId) override;
    void setCustomPointerIcon(const SpriteIcon& icon) override;
    void setSkipScreenshot(int32_t displayId, bool skip) override;

    virtual void setInactivityTimeout(InactivityTimeout inactivityTimeout);
    void doInactivityTimeout();
@@ -115,6 +116,7 @@ private:

        std::vector<gui::DisplayInfo> mDisplayInfos;
        std::unordered_map<int32_t /* displayId */, TouchSpotController> spotControllers;
        std::unordered_set<int32_t /* displayId */> displaysToSkipScreenshot;
    } mLocked GUARDED_BY(getLock());

    class DisplayInfoListener : public gui::WindowInfosListener {
+26 −7
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ void SpriteController::doUpdateSprites() {
            update.state.surfaceVisible = false;
            update.state.surfaceControl =
                    obtainSurface(update.state.surfaceWidth, update.state.surfaceHeight,
                                  update.state.displayId);
                                  update.state.displayId, update.state.skipScreenshot);
            if (update.state.surfaceControl != NULL) {
                update.surfaceChanged = surfaceChanged = true;
            }
@@ -209,7 +209,7 @@ void SpriteController::doUpdateSprites() {
              (update.state.dirty &
               (DIRTY_ALPHA | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER |
                DIRTY_VISIBILITY | DIRTY_HOTSPOT | DIRTY_DISPLAY_ID | DIRTY_ICON_STYLE |
                DIRTY_DRAW_DROP_SHADOW))))) {
                DIRTY_DRAW_DROP_SHADOW | DIRTY_SKIP_SCREENSHOT))))) {
            needApplyTransaction = true;

            if (wantSurfaceVisibleAndDrawn
@@ -260,6 +260,14 @@ void SpriteController::doUpdateSprites() {
                t.setLayer(update.state.surfaceControl, surfaceLayer);
            }

            if (wantSurfaceVisibleAndDrawn &&
                (becomingVisible || (update.state.dirty & DIRTY_SKIP_SCREENSHOT))) {
                int32_t flags =
                        update.state.skipScreenshot ? ISurfaceComposerClient::eSkipScreenshot : 0;
                t.setFlags(update.state.surfaceControl, flags,
                           ISurfaceComposerClient::eSkipScreenshot);
            }

            if (becomingVisible) {
                t.show(update.state.surfaceControl);

@@ -332,8 +340,8 @@ void SpriteController::ensureSurfaceComposerClient() {
    }
}

sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height,
                                                   int32_t displayId) {
sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height, int32_t displayId,
                                                   bool hideOnMirrored) {
    ensureSurfaceComposerClient();

    const sp<SurfaceControl> parent = mParentSurfaceProvider(displayId);
@@ -341,11 +349,13 @@ sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height
        ALOGE("Failed to get the parent surface for pointers on display %d", displayId);
    }

    int32_t createFlags = ISurfaceComposerClient::eHidden | ISurfaceComposerClient::eCursorWindow;
    if (hideOnMirrored) {
        createFlags |= ISurfaceComposerClient::eSkipScreenshot;
    }
    const sp<SurfaceControl> surfaceControl =
            mSurfaceComposerClient->createSurface(String8("Sprite"), width, height,
                                                  PIXEL_FORMAT_RGBA_8888,
                                                  ISurfaceComposerClient::eHidden |
                                                          ISurfaceComposerClient::eCursorWindow,
                                                  PIXEL_FORMAT_RGBA_8888, createFlags,
                                                  parent ? parent->getHandle() : nullptr);
    if (surfaceControl == nullptr || !surfaceControl->isValid()) {
        ALOGE("Error creating sprite surface.");
@@ -474,6 +484,15 @@ void SpriteController::SpriteImpl::setDisplayId(int32_t displayId) {
    }
}

void SpriteController::SpriteImpl::setSkipScreenshot(bool skip) {
    AutoMutex _l(mController.mLock);

    if (mLocked.state.skipScreenshot != skip) {
        mLocked.state.skipScreenshot = skip;
        invalidateLocked(DIRTY_SKIP_SCREENSHOT);
    }
}

void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) {
    bool wasDirty = mLocked.state.dirty;
    mLocked.state.dirty |= dirty;
+9 −1
Original line number Diff line number Diff line
@@ -96,6 +96,10 @@ public:

    /* Sets the id of the display where the sprite should be shown. */
    virtual void setDisplayId(int32_t displayId) = 0;

    /* Sets the flag to hide sprite on mirrored displays.
     * This will add ISurfaceComposerClient::eSkipScreenshot flag to the sprite. */
    virtual void setSkipScreenshot(bool skip) = 0;
};

/*
@@ -152,6 +156,7 @@ private:
        DIRTY_DISPLAY_ID = 1 << 7,
        DIRTY_ICON_STYLE = 1 << 8,
        DIRTY_DRAW_DROP_SHADOW = 1 << 9,
        DIRTY_SKIP_SCREENSHOT = 1 << 10,
    };

    /* Describes the state of a sprite.
@@ -182,6 +187,7 @@ private:
        int32_t surfaceHeight;
        bool surfaceDrawn;
        bool surfaceVisible;
        bool skipScreenshot;

        inline bool wantSurfaceVisible() const {
            return visible && alpha > 0.0f && icon.isValid();
@@ -209,6 +215,7 @@ private:
        virtual void setAlpha(float alpha);
        virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix);
        virtual void setDisplayId(int32_t displayId);
        virtual void setSkipScreenshot(bool skip);

        inline const SpriteState& getStateLocked() const {
            return mLocked.state;
@@ -272,7 +279,8 @@ private:
    void doDisposeSurfaces();

    void ensureSurfaceComposerClient();
    sp<SurfaceControl> obtainSurface(int32_t width, int32_t height, int32_t displayId);
    sp<SurfaceControl> obtainSurface(int32_t width, int32_t height, int32_t displayId,
                                     bool hideOnMirrored);
};

} // namespace android
+4 −3
Original line number Diff line number Diff line
@@ -40,12 +40,13 @@ namespace android {
// --- Spot ---

void TouchSpotController::Spot::updateSprite(const SpriteIcon* icon, float newX, float newY,
                                             int32_t displayId) {
                                             int32_t displayId, bool skipScreenshot) {
    sprite->setLayer(Sprite::BASE_LAYER_SPOT + id);
    sprite->setAlpha(alpha);
    sprite->setTransformationMatrix(SpriteTransformationMatrix(scale, 0.0f, 0.0f, scale));
    sprite->setPosition(newX, newY);
    sprite->setDisplayId(displayId);
    sprite->setSkipScreenshot(skipScreenshot);
    x = newX;
    y = newY;

@@ -84,7 +85,7 @@ TouchSpotController::~TouchSpotController() {
}

void TouchSpotController::setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
                                   BitSet32 spotIdBits) {
                                   BitSet32 spotIdBits, bool skipScreenshot) {
#if DEBUG_SPOT_UPDATES
    ALOGD("setSpots: idBits=%08x", spotIdBits.value);
    for (BitSet32 idBits(spotIdBits); !idBits.isEmpty();) {
@@ -116,7 +117,7 @@ void TouchSpotController::setSpots(const PointerCoords* spotCoords, const uint32
            spot = createAndAddSpotLocked(id, mLocked.displaySpots);
        }

        spot->updateSprite(&icon, x, y, mDisplayId);
        spot->updateSprite(&icon, x, y, mDisplayId, skipScreenshot);
    }

    for (Spot* spot : mLocked.displaySpots) {
Loading