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

Commit 3ba773a2 authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Telephony: Get SIM card capacity of SMS"

parents daa51a42 1c3c8178
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
import com.android.internal.telephony.uicc.IccConstants;
import com.android.internal.telephony.uicc.IccFileHandler;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.util.HexDump;

import java.io.FileDescriptor;
@@ -1336,6 +1338,28 @@ public class IccSmsInterfaceManager {
                SMS_MESSAGE_PERIOD_NOT_SPECIFIED);
    }

    public int getSmsCapacityOnIcc() {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
                "getSmsCapacityOnIcc");

        int numberOnIcc = 0;
        if (mPhone.getIccRecordsLoaded()) {
            final UiccProfile uiccProfile = UiccController.getInstance()
                    .getUiccProfileForPhone(mPhone.getPhoneId());
            if(uiccProfile != null) {
                numberOnIcc = uiccProfile.getIccRecords().getSmsCapacityOnIcc();
            } else {
                loge("uiccProfile is null");
            }
        } else {
            loge("getSmsCapacityOnIcc - aborting, no icc card present.");
        }

        log("getSmsCapacityOnIcc().numberOnIcc = " + numberOnIcc);
        return numberOnIcc;
    }

    private boolean isFailedOrDraft(ContentResolver resolver, Uri messageUri) {
        // Clear the calling identity and query the database using the phone user id
        // Otherwise the AppOps check in TelephonyProvider would complain about mismatch
+15 −0
Original line number Diff line number Diff line
@@ -625,4 +625,19 @@ public class SmsController extends ISmsImplBase {
                .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
        return manager.getActiveSubscriptionInfo(subId);
    }

    /**
     * Get the capacity count of sms on Icc card.
     */
    @Override
    public int getSmsCapacityOnIccForSubscriber(int subId) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);

        if (iccSmsIntMgr != null ) {
            return iccSmsIntMgr.getSmsCapacityOnIcc();
        } else {
            Rlog.e(LOG_TAG, "iccSmsIntMgr is null for " + " subId: " + subId);
            return 0;
        }
    }
}
+38 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@ public abstract class IccRecords extends Handler implements IccConstants {
    protected int mMncLength = UNINITIALIZED;
    protected int mMailboxIndex = 0; // 0 is no mailbox dailing number associated

    protected int mSmsCountOnIcc = 0;

    @UnsupportedAppUsage
    private String mSpn;

@@ -215,6 +217,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
    public static final int EVENT_GET_ICC_RECORD_DONE = 100;
    public static final int EVENT_REFRESH = 31; // ICC refresh occurred
    private static final int EVENT_AKA_AUTHENTICATE_DONE          = 90;
    protected static final int EVENT_GET_SMS_RECORD_SIZE_DONE = 28;

    protected static final int SYSTEM_EVENT_BASE = 0x100;
    protected static final int EVENT_APP_READY = 1 + SYSTEM_EVENT_BASE;
@@ -905,6 +908,33 @@ public abstract class IccRecords extends Handler implements IccConstants {

                break;

            case EVENT_GET_SMS_RECORD_SIZE_DONE:
                ar = (AsyncResult) msg.obj;

                if (ar.exception != null) {
                    onRecordLoaded();
                    loge("Exception in EVENT_GET_SMS_RECORD_SIZE_DONE " + ar.exception);
                    break;
                }

                int[] recordSize = (int[])ar.result;
                try {
                    // recordSize[0]  is the record length
                    // recordSize[1]  is the total length of the EF file
                    // recordSize[2]  is the number of records in the EF file
                    mSmsCountOnIcc = recordSize[2];
                    log("EVENT_GET_SMS_RECORD_SIZE_DONE Size " + recordSize[0]
                            + " total " + recordSize[1]
                                    + " record " + recordSize[2]);
                } catch (ArrayIndexOutOfBoundsException exc) {
                    mSmsCountOnIcc = -1;
                    loge("ArrayIndexOutOfBoundsException in EVENT_GET_SMS_RECORD_SIZE_DONE: "
                            + exc.toString());
                } finally {
                    onRecordLoaded();
                }
                break;

            default:
                super.handleMessage(msg);
        }
@@ -1246,6 +1276,14 @@ public abstract class IccRecords extends Handler implements IccConstants {
        return carrierNameDisplayCondition;
    }

    /**
     * Get SMS capacity count on ICC card.
     */
    public int getSmsCapacityOnIcc() {
        if (DBG) log("getSmsCapacityOnIcc: " + mSmsCountOnIcc);
        return mSmsCountOnIcc;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("IccRecords: " + this);
        pw.println(" mDestroyed=" + mDestroyed);
+2 −0
Original line number Diff line number Diff line
@@ -891,6 +891,8 @@ public class RuimRecords extends IccRecords {
        mFh.loadEFTransparent(EF_CSIM_MIPUPP,
                obtainMessage(EVENT_GET_ICC_RECORD_DONE, new EfCsimMipUppLoaded()));
        mRecordsToLoad++;
        mFh.getEFLinearRecordSize(EF_SMS, obtainMessage(EVENT_GET_SMS_RECORD_SIZE_DONE));
        mRecordsToLoad++;

        if (DBG) log("fetchRuimRecords " + mRecordsToLoad + " requested: " + mRecordsRequested);
        // Further records that can be inserted are Operator/OEM dependent
+2 −0
Original line number Diff line number Diff line
@@ -1659,6 +1659,8 @@ public class SIMRecords extends IccRecords {
        mRecordsToLoad++;

        loadEfLiAndEfPl();
        mFh.getEFLinearRecordSize(EF_SMS, obtainMessage(EVENT_GET_SMS_RECORD_SIZE_DONE));
        mRecordsToLoad++;

        // XXX should seek instead of examining them all
        if (false) { // XXX
Loading