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

Commit f67e0fee authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11192287 from f3faa1aa to 24Q1-release

Change-Id: I9749d9ba32d05583e8433ebd0b3cddc597d1ea84
parents 92044cb2 f3faa1aa
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -22,9 +22,11 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.telephony.AccessNetworkConstants.RadioAccessNetworkType;
import android.telephony.Annotation.DisconnectCauses;
import android.telephony.DisconnectCause;
import android.telephony.DomainSelectionService;
import android.telephony.DomainSelectionService.EmergencyScanType;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PreciseDisconnectCause;
import android.telephony.ims.ImsReasonInfo;

import com.android.internal.telephony.Phone;
@@ -37,6 +39,9 @@ import java.util.concurrent.CompletableFuture;
public class NormalCallDomainSelectionConnection extends DomainSelectionConnection {

    private static final boolean DBG = false;
    private int mDisconnectCause = DisconnectCause.NOT_VALID;
    private int mPreciseDisconnectCause = PreciseDisconnectCause.NOT_VALID;
    private String mReasonMessage = null;

    private @Nullable DomainSelectionConnectionCallback mCallback;

@@ -123,4 +128,49 @@ public class NormalCallDomainSelectionConnection extends DomainSelectionConnecti
        }
        return builder.build();
    }

    /**
     * Save call disconnect info for error propagation.
     * @param disconnectCause The code for the reason for the disconnect.
     * @param preciseDisconnectCause The code for the precise reason for the disconnect.
     * @param reasonMessage Description of the reason for the disconnect, not intended for the user
     *                      to see.
     */
    public void setDisconnectCause(int disconnectCause, int preciseDisconnectCause,
                                String reasonMessage) {
        mDisconnectCause = disconnectCause;
        mPreciseDisconnectCause = preciseDisconnectCause;
        mReasonMessage = reasonMessage;
    }

    public int getDisconnectCause() {
        return mDisconnectCause;
    }

    public int getPreciseDisconnectCause() {
        return mPreciseDisconnectCause;
    }

    public String getReasonMessage() {
        return mReasonMessage;
    }

    /**
     * @return imsReasonInfo Reason for the IMS call failure.
     */
    public @Nullable ImsReasonInfo getImsReasonInfo() {
        if (getSelectionAttributes() == null) {
            // Neither selectDomain(...) nor reselectDomain(...) has been called yet.
            return null;
        }

        return getSelectionAttributes().getPsDisconnectCause();
    }

    /**
     * @return phoneId To support localized message based on phoneId
     */
    public int getPhoneId() {
        return getPhone().getPhoneId();
    }
}
+31 −5
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import static com.android.internal.telephony.TelephonyStatsLog.UCE_EVENT_STATS;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_RAT_USAGE;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__CALL_DURATION__CALL_DURATION_UNKNOWN;
import static com.android.internal.telephony.util.TelephonyUtils.IS_DEBUGGABLE;

import android.app.StatsManager;
import android.content.Context;
@@ -135,6 +136,15 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
    private static final long MIN_COOLDOWN_MILLIS =
            DBG ? 10L * MILLIS_PER_SECOND : 23L * MILLIS_PER_HOUR;

    /**
     * Sets atom pull cool down to 4 minutes for userdebug build.
     *
     * <p>Applies to certain atoms: CellularServiceState.
     */
    private static final long CELL_SERVICE_MIN_COOLDOWN_MILLIS =
            DBG ? 10L * MILLIS_PER_SECOND :
                    IS_DEBUGGABLE ? 4L * MILLIS_PER_MINUTE : 23L * MILLIS_PER_HOUR;

    /**
     * Buckets with less than these many calls will be dropped.
     *
@@ -142,10 +152,18 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
     */
    private static final long MIN_CALLS_PER_BUCKET = DBG ? 0L : 5L;

    /** Bucket size in milliseconds to round call durations into. */
    /** Bucket size in milliseconds to round call durations info. */
    private static final long DURATION_BUCKET_MILLIS =
            DBG ? 2L * MILLIS_PER_SECOND : 5L * MILLIS_PER_MINUTE;

    /**
     * Sets smaller bucket size to round call durations for userdebug build.
     *
     * <p>Applies to certain atoms: CellularServiceState.
     */
    private static final long CELL_SERVICE_DURATION_BUCKET_MILLIS =
            DBG || IS_DEBUGGABLE ? 2L * MILLIS_PER_SECOND : 5L * MILLIS_PER_MINUTE;

    private final PersistAtomsStorage mStorage;
    private final DeviceStateHelper mDeviceStateHelper;
    private final StatsManager mStatsManager;
@@ -510,7 +528,7 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
        // Include the latest durations
        concludeServiceStateStats();
        CellularServiceState[] persistAtoms =
                mStorage.getCellularServiceStates(MIN_COOLDOWN_MILLIS);
                mStorage.getCellularServiceStates(CELL_SERVICE_MIN_COOLDOWN_MILLIS);
        if (persistAtoms != null) {
            // list is already shuffled when instances were inserted
            Arrays.stream(persistAtoms)
@@ -930,7 +948,8 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
                state.simSlotIndex,
                state.isMultiSim,
                state.carrierId,
                roundAndConvertMillisToSeconds(state.totalTimeMillis),
                roundAndConvertMillisToSeconds(state.totalTimeMillis,
                        CELL_SERVICE_DURATION_BUCKET_MILLIS),
                state.isEmergencyOnly,
                state.isInternetPdnUp,
                state.foldState,
@@ -1364,8 +1383,15 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
     * Rounds the duration and converts it from milliseconds to seconds.
     */
    private static int roundAndConvertMillisToSeconds(long valueMillis) {
        long roundedValueMillis = Math.round((double) valueMillis / DURATION_BUCKET_MILLIS)
                * DURATION_BUCKET_MILLIS;
        return roundAndConvertMillisToSeconds(valueMillis, DURATION_BUCKET_MILLIS);
    }

    /**
     * Rounds the duration and converts it from milliseconds to seconds.
     */
    private static int roundAndConvertMillisToSeconds(long valueMillis, long durationBucketSize) {
        long roundedValueMillis = Math.round((double) valueMillis / durationBucketSize)
                * durationBucketSize;
        return (int) (roundedValueMillis / MILLIS_PER_SECOND);
    }

+5 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.internal.telephony.TelephonyStatsLog.SIM_SLOT_STATE;
import static com.android.internal.telephony.TelephonyStatsLog.SUPPORTED_RADIO_ACCESS_FAMILY;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_RAT_USAGE;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION;
import static com.android.internal.telephony.util.TelephonyUtils.IS_DEBUGGABLE;

import static com.google.common.truth.Truth.assertThat;

@@ -67,6 +68,8 @@ public class MetricsCollectorTest extends TelephonyTest {
                    .setCoolDownMillis(24L * 3600L * 1000L)
                    .build();
    private static final long MIN_COOLDOWN_MILLIS = 23L * 3600L * 1000L;
    private static final long CELL_SERVICE_MIN_COOLDOWN_MILLIS =
            IS_DEBUGGABLE ? 4L *  60L * 1000L : MIN_COOLDOWN_MILLIS;
    private static final long MIN_CALLS_PER_BUCKET = 5L;

    // NOTE: these fields are currently 32-bit internally and padded to 64-bit by TelephonyManager
@@ -398,7 +401,8 @@ public class MetricsCollectorTest extends TelephonyTest {

        assertThat(actualAtoms).hasSize(0);
        assertThat(result).isEqualTo(StatsManager.PULL_SKIP);
        verify(mPersistAtomsStorage, times(1)).getCellularServiceStates(eq(MIN_COOLDOWN_MILLIS));
        verify(mPersistAtomsStorage, times(1)).getCellularServiceStates(
                eq(CELL_SERVICE_MIN_COOLDOWN_MILLIS));
        verifyNoMoreInteractions(mPersistAtomsStorage);
    }