summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authoryueg <yueg@google.com>2017-09-28 15:06:58 -0700
committerEric Erfanian <erfanian@google.com>2017-10-02 14:57:34 -0700
commit90b570e4f427f14fd17d53561c209d5eb1ac1936 (patch)
treea7fb6b6ab287054cf1806ff1b75067fc0d79a438 /java
parent4d705e558d25a8fd810cb551c43c5a517cd1c2b9 (diff)
Fix audio route selector.
1. Use onCancel() instead of onDismiss(). onCancel() is not called when changing orientation, so it won't crash on getParentUnsafe(). onCancel() is also not called when pressing home button, but it will be handled by AudioRouteSelectorActivity.onPause(). b/67013452 will happen after the fix. 2. Use FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_MULTIPLE_TASK when starting AudioRouteSelectorActivity. This prevents showing Dialer with AudioRouteSelectorActivity. The downside is that the activity is no longer excluded from recent screen. The two fixes can affect each other, so they are in one CL. Video: https://drive.google.com/open?id=0Bz1rQbdSCWSKYVJkd3R1SkI4c3c Test: manual PiperOrigin-RevId: 170404203 Change-Id: Ifa8ebcd566670115d3865b0d67c311c296fbbd51
Diffstat (limited to 'java')
-rw-r--r--java/com/android/incallui/AudioRouteSelectorActivity.java6
-rw-r--r--java/com/android/incallui/ReturnToCallActionReceiver.java8
-rw-r--r--java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java20
3 files changed, 20 insertions, 14 deletions
diff --git a/java/com/android/incallui/AudioRouteSelectorActivity.java b/java/com/android/incallui/AudioRouteSelectorActivity.java
index f0ae79bc2..2fdc89aa8 100644
--- a/java/com/android/incallui/AudioRouteSelectorActivity.java
+++ b/java/com/android/incallui/AudioRouteSelectorActivity.java
@@ -57,7 +57,9 @@ public class AudioRouteSelectorActivity extends FragmentActivity
if (audioRouteSelectorDialogFragment != null) {
audioRouteSelectorDialogFragment.dismiss();
}
- // We don't expect the activity to resume
- finish();
+ // We don't expect the activity to resume, except for orientation change.
+ if (!isChangingConfigurations()) {
+ finish();
+ }
}
}
diff --git a/java/com/android/incallui/ReturnToCallActionReceiver.java b/java/com/android/incallui/ReturnToCallActionReceiver.java
index b645c155c..c37b0b816 100644
--- a/java/com/android/incallui/ReturnToCallActionReceiver.java
+++ b/java/com/android/incallui/ReturnToCallActionReceiver.java
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telecom.CallAudioState;
+import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
@@ -51,6 +52,9 @@ public class ReturnToCallActionReceiver extends BroadcastReceiver {
case ACTION_END_CALL:
endCall(context);
break;
+ default:
+ throw Assert.createIllegalStateFailException(
+ "Invalid intent action: " + intent.getAction());
}
}
@@ -87,7 +91,9 @@ public class ReturnToCallActionReceiver extends BroadcastReceiver {
}
public void showAudioRouteSelector(Context context) {
- context.startActivity(new Intent(context, AudioRouteSelectorActivity.class));
+ Intent intent = new Intent(context, AudioRouteSelectorActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ context.startActivity(intent);
}
private void toggleMute(Context context) {
diff --git a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
index 860d2d282..9fd3aed5b 100644
--- a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
+++ b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
@@ -27,7 +27,6 @@ import android.support.design.widget.BottomSheetDialogFragment;
import android.telecom.CallAudioState;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
@@ -92,12 +91,14 @@ public class AudioRouteSelectorDialogFragment extends BottomSheetDialogFragment
(TextView) view.findViewById(R.id.audioroute_earpiece),
CallAudioState.ROUTE_EARPIECE,
audioState);
+
+ // TODO(b/67013452): set peak height correctly to fully expand it in landscape mode.
return view;
}
@Override
- public void onDismiss(DialogInterface dialogInterface) {
- super.onDismiss(dialogInterface);
+ public void onCancel(DialogInterface dialogInterface) {
+ super.onCancel(dialogInterface);
FragmentUtils.getParentUnsafe(
AudioRouteSelectorDialogFragment.this, AudioRouteSelectorPresenter.class)
.onAudioRouteSelectorDismiss();
@@ -113,14 +114,11 @@ public class AudioRouteSelectorDialogFragment extends BottomSheetDialogFragment
item.setCompoundDrawableTintMode(Mode.SRC_ATOP);
}
item.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dismiss();
- FragmentUtils.getParentUnsafe(
- AudioRouteSelectorDialogFragment.this, AudioRouteSelectorPresenter.class)
- .onAudioRouteSelected(itemRoute);
- }
+ (v) -> {
+ dismiss();
+ FragmentUtils.getParentUnsafe(
+ AudioRouteSelectorDialogFragment.this, AudioRouteSelectorPresenter.class)
+ .onAudioRouteSelected(itemRoute);
});
}
}