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

Commit a504624d authored by Neil Fuller's avatar Neil Fuller
Browse files

Tweak logged info for time / time zone detection

Tweak logged info for time / time zone detection: This reduces the
amount of history stored for bug reports to limit memory usage (it
can be increased again later if needed) and tries to make better
use of the history that is kept.

Bug: 140712361
Test: build / boot / dumpsys
Change-Id: I46b05eae77aac6d2a804cb6f3f6184772583f268
parent c0d59e39
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -87,11 +87,15 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
    private static final long SYSTEM_CLOCK_PARANOIA_THRESHOLD_MILLIS = 2 * 1000;

    /**
     * The number of previous telephony suggestions to keep for each ID (for use during debugging).
     * The number of suggestions to keep. These are logged in bug reports to assist when debugging
     * issues with detection.
     */
    private static final int KEEP_SUGGESTION_HISTORY_SIZE = 30;
    private static final int KEEP_SUGGESTION_HISTORY_SIZE = 10;

    // A log for changes made to the system clock and why.
    /**
     * A log that records the decisions / decision metadata that affected the device's system clock
     * time. This is logged in bug reports to assist with debugging issues with detection.
     */
    @NonNull
    private final LocalLog mTimeChangesLog = new LocalLog(30, false /* useLocalTimestamps */);

@@ -140,7 +144,18 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
        if (!validateSuggestionTime(timeSuggestion.getUtcTime(), timeSuggestion)) {
            return;
        }

        // The caller submits suggestions with the best available information when there are network
        // changes. The best available information may have been cached and if they were all stored
        // this would lead to duplicates showing up in the suggestion history. The suggestions may
        // be made for different reasons but there is not a significant benefit to storing the same
        // suggestion information again. doAutoTimeDetection() should still be called: this ensures
        // the suggestion and device state are always re-evaluated, which might produce a different
        // detected time if, for example, the age of all suggestions are considered.
        NetworkTimeSuggestion lastNetworkSuggestion = mLastNetworkSuggestion.get();
        if (lastNetworkSuggestion == null || !lastNetworkSuggestion.equals(timeSuggestion)) {
            mLastNetworkSuggestion.set(timeSuggestion);
        }

        // Now perform auto time detection. The new suggestion may be used to modify the system
        // clock.
+6 −6
Original line number Diff line number Diff line
@@ -161,16 +161,17 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat
    public static final int TELEPHONY_SCORE_USAGE_THRESHOLD = TELEPHONY_SCORE_MEDIUM;

    /**
     * The number of previous telephony suggestions to keep for each ID (for use during debugging).
     * The number of suggestions to keep. These are logged in bug reports to assist when debugging
     * issues with detection.
     */
    private static final int KEEP_TELEPHONY_SUGGESTION_HISTORY_SIZE = 30;
    private static final int KEEP_SUGGESTION_HISTORY_SIZE = 10;

    @NonNull
    private final Callback mCallback;

    /**
     * A log that records the decisions / decision metadata that affected the device's time zone
     * (for use during debugging).
     * A log that records the decisions / decision metadata that affected the device's time zone.
     * This is logged in bug reports to assist with debugging issues with detection.
     */
    @NonNull
    private final LocalLog mTimeZoneChangesLog = new LocalLog(30, false /* useLocalTimestamps */);
@@ -182,8 +183,7 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat
     */
    @GuardedBy("this")
    private ArrayMapWithHistory<Integer, QualifiedTelephonyTimeZoneSuggestion>
            mSuggestionBySlotIndex =
            new ArrayMapWithHistory<>(KEEP_TELEPHONY_SUGGESTION_HISTORY_SIZE);
            mSuggestionBySlotIndex = new ArrayMapWithHistory<>(KEEP_SUGGESTION_HISTORY_SIZE);

    /**
     * Creates a new instance of {@link TimeZoneDetectorStrategyImpl}.