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

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

Merge changes from topic "data-stall-metrics"

* changes:
  Add the recovered reason into metrics
  Modify the functions to meet the Android T new design
parents b4e8f589 121ea5fe
Loading
Loading
Loading
Loading
+69 −5
Original line number Diff line number Diff line
@@ -74,23 +74,45 @@ public class DataStallRecoveryManager extends Handler {
     * etc) using RIL_REQUEST_GET_DATA_CALL_LIST.  This will help in cases where the data stall
     * occurred because of a link property changed but not notified to connectivity service.
     */
    private static final int RECOVERY_ACTION_GET_DATA_CALL_LIST = 0;
    public static final int RECOVERY_ACTION_GET_DATA_CALL_LIST = 0;

    /* DataStallRecoveryManager will request DataNetworkController to reestablish internet using
     * RIL_REQUEST_DEACTIVATE_DATA_CALL and sets up the data call back using SETUP_DATA_CALL.
     * It will help to reestablish the channel between RIL and modem.
     */
    private static final int RECOVERY_ACTION_CLEANUP = 1;
    public static final int RECOVERY_ACTION_CLEANUP = 1;

    // TODO: b/214662910: Align the recovery action between DataStallRecoveryManager and Westworld.
    /* DataStallRecoveryManager will request ServiceStateTracker to send RIL_REQUEST_RADIO_POWER
     * to restart radio. It will restart the radio and re-attch to the network.
     */
    private static final int RECOVERY_ACTION_RADIO_RESTART = 2;
    public static final int RECOVERY_ACTION_RADIO_RESTART = 2;

    /* DataStallRecoveryManager will request to reboot modem using NV_RESET_CONFIG. It will recover
     * if there is a problem in modem side.
     */
    private static final int RECOVERY_ACTION_RESET_MODEM = 3;
    public static final int RECOVERY_ACTION_RESET_MODEM = 3;

    /** Recovered reason taken in case of data stall recovered */
    @IntDef(
            value = {
                RECOVERED_REASON_NONE,
                RECOVERED_REASON_DSRM,
                RECOVERED_REASON_MODEM,
                RECOVERED_REASON_USER
            })
    @Retention(RetentionPolicy.SOURCE)
    public @interface RecoveredReason {};

    /** The reason when data stall recovered. */
    /** The data stall not recovered yet. */
    private static final int RECOVERED_REASON_NONE = 0;
    /** The data stall recovered by our DataStallRecoveryManager. */
    private static final int RECOVERED_REASON_DSRM = 1;
    /** The data stall recovered by modem(Radio Power off/on). */
    private static final int RECOVERED_REASON_MODEM = 2;
    /** The data stall recovered by user (Mobile Data Power off/on). */
    private static final int RECOVERED_REASON_USER = 3;

    /** Event for data config updated. */
    private static final int EVENT_DATA_CONFIG_UPDATED = 1;
@@ -518,15 +540,19 @@ public class DataStallRecoveryManager extends Handler {
        }

        if (!mLastActionReported) {
            @RecoveredReason int reason = getRecoveredReason(isValid);
            int timeDuration = (int) (SystemClock.elapsedRealtime() - mDataStallStartMs);
            logl(
                    "data stall: lastaction = "
                            + recoveryActionToString(mLastAction)
                            + ", isRecovered = "
                            + isValid
                            + ", reason = "
                            + recoveredReasonToString(reason)
                            + ", TimeDuration = "
                            + timeDuration);
            DataStallRecoveryStats.onDataStallEvent(mLastAction, mPhone, isValid, timeDuration);
            DataStallRecoveryStats.onDataStallEvent(
                    mLastAction, mPhone, isValid, timeDuration, reason);
            mLastActionReported = true;
        }

@@ -536,6 +562,23 @@ public class DataStallRecoveryManager extends Handler {
        }
    }

    /**
     * Get the data stall recovered reason.
     *
     * @param isValid true for validation passed & false for validation failed
     */
    private int getRecoveredReason(boolean isValid) {
        if (!isValid) return RECOVERED_REASON_NONE;

        if (mRadioStateChangedDuringDataStall) {
            return RECOVERED_REASON_MODEM;
        } else if (mMobileDataChangedToEnabledDuringDataStall) {
            return RECOVERED_REASON_USER;
        } else {
            return RECOVERED_REASON_DSRM;
        }
    }

    /** Perform a series of data stall recovery actions. */
    private void doRecovery() {
        @RecoveryAction final int recoveryAction = getRecoveryAction();
@@ -578,6 +621,27 @@ public class DataStallRecoveryManager extends Handler {
        startNetworkCheckTimer(mLastAction);
    }

    /**
     * Convert @RecoveredReason to string
     *
     * @param reason The recovered reason.
     * @return The recovered reason in string format.
     */
    private static @NonNull String recoveredReasonToString(@RecoveredReason int reason) {
        switch (reason) {
            case RECOVERED_REASON_NONE:
                return "RECOVERED_REASON_NONE";
            case RECOVERED_REASON_DSRM:
                return "RECOVERED_REASON_DSRM";
            case RECOVERED_REASON_MODEM:
                return "RECOVERED_REASON_MODEM";
            case RECOVERED_REASON_USER:
                return "RECOVERED_REASON_USER";
            default:
                return "Unknown(" + reason + ")";
        }
    }

    /**
     * Convert RadioPowerState to string
     *
+0 −3
Original line number Diff line number Diff line
@@ -357,9 +357,6 @@ public class DcTracker extends Handler {
    // it effect the PhysicalLinkStatusChanged
    private boolean mLteEndcUsingUserDataForRrcDetection = false;

    // stats per data call recovery event
    private DataStallRecoveryStats mDataStallRecoveryStats;

    /* List of SubscriptionPlans, updated when initialized and when plans are changed. */
    private List<SubscriptionPlan> mSubscriptionPlans = null;
    /* List of network types an unmetered override applies to, set by onSubscriptionOverride
+60 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.TelephonyStatsLog;
import com.android.internal.telephony.data.DataStallRecoveryManager;
import com.android.internal.telephony.dataconnection.DcTracker;

/** Generates metrics related to data stall recovery events per phone ID for the pushed atom. */
@@ -35,6 +36,13 @@ public class DataStallRecoveryStats {
     * @param recoveryAction Data stall recovery action
     * @param phone
     */

    /* Since the Enum has been extended in Android T, we are mapping it to the correct number. */
    private static final int RECOVERY_ACTION_RADIO_RESTART_MAPPING = 3;
    private static final int RECOVERY_ACTION_RESET_MODEM_MAPPING = 4;


    /** TODO: b/214044479 : Remove this function when new data design(Android T) start. */
    public static void onDataStallEvent(
            @DcTracker.RecoveryAction int recoveryAction,
            Phone phone,
@@ -53,6 +61,56 @@ public class DataStallRecoveryStats {
        boolean isOpportunistic = getIsOpportunistic(phone);
        boolean isMultiSim = SimSlotState.getCurrentState().numActiveSims > 1;

        // Not use this field in Android S, so we send RECOVERED_REASON_NONE for default value.
        int recoveryReason = 0;
        TelephonyStatsLog.write(
                TelephonyStatsLog.DATA_STALL_RECOVERY_REPORTED,
                carrierId,
                rat,
                signalStrength,
                recoveryAction,
                isOpportunistic,
                isMultiSim,
                band,
                isRecovered,
                durationMillis,
                recoveryReason);
    }

    /**
     * Called when data stall happened.
     *
     * @param recoveryAction The recovery action.
     * @param phone The phone instance.
     * @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.
     */
    public static void onDataStallEvent(
            @DataStallRecoveryManager.RecoveryAction int recoveryAction,
            Phone phone,
            boolean isRecovered,
            int durationMillis,
            @DataStallRecoveryManager.RecoveredReason int reason) {
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS) {
            phone = phone.getDefaultPhone();
        }

        int carrierId = phone.getCarrierId();
        int rat = getRat(phone);
        int band =
                (rat == TelephonyManager.NETWORK_TYPE_IWLAN) ? 0 : ServiceStateStats.getBand(phone);
        // the number returned here matches the SignalStrength enum we have
        int signalStrength = phone.getSignalStrength().getLevel();
        boolean isOpportunistic = getIsOpportunistic(phone);
        boolean isMultiSim = SimSlotState.getCurrentState().numActiveSims > 1;

        if (recoveryAction == DataStallRecoveryManager.RECOVERY_ACTION_RADIO_RESTART) {
            recoveryAction = RECOVERY_ACTION_RADIO_RESTART_MAPPING;
        } else if (recoveryAction == DataStallRecoveryManager.RECOVERY_ACTION_RESET_MODEM) {
            recoveryAction = RECOVERY_ACTION_RESET_MODEM_MAPPING;
        }

        TelephonyStatsLog.write(
                TelephonyStatsLog.DATA_STALL_RECOVERY_REPORTED,
                carrierId,
@@ -63,7 +121,8 @@ public class DataStallRecoveryStats {
                isMultiSim,
                band,
                isRecovered,
                durationMillis);
                durationMillis,
                reason);
    }

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