diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2022-03-09 09:21:03 +0800 |
---|---|---|
committer | Pasty Chang <pastychang@google.com> | 2022-03-09 12:48:10 +0000 |
commit | 5f1c56d9797fed8acc4841977034497b0af37415 (patch) | |
tree | 946cde42a00ddb93d3b0e9b30f3821e27d487eeb | |
parent | 0158c0ced90fd4a63761400bc118d63a1dfe932d (diff) | |
download | setupcompat-5f1c56d9797fed8acc4841977034497b0af37415.tar.gz |
Import updated Android SetupCompat Library 433350413
Copied from google3/third_party/java_src/android_libs/setupcompat
Test: mm
Included changes:
- 433350413 Temporary remove PartnerCustomizedResource metrics to avo...
- 432341362 Make the loadinglayout header height match parent in land...
- 429462685 Add .proto definition for Tortal.
- 428716981 Add a partnerconfig for loading animation finished.
- 428618706 Cloned CL/423965608
- 427940353 Enable unbinding play setup service on Android T
- 427433902 [Tablet] Update the footer button style of decision point...
- 427122426 SetupCompatService should log warning instead of throw ex...
- 423493837 [Tablet] Make Vertical buttons of decision point activity...
PiperOrigin-RevId: 433350413
Change-Id: I7b0440787f97460ea1911fa69386f27ff5dc06fb
8 files changed, 40 insertions, 80 deletions
diff --git a/exempting_lint_checks.txt b/exempting_lint_checks.txt index 90b8caf..4129b20 100644 --- a/exempting_lint_checks.txt +++ b/exempting_lint_checks.txt @@ -5,3 +5,13 @@ third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setup third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java: CustomViewStyleable: attrs, R.styleable.SucPartnerCustomizationLayout, defStyleAttr, 0); third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/internal/TemplateLayout.java: CustomViewStyleable: getContext().obtainStyledAttributes(attrs, R.styleable.SucTemplateLayout, defStyleAttr, 0); third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/util/SystemBarHelper.java: AnnotateVersionCheck: public static void setImeInsetView(final View view) { +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java: CustomViewStyleable: attrs, R.styleable.SucPartnerCustomizationLayout, defStyleAttr, 0); +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java: ObsoleteSdkInt: @TargetApi(VERSION_CODES.HONEYCOMB) +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/internal/TemplateLayout.java: CustomViewStyleable: getContext().obtainStyledAttributes(attrs, R.styleable.SucTemplateLayout, defStyleAttr, 0); +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/internal/TemplateLayout.java: ObsoleteSdkInt: @TargetApi(VERSION_CODES.HONEYCOMB) +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/logging/internal/MetricBundleConverter.java: NewApi: bundle.putParcelable(MetricBundleKeys.CUSTOM_EVENT_BUNDLE, CustomEvent.toBundle(customEvent)); +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/template/FooterBarMixin.java: NewApi: onFooterButtonApplyPartnerResource(button, footerButtonPartnerConfig); +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java: NewApi: FooterButtonStyleUtils.updateButtonBackgroundWithPartnerConfig( +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java: NewApi: FooterButtonStyleUtils.updateButtonRippleColorWithPartnerConfig( +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/util/SystemBarHelper.java: AnnotateVersionCheck: public static void setImeInsetView(final View view) { +third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/view/StatusBarBackgroundLayout.java: ObsoleteSdkInt: @TargetApi(VERSION_CODES.HONEYCOMB) diff --git a/main/java/com/google/android/setupcompat/internal/SetupCompatServiceProvider.java b/main/java/com/google/android/setupcompat/internal/SetupCompatServiceProvider.java index e75d991..e259f22 100644 --- a/main/java/com/google/android/setupcompat/internal/SetupCompatServiceProvider.java +++ b/main/java/com/google/android/setupcompat/internal/SetupCompatServiceProvider.java @@ -82,8 +82,8 @@ public class SetupCompatServiceProvider { return waitForConnection(timeout, timeUnit); case NOT_STARTED: - throw new IllegalStateException( - "NOT_STARTED state only possible before instance is created."); + LOG.w("NOT_STARTED state only possible before instance is created."); + return null; } throw new IllegalStateException("Unknown state = " + serviceContext.state); } @@ -172,7 +172,8 @@ public class SetupCompatServiceProvider { return serviceContext; } - private void swapServiceContextAndNotify(ServiceContext latestServiceContext) { + @VisibleForTesting + void swapServiceContextAndNotify(ServiceContext latestServiceContext) { LOG.atInfo( String.format("State changed: %s -> %s", serviceContext.state, latestServiceContext.state)); @@ -200,7 +201,7 @@ public class SetupCompatServiceProvider { return countDownLatch; } countDownLatch = createCountDownLatch(); - } while (!connectedConditionRef.compareAndSet(/* expect= */ null, countDownLatch)); + } while (!connectedConditionRef.compareAndSet(/* expectedValue= */ null, countDownLatch)); return countDownLatch; } @@ -285,7 +286,8 @@ public class SetupCompatServiceProvider { REBIND_REQUIRED } - private static final class ServiceContext { + @VisibleForTesting + static final class ServiceContext { final State state; @Nullable final ISetupCompatService compatService; @@ -298,7 +300,8 @@ public class SetupCompatServiceProvider { } } - private ServiceContext(State state) { + @VisibleForTesting + ServiceContext(State state) { this(state, /* compatService= */ null); } } diff --git a/main/java/com/google/android/setupcompat/logging/internal/PartnerCustomizedResourceListMetric.java b/main/java/com/google/android/setupcompat/logging/internal/PartnerCustomizedResourceListMetric.java deleted file mode 100644 index 2aa1240..0000000 --- a/main/java/com/google/android/setupcompat/logging/internal/PartnerCustomizedResourceListMetric.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.setupcompat.logging.internal; - -import android.annotation.TargetApi; -import android.content.Context; -import android.os.Build.VERSION_CODES; -import android.os.Bundle; -import android.os.PersistableBundle; -import androidx.annotation.VisibleForTesting; -import com.google.android.setupcompat.logging.CustomEvent; -import com.google.android.setupcompat.logging.MetricKey; -import com.google.android.setupcompat.logging.SetupMetricsLogger; - -/** Uses to log internal event customization resource list. */ -@TargetApi(VERSION_CODES.Q) -public class PartnerCustomizedResourceListMetric { - - public static void logMetrics(Context context, String deviceDisplayName, Bundle bundle) { - PersistableBundle logBundle = - buildLogBundleFromResourceConfigBundle(context.getPackageName(), deviceDisplayName, bundle); - if (!logBundle.isEmpty()) { - SetupMetricsLogger.logCustomEvent( - context, - CustomEvent.create( - MetricKey.get("PartnerCustomizationResource", "NoScreenName"), logBundle)); - } - } - - @VisibleForTesting - public static PersistableBundle buildLogBundleFromResourceConfigBundle( - String defaultPackageName, String deviceDisplayName, Bundle resourceConfigBundle) { - PersistableBundle persistableBundle = new PersistableBundle(); - persistableBundle.putString("deviceDisplayName", deviceDisplayName); - for (String key : resourceConfigBundle.keySet()) { - Bundle resourceExtra = resourceConfigBundle.getBundle(key); - if (!resourceExtra.getString("packageName", defaultPackageName).equals(defaultPackageName)) { - persistableBundle.putBoolean(resourceExtra.getString("resourceName", key), true); - } else { - persistableBundle.putBoolean(resourceExtra.getString("resourceName", key), false); - } - } - - return persistableBundle; - } -} diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java index 6d92c40..9af0077 100644 --- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java +++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java @@ -73,7 +73,7 @@ public class FooterBarMixin implements Mixin { @VisibleForTesting final boolean applyDynamicColor; @VisibleForTesting final boolean useFullDynamicColor; - @VisibleForTesting LinearLayout buttonContainer; + @VisibleForTesting public LinearLayout buttonContainer; private FooterButton primaryButton; private FooterButton secondaryButton; @IdRes private int primaryButtonId; @@ -226,7 +226,7 @@ public class FooterBarMixin implements Mixin { FooterButtonStyleUtils.clearSavedDefaultTextColor(); } - private boolean isFooterButtonAlignedEnd() { + protected boolean isFooterButtonAlignedEnd() { if (PartnerConfigHelper.get(context) .isPartnerConfigAvailable(PartnerConfig.CONFIG_FOOTER_BUTTON_ALIGNED_END)) { return PartnerConfigHelper.get(context) @@ -247,11 +247,11 @@ public class FooterBarMixin implements Mixin { } private View addSpace() { - LinearLayout buttonContainer = ensureFooterInflated(); + LinearLayout buttonContainerlayout = ensureFooterInflated(); View space = new View(context); space.setLayoutParams(new LayoutParams(0, 0, 1.0f)); space.setVisibility(View.INVISIBLE); - buttonContainer.addView(space); + buttonContainerlayout.addView(space); return space; } @@ -615,10 +615,7 @@ public class FooterBarMixin implements Mixin { int color = PartnerConfigHelper.get(context).getColor(context, buttonBackgroundColorConfig); if (color == Color.TRANSPARENT) { overrideTheme = R.style.SucPartnerCustomizationButton_Secondary; - } else if (color != Color.TRANSPARENT) { - // TODO: remove the constrain (color != Color.WHITE), need to check all pages - // go well without customization. It should be fine since the default value of secondary bg - // color is set as transparent. + } else { overrideTheme = R.style.SucPartnerCustomizationButton_Primary; } } diff --git a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java index 5b7c3ad..8fa862f 100644 --- a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java +++ b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java @@ -60,15 +60,14 @@ public final class BuildCompatUtils { * <p>Supported configurations: * * <ul> - * <li>For current Android release: while new API is not finalized yet (CODENAME = "T", SDK_INT - * = 33) + * <li>For current Android release: while new API is not finalized yet (CODENAME = "Tiramisu", + * SDK_INT = 33) * <li>For current Android release: when new API is finalized (CODENAME = "REL", SDK_INT = 32) * <li>For next Android release (CODENAME = "U", SDK_INT = 34+) * </ul> * * <p>Note that Build.VERSION_CODES.T cannot be used here until final SDK is available in all - * channels, because it is equal to Build.VERSION_CODES.CUR_DEVELOPMENT before API - * finalization. + * channels, because it is equal to Build.VERSION_CODES.CUR_DEVELOPMENT before API finalization. * * @return Whether the current OS version is higher or equal to T. */ @@ -79,7 +78,8 @@ public final class BuildCompatUtils { return (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 33) || (Build.VERSION.CODENAME.length() == 1 && Build.VERSION.CODENAME.charAt(0) >= 'T' - && Build.VERSION.CODENAME.charAt(0) <= 'Z'); + && Build.VERSION.CODENAME.charAt(0) <= 'Z') + || (Build.VERSION.CODENAME.equals("Tiramisu") && Build.VERSION.SDK_INT >= 32); } private BuildCompatUtils() {} diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java index 442e86c..c9a1966 100644 --- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java +++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java @@ -456,6 +456,10 @@ public enum PartnerConfig { CONFIG_LOADING_LAYOUT_FULL_SCREEN_ILLUSTRATION_ENABLED( PartnerConfigKey.KEY_LOADING_LAYOUT_FULL_SCREEN_ILLUSTRATION_ENABLED, ResourceType.BOOL), + // Waiting for the animation finished before process to the next page/action. + CONFIG_LOADING_LAYOUT_WAIT_FOR_ANIMATION_FINISHED( + PartnerConfigKey.KEY_LOADING_LAYOUT_WAIT_FOR_ANIMATION_FINISHED, ResourceType.BOOL), + // The margin top of progress bar. CONFIG_PROGRESS_BAR_MARGIN_TOP( PartnerConfigKey.KEY_PROGRESS_BAR_MARGIN_TOP, ResourceType.DIMENSION), diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java index 3c35d29..0eeec5f 100644 --- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java +++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java @@ -89,7 +89,8 @@ public class PartnerConfigHelper { private static int savedConfigUiMode; - private static int savedOrientation = Configuration.ORIENTATION_PORTRAIT; + @VisibleForTesting + public static int savedOrientation = Configuration.ORIENTATION_PORTRAIT; /** * When testing related to fake PartnerConfigHelper instance, should sync the following saved diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java index cbf72f5..3fe7991 100644 --- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java +++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java @@ -138,6 +138,7 @@ import java.lang.annotation.RetentionPolicy; PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_BOTTOM, PartnerConfigKey.KEY_LOADING_LAYOUT_HEADER_HEIGHT, PartnerConfigKey.KEY_LOADING_LAYOUT_FULL_SCREEN_ILLUSTRATION_ENABLED, + PartnerConfigKey.KEY_LOADING_LAYOUT_WAIT_FOR_ANIMATION_FINISHED, PartnerConfigKey.KEY_PROGRESS_BAR_MARGIN_TOP, PartnerConfigKey.KEY_PROGRESS_BAR_MARGIN_BOTTOM, }) @@ -520,6 +521,10 @@ public @interface PartnerConfigKey { String KEY_LOADING_LAYOUT_FULL_SCREEN_ILLUSTRATION_ENABLED = "loading_layout_full_screen_illustration_enabled"; + // Waiting the animation finished before process to the next page/action. + String KEY_LOADING_LAYOUT_WAIT_FOR_ANIMATION_FINISHED = + "loading_layout_wait_for_animation_finished"; + // A margin top of the content frame of progress bar. String KEY_PROGRESS_BAR_MARGIN_TOP = "setup_design_progress_bar_margin_top"; |