summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiHealthMonitor.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java6
2 files changed, 14 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiHealthMonitor.java b/service/java/com/android/server/wifi/WifiHealthMonitor.java
index bc1f9af01..7b68ffce8 100644
--- a/service/java/com/android/server/wifi/WifiHealthMonitor.java
+++ b/service/java/com/android/server/wifi/WifiHealthMonitor.java
@@ -24,6 +24,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.app.AlarmManager;
import android.content.Context;
+import android.content.pm.ModuleInfo;
import android.content.pm.PackageManager;
import android.net.MacAddress;
import android.net.wifi.ScanResult;
@@ -76,7 +77,7 @@ public class WifiHealthMonitor {
"WifiHealthMonitor Schedule Post-Boot Detection Timer";
// Package name of WiFi mainline module found from the following adb command
// adb shell pm list packages --apex-only| grep wifi
- private static final String WIFI_APK_PACKAGE_NAME = "com.google.android.wifi";
+ private static final String WIFI_APEX_NAME = "com.android.wifi";
private static final String SYSTEM_INFO_DATA_NAME = "systemInfoData";
// The time that device waits after device boot before triggering post-boot detection.
// This needs be long enough so that memory read can complete before post-boot detection.
@@ -542,8 +543,13 @@ public class WifiHealthMonitor {
PackageManager packageManager = mContext.getPackageManager();
long wifiStackVersion = 0;
try {
- wifiStackVersion = packageManager.getPackageInfo(
- WIFI_APK_PACKAGE_NAME, PackageManager.MATCH_APEX).getLongVersionCode();
+ ModuleInfo wifiModule = packageManager.getModuleInfo(
+ WIFI_APEX_NAME, PackageManager.MODULE_APEX_NAME);
+ String wifiPackageName = wifiModule.getPackageName();
+ if (wifiPackageName != null) {
+ wifiStackVersion = packageManager.getPackageInfo(
+ wifiPackageName, PackageManager.MATCH_APEX).getLongVersionCode();
+ }
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, " Hit PackageManager exception", e);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java
index 21a00f9a1..1f524994a 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.when;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
import android.app.test.TestAlarmManager;
import android.content.Context;
+import android.content.pm.ModuleInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.MacAddress;
@@ -98,6 +99,8 @@ public class WifiHealthMonitorTest extends WifiBaseTest {
PackageManager mPackageManager;
@Mock
PackageInfo mPackageInfo;
+ @Mock
+ ModuleInfo mModuleInfo;
private final ArrayList<String> mKeys = new ArrayList<>();
private final ArrayList<WifiScoreCard.BlobListener> mBlobListeners = new ArrayList<>();
@@ -154,8 +157,9 @@ public class WifiHealthMonitorTest extends WifiBaseTest {
mDriverVersion = "build 1.1";
mFirmwareVersion = "HW 1.1";
when(mPackageInfo.getLongVersionCode()).thenReturn(MODULE_VERSION);
- when(mContext.getPackageName()).thenReturn("WifiAPK");
when(mPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mPackageInfo);
+ when(mPackageManager.getModuleInfo(anyString(), anyInt())).thenReturn(mModuleInfo);
+ when(mModuleInfo.getPackageName()).thenReturn("WifiAPK");
when(mContext.getPackageManager()).thenReturn(mPackageManager);
mWifiConfigManager = mockConfigManager();