[Wi-Fi] Apply WifiTrackerLib objects in Wi-Fi Slice
This change uses WifiTrackerLib's WifiPickerTracker & WifiEntry
to replace SettingLib's WifiTracker & AccessPoint.
This change includes
1. WifiScanWorker has the callbacks similar to a lifecycle component
but it's not a lifecycle component. Let WifiScanWorker implements
LifecycleOwner and provides #getLifecycle() for WifiPickerTracker.
2. Remove captive portal related code because WifiEntry#connect will
handle captive portal login if it's necessary.
3. Create WifiSliceItem to wrap WifiEntry because WifiEntry is an
abstract object and it does not provide copy constructor.
Without copy construcor, Wi-Fi Slice may show unexpected information
when a WifiEntry is updated.
4. Use WifiTrackerLib's NetworkDetailsTracker & WifiEntry in
WifiDialogActivity because it gets a WifiEntry key from Wi-Fi Slice.
NetworkDetailsTracker can get the WifiEntry of th key.
Bug: 155613549
Bug: 152571756
Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.slice
make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi
Change-Id: I0718f4647cea007a9b701922f3121a388dd43918
This commit is contained in:
@@ -18,7 +18,6 @@ package com.android.settings.wifi.slice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.android.settings.slices.SliceBackgroundWorker;
|
||||
|
||||
@@ -27,44 +26,12 @@ import com.android.settings.slices.SliceBackgroundWorker;
|
||||
*/
|
||||
public class ContextualWifiScanWorker extends WifiScanWorker {
|
||||
|
||||
private static long sVisibleUiSessionToken;
|
||||
private static long sActiveSession;
|
||||
|
||||
public ContextualWifiScanWorker(Context context, Uri uri) {
|
||||
super(context, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new visible UI session for the purpose of automatically starting captive portal.
|
||||
*
|
||||
* A visible UI session is defined as a duration of time when a UI screen is visible to user.
|
||||
* Going to a sub-page and coming out breaks the continuation, leaving the page and coming back
|
||||
* breaks it too.
|
||||
*/
|
||||
public static void newVisibleUiSession() {
|
||||
sVisibleUiSessionToken = SystemClock.elapsedRealtime();
|
||||
}
|
||||
|
||||
static void saveSession() {
|
||||
sActiveSession = sVisibleUiSessionToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearClickedWifiOnSliceUnpinned() {
|
||||
// Do nothing for contextual Wi-Fi slice
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSessionValid() {
|
||||
if (sVisibleUiSessionToken != sActiveSession) {
|
||||
clearClickedWifi();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getApRowCount() {
|
||||
return ContextualWifiSlice.getApRowCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user