Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c2e67e3 authored by Mark Teffeteller's avatar Mark Teffeteller
Browse files

Call transport connection initialization in the ID service.

Bug: 369313906
Test: atest frameworks/base/services/tests/security/intrusiondetection/src/com/android
/server/security/intrusiondetection/IntrusionDetectionServiceTest.java
Flag: android.security.afl_api


Change-Id: I9f302e9f9daeeba7d7d2e5f95fffc81942e97837
parent f85810e9
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -50,7 +50,7 @@ public class IntrusionDetectionEventTransportConnection implements ServiceConnec
    private static final String PRODUCTION_BUILD = "user";
    private static final String PRODUCTION_BUILD = "user";
    private static final String PROPERTY_BUILD_TYPE = "ro.build.type";
    private static final String PROPERTY_BUILD_TYPE = "ro.build.type";
    private static final String PROPERTY_INTRUSION_DETECTION_SERVICE_NAME =
    private static final String PROPERTY_INTRUSION_DETECTION_SERVICE_NAME =
            "intrusiondetection_service_name";
            "debug.intrusiondetection_package_name";
    private static final long FUTURE_TIMEOUT_MILLIS = 60 * 1000; // 1 min
    private static final long FUTURE_TIMEOUT_MILLIS = 60 * 1000; // 1 min
    private static final String TAG = "IntrusionDetectionEventTransportConnection";
    private static final String TAG = "IntrusionDetectionEventTransportConnection";
    private final Context mContext;
    private final Context mContext;
@@ -147,9 +147,9 @@ public class IntrusionDetectionEventTransportConnection implements ServiceConnec
    }
    }


    private String getSystemPropertyValue(String propertyName) {
    private String getSystemPropertyValue(String propertyName) {
        String comamandString = "getprop " + propertyName;
        String commandString = "getprop " + propertyName;
        try {
        try {
            Process process = Runtime.getRuntime().exec(comamandString);
            Process process = Runtime.getRuntime().exec(commandString);
            BufferedReader reader =
            BufferedReader reader =
                    new BufferedReader(new InputStreamReader(process.getInputStream()));
                    new BufferedReader(new InputStreamReader(process.getInputStream()));
            String propertyValue = reader.readLine();
            String propertyValue = reader.readLine();
@@ -175,6 +175,10 @@ public class IntrusionDetectionEventTransportConnection implements ServiceConnec
            mIntrusionDetectionEventTransportConfig =
            mIntrusionDetectionEventTransportConfig =
                    getSystemPropertyValue(PROPERTY_INTRUSION_DETECTION_SERVICE_NAME);
                    getSystemPropertyValue(PROPERTY_INTRUSION_DETECTION_SERVICE_NAME);
        }
        }
        Slog.d(
                TAG,
                "mIntrusionDetectionEventTransportConfig: "
                        + mIntrusionDetectionEventTransportConfig);


        if (TextUtils.isEmpty(mIntrusionDetectionEventTransportConfig)) {
        if (TextUtils.isEmpty(mIntrusionDetectionEventTransportConfig)) {
            Slog.e(TAG, "Unable to find a valid config for the transport service");
            Slog.e(TAG, "Unable to find a valid config for the transport service");
+5 −9
Original line number Original line Diff line number Diff line
@@ -232,12 +232,10 @@ public class IntrusionDetectionService extends SystemService {
            return;
            return;
        }
        }


        // TODO: temporarily disable the following for the CTS IntrusionDetectionManagerTest.
        if (!mIntrusionDetectionEventTransportConnection.initialize()) {
        //  Enable it when the transport component is ready.
            callback.onFailure(ERROR_TRANSPORT_UNAVAILABLE);
        // if (!mIntrusionDetectionEventTransportConnection.initialize()) {
            return;
        //     callback.onFailure(ERROR_TRANSPORT_UNAVAILABLE);
        }
        //   return;
        // }


        mDataAggregator.enable();
        mDataAggregator.enable();
        mState = STATE_ENABLED;
        mState = STATE_ENABLED;
@@ -252,9 +250,7 @@ public class IntrusionDetectionService extends SystemService {
            return;
            return;
        }
        }


        // TODO: temporarily disable the following for the CTS IntrusionDetectionManagerTest.
        mIntrusionDetectionEventTransportConnection.release();
        //  Enable it when the transport component is ready.
        // mIntrusionDetectionEventTransportConnection.release();
        mDataAggregator.disable();
        mDataAggregator.disable();
        mState = STATE_DISABLED;
        mState = STATE_DISABLED;
        notifyStateMonitors();
        notifyStateMonitors();