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

Commit 1caf1930 authored by Willy Hu's avatar Willy Hu
Browse files

Add metrics for data stall recovery enhancement

MDR: https://eldar.corp.google.com/assessments/296451350/drafts/988759905?jsmode=o

Bug: 262382363
Test: atest DataStallRecoveryManagerTest passed
Change-Id: I173e936315c9976a4dcbc592273e74388233f90b
Merged-In: I173e936315c9976a4dcbc592273e74388233f90b
parent f8a39d28
Loading
Loading
Loading
Loading
+35 −19
Original line number Diff line number Diff line
@@ -587,38 +587,54 @@ public class DataStallRecoveryManager extends Handler {
     * @param isValid true for validation passed & false for validation failed
     */
    private void setNetworkValidationState(boolean isValid) {
        boolean isLogNeeded = false;
        int timeDuration = 0;
        boolean isFirstDataStall = false;
        boolean isFirstValidationAfterDoRecovery = false;
        @RecoveredReason int reason = getRecoveredReason(isValid);
        // Validation status is true and was not data stall.
        if (isValid && !mDataStalled) {
            return;
        }

        if (!mDataStalled) {
            // First data stall
            isLogNeeded = true;
            mDataStalled = true;
            mDataStallStartMs = SystemClock.elapsedRealtime();
            logl("data stall: start time = " + DataUtils.elapsedTimeToString(mDataStallStartMs));
            return;
            isFirstDataStall = true;
        } else if (!mLastActionReported) {
            // When the first validation status appears, enter this block.
            isLogNeeded = true;
            timeDuration = (int) (SystemClock.elapsedRealtime() - mDataStallStartMs);
            mLastActionReported = true;
            isFirstValidationAfterDoRecovery = true;
        }

        if (!mLastActionReported) {
            @RecoveredReason int reason = getRecoveredReason(isValid);
            int timeDuration = (int) (SystemClock.elapsedRealtime() - mDataStallStartMs);
        if (isValid) {
            // When the validation passed(mobile data resume), enter this block.
            isLogNeeded = true;
            timeDuration = (int) (SystemClock.elapsedRealtime() - mDataStallStartMs);
            mLastActionReported = false;
            mDataStalled = false;
        }

        if (isLogNeeded) {
            DataStallRecoveryStats.onDataStallEvent(
                    mLastAction, mPhone, isValid, timeDuration, reason,
                    isFirstValidationAfterDoRecovery);
            logl(
                    "data stall: lastaction = "
                    "data stall: "
                    + (isFirstDataStall == true ? "start" : isValid == false ? "in process" : "end")
                    + ", lastaction="
                    + recoveryActionToString(mLastAction)
                    + ", isRecovered="
                    + isValid
                    + ", reason="
                    + recoveredReasonToString(reason)
                    + ", isFirstValidationAfterDoRecovery="
                    + isFirstValidationAfterDoRecovery
                    + ", TimeDuration="
                    + timeDuration);
            DataStallRecoveryStats.onDataStallEvent(
                    mLastAction, mPhone, isValid, timeDuration, reason);
            mLastActionReported = true;
        }

        if (isValid) {
            mLastActionReported = false;
            mDataStalled = false;
        }
    }

+20 −2
Original line number Diff line number Diff line
@@ -52,13 +52,15 @@ public class DataStallRecoveryStats {
     * @param isRecovered The data stall symptom recovered or not.
     * @param durationMillis The duration from data stall symptom occurred.
     * @param reason The recovered(data resume) reason.
     * @param isFirstValidation The validation status if it's the first come after recovery.
     */
    public static void onDataStallEvent(
            @DataStallRecoveryManager.RecoveryAction int recoveryAction,
            Phone phone,
            boolean isRecovered,
            int durationMillis,
            @DataStallRecoveryManager.RecoveredReason int reason) {
            @DataStallRecoveryManager.RecoveredReason int reason,
            boolean isFirstValidation) {
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS) {
            phone = phone.getDefaultPhone();
        }
@@ -97,6 +99,19 @@ public class DataStallRecoveryStats {
            }
        }

        // the number returned here matches the NetworkRegistrationState enum we have
        int phoneNetworkRegState = NetworkRegistrationInfo
                .REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING;

        NetworkRegistrationInfo phoneRegInfo = phone.getServiceState()
                        .getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                                AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (phoneRegInfo != null) {
            phoneNetworkRegState = phoneRegInfo.getRegistrationState();
        }

        int phoneId = phone.getPhoneId();

        TelephonyStatsLog.write(
                TelephonyStatsLog.DATA_STALL_RECOVERY_REPORTED,
                carrierId,
@@ -110,7 +125,10 @@ public class DataStallRecoveryStats {
                durationMillis,
                reason,
                otherSignalStrength,
                otherNetworkRegState);
                otherNetworkRegState,
                phoneNetworkRegState,
                isFirstValidation,
                phoneId);
    }

    /** Returns the RAT used for data (including IWLAN). */