Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf2849c8 authored by blong's avatar blong Committed by Gerrit - the friendly Code Review server
Browse files

Fix save contact to wrong sim card

- If the sim is not exist, return false to instead of use default
  sim,because it will cause unexpect result

Change-Id: I168f4fa835098d3e9d51f9d92f98d22f10ee8bbc
CRs-Fixed: 1063248
parent 41155c12
Loading
Loading
Loading
Loading
+21 −32
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import org.codeaurora.wrapper.UiccPhoneBookController_Wrapper;

/**
 * A service responsible for saving changes to the content provider.
 */
@@ -707,8 +709,6 @@ public class ContactSaveService extends IntentService {

        if (entity.isContactInsert()) {
            int count = 0;
                Cursor c = null;
                Uri iccUri;
            SubscriptionInfo subInfoRecord = null;
            try {
                subInfoRecord = mSubscriptionManager
@@ -717,24 +717,13 @@ public class ContactSaveService extends IntentService {
                Log.w(TAG, "SecurityException thrown, lack permission for"
                        + " getActiveSubscriptionInfoList", e);
            }
                if (subInfoRecord == null) {
                    iccUri = Uri.parse(SimContactsConstants.SIM_URI);
                } else {
                    iccUri = Uri.parse(SimContactsConstants.SIM_SUB_URI
                            + subInfoRecord.getSubscriptionId());
            if (subInfoRecord != null) {
                int[] adnCount = UiccPhoneBookController_Wrapper
                        .getAdnRecordsCapacityForSubscriber(subInfoRecord.getSubscriptionId());
                if(adnCount!=null)
                    count= adnCount[MoreContactUtils.ADN_USED_POS];
            }
                try {
                    c = resolver.query(iccUri, null, null, null, null);
                    if (c != null) {
                        count = c.getCount();
                    }
                } finally {
                    if (c != null) {
                        c.close();
                    }
                }

                if (count == MoreContactUtils.getAdnCount(this, subscription)) {
            if (count >0 && count == MoreContactUtils.getAdnCount(this, subscription)) {
                return RESULT_SIM_FULL_FAILURE;
            }
        }