From e1af31c338db20727c554349e0344761dd2d4438 Mon Sep 17 00:00:00 2001 From: Kai Shi Date: Mon, 10 Aug 2020 09:29:47 -0700 Subject: wifi:get wifi stack version from com.android.wifi Use getModuleInfo() with the MODULE_APEX_NAME of "com.android.wifi" to derive wifi stack version so that the devices without taking WiFi mainline module won't hit NameNotFoundException. Bug: 163158561 Test: atest com.android.server.wifi Test: manual check to ensure device with the mainline module doesn't hit the exception Change-Id: Id3d191b0dfb324aea6b226755e611cb8f13e801b Merged-In: Id3d191b0dfb324aea6b226755e611cb8f13e801b --- .../src/com/android/server/wifi/WifiHealthMonitorTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests') 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 mKeys = new ArrayList<>(); private final ArrayList 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(); -- cgit v1.2.3