1 /*
2  * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3  * Not a Contribution.
4  *
5  * Copyright (C) 2006 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 package com.android.internal.telephony.gsm;
21 
22 import android.telephony.Rlog;
23 import com.android.internal.telephony.CallForwardInfo;
24 
25 import java.util.ArrayList;
26 
27 /**
28  * See also RIL_StkCcUnsolSsResponse in include/telephony/ril.h
29  *
30  * {@hide}
31  */
32 public class SsData {
33     public enum ServiceType {
34         SS_CFU,
35         SS_CF_BUSY,
36         SS_CF_NO_REPLY,
37         SS_CF_NOT_REACHABLE,
38         SS_CF_ALL,
39         SS_CF_ALL_CONDITIONAL,
40         SS_CLIP,
41         SS_CLIR,
42         SS_COLP,
43         SS_COLR,
44         SS_WAIT,
45         SS_BAOC,
46         SS_BAOIC,
47         SS_BAOIC_EXC_HOME,
48         SS_BAIC,
49         SS_BAIC_ROAMING,
50         SS_ALL_BARRING,
51         SS_OUTGOING_BARRING,
52         SS_INCOMING_BARRING;
53 
isTypeCF()54         public boolean isTypeCF() {
55             return (this == SS_CFU || this == SS_CF_BUSY || this == SS_CF_NO_REPLY ||
56                   this == SS_CF_NOT_REACHABLE || this == SS_CF_ALL ||
57                   this == SS_CF_ALL_CONDITIONAL);
58         }
59 
isTypeUnConditional()60         public boolean isTypeUnConditional() {
61             return (this == SS_CFU || this == SS_CF_ALL);
62         }
63 
isTypeCW()64         public boolean isTypeCW() {
65             return (this == SS_WAIT);
66         }
67 
isTypeClip()68         public boolean isTypeClip() {
69             return (this == SS_CLIP);
70         }
71 
isTypeClir()72         public boolean isTypeClir() {
73             return (this == SS_CLIR);
74         }
75 
isTypeBarring()76         public boolean isTypeBarring() {
77             return (this == SS_BAOC || this == SS_BAOIC || this == SS_BAOIC_EXC_HOME ||
78                   this == SS_BAIC || this == SS_BAIC_ROAMING || this == SS_ALL_BARRING ||
79                   this == SS_OUTGOING_BARRING || this == SS_INCOMING_BARRING);
80         }
81     };
82 
83     public enum RequestType {
84         SS_ACTIVATION,
85         SS_DEACTIVATION,
86         SS_INTERROGATION,
87         SS_REGISTRATION,
88         SS_ERASURE;
89 
isTypeInterrogation()90         public boolean isTypeInterrogation() {
91             return (this == SS_INTERROGATION);
92         }
93     };
94 
95     public enum TeleserviceType {
96         SS_ALL_TELE_AND_BEARER_SERVICES,
97         SS_ALL_TELESEVICES,
98         SS_TELEPHONY,
99         SS_ALL_DATA_TELESERVICES,
100         SS_SMS_SERVICES,
101         SS_ALL_TELESERVICES_EXCEPT_SMS;
102     };
103 
104     public ServiceType serviceType;
105     public RequestType requestType;
106     public TeleserviceType teleserviceType;
107     public int serviceClass;
108     public int result;
109 
110     public int[] ssInfo; /* This is the response data for most of the SS GET/SET
111                             RIL requests. E.g. RIL_REQUSET_GET_CLIR returns
112                             two ints, so first two values of ssInfo[] will be
113                             used for respone if serviceType is SS_CLIR and
114                             requestType is SS_INTERROGATION */
115 
116     public CallForwardInfo[] cfInfo; /* This is the response data for SS request
117                                         to query call forward status. see
118                                         RIL_REQUEST_QUERY_CALL_FORWARD_STATUS */
119 
ServiceTypeFromRILInt(int type)120     public ServiceType ServiceTypeFromRILInt(int type) {
121         try {
122             return ServiceType.values()[type];
123         } catch (IndexOutOfBoundsException e) {
124             Rlog.e(GSMPhone.LOG_TAG, "Invalid Service type");
125             return null;
126         }
127     }
128 
RequestTypeFromRILInt(int type)129     public RequestType RequestTypeFromRILInt(int type) {
130         try {
131             return RequestType.values()[type];
132         } catch (IndexOutOfBoundsException e) {
133             Rlog.e(GSMPhone.LOG_TAG, "Invalid Request type");
134             return null;
135         }
136     }
137 
TeleserviceTypeFromRILInt(int type)138     public TeleserviceType TeleserviceTypeFromRILInt(int type) {
139         try {
140             return TeleserviceType.values()[type];
141         } catch (IndexOutOfBoundsException e) {
142             Rlog.e(GSMPhone.LOG_TAG, "Invalid Teleservice type");
143             return null;
144         }
145     }
146 
toString()147     public String toString() {
148         return "[SsData] " + "ServiceType: " + serviceType
149             + " RequestType: " + requestType
150             + " TeleserviceType: " + teleserviceType
151             + " ServiceClass: " + serviceClass
152             + " Result: " + result
153             + " Is Service Type CF: " + serviceType.isTypeCF();
154     }
155 }
156