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

Commit a651c223 authored by Cassie Han's avatar Cassie Han Committed by Gerrit Code Review
Browse files

Merge "Improve the status message logged in UiccCarrierPrivilege Rules for...

Merge "Improve the status message logged in UiccCarrierPrivilege Rules for better debugging purpose."
parents 7c9f519f 8d1c72c4
Loading
Loading
Loading
Loading
+33 −8
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.telephony.UiccAccessRule;
import android.text.TextUtils;
import android.util.LocalLog;

import com.android.internal.telephony.CommandException;

@@ -185,7 +186,8 @@ public class UiccCarrierPrivilegeRules extends Handler {
    private List<UiccAccessRule> mAccessRules;
    private String mRules;
    private Message mLoadedCallback;
    private String mStatusMessage;  // Only used for debugging.
    // LocalLog buffer to hold important status messages for debugging.
    private LocalLog mStatusMessage = new LocalLog(100);
    private int mChannelId; // Channel Id for communicating with UICC.
    private int mRetryCount;  // Number of retries for open logical channel.
    private boolean mCheckedRules = false;  // Flag that used to mark whether get rules from ARA-D.
@@ -209,7 +211,7 @@ public class UiccCarrierPrivilegeRules extends Handler {
        log("Creating UiccCarrierPrivilegeRules");
        mUiccProfile = uiccProfile;
        mState = new AtomicInteger(STATE_LOADING);
        mStatusMessage = "Not loaded.";
        mStatusMessage.log("Not loaded.");
        mLoadedCallback = loadedCallback;
        mRules = "";
        mAccessRules = new ArrayList<>();
@@ -446,7 +448,7 @@ public class UiccCarrierPrivilegeRules extends Handler {
                        if (mAIDInUse == ARAD) {
                            // Open logical channel with ARA_M.
                            mRules = "";
                            openChannel(1);
                            openChannel(ARAM);
                        }
                        if (mAIDInUse == ARAM) {
                            if (mCheckedRules) {
@@ -455,6 +457,13 @@ public class UiccCarrierPrivilegeRules extends Handler {
                                // if rules cannot be read from both ARA_D and ARA_M applet,
                                // fallback to PKCS15-based ARF.
                                log("No ARA, try ARF next.");
                                if (ar.exception instanceof CommandException
                                        && ((CommandException) (ar.exception)).getCommandError()
                                        != CommandException.Error.NO_SUCH_ELEMENT) {
                                    updateStatusMessage("No ARA due to "
                                            +
                                            ((CommandException) (ar.exception)).getCommandError());
                                }
                                mUiccPkcs15 = new UiccPkcs15(mUiccProfile,
                                        obtainMessage(EVENT_PKCS15_READ_DONE));
                            }
@@ -500,8 +509,19 @@ public class UiccCarrierPrivilegeRules extends Handler {
                        }
                    }
                } else {
                    if (mAIDInUse == ARAM) {
                        updateState(STATE_ERROR, "Error reading value from SIM.");
                    String errorMsg =  "Error reading value from SIM via "
                            + ((mAIDInUse == ARAD) ? "ARAD" : "ARAM") + " due to ";
                    if (ar.exception instanceof CommandException) {
                        CommandException.Error errorCode =
                                ((CommandException) (ar.exception)).getCommandError();
                        errorMsg += "error code : " + errorCode;
                    } else {
                        errorMsg += "unknown exception : " + ar.exception.getMessage();
                    }
                    if (mAIDInUse == ARAD) {
                        updateStatusMessage(errorMsg);
                    } else {
                        updateState(STATE_ERROR, errorMsg);
                    }
                }

@@ -515,7 +535,7 @@ public class UiccCarrierPrivilegeRules extends Handler {
                if (mAIDInUse == ARAD) {
                    // Close logical channel with ARA_D and then open logical channel with ARA_M.
                    mRules = "";
                    openChannel(1);
                    openChannel(ARAM);
                }
                break;

@@ -666,7 +686,11 @@ public class UiccCarrierPrivilegeRules extends Handler {
            mLoadedCallback.sendToTarget();
        }

        mStatusMessage = statusMessage;
        updateStatusMessage(statusMessage);
    }

    private void updateStatusMessage(String statusMessage) {
        mStatusMessage.log(statusMessage);
    }

    private static void log(String msg) {
@@ -679,7 +703,8 @@ public class UiccCarrierPrivilegeRules extends Handler {
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("UiccCarrierPrivilegeRules: " + this);
        pw.println(" mState=" + getStateString(mState.get()));
        pw.println(" mStatusMessage='" + mStatusMessage + "'");
        pw.println(" mStatusMessage=");
        mStatusMessage.dump(fd, pw, args);
        if (mAccessRules != null) {
            pw.println(" mAccessRules: ");
            for (UiccAccessRule ar : mAccessRules) {
+41 −40
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public class UiccPkcs15 extends Handler {
    private UiccProfile mUiccProfile;  // Parent
    private Message mLoadedCallback;
    private int mChannelId = -1; // Channel Id for communicating with UICC.
    private List<String> mRules = new ArrayList<String>();
    private List<String> mRules = null;
    private Pkcs15Selector mPkcs15Selector;
    private FileHandler mFh;

@@ -212,6 +212,7 @@ public class UiccPkcs15 extends Handler {

            case EVENT_LOAD_ACRF_DONE:
                if (ar.exception == null && ar.result != null) {
                    mRules = new ArrayList<String>();
                    String idAccf = parseAcrf((String) ar.result);
                    if (!mFh.loadFile(idAccf, obtainMessage(EVENT_LOAD_ACCF_DONE))) {
                        cleanUp();