blob: f7ef83435bc2a689cbf18002de6bd105465ed187 [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 */
16#include <dump/pixel_dump.h>
Adam Shihad76e7c2023-03-06 17:04:00 +080017#include <android-base/properties.h>
18#include <log/log.h>
19
20#define MODEM_LOGGING_PERSIST_PROPERTY "persist.vendor.sys.modem.logging.enable"
21#define MODEM_LOGGING_PROPERTY "vendor.sys.modem.logging.enable"
22#define MODEM_LOGGING_STATUS_PROPERTY "vendor.sys.modem.logging.status"
23#define MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY "persist.vendor.sys.modem.logging.br_num"
24#define MODEM_LOGGING_PATH_PROPERTY "vendor.sys.modem.logging.log_path"
kadirpili17da3ce2023-03-17 02:52:15 +000025#define MODEM_SIM_DIRECTORY "/data/vendor/radio/sim/"
Adam Shihad76e7c2023-03-06 17:04:00 +080026#define MODEM_LOG_PREFIX "sbuff_"
kadirpili17da3ce2023-03-17 02:52:15 +000027#define SIM_POWERON_LOG_PREFIX "sim_poweron_log_"
Adam Shih2a520eb2023-03-02 14:15:57 +080028
29int main() {
Adam Shihad76e7c2023-03-06 17:04:00 +080030 bool modemLogEnabled = ::android::base::GetBoolProperty(MODEM_LOGGING_PERSIST_PROPERTY, false);
31 if (modemLogEnabled && ::android::base::GetProperty(MODEM_LOGGING_PATH_PROPERTY, "") == MODEM_LOG_DIRECTORY) {
32 bool modemLogStarted = ::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false);
33 int maxFileNum = ::android::base::GetIntProperty(MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY, 100);
34
35 if (modemLogStarted) {
36 ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "false");
37 ALOGD("Stopping modem logging...\n");
38 } else {
39 ALOGD("modem logging is not running\n");
40 }
41
42 for (int i = 0; i < 15; i++) {
43 if (!::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false)) {
44 ALOGD("modem logging stopped\n");
45 sleep(1);
46 break;
47 }
48 sleep(1);
49 }
50
51 dumpLogs(MODEM_LOG_DIRECTORY, BUGREPORT_PACKING_DIR, maxFileNum, MODEM_LOG_PREFIX);
52
53 if (modemLogStarted) {
54 ALOGD("Restarting modem logging...\n");
55 ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "true");
56 }
57 }
58
59 dumpLogs("/data/vendor/radio/extended_logs", BUGREPORT_PACKING_DIR, 20, "extended_log_");
kadirpili17da3ce2023-03-17 02:52:15 +000060 dumpLogs(MODEM_SIM_DIRECTORY, BUGREPORT_PACKING_DIR, 1, SIM_POWERON_LOG_PREFIX);
Adam Shih2a520eb2023-03-02 14:15:57 +080061 copyFile("/mnt/vendor/efs/nv_normal.bin", "/data/vendor/radio/logs/always-on/all_logs/nv_normal.bin");
62 copyFile("/mnt/vendor/efs/nv_protected.bin", "/data/vendor/radio/logs/always-on/all_logs/nv_protected.bin");
63 return 0;
64}