Fix trust agent summary not being updated.
- move the handling for enabling the trust agent preference and its summary from displayPreference() into updateState(), so that when user navigates to change screen lock or update trust agent and returns to the security settings page, the trust agent preference enabled state and summary will be refreshed correctly. Change-Id: I60bccfdff755a046a9f5453d39a7ac9d3ce0277c Fixes: 72420147 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -20,7 +20,6 @@ import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
@@ -52,21 +51,18 @@ public class ManageTrustAgentsPreferenceController extends BasePreferenceControl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
final Preference preference = screen.findPreference(getPreferenceKey());
|
||||
if (preference == null) {
|
||||
return;
|
||||
}
|
||||
public void updateState(Preference preference) {
|
||||
final int numberOfTrustAgent = getTrustAgentCount();
|
||||
if (!mLockPatternUtils.isSecure(MY_USER_ID)) {
|
||||
preference.setEnabled(false);
|
||||
preference.setSummary(R.string.disabled_because_no_backup_security);
|
||||
} else if (numberOfTrustAgent > 0) {
|
||||
preference.setEnabled(true);
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.manage_trust_agents_summary_on,
|
||||
numberOfTrustAgent, numberOfTrustAgent));
|
||||
} else {
|
||||
preference.setEnabled(true);
|
||||
preference.setSummary(R.string.manage_trust_agents_summary);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user