summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-11 01:05:49 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-11 01:05:49 +0000
commit246b3191fbf835c93a324569b145ebff2b904a5a (patch)
tree621e976e278c1d50b0b36187146c0ddeb51a4942
parentaef6097a54e95ac97efe99c16db8e74e784e9196 (diff)
parent000ad45722c73f345de77ff43973b2ed811b90e1 (diff)
Snap for 6671561 from 000ad45722c73f345de77ff43973b2ed811b90e1 to rvc-release
Change-Id: Ie0ef0a18d501011e864efa458f0955492eb02a95
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java3
-rw-r--r--service/java/com/android/server/wifi/EapFailureNotifier.java12
-rw-r--r--service/java/com/android/server/wifi/WifiContext.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java14
-rw-r--r--tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java3
5 files changed, 41 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 678defbf2..6c31185da 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -1109,6 +1109,9 @@ public class ClientModeImpl extends StateMachine {
@Override
public void onNetworkUpdated(WifiConfiguration newConfig, WifiConfiguration oldConfig) {
+ // Clear invalid cached data.
+ mWifiNative.removeNetworkCachedData(oldConfig.networkId);
+
// Check if user/app change meteredOverride for connected network.
if (newConfig.networkId != mLastNetworkId
|| newConfig.meteredOverride == oldConfig.meteredOverride) {
diff --git a/service/java/com/android/server/wifi/EapFailureNotifier.java b/service/java/com/android/server/wifi/EapFailureNotifier.java
index fe4cfbd66..cdb120321 100644
--- a/service/java/com/android/server/wifi/EapFailureNotifier.java
+++ b/service/java/com/android/server/wifi/EapFailureNotifier.java
@@ -75,8 +75,16 @@ public class EapFailureNotifier {
Resources res = getResourcesForSubId(mContext,
mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
if (res == null) return;
- int resourceId = res.getIdentifier(ERROR_MESSAGE_OVERLAY_PREFIX + errorCode,
- "string", mContext.getWifiOverlayApkPkgName());
+ int resourceId = res.getIdentifier(
+ ERROR_MESSAGE_OVERLAY_PREFIX + errorCode,
+ "string",
+ // getIdentifier seems to use the Java package name rather than the Android
+ // application package name. i.e. what you would have used if the resource name was
+ // statically known:
+ // import com.android.wifi.resources.R;
+ // ...
+ // R.string.wifi_eap_error_message_code_###
+ mContext.getWifiOverlayJavaPkgName());
if (resourceId == 0) return;
String errorMessage = res.getString(resourceId, config.SSID);
diff --git a/service/java/com/android/server/wifi/WifiContext.java b/service/java/com/android/server/wifi/WifiContext.java
index b360a8e3c..bbcb9d8a7 100644
--- a/service/java/com/android/server/wifi/WifiContext.java
+++ b/service/java/com/android/server/wifi/WifiContext.java
@@ -40,6 +40,7 @@ public class WifiContext extends ContextWrapper {
/** Intent action that is used to identify ServiceWifiResources.apk */
private static final String ACTION_RESOURCES_APK =
"com.android.server.wifi.intent.action.SERVICE_WIFI_RESOURCES_APK";
+ private static final String WIFI_OVERLAY_JAVA_PKG_NAME = "com.android.wifi.resources";
private String mWifiOverlayApkPkgName;
@@ -52,7 +53,17 @@ public class WifiContext extends ContextWrapper {
super(contextBase);
}
- /** Get the package name of ServiceWifiResources.apk */
+ /**
+ * Get the Java package name of the resources in ServiceWifiResources.apk
+ *
+ * i.e. the package name of the Wifi Resources R class:
+ * {@code import com.android.wifi.resources.R;}, which is "com.android.wifi.resources"
+ */
+ public String getWifiOverlayJavaPkgName() {
+ return WIFI_OVERLAY_JAVA_PKG_NAME;
+ }
+
+ /** Get the Android application package name of ServiceWifiResources.apk */
public String getWifiOverlayApkPkgName() {
if (mWifiOverlayApkPkgName != null) {
return mWifiOverlayApkPkgName;
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 11ee5cd7c..23726786d 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -5237,6 +5237,20 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWifiNative, never()).removeNetworkCachedData(anyInt());
}
+ /**
+ * Verify that network cached data is cleared on updating a network.
+ */
+ @Test
+ public void testNetworkCachedDataIsClearedOnUpdatingNetwork() throws Exception {
+ WifiConfiguration oldConfig = new WifiConfiguration(mConnectedNetwork);
+ mConnectedNetwork.meteredOverride = METERED_OVERRIDE_METERED;
+
+ mConfigUpdateListenerCaptor.getValue().onNetworkUpdated(mConnectedNetwork, oldConfig);
+ mLooper.dispatchAll();
+ verify(mWifiNative).removeNetworkCachedData(eq(oldConfig.networkId));
+ }
+
+
@Test
public void testIpReachabilityLostAndRoamEventsRace() throws Exception {
connect();
diff --git a/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
index f2ec351ae..d2a3ac0dc 100644
--- a/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
@@ -89,7 +89,8 @@ public class EapFailureNotifierTest extends WifiBaseTest {
when(mResources.getString(eq(0), anyString())).thenReturn(null);
when(mResources.getString(eq(1), anyString())).thenReturn("Error Message");
when(mContext.createPackageContext(anyString(), eq(0))).thenReturn(mContext);
- when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.oem.android.wifi.resources");
+ when(mContext.getWifiOverlayJavaPkgName()).thenReturn("test.com.android.wifi.resources");
mEapFailureNotifier =
new EapFailureNotifier(mContext, mFrameworkFacade, mWifiCarrierInfoManager);
}