Import updated Android SetupCompat Library 397257643
Copied from google3/third_party/java_src/android_libs/setupcompat
Test: mm
Included changes:
- 397257643 Automated g4 rollback of changelist 396830381.
- 396830381 Automated g4 rollback of changelist 396740154.
- 396740154 Clear data cached when screen size change.
- 393330297 [Tablet] Support new button style in decision point lands...
- 392331695 Migrate setupwizard util "BuildCompatUtils" into setupcom...
Bug: 200764013
PiperOrigin-RevId: 397257643
Change-Id: I5d2a8b1bd5f53490e680d528ea71144cd9ec239f
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index 3a03559..52e3dc9 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -233,7 +233,7 @@
}
}
- private boolean isFooterButtonsEvenlyWeighted() {
+ protected boolean isFooterButtonsEvenlyWeighted() {
if (!isSecondaryButtonInPrimaryStyle) {
return false;
}
diff --git a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
index 3583b93..7fac760 100644
--- a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
+++ b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
@@ -26,6 +26,15 @@
public final class BuildCompatUtils {
/**
+ * Implementation of BuildCompat.isAtLeastR() suitable for use in Setup
+ *
+ * @return Whether the current OS version is higher or equal to R.
+ */
+ @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.R)
+ public static boolean isAtLeastR() {
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
+ }
+ /**
* Implementation of BuildCompat.isAtLeastS() suitable for use in Setup
*
* @return Whether the current OS version is higher or equal to S.
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
index 27bd521..c0be011 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
@@ -81,6 +81,14 @@
private static int savedOrientation = Configuration.ORIENTATION_PORTRAIT;
+ /**
+ * When testing related to fake PartnerConfigHelper instance, should sync the following saved
+ * config with testing environment.
+ */
+ @VisibleForTesting public static int savedScreenHeight = Configuration.SCREEN_HEIGHT_DP_UNDEFINED;
+
+ @VisibleForTesting public static int savedScreenWidth = Configuration.SCREEN_WIDTH_DP_UNDEFINED;
+
public static synchronized PartnerConfigHelper get(@NonNull Context context) {
if (!isValidInstance(context)) {
instance = new PartnerConfigHelper(context);
@@ -93,15 +101,21 @@
if (instance == null) {
savedConfigUiMode = currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
savedOrientation = currentConfig.orientation;
+ savedScreenWidth = currentConfig.screenWidthDp;
+ savedScreenHeight = currentConfig.screenHeightDp;
return false;
} else {
- if (isSetupWizardDayNightEnabled(context)
- && (currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) != savedConfigUiMode) {
+ boolean uiModeChanged =
+ isSetupWizardDayNightEnabled(context)
+ && (currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) != savedConfigUiMode;
+ if (uiModeChanged
+ || currentConfig.orientation != savedOrientation
+ || currentConfig.screenWidthDp != savedScreenWidth
+ || currentConfig.screenHeightDp != savedScreenHeight) {
savedConfigUiMode = currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
- resetInstance();
- return false;
- } else if (currentConfig.orientation != savedOrientation) {
savedOrientation = currentConfig.orientation;
+ savedScreenHeight = currentConfig.screenHeightDp;
+ savedScreenWidth = currentConfig.screenWidthDp;
resetInstance();
return false;
}