blob: 5aaa554f6011529abf4d9568822a431ae4fbe16e [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"
25#define MODEM_LOG_PREFIX "sbuff_"
Adam Shih2a520eb2023-03-02 14:15:57 +080026
27int main() {
Adam Shihad76e7c2023-03-06 17:04:00 +080028 bool modemLogEnabled = ::android::base::GetBoolProperty(MODEM_LOGGING_PERSIST_PROPERTY, false);
29 if (modemLogEnabled && ::android::base::GetProperty(MODEM_LOGGING_PATH_PROPERTY, "") == MODEM_LOG_DIRECTORY) {
30 bool modemLogStarted = ::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false);
31 int maxFileNum = ::android::base::GetIntProperty(MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY, 100);
32
33 if (modemLogStarted) {
34 ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "false");
35 ALOGD("Stopping modem logging...\n");
36 } else {
37 ALOGD("modem logging is not running\n");
38 }
39
40 for (int i = 0; i < 15; i++) {
41 if (!::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false)) {
42 ALOGD("modem logging stopped\n");
43 sleep(1);
44 break;
45 }
46 sleep(1);
47 }
48
49 dumpLogs(MODEM_LOG_DIRECTORY, BUGREPORT_PACKING_DIR, maxFileNum, MODEM_LOG_PREFIX);
50
51 if (modemLogStarted) {
52 ALOGD("Restarting modem logging...\n");
53 ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "true");
54 }
55 }
56
57 dumpLogs("/data/vendor/radio/extended_logs", BUGREPORT_PACKING_DIR, 20, "extended_log_");
Adam Shih2a520eb2023-03-02 14:15:57 +080058 copyFile("/mnt/vendor/efs/nv_normal.bin", "/data/vendor/radio/logs/always-on/all_logs/nv_normal.bin");
59 copyFile("/mnt/vendor/efs/nv_protected.bin", "/data/vendor/radio/logs/always-on/all_logs/nv_protected.bin");
60 return 0;
61}