Skip to content

Commit

Permalink
hide notifications pages in settings when using Notification Off (Full)
Browse files Browse the repository at this point in the history
  • Loading branch information
melo936 committed Dec 3, 2024
1 parent a89116c commit 770a89b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 33 deletions.
24 changes: 1 addition & 23 deletions common/lib/src/services/updates_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,7 @@ class UpdatesService implements SetupService {
}

void disableVisibilityWU() {
final currentValue = WinRegistryService.readString(
RegistryHive.localMachine,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'SettingsPageVisibility');

if (currentValue == null || currentValue.isEmpty) {
WinRegistryService.writeString(
Registry.localMachine,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'SettingsPageVisibility',
"hide:windowsupdate");
return;
}
if (!currentValue.contains("windowsupdate")) {
WinRegistryService.writeString(
Registry.localMachine,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'SettingsPageVisibility',
currentValue.endsWith(";") || currentValue.endsWith(":")
? "${currentValue}windowsupdate;"
: "$currentValue;windowsupdate;");
return;
}
WinRegistryService.hidePageVisibilitySettings("windowsupdate");
}

bool get statusDriversWU {
Expand Down
17 changes: 10 additions & 7 deletions common/lib/src/services/usability_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,6 @@ class UsabilityService implements SetupService {
'Value',
'Deny');

final wpnServices = WinRegistryService.getUserServices('Wpn');

for (final service in wpnServices) {
WinRegistryService.writeDword(Registry.localMachine,
r'SYSTEM\ControlSet001\Services\' + service, 'Start', 4);
}

await Process.run('taskkill.exe', ['/im', 'explorer.exe', '/f']);
await Process.run('explorer.exe', [], runInShell: true);
}
Expand All @@ -205,6 +198,16 @@ class UsabilityService implements SetupService {
r'SOFTWARE\Policies\Microsoft\Windows\Explorer',
'DisableNotificationCenter',
1);

final wpnServices = WinRegistryService.getUserServices('Wpn');

for (final service in wpnServices) {
WinRegistryService.writeDword(Registry.localMachine,
r'SYSTEM\ControlSet001\Services\' + service, 'Start', 4);
}
for (final page in ["notifications", "privacy-notifications"]) {
WinRegistryService.hidePageVisibilitySettings(page);
}
}

bool get statusLegacyBalloon {
Expand Down
26 changes: 26 additions & 0 deletions common/lib/src/services/win_registry_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ class WinRegistryService {
}
}

static void hidePageVisibilitySettings(String pageName) {
final currentValue = readString(
RegistryHive.localMachine,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'SettingsPageVisibility');

if (currentValue == null || currentValue.isEmpty) {
writeString(
Registry.localMachine,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'SettingsPageVisibility',
"hide:$pageName");
return;
}
if (!currentValue.contains(pageName)) {
writeString(
Registry.localMachine,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'SettingsPageVisibility',
currentValue.endsWith(";") || currentValue.endsWith(":")
? "$currentValue$pageName;"
: "$currentValue;$pageName;");
return;
}
}

static Iterable<String> getUserServices(String subkey) {
return Registry.openPath(RegistryHive.localMachine,
path: r'SYSTEM\ControlSet001\Services')
Expand Down
7 changes: 4 additions & 3 deletions common/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ final tempReviPath = p.join(Directory.systemTemp.path, 'Revision-Tool', 'Logs');
final logger = Logger(
filter: ProductionFilter(),
printer: PrettyPrinter(
methodCount: 0,
colors: false,
dateTimeFormat: DateTimeFormat.dateAndTime),
methodCount: 0,
colors: false,
dateTimeFormat: DateTimeFormat.dateAndTime,
),
output: AdvancedFileOutput(
overrideExisting: true,
path: tempReviPath,
Expand Down

0 comments on commit 770a89b

Please sign in to comment.