buffet: Add support for DEVICE_DELETED XMPP notification
When DEVICE_DELETED notification is received over XMPP channel,
buffet will remove any cloud registration information (credentials,
robot account) and close server connections (XMPP channel, etc).
BUG=brillo:1215
TEST=`FEATURES=test emerge-link buffet`
Test manually on the device.
Change-Id: I86e19659b9fbc06685bcabb6c659a633e797cae5
Reviewed-on: https://chromium-review.googlesource.com/281666
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/device_registration_info.cc b/buffet/device_registration_info.cc
index b76c79e..f1c84b8 100644
--- a/buffet/device_registration_info.cc
+++ b/buffet/device_registration_info.cc
@@ -1037,6 +1037,15 @@
base::Bind(&IgnoreCloudError));
}
+void DeviceRegistrationInfo::OnDeviceDeleted(const std::string& device_id) {
+ if (device_id != config_->device_id()) {
+ LOG(WARNING) << "Unexpected device deletion notification for device ID '"
+ << device_id << "'";
+ return;
+ }
+ MarkDeviceUnregistered();
+}
+
void DeviceRegistrationInfo::MarkDeviceUnregistered() {
if (!HaveRegistrationCredentials())
return;