summaryrefslogtreecommitdiff
path: root/services/QualifiedNetworksService/src/com/android/telephony/qns/AlternativeEventProvider.java
blob: b2ef78d21b9e3f894cb1a7727bb3b25503ba9ef8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.telephony.qns;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation;
import android.util.Log;

/** AlternativeEventProvider class */
public abstract class AlternativeEventProvider {
    private EventCallback mEventCb;
    private final String mLogTag;

    public AlternativeEventProvider(AlternativeEventListener altEventListener, int slotId) {
        mLogTag =
                QnsConstants.QNS_TAG
                        + "_"
                        + AlternativeEventProvider.class.getSimpleName()
                        + "_"
                        + slotId;
        altEventListener.setEventProvider(this);
    }

    /**
     * Thins is to register RTP threshold.
     *
     * @param callId CallId
     * @param jitter RTP jitter value
     * @param packetLossRate RTP packet loss rate
     * @param packetLossTimeInMilliSec timer for RTP packet loss
     * @param noRtpTimeInMilliSec time for no incoming RTP
     */
    public abstract void requestRtpThreshold(
            int callId,
            int jitter,
            int packetLossRate,
            int packetLossTimeInMilliSec,
            int noRtpTimeInMilliSec);

    /**
     * This is to set signal strength threshold.
     *
     * @param threshold signal strength threshold values
     */
    public abstract void setEcnoSignalThreshold(@Nullable int[] threshold);

    /**
     * Event provider calls this to notify call info changed.
     *
     * @param id CallId
     * @param type CallType
     * @param state CallState
     */
    public void notifyCallInfo(int id, int type, int state) {
        if (mEventCb != null) {
            mEventCb.onCallInfoChanged(id, type, state);
        }
    }

    /**
     * Event provider calls this to notify RTP low quality
     *
     * @param reason RTP low quality reason.
     */
    public void notifyRtpLowQuality(@QnsConstants.RtpLowQualityReason int reason) {
        if (mEventCb != null) {
            mEventCb.onVoiceRtpLowQuality(reason);
        }
    }

    /**
     * Event provider needs to call this to notify Emergency preference change
     *
     * @param type Emergency transport type preference for initial data connection.
     */
    public void notifyEmergencyPreferredTransportType(
            @AccessNetworkConstants.TransportType int type) {
        if (mEventCb != null) {
            mEventCb.onEmergencyPreferenceChanged(type);
        }
    }

    /**
     * Event provider needs to call this to notify try WFC connection state change
     *
     * @param isEnabled try WFC connection
     */
    public void notifyTryWfcConnectionState(boolean isEnabled) {
        if (mEventCb != null) {
            mEventCb.onTryWfcConnectionStateChanged(isEnabled);
        }
    }

    /**
     * Listener need to register CallBack with implements of EventCallback.
     *
     * @param eventCb implements of EventCallback.
     */
    public void registerCallBack(@NonNull EventCallback eventCb) {
        log("registerCallBack" + eventCb);
        mEventCb = eventCb;
    }

    /** Event callback for call related item */
    public interface EventCallback {
        /**
         * call type event notification.
         *
         * @param id CallId
         * @param type CallType
         * @param state CallState
         */
        void onCallInfoChanged(
                int id,
                @QnsConstants.QnsCallType int type,
                @Annotation.PreciseCallStates int state);

        /**
         * RTP event notification.
         *
         * @param reason reason for RTP low quality
         */
        void onVoiceRtpLowQuality(@QnsConstants.RtpLowQualityReason int reason);

        /**
         * Notify Emergency Transport Type Preference for initial connect.
         *
         * @param transport Transport Type
         */
        void onEmergencyPreferenceChanged(@AccessNetworkConstants.TransportType int transport);

        /**
         * Try WFC connection state change notification.
         *
         * @param isEnabled flag value for WFC connection state change notification
         */
        void onTryWfcConnectionStateChanged(boolean isEnabled);
    }

    protected void log(String s) {
        Log.d(mLogTag, s);
    }
}