diff options
6 files changed, 30 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/WifiHealthMonitor.java b/service/java/com/android/server/wifi/WifiHealthMonitor.java index 27167dccf..8ab3a74a6 100644 --- a/service/java/com/android/server/wifi/WifiHealthMonitor.java +++ b/service/java/com/android/server/wifi/WifiHealthMonitor.java @@ -326,6 +326,15 @@ public class WifiHealthMonitor { pw.println("WifiHealthMonitor - Log End ----"); } + /** + * Get current wifi mainline module long version code + * @Return a non-zero value if version code is available, 0 otherwise. + */ + public long getWifiStackVersion() { + WifiSoftwareBuildInfo currentBuild = getWifiSystemInfoStats().getCurrSoftwareBuildInfo(); + return (currentBuild == null) ? 0 : currentBuild.getWifiStackVersion(); + } + private synchronized void dailyDetectionHandler() { logd("Run daily detection"); // Clear daily detection result @@ -533,12 +542,12 @@ public class WifiHealthMonitor { return null; } PackageManager packageManager = mContext.getPackageManager(); - int wifiStackVersion = 0; + long wifiStackVersion = 0; try { wifiStackVersion = packageManager.getPackageInfo( - WIFI_APK_PACKAGE_NAME, PackageManager.MATCH_APEX).versionCode; + WIFI_APK_PACKAGE_NAME, PackageManager.MATCH_APEX).getLongVersionCode(); } catch (PackageManager.NameNotFoundException e) { - Log.e(TAG, " hit PackageManager nameNotFoundException"); + Log.e(TAG, " Hit PackageManager exception", e); } String osBuildVersion = replaceNullByEmptyString(Build.DISPLAY); if (mWifiNative == null) { @@ -629,10 +638,10 @@ public class WifiHealthMonitor { */ final class WifiSoftwareBuildInfo { private String mOsBuildVersion; - private int mWifiStackVersion; + private long mWifiStackVersion; private String mWifiDriverVersion; private String mWifiFirmwareVersion; - WifiSoftwareBuildInfo(@NonNull String osBuildVersion, int wifiStackVersion, + WifiSoftwareBuildInfo(@NonNull String osBuildVersion, long wifiStackVersion, @NonNull String wifiDriverVersion, @NonNull String wifiFirmwareVersion) { mOsBuildVersion = osBuildVersion; mWifiStackVersion = wifiStackVersion; @@ -648,7 +657,7 @@ public class WifiHealthMonitor { String getOsBuildVersion() { return mOsBuildVersion; } - int getWifiStackVersion() { + long getWifiStackVersion() { return mWifiStackVersion; } String getWifiDriverVersion() { @@ -842,7 +851,7 @@ public class WifiHealthMonitor { @NonNull SoftwareBuildInfo softwareBuildInfo) { String osBuildVersion = softwareBuildInfo.hasOsBuildVersion() ? softwareBuildInfo.getOsBuildVersion() : "NA"; - int stackVersion = softwareBuildInfo.hasWifiStackVersion() + long stackVersion = softwareBuildInfo.hasWifiStackVersion() ? softwareBuildInfo.getWifiStackVersion() : 0; String driverVersion = softwareBuildInfo.hasWifiDriverVersion() ? softwareBuildInfo.getWifiDriverVersion() : "NA"; diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index dbd532541..e23779e85 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -4359,8 +4359,9 @@ public class WifiMetrics { initialPartialScanStats.failedScanChannelCountHistogram = mInitPartialScanFailureHistogram.toProto(); mWifiLogProto.initPartialScanStats = initialPartialScanStats; - mWifiLogProto.carrierWifiMetrics = mCarrierWifiMetrics.toProto(); + mWifiLogProto.mainlineModuleVersion = mWifiHealthMonitor.getWifiStackVersion(); + } } diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index eaea7342b..349543d59 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -712,6 +712,9 @@ message WifiLog { // Metrics about carrier wifi network. optional CarrierWifiMetrics carrier_wifi_metrics = 200; + + // Long version code of wifi mainline module, 0 means not available. + optional int64 mainline_module_version = 201; } // Information that gets logged for every WiFi connection. diff --git a/service/proto/src/scorecard.proto b/service/proto/src/scorecard.proto index ad5822c72..d351c5666 100644 --- a/service/proto/src/scorecard.proto +++ b/service/proto/src/scorecard.proto @@ -146,7 +146,7 @@ message SoftwareBuildInfo { // Android OS build version optional string os_build_version = 1; // WiFi stack APK version, 0 means not available. - optional int32 wifi_stack_version = 2; + optional int64 wifi_stack_version = 2; // WiFi driver version optional string wifi_driver_version = 3; // WiFi firmware version diff --git a/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java index 4e0b5b75e..264fe9048 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiHealthMonitorTest.java @@ -110,6 +110,7 @@ public class WifiHealthMonitorTest extends WifiBaseTest { private WifiConfiguration mWifiConfig; private String mDriverVersion; private String mFirmwareVersion; + private static final long MODULE_VERSION = 1L; private TestAlarmManager mAlarmManager; private TestLooper mLooper = new TestLooper(); private List<WifiConfiguration> mConfiguredNetworks; @@ -152,7 +153,7 @@ public class WifiHealthMonitorTest extends WifiBaseTest { mDriverVersion = "build 1.1"; mFirmwareVersion = "HW 1.1"; - mPackageInfo.versionCode = 1; + when(mPackageInfo.getLongVersionCode()).thenReturn(MODULE_VERSION); when(mContext.getPackageName()).thenReturn("WifiAPK"); when(mPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mPackageInfo); when(mContext.getPackageManager()).thenReturn(mPackageManager); @@ -310,6 +311,7 @@ public class WifiHealthMonitorTest extends WifiBaseTest { // trigger extractCurrentSoftwareBuildInfo() call to update currSoftwareBuildInfo mWifiHealthMonitor.installMemoryStoreSetUpDetectionAlarm(mMemoryStore); mWifiHealthMonitor.setWifiEnabled(true); + assertEquals(0, mWifiHealthMonitor.getWifiStackVersion()); millisecondsPass(5000); mWifiScanner.startScan(mScanSettings, mScanListener); mAlarmManager.dispatch(WifiHealthMonitor.POST_BOOT_DETECTION_TIMER_TAG); @@ -365,6 +367,7 @@ public class WifiHealthMonitorTest extends WifiBaseTest { .getWifiFirmwareVersion()); assertEquals(mFirmwareVersion, wifiSystemInfoStats.getPrevSoftwareBuildInfo() .getWifiFirmwareVersion()); + assertEquals(MODULE_VERSION, mWifiHealthMonitor.getWifiStackVersion()); // Check write String writtenHex = hexStringFromByteArray(mBlobs.get(mKeys.size() - 1)); @@ -395,8 +398,7 @@ public class WifiHealthMonitorTest extends WifiBaseTest { SystemInfoStats systemInfoStats = SystemInfoStats.parseFrom(serialized); WifiSoftwareBuildInfo currSoftwareBuildInfoFromMemory = wifiSystemInfoStats .fromSoftwareBuildInfo(systemInfoStats.getCurrSoftwareBuildInfo()); - assertEquals(mPackageInfo.versionCode, - currSoftwareBuildInfoFromMemory.getWifiStackVersion()); + assertEquals(MODULE_VERSION, currSoftwareBuildInfoFromMemory.getWifiStackVersion()); assertEquals(mDriverVersion, currSoftwareBuildInfoFromMemory.getWifiDriverVersion()); assertEquals(mFirmwareVersion, currSoftwareBuildInfoFromMemory.getWifiFirmwareVersion()); assertEquals(Build.DISPLAY, currSoftwareBuildInfoFromMemory.getOsBuildVersion()); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index fcaee0550..ca5ae268d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -441,6 +441,7 @@ public class WifiMetricsTest extends WifiBaseTest { private static final int NUM_NETWORK_SUFFICIENT_RECENT_STATS_ONLY = 4; private static final int NUM_NETWORK_SUFFICIENT_RECENT_PREV_STATS = 5; private static final int NUM_BSSID_SELECTION_DIFFERENT_BETWEEN_FRAMEWORK_FIRMWARE = 3; + private static final long WIFI_MAINLINE_MODULE_VERSION = 123456L; /** Number of notifications per "Connect to Network" notification type. */ private static final int[] NUM_CONNECT_TO_NETWORK_NOTIFICATIONS = {0, 10, 20, 30, 40}; @@ -1010,6 +1011,7 @@ public class WifiMetricsTest extends WifiBaseTest { metrics.numNetworkSufficientRecentStatsOnly = NUM_NETWORK_SUFFICIENT_RECENT_STATS_ONLY; metrics.numNetworkSufficientRecentPrevStats = NUM_NETWORK_SUFFICIENT_RECENT_PREV_STATS; when(mWifiHealthMonitor.buildProto()).thenReturn(metrics); + when(mWifiHealthMonitor.getWifiStackVersion()).thenReturn(WIFI_MAINLINE_MODULE_VERSION); } private void addSoftApEventsToMetrics() { @@ -1412,6 +1414,7 @@ public class WifiMetricsTest extends WifiBaseTest { mDecodedProto.numConnectRequestWithFilsAkm); assertEquals(NUM_L2_CONNECTION_THROUGH_FILS_AUTHENTICATION, mDecodedProto.numL2ConnectionThroughFilsAuthentication); + assertEquals(WIFI_MAINLINE_MODULE_VERSION, mDecodedProto.mainlineModuleVersion); } |