• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2014 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.compat.annotation.UnsupportedAppUsage;
20 import android.os.Build;
21 import android.telephony.TelephonyManager;
22 
23 /**
24  * Object to indicate the phone radio capability.
25  *
26  * @hide
27  */
28 public class RadioCapability {
29 
30     /*
31      * The RC_PHASE constants are the set of valid values for the mPhase field.
32      */
33 
34     /**
35      *  LM is configured is initial value and value after FINISH completes.
36      */
37     public static final int RC_PHASE_CONFIGURED = 0;
38 
39     /**
40      * START is sent before Apply and indicates that an APPLY will be
41      * forthcoming with these same parameters.
42      */
43     public static final int RC_PHASE_START = 1;
44 
45     /**
46      * APPLY is sent after all LM's receive START and returned
47      * RIL_RadioCapability. status = 0, if any START's fail no APPLY will
48      * be sent.
49      */
50     public static final int RC_PHASE_APPLY = 2;
51 
52     /**
53      *  UNSOL_RSP is sent with RIL_UNSOL_RADIO_CAPABILITY.
54      */
55     public static final int RC_PHASE_UNSOL_RSP = 3;
56 
57     /**
58      * RC_PHASE_FINISH is sent after all previous phases have completed.
59      * If an error occurs in any previous commands the RIL_RadioAccessesFamily
60      * and LogicalModemId fields will be the prior configuration thus
61      * restoring the configuration to the previous value. An error returned
62      * by this command will generally be ignored or may cause that logical
63      * modem to be removed from service
64      */
65     public static final int RC_PHASE_FINISH = 4;
66 
67     /*
68      * The RC_STATUS_xxx constants are returned in the mStatus field.
69      */
70 
71      /**
72       *  this parameter is no meaning with RC_Phase_START, RC_Phase_APPLY
73       */
74     public static final int RC_STATUS_NONE = 0;
75 
76     /**
77      * Tell modem  the action transaction of set radio capability is
78      * success with RC_Phase_FINISH.
79      */
80     public static final int RC_STATUS_SUCCESS = 1;
81 
82     /**
83      * tell modem the action transaction of set radio capability is fail
84      * with RC_Phase_FINISH
85      */
86     public static final int RC_STATUS_FAIL = 2;
87 
88     /** Version of structure, RIL_RadioCapability_Version */
89     private static final int RADIO_CAPABILITY_VERSION = 1;
90 
91     /** Unique session value defined by framework returned in all "responses/unsol" */
92     private int mSession;
93 
94     /** CONFIGURED, START, APPLY, FINISH */
95     private int mPhase;
96 
97     /**
98      * RadioAccessFamily is a bit field of radio access technologies the
99      * for the modem is currently supporting. The initial value returned
100      * my the modem must the the set of bits that the modem currently supports.
101      * see {@link android.telephony.TelephonyManager.NetworkTypeBitMask}
102      */
103     @TelephonyManager.NetworkTypeBitMask
104     private int mRadioAccessFamily;
105 
106     /**
107      * Logical modem this radio is be connected to.
108      * This must be Globally unique on convention is
109      * to use a registered name such as com.google.android.lm0
110      */
111     private String mLogicalModemUuid;
112 
113     /** Return status and an input parameter for RC_Phase_FINISH */
114     private int mStatus;
115 
116     /** Phone ID of phone */
117     private int mPhoneId;
118 
119     /**
120      * Constructor.
121      *
122      * @param phoneId the phone ID
123      * @param session the request transaction id
124      * @param phase the request phase id
125      * @param radioAccessFamily the phone radio access family defined in
126      * {@link android.telephony.TelephonyManager.NetworkTypeBitMask}
127      *                          It's a bit mask value to represent the support type.
128      * @param logicalModemUuid the logicalModem UUID which phone connected to
129      * @param status tell modem the action transaction of
130      *        set radio capability is success or fail with RC_Phase_FINISH
131      */
RadioCapability(int phoneId, int session, int phase, @TelephonyManager.NetworkTypeBitMask int radioAccessFamily, String logicalModemUuid, int status)132     public RadioCapability(int phoneId, int session, int phase,
133                            @TelephonyManager.NetworkTypeBitMask int radioAccessFamily,
134                            String logicalModemUuid, int status) {
135         mPhoneId = phoneId;
136         mSession = session;
137         mPhase = phase;
138         mRadioAccessFamily = radioAccessFamily;
139         mLogicalModemUuid = logicalModemUuid;
140         mStatus = status;
141     }
142 
143     /**
144      * Get phone ID.
145      *
146      * @return phone ID
147      */
getPhoneId()148     public int getPhoneId() {
149         return mPhoneId;
150     }
151 
152     /**
153      * Get radio capability version.
154      *
155      * @return radio capability version
156      */
getVersion()157     public int getVersion() {
158         return RADIO_CAPABILITY_VERSION;
159     }
160 
161     /**
162      * Get unique session id.
163      *
164      * @return unique session id
165      */
getSession()166     public int getSession() {
167         return mSession;
168     }
169 
170 
171     /**
172      * get radio capability phase.
173      *
174      * @return RadioCapabilityPhase, including CONFIGURED, START, APPLY, FINISH
175      */
getPhase()176     public int getPhase() {
177         return mPhase;
178     }
179 
180     /**
181      * get radio access family.
182      *
183      * @return radio access family
184      */
185     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
getRadioAccessFamily()186     public int getRadioAccessFamily() {
187         return mRadioAccessFamily;
188     }
189 
190     /**
191      * get logical modem Universally Unique ID.
192      *
193      * @return logical modem uuid
194      */
getLogicalModemUuid()195     public String getLogicalModemUuid() {
196         return mLogicalModemUuid;
197     }
198 
199     /**
200      * get request status.
201      *
202      * @return status and an input parameter for RC_PHASE_FINISH
203      */
getStatus()204     public int getStatus() {
205         return mStatus;
206     }
207 
208     @Override
toString()209     public String toString() {
210         return "{mPhoneId = " + mPhoneId
211                 + " mVersion=" + getVersion()
212                 + " mSession=" + getSession()
213                 + " mPhase=" + getPhase()
214                 + " mRadioAccessFamily=" + getRadioAccessFamily()
215                 + " mLogicModemId=" + getLogicalModemUuid()
216                 + " mStatus=" + getStatus()
217                 + "}";
218     }
219 }
220 
221