Import updated Android SetupCompat Library 436455639
Copied from google3/third_party/java_src/android_libs/setupcompat
Test: mm
Included changes:
- 436455639 Automated g4 rollback of changelist 436438841.
- 436450355 Automated g4 rollback of changelist 436406248.
- 436438841 Return extended flag before S and return MY flag after T.
- 436406248 Update Glifv4 default value for button.
- 435273911 Add additional fields needed by Tortal to the info module...
- 435054680 [SetupDesign] use the SUW MY default while MY flag on & n...
PiperOrigin-RevId: 436455639
Change-Id: I932b3258016cd7f99206aa1a678a947cd1b08d5b
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;