-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix signaling the app shutdown event running as admin (#3874)
There's bug in the OS where the WM_QUERYENDSESSION message is not send when a package is being updated if the package is running elevated. This makes `winget configure --enable` to stop at 95% and eventually get terminated by the system for an update. The update is successful, but the experience is not the best. It also makes it harder to use `IConfigurationStatics::IConfigurationStatics` in an elevated context. The fix is to use the `PackageCatalog` APIs and register for `PackageUpdating` events when winget is running elevated and in a package context and signal the competition event if the progress is more than 0. Otherwise create the window and listen to messages. Enable test where a new update is being registered since now it will work and move test to force the WM_QUERYENDSESSION to UTs
- Loading branch information
1 parent
09c8771
commit e6b1d02
Showing
7 changed files
with
149 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include <winget/Runtime.h> | ||
#include "Commands/TestCommand.h" | ||
|
||
using namespace AppInstaller::CLI; | ||
|
||
TEST_CASE("AppShutdown_WindowMessage", "[appShutdown]") | ||
{ | ||
if (AppInstaller::Runtime::IsRunningAsAdmin() && AppInstaller::Runtime::IsRunningInPackagedContext()) | ||
{ | ||
WARN("Test can't run as admin in package context"); | ||
return; | ||
} | ||
|
||
std::ostringstream output; | ||
Execution::Context context{ output, std::cin }; | ||
context.Args.AddArg(Execution::Args::Type::Force); | ||
|
||
TestAppShutdownCommand appShutdownCmd({}); | ||
appShutdownCmd.Execute(context); | ||
|
||
REQUIRE(context.IsTerminated()); | ||
REQUIRE(S_OK == context.GetTerminationHR()); | ||
} |