Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check for updates in demo mode #163

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Backends/SystemUpdate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
}

public async void check_for_updates (bool force, bool notify) throws DBusError, IOError {
if (SettingsDaemon.Utils.is_running_in_demo_mode () && !force) {
return;
}

if (current_state.state != UP_TO_DATE && current_state.state != AVAILABLE && !force) {
return;
}
Expand Down
23 changes: 23 additions & 0 deletions src/Utils/SessionUtils.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

namespace SettingsDaemon.Utils {
public static bool is_running_in_demo_mode () {
var proc_cmdline = File.new_for_path ("/proc/cmdline");
try {
var @is = proc_cmdline.read ();
var dis = new DataInputStream (@is);

var line = dis.read_line ();
if ("boot=casper" in line || "boot=live" in line || "rd.live.image" in line) {
return true;
}
} catch (Error e) {
critical ("Couldn't detect if running in Demo Mode: %s", e.message);
}

return false;
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sources = files(
'Backends/PrefersColorSchemeSettings.vala',
'Backends/SystemUpdate.vala',
'Utils/PkUtils.vala',
'Utils/SessionUtils.vala',
'Utils/SunriseSunsetCalculator.vala',
)

Expand Down