Assign StaticIpConfiguration builder value to global variable

[Root Cause]
Due to call by reference for Object, we pass the StaticIpConfiguration
to method. But in method we new the staticIpConfiguration builder
and re-assign builder to parameter, it will release when the method is ended.
The value in Builder will not be set to global variable.

[Solution]
Assign the value in StaticIpConfiguration builder to global variable
directly.

Bug: 186489618
Test: manual test
      make RunSettingsRoboTests ROBOTEST_FILTER=WifiConfigController2Test
Change-Id: I1a6aee31e6977be42792440c3667db2557a20c4e
This commit is contained in:
changbetty
2021-05-04 14:40:31 +08:00
parent d8c11f5236
commit 01cc97f382

View File

@@ -923,7 +923,6 @@ public class WifiConfigController2 implements TextWatcher,
return R.string.wifi_ip_settings_invalid_dns;
}
dnsServers.add(dnsAddr);
staticIpConfiguration.getDnsServers().add(dnsAddr);
}
if (mDns2View.length() > 0) {
@@ -933,14 +932,13 @@ public class WifiConfigController2 implements TextWatcher,
return R.string.wifi_ip_settings_invalid_dns;
}
dnsServers.add(dnsAddr);
staticIpConfiguration.getDnsServers().add(dnsAddr);
}
staticIPBuilder.setDnsServers(dnsServers);
return 0;
} finally {
// Caller of this method may rely on staticIpConfiguration, so build the final result
// at the end of the method.
staticIpConfiguration = staticIPBuilder.build();
mStaticIpConfiguration = staticIPBuilder.build();
}
}