Overload DeviceInfoUtils.getSecurityPatch method
Bug: 365886251
Flag: EXEMPT Code refactor
Test: N/A
Change-Id: Idaef7f9b603e531b896057c1e76b0dc4927c9b81
diff --git a/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java b/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java
index ff00fb3..c634216 100644
--- a/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java
@@ -33,6 +33,8 @@
import android.text.format.DateFormat;
import android.util.Log;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import java.io.BufferedReader;
@@ -153,13 +155,19 @@
return null;
}
- public static String getSecurityPatch() {
+ /** Returns security patch in default locale. */
+ public static @Nullable String getSecurityPatch() {
+ return getSecurityPatch(Locale.getDefault());
+ }
+
+ /** Returns security patch in given locale. */
+ public static @Nullable String getSecurityPatch(@NonNull Locale locale) {
String patch = Build.VERSION.SECURITY_PATCH;
if (!"".equals(patch)) {
try {
SimpleDateFormat template = new SimpleDateFormat("yyyy-MM-dd");
Date patchDate = template.parse(patch);
- String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "dMMMMyyyy");
+ String format = DateFormat.getBestDateTimePattern(locale, "dMMMMyyyy");
patch = DateFormat.format(format, patchDate).toString();
} catch (ParseException e) {
// broken parse; fall through and use the raw string