Add predictive back aconfig flag
Bug: 309545085
Flag: ACONFIG com.android.window.flags.predictive_back_system_animations DISABLED
Test: atest BackAnimationPreferenceControllerTest; Manual, i.e. building and verifying correct behaviour for different flag configurations
Change-Id: I3f478dc23bbfeb1f13cae64f3d04b3210841731d
diff --git a/src/com/android/settings/development/BackAnimationPreferenceController.java b/src/com/android/settings/development/BackAnimationPreferenceController.java
index aa4faf5..95ffc25 100644
--- a/src/com/android/settings/development/BackAnimationPreferenceController.java
+++ b/src/com/android/settings/development/BackAnimationPreferenceController.java
@@ -16,6 +16,8 @@
package com.android.settings.development;
+import static com.android.window.flags.Flags.predictiveBackSystemAnimations;
+
import android.content.Context;
import android.provider.Settings;
@@ -56,6 +58,11 @@
}
@Override
+ public boolean isAvailable() {
+ return !predictiveBackSystemAnimations();
+ }
+
+ @Override
public String getPreferenceKey() {
return BACK_NAVIGATION_ANIMATION_KEY;
}
diff --git a/tests/unit/src/com/android/settings/development/BackAnimationPreferenceControllerTest.java b/tests/unit/src/com/android/settings/development/BackAnimationPreferenceControllerTest.java
index 3669358..dc4f56a 100644
--- a/tests/unit/src/com/android/settings/development/BackAnimationPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/development/BackAnimationPreferenceControllerTest.java
@@ -29,6 +29,10 @@
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
import androidx.preference.PreferenceManager;
@@ -37,8 +41,11 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
+import com.android.window.flags.Flags;
+
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -58,6 +65,9 @@
private BackAnimationPreferenceController mController;
private Looper mLooper;
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -81,6 +91,18 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_PREDICTIVE_BACK_SYSTEM_ANIMATIONS)
+ public void controllerNotAvailable_whenAconfigFlagEnabled() {
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ @RequiresFlagsDisabled(Flags.FLAG_PREDICTIVE_BACK_SYSTEM_ANIMATIONS)
+ public void controllerAvailable_whenAconfigFlagDisabled() {
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
public void onPreferenceChange_switchEnabled_shouldEnableBackAnimations() {
mController.onPreferenceChange(mPreference, true /* new value */);