Merge changes from topic "codec_availability_hal_api" into main

* changes:
  MediaCodec: define available and required resources test api
  media: add available/required resources test api
diff --git a/core/api/current.txt b/core/api/current.txt
index d6b8a51..d2e89b4 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -239,6 +239,7 @@
     field public static final String PROVIDE_OWN_AUTOFILL_SUGGESTIONS = "android.permission.PROVIDE_OWN_AUTOFILL_SUGGESTIONS";
     field public static final String PROVIDE_REMOTE_CREDENTIALS = "android.permission.PROVIDE_REMOTE_CREDENTIALS";
     field public static final String QUERY_ALL_PACKAGES = "android.permission.QUERY_ALL_PACKAGES";
+    field @FlaggedApi("android.permission.flags.ranging_permission_enabled") public static final String RANGING = "android.permission.RANGING";
     field public static final String READ_ASSISTANT_APP_SEARCH_DATA = "android.permission.READ_ASSISTANT_APP_SEARCH_DATA";
     field public static final String READ_BASIC_PHONE_STATE = "android.permission.READ_BASIC_PHONE_STATE";
     field public static final String READ_CALENDAR = "android.permission.READ_CALENDAR";
@@ -13509,7 +13510,7 @@
     field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1
     field public static final int FLAG_USE_APP_ZYGOTE = 8; // 0x8
     field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_CAMERA}, anyOf={android.Manifest.permission.CAMERA}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_CAMERA = 64; // 0x40
-    field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE}, anyOf={android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.CHANGE_NETWORK_STATE, android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.CHANGE_WIFI_MULTICAST_STATE, android.Manifest.permission.NFC, android.Manifest.permission.TRANSMIT_IR, android.Manifest.permission.UWB_RANGING}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE = 16; // 0x10
+    field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE}, anyOf={android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.CHANGE_NETWORK_STATE, android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.CHANGE_WIFI_MULTICAST_STATE, android.Manifest.permission.NFC, android.Manifest.permission.TRANSMIT_IR, android.Manifest.permission.UWB_RANGING, android.Manifest.permission.RANGING}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE = 16; // 0x10
     field @RequiresPermission(value=android.Manifest.permission.FOREGROUND_SERVICE_DATA_SYNC, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_DATA_SYNC = 1; // 0x1
     field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_HEALTH}, anyOf={android.Manifest.permission.ACTIVITY_RECOGNITION, android.Manifest.permission.BODY_SENSORS, android.Manifest.permission.HIGH_SAMPLING_RATE_SENSORS}) public static final int FOREGROUND_SERVICE_TYPE_HEALTH = 256; // 0x100
     field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_LOCATION}, anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_LOCATION = 8; // 0x8
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 1019ce8..f94c97e2 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -684,13 +684,17 @@
     field public static final String OPSTR_PLAY_AUDIO = "android:play_audio";
     field public static final String OPSTR_POST_NOTIFICATION = "android:post_notification";
     field public static final String OPSTR_PROJECT_MEDIA = "android:project_media";
+    field @FlaggedApi("android.permission.flags.ranging_permission_enabled") public static final String OPSTR_RANGING = "android:ranging";
     field @FlaggedApi("android.view.contentprotection.flags.rapid_clear_notifications_by_listener_app_op_enabled") public static final String OPSTR_RAPID_CLEAR_NOTIFICATIONS_BY_LISTENER = "android:rapid_clear_notifications_by_listener";
     field public static final String OPSTR_READ_CLIPBOARD = "android:read_clipboard";
+    field @FlaggedApi("android.permission.flags.replace_body_sensor_permission_enabled") public static final String OPSTR_READ_HEART_RATE = "android:read_heart_rate";
     field public static final String OPSTR_READ_ICC_SMS = "android:read_icc_sms";
     field public static final String OPSTR_READ_MEDIA_AUDIO = "android:read_media_audio";
     field public static final String OPSTR_READ_MEDIA_IMAGES = "android:read_media_images";
     field public static final String OPSTR_READ_MEDIA_VIDEO = "android:read_media_video";
     field public static final String OPSTR_READ_MEDIA_VISUAL_USER_SELECTED = "android:read_media_visual_user_selected";
+    field @FlaggedApi("android.permission.flags.replace_body_sensor_permission_enabled") public static final String OPSTR_READ_OXYGEN_SATURATION = "android:read_oxygen_saturation";
+    field @FlaggedApi("android.permission.flags.replace_body_sensor_permission_enabled") public static final String OPSTR_READ_SKIN_TEMPERATURE = "android:read_skin_temperature";
     field public static final String OPSTR_READ_WRITE_HEALTH_DATA = "android:read_write_health_data";
     field public static final String OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO = "android:receive_ambient_trigger_audio";
     field public static final String OPSTR_RECEIVE_EMERGENCY_BROADCAST = "android:receive_emergency_broadcast";
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 091d5ab..3eea903 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -54,6 +54,7 @@
 import android.content.pm.ParceledListSlice;
 import android.database.DatabaseUtils;
 import android.health.connect.HealthConnectManager;
+import android.health.connect.HealthPermissions;
 import android.media.AudioAttributes.AttributeUsage;
 import android.media.MediaRouter2;
 import android.os.Binder;
@@ -1608,9 +1609,25 @@
     public static final int OP_RECEIVE_SENSITIVE_NOTIFICATIONS =
             AppProtoEnums.APP_OP_RECEIVE_SENSITIVE_NOTIFICATIONS;
 
+    /** @hide Access to read heart rate sensor. */
+    public static final int OP_READ_HEART_RATE = AppProtoEnums.APP_OP_READ_HEART_RATE;
+
+    /** @hide Access to read skin temperature. */
+    public static final int OP_READ_SKIN_TEMPERATURE = AppProtoEnums.APP_OP_READ_SKIN_TEMPERATURE;
+
+    /**
+     * Allows an app to range with nearby devices using any ranging technology available.
+     *
+     * @hide
+     */
+    public static final int OP_RANGING = AppProtoEnums.APP_OP_RANGING;
+
+    /** @hide Access to read oxygen saturation. */
+    public static final int OP_READ_OXYGEN_SATURATION = AppProtoEnums.APP_OP_READ_OXYGEN_SATURATION;
+
     /** @hide */
     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
-    public static final int _NUM_OP = 149;
+    public static final int _NUM_OP = 153;
 
     /**
      * All app ops represented as strings.
@@ -1763,6 +1780,10 @@
             OPSTR_UNARCHIVAL_CONFIRMATION,
             OPSTR_EMERGENCY_LOCATION,
             OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS,
+            OPSTR_READ_HEART_RATE,
+            OPSTR_READ_SKIN_TEMPERATURE,
+            OPSTR_RANGING,
+            OPSTR_READ_OXYGEN_SATURATION,
     })
     public @interface AppOpString {}
 
@@ -2500,6 +2521,26 @@
     public static final String OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS =
             "android:receive_sensitive_notifications";
 
+    /** @hide Access to read heart rate sensor. */
+    @SystemApi
+    @FlaggedApi(Flags.FLAG_REPLACE_BODY_SENSOR_PERMISSION_ENABLED)
+    public static final String OPSTR_READ_HEART_RATE = "android:read_heart_rate";
+
+    /** @hide Access to read oxygen saturation. */
+    @SystemApi
+    @FlaggedApi(Flags.FLAG_REPLACE_BODY_SENSOR_PERMISSION_ENABLED)
+    public static final String OPSTR_READ_OXYGEN_SATURATION = "android:read_oxygen_saturation";
+
+    /** @hide Access to read skin temperature. */
+    @SystemApi
+    @FlaggedApi(Flags.FLAG_REPLACE_BODY_SENSOR_PERMISSION_ENABLED)
+    public static final String OPSTR_READ_SKIN_TEMPERATURE = "android:read_skin_temperature";
+
+    /** @hide Access to ranging */
+    @SystemApi
+    @FlaggedApi(Flags.FLAG_RANGING_PERMISSION_ENABLED)
+    public static final String OPSTR_RANGING = "android:ranging";
+
     /** {@link #sAppOpsToNote} not initialized yet for this op */
     private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0;
     /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */
@@ -2571,8 +2612,13 @@
             OP_BLUETOOTH_ADVERTISE,
             OP_UWB_RANGING,
             OP_NEARBY_WIFI_DEVICES,
+            Flags.rangingPermissionEnabled() ? OP_RANGING : OP_NONE,
             // Notifications
             OP_POST_NOTIFICATION,
+            // Health
+            Flags.replaceBodySensorPermissionEnabled() ? OP_READ_HEART_RATE : OP_NONE,
+            Flags.replaceBodySensorPermissionEnabled() ? OP_READ_SKIN_TEMPERATURE : OP_NONE,
+            Flags.replaceBodySensorPermissionEnabled() ? OP_READ_OXYGEN_SATURATION : OP_NONE,
     };
 
     /**
@@ -3080,6 +3126,24 @@
         new AppOpInfo.Builder(OP_RECEIVE_SENSITIVE_NOTIFICATIONS,
                 OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS, "RECEIVE_SENSITIVE_NOTIFICATIONS")
                 .setDefaultMode(MODE_IGNORED).build(),
+        new AppOpInfo.Builder(OP_READ_HEART_RATE, OPSTR_READ_HEART_RATE, "READ_HEART_RATE")
+                .setPermission(Flags.replaceBodySensorPermissionEnabled()
+                ? HealthPermissions.READ_HEART_RATE : null)
+                .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(),
+        new AppOpInfo.Builder(OP_READ_SKIN_TEMPERATURE, OPSTR_READ_SKIN_TEMPERATURE,
+                "READ_SKIN_TEMPERATURE").setPermission(
+                    Flags.replaceBodySensorPermissionEnabled()
+                        ? HealthPermissions.READ_SKIN_TEMPERATURE : null)
+                .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(),
+        new AppOpInfo.Builder(OP_RANGING, OPSTR_RANGING, "RANGING")
+                .setPermission(Flags.rangingPermissionEnabled()
+                ? Manifest.permission.RANGING : null)
+                .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(),
+        new AppOpInfo.Builder(OP_READ_OXYGEN_SATURATION, OPSTR_READ_OXYGEN_SATURATION,
+                "READ_OXYGEN_SATURATION").setPermission(
+                    Flags.replaceBodySensorPermissionEnabled()
+                        ? HealthPermissions.READ_OXYGEN_SATURATION : null)
+                .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(),
     };
 
     // The number of longs needed to form a full bitmask of app ops
@@ -3133,6 +3197,10 @@
             }
         }
         for (int op : RUNTIME_PERMISSION_OPS) {
+            if (op == OP_NONE) {
+                // Skip ops with a disabled feature flag.
+                continue;
+            }
             if (sAppOpInfos[op].permission != null) {
                 sPermToOp.put(sAppOpInfos[op].permission, op);
             }
diff --git a/core/java/android/app/ForegroundServiceTypePolicy.java b/core/java/android/app/ForegroundServiceTypePolicy.java
index d1e517b..16444dc 100644
--- a/core/java/android/app/ForegroundServiceTypePolicy.java
+++ b/core/java/android/app/ForegroundServiceTypePolicy.java
@@ -398,6 +398,7 @@
                 new RegularPermission(Manifest.permission.NFC),
                 new RegularPermission(Manifest.permission.TRANSMIT_IR),
                 new RegularPermission(Manifest.permission.UWB_RANGING),
+                new RegularPermission(Manifest.permission.RANGING),
                 new UsbDevicePermission(),
                 new UsbAccessoryPermission(),
             }, false),
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index 5b0cee7..4285b0a 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -251,6 +251,7 @@
      * {@link android.Manifest.permission#NFC},
      * {@link android.Manifest.permission#TRANSMIT_IR},
      * {@link android.Manifest.permission#UWB_RANGING},
+     * {@link android.Manifest.permission#RANGING},
      * or has been granted the access to one of the attached USB devices/accessories.
      */
     @RequiresPermission(
@@ -267,6 +268,7 @@
                 Manifest.permission.NFC,
                 Manifest.permission.TRANSMIT_IR,
                 Manifest.permission.UWB_RANGING,
+                Manifest.permission.RANGING,
             },
             conditional = true
     )
diff --git a/core/java/android/permission/flags.aconfig b/core/java/android/permission/flags.aconfig
index e029e52..5c54ecd 100644
--- a/core/java/android/permission/flags.aconfig
+++ b/core/java/android/permission/flags.aconfig
@@ -213,3 +213,21 @@
         purpose: PURPOSE_BUGFIX
     }
 }
+
+flag {
+    name: "replace_body_sensor_permission_enabled"
+    is_fixed_read_only: true
+    is_exported: true
+    namespace: "android_health_services"
+    description: "Enables replacement of BODY_SENSORS/BODY_SENSORS_BACKGROUND permissions with granular health permissions READ_HEART_RATE, READ_SKIN_TEMPERATURE, READ_OXYGEN_SATURATION, and READ_HEALTH_DATA_IN_BACKGROUND"
+    bug: "364638912"
+}
+
+flag {
+    name: "ranging_permission_enabled"
+    is_fixed_read_only: true
+    is_exported: true
+    namespace: "uwb"
+    description: "This fixed read-only flag is used to enable new ranging permission for all ranging use cases."
+    bug: "370977414"
+}
diff --git a/core/jni/com_android_internal_content_FileSystemUtils.cpp b/core/jni/com_android_internal_content_FileSystemUtils.cpp
index 6c72544..76ead2a 100644
--- a/core/jni/com_android_internal_content_FileSystemUtils.cpp
+++ b/core/jni/com_android_internal_content_FileSystemUtils.cpp
@@ -22,7 +22,6 @@
 #include <android-base/hex.h>
 #include <android-base/unique_fd.h>
 #include <bionic/macros.h>
-#include <elf.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <inttypes.h>
@@ -204,7 +203,8 @@
     return true;
 }
 
-bool punchHolesInElf64(const char *filePath, const uint64_t offset) {
+bool getLoadSegmentPhdrs(const char *filePath, const uint64_t offset,
+                         std::vector<Elf64_Phdr> &programHeaders) {
     // Open Elf file
     Elf64_Ehdr ehdr;
     std::ifstream inputStream(filePath, std::ifstream::in);
@@ -227,11 +227,6 @@
     uint64_t programHeaderOffset = ehdr.e_phoff;
     uint16_t programHeaderNum = ehdr.e_phnum;
 
-    IF_ALOGD() {
-        ALOGD("Punching holes in file: %s programHeaderOffset: %" PRIu64 " programHeaderNum: %hu",
-              filePath, programHeaderOffset, programHeaderNum);
-    }
-
     // if this is a zip file, also consider elf offset inside a file
     uint64_t phOffset;
     if (__builtin_add_overflow(offset, programHeaderOffset, &phOffset)) {
@@ -240,7 +235,6 @@
     }
     inputStream.seekg(phOffset);
 
-    std::vector<Elf64_Phdr> programHeaders;
     for (int headerIndex = 0; headerIndex < programHeaderNum; headerIndex++) {
         Elf64_Phdr header;
         inputStream.read((char *)&header, sizeof(header));
@@ -254,6 +248,15 @@
         programHeaders.push_back(header);
     }
 
+    return true;
+}
+
+bool punchHolesInElf64(const char *filePath, const uint64_t offset) {
+    std::vector<Elf64_Phdr> programHeaders;
+    if (!getLoadSegmentPhdrs(filePath, offset, programHeaders)) {
+        ALOGE("Failed to read program headers from ELF file.");
+        return false;
+    }
     return punchHoles(filePath, offset, programHeaders);
 }
 
diff --git a/core/jni/com_android_internal_content_FileSystemUtils.h b/core/jni/com_android_internal_content_FileSystemUtils.h
index 52445e2..4a95686c 100644
--- a/core/jni/com_android_internal_content_FileSystemUtils.h
+++ b/core/jni/com_android_internal_content_FileSystemUtils.h
@@ -15,8 +15,11 @@
  */
 #pragma once
 
+#include <elf.h>
 #include <sys/types.h>
 
+#include <vector>
+
 namespace android {
 
 /*
@@ -35,4 +38,11 @@
  */
 bool punchHolesInZip(const char* filePath, uint64_t offset, uint16_t extraFieldLen);
 
+/*
+ * This function reads program headers from ELF file. ELF can be specified with file path directly
+ * or it should be at offset inside Apk. Program headers passed to function is populated.
+ */
+bool getLoadSegmentPhdrs(const char* filePath, const uint64_t offset,
+                         std::vector<Elf64_Phdr>& programHeaders);
+
 } // namespace android
\ No newline at end of file
diff --git a/core/res/Android.bp b/core/res/Android.bp
index a44e92c..4254a47 100644
--- a/core/res/Android.bp
+++ b/core/res/Android.bp
@@ -163,6 +163,7 @@
         "android.net.platform.flags-aconfig",
         "com.android.window.flags.window-aconfig",
         "android.permission.flags-aconfig",
+        "ranging_aconfig_flags",
     ],
 }
 
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index e4c56a6..101ba11 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2406,6 +2406,16 @@
                 android:label="@string/permlab_nearby_wifi_devices"
                 android:protectionLevel="dangerous" />
 
+    <!-- Required to be able to range to devices using generic ranging module.
+         @FlaggedApi("android.permission.flags.ranging_permission_enabled")
+         <p>Protection level: dangerous -->
+    <permission android:name="android.permission.RANGING"
+        android:permissionGroup="android.permission-group.UNDEFINED"
+        android:description="@string/permdesc_ranging"
+        android:label="@string/permlab_ranging"
+        android:protectionLevel="dangerous"
+        android:featureFlag="android.permission.flags.ranging_permission_enabled"/>
+
     <!-- @SystemApi @TestApi Allows an application to suspend other apps, which will prevent the
          user from using them until they are unsuspended.
          @hide
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 1a2f0cc..aa192ec 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1770,6 +1770,11 @@
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=140]-->
     <string name="permdesc_nearby_wifi_devices">Allows the app to advertise, connect, and determine the relative position of nearby Wi\u2011Fi devices</string>
 
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=50]-->
+    <string name="permlab_ranging">determine relative position between nearby devices</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=120]-->
+    <string name="permdesc_ranging">Allow the app to determine relative position between nearby devices</string>
+
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_preferredPaymentInfo">Preferred NFC Payment Service Information</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/data/sounds/Android.bp b/data/sounds/Android.bp
new file mode 100644
index 0000000..65d4872
--- /dev/null
+++ b/data/sounds/Android.bp
@@ -0,0 +1,304 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+phony {
+    name: "frameworks_sounds",
+    required: [
+        "frameworks_alarm_sounds",
+        "frameworks_notifications_sounds",
+        "frameworks_ringtones_sounds",
+        "frameworks_ui_sounds",
+        "frameworks_ui_48k_sounds",
+    ],
+}
+
+prebuilt_media {
+    name: "frameworks_alarm_sounds",
+    srcs: [
+        "Alarm_Beep_01.ogg",
+        "Alarm_Beep_02.ogg",
+        "Alarm_Beep_03.ogg",
+        "Alarm_Buzzer.ogg",
+        "Alarm_Classic.ogg",
+        "Alarm_Rooster_02.ogg",
+        "alarms/ogg/Argon.ogg",
+        "alarms/ogg/Barium.ogg",
+        "alarms/ogg/Carbon.ogg",
+        "alarms/ogg/Helium.ogg",
+        "alarms/ogg/Krypton.ogg",
+        "alarms/ogg/Neon.ogg",
+        "alarms/ogg/Neptunium.ogg",
+        "alarms/ogg/Osmium.ogg",
+        "alarms/ogg/Oxygen.ogg",
+        "alarms/ogg/Platinum.ogg",
+        "alarms/ogg/Promethium.ogg",
+        "alarms/ogg/Scandium.ogg",
+    ],
+    relative_install_path: "audio/alarms",
+    product_specific: true,
+    no_full_install: true,
+}
+
+prebuilt_media {
+    name: "frameworks_notifications_sounds",
+    srcs: [
+        "notifications/ogg/Adara.ogg",
+        "notifications/Aldebaran.ogg",
+        "notifications/Altair.ogg",
+        "notifications/ogg/Alya.ogg",
+        "notifications/Antares.ogg",
+        "notifications/ogg/Antimony.ogg",
+        "notifications/ogg/Arcturus.ogg",
+        "notifications/ogg/Argon.ogg",
+        "notifications/Beat_Box_Android.ogg",
+        "notifications/ogg/Bellatrix.ogg",
+        "notifications/ogg/Beryllium.ogg",
+        "notifications/Betelgeuse.ogg",
+        "newwavelabs/CaffeineSnake.ogg",
+        "notifications/Canopus.ogg",
+        "notifications/ogg/Capella.ogg",
+        "notifications/Castor.ogg",
+        "notifications/ogg/CetiAlpha.ogg",
+        "notifications/ogg/Cobalt.ogg",
+        "notifications/Cricket.ogg",
+        "newwavelabs/DearDeer.ogg",
+        "notifications/Deneb.ogg",
+        "notifications/Doink.ogg",
+        "newwavelabs/DontPanic.ogg",
+        "notifications/Drip.ogg",
+        "notifications/Electra.ogg",
+        "F1_MissedCall.ogg",
+        "F1_New_MMS.ogg",
+        "F1_New_SMS.ogg",
+        "notifications/ogg/Fluorine.ogg",
+        "notifications/Fomalhaut.ogg",
+        "notifications/ogg/Gallium.ogg",
+        "notifications/Heaven.ogg",
+        "notifications/ogg/Helium.ogg",
+        "newwavelabs/Highwire.ogg",
+        "notifications/ogg/Hojus.ogg",
+        "notifications/ogg/Iridium.ogg",
+        "notifications/ogg/Krypton.ogg",
+        "newwavelabs/KzurbSonar.ogg",
+        "notifications/ogg/Lalande.ogg",
+        "notifications/Merope.ogg",
+        "notifications/ogg/Mira.ogg",
+        "newwavelabs/OnTheHunt.ogg",
+        "notifications/ogg/Palladium.ogg",
+        "notifications/Plastic_Pipe.ogg",
+        "notifications/ogg/Polaris.ogg",
+        "notifications/ogg/Pollux.ogg",
+        "notifications/ogg/Procyon.ogg",
+        "notifications/ogg/Proxima.ogg",
+        "notifications/ogg/Radon.ogg",
+        "notifications/ogg/Rubidium.ogg",
+        "notifications/ogg/Selenium.ogg",
+        "notifications/ogg/Shaula.ogg",
+        "notifications/Sirrah.ogg",
+        "notifications/SpaceSeed.ogg",
+        "notifications/ogg/Spica.ogg",
+        "notifications/ogg/Strontium.ogg",
+        "notifications/ogg/Syrma.ogg",
+        "notifications/TaDa.ogg",
+        "notifications/ogg/Talitha.ogg",
+        "notifications/ogg/Tejat.ogg",
+        "notifications/ogg/Thallium.ogg",
+        "notifications/Tinkerbell.ogg",
+        "notifications/ogg/Upsilon.ogg",
+        "notifications/ogg/Vega.ogg",
+        "newwavelabs/Voila.ogg",
+        "notifications/ogg/Xenon.ogg",
+        "notifications/ogg/Zirconium.ogg",
+        "notifications/arcturus.ogg",
+        "notifications/moonbeam.ogg",
+        "notifications/pixiedust.ogg",
+        "notifications/pizzicato.ogg",
+        "notifications/regulus.ogg",
+        "notifications/sirius.ogg",
+        "notifications/tweeters.ogg",
+        "notifications/vega.ogg",
+    ],
+    relative_install_path: "audio/notifications",
+    product_specific: true,
+    no_full_install: true,
+}
+
+prebuilt_media {
+    name: "frameworks_ringtones_sounds",
+    srcs: [
+        "ringtones/ANDROMEDA.ogg",
+        "ringtones/ogg/Andromeda.ogg",
+        "ringtones/ogg/Aquila.ogg",
+        "ringtones/ogg/ArgoNavis.ogg",
+        "ringtones/ogg/Atria.ogg",
+        "ringtones/BOOTES.ogg",
+        "newwavelabs/Backroad.ogg",
+        "newwavelabs/BeatPlucker.ogg",
+        "newwavelabs/BentleyDubs.ogg",
+        "newwavelabs/Big_Easy.ogg",
+        "newwavelabs/BirdLoop.ogg",
+        "newwavelabs/Bollywood.ogg",
+        "newwavelabs/BussaMove.ogg",
+        "ringtones/CANISMAJOR.ogg",
+        "ringtones/CASSIOPEIA.ogg",
+        "newwavelabs/Cairo.ogg",
+        "newwavelabs/Calypso_Steel.ogg",
+        "ringtones/ogg/CanisMajor.ogg",
+        "newwavelabs/CaribbeanIce.ogg",
+        "ringtones/ogg/Carina.ogg",
+        "ringtones/ogg/Centaurus.ogg",
+        "newwavelabs/Champagne_Edition.ogg",
+        "newwavelabs/Club_Cubano.ogg",
+        "newwavelabs/CrayonRock.ogg",
+        "newwavelabs/CrazyDream.ogg",
+        "newwavelabs/CurveBall.ogg",
+        "ringtones/ogg/Cygnus.ogg",
+        "newwavelabs/DancinFool.ogg",
+        "newwavelabs/Ding.ogg",
+        "newwavelabs/DonMessWivIt.ogg",
+        "ringtones/ogg/Draco.ogg",
+        "newwavelabs/DreamTheme.ogg",
+        "newwavelabs/Eastern_Sky.ogg",
+        "newwavelabs/Enter_the_Nexus.ogg",
+        "ringtones/Eridani.ogg",
+        "newwavelabs/EtherShake.ogg",
+        "ringtones/FreeFlight.ogg",
+        "newwavelabs/FriendlyGhost.ogg",
+        "newwavelabs/Funk_Yall.ogg",
+        "newwavelabs/GameOverGuitar.ogg",
+        "newwavelabs/Gimme_Mo_Town.ogg",
+        "ringtones/ogg/Girtab.ogg",
+        "newwavelabs/Glacial_Groove.ogg",
+        "newwavelabs/Growl.ogg",
+        "newwavelabs/HalfwayHome.ogg",
+        "ringtones/ogg/Hydra.ogg",
+        "newwavelabs/InsertCoin.ogg",
+        "ringtones/ogg/Kuma.ogg",
+        "newwavelabs/LoopyLounge.ogg",
+        "newwavelabs/LoveFlute.ogg",
+        "ringtones/Lyra.ogg",
+        "ringtones/ogg/Machina.ogg",
+        "newwavelabs/MidEvilJaunt.ogg",
+        "newwavelabs/MildlyAlarming.ogg",
+        "newwavelabs/Nairobi.ogg",
+        "newwavelabs/Nassau.ogg",
+        "newwavelabs/NewPlayer.ogg",
+        "newwavelabs/No_Limits.ogg",
+        "newwavelabs/Noises1.ogg",
+        "newwavelabs/Noises2.ogg",
+        "newwavelabs/Noises3.ogg",
+        "newwavelabs/OrganDub.ogg",
+        "ringtones/ogg/Orion.ogg",
+        "ringtones/PERSEUS.ogg",
+        "newwavelabs/Paradise_Island.ogg",
+        "ringtones/ogg/Pegasus.ogg",
+        "ringtones/ogg/Perseus.ogg",
+        "newwavelabs/Playa.ogg",
+        "ringtones/ogg/Pyxis.ogg",
+        "ringtones/ogg/Rasalas.ogg",
+        "newwavelabs/Revelation.ogg",
+        "ringtones/ogg/Rigel.ogg",
+        "Ring_Classic_02.ogg",
+        "Ring_Digital_02.ogg",
+        "Ring_Synth_02.ogg",
+        "Ring_Synth_04.ogg",
+        "newwavelabs/Road_Trip.ogg",
+        "newwavelabs/RomancingTheTone.ogg",
+        "newwavelabs/Safari.ogg",
+        "newwavelabs/Savannah.ogg",
+        "ringtones/ogg/Scarabaeus.ogg",
+        "ringtones/ogg/Sceptrum.ogg",
+        "newwavelabs/Seville.ogg",
+        "newwavelabs/Shes_All_That.ogg",
+        "newwavelabs/SilkyWay.ogg",
+        "newwavelabs/SitarVsSitar.ogg",
+        "ringtones/ogg/Solarium.ogg",
+        "newwavelabs/SpringyJalopy.ogg",
+        "newwavelabs/Steppin_Out.ogg",
+        "newwavelabs/Terminated.ogg",
+        "ringtones/Testudo.ogg",
+        "ringtones/ogg/Themos.ogg",
+        "newwavelabs/Third_Eye.ogg",
+        "newwavelabs/Thunderfoot.ogg",
+        "newwavelabs/TwirlAway.ogg",
+        "ringtones/URSAMINOR.ogg",
+        "ringtones/ogg/UrsaMinor.ogg",
+        "newwavelabs/VeryAlarmed.ogg",
+        "ringtones/Vespa.ogg",
+        "newwavelabs/World.ogg",
+        "ringtones/ogg/Zeta.ogg",
+        "ringtones/hydra.ogg",
+    ],
+    relative_install_path: "audio/ringtones",
+    product_specific: true,
+    no_full_install: true,
+}
+
+prebuilt_media {
+    name: "frameworks_ui_48k_sounds",
+    srcs: [
+        "effects/ogg/Effect_Tick_48k.ogg",
+        "effects/ogg/KeypressDelete_120_48k.ogg",
+        "effects/ogg/KeypressReturn_120_48k.ogg",
+        "effects/ogg/KeypressSpacebar_120_48k.ogg",
+        "effects/ogg/KeypressStandard_120_48k.ogg",
+        "effects/ogg/KeypressInvalid_120_48k.ogg",
+        "effects/ogg/Trusted_48k.ogg",
+        "effects/ogg/VideoRecord_48k.ogg",
+        "effects/ogg/VideoStop_48k.ogg",
+        "effects/ogg/camera_click_48k.ogg",
+    ],
+    dsts: [
+        "Effect_Tick.ogg",
+        "KeypressDelete.ogg",
+        "KeypressReturn.ogg",
+        "KeypressSpacebar.ogg",
+        "KeypressStandard.ogg",
+        "KeypressInvalid.ogg",
+        "Trusted.ogg",
+        "VideoRecord.ogg",
+        "VideoStop.ogg",
+        "camera_click.ogg",
+    ],
+    relative_install_path: "audio/ui",
+    product_specific: true,
+    no_full_install: true,
+}
+
+prebuilt_media {
+    name: "frameworks_ui_sounds",
+    srcs: [
+        "effects/ogg/Dock.ogg",
+        "effects/ogg/Lock.ogg",
+        "effects/ogg/LowBattery.ogg",
+        "effects/ogg/Undock.ogg",
+        "effects/ogg/Unlock.ogg",
+        "effects/ogg/WirelessChargingStarted.ogg",
+        "effects/ogg/camera_focus.ogg",
+        "effects/ogg/ChargingStarted.ogg",
+        "effects/ogg/InCallNotification.ogg",
+        "effects/ogg/NFCFailure.ogg",
+        "effects/ogg/NFCInitiated.ogg",
+        "effects/ogg/NFCSuccess.ogg",
+        "effects/ogg/NFCTransferComplete.ogg",
+        "effects/ogg/NFCTransferInitiated.ogg",
+    ],
+    relative_install_path: "audio/ui",
+    product_specific: true,
+    no_full_install: true,
+}
diff --git a/errorprone/java/com/google/errorprone/bugpatterns/android/EfficientParcelableChecker.java b/errorprone/java/com/google/errorprone/bugpatterns/android/EfficientParcelableChecker.java
index cae5d8e..35b2375 100644
--- a/errorprone/java/com/google/errorprone/bugpatterns/android/EfficientParcelableChecker.java
+++ b/errorprone/java/com/google/errorprone/bugpatterns/android/EfficientParcelableChecker.java
@@ -96,7 +96,7 @@
             }
             if (WRITE_PARCELABLE.matches(tree, state)) {
                 return buildDescription(tree)
-                        .setMessage("Recommended to use 'item.writeToParcel()' to improve "
+                        .setMessage("Recommended to use 'writeTypedObject()' to improve "
                                 + "efficiency; saves overhead of Parcelable class name")
                         .build();
             }
diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt
index a23845f..c25f77b 100644
--- a/nfc/api/system-current.txt
+++ b/nfc/api/system-current.txt
@@ -107,6 +107,7 @@
     method public void onRfDiscoveryStarted(boolean);
     method public void onRfFieldActivated(boolean);
     method public void onRoutingChanged();
+    method public void onRoutingTableFull();
     method public void onStateUpdated(int);
     method public void onTagConnected(boolean);
     method public void onTagDispatch(@NonNull java.util.function.Consumer<java.lang.Boolean>);
diff --git a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl
index b102e87..fb793b0 100644
--- a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl
+++ b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl
@@ -52,5 +52,6 @@
    void onNdefMessage(in Tag tag, in NdefMessage message, in ResultReceiver hasOemExecutableContent);
    void onLaunchHceAppChooserActivity(in String selectedAid, in List<ApduServiceInfo> services, in ComponentName failedComponent, in String category);
    void onLaunchHceTapAgainActivity(in ApduServiceInfo service, in String category);
+   void onRoutingTableFull();
    void onLogEventNotified(in OemLogItems item);
 }
diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java
index abd99bc..57ee981 100644
--- a/nfc/java/android/nfc/NfcOemExtension.java
+++ b/nfc/java/android/nfc/NfcOemExtension.java
@@ -394,6 +394,13 @@
         void onLaunchHceTapAgainDialog(@NonNull ApduServiceInfo service, @NonNull String category);
 
         /**
+         * Callback to indicate that routing table is full and the OEM can optionally launch a
+         * dialog to request the user to remove some Card Emulation apps from the device to free
+         * routing table space.
+         */
+        void onRoutingTableFull();
+
+        /**
          * Callback when OEM specified log event are notified.
          * @param item the log items that contains log information of NFC event.
          */
@@ -853,6 +860,12 @@
                     handleVoidCallback(enabled, cb::onReaderOptionChanged, ex));
         }
 
+        public void onRoutingTableFull() throws RemoteException {
+            mCallbackMap.forEach((cb, ex) ->
+                    handleVoidCallback(null,
+                            (Object input) -> cb.onRoutingTableFull(), ex));
+        }
+
         @Override
         public void onGetOemAppSearchIntent(List<String> packages, ResultReceiver intentConsumer)
                 throws RemoteException {
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 18dd5c1..676ff97 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -715,6 +715,9 @@
     <uses-permission android:name="android.permission.UWB_PRIVILEGED" />
     <uses-permission android:name="android.permission.UWB_RANGING" />
 
+    <!-- Permission required for CTS test - CtsRangingTestCases -->
+    <uses-permission android:name="android.permission.RANGING" />
+
     <!-- Permission required for CTS test - CtsAlarmManagerTestCases -->
     <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
 
diff --git a/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java b/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
index bb4ae96..a132876b 100644
--- a/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
+++ b/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
@@ -46,7 +46,6 @@
 import com.android.internal.R;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.server.LocalServices;
-import com.android.server.integrity.model.RuleMetadata;
 
 import java.io.File;
 import java.nio.charset.StandardCharsets;
diff --git a/services/core/java/com/android/server/integrity/model/IntegrityCheckResult.java b/services/core/java/com/android/server/integrity/model/IntegrityCheckResult.java
deleted file mode 100644
index b0647fc..0000000
--- a/services/core/java/com/android/server/integrity/model/IntegrityCheckResult.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.integrity.model;
-
-import android.annotation.Nullable;
-import android.content.integrity.Rule;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A class encapsulating the result from the evaluation engine after evaluating rules against app
- * install metadata.
- *
- * <p>It contains the outcome effect (whether to allow or block the install), and the rule causing
- * that effect.
- */
-public final class IntegrityCheckResult {
-
-    public enum Effect {
-        ALLOW,
-        DENY
-    }
-
-    private final Effect mEffect;
-    private final List<Rule> mRuleList;
-
-    private IntegrityCheckResult(Effect effect, @Nullable List<Rule> ruleList) {
-        this.mEffect = effect;
-        this.mRuleList = ruleList;
-    }
-
-    public Effect getEffect() {
-        return mEffect;
-    }
-
-    public List<Rule> getMatchedRules() {
-        return mRuleList;
-    }
-
-    /**
-     * Create an ALLOW evaluation outcome.
-     *
-     * @return An evaluation outcome with ALLOW effect and no rule.
-     */
-    public static IntegrityCheckResult allow() {
-        return new IntegrityCheckResult(Effect.ALLOW, Collections.emptyList());
-    }
-
-    /**
-     * Create an ALLOW evaluation outcome.
-     *
-     * @return An evaluation outcome with ALLOW effect and rule causing that effect.
-     */
-    public static IntegrityCheckResult allow(List<Rule> ruleList) {
-        return new IntegrityCheckResult(Effect.ALLOW, ruleList);
-    }
-
-    /**
-     * Create a DENY evaluation outcome.
-     *
-     * @param ruleList All valid rules that cause the DENY effect.
-     * @return An evaluation outcome with DENY effect and rule causing that effect.
-     */
-    public static IntegrityCheckResult deny(List<Rule> ruleList) {
-        return new IntegrityCheckResult(Effect.DENY, ruleList);
-    }
-
-    /** Returns true when the {@code mEffect} is caused by an app certificate mismatch. */
-    public boolean isCausedByAppCertRule() {
-        return mRuleList.stream().anyMatch(rule -> rule.getFormula().isAppCertificateFormula());
-    }
-
-    /** Returns true when the {@code mEffect} is caused by an installer rule. */
-    public boolean isCausedByInstallerRule() {
-        return mRuleList.stream().anyMatch(rule -> rule.getFormula().isInstallerFormula());
-    }
-
-}
diff --git a/services/core/java/com/android/server/integrity/model/RuleMetadata.java b/services/core/java/com/android/server/integrity/model/RuleMetadata.java
deleted file mode 100644
index 6b582ae..0000000
--- a/services/core/java/com/android/server/integrity/model/RuleMetadata.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.integrity.model;
-
-import android.annotation.Nullable;
-
-/** Data class containing relevant metadata associated with a rule set. */
-public class RuleMetadata {
-
-    private final String mRuleProvider;
-    private final String mVersion;
-
-    public RuleMetadata(String ruleProvider, String version) {
-        mRuleProvider = ruleProvider;
-        mVersion = version;
-    }
-
-    @Nullable
-    public String getRuleProvider() {
-        return mRuleProvider;
-    }
-
-    @Nullable
-    public String getVersion() {
-        return mVersion;
-    }
-}
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index ada812e..d99fc3e 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -235,6 +235,7 @@
         NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_SCAN);
         NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.UWB_RANGING);
         NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.NEARBY_WIFI_DEVICES);
+        NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.RANGING);
     }
 
     private static final Set<String> NOTIFICATION_PERMISSIONS = new ArraySet<>();
diff --git a/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java b/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java
index 93aa10b..fd22118 100644
--- a/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java
+++ b/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java
@@ -68,7 +68,6 @@
 
 import com.android.internal.R;
 import com.android.server.compat.PlatformCompat;
-import com.android.server.integrity.model.IntegrityCheckResult;
 import com.android.server.testutils.TestUtils;
 
 import org.junit.After;
diff --git a/services/tests/servicestests/src/com/android/server/integrity/model/IntegrityCheckResultTest.java b/services/tests/servicestests/src/com/android/server/integrity/model/IntegrityCheckResultTest.java
deleted file mode 100644
index d31ed68..0000000
--- a/services/tests/servicestests/src/com/android/server/integrity/model/IntegrityCheckResultTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.integrity.model;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.integrity.AtomicFormula;
-import android.content.integrity.CompoundFormula;
-import android.content.integrity.Rule;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-@RunWith(JUnit4.class)
-public class IntegrityCheckResultTest {
-
-    @Test
-    public void createAllowResult() {
-        IntegrityCheckResult allowResult = IntegrityCheckResult.allow();
-
-        assertThat(allowResult.getEffect()).isEqualTo(IntegrityCheckResult.Effect.ALLOW);
-        assertThat(allowResult.getMatchedRules()).isEmpty();
-    }
-
-    @Test
-    public void createAllowResultWithRule() {
-        String packageName = "com.test.deny";
-        Rule forceAllowRule =
-                new Rule(
-                        new AtomicFormula.StringAtomicFormula(AtomicFormula.PACKAGE_NAME,
-                                packageName),
-                        Rule.FORCE_ALLOW);
-
-        IntegrityCheckResult allowResult =
-                IntegrityCheckResult.allow(Collections.singletonList(forceAllowRule));
-
-        assertThat(allowResult.getEffect()).isEqualTo(IntegrityCheckResult.Effect.ALLOW);
-        assertThat(allowResult.getMatchedRules()).containsExactly(forceAllowRule);
-    }
-
-    @Test
-    public void createDenyResultWithRule() {
-        String packageName = "com.test.deny";
-        Rule failedRule =
-                new Rule(
-                        new AtomicFormula.StringAtomicFormula(AtomicFormula.PACKAGE_NAME,
-                                packageName),
-                        Rule.DENY);
-
-        IntegrityCheckResult denyResult =
-                IntegrityCheckResult.deny(Collections.singletonList(failedRule));
-
-        assertThat(denyResult.getEffect()).isEqualTo(IntegrityCheckResult.Effect.DENY);
-        assertThat(denyResult.getMatchedRules()).containsExactly(failedRule);
-    }
-
-    @Test
-    public void isDenyCausedByAppCertificate() {
-        String packageName = "com.test.deny";
-        String appCert = "app-cert";
-        Rule failedRule =
-                new Rule(
-                        new CompoundFormula(
-                                CompoundFormula.AND,
-                                Arrays.asList(
-                                        new AtomicFormula.StringAtomicFormula(
-                                                AtomicFormula.PACKAGE_NAME, packageName),
-                                        new AtomicFormula.StringAtomicFormula(
-                                                AtomicFormula.APP_CERTIFICATE, appCert))),
-                        Rule.DENY);
-        Rule otherFailedRule =
-                new Rule(
-                        new AtomicFormula.LongAtomicFormula(AtomicFormula.VERSION_CODE,
-                                AtomicFormula.EQ, 12),
-                        Rule.DENY);
-
-        IntegrityCheckResult denyResult =
-                IntegrityCheckResult.deny(Arrays.asList(failedRule, otherFailedRule));
-
-        assertThat(denyResult.isCausedByAppCertRule()).isTrue();
-        assertThat(denyResult.isCausedByInstallerRule()).isFalse();
-    }
-
-    @Test
-    public void isDenyCausedByInstaller() {
-        String packageName = "com.test.deny";
-        String appCert = "app-cert";
-        Rule failedRule =
-                new Rule(
-                        new CompoundFormula(
-                                CompoundFormula.AND,
-                                Arrays.asList(
-                                        new AtomicFormula.StringAtomicFormula(
-                                                AtomicFormula.PACKAGE_NAME, packageName),
-                                        new AtomicFormula.StringAtomicFormula(
-                                                AtomicFormula.INSTALLER_CERTIFICATE, appCert))),
-                        Rule.DENY);
-        Rule otherFailedRule =
-                new Rule(
-                        new AtomicFormula.LongAtomicFormula(AtomicFormula.VERSION_CODE,
-                                AtomicFormula.EQ, 12),
-                        Rule.DENY);
-
-        IntegrityCheckResult denyResult =
-                IntegrityCheckResult.deny(Arrays.asList(failedRule, otherFailedRule));
-
-        assertThat(denyResult.isCausedByAppCertRule()).isFalse();
-        assertThat(denyResult.isCausedByInstallerRule()).isTrue();
-    }
-}