Loading services/core/java/com/android/server/security/intrusiondetection/IntrusionDetectionService.java +5 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,11 @@ public class IntrusionDetectionService extends SystemService { } private void transport(List<IntrusionDetectionEvent> events) { try { mIntrusionDetectionEventTransportConnection.addData(events); } catch (Throwable t) { Slog.e(TAG, "Failed to transport data: ", t); } } @Override Loading services/core/java/com/android/server/security/intrusiondetection/NetworkLogSource.java +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ public class NetworkLogSource implements DataSource { return; } try { if (!mIpConnectivityMetrics.removeNetdEventCallback( if (mIpConnectivityMetrics.removeNetdEventCallback( INetdEventCallback.CALLBACK_CALLER_DEVICE_POLICY)) { mIsNetworkLoggingEnabled.set(false); Loading services/tests/security/intrusiondetection/src/com/android/server/security/intrusiondetection/TestApp/src/com/android/coretests/apps/testapp/LocalIntrusionDetectionEventTransport.java +25 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.coretests.apps.testapp; import android.app.admin.DnsEvent; import android.app.admin.SecurityLog; import android.app.admin.SecurityLog.SecurityEvent; import android.content.Context; Loading @@ -43,8 +44,11 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve private static final String ACTION_SECURITY_EVENT_RECEIVED = "com.android.coretests.apps.testapp.ACTION_SECURITY_EVENT_RECEIVED"; private static final String ACTION_DNS_EVENT_RECEIVED = "com.android.coretests.apps.testapp.ACTION_DNS_EVENT_RECEIVED"; private static final String TAG = "LocalIntrusionDetectionEventTransport"; private static final String TEST_SECURITY_EVENT_TAG = "test_security_event_tag"; private static final String TEST_DNS_EVENT_TAG = "google.com"; private static Context sContext; public LocalIntrusionDetectionEventTransport(Context context) { Loading @@ -57,13 +61,23 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve try { Intent intent = new Intent(ACTION_SECURITY_EVENT_RECEIVED); sContext.sendBroadcast(intent); Log.i(TAG, "LIZ_TESTING: sent broadcast"); } catch (Exception e) { Log.e(TAG, "Exception sending broadcast", e); Log.e(TAG, "Exception sending security event broadcast", e); } } private static void checkIfSecurityEventReceivedFromCts(List<IntrusionDetectionEvent> events) { // Broadcast an intent to the CTS test service to indicate that the DNS // event was received. private static void broadcastDnsEventReceived() { try { Intent intent = new Intent(ACTION_DNS_EVENT_RECEIVED); sContext.sendBroadcast(intent); } catch (Exception e) { Log.e(TAG, "Exception sending network event broadcast", e); } } private static void checkIfCtsEventReceived(List<IntrusionDetectionEvent> events) { // Loop through the events and check if any of them are the security event // that uses the TEST_SECURITY_EVENT_TAG tag, which is set by the CTS test. for (IntrusionDetectionEvent event : events) { Loading @@ -76,6 +90,13 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve return; } } if (event.getType() == IntrusionDetectionEvent.NETWORK_EVENT_DNS) { DnsEvent dnsEvent = event.getDnsEvent(); if (dnsEvent.getHostname().equals(TEST_DNS_EVENT_TAG)) { broadcastDnsEventReceived(); return; } } } } Loading @@ -90,7 +111,7 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve // verify the event is received with the appropriate data, we will // check the events locally and set a property value that can be // read by the test. checkIfSecurityEventReceivedFromCts(events); checkIfCtsEventReceived(events); mEvents.addAll(events); return true; } Loading Loading
services/core/java/com/android/server/security/intrusiondetection/IntrusionDetectionService.java +5 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,11 @@ public class IntrusionDetectionService extends SystemService { } private void transport(List<IntrusionDetectionEvent> events) { try { mIntrusionDetectionEventTransportConnection.addData(events); } catch (Throwable t) { Slog.e(TAG, "Failed to transport data: ", t); } } @Override Loading
services/core/java/com/android/server/security/intrusiondetection/NetworkLogSource.java +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ public class NetworkLogSource implements DataSource { return; } try { if (!mIpConnectivityMetrics.removeNetdEventCallback( if (mIpConnectivityMetrics.removeNetdEventCallback( INetdEventCallback.CALLBACK_CALLER_DEVICE_POLICY)) { mIsNetworkLoggingEnabled.set(false); Loading
services/tests/security/intrusiondetection/src/com/android/server/security/intrusiondetection/TestApp/src/com/android/coretests/apps/testapp/LocalIntrusionDetectionEventTransport.java +25 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.coretests.apps.testapp; import android.app.admin.DnsEvent; import android.app.admin.SecurityLog; import android.app.admin.SecurityLog.SecurityEvent; import android.content.Context; Loading @@ -43,8 +44,11 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve private static final String ACTION_SECURITY_EVENT_RECEIVED = "com.android.coretests.apps.testapp.ACTION_SECURITY_EVENT_RECEIVED"; private static final String ACTION_DNS_EVENT_RECEIVED = "com.android.coretests.apps.testapp.ACTION_DNS_EVENT_RECEIVED"; private static final String TAG = "LocalIntrusionDetectionEventTransport"; private static final String TEST_SECURITY_EVENT_TAG = "test_security_event_tag"; private static final String TEST_DNS_EVENT_TAG = "google.com"; private static Context sContext; public LocalIntrusionDetectionEventTransport(Context context) { Loading @@ -57,13 +61,23 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve try { Intent intent = new Intent(ACTION_SECURITY_EVENT_RECEIVED); sContext.sendBroadcast(intent); Log.i(TAG, "LIZ_TESTING: sent broadcast"); } catch (Exception e) { Log.e(TAG, "Exception sending broadcast", e); Log.e(TAG, "Exception sending security event broadcast", e); } } private static void checkIfSecurityEventReceivedFromCts(List<IntrusionDetectionEvent> events) { // Broadcast an intent to the CTS test service to indicate that the DNS // event was received. private static void broadcastDnsEventReceived() { try { Intent intent = new Intent(ACTION_DNS_EVENT_RECEIVED); sContext.sendBroadcast(intent); } catch (Exception e) { Log.e(TAG, "Exception sending network event broadcast", e); } } private static void checkIfCtsEventReceived(List<IntrusionDetectionEvent> events) { // Loop through the events and check if any of them are the security event // that uses the TEST_SECURITY_EVENT_TAG tag, which is set by the CTS test. for (IntrusionDetectionEvent event : events) { Loading @@ -76,6 +90,13 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve return; } } if (event.getType() == IntrusionDetectionEvent.NETWORK_EVENT_DNS) { DnsEvent dnsEvent = event.getDnsEvent(); if (dnsEvent.getHostname().equals(TEST_DNS_EVENT_TAG)) { broadcastDnsEventReceived(); return; } } } } Loading @@ -90,7 +111,7 @@ public class LocalIntrusionDetectionEventTransport extends IntrusionDetectionEve // verify the event is received with the appropriate data, we will // check the events locally and set a property value that can be // read by the test. checkIfSecurityEventReceivedFromCts(events); checkIfCtsEventReceived(events); mEvents.addAll(events); return true; } Loading