• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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;
18 
19 import android.os.RemoteException;
20 import android.telephony.Rlog;
21 
22 /**
23  * A holder for IRadioIms.
24  * Use getAidl to get IRadioIms and call the AIDL implementations of the HAL APIs.
25  */
26 public class RadioImsProxy extends RadioServiceProxy {
27     private static final String TAG = "RadioImsProxy";
28     private volatile android.hardware.radio.ims.IRadioIms mImsProxy = null;
29 
30     /**
31      * Sets IRadioIms as the AIDL implementation for RadioServiceProxy.
32      * @param halVersion Radio HAL version.
33      * @param ims IRadioIms implementation.
34      *
35      * @return updated HAL version.
36      */
setAidl(HalVersion halVersion, android.hardware.radio.ims.IRadioIms ims)37     public HalVersion setAidl(HalVersion halVersion, android.hardware.radio.ims.IRadioIms ims) {
38         HalVersion version = halVersion;
39         try {
40             version = RIL.getServiceHalVersion(ims.getInterfaceVersion());
41         } catch (RemoteException e) {
42             Rlog.e(TAG, "setAidl: " + e);
43         }
44         mHalVersion = version;
45         mImsProxy = ims;
46         mIsAidl = true;
47 
48         Rlog.d(TAG, "AIDL initialized mHalVersion=" + mHalVersion);
49         return mHalVersion;
50     }
51 
52     /**
53      * Gets the AIDL implementation of RadioImsProxy.
54      * @return IRadioIms implementation.
55      */
getAidl()56     public android.hardware.radio.ims.IRadioIms getAidl() {
57         return mImsProxy;
58     }
59 
60     /**
61      * Resets RadioImsProxy.
62      */
63     @Override
clear()64     public void clear() {
65         super.clear();
66         mImsProxy = null;
67     }
68 
69     /**
70      * Checks whether a RadioIms implementation exists.
71      * @return true if there is neither a HIDL nor AIDL implementation.
72      */
73     @Override
isEmpty()74     public boolean isEmpty() {
75         return mRadioProxy == null && mImsProxy == null;
76     }
77 
78     /**
79      * No implementation in IRadioIms.
80      * @throws RemoteException.
81      */
82     @Override
responseAcknowledgement()83     public void responseAcknowledgement() throws RemoteException {
84         /* Currently, IRadioIms doesn't support the following response types:
85          * - RadioIndicationType.UNSOLICITED_ACK_EXP
86          * - RadioResponseType.SOLICITED_ACK_EXP */
87         // no-op
88     }
89 
90     /**
91      * Calls IRadioIms#setSrvccCallInfo.
92      * @param serial Serial number of request.
93      * @param srvccCalls The list of call information.
94      * @throws RemoteException.
95      */
setSrvccCallInfo(int serial, android.hardware.radio.ims.SrvccCall[] srvccCalls)96     public void setSrvccCallInfo(int serial,
97             android.hardware.radio.ims.SrvccCall[] srvccCalls) throws RemoteException {
98         if (isEmpty()) return;
99         if (isAidl()) {
100             mImsProxy.setSrvccCallInfo(serial, srvccCalls);
101         }
102     }
103 
104     /**
105      * Calls IRadioIms#updateImsRegistrationInfo.
106      * @param serial Serial number of request.
107      * @param registrationInfo The registration state information.
108      * @throws RemoteException.
109      */
updateImsRegistrationInfo(int serial, android.hardware.radio.ims.ImsRegistration registrationInfo)110     public void updateImsRegistrationInfo(int serial,
111             android.hardware.radio.ims.ImsRegistration registrationInfo) throws RemoteException {
112         if (isEmpty()) return;
113         if (isAidl()) {
114             mImsProxy.updateImsRegistrationInfo(serial, registrationInfo);
115         }
116     }
117 
118     /**
119      * Calls IRadioIms#startImsTraffic.
120      * @param serial Serial number of request.
121      * @param token A nonce to identify the request.
122      * @param trafficType IMS traffic type like registration, voice, video, SMS, emergency, and etc.
123      * @param accessNetworkType The type of underlying radio access network used.
124      * @param trafficDirection Indicates whether traffic is originated by mobile originated or
125      *        mobile terminated use case eg. MO/MT call/SMS etc.
126      * @throws RemoteException.
127      */
startImsTraffic(int serial, int token, int trafficType, int accessNetworkType, int trafficDirection)128     public void startImsTraffic(int serial, int token, int trafficType, int accessNetworkType,
129             int trafficDirection) throws RemoteException {
130         if (isEmpty()) return;
131         if (isAidl()) {
132             mImsProxy.startImsTraffic(serial,
133                     token, trafficType, accessNetworkType, trafficDirection);
134         }
135     }
136 
137     /**
138      * Calls IRadioIms#stopImsTraffic.
139      * @param serial Serial number of request.
140      * @param token The token assigned by startImsTraffic.
141      * @throws RemoteException.
142      */
stopImsTraffic(int serial, int token)143     public void stopImsTraffic(int serial, int token)
144             throws RemoteException {
145         if (isEmpty()) return;
146         if (isAidl()) {
147             mImsProxy.stopImsTraffic(serial, token);
148         }
149     }
150 
151     /**
152      * Calls IRadioIms#triggerEpsFallback.
153      * @param serial Serial number of request.
154      * @param reason Specifies the reason for EPS fallback.
155      * @throws RemoteException.
156      */
triggerEpsFallback(int serial, int reason)157     public void triggerEpsFallback(int serial, int reason)
158             throws RemoteException {
159         if (isEmpty()) return;
160         if (isAidl()) {
161             mImsProxy.triggerEpsFallback(serial, reason);
162         }
163     }
164 
165     /**
166      * Calls IRadioIms#sendAnbrQuery.
167      * @param serial Serial number of request.
168      * @param mediaType Media type is used to identify media stream such as audio or video.
169      * @param direction Direction of this packet stream (e.g. uplink or downlink).
170      * @param bitsPerSecond The bit rate requested by the opponent UE.
171      * @throws RemoteException.
172      */
sendAnbrQuery(int serial, int mediaType, int direction, int bitsPerSecond)173     public void sendAnbrQuery(int serial, int mediaType, int direction, int bitsPerSecond)
174             throws RemoteException {
175         if (isEmpty()) return;
176         if (isAidl()) {
177             mImsProxy.sendAnbrQuery(serial, mediaType, direction, bitsPerSecond);
178         }
179     }
180 
181     /**
182      * Call IRadioIms#updateImsCallStatus
183      * @param serial Serial number of request.
184      * @param imsCalls The list of call status information.
185      * @throws RemoteException.
186      */
updateImsCallStatus(int serial, android.hardware.radio.ims.ImsCall[] imsCalls)187     public void updateImsCallStatus(int serial,
188             android.hardware.radio.ims.ImsCall[] imsCalls) throws RemoteException {
189         if (isEmpty()) return;
190         if (isAidl()) {
191             mImsProxy.updateImsCallStatus(serial, imsCalls);
192         }
193     }
194 }
195