Schematize Setup Wizard System Properties
Properties accessed across partitions are now schematized and will become APIs to make explicit interfaces among partitions. Bug: 117924132 Test: mma -j Change-Id: I53b16e6d784071a04fe3fe1a9aaac8d5be91077b (cherry picked from commit d328f613cbe55ba935f23cef081a0f1e1cc40977)
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.SystemProperties;
|
import android.sysprop.SetupWizardProperties;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -27,13 +27,10 @@ import com.google.android.setupdesign.util.ThemeHelper;
|
|||||||
|
|
||||||
public class SetupWizardUtils {
|
public class SetupWizardUtils {
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String SYSTEM_PROP_SETUPWIZARD_THEME = "setupwizard.theme";
|
|
||||||
|
|
||||||
public static int getTheme(Intent intent) {
|
public static int getTheme(Intent intent) {
|
||||||
String theme = intent.getStringExtra(WizardManagerHelper.EXTRA_THEME);
|
String theme = intent.getStringExtra(WizardManagerHelper.EXTRA_THEME);
|
||||||
if (theme == null) {
|
if (theme == null) {
|
||||||
theme = SystemProperties.get(SYSTEM_PROP_SETUPWIZARD_THEME);
|
theme = SetupWizardProperties.theme().orElse("");
|
||||||
}
|
}
|
||||||
if (theme != null) {
|
if (theme != null) {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
|
@@ -19,7 +19,7 @@ package com.android.settings;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.SystemProperties;
|
import android.sysprop.SetupWizardProperties;
|
||||||
|
|
||||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||||
import com.google.android.setupdesign.util.ThemeHelper;
|
import com.google.android.setupdesign.util.ThemeHelper;
|
||||||
@@ -47,8 +47,7 @@ public class SetupWizardUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
|
public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
|
||||||
SystemProperties.set(SetupWizardUtils.SYSTEM_PROP_SETUPWIZARD_THEME,
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
|
||||||
ThemeHelper.THEME_GLIF);
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
||||||
|
|
||||||
@@ -57,8 +56,7 @@ public class SetupWizardUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheme_withEmptyIntent_shouldReturnSystemProperty() {
|
public void testGetTheme_withEmptyIntent_shouldReturnSystemProperty() {
|
||||||
SystemProperties.set(SetupWizardUtils.SYSTEM_PROP_SETUPWIZARD_THEME,
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
||||||
ThemeHelper.THEME_GLIF_V2_LIGHT);
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
|
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
|
||||||
@@ -66,8 +64,7 @@ public class SetupWizardUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
|
public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
|
||||||
SystemProperties.set(SetupWizardUtils.SYSTEM_PROP_SETUPWIZARD_THEME,
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
||||||
ThemeHelper.THEME_GLIF_V3_LIGHT);
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
|
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
|
||||||
|
Reference in New Issue
Block a user