diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2022-04-01 00:46:50 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-04-01 00:46:50 +0000 |
commit | c9e1534352b7ea480a7af4c18d235bbf01ae2546 (patch) | |
tree | eb78cc922f54a6a03ef327d0052b4a8a7807b2d3 | |
parent | a427e5d6dadbf1eb9bfb2bcc0affb6244dfcc156 (diff) | |
parent | 76ab3e344b1d39e1b166f33c6509f20c9f04666e (diff) | |
download | setupcompat-c9e1534352b7ea480a7af4c18d235bbf01ae2546.tar.gz |
Import updated Android SetupCompat Library 437961224 am: 76ab3e344b
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupcompat/+/17506552
Change-Id: I9ed32b68e278cffa9389011565fa0bf0831c6273
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | main/java/com/google/android/setupcompat/util/WizardManagerHelper.java | 11 | ||||
-rw-r--r-- | partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java | 28 |
2 files changed, 30 insertions, 9 deletions
diff --git a/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java b/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java index 84bd68b..90de25e 100644 --- a/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java +++ b/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java @@ -186,6 +186,17 @@ public final class WizardManagerHelper { } /** + * Checks whether an intent is running in the portal setup wizard flow. + * + * @param originalIntent The original intent that was used to start the step, usually via {@link + * Activity#getIntent()}. + * @return true if the intent passed in was running in portal setup wizard. + */ + public static boolean isPortalSetupWizard(Intent originalIntent) { + return originalIntent != null && originalIntent.getBooleanExtra(EXTRA_IS_PORTAL_SETUP, false); + } + + /** * Checks whether an intent is running in the deferred setup wizard flow. * * @param originalIntent The original intent that was used to start the step, usually via {@link diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java index 98f6b6b..aca9a07 100644 --- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java +++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java @@ -35,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.google.android.setupcompat.partnerconfig.PartnerConfig.ResourceType; +import com.google.android.setupcompat.util.BuildCompatUtils; import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; @@ -547,10 +548,10 @@ public class PartnerConfigHelper { if (fallbackBundle != null) { resourceEntryBundle.putBundle(KEY_FALLBACK_CONFIG, fallbackBundle.getBundle(resourceName)); } - ResourceEntry tempResult = + ResourceEntry adjustResourceEntry = adjustResourceEntryDefaultValue( context, ResourceEntry.fromBundle(context, resourceEntryBundle)); - return adjustResourceEntryDayNightMode(context, tempResult); + return adjustResourceEntryDayNightMode(context, adjustResourceEntry); } /** @@ -576,11 +577,10 @@ public class PartnerConfigHelper { } // Check the MNStyle flag and replace the inputResourceEntry.resourceName & - // inputResourceEntry.resourceId - private ResourceEntry adjustResourceEntryDefaultValue( - Context context, ResourceEntry inputResourceEntry) { - boolean useMaterialYouDefaultValue = shouldApplyMaterialYouStyle(context); - if (useMaterialYouDefaultValue) { + // inputResourceEntry.resourceId after T, that means if using Gliv4 before S, will always use + // glifv3 resources. + ResourceEntry adjustResourceEntryDefaultValue(Context context, ResourceEntry inputResourceEntry) { + if (BuildCompatUtils.isAtLeastT() && shouldApplyMaterialYouStyle(context)) { // If not overlay resource try { if (SUW_PACKAGE_NAME.equals(inputResourceEntry.getPackageName())) { @@ -678,9 +678,12 @@ public class PartnerConfigHelper { IS_EXTENDED_PARTNER_CONFIG_ENABLED_METHOD, false)); } - /** Returns true if the SetupWizard is flow enabled "Material You(Glifv4)" style. */ + /** + * Returns true if the SetupWizard is flow enabled "Material You(Glifv4)" style, or the result of + * shouldApplyExtendedPartnerConfig() in SDK S as fallback. + */ public static boolean shouldApplyMaterialYouStyle(@NonNull Context context) { - if (applyMaterialYouConfigBundle == null) { + if (applyMaterialYouConfigBundle == null || applyMaterialYouConfigBundle.isEmpty()) { try { applyMaterialYouConfigBundle = context @@ -690,6 +693,13 @@ public class PartnerConfigHelper { IS_MATERIAL_YOU_STYLE_ENABLED_METHOD, /* arg= */ null, /* extras= */ null); + // The suw version did not support the flag yet, fallback to + // shouldApplyExtendedPartnerConfig() for SDK S. + if (applyMaterialYouConfigBundle != null + && applyMaterialYouConfigBundle.isEmpty() + && !BuildCompatUtils.isAtLeastT()) { + return shouldApplyExtendedPartnerConfig(context); + } } catch (IllegalArgumentException | SecurityException exception) { Log.w(TAG, "SetupWizard Material You configs supporting status unknown; return as false."); applyMaterialYouConfigBundle = null; |