diff options
author | Amin Hassani <ahassani@chromium.org> | 2019-06-21 17:43:32 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-06-28 21:50:21 -0700 |
commit | c80d2d8867d9ef659b5bdad5b66f77f58a1af2e4 (patch) | |
tree | fe46c559ef9d214cb9d4732876f09fc17dd388f5 | |
parent | 0787497df1ee8c7b89c5f326630fa6180184b9ba (diff) |
update_engine: Remove brillo binder library
Brillo binder library is not used anymor. Neither in Chrome OS nor
Android. This CL deprecates it.
BUG=chromium:978672
TEST=unittest
Change-Id: I45cbff7561ffd8d24b94782676695e00a131c451
Reviewed-on: https://chromium-review.googlesource.com/1672023
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
-rw-r--r-- | Android.bp | 40 | ||||
-rw-r--r-- | BUILD.gn | 1 | ||||
-rw-r--r-- | binder_bindings/android/brillo/IUpdateEngine.aidl | 46 | ||||
-rw-r--r-- | binder_bindings/android/brillo/IUpdateEngineStatusCallback.aidl | 24 | ||||
-rw-r--r-- | binder_bindings/android/brillo/ParcelableUpdateEngineStatus.aidl | 20 | ||||
-rw-r--r-- | client_library/client.cc | 46 | ||||
-rw-r--r-- | client_library/client_binder.cc | 264 | ||||
-rw-r--r-- | client_library/client_binder.h | 117 | ||||
-rw-r--r-- | client_library/client_dbus.cc | 12 | ||||
-rw-r--r-- | parcelable_update_engine_status.cc | 122 | ||||
-rw-r--r-- | parcelable_update_engine_status.h | 63 | ||||
-rw-r--r-- | parcelable_update_engine_status_unittest.cc | 92 |
12 files changed, 12 insertions, 835 deletions
@@ -369,46 +369,6 @@ cc_binary { required: ["android.hardware.boot@1.0-impl-wrapper.recovery"], } -// libupdate_engine_client (type: shared_library) -// ======================================================== -cc_library_shared { - name: "libupdate_engine_client", - - cflags: [ - "-Wall", - "-Werror", - "-Wno-unused-parameter", - "-DUSE_BINDER=1", - ], - export_include_dirs: ["client_library/include"], - include_dirs: [ - // TODO(deymo): Remove "external/cros/system_api/dbus" when dbus is not used. - "external/cros/system_api/dbus", - "system", - ], - - aidl: { - local_include_dirs: ["binder_bindings"], - }, - - shared_libs: [ - "libchrome", - "libbrillo", - "libbinder", - "libbrillo-binder", - "libutils", - ], - - srcs: [ - "binder_bindings/android/brillo/IUpdateEngine.aidl", - "binder_bindings/android/brillo/IUpdateEngineStatusCallback.aidl", - "client_library/client.cc", - "client_library/client_binder.cc", - "parcelable_update_engine_status.cc", - "update_status_utils.cc", - ], -} - // update_engine_client (type: executable) // ======================================================== // update_engine console client. @@ -299,7 +299,6 @@ executable("update_engine") { # update_engine client library. static_library("libupdate_engine_client") { sources = [ - "client_library/client.cc", "client_library/client_dbus.cc", "update_status_utils.cc", ] diff --git a/binder_bindings/android/brillo/IUpdateEngine.aidl b/binder_bindings/android/brillo/IUpdateEngine.aidl deleted file mode 100644 index 56e15246..00000000 --- a/binder_bindings/android/brillo/IUpdateEngine.aidl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.brillo; - -import android.brillo.IUpdateEngineStatusCallback; -import android.brillo.ParcelableUpdateEngineStatus; - -interface IUpdateEngine { - void SetUpdateAttemptFlags(in int flags); - boolean AttemptUpdate(in String app_version, in String omaha_url, in int flags); - void AttemptRollback(in boolean powerwash); - boolean CanRollback(); - void ResetStatus(); - ParcelableUpdateEngineStatus GetStatus(); - void RebootIfNeeded(); - void SetChannel(in String target_channel, in boolean powewash); - String GetChannel(in boolean get_current_channel); - void SetCohortHint(in String cohort_hint); - String GetCohortHint(); - void SetP2PUpdatePermission(in boolean enabled); - boolean GetP2PUpdatePermission(); - void SetUpdateOverCellularPermission(in boolean enabled); - void SetUpdateOverCellularTarget(in String target_version, - in long target_size); - boolean GetUpdateOverCellularPermission(); - long GetDurationSinceUpdate(); - String GetPrevVersion(); - String GetRollbackPartition(); - void RegisterStatusCallback(in IUpdateEngineStatusCallback callback); - int GetLastAttemptError(); - int GetEolStatus(); -} diff --git a/binder_bindings/android/brillo/IUpdateEngineStatusCallback.aidl b/binder_bindings/android/brillo/IUpdateEngineStatusCallback.aidl deleted file mode 100644 index 837d44d5..00000000 --- a/binder_bindings/android/brillo/IUpdateEngineStatusCallback.aidl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.brillo; - -import android.brillo.ParcelableUpdateEngineStatus; - -interface IUpdateEngineStatusCallback { - oneway - void HandleStatusUpdate(in ParcelableUpdateEngineStatus status); -} diff --git a/binder_bindings/android/brillo/ParcelableUpdateEngineStatus.aidl b/binder_bindings/android/brillo/ParcelableUpdateEngineStatus.aidl deleted file mode 100644 index fc10505b..00000000 --- a/binder_bindings/android/brillo/ParcelableUpdateEngineStatus.aidl +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.brillo; - -parcelable ParcelableUpdateEngineStatus cpp_header - "update_engine/parcelable_update_engine_status.h"; diff --git a/client_library/client.cc b/client_library/client.cc deleted file mode 100644 index b05df90b..00000000 --- a/client_library/client.cc +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (C) 2015 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "update_engine/client_library/include/update_engine/client.h" - -#include <memory> - -#if USE_BINDER -#include "update_engine/client_library/client_binder.h" -#else // !USE_BINDER -#include "update_engine/client_library/client_dbus.h" -#endif // USE_BINDER - -using std::unique_ptr; - -namespace update_engine { - -unique_ptr<UpdateEngineClient> UpdateEngineClient::CreateInstance() { -#if USE_BINDER - auto update_engine_client_impl = new internal::BinderUpdateEngineClient{}; -#else // !USE_BINDER - auto update_engine_client_impl = new internal::DBusUpdateEngineClient{}; -#endif // USE_BINDER - auto ret = unique_ptr<UpdateEngineClient>{update_engine_client_impl}; - - if (!update_engine_client_impl->Init()) { - ret.reset(); - } - - return ret; -} - -} // namespace update_engine diff --git a/client_library/client_binder.cc b/client_library/client_binder.cc deleted file mode 100644 index 588bc64b..00000000 --- a/client_library/client_binder.cc +++ /dev/null @@ -1,264 +0,0 @@ -// -// Copyright (C) 2015 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "update_engine/client_library/client_binder.h" - -#include <binder/IServiceManager.h> - -#include <base/message_loop/message_loop.h> -#include <utils/String8.h> - -#include "update_engine/common_service.h" -#include "update_engine/parcelable_update_engine_status.h" -#include "update_engine/update_status_utils.h" - -using android::getService; -using android::OK; -using android::String16; -using android::String8; -using android::binder::Status; -using android::brillo::ParcelableUpdateEngineStatus; -using chromeos_update_engine::StringToUpdateStatus; -using std::string; -using update_engine::UpdateAttemptFlags; - -namespace update_engine { -namespace internal { - -bool BinderUpdateEngineClient::Init() { - if (!binder_watcher_.Init()) - return false; - - return getService(String16{"android.brillo.UpdateEngineService"}, - &service_) == OK; -} - -bool BinderUpdateEngineClient::AttemptUpdate(const string& in_app_version, - const string& in_omaha_url, - bool at_user_request) { - bool started; - return service_ - ->AttemptUpdate( - String16{in_app_version.c_str()}, - String16{in_omaha_url.c_str()}, - at_user_request ? 0 : UpdateAttemptFlags::kFlagNonInteractive, - &started) - .isOk(); -} - -bool BinderUpdateEngineClient::AttemptInstall( - const string& omaha_url, const std::vector<string>& dlc_module_ids) { - return false; -} - -bool BinderUpdateEngineClient::GetStatus(int64_t* out_last_checked_time, - double* out_progress, - UpdateStatus* out_update_status, - string* out_new_version, - int64_t* out_new_size) const { - ParcelableUpdateEngineStatus status; - - if (!service_->GetStatus(&status).isOk()) - return false; - - *out_last_checked_time = status.last_checked_time_; - *out_progress = status.progress_; - StringToUpdateStatus(String8{status.current_operation_}.string(), - out_update_status); - *out_new_version = String8{status.new_version_}.string(); - *out_new_size = status.new_size_; - return true; -} - -bool BinderUpdateEngineClient::SetCohortHint(const string& in_cohort_hint) { - return service_->SetCohortHint(String16{in_cohort_hint.c_str()}).isOk(); -} - -bool BinderUpdateEngineClient::GetCohortHint(string* out_cohort_hint) const { - String16 out_as_string16; - - if (!service_->GetCohortHint(&out_as_string16).isOk()) - return false; - - *out_cohort_hint = String8{out_as_string16}.string(); - return true; -} - -bool BinderUpdateEngineClient::SetUpdateOverCellularPermission(bool allowed) { - return service_->SetUpdateOverCellularPermission(allowed).isOk(); -} - -bool BinderUpdateEngineClient::GetUpdateOverCellularPermission( - bool* allowed) const { - return service_->GetUpdateOverCellularPermission(allowed).isOk(); -} - -bool BinderUpdateEngineClient::SetP2PUpdatePermission(bool enabled) { - return service_->SetP2PUpdatePermission(enabled).isOk(); -} - -bool BinderUpdateEngineClient::GetP2PUpdatePermission(bool* enabled) const { - return service_->GetP2PUpdatePermission(enabled).isOk(); -} - -bool BinderUpdateEngineClient::Rollback(bool powerwash) { - return service_->AttemptRollback(powerwash).isOk(); -} - -bool BinderUpdateEngineClient::GetRollbackPartition( - string* rollback_partition) const { - String16 out_as_string16; - - if (!service_->GetRollbackPartition(&out_as_string16).isOk()) - return false; - - *rollback_partition = String8{out_as_string16}.string(); - return true; -} - -bool BinderUpdateEngineClient::GetPrevVersion(string* prev_version) const { - String16 out_as_string16; - - if (!service_->GetPrevVersion(&out_as_string16).isOk()) - return false; - - *prev_version = String8{out_as_string16}.string(); - return true; -} - -void BinderUpdateEngineClient::RebootIfNeeded() { - if (!service_->RebootIfNeeded().isOk()) { - // Reboot error code doesn't necessarily mean that a reboot - // failed. For example, D-Bus may be shutdown before we receive the - // result. - LOG(INFO) << "RebootIfNeeded() failure ignored."; - } -} - -bool BinderUpdateEngineClient::ResetStatus() { - return service_->ResetStatus().isOk(); -} - -Status BinderUpdateEngineClient::StatusUpdateCallback::HandleStatusUpdate( - const ParcelableUpdateEngineStatus& status) { - UpdateStatus update_status; - - StringToUpdateStatus(String8{status.current_operation_}.string(), - &update_status); - - for (auto& handler : client_->handlers_) { - handler->HandleStatusUpdate(status.last_checked_time_, - status.progress_, - update_status, - String8{status.new_version_}.string(), - status.new_size_); - } - - return Status::ok(); -} - -bool BinderUpdateEngineClient::RegisterStatusUpdateHandler( - StatusUpdateHandler* handler) { - if (!status_callback_.get()) { - status_callback_ = new BinderUpdateEngineClient::StatusUpdateCallback(this); - if (!service_->RegisterStatusCallback(status_callback_).isOk()) { - return false; - } - } - - handlers_.push_back(handler); - - int64_t last_checked_time; - double progress; - UpdateStatus update_status; - string new_version; - int64_t new_size; - - if (!GetStatus(&last_checked_time, - &progress, - &update_status, - &new_version, - &new_size)) { - handler->IPCError("Could not get status from binder service"); - } - - handler->HandleStatusUpdate( - last_checked_time, progress, update_status, new_version, new_size); - - return true; -} - -bool BinderUpdateEngineClient::UnregisterStatusUpdateHandler( - StatusUpdateHandler* handler) { - auto it = std::find(handlers_.begin(), handlers_.end(), handler); - if (it != handlers_.end()) { - handlers_.erase(it); - return true; - } - - return false; -} - -bool BinderUpdateEngineClient::SetTargetChannel(const string& in_target_channel, - bool allow_powerwash) { - return service_ - ->SetChannel(String16{in_target_channel.c_str()}, allow_powerwash) - .isOk(); -} - -bool BinderUpdateEngineClient::GetTargetChannel(string* out_channel) const { - String16 out_as_string16; - - if (!service_->GetChannel(false, &out_as_string16).isOk()) - return false; - - *out_channel = String8{out_as_string16}.string(); - return true; -} - -bool BinderUpdateEngineClient::GetChannel(string* out_channel) const { - String16 out_as_string16; - - if (!service_->GetChannel(true, &out_as_string16).isOk()) - return false; - - *out_channel = String8{out_as_string16}.string(); - return true; -} - -bool BinderUpdateEngineClient::GetLastAttemptError( - int32_t* last_attempt_error) const { - int out_as_int; - - if (!service_->GetLastAttemptError(&out_as_int).isOk()) - return false; - - *last_attempt_error = out_as_int; - return true; -} - -bool BinderUpdateEngineClient::GetEolStatus(int32_t* eol_status) const { - int out_as_int; - - if (!service_->GetEolStatus(&out_as_int).isOk()) - return false; - - *eol_status = out_as_int; - return true; -} - -} // namespace internal -} // namespace update_engine diff --git a/client_library/client_binder.h b/client_library/client_binder.h deleted file mode 100644 index f3e41026..00000000 --- a/client_library/client_binder.h +++ /dev/null @@ -1,117 +0,0 @@ -// -// Copyright (C) 2016 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_ -#define UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_ - -#include <cstdint> -#include <memory> -#include <string> -#include <vector> - -#include <base/macros.h> -#include <utils/String16.h> -#include <utils/StrongPointer.h> - -#include <brillo/binder_watcher.h> - -#include "android/brillo/BnUpdateEngineStatusCallback.h" -#include "android/brillo/IUpdateEngine.h" - -#include "update_engine/client_library/include/update_engine/client.h" - -namespace update_engine { -namespace internal { - -class BinderUpdateEngineClient : public UpdateEngineClient { - public: - BinderUpdateEngineClient() = default; - bool Init(); - - virtual ~BinderUpdateEngineClient() = default; - - bool AttemptUpdate(const std::string& app_version, - const std::string& omaha_url, - bool at_user_request) override; - - bool AttemptInstall(const std::string& omaha_url, - const std::vector<std::string>& dlc_module_ids) override; - - bool GetStatus(int64_t* out_last_checked_time, - double* out_progress, - UpdateStatus* out_update_status, - std::string* out_new_version, - int64_t* out_new_size) const override; - - bool SetCohortHint(const std::string& in_cohort_hint) override; - bool GetCohortHint(std::string* out_cohort_hint) const override; - - bool SetUpdateOverCellularPermission(bool allowed) override; - bool GetUpdateOverCellularPermission(bool* allowed) const override; - - bool SetP2PUpdatePermission(bool enabled) override; - bool GetP2PUpdatePermission(bool* enabled) const override; - - bool Rollback(bool powerwash) override; - - bool GetRollbackPartition(std::string* rollback_partition) const override; - - void RebootIfNeeded() override; - - bool GetPrevVersion(std::string* prev_version) const override; - - bool ResetStatus() override; - - bool SetTargetChannel(const std::string& target_channel, - bool allow_powerwash) override; - - bool GetTargetChannel(std::string* out_channel) const override; - - bool GetChannel(std::string* out_channel) const override; - - bool RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override; - bool UnregisterStatusUpdateHandler(StatusUpdateHandler* handler) override; - - bool GetLastAttemptError(int32_t* last_attempt_error) const override; - - bool GetEolStatus(int32_t* eol_status) const override; - - private: - class StatusUpdateCallback - : public android::brillo::BnUpdateEngineStatusCallback { - public: - explicit StatusUpdateCallback(BinderUpdateEngineClient* client) - : client_(client) {} - - android::binder::Status HandleStatusUpdate( - const android::brillo::ParcelableUpdateEngineStatus& status) override; - - private: - BinderUpdateEngineClient* client_; - }; - - android::sp<android::brillo::IUpdateEngine> service_; - android::sp<android::brillo::IUpdateEngineStatusCallback> status_callback_; - std::vector<update_engine::StatusUpdateHandler*> handlers_; - brillo::BinderWatcher binder_watcher_; - - DISALLOW_COPY_AND_ASSIGN(BinderUpdateEngineClient); -}; // class BinderUpdateEngineClient - -} // namespace internal -} // namespace update_engine - -#endif // UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_ diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc index 3ffb0886..809ad13a 100644 --- a/client_library/client_dbus.cc +++ b/client_library/client_dbus.cc @@ -18,6 +18,8 @@ #include <base/message_loop/message_loop.h> +#include <memory> + #include <dbus/bus.h> #include <dlcservice/proto_bindings/dlcservice.pb.h> #include <update_engine/dbus-constants.h> @@ -28,9 +30,19 @@ using chromeos_update_engine::StringToUpdateStatus; using dbus::Bus; using org::chromium::UpdateEngineInterfaceProxy; using std::string; +using std::unique_ptr; using std::vector; namespace update_engine { + +unique_ptr<UpdateEngineClient> UpdateEngineClient::CreateInstance() { + auto ret = std::make_unique<internal::DBusUpdateEngineClient>(); + if (!ret->Init()) { + ret.reset(); + } + return ret; +} + namespace internal { bool DBusUpdateEngineClient::Init() { diff --git a/parcelable_update_engine_status.cc b/parcelable_update_engine_status.cc deleted file mode 100644 index 8a2dbeba..00000000 --- a/parcelable_update_engine_status.cc +++ /dev/null @@ -1,122 +0,0 @@ -// -// Copyright (C) 2016 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "update_engine/parcelable_update_engine_status.h" -#include "update_engine/update_status_utils.h" - -#include <binder/Parcel.h> - -using update_engine::UpdateEngineStatus; - -namespace android { -namespace brillo { - -ParcelableUpdateEngineStatus::ParcelableUpdateEngineStatus( - const UpdateEngineStatus& status) - : last_checked_time_(status.last_checked_time), - current_operation_( - chromeos_update_engine::UpdateStatusToString(status.status)), - progress_(status.progress), - current_version_(String16{status.current_version.c_str()}), - current_system_version_(String16{status.current_system_version.c_str()}), - new_size_(status.new_size_bytes), - new_version_(String16{status.new_version.c_str()}), - new_system_version_(String16{status.new_system_version.c_str()}) {} - -status_t ParcelableUpdateEngineStatus::writeToParcel(Parcel* parcel) const { - status_t status; - - status = parcel->writeInt64(last_checked_time_); - if (status != OK) { - return status; - } - - status = parcel->writeString16(current_operation_); - if (status != OK) { - return status; - } - - status = parcel->writeDouble(progress_); - if (status != OK) { - return status; - } - - status = parcel->writeString16(current_version_); - if (status != OK) { - return status; - } - - status = parcel->writeString16(current_system_version_); - if (status != OK) { - return status; - } - - status = parcel->writeInt64(new_size_); - if (status != OK) { - return status; - } - - status = parcel->writeString16(new_version_); - if (status != OK) { - return status; - } - - return parcel->writeString16(new_system_version_); -} - -status_t ParcelableUpdateEngineStatus::readFromParcel(const Parcel* parcel) { - status_t status; - - status = parcel->readInt64(&last_checked_time_); - if (status != OK) { - return status; - } - - status = parcel->readString16(¤t_operation_); - if (status != OK) { - return status; - } - - status = parcel->readDouble(&progress_); - if (status != OK) { - return status; - } - - status = parcel->readString16(¤t_version_); - if (status != OK) { - return status; - } - - status = parcel->readString16(¤t_system_version_); - if (status != OK) { - return status; - } - - status = parcel->readInt64(&new_size_); - if (status != OK) { - return status; - } - - status = parcel->readString16(&new_version_); - if (status != OK) { - return status; - } - - return parcel->readString16(&new_system_version_); -} - -} // namespace brillo -} // namespace android diff --git a/parcelable_update_engine_status.h b/parcelable_update_engine_status.h deleted file mode 100644 index 3feac769..00000000 --- a/parcelable_update_engine_status.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// Copyright (C) 2016 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef UPDATE_ENGINE_PARCELABLE_UPDATE_ENGINE_STATUS_H_ -#define UPDATE_ENGINE_PARCELABLE_UPDATE_ENGINE_STATUS_H_ - -#include <binder/Parcelable.h> -#include <utils/String16.h> - -#include "update_engine/client_library/include/update_engine/update_status.h" - -namespace android { -namespace brillo { - -// Parcelable object containing the current status of update engine, to be sent -// over binder to clients from the server. -class ParcelableUpdateEngineStatus : public Parcelable { - public: - ParcelableUpdateEngineStatus() = default; - explicit ParcelableUpdateEngineStatus( - const update_engine::UpdateEngineStatus& status); - virtual ~ParcelableUpdateEngineStatus() = default; - - status_t writeToParcel(Parcel* parcel) const override; - status_t readFromParcel(const Parcel* parcel) override; - - // This list is kept in the Parcelable serialization order. - - // When the update_engine last checked for updates (seconds since unix Epoch) - int64_t last_checked_time_; - // The current status/operation of the update_engine. - android::String16 current_operation_; - // The current progress (0.0f-1.0f). - double progress_; - // The current product version. - android::String16 current_version_; - // The current system version. - android::String16 current_system_version_; - // The size of the update (bytes). This is int64_t for java compatibility. - int64_t new_size_; - // The new product version. - android::String16 new_version_; - // The new system version, if there is one (empty, otherwise). - android::String16 new_system_version_; -}; - -} // namespace brillo -} // namespace android - -#endif // UPDATE_ENGINE_PARCELABLE_UPDATE_ENGINE_STATUS_H_ diff --git a/parcelable_update_engine_status_unittest.cc b/parcelable_update_engine_status_unittest.cc deleted file mode 100644 index 20decb6b..00000000 --- a/parcelable_update_engine_status_unittest.cc +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (C) 2017 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "update_engine/parcelable_update_engine_status.h" -#include "update_engine/update_status_utils.h" - -#include <binder/Parcel.h> -#include <gtest/gtest.h> - -using android::Parcel; -using android::status_t; -using android::String16; -using android::brillo::ParcelableUpdateEngineStatus; -using update_engine::UpdateEngineStatus; -using update_engine::UpdateStatus; - -TEST(ParcelableUpdateEngineStatusTest, TestCreationFromUpdateEngineStatus) { - // This test creates an object and verifies that all the UpdateEngineStatus - // values are properly reflected in the Parcelable version of the class. - - UpdateEngineStatus ue_status = {123456789, - UpdateStatus::DOWNLOADING, - "0.1.2.3", - "1.2.3.4", - 0.5f, - 34567, - "2.3.4.5", - "3.4.5.6"}; - ParcelableUpdateEngineStatus parcelable_status(ue_status); - EXPECT_EQ(ue_status.last_checked_time, parcelable_status.last_checked_time_); - EXPECT_EQ( - String16{chromeos_update_engine::UpdateStatusToString(ue_status.status)}, - parcelable_status.current_operation_); - EXPECT_EQ(String16{ue_status.current_version.c_str()}, - parcelable_status.current_version_); - EXPECT_EQ(String16{ue_status.current_system_version.c_str()}, - parcelable_status.current_system_version_); - EXPECT_EQ(ue_status.progress, parcelable_status.progress_); - EXPECT_EQ(static_cast<int64_t>(ue_status.new_size_bytes), - parcelable_status.new_size_); - EXPECT_EQ(String16{ue_status.new_version.c_str()}, - parcelable_status.new_version_); - EXPECT_EQ(String16{ue_status.new_system_version.c_str()}, - parcelable_status.new_system_version_); -} - -TEST(ParcelableUpdateEngineStatusTest, TestParceling) { - // This tests the writeToParcel and readFromParcel methods for being correctly - // matched. - UpdateEngineStatus ue_status = {123456789, - UpdateStatus::DOWNLOADING, - "0.1.2.3", - "1.2.3.4", - 0.5f, - 34567, - "2.3.4.5", - "3.4.5.6"}; - ParcelableUpdateEngineStatus source_status(ue_status); - Parcel parcel_source, parcel_target; - status_t status = source_status.writeToParcel(&parcel_source); - EXPECT_EQ(::android::OK, status); - size_t parcel_len = parcel_source.dataSize(); - status = parcel_target.setData(parcel_source.data(), parcel_len); - EXPECT_EQ(::android::OK, status); - ParcelableUpdateEngineStatus target_status; - status = target_status.readFromParcel(&parcel_target); - EXPECT_EQ(::android::OK, status); - - EXPECT_EQ(source_status.last_checked_time_, target_status.last_checked_time_); - EXPECT_EQ(source_status.current_operation_, target_status.current_operation_); - EXPECT_EQ(source_status.current_version_, target_status.current_version_); - EXPECT_EQ(source_status.current_system_version_, - target_status.current_system_version_); - EXPECT_EQ(source_status.progress_, target_status.progress_); - EXPECT_EQ(source_status.new_size_, target_status.new_size_); - EXPECT_EQ(source_status.new_version_, target_status.new_version_); - EXPECT_EQ(source_status.new_system_version_, - target_status.new_system_version_); -} |