Merge changes from topic 'time_format_settings'

* changes:
  Extract is24HourLocale method.
  Allow null value for TIME_12_24 setting.
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 88aafdc..4725bd4 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3484,7 +3484,7 @@
 
         /** @hide */
         public static final Validator TIME_12_24_VALIDATOR =
-                new DiscreteValueValidator(new String[] {"12", "24"});
+                new DiscreteValueValidator(new String[] {"12", "24", null});
 
         /**
          * Date format string
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index 34fe07b..de2dcce 100755
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -16,6 +16,7 @@
 
 package android.text.format;
 
+import android.annotation.NonNull;
 import android.content.Context;
 import android.os.UserHandle;
 import android.provider.Settings;
@@ -183,8 +184,17 @@
             return value.equals("24");
         }
 
-        final Locale locale = context.getResources().getConfiguration().locale;
+        return is24HourLocale(context.getResources().getConfiguration().locale);
+    }
 
+    /**
+     * Returns true if the specified locale uses a 24-hour time format by default, ignoring user
+     * settings.
+     * @param locale the locale to check
+     * @return true if the locale uses a 24 hour time format by default, false otherwise
+     * @hide
+     */
+    public static boolean is24HourLocale(@NonNull Locale locale) {
         synchronized (sLocaleLock) {
             if (sIs24HourLocale != null && sIs24HourLocale.equals(locale)) {
                 return sIs24Hour;
diff --git a/core/tests/coretests/src/android/text/format/DateFormatTest.java b/core/tests/coretests/src/android/text/format/DateFormatTest.java
index 15c86f0..0f08d18 100644
--- a/core/tests/coretests/src/android/text/format/DateFormatTest.java
+++ b/core/tests/coretests/src/android/text/format/DateFormatTest.java
@@ -25,6 +25,8 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.Locale;
+
 @SmallTest
 @RunWith(AndroidJUnit4.class)
 public class DateFormatTest {
@@ -44,4 +46,10 @@
 
         assertFalse(DateFormat.hasDesignator("hh:mm 'yyyy'", DateFormat.YEAR));
     }
+
+    @Test
+    public void testIs24HourLocale() {
+        assertFalse(DateFormat.is24HourLocale(Locale.US));
+        assertTrue(DateFormat.is24HourLocale(Locale.GERMANY));
+    }
 }