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

Commit c8f7c0ec authored by Jim Miller's avatar Jim Miller
Browse files

Fix 2336057: Provide a way for the user to return to a call from LockScreen.

This makes the "Emergency call" button dual-purpose. If there's a call in progress,
the button will show "Return to call" and take them back to the call.
parent 746c4c44
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.accounts.AccountManagerCallback;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.InputFilter;
import android.text.LoginFilter;
@@ -51,7 +52,7 @@ import java.io.IOException;
 * account's login/password to unlock the phone (and reset their lock pattern).
 */
public class AccountUnlockScreen extends RelativeLayout implements KeyguardScreen,
        View.OnClickListener, TextWatcher {
        KeyguardUpdateMonitor.InfoCallback,View.OnClickListener, TextWatcher {
    private static final String LOCK_PATTERN_PACKAGE = "com.android.settings";
    private static final String LOCK_PATTERN_CLASS =
            "com.android.settings.ChooseLockPattern";
@@ -108,6 +109,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree

        mEmergencyCall = (Button) findViewById(R.id.emergencyCall);
        mEmergencyCall.setOnClickListener(this);
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
    }

    public void afterTextChanged(Editable s) {
@@ -143,6 +145,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
        mLogin.setText("");
        mPassword.setText("");
        mLogin.requestFocus();
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
    }

    /** {@inheritDoc} */
@@ -314,4 +317,24 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
        }
        return mCheckingDialog;
    }

    public void onPhoneStateChanged(String newState) {
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
    }

    public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel) {

    }

    public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {

    }

    public void onRingerModeChanged(int state) {

    }

    public void onTimeChanged() {

    }
}
+25 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ import static android.provider.Telephony.Intents.SPN_STRINGS_UPDATED_ACTION;

import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.TelephonyIntents;

import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.internal.R;
import com.google.android.collect.Lists;
@@ -96,6 +98,7 @@ public class KeyguardUpdateMonitor {
    private static final int MSG_CARRIER_INFO_UPDATE = 303;
    private static final int MSG_SIM_STATE_CHANGE = 304;
    private static final int MSG_RINGER_MODE_CHANGED = 305;
    private static final int MSG_PHONE_STATE_CHANGED = 306;


    /**
@@ -165,6 +168,9 @@ public class KeyguardUpdateMonitor {
                    case MSG_RINGER_MODE_CHANGED:
                        handleRingerModeChange(msg.arg1);
                        break;
                    case MSG_PHONE_STATE_CHANGED:
                        handlePhoneStateChanged((String)msg.obj);
                        break;
                }
            }
        };
@@ -221,6 +227,7 @@ public class KeyguardUpdateMonitor {
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
        filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
        filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
        filter.addAction(SPN_STRINGS_UPDATED_ACTION);
        filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
        context.registerReceiver(new BroadcastReceiver() {
@@ -255,11 +262,21 @@ public class KeyguardUpdateMonitor {
                } else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
                    mHandler.sendMessage(mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED,
                            intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1), 0));
                } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
                    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
                    mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
                }
            }
        }, filter);
    }

    protected void handlePhoneStateChanged(String newState) {
        if (DEBUG) Log.d(TAG, "handlePhoneStateChanged(" + newState + ")");
        for (int i = 0; i < mInfoCallbacks.size(); i++) {
            mInfoCallbacks.get(i).onPhoneStateChanged(newState);
        }
    }

    protected void handleRingerModeChange(int mode) {
        if (DEBUG) Log.d(TAG, "handleRingerModeChange(" + mode + ")");
        for (int i = 0; i < mInfoCallbacks.size(); i++) {
@@ -478,6 +495,14 @@ public class KeyguardUpdateMonitor {
         * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
         */
        void onRingerModeChanged(int state);

        /**
         * Called when the phone state changes. String will be one of:
         * {@link TelephonyManager#EXTRA_STATE_IDLE}
         * {@link TelephonyManager@EXTRA_STATE_RINGING}
         * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
         */
        void onPhoneStateChanged(String newState);
    }

    /**
+16 −31
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.SystemProperties;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
@@ -60,6 +61,9 @@ import java.io.IOException;
public class LockPatternKeyguardView extends KeyguardViewBase
        implements AccountManagerCallback<Account[]> {

    // time after launching EmergencyDialer before the screen goes blank.
    private static final int EMERGENCY_CALL_TIMEOUT = 10000;

    // intent action for launching emergency dialer activity.
    static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";

@@ -251,11 +255,17 @@ public class LockPatternKeyguardView extends KeyguardViewBase
            }

            public void takeEmergencyCallAction() {
                pokeWakelock(EMERGENCY_CALL_TIMEOUT);
                if (TelephonyManager.getDefault().getCallState()
                        == TelephonyManager.CALL_STATE_OFFHOOK) {
                    mLockPatternUtils.resumeCall();
                } else {
                    Intent intent = new Intent(ACTION_EMERGENCY_DIAL);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                            | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                    getContext().startActivity(intent);
                }
            }

            public void pokeWakelock() {
                getCallback().pokeWakelock();
@@ -556,7 +566,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase
            return new SimUnlockScreen(
                    mContext,
                    mUpdateMonitor,
                    mKeyguardScreenCallback);
                    mKeyguardScreenCallback,
                    mLockPatternUtils);
        } else if (unlockMode == UnlockMode.Account) {
            try {
                return new AccountUnlockScreen(
@@ -589,32 +600,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase
        }
    }

    private View getUnlockScreenForCurrentUnlockMode() {
        final UnlockMode unlockMode = getUnlockMode();

        // if a screen exists for the correct mode, we're done
        if (unlockMode == mUnlockScreenMode) {
            return mUnlockScreen;
        }

        // remember the mode
        mUnlockScreenMode = unlockMode;

        // unlock mode has changed and we have an existing old unlock screen
        // to clean up
        if (mScreenOn && (mUnlockScreen.getVisibility() == View.VISIBLE)) {
            ((KeyguardScreen) mUnlockScreen).onPause();
        }
        ((KeyguardScreen) mUnlockScreen).cleanUp();
        removeViewInLayout(mUnlockScreen);

        // create the new one
        mUnlockScreen = createUnlockScreenFor(unlockMode);
        mUnlockScreen.setVisibility(View.INVISIBLE);
        addView(mUnlockScreen);
        return mUnlockScreen;
    }

    /**
     * Given the current state of things, what should be the initial mode of
     * the lock screen (lock or unlock).
+10 −0
Original line number Diff line number Diff line
@@ -18,12 +18,15 @@ package com.android.internal.policy.impl;

import com.android.internal.R;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.Phone.State;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.SlidingTab;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.ColorStateList;
import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -190,6 +193,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM

        mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton);
        mEmergencyCallButton.setText(R.string.lockscreen_emergency_call);
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
        mScreenLocked = (TextView) findViewById(R.id.screenLocked);
        mSelector = (SlidingTab) findViewById(R.id.tab_selector);
        mSelector.setHoldAfterTrigger(true, false);
@@ -248,6 +252,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM

        refreshBatteryStringAndIcon();
        refreshAlarmDisplay();
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);

        mTimeFormat = DateFormat.getTimeFormat(getContext());
        mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
@@ -610,6 +615,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
    /** {@inheritDoc} */
    public void onResume() {
        resetStatusInfo(mUpdateMonitor);
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
    }

    /** {@inheritDoc} */
@@ -625,4 +631,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
            updateRightTabResources();
        }
    }

    public void onPhoneStateChanged(String newState) {
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
    }
}
+30 −4
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ import android.graphics.Rect;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardView;

import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -39,7 +41,8 @@ import com.android.internal.widget.PasswordEntryKeyboardHelper;
 * an unlock password
 */
public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen, View.OnClickListener,
        KeyguardUpdateMonitor.ConfigurationChangeCallback, OnEditorActionListener {
        KeyguardUpdateMonitor.ConfigurationChangeCallback, KeyguardUpdateMonitor.InfoCallback,
        OnEditorActionListener {

    private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;

@@ -49,7 +52,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
    private final boolean mCreatedWithKeyboardOpen;

    private EditText mPasswordEntry;
    private TextView mEmergencyCallButton;
    private Button mEmergencyCallButton;
    private LockPatternUtils mLockPatternUtils;
    private PasswordEntryKeyboardView mKeyboardView;
    private PasswordEntryKeyboardHelper mKeyboardHelper;
@@ -64,6 +67,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
        mUpdateMonitor = updateMonitor;
        mCallback = callback;
        mCreatedWithKeyboardOpen = mUpdateMonitor.isKeyboardOpen();
        mLockPatternUtils = lockPatternUtils;

        LayoutInflater layoutInflater = LayoutInflater.from(context);
        if (mUpdateMonitor.isInPortrait()) {
@@ -76,10 +80,10 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
        mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
        mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
        mPasswordEntry.setOnEditorActionListener(this);
        mEmergencyCallButton = (TextView) findViewById(R.id.emergencyCall);
        mEmergencyCallButton = (Button) findViewById(R.id.emergencyCall);
        mEmergencyCallButton.setOnClickListener(this);
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
        mUpdateMonitor.registerConfigurationChangeCallback(this);
        mLockPatternUtils = lockPatternUtils;

        mKeyboardHelper = new PasswordEntryKeyboardHelper(context, mKeyboardView, this);
        mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
@@ -90,6 +94,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen

        mKeyboardHelper.setVibratePattern(mLockPatternUtils.isTactileFeedbackEnabled() ?
                com.android.internal.R.array.config_virtualKeyVibePattern : 0);

    }

    @Override
@@ -113,6 +118,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
        // start fresh
        mPasswordEntry.setText("");
        mPasswordEntry.requestFocus();
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
    }

    /** {@inheritDoc} */
@@ -164,4 +170,24 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
        return false;
    }

    public void onPhoneStateChanged(String newState) {
        mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
    }

    public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel) {

    }

    public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {

    }

    public void onRingerModeChanged(int state) {

    }

    public void onTimeChanged() {

    }

}
Loading