From e2c7bb900cf83fe0a3834ad2189577687ffaa03f Mon Sep 17 00:00:00 2001 From: CodeforEvolution Date: Fri, 1 Mar 2019 13:58:24 +0000 Subject: [PATCH] Add Reboot Check to BPackageRoster A bit of an explanation for these weirdly named functions: LatestActivePackageInfos() returns the packages on the system that are both installed and fully set up. When packages are in the middle of being installed, LatestInactivePackageInfos() shows the packages in the process of being installed. Once the installation process is done, LatestInactivePackageInfos() returns nothing. If there are packages that can't be fully activated without a reboot, CurrentlyActivePackageInfos() will return the same information as LatestActivePackageInfos(), or if everything has been installed and activated, it will return no packages. Change-Id: Ia1814a5abda6d815c46e0b46dc812b4e7af81de3 Reviewed-on: https://review.haiku-os.org/c/1129 Reviewed-by: Adrien Destugues --- headers/os/package/PackageRoster.h | 2 ++ src/kits/package/PackageRoster.cpp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/headers/os/package/PackageRoster.h b/headers/os/package/PackageRoster.h index a9134f52b2..61d6e9f5ef 100644 --- a/headers/os/package/PackageRoster.h +++ b/headers/os/package/PackageRoster.h @@ -56,6 +56,8 @@ public: BPackageRoster(); ~BPackageRoster(); + bool IsRebootNeeded(); + status_t GetCommonRepositoryCachePath(BPath* path, bool create = false) const; status_t GetUserRepositoryCachePath(BPath* path, diff --git a/src/kits/package/PackageRoster.cpp b/src/kits/package/PackageRoster.cpp index f5c8a42d80..bae024c657 100644 --- a/src/kits/package/PackageRoster.cpp +++ b/src/kits/package/PackageRoster.cpp @@ -52,6 +52,27 @@ BPackageRoster::~BPackageRoster() } +bool +BPackageRoster::IsRebootNeeded() +{ + BInstallationLocationInfo info; + + // We get information on the system package installation location. + // If we fail, we just have to assume a reboot is not needed. + if (GetInstallationLocationInfo(B_PACKAGE_INSTALLATION_LOCATION_SYSTEM, + info) != B_OK) + return false; + + // CurrentlyActivePackageInfos() will return 0 if no packages need to be + // activated with a reboot. Otherwise, the method will return the total + // number of packages in the system package directory. + if (info.CurrentlyActivePackageInfos().CountInfos() != 0) + return true; + + return false; +} + + status_t BPackageRoster::GetCommonRepositoryConfigPath(BPath* path, bool create) const {