Add summary text to Lock screen preferences.
Each time we refresh the security preference page, get the current summary text from "On the lock screen" and populate to Lock screen preferences summary. Bug: 36540633 Test: make RunSettingsRoboTests Change-Id: I317e3892b35b30981b62f7b7aee9cfdacd04a3ed
This commit is contained in:
@@ -750,8 +750,6 @@
|
||||
<string name="encryption_and_credential_settings_summary">Phone encrypted</string>
|
||||
<!-- Security Settings screen setting option title for the item to take you to the lock screen preference screen [CHAR LIMIT=60] -->
|
||||
<string name="lockscreen_settings_title">Lock screen preferences</string>
|
||||
<!-- Security Settings screen setting option summary for the item to take you to the lock screen preference screen -->
|
||||
<string name="lockscreen_settings_summary">Show all notification content</string>
|
||||
|
||||
<!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen -->
|
||||
<string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string>
|
||||
|
@@ -31,7 +31,6 @@
|
||||
|
||||
<Preference android:key="lockscreen_preferences"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:summary="@string/lockscreen_settings_summary"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
<Preference android:key="lockscreen_preferences"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:summary="@string/lockscreen_settings_summary"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
<Preference android:key="lockscreen_preferences"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:summary="@string/lockscreen_settings_summary"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
<Preference android:key="lockscreen_preferences"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:summary="@string/lockscreen_settings_summary"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@@ -60,6 +60,7 @@ import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
|
||||
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
|
||||
import com.android.settings.fingerprint.FingerprintSettings;
|
||||
import com.android.settings.location.LocationPreferenceController;
|
||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
@@ -103,6 +104,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
@VisibleForTesting
|
||||
static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
|
||||
private static final String KEY_UNIFICATION = "unification";
|
||||
@VisibleForTesting
|
||||
static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
|
||||
|
||||
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
|
||||
private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
|
||||
@@ -169,6 +172,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
private LocationPreferenceController mLocationcontroller;
|
||||
private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController;
|
||||
private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController;
|
||||
private LockScreenNotificationPreferenceController mLockScreenNotificationPreferenceController;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -210,6 +214,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
= new ManageDeviceAdminPreferenceController(activity);
|
||||
mEnterprisePrivacyPreferenceController
|
||||
= new EnterprisePrivacyPreferenceController(activity, null /* lifecycle */);
|
||||
mLockScreenNotificationPreferenceController
|
||||
= new LockScreenNotificationPreferenceController(activity);
|
||||
}
|
||||
|
||||
private static int getResIdForLockUnlockScreen(Context context,
|
||||
@@ -317,6 +323,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
if (securityCategory != null) {
|
||||
maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
|
||||
numberOfTrustAgent = addTrustAgentSettings(securityCategory);
|
||||
setLockscreenPreferencesSummary(securityCategory);
|
||||
}
|
||||
|
||||
mVisiblePatternProfile =
|
||||
@@ -423,6 +430,15 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setLockscreenPreferencesSummary(PreferenceGroup group) {
|
||||
final Preference lockscreenPreferences = group.findPreference(KEY_LOCKSCREEN_PREFERENCES);
|
||||
if (lockscreenPreferences != null) {
|
||||
lockscreenPreferences.setSummary(
|
||||
mLockScreenNotificationPreferenceController.getSummaryResource());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
|
||||
* The preference must be a RestrictedPreference.
|
||||
|
@@ -267,16 +267,20 @@ public class LockScreenNotificationPreferenceController extends PreferenceContro
|
||||
}
|
||||
}
|
||||
|
||||
public int getSummaryResource() {
|
||||
final boolean enabled = getLockscreenNotificationsEnabled(UserHandle.myUserId());
|
||||
final boolean allowPrivate = !mSecure
|
||||
|| getLockscreenAllowPrivateNotifications(UserHandle.myUserId());
|
||||
return !enabled ? R.string.lock_screen_notifications_summary_disable :
|
||||
allowPrivate ? R.string.lock_screen_notifications_summary_show :
|
||||
R.string.lock_screen_notifications_summary_hide;
|
||||
}
|
||||
|
||||
private void updateLockscreenNotifications() {
|
||||
if (mLockscreen == null) {
|
||||
return;
|
||||
}
|
||||
final boolean enabled = getLockscreenNotificationsEnabled(UserHandle.myUserId());
|
||||
final boolean allowPrivate = !mSecure
|
||||
|| getLockscreenAllowPrivateNotifications(UserHandle.myUserId());
|
||||
mLockscreenSelectedValue = !enabled ? R.string.lock_screen_notifications_summary_disable :
|
||||
allowPrivate ? R.string.lock_screen_notifications_summary_show :
|
||||
R.string.lock_screen_notifications_summary_hide;
|
||||
mLockscreenSelectedValue = getSummaryResource();
|
||||
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
|
||||
}
|
||||
|
||||
|
@@ -24,10 +24,12 @@ import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
@@ -47,6 +49,7 @@ import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.Map;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
@@ -186,4 +189,22 @@ public class SecuritySettingsTest {
|
||||
verify(preference).setSummary(context.getResources().getQuantityString(
|
||||
R.plurals.manage_trust_agents_summary_on, 2, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetLockscreenPreferencesSummary_shouldSetSummaryFromLockScreenNotification() {
|
||||
final Preference preference = mock(Preference.class);
|
||||
final PreferenceGroup group = mock(PreferenceGroup.class);
|
||||
when(group.findPreference(SecuritySettings.KEY_LOCKSCREEN_PREFERENCES))
|
||||
.thenReturn(preference);
|
||||
final LockScreenNotificationPreferenceController controller =
|
||||
mock(LockScreenNotificationPreferenceController.class);
|
||||
|
||||
final SecuritySettings securitySettings = new SecuritySettings();
|
||||
ReflectionHelpers.setField(securitySettings,
|
||||
"mLockScreenNotificationPreferenceController", controller);
|
||||
|
||||
when(controller.getSummaryResource()).thenReturn(1234);
|
||||
securitySettings.setLockscreenPreferencesSummary(group);
|
||||
verify(preference).setSummary(1234);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user