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

Commit a6ccce8b authored by Jordan Liu's avatar Jordan Liu
Browse files

Pass call quality up through platform

Test: builds
Bug: 110107501
Change-Id: Id8c26ae8adec4cfa85b3c6581db00b5aaa72a5c2
parent b4f3759b
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.net.NetworkCapabilities;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.CallQuality;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.DataFailCause;
@@ -270,7 +271,8 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
                mRegistry.notifyPreciseCallState(
                        convertPreciseCallState(ringingCall.getState()),
                        convertPreciseCallState(foregroundCall.getState()),
                        convertPreciseCallState(backgroundCall.getState()));
                        convertPreciseCallState(backgroundCall.getState()),
                        sender.getPhoneId());
            } catch (RemoteException ex) {
                // system process is dead
            }
@@ -373,6 +375,17 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        }
    }

    @Override
    public void notifyCallQualityChanged(Phone sender, CallQuality callQuality) {
        try {
            if (mRegistry != null) {
                mRegistry.notifyCallQualityChanged(callQuality, sender.getPhoneId());
            }
        } catch (RemoteException ex) {
            // system process is dead
        }
    }

    /**
     * Convert the {@link Phone.DataActivityState} enum into the TelephonyManager.DATA_* constants
     * for the public API.
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.telephony.CallQuality;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.DataFailCause;
@@ -80,4 +81,7 @@ public interface PhoneNotifier {

    /** Notify of change to EmergencyNumberList. */
    void notifyEmergencyNumberList();

    /** Notify of a change to the call quality of an active foreground call. */
    void notifyCallQualityChanged(Phone sender, CallQuality callQuality);
}
+5 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.RegistrantList;
import android.os.SystemProperties;
import android.telephony.CallQuality;
import android.telephony.NetworkScanRequest;
import android.telephony.Rlog;
import android.telephony.ServiceState;
@@ -133,6 +134,10 @@ abstract class ImsPhoneBase extends Phone {
        mTtyModeReceivedRegistrants.notifyRegistrants(result);
    }

    public void onCallQualityChanged(CallQuality callQuality) {
        mNotifier.notifyCallQualityChanged(this, callQuality);
    }

    @Override
    public ServiceState getServiceState() {
        // FIXME: we may need to provide this when data connectivity is lost
+10 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.provider.Settings;
import android.telecom.ConferenceParticipant;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.CallQuality;
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
@@ -2752,6 +2753,15 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                conn.updateMultipartyState(isMultiParty);
            }
        }

        /**
         * Handles a change to the call quality for an {@code ImsCall}.
         * Notifies apps through the System API {@link PhoneStateListener#onCallAttributesChanged}.
         */
        @Override
        public void onCallQualityChanged(ImsCall imsCall, CallQuality callQuality) {
            mPhone.onCallQualityChanged(callQuality);
        }
    };

    /**
+11 −7
Original line number Diff line number Diff line
@@ -189,45 +189,49 @@ public class DefaultPhoneNotifierTest extends TelephonyTest {

        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(anyInt(), anyInt(),
                anyInt());
                anyInt(), anyInt());

        doReturn(mForeGroundCall).when(mPhone).getForegroundCall();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(anyInt(), anyInt(),
                anyInt());
                anyInt(), anyInt());

        doReturn(mBackGroundCall).when(mPhone).getBackgroundCall();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(0)).notifyPreciseCallState(anyInt(), anyInt(),
                anyInt());
                anyInt(), anyInt());

        doReturn(mRingingCall).when(mPhone).getRingingCall();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_IDLE);
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                mPhone.getPhoneId());

        doReturn(Call.State.ACTIVE).when(mForeGroundCall).getState();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_ACTIVE,
                PreciseCallState.PRECISE_CALL_STATE_IDLE);
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                mPhone.getPhoneId());

        doReturn(Call.State.HOLDING).when(mBackGroundCall).getState();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                PreciseCallState.PRECISE_CALL_STATE_IDLE,
                PreciseCallState.PRECISE_CALL_STATE_ACTIVE,
                PreciseCallState.PRECISE_CALL_STATE_HOLDING);
                PreciseCallState.PRECISE_CALL_STATE_HOLDING,
                mPhone.getPhoneId());

        doReturn(Call.State.ALERTING).when(mRingingCall).getState();
        mDefaultPhoneNotifierUT.notifyPreciseCallState(mPhone);
        verify(mTelephonyRegisteryMock, times(1)).notifyPreciseCallState(
                PreciseCallState.PRECISE_CALL_STATE_ALERTING,
                PreciseCallState.PRECISE_CALL_STATE_ACTIVE,
                PreciseCallState.PRECISE_CALL_STATE_HOLDING);
                PreciseCallState.PRECISE_CALL_STATE_HOLDING,
                mPhone.getPhoneId());
    }

    @Test @SmallTest
Loading