From 01cc97f382df76cfb985570bc23ec6c00becaffb Mon Sep 17 00:00:00 2001 From: changbetty Date: Tue, 4 May 2021 14:40:31 +0800 Subject: [PATCH] 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 --- src/com/android/settings/wifi/WifiConfigController2.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java index 9f3b1a711d9..d913f6f7329 100644 --- a/src/com/android/settings/wifi/WifiConfigController2.java +++ b/src/com/android/settings/wifi/WifiConfigController2.java @@ -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(); } }