From: adhavan.m Date: Fri, 13 Oct 2017 14:04:36 +0000 (+0530) Subject: [Telephony] Sample App implementation. X-Git-Tag: preview1-00325^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F155571%2F2;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Telephony] Sample App implementation. Change-Id: Id7d8bb8d12a0a30f2a0eff0a51ebf15e534ca2b0 Signed-off-by: adhavan.m --- diff --git a/test/SampleTelephony/CallPage.cs b/test/SampleTelephony/CallPage.cs new file mode 100755 index 0000000..195665c --- /dev/null +++ b/test/SampleTelephony/CallPage.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xamarin.Forms; +using Tizen; +using Tizen.Telephony; + +namespace XamarinForTizen.Tizen +{ + public class CallPage : ContentPage + { + private static Call _call = null; + private ChangeNotificationEventArgs.Notification[] notiArr = { ChangeNotificationEventArgs.Notification.CallPreferredVoiceSubscription, + ChangeNotificationEventArgs.Notification.VoiceCallStatusDialing, + ChangeNotificationEventArgs.Notification.VoiceCallStatusIncoming }; + public CallPage() + { + var subsBtn = new Button + { + Text = "Get preferred voice subscription", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + subsBtn.Clicked += subsBtn_Clicked; + + var callListBtn = new Button + { + Text = "Get call list", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + callListBtn.Clicked += callListBtn_Clicked; + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + subsBtn, callListBtn + } + }; + + try + { + if (Globals.slotHandle == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Globals.slotHandle.ChangeNotification += SlotHandle_ChangeNotification; + List notiList = new List(); + foreach (ChangeNotificationEventArgs.Notification noti in notiArr) + { + notiList.Add(noti); + } + + Globals.slotHandle.SetNotificationId(notiList); + _call = new Call(Globals.slotHandle); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Exception in call constructor: " + ex.ToString()); + } + } + + private void SlotHandle_ChangeNotification(object sender, ChangeNotificationEventArgs e) + { + Log.Debug(Globals.LogTag, "Change notification: " + e.NotificationType); + } + + private void callListBtn_Clicked(object sender, EventArgs e) + { + try + { + if (_call == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + List handleList = _call.GetCallHandleList().ToList(); + if (handleList.Count == 0) + { + Log.Debug(Globals.LogTag, "Call handle list is empty"); + return; + } + + foreach (CallHandle handle in handleList) + { + Log.Debug(Globals.LogTag, "HandleId: " + handle.HandleId); + Log.Debug(Globals.LogTag, "Number: " + handle.Number); + Log.Debug(Globals.LogTag, "Type: " + handle.Type); + Log.Debug(Globals.LogTag, "Status: " + handle.Status); + Log.Debug(Globals.LogTag, "Direction: " + handle.Direction); + Log.Debug(Globals.LogTag, "ConferenceStatus: " + handle.ConferenceStatus); + } + } + + catch(Exception ex) + { + Log.Debug(Globals.LogTag, "Exception caught in getting call list: " + ex.ToString()); + } + } + + private void subsBtn_Clicked(object sender, EventArgs e) + { + if (_call == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Preferred voice subscription: " + _call.PreferredVoiceSubscription); + } + } +} diff --git a/test/SampleTelephony/MainPage.cs b/test/SampleTelephony/MainPage.cs new file mode 100755 index 0000000..b6601dd --- /dev/null +++ b/test/SampleTelephony/MainPage.cs @@ -0,0 +1,143 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; +using Xamarin.Forms; +using Tizen; +using Tizen.Telephony; + +namespace XamarinForTizen.Tizen +{ + public class MainPage : ContentPage + { + public MainPage() + { + var initBtn = new Button + { + Text = "Initialize", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + initBtn.Clicked += initBtn_Clicked; + + var callBtn = new Button + { + Text = "Call", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + callBtn.Clicked += callBtn_Clicked; + + var ModemBtn = new Button + { + Text = "Modem", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + ModemBtn.Clicked += ModemBtn_Clicked; + + var NetworkBtn = new Button + { + Text = "Network", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + NetworkBtn.Clicked += NetworkBtn_Clicked; + + var simBtn = new Button + { + Text = "Sim", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + simBtn.Clicked += simBtn_Clicked; + + var deinitBtn = new Button + { + Text = "Deinitialize", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + deinitBtn.Clicked += deinitBtn_Clicked; + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + initBtn, callBtn, ModemBtn, NetworkBtn, simBtn, deinitBtn + } + }; + + try + { + Manager.StateChanged += Manager_StateChanged; + } + + catch(Exception ex) + { + Log.Debug(Globals.LogTag, "Exception in registering for state changed event: " + ex.ToString()); + } + } + + private void Manager_StateChanged(object sender, StateEventArgs e) + { + Log.Debug(Globals.LogTag, "Telephony state changed: " + e.CurrentState); + } + + private void deinitBtn_Clicked(object sender, EventArgs e) + { + try + { + Manager.Deinit(); + Globals.slotHandle = null; + Log.Debug(Globals.LogTag, "Deinit successful"); + } + + catch(Exception ex) + { + Log.Debug(Globals.LogTag, "Telephony deinit exception: " + ex.ToString()); + } + } + + private async void callBtn_Clicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new CallPage()); + } + + private async void ModemBtn_Clicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new ModemPage()); + } + + private async void NetworkBtn_Clicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new NetworkPage()); + } + + private async void simBtn_Clicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new SimPage()); + } + + private void initBtn_Clicked(object sender, EventArgs e) + { + try + { + List simList = Manager.Init().ToList(); + if (simList.Count == 0) + { + Log.Debug(Globals.LogTag, "SimList count is zero"); + return; + } + + Log.Debug(Globals.LogTag, "Telephony initialized successfully"); + Globals.slotHandle = simList.ElementAt(0); + } + + catch(Exception ex) + { + Log.Debug(Globals.LogTag, "Telephony init exception: " + ex.ToString()); + } + } + } +} diff --git a/test/SampleTelephony/ModemPage.cs b/test/SampleTelephony/ModemPage.cs new file mode 100755 index 0000000..e7c517d --- /dev/null +++ b/test/SampleTelephony/ModemPage.cs @@ -0,0 +1,95 @@ +using System; +using Xamarin.Forms; +using Tizen; +using Tizen.Telephony; + +namespace XamarinForTizen.Tizen +{ + public class ModemPage : ContentPage + { + private static Modem _modem = null; + public ModemPage() + { + var imeiBtn = new Button + { + Text = "Get IMEI", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + imeiBtn.Clicked += imeiBtn_Clicked; + + var powerBtn = new Button + { + Text = "Get power status", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + powerBtn.Clicked += powerBtn_Clicked; + + var meidBtn = new Button + { + Text = "Get MEID", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + meidBtn.Clicked += meidBtn_Clicked; + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + imeiBtn, powerBtn, meidBtn + } + }; + + try + { + if (Globals.slotHandle == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + _modem = new Modem(Globals.slotHandle); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Exception in modem constructor: " + ex.ToString()); + } + } + + private void meidBtn_Clicked(object sender, EventArgs e) + { + if (_modem == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "MEID: " + _modem.Meid); + } + + private void powerBtn_Clicked(object sender, EventArgs e) + { + if (_modem == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Power Status: " + _modem.CurrentPowerStatus); + } + + private void imeiBtn_Clicked(object sender, EventArgs e) + { + if (_modem == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "IMEI: " + _modem.Imei); + } + } +} diff --git a/test/SampleTelephony/NetworkPage.cs b/test/SampleTelephony/NetworkPage.cs new file mode 100755 index 0000000..aee48aa --- /dev/null +++ b/test/SampleTelephony/NetworkPage.cs @@ -0,0 +1,114 @@ +using System; +using Xamarin.Forms; +using Tizen; +using Tizen.Telephony; + +namespace XamarinForTizen.Tizen +{ + public class NetworkPage : ContentPage + { + private static Network _network = null; + public NetworkPage() + { + var cellBtn = new Button + { + Text = "Get cell ID", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + cellBtn.Clicked += cellBtn_Clicked; + + var lacBtn = new Button + { + Text = "Get LAC", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + lacBtn.Clicked += lacBtn_Clicked; + + var mccBtn = new Button + { + Text = "Get Mcc", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + mccBtn.Clicked += mccBtn_Clicked; + + var mncBtn = new Button + { + Text = "Get Mnc", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + mncBtn.Clicked += mncBtn_Clicked; + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + cellBtn, lacBtn, mccBtn, mncBtn + } + }; + + try + { + if (Globals.slotHandle == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + _network = new Network(Globals.slotHandle); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Exception in network constructor: " + ex.ToString()); + } + } + + private void mncBtn_Clicked(object sender, EventArgs e) + { + if (_network == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Mnc: " + _network.Mnc); + } + + private void mccBtn_Clicked(object sender, EventArgs e) + { + if (_network == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Mcc: " + _network.Mcc); + } + + private void lacBtn_Clicked(object sender, EventArgs e) + { + if (_network == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Lac: " + _network.Lac); + } + + private void cellBtn_Clicked(object sender, EventArgs e) + { + if (_network == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Cell ID: " + _network.CellId); + } + } +} diff --git a/test/SampleTelephony/Program.cs b/test/SampleTelephony/Program.cs new file mode 100755 index 0000000..d050539 --- /dev/null +++ b/test/SampleTelephony/Program.cs @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using Xamarin.Forms; +using Tizen; +using Tizen.System; +using Tizen.Telephony; + +namespace XamarinForTizen.Tizen +{ + internal static class Globals + { + internal static string LogTag = "TelephonyTest"; + internal static SlotHandle slotHandle = null; + } + public class App : Application + { + private static bool s_isTelephonySupported = false; + public App() + { + SystemInfo.TryGetValue("http://tizen.org/feature/network.telephony", out s_isTelephonySupported); + if (s_isTelephonySupported) + { + Log.Debug(Globals.LogTag, "Telephony feature check = " + s_isTelephonySupported); + MainPage = new NavigationPage(new MainPage()); + } + + else + { + Log.Debug(Globals.LogTag, "Telephony feature is not supported"); + } + } + + protected override void OnStart() + { + // Handle when your app starts + } + + protected override void OnSleep() + { + // Handle when your app sleeps + } + + protected override void OnResume() + { + // Handle when your app resumes + } + } + + class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + { + private static App _app; + protected override void OnCreate() + { + base.OnCreate(); + + Log.Debug(Globals.LogTag, "OnCreate()"); + _app = new App(); + LoadApplication(_app); + } + + public static App getApp() + { + return _app; + } + static void Main(string[] args) + { + var app = new Program(); + global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); + app.Run(args); + } + } +} \ No newline at end of file diff --git a/test/SampleTelephony/SampleTelephony.csproj b/test/SampleTelephony/SampleTelephony.csproj new file mode 100755 index 0000000..466348a --- /dev/null +++ b/test/SampleTelephony/SampleTelephony.csproj @@ -0,0 +1,63 @@ + + + + + $(MSBuildExtensionsPath)\Tizen\VisualStudio\ + + + + + + Exe + netcoreapp1.1 + + + + + true + $(PackageTargetFallback);portable-net45+wp80+win81+wpa81 + + + + + + portable + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/SampleTelephony/SampleTelephony.sln b/test/SampleTelephony/SampleTelephony.sln new file mode 100755 index 0000000..e76324f --- /dev/null +++ b/test/SampleTelephony/SampleTelephony.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleTelephony", "SampleTelephony.csproj", "{404DDD6F-0734-4F16-A70F-EB384C247669}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Telephony", "..\..\src\Tizen.Telephony\Tizen.Telephony.csproj", "{C5987A97-08BF-4143-BABD-2F044A75A52C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {404DDD6F-0734-4F16-A70F-EB384C247669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {404DDD6F-0734-4F16-A70F-EB384C247669}.Debug|Any CPU.Build.0 = Debug|Any CPU + {404DDD6F-0734-4F16-A70F-EB384C247669}.Release|Any CPU.ActiveCfg = Release|Any CPU + {404DDD6F-0734-4F16-A70F-EB384C247669}.Release|Any CPU.Build.0 = Release|Any CPU + {C5987A97-08BF-4143-BABD-2F044A75A52C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5987A97-08BF-4143-BABD-2F044A75A52C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5987A97-08BF-4143-BABD-2F044A75A52C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5987A97-08BF-4143-BABD-2F044A75A52C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/test/SampleTelephony/SimPage.cs b/test/SampleTelephony/SimPage.cs new file mode 100755 index 0000000..b10d149 --- /dev/null +++ b/test/SampleTelephony/SimPage.cs @@ -0,0 +1,117 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; +using Xamarin.Forms; +using Tizen; +using Tizen.Telephony; + +namespace XamarinForTizen.Tizen +{ + public class SimPage : ContentPage + { + private static Sim _sim = null; + public SimPage() + { + var changedBtn = new Button + { + Text = "Is sim changed", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + changedBtn.Clicked += changedBtn_Clicked; + + var operatorBtn = new Button + { + Text = "Get operator", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + operatorBtn.Clicked += operatorBtn_Clicked; + + var iccIdBtn = new Button + { + Text = "Get Icc id", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + iccIdBtn.Clicked += iccIdBtn_Clicked; + + var msinBtn = new Button + { + Text = "Get Msin", + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.FillAndExpand + }; + msinBtn.Clicked += msinBtn_Clicked; + + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + changedBtn, operatorBtn, iccIdBtn, msinBtn + } + }; + + try + { + if (Globals.slotHandle == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + _sim = new Sim(Globals.slotHandle); + } + + catch (Exception ex) + { + Log.Debug(Globals.LogTag, "Exception in Sim constructor: " + ex.ToString()); + } + } + + private void msinBtn_Clicked(object sender, EventArgs e) + { + if (_sim == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Msin: " + _sim.Msin); + } + + private void iccIdBtn_Clicked(object sender, EventArgs e) + { + if (_sim == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Icc id: " + _sim.IccId); + } + + private void operatorBtn_Clicked(object sender, EventArgs e) + { + if (_sim == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Operator: " + _sim.Operator); + } + + private void changedBtn_Clicked(object sender, EventArgs e) + { + if (_sim == null) + { + Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles"); + return; + } + + Log.Debug(Globals.LogTag, "Is sim changed: " + _sim.IsChanged); + } + } +} diff --git a/test/SampleTelephony/shared/res/Tizen.Telephony.Test.png b/test/SampleTelephony/shared/res/Tizen.Telephony.Test.png new file mode 100755 index 0000000..9f3cb98 Binary files /dev/null and b/test/SampleTelephony/shared/res/Tizen.Telephony.Test.png differ diff --git a/test/SampleTelephony/tizen-manifest.xml b/test/SampleTelephony/tizen-manifest.xml new file mode 100755 index 0000000..48e557c --- /dev/null +++ b/test/SampleTelephony/tizen-manifest.xml @@ -0,0 +1,13 @@ + + + + + + Tizen.Telephony.Test.png + + + + http://tizen.org/privilege/telephony + http://tizen.org/privilege/location.coarse + +