Merge "Fix order of voicemail ringtone initialization." into lmp-mr1-dev
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index de57fbc..9956397 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -1412,8 +1412,9 @@
      * Finish current Activity and go up to the top level Settings ({@link CallFeaturesSetting}).
      * This is useful for implementing "HomeAsUp" capability for second-level Settings.
      */
-    public static void goUpToTopLevelSetting(Activity activity) {
-        Intent intent = new Intent(activity, CallFeaturesSetting.class);
+    public static void goUpToTopLevelSetting(
+                Activity activity, SubscriptionInfoHelper subscriptionInfoHelper) {
+        Intent intent = subscriptionInfoHelper.getIntent(activity, CallFeaturesSetting.class);
         intent.setAction(Intent.ACTION_MAIN);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         activity.startActivity(intent);
diff --git a/src/com/android/phone/CallForwardEditPreference.java b/src/com/android/phone/CallForwardEditPreference.java
index b176c27..8d29c84 100644
--- a/src/com/android/phone/CallForwardEditPreference.java
+++ b/src/com/android/phone/CallForwardEditPreference.java
@@ -18,6 +18,7 @@
 import android.view.View;
 
 import static com.android.phone.TimeConsumingPreferenceActivity.RESPONSE_ERROR;
+import static com.android.phone.TimeConsumingPreferenceActivity.EXCEPTION_ERROR;
 
 public class CallForwardEditPreference extends EditPhoneNumberPreference {
     private static final String LOG_TAG = "CallForwardEditPreference";
@@ -191,8 +192,16 @@
             callForwardInfo = null;
             if (ar.exception != null) {
                 if (DBG) Log.d(LOG_TAG, "handleGetCFResponse: ar.exception=" + ar.exception);
-                mTcpListener.onException(CallForwardEditPreference.this,
-                        (CommandException) ar.exception);
+                if (ar.exception instanceof CommandException) {
+                    mTcpListener.onException(CallForwardEditPreference.this,
+                            (CommandException) ar.exception);
+                } else {
+                    // Most likely an ImsException and we can't handle it the same way as
+                    // a CommandException. The best we can do is to handle the exception
+                    // the same way as mTcpListener.onException() does when it is not of type
+                    // FDN_CHECK_FAILURE.
+                    mTcpListener.onError(CallForwardEditPreference.this, EXCEPTION_ERROR);
+                }
             } else {
                 if (ar.userObj instanceof Throwable) {
                     mTcpListener.onError(CallForwardEditPreference.this, RESPONSE_ERROR);
diff --git a/src/com/android/phone/GsmUmtsAdditionalCallOptions.java b/src/com/android/phone/GsmUmtsAdditionalCallOptions.java
index 0540547..30ce1fa 100644
--- a/src/com/android/phone/GsmUmtsAdditionalCallOptions.java
+++ b/src/com/android/phone/GsmUmtsAdditionalCallOptions.java
@@ -25,6 +25,7 @@
     private final ArrayList<Preference> mPreferences = new ArrayList<Preference>();
     private int mInitIndex = 0;
     private Phone mPhone;
+    private SubscriptionInfoHelper mSubscriptionInfoHelper;
 
     @Override
     protected void onCreate(Bundle icicle) {
@@ -32,10 +33,10 @@
 
         addPreferencesFromResource(R.xml.gsm_umts_additional_options);
 
-        SubscriptionInfoHelper subscriptionInfoHelper = new SubscriptionInfoHelper(getIntent());
-        subscriptionInfoHelper.setActionBarTitle(
+        mSubscriptionInfoHelper = new SubscriptionInfoHelper(getIntent());
+        mSubscriptionInfoHelper.setActionBarTitle(
                 getActionBar(), getResources(), R.string.additional_gsm_call_settings_with_label);
-        mPhone = subscriptionInfoHelper.getPhone();
+        mPhone = mSubscriptionInfoHelper.getPhone();
 
         PreferenceScreen prefSet = getPreferenceScreen();
         mCLIRButton = (CLIRListPreference) prefSet.findPreference(BUTTON_CLIR_KEY);
@@ -94,7 +95,7 @@
     public boolean onOptionsItemSelected(MenuItem item) {
         final int itemId = item.getItemId();
         if (itemId == android.R.id.home) {  // See ActionBar#setDisplayHomeAsUpEnabled()
-            CallFeaturesSetting.goUpToTopLevelSetting(this);
+            CallFeaturesSetting.goUpToTopLevelSetting(this, mSubscriptionInfoHelper);
             return true;
         }
         return super.onOptionsItemSelected(item);
diff --git a/src/com/android/phone/GsmUmtsCallForwardOptions.java b/src/com/android/phone/GsmUmtsCallForwardOptions.java
index 3c4bebe..fe27850 100644
--- a/src/com/android/phone/GsmUmtsCallForwardOptions.java
+++ b/src/com/android/phone/GsmUmtsCallForwardOptions.java
@@ -45,6 +45,7 @@
     private boolean mFirstResume;
     private Bundle mIcicle;
     private Phone mPhone;
+    private SubscriptionInfoHelper mSubscriptionInfoHelper;
 
     @Override
     protected void onCreate(Bundle icicle) {
@@ -52,10 +53,10 @@
 
         addPreferencesFromResource(R.xml.callforward_options);
 
-        SubscriptionInfoHelper subscriptionInfoHelper = new SubscriptionInfoHelper(getIntent());
-        subscriptionInfoHelper.setActionBarTitle(
+        mSubscriptionInfoHelper = new SubscriptionInfoHelper(getIntent());
+        mSubscriptionInfoHelper.setActionBarTitle(
                 getActionBar(), getResources(), R.string.call_forwarding_settings_with_label);
-        mPhone = subscriptionInfoHelper.getPhone();
+        mPhone = mSubscriptionInfoHelper.getPhone();
 
         PreferenceScreen prefSet = getPreferenceScreen();
         mButtonCFU = (CallForwardEditPreference) prefSet.findPreference(BUTTON_CFU_KEY);
@@ -181,7 +182,7 @@
     public boolean onOptionsItemSelected(MenuItem item) {
         final int itemId = item.getItemId();
         if (itemId == android.R.id.home) {  // See ActionBar#setDisplayHomeAsUpEnabled()
-            CallFeaturesSetting.goUpToTopLevelSetting(this);
+            CallFeaturesSetting.goUpToTopLevelSetting(this, mSubscriptionInfoHelper);
             return true;
         }
         return super.onOptionsItemSelected(item);
diff --git a/src/com/android/phone/settings/fdn/FdnSetting.java b/src/com/android/phone/settings/fdn/FdnSetting.java
index 8716d37..acbe0b8 100644
--- a/src/com/android/phone/settings/fdn/FdnSetting.java
+++ b/src/com/android/phone/settings/fdn/FdnSetting.java
@@ -521,7 +521,7 @@
     public boolean onOptionsItemSelected(MenuItem item) {
         final int itemId = item.getItemId();
         if (itemId == android.R.id.home) {  // See ActionBar#setDisplayHomeAsUpEnabled()
-            CallFeaturesSetting.goUpToTopLevelSetting(this);
+            CallFeaturesSetting.goUpToTopLevelSetting(this, mSubscriptionInfoHelper);
             return true;
         }
         return super.onOptionsItemSelected(item);