diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-01-23 23:01:11 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-23 23:01:11 +0000 |
commit | 7c295dedb1baf436082c636c069d80f11dc390cb (patch) | |
tree | 9dcb2246a36aecec6b87d7010ef23ad1c5c0eeba | |
parent | 5c45f3ab54df27709153cce90f756cd1977a9138 (diff) | |
parent | 25f59f14641032fd23159eeda444218eb02f42a3 (diff) | |
download | cts-7c295dedb1baf436082c636c069d80f11dc390cb.tar.gz |
Merge "Fix animation is turned off after testing" into android13-tests-dev am: 07d5dfa2aa am: 25f59f1464
Original change: https://android-review.googlesource.com/c/platform/cts/+/2909097
Change-Id: I6ed5b88e7258bbd8b0f8339fc180841b94f455ca
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | common/device-side/util-axt/src/com/android/compatibility/common/util/OverrideAnimationScaleRule.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/OverrideAnimationScaleRule.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/OverrideAnimationScaleRule.java index 2d50bfa91cd..c48f1bf8742 100644 --- a/common/device-side/util-axt/src/com/android/compatibility/common/util/OverrideAnimationScaleRule.java +++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/OverrideAnimationScaleRule.java @@ -18,7 +18,10 @@ package com.android.compatibility.common.util; import static com.android.compatibility.common.util.SystemUtil.runShellCommand; +import android.text.TextUtils; + import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -26,6 +29,9 @@ import org.junit.runners.model.Statement; public class OverrideAnimationScaleRule extends BeforeAfterRule { + // From javadoc definition, the default animator duration scale is 1 + private static final String DEFAULT_ANIMATOR_DURATION_SCALE = "1"; + @NonNull private final GlobalSetting mWindowAnimationScaleSetting = new GlobalSetting( "window_animation_scale"); @@ -34,7 +40,7 @@ public class OverrideAnimationScaleRule extends BeforeAfterRule { "transition_animation_scale"); @NonNull private final GlobalSetting mAnimatorDurationScaleSetting = new GlobalSetting( - "animator_duration_scale"); + "animator_duration_scale", DEFAULT_ANIMATOR_DURATION_SCALE); private final float mAnimationScale; @@ -62,9 +68,15 @@ public class OverrideAnimationScaleRule extends BeforeAfterRule { private final String mName; private String mInitialValue; + private String mDefaultValue; public GlobalSetting(@NonNull String name) { + this(name, /* defaultValue= */ null); + } + + GlobalSetting(@NonNull String name, @Nullable String defaultValue) { mName = name; + mDefaultValue = defaultValue; } public void put(@NonNull String value) { @@ -73,7 +85,13 @@ public class OverrideAnimationScaleRule extends BeforeAfterRule { } public void restore() { - runShellCommand("settings put global " + mName + " " + mInitialValue); + String restoreValue = + !isEmptyOrNullString(mInitialValue.trim()) ? mInitialValue : mDefaultValue; + runShellCommand("settings put global " + mName + " " + restoreValue); + } + + private boolean isEmptyOrNullString(String value) { + return TextUtils.isEmpty(value) || TextUtils.equals(value.toLowerCase(), "null"); } } } |