From 7c0aab93df4564676b447489fcd84b982d3ef35a Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Tue, 14 Mar 2023 15:24:14 -0400 Subject: [PATCH] Correct method signature of screenshot keychord invocation Fixes the screenshot call in PhoneWindowManager so that the screenshot source is correctly set. The root cause is that Handler.java has method signatures: obtainMessage(int msg, int arg1, int arg2) obtainMessage(int msg, Object obj) As part of the ScreenshotRequest refactor (ag/20894854), arg2 was no longer needed in PhoneWindowManager and was removed. However, this silently changed the signature (setting msg.obj instead of msg.arg1), and wasn't noticed since the int arg1 just gets cast to an object. Ultimately this makes the argument default to 0, which (once the ScreenshotRequest is constructed) gets translated to describing a global actions invocation. Bug: b/273560369 Fix: b/273560369 Test: manual (invoke a screenshot using the keychord, verify that we get a SCREENSHOT_REQUESTED_KEYCHORD log) Change-Id: I6337226ce7d36aed874e3d3a1a6ebc4ff9a00920 --- .../java/com/android/server/policy/PhoneWindowManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index eedb4b0a3bdeb..be4fe09d593c2 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1508,7 +1508,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void interceptScreenshotChord(int source, long pressDelay) { mHandler.removeMessages(MSG_SCREENSHOT_CHORD); - mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SCREENSHOT_CHORD, source), + // arg2 is unused, but necessary to insure we call the correct method signature + // since the screenshot source is read from message.arg1 + mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SCREENSHOT_CHORD, source, 0), pressDelay); }