Xiaochu Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 1 | // |
| 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 Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 19 | #include <dlcservice/proto_bindings/dlcservice.pb.h> |
Amin Hassani | 3bab177 | 2019-06-21 14:58:25 -0700 | [diff] [blame] | 20 | // NOLINTNEXTLINE(build/include_alpha) "dbus-proxies.h" needs "dlcservice.pb.h" |
| 21 | #include <dlcservice/dbus-proxies.h> |
Xiaochu Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 22 | |
| 23 | #include "update_engine/dbus_connection.h" |
| 24 | |
Amin Hassani | 3bab177 | 2019-06-21 14:58:25 -0700 | [diff] [blame] | 25 | using dlcservice::DlcModuleList; |
Xiaochu Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 26 | using std::string; |
| 27 | using std::vector; |
| 28 | |
| 29 | namespace chromeos_update_engine { |
| 30 | |
| 31 | std::unique_ptr<DlcServiceInterface> CreateDlcService() { |
| 32 | return std::make_unique<DlcServiceChromeOS>(); |
| 33 | } |
| 34 | |
| 35 | bool DlcServiceChromeOS::GetInstalled(vector<string>* dlc_module_ids) { |
| 36 | if (!dlc_module_ids) |
| 37 | return false; |
Jae Hoon Kim | c43f6bb | 2019-07-03 12:56:52 -0700 | [diff] [blame^] | 38 | dlc_module_ids->clear(); |
| 39 | |
Xiaochu Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 40 | org::chromium::DlcServiceInterfaceProxy dlcservice_proxy( |
| 41 | DBusConnection::Get()->GetDBus()); |
Amin Hassani | 3bab177 | 2019-06-21 14:58:25 -0700 | [diff] [blame] | 42 | |
Xiaochu Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 43 | dlcservice::DlcModuleList dlc_module_list; |
Amin Hassani | 3bab177 | 2019-06-21 14:58:25 -0700 | [diff] [blame] | 44 | if (!dlcservice_proxy.GetInstalled(&dlc_module_list, nullptr)) { |
| 45 | LOG(ERROR) << "dlcservice does not return installed DLC module list."; |
Xiaochu Liu | 8ba486f | 2018-11-06 11:14:10 -0800 | [diff] [blame] | 46 | 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 |