Adam Shih | 2a520eb | 2023-03-02 14:15:57 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 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 | */ |
Adam Shih | ad76e7c | 2023-03-06 17:04:00 +0800 | [diff] [blame] | 16 | #include <android-base/properties.h> |
kierancyphus | 52d632c | 2023-06-30 04:50:50 +0800 | [diff] [blame] | 17 | #include <dump/pixel_dump.h> |
Adam Shih | ad76e7c | 2023-03-06 17:04:00 +0800 | [diff] [blame] | 18 | |
kierancyphus | 52d632c | 2023-06-30 04:50:50 +0800 | [diff] [blame] | 19 | #include "dumper.h" |
| 20 | #include "modem_log_dumper.h" |
| 21 | |
kierancyphus | 3ed60ce | 2023-11-10 14:40:18 +0800 | [diff] [blame^] | 22 | namespace pixel_modem::logging { |
kierancyphus | 52d632c | 2023-06-30 04:50:50 +0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * @brief Implementation of AndroidPropertyManager that directly forwards to |
| 26 | * android base methods. |
| 27 | */ |
| 28 | class AndroidPropertyManagerImpl : public AndroidPropertyManager { |
| 29 | public: |
| 30 | bool GetBoolProperty(const std::string& key, bool default_value) override { |
| 31 | return android::base::GetBoolProperty(key, default_value); |
| 32 | }; |
| 33 | |
| 34 | std::string GetProperty(const std::string& key, |
| 35 | const std::string& default_value) override { |
| 36 | return android::base::GetProperty(key, default_value); |
| 37 | }; |
| 38 | int GetIntProperty(const std::string& key, int default_value) override { |
| 39 | return android::base::GetIntProperty(key, default_value); |
| 40 | }; |
| 41 | void SetProperty(const std::string& key, const std::string& value) override { |
| 42 | android::base::SetProperty(key, value); |
| 43 | }; |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * @brief Implementation of Dumper that directly forwards to their corresponding |
| 48 | * dumpstate methods. |
| 49 | */ |
| 50 | class DumperImpl : public Dumper { |
| 51 | public: |
| 52 | void DumpLogs(const LogDumpInfo& log_dump_info) override { |
| 53 | dumpLogs(log_dump_info.src_dir.data(), log_dump_info.dest_dir.data(), |
| 54 | log_dump_info.limit, log_dump_info.prefix.data()); |
| 55 | } |
| 56 | void CopyFile(const FileCopyInfo& file_copy_info) override { |
| 57 | copyFile(file_copy_info.src_dir.data(), file_copy_info.dest_dir.data()); |
| 58 | } |
| 59 | }; |
| 60 | |
kierancyphus | 3ed60ce | 2023-11-10 14:40:18 +0800 | [diff] [blame^] | 61 | } // namespace pixel_modem::logging |
Adam Shih | 2a520eb | 2023-03-02 14:15:57 +0800 | [diff] [blame] | 62 | |
| 63 | int main() { |
kierancyphus | 3ed60ce | 2023-11-10 14:40:18 +0800 | [diff] [blame^] | 64 | pixel_modem::logging::DumperImpl dumper_impl; |
| 65 | pixel_modem::logging::AndroidPropertyManagerImpl |
| 66 | android_property_manager_impl; |
| 67 | pixel_modem::logging::ModemLogDumper modem_log_dumper( |
kierancyphus | 52d632c | 2023-06-30 04:50:50 +0800 | [diff] [blame] | 68 | dumper_impl, android_property_manager_impl); |
Adam Shih | ad76e7c | 2023-03-06 17:04:00 +0800 | [diff] [blame] | 69 | |
kierancyphus | 52d632c | 2023-06-30 04:50:50 +0800 | [diff] [blame] | 70 | modem_log_dumper.DumpModemLogs(); |
| 71 | return 0; |
Adam Shih | 2a520eb | 2023-03-02 14:15:57 +0800 | [diff] [blame] | 72 | } |