Import updated Android Setupdesign Library 484134457 am: 06febcd5c0

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupdesign/+/20306065

Change-Id: Ib708147be141014198d93ef79ef2de760adfbb64
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/main/res/values-v31/styles.xml b/main/res/values-v31/styles.xml
index 1be5b13..5fab1c1 100644
--- a/main/res/values-v31/styles.xml
+++ b/main/res/values-v31/styles.xml
@@ -198,6 +198,8 @@
   </style>
 
   <style name="SudAppCompatButtonButtonBarAlertDialog" parent="Widget.AppCompat.ButtonBar.AlertDialog">
+    <item name="android:layout_marginStart">@dimen/sud_glif_alert_dialog_footer_bar_padding_start</item>
+    <item name="android:layout_marginLeft">@dimen/sud_glif_alert_dialog_footer_bar_padding_start</item>
     <item name="android:textAppearance">@style/SudTextAppearanceDeviceDefaultMedium</item>
     <item name="android:minWidth">@dimen/sud_alert_dialog_button_bar_width</item>
     <item name="android:minHeight">@dimen/sud_alert_dialog_button_bar_height</item>
diff --git a/main/res/values/dimens.xml b/main/res/values/dimens.xml
index 1562cc5..d3f0d02 100644
--- a/main/res/values/dimens.xml
+++ b/main/res/values/dimens.xml
@@ -56,6 +56,7 @@
     <dimen name="sud_horizontal_icon_height">32dp</dimen>
 
     <dimen name="sud_glif_alert_dialog_corner_radius">8dp</dimen>
+    <dimen name="sud_glif_alert_dialog_footer_bar_padding_start">8dp</dimen>
     <dimen name="sud_glif_v3_button_corner_radius">4dp</dimen>
     <dimen name="sud_glif_device_default_dialog_corner_radius">28dp</dimen>
     <dimen name="sud_glif_land_header_area_weight">1</dimen>
diff --git a/main/src/com/google/android/setupdesign/util/DeviceHelper.java b/main/src/com/google/android/setupdesign/util/DeviceHelper.java
index 5845cbb..37c5144 100644
--- a/main/src/com/google/android/setupdesign/util/DeviceHelper.java
+++ b/main/src/com/google/android/setupdesign/util/DeviceHelper.java
@@ -16,26 +16,34 @@
 
 package com.google.android.setupdesign.util;
 
+import android.annotation.SuppressLint;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.res.Resources.NotFoundException;
 import android.net.Uri;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.util.Log;
 import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
 import androidx.annotation.VisibleForTesting;
+import com.google.android.setupcompat.util.Logger;
 import com.google.android.setupdesign.R;
 
 /** Helper class to get attributes of the device, like a friendly display name. */
 public final class DeviceHelper {
 
+  private static final Logger LOG = new Logger("DeviceHelper");
   private static final String TAG = DeviceHelper.class.getSimpleName();
 
   @VisibleForTesting
   public static final String SUW_AUTHORITY = "com.google.android.setupwizard.partner";
 
+  @VisibleForTesting public static final String DEVICE_NAME = "device_name";
+  private static final String STRING = "string";
   @VisibleForTesting public static final String GET_DEVICE_NAME_METHOD = "getDeviceName";
 
+  @VisibleForTesting public static Bundle deviceName = null;
+
   /**
    * 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
@@ -45,30 +53,47 @@
    * com.google.android.setupwizard.util.PartnerResource#DEVICE_NAME}) > {@link
    * android.provider.Settings.Global#DEVICE_NAME} > system property ro.product.model)
    */
-  @Nullable
+  @NonNull
+  @SuppressLint("DiscouragedApi")
   public static CharSequence getDeviceName(@NonNull Context context) {
-    Bundle deviceName = null;
-
-    try {
-      deviceName =
-          context
-              .getContentResolver()
-              .call(
-                  new Uri.Builder()
-                      .scheme(ContentResolver.SCHEME_CONTENT)
-                      .authority(SUW_AUTHORITY)
-                      .build(),
-                  GET_DEVICE_NAME_METHOD,
-                  /* arg= */ null,
-                  /* extras= */ null);
-    } catch (IllegalArgumentException | SecurityException exception) {
-      Log.w(TAG, "device name unknown; return the device name as default value");
+    if (deviceName == null || deviceName.isEmpty()) {
+      try {
+        deviceName =
+            context
+                .getContentResolver()
+                .call(
+                    new Uri.Builder()
+                        .scheme(ContentResolver.SCHEME_CONTENT)
+                        .authority(SUW_AUTHORITY)
+                        .build(),
+                    GET_DEVICE_NAME_METHOD,
+                    /* arg= */ null,
+                    /* extras= */ null);
+      } catch (IllegalArgumentException | SecurityException exception) {
+        Log.w(TAG, "device name unknown; return the device name as default value");
+      }
     }
 
-    if (deviceName != null) {
+    if (deviceName != null && !deviceName.isEmpty()) {
       return deviceName.getCharSequence(GET_DEVICE_NAME_METHOD, null);
     }
 
+    Partner partner = Partner.get(context);
+    if (partner != null) {
+      try {
+        int resId =
+            partner.getResources().getIdentifier(DEVICE_NAME, STRING, partner.getPackageName());
+        String overlayDeviceName = partner.getResources().getString(resId);
+        if (!TextUtils.isEmpty(overlayDeviceName)) {
+          return overlayDeviceName;
+        } else {
+          LOG.w("The overlayDeviceName is null!");
+        }
+      } catch (NotFoundException ex) {
+        // fall through
+      }
+    }
+
     return context.getString(R.string.sud_default_device_name);
   }