Make CDMA Call Options UT aware

Introduce the ability for CDMA call options to detect when SS
over UT becomes available or unavailable and integrate the SS
over CDMA fallback carrier config for situations where SS over
UT becomes unavailable.

1) In the case where SS over CDMA is configured, never disable the
supp service settings, because there will always be an avenue to
set the settings.
2) In the  case where SS over UT is available, but SS over CDMA is
not, take into account the availability of SS over UT when the
settings are loaded and enable/disable the preference based on that
state. If the device moves from SS over UT capable -> unavailable
during this time, the setting will be disabled. If it happens while
a pending request is already being serviced, the framework will
throw an exception causing the UX to handle this and show an error
as well as gray out the Preference.
3) in the case that neither SS over CDMA or UT is available, just
gray out the settings that require either one be available.

Bug: 191057045
Test: manual
Change-Id: Ie03cce86da911571f3b3b6c3563a2882861818d2
diff --git a/src/com/android/phone/CdmaCallWaitingPreference.java b/src/com/android/phone/CdmaCallWaitingPreference.java
index 4cda7ba..3713b19 100644
--- a/src/com/android/phone/CdmaCallWaitingPreference.java
+++ b/src/com/android/phone/CdmaCallWaitingPreference.java
@@ -16,32 +16,29 @@
 
 package com.android.phone;
 
-import com.android.internal.telephony.CommandException;
-import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.Phone;
-
 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.res.TypedArray;
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
 import android.preference.Preference;
-import android.preference.PreferenceActivity;
 import android.util.AttributeSet;
 import android.util.Log;
 
+import com.android.internal.telephony.CommandException;
+import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.Phone;
+
 public class CdmaCallWaitingPreference extends Preference {
     private static final String LOG_TAG = "CdmaCallWaitingPreference";
     private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
 
-    private int mButtonClicked;
     private Context mContext;
     private Phone mPhone;
-    private SubscriptionInfoHelper mSubscriptionInfoHelper;
     private TimeConsumingPreferenceListener mTcpListener;
     private MyHandler mHandler = new MyHandler();
+    private boolean mIsActionAvailable = true;
 
     public CdmaCallWaitingPreference(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
@@ -67,6 +64,16 @@
         }
     }
 
+    /**
+     * Enables this preference if Call waiting is available in the platform. If not, this will
+     * override all attempts to enable the preference from the associated
+     * TimeConsumingPreferenceActivity.
+     */
+    public void setActionAvailable(boolean isAvailable) {
+        mIsActionAvailable = isAvailable;
+        super.setEnabled(mIsActionAvailable);
+    }
+
     @Override
     public void onClick() {
         super.onClick();
@@ -95,6 +102,14 @@
         builder.create().show();
     }
 
+    @Override
+    public void setEnabled(boolean enabled) {
+        // If this action is currently disabled due to configuration changes, do not allow anything
+        // to enable it.
+        if (!mIsActionAvailable) return;
+        super.setEnabled(enabled);
+    }
+
     private class MyHandler extends Handler {
         static final int MESSAGE_GET_CALL_WAITING = 0;
         static final int MESSAGE_SET_CALL_WAITING = 1;