Merge "[Thread] add country code overlay to enable/disable setting Thread country code" into main
This commit is contained in:
commit
adb71602c5
5 changed files with 40 additions and 0 deletions
|
|
@ -30,6 +30,15 @@
|
|||
-->
|
||||
<bool name="config_thread_border_router_default_enabled">false</bool>
|
||||
|
||||
<!-- Whether to enable or disable setting Thread country code from the telephony, wifi, location,
|
||||
etc. The country code could be used by the Thread co-processor for setting the fixed output
|
||||
power of Thread radio. If the device needs to dynamically change the max output power according
|
||||
to the user scenario to meet the requirement of Specific Absorption Rate (SAR), it should call
|
||||
the API `setChannelMaxPowers()` to change the max output power, and this configuration could be
|
||||
set to false to disable the Thread service from setting the Thread country code.
|
||||
-->
|
||||
<bool name="config_thread_country_code_enabled">true</bool>
|
||||
|
||||
<!-- Whether to use location APIs in the algorithm to determine country code or not.
|
||||
If disabled, will use other sources (telephony, wifi, etc) to determine device location for
|
||||
Thread Network regulatory purposes.
|
||||
|
|
|
|||
|
|
@ -628,12 +628,15 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub
|
|||
boolean srpServerWaitEnabled = mResources.get().getBoolean(srpServerConfig);
|
||||
int autoJoinConfig = R.bool.config_thread_border_router_auto_join_enabled;
|
||||
boolean autoJoinEnabled = mResources.get().getBoolean(autoJoinConfig);
|
||||
boolean countryCodeEnabled =
|
||||
mResources.get().getBoolean(R.bool.config_thread_country_code_enabled);
|
||||
return new OtDaemonConfiguration.Builder()
|
||||
.setBorderRouterEnabled(threadConfig.isBorderRouterEnabled())
|
||||
.setNat64Enabled(threadConfig.isNat64Enabled())
|
||||
.setDhcpv6PdEnabled(threadConfig.isDhcpv6PdEnabled())
|
||||
.setSrpServerWaitForBorderRoutingEnabled(srpServerWaitEnabled)
|
||||
.setBorderRouterAutoJoinEnabled(autoJoinEnabled)
|
||||
.setCountryCodeEnabled(countryCodeEnabled)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package com.android.server.thread;
|
||||
|
||||
import static android.net.thread.ThreadNetworkException.ERROR_UNSUPPORTED_FEATURE;
|
||||
|
||||
import static com.android.server.thread.ThreadPersistentSettings.KEY_COUNTRY_CODE;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
|
|
@ -223,6 +224,10 @@ public class ThreadNetworkCountryCode {
|
|||
.getBoolean(R.bool.config_thread_location_use_for_country_code_enabled);
|
||||
}
|
||||
|
||||
private boolean isCountryCodeEnabled() {
|
||||
return mResources.get().getBoolean(R.bool.config_thread_country_code_enabled);
|
||||
}
|
||||
|
||||
public ThreadNetworkCountryCode(
|
||||
LocationManager locationManager,
|
||||
ThreadNetworkControllerService threadNetworkControllerService,
|
||||
|
|
@ -270,6 +275,11 @@ public class ThreadNetworkCountryCode {
|
|||
|
||||
/** Sets up this country code module to listen to location country code changes. */
|
||||
public synchronized void initialize() {
|
||||
if (!isCountryCodeEnabled()) {
|
||||
LOG.i("Thread country code is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
registerGeocoderCountryCodeCallback();
|
||||
registerWifiCountryCodeCallback();
|
||||
registerTelephonyCountryCodeCallback();
|
||||
|
|
@ -654,6 +664,7 @@ public class ThreadNetworkCountryCode {
|
|||
/** Dumps the current state of this ThreadNetworkCountryCode object. */
|
||||
public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
pw.println("---- Dump of ThreadNetworkCountryCode begin ----");
|
||||
pw.println("isCountryCodeEnabled : " + isCountryCodeEnabled());
|
||||
pw.println("mIsCpSettingCountryCodeSupported: " + mIsCpSettingCountryCodeSupported);
|
||||
pw.println("mOverrideCountryCodeInfo : " + mOverrideCountryCodeInfo);
|
||||
pw.println("mTelephonyCountryCodeSlotInfoMap: " + mTelephonyCountryCodeSlotInfoMap);
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ public final class ThreadNetworkControllerServiceTest {
|
|||
.thenReturn(TEST_MODEL_NAME);
|
||||
when(mResources.getStringArray(eq(R.array.config_thread_mdns_vendor_specific_txts)))
|
||||
.thenReturn(new String[] {});
|
||||
when(mResources.getBoolean(eq(R.bool.config_thread_country_code_enabled))).thenReturn(true);
|
||||
|
||||
final AtomicFile storageFile = new AtomicFile(tempFolder.newFile("thread_settings.xml"));
|
||||
mPersistentSettings = new ThreadPersistentSettings(storageFile, mConnectivityResources);
|
||||
|
|
|
|||
|
|
@ -205,6 +205,21 @@ public class ThreadNetworkCountryCodeTest {
|
|||
assertThat(mThreadNetworkCountryCode.getCountryCode()).isEqualTo(TEST_COUNTRY_CODE_US);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_countryCodeDisabled_defaultCountryCodeIsUsed() {
|
||||
when(mResources.getBoolean(R.bool.config_thread_country_code_enabled)).thenReturn(false);
|
||||
|
||||
mThreadNetworkCountryCode.initialize();
|
||||
|
||||
verifyNoMoreInteractions(mWifiManager);
|
||||
verifyNoMoreInteractions(mTelephonyManager);
|
||||
verifyNoMoreInteractions(mSubscriptionManager);
|
||||
verifyNoMoreInteractions(mGeocoder);
|
||||
verifyNoMoreInteractions(mLocationManager);
|
||||
|
||||
assertThat(mThreadNetworkCountryCode.getCountryCode()).isEqualTo(DEFAULT_COUNTRY_CODE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_locationUseIsDisabled_locationFunctionIsNotCalled() {
|
||||
when(mResources.getBoolean(R.bool.config_thread_location_use_for_country_code_enabled))
|
||||
|
|
@ -507,6 +522,7 @@ public class ThreadNetworkCountryCodeTest {
|
|||
mThreadNetworkCountryCode.dump(new FileDescriptor(), printWriter, null);
|
||||
String outputString = stringWriter.toString();
|
||||
|
||||
assertThat(outputString).contains("isCountryCodeEnabled");
|
||||
assertThat(outputString).contains("mIsCpSettingCountryCodeSupported");
|
||||
assertThat(outputString).contains("mOverrideCountryCodeInfo");
|
||||
assertThat(outputString).contains("mTelephonyCountryCodeSlotInfoMap");
|
||||
|
|
|
|||
Loading…
Reference in a new issue