Update EVS service configurations

- evsmanagerd is added to the build only if ENABLE_EVS_SERVICE is true.
- Start evsmanagerd from init.evs.rc only if
  CUSTOMIZE_EVS_SERVICE_PARAMETER is not set as true.
- Start android.hardware.automotive.evs-default, evs_app, and
  cardisplayproxyd from their own rc files.
- Remove persist.automotive.evs.mode property.
- Allow evs_app to perform the binder IPC to evsmanagerd.

Bug: 226874713
Test: Build seahawk and cf_x86_64_auto targets and manually confirm that
      EVS service is functioning properly by running evs_app
Change-Id: I19ff95474454921894e23ef5a4577082f1a4d1ab
diff --git a/car_product/build/car_base.mk b/car_product/build/car_base.mk
index 3e7fb15..e2d212f 100644
--- a/car_product/build/car_base.mk
+++ b/car_product/build/car_base.mk
@@ -68,19 +68,27 @@
 PRODUCT_PROPERTY_OVERRIDES += config.disable_cameraservice=true
 endif
 
-# EVS service
+# ENABLE_EVS_SERVICE must be set as true from the product's makefile if it wants to support
+# the Extended View System service.
+ifeq ($(ENABLE_EVS_SERVICE), true)
 PRODUCT_PACKAGES += evsmanagerd
 
+# CUSTOMIZE_EVS_SERVICE_PARAMETER must be set as true from the product's makefile if it wants
+# to use IEvsEnumearor instances other than hw/1.
+ifneq ($(CUSTOMIZE_EVS_SERVICE_PARAMETER), true)
+PRODUCT_COPY_FILES += \
+    packages/services/Car/cpp/evs/manager/aidl/init.evs.rc:$(TARGET_COPY_OUT_SYSTEM)/etc/init/init.evs.rc
+endif
+
 ifeq ($(ENABLE_EVS_SAMPLE), true)
 # ENABLE_EVS_SAMPLE should set be true or their vendor specific equivalents should be included in
 # the device.mk with the corresponding selinux policies
-LOCAL_EVS_PROPERTIES ?= persist.automotive.evs.mode=0
-PRODUCT_PRODUCT_PROPERTIES += $(LOCAL_EVS_PROPERTIES)
 PRODUCT_PACKAGES += evs_app \
                     android.hardware.automotive.evs-default \
                     android.frameworks.automotive.display@1.0-service
 include packages/services/Car/cpp/evs/apps/sepolicy/evsapp.mk
-endif
+endif  # ENABLE_EVS_SAMPLE
+
 ifeq ($(ENABLE_CAREVSSERVICE_SAMPLE), true)
 PRODUCT_PACKAGES += CarEvsCameraPreviewApp
 endif
@@ -89,6 +97,8 @@
 PRODUCT_PACKAGE_OVERLAYS += packages/services/Car/tests/SampleRearViewCamera/overlay
 endif
 
+endif  # ENABLE_EVS_SERVICE
+
 # Device running Android is a car
 PRODUCT_COPY_FILES += \
     frameworks/native/data/etc/android.hardware.type.automotive.xml:system/etc/permissions/android.hardware.type.automotive.xml
diff --git a/car_product/init/init.car.rc b/car_product/init/init.car.rc
index 4780dd4..81e40b9 100644
--- a/car_product/init/init.car.rc
+++ b/car_product/init/init.car.rc
@@ -2,16 +2,3 @@
 on post-fs-data
     mkdir /data/system/car 0700 system system
     mkdir /data/system/car/watchdog 0700 system system
-
-# A property to enable EVS services conditionally
-on property:persist.automotive.evs.mode=0
-    # stop EVS and automotive display services
-    stop automotive_display
-    stop evs_sample_driver
-    stop evs_manager
-
-on property:persist.automotive.evs.mode=1
-    # start EVS and automotive display services
-    start automotive_display
-    start evs_sample_driver
-    start evs_manager
diff --git a/cpp/displayproxy/cardisplayproxyd.rc b/cpp/displayproxy/cardisplayproxyd.rc
index c4cf1f1..11cadfa 100644
--- a/cpp/displayproxy/cardisplayproxyd.rc
+++ b/cpp/displayproxy/cardisplayproxyd.rc
@@ -2,3 +2,7 @@
     class hal
     user graphics
     group automotive_evs
+    disabled
+
+on late-init
+    start cardisplayproxyd
diff --git a/cpp/evs/apps/default/evs_app.rc b/cpp/evs/apps/default/evs_app.rc
index f155e11..35cb730 100644
--- a/cpp/evs/apps/default/evs_app.rc
+++ b/cpp/evs/apps/default/evs_app.rc
@@ -4,3 +4,6 @@
     user automotive_evs
     group automotive_evs
     disabled # will not automatically start with its class; must be explictly started.
+
+on late-init
+    start evs_app
diff --git a/cpp/evs/apps/sepolicy/evsapp.mk b/cpp/evs/apps/sepolicy/evsapp.mk
index 495b3ab..72bf9e7 100644
--- a/cpp/evs/apps/sepolicy/evsapp.mk
+++ b/cpp/evs/apps/sepolicy/evsapp.mk
@@ -1,3 +1,2 @@
 # Selinux policies for the sample EVS application
-#PRODUCT_PUBLIC_SEPOLICY_DIRS += packages/services/Car/cpp/evs/apps/default/sepolicy/public
 PRODUCT_PRIVATE_SEPOLICY_DIRS += packages/services/Car/cpp/evs/apps/sepolicy/private
diff --git a/cpp/evs/apps/sepolicy/private/evsmanagerd.te b/cpp/evs/apps/sepolicy/private/evsmanagerd.te
new file mode 100644
index 0000000..8cee3af
--- /dev/null
+++ b/cpp/evs/apps/sepolicy/private/evsmanagerd.te
@@ -0,0 +1,2 @@
+# Allow to perform a binder IPC to evsmanagerd
+binder_call(evs_app, evsmanagerd)
diff --git a/cpp/evs/manager/aidl/init.evs.rc b/cpp/evs/manager/aidl/init.evs.rc
new file mode 100644
index 0000000..11deb18
--- /dev/null
+++ b/cpp/evs/manager/aidl/init.evs.rc
@@ -0,0 +1,2 @@
+on late-init
+    start evsmanagerd
diff --git a/cpp/evs/sampleDriver/aidl/android.hardware.automotive.evs-default.rc b/cpp/evs/sampleDriver/aidl/android.hardware.automotive.evs-default.rc
index 7816b52..33b47ba 100644
--- a/cpp/evs/sampleDriver/aidl/android.hardware.automotive.evs-default.rc
+++ b/cpp/evs/sampleDriver/aidl/android.hardware.automotive.evs-default.rc
@@ -3,4 +3,9 @@
     priority -20
     user graphics
     group automotive_evs camera
+    onrestart restart cardisplayproxyd
+    onrestart restart evsmanagerd
     disabled
+
+on late-init
+    start android.hardware.automotive.evs-default