chord: add two-key rule to trigger wear screenshot

- Register a TwoKeyCombinationRule to fire an intent to
  WearScreenshotReceiver to trigger wear screenshot logic.

Note: this is still using existing two-key rule logic where short/long
press are not differentiated for the same chord. See ag/20841280 for
potential logic change.

BUG: 262445007
Change-Id: Ibf57fcea24dacdabb5346db64bb3644676463069
(cherry picked from commit c0b18c2ad82b733a5441696a8657df7b7c8136c9)
This commit is contained in:
Chen Bai
2023-01-05 11:42:42 +00:00
parent 8c60a525f1
commit 441a4ffdf1

View File

@@ -38,6 +38,7 @@ import static android.view.KeyEvent.KEYCODE_DPAD_CENTER;
import static android.view.KeyEvent.KEYCODE_DPAD_DOWN;
import static android.view.KeyEvent.KEYCODE_HOME;
import static android.view.KeyEvent.KEYCODE_POWER;
import static android.view.KeyEvent.KEYCODE_STEM_PRIMARY;
import static android.view.KeyEvent.KEYCODE_UNKNOWN;
import static android.view.KeyEvent.KEYCODE_VOLUME_DOWN;
import static android.view.KeyEvent.KEYCODE_VOLUME_UP;
@@ -128,6 +129,7 @@ import android.media.AudioSystem;
import android.media.IAudioService;
import android.media.session.MediaSessionLegacyHelper;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.DeviceIdleManager;
import android.os.FactoryTest;
@@ -2248,6 +2250,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
cancelPendingScreenshotChordAction();
}
});
if (mHasFeatureWatch) {
mKeyCombinationManager.addRule(
new TwoKeysCombinationRule(KEYCODE_POWER, KEYCODE_STEM_PRIMARY) {
@Override
void execute() {
mPowerKeyHandled = true;
interceptScreenshotChord(SCREENSHOT_KEY_CHORD,
getScreenshotChordLongPressDelay());
}
@Override
void cancel() {
cancelPendingScreenshotChordAction();
}
});
}
}
mKeyCombinationManager.addRule(