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

Commit d6ad3320 authored by Patrick Rohr's avatar Patrick Rohr
Browse files

Support Overriding Key Wake Behavior via Config Overlays

This change adds support for configuring keys whose wake properties
should be ignored using config overlays.

Bug: 144979700
Test: Tested on Sabrina.
Change-Id: Ifc8d35758a2e1da7942127b8f09071fa8b97a81e
parent 6f1063c2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4331,4 +4331,9 @@
    <!-- Boolean indicating whether frameworks needs to reset cell broadcast geo-fencing
         check after reboot or airplane mode toggling -->
    <bool translatable="false" name="reset_geo_fencing_check_after_boot_or_apm">false</bool>

    <!-- Screen Wake Keys
         Determines whether the specified key groups can be used to wake up the device. -->
    <bool name="config_wakeOnDpadKeyPress">true</bool>
    <bool name="config_wakeOnAssistKeyPress">true</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -3027,6 +3027,10 @@
  <java-symbol type="id" name="notification_action_list_margin_target" />
  <java-symbol type="dimen" name="notification_action_disabled_alpha" />

  <!-- Override Wake Key Behavior When Screen is Off -->
  <java-symbol type="bool" name="config_wakeOnDpadKeyPress" />
  <java-symbol type="bool" name="config_wakeOnAssistKeyPress" />

  <!-- Pinner Service -->
  <java-symbol type="array" name="config_defaultPinnerServiceFiles" />
  <java-symbol type="bool" name="config_pinnerCameraApp" />
+20 −2
Original line number Diff line number Diff line
@@ -481,6 +481,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    int mVeryLongPressTimeout;
    boolean mAllowStartActivityForLongPressOnPowerDuringSetup;
    MetricsLogger mLogger;
    boolean mWakeOnDpadKeyPress;
    boolean mWakeOnAssistKeyPress;

    private boolean mHandleVolumeKeysInWM;

@@ -1729,6 +1731,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mAccessibilityShortcutController =
                new AccessibilityShortcutController(mContext, new Handler(), mCurrentUserId);
        mLogger = new MetricsLogger();

        Resources res = mContext.getResources();
        mWakeOnDpadKeyPress =
                res.getBoolean(com.android.internal.R.bool.config_wakeOnDpadKeyPress);
        mWakeOnAssistKeyPress =
                res.getBoolean(com.android.internal.R.bool.config_wakeOnAssistKeyPress);

        // Init display burn-in protection
        boolean burnInProtectionEnabled = context.getResources().getBoolean(
                com.android.internal.R.bool.config_enableBurnInProtection);
@@ -4072,13 +4081,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     */
    private boolean isWakeKeyWhenScreenOff(int keyCode) {
        switch (keyCode) {
            // ignore volume keys unless docked
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
                return mDefaultDisplayPolicy.getDockMode() != Intent.EXTRA_DOCK_STATE_UNDOCKED;

            // ignore media keys
            case KeyEvent.KEYCODE_MUTE:
            case KeyEvent.KEYCODE_HEADSETHOOK:
            case KeyEvent.KEYCODE_MEDIA_PLAY:
@@ -4092,7 +4099,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
                return false;

            case KeyEvent.KEYCODE_DPAD_UP:
            case KeyEvent.KEYCODE_DPAD_DOWN:
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_DPAD_CENTER:
                return mWakeOnDpadKeyPress;

            case KeyEvent.KEYCODE_ASSIST:
                return mWakeOnAssistKeyPress;
        }

        return true;
    }