Merge "Schematize Display system properties" am: b139a4c16b
am: 4d8f4919e0
Change-Id: I35412244d1fa97cb479d060e876bfddac6b523cb
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
import android.sysprop.DisplayProperties;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -31,9 +31,6 @@ public class ForceMSAAPreferenceController extends DeveloperOptionsPreferenceCon
|
|||||||
|
|
||||||
private static final String FORCE_MSAA_KEY = "force_msaa";
|
private static final String FORCE_MSAA_KEY = "force_msaa";
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String MSAA_PROPERTY = "debug.egl.force_msaa";
|
|
||||||
|
|
||||||
public ForceMSAAPreferenceController(Context context) {
|
public ForceMSAAPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
@@ -46,22 +43,21 @@ public class ForceMSAAPreferenceController extends DeveloperOptionsPreferenceCon
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
final boolean isEnabled = (Boolean) newValue;
|
final boolean isEnabled = (Boolean) newValue;
|
||||||
SystemProperties.set(MSAA_PROPERTY,
|
DisplayProperties.debug_force_msaa(isEnabled);
|
||||||
isEnabled ? Boolean.toString(true) : Boolean.toString(false));
|
|
||||||
SystemPropPoker.getInstance().poke();
|
SystemPropPoker.getInstance().poke();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
final boolean isEnabled = SystemProperties.getBoolean(MSAA_PROPERTY, false /* default */);
|
final boolean isEnabled = DisplayProperties.debug_force_msaa().orElse(false);
|
||||||
((SwitchPreference) mPreference).setChecked(isEnabled);
|
((SwitchPreference) mPreference).setChecked(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
super.onDeveloperOptionsSwitchDisabled();
|
super.onDeveloperOptionsSwitchDisabled();
|
||||||
SystemProperties.set(MSAA_PROPERTY, Boolean.toString(false));
|
DisplayProperties.debug_force_msaa(false);
|
||||||
((SwitchPreference) mPreference).setChecked(false);
|
((SwitchPreference) mPreference).setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.sysprop.DisplayProperties;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -78,8 +78,6 @@ public class RtlLayoutPreferenceController extends DeveloperOptionsPreferenceCon
|
|||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.DEVELOPMENT_FORCE_RTL,
|
Settings.Global.DEVELOPMENT_FORCE_RTL,
|
||||||
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
||||||
SystemProperties.set(Settings.Global.DEVELOPMENT_FORCE_RTL,
|
DisplayProperties.debug_force_rtl(isEnabled);
|
||||||
isEnabled ? Integer.toString(SETTING_VALUE_ON)
|
|
||||||
: Integer.toString(SETTING_VALUE_OFF));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
import android.sysprop.DisplayProperties;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -43,23 +43,21 @@ public class ShowLayoutBoundsPreferenceController extends DeveloperOptionsPrefer
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
final boolean isEnabled = (Boolean) newValue;
|
final boolean isEnabled = (Boolean) newValue;
|
||||||
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
|
DisplayProperties.debug_layout(isEnabled);
|
||||||
isEnabled ? Boolean.toString(true) : Boolean.toString(false));
|
|
||||||
SystemPropPoker.getInstance().poke();
|
SystemPropPoker.getInstance().poke();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
final boolean isEnabled = SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY,
|
final boolean isEnabled = DisplayProperties.debug_layout().orElse(false);
|
||||||
false /* default */);
|
|
||||||
((SwitchPreference) mPreference).setChecked(isEnabled);
|
((SwitchPreference) mPreference).setChecked(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
super.onDeveloperOptionsSwitchDisabled();
|
super.onDeveloperOptionsSwitchDisabled();
|
||||||
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, Boolean.toString(false));
|
DisplayProperties.debug_layout(false);
|
||||||
((SwitchPreference) mPreference).setChecked(false);
|
((SwitchPreference) mPreference).setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ import android.os.SystemProperties;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.quicksettings.Tile;
|
import android.service.quicksettings.Tile;
|
||||||
import android.service.quicksettings.TileService;
|
import android.service.quicksettings.TileService;
|
||||||
|
import android.sysprop.DisplayProperties;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
@@ -68,12 +69,12 @@ public abstract class DevelopmentTiles extends TileService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isEnabled() {
|
protected boolean isEnabled() {
|
||||||
return SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false);
|
return DisplayProperties.debug_layout().orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setIsEnabled(boolean isEnabled) {
|
protected void setIsEnabled(boolean isEnabled) {
|
||||||
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, isEnabled ? "true" : "false");
|
DisplayProperties.debug_layout(isEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ public abstract class DevelopmentTiles extends TileService {
|
|||||||
protected void setIsEnabled(boolean isEnabled) {
|
protected void setIsEnabled(boolean isEnabled) {
|
||||||
Settings.Global.putInt(
|
Settings.Global.putInt(
|
||||||
getContentResolver(), Settings.Global.DEVELOPMENT_FORCE_RTL, isEnabled ? 1 : 0);
|
getContentResolver(), Settings.Global.DEVELOPMENT_FORCE_RTL, isEnabled ? 1 : 0);
|
||||||
SystemProperties.set(Settings.Global.DEVELOPMENT_FORCE_RTL, isEnabled ? "1" : "0");
|
DisplayProperties.debug_force_rtl(isEnabled);
|
||||||
LocalePicker.updateLocales(getResources().getConfiguration().getLocales());
|
LocalePicker.updateLocales(getResources().getConfiguration().getLocales());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
import android.sysprop.DisplayProperties;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
@@ -59,8 +59,7 @@ public class ForceMSAAPreferenceControllerTest {
|
|||||||
public void onPreferenceChanged_settingEnabled_turnOnForceMsaa() {
|
public void onPreferenceChanged_settingEnabled_turnOnForceMsaa() {
|
||||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||||
|
|
||||||
final boolean mode = SystemProperties
|
final boolean mode = DisplayProperties.debug_force_msaa().orElse(false);
|
||||||
.getBoolean(ForceMSAAPreferenceController.MSAA_PROPERTY, false /* default */);
|
|
||||||
|
|
||||||
assertThat(mode).isTrue();
|
assertThat(mode).isTrue();
|
||||||
}
|
}
|
||||||
@@ -69,15 +68,14 @@ public class ForceMSAAPreferenceControllerTest {
|
|||||||
public void onPreferenceChanged_settingDisabled_turnOffForceMsaa() {
|
public void onPreferenceChanged_settingDisabled_turnOffForceMsaa() {
|
||||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||||
|
|
||||||
final boolean mode = SystemProperties
|
final boolean mode = DisplayProperties.debug_force_msaa().orElse(false);
|
||||||
.getBoolean(ForceMSAAPreferenceController.MSAA_PROPERTY, false /* default */);
|
|
||||||
|
|
||||||
assertThat(mode).isFalse();
|
assertThat(mode).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
||||||
SystemProperties.set(ForceMSAAPreferenceController.MSAA_PROPERTY, Boolean.toString(true));
|
DisplayProperties.debug_force_msaa(true);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(true);
|
verify(mPreference).setChecked(true);
|
||||||
@@ -85,7 +83,7 @@ public class ForceMSAAPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
||||||
SystemProperties.set(ForceMSAAPreferenceController.MSAA_PROPERTY, Boolean.toString(false));
|
DisplayProperties.debug_force_msaa(false);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(false);
|
verify(mPreference).setChecked(false);
|
||||||
|
@@ -20,7 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.os.SystemProperties;
|
import android.sysprop.DisplayProperties;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -57,8 +57,7 @@ public class ShowLayoutBoundsPreferenceControllerTest {
|
|||||||
public void onPreferenceChanged_settingEnabled_turnOnShowLayoutBounds() {
|
public void onPreferenceChanged_settingEnabled_turnOnShowLayoutBounds() {
|
||||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||||
|
|
||||||
final boolean mode =
|
final boolean mode = DisplayProperties.debug_layout().orElse(false);
|
||||||
SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false /* default */);
|
|
||||||
|
|
||||||
assertThat(mode).isTrue();
|
assertThat(mode).isTrue();
|
||||||
}
|
}
|
||||||
@@ -67,15 +66,14 @@ public class ShowLayoutBoundsPreferenceControllerTest {
|
|||||||
public void onPreferenceChanged_settingDisabled_turnOffShowLayoutBounds() {
|
public void onPreferenceChanged_settingDisabled_turnOffShowLayoutBounds() {
|
||||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||||
|
|
||||||
final boolean mode =
|
final boolean mode = DisplayProperties.debug_layout().orElse(false);
|
||||||
SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false /* default */);
|
|
||||||
|
|
||||||
assertThat(mode).isFalse();
|
assertThat(mode).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
||||||
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, Boolean.toString(true));
|
DisplayProperties.debug_layout(true);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(true);
|
verify(mPreference).setChecked(true);
|
||||||
@@ -83,7 +81,7 @@ public class ShowLayoutBoundsPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
||||||
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, Boolean.toString(false));
|
DisplayProperties.debug_layout(false);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(false);
|
verify(mPreference).setChecked(false);
|
||||||
@@ -93,8 +91,7 @@ public class ShowLayoutBoundsPreferenceControllerTest {
|
|||||||
public void onDeveloperOptionsDisabled_shouldDisablePreference() {
|
public void onDeveloperOptionsDisabled_shouldDisablePreference() {
|
||||||
mController.onDeveloperOptionsDisabled();
|
mController.onDeveloperOptionsDisabled();
|
||||||
|
|
||||||
final boolean mode =
|
final boolean mode = DisplayProperties.debug_layout().orElse(false);
|
||||||
SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false /* default */);
|
|
||||||
|
|
||||||
assertThat(mode).isFalse();
|
assertThat(mode).isFalse();
|
||||||
verify(mPreference).setEnabled(false);
|
verify(mPreference).setEnabled(false);
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
package com.android.settings.testutils.shadow;
|
package com.android.settings.testutils.shadow;
|
||||||
|
|
||||||
import android.icu.util.ULocale;
|
import android.icu.util.ULocale;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.sysprop.DisplayProperties;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -38,7 +38,7 @@ public class ShadowTextUtils {
|
|||||||
return ((locale != null && !locale.equals(Locale.ROOT)
|
return ((locale != null && !locale.equals(Locale.ROOT)
|
||||||
&& ULocale.forLocale(locale).isRightToLeft())
|
&& ULocale.forLocale(locale).isRightToLeft())
|
||||||
// If forcing into RTL layout mode, return RTL as default
|
// If forcing into RTL layout mode, return RTL as default
|
||||||
|| SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false))
|
|| DisplayProperties.debug_force_rtl().orElse(false))
|
||||||
? View.LAYOUT_DIRECTION_RTL
|
? View.LAYOUT_DIRECTION_RTL
|
||||||
: View.LAYOUT_DIRECTION_LTR;
|
: View.LAYOUT_DIRECTION_LTR;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user