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

Commit a61d1f19 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Added LocalLog for UICC."

parents 73fbc680 22294389
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -345,12 +345,12 @@ public class SubscriptionInfoUpdater extends Handler {
        if (iccId == null) {
            IccCard iccCard = mPhone[slotId].getIccCard();
            if (iccCard == null) {
                logd("handleSimLoaded: IccCard null");
                logd("handleSimLocked: IccCard null");
                return;
            }
            IccRecords records = iccCard.getIccRecords();
            if (records == null) {
                logd("handleSimLoaded: IccRecords null");
                logd("handleSimLocked: IccRecords null");
                return;
            }
            if (IccUtils.stripTrailingFs(records.getFullIccId()) == null) {
+0 −8
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.os.Handler;
import android.os.Message;
import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.util.LocalLog;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.TelephonyComponentFactory;
@@ -47,8 +46,6 @@ public class UiccCard {
    public static final String EXTRA_ICC_CARD_ADDED =
            "com.android.internal.telephony.uicc.ICC_CARD_ADDED";

    private static final String OPERATOR_BRAND_OVERRIDE_PREFIX = "operator_branding_";

    private final Object mLock = new Object();
    private CardState mCardState;
    private String mIccid;
@@ -56,7 +53,6 @@ public class UiccCard {
    private UiccProfile mUiccProfile;
    private Context mContext;
    private CommandsInterface mCi;
    private static final LocalLog mLocalLog = new LocalLog(100);
    private final int mPhoneId;

    public UiccCard(Context c, CommandsInterface ci, IccCardStatus ics, int phoneId) {
@@ -506,10 +502,6 @@ public class UiccCard {
        Rlog.e(LOG_TAG, msg);
    }

    private void loglocal(String msg) {
        if (DBG) mLocalLog.log(msg);
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("UiccCard:");
        pw.println(" mCi=" + mCi);
+28 −37
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import android.os.storage.StorageManager;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.text.format.Time;
import android.util.LocalLog;

import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
@@ -40,7 +40,6 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

/**
@@ -125,14 +124,13 @@ public class UiccController extends Handler {
    private UiccStateChangedLauncher mLauncher;
    private RadioConfig mRadioConfig;

    // Logging for dumpsys. Useful in cases when the cards run into errors.
    private static final int MAX_PROACTIVE_COMMANDS_TO_LOG = 20;
    private LinkedList<String> mCardLogs = new LinkedList<String>();
    // LocalLog buffer to hold important SIM related events for debugging
    static LocalLog sLocalLog = new LocalLog(100);

    public static UiccController make(Context c, CommandsInterface[] ci) {
        synchronized (mLock) {
            if (mInstance != null) {
                throw new RuntimeException("MSimUiccController.make() should only be called once");
                throw new RuntimeException("UiccController.make() should only be called once");
            }
            mInstance = new UiccController(c, ci);
            return mInstance;
@@ -143,9 +141,11 @@ public class UiccController extends Handler {
        if (DBG) log("Creating UiccController");
        mContext = c;
        mCis = ci;
        if (VDBG) {
            log("config_num_physical_slots = " + c.getResources().getInteger(
                    com.android.internal.R.integer.config_num_physical_slots));
        if (DBG) {
            String logStr = "config_num_physical_slots = " + c.getResources().getInteger(
                    com.android.internal.R.integer.config_num_physical_slots);
            log(logStr);
            sLocalLog.log(logStr);
        }
        int numPhysicalSlots = c.getResources().getInteger(
                com.android.internal.R.integer.config_num_physical_slots);
@@ -371,6 +371,8 @@ public class UiccController extends Handler {
                return;
            }

            sLocalLog.log("handleMessage: Received " + msg.what + " for phoneId " + phoneId);

            AsyncResult ar = (AsyncResult)msg.obj;
            switch (msg.what) {
                case EVENT_ICC_STATUS_CHANGED:
@@ -473,6 +475,8 @@ public class UiccController extends Handler {

        IccCardStatus status = (IccCardStatus)ar.result;

        sLocalLog.log("onGetIccCardStatusDone: phoneId " + index + " IccCardStatus: " + status);

        int slotId = status.physicalSlotIndex;
        if (VDBG) log("onGetIccCardStatusDone: phoneId " + index + " physicalSlotIndex " + slotId);
        if (slotId == INVALID_SLOT_ID) {
@@ -503,15 +507,20 @@ public class UiccController extends Handler {
        }
        Throwable e = ar.exception;
        if (e != null) {
            String logStr;
            if (!(e instanceof CommandException) || ((CommandException) e).getCommandError()
                    != CommandException.Error.REQUEST_NOT_SUPPORTED) {
                // this is not expected; there should be no exception other than
                // REQUEST_NOT_SUPPORTED
                Rlog.e(LOG_TAG, "Unexpected error getting slot status: " + ar.exception);
                logStr = "Unexpected error getting slot status: " + ar.exception;
                Rlog.e(LOG_TAG, logStr);
                sLocalLog.log(logStr);
            } else {
                // REQUEST_NOT_SUPPORTED
                log("onGetSlotStatusDone: request not supported; marking mIsSlotStatusSupported "
                        + "to false");
                logStr = "onGetSlotStatusDone: request not supported; marking "
                        + "mIsSlotStatusSupported to false";
                log(logStr);
                sLocalLog.log(logStr);
                mIsSlotStatusSupported = false;
            }
            return;
@@ -524,6 +533,8 @@ public class UiccController extends Handler {
            return;
        }

        sLastSlotStatus = status;

        int numActiveSlots = 0;
        for (int i = 0; i < status.size(); i++) {
            IccSlotStatus iss = status.get(i);
@@ -591,22 +602,10 @@ public class UiccController extends Handler {
            log("    phoneId " + i + " slotId " + mPhoneIdToSlotId[i]);
        }
    }
    /**
     * Slots are initialized when none of them are null.
     * todo: is this even needed?
     */
    private synchronized boolean areSlotsInitialized() {
        for (UiccSlot slot : mUiccSlots) {
            if (slot == null) {
                return false;
            }
        }
        return true;
    }

    private void onSimRefresh(AsyncResult ar, Integer index) {
        if (ar.exception != null) {
            Rlog.e(LOG_TAG, "Sim REFRESH with exception: " + ar.exception);
            Rlog.e(LOG_TAG, "onSimRefresh: Sim REFRESH with exception: " + ar.exception);
            return;
        }

@@ -617,6 +616,7 @@ public class UiccController extends Handler {

        IccRefreshResponse resp = (IccRefreshResponse) ar.result;
        log("onSimRefresh: " + resp);
        sLocalLog.log("onSimRefresh: " + resp);

        if (resp == null) {
            Rlog.e(LOG_TAG, "onSimRefresh: received without input");
@@ -629,7 +629,6 @@ public class UiccController extends Handler {
            return;
        }

        log("Handling refresh: " + resp);
        boolean changed = false;
        switch(resp.refreshResult) {
            case IccRefreshResponse.REFRESH_RESULT_RESET:
@@ -672,14 +671,8 @@ public class UiccController extends Handler {
        Rlog.d(LOG_TAG, string);
    }

    // TODO: This is hacky. We need a better way of saving the logs.
    public void addCardLog(String data) {
        Time t = new Time();
        t.setToNow();
        mCardLogs.addLast(t.format("%m-%d %H:%M:%S") + " " + data);
        if (mCardLogs.size() > MAX_PROACTIVE_COMMANDS_TO_LOG) {
            mCardLogs.removeFirst();
        }
        sLocalLog.log(data);
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -702,9 +695,7 @@ public class UiccController extends Handler {
                mUiccSlots[i].dump(fd, pw, args);
            }
        }
        pw.println("mCardLogs: ");
        for (int i = 0; i < mCardLogs.size(); ++i) {
            pw.println("  " + mCardLogs.get(i));
        }
        pw.println(" sLocalLog= ");
        sLocalLog.dump(fd, pw, args);
    }
}
+29 −44
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.LocalLog;
import android.view.WindowManager;

import com.android.internal.R;
@@ -86,7 +85,6 @@ public class UiccProfile extends Handler implements IccCard {
    protected static final String LOG_TAG = "UiccProfile";
    protected static final boolean DBG = true;
    private static final boolean VDBG = false; //STOPSHIP if true
    private static final boolean ICC_CARD_PROXY_REMOVED = true;

    private static final String OPERATOR_BRAND_OVERRIDE_PREFIX = "operator_branding_";

@@ -113,8 +111,6 @@ public class UiccProfile extends Handler implements IccCard {
    private static final int EVENT_SIM_IO_DONE = 19;
    private static final int EVENT_CARRIER_PRIVILEGES_LOADED = 20;

    private static final LocalLog sLocalLog = new LocalLog(100);

    private final int mPhoneId;

    /*----------------------------------------------------*/
@@ -147,27 +143,21 @@ public class UiccProfile extends Handler implements IccCard {
        if (DBG) log("Creating profile");
        mUiccCard = uiccCard;
        mPhoneId = phoneId;
        if (ICC_CARD_PROXY_REMOVED) {
        // set current app type based on phone type - do this before calling update() as that
        // calls updateIccAvailability() which uses mCurrentAppType
        Phone phone = PhoneFactory.getPhone(phoneId);
        if (phone != null) {
            setCurrentAppType(phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM);
        }
        }

        if (mUiccCard instanceof EuiccCard) {
            ((EuiccCard) mUiccCard).registerForEidReady(this, EVENT_EID_READY, null);
        }

        update(c, ci, ics);

        if (ICC_CARD_PROXY_REMOVED) {
        ci.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_UNAVAILABLE, null);

        resetProperties();
    }
    }

    /**
     * Dispose the UiccProfile.
@@ -183,9 +173,7 @@ public class UiccProfile extends Handler implements IccCard {
                ((EuiccCard) mUiccCard).unregisterForEidReady(this);
            }

            if (ICC_CARD_PROXY_REMOVED) {
            mCi.unregisterForOffOrNotAvailable(this);
            }

            if (mCatService != null) mCatService.dispose();
            for (UiccCardApplication app : mUiccApplications) {
@@ -233,6 +221,7 @@ public class UiccProfile extends Handler implements IccCard {
            loge("handleMessage: Received " + msg.what + " after dispose(); ignoring the message");
            return;
        }
        loglocal("handleMessage: Received " + msg.what + " for phoneId " + mPhoneId);
        switch (msg.what) {
            case EVENT_NETWORK_LOCKED:
                mNetworkLockedRegistrants.notifyRegistrants();
@@ -258,7 +247,7 @@ public class UiccProfile extends Handler implements IccCard {
                break;

            case EVENT_CARRIER_PRIVILEGES_LOADED:
                if (VDBG) log("EVENT_CARRIER_PRIVILEGES_LOADED");
                if (VDBG) log("handleMessage: EVENT_CARRIER_PRIVILEGES_LOADED");
                onCarrierPriviligesLoadedMessage();
                updateExternalState();
                break;
@@ -270,15 +259,15 @@ public class UiccProfile extends Handler implements IccCard {
            case EVENT_SIM_IO_DONE:
                AsyncResult ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    loglocal("Exception: " + ar.exception);
                    log("Error in SIM access with exception" + ar.exception);
                    loglocal("handleMessage: Exception " + ar.exception);
                    log("handleMessage: Error in SIM access with exception" + ar.exception);
                }
                AsyncResult.forMessage((Message) ar.userObj, ar.result, ar.exception);
                ((Message) ar.userObj).sendToTarget();
                break;

            default:
                loge("Unhandled message with number: " + msg.what);
                loge("handleMessage: Unhandled message with number: " + msg.what);
                break;
        }
    }
@@ -489,8 +478,10 @@ public class UiccProfile extends Handler implements IccCard {
        intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, value);
        intent.putExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON, reason);
        intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);  // SubId may not be valid.
        log("Sending intent ACTION_INTERNAL_SIM_STATE_CHANGED value=" + value
                + " for mPhoneId : " + phoneId);
        String logStr = "Sending intent ACTION_INTERNAL_SIM_STATE_CHANGED value=" + value
                + " for mPhoneId : " + phoneId;
        log(logStr);
        UiccController.sLocalLog.log("UiccProfile[" + phoneId + "]: " + logStr);
        ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
    }

@@ -1181,7 +1172,7 @@ public class UiccProfile extends Handler implements IccCard {
     * Exposes {@link CommandsInterface#iccOpenLogicalChannel}
     */
    public void iccOpenLogicalChannel(String aid, int p2, Message response) {
        loglocal("Open Logical Channel: " + aid + " , " + p2 + " by pid:" + Binder.getCallingPid()
        loglocal("iccOpenLogicalChannel: " + aid + " , " + p2 + " by pid:" + Binder.getCallingPid()
                + " uid:" + Binder.getCallingUid());
        mCi.iccOpenLogicalChannel(aid, p2,
                obtainMessage(EVENT_OPEN_LOGICAL_CHANNEL_DONE, response));
@@ -1191,7 +1182,7 @@ public class UiccProfile extends Handler implements IccCard {
     * Exposes {@link CommandsInterface#iccCloseLogicalChannel}
     */
    public void iccCloseLogicalChannel(int channel, Message response) {
        loglocal("Close Logical Channel: " + channel);
        loglocal("iccCloseLogicalChannel: " + channel);
        mCi.iccCloseLogicalChannel(channel,
                obtainMessage(EVENT_CLOSE_LOGICAL_CHANNEL_DONE, response));
    }
@@ -1410,7 +1401,7 @@ public class UiccProfile extends Handler implements IccCard {
    }

    private void loglocal(String msg) {
        if (DBG) sLocalLog.log(msg);
        if (DBG) UiccController.sLocalLog.log("UiccProfile[" + mPhoneId + "]: " + msg);
    }

    /**
@@ -1469,7 +1460,6 @@ public class UiccProfile extends Handler implements IccCard {
        }
        pw.flush();

        if (ICC_CARD_PROXY_REMOVED) {
        pw.println(" mNetworkLockedRegistrants: size=" + mNetworkLockedRegistrants.size());
        for (int i = 0; i < mNetworkLockedRegistrants.size(); i++) {
            pw.println("  mNetworkLockedRegistrants[" + i + "]="
@@ -1482,9 +1472,4 @@ public class UiccProfile extends Handler implements IccCard {
        pw.println(" mExternalState=" + mExternalState);
        pw.flush();
    }

        pw.println("sLocalLog:");
        sLocalLog.dump(fd, pw, args);
        pw.flush();
    }
}
+0 −9
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.telephony.Rlog;
import android.util.LocalLog;
import android.view.WindowManager;

import com.android.internal.R;
@@ -66,8 +65,6 @@ public class UiccSlot extends Handler {
    private static final int EVENT_CARD_REMOVED = 13;
    private static final int EVENT_CARD_ADDED = 14;

    private static final LocalLog sLocalLog = new LocalLog(100);

    public UiccSlot(Context c, boolean isActive) {
        if (DBG) log("Creating");
        mContext = c;
@@ -339,10 +336,6 @@ public class UiccSlot extends Handler {
        Rlog.e(TAG, msg);
    }

    private void loglocal(String msg) {
        if (DBG) sLocalLog.log(msg);
    }

    /**
     * Dump
     */
@@ -360,8 +353,6 @@ public class UiccSlot extends Handler {
        }
        pw.println();
        pw.flush();
        pw.println("sLocalLog:");
        sLocalLog.dump(fd, pw, args);
        pw.flush();
    }
}