From e4733207b38c6201ecd332417645e6cfa5bad8e3 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 28 Nov 2022 18:43:56 +0800 Subject: [PATCH] Use AppListEntry to construct app --- .../Programs/UWP.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 1c8665ed4..627d6d138 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -411,6 +411,16 @@ namespace Flow.Launcher.Plugin.Program.Programs public Application() { } + public Application(AppListEntry appListEntry) + { + UserModelId = appListEntry.AppUserModelId; + UniqueIdentifier = appListEntry.AppUserModelId; + DisplayName = appListEntry.DisplayInfo.DisplayName; + Description = appListEntry.DisplayInfo.Description; + //Package = package; + Enabled = true; + } + public Result Result(string query, IPublicAPI api) { string title; @@ -604,6 +614,18 @@ namespace Flow.Launcher.Plugin.Program.Programs return false; } + internal static bool IfAppCanRunElevated(XmlNode appNode, XmlNamespaceManager namespaceManager) + { + // According to https://learn.microsoft.com/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps#create-a-package-manifest-for-the-sparse-package + // and https://learn.microsoft.com/uwp/schemas/appxpackage/uapmanifestschema/element-application#attributes + + var entryPointNode = appNode.SelectSingleNode($"//*[local-name()='Application' and @EntryPoint]", namespaceManager); + var trustLevelNode = appNode.SelectSingleNode($"//*[local-name()='Application' and @uap10:TrustLevel]", namespaceManager); + + return entryPointNode?.Attributes["EntryPoint"]?.Value == "Windows.FullTrustApplication" || + trustLevelNode?.Attributes["uap10:TrustLevel"]?.Value == "mediumIL"; + } + internal string ResourceFromPri(string packageFullName, string packageName, string rawReferenceValue) { if (string.IsNullOrWhiteSpace(rawReferenceValue) || !rawReferenceValue.StartsWith("ms-resource:"))