Use the FLAG_DISMISS_KEYGUARD while we are in-call.
This is a better fix for bug b/2330359.
When we are actively in-call, we now set the FLAG_DISMISS_KEYGUARD flag
so the user can press Home to exit directly to the home screen.
But in the case of a declined or unanswered phone call we will drop into
the keyguard after the call terminates.
Change-Id: I6ee0759dbedeaf05e940558ed27f09f58c6582fa
Signed-off-by: Mike Lockwood <lockwood@android.com>
Bug: 2330359
diff --git a/src/com/android/phone/InCallScreen.java b/src/com/android/phone/InCallScreen.java
index 432273e..63568d9 100755
--- a/src/com/android/phone/InCallScreen.java
+++ b/src/com/android/phone/InCallScreen.java
@@ -558,12 +558,21 @@
super.onCreate(icicle);
- // set this flag so this activity will stay in front of the keyguard
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
-
final PhoneApp app = PhoneApp.getInstance();
app.setInCallScreenInstance(this);
+ // set this flag so this activity will stay in front of the keyguard
+ int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
+ if (app.getPhoneState() == Phone.State.OFFHOOK) {
+ // While we are in call, the in-call screen should dismiss the keyguard.
+ // This allows the user to press Home to go directly home without going through
+ // an insecure lock screen.
+ // But we do not want to do this if there is no active call so we do not
+ // bypass the keyguard if the call is not answered or declined.
+ flags |= WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
+ }
+ getWindow().addFlags(flags);
+
setPhone(app.phone); // Sets mPhone and mForegroundCall/mBackgroundCall/mRingingCall
mBluetoothHandsfree = app.getBluetoothHandsfree();
@@ -929,6 +938,10 @@
// Make sure we revert the poke lock and wake lock when we move to
// the background.
app.updateWakeState();
+
+ // clear the dismiss keyguard flag so we are back to the default state
+ // when we next resume
+ updateKeyguardPolicy(false);
}
@Override
@@ -1045,6 +1058,14 @@
return mIsForegroundActivity;
}
+ /* package */ void updateKeyguardPolicy(boolean dismissKeyguard) {
+ if (dismissKeyguard) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
+ } else {
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
+ }
+ }
+
private void registerForPhoneStates() {
if (!mRegisteredForPhoneStates) {
mPhone.registerForPreciseCallStateChanged(mHandler, PHONE_STATE_CHANGED, null);
diff --git a/src/com/android/phone/PhoneApp.java b/src/com/android/phone/PhoneApp.java
index e7f0872..f3ca4b3 100755
--- a/src/com/android/phone/PhoneApp.java
+++ b/src/com/android/phone/PhoneApp.java
@@ -1145,9 +1145,21 @@
updateProximitySensorMode(state);
// clear our beginning call flag
mBeginningCall = false;
+ // While we are in call, the in-call screen should dismiss the keyguard.
+ // This allows the user to press Home to go directly home without going through
+ // an insecure lock screen.
+ // But we do not want to do this if there is no active call so we do not
+ // bypass the keyguard if the call is not answered or declined.
+ if (mInCallScreen != null) {
+ mInCallScreen.updateKeyguardPolicy(state == Phone.State.OFFHOOK);
+ }
}
}
+ /* package */ Phone.State getPhoneState() {
+ return mLastPhoneState;
+ }
+
/**
* @return true if this device supports the "proximity sensor
* auto-lock" feature while in-call (see updateProximitySensorMode()).