Merge Android 14 QPR1

Merged-In: Ia0183acb9caa76e3ff38aaf8eb53e299181125cf
Bug: 315507370
Change-Id: I7b342e54cca8d94766a438afa91951bceab1bb3a
diff --git a/common/overlay/frameworks/base/core/res/res/values/config.xml b/common/overlay/frameworks/base/core/res/res/values/config.xml
index b66aa87..92b145a 100644
--- a/common/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/common/overlay/frameworks/base/core/res/res/values/config.xml
@@ -29,6 +29,8 @@
     <integer-array name="config_availableColorModes">
         <item>0</item> <!-- COLOR_MODE_NATURAL -->
     </integer-array>
+    <!-- The dreams feature (screensavers) is not supported in android auto -->
+    <bool name="config_dreamsSupported">false</bool>
     <!-- Device does not support near ultrasound audio-->
     <bool name="config_supportMicNearUltrasound">false</bool>
     <bool name="config_supportSpeakerNearUltrasound">false</bool>
diff --git a/common/preinstalled-packages-product-car-emulator.xml b/common/preinstalled-packages-product-car-emulator.xml
index 75ac5c8..1b65849 100644
--- a/common/preinstalled-packages-product-car-emulator.xml
+++ b/common/preinstalled-packages-product-car-emulator.xml
@@ -34,6 +34,10 @@
         <install-in user-type="FULL" />
         <install-in user-type="SYSTEM" />
     </install-in-user-type>
+    <install-in-user-type package="com.android.car.settings">
+        <install-in user-type="FULL" />
+        <install-in user-type="SYSTEM" />
+    </install-in-user-type>
     <install-in-user-type package="com.android.traceur">
         <install-in user-type="FULL" />
         <install-in user-type="SYSTEM" />
@@ -81,19 +85,17 @@
         <install-in user-type="FULL" />
         <install-in user-type="SYSTEM" />
     </install-in-user-type>
+
+    <install-in-user-type package="com.android.emulator.multidisplay">
+        <install-in user-type="SYSTEM" />
+    </install-in-user-type>
 <!--
   Apps that do need to run on SYSTEM and evaluated by package owner.
   Here the apps will have FULL only.
 -->
-    <install-in-user-type package="com.android.car.datacenter">
-        <install-in user-type="FULL" />
-    </install-in-user-type>
     <install-in-user-type package="com.android.car.goldilocks">
         <install-in user-type="FULL" />
     </install-in-user-type>
-    <install-in-user-type package="com.android.car.settings">
-        <install-in user-type="FULL" />
-    </install-in-user-type>
     <install-in-user-type package="com.android.car.speedbump">
         <install-in user-type="FULL" />
     </install-in-user-type>
@@ -151,9 +153,6 @@
     <install-in-user-type package="com.android.musicfx">
         <install-in user-type="FULL" />
     </install-in-user-type>
-    <install-in-user-type package="com.android.car.datacenter">
-        <install-in user-type="FULL" />
-    </install-in-user-type>
     <install-in-user-type package="com.android.timezone.updater">
         <install-in user-type="FULL" />
     </install-in-user-type>
@@ -169,9 +168,6 @@
     <install-in-user-type package="com.android.safetyregulatoryinfo">
         <install-in user-type="FULL" />
     </install-in-user-type>
-    <install-in-user-type package="com.android.emulator.multidisplay">
-        <install-in user-type="FULL" />
-    </install-in-user-type>
     <install-in-user-type package="com.android.providers.partnerbookmarks">
         <install-in user-type="FULL" />
     </install-in-user-type>
diff --git a/common/sepolicy/dumpstate.te b/common/sepolicy/dumpstate.te
index ad16894..6ecf7a3 100644
--- a/common/sepolicy/dumpstate.te
+++ b/common/sepolicy/dumpstate.te
@@ -1,7 +1,9 @@
-# Signal java processes to dump hal_vehicle_default, hal_audiocontrol_default
+# Signal java processes to dump HALs.
 allow dumpstate {
   hal_vehicle_default
   hal_audiocontrol_default
+  hal_ivn_default
+  hal_remoteaccess_default
 }:process signal;
 
 
@@ -15,3 +17,5 @@
 dump_hal(hal_identity)
 dump_hal(hal_light)
 dump_hal(hal_power)
+dump_hal(hal_ivn)
+dump_hal(hal_remoteaccess)
diff --git a/emulator/car_emulator_vendor.mk b/emulator/car_emulator_vendor.mk
index 37669d9..64033f5 100644
--- a/emulator/car_emulator_vendor.mk
+++ b/emulator/car_emulator_vendor.mk
@@ -141,5 +141,17 @@
 endif # BUILD_EMULATOR_CLUSTER_DISPLAY
 endif # EMULATOR_DYNAMIC_MULTIDISPLAY_CONFIG
 
+# Should use car bluetooth.prop.
+# This replaces value from device/generic/goldfish/64bitonly/product/vendor.mk below
+ifeq (,$(ENABLE_CAR_USB_PASSTHROUGH))
+ENABLE_CAR_USB_PASSTHROUGH := false
+endif
+ifeq (true,$(ENABLE_CAR_USB_PASSTHROUGH))
+TARGET_PRODUCT_PROP := device/generic/car/emulator/usbpt/bluetooth/bluetooth.prop
+endif
+
 # Goldfish vendor partition configurations
 $(call inherit-product-if-exists, device/generic/goldfish/64bitonly/product/vendor.mk)
+
+# Enable socket for qemu VHAL
+BOARD_SEPOLICY_DIRS += device/generic/car/emulator/sepolicy
diff --git a/emulator/cluster/rro_overlays/CarServiceOverlay_MdNd/res/values/config.xml b/emulator/cluster/rro_overlays/CarServiceOverlay_MdNd/res/values/config.xml
index 2182a64..1dd94b7 100644
--- a/emulator/cluster/rro_overlays/CarServiceOverlay_MdNd/res/values/config.xml
+++ b/emulator/cluster/rro_overlays/CarServiceOverlay_MdNd/res/values/config.xml
@@ -107,31 +107,40 @@
          Every item in this array contains a flatten component name of a service that needs to be
          started and a list of parameters after hashtag symbol. Here's the format:
 
-         <item>com.bar.foo/.Service#bind={bind|start|startForeground},user={all|system|foreground},
-         trigger={asap,userUnlocked}</item>
+         <item>com.bar.foo/.Service#bind={bind|start|startForeground},
+         user={all|system|foreground|visible|backgroundVisible},
+         trigger={asap|resume|userUnlocked|userPostUnlocked}</item>
 
          bind: bind - start service with Context#bindService
                start - start service with Context#startService
                startForeground - start service with Context#startForegroundService
                If service was bound it will be restarted unless it is constantly crashing.
                The default value is 'start'
-         user: all - the service will be bound/started for system and all foreground users
+         user: all - the service will be bound/started for system and all visible users
                system - the service will be started/bound only for system user (u0)
                foreground - the service will be bound/started only for foreground users
+               visible - the service will be bound/started only for visible users (as defined by
+                         `UserManager#isUserVisible()`).
                backgroundVisible - the service will be bound/started only for background users that
-                      are visible.
+                                   are visible.
                The default value is 'all'
          trigger: indicates when the service needs to be started/bound
                asap - the service might be bound when user is not fully loaded, be careful with
                       this value, the service also needs to have directBootAware flag set to true
+               resume - start service when the device resumes from suspend (suspend-to-RAM, or
+                        suspend-to-disk).
                userUnlocked - start service when user unlocked the device
+               userPostUnlocked - start service later after user unlocked. This is used when the
+                                  service is not urgent and can wait to start.
                The default value is 'userUnlocked'
+         maxRetries: the maximum number of attempts to rebind/restart a disconnected service.
+               Retries start with 4 second initial delay, being doubled after each failed attempt.
+               The default value is 6.
 
          If the service bound/started for foreground user it will be unbound/stopped when user
          is no longer foreground.
      -->
     <string-array translatable="false" name="config_earlyStartupServices">
-    <item>com.android.car.messenger/.MessengerService#bind=startForeground,user=foreground,trigger=userUnlocked</item>
         <item>com.google.android.companiondevicesupport/com.google.android.connecteddevice.service.ConnectedDeviceService#bind=bind,user=system,trigger=asap</item>
         <item>com.google.android.companiondevicesupport/com.google.android.connecteddevice.service.ConnectedDeviceFgUserService#bind=bind,user=foreground,trigger=asap</item>
         <!-- Starting Android Auto receiver service earlier for wireless projection. -->
diff --git a/emulator/cluster/rro_overlays/CarServiceOverlay_MdOsDouble/res/values/config.xml b/emulator/cluster/rro_overlays/CarServiceOverlay_MdOsDouble/res/values/config.xml
index d88c016..c314467 100644
--- a/emulator/cluster/rro_overlays/CarServiceOverlay_MdOsDouble/res/values/config.xml
+++ b/emulator/cluster/rro_overlays/CarServiceOverlay_MdOsDouble/res/values/config.xml
@@ -40,9 +40,9 @@
     -->
     <string-array translatable="false" name="config_occupant_zones">
         <item>occupantZoneId=0,occupantType=DRIVER,seatRow=1,seatSide=driver</item>
-        <item>occupantZoneId=1,occupantType=FRONT_PASSENGER,seatRow=1,seatSide=oppositeDriver</item>
-        <item>occupantZoneId=2,occupantType=REAR_PASSENGER,seatRow=2,seatSide=left</item>
-        <item>occupantZoneId=3,occupantType=REAR_PASSENGER,seatRow=2,seatSide=right</item>
+        <item>occupantZoneId=1,occupantType=REAR_PASSENGER,seatRow=2,seatSide=left</item>
+        <item>occupantZoneId=2,occupantType=REAR_PASSENGER,seatRow=2,seatSide=right</item>
+        <item>occupantZoneId=3,occupantType=FRONT_PASSENGER,seatRow=1,seatSide=oppositeDriver</item>
     </string-array>
 
     <!--
diff --git a/emulator/multi-display-dynamic/overlay/frameworks/base/core/res/res/values/config.xml b/emulator/multi-display-dynamic/overlay/frameworks/base/core/res/res/values/config.xml
index 17d24e6..cf176b9 100644
--- a/emulator/multi-display-dynamic/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/emulator/multi-display-dynamic/overlay/frameworks/base/core/res/res/values/config.xml
@@ -60,8 +60,4 @@
         support PROFILE user. -->
     <integer name="config_userTypePackageWhitelistMode">2</integer>
 
-    <!-- Whether the device allows users to start in background visible on displays.
-         Should be false for most devices, except automotive vehicle with passenger displays. -->
-    <bool name="config_multiuserVisibleBackgroundUsers">true</bool>
-
 </resources>
diff --git a/emulator/multi-display/overlay/frameworks/base/core/res/res/values/config.xml b/emulator/multi-display/overlay/frameworks/base/core/res/res/values/config.xml
index e9a7179..087ced2 100644
--- a/emulator/multi-display/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/emulator/multi-display/overlay/frameworks/base/core/res/res/values/config.xml
@@ -58,6 +58,7 @@
 
     <!-- Whether the device allows users to start in background visible on displays.
          Should be false for most devices, except automotive vehicle with passenger displays. -->
+    <!-- The config is enabled for the development purpose only. -->
     <bool name="config_multiuserVisibleBackgroundUsers">true</bool>
 
     <!-- Enable multi-user IME sessions -->
diff --git a/emulator/vhal_aidl/VehicleEmulator/EmulatedVehicleHardware.cpp b/emulator/vhal_aidl/VehicleEmulator/EmulatedVehicleHardware.cpp
index 54eb716..941d4f8 100644
--- a/emulator/vhal_aidl/VehicleEmulator/EmulatedVehicleHardware.cpp
+++ b/emulator/vhal_aidl/VehicleEmulator/EmulatedVehicleHardware.cpp
@@ -42,12 +42,15 @@
 using ::android::hardware::automotive::vehicle::V2_0::impl::MessageSender;
 
 EmulatedVehicleHardware::EmulatedVehicleHardware() {
-    mInQemu = isInQemu();
-    ALOGD("mInQemu=%s", mInQemu ? "true" : "false");
+    Init();
+}
 
-    mVehicleBusCallback = ::ndk::SharedRefBase::make<VehicleBusCallback>(this);
-    mEmulator = std::make_unique<VehicleEmulator>(this);
-    startVehicleBuses();
+EmulatedVehicleHardware::EmulatedVehicleHardware(
+    std::string_view default_config_dir, std::string_view override_config_dir,
+    bool force_override)
+    : FakeVehicleHardware(std::string(default_config_dir),
+                          std::string(override_config_dir), force_override) {
+  Init();
 }
 
 EmulatedVehicleHardware::EmulatedVehicleHardware(
@@ -67,6 +70,15 @@
     stopVehicleBuses();
 }
 
+void EmulatedVehicleHardware::Init() {
+    mInQemu = isInQemu();
+    ALOGD("mInQemu=%s", mInQemu ? "true" : "false");
+
+    mVehicleBusCallback = ::ndk::SharedRefBase::make<VehicleBusCallback>(this);
+    mEmulator = std::make_unique<VehicleEmulator>(this);
+    startVehicleBuses();
+}
+
 StatusCode EmulatedVehicleHardware::setValues(
             std::shared_ptr<const SetValuesCallback> callback,
             const std::vector<SetValueRequest>& requests) {
diff --git a/emulator/vhal_aidl/VehicleEmulator/include/EmulatedVehicleHardware.h b/emulator/vhal_aidl/VehicleEmulator/include/EmulatedVehicleHardware.h
index 3bd4f15..f5aaed1 100644
--- a/emulator/vhal_aidl/VehicleEmulator/include/EmulatedVehicleHardware.h
+++ b/emulator/vhal_aidl/VehicleEmulator/include/EmulatedVehicleHardware.h
@@ -33,7 +33,7 @@
 class VehicleEmulator;
 class VehicleEmulatorTest;
 
-class EmulatedVehicleHardware final : public FakeVehicleHardware {
+class EmulatedVehicleHardware : public FakeVehicleHardware {
   public:
     using AidlVehiclePropValue = aidl::android::hardware::automotive::vehicle::VehiclePropValue;
     using IVehicleBus = aidl::device::generic::car::emulator::IVehicleBus;
@@ -41,6 +41,9 @@
     using ConfigResultType = android::base::Result<const aidl::android::hardware::automotive::vehicle::VehiclePropConfig*, VhalError>;
 
     EmulatedVehicleHardware();
+    EmulatedVehicleHardware(std::string_view default_config_dir,
+                            std::string_view override_config_dir,
+                            bool force_override);
 
     ~EmulatedVehicleHardware();
 
@@ -77,6 +80,7 @@
 
     // determine if it's running inside Android Emulator
     static bool isInQemu();
+    void Init();
     void startVehicleBuses();
     void stopVehicleBuses();
 
diff --git a/sdk_car_md_arm64.mk b/sdk_car_md_arm64.mk
index a2131bd..52f8983 100644
--- a/sdk_car_md_arm64.mk
+++ b/sdk_car_md_arm64.mk
@@ -24,3 +24,5 @@
 PRODUCT_DEVICE := emulator_car64_arm64
 PRODUCT_BRAND := Android
 PRODUCT_MODEL := Car multi-display on arm64 emulator
+
+$(warning ${PRODUCT_NAME} is for development purposes only.)
diff --git a/sdk_car_md_x86_64.mk b/sdk_car_md_x86_64.mk
index 7db6934..728d741 100644
--- a/sdk_car_md_x86_64.mk
+++ b/sdk_car_md_x86_64.mk
@@ -24,3 +24,5 @@
 PRODUCT_DEVICE := emulator_car64_x86_64
 PRODUCT_BRAND := Android
 PRODUCT_MODEL := Car multi-display on x86_64 emulator
+
+$(warning ${PRODUCT_NAME} is for development purposes only.)