Import updated Android SetupCompat Library 436455639 am: 5be9fc7d68
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupcompat/+/17312338
Change-Id: I58bb1334b0a1a594babe8ca0f751a88a51c83d1d
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
index 0eeec5f..98f6b6b 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
@@ -68,6 +68,9 @@
@VisibleForTesting
public static final String IS_NEUTRAL_BUTTON_STYLE_ENABLED_METHOD = "isNeutralButtonStyleEnabled";
+ @VisibleForTesting public static final String SUW_PACKAGE_NAME = "com.google.android.setupwizard";
+ @VisibleForTesting public static final String MATERIAL_YOU_RESOURCE_SUFFIX = "_material_you";
+
@VisibleForTesting static Bundle suwDayNightEnabledBundle = null;
@VisibleForTesting public static Bundle applyExtendedPartnerConfigBundle = null;
@@ -544,9 +547,10 @@
if (fallbackBundle != null) {
resourceEntryBundle.putBundle(KEY_FALLBACK_CONFIG, fallbackBundle.getBundle(resourceName));
}
-
- return adjustResourceEntryDayNightMode(
- context, ResourceEntry.fromBundle(context, resourceEntryBundle));
+ ResourceEntry tempResult =
+ adjustResourceEntryDefaultValue(
+ context, ResourceEntry.fromBundle(context, resourceEntryBundle));
+ return adjustResourceEntryDayNightMode(context, tempResult);
}
/**
@@ -571,6 +575,45 @@
return resourceEntry;
}
+ // Check the MNStyle flag and replace the inputResourceEntry.resourceName &
+ // inputResourceEntry.resourceId
+ private ResourceEntry adjustResourceEntryDefaultValue(
+ Context context, ResourceEntry inputResourceEntry) {
+ boolean useMaterialYouDefaultValue = shouldApplyMaterialYouStyle(context);
+ if (useMaterialYouDefaultValue) {
+ // If not overlay resource
+ try {
+ if (SUW_PACKAGE_NAME.equals(inputResourceEntry.getPackageName())) {
+ String resourceTypeName =
+ inputResourceEntry
+ .getResources()
+ .getResourceTypeName(inputResourceEntry.getResourceId());
+ // try to update resourceName & resourceId
+ String materialYouResourceName =
+ inputResourceEntry.getResourceName().concat(MATERIAL_YOU_RESOURCE_SUFFIX);
+ int materialYouResourceId =
+ inputResourceEntry
+ .getResources()
+ .getIdentifier(
+ materialYouResourceName,
+ resourceTypeName,
+ inputResourceEntry.getPackageName());
+ if (materialYouResourceId != 0) {
+ Log.i(TAG, "use material you resource:" + materialYouResourceName);
+ return new ResourceEntry(
+ inputResourceEntry.getPackageName(),
+ materialYouResourceName,
+ materialYouResourceId,
+ inputResourceEntry.getResources());
+ }
+ }
+ } catch (NotFoundException ex) {
+ // fall through
+ }
+ }
+ return inputResourceEntry;
+ }
+
@VisibleForTesting
public static synchronized void resetInstance() {
instance = null;