FP2-617: The preferred SIM setting can not be saved after reboot at Airplane mode

When there is no SIM card or only one SIM card inserted, there is no Preferred SIM option,
and the Preferred SIM is set as the Inserted SIM card automatically.
The call and SMS will be sent out with the inserted card automatically.

	modified:   src/com/android/server/telecom/PhoneAccountRegistrar.java

Change-Id: Ide59d334b7bec19ed954ed52d6f4b4aa8acf0595
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java
index 9fc1cd9..c67ba6a 100755
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java
@@ -69,6 +69,8 @@
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.CopyOnWriteArrayList;
+import android.telephony.SubscriptionInfo;
+
 
 /**
  * Handles writing and reading PhoneAccountHandle registration entries. This is a simple verbatim
@@ -252,6 +254,11 @@
             mState.defaultOutgoing = null;
         } else {
             boolean found = false;
+            List<SubscriptionInfo> mSubInfoList = null;
+
+            if (mSubInfoList == null) {
+                mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
+            }
             for (PhoneAccount m : mState.accounts) {
                 if (Objects.equals(accountHandle, m.getAccountHandle())) {
                     found = true;
@@ -277,7 +284,19 @@
                 // If the account selected is a SIM account, propagate down to the subscription
                 // record.
                 int subId = getSubscriptionIdForPhoneAccount(accountHandle);
-                mSubscriptionManager.setDefaultVoiceSubId(subId);
+                int simSlotIndex =0;
+
+		 if (mSubInfoList != null) {
+                    final int availableSubInfoLength = mSubInfoList.size();
+
+                    for (int i = 0; i < availableSubInfoLength; ++i) {
+                        final SubscriptionInfo sir = mSubInfoList.get(i);
+                        if (sir.getSubscriptionId() == subId) {
+                            simSlotIndex = sir.getSimSlotIndex();
+                        }
+                    }
+                }
+                mSubscriptionManager.setDefaultVoiceSubId(simSlotIndex+1);
             }
 
             mState.defaultOutgoing = accountHandle;