Fix EapFailureNotifier failing to resolve resource name dynamically

Resources#getIdentifier uses the Java package name rather than
the Android APK's package name i.e. the package name generated
for R.java at compile time.

Bug: 160569695
Test: manually verified notification is displayed
Test: atest FrameworksWifiTests
Change-Id: I4c9a17c86e23956478a927021fb1b7ade3b86379
diff --git a/service/java/com/android/server/wifi/EapFailureNotifier.java b/service/java/com/android/server/wifi/EapFailureNotifier.java
index fe4cfbd..cdb1203 100644
--- a/service/java/com/android/server/wifi/EapFailureNotifier.java
+++ b/service/java/com/android/server/wifi/EapFailureNotifier.java
@@ -75,8 +75,16 @@
         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 b360a8e..bbcb9d8 100644
--- a/service/java/com/android/server/wifi/WifiContext.java
+++ b/service/java/com/android/server/wifi/WifiContext.java
@@ -40,6 +40,7 @@
     /** 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 @@
         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/EapFailureNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
index f2ec351..d2a3ac0 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 @@
         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);
     }