Skip WifiStep when Wifi is unavailable 01/265201/2
authorKrzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <k.wieclaw@samsung.com>
Fri, 8 Oct 2021 14:50:35 +0000 (16:50 +0200)
committerKrzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <k.wieclaw@samsung.com>
Thu, 14 Oct 2021 13:48:36 +0000 (15:48 +0200)
Change-Id: I695c9300d7b9f8172fd3c1a87b08bf30e196879d
Signed-off-by: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <k.wieclaw@samsung.com>
Oobe/Oobe.Common/Services/WifiAvailabilityCheckService.cs [new file with mode: 0644]
Oobe/Oobe/Managers/ProcessManager.cs
Oobe/Oobe/OobeApp.cs

diff --git a/Oobe/Oobe.Common/Services/WifiAvailabilityCheckService.cs b/Oobe/Oobe.Common/Services/WifiAvailabilityCheckService.cs
new file mode 100644 (file)
index 0000000..7912088
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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 System;
+using Tizen.Network.WiFi;
+
+namespace Oobe.Common.Services
+{
+    /// <summary>
+    /// Wifi feature checking service.
+    /// </summary>
+    public static class WifiAvailabilityCheckService
+    {
+        /// <summary>
+        /// Checks the availability of the Wifi Service.
+        /// </summary>
+        /// <returns>Availability of Wifi Service or null in case of error.</returns>
+        public static bool? IsWifiFeatureAvailable()
+        {
+           try
+           {
+                _ = WiFiManager.IsActive;
+                return true;
+           }
+           catch (NotSupportedException e)
+           {
+                if (e.Message == "Unsupported feature http://tizen.org/feature/network.wifi")
+                {
+                    Tizen.Log.Debug("oobe", $"Expected not supported error: {e.Message}");
+                    return false;
+                }
+                else
+                {
+                    Tizen.Log.Error("oobe", $"Unexpected error: {e}");
+                    return null;
+                }
+           }
+           catch (Exception e)
+           {
+                Tizen.Log.Error("oobe", $"Unexpected error: {e}");
+                return null;
+           }
+        }
+    }
+}
index 79391d1e30dfeeba96579e24e60a6fb4947b0e77..a9d7743e4bc9a67b21d32dc0d54a34768df3753e 100644 (file)
@@ -18,6 +18,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using Oobe.Common.Interfaces;
+using Oobe.Common.Services;
 using Oobe.Language;
 using Oobe.Region;
 using Oobe.Terms;
@@ -40,14 +41,17 @@ namespace Oobe
         private ProcessManager()
         {
             // TODO consider loading this from xaml or xml
-            steps = new LinkedList<Lazy<ProcessStep>>(new[]
-                    {
-                        new Lazy<ProcessStep>(() => new LanguageStep()),
-                        new Lazy<ProcessStep>(() => new RegionStep()),
-                        new Lazy<ProcessStep>(() => new TermsStep()),
-                        new Lazy<ProcessStep>(() => new WifiStep()),
-                        new Lazy<ProcessStep>(() => new WelcomeStep()),
-                    });
+            steps = new LinkedList<Lazy<ProcessStep>>();
+            steps.AddLast(new Lazy<ProcessStep>(() => new LanguageStep()));
+            steps.AddLast(new Lazy<ProcessStep>(() => new RegionStep()));
+            steps.AddLast(new Lazy<ProcessStep>(() => new TermsStep()));
+
+            if (WifiAvailabilityCheckService.IsWifiFeatureAvailable() ?? false)
+            {
+                steps.AddLast(new Lazy<ProcessStep>(() => new WifiStep()));
+            }
+
+            steps.AddLast(new Lazy<ProcessStep>(() => new WelcomeStep()));
         }
 
         public static ProcessManager Instance
index cca0be7e1b32970006edd524905fb96f7f2e325b..1083bb7f0f019ef2e3b4edcccf2f77c4aedcb8a1 100644 (file)
@@ -21,7 +21,6 @@ using Oobe.Common.Services;
 using Oobe.Common.Utils;
 using Oobe.Managers;
 using Tizen.NUI;
-using Tizen.NUI.Components;
 
 namespace Oobe
 {