[NUI] Fix SVACE issue.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Application / Application.cs
index ac87ddc..e296361 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2022 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.
@@ -24,16 +24,12 @@ using Tizen.NUI.Binding;
 
 namespace Tizen.NUI
 {
-    /**
-      * @brief Event arguments that passed via NUIApplicationInit signal
-      */
+    // Event arguments that passed via NUIApplicationInit signal
     internal class NUIApplicationInitEventArgs : EventArgs
     {
         private Application application;
 
-        /**
-          * @brief Application - is the application that is being initialized
-          */
+        // Application - is the application that is being initialized
         public Application Application
         {
             get
@@ -47,15 +43,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationTerminate signal
-      */
+    // Event arguments that passed via NUIApplicationTerminate signal
     internal class NUIApplicationTerminatingEventArgs : EventArgs
     {
         private Application application;
-        /**
-          * @brief Application - is the application that is being Terminated
-          */
+
+        // Application - is the application that is being Terminated
         public Application Application
         {
             get
@@ -69,15 +62,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationPause signal
-      */
+    // Event arguments that passed via NUIApplicationPause signal
     internal class NUIApplicationPausedEventArgs : EventArgs
     {
         private Application application;
-        /**
-          * @brief Application - is the application that is being Paused
-          */
+
+        // Application - is the application that is being Paused
         public Application Application
         {
             get
@@ -91,15 +81,11 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationResume signal
-      */
+    // Event arguments that passed via NUIApplicationResume signal
     internal class NUIApplicationResumedEventArgs : EventArgs
     {
         private Application application;
-        /**
-          * @brief Application - is the application that is being Resumed
-          */
+        // Application - is the application that is being Resumed
         public Application Application
         {
             get
@@ -113,15 +99,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationReset signal
-      */
+    // Event arguments that passed via NUIApplicationReset signal
     internal class NUIApplicationResetEventArgs : EventArgs
     {
         private Application application;
-        /**
-          * @brief Application - is the application that is being Reset
-          */
+
+        // Application - is the application that is being Reset
         public Application Application
         {
             get
@@ -135,15 +118,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
-      */
+    // Event arguments that passed via NUIApplicationLanguageChanged signal
     internal class NUIApplicationLanguageChangedEventArgs : EventArgs
     {
         private Application application;
-        /**
-          * @brief Application - is the application that is being affected with Device's language change
-          */
+
+        // Application - is the application that is being affected with Device's language change
         public Application Application
         {
             get
@@ -157,15 +137,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationRegionChanged signal
-      */
+    // Event arguments that passed via NUIApplicationRegionChanged signal
     internal class NUIApplicationRegionChangedEventArgs : EventArgs
     {
         private Application application;
-        /**
-          * @brief Application - is the application that is being affected with Device's region change
-          */
+
+        // Application - is the application that is being affected with Device's region change
         public Application Application
         {
             get
@@ -179,15 +156,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationBatteryLow signal
-      */
+    // Event arguments that passed via NUIApplicationBatteryLow signal
     internal class NUIApplicationBatteryLowEventArgs : EventArgs
     {
         private Application.BatteryStatus status;
-        /**
-          * @brief Application - is the application that is being affected when the battery level of the device is low
-          */
+
+        // Application - is the application that is being affected when the battery level of the device is low
         public Application.BatteryStatus BatteryStatus
         {
             get
@@ -201,15 +175,12 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationMemoryLow signal
-      */
+    // Event arguments that passed via NUIApplicationMemoryLow signal
     internal class NUIApplicationMemoryLowEventArgs : EventArgs
     {
         private Application.MemoryStatus status;
-        /**
-          * @brief Application - is the application that is being affected when the memory level of the device is low
-          */
+
+        // Application - is the application that is being affected when the memory level of the device is low
         public Application.MemoryStatus MemoryStatus
         {
             get
@@ -223,16 +194,32 @@ namespace Tizen.NUI
         }
     }
 
-    /**
-      * @brief Event arguments that passed via NUIApplicationAppControl         signal
-      */
+    // Event arguments that passed via NUIApplicationDeviceOrientationChanged signal
+    internal class NUIApplicationDeviceOrientationChangedEventArgs : EventArgs
+    {
+        private Application.DeviceOrientationStatus status;
+
+        // Application - is the application that is being affected when the device orientation is changed.
+        public Application.DeviceOrientationStatus DeviceOrientationStatus
+        {
+            get
+            {
+                return status;
+            }
+            set
+            {
+                status = value;
+            }
+        }
+    }
+
+    // Event arguments that passed via NUIApplicationAppControl         signal
     internal class NUIApplicationAppControlEventArgs : EventArgs
     {
         private Application application;
         private IntPtr voidp;
-        /**
-          * @brief Application - is the application that is receiving the launch request from another application
-          */
+
+        // Application - is the application that is receiving the launch request from another application
         public Application Application
         {
             get
@@ -244,9 +231,8 @@ namespace Tizen.NUI
                 application = value;
             }
         }
-        /**
-          * @brief VoidP - contains the information about why the application is launched
-          */
+
+        // VoidP - contains the information about why the application is launched
         public IntPtr VoidP
         {
             get
@@ -308,12 +294,9 @@ namespace Tizen.NUI
 
         public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e);
 
-        internal event EventHandler<ResourcesChangedEventArgs> XamlResourceChanged;
-
         internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
         {
             base.OnResourcesChanged(sender, e);
-            XamlResourceChanged?.Invoke(sender, e);
         }
 
         public ResourceDictionary XamlResources
@@ -358,6 +341,9 @@ namespace Tizen.NUI
 
         internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
         {
+            if (values == null)
+                return;
+
             if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
             {
                 base.OnParentResourcesChanged(values);
@@ -373,7 +359,8 @@ namespace Tizen.NUI
                 if (innerKeys.Add(value.Key))
                     changedResources.Add(value);
             }
-            OnResourcesChanged(changedResources);
+            if (changedResources.Count != 0)
+                OnResourcesChanged(changedResources);
         }
 
         internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
@@ -455,6 +442,13 @@ namespace Tizen.NUI
                 memoryLowSignal = null;
             }
 
+            if (applicationDeviceOrientationChangedEventCallback != null)
+            {
+                deviceOrientationChangedSignal?.Disconnect(applicationDeviceOrientationChangedEventCallback);
+                deviceOrientationChangedSignal?.Dispose();
+                deviceOrientationChangedSignal = null;
+            }
+
             if (applicationAppControlEventCallbackDelegate != null)
             {
                 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
@@ -462,6 +456,63 @@ namespace Tizen.NUI
                 appControlSignal = null;
             }
 
+            //Task
+            if (applicationTaskInitEventCallbackDelegate != null)
+            {
+                taskInitSignal?.Disconnect(applicationTaskInitEventCallbackDelegate);
+                taskInitSignal?.Dispose();
+                taskInitSignal = null;
+            }
+
+            if (applicationTaskTerminateEventCallbackDelegate != null)
+            {
+                taskTerminateSignal?.Disconnect(applicationTaskTerminateEventCallbackDelegate);
+                taskTerminateSignal?.Dispose();
+                taskTerminateSignal = null;
+            }
+
+            if (applicationTaskLanguageChangedEventCallbackDelegate != null)
+            {
+                taskLanguageChangedSignal?.Disconnect(applicationTaskLanguageChangedEventCallbackDelegate);
+                taskLanguageChangedSignal?.Dispose();
+                taskLanguageChangedSignal = null;
+            }
+
+            if (applicationTaskRegionChangedEventCallbackDelegate != null)
+            {
+                taskRegionChangedSignal?.Disconnect(applicationTaskRegionChangedEventCallbackDelegate);
+                taskRegionChangedSignal?.Dispose();
+                taskRegionChangedSignal = null;
+            }
+
+            if (applicationTaskBatteryLowEventCallbackDelegate != null)
+            {
+                taskBatteryLowSignal?.Disconnect(applicationTaskBatteryLowEventCallbackDelegate);
+                taskBatteryLowSignal?.Dispose();
+                taskBatteryLowSignal = null;
+            }
+
+            if (applicationTaskMemoryLowEventCallbackDelegate != null)
+            {
+                taskMemoryLowSignal?.Disconnect(applicationTaskMemoryLowEventCallbackDelegate);
+                taskMemoryLowSignal?.Dispose();
+                taskMemoryLowSignal = null;
+            }
+
+            if (applicationTaskDeviceOrientationChangedEventCallback != null)
+            {
+                taskDeviceOrientationChangedSignal?.Disconnect(applicationTaskDeviceOrientationChangedEventCallback);
+                taskDeviceOrientationChangedSignal?.Dispose();
+                taskDeviceOrientationChangedSignal = null;
+            }
+
+            if (applicationTaskAppControlEventCallbackDelegate != null)
+            {
+                taskAppControlSignal?.Disconnect(applicationTaskAppControlEventCallbackDelegate);
+                taskAppControlSignal?.Dispose();
+                taskAppControlSignal = null;
+            }
+
             window?.Dispose();
             window = null;
 
@@ -486,6 +537,14 @@ namespace Tizen.NUI
             CriticallyLow
         };
 
+        public enum DeviceOrientationStatus
+        {
+            Orientation_0 = 0,
+            Orientation_90 = 90,
+            Orientation_180 = 180,
+            Orientation_270 = 270
+        };
+
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
         private DaliEventHandler<object, NUIApplicationInitEventArgs> applicationInitEventHandler;
@@ -542,17 +601,53 @@ namespace Tizen.NUI
         private LowMemorySignalType memoryLowSignal;
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        private delegate void NUIApplicationDeviceOrientationChangedEventCallback(DeviceOrientationStatus status);
+        private DaliEventHandler<object, NUIApplicationDeviceOrientationChangedEventArgs> applicationDeviceOrientationChangedEventHandler;
+        private NUIApplicationDeviceOrientationChangedEventCallback applicationDeviceOrientationChangedEventCallback;
+        private DeviceOrientationChangedSignalType deviceOrientationChangedSignal;
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
         private DaliEventHandler<object, NUIApplicationAppControlEventArgs> applicationAppControlEventHandler;
         private NUIApplicationAppControlEventCallbackDelegate applicationAppControlEventCallbackDelegate;
         private ApplicationControlSignal appControlSignal;
 
+        private DaliEventHandler<object, NUIApplicationInitEventArgs> applicationTaskInitEventHandler;
+        private NUIApplicationInitEventCallbackDelegate applicationTaskInitEventCallbackDelegate;
+        private ApplicationSignal taskInitSignal;
+
+        private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> applicationTaskTerminateEventHandler;
+        private NUIApplicationTerminateEventCallbackDelegate applicationTaskTerminateEventCallbackDelegate;
+        private ApplicationSignal taskTerminateSignal;
+
+        private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> applicationTaskLanguageChangedEventHandler;
+        private NUIApplicationLanguageChangedEventCallbackDelegate applicationTaskLanguageChangedEventCallbackDelegate;
+        private ApplicationSignal taskLanguageChangedSignal;
+
+        private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> applicationTaskRegionChangedEventHandler;
+        private NUIApplicationRegionChangedEventCallbackDelegate applicationTaskRegionChangedEventCallbackDelegate;
+        private ApplicationSignal taskRegionChangedSignal;
+
+        private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> applicationTaskBatteryLowEventHandler;
+        private NUIApplicationBatteryLowEventCallbackDelegate applicationTaskBatteryLowEventCallbackDelegate;
+        private LowBatterySignalType taskBatteryLowSignal;
+
+        private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> applicationTaskMemoryLowEventHandler;
+        private NUIApplicationMemoryLowEventCallbackDelegate applicationTaskMemoryLowEventCallbackDelegate;
+        private LowMemorySignalType taskMemoryLowSignal;
+
+        private DaliEventHandler<object, NUIApplicationDeviceOrientationChangedEventArgs> applicationTaskDeviceOrientationChangedEventHandler;
+        private NUIApplicationDeviceOrientationChangedEventCallback applicationTaskDeviceOrientationChangedEventCallback;
+        private DeviceOrientationChangedSignalType taskDeviceOrientationChangedSignal;
+
+        private DaliEventHandler<object, NUIApplicationAppControlEventArgs> applicationTaskAppControlEventHandler;
+        private NUIApplicationAppControlEventCallbackDelegate applicationTaskAppControlEventCallbackDelegate;
+        private ApplicationControlSignal taskAppControlSignal;
+
         private Window window;
 
-        /**
-          * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. Initialized signal is emitted when application is initialized
-          */
+        // Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
+        // provided by the user. Initialized signal is emitted when application is initialized
         public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
         {
             add
@@ -583,29 +678,43 @@ namespace Tizen.NUI
         // Callback for Application InitSignal
         private void OnApplicationInit(IntPtr data)
         {
+            Log.Info("NUI", "[NUI] OnApplicationInit: DisposeQueue Initialize");
+            Tizen.Tracer.Begin("[NUI] OnApplicationInit: DisposeQueue Initialize");
             // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
             DisposeQueue.Instance.Initialize();
-            Window.Instance = GetWindow();
+            Tizen.Tracer.End();
 
+            Log.Info("NUI", "[NUI] OnApplicationInit: GetWindow");
+            Tizen.Tracer.Begin("[NUI] OnApplicationInit: GetWindow");
+            Window.Instance = GetWindow();
+#if !PROFILE_TV
+            //tv profile never use default focus indicator, so this is not needed!
+            _ = FocusManager.Instance;
+#endif
+            Tizen.Tracer.End();
+
+            Log.Info("NUI", "[NUI] OnApplicationInit: Window Show");
+            Tizen.Tracer.Begin("[NUI] OnApplicationInit: Window Show");
             // Notify that the window is displayed to the app core.
             if (NUIApplication.IsPreload)
             {
                 Window.Instance.Show();
             }
+            Tizen.Tracer.End();
 
+            Log.Info("NUI", "[NUI] OnApplicationInit: applicationInitEventHandler Invoke");
+            Tizen.Tracer.Begin("[NUI] OnApplicationInit: applicationInitEventHandler Invoke");
             if (applicationInitEventHandler != null)
             {
                 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
                 e.Application = this;
                 applicationInitEventHandler.Invoke(this, e);
             }
-
+            Tizen.Tracer.End();
         }
 
-        /**
-          * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. Terminated signal is emitted when application is terminating
-          */
+        // Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. Terminated signal is emitted when application is terminating
         public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
         {
             add
@@ -645,16 +754,17 @@ namespace Tizen.NUI
             }
 
             List<Window> windows = GetWindowList();
-            foreach (Window window in windows)
+            if (windows != null)
             {
-                window?.DisconnectNativeSignals();
+                foreach (Window window in windows)
+                {
+                    window?.DisconnectNativeSignals();
+                }
             }
         }
 
-        /**
-          * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
-          * provided by the user. Paused signal is emitted when application is paused
-          */
+        // Event for Paused signal which can be used to subscribe/unsubscribe the event handler
+        // provided by the user. Paused signal is emitted when application is paused
         public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
         {
             add
@@ -694,10 +804,8 @@ namespace Tizen.NUI
             }
         }
 
-        /**
-          * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. Resumed signal is emitted when application is resumed
-          */
+        // Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. Resumed signal is emitted when application is resumed
         public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
         {
             add
@@ -737,10 +845,8 @@ namespace Tizen.NUI
             }
         }
 
-        /**
-          * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. Reset signal is emitted when application is reset
-          */
+        // Event for Reset signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. Reset signal is emitted when application is reset
         public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
         {
             add
@@ -780,10 +886,8 @@ namespace Tizen.NUI
             }
         }
 
-        /**
-          * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
-          */
+        // Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
         public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
         {
             add
@@ -823,10 +927,8 @@ namespace Tizen.NUI
             }
         }
 
-        /**
-          * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
-          */
+        // Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
         public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
         {
             add
@@ -866,10 +968,8 @@ namespace Tizen.NUI
             }
         }
 
-        /**
-          * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
-          * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
-          */
+        // Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
+        // provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
         public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
         {
             add
@@ -908,10 +1008,8 @@ namespace Tizen.NUI
             applicationBatteryLowEventHandler?.Invoke(this, e);
         }
 
-        /**
-          * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
-          */
+        // Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
         public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
         {
             add
@@ -950,10 +1048,47 @@ namespace Tizen.NUI
             applicationMemoryLowEventHandler?.Invoke(this, e);
         }
 
-        /**
-          * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
-          *  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
-          */
+        // Event for changing Device orientation signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. DeviceOrientationChanged signal is emitted when the device orientation is changed.
+        public event DaliEventHandler<object, NUIApplicationDeviceOrientationChangedEventArgs> DeviceOrientationChanged
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationDeviceOrientationChangedEventHandler == null)
+                {
+                    applicationDeviceOrientationChangedEventHandler += value;
+
+                    applicationDeviceOrientationChangedEventCallback = new NUIApplicationDeviceOrientationChangedEventCallback(OnNUIApplicationDeviceOrientationChanged);
+                    deviceOrientationChangedSignal = this.DeviceOrientationChangedSignal();
+                    deviceOrientationChangedSignal?.Connect(applicationDeviceOrientationChangedEventCallback);
+                }
+            }
+
+            remove
+            {
+                if (applicationDeviceOrientationChangedEventHandler != null)
+                {
+                    deviceOrientationChangedSignal?.Disconnect(applicationDeviceOrientationChangedEventCallback);
+                    deviceOrientationChangedSignal?.Dispose();
+                    deviceOrientationChangedSignal = null;
+                }
+
+                applicationDeviceOrientationChangedEventHandler -= value;
+            }
+        }
+
+        // Callback for Application DeviceOrientationChangedSignal
+        private void OnNUIApplicationDeviceOrientationChanged(DeviceOrientationStatus status)
+        {
+            NUIApplicationDeviceOrientationChangedEventArgs e = new NUIApplicationDeviceOrientationChangedEventArgs();
+
+            e.DeviceOrientationStatus = status;
+            applicationDeviceOrientationChangedEventHandler?.Invoke(this, e);
+        }
+
+        // Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
+        //  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
         public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
         {
             add
@@ -994,6 +1129,339 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
+        ///  provided by the user. Initialized signal is emitted when application is initialized
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationInitEventArgs> TaskInitialized
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskInitEventHandler == null)
+                {
+                    Tizen.Log.Fatal("NUI", "TaskInitialized Property adding");
+                    applicationTaskInitEventHandler += value;
+                    applicationTaskInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationTaskInit);
+                    taskInitSignal = this.TaskInitSignal();
+                    taskInitSignal?.Connect(applicationTaskInitEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskInitEventHandler != null)
+                {
+                    taskInitSignal?.Disconnect(applicationTaskInitEventCallbackDelegate);
+                    taskInitSignal?.Dispose();
+                    taskInitSignal = null;
+                }
+
+                applicationTaskInitEventHandler -= value;
+            }
+        }
+
+        private void OnApplicationTaskInit(IntPtr data)
+        {
+            if (applicationTaskInitEventHandler != null)
+            {
+                NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
+                e.Application = this;
+                applicationTaskInitEventHandler.Invoke(this, e);
+            }
+
+        }
+
+        /// <summary>
+        /// Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
+        ///  provided by the user. Terminated signal is emitted when application is terminating
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> TaskTerminating
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskTerminateEventHandler == null)
+                {
+                    applicationTaskTerminateEventHandler += value;
+
+                    applicationTaskTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTaskTerminate);
+                    taskTerminateSignal = this.TaskTerminateSignal();
+                    taskTerminateSignal?.Connect(applicationTaskTerminateEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskTerminateEventHandler != null)
+                {
+                    taskTerminateSignal?.Disconnect(applicationTaskTerminateEventCallbackDelegate);
+                    taskTerminateSignal?.Dispose();
+                    taskTerminateSignal = null;
+                }
+
+                applicationTaskTerminateEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskTerminate(IntPtr data)
+        {
+            if (applicationTaskTerminateEventHandler != null)
+            {
+                NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
+                e.Application = this;
+                applicationTaskTerminateEventHandler.Invoke(this, e);
+            }
+        }
+
+        /// <summary>
+        /// Event for TaskLanguageChanged signal which can be used to subscribe/unsubscribe the event handler
+        ///  provided by the user. TaskLanguageChanged signal is emitted when the region of the device is changed.
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> TaskLanguageChanged
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskLanguageChangedEventHandler == null)
+                {
+                    applicationTaskLanguageChangedEventHandler += value;
+
+                    applicationTaskLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationTaskLanguageChanged);
+                    taskLanguageChangedSignal = this.TaskLanguageChangedSignal();
+                    taskLanguageChangedSignal?.Connect(applicationTaskLanguageChangedEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskLanguageChangedEventHandler != null)
+                {
+                    taskLanguageChangedSignal?.Disconnect(applicationTaskLanguageChangedEventCallbackDelegate);
+                    taskLanguageChangedSignal?.Dispose();
+                    taskLanguageChangedSignal = null;
+                }
+
+                applicationTaskLanguageChangedEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskLanguageChanged(IntPtr data)
+        {
+            if (applicationTaskLanguageChangedEventHandler != null)
+            {
+                NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
+                e.Application = this;
+                applicationTaskLanguageChangedEventHandler.Invoke(this, e);
+            }
+        }
+
+        /// <summary>
+        /// Event for TaskRegionChanged signal which can be used to subscribe/unsubscribe the event handler
+        ///  provided by the user. TaskRegionChanged signal is emitted when the region of the device is changed.
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> TaskRegionChanged
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskRegionChangedEventHandler == null)
+                {
+                    applicationTaskRegionChangedEventHandler += value;
+
+                    applicationTaskRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationTaskRegionChanged);
+                    taskRegionChangedSignal = this.TaskRegionChangedSignal();
+                    taskRegionChangedSignal?.Connect(applicationTaskRegionChangedEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskRegionChangedEventHandler != null)
+                {
+                    taskRegionChangedSignal?.Disconnect(applicationTaskRegionChangedEventCallbackDelegate);
+                    taskRegionChangedSignal?.Dispose();
+                    taskRegionChangedSignal = null;
+                }
+
+                applicationTaskRegionChangedEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskRegionChanged(IntPtr data)
+        {
+            if (applicationTaskRegionChangedEventHandler != null)
+            {
+                NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
+                e.Application = this;
+                applicationTaskRegionChangedEventHandler.Invoke(this, e);
+            }
+        }
+
+        /// <summary>
+        /// Event for TaskBatteryLow signal which can be used to subscribe/unsubscribe the event handler
+        /// provided by the user. TaskBatteryLow signal is emitted when the battery level of the device is low.
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> TaskBatteryLow
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskBatteryLowEventHandler == null)
+                {
+                    applicationTaskBatteryLowEventHandler += value;
+
+                    applicationTaskBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationTaskBatteryLow);
+                    taskBatteryLowSignal = this.TaskBatteryLowSignal();
+                    taskBatteryLowSignal?.Connect(applicationTaskBatteryLowEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskBatteryLowEventHandler != null)
+                {
+                    taskBatteryLowSignal?.Disconnect(applicationTaskBatteryLowEventCallbackDelegate);
+                    taskBatteryLowSignal?.Dispose();
+                    taskBatteryLowSignal = null;
+                }
+
+                applicationTaskBatteryLowEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskBatteryLow(BatteryStatus status)
+        {
+            NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
+
+            // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
+            e.BatteryStatus = status;
+            applicationTaskBatteryLowEventHandler?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Event for TaskMemoryLow signal which can be used to subscribe/unsubscribe the event handler
+        /// provided by the user. TaskMemoryLow signal is emitted when the memory level of the device is low.
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> TaskMemoryLow
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskMemoryLowEventHandler == null)
+                {
+                    applicationTaskMemoryLowEventHandler += value;
+
+                    applicationTaskMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationTaskMemoryLow);
+                    taskMemoryLowSignal = this.TaskMemoryLowSignal();
+                    taskMemoryLowSignal?.Connect(applicationTaskMemoryLowEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskMemoryLowEventHandler != null)
+                {
+                    taskMemoryLowSignal?.Disconnect(applicationTaskMemoryLowEventCallbackDelegate);
+                    taskMemoryLowSignal?.Dispose();
+                    taskMemoryLowSignal = null;
+                }
+
+                applicationTaskMemoryLowEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskMemoryLow(MemoryStatus status)
+        {
+            NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
+
+            // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
+            e.MemoryStatus = status;
+            applicationTaskMemoryLowEventHandler?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Event for TaskDeviceOrientationChanged signal which can be used to subscribe/unsubscribe the event handler
+        /// provided by the user. TaskDeviceOrientationChanged signal is emitted when the device orientation is changed.
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationDeviceOrientationChangedEventArgs> TaskDeviceOrientationChanged
+        {
+            add
+            {
+                if (applicationTaskDeviceOrientationChangedEventHandler == null)
+                {
+                    applicationTaskDeviceOrientationChangedEventHandler += value;
+
+                    applicationTaskDeviceOrientationChangedEventCallback = new NUIApplicationDeviceOrientationChangedEventCallback(OnNUIApplicationTaskDeviceOrientationChanged);
+                    taskDeviceOrientationChangedSignal = this.TaskDeviceOrientationChangedSignal();
+                    taskDeviceOrientationChangedSignal?.Connect(applicationTaskDeviceOrientationChangedEventCallback);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskDeviceOrientationChangedEventHandler != null)
+                {
+                    taskDeviceOrientationChangedSignal?.Disconnect(applicationTaskDeviceOrientationChangedEventCallback);
+                    taskDeviceOrientationChangedSignal?.Dispose();
+                    taskDeviceOrientationChangedSignal = null;
+                }
+
+                applicationTaskDeviceOrientationChangedEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskDeviceOrientationChanged(DeviceOrientationStatus status)
+        {
+            NUIApplicationDeviceOrientationChangedEventArgs e = new NUIApplicationDeviceOrientationChangedEventArgs();
+
+            e.DeviceOrientationStatus = status;
+            applicationTaskDeviceOrientationChangedEventHandler?.Invoke(this, e);
+        }
+
+        /// <summary>
+        /// Event for TaskAppControl signal which can be used to subscribe/unsubscribe the event handler
+        /// provided by the user. TaskAppControl signal is emitted when another application sends a launch request to the application.
+        /// </summary>
+        public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> TaskAppControl
+        {
+            add
+            {
+                // Restricted to only one listener
+                if (applicationTaskAppControlEventHandler == null)
+                {
+                    applicationTaskAppControlEventHandler += value;
+
+                    applicationTaskAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationTaskAppControl);
+                    taskAppControlSignal = this.TaskAppControlSignal();
+                    taskAppControlSignal?.Connect(applicationTaskAppControlEventCallbackDelegate);
+                }
+            }
+
+            remove
+            {
+                if (applicationTaskAppControlEventHandler != null)
+                {
+                    taskAppControlSignal?.Disconnect(applicationTaskAppControlEventCallbackDelegate);
+                    taskAppControlSignal?.Dispose();
+                    taskAppControlSignal = null;
+                }
+
+                applicationTaskAppControlEventHandler -= value;
+            }
+        }
+
+        private void OnNUIApplicationTaskAppControl(IntPtr application, IntPtr voidp)
+        {
+            if (applicationTaskAppControlEventHandler != null)
+            {
+                NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
+                e.VoidP = voidp;
+                e.Application = this;
+                applicationTaskAppControlEventHandler.Invoke(this, e);
+            }
+        }
+
         protected static Application instance; // singleton
 
         public static Application Instance
@@ -1098,6 +1566,32 @@ namespace Tizen.NUI
             return instance;
         }
 
+        public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize, bool useUIThread)
+        {
+            if (instance != null)
+            {
+                return instance;
+            }
+            Application ret = New(args, stylesheet, windowMode, positionSize, useUIThread);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+            instance = ret;
+            return instance;
+        }
+
+        public static Application NewApplication(string[] args, string stylesheet, bool useUIThread, WindowData windowData)
+        {
+            if (instance != null)
+            {
+                return instance;
+            }
+            Application ret = New(args, stylesheet, useUIThread, windowData);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+            instance = ret;
+            return instance;
+        }
+
         /// <summary>
         /// Ensures that the function passed in is called from the main loop when it is idle.
         /// </summary>
@@ -1216,6 +1710,54 @@ namespace Tizen.NUI
             return ret;
         }
 
+        public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize, bool useUIThread)
+        {
+            Application ret = null;
+            int argc = 0;
+            string argvStr = "";
+            try
+            {
+                argc = args.Length;
+                argvStr = string.Join(" ", args);
+
+                ret = new Application(Interop.Application.New(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize), useUIThread), true);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+            catch (Exception exception)
+            {
+                Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
+                Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
+                Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
+                throw;
+            }
+
+            return ret;
+        }
+
+        public static Application New(string[] args, string stylesheet, bool useUIThread, WindowData windowData)
+        {
+            Application ret = null;
+            int argc = 0;
+            string argvStr = "";
+            try
+            {
+                argc = args.Length;
+                argvStr = string.Join(" ", args);
+
+                ret = new Application(Interop.Application.New(argc, argvStr, stylesheet, useUIThread, WindowData.getCPtr(windowData)), true);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+            catch (Exception exception)
+            {
+                Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
+                Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
+                Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
+                throw;
+            }
+
+            return ret;
+        }
+
         public Application() : this(Interop.Application.NewApplication(), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
@@ -1265,7 +1807,18 @@ namespace Tizen.NUI
                 return window;
             }
 
-            window = (Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window) ?? new Window(Interop.Application.GetWindow(SwigCPtr), true);
+            var nativeWindow = Interop.Application.GetWindow(SwigCPtr);
+            window = Registry.GetManagedBaseHandleFromNativePtr(nativeWindow) as Window;
+            if (window != null)
+            {
+                HandleRef CPtr = new HandleRef(this, nativeWindow);
+                Interop.BaseHandle.DeleteBaseHandle(CPtr);
+                CPtr = new HandleRef(null, IntPtr.Zero);
+            }
+            else
+            {
+                window = new Window(nativeWindow, true);
+            }
 
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return window;
@@ -1295,13 +1848,19 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static List<Window> GetWindowList()
         {
+            if (Interop.Stage.IsInstalled() == false)
+            {
+                NUILog.ErrorBacktrace($"[ERROR] dali adaptor and dali window is not ready. just return NULL here");
+                return null;
+            }
+
             uint ListSize = Interop.Application.GetWindowsListSize();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
             List<Window> WindowList = new List<Window>();
             for (uint i = 0; i < ListSize; ++i)
             {
-                Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
+                Window currWin = WindowList.GetInstanceSafely<Window>(Interop.Application.GetWindowsFromList(i));
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 if (currWin != null)
                 {
@@ -1380,5 +1939,69 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
+
+        internal DeviceOrientationChangedSignalType DeviceOrientationChangedSignal()
+        {
+            DeviceOrientationChangedSignalType ret = new DeviceOrientationChangedSignalType(NDalicPINVOKE.ApplicationDeviceOrientationChangedSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        //Task
+        internal ApplicationSignal TaskInitSignal()
+        {
+            ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTaskInitSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal ApplicationSignal TaskTerminateSignal()
+        {
+            ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTaskTerminateSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal ApplicationControlSignal TaskAppControlSignal()
+        {
+            ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationTaskAppControlSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal ApplicationSignal TaskLanguageChangedSignal()
+        {
+            ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTaskLanguageChangedSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal ApplicationSignal TaskRegionChangedSignal()
+        {
+            ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTaskRegionChangedSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal LowBatterySignalType TaskBatteryLowSignal()
+        {
+            LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationTaskLowBatterySignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal LowMemorySignalType TaskMemoryLowSignal()
+        {
+            LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationTaskLowMemorySignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal DeviceOrientationChangedSignalType TaskDeviceOrientationChangedSignal()
+        {
+            DeviceOrientationChangedSignalType ret = new DeviceOrientationChangedSignalType(NDalicPINVOKE.ApplicationTaskDeviceOrientationChangedSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
     }
 }