augment FUS consent condition to honor the usage of non-commercial license (required for IJPL-149367)

GitOrigin-RevId: 33537ccf18914b7f3d4a28b6467b566c16d9b686
This commit is contained in:
Eugene Zhuravlev
2024-05-10 10:37:30 +02:00
committed by intellij-monorepo-bot
parent f4b1e85e0a
commit 91314059d0
4 changed files with 30 additions and 7 deletions

View File

@@ -257,6 +257,7 @@ e:com.intellij.formatting.FormattingMode
- s:valueOf(java.lang.String):com.intellij.formatting.FormattingMode
- s:values():com.intellij.formatting.FormattingMode[]
com.intellij.ide.ConsentOptionsProvider
- a:isActivatedWithFreeLicense():Z
- a:isEAP():Z
- a:isSendingUsageStatsAllowed():Z
- a:setSendingUsageStatsAllowed(Z):V

View File

@@ -1,10 +1,12 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide;
public interface ConsentOptionsProvider {
boolean isEAP();
boolean isActivatedWithFreeLicense();
void setSendingUsageStatsAllowed(boolean allowed);
boolean isSendingUsageStatsAllowed();

View File

@@ -1,7 +1,8 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.gdpr;
import com.intellij.ide.ConsentOptionsProvider;
import com.intellij.ui.LicensingFacade;
final class ConsentOptionsProviderImpl implements ConsentOptionsProvider {
@Override
@@ -9,6 +10,14 @@ final class ConsentOptionsProviderImpl implements ConsentOptionsProvider {
return ConsentOptions.getInstance().isEAP();
}
@Override
public boolean isActivatedWithFreeLicense() {
// Using free non-commercial license is by EULA a consent to sending feature usage statistics for product improvements
LicensingFacade facade = LicensingFacade.getInstance();
String meta = facade != null? facade.metadata : null;
return meta != null && meta.length() > 10 && meta.charAt(10) == 'F';
}
@Override
public void setSendingUsageStatsAllowed(boolean allowed) {
ConsentOptions.getInstance().setSendingUsageStatsAllowed(allowed);

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.internal.statistic.utils;
import com.intellij.ide.ConsentOptionsProvider;
import com.intellij.internal.statistic.eventLog.*;
import com.intellij.internal.statistic.eventLog.connection.EventLogSendListener;
import com.intellij.internal.statistic.eventLog.connection.EventLogStatisticsService;
@@ -34,8 +35,7 @@ public final class StatisticsUploadAssistant {
return isHeadlessStatisticsEnabled();
}
UsageStatisticsPersistenceComponent settings = UsageStatisticsPersistenceComponent.getInstance();
return settings != null && settings.isAllowed();
return isAllowedByUserConsent();
}
public static boolean isCollectAllowed() {
@@ -44,14 +44,25 @@ public final class StatisticsUploadAssistant {
}
if (!isDisableCollectStatistics() && !isCollectionForceDisabled()) {
UsageStatisticsPersistenceComponent settings = UsageStatisticsPersistenceComponent.getInstance();
if ((settings != null && settings.isAllowed()) || isLocalStatisticsWithoutReport()) {
if (isAllowedByUserConsent() || isLocalStatisticsWithoutReport()) {
return true;
}
}
return false;
}
public static boolean isAllowedByUserConsent() {
UsageStatisticsPersistenceComponent settings = UsageStatisticsPersistenceComponent.getInstance();
if (settings != null && settings.isAllowed()) {
return true;
}
ConsentOptionsProvider consentsProvider = ApplicationManager.getApplication().getService(ConsentOptionsProvider.class);
if (consentsProvider != null && consentsProvider.isActivatedWithFreeLicense()) {
return true;
}
return false;
}
private static boolean isForceCollectEnabled() {
return StatisticsEventLogProviderUtil.forceLoggingAlwaysEnabled();
}