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

Commit bc8d29f8 authored by The Android Open Source Project's avatar The Android Open Source Project
Browse files

auto import from //depot/cupcake/@136745

parent 919607c9
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.policy.impl;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.View;
import android.widget.FrameLayout;
@@ -36,6 +37,7 @@ public abstract class KeyguardViewBase extends FrameLayout {

    private KeyguardViewCallback mCallback;
    private AudioManager mAudioManager;
    private TelephonyManager mTelephonyManager = null;

    public KeyguardViewBase(Context context) {
        super(context);
@@ -131,8 +133,18 @@ public abstract class KeyguardViewBase extends FrameLayout {
        final int keyCode = event.getKeyCode();
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_HEADSETHOOK: 
                case KeyEvent.KEYCODE_PLAYPAUSE:
                    /* Suppress PLAYPAUSE toggle when phone is ringing or
                     * in-call to avoid music playback */
                    if (mTelephonyManager == null) {
                        mTelephonyManager = (TelephonyManager) getContext().getSystemService(
                                Context.TELEPHONY_SERVICE);
                    }
                    if (mTelephonyManager != null &&
                            mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE) {
                        return true;  // suppress key event
                    }
                case KeyEvent.KEYCODE_HEADSETHOOK: 
                case KeyEvent.KEYCODE_STOP: 
                case KeyEvent.KEYCODE_NEXTSONG: 
                case KeyEvent.KEYCODE_PREVIOUSSONG: 
+93 −78
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.util.AndroidRuntimeException;
import android.util.Config;
import android.util.EventLog;
@@ -148,6 +149,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

    private KeyguardManager mKeyguardManager = null;

    private TelephonyManager mTelephonyManager = null;
    
    private boolean mSearchKeyDownReceived;

    private boolean mKeycodeCallTimeoutActive = false;
@@ -189,8 +192,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                case MSG_CAMERA_LONG_PRESS: {
                    if (!mKeycodeCameraTimeoutActive) return;
                    // See above.
                    mKeycodeMenuTimeoutHandler.sendEmptyMessage(
                            MSG_CAMERA_LONG_PRESS_COMPLETE);
                    Message newMessage = Message.obtain(msg);
                    newMessage.what = MSG_CAMERA_LONG_PRESS_COMPLETE;
                    mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
                    break;
                }
                case MSG_MENU_LONG_PRESS_COMPLETE: {
@@ -1195,9 +1199,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                return true;
            }


            case KeyEvent.KEYCODE_PLAYPAUSE:
                /* Suppress PLAYPAUSE toggle when phone is ringing or in-call
                 * to avoid music playback */
                if (mTelephonyManager == null) {
                    mTelephonyManager = (TelephonyManager) getContext().getSystemService(
                            Context.TELEPHONY_SERVICE);
                }
                if (mTelephonyManager != null &&
                        mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE) {
                    return true;  // suppress key event
                }
            case KeyEvent.KEYCODE_MUTE:
            case KeyEvent.KEYCODE_HEADSETHOOK:
            case KeyEvent.KEYCODE_PLAYPAUSE:
            case KeyEvent.KEYCODE_STOP:
            case KeyEvent.KEYCODE_NEXTSONG:
            case KeyEvent.KEYCODE_PREVIOUSSONG: