blob: 1b6b2e92bea4e687971ab10c99f2dc1913a55b74 [file] [log] [blame]
Adam Shih2a520eb2023-03-02 14:15:57 +08001/*
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 Shihad76e7c2023-03-06 17:04:00 +080016#include <android-base/properties.h>
kierancyphus52d632c2023-06-30 04:50:50 +080017#include <dump/pixel_dump.h>
Adam Shihad76e7c2023-03-06 17:04:00 +080018
kierancyphus52d632c2023-06-30 04:50:50 +080019#include "dumper.h"
20#include "modem_log_dumper.h"
21
22namespace modem {
23namespace logging {
24
25/**
26 * @brief Implementation of AndroidPropertyManager that directly forwards to
27 * android base methods.
28 */
29class AndroidPropertyManagerImpl : public AndroidPropertyManager {
30 public:
31 bool GetBoolProperty(const std::string& key, bool default_value) override {
32 return android::base::GetBoolProperty(key, default_value);
33 };
34
35 std::string GetProperty(const std::string& key,
36 const std::string& default_value) override {
37 return android::base::GetProperty(key, default_value);
38 };
39 int GetIntProperty(const std::string& key, int default_value) override {
40 return android::base::GetIntProperty(key, default_value);
41 };
42 void SetProperty(const std::string& key, const std::string& value) override {
43 android::base::SetProperty(key, value);
44 };
45};
46
47/**
48 * @brief Implementation of Dumper that directly forwards to their corresponding
49 * dumpstate methods.
50 */
51class DumperImpl : public Dumper {
52 public:
53 void DumpLogs(const LogDumpInfo& log_dump_info) override {
54 dumpLogs(log_dump_info.src_dir.data(), log_dump_info.dest_dir.data(),
55 log_dump_info.limit, log_dump_info.prefix.data());
56 }
57 void CopyFile(const FileCopyInfo& file_copy_info) override {
58 copyFile(file_copy_info.src_dir.data(), file_copy_info.dest_dir.data());
59 }
60};
61
62} // namespace logging
63} // namespace modem
Adam Shih2a520eb2023-03-02 14:15:57 +080064
65int main() {
kierancyphus52d632c2023-06-30 04:50:50 +080066 modem::logging::DumperImpl dumper_impl;
67 modem::logging::AndroidPropertyManagerImpl android_property_manager_impl;
68 modem::logging::ModemLogDumper modem_log_dumper(
69 dumper_impl, android_property_manager_impl);
Adam Shihad76e7c2023-03-06 17:04:00 +080070
kierancyphus52d632c2023-06-30 04:50:50 +080071 modem_log_dumper.DumpModemLogs();
72 return 0;
Adam Shih2a520eb2023-03-02 14:15:57 +080073}