DO NOT MERGE: Keep access point list updated once in short time

The function onAccessPointsChanged will be called many times
and access points will be updated many times in 300ms. So check
if the same event exists before calling postDelayed.

Bug: 68230819
Test: Manual test
Change-Id: Id098e1b77c28b62a5495c3369ed950531e59dba2
This commit is contained in:
Bolun Shan
2017-10-12 15:17:08 +08:00
committed by Tomoharu Hatano
parent ea5243e28d
commit 92cf21583d

View File

@@ -37,6 +37,7 @@ import android.net.wifi.WifiManager;
import android.net.wifi.WpsInfo;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.PowerManager;
import android.os.Process;
@@ -703,6 +704,10 @@ public class WifiSettings extends RestrictedSettingsFragment
private void updateAccessPointsDelayed() {
// Safeguard from some delayed event handling
if (getActivity() != null && !mIsRestricted && mWifiManager.isWifiEnabled()) {
Handler handler = getView().getHandler();
if (handler != null && handler.hasCallbacks(mUpdateAccessPointsRunnable)) {
return;
}
setProgressBarVisible(true);
getView().postDelayed(mUpdateAccessPointsRunnable, 300 /* delay milliseconds */);
}