Merge "Dialer: WFC: Add wifi call features." into atel.lnx.2.0-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 283a836..4930315 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -42,6 +42,7 @@
     <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
     <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
@@ -59,6 +60,7 @@
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     <uses-permission android:name="android.permission.BROADCAST_STICKY" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <!-- This tells the activity manager to not delay any of our activity
      start requests, even if they happen immediately after the user
      presses home. -->
diff --git a/res/drawable-hdpi/fab_ic_wificall.png b/res/drawable-hdpi/fab_ic_wificall.png
new file mode 100755
index 0000000..1794845
--- /dev/null
+++ b/res/drawable-hdpi/fab_ic_wificall.png
Binary files differ
diff --git a/res/drawable-hdpi/wifi_calling_on_notification.png b/res/drawable-hdpi/wifi_calling_on_notification.png
new file mode 100755
index 0000000..fc34ae3
--- /dev/null
+++ b/res/drawable-hdpi/wifi_calling_on_notification.png
Binary files differ
diff --git a/res/drawable-mdpi/fab_ic_wificall.png b/res/drawable-mdpi/fab_ic_wificall.png
new file mode 100755
index 0000000..611f0d2
--- /dev/null
+++ b/res/drawable-mdpi/fab_ic_wificall.png
Binary files differ
diff --git a/res/drawable-xhdpi/fab_ic_wificall.png b/res/drawable-xhdpi/fab_ic_wificall.png
new file mode 100755
index 0000000..f4d522e
--- /dev/null
+++ b/res/drawable-xhdpi/fab_ic_wificall.png
Binary files differ
diff --git a/res/drawable-xhdpi/wifi_calling_on_notification.png b/res/drawable-xhdpi/wifi_calling_on_notification.png
new file mode 100755
index 0000000..2c11f32
--- /dev/null
+++ b/res/drawable-xhdpi/wifi_calling_on_notification.png
Binary files differ
diff --git a/res/drawable-xxhdpi/fab_ic_wificall.png b/res/drawable-xxhdpi/fab_ic_wificall.png
new file mode 100755
index 0000000..ef9d17d
--- /dev/null
+++ b/res/drawable-xxhdpi/fab_ic_wificall.png
Binary files differ
diff --git a/res/drawable-xxhdpi/wifi_calling_on_notification.png b/res/drawable-xxhdpi/wifi_calling_on_notification.png
new file mode 100755
index 0000000..23bb6f9
--- /dev/null
+++ b/res/drawable-xxhdpi/wifi_calling_on_notification.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/fab_ic_wificall.png b/res/drawable-xxxhdpi/fab_ic_wificall.png
new file mode 100755
index 0000000..4d78f05
--- /dev/null
+++ b/res/drawable-xxxhdpi/fab_ic_wificall.png
Binary files differ
diff --git a/res/values/config.xml b/res/values/config.xml
index 49babee..1149281 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -30,8 +30,6 @@
  */
 -->
 <resources>
-  <bool name="config_regional_call_data_usage_enable">true</bool>
-  <bool name="config_regional_pup_no_available_network">true</bool>
-  <bool name="config_regional_call_data_usage_enable">false</bool>
   <bool name="config_regional_video_call_welcome_dialog">false</bool>
+  <bool name="config_regional_pup_no_available_network">false</bool>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4f89b77..e54433d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1121,4 +1121,17 @@
     <string name="video_call_welcome_title"><b>Welcome to the new Video Calling Dialer</b></string>
     <string name="video_call_welcome_message">We all love to hear that familiar voice at the end of the line, but talking face-to-face is so much better! Here\'s what you should know to get your real-time (or FaceTime?) connections going: You\'ll need to be on 4G LTE or a Wi-Fi connection The device you\'re calling must also be video calling compatible Video calls use your high speed data You can also upgrade a voice call to a video call Check out <a>https://support.t-mobile.com/docs/DOC-23574</a> for more information.</string>
     <string name="video_call_welcome_message_repeat">Show this message every time</string>
+
+    <string name="toast_change_video_call_failed">Can not change to video call, incorrect number format</string>
+    <string name="toast_make_video_call_failed">Can not make video call, incorrect number format</string>
+    <!-- Add for enhance videocall ui -->
+    <string name="overflowBothCallMenuItemText">Video Call, show me</string>
+    <string name="overflowRXCallMenuItemText">Video Call, hide me</string>
+    <string name="overflowVOCallMenuItemText">Voice Call</string>
+    <string name="video_call">Video Calling</string>
+    <string name="call_data_info_label">Call/data Usage Timers</string>
+    <string name="call_data_info_description">Voice call usage time and data usage time</string>
+    <string name="alert_call_over_wifi">Calls will be made over Wi-Fi.</string>
+    <string name="alert_call_no_cellular_coverage">No cellular network available. Connect to available Wi-Fi to make calls.</string>
+    <string name="alert_user_connect_to_wifi_for_call">Connect to Wi-Fi to make calls.</string>
 </resources>
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 8bcabd8..8c4c4b4 100755
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -88,6 +88,7 @@
 import com.android.dialer.util.IntentUtil;
 import com.android.dialer.util.IntentUtil.CallIntentBuilder;
 import com.android.dialer.util.TelecomUtil;
+import com.android.dialer.util.WifiCallUtils;
 import com.android.dialer.voicemail.VoicemailArchiveActivity;
 import com.android.dialer.widget.ActionBarController;
 import com.android.dialer.widget.SearchEditTextLayout;
@@ -139,7 +140,7 @@
     /* Define for Activity permission request for reading phone state */
     private static final int PERMISSION_REQUEST_CODE_PHONE_STATE_ENABLED = 0;
     private static final int PERMISSION_REQUEST_CODE_PHONE_STATE_DISABLED = 1;
-
+    private static final int PERMISSION_REQUEST_CODE_LOCATION = 2;
     /**
      * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}.
      */
@@ -212,6 +213,7 @@
     private boolean mClearSearchOnPause;
     private boolean mIsDialpadShown;
     private boolean mShowDialpadOnResume;
+    private WifiCallUtils mWifiCallUtils;
 
     /**
      * Whether or not the device is in landscape orientation.
@@ -513,6 +515,22 @@
         Trace.beginSection(TAG + " initialize smart dialing");
         mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
         SmartDialPrefix.initializeNanpSettings(this);
+
+        mWifiCallUtils = new WifiCallUtils();
+        if (resources.getBoolean(R.bool.config_regional_pup_no_available_network)
+                && mFirstLaunch) {
+            mWifiCallUtils.addWifiCallReadyMarqueeMessage((Context) DialtactsActivity.this);
+            if (ActivityCompat.checkSelfPermission(DialtactsActivity.this,
+                        Manifest.permission.ACCESS_COARSE_LOCATION) !=
+                        PackageManager.PERMISSION_GRANTED) {
+                    requestPermissions(
+                            new String[] {Manifest.permission.ACCESS_COARSE_LOCATION},
+                            PERMISSION_REQUEST_CODE_LOCATION);
+            } else {
+                mWifiCallUtils.showWifiCallNotification((Context) DialtactsActivity.this);
+            }
+        }
+
         Trace.endSection();
         Trace.endSection();
 
@@ -1543,6 +1561,12 @@
                             && !isCurrentTabAllContacts) ? View.VISIBLE : View.GONE);
                 }
                 break;
+            case PERMISSION_REQUEST_CODE_LOCATION:
+                if (grantResults.length > 0 && grantResults[0] ==
+                        PackageManager.PERMISSION_GRANTED) {
+                    WifiCallUtils.showWifiCallNotification((Context) DialtactsActivity.this);
+                }
+                break;
             default:
                 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
         }
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index ea77722..d5f0035 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -29,18 +29,22 @@
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.PackageManager;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.media.AudioManager;
 import android.media.ToneGenerator;
+import android.Manifest;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Trace;
+import android.os.SystemProperties;
 import android.provider.Contacts.People;
 import android.provider.Contacts.Phones;
 import android.provider.Contacts.PhonesColumns;
 import android.provider.Settings;
+import android.support.v4.app.ActivityCompat;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
 import android.telephony.PhoneNumberUtils;
@@ -89,6 +93,7 @@
 import com.android.dialer.util.IntentUtil.CallIntentBuilder;
 import com.android.dialer.util.TelecomUtil;
 import com.android.incallui.Call.LogState;
+import com.android.dialer.util.WifiCallUtils;
 import com.android.phone.common.CallLogAsync;
 import com.android.phone.common.animation.AnimUtils;
 import com.android.phone.common.dialpad.DialpadKeyButton;
@@ -108,6 +113,8 @@
         DialpadKeyButton.OnPressedListener {
     private static final String TAG = "DialpadFragment";
 
+    /* define for Activity permission request for Android6.0 */
+    private static final int PERMISSION_REQUEST_CODE_LOCATION = 2;
     /**
      * LinearLayout with getter and setter methods for the translationY property using floats,
      * for animation purposes.
@@ -305,6 +312,15 @@
 
     private static final String PREF_DIGITS_FILLED_BY_INTENT = "pref_digits_filled_by_intent";
 
+    private static final String ACTION_WIFI_CALL_READY_STATUS_CHANGE
+        = "com.android.wificall.READY";
+    private static final String ACTION_WIFI_CALL_READY_EXTRA
+        = "com.android.wificall.ready.extra";
+    private static final String SYSTEM_PROPERTY_WIFI_CALL_READY
+        = "persist.sys.wificall.ready";
+    private BroadcastReceiver mWifiCallReadyReceiver;
+    private boolean isConfigAvailableNetwork = false;
+
     private TelephonyManager getTelephonyManager() {
         return (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
     }
@@ -356,6 +372,20 @@
         updateDeleteButtonEnabledState();
     }
 
+    private void changeDialpadButton(boolean ready) {
+        Log.d(TAG, "changeDialpadButton, ready = " + ready);
+        ImageView floatingActionButton =
+                (ImageButton) getView().findViewById(R.id.dialpad_floating_action_button);
+        if (floatingActionButton == null) {
+            return;
+        }
+        if (ready) {
+            floatingActionButton.setImageResource(R.drawable.fab_ic_wificall);
+        } else {
+            floatingActionButton.setImageResource(R.drawable.fab_ic_call);
+        }
+    }
+
     @Override
     public void onCreate(Bundle state) {
         Trace.beginSection(TAG + " onCreate");
@@ -380,6 +410,8 @@
             mCallStateReceiver = new CallStateReceiver();
             ((Context) getActivity()).registerReceiver(mCallStateReceiver, callStateIntentFilter);
         }
+        isConfigAvailableNetwork = getActivity().getResources().getBoolean(
+                R.bool.config_regional_pup_no_available_network);
         Trace.endSection();
     }
 
@@ -773,6 +805,20 @@
             mOperator.setVisibility(View.GONE);
         }
 
+        if (isConfigAvailableNetwork) {
+            Context context = getActivity();
+            mWifiCallReadyReceiver = new BroadcastReceiver() {
+                @Override
+                public void onReceive(Context context, Intent intent) {
+                    changeDialpadButton(
+                            intent.getBooleanExtra(ACTION_WIFI_CALL_READY_EXTRA, false));
+                }
+            };
+            IntentFilter filter = new IntentFilter(ACTION_WIFI_CALL_READY_STATUS_CHANGE);
+            context.registerReceiver(mWifiCallReadyReceiver, filter);
+            changeDialpadButton(
+                    SystemProperties.getBoolean(SYSTEM_PROPERTY_WIFI_CALL_READY, false));
+         }
         Trace.endSection();
     }
 
@@ -789,6 +835,10 @@
         mLastNumberDialed = EMPTY_NUMBER;  // Since we are going to query again, free stale number.
 
         SpecialCharSequenceMgr.cleanup();
+
+        if (isConfigAvailableNetwork) {
+            (getActivity()).unregisterReceiver(mWifiCallReadyReceiver);
+        }
     }
 
     @Override
@@ -1047,8 +1097,12 @@
     public void onClick(View view) {
         int resId = view.getId();
         if (resId == R.id.dialpad_floating_action_button) {
-            view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
-            handleDialButtonPressed();
+            if (isConfigAvailableNetwork) {
+                dialAfterNetworkCheck();
+            } else {
+                view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+                handleDialButtonPressed();
+            }
         } else if (resId == R.id.deleteButton) {
             keyPressed(KeyEvent.KEYCODE_DEL);
         } else if (resId == R.id.digits) {
@@ -1932,4 +1986,42 @@
                 .show();
     }
 
+    private void dialAfterNetworkCheck() {
+        if (ActivityCompat.checkSelfPermission(getContext(),
+                Manifest.permission.ACCESS_COARSE_LOCATION) !=
+            PackageManager.PERMISSION_GRANTED) {
+            requestPermissions(new String[] {Manifest.permission.ACCESS_COARSE_LOCATION},
+                    PERMISSION_REQUEST_CODE_LOCATION);
+        } else {
+            if(WifiCallUtils.shallShowWifiCallDialog(getActivity())) {
+                 WifiCallUtils.showWifiCallDialog(getActivity());
+             } else {
+                 getView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+                 handleDialButtonPressed();
+             }
+        }
+    }
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, String[] permissions,
+            int[] grantResults) {
+        switch (requestCode) {
+            case PERMISSION_REQUEST_CODE_LOCATION:
+                if ( grantResults.length > 0 && grantResults[0] ==
+                        PackageManager.PERMISSION_GRANTED) {
+                    if(WifiCallUtils.shallShowWifiCallDialog(getActivity())) {
+                        WifiCallUtils.showWifiCallDialog(getActivity());
+                    } else {
+                        getView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+                        handleDialButtonPressed();
+                    }
+                } else {
+                    getView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+                    handleDialButtonPressed();
+                }
+                break;
+            default:
+                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        }
+    }
 }
diff --git a/src/com/android/dialer/util/WifiCallUtils.java b/src/com/android/dialer/util/WifiCallUtils.java
new file mode 100644
index 0000000..fb143c8
--- /dev/null
+++ b/src/com/android/dialer/util/WifiCallUtils.java
@@ -0,0 +1,215 @@
+/*
+* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*     * Redistributions of source code must retain the above copyright
+*      notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above
+*       copyright notice, this list of conditions and the following
+*       disclaimer in the documentation and/or other materials provided
+*      with the distribution.
+*     * Neither the name of The Linux Foundation nor the names of its
+*      contributors may be used to endorse or promote products derived
+*       from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.android.dialer.util;
+
+import android.app.AlertDialog;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Handler;
+import android.os.SystemProperties;
+import android.telephony.CellInfo;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+import com.android.dialer.R;
+
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class WifiCallUtils {
+
+    private static final String TAG = WifiCallUtils.class.getSimpleName();
+    private static final int DELAYED_TIME = 5 * 1000;
+    private static final int NOTIFICATION_WIFI_CALL_ID = 1;
+    private WindowManager mWindowManager;
+    private TextView mTextView;
+    private boolean mViewRemoved = true;
+
+    private static final String SYSTEM_PROPERTY_WIFI_CALL_READY = "persist.sys.wificall.ready";
+    private static final String SYSTEM_PROPERTY_WIFI_CALL_TURNON = "persist.sys.wificall.turnon";
+
+    public void addWifiCallReadyMarqueeMessage(Context context) {
+        if (mViewRemoved && SystemProperties.getBoolean(SYSTEM_PROPERTY_WIFI_CALL_READY, false)) {
+            if (mWindowManager == null) mWindowManager =
+                (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+            if(mTextView == null){
+                mTextView = new TextView(context);
+                Log.d(TAG, "mTextView is null, new mTextView = " + mTextView);
+                mTextView.setText(
+                        com.android.dialer.R.string.alert_call_over_wifi);
+                mTextView.setSingleLine(true);
+                mTextView.setEllipsize(android.text.TextUtils.TruncateAt.MARQUEE);
+                mTextView.setMarqueeRepeatLimit(-1);
+                mTextView.setFocusableInTouchMode(true);
+            } else {
+                Log.d(TAG, "mTextView is not null, mTextView = " + mTextView);
+            }
+
+            WindowManager.LayoutParams windowParam = new WindowManager.LayoutParams();
+            windowParam.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+            windowParam.format= 1;
+            windowParam.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
+            windowParam.alpha = 1.0f;
+            windowParam.x = 0;
+            windowParam.y = -500;
+            windowParam.height = WindowManager.LayoutParams.WRAP_CONTENT;
+            windowParam.width = (mWindowManager.getDefaultDisplay().getWidth()
+                    < mWindowManager.getDefaultDisplay().getHeight()
+                    ? mWindowManager.getDefaultDisplay().getWidth()
+                    : mWindowManager.getDefaultDisplay().getHeight()) - 64;
+            mWindowManager.addView(mTextView, windowParam);
+            mViewRemoved = false;
+            Log.d(TAG, "addWifiCallReadyMarqueeMessage, mWindowManager:" + mWindowManager
+                    + " addView, mTextView:" + mTextView
+                    + " addWifiCallReadyMarqueeMessage, mViewRemoved = " + mViewRemoved);
+
+            scheduleRemoveWifiCallReadyMarqueeMessageTimer();
+        }
+    }
+
+    public void removeWifiCallReadyMarqueeMessage() {
+        if (!mViewRemoved) {
+            mWindowManager.removeView(mTextView);
+            mViewRemoved = true;
+            Log.d(TAG, "removeWifiCallReadyMarqueeMessage, mWindowManager:" + mWindowManager
+                    + " removeView, mTextView:" + mTextView
+                    + " removeWifiCallReadyMarqueeMessage, mViewRemoved = " + mViewRemoved);
+        }
+    }
+
+    private void scheduleRemoveWifiCallReadyMarqueeMessageTimer() {
+        // Schedule a timer, 5s later, remove the message
+        new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    Log.d(TAG, "Handler is running");
+                    removeWifiCallReadyMarqueeMessage();
+                }
+        }, DELAYED_TIME);
+        Log.d(TAG, "schedule timerTask");
+    }
+
+    private static boolean isCellularNetworkAvailable(Context context) {
+        boolean available = false;
+
+        TelephonyManager tm = (TelephonyManager) context.
+                getSystemService(Context.TELEPHONY_SERVICE);
+        List<CellInfo> cellInfoList = tm.getAllCellInfo();
+
+        if (cellInfoList != null) {
+            for (CellInfo cellinfo : cellInfoList) {
+                if (cellinfo.isRegistered()) {
+                    available = true;
+                }
+            }
+        }
+
+        return available;
+    }
+
+    public static void showWifiCallDialog(final Context context) {
+        String promptMessage = context.getString(com.android.dialer.R.string
+                .alert_call_no_cellular_coverage) +"\n"+ context.getString(com.android.dialer.R
+                        .string.alert_user_connect_to_wifi_for_call);
+        AlertDialog.Builder diaBuilder = new AlertDialog.Builder(context);
+        diaBuilder.setMessage(promptMessage);
+        diaBuilder.setPositiveButton(com.android.internal.R.string.ok, new OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                Intent intent = new Intent(Intent.ACTION_MAIN);
+                intent.setClassName("com.qualcomm.qti.extsettings",
+                        "com.qualcomm.qti.extsettings.wificall.WifiCallingEnhancedSettings");
+                context.startActivity(intent);
+            }
+        });
+        diaBuilder.setOnCancelListener(new OnCancelListener() {
+            @Override
+            public void onCancel(DialogInterface dialog) {
+            }
+        });
+        diaBuilder.create().show();
+    }
+
+    public static boolean shallShowWifiCallDialog(final Context context) {
+        boolean wifiCallTurnOn = SystemProperties.getBoolean(
+                SYSTEM_PROPERTY_WIFI_CALL_TURNON, false);
+
+        ConnectivityManager conManager = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        NetworkInfo wifiNetworkInfo = conManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+        boolean wifiAvailableNotConnected =
+                wifiNetworkInfo.isAvailable() && !wifiNetworkInfo.isConnected();
+
+        return wifiCallTurnOn && wifiAvailableNotConnected && !isCellularNetworkAvailable(context);
+    }
+
+    public static void showWifiCallNotification(final Context context) {
+        if (shallShowWifiCallDialog(context)) {
+            final NotificationManager notiManager =
+                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+            Intent intent = new Intent();
+            intent.setAction(android.provider.Settings.ACTION_WIFI_SETTINGS);
+            PendingIntent pendingIntent =
+                    PendingIntent.getActivity(
+                            context, NOTIFICATION_WIFI_CALL_ID,
+                            intent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+            Notification.Builder builder = new Notification.Builder(context);
+            builder.setOngoing(false);
+            builder.setWhen(0);
+            builder.setContentIntent(pendingIntent);
+            builder.setAutoCancel(true);
+            builder.setSmallIcon(R.drawable.wifi_calling_on_notification);
+            builder.setContentTitle(
+                    context.getResources().getString(R.string.alert_user_connect_to_wifi_for_call));
+            builder.setContentText(
+                    context.getResources().getString(R.string.alert_user_connect_to_wifi_for_call));
+            notiManager.notify(NOTIFICATION_WIFI_CALL_ID, builder.build());
+            new Handler().postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        notiManager.cancel(NOTIFICATION_WIFI_CALL_ID);
+                    }
+           }, 2000);
+        }
+    }
+}