Switching to setting QS on and off via writing settings.
We can do this now because we hav all 6 devices in the lab. Change-Id: I5d5fcd89086a3f945ed3fc204461cacbdde61a8a
This commit is contained in:
parent
3a4f503e5d
commit
8675deee02
|
@ -175,7 +175,7 @@ public class OverviewInteractionState {
|
|||
}
|
||||
}
|
||||
|
||||
public void notifySwipeUpSettingChanged(boolean swipeUpEnabled) {
|
||||
private void notifySwipeUpSettingChanged(boolean swipeUpEnabled) {
|
||||
mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED);
|
||||
mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0).
|
||||
sendToTarget();
|
||||
|
|
|
@ -19,6 +19,11 @@ package com.android.quickstep;
|
|||
import static com.android.quickstep.QuickStepOnOffRule.Mode.BOTH;
|
||||
import static com.android.quickstep.QuickStepOnOffRule.Mode.OFF;
|
||||
import static com.android.quickstep.QuickStepOnOffRule.Mode.ON;
|
||||
import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
|
||||
|
@ -69,38 +74,52 @@ public class QuickStepOnOffRule implements TestRule {
|
|||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
try {
|
||||
if (mode == ON || mode == BOTH) {
|
||||
evaluateWithQuickstepOn();
|
||||
}
|
||||
if (mode == OFF || mode == BOTH) {
|
||||
evaluateWithQuickstepOff();
|
||||
if (SwipeUpSetting.isSwipeUpSettingAvailable()) {
|
||||
if (mode == ON || mode == BOTH) {
|
||||
evaluateWithQuickstepOn();
|
||||
}
|
||||
if (mode == OFF || mode == BOTH) {
|
||||
evaluateWithQuickstepOff();
|
||||
}
|
||||
} else {
|
||||
// Execute without changing the setting, if the requested mode is
|
||||
// compatible.
|
||||
final boolean swipeUpEnabledDefaultValue =
|
||||
SwipeUpSetting.isSwipeUpEnabledDefaultValue();
|
||||
if (mode == BOTH ||
|
||||
mode == ON && swipeUpEnabledDefaultValue ||
|
||||
mode == OFF && !swipeUpEnabledDefaultValue) {
|
||||
evaluateWithoutChangingSetting(base);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
overrideSwipeUpEnabled(null);
|
||||
setSwipeUpSetting(null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateWithQuickstepOff() throws Throwable {
|
||||
overrideSwipeUpEnabled(false);
|
||||
public void setSwipeUpSetting(String value) {
|
||||
assertTrue("Couldn't change Quickstep mode",
|
||||
Settings.Secure.putString(
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext().
|
||||
getContentResolver(),
|
||||
SWIPE_UP_SETTING_NAME,
|
||||
value));
|
||||
}
|
||||
|
||||
public void evaluateWithoutChangingSetting(Statement base) throws Throwable {
|
||||
base.evaluate();
|
||||
}
|
||||
|
||||
private void evaluateWithQuickstepOff() throws Throwable {
|
||||
setSwipeUpSetting("0");
|
||||
evaluateWithoutChangingSetting(base);
|
||||
}
|
||||
|
||||
private void evaluateWithQuickstepOn() throws Throwable {
|
||||
overrideSwipeUpEnabled(true);
|
||||
setSwipeUpSetting("1");
|
||||
base.evaluate();
|
||||
}
|
||||
|
||||
private void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride)
|
||||
throws Throwable {
|
||||
mLauncher.overrideSwipeUpEnabled(swipeUpEnabledOverride);
|
||||
mMainThreadExecutor.execute(() -> OverviewInteractionState.INSTANCE.get(
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext()).
|
||||
notifySwipeUpSettingChanged(mLauncher.isSwipeUpEnabled()));
|
||||
// TODO(b/124236673): avoid using sleep().
|
||||
mLauncher.getDevice().waitForIdle();
|
||||
Thread.sleep(2000);
|
||||
mLauncher.getDevice().waitForIdle();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return base;
|
||||
|
|
|
@ -93,8 +93,6 @@ public final class LauncherInstrumentation {
|
|||
private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);
|
||||
|
||||
private final UiDevice mDevice;
|
||||
private final boolean mSwipeUpEnabled;
|
||||
private Boolean mSwipeUpEnabledOverride = null;
|
||||
private final Instrumentation mInstrumentation;
|
||||
private int mExpectedRotation = Surface.ROTATION_0;
|
||||
|
||||
|
@ -104,13 +102,6 @@ public final class LauncherInstrumentation {
|
|||
public LauncherInstrumentation(Instrumentation instrumentation) {
|
||||
mInstrumentation = instrumentation;
|
||||
mDevice = UiDevice.getInstance(instrumentation);
|
||||
final boolean swipeUpEnabledDefaultValue = SwipeUpSetting.isSwipeUpEnabledDefaultValue();
|
||||
mSwipeUpEnabled = SwipeUpSetting.isSwipeUpSettingAvailable() ?
|
||||
Settings.Secure.getInt(
|
||||
instrumentation.getTargetContext().getContentResolver(),
|
||||
SWIPE_UP_SETTING_NAME,
|
||||
swipeUpEnabledDefaultValue ? 1 : 0) == 1 :
|
||||
swipeUpEnabledDefaultValue;
|
||||
|
||||
// Launcher should run in test harness so that custom accessibility protocol between
|
||||
// Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
|
||||
|
@ -119,17 +110,18 @@ public final class LauncherInstrumentation {
|
|||
TestHelpers.isInLauncherProcess() || ActivityManager.isRunningInTestHarness());
|
||||
}
|
||||
|
||||
// Used only by TaplTests.
|
||||
public void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride) {
|
||||
mSwipeUpEnabledOverride = swipeUpEnabledOverride;
|
||||
}
|
||||
|
||||
void setActiveContainer(VisibleContainer container) {
|
||||
sActiveContainer = new WeakReference<>(container);
|
||||
}
|
||||
|
||||
public boolean isSwipeUpEnabled() {
|
||||
return mSwipeUpEnabledOverride != null ? mSwipeUpEnabledOverride : mSwipeUpEnabled;
|
||||
final boolean swipeUpEnabledDefaultValue = SwipeUpSetting.isSwipeUpEnabledDefaultValue();
|
||||
return SwipeUpSetting.isSwipeUpSettingAvailable() ?
|
||||
Settings.Secure.getInt(
|
||||
mInstrumentation.getTargetContext().getContentResolver(),
|
||||
SWIPE_UP_SETTING_NAME,
|
||||
swipeUpEnabledDefaultValue ? 1 : 0) == 1 :
|
||||
swipeUpEnabledDefaultValue;
|
||||
}
|
||||
|
||||
static void log(String message) {
|
||||
|
|
Loading…
Reference in New Issue