From c864a19f3cfd841863ed83029cd21d53dd8cda5e Mon Sep 17 00:00:00 2001 From: "adhavan.m" Date: Mon, 24 Jul 2017 15:40:50 +0530 Subject: [PATCH] [Tapitest] Added Sim test code and fixed framework issues. Signed-off-by: adhavan.m Change-Id: Icd49468d68515710b93801e3308592351e5a656e --- src/Tizen.Tapi/Interop/Interop.Tapi.cs | 2 +- src/Tizen.Tapi/Tizen.Tapi/Sim.cs | 35 ++- src/Tizen.Tapi/Tizen.Tapi/SimData.cs | 13 +- src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs | 15 +- test/Tizen.Tapitest/MainPage.cs | 15 +- test/Tizen.Tapitest/SimPage.cs | 453 ++++++++++++++++++++++++++++++ test/Tizen.Tapitest/Tizen.Tapitest.csproj | 217 +++++++------- 7 files changed, 619 insertions(+), 131 deletions(-) create mode 100755 test/Tizen.Tapitest/SimPage.cs diff --git a/src/Tizen.Tapi/Interop/Interop.Tapi.cs b/src/Tizen.Tapi/Interop/Interop.Tapi.cs index 1a7568a..c39a132 100755 --- a/src/Tizen.Tapi/Interop/Interop.Tapi.cs +++ b/src/Tizen.Tapi/Interop/Interop.Tapi.cs @@ -160,7 +160,7 @@ internal static partial class Interop [DllImport(Libraries.Tapi, EntryPoint = "tel_req_sim_atr")] internal static extern int SimRequestAtr(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_application_list")] - internal static extern int SimGetApplicationList(IntPtr handle, out IntPtr appList); + internal static extern int SimGetApplicationList(IntPtr handle, out byte appList); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_impi")] internal static extern int SimGetImpi(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_impu")] diff --git a/src/Tizen.Tapi/Tizen.Tapi/Sim.cs b/src/Tizen.Tapi/Tizen.Tapi/Sim.cs index c7d8acc..4400737 100755 --- a/src/Tizen.Tapi/Tizen.Tapi/Sim.cs +++ b/src/Tizen.Tapi/Tizen.Tapi/Sim.cs @@ -151,7 +151,7 @@ namespace Tizen.Tapi /// Thrown when it is failed due to invalid operation. public byte SimGetApplicationList() { - IntPtr appList; + byte appList; int ret = Interop.Tapi.Sim.SimGetApplicationList(_handle, out appList); if (ret != (int)TapiError.Success) { @@ -159,7 +159,7 @@ namespace Tizen.Tapi TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); } - return Marshal.ReadByte(appList); + return appList; } /// @@ -184,6 +184,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting ICCID info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting ICCID info, " + (SimAccessResult)result)); + return; } SimIccIdInfoStruct info = Marshal.PtrToStructure(data); @@ -226,6 +227,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting language preference: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting language preference, " + (SimAccessResult)result)); + return; } task.SetResult((SimLanguagePreference)Marshal.ReadInt32(data)); @@ -269,6 +271,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in setting language preference: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in setting language preference, " + (SimAccessResult)result)); + return; } task.SetResult(true); @@ -310,6 +313,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting call forward info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting call forward info, " + (SimAccessResult)result)); + return; } SimCallForwardResponseStruct info = Marshal.PtrToStructure(data); @@ -355,6 +359,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in setting call forward info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in setting call forward info, " + (SimAccessResult)result)); + return; } task.SetResult(true); @@ -402,6 +407,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting message waiting info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting message waiting info, " + (SimAccessResult)result)); + return; } SimMessageWaitingResponseStruct info = Marshal.PtrToStructure(data); @@ -447,6 +453,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in setting message waiting info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in setting message waiting info, " + (SimAccessResult)result)); + return; } task.SetResult(true); @@ -494,6 +501,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting mailbox info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting mailbox info, " + (SimAccessResult)result)); + return; } SimMailboxListStruct info = Marshal.PtrToStructure(data); @@ -540,6 +548,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in setting mailbox info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in setting mailbox info, " + (SimAccessResult)result)); + return; } task.SetResult(true); @@ -587,6 +596,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting CPHS info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting CPHS info, " + (SimAccessResult)result)); + return; } SimCphsInfoStruct info = Marshal.PtrToStructure(data); @@ -629,6 +639,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting service table: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting service table, " + (SimAccessResult)result)); + return; } SimServiceTableStruct info = Marshal.PtrToStructure(data); @@ -671,6 +682,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting MSISDN info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting MSISDN info, " + (SimAccessResult)result)); + return; } SimMsisdnListStruct info = Marshal.PtrToStructure(data); @@ -713,6 +725,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting OPLMNWACT info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting OPLMNWACT info, " + (SimAccessResult)result)); + return; } SimOplmnwactListStruct info = Marshal.PtrToStructure(data); @@ -755,6 +768,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SPN info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SPN info, " + (SimAccessResult)result)); + return; } SimSpnStruct info = Marshal.PtrToStructure(data); @@ -797,6 +811,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting CPHS netname info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting CPHS netname info, " + (SimAccessResult)result)); + return; } SimCphsNetNameStruct info = Marshal.PtrToStructure(data); @@ -842,6 +857,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in executing authentication procedure: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in executing authentication procedure, " + (SimAccessResult)result)); + return; } SimAuthenticationResponseStruct info = Marshal.PtrToStructure(data); @@ -894,6 +910,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in verifying SIM pins: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in verifying SIM pins, " + (SimAccessResult)result)); + return; } SimPinResultStruct info = Marshal.PtrToStructure(data); @@ -947,6 +964,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in verifying SIM puks: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in verifying SIM puks, " + (SimAccessResult)result)); + return; } SimPinResultStruct info = Marshal.PtrToStructure(data); @@ -1001,6 +1019,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in changing SIM pins: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in changing SIM pins, " + (SimAccessResult)result)); + return; } SimPinResultStruct info = Marshal.PtrToStructure(data); @@ -1054,6 +1073,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in disabling SIM facility: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in disabling SIM facility, " + (SimAccessResult)result)); + return; } SimFacilityResultStruct info = Marshal.PtrToStructure(data); @@ -1106,6 +1126,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in enabling SIM facility: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in enabling SIM facility, " + (SimAccessResult)result)); + return; } SimFacilityResultStruct info = Marshal.PtrToStructure(data); @@ -1155,6 +1176,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM facility: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SIM facility, " + (SimAccessResult)result)); + return; } SimFacilityInfoStruct info = Marshal.PtrToStructure(data); @@ -1198,6 +1220,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM lock info: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SIM lock info, " + (SimAccessResult)result)); + return; } SimLockInfoStruct info = Marshal.PtrToStructure(data); @@ -1242,6 +1265,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in setting SIM power state: " + (SimPowerSetResult)result); task.SetException(new InvalidOperationException("Error occurs in setting SIM power state, " + (SimPowerSetResult)result)); + return; } task.SetResult(true); @@ -1286,6 +1310,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in requesting SIM APDU: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in requesting SIM APDU, " + (SimAccessResult)result)); + return; } SimApduResponseStruct info = Marshal.PtrToStructure(data); @@ -1334,6 +1359,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in requesting SIM ATR: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in requesting SIM ATR, " + (SimAccessResult)result)); + return; } SimAtrResponseStruct info = Marshal.PtrToStructure(data); @@ -1376,6 +1402,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM IMPI: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SIM IMPI, " + (SimAccessResult)result)); + return; } task.SetResult(Marshal.PtrToStringAnsi(data)); @@ -1417,6 +1444,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM IMPU: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SIM IMPU, " + (SimAccessResult)result)); + return; } SimImpuListStruct info = Marshal.PtrToStructure(data); @@ -1459,6 +1487,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM domain: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SIM domain, " + (SimAccessResult)result)); + return; } task.SetResult(Marshal.PtrToStringAnsi(data)); @@ -1500,6 +1529,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM PCSCF: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting SIM PCSCF, " + (SimAccessResult)result)); + return; } SimPcscfListStruct info = Marshal.PtrToStructure(data); @@ -1542,6 +1572,7 @@ namespace Tizen.Tapi { Log.Error(TapiUtility.LogTag, "Error occurs in getting ISIM service table: " + (SimAccessResult)result); task.SetException(new InvalidOperationException("Error occurs in getting ISIM service table, " + (SimAccessResult)result)); + return; } task.SetResult(Encoding.ASCII.GetBytes(Marshal.PtrToStringAnsi(data))); diff --git a/src/Tizen.Tapi/Tizen.Tapi/SimData.cs b/src/Tizen.Tapi/Tizen.Tapi/SimData.cs index f378ab8..96a3cdb 100755 --- a/src/Tizen.Tapi/Tizen.Tapi/SimData.cs +++ b/src/Tizen.Tapi/Tizen.Tapi/SimData.cs @@ -2041,7 +2041,6 @@ namespace Tizen.Tapi /// public class SimApdu { - private ushort _apduLength; private byte[] _apdu; private SimApdu() { @@ -2050,22 +2049,12 @@ namespace Tizen.Tapi /// /// A constructor to instantiate SimApdu class with necessary parameters. /// - /// Length of APDU. /// APDU. - public SimApdu(ushort apduLength, byte[] apdu) + public SimApdu(byte[] apdu) { - _apduLength = apduLength; _apdu = apdu; } - internal ushort ApduLength - { - get - { - return _apduLength; - } - } - internal byte[] Apdu { get diff --git a/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs b/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs index 0be509a..24a38a6 100755 --- a/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs +++ b/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs @@ -254,12 +254,13 @@ namespace Tizen.Tapi [MarshalAs(UnmanagedType.LPStr)] internal string Apdu; } + [StructLayout(LayoutKind.Sequential)] internal struct SimApduResponseStruct { internal ushort RespLen; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5120)] - internal string ApduResp; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5120)] + internal byte[] ApduResp; } [StructLayout(LayoutKind.Sequential)] @@ -395,8 +396,8 @@ namespace Tizen.Tapi internal struct SimAtrResponseStruct { internal ushort AtrRespLen; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5120)] - internal string AtrResp; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5120)] + internal byte[] AtrResp; } [StructLayout(LayoutKind.Sequential)] @@ -840,7 +841,7 @@ namespace Tizen.Tapi { SimApduResponse response = new SimApduResponse(); response.ApduLen = respStruct.RespLen; - response.ApduResp = Encoding.ASCII.GetBytes(respStruct.ApduResp); + response.ApduResp = respStruct.ApduResp; return response; } @@ -848,7 +849,7 @@ namespace Tizen.Tapi { SimAtrResponse atrResp = new SimAtrResponse(); atrResp.AtrRespLen = respStruct.AtrRespLen; - atrResp.AtrResp = Encoding.ASCII.GetBytes(respStruct.AtrResp); + atrResp.AtrResp = respStruct.AtrResp; return atrResp; } @@ -1063,7 +1064,7 @@ namespace Tizen.Tapi internal static SimApduStruct ConvertSimApdu(SimApdu apdu) { SimApduStruct apduStruct = new SimApduStruct(); - apduStruct.ApduLen = apdu.ApduLength; + apduStruct.ApduLen = (ushort)apdu.Apdu.Length; apduStruct.Apdu = Encoding.UTF8.GetString(apdu.Apdu); return apduStruct; } diff --git a/test/Tizen.Tapitest/MainPage.cs b/test/Tizen.Tapitest/MainPage.cs index 0cc2678..0d1ffd1 100755 --- a/test/Tizen.Tapitest/MainPage.cs +++ b/test/Tizen.Tapitest/MainPage.cs @@ -31,15 +31,28 @@ namespace XamarinForTizen.Tizen }; nwBtn.Clicked += NwBtn_Clicked; + var simBtn = new Button + { + Text = "Sim", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + simBtn.Clicked += simBtn_Clicked; + Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { - commonBtn, modemBtn, nwBtn + commonBtn, modemBtn, nwBtn, simBtn } }; } + private async void simBtn_Clicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new SimPage()); + } + private async void NwBtn_Clicked(object sender, EventArgs e) { await Navigation.PushAsync(new NetworkPage()); diff --git a/test/Tizen.Tapitest/SimPage.cs b/test/Tizen.Tapitest/SimPage.cs new file mode 100755 index 0000000..1fa781b --- /dev/null +++ b/test/Tizen.Tapitest/SimPage.cs @@ -0,0 +1,453 @@ +using System; +using Xamarin.Forms; +using Tizen; +using Tizen.Tapi; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace XamarinForTizen.Tizen +{ + public class SimPage : ContentPage + { + Sim sim = null; + public SimPage() + { + try + { + sim = new Sim(Globals.handleModem0); + } + + catch(Exception ex) + { + Log.Debug(Globals.LogTag, "Sim constructor throws exception = " + ex.ToString()); + } + + var SimInitInfoBtn = new Button + { + Text = "SimInitInfo", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + SimInitInfoBtn.Clicked += SimInitInfoBtn_Clicked; + + var SimPropertiesBtn = new Button + { + Text = "Get sim properties(Type, Imsi, Ecc)", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + SimPropertiesBtn.Clicked += SimPropertiesBtn_Clicked; + + var appListBtn = new Button + { + Text = "Get sim application list", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + appListBtn.Clicked += appListBtn_Clicked; + + var iccIdBtn = new Button + { + Text = "Get sim ICCID", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + iccIdBtn.Clicked += iccIdBtn_Clicked; + + var langPrefBtn = new Button + { + Text = "Set & get sim language preference", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + langPrefBtn.Clicked += langPrefBtn_Clicked; + + var msisdnBtn = new Button + { + Text = "Get sim MSISDN", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + msisdnBtn.Clicked += msisdnBtn_Clicked; + + var oplmnwactBtn = new Button + { + Text = "Get sim OPLMNWACT", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + oplmnwactBtn.Clicked += oplmnwactBtn_Clicked; + + var spnBtn = new Button + { + Text = "Get sim SPN", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + spnBtn.Clicked += spnBtn_Clicked; + + var autnBtn = new Button + { + Text = "Sim authentication", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + autnBtn.Clicked += autnBtn_Clicked; + + var powerBtn = new Button + { + Text = "Sim change power state", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + powerBtn.Clicked += powerBtn_Clicked; + + var apduBtn = new Button + { + Text = "Sim APDU", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + apduBtn.Clicked += apduBtn_Clicked; + + var atrBtn = new Button + { + Text = "Sim ATR", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + atrBtn.Clicked += atrBtn_Clicked; + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + SimInitInfoBtn, SimPropertiesBtn, appListBtn, iccIdBtn, langPrefBtn, msisdnBtn, oplmnwactBtn, + spnBtn, autnBtn, powerBtn, apduBtn, atrBtn + } + }; + } + + private async void atrBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim request ATR call start"); + SimAtrResponse resp = await sim.SimRequestAtr(); + Log.Debug(Globals.LogTag, "Atr response length: " + resp.AtrRespLength); + for (int i = 0; i < resp.AtrRespLength; i++) + { + Log.Debug(Globals.LogTag, "[" + i + "]'s byte: [0x" + resp.AtrResponse[i] + "]"); + } + + Log.Debug(Globals.LogTag, "Sim request ATR call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim request ATR exception: " + ex.ToString()); + } + } + + private async void apduBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim request APDU call start"); + SimApdu apdu = new SimApdu(Encoding.ASCII.GetBytes("0070000000")); + SimApduResponse resp = await sim.SimRequestApdu(apdu); + Log.Debug(Globals.LogTag, "Apdu response length: " + resp.ApduLength); + for (int i = 0; i < resp.ApduLength; i++) + { + Log.Debug(Globals.LogTag, "[" + i + "]'s byte: [0x" + resp.ApduResponse[i] + "]"); + } + + Log.Debug(Globals.LogTag, "Sim request APDU call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim request APDU exception: " + ex.ToString()); + } + } + + private async void powerBtn_Clicked(object sender, EventArgs e) + { + TapiHandle handle = Globals.handleModem0; + try + { + Log.Debug(Globals.LogTag, "Sim set power state call start"); + handle.NotificationChanged += Handle_NotiPowerStateChanged; + handle.RegisterNotiEvent(Notification.SimStatus); + bool state = await sim.SimSetPowerState(SimPowerState.Off); + if (state) + { + await sim.SimSetPowerState(SimPowerState.On); + } + + Log.Debug(Globals.LogTag, "Sim set power state call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim set power state exception: " + ex.ToString()); + } + + finally + { + handle.DeregisterNotiEvent(Notification.SimStatus); + handle.NotificationChanged -= Handle_NotiPowerStateChanged; + } + } + + private void Handle_NotiPowerStateChanged(object sender, NotificationChangedEventArgs e) + { + Log.Debug(Globals.LogTag, "Sim status noti event received, Status: " + e.Data + " Noti value: " + e.Id); + } + + private async void autnBtn_Clicked(object sender, EventArgs e) + { + try + { + SimAuthenticationData authData = new SimAuthenticationData(SimAuthenticationType.Auth3G, 4, 4, Encoding.ASCII.GetBytes("qwerty"), Encoding.ASCII.GetBytes("asdf")); + Log.Debug(Globals.LogTag, "Sim execute authentication call start"); + SimAuthenticationResponse authResp = await sim.SimExecuteAuthentication(authData); + Log.Debug(Globals.LogTag, "Response auth type: " + authResp.AuthType); + Log.Debug(Globals.LogTag, "Response auth result: " + authResp.AuthResult); + Log.Debug(Globals.LogTag, "Response data: " + authResp.ResponseData); + Log.Debug(Globals.LogTag, "Auth key: " + authResp.AuthKey); + Log.Debug(Globals.LogTag, "Cipher data: " + authResp.CipherData); + Log.Debug(Globals.LogTag, "Integrity data: " + authResp.IntegrityData); + Log.Debug(Globals.LogTag, "Sim execute authentication call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get SPN exception: " + ex.ToString()); + } + } + + private async void spnBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim get SPN call start"); + SimSpn spn = await sim.SimGetSpn(); + Log.Debug(Globals.LogTag, "SPN display condition: " + spn.DisplayCondition); + Log.Debug(Globals.LogTag, "SPN name: " + spn.Spn); + Log.Debug(Globals.LogTag, "Sim get SPN call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get SPN exception: " + ex.ToString()); + } + } + + private async void oplmnwactBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim get oplmnwact call start"); + SimOplmnwactList oplmnwact = await sim.SimGetOplmnwact(); + Log.Debug(Globals.LogTag, "Sim OPLMNWACT count: " + oplmnwact.Count); + List oplmnList = oplmnwact.List.ToList(); + for (int i = 0; i < oplmnwact.Count; i++) + { + Log.Debug(Globals.LogTag, "Oplmn.list[" + i + "].Plmn: " + oplmnList[i].Plmn); + Log.Debug(Globals.LogTag, "Oplmn.list[" + i + "].IsUmt: " + oplmnList[i].IsUmts); + Log.Debug(Globals.LogTag, "Oplmn.list[" + i + "].IsGsm: " + oplmnList[i].IsGsm); + } + + Log.Debug(Globals.LogTag, "Sim get oplmnwact call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get oplmnwact exception: " + ex.ToString()); + } + } + + private async void msisdnBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim get msisdn call start"); + SimMsisdnList msisdn = await sim.SimGetMsisdn(); + Log.Debug(Globals.LogTag, "Sim MSISDN count: " + msisdn.Count); + List subs = msisdn.List.ToList(); + for (int i = 0; i < msisdn.Count; i++) + { + Log.Debug(Globals.LogTag, "Msisdn.list[" + i + "].Number: " + subs[i].Number); + Log.Debug(Globals.LogTag, "Msisdn.list[" + i + "].Name: " +subs[i].Name); + } + + Log.Debug(Globals.LogTag, "Sim get msisdn call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get msisdn exception: " + ex.ToString()); + } + } + + private async void langPrefBtn_Clicked(object sender, EventArgs e) + { + SimLanguagePreference current = await sim.SimGetLanguagePreference(); + try + { + Log.Debug(Globals.LogTag, "Sim get language preference call start"); + foreach (SimLanguagePreference pref in Enum.GetValues(typeof(SimLanguagePreference))) + { + if (pref == SimLanguagePreference.Unspecified) + { + break; + } + + Log.Debug(Globals.LogTag, "Setting sim language preference with " + pref); + bool setFlag = await sim.SimSetLanguagePreference(pref); + if (setFlag) + { + Log.Debug(Globals.LogTag, "Current sim language preference: " + await sim.SimGetLanguagePreference()); + } + } + + Log.Debug(Globals.LogTag, "Sim get language preference call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get language preference exception: " + ex.ToString()); + } + + finally + { + await sim.SimSetLanguagePreference(current); + } + } + + private async void iccIdBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim get ICC ID call start"); + SimIccIdInfo info = await sim.SimGetIccId(); + if (info == null) + { + Log.Debug(Globals.LogTag, "Sim icc id info is null"); + return; + } + + Log.Debug(Globals.LogTag, "Sim ICC ID length: " + info.IccLength); + Log.Debug(Globals.LogTag, "Sim ICC ID: " + info.IccNumber); + Log.Debug(Globals.LogTag, "Sim get ICC ID call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get ICC ID exception: " + ex.ToString()); + } + } + + private void appListBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim get app list call start"); + byte app = sim.SimGetApplicationList(); + Log.Debug(Globals.LogTag, "Sim app list: " + app); + if ((app & (byte)SimAppType.Sim) != 0) + { + Log.Debug(Globals.LogTag, "[SIM]"); + } + + if ((app & (byte)SimAppType.Usim) != 0) + { + Log.Debug(Globals.LogTag, "[USIM]"); + } + + if ((app & (byte)SimAppType.Csim) != 0) + { + Log.Debug(Globals.LogTag, "[CSIM]"); + } + + if ((app & (byte)SimAppType.Isim) != 0) + { + Log.Debug(Globals.LogTag, "[ISIM]"); + } + + Log.Debug(Globals.LogTag, "Sim get app list call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get app list exception: " + ex.ToString()); + } + } + + private void SimPropertiesBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim type call start"); + Log.Debug(Globals.LogTag, "Sim card type: " + sim.SimType); + Log.Debug(Globals.LogTag, "Sim type call success"); + + Log.Debug(Globals.LogTag, "Sim imsi info call start"); + SimImsiInfo imsi = sim.Imsi; + if (imsi == null) + { + Log.Debug(Globals.LogTag, "Imsi info is null"); + return; + } + + Log.Debug(Globals.LogTag, "Sim Mcc: " + imsi.Mcc); + Log.Debug(Globals.LogTag, "Sim Mnc: " + imsi.Mnc); + Log.Debug(Globals.LogTag, "Sim Msin: " + imsi.Msin); + Log.Debug(Globals.LogTag, "Sim imsi info call success"); + + Log.Debug(Globals.LogTag, "Sim ecc info call start"); + SimEccInfoList eccList = sim.Ecc; + Log.Debug(Globals.LogTag, "Sim ECC count: " + eccList.Count); + List ecc = eccList.EccList.ToList(); + for (int i = 0; i < eccList.Count; i++) + { + Log.Debug(Globals.LogTag, "EccList.list[" + i + "].Name: " + ecc[i].Name); + Log.Debug(Globals.LogTag, "EccList.list[" + i + "].Number: " + ecc[i].Number); + Log.Debug(Globals.LogTag, "EccList.list[" + i + "].Category: " + ecc[i].Category); + } + + Log.Debug(Globals.LogTag, "Sim ecc info call success"); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Sim get properties exception: " + ex.ToString()); + } + } + + private void SimInitInfoBtn_Clicked(object sender, EventArgs e) + { + try + { + Log.Debug(Globals.LogTag, "Sim init info call start"); + SimInitInfo info = sim.InitInfo; + if (info == null) + { + Log.Debug(Globals.LogTag, "Sim init info is null"); + return; + } + + Log.Debug(Globals.LogTag, "Sim status: " + info.Status); + Log.Debug(Globals.LogTag, "Sim card changed flag: " + info.IsCardChanged); + Log.Debug(Globals.LogTag, "Sim init info call success"); + } + + catch(Exception ex) + { + Log.Debug(Globals.LogTag, "Sim init info exception: " + ex.ToString()); + } + } + } +} diff --git a/test/Tizen.Tapitest/Tizen.Tapitest.csproj b/test/Tizen.Tapitest/Tizen.Tapitest.csproj index 28c7033..a5b91ea 100755 --- a/test/Tizen.Tapitest/Tizen.Tapitest.csproj +++ b/test/Tizen.Tapitest/Tizen.Tapitest.csproj @@ -1,120 +1,121 @@ - - - - 14.0 - Debug - AnyCPU - 8.0.30703 - 2.0 - {2F98DAC9-6F16-457B-AED7-D43CAC379341};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - {BC2C461D-A67A-47FF-8AAA-D584BD379226} - Exe - Properties - Tizen.Tapitest - Tizen.Tapitest - 512 - en-US - - - .NETCoreApp - v1.0 - false - .NETCoreApp,Version=v1.0 - .NETCoreApp,Version=v1.0 - true - $(NoWarn);1701 - false - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - {5bf0618d-32ca-4356-b25b-11bdfd0e6119} - Tizen.Tapi - - - - + + + + 14.0 + Debug + AnyCPU + 8.0.30703 + 2.0 + {2F98DAC9-6F16-457B-AED7-D43CAC379341};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {BC2C461D-A67A-47FF-8AAA-D584BD379226} + Exe + Properties + Tizen.Tapitest + Tizen.Tapitest + 512 + en-US + + + .NETCoreApp + v1.0 + false + .NETCoreApp,Version=v1.0 + .NETCoreApp,Version=v1.0 + true + $(NoWarn);1701 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {5bf0618d-32ca-4356-b25b-11bdfd0e6119} + Tizen.Tapi + + + + - + --> + + --> - <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) - <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) - true - - - - $(MSBuildExtensionsPath)\Tizen - $(TizenBuildPath)\bin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + --> + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) + true + + + + $(MSBuildExtensionsPath)\Tizen + $(TizenBuildPath)\bin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.7.4