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

Commit 01828b3f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed debug messages" into main

parents 8bf025c5 866dd1c1
Loading
Loading
Loading
Loading
+48 −63
Original line number Diff line number Diff line
@@ -27,13 +27,11 @@ import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.BroadcastOptions;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.AsyncResult;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.RegistrantList;
@@ -162,7 +160,6 @@ public class UiccController extends Handler {
    private final TelephonyManager mTelephonyManager;

    // this needs to be here, because on bootup we dont know which index maps to which UiccSlot
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private CommandsInterface[] mCis;
    private UiccSlot[] mUiccSlots;
    private int[] mPhoneIdToSlotId;
@@ -226,14 +223,12 @@ public class UiccController extends Handler {
    // SharedPreferences key for saving the default euicc card ID
    private static final String DEFAULT_CARD = "default_card";

    @UnsupportedAppUsage
    private static final Object mLock = new Object();
    @UnsupportedAppUsage

    private static UiccController mInstance;
    @VisibleForTesting
    public static ArrayList<IccSlotStatus> sLastSlotStatus;

    @UnsupportedAppUsage
    @VisibleForTesting
    public Context mContext;

@@ -276,7 +271,7 @@ public class UiccController extends Handler {
                com.android.internal.R.integer.config_num_physical_slots);
        numPhysicalSlots = TelephonyProperties.sim_slots_count().orElse(numPhysicalSlots);
        if (DBG) {
            logWithLocalLog("config_num_physical_slots = " + numPhysicalSlots);
            logl("config_num_physical_slots = " + numPhysicalSlots);
        }

        mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
@@ -341,7 +336,6 @@ public class UiccController extends Handler {
        }
    }

    @UnsupportedAppUsage
    public static UiccController getInstance() {
        if (mInstance == null) {
            throw new RuntimeException(
@@ -350,7 +344,6 @@ public class UiccController extends Handler {
        return mInstance;
    }

    @UnsupportedAppUsage
    public UiccCard getUiccCard(int phoneId) {
        synchronized (mLock) {
            return getUiccCardForPhone(phoneId);
@@ -469,7 +462,7 @@ public class UiccController extends Handler {
    /** Map logicalSlot to physicalSlot, portIndex and activate the physicalSlot with portIndex if
     *  it is inactive. */
    public void switchSlots(List<UiccSlotMapping> slotMapping, Message response) {
        logWithLocalLog("switchSlots: " + slotMapping);
        logl("switchSlots: " + slotMapping);
        mRadioConfig.setSimSlotsMapping(slotMapping, response);
    }

@@ -555,7 +548,6 @@ public class UiccController extends Handler {
    }

    // Easy to use API
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public IccRecords getIccRecords(int phoneId, int family) {
        synchronized (mLock) {
            UiccCardApplication app = getUiccCardApplication(phoneId, family);
@@ -567,7 +559,6 @@ public class UiccController extends Handler {
    }

    // Easy to use API
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public IccFileHandler getIccFileHandler(int phoneId, int family) {
        synchronized (mLock) {
            UiccCardApplication app = getUiccCardApplication(phoneId, family);
@@ -580,7 +571,6 @@ public class UiccController extends Handler {


    //Notifies when card status changes
    @UnsupportedAppUsage
    public void registerForIccChanged(Handler h, int what, Object obj) {
        synchronized (mLock) {
            mIccChangedRegistrants.addUnique(h, what, obj);
@@ -603,12 +593,12 @@ public class UiccController extends Handler {
            String eventName = eventToString(msg.what);

            if (phoneId < 0 || phoneId >= mCis.length) {
                Rlog.e(LOG_TAG, "Invalid phoneId : " + phoneId + " received with event "
                logel("Invalid phoneId : " + phoneId + " received with event "
                        + eventName);
                return;
            }

            logWithLocalLog("handleMessage: Received " + eventName + " for phoneId " + phoneId);
            logl("handleMessage: Received " + eventName + " for phoneId " + phoneId);

            AsyncResult ar = (AsyncResult)msg.obj;
            switch (msg.what) {
@@ -669,7 +659,7 @@ public class UiccController extends Handler {
                    onMultiSimConfigChanged(activeModemCount);
                    break;
                default:
                    Rlog.e(LOG_TAG, " Unknown Event " + msg.what);
                    logel(" Unknown Event " + msg.what);
                    break;
            }
        }
@@ -679,7 +669,7 @@ public class UiccController extends Handler {
        int prevActiveModemCount = mCis.length;
        mCis = PhoneFactory.getCommandsInterfaces();

        logWithLocalLog("onMultiSimConfigChanged: prevActiveModemCount " + prevActiveModemCount
        logl("onMultiSimConfigChanged: prevActiveModemCount " + prevActiveModemCount
                + ", newActiveModemCount " + newActiveModemCount);

        // Resize array.
@@ -736,7 +726,6 @@ public class UiccController extends Handler {
    }

    // Easy to use API
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public UiccCardApplication getUiccCardApplication(int phoneId, int family) {
        synchronized (mLock) {
            UiccPort uiccPort = getUiccPortForPhone(phoneId);
@@ -808,7 +797,7 @@ public class UiccController extends Handler {
        intent.putExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON, reason);
        int subId = SubscriptionManager.getSubscriptionId(phoneId);
        SubscriptionManager.putPhoneIdAndMaybeSubIdExtra(intent, phoneId, subId);
        Rlog.d(LOG_TAG, "Broadcasting intent ACTION_SIM_STATE_CHANGED " + state + " reason "
        log("Broadcasting intent ACTION_SIM_STATE_CHANGED " + state + " reason "
                + reason + " for phone: " + phoneId + " sub: " + subId);
        IntentBroadcaster.getInstance().broadcastStickyIntent(mContext, intent, phoneId);
    }
@@ -837,7 +826,7 @@ public class UiccController extends Handler {
                portIndex = slot.getPortIndexFromPhoneId(phoneId);
                intent.putExtra(PhoneConstants.PORT_KEY, portIndex);
            }
            Rlog.d(LOG_TAG, "Broadcasting intent ACTION_SIM_CARD_STATE_CHANGED "
            log("Broadcasting intent ACTION_SIM_CARD_STATE_CHANGED "
                    + TelephonyManager.simStateToString(state) + " for phone: " + phoneId
                    + " slot: " + slotId + " port: " + portIndex + " sub: " + subId);
            if (mFeatureFlags.hsumBroadcast()) {
@@ -881,7 +870,7 @@ public class UiccController extends Handler {
            if (slot != null) {
                intent.putExtra(PhoneConstants.PORT_KEY, slot.getPortIndexFromPhoneId(phoneId));
            }
            Rlog.d(LOG_TAG, "Broadcasting intent ACTION_SIM_APPLICATION_STATE_CHANGED "
            log("Broadcasting intent ACTION_SIM_APPLICATION_STATE_CHANGED "
                    + TelephonyManager.simStateToString(state)
                    + " for phone: " + phoneId + " slot: " + slotId + " port: "
                    + slot.getPortIndexFromPhoneId(phoneId) + " sub: " + subId);
@@ -914,7 +903,6 @@ public class UiccController extends Handler {
            case IccCardConstants.INTENT_VALUE_ABSENT_ON_PERM_DISABLED:
                return TelephonyManager.SIM_STATE_PERM_DISABLED;
            default:
                Rlog.e(LOG_TAG, "Unexpected SIM locked reason " + lockedReason);
                return TelephonyManager.SIM_STATE_UNKNOWN;
        }
    }
@@ -995,10 +983,10 @@ public class UiccController extends Handler {
    public void updateSimState(int phoneId, @NonNull IccCardConstants.State state,
            @Nullable String reason) {
        post(() -> {
            log("updateSimState: phoneId=" + phoneId + ", state=" + state + ", reason="
            logl("updateSimState: phoneId=" + phoneId + ", state=" + state + ", reason="
                    + reason);
            if (!SubscriptionManager.isValidPhoneId(phoneId)) {
                Rlog.e(LOG_TAG, "updateSimState: Invalid phone id " + phoneId);
                logel("updateSimState: Invalid phone id " + phoneId);
                return;
            }

@@ -1037,7 +1025,7 @@ public class UiccController extends Handler {
                        }

                        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
                            Rlog.e(LOG_TAG, "updateSimState: Cannot update carrier services. "
                            logel("updateSimState: Cannot update carrier services. "
                                    + "Invalid phone id " + phoneId);
                            return;
                        }
@@ -1045,7 +1033,7 @@ public class UiccController extends Handler {
                        // At this point, the SIM state must be a final state (meaning we won't
                        // get more SIM state updates). So resolve the carrier id and update the
                        // carrier services.
                        log("updateSimState: resolve carrier id and update carrier "
                        logl("updateSimState: resolve carrier id and update carrier "
                                + "services.");
                        PhoneFactory.getPhone(phoneId).resolveSubscriptionCarrierId(
                                legacySimState);
@@ -1057,26 +1045,26 @@ public class UiccController extends Handler {

    private synchronized void onGetIccCardStatusDone(AsyncResult ar, Integer index) {
        if (ar.exception != null) {
            Rlog.e(LOG_TAG,"Error getting ICC status. "
            logel("Error getting ICC status. "
                    + "RIL_REQUEST_GET_ICC_STATUS should "
                    + "never return an error", ar.exception);
                    + "never return an error " + ar.exception);
            return;
        }
        if (!isValidPhoneIndex(index)) {
            Rlog.e(LOG_TAG,"onGetIccCardStatusDone: invalid index : " + index);
            logel("onGetIccCardStatusDone: invalid index : " + index);
            return;
        }
        if (isShuttingDown()) {
            // Do not process the SIM/SLOT events during device shutdown,
            // as it may unnecessarily modify the persistent information
            // like, SubscriptionManager.UICC_APPLICATIONS_ENABLED.
            log("onGetIccCardStatusDone: shudown in progress ignore event");
            log("onGetIccCardStatusDone: shutdown in progress ignore event");
            return;
        }

        IccCardStatus status = (IccCardStatus)ar.result;

        logWithLocalLog("onGetIccCardStatusDone: phoneId-" + index + " IccCardStatus: " + status);
        logl("onGetIccCardStatusDone: phoneId-" + index + " IccCardStatus: " + status);

        int slotId = status.mSlotPortMapping.mPhysicalSlotIndex;
        if (VDBG) log("onGetIccCardStatusDone: phoneId-" + index + " physicalSlotIndex " + slotId);
@@ -1139,7 +1127,7 @@ public class UiccController extends Handler {
                if (mDefaultEuiccCardId == UNINITIALIZED_CARD_ID
                        || mDefaultEuiccCardId == TEMPORARILY_UNSUPPORTED_CARD_ID) {
                    mDefaultEuiccCardId = convertToPublicCardId(cardString);
                    logWithLocalLog("IccCardStatus eid="
                    logl("IccCardStatus eid="
                            + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, cardString) + " slot=" + slotId
                            + " mDefaultEuiccCardId=" + mDefaultEuiccCardId);
                }
@@ -1280,13 +1268,11 @@ public class UiccController extends Handler {
            for (UiccSlot slot : mUiccSlots) {
                if (slot != null && slot.isRemovable() && slot.isEuicc() && slot.isActive()) {
                    int cardId = convertToPublicCardId(slot.getEid());
                    Rlog.d(LOG_TAG,
                            "getCardIdForDefaultEuicc: Removable eSIM is default, cardId: "
                                    + cardId);
                    log("getCardIdForDefaultEuicc: Removable eSIM is default, cardId: " + cardId);
                    return cardId;
                }
            }
            Rlog.d(LOG_TAG, "getCardIdForDefaultEuicc: No removable eSIM slot is found");
            log("getCardIdForDefaultEuicc: No removable eSIM slot is found");
        }
        return mDefaultEuiccCardId;
    }
@@ -1324,10 +1310,10 @@ public class UiccController extends Handler {
                    != CommandException.Error.REQUEST_NOT_SUPPORTED) {
                // this is not expected; there should be no exception other than
                // REQUEST_NOT_SUPPORTED
                logeWithLocalLog("Unexpected error getting slot status: " + ar.exception);
                logel("Unexpected error getting slot status: " + ar.exception);
            } else {
                // REQUEST_NOT_SUPPORTED
                logWithLocalLog("onGetSlotStatusDone: request not supported; marking "
                logl("onGetSlotStatusDone: request not supported; marking "
                        + "mIsSlotStatusSupported to false");
                mIsSlotStatusSupported = false;
            }
@@ -1347,7 +1333,7 @@ public class UiccController extends Handler {
            log("onGetSlotStatusDone: No change in slot status");
            return;
        }
        logWithLocalLog("onGetSlotStatusDone: " + status);
        logl("onGetSlotStatusDone: " + status);

        sLastSlotStatus = status;

@@ -1358,7 +1344,7 @@ public class UiccController extends Handler {

        int numSlots = status.size();
        if (mUiccSlots.length < numSlots) {
            logeWithLocalLog("The number of the physical slots reported " + numSlots
            logel("The number of the physical slots reported " + numSlots
                    + " is greater than the expectation " + mUiccSlots.length);
            numSlots = mUiccSlots.length;
        }
@@ -1379,7 +1365,7 @@ public class UiccController extends Handler {
                        int logicalSlotIndex = iss.mSimPortInfos[j].mLogicalSlotIndex;
                        // Correctness check: logicalSlotIndex should be valid for an active slot
                        if (!isValidPhoneIndex(logicalSlotIndex)) {
                            Rlog.e(LOG_TAG, "Skipping slot " + i + " portIndex " + j + " as phone "
                            logel("Skipping slot " + i + " portIndex " + j + " as phone "
                                    + logicalSlotIndex
                                    + " is not available to communicate with this slot");
                        } else {
@@ -1413,7 +1399,7 @@ public class UiccController extends Handler {
                if (!mUiccSlots[i].isRemovable() && !isDefaultEuiccCardIdSet) {
                    isDefaultEuiccCardIdSet = true;
                    mDefaultEuiccCardId = convertToPublicCardId(eid);
                    logWithLocalLog("Using eid=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)
                    logl("Using eid=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)
                            + " in slot=" + i + " to set mDefaultEuiccCardId="
                            + mDefaultEuiccCardId);
                }
@@ -1432,7 +1418,7 @@ public class UiccController extends Handler {
                    if (!TextUtils.isEmpty(eid)) {
                        isDefaultEuiccCardIdSet = true;
                        mDefaultEuiccCardId = convertToPublicCardId(eid);
                        logWithLocalLog("Using eid="
                        logl("Using eid="
                                + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)
                                + " from removable eUICC in slot=" + i
                                + " to set mDefaultEuiccCardId=" + mDefaultEuiccCardId);
@@ -1443,7 +1429,7 @@ public class UiccController extends Handler {
        }

        if (mHasBuiltInEuicc && !anyEuiccIsActive && !isDefaultEuiccCardIdSet) {
            logWithLocalLog(
            logl(
                    "onGetSlotStatusDone: mDefaultEuiccCardId=TEMPORARILY_UNSUPPORTED_CARD_ID");
            isDefaultEuiccCardIdSet = true;
            mDefaultEuiccCardId = TEMPORARILY_UNSUPPORTED_CARD_ID;
@@ -1466,7 +1452,7 @@ public class UiccController extends Handler {
                    }
                }
                if (!defaultEuiccCardIdIsStillInserted) {
                    logWithLocalLog("onGetSlotStatusDone: mDefaultEuiccCardId="
                    logl("onGetSlotStatusDone: mDefaultEuiccCardId="
                            + mDefaultEuiccCardId
                            + " is no longer inserted. Setting mDefaultEuiccCardId=UNINITIALIZED");
                    mDefaultEuiccCardId = UNINITIALIZED_CARD_ID;
@@ -1474,7 +1460,7 @@ public class UiccController extends Handler {
            } else {
                // no known eUICCs at all (it's possible that an eUICC is inserted and we just don't
                // know it's EID)
                logWithLocalLog("onGetSlotStatusDone: mDefaultEuiccCardId=UNINITIALIZED");
                logl("onGetSlotStatusDone: mDefaultEuiccCardId=UNINITIALIZED");
                mDefaultEuiccCardId = UNINITIALIZED_CARD_ID;
            }
        }
@@ -1483,7 +1469,7 @@ public class UiccController extends Handler {

        // Correctness check: number of active ports should be valid
        if (numActivePorts != mPhoneIdToSlotId.length) {
            Rlog.e(LOG_TAG, "Number of active ports " + numActivePorts
            logel("Number of active ports " + numActivePorts
                       + " does not match the number of Phones" + mPhoneIdToSlotId.length);
        }

@@ -1535,32 +1521,32 @@ public class UiccController extends Handler {

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

        if (!isValidPhoneIndex(index)) {
            Rlog.e(LOG_TAG,"onSimRefresh: invalid index : " + index);
            logel("onSimRefresh: invalid index : " + index);
            return;
        }

        IccRefreshResponse resp = (IccRefreshResponse) ar.result;
        logWithLocalLog("onSimRefresh: index " + index + ", " + resp);
        logl("onSimRefresh: index " + index + ", " + resp);

        if (resp == null) {
            Rlog.e(LOG_TAG, "onSimRefresh: received without input");
            logel("onSimRefresh: received without input");
            return;
        }

        UiccCard uiccCard = getUiccCardForPhone(index);
        if (uiccCard == null) {
            Rlog.e(LOG_TAG,"onSimRefresh: refresh on null card : " + index);
            logel("onSimRefresh: refresh on null card : " + index);
            return;
        }

        UiccPort uiccPort = getUiccPortForPhone(index);
        if (uiccPort == null) {
            Rlog.e(LOG_TAG, "onSimRefresh: refresh on null port : " + index);
            logel("onSimRefresh: refresh on null port : " + index);
            return;
        }

@@ -1596,18 +1582,18 @@ public class UiccController extends Handler {
    // is first loaded
    private void onEidReady(AsyncResult ar, Integer index) {
        if (ar.exception != null) {
            Rlog.e(LOG_TAG, "onEidReady: exception: " + ar.exception);
            logel("onEidReady: exception: " + ar.exception);
            return;
        }

        if (!isValidPhoneIndex(index)) {
            Rlog.e(LOG_TAG, "onEidReady: invalid index: " + index);
            logel("onEidReady: invalid index: " + index);
            return;
        }
        int slotId = mPhoneIdToSlotId[index];
        EuiccCard card = (EuiccCard) mUiccSlots[slotId].getUiccCard();
        if (card == null) {
            Rlog.e(LOG_TAG, "onEidReady: UiccCard in slot " + slotId + " is null");
            logel("onEidReady: UiccCard in slot " + slotId + " is null");
            return;
        }

@@ -1618,14 +1604,14 @@ public class UiccController extends Handler {
                || mDefaultEuiccCardId == TEMPORARILY_UNSUPPORTED_CARD_ID) {
            if (!mUiccSlots[slotId].isRemovable()) {
                mDefaultEuiccCardId = convertToPublicCardId(eid);
                logWithLocalLog("onEidReady: eid="
                logl("onEidReady: eid="
                        + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)
                        + " slot=" + slotId + " mDefaultEuiccCardId=" + mDefaultEuiccCardId);
            } else if (!mHasActiveBuiltInEuicc) {
                // we only set a removable eUICC to the default if there are no active non-removable
                // eUICCs
                mDefaultEuiccCardId = convertToPublicCardId(eid);
                logWithLocalLog("onEidReady: eid="
                logl("onEidReady: eid="
                        + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)
                        + " from removable eUICC in slot=" + slotId + " mDefaultEuiccCardId="
                        + mDefaultEuiccCardId);
@@ -1768,7 +1754,7 @@ public class UiccController extends Handler {
                PreferenceManager.getDefaultSharedPreferences(mContext).edit();
        editor.putBoolean(REMOVABLE_ESIM_AS_DEFAULT, isDefault);
        editor.apply();
        Rlog.d(LOG_TAG, "setRemovableEsimAsDefaultEuicc isDefault: " + isDefault);
        log("setRemovableEsimAsDefaultEuicc isDefault: " + isDefault);
    }

    /**
@@ -1776,7 +1762,7 @@ public class UiccController extends Handler {
     * This API is added for test purpose to check whether removable eSIM is default eUICC or not.
     */
    public boolean isRemovableEsimDefaultEuicc() {
        Rlog.d(LOG_TAG, "mUseRemovableEsimAsDefault: " + mUseRemovableEsimAsDefault);
        log("mUseRemovableEsimAsDefault: " + mUseRemovableEsimAsDefault);
        return mUseRemovableEsimAsDefault;
    }

@@ -1793,17 +1779,16 @@ public class UiccController extends Handler {
        }
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void log(String string) {
        Rlog.d(LOG_TAG, string);
    }

    private void logWithLocalLog(String string) {
    private void logl(String string) {
        Rlog.d(LOG_TAG, string);
        sLocalLog.log("UiccController: " + string);
    }

    private void logeWithLocalLog(String string) {
    private void logel(String string) {
        Rlog.e(LOG_TAG, string);
        sLocalLog.log("UiccController: " + string);
    }