Merge "More concisely export whether we have a "tetherable configuration"" am: 1b2a1b911d

am: 72c17a7234

Change-Id: Ic67b2d4589f586c67109216330f68cb1fc08c55a
This commit is contained in:
Erik Kline
2017-01-23 07:20:32 +00:00
committed by android-build-merger
2 changed files with 13 additions and 16 deletions

View File

@@ -3108,10 +3108,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

@@ -204,7 +204,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
return (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
}
void updateConfiguration() {
private void updateConfiguration() {
mConfig = new TetheringConfiguration(mContext);
}
@@ -816,6 +816,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() {
@@ -863,17 +874,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>();