Snap for 4562879 from 449e7d62a5db0cb1a925ee9d9265594b993ac419 to pi-release

Change-Id: Ie735bc7973fc7e50c838205654ab9aea90f9a28e
This commit is contained in:
android-build-team Robot
2018-01-24 08:20:33 +00:00
6 changed files with 78 additions and 1 deletions

View File

@@ -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();
}
}
}

View File

@@ -180,4 +180,6 @@ interface IConnectivityManager
void stopKeepalive(in Network network, int slot);
String getCaptivePortalServerUrl();
byte[] getNetworkWatchlistConfigHash();
}

View File

@@ -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) {

View File

@@ -67,7 +67,7 @@ public class NetworkStatsFactoryTest {
IoUtils.deleteContents(mTestProc);
}
mFactory = new NetworkStatsFactory(mTestProc);
mFactory = new NetworkStatsFactory(mTestProc, false);
}
@After
@@ -115,6 +115,20 @@ public class NetworkStatsFactoryTest {
assertStatsEntry(stats, "rmnet1", 10021, SET_FOREGROUND, 0x30100000, 742L, 3L, 1265L, 3L);
}
@Test
public void testNetworkStatsSummary() throws Exception {
stageFile(R.raw.net_dev_typical, file("net/dev"));
final NetworkStats stats = mFactory.readNetworkStatsIfaceDev();
assertEquals(6, stats.size());
assertStatsEntry(stats, "lo", UID_ALL, SET_ALL, TAG_NONE, 8308L, 8308L);
assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 1507570L, 489339L);
assertStatsEntry(stats, "ifb0", UID_ALL, SET_ALL, TAG_NONE, 52454L, 0L);
assertStatsEntry(stats, "ifb1", UID_ALL, SET_ALL, TAG_NONE, 52454L, 0L);
assertStatsEntry(stats, "sit0", UID_ALL, SET_ALL, TAG_NONE, 0L, 0L);
assertStatsEntry(stats, "ip6tnl0", UID_ALL, SET_ALL, TAG_NONE, 0L, 0L);
}
@Test
public void testNetworkStatsSingle() throws Exception {
stageFile(R.raw.xt_qtaguid_iface_typical, file("net/xt_qtaguid/iface_stat_all"));

View File

@@ -268,6 +268,31 @@ public class IpSecServiceParameterizedTest {
anyInt());
}
public void testCreateTwoTransformsWithSameSpis() throws Exception {
IpSecConfig ipSecConfig = new IpSecConfig();
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
addAuthAndCryptToIpSecConfig(ipSecConfig);
IpSecTransformResponse createTransformResp =
mIpSecService.createTransform(ipSecConfig, new Binder());
assertEquals(IpSecManager.Status.OK, createTransformResp.status);
// Attempting to create transform a second time with the same SPIs should throw an error...
try {
mIpSecService.createTransform(ipSecConfig, new Binder());
fail("IpSecService should have thrown an error for reuse of SPI");
} catch (IllegalStateException expected) {
}
// ... even if the transform is deleted
mIpSecService.deleteTransform(createTransformResp.resourceId);
try {
mIpSecService.createTransform(ipSecConfig, new Binder());
fail("IpSecService should have thrown an error for reuse of SPI");
} catch (IllegalStateException expected) {
}
}
@Test
public void testDeleteTransform() throws Exception {
IpSecConfig ipSecConfig = new IpSecConfig();

View File

@@ -0,0 +1,8 @@
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 8308 116 0 0 0 0 0 0 8308 116 0 0 0 0 0 0
rmnet0: 1507570 2205 0 0 0 0 0 0 489339 2237 0 0 0 0 0 0
ifb0: 52454 151 0 151 0 0 0 0 0 0 0 0 0 0 0 0
ifb1: 52454 151 0 151 0 0 0 0 0 0 0 0 0 0 0 0
sit0: 0 0 0 0 0 0 0 0 0 0 148 0 0 0 0 0
ip6tnl0: 0 0 0 0 0 0 0 0 0 0 151 151 0 0 0 0