Make TetherSettings extend RestrictedDashboardFragment
RestrictedSettingsFragment is deprecated and no longer supported. To be compatible with catalyst, change the super class to RestrictedDashboardFragment. Bug: 368359963 Test: atest TetherSettingsTest, manual test with the user restriction Flag: EXEMPT N/A Change-Id: If8c5af9d716c63fd33cb508394e7d13450c9d2e7
This commit is contained in:
@@ -54,8 +54,8 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
import com.android.settings.datausage.DataSaverBackend;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.wifi.tether.WifiTetherPreferenceController;
|
||||
@@ -75,7 +75,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
* Displays preferences for Tethering.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class TetherSettings extends RestrictedSettingsFragment
|
||||
public class TetherSettings extends RestrictedDashboardFragment
|
||||
implements DataSaverBackend.Listener {
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -143,11 +143,19 @@ public class TetherSettings extends RestrictedSettingsFragment
|
||||
super(UserManager.DISALLOW_CONFIG_TETHERING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.tether_prefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
// Even when the UI is restricted, addPreferencesFromResource cannot be omitted.
|
||||
addPreferencesFromResource(R.xml.tether_prefs);
|
||||
setIfOnlyAvailableForAdmins(true);
|
||||
if (isUiRestricted()) {
|
||||
return;
|
||||
|
@@ -54,7 +54,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
import com.android.settings.wifi.tether.WifiTetherPreferenceController;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
@@ -130,14 +130,12 @@ public class TetherSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowRestrictedSettingsFragment.class)
|
||||
@Config(shadows = ShadowRestrictedDashboardFragment.class)
|
||||
public void onCreate_isUiRestricted_doNotSetupViewModel() {
|
||||
doNothing().when(mTetherSettings).addPreferencesFromResource(anyInt());
|
||||
when(mTetherSettings.isUiRestricted()).thenReturn(true);
|
||||
|
||||
mTetherSettings.onCreate(null);
|
||||
|
||||
verify(mTetherSettings).addPreferencesFromResource(anyInt());
|
||||
verify(mTetherSettings, never()).setupViewModel();
|
||||
}
|
||||
|
||||
@@ -454,8 +452,8 @@ public class TetherSettingsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Implements(RestrictedSettingsFragment.class)
|
||||
public static final class ShadowRestrictedSettingsFragment {
|
||||
@Implements(RestrictedDashboardFragment.class)
|
||||
public static final class ShadowRestrictedDashboardFragment {
|
||||
@Implementation
|
||||
public void onCreate(Bundle icicle) {
|
||||
// do nothing
|
||||
|
Reference in New Issue
Block a user