Pass in window name along with focus request

Used for generating focus event logs and debug
logs.

Test: go/wm-smoke, check event logs and logcat

Change-Id: Ib5bdf8693212388c1f0db397458b45eef4db8a51
This commit is contained in:
Vishnu Nair
2021-01-15 12:54:56 -08:00
parent b1dc062e3a
commit 0c3269ea1f
4 changed files with 41 additions and 15 deletions

View File

@@ -225,7 +225,7 @@ public final class SurfaceControl implements Parcelable {
private static native void nativeSetFixedTransformHint(long transactionObj, long nativeObject,
int transformHint);
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,
long frameTimelineVsyncId);
private static native void nativeAddJankDataListener(long nativeListener,
@@ -3282,8 +3282,10 @@ public final class SurfaceControl implements Parcelable {
*
* @hide
*/
public Transaction setFocusedWindow(@NonNull IBinder token, int displayId) {
nativeSetFocusedWindow(mNativeObject, token, null /* focusedToken */, displayId);
public Transaction setFocusedWindow(@NonNull IBinder token, String windowName,
int displayId) {
nativeSetFocusedWindow(mNativeObject, token, windowName,
null /* focusedToken */, null /* focusedWindowName */, displayId);
return this;
}
@@ -3298,9 +3300,12 @@ public final class SurfaceControl implements Parcelable {
* @hide
*/
public Transaction requestFocusTransfer(@NonNull IBinder token,
String windowName,
@NonNull IBinder focusedToken,
String focusedWindowName,
int displayId) {
nativeSetFocusedWindow(mNativeObject, token, focusedToken, displayId);
nativeSetFocusedWindow(mNativeObject, token, windowName, focusedToken,
focusedWindowName, displayId);
return this;
}

View File

@@ -1593,7 +1593,9 @@ static jlong nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
}
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);
if (toTokenObj == NULL) return;
@@ -1602,8 +1604,22 @@ static void nativeSetFocusedWindow(JNIEnv* env, jclass clazz, jlong transactionO
if (focusedTokenObj != NULL) {
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,
@@ -1865,7 +1881,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeGetHandle },
{"nativeSetFixedTransformHint", "(JJI)V",
(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},
{"nativeSetFrameTimelineVsync", "(JJ)V",
(void*)nativeSetFrameTimelineVsync },

View File

@@ -427,7 +427,7 @@ final class InputMonitor {
}
mInputFocus = focusToken;
mInputTransaction.setFocusedWindow(mInputFocus, mDisplayId);
mInputTransaction.setFocusedWindow(mInputFocus, focus.getName(), mDisplayId);
EventLog.writeEvent(LOGTAG_INPUT_FOCUS, "Focus request " + focus,
"reason=UpdateInputWindows");
ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Focus requested for window=%s", focus);

View File

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