blob: ad5806ac8dab067bd4de85c8d9301d7661d2ac08 [file] [log] [blame]
Xiaochu Liu8ba486f2018-11-06 11:14:10 -08001//
2// Copyright (C) 2018 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#include "update_engine/dlcservice_chromeos.h"
18
Xiaochu Liu8ba486f2018-11-06 11:14:10 -080019#include <dlcservice/proto_bindings/dlcservice.pb.h>
Amin Hassani3bab1772019-06-21 14:58:25 -070020// NOLINTNEXTLINE(build/include_alpha) "dbus-proxies.h" needs "dlcservice.pb.h"
21#include <dlcservice/dbus-proxies.h>
Xiaochu Liu8ba486f2018-11-06 11:14:10 -080022
23#include "update_engine/dbus_connection.h"
24
Amin Hassani3bab1772019-06-21 14:58:25 -070025using dlcservice::DlcModuleList;
Xiaochu Liu8ba486f2018-11-06 11:14:10 -080026using std::string;
27using std::vector;
28
29namespace chromeos_update_engine {
30
31std::unique_ptr<DlcServiceInterface> CreateDlcService() {
32 return std::make_unique<DlcServiceChromeOS>();
33}
34
35bool DlcServiceChromeOS::GetInstalled(vector<string>* dlc_module_ids) {
36 if (!dlc_module_ids)
37 return false;
Jae Hoon Kimc43f6bb2019-07-03 12:56:52 -070038 dlc_module_ids->clear();
39
Xiaochu Liu8ba486f2018-11-06 11:14:10 -080040 org::chromium::DlcServiceInterfaceProxy dlcservice_proxy(
41 DBusConnection::Get()->GetDBus());
Amin Hassani3bab1772019-06-21 14:58:25 -070042
Xiaochu Liu8ba486f2018-11-06 11:14:10 -080043 dlcservice::DlcModuleList dlc_module_list;
Amin Hassani3bab1772019-06-21 14:58:25 -070044 if (!dlcservice_proxy.GetInstalled(&dlc_module_list, nullptr)) {
45 LOG(ERROR) << "dlcservice does not return installed DLC module list.";
Xiaochu Liu8ba486f2018-11-06 11:14:10 -080046 return false;
47 }
48 for (const auto& dlc_module_info : dlc_module_list.dlc_module_infos()) {
49 dlc_module_ids->emplace_back(dlc_module_info.dlc_id());
50 }
51 return true;
52}
53
54} // namespace chromeos_update_engine