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

Commit 32cf19bb authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge changes I35cd3abd,I730c3307 into main

* changes:
  Clear invalid SIM slot data when INVALID SUBSCRIPTION received
  Add separate SIM log buffer
parents 3d22e6f4 c427812e
Loading
Loading
Loading
Loading
+39 −27
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.logging.KeyguardUpdateMonitorLogger;
import com.android.keyguard.logging.SimLogger;
import com.android.settingslib.Utils;
import com.android.settingslib.WirelessUtils;
import com.android.settingslib.fuelgauge.BatteryStatus;
@@ -285,6 +286,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final Context mContext;
    private final UserTracker mUserTracker;
    private final KeyguardUpdateMonitorLogger mLogger;
    private final SimLogger mSimLogger;
    private final boolean mIsSystemUser;
    private final Provider<JavaAdapter> mJavaAdapter;
    private final Provider<SceneInteractor> mSceneInteractor;
@@ -582,14 +584,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    private void handleSimSubscriptionInfoChanged() {
        Assert.isMainThread();
        mLogger.v("onSubscriptionInfoChanged()");
        mSimLogger.v("onSubscriptionInfoChanged()");
        List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */);
        if (!subscriptionInfos.isEmpty()) {
            for (SubscriptionInfo subInfo : subscriptionInfos) {
                mLogger.logSubInfo(subInfo);
                mSimLogger.logSubInfo(subInfo);
            }
        } else {
            mLogger.v("onSubscriptionInfoChanged: list is null");
            mSimLogger.v("onSubscriptionInfoChanged: list is null");
        }

        // Hack level over 9000: Because the subscription id is not yet valid when we see the
@@ -612,7 +614,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        while (iter.hasNext()) {
            Map.Entry<Integer, SimData> simData = iter.next();
            if (!activeSubIds.contains(simData.getKey())) {
                mLogger.logInvalidSubId(simData.getKey());
                mSimLogger.logInvalidSubId(simData.getKey());
                iter.remove();

                SimData data = simData.getValue();
@@ -1700,7 +1702,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    }
                    return;
                }
                mLogger.logSimStateFromIntent(action,
                mSimLogger.logSimStateFromIntent(action,
                        intent.getStringExtra(Intent.EXTRA_SIM_STATE),
                        args.slotId,
                        args.subId);
@@ -1720,7 +1722,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
                int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
                mLogger.logServiceStateIntent(action, serviceState, subId);
                mSimLogger.logServiceStateIntent(action, serviceState, subId);
                mHandler.sendMessage(
                        mHandler.obtainMessage(MSG_SERVICE_STATE_CHANGE, subId, 0, serviceState));
            } else if (TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED.equals(action)) {
@@ -2154,6 +2156,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            LatencyTracker latencyTracker,
            ActiveUnlockConfig activeUnlockConfiguration,
            KeyguardUpdateMonitorLogger logger,
            SimLogger simLogger,
            UiEventLogger uiEventLogger,
            // This has to be a provider because SessionTracker depends on KeyguardUpdateMonitor :(
            Provider<SessionTracker> sessionTrackerProvider,
@@ -2196,6 +2199,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mSensorPrivacyManager = sensorPrivacyManager;
        mActiveUnlockConfig = activeUnlockConfiguration;
        mLogger = logger;
        mSimLogger = simLogger;
        mUiEventLogger = uiEventLogger;
        mSessionTrackerProvider = sessionTrackerProvider;
        mTrustManager = trustManager;
@@ -3368,37 +3372,40 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
    }

    /**
     * Removes all valid subscription info from the map for the given slotId.
     */
    private void invalidateSlot(int slotId) {
        Iterator<Map.Entry<Integer, SimData>> iter = mSimDatas.entrySet().iterator();
        while (iter.hasNext()) {
            SimData data = iter.next().getValue();
            if (data.slotId == slotId && SubscriptionManager.isValidSubscriptionId(data.subId)) {
                mSimLogger.logInvalidSubId(data.subId);
                iter.remove();
            }
        }
    }

    /**
     * Handle {@link #MSG_SIM_STATE_CHANGE}
     */
    @VisibleForTesting
    void handleSimStateChange(int subId, int slotId, int state) {
        Assert.isMainThread();
        mLogger.logSimState(subId, slotId, state);
        mSimLogger.logSimState(subId, slotId, state);

        boolean becameAbsent = false;
        boolean becameAbsent = ABSENT_SIM_STATE_LIST.contains(state);
        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            mLogger.w("invalid subId in handleSimStateChange()");
            mSimLogger.w("invalid subId in handleSimStateChange()");
            /* Only handle No SIM(ABSENT) and Card Error(CARD_IO_ERROR) due to
             * handleServiceStateChange() handle other case */
            if (state == TelephonyManager.SIM_STATE_ABSENT) {
            if (state == TelephonyManager.SIM_STATE_ABSENT
                    || state == TelephonyManager.SIM_STATE_CARD_IO_ERROR) {
                updateTelephonyCapable(true);
                // Even though the subscription is not valid anymore, we need to notify that the
                // SIM card was removed so we can update the UI.
                becameAbsent = true;
                for (SimData data : mSimDatas.values()) {
                    // Set the SIM state of all SimData associated with that slot to ABSENT se we
                    // do not move back into PIN/PUK locked and not detect the change below.
                    if (data.slotId == slotId) {
                        data.simState = TelephonyManager.SIM_STATE_ABSENT;
                    }
                }
            } else if (state == TelephonyManager.SIM_STATE_CARD_IO_ERROR) {
                updateTelephonyCapable(true);
            }
            }

        becameAbsent |= ABSENT_SIM_STATE_LIST.contains(state);
            invalidateSlot(slotId);
        }

        // TODO(b/327476182): Preserve SIM_STATE_CARD_IO_ERROR sims in a separate data source.
        SimData data = mSimDatas.get(subId);
@@ -3428,10 +3435,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     */
    @VisibleForTesting
    void handleServiceStateChange(int subId, ServiceState serviceState) {
        mLogger.logServiceStateChange(subId, serviceState);
        mSimLogger.logServiceStateChange(subId, serviceState);

        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            mLogger.w("invalid subId in handleServiceStateChange()");
            mSimLogger.w("invalid subId in handleServiceStateChange()");
            return;
        } else {
            updateTelephonyCapable(true);
@@ -3711,7 +3718,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     */
    @MainThread
    public void reportSimUnlocked(int subId) {
        mLogger.logSimUnlocked(subId);
        mSimLogger.logSimUnlocked(subId);
        handleSimStateChange(subId, getSlotId(subId), TelephonyManager.SIM_STATE_READY);
    }

@@ -3870,6 +3877,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean refreshSimState(int subId, int slotId) {
        int state = mTelephonyManager.getSimState(slotId);
        SimData data = mSimDatas.get(subId);

        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            invalidateSlot(slotId);
        }

        final boolean changed;
        if (data == null) {
            data = new SimData(state, slotId, subId);
+45 −117
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.content.Intent
import android.hardware.biometrics.BiometricConstants.LockoutMode
import android.hardware.biometrics.BiometricSourceType
import android.os.PowerManager
import android.telephony.ServiceState
import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.TelephonyManager
@@ -34,7 +32,6 @@ import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.log.core.LogLevel.ERROR
import com.android.systemui.log.core.LogLevel.INFO
import com.android.systemui.log.core.LogLevel.VERBOSE
import com.android.systemui.log.core.LogLevel.WARNING
import com.android.systemui.log.dagger.KeyguardUpdateMonitorLog
@@ -63,7 +60,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            "ActiveUnlock",
            DEBUG,
            { str1 = reason },
            { "initiate active unlock triggerReason=$str1" }
            { "initiate active unlock triggerReason=$str1" },
        )
    }

@@ -75,7 +72,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "Skip requesting active unlock from wake reason that doesn't trigger face auth" +
                    " reason=${PowerManager.wakeReasonToString(int1)}"
            }
            },
        )
    }

@@ -92,7 +89,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            DEBUG,
            { bool1 = deviceProvisioned },
            { "DEVICE_PROVISIONED state = $bool1" }
            { "DEVICE_PROVISIONED state = $bool1" },
        )
    }

@@ -108,7 +105,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                str1 = originalErrMsg
                int1 = msgId
            },
            { "Face error received: $str1 msgId= $int1" }
            { "Face error received: $str1 msgId= $int1" },
        )
    }

@@ -117,7 +114,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            DEBUG,
            { int1 = authUserId },
            { "Face authenticated for wrong user: $int1" }
            { "Face authenticated for wrong user: $int1" },
        )
    }

@@ -130,7 +127,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            FP_LOG_TAG,
            DEBUG,
            { int1 = authUserId },
            { "Fingerprint authenticated for wrong user: $int1" }
            { "Fingerprint authenticated for wrong user: $int1" },
        )
    }

@@ -139,7 +136,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            FP_LOG_TAG,
            DEBUG,
            { int1 = userId },
            { "Fingerprint disabled by DPM for userId: $int1" }
            { "Fingerprint disabled by DPM for userId: $int1" },
        )
    }

@@ -148,7 +145,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            FP_LOG_TAG,
            DEBUG,
            { int1 = mode },
            { "handleFingerprintLockoutReset: $int1" }
            { "handleFingerprintLockoutReset: $int1" },
        )
    }

@@ -157,7 +154,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            FP_LOG_TAG,
            DEBUG,
            { int1 = fingerprintRunningState },
            { "fingerprintRunningState: $int1" }
            { "fingerprintRunningState: $int1" },
        )
    }

@@ -169,7 +166,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                bool1 = isStrongBiometric
            },
            { "Fingerprint auth successful: userId: $int1, isStrongBiometric: $bool1" }
            { "Fingerprint auth successful: userId: $int1, isStrongBiometric: $bool1" },
        )
    }

@@ -181,7 +178,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                bool1 = isStrongBiometric
            },
            { "Face detected: userId: $int1, isStrongBiometric: $bool1" }
            { "Face detected: userId: $int1, isStrongBiometric: $bool1" },
        )
    }

@@ -193,7 +190,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                bool1 = isStrongBiometric
            },
            { "Fingerprint detected: userId: $int1, isStrongBiometric: $bool1" }
            { "Fingerprint detected: userId: $int1, isStrongBiometric: $bool1" },
        )
    }

@@ -205,22 +202,13 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                str1 = originalErrMsg
                int1 = msgId
            },
            { "Fingerprint error received: $str1 msgId= $int1" }
        )
    }

    fun logInvalidSubId(subId: Int) {
        logBuffer.log(
            TAG,
            INFO,
            { int1 = subId },
            { "Previously active sub id $int1 is now invalid, will remove" }
            { "Fingerprint error received: $str1 msgId= $int1" },
        )
    }

    fun logPrimaryKeyguardBouncerChanged(
        primaryBouncerIsOrWillBeShowing: Boolean,
        primaryBouncerFullyShown: Boolean
        primaryBouncerFullyShown: Boolean,
    ) {
        logBuffer.log(
            TAG,
@@ -232,7 +220,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "handlePrimaryBouncerChanged " +
                    "primaryBouncerIsOrWillBeShowing=$bool1 primaryBouncerFullyShown=$bool2"
            }
            },
        )
    }

@@ -249,7 +237,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                bool2 = occluded
                bool3 = visible
            },
            { "keyguardShowingChanged(showing=$bool1 occluded=$bool2 visible=$bool3)" }
            { "keyguardShowingChanged(showing=$bool1 occluded=$bool2 visible=$bool3)" },
        )
    }

@@ -258,7 +246,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            ERROR,
            { int1 = userId },
            { "No Profile Owner or Device Owner supervision app found for User $int1" }
            { "No Profile Owner or Device Owner supervision app found for User $int1" },
        )
    }

@@ -279,7 +267,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int2 = delay
                str1 = "$errString"
            },
            { "Fingerprint scheduling retry auth after $int2 ms due to($int1) -> $str1" }
            { "Fingerprint scheduling retry auth after $int2 ms due to($int1) -> $str1" },
        )
    }

@@ -288,7 +276,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            WARNING,
            { int1 = retryCount },
            { "Retrying fingerprint attempt: $int1" }
            { "Retrying fingerprint attempt: $int1" },
        )
    }

@@ -306,32 +294,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "sendPrimaryBouncerChanged primaryBouncerIsOrWillBeShowing=$bool1 " +
                    "primaryBouncerFullyShown=$bool2"
            }
        )
    }

    fun logServiceStateChange(subId: Int, serviceState: ServiceState?) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = subId
                str1 = "$serviceState"
            },
            { "handleServiceStateChange(subId=$int1, serviceState=$str1)" }
        )
    }

    fun logServiceStateIntent(action: String?, serviceState: ServiceState?, subId: Int) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                str1 = action
                str2 = "$serviceState"
                int1 = subId
            },
            { "action $str1 serviceState=$str2 subId=$int1" }
        )
    }

@@ -344,51 +307,16 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                str1 = intent.getStringExtra(TelephonyManager.EXTRA_SPN)
                str2 = intent.getStringExtra(TelephonyManager.EXTRA_PLMN)
            },
            { "action SERVICE_PROVIDERS_UPDATED subId=$int1 spn=$str1 plmn=$str2" }
        )
    }

    fun logSimState(subId: Int, slotId: Int, state: Int) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = subId
                int2 = slotId
                long1 = state.toLong()
            },
            { "handleSimStateChange(subId=$int1, slotId=$int2, state=$long1)" }
            { "action SERVICE_PROVIDERS_UPDATED subId=$int1 spn=$str1 plmn=$str2" },
        )
    }

    fun logSimStateFromIntent(action: String?, extraSimState: String?, slotId: Int, subId: Int) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                str1 = action
                str2 = extraSimState
                int1 = slotId
                int2 = subId
            },
            { "action $str1 state: $str2 slotId: $int1 subid: $int2" }
        )
    }

    fun logSimUnlocked(subId: Int) {
        logBuffer.log(TAG, VERBOSE, { int1 = subId }, { "reportSimUnlocked(subId=$int1)" })
    }

    fun logSubInfo(subInfo: SubscriptionInfo?) {
        logBuffer.log(TAG, DEBUG, { str1 = "$subInfo" }, { "SubInfo:$str1" })
    }

    fun logTimeFormatChanged(newTimeFormat: String?) {
        logBuffer.log(
            TAG,
            DEBUG,
            { str1 = newTimeFormat },
            { "handleTimeFormatUpdate timeFormat=$str1" }
            { "handleTimeFormatUpdate timeFormat=$str1" },
        )
    }

@@ -402,7 +330,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {

    fun logUnexpectedFpCancellationSignalState(
        fingerprintRunningState: Int,
        unlockPossible: Boolean
        unlockPossible: Boolean,
    ) {
        logBuffer.log(
            TAG,
@@ -414,7 +342,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "Cancellation signal is not null, high chance of bug in " +
                    "fp auth lifecycle management. FP state: $int1, unlockPossible: $bool1"
            }
            },
        )
    }

@@ -425,7 +353,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
    fun logUserRequestedUnlock(
        requestOrigin: ActiveUnlockConfig.ActiveUnlockRequestOrigin,
        reason: String?,
        dismissKeyguard: Boolean
        dismissKeyguard: Boolean,
    ) {
        logBuffer.log(
            "ActiveUnlock",
@@ -435,7 +363,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                str2 = reason
                bool1 = dismissKeyguard
            },
            { "reportUserRequestedUnlock origin=$str1 reason=$str2 dismissKeyguard=$bool1" }
            { "reportUserRequestedUnlock origin=$str1 reason=$str2 dismissKeyguard=$bool1" },
        )
    }

@@ -443,7 +371,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        flags: Int,
        newlyUnlocked: Boolean,
        userId: Int,
        message: String?
        message: String?,
    ) {
        logBuffer.log(
            TAG,
@@ -457,7 +385,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "trustGrantedWithFlags[user=$int2] newlyUnlocked=$bool1 " +
                    "flags=${TrustGrantFlags(int1)} message=$str1"
            }
            },
        )
    }

@@ -470,7 +398,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                bool2 = isNowTrusted
                int1 = userId
            },
            { "onTrustChanged[user=$int1] wasTrusted=$bool1 isNowTrusted=$bool2" }
            { "onTrustChanged[user=$int1] wasTrusted=$bool1 isNowTrusted=$bool2" },
        )
    }

@@ -478,7 +406,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        secure: Boolean,
        canDismissLockScreen: Boolean,
        trusted: Boolean,
        trustManaged: Boolean
        trustManaged: Boolean,
    ) {
        logBuffer.log(
            "KeyguardState",
@@ -492,7 +420,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "#update secure=$bool1 canDismissKeyguard=$bool2" +
                    " trusted=$bool3 trustManaged=$bool4"
            }
            },
        )
    }

@@ -501,7 +429,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            VERBOSE,
            { bool1 = assistantVisible },
            { "TaskStackChanged for ACTIVITY_TYPE_ASSISTANT, assistant visible: $bool1" }
            { "TaskStackChanged for ACTIVITY_TYPE_ASSISTANT, assistant visible: $bool1" },
        )
    }

@@ -510,7 +438,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            VERBOSE,
            { bool1 = allow },
            { "allowFingerprintOnCurrentOccludingActivityChanged: $bool1" }
            { "allowFingerprintOnCurrentOccludingActivityChanged: $bool1" },
        )
    }

@@ -519,7 +447,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            VERBOSE,
            { bool1 = assistantVisible },
            { "Updating mAssistantVisible to new value: $bool1" }
            { "Updating mAssistantVisible to new value: $bool1" },
        )
    }

@@ -531,7 +459,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                bool1 = isStrongBiometric
                int1 = userId
            },
            { "reporting successful biometric unlock: isStrongBiometric: $bool1, userId: $int1" }
            { "reporting successful biometric unlock: isStrongBiometric: $bool1, userId: $int1" },
        )
    }

@@ -543,7 +471,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            {
                "MSG_BIOMETRIC_AUTHENTICATION_CONTINUE already queued up, " +
                    "ignoring updating FP listening state to $int1"
            }
            },
        )
    }

@@ -551,7 +479,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        userId: Int,
        oldValue: Boolean,
        newValue: Boolean,
        context: String
        context: String,
    ) {
        logBuffer.log(
            TAG,
@@ -568,7 +496,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                    "old: $bool1, " +
                    "new: $bool2 " +
                    "context: $str1"
            }
            },
        )
    }

@@ -591,7 +519,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                    "plugged=$str1, " +
                    "chargingStatus=$int2, " +
                    "maxChargingWattage= $long2}"
            }
            },
        )
    }

@@ -604,7 +532,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            DEBUG,
            { str1 = "$biometricSourceType" },
            { "notifying about enrollments changed: $str1" }
            { "notifying about enrollments changed: $str1" },
        )
    }

@@ -616,7 +544,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                str1 = context
            },
            { "userCurrentlySwitching: $str1, userId: $int1" }
            { "userCurrentlySwitching: $str1, userId: $int1" },
        )
    }

@@ -628,7 +556,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                str1 = context
            },
            { "userSwitchComplete: $str1, userId: $int1" }
            { "userSwitchComplete: $str1, userId: $int1" },
        )
    }

@@ -637,7 +565,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            FP_LOG_TAG,
            DEBUG,
            { int1 = acquireInfo },
            { "fingerprint acquire message: $int1" }
            { "fingerprint acquire message: $int1" },
        )
    }

@@ -646,7 +574,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            TAG,
            DEBUG,
            { bool1 = keepUnlocked },
            { "keepUnlockedOnFold changed to: $bool1" }
            { "keepUnlockedOnFold changed to: $bool1" },
        )
    }

@@ -662,7 +590,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                bool1 = isUnlocked
            },
            { "userStopped userId: $int1 isUnlocked: $bool1" }
            { "userStopped userId: $int1 isUnlocked: $bool1" },
        )
    }

@@ -678,7 +606,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
                int1 = userId
                bool1 = isUnlocked
            },
            { "userUnlockedInitialState userId: $int1 isUnlocked: $bool1" }
            { "userUnlockedInitialState userId: $int1 isUnlocked: $bool1" },
        )
    }
}
+131 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.keyguard.logging

import android.content.Intent
import android.telephony.ServiceState
import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.TelephonyManager
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.log.core.LogLevel.ERROR
import com.android.systemui.log.core.LogLevel.INFO
import com.android.systemui.log.core.LogLevel.VERBOSE
import com.android.systemui.log.core.LogLevel.WARNING
import com.android.systemui.log.dagger.SimLog
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject

private const val TAG = "SimLog"

/** Helper class for logging for SIM events */
class SimLogger @Inject constructor(@SimLog private val logBuffer: LogBuffer) {
    fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG)

    fun e(@CompileTimeConstant msg: String) = log(msg, ERROR)

    fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE)

    fun w(@CompileTimeConstant msg: String) = log(msg, WARNING)

    fun log(@CompileTimeConstant msg: String, level: LogLevel) = logBuffer.log(TAG, level, msg)

    fun logInvalidSubId(subId: Int) {
        logBuffer.log(
            TAG,
            INFO,
            { int1 = subId },
            { "Previously active sub id $int1 is now invalid, will remove" },
        )
    }

    fun logServiceStateChange(subId: Int, serviceState: ServiceState?) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = subId
                str1 = "$serviceState"
            },
            { "handleServiceStateChange(subId=$int1, serviceState=$str1)" },
        )
    }

    fun logServiceStateIntent(action: String?, serviceState: ServiceState?, subId: Int) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                str1 = action
                str2 = "$serviceState"
                int1 = subId
            },
            { "action $str1 serviceState=$str2 subId=$int1" },
        )
    }

    fun logServiceProvidersUpdated(intent: Intent) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                int1 = intent.getIntExtra(EXTRA_SUBSCRIPTION_INDEX, INVALID_SUBSCRIPTION_ID)
                str1 = intent.getStringExtra(TelephonyManager.EXTRA_SPN)
                str2 = intent.getStringExtra(TelephonyManager.EXTRA_PLMN)
            },
            { "action SERVICE_PROVIDERS_UPDATED subId=$int1 spn=$str1 plmn=$str2" },
        )
    }

    fun logSimState(subId: Int, slotId: Int, state: Int) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = subId
                int2 = slotId
                long1 = state.toLong()
            },
            { "handleSimStateChange(subId=$int1, slotId=$int2, state=$long1)" },
        )
    }

    fun logSimStateFromIntent(action: String?, extraSimState: String?, slotId: Int, subId: Int) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                str1 = action
                str2 = extraSimState
                int1 = slotId
                int2 = subId
            },
            { "action $str1 state: $str2 slotId: $int1 subid: $int2" },
        )
    }

    fun logSimUnlocked(subId: Int) {
        logBuffer.log(TAG, VERBOSE, { int1 = subId }, { "reportSimUnlocked(subId=$int1)" })
    }

    fun logSubInfo(subInfo: SubscriptionInfo?) {
        logBuffer.log(TAG, DEBUG, { str1 = "$subInfo" }, { "SubInfo:$str1" })
    }
}
+10 −0

File changed.

Preview size limit exceeded, changes collapsed.

+22 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading