add:Dlass遥测
This commit is contained in:
@@ -530,6 +530,7 @@ namespace Ink_Canvas
|
|||||||
//加载设置
|
//加载设置
|
||||||
LoadSettings(true);
|
LoadSettings(true);
|
||||||
AutoBackupManager.Initialize(Settings);
|
AutoBackupManager.Initialize(Settings);
|
||||||
|
CheckUpdateChannelAndTelemetryConsistency();
|
||||||
|
|
||||||
// 初始化Dlass上传队列(恢复上次的上传队列)
|
// 初始化Dlass上传队列(恢复上次的上传队列)
|
||||||
DlassNoteUploader.InitializeQueue();
|
DlassNoteUploader.InitializeQueue();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -34,6 +35,180 @@ namespace Ink_Canvas
|
|||||||
private bool _isChangingTelemetryInternally;
|
private bool _isChangingTelemetryInternally;
|
||||||
private bool _isChangingTelemetryPrivacyInternally;
|
private bool _isChangingTelemetryPrivacyInternally;
|
||||||
|
|
||||||
|
private void CheckUpdateChannelAndTelemetryConsistency()
|
||||||
|
{
|
||||||
|
var currentChannel = Settings.Startup.UpdateChannel;
|
||||||
|
bool isTestChannel = currentChannel == UpdateChannel.Preview || currentChannel == UpdateChannel.Beta;
|
||||||
|
|
||||||
|
if (!isTestChannel)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Settings.Startup.HasAcceptedTelemetryPrivacy)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show(
|
||||||
|
$"检测到您当前处于 {currentChannel} 通道,但尚未同意隐私说明。\n\n" +
|
||||||
|
"使用预览/测试通道需要同意隐私说明并启用匿名使用数据上传。\n\n" +
|
||||||
|
"是否现在同意隐私说明并启用基础数据上传?\n" +
|
||||||
|
"(选择“否”将自动切换回正式通道)",
|
||||||
|
"更新通道与隐私协议不匹配",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Warning);
|
||||||
|
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string privacyPath = Path.Combine(App.RootPath, "privacy.txt");
|
||||||
|
if (!File.Exists(privacyPath))
|
||||||
|
{
|
||||||
|
privacyPath = Path.Combine(App.RootPath, "privacy");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(privacyPath))
|
||||||
|
{
|
||||||
|
string privacyText = File.ReadAllText(privacyPath, System.Text.Encoding.UTF8);
|
||||||
|
var confirmResult = MessageBox.Show(
|
||||||
|
privacyText + "\n\n是否同意以上隐私说明并启用匿名使用数据上传?",
|
||||||
|
"隐私说明确认",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Information,
|
||||||
|
MessageBoxResult.No);
|
||||||
|
|
||||||
|
if (confirmResult == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
Settings.Startup.HasAcceptedTelemetryPrivacy = true;
|
||||||
|
Settings.Startup.TelemetryUploadLevel = TelemetryUploadLevel.Basic;
|
||||||
|
|
||||||
|
if (isLoaded)
|
||||||
|
{
|
||||||
|
if (CheckBoxTelemetryPrivacyAccepted != null)
|
||||||
|
{
|
||||||
|
CheckBoxTelemetryPrivacyAccepted.IsChecked = true;
|
||||||
|
}
|
||||||
|
if (ComboBoxTelemetryUploadLevel != null)
|
||||||
|
{
|
||||||
|
ComboBoxTelemetryUploadLevel.SelectedIndex = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveSettingsToFile();
|
||||||
|
DeviceIdentifier.UpdateUsageChannel(currentChannel);
|
||||||
|
LogHelper.WriteLogToFile($"启动检测 | 用户同意隐私协议并启用基础遥测,保持 {currentChannel} 通道");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"未找到隐私说明文件(privacy.txt 或 privacy)。\n\n将切换回正式通道。",
|
||||||
|
"隐私文件缺失",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogHelper.WriteLogToFile($"启动检测 | 读取隐私文件失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
MessageBox.Show(
|
||||||
|
"读取隐私说明文件时出错。\n\n将切换回正式通道。",
|
||||||
|
"读取隐私文件失败",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.Startup.UpdateChannel = UpdateChannel.Release;
|
||||||
|
DeviceIdentifier.UpdateUsageChannel(UpdateChannel.Release);
|
||||||
|
SaveSettingsToFile();
|
||||||
|
|
||||||
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
_isChangingUpdateChannelInternally = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (isLoaded && UpdateChannelSelector != null)
|
||||||
|
{
|
||||||
|
foreach (var item in UpdateChannelSelector.Items)
|
||||||
|
{
|
||||||
|
if (item is RadioButton rb && rb.Tag != null &&
|
||||||
|
string.Equals(rb.Tag.ToString(), "Release", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
rb.IsChecked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isChangingUpdateChannelInternally = false;
|
||||||
|
}
|
||||||
|
}), DispatcherPriority.Normal);
|
||||||
|
|
||||||
|
LogHelper.WriteLogToFile($"启动检测 | 用户未同意隐私协议,已切换回 Release 通道");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.Startup.TelemetryUploadLevel == TelemetryUploadLevel.None)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show(
|
||||||
|
$"检测到您当前处于 {currentChannel} 通道,但匿名使用数据上传已关闭。\n\n" +
|
||||||
|
"使用预览/测试通道需要启用匿名使用数据上传。\n\n" +
|
||||||
|
"是否现在启用基础数据上传?\n" +
|
||||||
|
"(选择“否”将自动切换回正式通道)",
|
||||||
|
"更新通道与遥测状态不匹配",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Warning);
|
||||||
|
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
Settings.Startup.TelemetryUploadLevel = TelemetryUploadLevel.Basic;
|
||||||
|
|
||||||
|
if (isLoaded && ComboBoxTelemetryUploadLevel != null)
|
||||||
|
{
|
||||||
|
ComboBoxTelemetryUploadLevel.SelectedIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveSettingsToFile();
|
||||||
|
DeviceIdentifier.UpdateUsageChannel(currentChannel);
|
||||||
|
LogHelper.WriteLogToFile($"启动检测 | 用户启用基础遥测,保持 {currentChannel} 通道");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Settings.Startup.UpdateChannel = UpdateChannel.Release;
|
||||||
|
DeviceIdentifier.UpdateUsageChannel(UpdateChannel.Release);
|
||||||
|
SaveSettingsToFile();
|
||||||
|
|
||||||
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
_isChangingUpdateChannelInternally = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (isLoaded && UpdateChannelSelector != null)
|
||||||
|
{
|
||||||
|
foreach (var item in UpdateChannelSelector.Items)
|
||||||
|
{
|
||||||
|
if (item is RadioButton rb && rb.Tag != null &&
|
||||||
|
string.Equals(rb.Tag.ToString(), "Release", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
rb.IsChecked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isChangingUpdateChannelInternally = false;
|
||||||
|
}
|
||||||
|
}), DispatcherPriority.Normal);
|
||||||
|
|
||||||
|
LogHelper.WriteLogToFile($"启动检测 | 用户未启用遥测,已切换回 Release 通道");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ComboBoxTelemetryUploadLevel_SelectionChanged(object sender, RoutedEventArgs e)
|
private void ComboBoxTelemetryUploadLevel_SelectionChanged(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
@@ -4217,28 +4392,33 @@ namespace Ink_Canvas
|
|||||||
MessageBoxButton.OK,
|
MessageBoxButton.OK,
|
||||||
MessageBoxImage.Warning);
|
MessageBoxImage.Warning);
|
||||||
|
|
||||||
_isChangingUpdateChannelInternally = true;
|
Settings.Startup.UpdateChannel = oldChannel;
|
||||||
try
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
Settings.Startup.UpdateChannel = oldChannel;
|
_isChangingUpdateChannelInternally = true;
|
||||||
if (UpdateChannelSelector != null)
|
try
|
||||||
{
|
{
|
||||||
foreach (var item in UpdateChannelSelector.Items)
|
if (UpdateChannelSelector != null)
|
||||||
{
|
{
|
||||||
if (item is RadioButton rb && rb.Tag != null &&
|
string oldChannelTag = oldChannel.ToString();
|
||||||
string.Equals(rb.Tag.ToString(), oldChannel.ToString(), StringComparison.OrdinalIgnoreCase))
|
foreach (var item in UpdateChannelSelector.Items)
|
||||||
{
|
{
|
||||||
rb.IsChecked = true;
|
if (item is RadioButton rb && rb.Tag != null &&
|
||||||
break;
|
string.Equals(rb.Tag.ToString(), oldChannelTag, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
rb.IsChecked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
finally
|
||||||
finally
|
{
|
||||||
{
|
_isChangingUpdateChannelInternally = false;
|
||||||
_isChangingUpdateChannelInternally = false;
|
}
|
||||||
}
|
}), DispatcherPriority.Normal);
|
||||||
|
|
||||||
|
SaveSettingsToFile();
|
||||||
LogHelper.WriteLogToFile("Settings | User not accepted privacy, reverted update channel");
|
LogHelper.WriteLogToFile("Settings | User not accepted privacy, reverted update channel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4258,32 +4438,38 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
ComboBoxTelemetryUploadLevel.SelectedIndex = 1;
|
ComboBoxTelemetryUploadLevel.SelectedIndex = 1;
|
||||||
}
|
}
|
||||||
|
SaveSettingsToFile();
|
||||||
LogHelper.WriteLogToFile("Settings | Telemetry enabled (Basic) for preview/beta update channel");
|
LogHelper.WriteLogToFile("Settings | Telemetry enabled (Basic) for preview/beta update channel");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_isChangingUpdateChannelInternally = true;
|
Settings.Startup.UpdateChannel = oldChannel;
|
||||||
try
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
Settings.Startup.UpdateChannel = oldChannel;
|
_isChangingUpdateChannelInternally = true;
|
||||||
if (UpdateChannelSelector != null)
|
try
|
||||||
{
|
{
|
||||||
foreach (var item in UpdateChannelSelector.Items)
|
if (UpdateChannelSelector != null)
|
||||||
{
|
{
|
||||||
if (item is RadioButton rb && rb.Tag != null &&
|
string oldChannelTag = oldChannel.ToString();
|
||||||
string.Equals(rb.Tag.ToString(), oldChannel.ToString(), StringComparison.OrdinalIgnoreCase))
|
foreach (var item in UpdateChannelSelector.Items)
|
||||||
{
|
{
|
||||||
rb.IsChecked = true;
|
if (item is RadioButton rb && rb.Tag != null &&
|
||||||
break;
|
string.Equals(rb.Tag.ToString(), oldChannelTag, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
rb.IsChecked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
finally
|
||||||
finally
|
{
|
||||||
{
|
_isChangingUpdateChannelInternally = false;
|
||||||
_isChangingUpdateChannelInternally = false;
|
}
|
||||||
}
|
}), DispatcherPriority.Normal);
|
||||||
|
|
||||||
|
SaveSettingsToFile();
|
||||||
LogHelper.WriteLogToFile("Settings | User declined telemetry, reverted update channel");
|
LogHelper.WriteLogToFile("Settings | User declined telemetry, reverted update channel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user