blob: cbfdc17d9b048cb1a922b0e30d7571b35f3edc92 [file] [log] [blame]
Jay Srinivasane73acab2012-07-10 14:34:03 -07001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "update_engine/dbus_service.h"
Darin Petkova07586b2010-10-20 13:41:15 -07006
Alex Deymof4867c42013-06-28 14:41:39 -07007#include <set>
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07008#include <string>
Darin Petkova07586b2010-10-20 13:41:15 -07009
10#include <base/logging.h>
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070011#include <policy/device_policy.h>
Darin Petkova07586b2010-10-20 13:41:15 -070012
David Zeuthen3c55abd2013-10-14 12:48:03 -070013#include "update_engine/clock_interface.h"
Alex Deymof4867c42013-06-28 14:41:39 -070014#include "update_engine/connection_manager.h"
David Zeuthen75a4c3e2013-09-06 11:36:59 -070015#include "update_engine/dbus_constants.h"
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070016#include "update_engine/hardware_interface.h"
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070017#include "update_engine/marshal.glibmarshal.h"
Darin Petkov49d91322010-10-25 16:34:58 -070018#include "update_engine/omaha_request_params.h"
Alex Deymo5fdf7762013-07-17 20:01:40 -070019#include "update_engine/p2p_manager.h"
Alex Deymof4867c42013-06-28 14:41:39 -070020#include "update_engine/prefs.h"
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070021#include "update_engine/update_attempter.h"
Darin Petkova07586b2010-10-20 13:41:15 -070022#include "update_engine/utils.h"
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070023
Alex Deymof4867c42013-06-28 14:41:39 -070024using std::set;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070025using std::string;
David Zeuthen75a4c3e2013-09-06 11:36:59 -070026using chromeos_update_engine::AttemptUpdateFlags;
27using chromeos_update_engine::kAttemptUpdateFlagNonInteractive;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070028
Don Garrettbb26fc82013-11-15 10:40:17 -080029#define UPDATE_ENGINE_SERVICE_ERROR update_engine_service_error_quark ()
30#define UPDATE_ENGINE_SERVICE_TYPE_ERROR \
31 (update_engine_service_error_get_type())
32
33typedef enum
34{
35 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
36 UPDATE_ENGINE_SERVICE_NUM_ERRORS
37} UpdateEngineServiceError;
38
39static GQuark update_engine_service_error_quark(void) {
40 static GQuark ret = 0;
41
42 if (ret == 0)
43 ret = g_quark_from_static_string("update_engine_service_error");
44
45 return ret;
46}
47
48#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
49
50static GType update_engine_service_error_get_type(void) {
51 static GType etype = 0;
52
53 if (etype == 0) {
54 static const GEnumValue values[] = {
55 ENUM_ENTRY(UPDATE_ENGINE_SERVICE_ERROR_FAILED, "Failed"),
56 { 0, 0, 0 }
57 };
58 G_STATIC_ASSERT(UPDATE_ENGINE_SERVICE_NUM_ERRORS ==
59 G_N_ELEMENTS (values) - 1);
60 etype = g_enum_register_static("UpdateEngineServiceError", values);
61 }
62
63 return etype;
64}
65
Darin Petkov820a77b2011-04-27 16:48:58 -070066static const char kAUTestURLRequest[] = "autest";
Jay Srinivasane73acab2012-07-10 14:34:03 -070067// By default autest bypasses scattering. If we want to test scattering,
68// we should use autest-scheduled. The Url used is same in both cases, but
69// different params are passed to CheckForUpdate method.
70static const char kScheduledAUTestURLRequest[] = "autest-scheduled";
71
Darin Petkov820a77b2011-04-27 16:48:58 -070072static const char kAUTestURL[] =
Darin Petkov5445e162011-11-04 10:10:27 +010073 "https://omaha.sandbox.google.com/service/update2";
Darin Petkov820a77b2011-04-27 16:48:58 -070074
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070075G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT)
76
77static void update_engine_service_finalize(GObject* object) {
78 G_OBJECT_CLASS(update_engine_service_parent_class)->finalize(object);
79}
80
Don Garrettbb26fc82013-11-15 10:40:17 -080081static void log_and_set_response_error(GError** error,
82 UpdateEngineServiceError error_code,
83 const string& reason) {
84 LOG(ERROR) << "Sending DBus Failure: " << reason;
85 g_set_error_literal(error, UPDATE_ENGINE_SERVICE_ERROR,
86 error_code, reason.c_str());
87}
88
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070089static guint status_update_signal = 0;
90
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070091static void update_engine_service_class_init(UpdateEngineServiceClass* klass) {
92 GObjectClass *object_class;
93 object_class = G_OBJECT_CLASS(klass);
94 object_class->finalize = update_engine_service_finalize;
Darin Petkov5a7f5652010-07-22 21:40:09 -070095
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070096 status_update_signal = g_signal_new(
97 "status_update",
98 G_OBJECT_CLASS_TYPE(klass),
99 G_SIGNAL_RUN_LAST,
100 0, // 0 == no class method associated
101 NULL, // Accumulator
102 NULL, // Accumulator data
103 update_engine_VOID__INT64_DOUBLE_STRING_STRING_INT64,
104 G_TYPE_NONE, // Return type
105 5, // param count:
106 G_TYPE_INT64,
107 G_TYPE_DOUBLE,
108 G_TYPE_STRING,
109 G_TYPE_STRING,
110 G_TYPE_INT64);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700111}
112
113static void update_engine_service_init(UpdateEngineService* object) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800114 dbus_g_error_domain_register (UPDATE_ENGINE_SERVICE_ERROR,
115 "org.chromium.UpdateEngine.Error",
116 UPDATE_ENGINE_SERVICE_TYPE_ERROR);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700117}
118
119UpdateEngineService* update_engine_service_new(void) {
120 return reinterpret_cast<UpdateEngineService*>(
121 g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL));
122}
123
Darin Petkov296889c2010-07-23 16:20:54 -0700124gboolean update_engine_service_attempt_update(UpdateEngineService* self,
125 gchar* app_version,
126 gchar* omaha_url,
127 GError **error) {
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700128 return update_engine_service_attempt_update_with_flags(self,
129 app_version,
130 omaha_url,
131 0, // No flags set.
132 error);
133}
134
135gboolean update_engine_service_attempt_update_with_flags(
136 UpdateEngineService* self,
137 gchar* app_version,
138 gchar* omaha_url,
139 gint flags_as_int,
140 GError **error) {
Darin Petkova07586b2010-10-20 13:41:15 -0700141 string update_app_version;
142 string update_omaha_url;
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700143 AttemptUpdateFlags flags = static_cast<AttemptUpdateFlags>(flags_as_int);
Gilad Arnoldb92f0df2013-01-10 16:32:45 -0800144 bool interactive = true;
Jay Srinivasane73acab2012-07-10 14:34:03 -0700145
Darin Petkova07586b2010-10-20 13:41:15 -0700146 // Only non-official (e.g., dev and test) builds can override the current
Darin Petkov820a77b2011-04-27 16:48:58 -0700147 // version and update server URL over D-Bus. However, pointing to the
148 // hardcoded test update server URL is always allowed.
J. Richard Barnette056b0ab2013-10-29 15:24:56 -0700149 if (!self->system_state_->hardware()->IsOfficialBuild()) {
Darin Petkova07586b2010-10-20 13:41:15 -0700150 if (app_version) {
151 update_app_version = app_version;
152 }
153 if (omaha_url) {
154 update_omaha_url = omaha_url;
155 }
156 }
Jay Srinivasane73acab2012-07-10 14:34:03 -0700157 if (omaha_url) {
158 if (strcmp(omaha_url, kScheduledAUTestURLRequest) == 0) {
159 update_omaha_url = kAUTestURL;
160 // pretend that it's not user-initiated even though it is,
161 // so as to test scattering logic, etc. which get kicked off
162 // only in scheduled update checks.
Gilad Arnoldb92f0df2013-01-10 16:32:45 -0800163 interactive = false;
Jay Srinivasane73acab2012-07-10 14:34:03 -0700164 } else if (strcmp(omaha_url, kAUTestURLRequest) == 0) {
165 update_omaha_url = kAUTestURL;
166 }
Darin Petkov820a77b2011-04-27 16:48:58 -0700167 }
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700168 if (flags & kAttemptUpdateFlagNonInteractive)
169 interactive = false;
Darin Petkov296889c2010-07-23 16:20:54 -0700170 LOG(INFO) << "Attempt update: app_version=\"" << update_app_version << "\" "
Jay Srinivasane73acab2012-07-10 14:34:03 -0700171 << "omaha_url=\"" << update_omaha_url << "\" "
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700172 << "flags=0x" << std::hex << flags << " "
Gilad Arnoldb92f0df2013-01-10 16:32:45 -0800173 << "interactive=" << (interactive? "yes" : "no");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700174 self->system_state_->update_attempter()->CheckForUpdate(update_app_version,
175 update_omaha_url,
176 interactive);
Darin Petkov296889c2010-07-23 16:20:54 -0700177 return TRUE;
178}
179
Chris Sosad317e402013-06-12 13:47:09 -0700180gboolean update_engine_service_attempt_rollback(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700181 gboolean powerwash,
Chris Sosad317e402013-06-12 13:47:09 -0700182 GError **error) {
183 LOG(INFO) << "Attempting rollback to non-active partitions.";
Don Garrettbb26fc82013-11-15 10:40:17 -0800184
185 if (!self->system_state_->update_attempter()->Rollback(powerwash, NULL)) {
186 // TODO(dgarrett): Give a more specific error code/reason.
187 log_and_set_response_error(error,
188 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
189 "Rollback attempt failed.");
190 return FALSE;
191 }
192
193 return TRUE;
Chris Sosad317e402013-06-12 13:47:09 -0700194}
195
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -0700196gboolean update_engine_service_reset_status(UpdateEngineService* self,
197 GError **error) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800198 if (!self->system_state_->update_attempter()->ResetStatus()) {
199 // TODO(dgarrett): Give a more specific error code/reason.
200 log_and_set_response_error(error,
201 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
202 "ResetStatus failed.");
203 return FALSE;
204 }
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -0700205
Don Garrettbb26fc82013-11-15 10:40:17 -0800206 return TRUE;
207}
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -0700208
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700209gboolean update_engine_service_get_status(UpdateEngineService* self,
210 int64_t* last_checked_time,
211 double* progress,
212 gchar** current_operation,
213 gchar** new_version,
214 int64_t* new_size,
215 GError **error) {
216 string current_op;
217 string new_version_str;
Darin Petkov5a7f5652010-07-22 21:40:09 -0700218
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700219 CHECK(self->system_state_->update_attempter()->GetStatus(last_checked_time,
220 progress,
221 &current_op,
222 &new_version_str,
223 new_size));
Satoru Takabayashid6982312010-11-29 12:54:12 +0900224 *current_operation = g_strdup(current_op.c_str());
225 *new_version = g_strdup(new_version_str.c_str());
Don Garrettbb26fc82013-11-15 10:40:17 -0800226
227 if (!*current_operation) {
228 log_and_set_response_error(error,
229 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
230 "Unable to find current_operation.");
Chris Masonec6c57a52010-09-23 13:06:14 -0700231 return FALSE;
232 }
Don Garrettbb26fc82013-11-15 10:40:17 -0800233
234 if (!*new_version) {
235 log_and_set_response_error(error,
236 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
237 "Unable to find vew_version.");
238 return FALSE;
239 }
240
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700241 return TRUE;
242}
243
Darin Petkov296889c2010-07-23 16:20:54 -0700244gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700245 GError **error) {
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700246 if (!self->system_state_->update_attempter()->RebootIfNeeded()) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800247 // TODO(dgarrett): Give a more specific error code/reason.
248 log_and_set_response_error(error,
249 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
250 "Reboot not needed, or attempt failed.");
Darin Petkov296889c2010-07-23 16:20:54 -0700251 return FALSE;
252 }
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700253 return TRUE;
254}
255
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700256gboolean update_engine_service_set_channel(UpdateEngineService* self,
257 gchar* target_channel,
Alex Deymoad923732013-08-29 16:13:49 -0700258 gboolean is_powerwash_allowed,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700259 GError **error) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800260 if (!target_channel) {
261 log_and_set_response_error(error,
262 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
263 "Target channel to set not specified.");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700264 return FALSE;
Don Garrettbb26fc82013-11-15 10:40:17 -0800265 }
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700266
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700267 const policy::DevicePolicy* device_policy =
268 self->system_state_->device_policy();
Chris Sosacb7fa882013-07-25 17:02:59 -0700269
270 // The device_policy is loaded in a lazy way before an update check. Load it
271 // now from the libchromeos cache if it wasn't already loaded.
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700272 if (!device_policy) {
Chris Sosacb7fa882013-07-25 17:02:59 -0700273 chromeos_update_engine::UpdateAttempter* update_attempter =
274 self->system_state_->update_attempter();
275 if (update_attempter) {
276 update_attempter->RefreshDevicePolicy();
277 device_policy = self->system_state_->device_policy();
278 }
Darin Petkov8daa3242010-10-25 13:28:47 -0700279 }
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700280
281 bool delegated = false;
Chris Sosacb7fa882013-07-25 17:02:59 -0700282 if (device_policy &&
283 device_policy->GetReleaseChannelDelegated(&delegated) && !delegated) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800284 log_and_set_response_error(
285 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
286 "Cannot set target channel explicitly when channel "
287 "policy/settings is not delegated");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700288 return FALSE;
289 }
290
291 LOG(INFO) << "Setting destination channel to: " << target_channel;
292 if (!self->system_state_->request_params()->SetTargetChannel(
293 target_channel, is_powerwash_allowed)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800294 // TODO(dgarrett): Give a more specific error code/reason.
295 log_and_set_response_error(error,
296 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
297 "Setting channel failed.");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700298 return FALSE;
299 }
300
301 return TRUE;
302}
303
304gboolean update_engine_service_get_channel(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700305 gboolean get_current_channel,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700306 gchar** channel,
307 GError **error) {
308 chromeos_update_engine::OmahaRequestParams* rp =
309 self->system_state_->request_params();
310
311 string channel_str = get_current_channel ?
312 rp->current_channel() : rp->target_channel();
313
314 *channel = g_strdup(channel_str.c_str());
Darin Petkov8daa3242010-10-25 13:28:47 -0700315 return TRUE;
316}
317
Alex Deymo5fdf7762013-07-17 20:01:40 -0700318gboolean update_engine_service_set_p2p_update_permission(
319 UpdateEngineService* self,
320 gboolean enabled,
321 GError **error) {
322 chromeos_update_engine::PrefsInterface* prefs = self->system_state_->prefs();
323 chromeos_update_engine::P2PManager* p2p_manager =
324 self->system_state_->p2p_manager();
325
326 bool p2p_was_enabled = p2p_manager && p2p_manager->IsP2PEnabled();
327
328 if (!prefs->SetBoolean(chromeos_update_engine::kPrefsP2PEnabled, enabled)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800329 log_and_set_response_error(
330 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
331 string("Error setting the update over cellular to ") +
332 (enabled ? "true." : "false."));
Alex Deymo5fdf7762013-07-17 20:01:40 -0700333 return FALSE;
334 }
335
336 // If P2P is being effectively disabled (IsP2PEnabled() reports the change)
337 // then we need to shutdown the service.
338 if (p2p_was_enabled && !p2p_manager->IsP2PEnabled())
339 p2p_manager->EnsureP2PNotRunning();
340
341 return TRUE;
342}
343
344gboolean update_engine_service_get_p2p_update_permission(
345 UpdateEngineService* self,
346 gboolean* enabled,
347 GError **error) {
348 chromeos_update_engine::PrefsInterface* prefs = self->system_state_->prefs();
349
350 // The default for not present setting is false.
351 if (!prefs->Exists(chromeos_update_engine::kPrefsP2PEnabled)) {
352 *enabled = false;
353 return TRUE;
354 }
355
356 bool p2p_pref = false;
357 if (!prefs->GetBoolean(chromeos_update_engine::kPrefsP2PEnabled, &p2p_pref)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800358 log_and_set_response_error(error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
359 "Error getting the P2PEnabled setting.");
Alex Deymo5fdf7762013-07-17 20:01:40 -0700360 return FALSE;
361 }
362
363 *enabled = p2p_pref;
364 return TRUE;
365}
366
Alex Deymof4867c42013-06-28 14:41:39 -0700367gboolean update_engine_service_set_update_over_cellular_permission(
368 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700369 gboolean allowed,
Alex Deymof4867c42013-06-28 14:41:39 -0700370 GError **error) {
371 set<string> allowed_types;
372 const policy::DevicePolicy* device_policy =
373 self->system_state_->device_policy();
374
375 // The device_policy is loaded in a lazy way before an update check. Load it
376 // now from the libchromeos cache if it wasn't already loaded.
377 if (!device_policy) {
378 chromeos_update_engine::UpdateAttempter* update_attempter =
379 self->system_state_->update_attempter();
380 if (update_attempter) {
381 update_attempter->RefreshDevicePolicy();
Chris Sosacb7fa882013-07-25 17:02:59 -0700382 device_policy = self->system_state_->device_policy();
Alex Deymof4867c42013-06-28 14:41:39 -0700383 }
384 }
385
386 // Check if this setting is allowed by the device policy.
387 if (device_policy &&
388 device_policy->GetAllowedConnectionTypesForUpdate(&allowed_types)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800389 log_and_set_response_error(
390 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
391 "Ignoring the update over cellular setting since there's "
392 "a device policy enforcing this setting.");
Alex Deymof4867c42013-06-28 14:41:39 -0700393 return FALSE;
394 }
395
396 // If the policy wasn't loaded yet, then it is still OK to change the local
397 // setting because the policy will be checked again during the update check.
398
399 chromeos_update_engine::PrefsInterface* prefs = self->system_state_->prefs();
400
Alex Deymoefb7c4c2013-07-09 14:34:00 -0700401 if (!prefs->SetBoolean(
Alex Deymof4867c42013-06-28 14:41:39 -0700402 chromeos_update_engine::kPrefsUpdateOverCellularPermission,
Alex Deymoefb7c4c2013-07-09 14:34:00 -0700403 allowed)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800404 log_and_set_response_error(
405 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
406 string("Error setting the update over cellular to ") +
407 (allowed ? "true" : "false"));
Alex Deymof4867c42013-06-28 14:41:39 -0700408 return FALSE;
409 }
410
411 return TRUE;
412}
413
414gboolean update_engine_service_get_update_over_cellular_permission(
415 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700416 gboolean* allowed,
Don Garrettbb26fc82013-11-15 10:40:17 -0800417 GError **error) {
Alex Deymof4867c42013-06-28 14:41:39 -0700418 chromeos_update_engine::ConnectionManager* cm =
419 self->system_state_->connection_manager();
420
421 // The device_policy is loaded in a lazy way before an update check and is
422 // used to determine if an update is allowed over cellular. Load the device
423 // policy now from the libchromeos cache if it wasn't already loaded.
424 if (!self->system_state_->device_policy()) {
425 chromeos_update_engine::UpdateAttempter* update_attempter =
426 self->system_state_->update_attempter();
427 if (update_attempter)
428 update_attempter->RefreshDevicePolicy();
429 }
430
431 // Return the current setting based on the same logic used while checking for
432 // updates. A log message could be printed as the result of this test.
433 LOG(INFO) << "Checking if updates over cellular networks are allowed:";
434 *allowed = cm->IsUpdateAllowedOver(chromeos_update_engine::kNetCellular);
435
436 return TRUE;
437}
438
David Zeuthen3c55abd2013-10-14 12:48:03 -0700439gboolean update_engine_service_get_duration_since_update(
440 UpdateEngineService* self,
441 gint64* out_usec_wallclock,
Don Garrettbb26fc82013-11-15 10:40:17 -0800442 GError **error) {
David Zeuthen3c55abd2013-10-14 12:48:03 -0700443
444 base::Time time;
Don Garrettbb26fc82013-11-15 10:40:17 -0800445 if (!self->system_state_->update_attempter()->GetBootTimeAtUpdate(&time)) {
446 log_and_set_response_error(error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
447 "No pending update.");
David Zeuthen3c55abd2013-10-14 12:48:03 -0700448 return FALSE;
Don Garrettbb26fc82013-11-15 10:40:17 -0800449 }
David Zeuthen3c55abd2013-10-14 12:48:03 -0700450
451 chromeos_update_engine::ClockInterface *clock = self->system_state_->clock();
452 *out_usec_wallclock = (clock->GetBootTime() - time).InMicroseconds();
453 return TRUE;
454}
455
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700456gboolean update_engine_service_emit_status_update(
457 UpdateEngineService* self,
458 gint64 last_checked_time,
459 gdouble progress,
460 const gchar* current_operation,
461 const gchar* new_version,
462 gint64 new_size) {
463 g_signal_emit(self,
464 status_update_signal,
465 0,
466 last_checked_time,
467 progress,
468 current_operation,
469 new_version,
470 new_size);
471 return TRUE;
472}