2 using System.Collections.Generic;
8 namespace XamarinForTizen.Tizen
10 public class CommonPage : ContentPage
12 List<string> cplist = new List<string>();
15 var cpNameBtn = new Button
18 VerticalOptions = LayoutOptions.Start,
19 HorizontalOptions = LayoutOptions.FillAndExpand
21 cpNameBtn.Clicked += cpNameBtn_Clicked;
23 var initBtn0 = new Button
25 Text = "InitTapimodem0",
26 VerticalOptions = LayoutOptions.Start,
27 HorizontalOptions = LayoutOptions.FillAndExpand
29 initBtn0.Clicked += initBtn0_Clicked;
31 var initBtn1 = new Button
33 Text = "InitTapimodem1",
34 VerticalOptions = LayoutOptions.Start,
35 HorizontalOptions = LayoutOptions.FillAndExpand
37 initBtn1.Clicked += initBtn1_Clicked;
39 var deinitBtn0 = new Button
41 Text = "DeinitTapimodem0",
42 VerticalOptions = LayoutOptions.Start,
43 HorizontalOptions = LayoutOptions.FillAndExpand
45 deinitBtn0.Clicked += deinitBtn0_Clicked;
47 var deinitBtn1 = new Button
49 Text = "DeinitTapimodem1",
50 VerticalOptions = LayoutOptions.Start,
51 HorizontalOptions = LayoutOptions.FillAndExpand
53 deinitBtn1.Clicked += deinitBtn1_Clicked;
55 var getIntPropBtn = new Button
57 Text = "GetIntProperty",
58 VerticalOptions = LayoutOptions.Start,
59 HorizontalOptions = LayoutOptions.FillAndExpand
61 getIntPropBtn.Clicked += GetIntPropBtn_Clicked;
63 var getStrPropBtn = new Button
65 Text = "GetStringProperty",
66 VerticalOptions = LayoutOptions.Start,
67 HorizontalOptions = LayoutOptions.FillAndExpand
69 getStrPropBtn.Clicked += GetStrPropBtn_Clicked;
71 var getReadyBtn = new Button
73 Text = "GetReadyState",
74 VerticalOptions = LayoutOptions.Start,
75 HorizontalOptions = LayoutOptions.FillAndExpand
77 getReadyBtn.Clicked += GetReadyBtn_Clicked;
79 Content = new StackLayout
81 VerticalOptions = LayoutOptions.Center,
83 cpNameBtn, initBtn0, deinitBtn0, initBtn1, deinitBtn1, getIntPropBtn, getStrPropBtn, getReadyBtn
88 private void GetReadyBtn_Clicked(object sender, EventArgs e)
90 //Get the state of Tapi
91 int s = TapiManager.State;
93 Log.Debug(Globals.LogTag, "Tapi state, result = false");
95 Log.Debug(Globals.LogTag, "Tapi state, result = true");
97 Log.Debug(Globals.LogTag, "Tapi state, result = " + s);
100 private async void GetStrPropBtn_Clicked(object sender, EventArgs e)
104 var action = await DisplayActionSheet("Operation", "Cancel", null, "Network Name", "Network Spn Name", "Network Name Option");
105 Log.Debug(Globals.LogTag, "Action: " + action);
108 Property p = Property.NetworkPlmn;
109 if (action == "Network Name")
110 p = Property.NetworkName;
111 else if (action == "Network Spn Name")
112 p = Property.NetworkSpnName;
113 else if (action == "Network Name Option")
114 p = Property.NetworkNameOption;
115 if (Globals.handleModem0 != null)
117 string val = Globals.handleModem0.GetStringProperty(p);
118 Log.Debug(Globals.LogTag, "String property result = " + val);
120 else if (Globals.handleModem1 != null)
122 string val = Globals.handleModem1.GetStringProperty(p);
123 Log.Debug(Globals.LogTag, "String property result = " + val);
130 Log.Debug(Globals.LogTag, "GetStringProperty tapi exception = " + ex.ToString());
134 private async void GetIntPropBtn_Clicked(object sender, EventArgs e)
138 var action = await DisplayActionSheet("Operation", "Cancel", null, "Ps Type", "Power", "Dongle Status");
139 Log.Debug(Globals.LogTag, "Action: " + action);
142 Property p = Property.NetworkPlmn;
143 if (action == "Ps Type")
144 p = Property.NetworkPsType;
145 else if (action == "Power")
146 p = Property.ModemPower;
147 else if (action == "Dongle Status")
148 p = Property.ModemDongleStatus;
149 if (Globals.handleModem0 != null)
151 int val = Globals.handleModem0.GetIntProperty(p);
152 Log.Debug(Globals.LogTag, "Int property result = " + val);
154 else if (Globals.handleModem1 != null)
156 int val = Globals.handleModem1.GetIntProperty(p);
157 Log.Debug(Globals.LogTag, "Int property result = " + val);
164 Log.Debug(Globals.LogTag, "GetIntProperty tapi exception = " + ex.ToString());
168 private void deinitBtn1_Clicked(object sender, EventArgs e)
172 if (Globals.handleModem1 != null)
174 TapiManager.DeinitTapi(Globals.handleModem1);
175 Log.Debug(Globals.LogTag, "Deinit tapi is successful");
178 Log.Debug(Globals.LogTag, "TapiHandle is null");
183 Log.Debug(Globals.LogTag, "inside deinit tapi exception = " + ex.ToString());
187 private void deinitBtn0_Clicked(object sender, EventArgs e)
191 if (Globals.handleModem0 != null)
193 TapiManager.DeinitTapi(Globals.handleModem0);
194 Log.Debug(Globals.LogTag, "Deinit tapi is successful");
197 Log.Debug(Globals.LogTag, "TapiHandle is null");
202 Log.Debug(Globals.LogTag, "inside deinit tapi exception = " + ex.ToString());
206 private void initBtn1_Clicked(object sender, EventArgs e)
210 Globals.handleModem1 = TapiManager.InitTapi(cplist[1]);
211 if (Globals.handleModem1 == null)
212 Log.Debug(Globals.LogTag, "Init tapi is not successful and TapiHandle is null");
214 Log.Debug(Globals.LogTag, "Init tapi is successful");
219 Log.Debug(Globals.LogTag, "inside init tapi exception = " + ex.ToString());
223 private void initBtn0_Clicked(object sender, EventArgs e)
227 Globals.handleModem0 = TapiManager.InitTapi(cplist[0]);
228 if (Globals.handleModem0 == null)
229 Log.Debug(Globals.LogTag, "Init tapi is not successful and TapiHandle is null");
231 Log.Debug(Globals.LogTag, "Init tapi is successful");
236 Log.Debug(Globals.LogTag, "inside init tapi exception = " + ex.ToString());
240 private void cpNameBtn_Clicked(object sender, EventArgs e)
244 cplist = TapiManager.GetCpNames().ToList();
247 Log.Debug(Globals.LogTag, "inside common button clicked ");
248 for (int i = 0; i < cplist.Count; i++)
249 Log.Debug(Globals.LogTag, "Cp name = " + cplist[i]);
255 Log.Debug(Globals.LogTag, "Getcpnames throw exception = " + ex.ToString());