WifiManager: Ignore void API calls with default values
When wifi service is not yet up, we throw a remote exception for API calls which have void return. Change this to only throw a remote exception when the input params have non-default values. This takes care of cases where some other system modules resets wifi params as a part of their initialization sequence (which will already be the value when the wifi service comes up, so the calls are not useful) Bug: 140076130 Bug: 139897982 Test: atest WifiManagerTest Change-Id: If24d5ae52f1d39d2d99a860f3dc6c5f1860fd656
This commit is contained in:
@@ -52,12 +52,14 @@ import android.os.Messenger;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.WorkSource;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.AsyncChannel;
|
||||
import com.android.internal.util.Protocol;
|
||||
import com.android.server.net.NetworkPinner;
|
||||
@@ -1821,6 +1823,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (config == null) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
if (!iWifiManager.addOrUpdatePasspointConfiguration(
|
||||
@@ -1849,6 +1852,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (TextUtils.isEmpty(fqdn)) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
if (!iWifiManager.removePasspointConfiguration(
|
||||
@@ -1899,6 +1903,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (bssid == 0L || TextUtils.isEmpty(fileName)) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.queryPasspointIcon(bssid, fileName);
|
||||
@@ -1928,6 +1933,8 @@ public class WifiManager {
|
||||
* @param holdoff hold off time in milliseconds
|
||||
* @param ess set if the hold off pertains to an ESS rather than a BSS
|
||||
* @hide
|
||||
*
|
||||
* TODO (140167680): This needs to be removed, the implementation is empty!
|
||||
*/
|
||||
public void deauthenticateNetwork(long holdoff, boolean ess) {
|
||||
try {
|
||||
@@ -2504,6 +2511,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (TextUtils.isEmpty(country)) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.setCountryCode(country);
|
||||
@@ -2692,6 +2700,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (TextUtils.isEmpty(ifaceName) || mode == IFACE_IP_MODE_UNSPECIFIED) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.updateInterfaceIpState(ifaceName, mode);
|
||||
@@ -3044,6 +3053,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (remoteIPAddress == null || !enable) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.enableTdls(remoteIPAddress.getHostAddress(), enable);
|
||||
@@ -3062,6 +3072,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (TextUtils.isEmpty(remoteMacAddress) || !enable) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.enableTdlsWithMacAddress(remoteMacAddress, enable);
|
||||
@@ -3956,7 +3967,7 @@ public class WifiManager {
|
||||
android.Manifest.permission.NETWORK_STACK
|
||||
})
|
||||
public void disableEphemeralNetwork(String SSID) {
|
||||
if (SSID == null) throw new IllegalArgumentException("SSID cannot be null");
|
||||
if (TextUtils.isEmpty(SSID)) throw new IllegalArgumentException("SSID cannot be null");
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
@@ -4495,6 +4506,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (verbose == 0) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.enableVerboseLogging(verbose);
|
||||
@@ -4581,6 +4593,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (enabled) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.enableWifiConnectivityManager(enabled);
|
||||
@@ -4611,6 +4624,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (ArrayUtils.isEmpty(data)) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.restoreBackupData(data);
|
||||
@@ -4631,6 +4645,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (ArrayUtils.isEmpty(supplicantData) && ArrayUtils.isEmpty(ipConfigData)) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.restoreSupplicantBackupData(supplicantData, ipConfigData);
|
||||
@@ -4937,6 +4952,7 @@ public class WifiManager {
|
||||
try {
|
||||
IWifiManager iWifiManager = getIWifiManager();
|
||||
if (iWifiManager == null) {
|
||||
if (state == DEVICE_MOBILITY_STATE_UNKNOWN) return;
|
||||
throw new RemoteException("Wifi service is not running");
|
||||
}
|
||||
iWifiManager.setDeviceMobilityState(state);
|
||||
|
||||
Reference in New Issue
Block a user