summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-08-10 09:29:47 -0700
committerKai Shi <kaishi@google.com>2020-09-08 20:43:42 +0000
commite1af31c338db20727c554349e0344761dd2d4438 (patch)
treec8e8016cd3a84b7fd46aa5c47a02f45d8a03e265 /service
parenta0d01b665d79abaeabcbddba79c46d7d3b10e168 (diff)
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
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiHealthMonitor.java12
1 files changed, 9 insertions, 3 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);
}