1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.telephony.metrics;
18 
19 import com.android.internal.telephony.nano.TelephonyProto.EmergencyNumberInfo;
20 import com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities;
21 import com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState;
22 import com.android.internal.telephony.nano.TelephonyProto.ImsReasonInfo;
23 import com.android.internal.telephony.nano.TelephonyProto.RilDataCall;
24 import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession;
25 import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.CallQuality;
26 import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.CallQualitySummary;
27 import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.RilCall;
28 import com.android.internal.telephony.nano.TelephonyProto.TelephonyServiceState;
29 import com.android.internal.telephony.nano.TelephonyProto.TelephonySettings;
30 
31 public class CallSessionEventBuilder {
32     private final TelephonyCallSession.Event mEvent = new TelephonyCallSession.Event();
33 
build()34     public TelephonyCallSession.Event build() {
35         return mEvent;
36     }
37 
CallSessionEventBuilder(int type)38     public CallSessionEventBuilder(int type) {
39         mEvent.type = type;
40     }
41 
setDelay(int delay)42     public CallSessionEventBuilder setDelay(int delay) {
43         mEvent.delay = delay;
44         return this;
45     }
46 
setRilRequest(int rilRequestType)47     public CallSessionEventBuilder setRilRequest(int rilRequestType) {
48         mEvent.rilRequest = rilRequestType;
49         return this;
50     }
51 
setRilRequestId(int rilRequestId)52     public CallSessionEventBuilder setRilRequestId(int rilRequestId) {
53         mEvent.rilRequestId = rilRequestId;
54         return this;
55     }
56 
setRilError(int rilError)57     public CallSessionEventBuilder setRilError(int rilError) {
58         mEvent.error = rilError;
59         return this;
60     }
61 
setCallIndex(int callIndex)62     public CallSessionEventBuilder setCallIndex(int callIndex) {
63         mEvent.callIndex = callIndex;
64         return this;
65     }
66 
setCallState(int state)67     public CallSessionEventBuilder setCallState(int state) {
68         mEvent.callState = state;
69         return this;
70     }
71 
setSrvccState(int srvccState)72     public CallSessionEventBuilder setSrvccState(int srvccState) {
73         mEvent.srvccState = srvccState;
74         return this;
75     }
76 
setImsCommand(int imsCommand)77     public CallSessionEventBuilder setImsCommand(int imsCommand) {
78         mEvent.imsCommand = imsCommand;
79         return this;
80     }
81 
setImsReasonInfo(ImsReasonInfo reasonInfo)82     public CallSessionEventBuilder setImsReasonInfo(ImsReasonInfo reasonInfo) {
83         mEvent.reasonInfo = reasonInfo;
84         return this;
85     }
86 
setSrcAccessTech(int tech)87     public CallSessionEventBuilder setSrcAccessTech(int tech) {
88         mEvent.srcAccessTech = tech;
89         return this;
90     }
91 
setTargetAccessTech(int tech)92     public CallSessionEventBuilder setTargetAccessTech(int tech) {
93         mEvent.targetAccessTech = tech;
94         return this;
95     }
96 
setSettings(TelephonySettings settings)97     public CallSessionEventBuilder setSettings(TelephonySettings settings) {
98         mEvent.settings = settings;
99         return this;
100     }
101 
setServiceState(TelephonyServiceState state)102     public CallSessionEventBuilder setServiceState(TelephonyServiceState state) {
103         mEvent.serviceState = state;
104         return this;
105     }
106 
setImsConnectionState(ImsConnectionState state)107     public CallSessionEventBuilder setImsConnectionState(ImsConnectionState state) {
108         mEvent.imsConnectionState = state;
109         return this;
110     }
111 
setImsCapabilities(ImsCapabilities capabilities)112     public CallSessionEventBuilder setImsCapabilities(ImsCapabilities capabilities) {
113         mEvent.imsCapabilities = capabilities;
114         return this;
115     }
116 
setDataCalls(RilDataCall[] dataCalls)117     public CallSessionEventBuilder setDataCalls(RilDataCall[] dataCalls) {
118         mEvent.dataCalls = dataCalls;
119         return this;
120     }
121 
setPhoneState(int phoneState)122     public CallSessionEventBuilder setPhoneState(int phoneState) {
123         mEvent.phoneState = phoneState;
124         return this;
125     }
126 
setNITZ(long timestamp)127     public CallSessionEventBuilder setNITZ(long timestamp) {
128         mEvent.nitzTimestampMillis = timestamp;
129         return this;
130     }
131 
setRilCalls(RilCall[] rilCalls)132     public CallSessionEventBuilder setRilCalls(RilCall[] rilCalls) {
133         mEvent.calls = rilCalls;
134         return this;
135     }
136 
137     /** Set the audio codec. */
setAudioCodec(int audioCodec)138     public CallSessionEventBuilder setAudioCodec(int audioCodec) {
139         mEvent.audioCodec = audioCodec;
140         return this;
141     }
142 
143     /** Set the call quality. */
setCallQuality(CallQuality callQuality)144     public CallSessionEventBuilder setCallQuality(CallQuality callQuality) {
145         mEvent.callQuality = callQuality;
146         return this;
147     }
148 
149     /** Set the downlink call quality summary. */
setCallQualitySummaryDl(CallQualitySummary callQualitySummary)150     public CallSessionEventBuilder setCallQualitySummaryDl(CallQualitySummary callQualitySummary) {
151         mEvent.callQualitySummaryDl = callQualitySummary;
152         return this;
153     }
154 
155     /** Set the uplink call quality summary. */
setCallQualitySummaryUl(CallQualitySummary callQualitySummary)156     public CallSessionEventBuilder setCallQualitySummaryUl(CallQualitySummary callQualitySummary) {
157         mEvent.callQualitySummaryUl = callQualitySummary;
158         return this;
159     }
160 
161     /** Set if the Ims call is emergency. */
setIsImsEmergencyCall(boolean isImsEmergencyCall)162     public CallSessionEventBuilder setIsImsEmergencyCall(boolean isImsEmergencyCall) {
163         mEvent.isImsEmergencyCall = isImsEmergencyCall;
164         return this;
165     }
166 
167     /** Set the emergency number database version in Ims emergency call information. */
setEmergencyNumberDatabaseVersion( int emergencyNumberDatabaseVersion)168     public CallSessionEventBuilder setEmergencyNumberDatabaseVersion(
169             int emergencyNumberDatabaseVersion) {
170         mEvent.emergencyNumberDatabaseVersion = emergencyNumberDatabaseVersion;
171         return this;
172     }
173 
174     /** Set the Ims emergency call information. */
setImsEmergencyNumberInfo( EmergencyNumberInfo imsEmergencyNumberInfo)175     public CallSessionEventBuilder setImsEmergencyNumberInfo(
176             EmergencyNumberInfo imsEmergencyNumberInfo) {
177         mEvent.imsEmergencyNumberInfo = imsEmergencyNumberInfo;
178         return this;
179     }
180 }
181