Clean up NetworkServices from setTemplate

Not used any more.

Bug: 290856342
Test: manual - on mobile settings
Test: m RunSettingsRoboTests
Test: unit test
Change-Id: I9c8dde2a8812e83e535d15713ccbf25b42f1f303
This commit is contained in:
Chaohui Wang
2023-09-21 12:46:50 +08:00
parent ba1ec910ac
commit c39acee194
12 changed files with 24 additions and 60 deletions

View File

@@ -23,7 +23,6 @@ import android.util.AttributeSet
import androidx.preference.Preference
import com.android.settings.R
import com.android.settings.core.SubSettingLauncher
import com.android.settings.datausage.TemplatePreference.NetworkServices
import com.android.settings.datausage.lib.BillingCycleRepository
import com.android.settings.network.MobileDataEnabledListener
@@ -45,7 +44,7 @@ class BillingCyclePreference @JvmOverloads constructor(
updateEnabled()
}
override fun setTemplate(template: NetworkTemplate, subId: Int, services: NetworkServices?) {
override fun setTemplate(template: NetworkTemplate, subId: Int) {
this.template = template
this.subId = subId
summary = null

View File

@@ -42,7 +42,7 @@ public class BillingCyclePreferenceController extends BasePreferenceController {
NetworkTemplate template = DataUsageLib.getMobileTemplate(mContext, mSubscriptionId);
preference.setTemplate(template, mSubscriptionId, null);
preference.setTemplate(template, mSubscriptionId);
}
@Override

View File

@@ -99,7 +99,7 @@ public class CellDataPreference extends CustomDialogPreferenceCompat
}
@Override
public void setTemplate(NetworkTemplate template, int subId, NetworkServices services) {
public void setTemplate(NetworkTemplate template, int subId) {
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
throw new IllegalArgumentException("CellDataPreference needs a SubscriptionInfo");
}

View File

@@ -49,7 +49,7 @@ public class DataUsagePreference extends Preference implements TemplatePreferenc
}
@Override
public void setTemplate(NetworkTemplate template, int subId, NetworkServices services) {
public void setTemplate(NetworkTemplate template, int subId) {
mTemplate = template;
mSubId = subId;
final DataUsageController controller = getDataUsageController();

View File

@@ -183,9 +183,8 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
private void addMobileSection(int subId, SubscriptionInfo subInfo) {
TemplatePreferenceCategory category = (TemplatePreferenceCategory)
inflatePreferences(R.xml.data_usage_cellular);
category.setTemplate(DataUsageLib.getMobileTemplate(getContext(), subId),
subId, services);
category.pushTemplates(services);
category.setTemplate(DataUsageLib.getMobileTemplate(getContext(), subId), subId);
category.pushTemplates();
final CharSequence displayName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
subInfo, getContext());
if (subInfo != null && !TextUtils.isEmpty(displayName)) {
@@ -198,15 +197,14 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
void addWifiSection() {
TemplatePreferenceCategory category = (TemplatePreferenceCategory)
inflatePreferences(R.xml.data_usage_wifi);
category.setTemplate(new NetworkTemplate.Builder(NetworkTemplate.MATCH_WIFI).build(),
0, services);
category.setTemplate(new NetworkTemplate.Builder(NetworkTemplate.MATCH_WIFI).build(), 0);
}
private void addEthernetSection() {
TemplatePreferenceCategory category = (TemplatePreferenceCategory)
inflatePreferences(R.xml.data_usage_ethernet);
category.setTemplate(new NetworkTemplate.Builder(NetworkTemplate.MATCH_ETHERNET).build(),
0, services);
category.setTemplate(
new NetworkTemplate.Builder(NetworkTemplate.MATCH_ETHERNET).build(), 0);
}
private Preference inflatePreferences(int resId) {
@@ -259,10 +257,10 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
private void updateState() {
PreferenceScreen screen = getPreferenceScreen();
for (int i = 1; i < screen.getPreferenceCount(); i++) {
Preference currentPreference = screen.getPreference(i);
if (currentPreference instanceof TemplatePreferenceCategory) {
((TemplatePreferenceCategory) currentPreference).pushTemplates(services);
}
Preference currentPreference = screen.getPreference(i);
if (currentPreference instanceof TemplatePreferenceCategory) {
((TemplatePreferenceCategory) currentPreference).pushTemplates();
}
}
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright (C) 2016 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.
*/
package com.android.settings.datausage;
import android.content.Context;
import android.net.NetworkTemplate;
import android.util.AttributeSet;
import androidx.preference.Preference;
public class NetworkRestrictionsPreference extends Preference implements TemplatePreference {
public NetworkRestrictionsPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void setTemplate(NetworkTemplate template, int subId,
NetworkServices services) {
// TODO: Summary
}
}

View File

@@ -25,7 +25,8 @@ import com.android.settingslib.NetworkPolicyEditor;
public interface TemplatePreference {
void setTemplate(NetworkTemplate template, int subId, NetworkServices services);
/** Sets the network template. */
void setTemplate(NetworkTemplate template, int subId);
class NetworkServices {
INetworkManagementService mNetworkService;

View File

@@ -31,8 +31,7 @@ public class TemplatePreferenceCategory extends PreferenceCategory implements Te
}
@Override
public void setTemplate(NetworkTemplate template, int subId,
NetworkServices services) {
public void setTemplate(NetworkTemplate template, int subId) {
mTemplate = template;
mSubId = subId;
}
@@ -46,12 +45,13 @@ public class TemplatePreferenceCategory extends PreferenceCategory implements Te
return super.addPreference(preference);
}
public void pushTemplates(NetworkServices services) {
/** Pushes the templates. */
public void pushTemplates() {
if (mTemplate == null) {
throw new RuntimeException("null mTemplate for " + getKey());
}
for (int i = 0; i < getPreferenceCount(); i++) {
((TemplatePreference) getPreference(i)).setTemplate(mTemplate, mSubId, services);
((TemplatePreference) getPreference(i)).setTemplate(mTemplate, mSubId);
}
}