@@ -18,19 +18,21 @@ class AutoUpdateManager {
18
18
19
19
// Check if auto update is enabled
20
20
Future <bool > isAutoUpdateEnabled () async {
21
- if (! kEnableSelfUpdate) return false ;
21
+ if (! kEnableSelfUpdate) return false ; // Hard off for FDroid builds
22
22
final prefs = await SharedPreferences .getInstance ();
23
23
return prefs.getBool (_autoUpdateKey) ?? true ;
24
24
}
25
25
26
26
// Set auto update preference
27
27
Future <void > setAutoUpdateEnabled (bool enabled) async {
28
+ if (! kEnableSelfUpdate) return ; // no-op in FDroid
28
29
final prefs = await SharedPreferences .getInstance ();
29
30
await prefs.setBool (_autoUpdateKey, enabled);
30
31
}
31
32
32
33
// Get last update check timestamp
33
34
Future <DateTime ?> getLastUpdateCheck () async {
35
+ if (! kEnableSelfUpdate) return null ; // no tracking when disabled
34
36
final prefs = await SharedPreferences .getInstance ();
35
37
final timestamp = prefs.getInt (_lastUpdateCheckKey);
36
38
return timestamp != null
@@ -40,24 +42,28 @@ class AutoUpdateManager {
40
42
41
43
// Set last update check timestamp
42
44
Future <void > setLastUpdateCheck (DateTime dateTime) async {
45
+ if (! kEnableSelfUpdate) return ; // no-op
43
46
final prefs = await SharedPreferences .getInstance ();
44
47
await prefs.setInt (_lastUpdateCheckKey, dateTime.millisecondsSinceEpoch);
45
48
}
46
49
47
50
// Get skipped version
48
51
Future <String ?> getSkippedVersion () async {
52
+ if (! kEnableSelfUpdate) return null ;
49
53
final prefs = await SharedPreferences .getInstance ();
50
54
return prefs.getString (_skippedVersionKey);
51
55
}
52
56
53
57
// Set skipped version
54
58
Future <void > setSkippedVersion (String version) async {
59
+ if (! kEnableSelfUpdate) return ; // no-op
55
60
final prefs = await SharedPreferences .getInstance ();
56
61
await prefs.setString (_skippedVersionKey, version);
57
62
}
58
63
59
64
// Check if should check for updates (based on time interval)
60
65
Future <bool > shouldCheckForUpdates () async {
66
+ if (! kEnableSelfUpdate) return false ;
61
67
if (! await isAutoUpdateEnabled ()) return false ;
62
68
63
69
final lastCheck = await getLastUpdateCheck ();
@@ -75,7 +81,9 @@ class AutoUpdateManager {
75
81
String repo = 'Shojin_App' ,
76
82
}) async {
77
83
if (! kEnableSelfUpdate) {
78
- debugPrint ('[FDROID] Self-update disabled by build flag' );
84
+ debugPrint (
85
+ '[FDROID] Self-update disabled by build flag (startup check skipped)' ,
86
+ );
79
87
return ;
80
88
}
81
89
if (! await shouldCheckForUpdates ()) {
@@ -127,6 +135,7 @@ class AutoUpdateManager {
127
135
BuildContext context,
128
136
EnhancedAppUpdateInfo updateInfo,
129
137
) {
138
+ if (! kEnableSelfUpdate) return ; // safety
130
139
if (! context.mounted) return ;
131
140
132
141
// Show as a SnackBar first, then dialog on tap
@@ -154,6 +163,7 @@ class AutoUpdateManager {
154
163
BuildContext context,
155
164
EnhancedAppUpdateInfo updateInfo,
156
165
) {
166
+ if (! kEnableSelfUpdate) return ; // safety
157
167
if (! context.mounted) return ;
158
168
159
169
showDialog (
@@ -177,6 +187,7 @@ class AutoUpdateManager {
177
187
BuildContext context,
178
188
EnhancedAppUpdateInfo updateInfo,
179
189
) {
190
+ if (! kEnableSelfUpdate) return ; // safety
180
191
if (! context.mounted) return ;
181
192
182
193
showDialog (
@@ -214,6 +225,10 @@ class AutoUpdateManager {
214
225
String owner = 'yuubinnkyoku' ,
215
226
String repo = 'Shojin_App' ,
216
227
}) async {
228
+ if (! kEnableSelfUpdate) {
229
+ debugPrint ('[FDROID] Manual update check suppressed' );
230
+ return null ;
231
+ }
217
232
try {
218
233
debugPrint ('=== 手動アップデートチェック開始 ===' );
219
234
debugPrint ('Repository: $owner /$repo ' );
@@ -249,6 +264,7 @@ class AutoUpdateManager {
249
264
BuildContext context,
250
265
EnhancedAppUpdateInfo updateInfo,
251
266
) {
267
+ if (! kEnableSelfUpdate) return ; // safety
252
268
_showUpdateDialog (context, updateInfo);
253
269
}
254
270
}
0 commit comments