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

Commit 7b8f6cdf authored by Jayachandran C's avatar Jayachandran C Committed by Automerger Merge Worker
Browse files

Merge changes from topic "cts-simpb" am: 399ee834 am: b23a485f

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1981027

Change-Id: I3f7eaa6e416680aebee75b3e3a652738b6fd7778
parents 43021169 b23a485f
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -166,10 +166,6 @@ public class IccPhoneBookInterfaceManager {
        return new AdnRecord(oldTag, oldPhoneNumber, oldEmailArray, oldAnrArray);
    }

    private AdnRecord generateAdnRecordWithNewTagByContentValues(ContentValues values) {
        return generateAdnRecordWithNewTagByContentValues(0, 0, values);
    }

    private AdnRecord generateAdnRecordWithNewTagByContentValues(
            int efId, int recordNumber, ContentValues values) {
        if (values == null) {
@@ -219,12 +215,14 @@ public class IccPhoneBookInterfaceManager {
        synchronized (updateRequest) {
            Message response = mBaseHandler.obtainMessage(EVENT_UPDATE_DONE, updateRequest);
            AdnRecord oldAdn = generateAdnRecordWithOldTagByContentValues(values);
            AdnRecord newAdn = generateAdnRecordWithNewTagByContentValues(values);
            if (usesPbCache(efid)) {
                AdnRecord newAdn =
                        generateAdnRecordWithNewTagByContentValues(IccConstants.EF_ADN, 0, values);
                mSimPbRecordCache.updateSimPbAdnBySearch(oldAdn, newAdn, response);
                waitForResult(updateRequest);
                return (boolean) updateRequest.mResult;
            } else {
                AdnRecord newAdn = generateAdnRecordWithNewTagByContentValues(efid, 0, values);
                if (mAdnCache != null) {
                    mAdnCache.updateAdnBySearch(efid, oldAdn, newAdn, pin2, response);
                    waitForResult(updateRequest);
@@ -272,12 +270,15 @@ public class IccPhoneBookInterfaceManager {
        Request updateRequest = new Request();
        synchronized (updateRequest) {
            Message response = mBaseHandler.obtainMessage(EVENT_UPDATE_DONE, updateRequest);
            AdnRecord newAdn = generateAdnRecordWithNewTagByContentValues(efid, index, values);
            if (usesPbCache(efid)) {
                AdnRecord newAdn =
                        generateAdnRecordWithNewTagByContentValues(IccConstants.EF_ADN,
                        index, values);
                mSimPbRecordCache.updateSimPbAdnByRecordId(index, newAdn, response);
                waitForResult(updateRequest);
                return (boolean) updateRequest.mResult;
            } else {
                AdnRecord newAdn = generateAdnRecordWithNewTagByContentValues(efid, index, values);
                if (mAdnCache != null) {
                    mAdnCache.updateAdnByIndex(efid, newAdn, index, pin2, response);
                    waitForResult(updateRequest);
+6 −41
Original line number Diff line number Diff line
@@ -4370,21 +4370,10 @@ public class RILUtils {
     */
    public static android.hardware.radio.V1_6.PhonebookRecordInfo convertToHalPhonebookRecordInfo(
            SimPhonebookRecord record) {
        android.hardware.radio.V1_6.PhonebookRecordInfo pbRecordInfo =
                new android.hardware.radio.V1_6.PhonebookRecordInfo();
        pbRecordInfo.recordId = record.getRecordIndex();
        pbRecordInfo.name = convertNullToEmptyString(record.getAlphaTag());
        pbRecordInfo.number = convertNullToEmptyString(
                convertToHalPhonebookRecordInfoNumber(record.getNumber()));
        if (record.getEmails() != null) {
            pbRecordInfo.emails = primitiveArrayToArrayList(record.getEmails());
        if(record != null) {
            return record.toPhonebookRecordInfo();
        }
        if (record.getAdditionalNumbers() != null) {
            for (String addNum : record.getAdditionalNumbers()) {
                pbRecordInfo.additionalNumbers.add(convertToHalPhonebookRecordInfoNumber(addNum));
            }
        }
        return pbRecordInfo;
        return null;
    }

    /**
@@ -4394,34 +4383,10 @@ public class RILUtils {
     */
    public static android.hardware.radio.sim.PhonebookRecordInfo
            convertToHalPhonebookRecordInfoAidl(SimPhonebookRecord record) {
        android.hardware.radio.sim.PhonebookRecordInfo pbRecordInfo =
                new android.hardware.radio.sim.PhonebookRecordInfo();
        pbRecordInfo.recordId = record.getRecordIndex();
        pbRecordInfo.name = convertNullToEmptyString(record.getAlphaTag());
        pbRecordInfo.number = convertNullToEmptyString(
                convertToHalPhonebookRecordInfoNumber(record.getNumber()));
        pbRecordInfo.emails = record.getEmails();
        if (record.getAdditionalNumbers() != null) {
            String[] additionalNumbers = new String[record.getAdditionalNumbers().length];
            for (int i = 0; i < additionalNumbers.length; i++) {
                additionalNumbers[i] =
                        convertToHalPhonebookRecordInfoNumber(record.getAdditionalNumbers()[i]);
            }
            pbRecordInfo.additionalNumbers = additionalNumbers;
        }
        return pbRecordInfo;
        if(record != null) {
            return record.toPhonebookRecordInfoAidl();
        }

    /**
     * Convert the GSM pause/wild/wait character to the phone number in the SIM PhonebookRecordInfo
     * number format
     * @param input GSM pause/wild/wait character
     * @return The converted PhonebookRecordInfo number
     */
    private static String convertToHalPhonebookRecordInfoNumber(String input) {
        return input == null ? null : input.replace(PhoneNumberUtils.WAIT, 'e')
                .replace(PhoneNumberUtils.PAUSE, 'T')
                .replace(PhoneNumberUtils.WILD, '?');
        return null;
    }

    /**
+12 −0
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@ public class AdnCapacity implements Parcelable {
        mMaxAnrLength = maxAnrLength;
    }

    public AdnCapacity() {
        this(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    public int getMaxAdnCount() {
        return mMaxAdnCount;
    }
@@ -98,6 +102,14 @@ public class AdnCapacity implements Parcelable {
        return mMaxAdnCount == mUsedAdnCount;
    }

    public boolean isSimEmpty() {
        return mUsedAdnCount == 0;
    }

    public boolean isSimValid() {
        return mMaxAdnCount > 0;
    }

    public static final Parcelable.Creator<AdnCapacity> CREATOR
            = new Parcelable.Creator<AdnCapacity>() {
        @Override
+99 −17
Original line number Diff line number Diff line
@@ -16,12 +16,14 @@

package com.android.internal.telephony.uicc;

import android.hardware.radio.V1_6.PhonebookRecordInfo;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;

import com.android.internal.telephony.util.ArrayUtils;

import java.util.Arrays;
import java.util.ArrayList;

/**
 * Represents a Phonebook entry from the SIM.
@@ -30,15 +32,16 @@ import java.util.Arrays;
 */
public class SimPhonebookRecord {
    // Instance variables
    private int mRecordIndex = 0;
    private int mRecordId = 0;
    private String mAlphaTag;
    private String mNumber;
    private String[] mEmails;
    private String[] mAdditionalNumbers;

    public SimPhonebookRecord (int recordIndex, String alphaTag, String number,
    // Instance methods
    public SimPhonebookRecord (int recordId, String alphaTag, String number,
               String[] emails, String[] adNumbers) {
        mRecordIndex = recordIndex;
        mRecordId = recordId;
        mAlphaTag = alphaTag;
        mNumber = convertRecordFormatToNumber(number);
        mEmails = emails;
@@ -50,8 +53,58 @@ public class SimPhonebookRecord {
        }
    }

    public int getRecordIndex() {
        return mRecordIndex;
    public SimPhonebookRecord(PhonebookRecordInfo recInfo) {
        if (recInfo != null) {
            mRecordId = recInfo.recordId;
            mAlphaTag = recInfo.name;
            mNumber = recInfo.number;
            mEmails = recInfo.emails == null ? null
                    : recInfo.emails.toArray(new String[recInfo.emails.size()]);
            mAdditionalNumbers = recInfo.additionalNumbers == null ? null
                    : recInfo.additionalNumbers.toArray(
                            new String[recInfo.additionalNumbers.size()]);
        }
    }

    public SimPhonebookRecord() {}

    public PhonebookRecordInfo toPhonebookRecordInfo() {
        PhonebookRecordInfo pbRecordInfo = new PhonebookRecordInfo();
        pbRecordInfo.recordId = mRecordId;
        pbRecordInfo.name = convertNullToEmptyString(mAlphaTag);
        pbRecordInfo.number = convertNullToEmptyString(convertNumberToRecordFormat(mNumber));
        if (mEmails != null) {
            pbRecordInfo.emails = new ArrayList<>(Arrays.asList(mEmails));
        }
        if (mAdditionalNumbers != null) {
            for (String addNum : mAdditionalNumbers) {
                pbRecordInfo.additionalNumbers.add(convertNumberToRecordFormat(addNum));
            }
        }
        return pbRecordInfo;
    }

    public android.hardware.radio.sim.PhonebookRecordInfo toPhonebookRecordInfoAidl() {
        android.hardware.radio.sim.PhonebookRecordInfo pbRecordInfo =
                new android.hardware.radio.sim.PhonebookRecordInfo();
        pbRecordInfo.recordId = mRecordId;
        pbRecordInfo.name = convertNullToEmptyString(mAlphaTag);
        pbRecordInfo.number = convertNullToEmptyString(convertNumberToRecordFormat(mNumber));
        if (mEmails != null) {
            pbRecordInfo.emails = mEmails;
        }
        if (mAdditionalNumbers != null) {
            String[] additionalNumbers = new String[mAdditionalNumbers.length];
            for (int i = 0; i < additionalNumbers.length; i++) {
                additionalNumbers[i] = convertNumberToRecordFormat(mAdditionalNumbers[i]);
            }
            pbRecordInfo.additionalNumbers = additionalNumbers;
        }
        return pbRecordInfo;
    }

    public int getRecordId() {
        return mRecordId;
    }

    public String getAlphaTag() {
@@ -70,15 +123,35 @@ public class SimPhonebookRecord {
        return mAdditionalNumbers;
    }

    /** Convert null to an empty String */
    private String convertNullToEmptyString(String str) {
        return str != null ? str : "";
    }

    /**
     * convert phone number in the SIM phonebook record format to GSM pause/wild/wait character
     * Convert the SIM PhonebookRecordInfo number to the GSM pause/wild/wait number
     * @param input the SIM PhonebookRecordInfo number
     * @return The converted GSM pause/wild/wait number
     */
    private static String convertRecordFormatToNumber(String input) {
    private String convertRecordFormatToNumber(String input) {
        return input == null ? null : input.replace('e', PhoneNumberUtils.WAIT)
                .replace('T', PhoneNumberUtils.PAUSE)
                .replace('?', PhoneNumberUtils.WILD);
    }

    /**
     * Convert the GSM pause/wild/wait characters to the phone number in the SIM PhonebookRecordInfo
     * number format
     * @param input GSM pause/wild/wait character
     * @return The converted PhonebookRecordInfo number
     */
    private String convertNumberToRecordFormat(String input) {
        return input == null ? null : input.replace(PhoneNumberUtils.WAIT, 'e')
                .replace(PhoneNumberUtils.PAUSE, 'T')
                .replace(PhoneNumberUtils.WILD, '?');
    }


    public boolean isEmpty() {
        return TextUtils.isEmpty(mAlphaTag)
                && TextUtils.isEmpty(mNumber)
@@ -89,8 +162,8 @@ public class SimPhonebookRecord {
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("SimPhoneBookRecord{").append("index =")
                .append(mRecordIndex).append(", name = ")
        sb.append("SimPhoneBookRecord{").append("ID =")
                .append(mRecordId).append(", name = ")
                .append(mAlphaTag == null ? "null" : mAlphaTag)
                .append(", number = ").append(mNumber == null ? "null" : mNumber)
                .append(", email count = ").append(mEmails == null ? 0 : mEmails.length)
@@ -103,19 +176,28 @@ public class SimPhonebookRecord {
    }

    public final static class Builder {
        private int mRecordIndex = 0;
        private int mRecordId = 0;
        private String mAlphaTag = null;
        private String mNumber = null;
        private String[] mEmails;
        private String[] mAdditionalNumbers;

        public SimPhonebookRecord build() {
            return new SimPhonebookRecord(mRecordIndex, mAlphaTag, mNumber, mEmails,
                    mAdditionalNumbers);
            SimPhonebookRecord record = new SimPhonebookRecord();
            record.mAlphaTag = mAlphaTag;
            record.mRecordId = mRecordId;
            record.mNumber = mNumber;
            if (mEmails != null) {
                record.mEmails = mEmails;
            }
            if (mAdditionalNumbers != null) {
                record.mAdditionalNumbers = mAdditionalNumbers;
            }
            return record;
        }

        public Builder setRecordIndex(int index) {
            mRecordIndex = index;
        public Builder setRecordId(int recordId) {
            mRecordId = recordId;
            return this;
        }

+118 −102

File changed.

Preview size limit exceeded, changes collapsed.

Loading