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

Commit c9aa3095 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Code cleanup.

Enforce 100 char line length, and remove checks for always-true
conditions.

Change-Id: Ie24d12919859e8269f77fabf93b3d745ece94479
parent d0456e88
Loading
Loading
Loading
Loading
+39 −41
Original line number Diff line number Diff line
@@ -588,14 +588,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK:
                    dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj);
                    break;
                case MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK:
                case MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK: {
                    KeyEvent event = (KeyEvent) msg.obj;
                    mIsLongPress = true;
                    dispatchMediaKeyWithWakeLockToAudioService((KeyEvent)msg.obj);
                    dispatchMediaKeyWithWakeLockToAudioService(KeyEvent.changeAction((KeyEvent)msg.obj, KeyEvent.ACTION_UP));
                    dispatchMediaKeyWithWakeLockToAudioService(event);
                    dispatchMediaKeyWithWakeLockToAudioService(
                            KeyEvent.changeAction(event, KeyEvent.ACTION_UP));
                    break;
                }
            }
        }
    }

    private UEventObserver mHDMIObserver = new UEventObserver() {
        @Override
@@ -1042,15 +1045,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            final VolumePanel volumePanel = new VolumePanel(getUiContext(),
                    (AudioService) getAudioService());
            if (ringerMode == AudioManager.RINGER_MODE_NORMAL) {
                boolean vibrateSetting = Settings.System.getIntForUser(mContext.getContentResolver(),
                        Settings.System.VIBRATE_WHEN_RINGING, 0, UserHandle.USER_CURRENT) != 0;
                am.setRingerMode(vibrateSetting ? AudioManager.RINGER_MODE_VIBRATE :
                                   AudioManager.RINGER_MODE_SILENT);
                boolean vibrateEnabled = Settings.System.getIntForUser(
                        mContext.getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING,
                        0, UserHandle.USER_CURRENT) != 0;
                am.setRingerMode(vibrateEnabled
                        ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT);
            } else {
                am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
            }
            volumePanel.postVolumeChanged(AudioManager.STREAM_RING,AudioManager.FLAG_SHOW_UI
                                          | AudioManager.FLAG_VIBRATE);
            volumePanel.postVolumeChanged(AudioManager.STREAM_RING,
                    AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
        }
    };

@@ -3244,8 +3248,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    @Override
    public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) {
        final int fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs);
        final int systemUiVisibility = updateSystemUiVisibilityFlagsForExpandedDesktop(
        final int fl = updateWindowManagerVisibilityForExpandedDesktop(attrs);
        final int systemUiVisibility = updateSystemUiVisibilityForExpandedDesktop(
                attrs.systemUiVisibility|attrs.subtreeSystemUiVisibility);

        if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR))
@@ -3405,7 +3409,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight);
                if (mNavigationBarOnBottom) {
                    // It's a system nav bar or a portrait screen; nav bar goes on bottom.
                    int top = displayHeight - overscanBottom - mNavigationBarHeightForRotation[displayRotation];
                    int top = displayHeight - overscanBottom
                            - mNavigationBarHeightForRotation[displayRotation];
                    mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom);
                    mStableBottom = mTmpNavigationFrame.top;
                    if (!expandedDesktopHidesNavigationBar()) {
@@ -3417,7 +3422,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        mNavigationBarController.setBarShowingLw(true);
                        mDockBottom = mTmpNavigationFrame.top;
                        mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop;
                        mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop;
                        mRestrictedOverscanScreenHeight =
                                mDockBottom - mRestrictedOverscanScreenTop;
                    } else {
                        // We currently want to hide the navigation UI.
                        mNavigationBarController.setBarShowingLw(false);
@@ -3636,7 +3642,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private void applyStableConstraints(int sysui, WindowManager.LayoutParams attrs, Rect r) {
        final int fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs);
        final int fl = updateWindowManagerVisibilityForExpandedDesktop(attrs);
        if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
            // If app is requesting a stable layout, don't let the
            // content insets go below the stable values.
@@ -3672,7 +3678,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        final int fl = attrs.flags;
        final int sim = attrs.softInputMode;
        final int sysUiFl = updateSystemUiVisibilityFlagsForExpandedDesktop(win.getSystemUiVisibility());
        final int sysUiFl = updateSystemUiVisibilityForExpandedDesktop(win.getSystemUiVisibility());

        final Rect pf = mTmpParentFrame;
        final Rect df = mTmpDisplayFrame;
@@ -4050,7 +4056,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    private int updateSystemUiVisibilityFlagsForExpandedDesktop(int vis) {
    private int updateSystemUiVisibilityForExpandedDesktop(int vis) {
        if (expandedDesktopHidesNavigationBar()) {
            if ((vis & View.SYSTEM_UI_FLAG_SHOW_NAVIGATION_IN_EXPANDED_DESKTOP) == 0) {
                vis |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
@@ -4064,7 +4070,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return vis;
    }

    private int updateWindowManagerVisibilityFlagsForExpandedDesktop(WindowManager.LayoutParams lp) {
    private int updateWindowManagerVisibilityForExpandedDesktop(WindowManager.LayoutParams lp) {
        if (mExpandedDesktopStyle == 0) {
            return lp.flags;
        }
@@ -4127,7 +4133,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                WindowManager.LayoutParams attrs) {
        if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
                + win.isVisibleOrBehindKeyguardLw());
        final int flags = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs);
        final int flags = updateWindowManagerVisibilityForExpandedDesktop(attrs);
        if (mTopFullscreenOpaqueWindowState == null
                && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) {
            mForcingShowNavBar = true;
@@ -4730,17 +4736,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }
            case KeyEvent.KEYCODE_HOME:
                if (down && !isScreenOn && isWakeKey && mHomeWakeScreen) {
                    if ((keyCode != KeyEvent.KEYCODE_VOLUME_UP) && (keyCode != KeyEvent.KEYCODE_VOLUME_DOWN)) {
                        // Otherwise, wake the device ourselves.
                    result |= ACTION_WAKE_UP;
                }
                }
                break;
            case KeyEvent.KEYCODE_FOCUS:
                if (down && !isScreenOn && mCameraWakeScreen) {
                    if ((keyCode != KeyEvent.KEYCODE_VOLUME_UP) && (keyCode != KeyEvent.KEYCODE_VOLUME_DOWN)) {
                    result |= ACTION_WAKE_UP;
                    }
                    if (mCameraSleepOnRelease) {
                        mIsFocusPressed = true;
                    }
@@ -4754,10 +4755,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mIsFocusPressed = false;
                }
                if (down && !isScreenOn && mCameraWakeScreen && mSingleStageCameraKey) {
                    if ((keyCode != KeyEvent.KEYCODE_VOLUME_UP) && (keyCode != KeyEvent.KEYCODE_VOLUME_DOWN)) {
                    result |= ACTION_WAKE_UP;
                }
                }
                if (mCameraMusicControls) {
                    // if the camera key is not pressable, see if music is active
                    if (!mCameraKeyPressable) {
@@ -4766,11 +4765,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

                    if (mCameraKeyPressable) {
                        if (down) {
                            Message msg = mHandler.obtainMessage(MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK,
                                    new KeyEvent(event.getDownTime(), event.getEventTime(),
                                    event.getAction(), KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0));
                            msg.setAsynchronous(true);
                            mHandler.sendMessageDelayed(msg, ViewConfiguration.getLongPressTimeout());
                            scheduleLongPressKeyEvent(event, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
                            break;
                        } else {
                            mHandler.removeMessages(MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK);
@@ -4868,12 +4863,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            // TODO: Long press of MUTE could be mapped to KEYCODE_MEDIA_PLAY_PAUSE
                            int newKeyCode = event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP ?
                                    KeyEvent.KEYCODE_MEDIA_NEXT : KeyEvent.KEYCODE_MEDIA_PREVIOUS;
                            Message msg = mHandler.obtainMessage(MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK,
                                    new KeyEvent(event.getDownTime(), event.getEventTime(),
                                    event.getAction(), newKeyCode, 0));
                            msg.setAsynchronous(true);
                            mHandler.sendMessageDelayed(msg,
                                    ViewConfiguration.getLongPressTimeout());
                            scheduleLongPressKeyEvent(event, newKeyCode);
                            // Consume key down events of all presses.
                            break;
                        } else {
@@ -5016,6 +5006,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return result;
    }

    private void scheduleLongPressKeyEvent(KeyEvent origEvent, int keyCode) {
        KeyEvent event = new KeyEvent(origEvent.getDownTime(), origEvent.getEventTime(),
                origEvent.getAction(), keyCode, 0);
        Message msg = mHandler.obtainMessage(MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK, event);
        msg.setAsynchronous(true);
        mHandler.sendMessageDelayed(msg, ViewConfiguration.getLongPressTimeout());
    }

    /**
     * When the screen is off we ignore some keys that might otherwise typically
     * be considered wake keys.  We filter them out here.
@@ -6104,7 +6102,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        int tmpVisibility = win.getSystemUiVisibility()
                & ~mResettingSystemUiFlags
                & ~mForceClearedSystemUiFlags;
        tmpVisibility = updateSystemUiVisibilityFlagsForExpandedDesktop(tmpVisibility);
        tmpVisibility = updateSystemUiVisibilityForExpandedDesktop(tmpVisibility);

        final boolean subWindowInExpandedMode = expandedDesktopHidesNavigationBar()
                && (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW