/*
* Copyright (C) 2006 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.phone;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.KeyguardManager;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.IBluetoothHeadsetPhone;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.ComponentName;
import android.graphics.Typeface;
import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Telephony.SIMInfo;
import android.telephony.ServiceState;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.method.DialerKeyListener;
import android.telephony.PhoneNumberUtils;
import android.util.EventLog;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.view.MenuInflater;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ImageView;
import com.android.internal.telephony.sip.SipPhone;
import android.widget.ListAdapter;
import android.view.MotionEvent;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.CallStateException;
import com.android.internal.telephony.CallManager;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.MmiCode;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyCapabilities;
import com.android.phone.Constants.CallStatusCode;
import com.android.phone.InCallUiState.InCallScreenMode;
import com.android.phone.OtaUtils.CdmaOtaScreenState;
import com.android.phone.sip.SipSharedPreferences;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.gemini.MTKCallManager;
import com.android.internal.telephony.gemini.GeminiPhone;
import android.preference.PreferenceManager;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import com.android.internal.telephony.gsm.SuppCrssNotification;
import android.widget.Button;
import android.view.MenuItem;
import com.mediatek.common.MediatekClassFactory;
import com.mediatek.common.telephony.IServiceStateExt;
import com.mediatek.vt.VTManager;
import android.view.SurfaceView;
import java.io.File;
import java.io.IOException;
import android.os.StatFs;
import android.content.ContextWrapper;
import java.util.Timer;
import java.util.TimerTask;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.view.SurfaceHolder;
import android.os.PowerManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.app.ProgressDialog;
import java.util.Timer;
import java.util.TimerTask;
import android.text.format.DateFormat;
import java.util.Date;
import android.graphics.drawable.AnimationDrawable;
import android.os.RemoteException;
import android.provider.Telephony.Intents;
import static android.provider.Telephony.Intents.ACTION_UNLOCK_KEYGUARD;
import java.util.List;
import com.android.internal.telephony.cdma.CdmaMmiCode;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.mediatek.phone.PhoneFeatureConstants.FeatureOption;
import android.os.Process;
import com.mediatek.phone.ext.ExtensionManager;
import com.mediatek.phone.ext.InCallScreenExtension;
import com.mediatek.phone.ext.IInCallScreen;
import com.mediatek.phone.gemini.GeminiUtils;
import com.mediatek.phone.gemini.GeminiRegister;
import com.mediatek.phone.CallPickerAdapter;
import com.mediatek.phone.recording.PhoneRecorder;
import com.mediatek.phone.recording.PhoneRecorderHandler;
import com.mediatek.phone.vt.IVTInCallScreen;
import com.mediatek.phone.vt.VTCallUtils;
import com.mediatek.phone.vt.VTInCallScreenFlags;
import com.mediatek.phone.vt.VTInCallScreenProxy;
import com.mediatek.phone.DualTalkUtils;
import com.mediatek.phone.InCallMenuState;
import com.mediatek.phone.VoiceCommandHandler;
import com.mediatek.settings.VTSettingUtils;
/**
* Phone app "in call" screen.
*/
public class InCallScreen extends Activity
implements View.OnClickListener, CallTime.OnTickListener, PopupMenu.OnMenuItemClickListener,
PhoneRecorderHandler.Listener, DialogInterface.OnShowListener, IInCallScreen,
VoiceCommandHandler.Listener {
private static final String LOG_TAG = "InCallScreen";
//private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
//private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
private static final boolean DBG = true;
private static final boolean VDBG = true;
private static final boolean bSamsungUI = true;//FeatureOption.SAMSUNG_UI_SUPPORT; // mgl
/**
* Intent extra used to specify whether the DTMF dialpad should be
* initially visible when bringing up the InCallScreen. (If this
* extra is present, the dialpad will be initially shown if the extra
* has the boolean value true, and initially hidden otherwise.)
*/
// TODO: Should be EXTRA_SHOW_DIALPAD for consistency.
static final String SHOW_DIALPAD_EXTRA = "com.android.phone.ShowDialpad";
static final String KEY_EMERGENCY_DIALER = "com.android.phone.EmergencyDialer";
/**
* Intent extra to specify the package name of the gateway
* provider. Used to get the name displayed in the in-call screen
* during the call setup. The value is a string.
*/
// TODO: This extra is currently set by the gateway application as
// a temporary measure. Ultimately, the framework will securely
// set it.
/* package */ static final String EXTRA_GATEWAY_PROVIDER_PACKAGE =
"com.android.phone.extra.GATEWAY_PROVI