Loading quickstep/src/com/android/quickstep/NavBarModeOverlayResourceObserver.java 0 → 100644 +85 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.android.quickstep; import static android.content.Intent.ACTION_OVERLAY_CHANGED; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.util.Log; import com.android.systemui.shared.system.QuickStepContract; /** * Observer for the resource config that specifies the navigation bar mode. */ public class NavBarModeOverlayResourceObserver extends BroadcastReceiver { private static final String TAG = "NavBarModeOverlayResourceObserver"; private static final String NAV_BAR_INTERACTION_MODE_RES_NAME = "config_navBarInteractionMode"; private final Context mContext; private final OnChangeListener mOnChangeListener; public NavBarModeOverlayResourceObserver(Context context, OnChangeListener listener) { mContext = context; mOnChangeListener = listener; } public void register() { IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED); filter.addDataScheme("package"); mContext.registerReceiver(this, filter); } @Override public void onReceive(Context context, Intent intent) { mOnChangeListener.onNavBarModeChanged(getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); } public interface OnChangeListener { void onNavBarModeChanged(int mode); } public static boolean isSwipeUpModeEnabled(Context context) { return QuickStepContract.isSwipeUpMode(getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); } public static boolean isEdgeToEdgeModeEnabled(Context context) { return QuickStepContract.isGesturalMode(getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); } private static int getSystemIntegerRes(Context context, String resName) { Resources res = context.getResources(); int resId = res.getIdentifier(resName, "integer", "android"); if (resId != 0) { return res.getInteger(resId); } else { Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?"); return -1; } } } quickstep/src/com/android/quickstep/OverviewInteractionState.java +17 −10 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ */ package com.android.quickstep; import static com.android.quickstep.SwipeUpSetting.newSwipeUpSettingsObserver; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_QUICK_SCRUB; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON; Loading @@ -28,10 +27,11 @@ import android.util.Log; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SecureSettingsObserver; import com.android.launcher3.util.UiThreadHelper; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.system.QuickStepContract; import androidx.annotation.WorkerThread; Loading @@ -58,7 +58,8 @@ public class OverviewInteractionState { private static final int MSG_SET_BACK_BUTTON_ALPHA = 201; private static final int MSG_SET_SWIPE_UP_ENABLED = 202; private final SecureSettingsObserver mSwipeUpSettingObserver; // TODO: Discriminate between swipe up and edge to edge private final NavBarModeOverlayResourceObserver mSwipeUpSettingObserver; private final Context mContext; private final Handler mUiHandler; Loading @@ -66,7 +67,7 @@ public class OverviewInteractionState { // These are updated on the background thread private ISystemUiProxy mISystemUiProxy; private boolean mSwipeUpEnabled = true; private boolean mSwipeUpEnabled; private float mBackButtonAlpha = 1; private Runnable mOnSwipeUpSettingChangedListener; Loading @@ -80,15 +81,15 @@ public class OverviewInteractionState { mUiHandler = new Handler(this::handleUiMessage); mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage); if (SwipeUpSetting.isSwipeUpSettingAvailable()) { mSwipeUpSettingObserver = newSwipeUpSettingsObserver(context, this::notifySwipeUpSettingChanged); mSwipeUpEnabled = NavBarModeOverlayResourceObserver.isSwipeUpModeEnabled(mContext) || NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(mContext); if (SwipeUpSetting.isSystemNavigationSettingAvailable()) { mSwipeUpSettingObserver = new NavBarModeOverlayResourceObserver(context, this::notifySwipeUpSettingChanged); mSwipeUpSettingObserver.register(); mSwipeUpEnabled = mSwipeUpSettingObserver.getValue(); resetHomeBounceSeenOnQuickstepEnabledFirstTime(); } else { mSwipeUpSettingObserver = null; mSwipeUpEnabled = SwipeUpSetting.isSwipeUpEnabledDefaultValue(); } } Loading Loading @@ -175,7 +176,13 @@ public class OverviewInteractionState { } } private void notifySwipeUpSettingChanged(boolean swipeUpEnabled) { private void notifySwipeUpSettingChanged(int mode) { boolean swipeUpEnabled = !QuickStepContract.isLegacyMode(mode); boolean gesturalEnabled = QuickStepContract.isGesturalMode(mode); FeatureFlags.SWIPE_HOME.updateStorage(mContext, gesturalEnabled); FeatureFlags.ENABLE_ASSISTANT_GESTURE.updateStorage(mContext, gesturalEnabled); mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED); mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0). sendToTarget(); Loading quickstep/src/com/android/quickstep/SwipeUpSetting.java +3 −22 Original line number Diff line number Diff line Loading @@ -16,23 +16,18 @@ package com.android.quickstep; import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME; import android.content.Context; import android.content.res.Resources; import android.util.Log; import com.android.launcher3.util.SecureSettingsObserver; import com.android.launcher3.util.SecureSettingsObserver.OnChangeListener; public final class SwipeUpSetting { private static final String TAG = "SwipeUpSetting"; private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME = "config_swipe_up_gesture_setting_available"; private static final String SWIPE_UP_ENABLED_DEFAULT_RES_NAME = "config_swipe_up_gesture_default"; public static boolean isSystemNavigationSettingAvailable() { return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME); } private static boolean getSystemBooleanRes(String resName) { Resources res = Resources.getSystem(); Loading @@ -45,18 +40,4 @@ public final class SwipeUpSetting { return false; } } public static boolean isSwipeUpSettingAvailable() { return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME); } public static boolean isSwipeUpEnabledDefaultValue() { return getSystemBooleanRes(SWIPE_UP_ENABLED_DEFAULT_RES_NAME); } public static SecureSettingsObserver newSwipeUpSettingsObserver(Context context, OnChangeListener listener) { return new SecureSettingsObserver(context.getContentResolver(), listener, SWIPE_UP_SETTING_NAME, isSwipeUpEnabledDefaultValue() ? 1 : 0); } } quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java +46 −36 Original line number Diff line number Diff line Loading @@ -16,25 +16,29 @@ package com.android.quickstep; import static androidx.test.InstrumentationRegistry.getInstrumentation; 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 static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY; import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY; import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY; import android.provider.Settings; import android.content.Context; import android.util.Log; import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.UiDevice; import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.TestHelpers; import com.android.systemui.shared.system.QuickStepContract; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -76,7 +80,12 @@ public class QuickStepOnOffRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { if (SwipeUpSetting.isSwipeUpSettingAvailable()) { final Context context = getInstrumentation().getContext(); final String prevOverlayPkg = QuickStepContract.isGesturalMode(context) ? NAV_BAR_MODE_GESTURAL_OVERLAY : QuickStepContract.isSwipeUpMode(context) ? NAV_BAR_MODE_2BUTTON_OVERLAY : NAV_BAR_MODE_3BUTTON_OVERLAY; try { if (mode == ON || mode == BOTH) { evaluateWithQuickstepOn(); Loading @@ -85,44 +94,45 @@ public class QuickStepOnOffRule implements TestRule { evaluateWithQuickstepOff(); } } finally { setSwipeUpSetting(null); } } 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); } setActiveOverlay(prevOverlayPkg); } } public void setSwipeUpSetting(String value) { Log.d(TAG, "setSwipeUpSetting: " + 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"); setActiveOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY); evaluateWithoutChangingSetting(base); } private void evaluateWithQuickstepOn() throws Throwable { setSwipeUpSetting("1"); setActiveOverlay(NAV_BAR_MODE_2BUTTON_OVERLAY); base.evaluate(); } private void setActiveOverlay(String overlayPackage) { setOverlayPackageEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY, overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY); setOverlayPackageEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY, overlayPackage == NAV_BAR_MODE_2BUTTON_OVERLAY); setOverlayPackageEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY, overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY); // TODO: Wait until nav bar mode has applied } private void setOverlayPackageEnabled(String overlayPackage, boolean enable) { Log.d(TAG, "setOverlayPackageEnabled: " + overlayPackage + " " + enable); final String action = enable ? "enable" : "disable"; try { UiDevice.getInstance(getInstrumentation()).executeShellCommand( "cmd overlay " + action + " " + overlayPackage); } catch (IOException e) { e.printStackTrace(); } } }; } else { return base; Loading src/com/android/launcher3/config/BaseFlags.java +2 −2 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ abstract class BaseFlags { currentValue = getFromStorage(context, defaultValue); } void updateStorage(Context context, boolean value) { public void updateStorage(Context context, boolean value) { SharedPreferences.Editor editor = context.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE).edit(); if (value == defaultValue) { Loading Loading @@ -272,7 +272,7 @@ abstract class BaseFlags { } @Override void updateStorage(Context context, boolean value) { public void updateStorage(Context context, boolean value) { if (contentResolver == null) { return; } Loading Loading
quickstep/src/com/android/quickstep/NavBarModeOverlayResourceObserver.java 0 → 100644 +85 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.android.quickstep; import static android.content.Intent.ACTION_OVERLAY_CHANGED; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.util.Log; import com.android.systemui.shared.system.QuickStepContract; /** * Observer for the resource config that specifies the navigation bar mode. */ public class NavBarModeOverlayResourceObserver extends BroadcastReceiver { private static final String TAG = "NavBarModeOverlayResourceObserver"; private static final String NAV_BAR_INTERACTION_MODE_RES_NAME = "config_navBarInteractionMode"; private final Context mContext; private final OnChangeListener mOnChangeListener; public NavBarModeOverlayResourceObserver(Context context, OnChangeListener listener) { mContext = context; mOnChangeListener = listener; } public void register() { IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED); filter.addDataScheme("package"); mContext.registerReceiver(this, filter); } @Override public void onReceive(Context context, Intent intent) { mOnChangeListener.onNavBarModeChanged(getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); } public interface OnChangeListener { void onNavBarModeChanged(int mode); } public static boolean isSwipeUpModeEnabled(Context context) { return QuickStepContract.isSwipeUpMode(getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); } public static boolean isEdgeToEdgeModeEnabled(Context context) { return QuickStepContract.isGesturalMode(getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME)); } private static int getSystemIntegerRes(Context context, String resName) { Resources res = context.getResources(); int resId = res.getIdentifier(resName, "integer", "android"); if (resId != 0) { return res.getInteger(resId); } else { Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?"); return -1; } } }
quickstep/src/com/android/quickstep/OverviewInteractionState.java +17 −10 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ */ package com.android.quickstep; import static com.android.quickstep.SwipeUpSetting.newSwipeUpSettingsObserver; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_QUICK_SCRUB; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON; Loading @@ -28,10 +27,11 @@ import android.util.Log; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SecureSettingsObserver; import com.android.launcher3.util.UiThreadHelper; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.system.QuickStepContract; import androidx.annotation.WorkerThread; Loading @@ -58,7 +58,8 @@ public class OverviewInteractionState { private static final int MSG_SET_BACK_BUTTON_ALPHA = 201; private static final int MSG_SET_SWIPE_UP_ENABLED = 202; private final SecureSettingsObserver mSwipeUpSettingObserver; // TODO: Discriminate between swipe up and edge to edge private final NavBarModeOverlayResourceObserver mSwipeUpSettingObserver; private final Context mContext; private final Handler mUiHandler; Loading @@ -66,7 +67,7 @@ public class OverviewInteractionState { // These are updated on the background thread private ISystemUiProxy mISystemUiProxy; private boolean mSwipeUpEnabled = true; private boolean mSwipeUpEnabled; private float mBackButtonAlpha = 1; private Runnable mOnSwipeUpSettingChangedListener; Loading @@ -80,15 +81,15 @@ public class OverviewInteractionState { mUiHandler = new Handler(this::handleUiMessage); mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage); if (SwipeUpSetting.isSwipeUpSettingAvailable()) { mSwipeUpSettingObserver = newSwipeUpSettingsObserver(context, this::notifySwipeUpSettingChanged); mSwipeUpEnabled = NavBarModeOverlayResourceObserver.isSwipeUpModeEnabled(mContext) || NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(mContext); if (SwipeUpSetting.isSystemNavigationSettingAvailable()) { mSwipeUpSettingObserver = new NavBarModeOverlayResourceObserver(context, this::notifySwipeUpSettingChanged); mSwipeUpSettingObserver.register(); mSwipeUpEnabled = mSwipeUpSettingObserver.getValue(); resetHomeBounceSeenOnQuickstepEnabledFirstTime(); } else { mSwipeUpSettingObserver = null; mSwipeUpEnabled = SwipeUpSetting.isSwipeUpEnabledDefaultValue(); } } Loading Loading @@ -175,7 +176,13 @@ public class OverviewInteractionState { } } private void notifySwipeUpSettingChanged(boolean swipeUpEnabled) { private void notifySwipeUpSettingChanged(int mode) { boolean swipeUpEnabled = !QuickStepContract.isLegacyMode(mode); boolean gesturalEnabled = QuickStepContract.isGesturalMode(mode); FeatureFlags.SWIPE_HOME.updateStorage(mContext, gesturalEnabled); FeatureFlags.ENABLE_ASSISTANT_GESTURE.updateStorage(mContext, gesturalEnabled); mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED); mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0). sendToTarget(); Loading
quickstep/src/com/android/quickstep/SwipeUpSetting.java +3 −22 Original line number Diff line number Diff line Loading @@ -16,23 +16,18 @@ package com.android.quickstep; import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME; import android.content.Context; import android.content.res.Resources; import android.util.Log; import com.android.launcher3.util.SecureSettingsObserver; import com.android.launcher3.util.SecureSettingsObserver.OnChangeListener; public final class SwipeUpSetting { private static final String TAG = "SwipeUpSetting"; private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME = "config_swipe_up_gesture_setting_available"; private static final String SWIPE_UP_ENABLED_DEFAULT_RES_NAME = "config_swipe_up_gesture_default"; public static boolean isSystemNavigationSettingAvailable() { return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME); } private static boolean getSystemBooleanRes(String resName) { Resources res = Resources.getSystem(); Loading @@ -45,18 +40,4 @@ public final class SwipeUpSetting { return false; } } public static boolean isSwipeUpSettingAvailable() { return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME); } public static boolean isSwipeUpEnabledDefaultValue() { return getSystemBooleanRes(SWIPE_UP_ENABLED_DEFAULT_RES_NAME); } public static SecureSettingsObserver newSwipeUpSettingsObserver(Context context, OnChangeListener listener) { return new SecureSettingsObserver(context.getContentResolver(), listener, SWIPE_UP_SETTING_NAME, isSwipeUpEnabledDefaultValue() ? 1 : 0); } }
quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java +46 −36 Original line number Diff line number Diff line Loading @@ -16,25 +16,29 @@ package com.android.quickstep; import static androidx.test.InstrumentationRegistry.getInstrumentation; 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 static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY; import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY; import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY; import android.provider.Settings; import android.content.Context; import android.util.Log; import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.UiDevice; import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.TestHelpers; import com.android.systemui.shared.system.QuickStepContract; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -76,7 +80,12 @@ public class QuickStepOnOffRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { if (SwipeUpSetting.isSwipeUpSettingAvailable()) { final Context context = getInstrumentation().getContext(); final String prevOverlayPkg = QuickStepContract.isGesturalMode(context) ? NAV_BAR_MODE_GESTURAL_OVERLAY : QuickStepContract.isSwipeUpMode(context) ? NAV_BAR_MODE_2BUTTON_OVERLAY : NAV_BAR_MODE_3BUTTON_OVERLAY; try { if (mode == ON || mode == BOTH) { evaluateWithQuickstepOn(); Loading @@ -85,44 +94,45 @@ public class QuickStepOnOffRule implements TestRule { evaluateWithQuickstepOff(); } } finally { setSwipeUpSetting(null); } } 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); } setActiveOverlay(prevOverlayPkg); } } public void setSwipeUpSetting(String value) { Log.d(TAG, "setSwipeUpSetting: " + 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"); setActiveOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY); evaluateWithoutChangingSetting(base); } private void evaluateWithQuickstepOn() throws Throwable { setSwipeUpSetting("1"); setActiveOverlay(NAV_BAR_MODE_2BUTTON_OVERLAY); base.evaluate(); } private void setActiveOverlay(String overlayPackage) { setOverlayPackageEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY, overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY); setOverlayPackageEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY, overlayPackage == NAV_BAR_MODE_2BUTTON_OVERLAY); setOverlayPackageEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY, overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY); // TODO: Wait until nav bar mode has applied } private void setOverlayPackageEnabled(String overlayPackage, boolean enable) { Log.d(TAG, "setOverlayPackageEnabled: " + overlayPackage + " " + enable); final String action = enable ? "enable" : "disable"; try { UiDevice.getInstance(getInstrumentation()).executeShellCommand( "cmd overlay " + action + " " + overlayPackage); } catch (IOException e) { e.printStackTrace(); } } }; } else { return base; Loading
src/com/android/launcher3/config/BaseFlags.java +2 −2 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ abstract class BaseFlags { currentValue = getFromStorage(context, defaultValue); } void updateStorage(Context context, boolean value) { public void updateStorage(Context context, boolean value) { SharedPreferences.Editor editor = context.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE).edit(); if (value == defaultValue) { Loading Loading @@ -272,7 +272,7 @@ abstract class BaseFlags { } @Override void updateStorage(Context context, boolean value) { public void updateStorage(Context context, boolean value) { if (contentResolver == null) { return; } Loading