Skip to content

Commit

Permalink
Try Not using BreakAwayProcess for FindPackageForUser by PackageFamil…
Browse files Browse the repository at this point in the history
…y in GetStatus
  • Loading branch information
Santosh Chintalapati committed Sep 28, 2022
1 parent 38cacca commit 28e3b21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions dev/Deployment/Deployment.idl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
/// Checks the status of the WindowsAppRuntime of the current package and attempts to
/// repair already installed WinAppSDK packages.
[contract(DeploymentContract, 3)]
[overload("Repair")]
static DeploymentResult Repair();

/// Checks the status of the WindowsAppRuntime of the current package and attempts to
Expand Down
25 changes: 17 additions & 8 deletions dev/Deployment/DeploymentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::DeploymentResult DeploymentManager::Repair(
winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::DeploymentRepairOptions const& deploymentRepairOptions)
{
return Initialize(GetCurrentFrameworkPackageFullName(), options, true);
return Initialize(GetCurrentFrameworkPackageFullName(), deploymentRepairOptions, true);
}

winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::DeploymentResult DeploymentManager::GetStatus(hstring const& packageFullName)
Expand Down Expand Up @@ -333,29 +333,38 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
HRESULT DeploymentManager::VerifyPackage(const std::wstring& packageFamilyName, const PACKAGE_VERSION targetVersion,
__out std::wstring& packageIdentifier) try
{
auto packageFullNames{ FindPackagesByFamily(packageFamilyName) };
winrt::Windows::Management::Deployment::PackageManager packageManager;
auto packages{ packageManager.FindPackagesForUser(L"", packageFamilyName) };

bool match{};
for (const auto& packageFullName : packageFullNames)
bool matchedPackageStatusIsOK{};
for (const auto& package : packages)
{
auto packagePath{ GetPackagePath(packageFullName) };
auto packagePath{ package.InstalledPath()};
if (packagePath.empty())
{
continue;
}

auto packageId{ AppModel::Identity::PackageIdentity::FromPackageFullName(packageFullName.c_str()) };
if (packageId.Version().Version >= targetVersion.Version)
UINT64 packageVersion = (static_cast<UINT64>(package.Id().Version().Major) << 48) +
(static_cast<UINT64>(package.Id().Version().Minor) << 32) +
(static_cast<UINT64>(package.Id().Version().Build) << 16) +
(static_cast<UINT64>(package.Id().Version().Revision));

if (packageVersion >= targetVersion.Version)
{
match = true;
if (packageId.Version().Version > targetVersion.Version)
matchedPackageStatusIsOK = package.Status().VerifyIsOK();
if (packageVersion > targetVersion.Version)
{
g_existingTargetPackagesIfHigherVersion.insert(std::make_pair(packageIdentifier, packageFullName));
g_existingTargetPackagesIfHigherVersion.insert(std::make_pair(packageIdentifier, package.Id().FullName()));
}
break;
}
}

RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), !match);
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), !matchedPackageStatusIsOK);
return S_OK;
}
CATCH_RETURN()
Expand Down

0 comments on commit 28e3b21

Please sign in to comment.