summaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2017-11-09 16:27:13 -0800
committerzachh <zachh@google.com>2017-11-12 02:51:00 +0000
commit9a915fc8a2fdc9e4d4511171b562c4d4e52fafb6 (patch)
tree5aeac53014252a2db7ffae757d732f3a19934c44 /java/com
parent3af5c6b002968a44b964d91cdca26056c3aaf8c3 (diff)
Stop turning on the screen when the incoming/outgoing call is via Bluetooth.
Bug: 38453773 Test: InCallActivityTest PiperOrigin-RevId: 175230358 Change-Id: I2460308e1af554e2198c256fb1f4c62d2b8124b2
Diffstat (limited to 'java/com')
-rw-r--r--java/com/android/incallui/InCallActivityCommon.java44
1 files changed, 36 insertions, 8 deletions
diff --git a/java/com/android/incallui/InCallActivityCommon.java b/java/com/android/incallui/InCallActivityCommon.java
index a9702b447..5a5d770d0 100644
--- a/java/com/android/incallui/InCallActivityCommon.java
+++ b/java/com/android/incallui/InCallActivityCommon.java
@@ -33,10 +33,12 @@ import android.os.Trace;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.res.ResourcesCompat;
+import android.telecom.CallAudioState;
import android.telecom.PhoneAccountHandle;
import android.view.KeyEvent;
import android.view.View;
@@ -65,6 +67,7 @@ import com.android.incallui.disconnectdialog.DisconnectMessage;
import com.android.incallui.incalluilock.InCallUiLock;
import com.android.incallui.telecomeventui.InternationalCallOnWifiDialogFragment;
import com.android.incallui.telecomeventui.InternationalCallOnWifiDialogFragment.Callback;
+import com.google.common.base.Optional;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -96,6 +99,8 @@ public class InCallActivityCommon {
private static final int DIALPAD_REQUEST_SHOW = 2;
private static final int DIALPAD_REQUEST_HIDE = 3;
+ private static Optional<Integer> audioRouteForTesting = Optional.absent();
+
private final InCallActivity inCallActivity;
private boolean dismissKeyguard;
private boolean showPostCharWaitDialogOnResume;
@@ -171,14 +176,7 @@ public class InCallActivityCommon {
}
public void onCreate(Bundle icicle) {
- // set this flag so this activity will stay in front of the keyguard
- // Have the WindowManager filter out touch events that are "too fat".
- int flags =
- WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
- | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
- | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
-
- inCallActivity.getWindow().addFlags(flags);
+ setWindowFlags();
inCallActivity.setContentView(R.layout.incall_screen);
@@ -483,6 +481,36 @@ public class InCallActivityCommon {
return event.getRepeatCount() == 0 && handleDialerKeyDown(keyCode, event);
}
+ private void setWindowFlags() {
+ // Allow the activity to be shown when the screen is locked and filter out touch events that are
+ // "too fat".
+ int flags =
+ WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
+
+ // When the audio stream is not directed through Bluetooth, turn the screen on once the
+ // activity is shown.
+ final int audioRoute = getAudioRoute();
+ if (audioRoute != CallAudioState.ROUTE_BLUETOOTH) {
+ flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
+ }
+
+ inCallActivity.getWindow().addFlags(flags);
+ }
+
+ private static int getAudioRoute() {
+ if (audioRouteForTesting.isPresent()) {
+ return audioRouteForTesting.get();
+ }
+
+ return AudioModeProvider.getInstance().getAudioState().getRoute();
+ }
+
+ @VisibleForTesting(otherwise = VisibleForTesting.NONE)
+ public static void setAudioRouteForTesting(int audioRoute) {
+ audioRouteForTesting = Optional.of(audioRoute);
+ }
+
private boolean handleDialerKeyDown(int keyCode, KeyEvent event) {
LogUtil.v("InCallActivityCommon.handleDialerKeyDown", "keyCode %d, event: %s", keyCode, event);