Fix sketchy usage of new PreferenceScreen

Things get weird if you don't use PreferenceManager#createPreferenceScreen

Bug: 37216851
Test: Compiles and runs
Change-Id: I7cebec133c4f27f7eeda83c95d8acb4823f67dc4
This commit is contained in:
Tony Mantler
2017-04-10 15:20:59 -07:00
parent 8bb9f33c6f
commit 76f46fc869
3 changed files with 20 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen />

View File

@@ -184,8 +184,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
mUnavailable = isUiRestricted(); mUnavailable = isUiRestricted();
setHasOptionsMenu(!mUnavailable); setHasOptionsMenu(!mUnavailable);
if (mUnavailable) { if (mUnavailable) {
setPreferenceScreen(new PreferenceScreen(getPrefContext(), null)); addPreferencesFromResource(R.xml.empty_settings);
getPreferenceScreen().removeAll();
return; return;
} }

View File

@@ -396,7 +396,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
// Block access to developer options if the user is not the owner, if user policy // Block access to developer options if the user is not the owner, if user policy
// restricts it, or if the device has not been provisioned // restricts it, or if the device has not been provisioned
mUnavailable = true; mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getPrefContext(), null)); addPreferencesFromResource(R.xml.empty_settings);
return; return;
} }