Skip to content

Commit 770a89b

Browse files
committed
hide notifications pages in settings when using Notification Off (Full)
1 parent a89116c commit 770a89b

4 files changed

Lines changed: 41 additions & 33 deletions

File tree

common/lib/src/services/updates_service.dart

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,7 @@ class UpdatesService implements SetupService {
128128
}
129129

130130
void disableVisibilityWU() {
131-
final currentValue = WinRegistryService.readString(
132-
RegistryHive.localMachine,
133-
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
134-
'SettingsPageVisibility');
135-
136-
if (currentValue == null || currentValue.isEmpty) {
137-
WinRegistryService.writeString(
138-
Registry.localMachine,
139-
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
140-
'SettingsPageVisibility',
141-
"hide:windowsupdate");
142-
return;
143-
}
144-
if (!currentValue.contains("windowsupdate")) {
145-
WinRegistryService.writeString(
146-
Registry.localMachine,
147-
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
148-
'SettingsPageVisibility',
149-
currentValue.endsWith(";") || currentValue.endsWith(":")
150-
? "${currentValue}windowsupdate;"
151-
: "$currentValue;windowsupdate;");
152-
return;
153-
}
131+
WinRegistryService.hidePageVisibilitySettings("windowsupdate");
154132
}
155133

156134
bool get statusDriversWU {

common/lib/src/services/usability_service.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,6 @@ class UsabilityService implements SetupService {
182182
'Value',
183183
'Deny');
184184

185-
final wpnServices = WinRegistryService.getUserServices('Wpn');
186-
187-
for (final service in wpnServices) {
188-
WinRegistryService.writeDword(Registry.localMachine,
189-
r'SYSTEM\ControlSet001\Services\' + service, 'Start', 4);
190-
}
191-
192185
await Process.run('taskkill.exe', ['/im', 'explorer.exe', '/f']);
193186
await Process.run('explorer.exe', [], runInShell: true);
194187
}
@@ -205,6 +198,16 @@ class UsabilityService implements SetupService {
205198
r'SOFTWARE\Policies\Microsoft\Windows\Explorer',
206199
'DisableNotificationCenter',
207200
1);
201+
202+
final wpnServices = WinRegistryService.getUserServices('Wpn');
203+
204+
for (final service in wpnServices) {
205+
WinRegistryService.writeDword(Registry.localMachine,
206+
r'SYSTEM\ControlSet001\Services\' + service, 'Start', 4);
207+
}
208+
for (final page in ["notifications", "privacy-notifications"]) {
209+
WinRegistryService.hidePageVisibilitySettings(page);
210+
}
208211
}
209212

210213
bool get statusLegacyBalloon {

common/lib/src/services/win_registry_service.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ class WinRegistryService {
5050
}
5151
}
5252

53+
static void hidePageVisibilitySettings(String pageName) {
54+
final currentValue = readString(
55+
RegistryHive.localMachine,
56+
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
57+
'SettingsPageVisibility');
58+
59+
if (currentValue == null || currentValue.isEmpty) {
60+
writeString(
61+
Registry.localMachine,
62+
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
63+
'SettingsPageVisibility',
64+
"hide:$pageName");
65+
return;
66+
}
67+
if (!currentValue.contains(pageName)) {
68+
writeString(
69+
Registry.localMachine,
70+
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
71+
'SettingsPageVisibility',
72+
currentValue.endsWith(";") || currentValue.endsWith(":")
73+
? "$currentValue$pageName;"
74+
: "$currentValue;$pageName;");
75+
return;
76+
}
77+
}
78+
5379
static Iterable<String> getUserServices(String subkey) {
5480
return Registry.openPath(RegistryHive.localMachine,
5581
path: r'SYSTEM\ControlSet001\Services')

common/lib/src/utils.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ final tempReviPath = p.join(Directory.systemTemp.path, 'Revision-Tool', 'Logs');
1414
final logger = Logger(
1515
filter: ProductionFilter(),
1616
printer: PrettyPrinter(
17-
methodCount: 0,
18-
colors: false,
19-
dateTimeFormat: DateTimeFormat.dateAndTime),
17+
methodCount: 0,
18+
colors: false,
19+
dateTimeFormat: DateTimeFormat.dateAndTime,
20+
),
2021
output: AdvancedFileOutput(
2122
overrideExisting: true,
2223
path: tempReviPath,

0 commit comments

Comments
 (0)