From: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics Date: Fri, 8 Oct 2021 14:50:35 +0000 (+0200) Subject: Skip WifiStep when Wifi is unavailable X-Git-Tag: submit/tizen/20211018.150202~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F265201%2F2;p=profile%2Fiot%2Fapps%2Fnative%2Foobe.git Skip WifiStep when Wifi is unavailable Change-Id: I695c9300d7b9f8172fd3c1a87b08bf30e196879d Signed-off-by: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics --- diff --git a/Oobe/Oobe.Common/Services/WifiAvailabilityCheckService.cs b/Oobe/Oobe.Common/Services/WifiAvailabilityCheckService.cs new file mode 100644 index 0000000..7912088 --- /dev/null +++ b/Oobe/Oobe.Common/Services/WifiAvailabilityCheckService.cs @@ -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 +{ + /// + /// Wifi feature checking service. + /// + public static class WifiAvailabilityCheckService + { + /// + /// Checks the availability of the Wifi Service. + /// + /// Availability of Wifi Service or null in case of error. + 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; + } + } + } +} diff --git a/Oobe/Oobe/Managers/ProcessManager.cs b/Oobe/Oobe/Managers/ProcessManager.cs index 79391d1..a9d7743 100644 --- a/Oobe/Oobe/Managers/ProcessManager.cs +++ b/Oobe/Oobe/Managers/ProcessManager.cs @@ -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>(new[] - { - new Lazy(() => new LanguageStep()), - new Lazy(() => new RegionStep()), - new Lazy(() => new TermsStep()), - new Lazy(() => new WifiStep()), - new Lazy(() => new WelcomeStep()), - }); + steps = new LinkedList>(); + steps.AddLast(new Lazy(() => new LanguageStep())); + steps.AddLast(new Lazy(() => new RegionStep())); + steps.AddLast(new Lazy(() => new TermsStep())); + + if (WifiAvailabilityCheckService.IsWifiFeatureAvailable() ?? false) + { + steps.AddLast(new Lazy(() => new WifiStep())); + } + + steps.AddLast(new Lazy(() => new WelcomeStep())); } public static ProcessManager Instance diff --git a/Oobe/Oobe/OobeApp.cs b/Oobe/Oobe/OobeApp.cs index cca0be7..1083bb7 100644 --- a/Oobe/Oobe/OobeApp.cs +++ b/Oobe/Oobe/OobeApp.cs @@ -21,7 +21,6 @@ using Oobe.Common.Services; using Oobe.Common.Utils; using Oobe.Managers; using Tizen.NUI; -using Tizen.NUI.Components; namespace Oobe {