summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2022-03-29 16:20:41 +0800
committerPasty Chang <pastychang@google.com>2022-03-31 00:14:33 +0000
commit76ab3e344b1d39e1b166f33c6509f20c9f04666e (patch)
treeeb78cc922f54a6a03ef327d0052b4a8a7807b2d3
parent5be9fc7d689d48f31f94cdd1096fabd8dfa35ff9 (diff)
downloadsetupcompat-76ab3e344b1d39e1b166f33c6509f20c9f04666e.tar.gz
Import updated Android SetupCompat Library 437961224
Copied from google3/third_party/java_src/android_libs/setupcompat Test: mm Bug: 225800660 Included changes: - 437961224 Automated g4 rollback of changelist 437849321. - 437849321 Automated g4 rollback of changelist 437438413. - 437438413 Automated g4 rollback of changelist 436450355. - 437188126 Avoid empty bundle to cause return incorrect result in sh... - 436966525 Add an API to check portal flow - 436688125 Automated g4 rollback of changelist 436455639. PiperOrigin-RevId: 437961224 Change-Id: I0d010db4eb7feb12d5958c7e5870df10f771632c
-rw-r--r--main/java/com/google/android/setupcompat/util/WizardManagerHelper.java11
-rw-r--r--partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java28
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;