CallSettings: Requirement for modifying call settings submenu.

Enables/Diables call settings options based on carrier.

Change-Id: I841aed53a4eb6c22c51dfd7fa4f6da7ac70106e6
CRs-Fixed: 1080125
diff --git a/res/values/qtistrings.xml b/res/values/qtistrings.xml
index a11e5e5..73fbf5c 100644
--- a/res/values/qtistrings.xml
+++ b/res/values/qtistrings.xml
@@ -32,4 +32,7 @@
     <!-- OEM Key strings -->
     <string name="oem_key_code_action"></string>
     <string name="oem_code"></string>
+
+    <!-- Call Settings -->
+    <string name="call_settings_lbl">Call Settings</string>
 </resources>
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index 303c73a..3c6c66c 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -39,10 +39,12 @@
 
 import java.util.List;
 
+import org.codeaurora.ims.utils.QtiImsExtUtils;
+
 public class DialerSettingsActivity extends AppCompatPreferenceActivity {
     protected SharedPreferences mPreferences;
     private boolean migrationStatusOnBuildHeaders;
-
+    private final String ACTION_LAUNCH_CALL_SETTINGS = "org.codeaurora.CALL_SETTINGS";
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -85,13 +87,15 @@
             target.add(quickResponseSettingsHeader);
         }
 
-        Header speedDialSettingsHeader = new Header();
-        Intent speedDialSettingsIntent = new Intent(this, SpeedDialListActivity.class);
-        speedDialSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        if (!QtiImsExtUtils.isCarrierOneSupported()) {
+            Header speedDialSettingsHeader = new Header();
+            Intent speedDialSettingsIntent = new Intent(this, SpeedDialListActivity.class);
+            speedDialSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
-        speedDialSettingsHeader.titleRes = R.string.speed_dial_settings;
-        speedDialSettingsHeader.intent = speedDialSettingsIntent;
-        target.add(speedDialSettingsHeader);
+            speedDialSettingsHeader.titleRes = R.string.speed_dial_settings;
+            speedDialSettingsHeader.intent = speedDialSettingsIntent;
+            target.add(speedDialSettingsHeader);
+        }
 
         TelephonyManager telephonyManager =
                 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
@@ -101,25 +105,38 @@
         // primary user and there are multiple SIMs. In N+, "Calling accounts" is shown whenever
         // "Call Settings" is not shown.
         boolean isPrimaryUser = isPrimaryUser();
-        if (isPrimaryUser
-                && TelephonyManagerCompat.getPhoneCount(telephonyManager) <= 1) {
-            Header callSettingsHeader = new Header();
-            Intent callSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS);
-            callSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
-            callSettingsHeader.titleRes = R.string.call_settings_label;
-            callSettingsHeader.intent = callSettingsIntent;
-            target.add(callSettingsHeader);
-        } else if (BuildCompat.isAtLeastN() || isPrimaryUser) {
-            Header phoneAccountSettingsHeader = new Header();
-            Intent phoneAccountSettingsIntent =
-                    new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
-            phoneAccountSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        if (QtiImsExtUtils.isCarrierOneSupported()) {
+            if (isPrimaryUser) {
+                Header callSettingsHeader =  new Header();
+                Intent callSettingsIntent = new Intent(ACTION_LAUNCH_CALL_SETTINGS);
+                callSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
-            phoneAccountSettingsHeader.titleRes = R.string.phone_account_settings_label;
-            phoneAccountSettingsHeader.intent = phoneAccountSettingsIntent;
-            target.add(phoneAccountSettingsHeader);
-        }
+                callSettingsHeader.titleRes = R.string.call_settings_lbl;
+                callSettingsHeader.intent = callSettingsIntent;
+                target.add(callSettingsHeader);
+           }
+        } else {
+            if (isPrimaryUser
+                    && TelephonyManagerCompat.getPhoneCount(telephonyManager) <= 1) {
+                Header callSettingsHeader = new Header();
+                Intent callSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS);
+                callSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+
+                callSettingsHeader.titleRes = R.string.call_settings_label;
+                callSettingsHeader.intent = callSettingsIntent;
+                target.add(callSettingsHeader);
+            } else if (BuildCompat.isAtLeastN() || isPrimaryUser) {
+                Header phoneAccountSettingsHeader = new Header();
+                Intent phoneAccountSettingsIntent =
+                        new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
+                phoneAccountSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+
+                phoneAccountSettingsHeader.titleRes = R.string.phone_account_settings_label;
+                phoneAccountSettingsHeader.intent = phoneAccountSettingsIntent;
+                target.add(phoneAccountSettingsHeader);
+            }
+       }
         if (FilteredNumberCompat.canCurrentUserOpenBlockSettings(this)) {
             Header blockedCallsHeader = new Header();
             blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label;
diff --git a/src/com/android/dialer/settings/SoundSettingsFragment.java b/src/com/android/dialer/settings/SoundSettingsFragment.java
index 59f8798..3736512 100644
--- a/src/com/android/dialer/settings/SoundSettingsFragment.java
+++ b/src/com/android/dialer/settings/SoundSettingsFragment.java
@@ -38,6 +38,8 @@
 import com.android.dialer.compat.SettingsCompat;
 import com.android.phone.common.util.SettingsUtil;
 
+import org.codeaurora.ims.utils.QtiImsExtUtils;
+
 public class SoundSettingsFragment extends PreferenceFragment
         implements Preference.OnPreferenceChangeListener {
 
@@ -140,8 +142,16 @@
             mVibrateWhenRinging.setChecked(shouldVibrateWhenRinging());
         }
 
+        if (QtiImsExtUtils.isCarrierOneSupported()) {
+            getPreferenceScreen().removePreference(mRingtonePreference);
+            mRingtonePreference = null;
+        }
+
+
         // Lookup the ringtone name asynchronously.
-        new Thread(mRingtoneLookupRunnable).start();
+        if (mRingtonePreference != null) {
+           new Thread(mRingtoneLookupRunnable).start();
+        }
     }
 
     /**
@@ -197,12 +207,14 @@
      * Updates the summary text on the ringtone preference with the name of the ringtone.
      */
     private void updateRingtonePreferenceSummary() {
-        SettingsUtil.updateRingtoneName(
-                getActivity(),
-                mRingtoneLookupComplete,
-                RingtoneManager.TYPE_RINGTONE,
-                mRingtonePreference.getKey(),
-                MSG_UPDATE_RINGTONE_SUMMARY);
+        if (mRingtonePreference != null) {
+            SettingsUtil.updateRingtoneName(
+                    getActivity(),
+                    mRingtoneLookupComplete,
+                    RingtoneManager.TYPE_RINGTONE,
+                    mRingtonePreference.getKey(),
+                    MSG_UPDATE_RINGTONE_SUMMARY);
+       }
     }
 
     /**