Commit Graph

15 Commits

Author SHA1 Message Date
Twain Byrnes
84b06ed258 migrate powerd plugin from method call to signal
Allow fwupd to use the BatteryStatePoll signal instead
of the GetBatteryState method call so that fwupd does
not need to run a timer itself and is automatically updated
on power connect/disconnect.

Change-Id: I81aad6a5933fa267473a83d1b97f4638235b155a
2021-08-12 17:01:13 +01:00
Richard Hughes
bc759d0584 Fix cleanup and plugin to have the correct args order
All the other vfuncs have 'plugin, device, flags' but prepare and
cleanup vfuncs being 'plugin, flags, device' order has been triggering
my OCD for the last few years.

We've just broken the symbol names, so it's the right time to fix this.
2021-08-10 09:57:49 +01:00
Richard Hughes
a5a978b3f6 Rename some confusing API
More than one person has asked about 'why call fu_plugin_update() for a
reinstall or downgrade' and I didn't have a very good answer.

The plugin API is not officially stable, and we should fix things to be
less confusing. Use the same verbs as the FuDevice vfuncs instead.
2021-08-06 19:49:53 +01:00
Twain Byrnes
eed815331c Inhibit system suspend during update
Create and destroy /run/lock/power_override/fwupd.lock.
This file will hold the contents of getpid (), which will
stop the device from being suspended while the file exists.
The file will be created and written just before the
update is put into motion and be destroyed once the update
finishes, or upon restart in case of catastrophic failure.

Change-Id: If8dd17b0358862a842c9589e11ed0de12d852797
2021-08-04 08:33:57 +01:00
Mario Limonciello
143efb9d88 trivial: only build powerd on new enough glib
snap has an older glib and the plugin fails to compile.
2021-07-30 20:25:46 -05:00
George Popoola
1a58398afb powerd: Creating recurring powerd callback
This CL moves the battery information retrieval into a new function,
called "fu_plugin_powerd_callback()", which returns the information in a
struct.

This information is then used in fu_plugin_update_prepare() for battery
checks. There is also a g_timeout_add() function being created in
fu_plugin_startup() in order to enable the plugin to repeatedly send a method
call to powerd.

fu_plugin_update_prepare is removed as its functionality is now handled
by src/fu-engine.c
2021-07-30 10:58:40 -06:00
Daniel Campello
40295c673d trival: reformat fu-plugin-powerd.c 2021-07-30 10:58:40 -06:00
George Popoola
8e4624809c powerd: Enable updates on devices without battery
This adds a condition to the powerd plugin that passes updates on devices
that do not give provide valid battery information or whose battery
information is unknown, such as Chromeboxes, which have no battery to
read.
2021-07-27 15:36:51 -06:00
George Popoola
f7195f0a22 powerd: Moving ignore power case before method call
This adds a condition that permits updates for devices that don't take
any power conditions into account.
2021-07-22 16:26:54 -06:00
George Popoola
1d8d26d167 powerd: Adding case for devices that ignore power
This adds a condition that permits updates for devices that don't take
any power conditions into account.
2021-07-22 20:57:32 +01:00
Daniel Campello
4b10b1324c trivial: powerd: reformat code with contrib/reformat-code.py 2021-07-22 10:45:45 -06:00
Richard Hughes
0920c44088 powerd: Use the system-defined battery threshold 2021-07-21 09:36:11 -06:00
Richard Hughes
56bf223a0f powerd: trivial style fixups 2021-07-21 09:36:11 -06:00
George Popoola
357bfd07da powerd: DBus Connection and Parsing
A series of changes are made to the powerd skeleton
plugin in order to reach two goals: ensuring that it handles cases correctly, given certain
information about the battery and/or certain return types and that it
successfully retrieves battery information from powerd to be used later.

Logic is then added to ensure updates are only performed
when that battery level is at or above the minimum threshold.
Then logic is added that checks if the device being updating requires
AC power. Along with this, specific
error statements are added for each scenario where an update is blocked.

To address the next goal, within fu_plugin_startup(), a GDBus connection
is established. However, instead of a direct connection to
powerd, the connection is changed to link to the general system bus with
g_bus_get_sync(). From there, a proxy is created to represent the
connection to powerd. A test call is made for the name of the service that the
proxy represents to check for successful communication.

Then, in fu_plugin_update_prepare(), the existing proxy is called and in the call,
the "GetBatteryState" is passed to make a method call method. The
response is filled into a GVariant, whose entries are initialized in new variables to use
for battery checks. And checks are added to make sure every step was
successful.
2021-07-19 13:40:11 -07:00
Twain Byrnes
379250996a Skeleton plugin for powerd
This CL creates a mostly empty fu-plugin-powerd.c that
has the file disable itself on startup with an error.

The README.md file was re-created to include information on
powerd and the specific interface it will use.

A meson.build file re-created to call fu-plugin-powerd.c.
It excludes a .conf install function was removed to be consistent with
an upstream change.

The general meson.build file includes the
powerd subdirectory for powerd to compile.

No .quirk file was included. There will be general daemon.quirk file for all plugins.

FIXUP: Adjusted copyright format and whitespace in fu-plugin-powerd.c
and plugin returns false on startup. Also added to "fu-plugin-powerd.so"
entry fwupd.spec.in.
2021-07-19 13:40:11 -07:00