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

Commit a564a440 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add metrics for data stall recovery enhancement"

parents fc244159 c226db00
Loading
Loading
Loading
Loading
+35 −19
Original line number Diff line number Diff line
@@ -592,38 +592,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
@@ -54,13 +54,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();
        }
@@ -99,6 +101,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,
@@ -112,7 +127,10 @@ public class DataStallRecoveryStats {
                durationMillis,
                reason,
                otherSignalStrength,
                otherNetworkRegState);
                otherNetworkRegState,
                phoneNetworkRegState,
                isFirstValidation,
                phoneId);
    }

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