Send PhoneAccountHandle with ACTION_CONFIGURE_VOICEMAIL

When opening a voicemail setting from Dialer with
ACTION_CONFIGURE_VOICEMAIL, no subId is passed.
So on a multi-SIM device, it is always configuration on the default
phone regardless of SIM.

To solve this, set the PhoneAccountHandle to intent extra for
ACTION_CONFIGURE_VOICEMAIL. In the advanced settings, obtains subId
from the PhoneAccountHandle.

Test: manual - Checked that correct PhoneAccountHandle will be passed
with ACTION_CONFIGURE_VOICEMAIL intent
Bug: 65001008

Change-Id: I6729c4f792849f9a8c89b9e05ca3cf07e618f11f
diff --git a/src/com/android/phone/settings/VoicemailSettingsActivity.java b/src/com/android/phone/settings/VoicemailSettingsActivity.java
index 4d55421..74b8e4e 100644
--- a/src/com/android/phone/settings/VoicemailSettingsActivity.java
+++ b/src/com/android/phone/settings/VoicemailSettingsActivity.java
@@ -32,6 +32,7 @@
 import android.preference.SwitchPreference;
 import android.provider.ContactsContract.CommonDataKinds;
 import android.provider.Settings;
+import android.telecom.PhoneAccountHandle;
 import android.telephony.CarrierConfigManager;
 import android.telephony.TelephonyManager;
 import android.text.BidiFormatter;
@@ -48,6 +49,7 @@
 import com.android.internal.telephony.util.NotificationChannelController;
 import com.android.phone.EditPhoneNumberPreference;
 import com.android.phone.PhoneGlobals;
+import com.android.phone.PhoneUtils;
 import com.android.phone.R;
 import com.android.phone.SubscriptionInfoHelper;
 
@@ -222,6 +224,12 @@
         mShowVoicemailPreference = (icicle == null) &&
                 TextUtils.equals(getIntent().getAction(), ACTION_ADD_VOICEMAIL);
 
+        PhoneAccountHandle phoneAccountHandle = (PhoneAccountHandle)
+                getIntent().getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE);
+        if (phoneAccountHandle != null) {
+            getIntent().putExtra(SubscriptionInfoHelper.SUB_ID_EXTRA,
+                    PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle));
+        }
         mSubscriptionInfoHelper = new SubscriptionInfoHelper(this, getIntent());
         mSubscriptionInfoHelper.setActionBarTitle(
                 getActionBar(), getResources(), R.string.voicemail_settings_with_label);