Merge tag 'android-13.0.0_r32' into int/13/fp3

Android 13.0.0 release 32

* tag 'android-13.0.0_r32':
  Move the modem simulator region to 9600 zone for extra spacing.
  modem_simulator: Reuse active call indexes
  Bring back setup_wifi interface configuration to T QPR
  Allow targets deriving from CF to turn off rename_eth0
  Allow targets deriving from CF choosing the interface to setup wifi on.
  Add rear display state jetpack mapping
  [LPA][Cuttlefish] Add notification pregrant
  Adds config values for rear display mode
  Make the cluster display private.
  Disable background blur for widget picker in cuttlefish
  Fix a typo in cuttlefish blur sysprop

Change-Id: Iff4f35d32e23af3ad673990ccdd01884036f7f17
diff --git a/default-permissions.xml b/default-permissions.xml
index 48b0f17..2d5020a 100644
--- a/default-permissions.xml
+++ b/default-permissions.xml
@@ -133,4 +133,9 @@
         <!-- Notifications -->
         <permission name="android.permission.POST_NOTIFICATIONS" fixed="false"/>
     </exception>
+    <exception
+        package="com.google.android.euicc">
+        <!-- Notifications -->
+        <permission name="android.permission.POST_NOTIFICATIONS" fixed="false"/>
+    </exception>
 </exceptions>
diff --git a/guest/commands/setup_wifi/main.cpp b/guest/commands/setup_wifi/main.cpp
index 4a91442..2727fb4 100644
--- a/guest/commands/setup_wifi/main.cpp
+++ b/guest/commands/setup_wifi/main.cpp
@@ -33,6 +33,7 @@
 #include "common/libs/net/network_interface_manager.h"
 
 DEFINE_string(mac_prefix, "", "mac prefix to use for wlan0");
+DEFINE_string(interface, "eth2", "interface to create wlan wrapper on");
 
 static std::array<unsigned char, 6> prefix_to_mac(
     const std::string& mac_prefix) {
@@ -138,9 +139,9 @@
 
   gflags::ParseCommandLineFlags(&argc, &argv, true);
 
-  int renamed_eth2 = RenameNetwork("eth2", "buried_eth2");
-  if (renamed_eth2 != 0) {
-    return renamed_eth2;
+  int renamed_if = RenameNetwork(FLAGS_interface, "buried_" + FLAGS_interface);
+  if (renamed_if != 0) {
+    return renamed_if;
   }
-  return CreateWifiWrapper("buried_eth2", "wlan0");
+  return CreateWifiWrapper("buried_" + FLAGS_interface, "wlan0");
 }
diff --git a/guest/commands/setup_wifi/setup_wifi.rc b/guest/commands/setup_wifi/setup_wifi.rc
index a2f1eb5..993e957 100644
--- a/guest/commands/setup_wifi/setup_wifi.rc
+++ b/guest/commands/setup_wifi/setup_wifi.rc
@@ -1,2 +1,2 @@
-service setup_wifi /vendor/bin/setup_wifi
+service setup_wifi /vendor/bin/setup_wifi --interface=${ro.vendor.virtwifi.port}
     oneshot
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 5d01c80..a68a475 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -759,7 +759,7 @@
     const auto vsock_guest_cid = FLAGS_vsock_guest_cid + num - GetInstance();
     instance.set_vsock_guest_cid(vsock_guest_cid);
     auto calc_vsock_port = [vsock_guest_cid](const int base_port) {
-      // a base (vsock) port is like 9200 for modem_simulator, etc
+      // a base (vsock) port is like 9600 for modem_simulator, etc
       return cuttlefish::GetVsockServerPort(base_port, vsock_guest_cid);
     };
     instance.set_session_id(iface_config.mobile_tap.session_id);
@@ -882,10 +882,10 @@
     if (modem_simulator_count > 0) {
       std::stringstream modem_ports;
       for (auto index {0}; index < modem_simulator_count - 1; index++) {
-        auto port = 9200 + (modem_simulator_count * (num - 1)) + index;
+        auto port = 9600 + (modem_simulator_count * (num - 1)) + index;
         modem_ports << calc_vsock_port(port) << ",";
       }
-      auto port = 9200 + (modem_simulator_count * (num - 1)) +
+      auto port = 9600 + (modem_simulator_count * (num - 1)) +
                   modem_simulator_count - 1;
       modem_ports << calc_vsock_port(port);
       instance.set_modem_simulator_ports(modem_ports.str());
diff --git a/host/commands/modem_simulator/call_service.cpp b/host/commands/modem_simulator/call_service.cpp
index 674c153..7e40870 100644
--- a/host/commands/modem_simulator/call_service.cpp
+++ b/host/commands/modem_simulator/call_service.cpp
@@ -37,7 +37,6 @@
   auto instance = nvram_config->ForInstance(service_id_);
   in_emergency_mode_ = instance.emergency_mode();
 
-  last_active_call_index_ = 1;
   mute_on_ = false;
 }
 
@@ -216,7 +215,7 @@
     call_status.is_mobile_terminated = false;
     call_status.call_state = CallStatus::CALL_STATE_DIALING;
     call_status.remote_client = remote_client;
-    int index = last_active_call_index_++;
+    auto index = FindFreeCallIndex();
 
     auto call_token = std::make_pair(index, call_status.number);
     call_status.timeout_serial = thread_looper_->Post(
@@ -232,7 +231,7 @@
     CallStatus call_status(number);
     call_status.is_mobile_terminated = false;
     call_status.call_state = CallStatus::CALL_STATE_DIALING;
-    auto index = last_active_call_index_++;
+    auto index = FindFreeCallIndex();
     active_calls_[index] = call_status;
 
     if (emergency_number) {
@@ -707,7 +706,7 @@
       call_status.remote_client = client.client_fd;
       call_status.call_state = CallStatus::CALL_STATE_INCOMING;
 
-      auto index = last_active_call_index_++;
+      auto index = FindFreeCallIndex();
       active_calls_[index] = call_status;
       break;
     }
diff --git a/host/commands/modem_simulator/call_service.h b/host/commands/modem_simulator/call_service.h
index 1870372..f57eb05 100644
--- a/host/commands/modem_simulator/call_service.h
+++ b/host/commands/modem_simulator/call_service.h
@@ -42,6 +42,13 @@
   void HandleCancelUssd(const Client& client, const std::string& command);
   void HandleEmergencyMode(const Client& client, const std::string& command);
   void HandleRemoteCall(const Client& client, const std::string& command);
+  int FindFreeCallIndex() const {
+    for (int index = 1; true; index++) {
+      if (active_calls_.find(index) == active_calls_.end()) {
+        return index;
+      }
+    }
+  }
 
  private:
   void InitializeServiceState();
@@ -141,7 +148,6 @@
   // private data members
   SimService* sim_service_;
   NetworkService* network_service_;
-  int32_t last_active_call_index_;
   std::map<int, CallStatus> active_calls_;
   bool in_emergency_mode_;
   bool mute_on_;
diff --git a/shared/auto/overlay/frameworks/base/core/res/res/values/config.xml b/shared/auto/overlay/frameworks/base/core/res/res/values/config.xml
index bf07d05..7eaea59 100644
--- a/shared/auto/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/shared/auto/overlay/frameworks/base/core/res/res/values/config.xml
@@ -34,4 +34,11 @@
       Handle volume keys directly in CarAudioService without passing them to the foreground app
     -->
     <bool name="config_handleVolumeKeysInWindowManager">true</bool>
+
+    <!-- Controls if local secondary displays should be private or not. Value specified in the array
+         represents physical port address of each display and display in this list will be marked
+         as private. {@see android.view.Display#FLAG_PRIVATE} -->
+    <integer-array translatable="false" name="config_localPrivateDisplayPorts">
+        <item>1</item> <!-- ClusterDisplay -->
+    </integer-array>
 </resources>
diff --git a/shared/config/init.vendor.rc b/shared/config/init.vendor.rc
index cb702a0..83a52c4 100644
--- a/shared/config/init.vendor.rc
+++ b/shared/config/init.vendor.rc
@@ -55,7 +55,7 @@
     # set RLIMIT_MEMLOCK to 64MB
     setrlimit 8 67108864 67108864
 
-on post-fs-data
+on post-fs-data && property:ro.vendor.disable_rename_eth0=
     # works around framework netiface enumeration issue
     # TODO(b/202731768): Add this `start rename_eth0` command to the init.rc for rename_netiface
     start rename_eth0
diff --git a/shared/device.mk b/shared/device.mk
index 8344163..3213aeb 100644
--- a/shared/device.mk
+++ b/shared/device.mk
@@ -772,6 +772,12 @@
 PRODUCT_COPY_FILES += \
     device/google/cuttlefish/shared/config/wpa_supplicant.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/wpa_supplicant.rc
 
+# VirtWifi interface configuration
+ifeq ($(DEVICE_VIRTWIFI_PORT),)
+    DEVICE_VIRTWIFI_PORT := eth2
+endif
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.virtwifi.port=${DEVICE_VIRTWIFI_PORT}
+
 # WLAN driver configuration files
 ifndef LOCAL_WPA_SUPPLICANT_OVERLAY
 LOCAL_WPA_SUPPLICANT_OVERLAY := $(LOCAL_PATH)/config/wpa_supplicant_overlay.conf
@@ -830,7 +836,11 @@
 
 # Enable GPU-intensive background blur support on Cuttlefish when requested by apps
 PRODUCT_VENDOR_PROPERTIES += \
-    ro.surface_flinger.supports_background_blur 1
+    ro.surface_flinger.supports_background_blur=1
+
+# Disable GPU-intensive background blur for widget picker
+PRODUCT_SYSTEM_PROPERTIES += \
+    ro.launcher.depth.widget=0
 
 # Vendor Dlkm Locader
 PRODUCT_PACKAGES += \
diff --git a/shared/foldable/device_state_configuration.xml b/shared/foldable/device_state_configuration.xml
index 9618b11..877a583 100644
--- a/shared/foldable/device_state_configuration.xml
+++ b/shared/foldable/device_state_configuration.xml
@@ -34,4 +34,11 @@
       </lid-switch>
     </conditions>
   </device-state>
+  <device-state>
+    <identifier>3</identifier>
+    <name>REAR_DISPLAY_MODE</name>
+    <flags>
+      <flag>FLAG_EMULATED_ONLY</flag>
+    </flags>
+  </device-state>
 </device-state-config>
diff --git a/shared/foldable/display_layout_configuration.xml b/shared/foldable/display_layout_configuration.xml
index 54b76b1..2c50e76 100644
--- a/shared/foldable/display_layout_configuration.xml
+++ b/shared/foldable/display_layout_configuration.xml
@@ -38,4 +38,17 @@
       <address>4619827551948147201</address>
     </display>
   </layout>
+
+  <layout>
+  <!-- REAR_DISPLAY_MODE: display0 disabled, display1 enabled -->
+    <state>3</state>
+
+    <display enabled="false">
+      <address>4619827259835644672</address>
+    </display>
+
+    <display enabled="true" defaultDisplay="true">
+      <address>4619827551948147201</address>
+    </display>
+  </layout>
 </layouts>
diff --git a/shared/foldable/overlay/frameworks/base/core/res/res/values/config.xml b/shared/foldable/overlay/frameworks/base/core/res/res/values/config.xml
index c93ab5a..8186c97 100644
--- a/shared/foldable/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/shared/foldable/overlay/frameworks/base/core/res/res/values/config.xml
@@ -24,6 +24,7 @@
       <item>0:1</item> <!-- CLOSED : STATE_FLAT -->
       <item>1:2</item> <!-- HALF_OPENED : STATE_HALF_OPENED -->
       <item>2:3</item> <!-- OPENED : STATE_FLIPPED -->
+      <item>3:1</item> <!-- REAR_DISPLAY: STATE_FLAT -->
   </string-array>
   <!-- The device states (supplied by DeviceStateManager) that should be treated as folded by the
        display fold controller. -->
@@ -49,5 +50,5 @@
 
   <!-- Device state that corresponds to rear display mode, feature provided
          through Jetpack WindowManager -->
-  <integer name="config_deviceStateRearDisplay">0</integer>
+  <integer name="config_deviceStateRearDisplay">3</integer>
 </resources>