Is this a bug of Wifi background scan?

61 views
Skip to first unread message

yf...@mobvoi.com

unread,
Feb 22, 2017, 11:43:43 AM2/22/17
to android-platform
Acording to the source code, there's two kinds of background scan mode, one is supported by hardware, one is implemented by software. My device do not support hardware scan, but do not perform software scan either. I checked the code and find out this:


    private void setScanAlarm(boolean enabled) {
        if (PDBG) {
            loge("setScanAlarm " + enabled
                    + " period " + mDefaultFrameworkScanIntervalMs
                    + " mBackgroundScanSupported " + mBackgroundScanSupported);
        }
        if (mBackgroundScanSupported == false) {
            // Scan alarm is only used for background scans if they are not
            // offloaded to the wifi chipset, hence enable the scan alarm
            // gicing us RTC_WAKEUP of backgroundScan is NOT supported
            enabled = true;
        }

        if (enabled == mAlarmEnabled) return;
        if (enabled) {
            /* Set RTC_WAKEUP alarms if PNO is not supported - because no one is */
            /* going to wake up the host processor to look for access points */
            mAlarmManager.set(AlarmManager.RTC_WAKEUP,
                    System.currentTimeMillis() + mDefaultFrameworkScanIntervalMs,
                    mScanIntent);
            mAlarmEnabled = true;
        } else {
            mAlarmManager.cancel(mScanIntent);
            mAlarmEnabled = false;
        }
    }

this code is in WifiStateMachine, since there's no hardware scan funcion in my device, the mBackgroundScanSupported is false (I'v checked this), so no matter what the "enabled" parameter is, it will be set to true, and no matter what mAlarmEnabled is ,it will set to true too.
This makes setScanAlarm method only set alarm once, and after this ,no matter who called this method, will return and do nothing.

I'v noticed mDefaultFrameworkScanIntervalMs, which get expland by google:
    /**
     * Default framework scan interval in milliseconds. This is used in the scenario in which
     * wifi chipset does not support background scanning to set up a
     * periodic wake up scan so that the device can connect to a new access
     * point on the move. {@link Settings.Global#WIFI_FRAMEWORK_SCAN_INTERVAL_MS} can
     * override this.
     */
neither the alarm will be set second time nor  it use AlarmManager.setRepet, how could this scan act as "period"?

I'v checked multi-times, this alarm will only be triggered once when system is boot completed. So is this a bug or my understanding is wrong?
Reply all
Reply to author
Forward
0 new messages