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

Commit d8463463 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I0dc4641d,I99a304e7

* changes:
  Log raw fail cause to metrics
  Add unsatisfied NetworkRequest if retry networkRequest have been removed.
parents 9e2172fd 115e8ab3
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -2481,7 +2481,8 @@ public class DataNetwork extends StateMachine {
                getDataNetworkType(),
                apnTypeBitmask,
                protocol,
                mFailCause);
                // Log the raw fail cause to avoid large amount of UNKNOWN showing on metrics.
                response != null ? response.getCause() : mFailCause);
    }

    /**
@@ -3295,7 +3296,7 @@ public class DataNetwork extends StateMachine {
            mDataNetworkCallback.invokeFromExecutor(
                    () -> mDataNetworkCallback.onHandoverFailed(DataNetwork.this,
                            mFailCause, retry, handoverFailureMode));
            trackHandoverFailure();
            trackHandoverFailure(response != null ? response.getCause() : mFailCause);
        }

        // No matter handover succeeded or not, transit back to connected state.
@@ -3305,13 +3306,15 @@ public class DataNetwork extends StateMachine {
    /**
     * Called when handover failed. Record the source and target RAT{@link NetworkType} and the
     * failure cause {@link android.telephony.DataFailCause}.
     *
     * @param cause The fail cause.
     */
    private void trackHandoverFailure() {
    private void trackHandoverFailure(int cause) {
        int sourceRat = getDataNetworkType();
        int targetTransport = DataUtils.getTargetTransport(mTransport);
        int targetRat = getDataNetworkType(targetTransport);

        mDataCallSessionStats.onHandoverFailure(mFailCause, sourceRat, targetRat);
        mDataCallSessionStats.onHandoverFailure(cause, sourceRat, targetRat);
    }

    /**
+11 −0
Original line number Diff line number Diff line
@@ -2684,11 +2684,22 @@ public class DataNetworkController extends Handler {
        NetworkRequestList requestList = new NetworkRequestList(
                dataSetupRetryEntry.networkRequestList);
        requestList.removeIf(request -> !mAllNetworkRequestList.contains(request));
        // Retrieves the newly added unsatisfied NetworkRequest if all NetworkRequests in the
        // DataSetupRetryEntry have already been removed.
        if (requestList.isEmpty()) {
            List<NetworkRequestList> groupRequestLists = getGroupedUnsatisfiedNetworkRequests();
            dataSetupRetryEntry.networkRequestList.stream()
                    .filter(request -> groupRequestLists.stream()
                            .anyMatch(groupRequestList -> groupRequestList
                                    .get(request.getCapabilities()) != null))
                    .forEach(requestList::add);
        }
        if (requestList.isEmpty()) {
            loge("onDataNetworkSetupRetry: Request list is empty. Abort retry.");
            dataSetupRetryEntry.setState(DataRetryEntry.RETRY_STATE_CANCELLED);
            return;
        }
        log("onDataNetworkSetupRetry: Request list:" + requestList);
        TelephonyNetworkRequest telephonyNetworkRequest = requestList.get(0);

        int networkCapability = telephonyNetworkRequest.getApnTypeNetworkCapability();
+2 −2
Original line number Diff line number Diff line
@@ -81,14 +81,14 @@ public class DataCallSessionStats {
     * @param currentRat The data call current Network Type
     * @param apnTypeBitmask APN type bitmask
     * @param protocol Data connection protocol
     * @param failureCause failure cause as per android.telephony.DataFailCause
     * @param failureCause The raw failure cause from modem/IWLAN data service.
     */
    public synchronized void onSetupDataCallResponse(
            @Nullable DataCallResponse response,
            @NetworkType int currentRat,
            @ApnType int apnTypeBitmask,
            @ProtocolType int protocol,
            @DataFailureCause int failureCause) {
            int failureCause) {
        // there should've been a call to onSetupDataCall to initiate the atom,
        // so this method is being called out of order -> no metric will be logged
        if (mDataCallSession == null) {
+58 −0
Original line number Diff line number Diff line
@@ -2717,6 +2717,64 @@ public class DataNetworkControllerTest extends TelephonyTest {
                any(), any(), anyBoolean(), any(Message.class));
    }

    @Test
    public void testSetupDataNetworkRetryFailedNetworkRequestRemovedAndAdded() throws Exception {
        mDataNetworkControllerUT.getDataRetryManager()
                .registerCallback(mMockedDataRetryManagerCallback);
        setFailedSetupDataResponse(mMockedWwanDataServiceManager, DataFailCause.CONGESTION,
                10000, false);

        TelephonyNetworkRequest firstTnr = createNetworkRequest(
                NetworkCapabilities.NET_CAPABILITY_IMS);
        TelephonyNetworkRequest secondTnr = createNetworkRequest(
                NetworkCapabilities.NET_CAPABILITY_IMS);

        mDataNetworkControllerUT.addNetworkRequest(firstTnr);
        processAllMessages();

        mDataNetworkControllerUT.removeNetworkRequest(firstTnr);
        mDataNetworkControllerUT.addNetworkRequest(secondTnr);
        processAllFutureMessages();

        verify(mMockedWwanDataServiceManager, times(1)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));

        ArgumentCaptor<DataRetryManager.DataSetupRetryEntry> retryEntry =
                ArgumentCaptor.forClass(DataRetryManager.DataSetupRetryEntry.class);
        verify(mMockedDataRetryManagerCallback, times(1))
                .onDataNetworkSetupRetry(retryEntry.capture());
        assertThat(retryEntry.getValue().getState()).isEqualTo(
                DataRetryManager.DataRetryEntry.RETRY_STATE_FAILED);
        assertThat(retryEntry.getValue().networkRequestList.size()).isEqualTo(1);
        assertThat(retryEntry.getValue().networkRequestList.get(0)).isEqualTo(firstTnr);

        DataRetryManager.DataSetupRetryEntry dataSetupRetryEntry = retryEntry.getValue();
        logd("DataSetupRetryEntry:" + dataSetupRetryEntry);

        processAllMessages();
        processAllFutureMessages();

        setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 1);
        logd("Sending TAC_CHANGED event");
        mDataNetworkControllerUT.obtainMessage(25/*EVENT_TAC_CHANGED*/).sendToTarget();
        mDataNetworkControllerUT.getDataRetryManager().obtainMessage(10/*EVENT_TAC_CHANGED*/)
                .sendToTarget();
        processAllFutureMessages();

        // TAC changes should clear the already-scheduled retry and throttling.
        assertThat(mDataNetworkControllerUT.getDataRetryManager().isAnySetupRetryScheduled(
                mImsCellularDataProfile, AccessNetworkConstants.TRANSPORT_TYPE_WWAN)).isFalse();

        // But DNC should re-evaluate unsatisfied request and setup IMS again.
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                NetworkCapabilities.NET_CAPABILITY_MMTEL);

        verify(mMockedWwanDataServiceManager, times(2)).setupDataCall(anyInt(),
                any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                any(), any(), anyBoolean(), any(Message.class));
    }

    @Test
    public void testSetupDataNetworkPermanentFailure() {
        setFailedSetupDataResponse(mMockedWwanDataServiceManager, DataFailCause.PROTOCOL_ERRORS,