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

Commit e62467d7 authored by Willy Hu's avatar Willy Hu Committed by Automerger Merge Worker
Browse files

Modify the functions to meet the Android T new design am: cd92e0cc am: c2021a86

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2032439

Change-Id: I92e95ec2cc7a615976fb44300187abad4cc49e08
parents cc9bcb7c c2021a86
Loading
Loading
Loading
Loading
+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). */