Enable(visible) or Disabled(invisible) all one-handed settings
preference by System Property flag configuration. To check System Property flag "support_one_handed_mode" configuration then enable(visible) or disable(invisible) all one-handed settings preference. Bug: 154290458 Test: manual Test: RunSettingsRoboTests Change-Id: Ib6ed12dd65e66747e53b6333574ba0ad5be3c6e0
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -27,13 +28,17 @@ import com.android.settings.core.TogglePreferenceController;
|
|||||||
**/
|
**/
|
||||||
public class OneHandedEnablePreferenceController extends TogglePreferenceController {
|
public class OneHandedEnablePreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
|
static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
|
||||||
|
|
||||||
public OneHandedEnablePreferenceController(Context context, String key) {
|
public OneHandedEnablePreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return BasePreferenceController.AVAILABLE;
|
return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)
|
||||||
|
? BasePreferenceController.AVAILABLE
|
||||||
|
: BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
@@ -47,5 +49,11 @@ public class OneHandedSettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.one_handed_settings);
|
new BaseSearchIndexProvider(R.xml.one_handed_settings) {
|
||||||
|
@Override
|
||||||
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
|
return SystemProperties.getBoolean(
|
||||||
|
OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.gestures;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -57,11 +58,21 @@ public class OneHandedEnablePreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_byDefault_shouldAvailable() {
|
public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() {
|
||||||
|
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_unsetSupportOneHandedModeProperty_shouldUnsupported() {
|
||||||
|
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_enabledOneHanded_shouldDisplayOnSummary() {
|
public void getSummary_enabledOneHanded_shouldDisplayOnSummary() {
|
||||||
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, true);
|
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, true);
|
||||||
|
@@ -18,6 +18,8 @@ package com.android.settings.gestures;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -25,6 +27,7 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -32,10 +35,12 @@ import java.util.List;
|
|||||||
public class OneHandedSettingsTest {
|
public class OneHandedSettingsTest {
|
||||||
|
|
||||||
private OneHandedSettings mSettings;
|
private OneHandedSettings mSettings;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mSettings = new OneHandedSettings();
|
mSettings = new OneHandedSettings();
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -47,4 +52,26 @@ public class OneHandedSettingsTest {
|
|||||||
assertThat(indexRes).isNotNull();
|
assertThat(indexRes).isNotNull();
|
||||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isPageSearchEnabled_setSupportOneHandedModeProperty_shouldReturnTrue() {
|
||||||
|
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
|
||||||
|
|
||||||
|
final Object obj = ReflectionHelpers.callInstanceMethod(
|
||||||
|
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
|
||||||
|
ReflectionHelpers.ClassParameter.from(Context.class, mContext));
|
||||||
|
final boolean isEnabled = (Boolean) obj;
|
||||||
|
assertThat(isEnabled).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isPageSearchEnabled_unsetSupportOneHandedModeProperty_shouldReturnFalse() {
|
||||||
|
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
|
||||||
|
|
||||||
|
final Object obj = ReflectionHelpers.callInstanceMethod(
|
||||||
|
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
|
||||||
|
ReflectionHelpers.ClassParameter.from(Context.class, mContext));
|
||||||
|
final boolean isEnabled = (Boolean) obj;
|
||||||
|
assertThat(isEnabled).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user