diff options
Diffstat (limited to 'java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java')
-rw-r--r-- | java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java b/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java index 35f36f727..ccb132b95 100644 --- a/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java +++ b/java/com/android/incallui/answer/impl/answermethod/AnswerMethodFactory.java @@ -19,12 +19,15 @@ package com.android.incallui.answer.impl.answermethod; import android.app.Activity; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.support.v4.app.Fragment; +import com.android.dialer.common.LogUtil; import com.android.dialer.compat.ActivityCompat; import com.android.incallui.util.AccessibilityUtil; /** Creates the appropriate {@link AnswerMethod} for the circumstances. */ public class AnswerMethodFactory { + private static boolean shouldUseTwoButtonMethodForTesting; @NonNull public static AnswerMethod createAnswerMethod(@NonNull Activity activity) { @@ -45,7 +48,17 @@ public class AnswerMethodFactory { return !(answerMethod instanceof TwoButtonMethod) && needTwoButton(answerMethod.getActivity()); } + @VisibleForTesting + public static void setShouldUseTwoButtonMethodForTesting(boolean shouldUse) { + shouldUseTwoButtonMethodForTesting = shouldUse; + } + private static boolean needTwoButton(@NonNull Activity activity) { + if (shouldUseTwoButtonMethodForTesting) { + LogUtil.i("AnswerMethodFactory.needTwoButton", "enabled for testing"); + return true; + } + return AccessibilityUtil.isTouchExplorationEnabled(activity) || ActivityCompat.isInMultiWindowMode(activity); } |