Merge "Add ConnectivityManager.getNetworkWatchlistConfigHash()"
This commit is contained in:
@@ -3763,4 +3763,20 @@ public class ConnectivityManager {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The network watchlist is a list of domains and IP addresses that are associated with
|
||||
* potentially harmful apps. This method returns the hash of the watchlist currently
|
||||
* used by the system.
|
||||
*
|
||||
* @return Hash of network watchlist config file. Null if config does not exist.
|
||||
*/
|
||||
public byte[] getNetworkWatchlistConfigHash() {
|
||||
try {
|
||||
return mService.getNetworkWatchlistConfigHash();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to get watchlist config hash");
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,4 +180,6 @@ interface IConnectivityManager
|
||||
void stopKeepalive(in Network network, int slot);
|
||||
|
||||
String getCaptivePortalServerUrl();
|
||||
|
||||
byte[] getNetworkWatchlistConfigHash();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ import android.net.NetworkRequest;
|
||||
import android.net.NetworkSpecifier;
|
||||
import android.net.NetworkState;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.NetworkWatchlistManager;
|
||||
import android.net.Proxy;
|
||||
import android.net.ProxyInfo;
|
||||
import android.net.RouteInfo;
|
||||
@@ -5708,6 +5709,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
Settings.Global.NETWORK_AVOID_BAD_WIFI, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getNetworkWatchlistConfigHash() {
|
||||
NetworkWatchlistManager nwm = mContext.getSystemService(NetworkWatchlistManager.class);
|
||||
if (nwm == null) {
|
||||
loge("Unable to get NetworkWatchlistManager");
|
||||
return null;
|
||||
}
|
||||
// Redirect it to network watchlist service to access watchlist file and calculate hash.
|
||||
return nwm.getWatchlistConfigHash();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public NetworkMonitor createNetworkMonitor(Context context, Handler handler,
|
||||
NetworkAgentInfo nai, NetworkRequest defaultRequest) {
|
||||
|
||||
Reference in New Issue
Block a user