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<PackageManagerEventArgs> s_installEventHandler;
private static event EventHandler<PackageManagerEventArgs> s_uninstallEventHandler;
private static event EventHandler<PackageManagerEventArgs> s_updateEventHandler;
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)
}
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;
}
}
{
throw PackageManagerErrorFactory.GetException(err, "Failed to unregister package manager event event.");
}
+ s_registered_eventStatus = Interop.PackageManager.EventStatus.All;
}
}
}