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

Commit 0aa21cca authored by Manasi Navare's avatar Manasi Navare Committed by Android (Google) Code Review
Browse files

Merge "Add dispatchModeRejected in NativeDisplayReceiver" into main

parents 73c3aa9b 6cd20750
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -286,13 +286,22 @@ public abstract class DisplayEventReceiver {
     * @param timestampNanos The timestamp of the event, in the {@link System#nanoTime()}
     * timebase.
     * @param physicalDisplayId Stable display ID that uniquely describes a (display, port) pair.
     * @param modeId The new mode Id
     * @param modeId The new mode ID
     * @param renderPeriod The render frame period, which is a multiple of the mode's vsync period
     */
    public void onModeChanged(long timestampNanos, long physicalDisplayId, int modeId,
            long renderPeriod) {
    }

    /**
     * Called when a display mode rejection event is received.
     *
     * @param physicalDisplayId Stable display ID that uniquely describes a (display, port) pair.
     * @param modeId The mode ID of the mode that was rejected
     */
    public void onModeRejected(long physicalDisplayId, int modeId) {
    }

    /**
     * Called when a display hdcp levels change event is received.
     *
@@ -384,6 +393,12 @@ public abstract class DisplayEventReceiver {
        onModeChanged(timestampNanos, physicalDisplayId, modeId, renderPeriod);
    }

    // Called from native code.
    @SuppressWarnings("unused")
    private void dispatchModeRejected(long physicalDisplayId, int modeId) {
        onModeRejected(physicalDisplayId, modeId);
    }

    // Called from native code.
    @SuppressWarnings("unused")
    private void dispatchFrameRateOverrides(long timestampNanos, long physicalDisplayId,
+17 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ static struct {
    jmethodID dispatchHotplug;
    jmethodID dispatchHotplugConnectionError;
    jmethodID dispatchModeChanged;
    jmethodID dispatchModeRejected;
    jmethodID dispatchFrameRateOverrides;
    jmethodID dispatchHdcpLevelsChanged;

@@ -95,6 +96,7 @@ private:
    void dispatchHotplugConnectionError(nsecs_t timestamp, int errorCode) override;
    void dispatchModeChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t modeId,
                             nsecs_t renderPeriod) override;
    void dispatchModeRejected(PhysicalDisplayId displayId, int32_t modeId) override;
    void dispatchFrameRateOverrides(nsecs_t timestamp, PhysicalDisplayId displayId,
                                    std::vector<FrameRateOverride> overrides) override;
    void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) override {}
@@ -271,6 +273,18 @@ void NativeDisplayEventReceiver::dispatchModeChanged(nsecs_t timestamp, Physical
    mMessageQueue->raiseAndClearException(env, "dispatchModeChanged");
}

void NativeDisplayEventReceiver::dispatchModeRejected(PhysicalDisplayId displayId, int32_t modeId) {
    JNIEnv* env = AndroidRuntime::getJNIEnv();

    ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
    if (receiverObj.get()) {
        ALOGV("receiver %p ~ Invoking Mode Rejected handler.", this);
        env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchModeRejected,
                            displayId.value, modeId);
        ALOGV("receiver %p ~ Returned from Mode Rejected handler.", this);
    }
}

void NativeDisplayEventReceiver::dispatchFrameRateOverrides(
        nsecs_t timestamp, PhysicalDisplayId displayId, std::vector<FrameRateOverride> overrides) {
    JNIEnv* env = AndroidRuntime::getJNIEnv();
@@ -405,6 +419,9 @@ int register_android_view_DisplayEventReceiver(JNIEnv* env) {
    gDisplayEventReceiverClassInfo.dispatchModeChanged =
            GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz, "dispatchModeChanged",
                             "(JJIJ)V");
    gDisplayEventReceiverClassInfo.dispatchModeRejected =
            GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz, "dispatchModeRejected",
                             "(JI)V");
    gDisplayEventReceiverClassInfo.dispatchFrameRateOverrides =
            GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz,
                             "dispatchFrameRateOverrides",