Merge "More concisely export whether we have a "tetherable configuration""

This commit is contained in:
Treehugger Robot
2017-01-23 07:04:21 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 16 deletions

View File

@@ -3130,10 +3130,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
Settings.Global.TETHER_SUPPORTED, defaultVal) != 0) Settings.Global.TETHER_SUPPORTED, defaultVal) != 0)
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING); && !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
return tetherEnabledInSettings && mUserManager.isAdminUser() && return tetherEnabledInSettings && mUserManager.isAdminUser() &&
((mTethering.getTetherableUsbRegexs().length != 0 || mTethering.hasTetherableConfiguration();
mTethering.getTetherableWifiRegexs().length != 0 ||
mTethering.getTetherableBluetoothRegexs().length != 0) &&
mTethering.getUpstreamIfaceTypes().length != 0);
} }
@Override @Override

View File

@@ -205,7 +205,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
return (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); return (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
} }
void updateConfiguration() { private void updateConfiguration() {
mConfig = new TetheringConfiguration(mContext); mConfig = new TetheringConfiguration(mContext);
} }
@@ -817,6 +817,17 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
return mConfig; return mConfig;
} }
public boolean hasTetherableConfiguration() {
final TetheringConfiguration cfg = mConfig;
final boolean hasDownstreamConfiguration =
(cfg.tetherableUsbRegexs.length != 0) ||
(cfg.tetherableWifiRegexs.length != 0) ||
(cfg.tetherableBluetoothRegexs.length != 0);
final boolean hasUpstreamConfiguration = !cfg.preferredUpstreamIfaceTypes.isEmpty();
return hasDownstreamConfiguration && hasUpstreamConfiguration;
}
// TODO - update callers to use getTetheringConfiguration(), // TODO - update callers to use getTetheringConfiguration(),
// which has only final members. // which has only final members.
public String[] getTetherableUsbRegexs() { public String[] getTetherableUsbRegexs() {
@@ -864,17 +875,6 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
return ConnectivityManager.TETHER_ERROR_NO_ERROR; return ConnectivityManager.TETHER_ERROR_NO_ERROR;
} }
public int[] getUpstreamIfaceTypes() {
updateConfiguration(); // TODO - remove?
final Collection<Integer> upstreams = mConfig.preferredUpstreamIfaceTypes;
final int[] values = new int[upstreams.size()];
int i = 0;
for (Integer u : upstreams) {
values[i++] = u.intValue();
}
return values;
}
// TODO review API - maybe return ArrayList<String> here and below? // TODO review API - maybe return ArrayList<String> here and below?
public String[] getTetheredIfaces() { public String[] getTetheredIfaces() {
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();