Skip to content

Commit

Permalink
Suppress Windows Defender Autofix startup check in test-runtimes
Browse files Browse the repository at this point in the history
Only run the startup check if the running application is
'org.eclipse.ui.ide.workbench', which runs in a usual Eclipse IDE.
Requiring this specific app-id prevents the start-up check and
consequently a pop-up in test applications launched by PDE or Tycho for
OSGi Junit tests or general console applications (that still have the
'o.e.ui.workbench' plugin installed) on Windows.

Fixes #1683
  • Loading branch information
HannesWell committed Feb 14, 2024
1 parent e23ac65 commit 42a4d8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
Expand Down Expand Up @@ -83,7 +84,7 @@ public class WindowsDefenderConfigurator implements EventHandler {

@Override
public void handleEvent(Event event) {
if (isRelevant()) {
if (runStartupCheck()) {
Job job = Job.create(WorkbenchMessages.WindowsDefenderConfigurator_statusCheck, m -> {
SubMonitor monitor = SubMonitor.convert(m, 10);
if (preferences.getBoolean(PI_WORKBENCH, PREFERENCE_SKIP, PREFERENCE_SKIP_DEFAULT, null)) {
Expand All @@ -105,8 +106,14 @@ public void handleEvent(Event event) {
}
}

public static boolean isRelevant() {
return Platform.OS_WIN32.equals(Platform.getOS()) && !Platform.inDevelopmentMode();
private static boolean runStartupCheck() {
if (Platform.isRunning() && Platform.OS.isWindows() && !Platform.inDevelopmentMode()) {
IProduct product = Platform.getProduct();
if (product != null) {
return "org.eclipse.ui.ide.workbench".equals(product.getApplication()); //$NON-NLS-1$
}
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected Control createContents(Composite parent) {
}

protected void createExtraContent(Composite composite) {
if (WindowsDefenderConfigurator.isRelevant()) {
if (Platform.OS.isWindows()) {
new Label(composite, SWT.NONE); // add spacer

GridDataFactory grapHorizontalSpace = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING)
Expand Down

0 comments on commit 42a4d8b

Please sign in to comment.