summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Josep del Rio <joseprio@google.com> 2024-03-05 18:34:37 +0000
committer Josep del Rio <joseprio@google.com> 2024-03-05 19:12:47 +0000
commit9368ac271bad5e81ca55ef480f5dfe9f5fadce3d (patch)
treec2e312cf8f107af49b550bbb54de4d9f932516be
parentb30ba815edc05473adac33c775e02ba36a302717 (diff)
Keep device awake when using keyboard
At the moment the device screen will go to sleep while using the keyboard while on the lock screen. This CL will align the behavior of touch and key pressing. Bug: 325932166 Test: Flashed on device Flag: NA Change-Id: I9293eca29dd91b2bf51d997ebb915bba14e3402f
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index fd3c480a334f..81bca6f8136b 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -71,6 +71,8 @@ import android.util.IndentingPrintWriter;
import android.util.Log;
import android.util.MathUtils;
import android.view.HapticFeedbackConstants;
+import android.view.InputDevice;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -361,6 +363,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
private final QuickSettingsController mQsController;
private final NaturalScrollingSettingObserver mNaturalScrollingSettingObserver;
private final TouchHandler mTouchHandler = new TouchHandler();
+ private final KeyHandler mKeyHandler = new KeyHandler();
private long mDownTime;
private boolean mTouchSlopExceededBeforeDown;
@@ -823,6 +826,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
mView.addOnLayoutChangeListener(new ShadeLayoutChangeListener());
mView.setOnTouchListener(getTouchHandler());
+ mView.setOnKeyListener(getKeyHandler());
mView.setOnConfigurationChangedListener(config -> loadDimens());
mResources = mView.getResources();
@@ -3600,6 +3604,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
return mTouchHandler;
}
+ @VisibleForTesting
+ KeyHandler getKeyHandler() {
+ return mKeyHandler;
+ }
+
@Override
public void disableHeader(int state1, int state2, boolean animated) {
mShadeHeaderController.disable(state1, state2, animated);
@@ -5248,6 +5257,21 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
}
}
+ /** Handles KeyEvents for the Shade. */
+ public final class KeyHandler implements View.OnKeyListener {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (event.getAction() == KeyEvent.ACTION_DOWN) {
+ final InputDevice d = event.getDevice();
+ // Trigger user activity if the event comes from a full external keyboard
+ if (d != null && d.isFullKeyboard() && d.isExternal()) {
+ mCentralSurfaces.userActivity();
+ }
+ }
+ return false;
+ }
+ }
+
private final class HeadsUpNotificationViewControllerImpl implements
HeadsUpTouchHelper.HeadsUpNotificationViewController {
@Override