blob: 3449f1f6c31b5bffc9fa222b63e3e4655b9186c3 [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
Alex Deymo759c2752014-03-17 21:09:36 -07005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H_
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07007
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 Reyes63b96d72010-05-10 13:08:54 -070018#define UPDATE_ENGINE_SERVICE(obj) \
19 (G_TYPE_CHECK_INSTANCE_CAST((obj), UPDATE_ENGINE_TYPE_SERVICE, \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070020 UpdateEngineService))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070021#define UPDATE_ENGINE_IS_SERVICE(obj) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070022 (G_TYPE_CHECK_INSTANCE_TYPE((obj), UPDATE_ENGINE_TYPE_SERVICE))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070023#define UPDATE_ENGINE_SERVICE_CLASS(klass) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070024 (G_TYPE_CHECK_CLASS_CAST((klass), UPDATE_ENGINE_TYPE_SERVICE, \
25 UpdateEngineService))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070026#define UPDATE_ENGINE_IS_SERVICE_CLASS(klass) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070027 (G_TYPE_CHECK_CLASS_TYPE((klass), UPDATE_ENGINE_TYPE_SERVICE))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070028#define UPDATE_ENGINE_SERVICE_GET_CLASS(obj) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070029 (G_TYPE_INSTANCE_GET_CLASS((obj), UPDATE_ENGINE_TYPE_SERVICE, \
30 UpdateEngineService))
31
32G_BEGIN_DECLS
33
34struct UpdateEngineService {
35 GObject parent_instance;
36
Jay Srinivasanae4697c2013-03-18 17:08:08 -070037 chromeos_update_engine::SystemState* system_state_;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070038};
39
40struct UpdateEngineServiceClass {
41 GObjectClass parent_class;
42};
43
44UpdateEngineService* update_engine_service_new(void);
45GType update_engine_service_get_type(void);
46
47// Methods
48
Darin Petkov296889c2010-07-23 16:20:54 -070049gboolean update_engine_service_attempt_update(UpdateEngineService* self,
50 gchar* app_version,
51 gchar* omaha_url,
52 GError **error);
53
David Zeuthen75a4c3e2013-09-06 11:36:59 -070054gboolean 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 Sosad317e402013-06-12 13:47:09 -070061gboolean update_engine_service_attempt_rollback(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -070062 gboolean powerwash,
Chris Sosad317e402013-06-12 13:47:09 -070063 GError **error);
64
Alex Vakulenko59e253e2014-02-24 10:40:21 -080065// Checks if the system rollback is available by verifying if the secondary
66// system partition is valid and bootable.
67gboolean update_engine_service_can_rollback(
68 UpdateEngineService* self,
69 gboolean* out_can_rollback,
70 GError **error);
71
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -070072gboolean update_engine_service_reset_status(UpdateEngineService* self,
73 GError **error);
74
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070075gboolean update_engine_service_get_status(UpdateEngineService* self,
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070076 int64_t* last_checked_time,
77 double* progress,
78 gchar** current_operation,
79 gchar** new_version,
80 int64_t* new_size,
81 GError **error);
82
Jay Srinivasanae4697c2013-03-18 17:08:08 -070083gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
84 GError **error);
85
Jay Srinivasanae4697c2013-03-18 17:08:08 -070086// Changes the current channel of the device to the target channel. If the
87// target channel is a less stable channel than the current channel, then the
88// channel change happens immediately (at the next update check). If the
89// target channel is a more stable channel, then if is_powerwash_allowed is set
90// to true, then also the change happens immediately but with a powerwash if
91// required. Otherwise, the change takes effect eventually (when the version on
92// the target channel goes above the version number of what the device
93// currently has).
94gboolean update_engine_service_set_channel(UpdateEngineService* self,
95 gchar* target_channel,
Alex Deymoad923732013-08-29 16:13:49 -070096 gboolean is_powerwash_allowed,
Jay Srinivasanae4697c2013-03-18 17:08:08 -070097 GError **error);
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070098
Jay Srinivasanae4697c2013-03-18 17:08:08 -070099// If get_current_channel is set to true, populates |channel| with the name of
100// the channel that the device is currently on. Otherwise, it populates it with
101// the name of the channel the device is supposed to be (in case of a pending
102// channel change).
103gboolean update_engine_service_get_channel(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700104 gboolean get_current_channel,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700105 gchar** channel,
106 GError **error);
Darin Petkov8daa3242010-10-25 13:28:47 -0700107
Alex Deymo5fdf7762013-07-17 20:01:40 -0700108// Enables or disables the sharing and consuming updates over P2P feature
109// according to the |enabled| argument passed.
110gboolean update_engine_service_set_p2p_update_permission(
111 UpdateEngineService* self,
112 gboolean enabled,
113 GError **error);
114
115// Returns in |enabled| the current value for the P2P enabled setting. This
116// involves both sharing and consuming updates over P2P.
117gboolean update_engine_service_get_p2p_update_permission(
118 UpdateEngineService* self,
119 gboolean* enabled,
120 GError **error);
121
Alex Deymof4867c42013-06-28 14:41:39 -0700122// If there's no device policy installed, sets the update over cellular networks
123// permission to the |allowed| value. Otherwise, this method returns with an
124// error since this setting is overridden by the applied policy.
125gboolean update_engine_service_set_update_over_cellular_permission(
126 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700127 gboolean allowed,
Alex Deymof4867c42013-06-28 14:41:39 -0700128 GError **error);
129
130// Returns the current value of the update over cellular network setting, either
131// forced by the device policy if the device is enrolled or the current user
132// preference otherwise.
133gboolean update_engine_service_get_update_over_cellular_permission(
134 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700135 gboolean* allowed,
Alex Deymof4867c42013-06-28 14:41:39 -0700136 GError **error);
137
David Zeuthen3c55abd2013-10-14 12:48:03 -0700138// Returns the duration since the last successful update, as the
139// duration on the wallclock. Returns an error if the device has not
140// updated.
141gboolean update_engine_service_get_duration_since_update(
142 UpdateEngineService* self,
143 gint64* out_usec_wallclock,
144 GError **error);
145
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700146gboolean update_engine_service_emit_status_update(
147 UpdateEngineService* self,
148 gint64 last_checked_time,
149 gdouble progress,
150 const gchar* current_operation,
151 const gchar* new_version,
152 gint64 new_size);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700153
Alex Vakulenkodea2eac2014-03-14 15:56:59 -0700154// Returns the version string of OS that was used before the last reboot
155// into an updated version. This is avalable only when rebooting into an
156// update from previous version, otherwise an empty string is returned.
157gboolean update_engine_service_get_prev_version(
158 UpdateEngineService* self,
159 gchar** prev_version,
160 GError **error);
161
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700162G_END_DECLS
163
Alex Deymo759c2752014-03-17 21:09:36 -0700164#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H_