Update homepage summaries for Display and Security

Also clear the redundant strings and tests.

Bug: 183586663
Test: robotests & visual
Change-Id: Iff149ac566c4b42d89810fe389ad4f723765b6b5
This commit is contained in:
Yanting Yang
2021-05-07 20:59:13 +08:00
parent cb88a7e24d
commit b2eb2bbc28
4 changed files with 4 additions and 87 deletions

View File

@@ -731,13 +731,7 @@
<!-- In the security screen, the header title for security statuses -->
<string name="security_status_title">Security status</string>
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE] -->
<string name="security_dashboard_summary_face">Screen lock, face unlock</string>
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE] -->
<string name="security_dashboard_summary">Screen lock, fingerprint</string>
<!-- Summary for Security settings when fingerprint is not supported [CHAR LIMIT=NONE]-->
<string name="security_dashboard_summary_no_fingerprint">Screen lock</string>
<!-- Summary for Security settings when biometric unlock is supported [CHAR LIMIT=NONE] -->
<string name="security_dashboard_summary_biometric">Screen lock, biometric unlock, app security</string>
<string name="security_dashboard_summary">Screen lock, Find My Device, app security</string>
<!-- Face enrollment and settings --><skip />
<!-- Message shown in summary field when face unlock is set up. [CHAR LIMIT=40] -->
@@ -10783,16 +10777,7 @@
<!-- Summary of display with screen sleep timeout [CHAR LIMIT=NONE] -->
<string name="display_summary">Sleep after <xliff:g id="timeout_description" example="10 minutes">%1$s</xliff:g> of inactivity</string>
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="display_dashboard_summary">Wallpaper, sleep, font size</string>
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="display_dashboard_summary_with_style">Styles, wallpapers, screen timeout, font size</string>
<!-- Summary for the top level Display Settings [CHAR LIMIT=NONE]-->
<string name="display_dashboard_summary_2">Screen timeout, font size</string>
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="display_dashboard_nowallpaper_summary">Sleep, font size</string>
<string name="display_dashboard_summary">Screen timeout, font size</string>
<!-- Example summary of display used in Setup Wizard preview screen [CHAR LIMIT=NONE] -->
<string name="display_summary_example">Sleep after 10 minutes of inactivity</string>

View File

@@ -86,7 +86,7 @@
android:key="top_level_display"
android:order="-80"
android:title="@string/display_settings"
android:summary="@string/summary_placeholder"
android:summary="@string/display_dashboard_summary"
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
<com.android.settingslib.RestrictedTopLevelPreference
@@ -112,7 +112,7 @@
android:key="top_level_security"
android:order="-50"
android:title="@string/security_settings_title"
android:summary="@string/security_dashboard_summary_biometric"
android:summary="@string/security_dashboard_summary"
settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
<Preference

View File

@@ -33,18 +33,4 @@ public class TopLevelDisplayPreferenceController extends BasePreferenceControlle
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@Override
public CharSequence getSummary() {
final WallpaperPreferenceController controller =
new WallpaperPreferenceController(mContext, "unused_key");
if (controller.isAvailable()) {
return mContext.getText(
controller.areStylesAvailable()
? R.string.display_dashboard_summary_with_style
: R.string.display_dashboard_summary);
} else {
return mContext.getText(R.string.display_dashboard_nowallpaper_summary);
}
}
}

View File

@@ -21,47 +21,27 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class TopLevelDisplayPreferenceControllerTest {
private Context mContext;
@Mock
private PackageManager mPackageManager;
private TopLevelDisplayPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mContext.getString(R.string.config_wallpaper_picker_package)).thenReturn("pkg");
when(mContext.getString(R.string.config_wallpaper_picker_class)).thenReturn("cls");
mController = new TopLevelDisplayPreferenceController(mContext, "test_key");
}
@@ -75,38 +55,4 @@ public class TopLevelDisplayPreferenceControllerTest {
public void getAvailabilityStatus_unsupportedWhenSet() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
@Test
public void getSummary_hasWallpaper_shouldReturnWallpaperSummary() {
final List<ResolveInfo> resolveInfos = new ArrayList<>();
resolveInfos.add(mock(ResolveInfo.class));
when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
.thenReturn(resolveInfos);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.display_dashboard_summary));
}
@Test
public void getSummary_hasWallpaperWithStyles_shouldReturnWallpaperSummary() {
when(mContext.getString(R.string.config_styles_and_wallpaper_picker_class))
.thenReturn("any.nonempty.class");
final List<ResolveInfo> resolveInfos = new ArrayList<>();
resolveInfos.add(mock(ResolveInfo.class));
when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
.thenReturn(resolveInfos);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.display_dashboard_summary_with_style));
}
@Test
public void getSummary_hasWallpaper_shouldReturnNoWallpaperSummary() {
final List<ResolveInfo> resolveInfos = new ArrayList<>();
when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
.thenReturn(resolveInfos);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.display_dashboard_nowallpaper_summary));
}
}