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

Commit f7ba9911 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Fix save contact to wrong sim card"

parents 487fae9c cf2849c8
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;
            }
        }