Fixed Device Storage Taking too much time to show. 83/318483/5
authorMd. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics <farhan.m1@samsung.com>
Mon, 30 Sep 2024 10:37:51 +0000 (16:37 +0600)
committerMd. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics <farhan.m1@samsung.com>
Mon, 30 Sep 2024 11:35:28 +0000 (17:35 +0600)
[Problem]: [TNINE-4665] Device Storage Taking too much time

[Cause & Measure]
 Cause  : Tizen.Application.PackageManager.GetTotalSizeInformationAsync function completes brefore any view being created
 Measure : Updated view after creation if Tizen.Application.PackageManager.GetTotalSizeInformationAsync completes before it.

Change-Id: Id39ec7685558e39916effa22abe7e3fc4984e946
Signed-off-by: Md. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics <farhan.m1@samsung.com>
SettingMainGadget/SettingMainGadget/StorageGadget.cs

index 0931ec38d5a67ab215a1657feb2745fab60feb7f..5779c8c73fc6e986b0b0fed1e3ce020065835425 100644 (file)
@@ -49,6 +49,8 @@ namespace Setting.Menu
         private double sizeAudio;
         private double sizeMisc;
         private IDictionary<string, Action> sectionViews;
+        private Task initialSizeCalculation;
+        private PackageSizeInformation sizeInfo;
 
         protected override View OnCreate()
         {
@@ -79,11 +81,11 @@ namespace Setting.Menu
                 },
             };
 
-            var calculating = StartCalculatingAppCacheSize();
+            initialSizeCalculation = StartCalculatingAppCacheSize();
 
             content.Relayout += (s, e) =>
             {
-                if (calculating.IsCompleted)
+                if (initialSizeCalculation.IsCompleted)
                 {
                     storageIndicator.Update();
                 }
@@ -204,21 +206,21 @@ namespace Setting.Menu
             var imageItem = new TextWithIconListItem(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_IMAGES)), new Color("#FF8A00"), subText: GetMediaSizeString(sizeImage));
             imageItem.Clicked += (s, e) =>
             {
-                // TODO : add media files info gadget 
+                // TODO : add media files info gadget
             };
             usageSummary.Add(imageItem);
 
             var videoItem = new TextWithIconListItem(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_VIDEOS)), new Color("#FF6200"), subText: GetMediaSizeString(sizeVideo));
             videoItem.Clicked += (s, e) =>
             {
-                // TODO : add media files info gadget 
+                // TODO : add media files info gadget
             };
             usageSummary.Add(videoItem);
 
             var audioItem = new TextWithIconListItem(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_AUDIO)), new Color("#A40404"), subText: GetMediaSizeString(sizeAudio));
             audioItem.Clicked += (s, e) =>
             {
-                // TODO : add media files info gadget 
+                // TODO : add media files info gadget
             };
             usageSummary.Add(audioItem);
 
@@ -227,7 +229,7 @@ namespace Setting.Menu
             var miscItem = new TextWithIconListItem(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_MISCELLANEOUS_FILES)), new Color("#28262B"), subText: GetMediaSizeString(sizeMisc));
             miscItem.Clicked += (s, e) =>
             {
-                // TODO : add miscellaneous info gadget 
+                // TODO : add miscellaneous info gadget
             };
             usageSummary.Add(miscItem);
 
@@ -242,6 +244,11 @@ namespace Setting.Menu
             usageSummary.Add(systemItem);
 
             content.Add(usageSummary);
+
+            if (initialSizeCalculation.IsCompleted)
+            {
+                UpdateSizeInfo();
+            }
         }
 
         private void ExternalUsageView()
@@ -369,10 +376,15 @@ namespace Setting.Menu
 
         private async Task StartCalculatingAppCacheSize()
         {
-            var sizeInfo = await PackageManager.GetTotalSizeInformationAsync();
+            sizeInfo = await PackageManager.GetTotalSizeInformationAsync();
+            UpdateSizeInfo();
+        }
 
+        private void UpdateSizeInfo()
+        {
             long sizeApp = sizeInfo.AppSize;
             long sizeCache = sizeInfo.CacheSize;
+            bool indicatorValueChanged = false;
 
             if (appsItem != null)
             {
@@ -382,6 +394,7 @@ namespace Setting.Menu
                 if (apps != null)
                 {
                     apps.SizeInfo = sizeApp;
+                    indicatorValueChanged = true;
                 }
             }
             if (cacheItem != null)
@@ -392,6 +405,7 @@ namespace Setting.Menu
                 if (cache != null)
                 {
                     cache.SizeInfo = sizeCache;
+                    indicatorValueChanged = true;
                 }
             }
             if (systemItem != null)
@@ -402,10 +416,14 @@ namespace Setting.Menu
                 if (system != null)
                 {
                     system.SizeInfo = (float)(nonSystemSpace - sizeApp - sizeCache);
+                    indicatorValueChanged = true;
                 }
             }
 
-            storageIndicator.Update();
+            if (indicatorValueChanged)
+            {
+                storageIndicator.Update();
+            }
         }
 
         private void GetMediaInfo(out double sizeImage, out double sizeVideo, out double sizeAudio)
@@ -511,7 +529,7 @@ namespace Setting.Menu
                 Layout = new FlexLayout()
                 {
                     Justification = FlexLayout.FlexJustification.Center,
-                    Direction = FlexLayout.FlexDirection.Column, 
+                    Direction = FlexLayout.FlexDirection.Column,
                     Alignment = FlexLayout.AlignmentType.Center,
                 },
             };
@@ -558,7 +576,7 @@ namespace Setting.Menu
                 Size = new Size(252, 48).SpToPx(),
                 Margin = new Extents(61, 32, 0, 32).SpToPx(),
             };
-            clearButton.Clicked += (s, e) => 
+            clearButton.Clicked += (s, e) =>
             {
                 PackageManager.ClearAllCacheDirectory();
                 // TODO : update cache info
@@ -575,9 +593,9 @@ namespace Setting.Menu
                 Margin = new Extents(32, 61, 0, 32).SpToPx(),
             };
 
-            cancelButton.Clicked += (s, e) => 
-            { 
-                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop(); 
+            cancelButton.Clicked += (s, e) =>
+            {
+                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
             };
 
             buttons.Add(cancelButton);