WifiNetworkScoreCache: Use @hide INetworkScoreCache

This version of WifiNetworkScoreCache extends the @hide AIDL callback.
This will not be a part of the mainline module and will be used by
settings/setupwizard.

Bug: 144487252
Test: Compiles
Test: Device boots up & connects to wifi networks.
Change-Id: I3bf1525642329d4cc55830985ab5fb89ff651912
This commit is contained in:
Roshan Pius
2019-12-03 11:36:41 -08:00
parent 9e51dbbb90
commit 7abff1d6fe

View File

@@ -22,7 +22,6 @@ import android.annotation.Nullable;
import android.content.Context;
import android.net.INetworkScoreCache;
import android.net.NetworkKey;
import android.net.NetworkScoreManager;
import android.net.ScoredNetwork;
import android.os.Handler;
import android.os.Process;
@@ -39,10 +38,10 @@ import java.util.List;
/**
* {@link INetworkScoreCache} implementation for Wifi Networks.
*
* TODO: This should not be part of wifi mainline module.
* @hide
*/
public class WifiNetworkScoreCache extends INetworkScoreCache.Stub
implements NetworkScoreManager.NetworkScoreCallback {
public class WifiNetworkScoreCache extends INetworkScoreCache.Stub {
private static final String TAG = "WifiNetworkScoreCache";
private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
@@ -248,17 +247,6 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub
}
@Override protected final void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
dumpWithLatestScanResults(fd, writer, args, wifiManager.getScanResults());
}
/**
* This is directly invoked from within Wifi-Service (on it's instance of this class), hence
* avoid making the WifiManager.getScanResults() call to avoid a deadlock.
*/
public final void dumpWithLatestScanResults(
FileDescriptor fd, PrintWriter writer, String[] args,
List<ScanResult> latestScanResults) {
mContext.enforceCallingOrSelfPermission(permission.DUMP, TAG);
String header = String.format("WifiNetworkScoreCache (%s/%d)",
mContext.getPackageName(), Process.myUid());
@@ -269,7 +257,8 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub
writer.println(" " + score);
}
writer.println(" Network scores for latest ScanResults:");
for (ScanResult scanResult : latestScanResults) {
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
for (ScanResult scanResult : wifiManager.getScanResults()) {
writer.println(
" " + buildNetworkKey(scanResult) + ": " + getNetworkScore(scanResult));
}