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

Commit ca6831f5 authored by Cameron Pickett's avatar Cameron Pickett
Browse files

Fix can't change in-call volume with screen off

This is a fix for the following issue:
http://code.google.com/p/cyanogenmod/issues/detail?id=4070

Issue: Proximity sensor disables screen wake using power button. With the
"volume rocker wake" option enabled in CMParts, volume keys emulate the power
button whenever the screen is off. If the screen is off due to proximity
sensor, volume keys become useless.

Solution: When screen is off due to the proximity sensor, do NOT override the
volume keys as power buttons. This allows the user to adjust in-call volume
using volume keys while phone is to their ear.

Also: Small clean-up of unecessary code and style fixes.

Change-Id: I9f21bc1a59f940242b2196d423a7b8de62c855e0
parent 1d4860a9
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -234,6 +234,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    int mLidKeyboardAccessibility;
    int mLidNavigationAccessibility;
    boolean mScreenOn = false;
    int mScreenOffReason;
    boolean mOrientationSensorEnabled = false;
    int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    static final int DEFAULT_ACCELEROMETER_ROTATION = 0;
@@ -2066,16 +2067,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    || ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) && mVolumeWakeScreen);

            // Don't wake the screen if we have not set the option "wake with volume" in CMParts
            // OR if "wake with volume" is set but screen is off due to proximity sensor
            // regardless if WAKE Flag is set in keylayout
            if (!isScreenOn
                    && isWakeKey
                    && !mVolumeWakeScreen
            final boolean isOffByProx = (mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR);
            if (isWakeKey
                    && (!mVolumeWakeScreen || isOffByProx)
                    && ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))) {
                isWakeKey = false;
            }

            // make sure keyevent get's handled as power key on volume-wake
            if(!isScreenOn && mVolumeWakeScreen && isWakeKey && ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)
            if(mVolumeWakeScreen && isWakeKey && ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)
                    || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)))
                keyCode = KeyEvent.KEYCODE_POWER;

@@ -2324,6 +2326,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mKeyguardMediator.onScreenTurnedOff(why);
        synchronized (mLock) {
            mScreenOn = false;
            mScreenOffReason = why;
            updateOrientationListenerLp();
            updateLockScreenTimeout();
        }