Updating settings to use resource overlay instead of setting.
Bug: 127366543 Test: Manual test on device Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationLegacyPreferenceControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationSwipeUpPreferenceControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationEdgeToEdgePreferenceControllerTest Change-Id: I021d05a21e00136c6f3651247964319274bdab91
This commit is contained in:
@@ -16,9 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.om.IOverlayManager;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.widget.RadioButtonPreference;
|
import com.android.settings.widget.RadioButtonPreference;
|
||||||
|
|
||||||
public class SystemNavigationEdgeToEdgePreferenceController extends
|
public class SystemNavigationEdgeToEdgePreferenceController extends
|
||||||
@@ -26,7 +32,14 @@ public class SystemNavigationEdgeToEdgePreferenceController extends
|
|||||||
static final String PREF_KEY_EDGE_TO_EDGE = "gesture_edge_to_edge";
|
static final String PREF_KEY_EDGE_TO_EDGE = "gesture_edge_to_edge";
|
||||||
|
|
||||||
public SystemNavigationEdgeToEdgePreferenceController(Context context, String key) {
|
public SystemNavigationEdgeToEdgePreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
|
||||||
|
Context.OVERLAY_SERVICE)), key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public SystemNavigationEdgeToEdgePreferenceController(Context context,
|
||||||
|
IOverlayManager overlayManager, String key) {
|
||||||
|
super(context, overlayManager, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -36,8 +49,7 @@ public class SystemNavigationEdgeToEdgePreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
||||||
setSwipeUpEnabled(mContext, true);
|
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
|
||||||
setEdgeToEdgeGestureEnabled(mContext, true);
|
|
||||||
selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
|
selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,9 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.om.IOverlayManager;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.widget.RadioButtonPreference;
|
import com.android.settings.widget.RadioButtonPreference;
|
||||||
|
|
||||||
public class SystemNavigationLegacyPreferenceController extends
|
public class SystemNavigationLegacyPreferenceController extends
|
||||||
@@ -26,7 +32,14 @@ public class SystemNavigationLegacyPreferenceController extends
|
|||||||
static final String PREF_KEY_LEGACY = "gesture_legacy";
|
static final String PREF_KEY_LEGACY = "gesture_legacy";
|
||||||
|
|
||||||
public SystemNavigationLegacyPreferenceController(Context context, String key) {
|
public SystemNavigationLegacyPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
|
||||||
|
Context.OVERLAY_SERVICE)), key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public SystemNavigationLegacyPreferenceController(Context context,
|
||||||
|
IOverlayManager overlayManager, String key) {
|
||||||
|
super(context, overlayManager, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -36,8 +49,7 @@ public class SystemNavigationLegacyPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
||||||
setEdgeToEdgeGestureEnabled(mContext, false);
|
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
|
||||||
setSwipeUpEnabled(mContext, false);
|
|
||||||
selectRadioButtonInGroup(PREF_KEY_LEGACY, mPreferenceScreen);
|
selectRadioButtonInGroup(PREF_KEY_LEGACY, mPreferenceScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,12 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import static android.os.UserHandle.USER_SYSTEM;
|
import static android.os.UserHandle.USER_CURRENT;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -24,8 +29,6 @@ import android.content.Intent;
|
|||||||
import android.content.om.IOverlayManager;
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -38,33 +41,6 @@ import com.android.settings.widget.RadioButtonPreference;
|
|||||||
public abstract class SystemNavigationPreferenceController extends GesturePreferenceController
|
public abstract class SystemNavigationPreferenceController extends GesturePreferenceController
|
||||||
implements RadioButtonPreference.OnClickListener {
|
implements RadioButtonPreference.OnClickListener {
|
||||||
|
|
||||||
private static final int OFF = 0;
|
|
||||||
private static final int ON = 1;
|
|
||||||
|
|
||||||
private static final String HIDE_BACK_BUTTON = "quickstepcontroller_hideback";
|
|
||||||
private static final String HIDE_HOME_BUTTON = "quickstepcontroller_hidehome";
|
|
||||||
private static final String HIDE_NAVBAR_DIVIDER = "hide_navigationbar_divider";
|
|
||||||
private static final String SHOW_HANDLE = "quickstepcontroller_showhandle";
|
|
||||||
private static final String ENABLE_CLICK_THROUGH = "quickstepcontroller_clickthrough";
|
|
||||||
private static final String ENABLE_LAUNCHER_SWIPE_TO_HOME = "SWIPE_HOME";
|
|
||||||
private static final String ENABLE_COLOR_ADAPT_FOR_HANDLE = "navbar_color_adapt_enable";
|
|
||||||
private static final String ENABLE_ASSISTANT_GESTURE = "ENABLE_ASSISTANT_GESTURE";
|
|
||||||
private static final String PROTOTYPE_ENABLED = "prototype_enabled";
|
|
||||||
|
|
||||||
private static final int EDGE_SENSITIVITY_WIDTH = 48;
|
|
||||||
private static final String EDGE_SENSITIVITY_KEY = "quickstepcontroller_edge_width_sensitivity";
|
|
||||||
|
|
||||||
private static final String GESTURES_MATCH_MAP_OFF = "000000";
|
|
||||||
private static final String GESTURES_MATCH_MAP_ON = "071133";
|
|
||||||
private static final String GESTURES_MATCH_MAP_KEY = "quickstepcontroller_gesture_match_map";
|
|
||||||
|
|
||||||
private static final String OVERLAY_NAVBAR_KEY =
|
|
||||||
"com.android.internal.experiment.navbar.default";
|
|
||||||
private static final String OVERLAY_NAVBAR_TYPE_INSET =
|
|
||||||
"com.android.internal.experiment.navbar.type.inset";
|
|
||||||
private static final String OVERLAY_NAVBAR_TYPE_FLOATING =
|
|
||||||
"com.android.internal.experiment.navbar.type.floating";
|
|
||||||
|
|
||||||
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
|
private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
|
||||||
|
|
||||||
@@ -74,10 +50,13 @@ public abstract class SystemNavigationPreferenceController extends GesturePrefer
|
|||||||
SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE,
|
SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected final IOverlayManager mOverlayManager;
|
||||||
protected PreferenceScreen mPreferenceScreen;
|
protected PreferenceScreen mPreferenceScreen;
|
||||||
|
|
||||||
public SystemNavigationPreferenceController(Context context, String key) {
|
public SystemNavigationPreferenceController(Context context, IOverlayManager overlayManager,
|
||||||
|
String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
|
mOverlayManager = overlayManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,55 +135,36 @@ public abstract class SystemNavigationPreferenceController extends GesturePrefer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setEdgeToEdgeGestureEnabled(Context context, boolean enable) {
|
/**
|
||||||
// TODO(b/127366543): replace all of this with a single switch
|
* Enables the specified overlay package.
|
||||||
setBooleanGlobalSetting(context, HIDE_BACK_BUTTON, enable);
|
*/
|
||||||
setBooleanGlobalSetting(context, HIDE_HOME_BUTTON, enable);
|
static void setNavBarInteractionMode(IOverlayManager overlayManager, String overlayPackage) {
|
||||||
setBooleanGlobalSetting(context, HIDE_NAVBAR_DIVIDER, enable);
|
setOverlayEnabled(overlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY,
|
||||||
setBooleanGlobalSetting(context, SHOW_HANDLE, enable);
|
overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY);
|
||||||
setBooleanGlobalSetting(context, ENABLE_CLICK_THROUGH, enable);
|
setOverlayEnabled(overlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY,
|
||||||
setBooleanGlobalSetting(context, ENABLE_LAUNCHER_SWIPE_TO_HOME, enable);
|
overlayPackage == NAV_BAR_MODE_2BUTTON_OVERLAY);
|
||||||
setBooleanGlobalSetting(context, ENABLE_COLOR_ADAPT_FOR_HANDLE, enable);
|
setOverlayEnabled(overlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY,
|
||||||
setBooleanGlobalSetting(context, ENABLE_ASSISTANT_GESTURE, enable);
|
overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY);
|
||||||
setBooleanGlobalSetting(context, PROTOTYPE_ENABLED, enable);
|
|
||||||
Settings.Global.putInt(context.getContentResolver(), EDGE_SENSITIVITY_KEY,
|
|
||||||
EDGE_SENSITIVITY_WIDTH);
|
|
||||||
Settings.Global.putString(context.getContentResolver(), GESTURES_MATCH_MAP_KEY,
|
|
||||||
enable ? GESTURES_MATCH_MAP_ON : GESTURES_MATCH_MAP_OFF);
|
|
||||||
|
|
||||||
IOverlayManager overlayManager = IOverlayManager.Stub
|
|
||||||
.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
|
|
||||||
if (overlayManager != null) {
|
|
||||||
try {
|
|
||||||
overlayManager.setEnabled(OVERLAY_NAVBAR_KEY, true, USER_SYSTEM);
|
|
||||||
overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_FLOATING, false, USER_SYSTEM);
|
|
||||||
overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_INSET, enable, USER_SYSTEM);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setBooleanGlobalSetting(Context context, String name, boolean flag) {
|
|
||||||
Settings.Global.putInt(context.getContentResolver(), name, flag ? ON : OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setSwipeUpEnabled(Context context, boolean enabled) {
|
|
||||||
Settings.Secure.putInt(context.getContentResolver(),
|
|
||||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, enabled ? ON : OFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isSwipeUpEnabled(Context context) {
|
static boolean isSwipeUpEnabled(Context context) {
|
||||||
if (isEdgeToEdgeEnabled(context)) {
|
if (isEdgeToEdgeEnabled(context)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int defaultSwipeUpValue = context.getResources()
|
return NAV_BAR_MODE_2BUTTON == context.getResources().getInteger(
|
||||||
.getBoolean(com.android.internal.R.bool.config_swipe_up_gesture_default) ? ON : OFF;
|
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||||
return Settings.Secure.getInt(context.getContentResolver(),
|
|
||||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, defaultSwipeUpValue) == ON;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isEdgeToEdgeEnabled(Context context) {
|
static boolean isEdgeToEdgeEnabled(Context context) {
|
||||||
return Settings.Global.getInt(context.getContentResolver(), PROTOTYPE_ENABLED, OFF) == ON;
|
return NAV_BAR_MODE_GESTURAL == context.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setOverlayEnabled(IOverlayManager overlayManager, String pkg, boolean enabled) {
|
||||||
|
try {
|
||||||
|
overlayManager.setEnabled(pkg, enabled, USER_CURRENT);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.om.IOverlayManager;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.widget.RadioButtonPreference;
|
import com.android.settings.widget.RadioButtonPreference;
|
||||||
|
|
||||||
public class SystemNavigationSwipeUpPreferenceController extends
|
public class SystemNavigationSwipeUpPreferenceController extends
|
||||||
@@ -26,7 +32,14 @@ public class SystemNavigationSwipeUpPreferenceController extends
|
|||||||
static final String PREF_KEY_SWIPE_UP = "gesture_swipe_up";
|
static final String PREF_KEY_SWIPE_UP = "gesture_swipe_up";
|
||||||
|
|
||||||
public SystemNavigationSwipeUpPreferenceController(Context context, String key) {
|
public SystemNavigationSwipeUpPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
|
||||||
|
Context.OVERLAY_SERVICE)), key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public SystemNavigationSwipeUpPreferenceController(Context context,
|
||||||
|
IOverlayManager overlayManager, String key) {
|
||||||
|
super(context, overlayManager, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -36,8 +49,7 @@ public class SystemNavigationSwipeUpPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
||||||
setEdgeToEdgeGestureEnabled(mContext, false);
|
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
|
||||||
setSwipeUpEnabled(mContext, true);
|
|
||||||
selectRadioButtonInGroup(PREF_KEY_SWIPE_UP, mPreferenceScreen);
|
selectRadioButtonInGroup(PREF_KEY_SWIPE_UP, mPreferenceScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
|
import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
|
||||||
import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
|
import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
|
||||||
import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
|
import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
|
||||||
@@ -24,18 +28,17 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
@@ -46,6 +49,8 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.Shadows;
|
import org.robolectric.Shadows;
|
||||||
@@ -59,22 +64,24 @@ public class SystemNavigationEdgeToEdgePreferenceControllerTest {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ShadowPackageManager mPackageManager;
|
private ShadowPackageManager mPackageManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private IOverlayManager mOverlayManager;
|
||||||
|
|
||||||
private SystemNavigationEdgeToEdgePreferenceController mController;
|
private SystemNavigationEdgeToEdgePreferenceController mController;
|
||||||
|
|
||||||
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
||||||
true);
|
true);
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
|
|
||||||
|
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
Settings.Global.putInt(mContext.getContentResolver(), "prototype_enabled", 1);
|
|
||||||
|
|
||||||
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||||
|
|
||||||
mController = new SystemNavigationEdgeToEdgePreferenceController(mContext,
|
mController = new SystemNavigationEdgeToEdgePreferenceController(mContext, mOverlayManager,
|
||||||
PREF_KEY_EDGE_TO_EDGE);
|
PREF_KEY_EDGE_TO_EDGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,18 +131,30 @@ public class SystemNavigationEdgeToEdgePreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsTrue_shouldReturnTrue() {
|
public void testIsChecked_defaultIsEdgeToEdge_shouldReturnTrue() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_GESTURAL);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
|
public void testIsChecked_defaultIsLegacy_shouldReturnFalse() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(), "prototype_enabled", 0);
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_3BUTTON);
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsChecked_defaultIsSwipeUp_shouldReturnFalse() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_2BUTTON);
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
|
public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_GESTURAL);
|
||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
mController.onRadioButtonClicked(null);
|
mController.onRadioButtonClicked(null);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
|
import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
|
||||||
import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
|
import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
|
||||||
import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
|
import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
|
||||||
@@ -24,17 +28,17 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
@@ -45,6 +49,8 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.Shadows;
|
import org.robolectric.Shadows;
|
||||||
@@ -58,20 +64,25 @@ public class SystemNavigationLegacyPreferenceControllerTest {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ShadowPackageManager mPackageManager;
|
private ShadowPackageManager mPackageManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private IOverlayManager mOverlayManager;
|
||||||
|
|
||||||
private SystemNavigationLegacyPreferenceController mController;
|
private SystemNavigationLegacyPreferenceController mController;
|
||||||
|
|
||||||
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
||||||
true);
|
true);
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, false);
|
|
||||||
|
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||||
|
|
||||||
mController = new SystemNavigationLegacyPreferenceController(mContext, PREF_KEY_LEGACY);
|
mController = new SystemNavigationLegacyPreferenceController(mContext, mOverlayManager,
|
||||||
|
PREF_KEY_LEGACY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -120,19 +131,32 @@ public class SystemNavigationLegacyPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsTrue_shouldReturnTrue() {
|
public void testIsChecked_defaultIsLegacy_shouldReturnTrue() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_3BUTTON);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
|
public void testIsChecked_defaultIsSwipeUp_shouldReturnFalse() {
|
||||||
// Turn on the Swipe Up mode (2-buttons)
|
// Turn on the Swipe Up mode (2-buttons)
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_2BUTTON);
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsChecked_defaultIsEdgeToEdge_shouldReturnFalse() {
|
||||||
|
// Turn on the Edge to Edge
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_GESTURAL);
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
|
public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_3BUTTON);
|
||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
mController.onRadioButtonClicked(null);
|
mController.onRadioButtonClicked(null);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
|
import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
|
||||||
import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
|
import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
|
||||||
import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
|
import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
|
||||||
@@ -24,17 +28,17 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
@@ -45,6 +49,8 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.Shadows;
|
import org.robolectric.Shadows;
|
||||||
@@ -58,20 +64,25 @@ public class SystemNavigationSwipeUpPreferenceControllerTest {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ShadowPackageManager mPackageManager;
|
private ShadowPackageManager mPackageManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private IOverlayManager mOverlayManager;
|
||||||
|
|
||||||
private SystemNavigationSwipeUpPreferenceController mController;
|
private SystemNavigationSwipeUpPreferenceController mController;
|
||||||
|
|
||||||
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
|
||||||
true);
|
true);
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
|
|
||||||
|
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||||
|
|
||||||
mController = new SystemNavigationSwipeUpPreferenceController(mContext, PREF_KEY_SWIPE_UP);
|
mController = new SystemNavigationSwipeUpPreferenceController(mContext, mOverlayManager,
|
||||||
|
PREF_KEY_SWIPE_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -120,18 +131,30 @@ public class SystemNavigationSwipeUpPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsTrue_shouldReturnTrue() {
|
public void testIsChecked_defaultIsSwipeUp_shouldReturnTrue() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_2BUTTON);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
|
public void testIsChecked_defaultIsLegacy_shouldReturnFalse() {
|
||||||
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, false);
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_3BUTTON);
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsChecked_defaultIsEdgeToEdge_shouldReturnFalse() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_GESTURAL);
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
|
public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
|
||||||
|
SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
|
||||||
|
NAV_BAR_MODE_2BUTTON);
|
||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
mController.onRadioButtonClicked(null);
|
mController.onRadioButtonClicked(null);
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
Reference in New Issue
Block a user