1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.server.telecom.ui; 18 19 import com.android.server.telecom.R; 20 21 import android.app.Activity; 22 import android.app.AlertDialog; 23 import android.content.DialogInterface; 24 import android.os.Bundle; 25 import android.telecom.Log; 26 27 /** 28 * Dialog activity used when there is an ongoing call redirected by the call redirection service. 29 * The dialog prompts the user to inform the redirected outgoing call is canceled due to timeout. 30 */ 31 public class CallRedirectionTimeoutDialogActivity extends Activity { 32 public static final String EXTRA_REDIRECTION_APP_NAME = 33 "android.telecom.extra.REDIRECTION_APP_NAME"; 34 35 @Override onCreate(Bundle savedInstanceState)36 protected void onCreate(Bundle savedInstanceState) { 37 super.onCreate(savedInstanceState); 38 Log.i(this, "CallRedirectionTimeoutDialogActivity onCreate."); 39 final CharSequence redirectionAppName = getIntent().getStringExtra( 40 EXTRA_REDIRECTION_APP_NAME); 41 showDialog(redirectionAppName); 42 } 43 showDialog(final CharSequence redirectionAppName)44 private void showDialog(final CharSequence redirectionAppName) { 45 Log.i(this, "showDialog: timeout redirection with %s", redirectionAppName); 46 CharSequence message = getString( 47 R.string.alert_redirect_outgoing_call_timeout, redirectionAppName); 48 final AlertDialog errorDialog = new AlertDialog.Builder(this) 49 .setMessage(message) 50 .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 51 @Override 52 public void onClick(DialogInterface dialog, int which) { 53 dialog.dismiss(); 54 finish(); 55 } 56 }) 57 .setOnCancelListener(new DialogInterface.OnCancelListener() { 58 @Override 59 public void onCancel(DialogInterface dialog) { 60 dialog.dismiss(); 61 finish(); 62 } 63 }) 64 .create(); 65 66 errorDialog.show(); 67 } 68 } 69