aboutsummaryrefslogtreecommitdiff
path: root/modem/dump_modemlog.cpp
blob: 1b6b2e92bea4e687971ab10c99f2dc1913a55b74 (plain)
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
/*
 * Copyright 2022 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 <android-base/properties.h>
#include <dump/pixel_dump.h>

#include "dumper.h"
#include "modem_log_dumper.h"

namespace modem {
namespace logging {

/**
 * @brief Implementation of AndroidPropertyManager that directly forwards to
 * android base methods.
 */
class AndroidPropertyManagerImpl : public AndroidPropertyManager {
 public:
  bool GetBoolProperty(const std::string& key, bool default_value) override {
    return android::base::GetBoolProperty(key, default_value);
  };

  std::string GetProperty(const std::string& key,
                          const std::string& default_value) override {
    return android::base::GetProperty(key, default_value);
  };
  int GetIntProperty(const std::string& key, int default_value) override {
    return android::base::GetIntProperty(key, default_value);
  };
  void SetProperty(const std::string& key, const std::string& value) override {
    android::base::SetProperty(key, value);
  };
};

/**
 * @brief Implementation of Dumper that directly forwards to their corresponding
 * dumpstate methods.
 */
class DumperImpl : public Dumper {
 public:
  void DumpLogs(const LogDumpInfo& log_dump_info) override {
    dumpLogs(log_dump_info.src_dir.data(), log_dump_info.dest_dir.data(),
             log_dump_info.limit, log_dump_info.prefix.data());
  }
  void CopyFile(const FileCopyInfo& file_copy_info) override {
    copyFile(file_copy_info.src_dir.data(), file_copy_info.dest_dir.data());
  }
};

}  // namespace logging
}  // namespace modem

int main() {
  modem::logging::DumperImpl dumper_impl;
  modem::logging::AndroidPropertyManagerImpl android_property_manager_impl;
  modem::logging::ModemLogDumper modem_log_dumper(
      dumper_impl, android_property_manager_impl);

  modem_log_dumper.DumpModemLogs();
  return 0;
}