Reapply Screen timeout when in call activity is recreated
Previously the keep screen on flag is only applied the the activity once when the video call is created. The flag will be lost when the activity is recreated, such as rotating the screen.
In this CL, the keep screen on state is persisted in the InCallPresenter, and will be reapplied every time the activity is created. The flag will be cleared when the call is finished or when the video call has ened
Bug: 64101648,63917358
Test: InCallPresenterTest
PiperOrigin-RevId: 164030247
Change-Id: Ie90f8dd0dfc9b542d691296c729dc3342a8bc2ad
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java
index 3a48622..6c08c49 100644
--- a/java/com/android/incallui/InCallPresenter.java
+++ b/java/com/android/incallui/InCallPresenter.java
@@ -191,6 +191,8 @@
/** Determines if the InCall UI is in fullscreen mode or not. */
private boolean mIsFullScreen = false;
+ private boolean mScreenTimeoutEnabled = true;
+
private PhoneStateListener mPhoneStateListener =
new PhoneStateListener() {
@Override
@@ -400,6 +402,7 @@
}
private void attemptFinishActivity() {
+ mScreenTimeoutEnabled = true;
final boolean doFinish = (mInCallActivity != null && isActivityStarted());
LogUtil.i("InCallPresenter.attemptFinishActivity", "Hide in call UI: " + doFinish);
if (doFinish) {
@@ -1077,6 +1080,7 @@
// TODO(maxwelb) - b/36649622: Investigate this redundant call
mStatusBarNotifier.updateNotification(mCallList);
}
+ applyScreenTimeout();
}
/*package*/
@@ -1590,13 +1594,18 @@
public void enableScreenTimeout(boolean enable) {
LogUtil.v("InCallPresenter.enableScreenTimeout", "enableScreenTimeout: value=" + enable);
+ mScreenTimeoutEnabled = enable;
+ applyScreenTimeout();
+ }
+
+ private void applyScreenTimeout() {
if (mInCallActivity == null) {
- LogUtil.e("InCallPresenter.enableScreenTimeout", "InCallActivity is null.");
+ LogUtil.e("InCallPresenter.applyScreenTimeout", "InCallActivity is null.");
return;
}
final Window window = mInCallActivity.getWindow();
- if (enable) {
+ if (mScreenTimeoutEnabled) {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
diff --git a/java/com/android/incallui/VideoCallPresenter.java b/java/com/android/incallui/VideoCallPresenter.java
index 233b2b5..89cddb9 100644
--- a/java/com/android/incallui/VideoCallPresenter.java
+++ b/java/com/android/incallui/VideoCallPresenter.java
@@ -867,7 +867,7 @@
false /* isRemotelyHeld */);
enableCamera(mVideoCall, false);
InCallPresenter.getInstance().setFullScreen(false);
-
+ InCallPresenter.getInstance().enableScreenTimeout(false);
mIsVideoMode = false;
}