[Catalyst] Rebind restricted preferences for SettingsPreferenceFragment
Bug: 377600992 Fix: 397357248 Flag: com.android.settings.flags.catalyst Test: manual Change-Id: I4ce83d8032d9ef8730dec5efd61f9834f2433983
This commit is contained in:
@@ -50,12 +50,14 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.restriction.UserRestrictionBindingHelper;
|
||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||
import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
|
||||
import com.android.settings.widget.LoadingViewController;
|
||||
import com.android.settingslib.CustomDialogPreferenceCompat;
|
||||
import com.android.settingslib.CustomEditTextPreferenceCompat;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.preference.PreferenceScreenBindingHelper;
|
||||
import com.android.settingslib.preference.PreferenceScreenCreator;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
@@ -130,6 +132,8 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
public HighlightablePreferenceGroupAdapter mAdapter;
|
||||
private boolean mPreferenceHighlighted = false;
|
||||
|
||||
private @Nullable UserRestrictionBindingHelper mUserRestrictionBindingHelper;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
if (shouldSkipForInitialSUW() && !WizardManagerHelper.isDeviceProvisioned(getContext())) {
|
||||
@@ -148,6 +152,14 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
|
||||
}
|
||||
HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(this /* host */);
|
||||
|
||||
if (isCatalystEnabled()) {
|
||||
PreferenceScreenBindingHelper helper = getPreferenceScreenBindingHelper();
|
||||
if (helper != null) {
|
||||
mUserRestrictionBindingHelper = new UserRestrictionBindingHelper(requireContext(),
|
||||
helper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -500,6 +512,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
return getActivity().getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mUserRestrictionBindingHelper != null) {
|
||||
mUserRestrictionBindingHelper.close();
|
||||
mUserRestrictionBindingHelper = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
if (isRemoving()) {
|
||||
|
Reference in New Issue
Block a user