-
Notifications
You must be signed in to change notification settings - Fork 1
/
dbus_service.cc
213 lines (174 loc) · 6.68 KB
/
dbus_service.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//
// Copyright (C) 2012 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 "hello_world/dbus_service.h"
#include <string>
#include <vector>
#include <dbus_bindings/dbus-constants.h>
#include <hello_world/proto_bindings/hello_world.pb.h>
#include "dbus_bindings/dbus_connection.h"
#include "proto_bindings/hello_world.pb.h"
#include "HelloWorld_Status.h"
namespace chromeos_hello_world {
using brillo::ErrorPtr;
using chromeos_hello_world::DBusHelloWorldService;
using std::string;
using std::vector;
DBusHelloWorldService::DBusHelloWorldService(){
}
// org::chromium::HelloWorldInterfaceInterface methods implementation.
bool DBusHelloWorldService::AttemptHello(ErrorPtr* error,
const string& in_app_version,
const string& in_omaha_url) {
return true;
}
bool DBusHelloWorldService::AttemptHelloWithFlags(
ErrorPtr* error,
const string& in_app_version,
const string& in_omaha_url,
int32_t in_flags_as_int) {
auto flags = static_cast<hello_world::HelloAttemptFlags>(in_flags_as_int);
bool interactive = !(flags & hello_world::HelloAttemptFlags::kFlagNonInteractive);
bool restrict_downloads = (flags & hello_world::HelloAttemptFlags::kFlagRestrictDownload);
LOG(INFO) << "Attempt update: app_version=\"" << in_app_version << "\" "
<< "omaha_url=\"" << in_omaha_url << "\" "
<< "flags=0x" << std::hex << flags << " "
<< "interactive=" << (interactive ? "yes " : "no ")
<< "RestrictDownload=" << (restrict_downloads ? "yes " : "no ");
return true;
}
bool DBusHelloWorldService::AttemptInstall(ErrorPtr* error,
const string& dlc_request) {
// Parse the raw parameters into protobuf.
DlcParameters dlc_parameters;
if (!dlc_parameters.ParseFromString(dlc_request)) {
*error = brillo::Error::Create(
FROM_HERE, "update_engine", "INTERNAL", "parameters are invalid.");
return false;
}
// Extract fields from the protobuf.
vector<string> dlc_ids;
for (const auto& dlc_info : dlc_parameters.dlc_infos()) {
if (dlc_info.dlc_id().empty()) {
*error = brillo::Error::Create(
FROM_HERE, "update_engine", "INTERNAL", "parameters are invalid.");
return false;
}
LOG(INFO) << dlc_info.dlc_id() << "\n";
dlc_ids.push_back(dlc_info.dlc_id());
}
return true;
}
bool DBusHelloWorldService::AttemptRollback(ErrorPtr* error,
bool in_powerwash) {
return true;
}
bool DBusHelloWorldService::CanRollback(ErrorPtr* error,
bool* out_can_rollback) {
return true;
}
bool DBusHelloWorldService::ResetStatus(ErrorPtr* error) {
return true;
}
bool DBusHelloWorldService::GetStatus(ErrorPtr* error,
int64_t* out_last_checked_time,
double* out_progress,
string* out_current_operation,
string* out_new_version,
int64_t* out_new_size) {
return true;
}
bool DBusHelloWorldService::RebootIfNeeded(ErrorPtr* error) {
return true;
}
bool DBusHelloWorldService::SetChannel(ErrorPtr* error,
const string& in_target_channel,
bool in_is_powerwash_allowed) {
return true;
}
bool DBusHelloWorldService::GetChannel(ErrorPtr* error,
bool in_get_current_channel,
string* out_channel) {
return true;
}
bool DBusHelloWorldService::GetCohortHint(ErrorPtr* error,
string* out_cohort_hint) {
return true;
}
bool DBusHelloWorldService::SetCohortHint(ErrorPtr* error,
const string& in_cohort_hint) {
return true;
}
bool DBusHelloWorldService::SetP2PHelloPermission(ErrorPtr* error,
bool in_enabled) {
return true;
}
bool DBusHelloWorldService::GetP2PHelloPermission(ErrorPtr* error,
bool* out_enabled) {
return true;
}
bool DBusHelloWorldService::SetHelloOverCellularPermission(ErrorPtr* error,
bool in_allowed) {
return true;
}
bool DBusHelloWorldService::SetHelloOverCellularTarget(
brillo::ErrorPtr* error,
const std::string& target_version,
int64_t target_size) {
return true;
}
bool DBusHelloWorldService::GetHelloOverCellularPermission(
ErrorPtr* error, bool* out_allowed) {
return true;
}
bool DBusHelloWorldService::GetDurationSinceHello(
ErrorPtr* error, int64_t* out_usec_wallclock) {
return true;
}
bool DBusHelloWorldService::GetPrevVersion(ErrorPtr* error,
string* out_prev_version) {
return true;
}
bool DBusHelloWorldService::GetRollbackPartition(
ErrorPtr* error, string* out_rollback_partition_name) {
return true;
}
bool DBusHelloWorldService::GetLastAttemptError(
ErrorPtr* error, int32_t* out_last_attempt_error) {
return true;
}
bool DBusHelloWorldService::GetEolStatus(ErrorPtr* error,
int32_t* out_eol_status) {
return true;
}
HelloWorldAdaptor::HelloWorldAdaptor()
: org::chromium::HelloWorldInterfaceAdaptor(&dbus_service_),
bus_(DBusConnection::Get()->GetDBus()),
dbus_object_(nullptr,
bus_,
dbus::ObjectPath(hello_world::kHelloWorldServicePath)) {}
void HelloWorldAdaptor::RegisterAsync(
const base::Callback<void(bool)>& completion_callback) {
RegisterWithDBusObject(&dbus_object_);
dbus_object_.RegisterAsync(completion_callback);
}
bool HelloWorldAdaptor::RequestOwnership() {
return bus_->RequestOwnershipAndBlock(hello_world::kHelloWorldServiceName,
dbus::Bus::REQUIRE_PRIMARY);
}
void HelloWorldAdaptor::SendStatusHello(
const std::string &status) {
}
} // namespace chromeos_hello_world