1a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin//
2a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// Copyright (C) 2015 The Android Open Source Project
3a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin//
4a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// Licensed under the Apache License, Version 2.0 (the "License");
5a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// you may not use this file except in compliance with the License.
6a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// You may obtain a copy of the License at
7a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin//
8a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin//      http://www.apache.org/licenses/LICENSE-2.0
9a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin//
10a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// Unless required by applicable law or agreed to in writing, software
11a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// distributed under the License is distributed on an "AS IS" BASIS,
12a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// See the License for the specific language governing permissions and
14a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin// limitations under the License.
15a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin//
16a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
17a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#include "update_engine/client_library/client_binder.h"
18a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
19a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#include <binder/IServiceManager.h>
20a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
21a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#include <base/message_loop/message_loop.h>
22a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#include <utils/String8.h>
23a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
246ee50b9814f101b5b5c0ae60af1dedf059ad2106Casey Dahlin#include "update_engine/common_service.h"
25a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#include "update_engine/parcelable_update_engine_status.h"
26a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#include "update_engine/update_status_utils.h"
27a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
28a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing android::OK;
29a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing android::String16;
30a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing android::String8;
31a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing android::brillo::ParcelableUpdateEngineStatus;
3240892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlinusing android::binder::Status;
33a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing android::getService;
34a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing chromeos_update_engine::StringToUpdateStatus;
356ee50b9814f101b5b5c0ae60af1dedf059ad2106Casey Dahlinusing chromeos_update_engine::UpdateEngineService;
36a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinusing std::string;
37a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
38a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinnamespace update_engine {
39a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinnamespace internal {
40a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
41a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::Init() {
4240892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  if (!binder_watcher_.Init()) return false;
4340892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin
44a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return getService(String16{"android.brillo.UpdateEngineService"},
45a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin      &service_) == OK;
46a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
47a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
48a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::AttemptUpdate(const string& in_app_version,
49a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                             const string& in_omaha_url,
50a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                             bool at_user_request) {
51a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->AttemptUpdate(String16{in_app_version.c_str()},
526ee50b9814f101b5b5c0ae60af1dedf059ad2106Casey Dahlin      String16{in_omaha_url.c_str()},
536ee50b9814f101b5b5c0ae60af1dedf059ad2106Casey Dahlin      at_user_request ? 0 :
546ee50b9814f101b5b5c0ae60af1dedf059ad2106Casey Dahlin          UpdateEngineService::kAttemptUpdateFlagNonInteractive).isOk();
55a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
56a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
57a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetStatus(int64_t* out_last_checked_time,
58a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                         double* out_progress,
59a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                         UpdateStatus* out_update_status,
60a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                         string* out_new_version,
61a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                         int64_t* out_new_size) const {
62a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  ParcelableUpdateEngineStatus status;
63a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
64a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  if (!service_->GetStatus(&status).isOk())
65a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    return false;
66a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
67a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *out_last_checked_time = status.last_checked_time_;
68a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *out_progress = status.progress_;
69a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  StringToUpdateStatus(String8{status.current_operation_}.string(),
70a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                       out_update_status);
71a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *out_new_version = String8{status.new_version_}.string();
72a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *out_new_size = status.new_size_;
73a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return true;
74a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
75a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
76a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::SetUpdateOverCellularPermission(bool allowed) {
77a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->SetUpdateOverCellularPermission(allowed).isOk();
78a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
79a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
80a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetUpdateOverCellularPermission(
81a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    bool* allowed) const {
82a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->GetUpdateOverCellularPermission(allowed).isOk();
83a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
84a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
85a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::SetP2PUpdatePermission(bool enabled) {
86a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->SetP2PUpdatePermission(enabled).isOk();
87a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
88a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
89a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetP2PUpdatePermission(bool* enabled) const {
90a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->GetP2PUpdatePermission(enabled).isOk();
91a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
92a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
93a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::Rollback(bool powerwash) {
94a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->AttemptRollback(powerwash).isOk();
95a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
96a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
97a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetRollbackPartition(
98a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    string* rollback_partition) const {
99a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  String16 out_as_string16;
100a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
101a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  if (!service_->GetRollbackPartition(&out_as_string16).isOk())
102a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    return false;
103a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
104a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *rollback_partition = String8{out_as_string16}.string();
105a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return true;
106a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
107a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
108a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetPrevVersion(string* prev_version) const {
109a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  String16 out_as_string16;
110a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
111a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  if (!service_->GetPrevVersion(&out_as_string16).isOk())
112a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    return false;
113a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
114a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *prev_version = String8{out_as_string16}.string();
115a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return true;
116a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
117a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
118a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinvoid BinderUpdateEngineClient::RebootIfNeeded() {
119a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  if (!service_->RebootIfNeeded().isOk()) {
120a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    // Reboot error code doesn't necessarily mean that a reboot
121a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    // failed. For example, D-Bus may be shutdown before we receive the
122a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    // result.
123a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    LOG(INFO) << "RebootIfNeeded() failure ignored.";
124a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  }
125a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
126a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
127a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::ResetStatus() {
128a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->ResetStatus().isOk();
129a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
130a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
13140892497a9b1ea124058baf09f5f2873a15cb696Casey DahlinStatus BinderUpdateEngineClient::StatusUpdateCallback::HandleStatusUpdate(
13240892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    int64_t last_checked_time,
13340892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    double progress,
13440892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    const String16& current_operation,
13540892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    const String16& new_version,
13640892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    int64_t new_size) {
13740892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  UpdateStatus update_status;
13840892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin
13940892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  StringToUpdateStatus(String8{current_operation}.string(), &update_status);
14040892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin
14140892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  for (auto& handler : client_->handlers_) {
14240892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    handler->HandleStatusUpdate(last_checked_time, progress, update_status,
14340892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin                                String8{new_version}.string(), new_size);
14440892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  }
14540892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin
14640892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  return Status::ok();
14740892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin}
14840892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin
14940892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlinbool BinderUpdateEngineClient::RegisterStatusUpdateHandler(
150a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    StatusUpdateHandler* handler) {
15140892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  if (!status_callback_.get()) {
15240892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    status_callback_ =
15340892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin        new BinderUpdateEngineClient::StatusUpdateCallback(this);
15440892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    if (!service_->RegisterStatusCallback(status_callback_).isOk()) {
15540892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin      return false;
15640892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin    }
15740892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  }
15840892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin
15940892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  handlers_.push_back(handler);
160a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
161a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  int64_t last_checked_time;
162a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  double progress;
163a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  UpdateStatus update_status;
164a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  string new_version;
165a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  int64_t new_size;
166a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
167a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  if (!GetStatus(&last_checked_time, &progress, &update_status,
168a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin                 &new_version, &new_size)) {
169a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin    handler->IPCError("Could not get status from binder service");
170a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  }
171a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
172a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  handler->HandleStatusUpdate(last_checked_time, progress, update_status,
173a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin                              new_version, new_size);
174a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
17540892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin  return true;
176a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
177a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
178a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlinbool BinderUpdateEngineClient::UnregisterStatusUpdateHandler(
179a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin    StatusUpdateHandler* handler) {
180a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  auto it = handlers_.begin();
181a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
182a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  for (; *it != handler && it != handlers_.end(); it++);
183a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
184a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  if (it != handlers_.end()) {
185a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin    handlers_.erase(it);
186a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin    return true;
187a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  }
188a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
189a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin  return false;
190a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin}
191a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin
192a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::SetTargetChannel(const string& in_target_channel,
193a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                                                bool allow_powerwash) {
194a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return service_->SetChannel(String16{in_target_channel.c_str()},
195a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin                              allow_powerwash).isOk();
196a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
197a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
198a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetTargetChannel(string* out_channel) const {
199a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  String16 out_as_string16;
200a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
201a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  if (!service_->GetChannel(false, &out_as_string16).isOk())
202a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    return false;
203a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
204a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *out_channel = String8{out_as_string16}.string();
205a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return true;
206a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
207a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
208a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinbool BinderUpdateEngineClient::GetChannel(string* out_channel) const {
209a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  String16 out_as_string16;
210a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
211a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  if (!service_->GetChannel(true, &out_as_string16).isOk())
212a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin    return false;
213a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
214a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  *out_channel = String8{out_as_string16}.string();
215a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin  return true;
216a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}
217a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin
2182997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhaobool BinderUpdateEngineClient::GetLastAttemptError(
2192997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao    int32_t* last_attempt_error) const {
2202997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao  int out_as_int;
2212997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao
2222997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao  if (!service_->GetLastAttemptError(&out_as_int).isOk())
2232997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao    return false;
2242997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao
2252997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao  *last_attempt_error = out_as_int;
2262997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao  return true;
2272997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao}
2282997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao
229a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}  // namespace internal
230a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}  // namespace update_engine
231