[EflSharp] Update Circle and efl cs files (#995)
[platform/core/csapi/tizenfx.git] / test / SampleTelephony / SimPage.cs
1 using System;
2 using System.Threading.Tasks;
3 using System.Collections.Generic;
4 using System.Linq;
5 using Xamarin.Forms;
6 using Tizen;
7 using Tizen.Telephony;
8
9 namespace XamarinForTizen.Tizen
10 {
11     public class SimPage : ContentPage
12     {
13         private static Sim _sim = null;
14         private ChangeNotificationEventArgs.Notification[] notiArr = { ChangeNotificationEventArgs.Notification.SimStatus,
15                                                                        ChangeNotificationEventArgs.Notification.SimCallForwardingIndicatorState };
16         public SimPage()
17         {
18             var changedBtn = new Button
19             {
20                 Text = "Is sim changed",
21                 VerticalOptions = LayoutOptions.Start,
22                 HorizontalOptions = LayoutOptions.FillAndExpand
23             };
24             changedBtn.Clicked += changedBtn_Clicked;
25
26             var operatorBtn = new Button
27             {
28                 Text = "Get operator",
29                 VerticalOptions = LayoutOptions.Start,
30                 HorizontalOptions = LayoutOptions.FillAndExpand
31             };
32             operatorBtn.Clicked += operatorBtn_Clicked;
33
34             var iccIdBtn = new Button
35             {
36                 Text = "Get Icc id",
37                 VerticalOptions = LayoutOptions.Start,
38                 HorizontalOptions = LayoutOptions.FillAndExpand
39             };
40             iccIdBtn.Clicked += iccIdBtn_Clicked;
41
42             var msinBtn = new Button
43             {
44                 Text = "Get Msin",
45                 VerticalOptions = LayoutOptions.Start,
46                 HorizontalOptions = LayoutOptions.FillAndExpand
47             };
48             msinBtn.Clicked += msinBtn_Clicked;
49
50             var spnBtn = new Button
51             {
52                 Text = "Get SPN",
53                 VerticalOptions = LayoutOptions.Start,
54                 HorizontalOptions = LayoutOptions.FillAndExpand
55             };
56             spnBtn.Clicked += spnBtn_Clicked;
57
58             var stateBtn = new Button
59             {
60                 Text = "Get sim state",
61                 VerticalOptions = LayoutOptions.Start,
62                 HorizontalOptions = LayoutOptions.FillAndExpand
63             };
64             stateBtn.Clicked += stateBtn_Clicked;
65
66             var appListBtn = new Button
67             {
68                 Text = "Get sim application list",
69                 VerticalOptions = LayoutOptions.Start,
70                 HorizontalOptions = LayoutOptions.FillAndExpand
71             };
72             appListBtn.Clicked += appListBtn_Clicked;
73
74             var subscriberBtn = new Button
75             {
76                 Text = "Get subscriber number",
77                 VerticalOptions = LayoutOptions.Start,
78                 HorizontalOptions = LayoutOptions.FillAndExpand
79             };
80             subscriberBtn.Clicked += subscriberBtn_Clicked;
81
82             var subscriberIdBtn = new Button
83             {
84                 Text = "Get subscriber ID",
85                 VerticalOptions = LayoutOptions.Start,
86                 HorizontalOptions = LayoutOptions.FillAndExpand
87             };
88             subscriberIdBtn.Clicked += subscriberIdBtn_Clicked;
89
90             var lockStateBtn = new Button
91             {
92                 Text = "Get lock state",
93                 VerticalOptions = LayoutOptions.Start,
94                 HorizontalOptions = LayoutOptions.FillAndExpand
95             };
96             lockStateBtn.Clicked += lockStateBtn_Clicked;
97
98             var groupIdBtn = new Button
99             {
100                 Text = "Get group ID1",
101                 VerticalOptions = LayoutOptions.Start,
102                 HorizontalOptions = LayoutOptions.FillAndExpand
103             };
104             groupIdBtn.Clicked += groupIdBtn_Clicked;
105
106             var cfIndiStateBtn = new Button
107             {
108                 Text = "Get call forwarding indicator state",
109                 VerticalOptions = LayoutOptions.Start,
110                 HorizontalOptions = LayoutOptions.FillAndExpand
111             };
112             cfIndiStateBtn.Clicked += cfIndiStateBtn_Clicked;
113
114             Content = new StackLayout
115             {
116                 VerticalOptions = LayoutOptions.Center,
117                 Children = {
118                         changedBtn, operatorBtn, iccIdBtn, msinBtn, spnBtn, stateBtn, appListBtn, subscriberBtn,
119                         subscriberIdBtn, lockStateBtn, groupIdBtn, cfIndiStateBtn
120                     }
121             };
122
123             try
124             {
125                 if (Globals.slotHandle == null)
126                 {
127                     Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
128                     return;
129                 }
130
131                 Globals.slotHandle.ChangeNotification += SlotHandle_ChangeNotification;
132                 List<ChangeNotificationEventArgs.Notification> notiList = new List<ChangeNotificationEventArgs.Notification>();
133                 foreach (ChangeNotificationEventArgs.Notification noti in notiArr)
134                 {
135                     notiList.Add(noti);
136                 }
137
138                 Globals.slotHandle.SetNotificationId(notiList);
139                 _sim = new Sim(Globals.slotHandle);
140             }
141
142             catch (Exception ex)
143             {
144                 Log.Debug(Globals.LogTag, "Exception in Sim constructor: " + ex.ToString());
145             }
146         }
147
148         private void SlotHandle_ChangeNotification(object sender, ChangeNotificationEventArgs e)
149         {
150             Log.Debug(Globals.LogTag, "Change notification: " + e.NotificationType);
151         }
152
153         private void cfIndiStateBtn_Clicked(object sender, EventArgs e)
154         {
155             if (_sim == null)
156             {
157                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
158                 return;
159             }
160
161             Log.Debug(Globals.LogTag, "Call forwarding indicator state: " + _sim.CallForwardingIndicatorState);
162         }
163
164         private void groupIdBtn_Clicked(object sender, EventArgs e)
165         {
166             if (_sim == null)
167             {
168                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
169                 return;
170             }
171
172             Log.Debug(Globals.LogTag, "Group ID1: " + _sim.GroupId1);
173         }
174
175         private void lockStateBtn_Clicked(object sender, EventArgs e)
176         {
177             if (_sim == null)
178             {
179                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
180                 return;
181             }
182
183             Log.Debug(Globals.LogTag, "Sim lock state: " + _sim.CurrentLockState);
184         }
185
186         private void subscriberIdBtn_Clicked(object sender, EventArgs e)
187         {
188             if (_sim == null)
189             {
190                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
191                 return;
192             }
193
194             Log.Debug(Globals.LogTag, "Subscriber ID: " + _sim.SubscriberId);
195         }
196
197         private void subscriberBtn_Clicked(object sender, EventArgs e)
198         {
199             if (_sim == null)
200             {
201                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
202                 return;
203             }
204
205             Log.Debug(Globals.LogTag, "Subscriber Number: " + _sim.SubscriberNumber);
206         }
207
208         private void appListBtn_Clicked(object sender, EventArgs e)
209         {
210             if (_sim == null)
211             {
212                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
213                 return;
214             }
215
216             Log.Debug(Globals.LogTag, "Application list: " + _sim.ApplicationList);
217         }
218
219         private void stateBtn_Clicked(object sender, EventArgs e)
220         {
221             if (_sim == null)
222             {
223                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
224                 return;
225             }
226
227             Log.Debug(Globals.LogTag, "Sim state: " + _sim.CurrentState);
228         }
229
230         private void spnBtn_Clicked(object sender, EventArgs e)
231         {
232             if (_sim == null)
233             {
234                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
235                 return;
236             }
237
238             Log.Debug(Globals.LogTag, "Spn: " + _sim.Spn);
239         }
240
241         private void msinBtn_Clicked(object sender, EventArgs e)
242         {
243             if (_sim == null)
244             {
245                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
246                 return;
247             }
248
249             Log.Debug(Globals.LogTag, "Msin: " + _sim.Msin);
250         }
251
252         private void iccIdBtn_Clicked(object sender, EventArgs e)
253         {
254             if (_sim == null)
255             {
256                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
257                 return;
258             }
259
260             Log.Debug(Globals.LogTag, "Icc id: " + _sim.IccId);
261         }
262
263         private void operatorBtn_Clicked(object sender, EventArgs e)
264         {
265             if (_sim == null)
266             {
267                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
268                 return;
269             }
270
271             Log.Debug(Globals.LogTag, "Operator: " + _sim.Operator);
272         }
273
274         private void changedBtn_Clicked(object sender, EventArgs e)
275         {
276             if (_sim == null)
277             {
278                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
279                 return;
280             }
281
282             Log.Debug(Globals.LogTag, "Is sim changed: " + _sim.IsChanged);
283         }
284     }
285 }