From: ilho159kim Date: Wed, 31 Jan 2024 09:46:08 +0000 (+0900) Subject: [Packagemanager] Fix SetPackageManagerEventStatus (#5930) X-Git-Tag: accepted/tizen/8.0/unified/20240613.065534~65 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45867b91c5e5b72d4dacb894723e0ddc66e0f41c;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Packagemanager] Fix SetPackageManagerEventStatus (#5930) Since native API internally unregister event and register event so fix it to actually set event only when necessary Signed-off-by: Ilho Kim --- diff --git a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs index 3ad18b8..9daf048 100755 --- a/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs +++ b/src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs @@ -37,6 +37,7 @@ namespace Tizen.Applications private static SafePackageManagerHandle s_handle = new SafePackageManagerHandle(); private static Interop.PackageManager.EventStatus s_eventStatus = Interop.PackageManager.EventStatus.All; + private static Interop.PackageManager.EventStatus s_registered_eventStatus = Interop.PackageManager.EventStatus.All; private static event EventHandler s_installEventHandler; private static event EventHandler s_uninstallEventHandler; private static event EventHandler s_updateEventHandler; @@ -1391,6 +1392,9 @@ namespace Tizen.Applications if (s_installEventHandler != null && s_uninstallEventHandler != null && s_updateEventHandler != null && s_moveEventHandler != null && s_clearDataEventHandler != null) return; + if ((s_registered_eventStatus & s_eventStatus) == s_eventStatus) + return; + var err = Interop.PackageManager.ErrorCode.None; if (!Handle.IsInvalid) @@ -1402,7 +1406,10 @@ namespace Tizen.Applications } if (err != Interop.PackageManager.ErrorCode.None) { + s_registered_eventStatus = Interop.PackageManager.EventStatus.All; Log.Warn(LogTag, string.Format("Failed to register callback for package manager event. err = {0}", err)); + } else { + s_registered_eventStatus = s_eventStatus; } } @@ -1461,6 +1468,7 @@ namespace Tizen.Applications { throw PackageManagerErrorFactory.GetException(err, "Failed to unregister package manager event event."); } + s_registered_eventStatus = Interop.PackageManager.EventStatus.All; } } }