summaryrefslogtreecommitdiff
path: root/java/com/android/incallui
diff options
context:
space:
mode:
authoryueg <yueg@google.com>2018-04-25 12:01:09 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-25 17:22:16 -0700
commita489f5159eba96d9ea7db138da3f93a37d3318de (patch)
treea0767b63bed75be113b51e3dbe7a18dcd4241b1b /java/com/android/incallui
parent6d5a31b13b2624ebdeb5f5eccb327bc66544917d (diff)
Show post char dialog without InCallActivity.
Bug: 74022483 Test: InCallPresenterTest PiperOrigin-RevId: 194275941 Change-Id: If5a40a9778e3c0f5a05c7e33f365cb609bf6e74a
Diffstat (limited to 'java/com/android/incallui')
-rw-r--r--java/com/android/incallui/AndroidManifest.xml7
-rw-r--r--java/com/android/incallui/InCallActivity.java21
-rw-r--r--java/com/android/incallui/InCallPresenter.java16
-rw-r--r--java/com/android/incallui/PostCharDialogActivity.java100
-rw-r--r--java/com/android/incallui/PostCharDialogFragment.java3
5 files changed, 126 insertions, 21 deletions
diff --git a/java/com/android/incallui/AndroidManifest.xml b/java/com/android/incallui/AndroidManifest.xml
index 832a5e874..7286b0db7 100644
--- a/java/com/android/incallui/AndroidManifest.xml
+++ b/java/com/android/incallui/AndroidManifest.xml
@@ -106,6 +106,13 @@
android:theme="@style/Theme.Incall.DialogHolder"
/>
+ <activity
+ android:excludeFromRecents="true"
+ android:exported="false"
+ android:name="com.android.incallui.PostCharDialogActivity"
+ android:noHistory="true"
+ android:theme="@style/Theme.Incall.DialogHolder"/>
+
<!-- BroadcastReceiver for receiving Intents from Notification mechanism. -->
<receiver
android:directBootAware="true"
diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java
index 2b6c2b49d..02335b6e4 100644
--- a/java/com/android/incallui/InCallActivity.java
+++ b/java/com/android/incallui/InCallActivity.java
@@ -145,8 +145,6 @@ public class InCallActivity extends TransactionSafeFragmentActivity
private View pseudoBlackScreenOverlay;
private SelectPhoneAccountDialogFragment selectPhoneAccountDialogFragment;
private String dtmfTextToPrepopulate;
- private String showPostCharWaitDialogCallId;
- private String showPostCharWaitDialogChars;
private boolean allowOrientationChange;
private boolean animateDialpadOnShow;
private boolean didShowAnswerScreen;
@@ -160,7 +158,6 @@ public class InCallActivity extends TransactionSafeFragmentActivity
private boolean isRecreating; // whether the activity is going to be recreated
private boolean isVisible;
private boolean needDismissPendingDialogs;
- private boolean showPostCharWaitDialogOnResume;
private boolean touchDownWhenPseudoScreenOff;
private int[] backgroundDrawableColors;
@DialpadRequestType private int showDialpadRequest = DIALPAD_REQUEST_NONE;
@@ -531,10 +528,6 @@ public class InCallActivity extends TransactionSafeFragmentActivity
}
updateNavigationBar(isDialpadVisible());
- if (showPostCharWaitDialogOnResume) {
- showDialogForPostCharWait(showPostCharWaitDialogCallId, showPostCharWaitDialogChars);
- }
-
CallList.getInstance()
.onInCallUiShown(getIntent().getBooleanExtra(IntentExtraNames.FOR_FULL_SCREEN, false));
@@ -1016,18 +1009,8 @@ public class InCallActivity extends TransactionSafeFragmentActivity
}
public void showDialogForPostCharWait(String callId, String chars) {
- if (isVisible) {
- PostCharDialogFragment fragment = new PostCharDialogFragment(callId, chars);
- fragment.show(getSupportFragmentManager(), Tags.POST_CHAR_DIALOG_FRAGMENT);
-
- showPostCharWaitDialogOnResume = false;
- showPostCharWaitDialogCallId = null;
- showPostCharWaitDialogChars = null;
- } else {
- showPostCharWaitDialogOnResume = true;
- showPostCharWaitDialogCallId = callId;
- showPostCharWaitDialogChars = chars;
- }
+ PostCharDialogFragment fragment = new PostCharDialogFragment(callId, chars);
+ fragment.show(getSupportFragmentManager(), Tags.POST_CHAR_DIALOG_FRAGMENT);
}
public void showDialogOrToastForDisconnectedCall(DisconnectMessage disconnectMessage) {
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java
index 526cc64d3..6e7daf551 100644
--- a/java/com/android/incallui/InCallPresenter.java
+++ b/java/com/android/incallui/InCallPresenter.java
@@ -1271,8 +1271,22 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud
}
public void onPostDialCharWait(String callId, String chars) {
- if (isActivityStarted()) {
+ // If not visible, inCallActivity is stopped. Starting from P, calling recreate() will destroy
+ // the old activity instance and create a new instance immediately. Previously, the old activity
+ // went through its lifecycle from create to destroy before creating a new instance.
+ // So this case doesn't work now: make a call with char WAIT, leave in call UI, call gets
+ // connected, and go back to in call UI to see the dialog.
+ // So we should show dialog in an empty activity if inCallActivity is not visible. And it also
+ // helps with background calling.
+ if (isActivityStarted() && inCallActivity.isVisible()) {
inCallActivity.showDialogForPostCharWait(callId, chars);
+ } else {
+ Intent intent = new Intent(context, PostCharDialogActivity.class);
+ // Prevent showing MainActivity with PostCharDialogActivity on above
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ intent.putExtra(PostCharDialogActivity.EXTRA_CALL_ID, callId);
+ intent.putExtra(PostCharDialogActivity.EXTRA_POST_DIAL_STRING, chars);
+ context.startActivity(intent);
}
}
diff --git a/java/com/android/incallui/PostCharDialogActivity.java b/java/com/android/incallui/PostCharDialogActivity.java
new file mode 100644
index 000000000..dcdc9d663
--- /dev/null
+++ b/java/com/android/incallui/PostCharDialogActivity.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.incallui;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import com.android.incallui.call.CallList;
+import com.android.incallui.call.DialerCall;
+
+/**
+ * Activity that contains an alert dialog with OK and Cancel buttons to allow user to Accept or
+ * Reject the WAIT inserted as part of the Dial string.
+ */
+public class PostCharDialogActivity extends AppCompatActivity implements CallList.Listener {
+
+ public static final String EXTRA_CALL_ID = "extra_call_id";
+ public static final String EXTRA_POST_DIAL_STRING = "extra_post_dial_string";
+ private static final String TAG_INTERNATIONAL_CALL_ON_WIFI = "tag_international_call_on_wifi";
+
+ private String callId;
+
+ @Override
+ protected void onCreate(@Nullable Bundle bundle) {
+ super.onCreate(bundle);
+
+ callId = getIntent().getStringExtra(EXTRA_CALL_ID);
+ String postDialString = getIntent().getStringExtra(EXTRA_POST_DIAL_STRING);
+ if (callId == null || postDialString == null) {
+ finish();
+ return;
+ }
+
+ PostCharDialogFragment fragment = new PostCharDialogFragment(callId, postDialString);
+ fragment.show(getSupportFragmentManager(), TAG_INTERNATIONAL_CALL_ON_WIFI);
+
+ CallList.getInstance().addListener(this);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ CallList.getInstance().removeListener(this);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ // We don't expect the activity to resume, except for orientation change.
+ if (!isChangingConfigurations()) {
+ finish();
+ }
+ }
+
+ @Override
+ public void onDisconnect(DialerCall call) {
+ if (callId.equals(call.getId())) {
+ finish();
+ }
+ }
+
+ @Override
+ public void onIncomingCall(DialerCall call) {}
+
+ @Override
+ public void onUpgradeToVideo(DialerCall call) {}
+
+ @Override
+ public void onUpgradeToRtt(DialerCall call, int rttRequestId) {}
+
+ @Override
+ public void onSessionModificationStateChange(DialerCall call) {}
+
+ @Override
+ public void onCallListChange(CallList callList) {}
+
+ @Override
+ public void onWiFiToLteHandover(DialerCall call) {}
+
+ @Override
+ public void onHandoverToWifiFailed(DialerCall call) {}
+
+ @Override
+ public void onInternationalCallOnWifi(@NonNull DialerCall call) {}
+}
diff --git a/java/com/android/incallui/PostCharDialogFragment.java b/java/com/android/incallui/PostCharDialogFragment.java
index 4bcc68e33..1d06fd487 100644
--- a/java/com/android/incallui/PostCharDialogFragment.java
+++ b/java/com/android/incallui/PostCharDialogFragment.java
@@ -55,7 +55,8 @@ public class PostCharDialogFragment extends DialogFragment {
buf.append(getResources().getText(R.string.wait_prompt_str));
buf.append(postDialStr);
- final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ final AlertDialog.Builder builder =
+ new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme);
builder.setMessage(buf.toString());
builder.setPositiveButton(