Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 817d9fbd authored by Jason Hsu's avatar Jason Hsu Committed by Android (Google) Code Review
Browse files

Merge "[ha_feedback] Change to keep the latest connection/paired record...

Merge "[ha_feedback] Change to keep the latest connection/paired record history of the same day" into main
parents 53ee8b50 cf571fe2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -268,9 +268,9 @@ public final class HearingDeviceStatsLogUtils {
        }
        if (history.peekLast() != null && isSameDay(timestamp, history.peekLast())) {
            if (DEBUG) {
                Log.w(TAG, "Skip record of history type=" + type + ", it's same day record");
                Log.w(TAG, "Remove the earlier same day record of history type=" + type);
            }
            return;
            history.remove(history.peekLast());
        }
        history.add(timestamp);
        SharedPreferences.Editor editor = getSharedPreferences(context).edit();
+5 −3
Original line number Diff line number Diff line
@@ -117,17 +117,19 @@ public class HearingDeviceStatsLogUtilsTest {
        assertThat(history.size()).isEqualTo(2);
    }
    @Test
    public void addCurrentTimeToHistory_skipSameDateData() {
    public void addCurrentTimeToHistory_replaceSameDateData() {
        final long todayStartOfDay = convertToStartOfDayTime(System.currentTimeMillis());
        HearingDeviceStatsLogUtils.addToHistory(mContext, TEST_HISTORY_TYPE, todayStartOfDay);

        HearingDeviceStatsLogUtils.addCurrentTimeToHistory(mContext, TEST_HISTORY_TYPE);
        final long newerTodayStartOfDay = todayStartOfDay + 1;
        HearingDeviceStatsLogUtils.addToHistory(mContext, TEST_HISTORY_TYPE,
                newerTodayStartOfDay);

        LinkedList<Long> history = HearingDeviceStatsLogUtils.getHistory(mContext,
                TEST_HISTORY_TYPE);
        assertThat(history).isNotNull();
        assertThat(history.size()).isEqualTo(1);
        assertThat(history.getFirst()).isEqualTo(todayStartOfDay);
        assertThat(history.getFirst()).isEqualTo(newerTodayStartOfDay);
    }

    @Test