summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RROOverlaySampleApp/Android.bp13
-rw-r--r--RROOverlaySampleApp/AndroidManifest.xml4
-rw-r--r--RROOverlaySampleApp/AndroidManifest_InProcess.xml29
-rw-r--r--service/Android.bp72
-rw-r--r--service/AndroidManifest_Resources.xml (renamed from service/AndroidManifest.xml)9
-rw-r--r--service/java/com/android/server/wifi/ActiveModeWarden.java7
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java27
-rw-r--r--service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java12
-rw-r--r--service/java/com/android/server/wifi/DeviceConfigFacade.java13
-rw-r--r--service/java/com/android/server/wifi/ExtendedWifiInfo.java24
-rw-r--r--service/java/com/android/server/wifi/HostapdHal.java28
-rw-r--r--service/java/com/android/server/wifi/LinkProbeManager.java52
-rw-r--r--service/java/com/android/server/wifi/SarManager.java7
-rw-r--r--service/java/com/android/server/wifi/SavedNetworkEvaluator.java66
-rw-r--r--service/java/com/android/server/wifi/ScoringParams.java23
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java2
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaNetworkHal.java12
-rw-r--r--service/java/com/android/server/wifi/ThroughputPredictor.java25
-rw-r--r--service/java/com/android/server/wifi/WakeupNotificationFactory.java2
-rw-r--r--service/java/com/android/server/wifi/WifiApConfigStore.java35
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java34
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java99
-rw-r--r--service/java/com/android/server/wifi/WifiContext.java57
-rw-r--r--service/java/com/android/server/wifi/WifiCountryCode.java27
-rw-r--r--service/java/com/android/server/wifi/WifiDiagnostics.java34
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java12
-rw-r--r--service/java/com/android/server/wifi/WifiLastResortWatchdog.java16
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java17
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSelector.java24
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiService.java7
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java30
-rw-r--r--service/java/com/android/server/wifi/WrongPasswordNotifier.java2
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareService.java7
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java2
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pService.java7
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java8
-rw-r--r--service/java/com/android/server/wifi/rtt/RttService.java9
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningService.java9
-rw-r--r--service/java/com/android/server/wifi/scanner/WificondScannerImpl.java11
-rw-r--r--service/java/com/android/server/wifi/util/RssiUtil.java2
-rw-r--r--service/res/values/strings.xml2
-rw-r--r--tests/wifitests/Android.bp62
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SarManagerTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java17
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java7
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java21
-rw-r--r--tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java2
71 files changed, 544 insertions, 509 deletions
diff --git a/RROOverlaySampleApp/Android.bp b/RROOverlaySampleApp/Android.bp
index 0f8265ab3..52c56d966 100644
--- a/RROOverlaySampleApp/Android.bp
+++ b/RROOverlaySampleApp/Android.bp
@@ -23,16 +23,3 @@ android_app {
sdk_version: "current",
product_specific: true
}
-
-// In process version of the overlay.
-// TODO (b/135938806): Remove this once the overlay tag can support multiple
-// targetPackage attributes.
-android_app {
- name: "InProcessWifiRROOverlaySampleApp",
- resource_dirs: [
- "res",
- ],
- sdk_version: "current",
- manifest: "AndroidManifest_InProcess.xml",
- product_specific: true
-}
diff --git a/RROOverlaySampleApp/AndroidManifest.xml b/RROOverlaySampleApp/AndroidManifest.xml
index d350624a0..de2e359ac 100644
--- a/RROOverlaySampleApp/AndroidManifest.xml
+++ b/RROOverlaySampleApp/AndroidManifest.xml
@@ -17,12 +17,12 @@
<!-- Simple app to demonstrate how OEM's can customize the various overlays exposed by
the wifi stack -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi.overlay.sample"
+ package="com.android.wifi.resources.sample"
android:versionCode="1"
android:versionName="1.0">
<application android:hasCode="false" />
<overlay
- android:targetPackage="com.android.wifi"
+ android:targetPackage="com.android.wifi.resources"
android:targetName="WifiCustomization"
android:isStatic="true"
android:priority="0"/>
diff --git a/RROOverlaySampleApp/AndroidManifest_InProcess.xml b/RROOverlaySampleApp/AndroidManifest_InProcess.xml
deleted file mode 100644
index cf01a7322..000000000
--- a/RROOverlaySampleApp/AndroidManifest_InProcess.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Simple app to demonstrate how OEM's can customize the various overlays exposed by
- the wifi stack -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi.inprocess.overlay.sample"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:hasCode="false" />
- <overlay
- android:targetPackage="com.android.wifi.inprocess"
- android:targetName="WifiCustomization"
- android:isStatic="true"
- android:priority="0"/>
-</manifest>
diff --git a/service/Android.bp b/service/Android.bp
index e27e2ed23..966cb9cdc 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -14,13 +14,8 @@
// limitations under the License.
//
java_defaults {
- name: "WifiStackCommon",
+ name: "wifi-service-common",
min_sdk_version: "29",
- platform_apis: true,
- privileged: true,
- dex_preopt: {
- enabled: false,
- },
errorprone: {
javacflags: ["-Xep:CheckReturnValue:ERROR"],
},
@@ -29,9 +24,6 @@ java_defaults {
enabled: false,
},
},
- resource_dirs: [
- "res",
- ],
}
// Make the JNI part
@@ -71,34 +63,37 @@ cc_library_shared {
},
}
+// These filegroups are created for wifi tests.
filegroup {
- name: "wifi-jarjar-rules",
+ name: "wifi-service-jarjar-rules",
srcs: [ "jarjar-rules-shared.txt"]
}
-// Build the wifi-service static library
-// ============================================================
-android_library {
- name: "wifi-service",
- installable: true,
- defaults: ["WifiStackCommon"],
+filegroup {
+ name: "wifi-service-srcs",
srcs: [
"java/**/*.java",
"java/**/*.logtags",
":framework-wifistack-shared-srcs",
],
+}
+
+// wifi-service static library
+// ============================================================
+java_library {
+ name: "wifi-service",
+ installable: true,
+ defaults: ["wifi-service-common"],
+ srcs: [ ":wifi-service-srcs" ],
libs: [
"error_prone_annotations",
"jsr305",
"services",
+ // load the resources from the resources APK.
+ "wifi-service-resources"
],
- jarjar_rules: ":wifi-jarjar-rules",
- optimize: {
- proguard_flags_files: ["proguard.flags"],
- },
-
static_libs: [
"android.hardware.wifi-V1.0-java",
"android.hardware.wifi-V1.1-java",
@@ -121,18 +116,47 @@ android_library {
// the necessary core platform APIs.
"libprotobuf-java-lite",
"libnanohttpd",
- "services.net",
- "services.core",
"libwificond_aidl-java",
+ "services.net",
"wifi_proto_scorecard",
"wifi_proto_metrics",
],
required: [
+ "cacerts_wfa",
"libwifi-jni",
"services",
- "cacerts_wfa",
+ "wifi-service-resources",
],
+ jarjar_rules: ":wifi-service-jarjar-rules",
+ optimize: {
+ enabled: true,
+ shrink: true,
+ proguard_flags_files: ["proguard.flags"],
+ },
+ dex_preopt: {
+ enabled: false,
+ app_image: false,
+ },
+
+ // TODO: Remove this once all @hide dependencies are resolved.
+ platform_apis: true,
+
init_rc: ["wifi.rc"],
}
+
+// APK to hold all the wifi overlayable resources.
+// TODO: This should be signed by a wifi specific certificate.
+// ============================================================
+android_app {
+ name: "wifi-service-resources",
+ defaults: ["wifi-service-common"],
+ resource_dirs: [
+ "res",
+ ],
+ privileged: true,
+ sdk_version: "system_current",
+ export_package_resources: true,
+ manifest: "AndroidManifest_Resources.xml",
+}
diff --git a/service/AndroidManifest.xml b/service/AndroidManifest_Resources.xml
index 787cd7539..458572153 100644
--- a/service/AndroidManifest.xml
+++ b/service/AndroidManifest_Resources.xml
@@ -16,12 +16,13 @@
* limitations under the License.
*/
-->
+<!-- Manifest for wifi resources APK -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi"
- android:versionCode="11"
- android:versionName="Q-initial">
+ package="com.android.wifi.resources"
+ android:versionCode="1"
+ android:versionName="R-initial">
<application
- android:label="@string/wifiAppLabel"
+ android:label="@string/wifiResourcesAppLabel"
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true"
android:usesCleartextTraffic="true">
diff --git a/service/java/com/android/server/wifi/ActiveModeWarden.java b/service/java/com/android/server/wifi/ActiveModeWarden.java
index 19b64b0cb..73f18e129 100644
--- a/service/java/com/android/server/wifi/ActiveModeWarden.java
+++ b/service/java/com/android/server/wifi/ActiveModeWarden.java
@@ -41,7 +41,7 @@ import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.wifi.util.WifiPermissionsUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -519,8 +519,6 @@ public class ActiveModeWarden {
// 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;
- private final int mRecoveryDelayMillis;
-
private static final int BASE = Protocol.BASE_WIFI_CONTROLLER;
static final int CMD_EMERGENCY_MODE_CHANGED = BASE + 1;
@@ -560,7 +558,6 @@ public class ActiveModeWarden {
setLogRecSize(100);
setLogOnlyTransitions(false);
- mRecoveryDelayMillis = readWifiRecoveryDelay();
}
@Override
@@ -748,7 +745,7 @@ public class ActiveModeWarden {
case CMD_DEFERRED_RECOVERY_RESTART_WIFI:
// wait mRecoveryDelayMillis for letting driver clean reset.
sendMessageDelayed(CMD_RECOVERY_RESTART_WIFI_CONTINUE,
- mRecoveryDelayMillis);
+ readWifiRecoveryDelay());
break;
case CMD_RECOVERY_RESTART_WIFI_CONTINUE:
if (shouldEnableSta()) {
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 6c4f0e375..cc859ebe1 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -119,7 +119,7 @@ import com.android.server.wifi.util.TelephonyUtil.SimAuthRequestData;
import com.android.server.wifi.util.TelephonyUtil.SimAuthResponseData;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.BufferedReader;
import java.io.FileDescriptor;
@@ -681,7 +681,6 @@ public class ClientModeImpl extends StateMachine {
private final TelephonyUtil mTelephonyUtil;
- private final String mTcpBufferSizes;
// Used for debug and stats gathering
private static int sScanAlarmIntentCount = 0;
@@ -691,7 +690,6 @@ public class ClientModeImpl extends StateMachine {
private final BackupManagerProxy mBackupManagerProxy;
private final WrongPasswordNotifier mWrongPasswordNotifier;
private WifiNetworkSuggestionsManager mWifiNetworkSuggestionsManager;
- private boolean mConnectedMacRandomzationSupported;
// Maximum duration to continue to log Wifi usability stats after a data stall is triggered.
@VisibleForTesting
public static final long DURATION_TO_WAIT_ADD_STATS_AFTER_DATA_STALL_MS = 30 * 1000;
@@ -743,7 +741,7 @@ public class ClientModeImpl extends StateMachine {
mWifiPermissionsWrapper = mWifiInjector.getWifiPermissionsWrapper();
mWifiDataStall = mWifiInjector.getWifiDataStall();
- mWifiInfo = new ExtendedWifiInfo();
+ mWifiInfo = new ExtendedWifiInfo(context);
mSupplicantStateTracker = supplicantStateTracker;
mWifiConnectivityManager = mWifiInjector.makeWifiConnectivityManager(this);
mBssidBlocklistMonitor = mWifiInjector.getBssidBlocklistMonitor();
@@ -821,13 +819,6 @@ public class ClientModeImpl extends StateMachine {
mSuspendWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WifiSuspend");
mSuspendWakeLock.setReferenceCounted(false);
- mConnectedMacRandomzationSupported = mContext.getResources()
- .getBoolean(R.bool.config_wifi_connected_mac_randomization_supported);
- mWifiInfo.setEnableConnectedMacRandomization(mConnectedMacRandomzationSupported);
- mWifiMetrics.setIsMacRandomizationOn(mConnectedMacRandomzationSupported);
-
- mTcpBufferSizes = mContext.getResources().getString(
- R.string.config_wifi_tcp_buffers);
mWifiConfigManager.addOnNetworkUpdateListener(new OnNetworkUpdateListener());
// CHECKSTYLE:OFF IndentationCheck
@@ -3043,7 +3034,8 @@ public class ClientModeImpl extends StateMachine {
* @return boolean true if Connected MAC randomization is supported, false otherwise
*/
public boolean isConnectedMacRandomizationEnabled() {
- return mConnectedMacRandomzationSupported;
+ return mContext.getResources().getBoolean(
+ R.bool.config_wifi_connected_mac_randomization_supported);
}
/**
@@ -3119,6 +3111,7 @@ public class ClientModeImpl extends StateMachine {
// get other services that we need to manage
getAdditionalWifiServiceInterfaces();
registerNetworkFactory();
+ mSarManager.handleBootCompleted();
break;
case CMD_SCREEN_STATE_CHANGED:
handleScreenStateChanged(message.arg1 != 0);
@@ -3734,7 +3727,7 @@ public class ClientModeImpl extends StateMachine {
WifiMetricsProto.ConnectionEvent.ROAM_UNRELATED);
if (config.macRandomizationSetting
== WifiConfiguration.RANDOMIZATION_PERSISTENT
- && mConnectedMacRandomzationSupported) {
+ && isConnectedMacRandomizationEnabled()) {
configureRandomizedMacAddress(config);
} else {
setCurrentMacToFactoryMac(config);
@@ -4661,8 +4654,10 @@ public class ClientModeImpl extends StateMachine {
if (mIpClient != null) {
mIpClient.setHttpProxy(currentConfig.getHttpProxy());
- if (!TextUtils.isEmpty(mTcpBufferSizes)) {
- mIpClient.setTcpBufferSizes(mTcpBufferSizes);
+ if (!TextUtils.isEmpty(mContext.getResources().getString(
+ R.string.config_wifi_tcp_buffers))) {
+ mIpClient.setTcpBufferSizes(mContext.getResources().getString(
+ R.string.config_wifi_tcp_buffers));
}
}
final ProvisioningConfiguration prov;
@@ -5612,7 +5607,7 @@ public class ClientModeImpl extends StateMachine {
if (macAddress != null) {
return macAddress.toString();
}
- if (!mConnectedMacRandomzationSupported) {
+ if (!isConnectedMacRandomizationEnabled()) {
return mWifiNative.getMacAddress(mInterfaceName);
}
return null;
diff --git a/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java b/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
index 02065dac5..621aa7823 100644
--- a/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
+++ b/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
@@ -20,11 +20,10 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
import android.net.wifi.ScanResult;
import android.util.Log;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
/**
* Helper to create notifications for {@link OpenNetworkNotifier}.
@@ -53,7 +52,6 @@ public class ConnectToNetworkNotificationBuilder {
private Context mContext;
private WifiInjector mWifiInjector;
- private Resources mResources;
private FrameworkFacade mFrameworkFacade;
public ConnectToNetworkNotificationBuilder(
@@ -62,7 +60,6 @@ public class ConnectToNetworkNotificationBuilder {
FrameworkFacade framework) {
mContext = context;
mWifiInjector = wifiInjector;
- mResources = context.getResources();
mFrameworkFacade = framework;
}
@@ -89,10 +86,10 @@ public class ConnectToNetworkNotificationBuilder {
return null;
}
Notification.Action connectAction = new Notification.Action.Builder(null /* icon */,
- mResources.getText(R.string.wifi_available_action_connect),
+ mContext.getResources().getText(R.string.wifi_available_action_connect),
getPrivateBroadcast(ACTION_CONNECT_TO_NETWORK, notifierTag)).build();
Notification.Action allNetworksAction = new Notification.Action.Builder(null /* icon */,
- mResources.getText(R.string.wifi_available_action_all_networks),
+ mContext.getResources().getText(R.string.wifi_available_action_all_networks),
getPrivateBroadcast(ACTION_PICK_WIFI_NETWORK, notifierTag)).build();
return createNotificationBuilder(title, network.SSID, notifierTag)
.setContentIntent(getPrivateBroadcast(ACTION_PICK_WIFI_NETWORK, notifierTag))
@@ -167,7 +164,8 @@ public class ConnectToNetworkNotificationBuilder {
.setDeleteIntent(getPrivateBroadcast(ACTION_USER_DISMISSED_NOTIFICATION, extraData))
.setShowWhen(false)
.setLocalOnly(true)
- .setColor(mResources.getColor(android.R.color.system_notification_accent_color,
+ .setColor(mContext.getResources().getColor(
+ android.R.color.system_notification_accent_color,
mContext.getTheme()));
}
diff --git a/service/java/com/android/server/wifi/DeviceConfigFacade.java b/service/java/com/android/server/wifi/DeviceConfigFacade.java
index 1c59797fe..096d54f52 100644
--- a/service/java/com/android/server/wifi/DeviceConfigFacade.java
+++ b/service/java/com/android/server/wifi/DeviceConfigFacade.java
@@ -22,7 +22,7 @@ import android.provider.DeviceConfig;
import android.util.ArraySet;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.util.Collections;
import java.util.Set;
@@ -52,7 +52,6 @@ public class DeviceConfigFacade {
public static final int DEFAULT_DATA_STALL_TX_PER_THR = 90;
// Default threshold of CCA level above which to trigger a data stall in percentage
public static final int DEFAULT_DATA_STALL_CCA_LEVEL_THR = 100;
- private boolean mDefaultMacRandomizationAggressiveModeSsidWhitelistEnabled;
// Cached values of fields updated via updateDeviceConfigFlags()
private boolean mIsAbnormalConnectionBugreportEnabled;
@@ -68,8 +67,6 @@ public class DeviceConfigFacade {
public DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics) {
mContext = context;
mWifiMetrics = wifiMetrics;
- mDefaultMacRandomizationAggressiveModeSsidWhitelistEnabled = mContext.getResources()
- .getBoolean(R.bool.config_wifi_aggressive_randomization_ssid_whitelist_enabled);
updateDeviceConfigFlags();
DeviceConfig.addOnPropertiesChangedListener(
@@ -86,9 +83,6 @@ public class DeviceConfigFacade {
mAbnormalConnectionDurationMs = DeviceConfig.getInt(NAMESPACE,
"abnormal_connection_duration_ms",
DEFAULT_ABNORMAL_CONNECTION_DURATION_MS);
- mIsAggressiveMacRandomizationSsidWhitelistEnabled = DeviceConfig.getBoolean(NAMESPACE,
- "aggressive_randomization_ssid_whitelist_enabled",
- mDefaultMacRandomizationAggressiveModeSsidWhitelistEnabled);
mDataStallDurationMs = DeviceConfig.getInt(NAMESPACE,
"data_stall_duration_ms", DEFAULT_DATA_STALL_DURATION_MS);
@@ -144,7 +138,10 @@ public class DeviceConfigFacade {
* Gets the feature flag for aggressive MAC randomization per-SSID opt-in.
*/
public boolean isAggressiveMacRandomizationSsidWhitelistEnabled() {
- return mIsAggressiveMacRandomizationSsidWhitelistEnabled;
+ return DeviceConfig.getBoolean(NAMESPACE,
+ "aggressive_randomization_ssid_whitelist_enabled",
+ mContext.getResources().getBoolean(
+ R.bool.config_wifi_aggressive_randomization_ssid_whitelist_enabled));
}
/**
diff --git a/service/java/com/android/server/wifi/ExtendedWifiInfo.java b/service/java/com/android/server/wifi/ExtendedWifiInfo.java
index 4aa355286..2ec3de6cb 100644
--- a/service/java/com/android/server/wifi/ExtendedWifiInfo.java
+++ b/service/java/com/android/server/wifi/ExtendedWifiInfo.java
@@ -17,8 +17,11 @@
package com.android.server.wifi;
import android.annotation.NonNull;
+import android.content.Context;
import android.net.wifi.WifiInfo;
+import com.android.wifi.resources.R;
+
/**
* Extends WifiInfo with the methods for computing the averaged packet rates
*/
@@ -29,16 +32,23 @@ public class ExtendedWifiInfo extends WifiInfo {
private static final int SOURCE_TRAFFIC_COUNTERS = 1;
private static final int SOURCE_LLSTATS = 2;
+ private final Context mContext;
+
private int mLastSource = SOURCE_UNKNOWN;
private long mLastPacketCountUpdateTimeStamp = RESET_TIME_STAMP;
- private boolean mEnableConnectedMacRandomization = false;
+
+ ExtendedWifiInfo(Context context) {
+ super();
+ mContext = context;
+ }
@Override
public void reset() {
super.reset();
mLastSource = SOURCE_UNKNOWN;
mLastPacketCountUpdateTimeStamp = RESET_TIME_STAMP;
- if (mEnableConnectedMacRandomization) {
+ if (mContext.getResources().getBoolean(
+ R.bool.config_wifi_connected_mac_randomization_supported)) {
setMacAddress(DEFAULT_MAC_ADDRESS);
}
}
@@ -103,14 +113,4 @@ public class ExtendedWifiInfo extends WifiInfo {
txRetries = txretries;
mLastPacketCountUpdateTimeStamp = timeStamp;
}
-
- /**
- * Updates whether Connected MAC Randomization is enabled.
- *
- * @hide
- */
- public void setEnableConnectedMacRandomization(boolean enableConnectedMacRandomization) {
- mEnableConnectedMacRandomization = enableConnectedMacRandomization;
- }
-
}
diff --git a/service/java/com/android/server/wifi/HostapdHal.java b/service/java/com/android/server/wifi/HostapdHal.java
index 9c69e26bf..0e1f621e8 100644
--- a/service/java/com/android/server/wifi/HostapdHal.java
+++ b/service/java/com/android/server/wifi/HostapdHal.java
@@ -33,7 +33,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.WifiNative.HostapdDeathEventHandler;
import com.android.server.wifi.util.ApConfigUtil;
import com.android.server.wifi.util.NativeUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.util.ArrayList;
import java.util.HashMap;
@@ -59,11 +59,8 @@ public class HostapdHal {
private final Object mLock = new Object();
private boolean mVerboseLoggingEnabled = false;
+ private final Context mContext;
private final Handler mEventHandler;
- private final boolean mEnableAcs;
- private final boolean mEnableIeee80211AC;
- private final List<android.hardware.wifi.hostapd.V1_1.IHostapd.AcsChannelRange>
- mAcsChannelRanges;
private boolean mForceApChannel = false;
private int mForcedApChannel;
@@ -119,13 +116,8 @@ public class HostapdHal {
}
public HostapdHal(Context context, Handler handler) {
+ mContext = context;
mEventHandler = handler;
- mEnableAcs = context.getResources().getBoolean(R.bool.config_wifi_softap_acs_supported);
- mEnableIeee80211AC =
- context.getResources().getBoolean(R.bool.config_wifi_softap_ieee80211ac_supported);
- mAcsChannelRanges = toAcsChannelRanges(context.getResources().getString(
- R.string.config_wifi_softap_acs_supported_channel_list));
-
mServiceManagerDeathRecipient = new ServiceManagerDeathRecipient();
mHostapdDeathRecipient = new HostapdDeathRecipient();
}
@@ -333,7 +325,9 @@ public class HostapdHal {
IHostapd.IfaceParams ifaceParams = new IHostapd.IfaceParams();
ifaceParams.ifaceName = ifaceName;
ifaceParams.hwModeParams.enable80211N = true;
- ifaceParams.hwModeParams.enable80211AC = mEnableIeee80211AC;
+ ifaceParams.hwModeParams.enable80211AC =
+ mContext.getResources().getBoolean(
+ R.bool.config_wifi_softap_ieee80211ac_supported);
try {
ifaceParams.channelParams.band = getBand(config);
} catch (IllegalArgumentException e) {
@@ -348,7 +342,8 @@ public class HostapdHal {
} else {
ifaceParams.channelParams.band = IHostapd.Band.BAND_5_GHZ;
}
- } else if (mEnableAcs) {
+ } else if (mContext.getResources().getBoolean(
+ R.bool.config_wifi_softap_acs_supported)) {
ifaceParams.channelParams.enableAcs = true;
ifaceParams.channelParams.acsShouldExcludeDfs = true;
} else {
@@ -380,8 +375,11 @@ public class HostapdHal {
android.hardware.wifi.hostapd.V1_1.IHostapd.IfaceParams ifaceParams1_1 =
new android.hardware.wifi.hostapd.V1_1.IHostapd.IfaceParams();
ifaceParams1_1.V1_0 = ifaceParams;
- if (mEnableAcs) {
- ifaceParams1_1.channelParams.acsChannelRanges.addAll(mAcsChannelRanges);
+ if (mContext.getResources().getBoolean(
+ R.bool.config_wifi_softap_acs_supported)) {
+ ifaceParams1_1.channelParams.acsChannelRanges.addAll(
+ toAcsChannelRanges(mContext.getResources().getString(
+ R.string.config_wifi_softap_acs_supported_channel_list)));
}
android.hardware.wifi.hostapd.V1_1.IHostapd iHostapdV1_1 =
getHostapdMockableV1_1();
diff --git a/service/java/com/android/server/wifi/LinkProbeManager.java b/service/java/com/android/server/wifi/LinkProbeManager.java
index 800dc136f..82c1cda0c 100644
--- a/service/java/com/android/server/wifi/LinkProbeManager.java
+++ b/service/java/com/android/server/wifi/LinkProbeManager.java
@@ -26,7 +26,7 @@ import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.util.TimedQuotaManager;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -69,9 +69,10 @@ public class LinkProbeManager {
private final WifiNative mWifiNative;
private final WifiMetrics mWifiMetrics;
private final FrameworkFacade mFrameworkFacade;
+ private final Handler mHandler;
private final Context mContext;
- private boolean mLinkProbingSupported;
+ private Boolean mLinkProbingSupported = null;
private boolean mLinkProbingEnabled = false;
private boolean mVerboseLoggingEnabled = false;
@@ -109,27 +110,33 @@ public class LinkProbeManager {
mWifiNative = wifiNative;
mWifiMetrics = wifiMetrics;
mFrameworkFacade = frameworkFacade;
+ mHandler = handler;
mContext = context;
- mLinkProbingSupported = mContext.getResources()
- .getBoolean(R.bool.config_wifi_link_probing_supported);
mTimedQuotaManager = new TimedQuotaManager(clock, MAX_PROBE_COUNT_IN_PERIOD, PERIOD_MILLIS);
- if (mLinkProbingSupported) {
- mFrameworkFacade.registerContentObserver(mContext, Settings.Global.getUriFor(
- Settings.Global.WIFI_LINK_PROBING_ENABLED), false,
- new ContentObserver(handler) {
- @Override
- public void onChange(boolean selfChange) {
- updateLinkProbeSetting();
- }
- });
- updateLinkProbeSetting();
+ initExperiments();
+ }
- resetOnNewConnection();
- resetOnScreenTurnedOn();
- }
+ private boolean isLinkProbingSupported() {
+ if (mLinkProbingSupported == null) {
+ mLinkProbingSupported = mContext.getResources()
+ .getBoolean(R.bool.config_wifi_link_probing_supported);
+ if (mLinkProbingSupported) {
+ mFrameworkFacade.registerContentObserver(mContext, Settings.Global.getUriFor(
+ Settings.Global.WIFI_LINK_PROBING_ENABLED), false,
+ new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateLinkProbeSetting();
+ }
+ });
+ updateLinkProbeSetting();
- initExperiments();
+ resetOnNewConnection();
+ resetOnScreenTurnedOn();
+ }
+ }
+ return mLinkProbingSupported;
}
private void updateLinkProbeSetting() {
@@ -147,7 +154,8 @@ public class LinkProbeManager {
/** dumps internal state */
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("Dump of LinkProbeManager");
- pw.println("LinkProbeManager - link probing supported by device: " + mLinkProbingSupported);
+ pw.println("LinkProbeManager - link probing supported by device: "
+ + isLinkProbingSupported());
pw.println("LinkProbeManager - link probing feature flag enabled: " + mLinkProbingEnabled);
pw.println("LinkProbeManager - mLastLinkProbeTimestampMs: " + mLastLinkProbeTimestampMs);
pw.println("LinkProbeManager - mLastTxSuccessIncreaseTimestampMs: "
@@ -162,7 +170,7 @@ public class LinkProbeManager {
*/
public void resetOnNewConnection() {
mExperiments.forEach(Experiment::resetOnNewConnection);
- if (!mLinkProbingSupported) return;
+ if (!isLinkProbingSupported()) return;
long now = mClock.getElapsedSinceBootMillis();
mLastLinkProbeTimestampMs = now;
@@ -176,7 +184,7 @@ public class LinkProbeManager {
*/
public void resetOnScreenTurnedOn() {
mExperiments.forEach(Experiment::resetOnScreenTurnedOn);
- if (!mLinkProbingSupported) return;
+ if (!isLinkProbingSupported()) return;
mLastScreenOnTimestampMs = mClock.getElapsedSinceBootMillis();
}
@@ -191,7 +199,7 @@ public class LinkProbeManager {
public void updateConnectionStats(WifiInfo wifiInfo, String interfaceName) {
mExperiments.forEach(e -> e.updateConnectionStats(wifiInfo));
- if (!mLinkProbingSupported) return;
+ if (!isLinkProbingSupported()) return;
long now = mClock.getElapsedSinceBootMillis();
diff --git a/service/java/com/android/server/wifi/SarManager.java b/service/java/com/android/server/wifi/SarManager.java
index eaba1b9bb..c8d222286 100644
--- a/service/java/com/android/server/wifi/SarManager.java
+++ b/service/java/com/android/server/wifi/SarManager.java
@@ -35,7 +35,7 @@ import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.server.wifi.util.WifiHandler;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -90,7 +90,12 @@ public class SarManager {
mLooper = looper;
mHandler = new WifiHandler(TAG, looper);
mPhoneStateListener = new WifiPhoneStateListener(looper);
+ }
+ /**
+ * Handle boot completed, read config flags.
+ */
+ public void handleBootCompleted() {
readSarConfigs();
if (mSupportSarTxPowerLimit) {
mSarInfo = new SarInfo();
diff --git a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java
index 0437dc49a..99233c9b6 100644
--- a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java
+++ b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java
@@ -24,7 +24,7 @@ import android.util.LocalLog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.util.TelephonyUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.util.List;
@@ -35,21 +35,15 @@ import java.util.List;
public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluator {
private static final String NAME = "SavedNetworkEvaluator";
private final WifiConfigManager mWifiConfigManager;
+ private final Context mContext;
private final Clock mClock;
private final LocalLog mLocalLog;
private final WifiConnectivityHelper mConnectivityHelper;
private final TelephonyUtil mTelephonyUtil;
- private final int mRssiScoreSlope;
- private final int mRssiScoreOffset;
- private final int mSameBssidAward;
- private final int mSameNetworkAward;
- private final int mBand5GHzAward;
- private final int mLastSelectionAward;
- private final int mSecurityAward;
private final ScoringParams mScoringParams;
/**
- * Time it takes for the mLastSelectionAward to decay by one point, in milliseconds
+ * Time it takes for the lastSelectionAward to decay by one point, in milliseconds
*/
@VisibleForTesting
public static final int LAST_SELECTION_AWARD_DECAY_MSEC = 60 * 1000;
@@ -59,6 +53,7 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat
WifiConfigManager configManager, Clock clock,
LocalLog localLog, WifiConnectivityHelper connectivityHelper,
TelephonyUtil telephonyUtil) {
+ mContext = context;
mScoringParams = scoringParams;
mWifiConfigManager = configManager;
mClock = clock;
@@ -66,20 +61,6 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat
mConnectivityHelper = connectivityHelper;
mTelephonyUtil = telephonyUtil;
- mRssiScoreSlope = context.getResources().getInteger(
- R.integer.config_wifi_framework_RSSI_SCORE_SLOPE);
- mRssiScoreOffset = context.getResources().getInteger(
- R.integer.config_wifi_framework_RSSI_SCORE_OFFSET);
- mSameBssidAward = context.getResources().getInteger(
- R.integer.config_wifi_framework_SAME_BSSID_AWARD);
- mSameNetworkAward = context.getResources().getInteger(
- R.integer.config_wifi_framework_current_network_boost);
- mLastSelectionAward = context.getResources().getInteger(
- R.integer.config_wifi_framework_LAST_SELECTION_AWARD);
- mSecurityAward = context.getResources().getInteger(
- R.integer.config_wifi_framework_SECURITY_AWARD);
- mBand5GHzAward = context.getResources().getInteger(
- R.integer.config_wifi_framework_5GHz_preference_boost_factor);
}
private void localLog(String log) {
@@ -114,18 +95,33 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat
int score = 0;
boolean is5GHz = scanResult.is5GHz();
+ final int rssiScoreSlope = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_RSSI_SCORE_SLOPE);
+ final int rssiScoreOffset = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_RSSI_SCORE_OFFSET);
+ final int sameBssidAward = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_SAME_BSSID_AWARD);
+ final int sameNetworkAward = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_current_network_boost);
+ final int lastSelectionAward = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_LAST_SELECTION_AWARD);
+ final int securityAward = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_SECURITY_AWARD);
+ final int band5GHzAward = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_5GHz_preference_boost_factor);
+
sbuf.append("[ ").append(scanResult.SSID).append(" ").append(scanResult.BSSID)
.append(" RSSI:").append(scanResult.level).append(" ] ");
// Calculate the RSSI score.
int rssiSaturationThreshold = mScoringParams.getGoodRssi(scanResult.frequency);
int rssi = Math.min(scanResult.level, rssiSaturationThreshold);
- score += (rssi + mRssiScoreOffset) * mRssiScoreSlope;
+ score += (rssi + rssiScoreOffset) * rssiScoreSlope;
sbuf.append(" RSSI score: ").append(score).append(",");
// 5GHz band bonus.
if (is5GHz) {
- score += mBand5GHzAward;
- sbuf.append(" 5GHz bonus: ").append(mBand5GHzAward).append(",");
+ score += band5GHzAward;
+ sbuf.append(" 5GHz bonus: ").append(band5GHzAward).append(",");
}
// Last user selection award.
@@ -136,7 +132,7 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat
- mWifiConfigManager.getLastSelectedTimeStamp();
if (timeDifference > 0) {
int decay = (int) (timeDifference / LAST_SELECTION_AWARD_DECAY_MSEC);
- int bonus = Math.max(mLastSelectionAward - decay, 0);
+ int bonus = Math.max(lastSelectionAward - decay, 0);
score += bonus;
sbuf.append(" User selection ").append(timeDifference)
.append(" ms ago, bonus: ").append(bonus).append(",");
@@ -145,28 +141,28 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat
// Same network award.
if (currentNetwork != null && network.networkId == currentNetwork.networkId) {
- score += mSameNetworkAward;
- sbuf.append(" Same network bonus: ").append(mSameNetworkAward).append(",");
+ score += sameNetworkAward;
+ sbuf.append(" Same network bonus: ").append(sameNetworkAward).append(",");
// When firmware roaming is supported, equivalent BSSIDs (the ones under the
// same network as the currently connected one) get the same BSSID award.
if (mConnectivityHelper.isFirmwareRoamingSupported()
&& currentBssid != null && !currentBssid.equals(scanResult.BSSID)) {
- score += mSameBssidAward;
- sbuf.append(" Equivalent BSSID bonus: ").append(mSameBssidAward).append(",");
+ score += sameBssidAward;
+ sbuf.append(" Equivalent BSSID bonus: ").append(sameBssidAward).append(",");
}
}
// Same BSSID award.
if (currentBssid != null && currentBssid.equals(scanResult.BSSID)) {
- score += mSameBssidAward;
- sbuf.append(" Same BSSID bonus: ").append(mSameBssidAward).append(",");
+ score += sameBssidAward;
+ sbuf.append(" Same BSSID bonus: ").append(sameBssidAward).append(",");
}
// Security award.
if (!WifiConfigurationUtil.isConfigForOpenNetwork(network)) {
- score += mSecurityAward;
- sbuf.append(" Secure network bonus: ").append(mSecurityAward).append(",");
+ score += securityAward;
+ sbuf.append(" Secure network bonus: ").append(securityAward).append(",");
}
sbuf.append(" ## Total score: ").append(score).append("\n");
diff --git a/service/java/com/android/server/wifi/ScoringParams.java b/service/java/com/android/server/wifi/ScoringParams.java
index beef1ab49..b7a9a1b90 100644
--- a/service/java/com/android/server/wifi/ScoringParams.java
+++ b/service/java/com/android/server/wifi/ScoringParams.java
@@ -25,7 +25,8 @@ import android.provider.Settings;
import android.util.KeyValueListParser;
import android.util.Log;
-import com.android.wifi.R;
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.wifi.resources.R;
/**
* Holds parameters used for scoring networks.
@@ -38,6 +39,8 @@ public class ScoringParams {
// A long name that describes itself pretty well
public static final int MINIMUM_5GHZ_BAND_FREQUENCY_IN_MEGAHERTZ = 5000;
+ private final Context mContext;
+
private static final String TAG = "WifiScoringParams";
private static final int EXIT = 0;
private static final int ENTRY = 1;
@@ -199,21 +202,26 @@ public class ScoringParams {
}
}
- @NonNull private Values mVal = new Values();
+ @NonNull private Values mVal = null;
+ @VisibleForTesting
public ScoringParams() {
+ mContext = null;
+ mVal = new Values();
}
public ScoringParams(Context context) {
- loadResources(context);
+ mContext = context;
}
public ScoringParams(Context context, FrameworkFacade facade, Handler handler) {
- loadResources(context);
+ mContext = context;
setupContentObserver(context, facade, handler);
}
private void loadResources(Context context) {
+ if (mVal != null) return;
+ mVal = new Values();
mVal.rssi2[EXIT] = context.getResources().getInteger(
R.integer.config_wifi_framework_wifi_score_bad_rssi_threshold_24GHz);
mVal.rssi2[ENTRY] = context.getResources().getInteger(
@@ -275,6 +283,7 @@ public class ScoringParams {
if (!("," + kvList).matches(COMMA_KEY_VAL_STAR)) {
return false;
}
+ loadResources(mContext);
Values v = new Values(mVal);
try {
v.parseString(kvList);
@@ -340,6 +349,7 @@ public class ScoringParams {
* Returns the number of seconds to use for rssi forecast.
*/
public int getHorizonSeconds() {
+ loadResources(mContext);
return mVal.horizon;
}
@@ -348,6 +358,7 @@ public class ScoringParams {
* no matter how bad the RSSI gets (packets per second).
*/
public int getYippeeSkippyPacketsPerSecond() {
+ loadResources(mContext);
return mVal.pps[2];
}
@@ -363,6 +374,7 @@ public class ScoringParams {
*
*/
public int getNudKnob() {
+ loadResources(mContext);
return mVal.nud;
}
@@ -372,10 +384,12 @@ public class ScoringParams {
* This value may be used to tag a set of experimental settings.
*/
public int getExperimentIdentifier() {
+ loadResources(mContext);
return mVal.expid;
}
private int[] getRssiArray(int frequency) {
+ loadResources(mContext);
if (frequency < MINIMUM_5GHZ_BAND_FREQUENCY_IN_MEGAHERTZ) {
return mVal.rssi2;
} else {
@@ -385,6 +399,7 @@ public class ScoringParams {
@Override
public String toString() {
+ loadResources(mContext);
return mVal.toString();
}
}
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 08f83f323..7793300fb 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -50,7 +50,7 @@ import com.android.server.wifi.WifiNative.SoftApListener;
import com.android.server.wifi.util.ApConfigUtil;
import com.android.server.wifi.wificond.IApInterfaceEventCallback;
import com.android.server.wifi.wificond.NativeWifiClient;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
diff --git a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java
index ddbfe9aa7..b69bd690f 100644
--- a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java
@@ -32,7 +32,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.server.wifi.util.GeneralUtil.Mutable;
import com.android.server.wifi.util.NativeUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.json.JSONException;
import org.json.JSONObject;
@@ -89,15 +89,13 @@ public class SupplicantStaNetworkHal {
Pattern.compile("^:([0-9a-fA-F]+)$");
private final Object mLock = new Object();
+ private final Context mContext;
private final String mIfaceName;
private final WifiMonitor mWifiMonitor;
private ISupplicantStaNetwork mISupplicantStaNetwork;
private ISupplicantStaNetworkCallback mISupplicantStaNetworkCallback;
private boolean mVerboseLoggingEnabled = false;
- // Indicates whether the system is capable of 802.11r fast BSS transition.
- private boolean mSystemSupportsFastBssTransition = false;
-
// Network variables read from wpa_supplicant.
private int mNetworkId;
private ArrayList<Byte> mSsid;
@@ -136,10 +134,9 @@ public class SupplicantStaNetworkHal {
SupplicantStaNetworkHal(ISupplicantStaNetwork iSupplicantStaNetwork, String ifaceName,
Context context, WifiMonitor monitor) {
mISupplicantStaNetwork = iSupplicantStaNetwork;
+ mContext = context;
mIfaceName = ifaceName;
mWifiMonitor = monitor;
- mSystemSupportsFastBssTransition =
- context.getResources().getBoolean(R.bool.config_wifi_fast_bss_transition_enabled);
}
/**
@@ -3177,7 +3174,8 @@ public class SupplicantStaNetworkHal {
*/
private BitSet addFastTransitionFlags(BitSet keyManagementFlags) {
synchronized (mLock) {
- if (!mSystemSupportsFastBssTransition) {
+ if (!mContext.getResources().getBoolean(
+ R.bool.config_wifi_fast_bss_transition_enabled)) {
return keyManagementFlags;
}
BitSet modifiedFlags = (BitSet) keyManagementFlags.clone();
diff --git a/service/java/com/android/server/wifi/ThroughputPredictor.java b/service/java/com/android/server/wifi/ThroughputPredictor.java
index a8e8adac3..1f3ecfeb2 100644
--- a/service/java/com/android/server/wifi/ThroughputPredictor.java
+++ b/service/java/com/android/server/wifi/ThroughputPredictor.java
@@ -22,7 +22,7 @@ import android.content.Context;
import android.net.wifi.ScanResult;
import android.util.Log;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
/**
* A class that predicts network throughput based on RSSI, channel utilization, channel width,
@@ -90,18 +90,11 @@ public class ThroughputPredictor {
private static final int MAX_NUM_SPATIAL_STREAM_11N = 4;
private static final int MAX_NUM_SPATIAL_STREAM_LEGACY = 1;
- private final boolean mAxSupported;
- private final boolean mContiguous160MHzSupported;
- private final int mMaxNumSpatialStreamSupported;
+ private final Context mContext;
+ // TODO: b/144576344 get the resource values form HAL instead.
ThroughputPredictor(Context context) {
- // TODO: b/144576344 get the following information from HAL
- mAxSupported = context.getResources().getBoolean(
- R.bool.config_wifi_11ax_supported);
- mContiguous160MHzSupported = context.getResources().getBoolean(
- R.bool.config_wifi_contiguous_160mhz_supported);
- mMaxNumSpatialStreamSupported = context.getResources().getInteger(
- R.integer.config_wifi_max_num_spatial_stream_supported);
+ mContext = context;
}
/**
@@ -121,16 +114,20 @@ public class ThroughputPredictor {
int channelUtilizationBssLoad, int channelUtilizationLinkLayerStats,
boolean isBluetoothConnected) {
- int maxNumSpatialStream = Math.min(mMaxNumSpatialStreamSupported, maxNumSpatialStreamAp);
+ int maxNumSpatialStream = Math.min(mContext.getResources().getInteger(
+ R.integer.config_wifi_max_num_spatial_stream_supported),
+ maxNumSpatialStreamAp);
// Downgrade to AC mode if 11AX AP is found but 11AX mode is not supported by the device
- if (!mAxSupported && wifiStandard == ScanResult.WIFI_STANDARD_11AX) {
+ if (!mContext.getResources().getBoolean(R.bool.config_wifi_11ax_supported)
+ && wifiStandard == ScanResult.WIFI_STANDARD_11AX) {
wifiStandard = ScanResult.WIFI_STANDARD_11AC;
}
int channelWidth = channelWidthAp;
// Downgrade to 80MHz if 160MHz AP is found but 160MHz mode is not supported by the device
- if (!mContiguous160MHzSupported && (channelWidth == ScanResult.CHANNEL_WIDTH_160MHZ)) {
+ if (!mContext.getResources().getBoolean(R.bool.config_wifi_contiguous_160mhz_supported)
+ && (channelWidth == ScanResult.CHANNEL_WIDTH_160MHZ)) {
channelWidth = ScanResult.CHANNEL_WIDTH_80MHZ;
}
diff --git a/service/java/com/android/server/wifi/WakeupNotificationFactory.java b/service/java/com/android/server/wifi/WakeupNotificationFactory.java
index a16a4e591..e69fa4728 100644
--- a/service/java/com/android/server/wifi/WakeupNotificationFactory.java
+++ b/service/java/com/android/server/wifi/WakeupNotificationFactory.java
@@ -22,7 +22,7 @@ import android.content.Context;
import android.content.Intent;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
/** Factory for Wifi Wake notifications. */
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java
index 80421e78c..046f76059 100644
--- a/service/java/com/android/server/wifi/WifiApConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiApConfigStore.java
@@ -30,7 +30,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
@@ -82,15 +82,12 @@ public class WifiApConfigStore {
private WifiConfiguration mPersistentWifiApConfig = null;
- private ArrayList<Integer> mAllowed2GChannel = null;
-
private final Context mContext;
private final Handler mHandler;
private final BackupManagerProxy mBackupManagerProxy;
private final MacAddressUtil mMacAddressUtil;
private final Mac mMac;
private final WifiConfigManager mWifiConfigManager;
- private boolean mRequiresApBandConversion = false;
private boolean mHasNewDataToSerialize = false;
/**
@@ -142,21 +139,6 @@ public class WifiApConfigStore {
mBackupManagerProxy = backupManagerProxy;
mWifiConfigManager = wifiConfigManager;
- String ap2GChannelListStr = mContext.getResources().getString(
- R.string.config_wifi_framework_sap_2G_channel_list);
- Log.d(TAG, "2G band allowed channels are:" + ap2GChannelListStr);
-
- if (ap2GChannelListStr != null) {
- mAllowed2GChannel = new ArrayList<Integer>();
- String channelList[] = ap2GChannelListStr.split(",");
- for (String tmp : channelList) {
- mAllowed2GChannel.add(Integer.parseInt(tmp));
- }
- }
-
- mRequiresApBandConversion = mContext.getResources().getBoolean(
- R.bool.config_wifi_convert_apband_5ghz_to_any);
-
// One time migration from legacy config store.
try {
File file = new File(apConfigFile);
@@ -222,7 +204,18 @@ public class WifiApConfigStore {
}
public ArrayList<Integer> getAllowed2GChannel() {
- return mAllowed2GChannel;
+ String ap2GChannelListStr = mContext.getResources().getString(
+ R.string.config_wifi_framework_sap_2G_channel_list);
+ Log.d(TAG, "2G band allowed channels are:" + ap2GChannelListStr);
+
+ ArrayList<Integer> allowed2GChannels = new ArrayList<>();
+ if (ap2GChannelListStr != null) {
+ String[] channelList = ap2GChannelListStr.split(",");
+ for (String tmp : channelList) {
+ allowed2GChannels.add(Integer.parseInt(tmp));
+ }
+ }
+ return allowed2GChannels;
}
private WifiConfiguration sanitizePersistentApConfig(WifiConfiguration config) {
@@ -234,7 +227,7 @@ public class WifiApConfigStore {
convertedConfig.BSSID = null;
}
- if (mRequiresApBandConversion) {
+ if (mContext.getResources().getBoolean(R.bool.config_wifi_convert_apband_5ghz_to_any)) {
// some devices are unable to support 5GHz only operation, check for 5GHz and
// move to ANY if apBand conversion is required.
if (config.apBand == WifiConfiguration.AP_BAND_5GHZ) {
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 84a8bdca1..d2faa84b6 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -56,7 +56,7 @@ import com.android.server.wifi.hotspot2.PasspointManager;
import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.xmlpull.v1.XmlPullParserException;
@@ -243,7 +243,6 @@ public class WifiConfigManager {
private final WifiPermissionsWrapper mWifiPermissionsWrapper;
private final WifiInjector mWifiInjector;
private final MacAddressUtil mMacAddressUtil;
- private boolean mConnectedMacRandomzationSupported;
private final Mac mMac;
private final TelephonyUtil mTelephonyUtil;
@@ -283,15 +282,6 @@ public class WifiConfigManager {
* Store the network update listeners.
*/
private final List<OnNetworkUpdateListener> mListeners;
- /**
- * Flag to indicate if only networks with the same psk should be linked.
- * TODO(b/30706406): Remove this flag if unused.
- */
- private final boolean mOnlyLinkSameCredentialConfigurations;
- /**
- * Number of channels to scan for during partial scans initiated while connected.
- */
- private final int mMaxNumActiveChannelsForPartialScans;
private final FrameworkFacade mFrameworkFacade;
private final DeviceConfigFacade mDeviceConfigFacade;
@@ -394,10 +384,6 @@ public class WifiConfigManager {
mWifiConfigStore.registerStoreData(mDeletedEphemeralSsidsStoreData);
mWifiConfigStore.registerStoreData(mRandomizedMacStoreData);
- mOnlyLinkSameCredentialConfigurations = mContext.getResources().getBoolean(
- R.bool.config_wifi_only_link_same_credential_configurations);
- mMaxNumActiveChannelsForPartialScans = mContext.getResources().getInteger(
- R.integer.config_wifi_framework_associated_partial_scan_max_num_active_channels);
mFrameworkFacade = frameworkFacade;
mFrameworkFacade.registerContentObserver(mContext, Settings.Global.getUriFor(
Settings.Global.WIFI_PNO_FREQUENCY_CULLING_ENABLED), false,
@@ -417,8 +403,6 @@ public class WifiConfigManager {
}
});
updatePnoRecencySortingSetting();
- mConnectedMacRandomzationSupported = mContext.getResources()
- .getBoolean(R.bool.config_wifi_connected_mac_randomization_supported);
mDeviceConfigFacade = deviceConfigFacade;
mAggressiveMacRandomizationWhitelist = new ArraySet<>();
mAggressiveMacRandomizationBlacklist = new ArraySet<>();
@@ -721,7 +705,8 @@ public class WifiConfigManager {
&& targetUid != configuration.creatorUid) {
maskRandomizedMacAddressInWifiConfiguration(network);
}
- if (!mConnectedMacRandomzationSupported) {
+ if (!mContext.getResources().getBoolean(
+ R.bool.config_wifi_connected_mac_randomization_supported)) {
network.macRandomizationSetting = WifiConfiguration.RANDOMIZATION_NONE;
}
return network;
@@ -2510,7 +2495,8 @@ public class WifiConfigManager {
ScanDetailCache scanDetailCache1, ScanDetailCache scanDetailCache2) {
// TODO (b/30706406): Link networks only with same passwords if the
// |mOnlyLinkSameCredentialConfigurations| flag is set.
- if (mOnlyLinkSameCredentialConfigurations) {
+ if (mContext.getResources().getBoolean(
+ R.bool.config_wifi_only_link_same_credential_configurations)) {
if (!TextUtils.equals(network1.preSharedKey, network2.preSharedKey)) {
if (mVerboseLoggingEnabled) {
Log.v(TAG, "shouldNetworksBeLinked unlink due to password mismatch");
@@ -2706,6 +2692,8 @@ public class WifiConfigManager {
Log.i(TAG, "No scan detail and linked configs associated with networkId " + networkId);
return null;
}
+ final int maxNumActiveChannelsForPartialScans = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_associated_partial_scan_max_num_active_channels);
if (mVerboseLoggingEnabled) {
StringBuilder dbg = new StringBuilder();
dbg.append("fetchChannelSetForNetworkForPartialScan ageInMillis ")
@@ -2713,7 +2701,7 @@ public class WifiConfigManager {
.append(" for ")
.append(config.configKey())
.append(" max ")
- .append(mMaxNumActiveChannelsForPartialScans);
+ .append(maxNumActiveChannelsForPartialScans);
if (scanDetailCache != null) {
dbg.append(" bssids " + scanDetailCache.size());
}
@@ -2727,7 +2715,7 @@ public class WifiConfigManager {
// First add the currently connected network channel.
if (homeChannelFreq > 0) {
channelSet.add(homeChannelFreq);
- if (channelSet.size() >= mMaxNumActiveChannelsForPartialScans) {
+ if (channelSet.size() >= maxNumActiveChannelsForPartialScans) {
return channelSet;
}
}
@@ -2737,7 +2725,7 @@ public class WifiConfigManager {
// Then get channels for the network.
if (!addToChannelSetForNetworkFromScanDetailCache(
channelSet, scanDetailCache, nowInMillis, ageInMillis,
- mMaxNumActiveChannelsForPartialScans)) {
+ maxNumActiveChannelsForPartialScans)) {
return channelSet;
}
@@ -2752,7 +2740,7 @@ public class WifiConfigManager {
getScanDetailCacheForNetwork(linkedConfig.networkId);
if (!addToChannelSetForNetworkFromScanDetailCache(
channelSet, linkedScanDetailCache, nowInMillis, ageInMillis,
- mMaxNumActiveChannelsForPartialScans)) {
+ maxNumActiveChannelsForPartialScans)) {
break;
}
}
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 25d52bb97..1dd0a484e 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -38,7 +38,7 @@ import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.util.ScanResultUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -119,6 +119,7 @@ public class WifiConnectivityManager {
// Log tag for this class
private static final String TAG = "WifiConnectivityManager";
+ private final Context mContext;
private final ClientModeImpl mStateMachine;
private final WifiInjector mWifiInjector;
private final WifiConfigManager mConfigManager;
@@ -155,29 +156,17 @@ public class WifiConnectivityManager {
private boolean mPnoScanStarted = false;
private boolean mPeriodicScanTimerSet = false;
// Device configs
- private boolean mEnableAutoJoinWhenAssociated;
private boolean mWaitForFullBandScanResults = false;
- private boolean mUseSingleRadioChainScanResults = false;
- private int mFullScanMaxTxRate;
- private int mFullScanMaxRxRate;
-
- // PNO settings
- private int mCurrentConnectionBonus;
- private int mSameNetworkBonus;
- private int mSecureBonus;
- private int mBand5GHzBonus;
- private int mRssiScoreOffset;
- private int mRssiScoreSlope;
- private int mPnoScanIntervalMs;
// Scanning Schedules
// Default schedule used in case of invalid configuration
private static final int[] DEFAULT_SCANNING_SCHEDULE = {20, 40, 80, 160};
- private final int[] mConnectedSingleScanSchedule;
- private final int[] mDisconnectedSingleScanSchedule;
+ private int[] mConnectedSingleScanSchedule;
+ private int[] mDisconnectedSingleScanSchedule;
private int[] mCurrentSingleScanSchedule;
private int mCurrentSingleScanScheduleIndex;
+ private int mPnoScanIntervalMs;
private WifiChannelUtilization mWifiChannelUtilization;
// A helper to log debugging information in the local log buffer, which can
@@ -366,7 +355,8 @@ public class WifiConnectivityManager {
// When the scan result has radio chain info, ensure we throw away scan results
// not received with both radio chains (if |mUseSingleRadioChainScanResults| is false).
- if (!mUseSingleRadioChainScanResults
+ if (!mContext.getResources().getBoolean(
+ R.bool.config_wifi_framework_use_single_radio_chain_scan_results_network_selection)
&& fullScanResult.radioChainInfos != null
&& fullScanResult.radioChainInfos.length == 1) {
// Keep track of the number of dropped scan results for logging.
@@ -564,6 +554,7 @@ public class WifiConnectivityManager {
WifiLastResortWatchdog wifiLastResortWatchdog, OpenNetworkNotifier openNetworkNotifier,
CarrierNetworkConfig carrierNetworkConfig, WifiMetrics wifiMetrics, Handler handler,
Clock clock, LocalLog localLog) {
+ mContext = context;
mStateMachine = stateMachine;
mWifiInjector = injector;
mConfigManager = configManager;
@@ -581,42 +572,8 @@ public class WifiConnectivityManager {
mScoringParams = scoringParams;
mConnectionAttemptTimeStamps = new LinkedList<>();
- mBand5GHzBonus = context.getResources().getInteger(
- R.integer.config_wifi_framework_5GHz_preference_boost_factor);
- mCurrentConnectionBonus = context.getResources().getInteger(
- R.integer.config_wifi_framework_current_network_boost);
- mSameNetworkBonus = context.getResources().getInteger(
- R.integer.config_wifi_framework_SAME_BSSID_AWARD);
- mSecureBonus = context.getResources().getInteger(
- R.integer.config_wifi_framework_SECURITY_AWARD);
- mRssiScoreOffset = context.getResources().getInteger(
- R.integer.config_wifi_framework_RSSI_SCORE_OFFSET);
- mRssiScoreSlope = context.getResources().getInteger(
- R.integer.config_wifi_framework_RSSI_SCORE_SLOPE);
- mEnableAutoJoinWhenAssociated = context.getResources().getBoolean(
- R.bool.config_wifi_framework_enable_associated_network_selection);
- mUseSingleRadioChainScanResults = context.getResources().getBoolean(
- R.bool.config_wifi_framework_use_single_radio_chain_scan_results_network_selection);
-
- mFullScanMaxTxRate = context.getResources().getInteger(
- R.integer.config_wifi_framework_max_tx_rate_for_full_scan);
- mFullScanMaxRxRate = context.getResources().getInteger(
- R.integer.config_wifi_framework_max_rx_rate_for_full_scan);
-
- mConnectedSingleScanSchedule = initializeScanningSchedule(context, WIFI_STATE_CONNECTED);
- mDisconnectedSingleScanSchedule = initializeScanningSchedule(context,
- WIFI_STATE_DISCONNECTED);
-
mPnoScanIntervalMs = MOVING_PNO_SCAN_INTERVAL_MS;
- localLog("PNO settings:"
- + " min5GHzRssi " + mScoringParams.getEntryRssi(ScoringParams.BAND5)
- + " min24GHzRssi " + mScoringParams.getEntryRssi(ScoringParams.BAND2)
- + " currentConnectionBonus " + mCurrentConnectionBonus
- + " sameNetworkBonus " + mSameNetworkBonus
- + " secureNetworkBonus " + mSecureBonus
- + " initialScoreMax " + initialScoreMax());
-
// Listen to WifiConfigManager network update events
mConfigManager.addOnNetworkUpdateListener(new OnNetworkUpdateListener());
mBssidBlocklistMonitor = mWifiInjector.getBssidBlocklistMonitor();
@@ -660,9 +617,13 @@ public class WifiConnectivityManager {
/** Returns maximum PNO score, before any awards/bonuses. */
private int initialScoreMax() {
- return mRssiScoreSlope * (Math.max(mScoringParams.getGoodRssi(ScoringParams.BAND2),
+ final int rssiScoreOffset = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_RSSI_SCORE_OFFSET);
+ final int rssiScoreSlope = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_RSSI_SCORE_SLOPE);
+ return rssiScoreSlope * (Math.max(mScoringParams.getGoodRssi(ScoringParams.BAND2),
mScoringParams.getGoodRssi(ScoringParams.BAND5))
- + mRssiScoreOffset);
+ + rssiScoreOffset);
}
/**
@@ -857,8 +818,12 @@ public class WifiConnectivityManager {
boolean isScanNeeded = true;
boolean isFullBandScan = true;
- boolean isTrafficOverThreshold = mWifiInfo.getTxSuccessRate() > mFullScanMaxTxRate
- || mWifiInfo.getRxSuccessRate() > mFullScanMaxRxRate;
+ boolean isTrafficOverThreshold = mWifiInfo.getTxSuccessRate()
+ > mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_max_tx_rate_for_full_scan)
+ || mWifiInfo.getRxSuccessRate()
+ > mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_max_rx_rate_for_full_scan);
// If the WiFi traffic is heavy, only partial scan is proposed.
if (mWifiState == WIFI_STATE_CONNECTED && isTrafficOverThreshold) {
@@ -964,7 +929,8 @@ public class WifiConnectivityManager {
mPnoScanListener.resetLowRssiNetworkRetryDelay();
// No connectivity scan if auto roaming is disabled.
- if (mWifiState == WIFI_STATE_CONNECTED && !mEnableAutoJoinWhenAssociated) {
+ if (mWifiState == WIFI_STATE_CONNECTED && !mContext.getResources().getBoolean(
+ R.bool.config_wifi_framework_enable_associated_network_selection)) {
return;
}
@@ -1047,10 +1013,14 @@ public class WifiConnectivityManager {
pnoSettings.min5GHzRssi = mScoringParams.getEntryRssi(ScoringParams.BAND5);
pnoSettings.min24GHzRssi = mScoringParams.getEntryRssi(ScoringParams.BAND2);
pnoSettings.initialScoreMax = initialScoreMax();
- pnoSettings.currentConnectionBonus = mCurrentConnectionBonus;
- pnoSettings.sameNetworkBonus = mSameNetworkBonus;
- pnoSettings.secureBonus = mSecureBonus;
- pnoSettings.band5GHzBonus = mBand5GHzBonus;
+ pnoSettings.currentConnectionBonus = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_current_network_boost);
+ pnoSettings.sameNetworkBonus = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_SAME_BSSID_AWARD);
+ pnoSettings.secureBonus = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_SECURITY_AWARD);
+ pnoSettings.band5GHzBonus = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_5GHz_preference_boost_factor);
// Initialize scan settings
ScanSettings scanSettings = new ScanSettings();
@@ -1202,6 +1172,15 @@ public class WifiConnectivityManager {
public void handleConnectionStateChanged(int state) {
localLog("handleConnectionStateChanged: state=" + stateToString(state));
+ if (mConnectedSingleScanSchedule == null) {
+ mConnectedSingleScanSchedule = initializeScanningSchedule(
+ mContext, WIFI_STATE_CONNECTED);
+ }
+ if (mDisconnectedSingleScanSchedule == null) {
+ mDisconnectedSingleScanSchedule = initializeScanningSchedule(
+ mContext, WIFI_STATE_DISCONNECTED);
+ }
+
mWifiState = state;
// Reset BSSID of last connection attempt and kick off
diff --git a/service/java/com/android/server/wifi/WifiContext.java b/service/java/com/android/server/wifi/WifiContext.java
new file mode 100644
index 000000000..5ac6f208d
--- /dev/null
+++ b/service/java/com/android/server/wifi/WifiContext.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.util.Log;
+
+/**
+ * Wrapper for context to override getResources method. Resources for wifi mainline jar needs to be
+ * fetched from the resources APK.
+ */
+public class WifiContext extends ContextWrapper {
+ private static final String TAG = "WifiContext";
+ private static final String WIFI_OVERLAY_APK_PKG_NAME = "com.android.wifi.resources";
+
+ // Cached resources from the resources APK.
+ private Resources mWifiResourcesFromApk;
+
+ public WifiContext(@NonNull Context contextBase) {
+ super(contextBase);
+ }
+
+ /**
+ * Retrieve resources held in the wifi resources APK.
+ */
+ @Override
+ public Resources getResources() {
+ if (mWifiResourcesFromApk == null) {
+ try {
+ Context overlayAppContext =
+ createPackageContext(WIFI_OVERLAY_APK_PKG_NAME, 0);
+ mWifiResourcesFromApk = overlayAppContext.getResources();
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.wtf(TAG, "Failed to load resources", e);
+ }
+ }
+ return mWifiResourcesFromApk;
+ }
+}
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java
index 1d4edf319..dc686f784 100644
--- a/service/java/com/android/server/wifi/WifiCountryCode.java
+++ b/service/java/com/android/server/wifi/WifiCountryCode.java
@@ -26,6 +26,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -41,16 +42,13 @@ import java.util.Locale;
*/
public class WifiCountryCode {
private static final String TAG = "WifiCountryCode";
+ private final Context mContext;
private final TelephonyManager mTelephonyManager;
private final WifiNative mWifiNative;
private boolean DBG = false;
private boolean mReady = false;
private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
- /** config option that indicate whether or not to reset country code to default when
- * cellular radio indicates country code loss
- */
- private boolean mRevertCountryCodeOnCellularLoss;
private String mDefaultCountryCode = null;
private String mTelephonyCountryCode = null;
private String mDriverCountryCode = null;
@@ -63,20 +61,13 @@ public class WifiCountryCode {
Context context,
Handler handler,
WifiNative wifiNative,
- String oemDefaultCountryCode,
- boolean revertCountryCodeOnCellularLoss) {
+ String oemDefaultCountryCode) {
+ mContext = context;
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
mWifiNative = wifiNative;
- mRevertCountryCodeOnCellularLoss = revertCountryCodeOnCellularLoss;
if (!TextUtils.isEmpty(oemDefaultCountryCode)) {
mDefaultCountryCode = oemDefaultCountryCode.toUpperCase(Locale.US);
- } else {
- if (mRevertCountryCodeOnCellularLoss) {
- Log.w(TAG, "config_wifi_revert_country_code_on_cellular_loss is set, "
- + "but there is no default country code.");
- mRevertCountryCodeOnCellularLoss = false;
- }
}
context.registerReceiver(new BroadcastReceiver() {
@Override
@@ -86,8 +77,7 @@ public class WifiCountryCode {
setCountryCodeAndUpdate(countryCode);
}}, new IntentFilter(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED), null, handler);
- Log.d(TAG, "mDefaultCountryCode " + mDefaultCountryCode
- + " mRevertCountryCodeOnCellularLoss " + mRevertCountryCodeOnCellularLoss);
+ Log.d(TAG, "mDefaultCountryCode " + mDefaultCountryCode);
}
/**
@@ -166,7 +156,8 @@ public class WifiCountryCode {
// Empty country code.
if (TextUtils.isEmpty(countryCode)) {
- if (mRevertCountryCodeOnCellularLoss) {
+ if (mContext.getResources()
+ .getBoolean(R.bool.config_wifi_revert_country_code_on_cellular_loss)) {
Log.d(TAG, "Received empty country code, reset to default country code");
mTelephonyCountryCode = null;
}
@@ -225,7 +216,9 @@ public class WifiCountryCode {
* Method to dump the current state of this WifiCounrtyCode object.
*/
public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- pw.println("mRevertCountryCodeOnCellularLoss: " + mRevertCountryCodeOnCellularLoss);
+ pw.println("mRevertCountryCodeOnCellularLoss: "
+ + mContext.getResources().getBoolean(
+ R.bool.config_wifi_revert_country_code_on_cellular_loss));
pw.println("mDefaultCountryCode: " + mDefaultCountryCode);
pw.println("mDriverCountryCode: " + mDriverCountryCode);
pw.println("mTelephonyCountryCode: " + mTelephonyCountryCode);
diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java
index 742581e9d..1e6386716 100644
--- a/service/java/com/android/server/wifi/WifiDiagnostics.java
+++ b/service/java/com/android/server/wifi/WifiDiagnostics.java
@@ -29,7 +29,7 @@ import android.util.SparseLongArray;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.util.ByteArrayRingBuffer;
import com.android.server.wifi.util.StringUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
@@ -44,7 +44,6 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.zip.Deflater;
@@ -122,8 +121,6 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
@VisibleForTesting public static final String DRIVER_DUMP_SECTION_HEADER =
"Driver state dump";
- private final int RING_BUFFER_BYTE_LIMIT_SMALL;
- private final int RING_BUFFER_BYTE_LIMIT_LARGE;
private int mLogLevel = VERBOSE_NO_LOG;
private boolean mIsLoggingEventHandlerRegistered;
private WifiNative.RingBufferStatus[] mRingBuffers;
@@ -135,8 +132,6 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
private final Runtime mJavaRuntime;
private final WifiMetrics mWifiMetrics;
private int mMaxRingBufferSizeBytes;
- private final List<Integer> mFatalFirmwareAlertErrorCodeList;
- private final boolean mBugreportEnabled;
private WifiInjector mWifiInjector;
private Clock mClock;
@@ -147,21 +142,10 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
WifiNative wifiNative, BuildProperties buildProperties,
LastMileLogger lastMileLogger, Clock clock) {
super(wifiNative);
- RING_BUFFER_BYTE_LIMIT_SMALL = context.getResources().getInteger(
- R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb) * 1024;
- RING_BUFFER_BYTE_LIMIT_LARGE = context.getResources().getInteger(
- R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb) * 1024;
- int[] fatalFirmwareAlertErrorCodeArray = context.getResources().getIntArray(
- R.array.config_wifi_fatal_firmware_alert_error_code_list);
- mBugreportEnabled = context.getResources().getBoolean(
- R.bool.config_wifi_diagnostics_bugreport_enabled);
mContext = context;
mBuildProperties = buildProperties;
mIsLoggingEventHandlerRegistered = false;
- mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_SMALL;
- mFatalFirmwareAlertErrorCodeList = Arrays.stream(fatalFirmwareAlertErrorCodeArray)
- .boxed().collect(Collectors.toList());
mLog = wifiInjector.makeLog(TAG);
mLastMileLogger = lastMileLogger;
mJavaRuntime = wifiInjector.getJavaRuntime();
@@ -278,7 +262,9 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
report.alertData = alertData;
mLastAlerts.addLast(report);
/* Flush HAL ring buffer when detecting data stall */
- if (mFatalFirmwareAlertErrorCodeList.contains(errorCode)) {
+ if (Arrays.stream(mContext.getResources().getIntArray(
+ R.array.config_wifi_fatal_firmware_alert_error_code_list))
+ .boxed().collect(Collectors.toList()).contains(errorCode)) {
flushDump(REPORT_REASON_FATAL_FW_ALERT);
}
}
@@ -315,7 +301,9 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
*/
@Override
public void takeBugReport(String bugTitle, String bugDetail) {
- if (mBuildProperties.isUserBuild() || !mBugreportEnabled) {
+ if (mBuildProperties.isUserBuild()
+ || !mContext.getResources().getBoolean(
+ R.bool.config_wifi_diagnostics_bugreport_enabled)) {
return;
}
@@ -500,13 +488,17 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
*/
@Override
public synchronized void enableVerboseLogging(boolean verboseEnabled) {
+ final int ringBufferByteLimitSmall = mContext.getResources().getInteger(
+ R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb) * 1024;
+ final int ringBufferByteLimitLarge = mContext.getResources().getInteger(
+ R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb) * 1024;
if (verboseEnabled) {
mLogLevel = VERBOSE_LOG_WITH_WAKEUP;
- mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_LARGE;
+ mMaxRingBufferSizeBytes = ringBufferByteLimitLarge;
} else {
mLogLevel = VERBOSE_NORMAL_LOG;
mMaxRingBufferSizeBytes = enableVerboseLoggingForDogfood()
- ? RING_BUFFER_BYTE_LIMIT_LARGE : RING_BUFFER_BYTE_LIMIT_SMALL;
+ ? ringBufferByteLimitLarge : ringBufferByteLimitSmall;
}
if (!mActiveInterfaces.isEmpty()) {
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index b8f8b47eb..d453986aa 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -45,6 +45,7 @@ import android.security.keystore.AndroidKeyStoreProvider;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.LocalLog;
+import android.util.Log;
import com.android.internal.os.PowerProfile;
import com.android.server.wifi.aware.WifiAwareMetrics;
@@ -60,7 +61,6 @@ import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
import com.android.server.wifi.wificond.IWificond;
-import com.android.wifi.R;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -76,6 +76,7 @@ import java.util.Random;
* an instance of the WifiInjector.
*/
public class WifiInjector {
+ private static final String TAG = "WifiInjector";
private static final String BOOT_DEFAULT_WIFI_COUNTRY_CODE = "ro.boot.wificountrycode";
private static final String WIFICOND_SERVICE_NAME = "wificond";
@@ -240,14 +241,13 @@ public class WifiInjector {
// Now get instances of all the objects that depend on the HandlerThreads
mWifiTrafficPoller = new WifiTrafficPoller(wifiHandler);
mCountryCode = new WifiCountryCode(mContext, wifiHandler, mWifiNative,
- SystemProperties.get(BOOT_DEFAULT_WIFI_COUNTRY_CODE),
- mContext.getResources()
- .getBoolean(R.bool.config_wifi_revert_country_code_on_cellular_loss));
+ SystemProperties.get(BOOT_DEFAULT_WIFI_COUNTRY_CODE));
// WifiConfigManager/Store objects and their dependencies.
KeyStore keyStore = null;
try {
keyStore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
} catch (KeyStoreException | NoSuchProviderException e) {
+ Log.wtf(TAG, "Failed to load keystore", e);
}
mKeyStore = keyStore;
mWifiKeyStore = new WifiKeyStore(mKeyStore);
@@ -297,8 +297,8 @@ public class WifiInjector {
mTelephonyUtil);
mNetworkSuggestionEvaluator = new NetworkSuggestionEvaluator(mWifiNetworkSuggestionsManager,
mWifiConfigManager, mConnectivityLocalLog);
- mScoredNetworkEvaluator = new ScoredNetworkEvaluator(context, wifiHandler,
- mFrameworkFacade, mNetworkScoreManager, context.getPackageManager(),
+ mScoredNetworkEvaluator = new ScoredNetworkEvaluator(mContext, wifiHandler,
+ mFrameworkFacade, mNetworkScoreManager, mContext.getPackageManager(),
mWifiConfigManager, mConnectivityLocalLog,
mWifiNetworkScoreCache, mWifiPermissionsUtil);
mCarrierNetworkEvaluator = new CarrierNetworkEvaluator(mWifiConfigManager,
diff --git a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
index 5dc799d65..0858f03c6 100644
--- a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
+++ b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
@@ -28,7 +28,7 @@ import android.util.Log;
import android.util.Pair;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -120,7 +120,7 @@ public class WifiLastResortWatchdog {
private final Handler mHandler;
private final WifiThreadRunner mWifiThreadRunner;
- private boolean mWatchdogFeatureEnabled;
+ private Boolean mWatchdogFeatureEnabled = null;
/**
* Local log used for debugging any WifiLastResortWatchdog issues.
@@ -143,8 +143,6 @@ public class WifiLastResortWatchdog {
processMessage(msg);
}
};
- mWatchdogFeatureEnabled = mContext.getResources()
- .getBoolean(R.bool.config_wifi_watchdog_enabled);
}
/**
@@ -313,7 +311,7 @@ public class WifiLastResortWatchdog {
Log.v(TAG, "isRestartNeeded = " + isRestartNeeded);
}
if (isRestartNeeded) {
- if (mWatchdogFeatureEnabled) {
+ if (getWifiWatchdogFeature()) {
// Stop the watchdog from triggering until re-enabled
localLog("Trigger recovery: setWatchdogTriggerEnabled to false");
setWatchdogTriggerEnabled(false);
@@ -347,7 +345,7 @@ public class WifiLastResortWatchdog {
return;
}
if (!mWatchdogAllowedToTrigger && mWatchdogFixedWifi
- && mWatchdogFeatureEnabled
+ && getWifiWatchdogFeature()
&& checkIfAtleastOneNetworkHasEverConnected()
&& checkIfConnectedBackToSameSsid()
&& checkIfConnectedBssidHasEverFailed()) {
@@ -636,7 +634,7 @@ public class WifiLastResortWatchdog {
*/
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("mWatchdogFeatureEnabled: ").append(mWatchdogFeatureEnabled);
+ sb.append("mWatchdogFeatureEnabled: ").append(getWifiWatchdogFeature());
sb.append("\nmWatchdogAllowedToTrigger: ").append(mWatchdogAllowedToTrigger);
sb.append("\nmWifiIsConnected: ").append(mWifiIsConnected);
sb.append("\nmRecentAvailableNetworks: ").append(mRecentAvailableNetworks.size());
@@ -710,6 +708,10 @@ public class WifiLastResortWatchdog {
* Returns whether wifi watchdog should trigger recovery.
*/
public boolean getWifiWatchdogFeature() {
+ if (mWatchdogFeatureEnabled == null) {
+ mWatchdogFeatureEnabled = mContext.getResources().getBoolean(
+ R.bool.config_wifi_watchdog_enabled);
+ }
return mWatchdogFeatureEnabled;
}
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 0a753e731..0dcd0166c 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -88,6 +88,7 @@ import com.android.server.wifi.util.IntHistogram;
import com.android.server.wifi.util.MetricsUtils;
import com.android.server.wifi.util.ObjectCounter;
import com.android.server.wifi.util.ScanResultUtil;
+import com.android.wifi.resources.R;
import org.json.JSONArray;
import org.json.JSONException;
@@ -382,8 +383,6 @@ public class WifiMetrics {
/** Wifi P2p metrics */
private final WifiP2pMetrics mWifiP2pMetrics;
- private boolean mIsMacRandomizationOn = false;
-
/** DPP */
private final DppMetrics mDppMetrics;
@@ -2289,13 +2288,6 @@ public class WifiMetrics {
}
}
- /** Sets if Connected MAC Randomization feature is enabled */
- public void setIsMacRandomizationOn(boolean enabled) {
- synchronized (mLock) {
- mIsMacRandomizationOn = enabled;
- }
- }
-
/** Log firmware alert related metrics */
public void logFirmwareAlert(int errorCode) {
incrementAlertReasonCount(errorCode);
@@ -2739,7 +2731,9 @@ public class WifiMetrics {
mWifiPowerMetrics.dump(pw);
mWifiWakeMetrics.dump(pw);
- pw.println("mWifiLogProto.isMacRandomizationOn=" + mIsMacRandomizationOn);
+ pw.println("mWifiLogProto.isMacRandomizationOn="
+ + mContext.getResources().getBoolean(
+ R.bool.config_wifi_connected_mac_randomization_supported));
pw.println("mWifiLogProto.scoreExperimentId=" + mWifiLogProto.scoreExperimentId);
pw.println("mExperimentValues.wifiIsUnusableLoggingEnabled="
+ mExperimentValues.wifiIsUnusableLoggingEnabled);
@@ -3275,7 +3269,8 @@ public class WifiMetrics {
mWifiLogProto.wifiPowerStats = mWifiPowerMetrics.buildProto();
mWifiLogProto.wifiRadioUsage = mWifiPowerMetrics.buildWifiRadioUsageProto();
mWifiLogProto.wifiWakeStats = mWifiWakeMetrics.buildProto();
- mWifiLogProto.isMacRandomizationOn = mIsMacRandomizationOn;
+ mWifiLogProto.isMacRandomizationOn = mContext.getResources().getBoolean(
+ R.bool.config_wifi_connected_mac_randomization_supported);
mWifiLogProto.experimentValues = mExperimentValues;
mWifiLogProto.wifiIsUnusableEventList =
new WifiIsUnusableEvent[mWifiIsUnusableList.size()];
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java
index 63acb6682..6660075e5 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSelector.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java
@@ -39,7 +39,7 @@ import com.android.internal.util.Preconditions;
import com.android.server.wifi.proto.nano.WifiMetricsProto;
import com.android.server.wifi.util.InformationElementUtil.BssLoad;
import com.android.server.wifi.util.ScanResultUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -100,6 +100,7 @@ public class WifiNetworkSelector {
*/
public static final int LEGACY_CANDIDATE_SCORER_EXP_ID = 0;
+ private final Context mContext;
private final WifiConfigManager mWifiConfigManager;
private final Clock mClock;
private final LocalLog mLocalLog;
@@ -112,9 +113,6 @@ public class WifiNetworkSelector {
private List<ScanDetail> mFilteredNetworks = new ArrayList<>();
private final WifiScoreCard mWifiScoreCard;
private final ScoringParams mScoringParams;
- private final int mStayOnNetworkMinimumTxRate;
- private final int mStayOnNetworkMinimumRxRate;
- private final boolean mEnableAutoJoinWhenAssociated;
private final WifiNative mWifiNative;
private final Map<String, WifiCandidates.CandidateScorer> mCandidateScorers = new ArrayMap<>();
@@ -232,11 +230,15 @@ public class WifiNetworkSelector {
+ " , ID: " + wifiInfo.getNetworkId());
}
+ final int stayOnNetworkMinimumTxRate = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_min_tx_rate_for_staying_on_network);
+ final int stayOnNetworkMinimumRxRate = mContext.getResources().getInteger(
+ R.integer.config_wifi_framework_min_rx_rate_for_staying_on_network);
int currentRssi = wifiInfo.getRssi();
boolean hasQualifiedRssi = currentRssi
> mScoringParams.getSufficientRssi(wifiInfo.getFrequency());
- boolean hasActiveStream = (wifiInfo.getTxSuccessRate() > mStayOnNetworkMinimumTxRate)
- || (wifiInfo.getRxSuccessRate() > mStayOnNetworkMinimumRxRate);
+ boolean hasActiveStream = (wifiInfo.getTxSuccessRate() > stayOnNetworkMinimumTxRate)
+ || (wifiInfo.getRxSuccessRate() > stayOnNetworkMinimumRxRate);
if (hasQualifiedRssi && hasActiveStream) {
localLog("Stay on current network because of good RSSI and ongoing traffic");
return true;
@@ -313,7 +315,8 @@ public class WifiNetworkSelector {
if (connected) {
// Is roaming allowed?
- if (!mEnableAutoJoinWhenAssociated) {
+ if (!mContext.getResources().getBoolean(
+ R.bool.config_wifi_framework_enable_associated_network_selection)) {
localLog("Switching networks in connected state is not allowed."
+ " Skip network selection.");
return false;
@@ -972,6 +975,7 @@ public class WifiNetworkSelector {
WifiConfigManager configManager, Clock clock, LocalLog localLog,
WifiMetrics wifiMetrics, WifiNative wifiNative,
ThroughputPredictor throughputPredictor) {
+ mContext = context;
mWifiConfigManager = configManager;
mClock = clock;
mWifiScoreCard = wifiScoreCard;
@@ -980,11 +984,5 @@ public class WifiNetworkSelector {
mWifiMetrics = wifiMetrics;
mWifiNative = wifiNative;
mThroughputPredictor = throughputPredictor;
- mEnableAutoJoinWhenAssociated = context.getResources().getBoolean(
- R.bool.config_wifi_framework_enable_associated_network_selection);
- mStayOnNetworkMinimumTxRate = context.getResources().getInteger(
- R.integer.config_wifi_framework_min_tx_rate_for_staying_on_network);
- mStayOnNetworkMinimumRxRate = context.getResources().getInteger(
- R.integer.config_wifi_framework_min_rx_rate_for_staying_on_network);
}
}
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index ce030c918..fad73661d 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -53,7 +53,7 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.server.wifi.util.ExternalCallbackTracker;
import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
diff --git a/service/java/com/android/server/wifi/WifiService.java b/service/java/com/android/server/wifi/WifiService.java
index 9eb118278..34f1a76b7 100644
--- a/service/java/com/android/server/wifi/WifiService.java
+++ b/service/java/com/android/server/wifi/WifiService.java
@@ -41,9 +41,10 @@ public final class WifiService extends SystemService {
final WifiServiceImpl mImpl;
- public WifiService(Context context) {
- super(context);
- mImpl = new WifiServiceImpl(context, new WifiInjector(context), new WifiAsyncChannel(TAG));
+ public WifiService(Context contextBase) {
+ super(new WifiContext(contextBase));
+ mImpl = new WifiServiceImpl(getContext(), new WifiInjector(getContext()),
+ new WifiAsyncChannel(TAG));
}
@Override
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 5ed82a8ec..46f76a76d 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -110,7 +110,7 @@ import com.android.server.wifi.util.ExternalCallbackTracker;
import com.android.server.wifi.util.RssiUtil;
import com.android.server.wifi.util.WifiHandler;
import com.android.server.wifi.util.WifiPermissionsUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.BufferedReader;
import java.io.FileDescriptor;
@@ -361,6 +361,20 @@ public class WifiServiceImpl extends BaseWifiService {
public void handleBootCompleted() {
Log.d(TAG, "Handle boot completed");
+
+ // Register for system broadcasts.
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(Intent.ACTION_USER_REMOVED);
+ intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
+ intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
+ intentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
+ boolean trackEmergencyCallState = mContext.getResources().getBoolean(
+ R.bool.config_wifi_turn_off_during_emergency_call);
+ if (trackEmergencyCallState) {
+ intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED);
+ }
+ mContext.registerReceiver(mReceiver, intentFilter);
+
mWifiThreadRunner.post(() -> {
new MemoryStoreImpl(mContext, mWifiInjector, mWifiInjector.getWifiScoreCard()).start();
if (!mWifiConfigManager.loadFromStore()) {
@@ -2536,20 +2550,6 @@ public class WifiServiceImpl extends BaseWifiService {
private void registerForBroadcasts() {
IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(Intent.ACTION_USER_PRESENT);
- intentFilter.addAction(Intent.ACTION_USER_REMOVED);
- intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
- intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
- intentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
-
- boolean trackEmergencyCallState = mContext.getResources().getBoolean(
- R.bool.config_wifi_turn_off_during_emergency_call);
- if (trackEmergencyCallState) {
- intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED);
- }
- mContext.registerReceiver(mReceiver, intentFilter);
-
- intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
intentFilter.addDataScheme("package");
mContext.registerReceiver(new BroadcastReceiver() {
diff --git a/service/java/com/android/server/wifi/WrongPasswordNotifier.java b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
index 2ad7b2cba..e13029dbf 100644
--- a/service/java/com/android/server/wifi/WrongPasswordNotifier.java
+++ b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
@@ -87,7 +87,7 @@ public class WrongPasswordNotifier {
// TODO(zqiu): consider creating a new icon.
.setSmallIcon(android.R.drawable.stat_notify_wifi_in_range)
.setContentTitle(mContext.getString(
- com.android.wifi.R.string.wifi_available_title_failed_to_connect))
+ com.android.wifi.resources.R.string.wifi_available_title_failed_to_connect))
.setContentText(ssid)
.setContentIntent(mFrameworkFacade.getActivity(
mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT))
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareService.java b/service/java/com/android/server/wifi/aware/WifiAwareService.java
index f38c37316..f1aa0e4d4 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareService.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareService.java
@@ -22,6 +22,7 @@ import android.util.Log;
import com.android.server.SystemService;
import com.android.server.wifi.HalDeviceManager;
+import com.android.server.wifi.WifiContext;
import com.android.server.wifi.WifiInjector;
/**
@@ -32,9 +33,9 @@ public final class WifiAwareService extends SystemService {
private static final String TAG = "WifiAwareService";
final WifiAwareServiceImpl mImpl;
- public WifiAwareService(Context context) {
- super(context);
- mImpl = new WifiAwareServiceImpl(context);
+ public WifiAwareService(Context contextBase) {
+ super(new WifiContext(contextBase));
+ mImpl = new WifiAwareServiceImpl(getContext());
}
@Override
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
index f30e74005..fbfa50ce0 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
@@ -77,7 +77,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
private final SparseIntArray mUidByClientId = new SparseIntArray();
public WifiAwareServiceImpl(Context context) {
- mContext = context.getApplicationContext();
+ mContext = context;
mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
}
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pService.java b/service/java/com/android/server/wifi/p2p/WifiP2pService.java
index 6137c3cd9..2b536b0cd 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pService.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pService.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.util.Log;
import com.android.server.SystemService;
+import com.android.server.wifi.WifiContext;
import com.android.server.wifi.WifiInjector;
/**
@@ -32,9 +33,9 @@ public final class WifiP2pService extends SystemService {
private static final String TAG = "WifiP2pService";
final WifiP2pServiceImpl mImpl;
- public WifiP2pService(Context context) {
- super(context);
- mImpl = new WifiP2pServiceImpl(context, WifiInjector.getInstance());
+ public WifiP2pService(Context contextBase) {
+ super(new WifiContext(contextBase));
+ mImpl = new WifiP2pServiceImpl(getContext(), WifiInjector.getInstance());
}
@Override
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 8aea25aff..571444a47 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -95,7 +95,7 @@ import com.android.server.wifi.util.WifiAsyncChannel;
import com.android.server.wifi.util.WifiHandler;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -452,9 +452,6 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
mP2pSupported = mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_WIFI_DIRECT);
- mThisDevice.primaryDeviceType = mContext.getResources().getString(
- R.string.config_wifi_p2p_device_type);
-
HandlerThread wifiP2pThread = mWifiInjector.getWifiP2pServiceHandlerThread();
mClientHandler = new ClientHandler(TAG, wifiP2pThread.getLooper());
mP2pStateMachine = new P2pStateMachine(TAG, wifiP2pThread.getLooper(), mP2pSupported);
@@ -3716,6 +3713,9 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
private void initializeP2pSettings() {
mThisDevice.deviceName = getPersistedDeviceName();
+ mThisDevice.primaryDeviceType = mContext.getResources().getString(
+ R.string.config_wifi_p2p_device_type);
+
mWifiNative.setP2pDeviceName(mThisDevice.deviceName);
// DIRECT-XY-DEVICENAME (XY is randomly generated)
mWifiNative.setP2pSsidPostfix("-" + mThisDevice.deviceName);
diff --git a/service/java/com/android/server/wifi/rtt/RttService.java b/service/java/com/android/server/wifi/rtt/RttService.java
index 74370516e..ae4cdfe8b 100644
--- a/service/java/com/android/server/wifi/rtt/RttService.java
+++ b/service/java/com/android/server/wifi/rtt/RttService.java
@@ -24,6 +24,7 @@ import android.util.Log;
import com.android.server.SystemService;
import com.android.server.wifi.HalDeviceManager;
+import com.android.server.wifi.WifiContext;
import com.android.server.wifi.WifiInjector;
import com.android.server.wifi.util.WifiPermissionsUtil;
@@ -32,13 +33,11 @@ import com.android.server.wifi.util.WifiPermissionsUtil;
*/
public class RttService extends SystemService {
private static final String TAG = "RttService";
- private Context mContext;
private RttServiceImpl mImpl;
- public RttService(Context context) {
- super(context);
- mContext = context;
- mImpl = new RttServiceImpl(context);
+ public RttService(Context contextBase) {
+ super(new WifiContext(contextBase));
+ mImpl = new RttServiceImpl(getContext());
}
@Override
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningService.java b/service/java/com/android/server/wifi/scanner/WifiScanningService.java
index 8c0de0e8c..8ec0d15e2 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningService.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningService.java
@@ -22,6 +22,7 @@ import android.os.HandlerThread;
import android.util.Log;
import com.android.server.SystemService;
+import com.android.server.wifi.WifiContext;
import com.android.server.wifi.WifiInjector;
/**
@@ -34,14 +35,14 @@ public class WifiScanningService extends SystemService {
private final WifiScanningServiceImpl mImpl;
private final HandlerThread mHandlerThread;
- public WifiScanningService(Context context) {
- super(context);
+ public WifiScanningService(Context contextBase) {
+ super(new WifiContext(contextBase));
Log.i(TAG, "Creating " + Context.WIFI_SCANNING_SERVICE);
mHandlerThread = new HandlerThread("WifiScanningService");
mHandlerThread.start();
- mImpl = new WifiScanningServiceImpl(context, mHandlerThread.getLooper(),
+ mImpl = new WifiScanningServiceImpl(getContext(), mHandlerThread.getLooper(),
WifiScannerImpl.DEFAULT_FACTORY,
- context.getSystemService(BatteryStatsManager.class),
+ getContext().getSystemService(BatteryStatsManager.class),
WifiInjector.getInstance());
}
diff --git a/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java b/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java
index 9bf8ea489..287a3e144 100644
--- a/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java
@@ -32,7 +32,7 @@ import com.android.server.wifi.WifiNative;
import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection;
import com.android.server.wifi.util.NativeUtil;
import com.android.server.wifi.util.ScanResultUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -80,8 +80,6 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
// Settings for the currently running pno scan, null if no scan active
private LastPnoScanSettings mLastPnoScanSettings = null;
- private final boolean mHwPnoScanSupported;
-
/**
* Duration to wait before timing out a scan.
*
@@ -105,10 +103,6 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
mEventHandler = new Handler(looper, this);
mClock = clock;
- // Check if the device supports HW PNO scans.
- mHwPnoScanSupported = mContext.getResources().getBoolean(
- R.bool.config_wifi_background_scan_support);
-
wifiMonitor.registerHandler(getIfaceName(),
WifiMonitor.SCAN_FAILED_EVENT, mEventHandler);
wifiMonitor.registerHandler(getIfaceName(),
@@ -432,7 +426,8 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
* @return true if HW PNO scan is required, false otherwise.
*/
private boolean isHwPnoScanRequired(boolean isConnectedPno) {
- return (!isConnectedPno && mHwPnoScanSupported);
+ return (!isConnectedPno
+ && mContext.getResources().getBoolean(R.bool.config_wifi_background_scan_support));
}
@Override
diff --git a/service/java/com/android/server/wifi/util/RssiUtil.java b/service/java/com/android/server/wifi/util/RssiUtil.java
index a1a1d57c2..134970af5 100644
--- a/service/java/com/android/server/wifi/util/RssiUtil.java
+++ b/service/java/com/android/server/wifi/util/RssiUtil.java
@@ -18,7 +18,7 @@ package com.android.server.wifi.util;
import android.annotation.NonNull;
import android.content.Context;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
/** Utilities for computations involving RSSI. */
public class RssiUtil {
diff --git a/service/res/values/strings.xml b/service/res/values/strings.xml
index 4a39e9875..4cb06447f 100644
--- a/service/res/values/strings.xml
+++ b/service/res/values/strings.xml
@@ -16,7 +16,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Official label of the wifi stack -->
- <string name="wifiAppLabel" product="default">System Wi-Fi</string>
+ <string name="wifiResourcesAppLabel" product="default">System Wi-Fi Resources</string>
<!-- A notification is shown when there are open wireless networks nearby. This is the notification's title. -->
<plurals name="wifi_available">
<item quantity="one">Wi-Fi network available</item>
diff --git a/tests/wifitests/Android.bp b/tests/wifitests/Android.bp
index 2e3b28ecf..12b6fc3ff 100644
--- a/tests/wifitests/Android.bp
+++ b/tests/wifitests/Android.bp
@@ -15,11 +15,15 @@
// Make test APK
// ============================================================
android_test {
- // TODO(rpius): Rename once all google3 config files are changed
- // name: "WifiStackTests",
name: "FrameworksWifiTests",
- srcs: ["**/*.java"],
+ srcs: [
+ "**/*.java",
+ // wifi-service sources must be included here so that the latest changes
+ // will be used when tests. Otherwise the tests would run against the installed
+ // system.
+ ":wifi-service-srcs",
+ ],
// For coverage
jacoco: {
@@ -51,7 +55,6 @@ android_test {
"com.android.server.wifi.aware.WifiAwareStateManager",
"com.android.server.wifi.aware.WifiAwareStateManager.*",
"com.android.server.wifi.BaseWifiDiagnostics",
- "com.android.server.wifi.BootCompleteReceiver",
"com.android.server.wifi.BssidBlocklistMonitor",
"com.android.server.wifi.BssidBlocklistMonitor.*",
"com.android.server.wifi.BubbleFunScorer",
@@ -370,8 +373,6 @@ android_test {
"com.android.server.wifi.WifiSettingsStore",
"com.android.server.wifi.WifiShellCommand",
"com.android.server.wifi.WifiShellCommand.*",
- "com.android.server.wifi.WifiStackService",
- "com.android.server.wifi.WifiStackService.*",
"com.android.server.wifi.WifiStateTracker",
"com.android.server.wifi.WifiThreadRunner",
"com.android.server.wifi.WifiThreadRunner.*",
@@ -392,26 +393,55 @@ android_test {
java_version: "1.9",
- // wifi-service and services must be included here so that the latest changes
- // will be used when tests. Otherwise the tests would run against the installed
- // system.
- // TODO figure out if this is the correct thing to do, this seems to not be right
- // since neither is declared a static java library.
static_libs: [
"androidx.test.rules",
"hamcrest-library",
"mockito-target-extended-minus-junit4",
"frameworks-base-testutils",
- "services",
- "wifi-service",
- "truth-prebuilt",
+ "truth-prebuilt",
+
+ // Libraries needed by wifi-service
+ "android.hardware.wifi-V1.0-java",
+ "android.hardware.wifi-V1.1-java",
+ "android.hardware.wifi-V1.2-java",
+ "android.hardware.wifi-V1.3-java",
+ "android.hardware.wifi-V1.4-java",
+ "android.hardware.wifi.hostapd-V1.0-java",
+ "android.hardware.wifi.hostapd-V1.1-java",
+ "android.hardware.wifi.supplicant-V1.0-java",
+ "android.hardware.wifi.supplicant-V1.1-java",
+ "android.hardware.wifi.supplicant-V1.2-java",
+ "android.hardware.wifi.supplicant-V1.3-java",
+ "android.hidl.manager-V1.2-java",
+ "androidx.annotation_annotation",
+ "bouncycastle-unbundled",
+ "ksoap2",
+ // Note: libprotobuf-java-lite uses a few core platform APIs which
+ // does show up as @hide API usage. But, this can be safely ignored
+ // since the library uses reflection to ensure that the OS does provide
+ // the necessary core platform APIs.
+ "libprotobuf-java-lite",
+ "libnanohttpd",
+ "libwificond_aidl-java",
+ "services.net",
+ "services.core",
+ "wifi_proto_scorecard",
+ "wifi_proto_metrics",
],
+ jarjar_rules: ":wifi-service-jarjar-rules",
+
libs: [
"android.test.runner",
- "android.hidl.manager-V1.2-java",
"android.test.base",
"android.test.mock",
+
+ // Libraries needed by wifi-service
+ "error_prone_annotations",
+ "jsr305",
+ "services",
+ // load the resources from the resources APK.
+ "wifi-service-resources"
],
// These must be explicitly included because they are not normally accessible
@@ -432,8 +462,6 @@ android_test {
"libstaticjvmtiagent",
],
- jarjar_rules: ":wifi-jarjar-rules",
-
min_sdk_version: "29",
platform_apis: true,
privileged: true,
diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
index e681534ca..029e423f8 100644
--- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
@@ -58,7 +58,7 @@ import androidx.test.filters.SmallTest;
import com.android.server.wifi.util.GeneralUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 19ac38213..7946ecbc0 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -103,7 +103,7 @@ import com.android.server.wifi.util.RssiUtilTest;
import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
@@ -664,10 +664,6 @@ public class ClientModeImplTest extends WifiBaseTest {
assertEquals(WifiManager.WIFI_STATE_ENABLED, mCmi.syncGetWifiState());
assertEquals("enabled", mCmi.syncGetWifiStateByName());
- // reset the expectations on mContext since we did get an expected broadcast, but we should
- // not on the next transition
- reset(mContext);
-
// now disable wifi and verify the reported wifi state
mCmi.setWifiStateForApiCalls(WifiManager.WIFI_STATE_DISABLED);
mCmi.setOperationalMode(ClientModeImpl.DISABLED_MODE, null);
diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
index 900d3a7f3..ddce73be1 100644
--- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
@@ -33,7 +33,7 @@ import android.util.ArraySet;
import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
index 8a5d4deae..94f5eb77c 100644
--- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
@@ -39,7 +39,7 @@ import android.os.test.TestLooper;
import androidx.test.filters.SmallTest;
import com.android.server.wifi.util.NativeUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java
index 46b0ba067..74396a02e 100644
--- a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java
@@ -37,7 +37,7 @@ import android.provider.Settings;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
@@ -86,6 +86,10 @@ public class LinkProbeManagerTest extends WifiBaseTest {
mTimeMs = 1000;
when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs);
+ // Simulate new connection to trigger check for isSupported resource flag.
+ mLinkProbeManager.resetOnNewConnection();
+ mLinkProbeManager.resetOnScreenTurnedOn();
+
ArgumentCaptor<ContentObserver> observerCaptor = ArgumentCaptor.forClass(
ContentObserver.class);
verify(mFrameworkFacade).registerContentObserver(eq(mContext),
diff --git a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
index f6db3dd3f..ce9c596d4 100644
--- a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
@@ -34,7 +34,7 @@ import android.telephony.TelephonyManager;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
@@ -123,6 +123,8 @@ public class SarManagerTest extends WifiBaseTest {
mSarMgr = new SarManager(mContext, mTelephonyManager, mLooper.getLooper(),
mWifiNative);
+ mSarMgr.handleBootCompleted();
+
if (isSarEnabled) {
/* Capture the PhoneStateListener */
ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor =
diff --git a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java
index 3a76eda50..90420b889 100644
--- a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java
@@ -33,7 +33,7 @@ import android.util.LocalLog;
import com.android.server.wifi.WifiNetworkSelector.NetworkEvaluator.OnConnectableListener;
import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs;
import com.android.server.wifi.util.TelephonyUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
index 3fefb443c..41900f3fa 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
@@ -35,7 +35,7 @@ import android.provider.Settings;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 68c0cf866..27ed5be10 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -67,7 +67,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.util.WakeupMessage;
import com.android.server.wifi.wificond.IApInterfaceEventCallback;
import com.android.server.wifi.wificond.NativeWifiClient;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
index a9436e7e1..f7a5a4c2b 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
@@ -47,7 +47,7 @@ import android.text.TextUtils;
import androidx.test.filters.SmallTest;
import com.android.server.wifi.util.NativeUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java
index 08119e59b..35ace4eac 100644
--- a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java
@@ -30,7 +30,7 @@ import android.net.wifi.ScanResult;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java
index 214e80947..ad890ebb7 100644
--- a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java
@@ -26,7 +26,7 @@ import android.net.wifi.WifiInfo;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
index 851289c0d..ba3fbeeff 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
@@ -40,7 +40,7 @@ import android.os.test.TestLooper;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 0e4d049de..147b2a0d8 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -54,7 +54,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index 96e5b5d22..c1445c158 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -51,7 +51,7 @@ import android.util.LocalLog;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
index 3a2583bdb..6fb035462 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java
@@ -33,6 +33,8 @@ import android.telephony.TelephonyManager;
import androidx.test.filters.SmallTest;
+import com.android.wifi.resources.R;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -54,6 +56,7 @@ public class WifiCountryCodeTest extends WifiBaseTest {
private String mTelephonyCountryCode = "JP";
private boolean mRevertCountryCodeOnCellularLoss = true;
@Mock Context mContext;
+ MockResources mResources = new MockResources();
@Mock TelephonyManager mTelephonyManager;
@Mock Handler mHandler;
@Mock WifiNative mWifiNative;
@@ -76,12 +79,14 @@ public class WifiCountryCodeTest extends WifiBaseTest {
}
private void createWifiCountryCode() {
+ mResources.setBoolean(R.bool.config_wifi_revert_country_code_on_cellular_loss,
+ mRevertCountryCodeOnCellularLoss);
+ when(mContext.getResources()).thenReturn(mResources);
mWifiCountryCode = new WifiCountryCode(
mContext,
mHandler,
mWifiNative,
- mDefaultCountryCode,
- mRevertCountryCodeOnCellularLoss);
+ mDefaultCountryCode);
verify(mContext, atLeastOnce()).registerReceiver(
mBroadcastReceiverCaptor.capture(), any(), any(), any());
}
@@ -247,12 +252,8 @@ public class WifiCountryCodeTest extends WifiBaseTest {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- mWifiCountryCode = new WifiCountryCode(
- mContext,
- mHandler,
- mWifiNative,
- null,
- false /* config_wifi_revert_country_code_on_cellular_loss */);
+ mRevertCountryCodeOnCellularLoss = false;
+ createWifiCountryCode();
mWifiCountryCode.dump(null, pw, null);
String dumpCountryCodeStr = sw.toString();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index 82b62afef..27990e738 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -41,7 +41,7 @@ import android.os.UserHandle;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Ignore;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
index fc85b4d6e..282393f1d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
@@ -31,7 +31,7 @@ import android.util.Pair;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java
index 2d6bb5a3c..608c76e13 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java
@@ -18,6 +18,9 @@ package com.android.server.wifi;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import android.content.Context;
import androidx.test.filters.SmallTest;
@@ -41,7 +44,7 @@ public class WifiLinkLayerStatsTest extends WifiBaseTest {
*/
@Before
public void setUp() throws Exception {
- mWifiInfo = new ExtendedWifiInfo();
+ mWifiInfo = new ExtendedWifiInfo(mock(Context.class));
mWifiLinkLayerStats = new WifiLinkLayerStats();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index b55735f8e..4ee6c79a4 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -103,6 +103,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStatsEnt
import com.android.server.wifi.proto.nano.WifiMetricsProto.WpsMetrics;
import com.android.server.wifi.rtt.RttMetrics;
import com.android.server.wifi.util.ExternalCallbackTracker;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
@@ -137,6 +138,7 @@ public class WifiMetricsTest extends WifiBaseTest {
private static final int TEST_WIFI_USABILITY_STATS_LISTENER_IDENTIFIER = 2;
private static final int TEST_NETWORK_ID = 42;
@Mock Context mContext;
+ MockResources mResources;
@Mock FrameworkFacade mFacade;
@Mock Clock mClock;
@Mock ScoringParams mScoringParams;
@@ -157,6 +159,8 @@ public class WifiMetricsTest extends WifiBaseTest {
mDecodedProto = null;
when(mClock.getElapsedSinceBootMillis()).thenReturn((long) 0);
mTestLooper = new TestLooper();
+ mResources = new MockResources();
+ when(mContext.getResources()).thenReturn(mResources);
mWifiMetrics = new WifiMetrics(mContext, mFacade, mClock, mTestLooper.getLooper(),
new WifiAwareMetrics(mClock), new RttMetrics(mClock), mWifiPowerMetrics,
mWifiP2pMetrics, mDppMetrics);
@@ -863,7 +867,8 @@ public class WifiMetricsTest extends WifiBaseTest {
}
mWifiMetrics.setWatchdogSuccessTimeDurationMs(NUM_WATCHDOG_SUCCESS_DURATION_MS);
- mWifiMetrics.setIsMacRandomizationOn(IS_MAC_RANDOMIZATION_ON);
+ mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported,
+ IS_MAC_RANDOMIZATION_ON);
addWifiPowerMetrics();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
index 77d4cdeb7..d1860c947 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
@@ -41,7 +41,7 @@ import androidx.test.filters.SmallTest;
import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs;
import com.android.server.wifi.proto.nano.WifiMetricsProto;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 6dc87aaf7..b50cf27ea 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -64,7 +64,7 @@ import com.android.server.wifi.WifiNetworkSuggestionsManager.PerAppInfo;
import com.android.server.wifi.hotspot2.PasspointManager;
import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
index 135a71ee2..128bdc15d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
@@ -21,6 +21,7 @@ import static com.android.server.wifi.util.NativeUtil.hexStringFromByteArray;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import android.content.Context;
import android.net.MacAddress;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiSsid;
@@ -51,7 +52,7 @@ import java.util.Arrays;
public class WifiScoreCardTest extends WifiBaseTest {
static final WifiSsid TEST_SSID_1 = WifiSsid.createFromAsciiEncoded("Joe's Place");
- static final WifiSsid TEST_SSID_2 = WifiSsid.createFromAsciiEncoded("Poe's Raven");
+ static final WifiSsid TEST_SSID_2 = WifiSsid.createFromAsciiEncoded("Poe's Ravn");
static final MacAddress TEST_BSSID_1 = MacAddress.fromString("aa:bb:cc:dd:ee:ff");
static final MacAddress TEST_BSSID_2 = MacAddress.fromString("1:2:3:4:5:6");
@@ -96,7 +97,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
mBlobListeners.clear();
mBlobs.clear();
mMilliSecondsSinceBoot = 0;
- mWifiInfo = new ExtendedWifiInfo();
+ mWifiInfo = new ExtendedWifiInfo(mock(Context.class));
mWifiInfo.setSSID(TEST_SSID_1);
mWifiInfo.setBSSID(TEST_BSSID_1.toString());
mWifiInfo.setNetworkId(TEST_NETWORK_CONFIG_ID);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
index c85b9f49c..73af4ae5e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
@@ -38,7 +38,7 @@ import android.net.wifi.WifiInfo;
import androidx.test.filters.SmallTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 4bf695d77..6282abed1 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -143,6 +143,7 @@ import com.android.server.wifi.hotspot2.PasspointProvisioningTestUtil;
import com.android.server.wifi.util.WifiAsyncChannel;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
@@ -1668,7 +1669,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testStartLocalOnlyHotspotAt5Ghz() {
when(mResources.getBoolean(
- eq(com.android.wifi.R.bool.config_wifi_local_only_hotspot_5ghz)))
+ eq(R.bool.config_wifi_local_only_hotspot_5ghz)))
.thenReturn(true);
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)).thenReturn(true);
when(mClientModeImpl.syncGetSupportedFeatures(any(AsyncChannel.class)))
@@ -3030,16 +3031,22 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testHandleDelayedScanAfterIdleMode() throws Exception {
when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false);
+ when(mWifiInjector.getPasspointProvisionerHandlerThread())
+ .thenReturn(mock(HandlerThread.class));
mWifiServiceImpl.checkAndStartWifi();
+ mWifiServiceImpl.handleBootCompleted();
verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
(IntentFilter) argThat(new IdleModeIntentMatcher()));
// Tell the wifi service that the device became idle.
when(mPowerManager.isDeviceIdleMode()).thenReturn(true);
TestUtil.sendIdleModeChanged(mBroadcastReceiverCaptor.getValue(), mContext);
+ mLooper.dispatchAll();
// Send a scan request while the device is idle.
+ mLooper.startAutoDispatch();
assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID));
+ mLooper.stopAutoDispatchAndIgnoreExceptions();
// No scans must be made yet as the device is idle.
verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME);
@@ -3184,7 +3191,10 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testUserRemovedBroadcastHandling() {
+ when(mWifiInjector.getPasspointProvisionerHandlerThread())
+ .thenReturn(mock(HandlerThread.class));
mWifiServiceImpl.checkAndStartWifi();
+ mWifiServiceImpl.handleBootCompleted();
verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
argThat((IntentFilter filter) ->
filter.hasAction(Intent.ACTION_USER_REMOVED)));
@@ -3201,7 +3211,10 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testUserRemovedBroadcastHandlingWithWrongIntentAction() {
+ when(mWifiInjector.getPasspointProvisionerHandlerThread())
+ .thenReturn(mock(HandlerThread.class));
mWifiServiceImpl.checkAndStartWifi();
+ mWifiServiceImpl.handleBootCompleted();
verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
argThat((IntentFilter filter) ->
filter.hasAction(Intent.ACTION_USER_REMOVED)));
@@ -3222,7 +3235,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testNeeds5GHzToAnyApBandConversionReturnedTrue() {
when(mResources.getBoolean(
- eq(com.android.wifi.R.bool.config_wifi_convert_apband_5ghz_to_any)))
+ eq(R.bool.config_wifi_convert_apband_5ghz_to_any)))
.thenReturn(true);
assertTrue(mWifiServiceImpl.needs5GHzToAnyApBandConversion());
@@ -3237,7 +3250,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
@Test
public void testNeeds5GHzToAnyApBandConversionReturnedFalse() {
when(mResources.getBoolean(
- eq(com.android.wifi.R.bool.config_wifi_convert_apband_5ghz_to_any)))
+ eq(R.bool.config_wifi_convert_apband_5ghz_to_any)))
.thenReturn(false);
assertFalse(mWifiServiceImpl.needs5GHzToAnyApBandConversion());
@@ -4123,7 +4136,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
private void setupMaxApInterfaces(int val) {
when(mResources.getInteger(
- eq(com.android.wifi.R.integer.config_wifi_max_ap_interfaces)))
+ eq(R.integer.config_wifi_max_ap_interfaces)))
.thenReturn(val);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
index 9bd99953d..57c5d8aee 100644
--- a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
@@ -83,7 +83,7 @@ import com.android.server.wifi.WifiInjector;
import com.android.server.wifi.proto.nano.WifiMetricsProto.P2pConnectionEvent;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
index ad66e55ab..e15fa2bb1 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
@@ -38,7 +38,7 @@ import com.android.server.wifi.WifiBaseTest;
import com.android.server.wifi.WifiMonitor;
import com.android.server.wifi.WifiNative;
import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java
index cebf83766..d87d94c56 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java
@@ -34,7 +34,7 @@ import android.os.Looper;
import androidx.test.filters.SmallTest;
import com.android.server.wifi.WifiBaseTest;
-import com.android.wifi.R;
+import com.android.wifi.resources.R;
import org.junit.Before;
import org.junit.Test;