More concisely export whether we have a "tetherable configuration"

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - vanilla WiFi-to-mobile tethering works
Bug: 32163131
Change-Id: I20dd36b5bf7fc55a639c76ea4bdb55b650654881
This commit is contained in:
Erik Kline
2017-01-23 13:01:58 +09:00
parent b3b665de22
commit d781fbad3f
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)
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
return tetherEnabledInSettings && mUserManager.isAdminUser() &&
((mTethering.getTetherableUsbRegexs().length != 0 ||
mTethering.getTetherableWifiRegexs().length != 0 ||
mTethering.getTetherableBluetoothRegexs().length != 0) &&
mTethering.getUpstreamIfaceTypes().length != 0);
mTethering.hasTetherableConfiguration();
}
@Override

View File

@@ -205,7 +205,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
return (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
}
void updateConfiguration() {
private void updateConfiguration() {
mConfig = new TetheringConfiguration(mContext);
}
@@ -817,6 +817,17 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
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(),
// which has only final members.
public String[] getTetherableUsbRegexs() {
@@ -864,17 +875,6 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
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?
public String[] getTetheredIfaces() {
ArrayList<String> list = new ArrayList<String>();