summaryrefslogtreecommitdiffstats
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java8
-rw-r--r--service/java/com/android/server/wifi/DppManager.java10
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiConfigStore.java5
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityHelper.java5
-rw-r--r--service/java/com/android/server/wifi/WifiController.java24
-rw-r--r--service/java/com/android/server/wifi/WifiLockManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java17
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java41
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java14
10 files changed, 89 insertions, 39 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index e6fdf08e3..daab813af 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -1770,9 +1770,9 @@ public class ClientModeImpl extends StateMachine {
* Get adaptors synchronously
*/
- public int syncGetSupportedFeatures(AsyncChannel channel) {
+ public long syncGetSupportedFeatures(AsyncChannel channel) {
Message resultMsg = channel.sendMessageSynchronously(CMD_GET_SUPPORTED_FEATURES);
- int supportedFeatureSet = resultMsg.arg1;
+ long supportedFeatureSet = ((Long) resultMsg.obj).longValue();
resultMsg.recycle();
// Mask the feature set against system properties.
@@ -3562,8 +3562,8 @@ public class ClientModeImpl extends StateMachine {
WifiManager.BUSY);
break;
case CMD_GET_SUPPORTED_FEATURES:
- int featureSet = mWifiNative.getSupportedFeatureSet(mInterfaceName);
- replyToMessage(message, message.what, featureSet);
+ long featureSet = (mWifiNative.getSupportedFeatureSet(mInterfaceName));
+ replyToMessage(message, message.what, Long.valueOf(featureSet));
break;
case CMD_GET_LINK_LAYER_STATS:
// Not supported hence reply with error message
diff --git a/service/java/com/android/server/wifi/DppManager.java b/service/java/com/android/server/wifi/DppManager.java
index f1a84b57f..f7e380819 100644
--- a/service/java/com/android/server/wifi/DppManager.java
+++ b/service/java/com/android/server/wifi/DppManager.java
@@ -170,7 +170,7 @@ public class DppManager {
try {
Log.e(TAG, "Wi-Fi client interface does not exist");
// On going DPP. Call the failure callback directly
- callback.onFailure(EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE);
+ callback.onFailure(EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_GENERIC);
} catch (RemoteException e) {
// Empty
}
@@ -184,7 +184,7 @@ public class DppManager {
try {
Log.e(TAG, "Selected network is null");
// On going DPP. Call the failure callback directly
- callback.onFailure(EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE);
+ callback.onFailure(EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_GENERIC);
} catch (RemoteException e) {
// Empty
}
@@ -228,7 +228,7 @@ public class DppManager {
if (!linkToDeath(mDppRequestInfo)) {
// Notify failure and clean up
- onFailure(EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE);
+ onFailure(EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_GENERIC);
return;
}
@@ -462,7 +462,7 @@ public class DppManager {
default:
Log.e(TAG, "onProgress: unknown code " + dppStatusCode);
mDppRequestInfo.callback.onFailure(
- EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE);
+ EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_GENERIC);
cleanupDppResources();
return;
}
@@ -560,7 +560,7 @@ public class DppManager {
case DppFailureCode.FAILURE:
default:
- dppFailureCode = EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE;
+ dppFailureCode = EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_GENERIC;
break;
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 4a0d02465..bd5ffe905 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -223,7 +223,7 @@ public class WifiConfigManager {
@VisibleForTesting
public static final long MAX_PNO_SCAN_FREQUENCY_AGE_MS = (long) 1000 * 3600 * 24 * 30;
- private static final int WIFI_PNO_FREQUENCY_CULLING_ENABLED_DEFAULT = 0; // 0 = disabled
+ private static final int WIFI_PNO_FREQUENCY_CULLING_ENABLED_DEFAULT = 1; // 0 = disabled
private static final int WIFI_PNO_RECENCY_SORTING_ENABLED_DEFAULT = 0; // 0 = disabled:
/**
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index 00f09f571..82f2e4ca4 100644
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -682,10 +682,7 @@ public class WifiConfigStore {
* even when an exception is encountered.
*/
public void writeBufferedRawData() throws IOException {
- if (mWriteData == null) {
- Log.w(TAG, "No data stored for writing to file: " + mFileName);
- return;
- }
+ if (mWriteData == null) return; // No data to write for this file.
// Write the data to the atomic file.
FileOutputStream out = null;
try {
diff --git a/service/java/com/android/server/wifi/WifiConnectivityHelper.java b/service/java/com/android/server/wifi/WifiConnectivityHelper.java
index f6ccb9d7b..ed541a959 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityHelper.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityHelper.java
@@ -59,8 +59,9 @@ public class WifiConnectivityHelper {
mMaxNumBlacklistBssid = INVALID_LIST_SIZE;
mMaxNumWhitelistSsid = INVALID_LIST_SIZE;
- int fwFeatureSet = mWifiNative.getSupportedFeatureSet(mWifiNative.getClientInterfaceName());
- Log.d(TAG, "Firmware supported feature set: " + Integer.toHexString(fwFeatureSet));
+ long fwFeatureSet =
+ mWifiNative.getSupportedFeatureSet(mWifiNative.getClientInterfaceName());
+ Log.d(TAG, "Firmware supported feature set: " + Long.toHexString(fwFeatureSet));
if ((fwFeatureSet & WIFI_FEATURE_CONTROL_ROAMING) == 0) {
Log.d(TAG, "Firmware roaming is not supported");
diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java
index 0b0445d92..d46a9ea24 100644
--- a/service/java/com/android/server/wifi/WifiController.java
+++ b/service/java/com/android/server/wifi/WifiController.java
@@ -31,6 +31,7 @@ import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
+import com.android.internal.R;
import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -52,6 +53,9 @@ public class WifiController extends StateMachine {
*/
private static final long DEFAULT_REENABLE_DELAY_MS = 500;
+ // Maximum limit to use for timeout delay if the value from overlay setting is too large.
+ private static final int MAX_RECOVERY_TIMEOUT_DELAY_MS = 4000;
+
// finding that delayed messages can sometimes be delivered earlier than expected
// probably rounding errors. add a margin to prevent problems
private static final long DEFER_MARGIN_MS = 5;
@@ -66,6 +70,8 @@ public class WifiController extends StateMachine {
private long mReEnableDelayMillis;
+ private int mRecoveryDelayMillis;
+
private FrameworkFacade mFacade;
private static final int BASE = Protocol.BASE_WIFI_CONTROLLER;
@@ -88,6 +94,7 @@ public class WifiController extends StateMachine {
static final int CMD_RECOVERY_DISABLE_WIFI = BASE + 19;
static final int CMD_STA_STOPPED = BASE + 20;
static final int CMD_SCANNING_STOPPED = BASE + 21;
+ static final int CMD_DEFERRED_RECOVERY_RESTART_WIFI = BASE + 22;
private DefaultState mDefaultState = new DefaultState();
private StaEnabledState mStaEnabledState = new StaEnabledState();
@@ -175,6 +182,7 @@ public class WifiController extends StateMachine {
new IntentFilter(filter));
readWifiReEnableDelay();
+ readWifiRecoveryDelay();
}
private boolean checkScanOnlyModeAvailable() {
@@ -233,6 +241,15 @@ public class WifiController extends StateMachine {
Settings.Global.WIFI_REENABLE_DELAY_MS, DEFAULT_REENABLE_DELAY_MS);
}
+ private void readWifiRecoveryDelay() {
+ mRecoveryDelayMillis = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_recovery_timeout_delay);
+ if (mRecoveryDelayMillis > MAX_RECOVERY_TIMEOUT_DELAY_MS) {
+ mRecoveryDelayMillis = MAX_RECOVERY_TIMEOUT_DELAY_MS;
+ Log.w(TAG, "Overriding timeout delay with maximum limit value");
+ }
+ }
+
class DefaultState extends State {
@Override
public boolean processMessage(Message msg) {
@@ -244,6 +261,7 @@ public class WifiController extends StateMachine {
case CMD_STA_STOPPED:
case CMD_STA_START_FAILURE:
case CMD_RECOVERY_RESTART_WIFI_CONTINUE:
+ case CMD_DEFERRED_RECOVERY_RESTART_WIFI:
break;
case CMD_RECOVERY_DISABLE_WIFI:
log("Recovery has been throttled, disable wifi");
@@ -251,7 +269,7 @@ public class WifiController extends StateMachine {
transitionTo(mStaDisabledState);
break;
case CMD_RECOVERY_RESTART_WIFI:
- deferMessage(obtainMessage(CMD_RECOVERY_RESTART_WIFI_CONTINUE));
+ deferMessage(obtainMessage(CMD_DEFERRED_RECOVERY_RESTART_WIFI));
mActiveModeWarden.shutdownWifi();
transitionTo(mStaDisabledState);
break;
@@ -359,6 +377,10 @@ public class WifiController extends StateMachine {
log("DEFERRED_TOGGLE handled");
sendMessage((Message)(msg.obj));
break;
+ case CMD_DEFERRED_RECOVERY_RESTART_WIFI:
+ // wait mRecoveryDelayMillis for letting driver clean reset.
+ sendMessageDelayed(CMD_RECOVERY_RESTART_WIFI_CONTINUE, mRecoveryDelayMillis);
+ break;
case CMD_RECOVERY_RESTART_WIFI_CONTINUE:
if (mSettingsStore.isWifiToggleEnabled()) {
// wifi is currently disabled but the toggle is on, must have had an
diff --git a/service/java/com/android/server/wifi/WifiLockManager.java b/service/java/com/android/server/wifi/WifiLockManager.java
index 835625b6f..3f1928df2 100644
--- a/service/java/com/android/server/wifi/WifiLockManager.java
+++ b/service/java/com/android/server/wifi/WifiLockManager.java
@@ -526,7 +526,7 @@ public class WifiLockManager {
private int getLowLatencyModeSupport() {
if (mLatencyModeSupport == LOW_LATENCY_SUPPORT_UNDEFINED
&& mClientModeImplChannel != null) {
- int supportedFeatures =
+ long supportedFeatures =
mClientModeImpl.syncGetSupportedFeatures(mClientModeImplChannel);
if (supportedFeatures != 0) {
if ((supportedFeatures & WifiManager.WIFI_FEATURE_LOW_LATENCY) != 0) {
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 7444f5ef0..40d6492e2 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -431,7 +431,8 @@ public class WifiNative {
if (observer == null) return false;
try {
mNwManagementService.registerObserver(observer);
- } catch (RemoteException e) {
+ } catch (RemoteException | IllegalStateException e) {
+ Log.e(TAG, "Unable to register observer", e);
return false;
}
return true;
@@ -442,7 +443,8 @@ public class WifiNative {
if (observer == null) return false;
try {
mNwManagementService.unregisterObserver(observer);
- } catch (RemoteException e) {
+ } catch (RemoteException | IllegalStateException e) {
+ Log.e(TAG, "Unable to unregister observer", e);
return false;
}
return true;
@@ -901,10 +903,8 @@ public class WifiNative {
// - kernel is unaware when connected and fails to start IPv6 negotiation
// - kernel can start autoconfiguration when 802.1x is not complete
mNwManagementService.disableIpv6(ifaceName);
- } catch (RemoteException re) {
- Log.e(TAG, "Unable to change interface settings: " + re);
- } catch (IllegalStateException ie) {
- Log.e(TAG, "Unable to change interface settings: " + ie);
+ } catch (RemoteException | IllegalStateException e) {
+ Log.e(TAG, "Unable to change interface settings", e);
}
}
@@ -1093,7 +1093,8 @@ public class WifiNative {
InterfaceConfiguration config = null;
try {
config = mNwManagementService.getInterfaceConfig(ifaceName);
- } catch (RemoteException e) {
+ } catch (RemoteException | IllegalStateException e) {
+ Log.e(TAG, "Unable to get interface config", e);
}
if (config == null) {
return false;
@@ -2616,7 +2617,7 @@ public class WifiNative {
* @param ifaceName Name of the interface.
* @return bitmask defined by WifiManager.WIFI_FEATURE_*
*/
- public int getSupportedFeatureSet(@NonNull String ifaceName) {
+ public long getSupportedFeatureSet(@NonNull String ifaceName) {
return mSupplicantStaIfaceHal.getAdvancedKeyMgmtCapabilities(ifaceName)
| mWifiVendorHal.getSupportedFeatureSet(ifaceName);
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 290103844..b3d6e9db9 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -54,6 +54,7 @@ import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
+import android.content.pm.ResolveInfo;
import android.database.ContentObserver;
import android.net.DhcpInfo;
import android.net.DhcpResults;
@@ -97,6 +98,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.WorkSource;
import android.provider.Settings;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.MutableInt;
@@ -136,6 +138,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -760,6 +763,17 @@ public class WifiServiceImpl extends BaseWifiService {
|| dpmi.isActiveAdminWithPolicy(uid, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
}
+ // Helper method to check if the entity initiating the binder call is the default car dock app.
+ private boolean isDefaultCarDock(String packageName) {
+ final Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_CAR_DOCK);
+ final ResolveInfo ri = mContext.getPackageManager().resolveActivity(
+ intent, PackageManager.GET_META_DATA | PackageManager.MATCH_DEFAULT_ONLY);
+ if (ri == null || ri.activityInfo == null) {
+ return false;
+ }
+ return Objects.equals(packageName, ri.activityInfo.packageName);
+ }
+
private void enforceNetworkSettingsPermission() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.NETWORK_SETTINGS,
"WifiService");
@@ -856,7 +870,8 @@ public class WifiServiceImpl extends BaseWifiService {
// DO/PO apps should be able to add/modify saved networks.
|| isDeviceOrProfileOwner(uid)
// TODO: Remove this system app bypass once Q is released.
- || isSystem(packageName);
+ || isSystem(packageName)
+ || isDefaultCarDock(packageName);
}
/**
@@ -1672,7 +1687,7 @@ public class WifiServiceImpl extends BaseWifiService {
* see {@link android.net.wifi.WifiManager#getSupportedFeatures}
*/
@Override
- public int getSupportedFeatures() {
+ public long getSupportedFeatures() {
enforceAccessPermission();
if (mVerboseLoggingEnabled) {
mLog.info("getSupportedFeatures uid=%").c(Binder.getCallingUid()).flush();
@@ -1785,8 +1800,12 @@ public class WifiServiceImpl extends BaseWifiService {
Binder.restoreCallingIdentity(ident);
}
}
- if (!isTargetSdkLessThanQOrPrivileged(
- packageName, Binder.getCallingPid(), callingUid)) {
+ boolean isTargetSdkLessThanQOrPrivileged = isTargetSdkLessThanQOrPrivileged(
+ packageName, Binder.getCallingPid(), callingUid);
+ boolean isCarrierApp =
+ mWifiInjector.makeTelephonyManager().checkCarrierPrivilegesForPackage(packageName)
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
+ if (!isTargetSdkLessThanQOrPrivileged && !isCarrierApp) {
mLog.info("getConfiguredNetworks not allowed for uid=%")
.c(callingUid).flush();
return new ParceledListSlice<>(new ArrayList<>());
@@ -1806,7 +1825,17 @@ public class WifiServiceImpl extends BaseWifiService {
List<WifiConfiguration> configs = mClientModeImpl.syncGetConfiguredNetworks(
callingUid, mClientModeImplChannel, targetConfigUid);
if (configs != null) {
- return new ParceledListSlice<WifiConfiguration>(configs);
+ if (isTargetSdkLessThanQOrPrivileged) {
+ return new ParceledListSlice<WifiConfiguration>(configs);
+ } else { // Carrier app: should only get its own configs
+ List<WifiConfiguration> creatorConfigs = new ArrayList<>();
+ for (WifiConfiguration config : configs) {
+ if (config.creatorUid == callingUid) {
+ creatorConfigs.add(config);
+ }
+ }
+ return new ParceledListSlice<WifiConfiguration>(creatorConfigs);
+ }
}
} else {
Slog.e(TAG, "mClientModeImplChannel is not initialized");
@@ -3080,7 +3109,7 @@ public class WifiServiceImpl extends BaseWifiService {
return (getSupportedFeaturesInternal() & WIFI_FEATURE_INFRA_5G) == WIFI_FEATURE_INFRA_5G;
}
- private int getSupportedFeaturesInternal() {
+ private long getSupportedFeaturesInternal() {
final AsyncChannel channel = mClientModeImplChannel;
if (channel != null) {
return mClientModeImpl.syncGetSupportedFeatures(channel);
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index d14fc28ad..10c3ab806 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -58,7 +58,7 @@ import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import android.util.MutableBoolean;
-import android.util.MutableInt;
+import android.util.MutableLong;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
@@ -1087,7 +1087,7 @@ public class WifiVendorHal {
* Translation table used by getSupportedFeatureSet for translating IWifiChip caps for
* additional capabilities introduced in V1.3
*/
- private static final int[][] sChipFeatureCapabilityTranslation13 = {
+ private static final long[][] sChipFeatureCapabilityTranslation13 = {
{WifiManager.WIFI_FEATURE_LOW_LATENCY,
android.hardware.wifi.V1_3.IWifiChip.ChipCapabilityMask.SET_LATENCY_MODE
}
@@ -1117,9 +1117,9 @@ public class WifiVendorHal {
* @return bitmask defined by WifiManager.WIFI_FEATURE_*
*/
@VisibleForTesting
- int wifiFeatureMaskFromChipCapabilities_1_3(int capabilities) {
+ long wifiFeatureMaskFromChipCapabilities_1_3(int capabilities) {
// First collect features from previous versions
- int features = wifiFeatureMaskFromChipCapabilities(capabilities);
+ long features = wifiFeatureMaskFromChipCapabilities(capabilities);
// Next collect features for V1_3 version
for (int i = 0; i < sChipFeatureCapabilityTranslation13.length; i++) {
@@ -1201,13 +1201,13 @@ public class WifiVendorHal {
* @param ifaceName Name of the interface.
* @return bitmask defined by WifiManager.WIFI_FEATURE_*
*/
- public int getSupportedFeatureSet(@NonNull String ifaceName) {
- int featureSet = 0;
+ public long getSupportedFeatureSet(@NonNull String ifaceName) {
+ long featureSet = 0;
if (!mHalDeviceManager.isStarted()) {
return featureSet; // TODO: can't get capabilities with Wi-Fi down
}
try {
- final MutableInt feat = new MutableInt(0);
+ final MutableLong feat = new MutableLong(0);
synchronized (sLock) {
android.hardware.wifi.V1_3.IWifiChip iWifiChipV13 = getWifiChipForV1_3Mockable();
if (iWifiChipV13 != null) {