summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpihuei <pihuei@google.com>2023-01-16 14:50:04 +0000
committerPihuei Wang <pihuei@google.com>2023-01-16 14:52:55 +0000
commitaef17b6184392621ffab36bee05cffd453a66939 (patch)
tree0b175e08a59a1cf86fb0b87b51855b6c55a9b38a
parentff1efb9d28add86a03718854ee6894b9de269456 (diff)
downloadsetupdesign-android13-qpr3-c-s4-release.tar.gz
copied from cl/501707304 Bug: 264949555 Test: manual test Change-Id: I32db277bd7b4747a38e2dfa09bf39ccab6500e1e
-rw-r--r--main/src/com/google/android/setupdesign/util/DeviceHelper.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/main/src/com/google/android/setupdesign/util/DeviceHelper.java b/main/src/com/google/android/setupdesign/util/DeviceHelper.java
index 37c5144..1a7e0bd 100644
--- a/main/src/com/google/android/setupdesign/util/DeviceHelper.java
+++ b/main/src/com/google/android/setupdesign/util/DeviceHelper.java
@@ -53,10 +53,25 @@ public final class DeviceHelper {
* com.google.android.setupwizard.util.PartnerResource#DEVICE_NAME}) > {@link
* android.provider.Settings.Global#DEVICE_NAME} > system property ro.product.model)
*/
+ public static CharSequence getDeviceName(@NonNull Context context) {
+ return getDeviceName(context, /* enableCache= */ true);
+ }
+
+ /**
+ * Get the device name text from these resources, if they are unavailable or setupwizard apk is
+ * older which does not contains {@link DeviceHelper#GET_DEVICE_NAME_METHOD} method, return the
+ * device name as default value "device".
+ *
+ * <p>Priority: partner config ({@link
+ * com.google.android.setupwizard.util.PartnerResource#DEVICE_NAME}) > {@link
+ * android.provider.Settings.Global#DEVICE_NAME} > system property ro.product.model)
+ *
+ * @param enableCache Indicates whether the device name is preferentially obtained from the cache.
+ */
@NonNull
@SuppressLint("DiscouragedApi")
- public static CharSequence getDeviceName(@NonNull Context context) {
- if (deviceName == null || deviceName.isEmpty()) {
+ public static CharSequence getDeviceName(@NonNull Context context, boolean enableCache) {
+ if (deviceName == null || deviceName.isEmpty() || !enableCache) {
try {
deviceName =
context