blob: d61e3b547f787318e572709adb05157862d22f0d [file] [log] [blame]
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07001// 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 Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_DBUS_SERVICE_H_
6#define UPDATE_ENGINE_DBUS_SERVICE_H_
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07007
8#include <inttypes.h>
Alex Vakulenko44cab302014-07-23 13:12:15 -07009
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070010#include <dbus/dbus-glib.h>
11#include <dbus/dbus-glib-bindings.h>
12#include <dbus/dbus-glib-lowlevel.h>
13#include <glib-object.h>
14
15#include "update_engine/update_attempter.h"
16
17// Type macros:
18#define UPDATE_ENGINE_TYPE_SERVICE (update_engine_service_get_type())
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070019#define UPDATE_ENGINE_SERVICE(obj) \
20 (G_TYPE_CHECK_INSTANCE_CAST((obj), UPDATE_ENGINE_TYPE_SERVICE, \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070021 UpdateEngineService))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070022#define UPDATE_ENGINE_IS_SERVICE(obj) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070023 (G_TYPE_CHECK_INSTANCE_TYPE((obj), UPDATE_ENGINE_TYPE_SERVICE))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070024#define UPDATE_ENGINE_SERVICE_CLASS(klass) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070025 (G_TYPE_CHECK_CLASS_CAST((klass), UPDATE_ENGINE_TYPE_SERVICE, \
26 UpdateEngineService))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070027#define UPDATE_ENGINE_IS_SERVICE_CLASS(klass) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070028 (G_TYPE_CHECK_CLASS_TYPE((klass), UPDATE_ENGINE_TYPE_SERVICE))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070029#define UPDATE_ENGINE_SERVICE_GET_CLASS(obj) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070030 (G_TYPE_INSTANCE_GET_CLASS((obj), UPDATE_ENGINE_TYPE_SERVICE, \
31 UpdateEngineService))
32
33G_BEGIN_DECLS
34
35struct UpdateEngineService {
36 GObject parent_instance;
37
Jay Srinivasanae4697c2013-03-18 17:08:08 -070038 chromeos_update_engine::SystemState* system_state_;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070039};
40
41struct UpdateEngineServiceClass {
42 GObjectClass parent_class;
43};
44
45UpdateEngineService* update_engine_service_new(void);
46GType update_engine_service_get_type(void);
47
48// Methods
49
Darin Petkov296889c2010-07-23 16:20:54 -070050gboolean update_engine_service_attempt_update(UpdateEngineService* self,
51 gchar* app_version,
52 gchar* omaha_url,
53 GError **error);
54
David Zeuthen75a4c3e2013-09-06 11:36:59 -070055gboolean update_engine_service_attempt_update_with_flags(
56 UpdateEngineService* self,
57 gchar* app_version,
58 gchar* omaha_url,
59 gint flags_as_int,
60 GError **error);
61
Chris Sosad317e402013-06-12 13:47:09 -070062gboolean update_engine_service_attempt_rollback(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -070063 gboolean powerwash,
Chris Sosad317e402013-06-12 13:47:09 -070064 GError **error);
65
Alex Vakulenko59e253e2014-02-24 10:40:21 -080066// Checks if the system rollback is available by verifying if the secondary
67// system partition is valid and bootable.
68gboolean update_engine_service_can_rollback(
69 UpdateEngineService* self,
70 gboolean* out_can_rollback,
71 GError **error);
72
Alex Vakulenko2bddadd2014-03-27 13:23:46 -070073// Returns the name of kernel partition that can be rolled back into.
74gboolean update_engine_service_get_rollback_partition(
75 UpdateEngineService* self,
76 gchar** out_rollback_partition_name,
77 GError **error);
78
79// Returns a list of available kernel partitions and whether each of them
80// can be booted from or not.
81gboolean update_engine_service_get_kernel_devices(UpdateEngineService* self,
82 gchar** out_kernel_devices,
83 GError **error);
84
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -070085gboolean update_engine_service_reset_status(UpdateEngineService* self,
86 GError **error);
87
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070088gboolean update_engine_service_get_status(UpdateEngineService* self,
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070089 int64_t* last_checked_time,
90 double* progress,
91 gchar** current_operation,
92 gchar** new_version,
93 int64_t* new_size,
94 GError **error);
95
Jay Srinivasanae4697c2013-03-18 17:08:08 -070096gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
97 GError **error);
98
Jay Srinivasanae4697c2013-03-18 17:08:08 -070099// Changes the current channel of the device to the target channel. If the
100// target channel is a less stable channel than the current channel, then the
101// channel change happens immediately (at the next update check). If the
102// target channel is a more stable channel, then if is_powerwash_allowed is set
103// to true, then also the change happens immediately but with a powerwash if
104// required. Otherwise, the change takes effect eventually (when the version on
105// the target channel goes above the version number of what the device
106// currently has).
107gboolean update_engine_service_set_channel(UpdateEngineService* self,
108 gchar* target_channel,
Alex Deymoad923732013-08-29 16:13:49 -0700109 gboolean is_powerwash_allowed,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700110 GError **error);
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700111
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700112// If get_current_channel is set to true, populates |channel| with the name of
113// the channel that the device is currently on. Otherwise, it populates it with
114// the name of the channel the device is supposed to be (in case of a pending
115// channel change).
116gboolean update_engine_service_get_channel(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700117 gboolean get_current_channel,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700118 gchar** channel,
119 GError **error);
Darin Petkov8daa3242010-10-25 13:28:47 -0700120
Alex Deymo5fdf7762013-07-17 20:01:40 -0700121// Enables or disables the sharing and consuming updates over P2P feature
122// according to the |enabled| argument passed.
123gboolean update_engine_service_set_p2p_update_permission(
124 UpdateEngineService* self,
125 gboolean enabled,
126 GError **error);
127
128// Returns in |enabled| the current value for the P2P enabled setting. This
129// involves both sharing and consuming updates over P2P.
130gboolean update_engine_service_get_p2p_update_permission(
131 UpdateEngineService* self,
132 gboolean* enabled,
133 GError **error);
134
Alex Deymof4867c42013-06-28 14:41:39 -0700135// If there's no device policy installed, sets the update over cellular networks
136// permission to the |allowed| value. Otherwise, this method returns with an
137// error since this setting is overridden by the applied policy.
138gboolean update_engine_service_set_update_over_cellular_permission(
139 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700140 gboolean allowed,
Alex Deymof4867c42013-06-28 14:41:39 -0700141 GError **error);
142
143// Returns the current value of the update over cellular network setting, either
144// forced by the device policy if the device is enrolled or the current user
145// preference otherwise.
146gboolean update_engine_service_get_update_over_cellular_permission(
147 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700148 gboolean* allowed,
Alex Deymof4867c42013-06-28 14:41:39 -0700149 GError **error);
150
David Zeuthen3c55abd2013-10-14 12:48:03 -0700151// Returns the duration since the last successful update, as the
152// duration on the wallclock. Returns an error if the device has not
153// updated.
154gboolean update_engine_service_get_duration_since_update(
155 UpdateEngineService* self,
156 gint64* out_usec_wallclock,
157 GError **error);
158
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700159gboolean update_engine_service_emit_status_update(
160 UpdateEngineService* self,
161 gint64 last_checked_time,
162 gdouble progress,
163 const gchar* current_operation,
164 const gchar* new_version,
165 gint64 new_size);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700166
Alex Vakulenkodea2eac2014-03-14 15:56:59 -0700167// Returns the version string of OS that was used before the last reboot
Alex Vakulenko072359c2014-07-18 11:41:07 -0700168// into an updated version. This is available only when rebooting into an
Alex Vakulenkodea2eac2014-03-14 15:56:59 -0700169// update from previous version, otherwise an empty string is returned.
170gboolean update_engine_service_get_prev_version(
171 UpdateEngineService* self,
172 gchar** prev_version,
173 GError **error);
174
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700175G_END_DECLS
176
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700177#endif // UPDATE_ENGINE_DBUS_SERVICE_H_