blob: f75823cb58c1022e5f6e072ceb0bc332c1aa08dd [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"
Darin Petkov49d91322010-10-25 16:34:58 -070017#include "update_engine/omaha_request_params.h"
Alex Deymo5fdf7762013-07-17 20:01:40 -070018#include "update_engine/p2p_manager.h"
Alex Deymof4867c42013-06-28 14:41:39 -070019#include "update_engine/prefs.h"
J. Richard Barnette056b0ab2013-10-29 15:24:56 -070020#include "update_engine/update_attempter.h"
Darin Petkova07586b2010-10-20 13:41:15 -070021#include "update_engine/utils.h"
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070022
Alex Deymof4867c42013-06-28 14:41:39 -070023using std::set;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070024using std::string;
David Zeuthen75a4c3e2013-09-06 11:36:59 -070025using chromeos_update_engine::AttemptUpdateFlags;
26using chromeos_update_engine::kAttemptUpdateFlagNonInteractive;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070027
Don Garrettbb26fc82013-11-15 10:40:17 -080028#define UPDATE_ENGINE_SERVICE_ERROR update_engine_service_error_quark ()
29#define UPDATE_ENGINE_SERVICE_TYPE_ERROR \
30 (update_engine_service_error_get_type())
31
32typedef enum
33{
34 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
35 UPDATE_ENGINE_SERVICE_NUM_ERRORS
36} UpdateEngineServiceError;
37
38static GQuark update_engine_service_error_quark(void) {
39 static GQuark ret = 0;
40
41 if (ret == 0)
42 ret = g_quark_from_static_string("update_engine_service_error");
43
44 return ret;
45}
46
47#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
48
49static GType update_engine_service_error_get_type(void) {
50 static GType etype = 0;
51
52 if (etype == 0) {
53 static const GEnumValue values[] = {
54 ENUM_ENTRY(UPDATE_ENGINE_SERVICE_ERROR_FAILED, "Failed"),
55 { 0, 0, 0 }
56 };
57 G_STATIC_ASSERT(UPDATE_ENGINE_SERVICE_NUM_ERRORS ==
58 G_N_ELEMENTS (values) - 1);
59 etype = g_enum_register_static("UpdateEngineServiceError", values);
60 }
61
62 return etype;
63}
64
Darin Petkov820a77b2011-04-27 16:48:58 -070065static const char kAUTestURLRequest[] = "autest";
Jay Srinivasane73acab2012-07-10 14:34:03 -070066// By default autest bypasses scattering. If we want to test scattering,
67// we should use autest-scheduled. The Url used is same in both cases, but
68// different params are passed to CheckForUpdate method.
69static const char kScheduledAUTestURLRequest[] = "autest-scheduled";
70
Darin Petkov820a77b2011-04-27 16:48:58 -070071static const char kAUTestURL[] =
Darin Petkov5445e162011-11-04 10:10:27 +010072 "https://omaha.sandbox.google.com/service/update2";
Darin Petkov820a77b2011-04-27 16:48:58 -070073
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070074G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT)
75
76static void update_engine_service_finalize(GObject* object) {
77 G_OBJECT_CLASS(update_engine_service_parent_class)->finalize(object);
78}
79
Don Garrettbb26fc82013-11-15 10:40:17 -080080static void log_and_set_response_error(GError** error,
81 UpdateEngineServiceError error_code,
82 const string& reason) {
83 LOG(ERROR) << "Sending DBus Failure: " << reason;
84 g_set_error_literal(error, UPDATE_ENGINE_SERVICE_ERROR,
85 error_code, reason.c_str());
86}
87
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070088static guint status_update_signal = 0;
89
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070090static void update_engine_service_class_init(UpdateEngineServiceClass* klass) {
91 GObjectClass *object_class;
92 object_class = G_OBJECT_CLASS(klass);
93 object_class->finalize = update_engine_service_finalize;
Darin Petkov5a7f5652010-07-22 21:40:09 -070094
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070095 status_update_signal = g_signal_new(
96 "status_update",
97 G_OBJECT_CLASS_TYPE(klass),
98 G_SIGNAL_RUN_LAST,
99 0, // 0 == no class method associated
100 NULL, // Accumulator
101 NULL, // Accumulator data
Alex Deymo3d41c4d2014-02-13 23:26:33 -0800102 NULL, // Marshaller
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700103 G_TYPE_NONE, // Return type
104 5, // param count:
105 G_TYPE_INT64,
106 G_TYPE_DOUBLE,
107 G_TYPE_STRING,
108 G_TYPE_STRING,
109 G_TYPE_INT64);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700110}
111
112static void update_engine_service_init(UpdateEngineService* object) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800113 dbus_g_error_domain_register (UPDATE_ENGINE_SERVICE_ERROR,
114 "org.chromium.UpdateEngine.Error",
115 UPDATE_ENGINE_SERVICE_TYPE_ERROR);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700116}
117
118UpdateEngineService* update_engine_service_new(void) {
119 return reinterpret_cast<UpdateEngineService*>(
120 g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL));
121}
122
Darin Petkov296889c2010-07-23 16:20:54 -0700123gboolean update_engine_service_attempt_update(UpdateEngineService* self,
124 gchar* app_version,
125 gchar* omaha_url,
126 GError **error) {
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700127 return update_engine_service_attempt_update_with_flags(self,
128 app_version,
129 omaha_url,
130 0, // No flags set.
131 error);
132}
133
134gboolean update_engine_service_attempt_update_with_flags(
135 UpdateEngineService* self,
136 gchar* app_version,
137 gchar* omaha_url,
138 gint flags_as_int,
139 GError **error) {
Darin Petkova07586b2010-10-20 13:41:15 -0700140 string update_app_version;
141 string update_omaha_url;
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700142 AttemptUpdateFlags flags = static_cast<AttemptUpdateFlags>(flags_as_int);
Gilad Arnoldb92f0df2013-01-10 16:32:45 -0800143 bool interactive = true;
Jay Srinivasane73acab2012-07-10 14:34:03 -0700144
Darin Petkova07586b2010-10-20 13:41:15 -0700145 // Only non-official (e.g., dev and test) builds can override the current
Darin Petkov820a77b2011-04-27 16:48:58 -0700146 // version and update server URL over D-Bus. However, pointing to the
147 // hardcoded test update server URL is always allowed.
J. Richard Barnette056b0ab2013-10-29 15:24:56 -0700148 if (!self->system_state_->hardware()->IsOfficialBuild()) {
Darin Petkova07586b2010-10-20 13:41:15 -0700149 if (app_version) {
150 update_app_version = app_version;
151 }
152 if (omaha_url) {
153 update_omaha_url = omaha_url;
154 }
155 }
Jay Srinivasane73acab2012-07-10 14:34:03 -0700156 if (omaha_url) {
157 if (strcmp(omaha_url, kScheduledAUTestURLRequest) == 0) {
158 update_omaha_url = kAUTestURL;
159 // pretend that it's not user-initiated even though it is,
160 // so as to test scattering logic, etc. which get kicked off
161 // only in scheduled update checks.
Gilad Arnoldb92f0df2013-01-10 16:32:45 -0800162 interactive = false;
Jay Srinivasane73acab2012-07-10 14:34:03 -0700163 } else if (strcmp(omaha_url, kAUTestURLRequest) == 0) {
164 update_omaha_url = kAUTestURL;
165 }
Darin Petkov820a77b2011-04-27 16:48:58 -0700166 }
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700167 if (flags & kAttemptUpdateFlagNonInteractive)
168 interactive = false;
Darin Petkov296889c2010-07-23 16:20:54 -0700169 LOG(INFO) << "Attempt update: app_version=\"" << update_app_version << "\" "
Jay Srinivasane73acab2012-07-10 14:34:03 -0700170 << "omaha_url=\"" << update_omaha_url << "\" "
David Zeuthen75a4c3e2013-09-06 11:36:59 -0700171 << "flags=0x" << std::hex << flags << " "
Gilad Arnoldb92f0df2013-01-10 16:32:45 -0800172 << "interactive=" << (interactive? "yes" : "no");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700173 self->system_state_->update_attempter()->CheckForUpdate(update_app_version,
174 update_omaha_url,
175 interactive);
Darin Petkov296889c2010-07-23 16:20:54 -0700176 return TRUE;
177}
178
Chris Sosad317e402013-06-12 13:47:09 -0700179gboolean update_engine_service_attempt_rollback(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700180 gboolean powerwash,
Chris Sosad317e402013-06-12 13:47:09 -0700181 GError **error) {
182 LOG(INFO) << "Attempting rollback to non-active partitions.";
Don Garrettbb26fc82013-11-15 10:40:17 -0800183
184 if (!self->system_state_->update_attempter()->Rollback(powerwash, NULL)) {
185 // TODO(dgarrett): Give a more specific error code/reason.
186 log_and_set_response_error(error,
187 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
188 "Rollback attempt failed.");
189 return FALSE;
190 }
191
192 return TRUE;
Chris Sosad317e402013-06-12 13:47:09 -0700193}
194
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -0700195gboolean update_engine_service_reset_status(UpdateEngineService* self,
196 GError **error) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800197 if (!self->system_state_->update_attempter()->ResetStatus()) {
198 // TODO(dgarrett): Give a more specific error code/reason.
199 log_and_set_response_error(error,
200 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
201 "ResetStatus failed.");
202 return FALSE;
203 }
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -0700204
Don Garrettbb26fc82013-11-15 10:40:17 -0800205 return TRUE;
206}
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -0700207
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700208gboolean update_engine_service_get_status(UpdateEngineService* self,
209 int64_t* last_checked_time,
210 double* progress,
211 gchar** current_operation,
212 gchar** new_version,
213 int64_t* new_size,
214 GError **error) {
215 string current_op;
216 string new_version_str;
Darin Petkov5a7f5652010-07-22 21:40:09 -0700217
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700218 CHECK(self->system_state_->update_attempter()->GetStatus(last_checked_time,
219 progress,
220 &current_op,
221 &new_version_str,
222 new_size));
Satoru Takabayashid6982312010-11-29 12:54:12 +0900223 *current_operation = g_strdup(current_op.c_str());
224 *new_version = g_strdup(new_version_str.c_str());
Don Garrettbb26fc82013-11-15 10:40:17 -0800225
226 if (!*current_operation) {
227 log_and_set_response_error(error,
228 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
229 "Unable to find current_operation.");
Chris Masonec6c57a52010-09-23 13:06:14 -0700230 return FALSE;
231 }
Don Garrettbb26fc82013-11-15 10:40:17 -0800232
233 if (!*new_version) {
234 log_and_set_response_error(error,
235 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
236 "Unable to find vew_version.");
237 return FALSE;
238 }
239
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700240 return TRUE;
241}
242
Darin Petkov296889c2010-07-23 16:20:54 -0700243gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700244 GError **error) {
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700245 if (!self->system_state_->update_attempter()->RebootIfNeeded()) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800246 // TODO(dgarrett): Give a more specific error code/reason.
247 log_and_set_response_error(error,
248 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
249 "Reboot not needed, or attempt failed.");
Darin Petkov296889c2010-07-23 16:20:54 -0700250 return FALSE;
251 }
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700252 return TRUE;
253}
254
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700255gboolean update_engine_service_set_channel(UpdateEngineService* self,
256 gchar* target_channel,
Alex Deymoad923732013-08-29 16:13:49 -0700257 gboolean is_powerwash_allowed,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700258 GError **error) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800259 if (!target_channel) {
260 log_and_set_response_error(error,
261 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
262 "Target channel to set not specified.");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700263 return FALSE;
Don Garrettbb26fc82013-11-15 10:40:17 -0800264 }
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700265
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700266 const policy::DevicePolicy* device_policy =
267 self->system_state_->device_policy();
Chris Sosacb7fa882013-07-25 17:02:59 -0700268
269 // The device_policy is loaded in a lazy way before an update check. Load it
270 // now from the libchromeos cache if it wasn't already loaded.
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700271 if (!device_policy) {
Chris Sosacb7fa882013-07-25 17:02:59 -0700272 chromeos_update_engine::UpdateAttempter* update_attempter =
273 self->system_state_->update_attempter();
274 if (update_attempter) {
275 update_attempter->RefreshDevicePolicy();
276 device_policy = self->system_state_->device_policy();
277 }
Darin Petkov8daa3242010-10-25 13:28:47 -0700278 }
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700279
280 bool delegated = false;
Chris Sosacb7fa882013-07-25 17:02:59 -0700281 if (device_policy &&
282 device_policy->GetReleaseChannelDelegated(&delegated) && !delegated) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800283 log_and_set_response_error(
284 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
285 "Cannot set target channel explicitly when channel "
286 "policy/settings is not delegated");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700287 return FALSE;
288 }
289
290 LOG(INFO) << "Setting destination channel to: " << target_channel;
291 if (!self->system_state_->request_params()->SetTargetChannel(
292 target_channel, is_powerwash_allowed)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800293 // TODO(dgarrett): Give a more specific error code/reason.
294 log_and_set_response_error(error,
295 UPDATE_ENGINE_SERVICE_ERROR_FAILED,
296 "Setting channel failed.");
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700297 return FALSE;
298 }
299
300 return TRUE;
301}
302
303gboolean update_engine_service_get_channel(UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700304 gboolean get_current_channel,
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700305 gchar** channel,
306 GError **error) {
307 chromeos_update_engine::OmahaRequestParams* rp =
308 self->system_state_->request_params();
309
310 string channel_str = get_current_channel ?
311 rp->current_channel() : rp->target_channel();
312
313 *channel = g_strdup(channel_str.c_str());
Darin Petkov8daa3242010-10-25 13:28:47 -0700314 return TRUE;
315}
316
Alex Deymo5fdf7762013-07-17 20:01:40 -0700317gboolean update_engine_service_set_p2p_update_permission(
318 UpdateEngineService* self,
319 gboolean enabled,
320 GError **error) {
321 chromeos_update_engine::PrefsInterface* prefs = self->system_state_->prefs();
322 chromeos_update_engine::P2PManager* p2p_manager =
323 self->system_state_->p2p_manager();
324
325 bool p2p_was_enabled = p2p_manager && p2p_manager->IsP2PEnabled();
326
327 if (!prefs->SetBoolean(chromeos_update_engine::kPrefsP2PEnabled, enabled)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800328 log_and_set_response_error(
329 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
330 string("Error setting the update over cellular to ") +
331 (enabled ? "true." : "false."));
Alex Deymo5fdf7762013-07-17 20:01:40 -0700332 return FALSE;
333 }
334
335 // If P2P is being effectively disabled (IsP2PEnabled() reports the change)
336 // then we need to shutdown the service.
337 if (p2p_was_enabled && !p2p_manager->IsP2PEnabled())
338 p2p_manager->EnsureP2PNotRunning();
339
340 return TRUE;
341}
342
343gboolean update_engine_service_get_p2p_update_permission(
344 UpdateEngineService* self,
345 gboolean* enabled,
346 GError **error) {
347 chromeos_update_engine::PrefsInterface* prefs = self->system_state_->prefs();
348
349 // The default for not present setting is false.
350 if (!prefs->Exists(chromeos_update_engine::kPrefsP2PEnabled)) {
351 *enabled = false;
352 return TRUE;
353 }
354
355 bool p2p_pref = false;
356 if (!prefs->GetBoolean(chromeos_update_engine::kPrefsP2PEnabled, &p2p_pref)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800357 log_and_set_response_error(error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
358 "Error getting the P2PEnabled setting.");
Alex Deymo5fdf7762013-07-17 20:01:40 -0700359 return FALSE;
360 }
361
362 *enabled = p2p_pref;
363 return TRUE;
364}
365
Alex Deymof4867c42013-06-28 14:41:39 -0700366gboolean update_engine_service_set_update_over_cellular_permission(
367 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700368 gboolean allowed,
Alex Deymof4867c42013-06-28 14:41:39 -0700369 GError **error) {
370 set<string> allowed_types;
371 const policy::DevicePolicy* device_policy =
372 self->system_state_->device_policy();
373
374 // The device_policy is loaded in a lazy way before an update check. Load it
375 // now from the libchromeos cache if it wasn't already loaded.
376 if (!device_policy) {
377 chromeos_update_engine::UpdateAttempter* update_attempter =
378 self->system_state_->update_attempter();
379 if (update_attempter) {
380 update_attempter->RefreshDevicePolicy();
Chris Sosacb7fa882013-07-25 17:02:59 -0700381 device_policy = self->system_state_->device_policy();
Alex Deymof4867c42013-06-28 14:41:39 -0700382 }
383 }
384
385 // Check if this setting is allowed by the device policy.
386 if (device_policy &&
387 device_policy->GetAllowedConnectionTypesForUpdate(&allowed_types)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800388 log_and_set_response_error(
389 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
390 "Ignoring the update over cellular setting since there's "
391 "a device policy enforcing this setting.");
Alex Deymof4867c42013-06-28 14:41:39 -0700392 return FALSE;
393 }
394
395 // If the policy wasn't loaded yet, then it is still OK to change the local
396 // setting because the policy will be checked again during the update check.
397
398 chromeos_update_engine::PrefsInterface* prefs = self->system_state_->prefs();
399
Alex Deymoefb7c4c2013-07-09 14:34:00 -0700400 if (!prefs->SetBoolean(
Alex Deymof4867c42013-06-28 14:41:39 -0700401 chromeos_update_engine::kPrefsUpdateOverCellularPermission,
Alex Deymoefb7c4c2013-07-09 14:34:00 -0700402 allowed)) {
Don Garrettbb26fc82013-11-15 10:40:17 -0800403 log_and_set_response_error(
404 error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
405 string("Error setting the update over cellular to ") +
406 (allowed ? "true" : "false"));
Alex Deymof4867c42013-06-28 14:41:39 -0700407 return FALSE;
408 }
409
410 return TRUE;
411}
412
413gboolean update_engine_service_get_update_over_cellular_permission(
414 UpdateEngineService* self,
Alex Deymoad923732013-08-29 16:13:49 -0700415 gboolean* allowed,
Don Garrettbb26fc82013-11-15 10:40:17 -0800416 GError **error) {
Alex Deymof4867c42013-06-28 14:41:39 -0700417 chromeos_update_engine::ConnectionManager* cm =
418 self->system_state_->connection_manager();
419
420 // The device_policy is loaded in a lazy way before an update check and is
421 // used to determine if an update is allowed over cellular. Load the device
422 // policy now from the libchromeos cache if it wasn't already loaded.
423 if (!self->system_state_->device_policy()) {
424 chromeos_update_engine::UpdateAttempter* update_attempter =
425 self->system_state_->update_attempter();
426 if (update_attempter)
427 update_attempter->RefreshDevicePolicy();
428 }
429
430 // Return the current setting based on the same logic used while checking for
431 // updates. A log message could be printed as the result of this test.
432 LOG(INFO) << "Checking if updates over cellular networks are allowed:";
433 *allowed = cm->IsUpdateAllowedOver(chromeos_update_engine::kNetCellular);
434
435 return TRUE;
436}
437
David Zeuthen3c55abd2013-10-14 12:48:03 -0700438gboolean update_engine_service_get_duration_since_update(
439 UpdateEngineService* self,
440 gint64* out_usec_wallclock,
Don Garrettbb26fc82013-11-15 10:40:17 -0800441 GError **error) {
David Zeuthen3c55abd2013-10-14 12:48:03 -0700442
443 base::Time time;
Don Garrettbb26fc82013-11-15 10:40:17 -0800444 if (!self->system_state_->update_attempter()->GetBootTimeAtUpdate(&time)) {
445 log_and_set_response_error(error, UPDATE_ENGINE_SERVICE_ERROR_FAILED,
446 "No pending update.");
David Zeuthen3c55abd2013-10-14 12:48:03 -0700447 return FALSE;
Don Garrettbb26fc82013-11-15 10:40:17 -0800448 }
David Zeuthen3c55abd2013-10-14 12:48:03 -0700449
450 chromeos_update_engine::ClockInterface *clock = self->system_state_->clock();
451 *out_usec_wallclock = (clock->GetBootTime() - time).InMicroseconds();
452 return TRUE;
453}
454
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700455gboolean update_engine_service_emit_status_update(
456 UpdateEngineService* self,
457 gint64 last_checked_time,
458 gdouble progress,
459 const gchar* current_operation,
460 const gchar* new_version,
461 gint64 new_size) {
462 g_signal_emit(self,
463 status_update_signal,
464 0,
465 last_checked_time,
466 progress,
467 current_operation,
468 new_version,
469 new_size);
470 return TRUE;
471}