Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_DBUS_SERVICE_H_ |
| 6 | #define UPDATE_ENGINE_DBUS_SERVICE_H_ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 7 | |
| 8 | #include <inttypes.h> |
| 9 | #include <dbus/dbus-glib.h> |
| 10 | #include <dbus/dbus-glib-bindings.h> |
| 11 | #include <dbus/dbus-glib-lowlevel.h> |
| 12 | #include <glib-object.h> |
| 13 | |
| 14 | #include "update_engine/update_attempter.h" |
| 15 | |
| 16 | // Type macros: |
| 17 | #define UPDATE_ENGINE_TYPE_SERVICE (update_engine_service_get_type()) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 18 | #define UPDATE_ENGINE_SERVICE(obj) \ |
| 19 | (G_TYPE_CHECK_INSTANCE_CAST((obj), UPDATE_ENGINE_TYPE_SERVICE, \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 20 | UpdateEngineService)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 21 | #define UPDATE_ENGINE_IS_SERVICE(obj) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 22 | (G_TYPE_CHECK_INSTANCE_TYPE((obj), UPDATE_ENGINE_TYPE_SERVICE)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 23 | #define UPDATE_ENGINE_SERVICE_CLASS(klass) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 24 | (G_TYPE_CHECK_CLASS_CAST((klass), UPDATE_ENGINE_TYPE_SERVICE, \ |
| 25 | UpdateEngineService)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 26 | #define UPDATE_ENGINE_IS_SERVICE_CLASS(klass) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 27 | (G_TYPE_CHECK_CLASS_TYPE((klass), UPDATE_ENGINE_TYPE_SERVICE)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 28 | #define UPDATE_ENGINE_SERVICE_GET_CLASS(obj) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 29 | (G_TYPE_INSTANCE_GET_CLASS((obj), UPDATE_ENGINE_TYPE_SERVICE, \ |
| 30 | UpdateEngineService)) |
| 31 | |
| 32 | G_BEGIN_DECLS |
| 33 | |
| 34 | struct UpdateEngineService { |
| 35 | GObject parent_instance; |
| 36 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 37 | chromeos_update_engine::SystemState* system_state_; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct UpdateEngineServiceClass { |
| 41 | GObjectClass parent_class; |
| 42 | }; |
| 43 | |
| 44 | UpdateEngineService* update_engine_service_new(void); |
| 45 | GType update_engine_service_get_type(void); |
| 46 | |
| 47 | // Methods |
| 48 | |
Darin Petkov | 296889c | 2010-07-23 16:20:54 -0700 | [diff] [blame] | 49 | gboolean update_engine_service_attempt_update(UpdateEngineService* self, |
| 50 | gchar* app_version, |
| 51 | gchar* omaha_url, |
| 52 | GError **error); |
| 53 | |
David Zeuthen | 75a4c3e | 2013-09-06 11:36:59 -0700 | [diff] [blame] | 54 | gboolean update_engine_service_attempt_update_with_flags( |
| 55 | UpdateEngineService* self, |
| 56 | gchar* app_version, |
| 57 | gchar* omaha_url, |
| 58 | gint flags_as_int, |
| 59 | GError **error); |
| 60 | |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 61 | gboolean update_engine_service_attempt_rollback(UpdateEngineService* self, |
Alex Deymo | ad92373 | 2013-08-29 16:13:49 -0700 | [diff] [blame] | 62 | gboolean powerwash, |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 63 | GError **error); |
| 64 | |
Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 65 | // Checks if the system rollback is available by verifying if the secondary |
| 66 | // system partition is valid and bootable. |
| 67 | gboolean update_engine_service_can_rollback( |
| 68 | UpdateEngineService* self, |
| 69 | gboolean* out_can_rollback, |
| 70 | GError **error); |
| 71 | |
Alex Vakulenko | 2bddadd | 2014-03-27 13:23:46 -0700 | [diff] [blame] | 72 | // Returns the name of kernel partition that can be rolled back into. |
| 73 | gboolean update_engine_service_get_rollback_partition( |
| 74 | UpdateEngineService* self, |
| 75 | gchar** out_rollback_partition_name, |
| 76 | GError **error); |
| 77 | |
| 78 | // Returns a list of available kernel partitions and whether each of them |
| 79 | // can be booted from or not. |
| 80 | gboolean update_engine_service_get_kernel_devices(UpdateEngineService* self, |
| 81 | gchar** out_kernel_devices, |
| 82 | GError **error); |
| 83 | |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 84 | gboolean update_engine_service_reset_status(UpdateEngineService* self, |
| 85 | GError **error); |
| 86 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 87 | gboolean update_engine_service_get_status(UpdateEngineService* self, |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 88 | int64_t* last_checked_time, |
| 89 | double* progress, |
| 90 | gchar** current_operation, |
| 91 | gchar** new_version, |
| 92 | int64_t* new_size, |
| 93 | GError **error); |
| 94 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 95 | gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self, |
| 96 | GError **error); |
| 97 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 98 | // Changes the current channel of the device to the target channel. If the |
| 99 | // target channel is a less stable channel than the current channel, then the |
| 100 | // channel change happens immediately (at the next update check). If the |
| 101 | // target channel is a more stable channel, then if is_powerwash_allowed is set |
| 102 | // to true, then also the change happens immediately but with a powerwash if |
| 103 | // required. Otherwise, the change takes effect eventually (when the version on |
| 104 | // the target channel goes above the version number of what the device |
| 105 | // currently has). |
| 106 | gboolean update_engine_service_set_channel(UpdateEngineService* self, |
| 107 | gchar* target_channel, |
Alex Deymo | ad92373 | 2013-08-29 16:13:49 -0700 | [diff] [blame] | 108 | gboolean is_powerwash_allowed, |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 109 | GError **error); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 110 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 111 | // If get_current_channel is set to true, populates |channel| with the name of |
| 112 | // the channel that the device is currently on. Otherwise, it populates it with |
| 113 | // the name of the channel the device is supposed to be (in case of a pending |
| 114 | // channel change). |
| 115 | gboolean update_engine_service_get_channel(UpdateEngineService* self, |
Alex Deymo | ad92373 | 2013-08-29 16:13:49 -0700 | [diff] [blame] | 116 | gboolean get_current_channel, |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 117 | gchar** channel, |
| 118 | GError **error); |
Darin Petkov | 8daa324 | 2010-10-25 13:28:47 -0700 | [diff] [blame] | 119 | |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 120 | // Enables or disables the sharing and consuming updates over P2P feature |
| 121 | // according to the |enabled| argument passed. |
| 122 | gboolean update_engine_service_set_p2p_update_permission( |
| 123 | UpdateEngineService* self, |
| 124 | gboolean enabled, |
| 125 | GError **error); |
| 126 | |
| 127 | // Returns in |enabled| the current value for the P2P enabled setting. This |
| 128 | // involves both sharing and consuming updates over P2P. |
| 129 | gboolean update_engine_service_get_p2p_update_permission( |
| 130 | UpdateEngineService* self, |
| 131 | gboolean* enabled, |
| 132 | GError **error); |
| 133 | |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 134 | // If there's no device policy installed, sets the update over cellular networks |
| 135 | // permission to the |allowed| value. Otherwise, this method returns with an |
| 136 | // error since this setting is overridden by the applied policy. |
| 137 | gboolean update_engine_service_set_update_over_cellular_permission( |
| 138 | UpdateEngineService* self, |
Alex Deymo | ad92373 | 2013-08-29 16:13:49 -0700 | [diff] [blame] | 139 | gboolean allowed, |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 140 | GError **error); |
| 141 | |
| 142 | // Returns the current value of the update over cellular network setting, either |
| 143 | // forced by the device policy if the device is enrolled or the current user |
| 144 | // preference otherwise. |
| 145 | gboolean update_engine_service_get_update_over_cellular_permission( |
| 146 | UpdateEngineService* self, |
Alex Deymo | ad92373 | 2013-08-29 16:13:49 -0700 | [diff] [blame] | 147 | gboolean* allowed, |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 148 | GError **error); |
| 149 | |
David Zeuthen | 3c55abd | 2013-10-14 12:48:03 -0700 | [diff] [blame] | 150 | // Returns the duration since the last successful update, as the |
| 151 | // duration on the wallclock. Returns an error if the device has not |
| 152 | // updated. |
| 153 | gboolean update_engine_service_get_duration_since_update( |
| 154 | UpdateEngineService* self, |
| 155 | gint64* out_usec_wallclock, |
| 156 | GError **error); |
| 157 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 158 | gboolean update_engine_service_emit_status_update( |
| 159 | UpdateEngineService* self, |
| 160 | gint64 last_checked_time, |
| 161 | gdouble progress, |
| 162 | const gchar* current_operation, |
| 163 | const gchar* new_version, |
| 164 | gint64 new_size); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 165 | |
Alex Vakulenko | dea2eac | 2014-03-14 15:56:59 -0700 | [diff] [blame] | 166 | // Returns the version string of OS that was used before the last reboot |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame^] | 167 | // into an updated version. This is available only when rebooting into an |
Alex Vakulenko | dea2eac | 2014-03-14 15:56:59 -0700 | [diff] [blame] | 168 | // update from previous version, otherwise an empty string is returned. |
| 169 | gboolean update_engine_service_get_prev_version( |
| 170 | UpdateEngineService* self, |
| 171 | gchar** prev_version, |
| 172 | GError **error); |
| 173 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 174 | G_END_DECLS |
| 175 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 176 | #endif // UPDATE_ENGINE_DBUS_SERVICE_H_ |