Merge changes from topic "recovery_dtbo" am: 3ac694632c am: c9dffd158c
am: 7cc1d44b94
Change-Id: Ie04e87d3d0d2d6f1b0531652fc9438eb0e7e865b
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c
index 937a218..5a210ab 100644
--- a/lmkd/lmkd.c
+++ b/lmkd/lmkd.c
@@ -80,6 +80,9 @@
/* Defined as ProcessList.SYSTEM_ADJ in ProcessList.java */
#define SYSTEM_ADJ (-900)
+#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
+#define STRINGIFY_INTERNAL(x) #x
+
/* default to old in-kernel interface if no memory pressure events */
static int use_inkernel_interface = 1;
static bool has_inkernel_module;
@@ -583,10 +586,10 @@
#ifdef LMKD_LOG_STATS
static void memory_stat_parse_line(char *line, struct memory_stat *mem_st) {
- char key[LINE_MAX];
+ char key[LINE_MAX + 1];
int64_t value;
- sscanf(line,"%s %" SCNd64 "", key, &value);
+ sscanf(line, "%" STRINGIFY(LINE_MAX) "s %" SCNd64 "", key, &value);
if (strcmp(key, "total_") < 0) {
return;
diff --git a/rootdir/etc/public.libraries.android.txt b/rootdir/etc/public.libraries.android.txt
index e20b95d..2a51d53 100644
--- a/rootdir/etc/public.libraries.android.txt
+++ b/rootdir/etc/public.libraries.android.txt
@@ -1,6 +1,7 @@
# See https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
libandroid.so
libaaudio.so
+libamidi.so
libc.so
libcamera2ndk.so
libdl.so
diff --git a/rootdir/etc/public.libraries.wear.txt b/rootdir/etc/public.libraries.wear.txt
index 3c46094..56055ba 100644
--- a/rootdir/etc/public.libraries.wear.txt
+++ b/rootdir/etc/public.libraries.wear.txt
@@ -1,6 +1,7 @@
# See https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
libandroid.so
libaaudio.so
+libamidi.so
libc.so
libcamera2ndk.so
libdl.so
diff --git a/storaged/include/storaged_info.h b/storaged/include/storaged_info.h
index 88a53de..9c3d0e7 100644
--- a/storaged/include/storaged_info.h
+++ b/storaged/include/storaged_info.h
@@ -38,6 +38,7 @@
class storage_info_t {
protected:
FRIEND_TEST(storaged_test, storage_info_t);
+ FRIEND_TEST(storaged_test, storage_info_t_proto);
// emmc lifetime
uint16_t eol; // pre-eol (end of life) information
uint16_t lifetime_a; // device life time estimation (type A)
diff --git a/storaged/storaged_info.cpp b/storaged/storaged_info.cpp
index 055f375..5605f66 100644
--- a/storaged/storaged_info.cpp
+++ b/storaged/storaged_info.cpp
@@ -157,11 +157,14 @@
return;
}
- recent_perf.erase(recent_perf.begin() + nr_samples,
- recent_perf.end());
+ if (nr_samples < recent_perf.size()) {
+ recent_perf.erase(recent_perf.begin() + nr_samples, recent_perf.end());
+ }
- uint32_t daily_avg_bw = accumulate(recent_perf.begin(),
- recent_perf.begin() + nr_samples, 0) / nr_samples;
+ uint32_t daily_avg_bw = 0;
+ if (!recent_perf.empty()) {
+ daily_avg_bw = accumulate(recent_perf.begin(), recent_perf.end(), 0) / recent_perf.size();
+ }
day_start_tp = tp - chrono::seconds(duration_cast<chrono::seconds>(
tp.time_since_epoch()).count() % DAY_TO_SEC);
@@ -176,6 +179,7 @@
return;
}
+ DCHECK(nr_days > 0);
uint32_t week_avg_bw = accumulate(daily_perf.begin(),
daily_perf.begin() + nr_days, 0) / nr_days;
diff --git a/storaged/tests/storaged_test.cpp b/storaged/tests/storaged_test.cpp
index d1fa9ed..ec47b65 100644
--- a/storaged/tests/storaged_test.cpp
+++ b/storaged/tests/storaged_test.cpp
@@ -416,6 +416,31 @@
}
}
+TEST(storaged_test, storage_info_t_proto) {
+ storage_info_t si;
+ si.day_start_tp = {};
+
+ IOPerfHistory proto;
+ proto.set_nr_samples(10);
+ proto.set_day_start_sec(0);
+ si.load_perf_history_proto(proto);
+
+ // Skip ahead > 1 day, with no data points in the previous day.
+ time_point<system_clock> stp;
+ stp += hours(36);
+ si.update_perf_history(100, stp);
+
+ vector<int> history = si.get_perf_history();
+ EXPECT_EQ(history.size(), 63UL);
+ EXPECT_EQ(history[0], 1);
+ EXPECT_EQ(history[1], 7);
+ EXPECT_EQ(history[2], 52);
+ EXPECT_EQ(history[3], 100);
+ for (size_t i = 4; i < history.size(); i++) {
+ EXPECT_EQ(history[i], 0);
+ }
+}
+
TEST(storaged_test, uid_monitor) {
uid_monitor uidm;