Skip to content

Commit

Permalink
Add support for offline firmware updates (#244)
Browse files Browse the repository at this point in the history
* FirmwareClient: Set default install flags

* FirmwareView: Check if device can only do offline updates
  • Loading branch information
meisenzahl committed Feb 8, 2022
1 parent e539e1d commit d9e8661
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Interfaces/FirmwareClient.vala
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public class About.FirmwareClient {
return releases;
}

public static async bool install (Fwupd.Client client, string device_id, string path) throws GLib.Error {
public static async bool install (Fwupd.Client client, string device_id, string path, Fwupd.InstallFlags install_flags = Fwupd.InstallFlags.NONE) throws GLib.Error {
SourceFunc callback = install.callback;
GLib.Error error = null;
bool result = false;

new Thread<void> ("install", () => {
try {
result = client.install (device_id, path, Fwupd.InstallFlags.NONE);
result = client.install (device_id, path, install_flags);
} catch (Error e) {
error = e;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Views/FirmwareView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ public class About.FirmwareView : Granite.SimpleSettingsPage {
var path = yield download_file (device, release.get_uri ());

try {
if (yield FirmwareClient.install (fwupd_client, device.get_id (), path)) {
var install_flags = Fwupd.InstallFlags.NONE;
if (device.has_flag (Fwupd.DEVICE_FLAG_ONLY_OFFLINE)) {
install_flags = Fwupd.InstallFlags.OFFLINE;
}

if (yield FirmwareClient.install (fwupd_client, device.get_id (), path, install_flags)) {
if (device.has_flag (Fwupd.DEVICE_FLAG_NEEDS_REBOOT)) {
show_reboot_dialog ();
} else if (device.has_flag (Fwupd.DEVICE_FLAG_NEEDS_SHUTDOWN)) {
Expand Down

0 comments on commit d9e8661

Please sign in to comment.