commit 5c5826e44c58b44e385ad1794ebc4f4983cb401f
parent 2de86a48b8c41bdb2474e6cbd3c413fadb715655
Author: JohnMcPMS <johnmcp@microsoft.com>
Date: Fri, 5 Nov 2021 13:31:43 -0700
Add product code and PFN to enable existing searches (#1677)
Diffstat:
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/Microsoft.Management.Deployment/Converters.cpp b/src/Microsoft.Management.Deployment/Converters.cpp
@@ -29,6 +29,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation
case ::AppInstaller::Repository::PackageMatchField::Tag:
matchField = Microsoft::Management::Deployment::PackageMatchField::Tag;
break;
+ case ::AppInstaller::Repository::PackageMatchField::ProductCode:
+ matchField = Microsoft::Management::Deployment::PackageMatchField::ProductCode;
+ break;
+ case ::AppInstaller::Repository::PackageMatchField::PackageFamilyName:
+ matchField = Microsoft::Management::Deployment::PackageMatchField::PackageFamilyName;
+ break;
default:
matchField = Microsoft::Management::Deployment::PackageMatchField::Id;
break;
@@ -56,6 +62,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation
case Microsoft::Management::Deployment::PackageMatchField::Tag:
matchField = ::AppInstaller::Repository::PackageMatchField::Tag;
break;
+ case Microsoft::Management::Deployment::PackageMatchField::ProductCode:
+ matchField = ::AppInstaller::Repository::PackageMatchField::ProductCode;
+ break;
+ case Microsoft::Management::Deployment::PackageMatchField::PackageFamilyName:
+ matchField = ::AppInstaller::Repository::PackageMatchField::PackageFamilyName;
+ break;
default:
matchField = ::AppInstaller::Repository::PackageMatchField::Id;
break;
diff --git a/src/Microsoft.Management.Deployment/Helpers.cpp b/src/Microsoft.Management.Deployment/Helpers.cpp
@@ -50,9 +50,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation
auto capability = winrt::Windows::Security::Authorization::AppCapabilityAccess::AppCapability::CreateWithProcessIdForUser(nullptr, GetStringForCapability(requiredCapability), callerProcessId);
status = capability.CheckAccess();
- RETURN_HR_IF(E_ACCESSDENIED, status != winrt::Windows::Security::Authorization::AppCapabilityAccess::AppCapabilityAccessStatus::Allowed);
- return S_OK;
+ return (status != winrt::Windows::Security::Authorization::AppCapabilityAccess::AppCapabilityAccessStatus::Allowed ? E_ACCESSDENIED : S_OK);
}
HRESULT EnsureComCallerHasCapability(Capability requiredCapability)
@@ -64,9 +63,9 @@ namespace winrt::Microsoft::Management::Deployment::implementation
// and packageQuery does not need to be declared separately.
if (FAILED(hr) && requiredCapability == Capability::PackageQuery)
{
- return EnsureProcessHasCapability(Capability::PackageManagement, callerProcessId);
+ hr = EnsureProcessHasCapability(Capability::PackageManagement, callerProcessId);
}
- return hr;
+ RETURN_HR(hr);
}
// Best effort at getting caller info. This should only be used for logging.
diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
namespace Microsoft.Management.Deployment
{
- [contractversion(2)]
+ [contractversion(3)]
apicontract WindowsPackageManagerContract{};
/// State of the install.
@@ -283,9 +283,12 @@ namespace Microsoft.Management.Deployment
Moniker,
Command,
Tag,
+ [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 3)]
+ {
+ PackageFamilyName,
+ ProductCode,
+ }
/// DESIGN NOTE: The following PackageFieldMatchOption from winget/RepositorySearch.h are not implemented in V1.
- /// PackageFamilyName,
- /// ProductCode,
/// NormalizedNameAndPublisher,
};