diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-01-24 08:46:30 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-01-24 08:46:30 +0000 |
commit | 7c9b336d063953eabcf824f333777ba652d1089f (patch) | |
tree | 9dcb2246a36aecec6b87d7010ef23ad1c5c0eeba | |
parent | d10778c98108c8e663af8f4adc54e1aa8a4dbac6 (diff) | |
parent | 7c295dedb1baf436082c636c069d80f11dc390cb (diff) | |
download | cts-aml_tz4_332714010.tar.gz |
Snap for 11351012 from 7c295dedb1baf436082c636c069d80f11dc390cb to mainline-tzdata4-releaseaml_tz4_332714070aml_tz4_332714050aml_tz4_332714010aml_tz4_332714010
Change-Id: I7d5b2e26dc9cce6dffae993072e112773904f97d
-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"); } } } |