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

Commit 904f8a20 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Code Review
Browse files

Merge "Ensuring thread-safe usage of DateFormat."

parents a67191a1 25d8b05f
Loading
Loading
Loading
Loading
+16 −10
Original line number Original line Diff line number Diff line
@@ -642,6 +642,11 @@ public class DateUtils


    private static void initFormatStrings() {
    private static void initFormatStrings() {
        synchronized (sLock) {
        synchronized (sLock) {
            initFormatStringsLocked();
        }
    }

    private static void initFormatStringsLocked() {
        Resources r = Resources.getSystem();
        Resources r = Resources.getSystem();
        Configuration cfg = r.getConfiguration();
        Configuration cfg = r.getConfiguration();
        if (sLastConfig == null || !sLastConfig.equals(cfg)) {
        if (sLastConfig == null || !sLastConfig.equals(cfg)) {
@@ -651,7 +656,6 @@ public class DateUtils
            sElapsedFormatHMMSS = r.getString(com.android.internal.R.string.elapsed_time_short_format_h_mm_ss);
            sElapsedFormatHMMSS = r.getString(com.android.internal.R.string.elapsed_time_short_format_h_mm_ss);
        }
        }
    }
    }
    }


    /**
    /**
     * Format a time so it appears like it would in the status bar clock.
     * Format a time so it appears like it would in the status bar clock.
@@ -659,9 +663,11 @@ public class DateUtils
     * @hide
     * @hide
     */
     */
    public static final CharSequence timeString(long millis) {
    public static final CharSequence timeString(long millis) {
        initFormatStrings();
        synchronized (sLock) {
            initFormatStringsLocked();
            return sStatusTimeFormat.format(millis);
            return sStatusTimeFormat.format(millis);
        }
        }
    }


    /**
    /**
     * Formats an elapsed time in the form "MM:SS" or "H:MM:SS"
     * Formats an elapsed time in the form "MM:SS" or "H:MM:SS"