Use FooterPreference in xml explicitly

Removed the FooterPreferenceMixin from the ChooseLockGeneric page.

Fixes: 139269907
Test: manual test
Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.password
Change-Id: I86e294015354c0a6a6311441892a770503382d1f
This commit is contained in:
Sunny Shao
2019-08-12 20:33:47 +08:00
parent 2961394f98
commit 1bebe19101
3 changed files with 19 additions and 12 deletions

View File

@@ -15,6 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/lock_settings_picker_title"
android:key="lock_settings_picker">
@@ -57,4 +58,9 @@
android:title="@string/face_unlock_skip_face"
android:persistent="false"/>
<com.android.settingslib.widget.FooterPreference
android:key="lock_settings_footer"
android:selectable="false"
settings:searchable="false"/>
</PreferenceScreen>

View File

@@ -74,8 +74,6 @@ import com.android.settings.search.SearchFeatureProvider;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.widget.FooterPreference;
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
import java.util.List;
@@ -112,6 +110,7 @@ public class ChooseLockGeneric extends SettingsActivity {
public static final String MINIMUM_QUALITY_KEY = "minimum_quality";
public static final String HIDE_DISABLED_PREFS = "hide_disabled_prefs";
public static final String TAG_FRP_WARNING_DIALOG = "frp_warning_dialog";
public static final String KEY_LOCK_SETTINGS_FOOTER ="lock_settings_footer";
/**
* Boolean extra determining whether a "screen lock options" button should be shown. This
@@ -499,11 +498,12 @@ public class ChooseLockGeneric extends SettingsActivity {
protected void addPreferences() {
addPreferencesFromResource(R.xml.security_settings_picker);
final Preference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER);
if (!TextUtils.isEmpty(mCallerAppName) && !mIsCallingAppAdmin) {
FooterPreferenceMixinCompat footerMixin =
new FooterPreferenceMixinCompat(this, getSettingsLifecycle());
FooterPreference footer = footerMixin.createFooterPreference();
footer.setVisible(true);
footer.setTitle(getFooterString());
} else {
footer.setVisible(false);
}
// Used for testing purposes

View File

@@ -22,6 +22,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_LOW;
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_MEDIUM;
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.KEY_LOCK_SETTINGS_FOOTER;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
@@ -136,7 +137,7 @@ public class ChooseLockGenericTest {
mActivity.getString(R.string.unlock_footer_high_complexity_requested, "app name");
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
assertThat(footer.getTitle()).isEqualTo(expectedTitle);
}
@@ -152,7 +153,7 @@ public class ChooseLockGenericTest {
mActivity.getString(R.string.unlock_footer_medium_complexity_requested, "app name");
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
assertThat(footer.getTitle()).isEqualTo(expectedTitle);
}
@@ -168,7 +169,7 @@ public class ChooseLockGenericTest {
mActivity.getString(R.string.unlock_footer_low_complexity_requested, "app name");
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
assertThat(footer.getTitle()).isEqualTo(expectedTitle);
}
@@ -184,19 +185,19 @@ public class ChooseLockGenericTest {
mActivity.getString(R.string.unlock_footer_none_complexity_requested, "app name");
mFragment.updatePreferencesOrFinish(/* isRecreatingActivity= */ false);
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
assertThat(footer.getTitle()).isEqualTo(expectedTitle);
}
@Test
public void updatePreferencesOrFinish_callingAppIsAdmin_noFooter() {
public void updatePreferencesOrFinish_callingAppIsAdmin_footerInvisible() {
initActivity(new Intent().putExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, true));
mFragment.updatePreferencesOrFinish(/* isRecreatingActivity= */ false);
FooterPreference footer = mFragment.findPreference(FooterPreference.KEY_FOOTER);
assertThat(footer).isNull();
FooterPreference footer = mFragment.findPreference(KEY_LOCK_SETTINGS_FOOTER);
assertThat(footer.isVisible()).isFalse();
}
@Test