From 21256c08138c6700e47d7ea0517ecd001d681644 Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Thu, 14 Nov 2013 12:31:02 -0800 Subject: Add logic to dynamic dismiss keyguard. If the user rejects or misses call, keyguard should not be dismissed. Check for active or outgoing call. Bug: 11580109 Change-Id: I1d83041d38ae60dd835bb967ae307791b605cf21 --- InCallUI/src/com/android/incallui/InCallActivity.java | 15 ++++++++++++--- InCallUI/src/com/android/incallui/InCallPresenter.java | 10 ++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 64e856c93..08a8f12d0 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -62,10 +62,11 @@ public class InCallActivity extends Activity { // set this flag so this activity will stay in front of the keyguard // Have the WindowManager filter out touch events that are "too fat". - getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON - | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD - | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES); + | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES; + + getWindow().addFlags(flags); requestWindowFeature(Window.FEATURE_NO_TITLE); @@ -388,6 +389,14 @@ public class InCallActivity extends Activity { mCallButtonFragment.displayDialpad(false); } + public void dismissKeyguard(boolean dismiss) { + if (dismiss) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); + } + } + public void displayDialpad(boolean showDialpad) { if (showDialpad) { mDialpadFragment.setVisible(true); diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 5830e726c..ae9da3632 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -233,6 +233,12 @@ public class InCallPresenter implements CallList.Listener { Log.d(this, "Notify " + listener + " of state " + mInCallState.toString()); listener.onStateChange(mInCallState, callList); } + + if (isActivityStarted()) { + final boolean hasCall = callList.getActiveOrBackgroundCall() != null || + callList.getOutgoingCall() != null; + mInCallActivity.dismissKeyguard(hasCall); + } } /** @@ -268,6 +274,10 @@ public class InCallPresenter implements CallList.Listener { // We need to do the run the same code as onCallListChange. onCallListChange(CallList.getInstance()); + + if (isActivityStarted()) { + mInCallActivity.dismissKeyguard(false); + } } /** -- cgit v1.2.3