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

Commit 68c6e0a8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass in window name along with focus request"

parents 036c6187 0c3269ea
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -225,7 +225,7 @@ public final class SurfaceControl implements Parcelable {
    private static native void nativeSetFixedTransformHint(long transactionObj, long nativeObject,
    private static native void nativeSetFixedTransformHint(long transactionObj, long nativeObject,
            int transformHint);
            int transformHint);
    private static native void nativeSetFocusedWindow(long transactionObj, IBinder toToken,
    private static native void nativeSetFocusedWindow(long transactionObj, IBinder toToken,
                                                      IBinder focusedToken, int displayId);
            String windowName, IBinder focusedToken, String focusedWindowName, int displayId);
    private static native void nativeSetFrameTimelineVsync(long transactionObj,
    private static native void nativeSetFrameTimelineVsync(long transactionObj,
            long frameTimelineVsyncId);
            long frameTimelineVsyncId);
    private static native void nativeAddJankDataListener(long nativeListener,
    private static native void nativeAddJankDataListener(long nativeListener,
@@ -3282,8 +3282,10 @@ public final class SurfaceControl implements Parcelable {
         *
         *
         * @hide
         * @hide
         */
         */
        public Transaction setFocusedWindow(@NonNull IBinder token, int displayId) {
        public Transaction setFocusedWindow(@NonNull IBinder token, String windowName,
            nativeSetFocusedWindow(mNativeObject, token,  null /* focusedToken */, displayId);
                int displayId) {
            nativeSetFocusedWindow(mNativeObject, token,  windowName,
                    null /* focusedToken */, null /* focusedWindowName */, displayId);
            return this;
            return this;
        }
        }


@@ -3298,9 +3300,12 @@ public final class SurfaceControl implements Parcelable {
         * @hide
         * @hide
         */
         */
        public Transaction requestFocusTransfer(@NonNull IBinder token,
        public Transaction requestFocusTransfer(@NonNull IBinder token,
                                                String windowName,
                                                @NonNull IBinder focusedToken,
                                                @NonNull IBinder focusedToken,
                                                String focusedWindowName,
                                                int displayId) {
                                                int displayId) {
            nativeSetFocusedWindow(mNativeObject, token, focusedToken, displayId);
            nativeSetFocusedWindow(mNativeObject, token, windowName, focusedToken,
                    focusedWindowName, displayId);
            return this;
            return this;
        }
        }


+20 −4
Original line number Original line Diff line number Diff line
@@ -1593,7 +1593,9 @@ static jlong nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
}
}


static void nativeSetFocusedWindow(JNIEnv* env, jclass clazz, jlong transactionObj,
static void nativeSetFocusedWindow(JNIEnv* env, jclass clazz, jlong transactionObj,
                                   jobject toTokenObj, jobject focusedTokenObj, jint displayId) {
                                   jobject toTokenObj, jstring windowNameJstr,
                                   jobject focusedTokenObj, jstring focusedWindowNameJstr,
                                   jint displayId) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    if (toTokenObj == NULL) return;
    if (toTokenObj == NULL) return;


@@ -1602,8 +1604,22 @@ static void nativeSetFocusedWindow(JNIEnv* env, jclass clazz, jlong transactionO
    if (focusedTokenObj != NULL) {
    if (focusedTokenObj != NULL) {
        focusedToken = ibinderForJavaObject(env, focusedTokenObj);
        focusedToken = ibinderForJavaObject(env, focusedTokenObj);
    }
    }
    transaction->setFocusedWindow(toToken, focusedToken, systemTime(SYSTEM_TIME_MONOTONIC),

                                  displayId);
    FocusRequest request;
    request.token = toToken;
    if (windowNameJstr != NULL) {
        ScopedUtfChars windowName(env, windowNameJstr);
        request.windowName = windowName.c_str();
    }

    request.focusedToken = focusedToken;
    if (focusedWindowNameJstr != NULL) {
        ScopedUtfChars focusedWindowName(env, focusedWindowNameJstr);
        request.focusedWindowName = focusedWindowName.c_str();
    }
    request.timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
    request.displayId = displayId;
    transaction->setFocusedWindow(request);
}
}


static void nativeSetFrameTimelineVsync(JNIEnv* env, jclass clazz, jlong transactionObj,
static void nativeSetFrameTimelineVsync(JNIEnv* env, jclass clazz, jlong transactionObj,
@@ -1865,7 +1881,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeGetHandle },
            (void*)nativeGetHandle },
    {"nativeSetFixedTransformHint", "(JJI)V",
    {"nativeSetFixedTransformHint", "(JJI)V",
            (void*)nativeSetFixedTransformHint},
            (void*)nativeSetFixedTransformHint},
    {"nativeSetFocusedWindow", "(JLandroid/os/IBinder;Landroid/os/IBinder;I)V",
    {"nativeSetFocusedWindow", "(JLandroid/os/IBinder;Ljava/lang/String;Landroid/os/IBinder;Ljava/lang/String;I)V",
            (void*)nativeSetFocusedWindow},
            (void*)nativeSetFocusedWindow},
    {"nativeSetFrameTimelineVsync", "(JJ)V",
    {"nativeSetFrameTimelineVsync", "(JJ)V",
            (void*)nativeSetFrameTimelineVsync },
            (void*)nativeSetFrameTimelineVsync },
+1 −1
Original line number Original line Diff line number Diff line
@@ -407,7 +407,7 @@ final class InputMonitor {
        }
        }


        mInputFocus = focusToken;
        mInputFocus = focusToken;
        mInputTransaction.setFocusedWindow(mInputFocus, mDisplayId);
        mInputTransaction.setFocusedWindow(mInputFocus, focus.getName(), mDisplayId);
        EventLog.writeEvent(LOGTAG_INPUT_FOCUS, "Focus request " + focus,
        EventLog.writeEvent(LOGTAG_INPUT_FOCUS, "Focus request " + focus,
                "reason=UpdateInputWindows");
                "reason=UpdateInputWindows");
        ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Focus requested for window=%s", focus);
        ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Focus requested for window=%s", focus);
+11 −6
Original line number Original line Diff line number Diff line
@@ -8411,10 +8411,10 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    void grantEmbeddedWindowFocus(Session session, IBinder targetInputToken, boolean grantFocus) {
    void grantEmbeddedWindowFocus(Session session, IBinder inputToken, boolean grantFocus) {
        synchronized (mGlobalLock) {
        synchronized (mGlobalLock) {
            final EmbeddedWindowController.EmbeddedWindow embeddedWindow =
            final EmbeddedWindowController.EmbeddedWindow embeddedWindow =
                    mEmbeddedWindowController.get(targetInputToken);
                    mEmbeddedWindowController.get(inputToken);
            if (embeddedWindow == null) {
            if (embeddedWindow == null) {
                Slog.e(TAG, "Embedded window not found");
                Slog.e(TAG, "Embedded window not found");
                return;
                return;
@@ -8426,7 +8426,7 @@ public class WindowManagerService extends IWindowManager.Stub
            SurfaceControl.Transaction t = mTransactionFactory.get();
            SurfaceControl.Transaction t = mTransactionFactory.get();
            final int displayId = embeddedWindow.mDisplayId;
            final int displayId = embeddedWindow.mDisplayId;
            if (grantFocus) {
            if (grantFocus) {
                t.setFocusedWindow(targetInputToken, displayId).apply();
                t.setFocusedWindow(inputToken, embeddedWindow.getName(), displayId).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Focus request " + embeddedWindow.getName(),
                        "Focus request " + embeddedWindow.getName(),
                        "reason=grantEmbeddedWindowFocus(true)");
                        "reason=grantEmbeddedWindowFocus(true)");
@@ -8441,7 +8441,8 @@ public class WindowManagerService extends IWindowManager.Stub
                            embeddedWindow.getName());
                            embeddedWindow.getName());
                    return;
                    return;
                }
                }
                t.requestFocusTransfer(newFocusTarget.mInputChannelToken, targetInputToken,
                t.requestFocusTransfer(newFocusTarget.mInputChannelToken, newFocusTarget.getName(),
                        inputToken, embeddedWindow.getName(),
                        displayId).apply();
                        displayId).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Transfer focus request " + newFocusTarget,
                        "Transfer focus request " + newFocusTarget,
@@ -8477,13 +8478,17 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            }
            SurfaceControl.Transaction t = mTransactionFactory.get();
            SurfaceControl.Transaction t = mTransactionFactory.get();
            if (grantFocus) {
            if (grantFocus) {
                t.requestFocusTransfer(targetInputToken, hostWindow.mInputChannel.getToken(),
                t.requestFocusTransfer(targetInputToken, embeddedWindow.getName(),
                        hostWindow.mInputChannel.getToken(),
                        hostWindow.getName(),
                        hostWindow.getDisplayId()).apply();
                        hostWindow.getDisplayId()).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Transfer focus request " + embeddedWindow.getName(),
                        "Transfer focus request " + embeddedWindow.getName(),
                        "reason=grantEmbeddedWindowFocus(true)");
                        "reason=grantEmbeddedWindowFocus(true)");
            } else {
            } else {
                t.requestFocusTransfer(hostWindow.mInputChannel.getToken(), targetInputToken,
                t.requestFocusTransfer(hostWindow.mInputChannel.getToken(), hostWindow.getName(),
                        targetInputToken,
                        embeddedWindow.getName(),
                        hostWindow.getDisplayId()).apply();
                        hostWindow.getDisplayId()).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Transfer focus request " + hostWindow,
                        "Transfer focus request " + hostWindow,