autoupdate: Return response with client's app ID
Currently in autoupdate we sent a default hard coded app ID to the
client. However, this is not the bahvior of omaha, as omaha always, reply with
the same app ID requested by the user. This CL, modifes this bahavior in
autoupdate to return the app ID associated with the client's request.
BUG=chromium:821514
TEST=cros flash
Change-Id: I7cd36c8e7ed6e36bed257a5373e62483136b585e
Reviewed-on: https://chromium-review.googlesource.com/961585
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index ca5dd1e..34fc4bb 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -874,6 +874,7 @@
# Parse the XML we got into the components we care about.
protocol, app, event, update_check = autoupdate_lib.ParseUpdateRequest(data)
+ appid = app.getAttribute('appid')
# Process attributes of the update check.
request_attrs = self._ProcessUpdateComponents(app, event)
@@ -892,7 +893,7 @@
self.max_updates -= 1
_Log('A non-update event notification received. Returning an ack.')
- return autoupdate_lib.GetEventResponse(protocol)
+ return autoupdate_lib.GetEventResponse(protocol, appid)
if request_attrs.forced_update_label:
if label:
@@ -906,7 +907,7 @@
# update requests from the same client due to a timeout.
if self.max_updates == 0:
_Log('Request received but max number of updates already served.')
- return autoupdate_lib.GetNoUpdateResponse(protocol)
+ return autoupdate_lib.GetNoUpdateResponse(protocol, appid)
_Log('Update Check Received. Client is using protocol version: %s',
protocol)
@@ -943,7 +944,7 @@
except AutoupdateError as e:
# Raised if we fail to generate an update payload.
_Log('Failed to process an update: %r', e)
- return autoupdate_lib.GetNoUpdateResponse(protocol)
+ return autoupdate_lib.GetNoUpdateResponse(protocol, appid)
# Sign the metadata hash, if requested.
signed_metadata_hash = None
@@ -960,7 +961,8 @@
update_response = autoupdate_lib.GetUpdateResponse(
metadata_obj.sha1, metadata_obj.sha256, metadata_obj.size, url,
metadata_obj.is_delta_format, metadata_obj.metadata_size,
- signed_metadata_hash, public_key_data, protocol, self.critical_update)
+ signed_metadata_hash, public_key_data, protocol, appid,
+ self.critical_update)
_Log('Responding to client to use url %s to get image', url)
return update_response