Introduce oobe_done flag (#6)
authorLukasz Stanislawski/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <l.stanislaws@samsung.com>
Wed, 18 Mar 2020 14:13:53 +0000 (15:13 +0100)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 18 Mar 2020 14:13:53 +0000 (15:13 +0100)
* Introduce oobe_done flag

Create oobe_done file which preserve information
about previosly finished oobe process.

Setting oobe_done is currently disabled in Debug mode.

Oobe/Oobe/Managers/ProcessManager.cs
Oobe/Oobe/Oobe.cs

index 1f3526d..20cabf5 100644 (file)
@@ -7,6 +7,7 @@ using Tizen.NUI;
 using Oobe.Region;
 using System;
 using Oobe.Wifi;
+using System.IO;
 
 namespace Oobe
  {
@@ -16,6 +17,8 @@ namespace Oobe
         private LinkedList<Lazy<ProcessStep>> steps;
         private LinkedListNode<Lazy<ProcessStep>> current;
 
+        static private string doneFile = Tizen.Applications.CoreUIApplication.Current.DirectoryInfo.Data + "oobe_done";
+
         public ProcessManager()
         {
             //TODO consider loading this from xaml, xml or something...
@@ -64,6 +67,9 @@ namespace Oobe
             {
                 step.Value.Shutdown();
             }
+            #if RELEASE
+            SetDone();
+            #endif
             NUIApplication.Current.Exit();
         }
 
@@ -78,5 +84,27 @@ namespace Oobe
                 ui.Pop();
             }
         }
+
+        static void SetDone()
+        {
+            if (!File.Exists(doneFile))
+            {
+                File.Create(doneFile).Dispose();
+            }
+        }
+
+        /// <summary>
+        /// Indicates if oobe process has been previously finished
+        /// </summary>
+        /// <returns></returns>
+        static public bool IsDone()
+        {
+            return File.Exists(doneFile);
+        }
+
+        static void ClearDone()
+        {
+            File.Delete(doneFile);
+        }
     }
 }
index 3fc8495..97b85ff 100644 (file)
@@ -10,6 +10,13 @@ namespace Oobe
 
         protected override void OnCreate()
         {
+            processManager = new ProcessManager();
+            if (ProcessManager.IsDone())
+            {
+                NUIApplication.Current.Exit();
+                return;
+            }
+
             base.OnCreate();
             Initialize();
         }
@@ -18,7 +25,6 @@ namespace Oobe
         {
             processManager = new ProcessManager();
             processManager.Start();
-
             Button button = new Button();
             button.Text = "Next";
             button.BackgroundColor = Color.Blue;