From e0adae2b89091561ab918f3cc1ff60f21121e197 Mon Sep 17 00:00:00 2001 From: David Su Date: Thu, 11 Jun 2020 17:38:36 -0700 Subject: ConfigWifiDisableInEcbm: add null check and change default value 1. CarrierConfigManager#getConfig() is @Nullable, so perform a null check to avoid NPE. 2. Change the default value from true to false to be consistent with the declaration of KEY_CONFIG_WIFI_DISABLE_IN_ECBM in CarrierConfigManager. The initial commits (under the same topic no less) were contradictory regarding the default values. I5af370c143630bdd4b075f4730fd1de1bbe1fe7d states in the commit message and code that the default should be false, but If1724f825f1c8b47ec2f29ecd8abda45ef9bc393 has the default value set to true. Bug: 156962944 Test: compiles Change-Id: I87c4d9380d6ab1f8b74c58ec8a91de4003eec426 --- service/java/com/android/server/wifi/FrameworkFacade.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java index a0b510f0f..875154e5b 100644 --- a/service/java/com/android/server/wifi/FrameworkFacade.java +++ b/service/java/com/android/server/wifi/FrameworkFacade.java @@ -32,6 +32,7 @@ import android.net.TrafficStats; import android.net.Uri; import android.net.ip.IpClientCallbacks; import android.net.ip.IpClientUtil; +import android.os.PersistableBundle; import android.provider.Settings; import android.telephony.CarrierConfigManager; import android.util.Log; @@ -173,12 +174,14 @@ public class FrameworkFacade { public boolean getConfigWiFiDisableInECBM(Context context) { CarrierConfigManager configManager = getCarrierConfigManager(context); - if (configManager != null) { - return configManager.getConfig().getBoolean( - CarrierConfigManager.KEY_CONFIG_WIFI_DISABLE_IN_ECBM); + if (configManager == null) { + return false; } - /* Default to TRUE */ - return true; + PersistableBundle bundle = configManager.getConfig(); + if (bundle == null) { + return false; + } + return bundle.getBoolean(CarrierConfigManager.KEY_CONFIG_WIFI_DISABLE_IN_ECBM); } public long getTxPackets(String iface) { -- cgit v1.2.3