Merge "Speed up kernel wakelock polling" into main
diff --git a/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/IKeystoreService.aidl b/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/IKeystoreService.aidl
index d2f03cf..0c292c8 100644
--- a/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/IKeystoreService.aidl
+++ b/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/IKeystoreService.aidl
@@ -47,4 +47,5 @@
   void ungrant(in android.system.keystore2.KeyDescriptor key, in int granteeUid);
   int getNumberOfEntries(in android.system.keystore2.Domain domain, in long nspace);
   android.system.keystore2.KeyDescriptor[] listEntriesBatched(in android.system.keystore2.Domain domain, in long nspace, in @nullable String startingPastAlias);
+  byte[] getSupplementaryAttestationInfo(in android.hardware.security.keymint.Tag tag);
 }
diff --git a/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/ResponseCode.aidl b/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/ResponseCode.aidl
index e1ff0bb..51dddf0 100644
--- a/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/ResponseCode.aidl
+++ b/keystore2/aidl/aidl_api/android.system.keystore2/current/android/system/keystore2/ResponseCode.aidl
@@ -55,4 +55,5 @@
   OUT_OF_KEYS_TRANSIENT_ERROR = 25,
   OUT_OF_KEYS_PERMANENT_ERROR = 26,
   GET_ATTESTATION_APPLICATION_ID_FAILED = 27,
+  INFO_NOT_AVAILABLE = 28,
 }
diff --git a/keystore2/aidl/android/system/keystore2/IKeystoreService.aidl b/keystore2/aidl/android/system/keystore2/IKeystoreService.aidl
index 9beac0a..666985c 100644
--- a/keystore2/aidl/android/system/keystore2/IKeystoreService.aidl
+++ b/keystore2/aidl/android/system/keystore2/IKeystoreService.aidl
@@ -17,14 +17,15 @@
 package android.system.keystore2;
 
 import android.hardware.security.keymint.SecurityLevel;
+import android.hardware.security.keymint.Tag;
 import android.system.keystore2.Domain;
 import android.system.keystore2.IKeystoreSecurityLevel;
 import android.system.keystore2.KeyDescriptor;
 import android.system.keystore2.KeyEntryResponse;
 
 /**
- * `IKeystoreService` is the primary interface to Keystore. It provides
- * access simple database bound requests. Request that require interactions
+ * `IKeystoreService` is the primary interface to Keystore. It primarily provides
+ * access to simple database bound requests. Request that require interactions
  * with a KeyMint backend are delegated to `IKeystoreSecurityLevel` which
  * may be acquired through this interface as well.
  *
@@ -246,4 +247,19 @@
     KeyDescriptor[] listEntriesBatched(in Domain domain, in long nspace,
             in @nullable String startingPastAlias);
 
+    /**
+     * Returns tag-specific info required to interpret a tag's attested value.
+     * Attested values themselves are located in the attestation certificate.
+     *
+     * The semantics of the return value is specific to the input tag:
+     *
+     * o Tag::MODULE_HASH: returns the DER-encoded structure corresponding to the `Modules` schema
+     *   described in the KeyMint HAL's KeyCreationResult.aidl. The SHA-256 hash of this encoded
+     *   structure is what's included with the tag in attestations.
+     *
+     * ## Error conditions
+     * `ResponseCode::INVALID_ARGUMENT` if `tag` is not specified in the list above.
+     * `ResponseCode::INFO_NOT_AVAILABLE` if `IKeystoreService` does not have the requested info.
+     */
+    byte[] getSupplementaryAttestationInfo(in Tag tag);
 }
diff --git a/keystore2/aidl/android/system/keystore2/ResponseCode.aidl b/keystore2/aidl/android/system/keystore2/ResponseCode.aidl
index 4fe7db3..0424f5b 100644
--- a/keystore2/aidl/android/system/keystore2/ResponseCode.aidl
+++ b/keystore2/aidl/android/system/keystore2/ResponseCode.aidl
@@ -137,4 +137,8 @@
      */
     GET_ATTESTATION_APPLICATION_ID_FAILED = 27,
 
+    /**
+     * Indicates that some information is not available.
+     */
+    INFO_NOT_AVAILABLE = 28,
 }
diff --git a/media/Android.bp b/media/Android.bp
index 5ba8985..b89d1b0 100644
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -68,7 +68,6 @@
         "aidl/android/media/audio/common/AudioOffloadInfo.aidl",
         "aidl/android/media/audio/common/AudioOutputFlags.aidl",
         "aidl/android/media/audio/common/AudioPlaybackRate.aidl",
-        "aidl/android/media/audio/common/AudioPolicyForcedConfig.aidl",
         "aidl/android/media/audio/common/AudioPolicyForceUse.aidl",
         "aidl/android/media/audio/common/AudioPort.aidl",
         "aidl/android/media/audio/common/AudioPortConfig.aidl",
diff --git a/media/aidl/android/media/audio/common/AudioHalCapCriterionV2.aidl b/media/aidl/android/media/audio/common/AudioHalCapCriterionV2.aidl
index 5e034c8..2416bca 100644
--- a/media/aidl/android/media/audio/common/AudioHalCapCriterionV2.aidl
+++ b/media/aidl/android/media/audio/common/AudioHalCapCriterionV2.aidl
@@ -20,7 +20,6 @@
 import android.media.audio.common.AudioDeviceDescription;
 import android.media.audio.common.AudioMode;
 import android.media.audio.common.AudioPolicyForceUse;
-import android.media.audio.common.AudioPolicyForcedConfig;
 
 /**
  * AudioHalCapCriterion is a wrapper for a CriterionType and its default value.
@@ -48,12 +47,13 @@
      */
     @VintfStability
     parcelable ForceConfigForUse {
-        /**  Force usage addressed by this criterion. */
-        AudioPolicyForceUse forceUse = AudioPolicyForceUse.MEDIA;
         /** List of supported value by this criterion. */
-        AudioPolicyForcedConfig[] values;
-        /** Default configuration applied if none is provided. */
-        AudioPolicyForcedConfig defaultValue = AudioPolicyForcedConfig.NONE;
+        AudioPolicyForceUse[] values;
+        /**
+         * Default configuration applied if none is provided. This is the default-initialized
+         * value of 'AudioPolicyForceUse' which is 'forMedia = NONE'.
+         */
+        AudioPolicyForceUse defaultValue;
         /** Logic followed by this criterion, only one value at given time. */
         LogicalDisjunction logic = LogicalDisjunction.EXCLUSIVE;
     }
diff --git a/media/aidl/android/media/audio/common/AudioPolicyForceUse.aidl b/media/aidl/android/media/audio/common/AudioPolicyForceUse.aidl
index 017fb30..4a67851 100644
--- a/media/aidl/android/media/audio/common/AudioPolicyForceUse.aidl
+++ b/media/aidl/android/media/audio/common/AudioPolicyForceUse.aidl
@@ -16,48 +16,92 @@
 package android.media.audio.common;
 
 /**
- * List of usages to be used the values from 'AudioPolicyForcedConfig' in order
- * to force audio routing.
+ * "Force Use" specifies high-level routing policies which are used
+ * in order to override the usual routing behavior.
  *
  * {@hide}
  */
-@Backing(type="int")
 @SuppressWarnings(value={"redundant-name"})
 @VintfStability
-enum AudioPolicyForceUse {
-    /**
-     * Configures the audio device used for "communication" (telephony, VoIP) use cases.
-     */
-    COMMUNICATION = 0,
+union AudioPolicyForceUse {
+    @Backing(type="byte")
+    @VintfStability
+    enum CommunicationDeviceCategory {
+        NONE = 0,
+        SPEAKER,
+        BT_SCO,
+        BT_BLE,
+        WIRED_ACCESSORY,
+    }
+    @Backing(type="byte")
+    @VintfStability
+    enum MediaDeviceCategory {
+        NONE = 0,
+        SPEAKER,
+        HEADPHONES,
+        BT_A2DP,
+        ANALOG_DOCK,
+        DIGITAL_DOCK,
+        WIRED_ACCESSORY,
+        NO_BT_A2DP,
+    }
+    @Backing(type="byte")
+    @VintfStability
+    enum DockType {
+        NONE = 0,
+        BT_CAR_DOCK,
+        BT_DESK_DOCK,
+        ANALOG_DOCK,
+        DIGITAL_DOCK,
+        WIRED_ACCESSORY,
+    }
+    @Backing(type="byte")
+    @VintfStability
+    enum EncodedSurroundConfig {
+        UNSPECIFIED = 0,
+        NEVER,
+        ALWAYS,
+        MANUAL,
+    }
+
     /**
      * Configures the audio device used for media playback.
+     * This is also the default value.
      */
-    MEDIA = 1,
+    MediaDeviceCategory forMedia = MediaDeviceCategory.NONE;
+    /**
+     * Configures the audio device used for "communication" (telephony, VoIP) use cases.
+     * Note that 'BT_BLE' and 'WIRED_ACCESSORY' can not be used in this case.
+     */
+    CommunicationDeviceCategory forCommunication = CommunicationDeviceCategory.NONE;
     /**
      * Configures the audio device used for recording.
+     * Note that 'SPEAKER' and 'BT_BLE' can not be used in this case.
      */
-    RECORD = 2,
+    CommunicationDeviceCategory forRecord = CommunicationDeviceCategory.NONE;
+    /**
+     * Configures whether in muted audio mode ringing should also be sent to a BT device.
+     * Note that 'SPEAKER' and 'WIRED_ACCESSORY' can not be used in this case.
+     */
+    CommunicationDeviceCategory forVibrateRinging = CommunicationDeviceCategory.NONE;
     /**
      * Specifies whether the phone is currently placed into a dock. The value of
-     * 'AudioPolicyForcedConfig' specifies the kind of the dock.
+     * specifies the kind of the dock. This field may also be used that sending
+     * of audio to the dock is overridden by another device.
      */
-    DOCK = 3,
+    DockType dock = DockType.NONE;
     /**
      * Specifies whether enforcing of certain sounds is enabled, for example,
      * enforcing of the camera shutter sound.
      */
-    SYSTEM = 4,
+    boolean systemSounds = false;
     /**
      * Specifies whether sending of system audio via HDMI is enabled.
      */
-    HDMI_SYSTEM_AUDIO = 5,
+    boolean hdmiSystemAudio = false;
     /**
      * Configures whether support for encoded surround formats is enabled for
      * applications.
      */
-    ENCODED_SURROUND = 6,
-    /**
-     * Configures whether in muted audio mode ringing should also be sent to a BT device.
-     */
-    VIBRATE_RINGING = 7,
+    EncodedSurroundConfig encodedSurround = EncodedSurroundConfig.UNSPECIFIED;
 }
diff --git a/media/aidl/android/media/audio/common/AudioPolicyForcedConfig.aidl b/media/aidl/android/media/audio/common/AudioPolicyForcedConfig.aidl
deleted file mode 100644
index a9e32bc..0000000
--- a/media/aidl/android/media/audio/common/AudioPolicyForcedConfig.aidl
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 android.media.audio.common;
-
-/**
- * List of forced configurations aka device categories to be used in addition to the force use
- * in order to force the audio routing. This is the "destination" for 'AudioPolicyForceUse'.
- *
- * {@hide}
- */
-@Backing(type="int")
-@SuppressWarnings(value={"redundant-name"})
-@VintfStability
-enum AudioPolicyForcedConfig {
-    /**
-     * The 'NONE' value can be used with all uses from 'AudioPolicyForceUse'.
-     */
-    NONE = 0,
-    /**
-     * The following configurations are used with 'AudioPolicyForceUse.COMMUNICATION',
-     * '.MEDIA', and '.RECORD'.
-     *
-     * BT_SCO is also used with 'AudioPolicyForceUse.VIBRATE_RINGING' to specify that
-     * in addition to vibration the ringing should be played via the BT SCO device.
-     */
-    SPEAKER = 1,
-    HEADPHONES = 2,
-    BT_SCO = 3,
-    BT_A2DP = 4,
-    WIRED_ACCESSORY = 5,
-    /**
-     * The '*_DOCK' values are for 'AudioPolicyForceUse.DOCK'.
-     */
-    BT_CAR_DOCK = 6,
-    BT_DESK_DOCK = 7,
-    ANALOG_DOCK = 8,
-    DIGITAL_DOCK = 9,
-    /**
-     * BT A2DP sink is not preferred to the speaker or a wired headset. Used for
-     * 'AudioPolicyForceUse.MEDIA'.
-     */
-    NO_BT_A2DP = 10,
-    /**
-     * Used with 'AudioPolicyForceUse.SYSTEM' to indicate that sound enforcement is enabled.
-     */
-    SYSTEM_ENFORCED = 11,
-    /**
-     * Used with 'AudioPolicyForceUse.HDMI_SYSTEM_AUDIO' to indicate that sending
-     * of system audio to HDMI is enabled.
-     */
-    HDMI_SYSTEM_AUDIO_ENFORCED = 12,
-    /**
-     * The '*_ENCODED_SURROUND' values are for 'AudioPolicyForceUse.ENCODED_SURROUND'.
-     */
-    ENCODED_SURROUND_NEVER = 13,
-    ENCODED_SURROUND_ALWAYS = 14,
-    ENCODED_SURROUND_MANUAL = 15,
-    /**
-     * Used with 'AudioPolicyForceUse.VIBRATE_RINGING' to specify that in addition to
-     * vibration the ringing should be played via the BT BLE device.
-     */
-    BT_BLE = 16,
-}
diff --git a/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioHalCapCriterionV2.aidl b/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioHalCapCriterionV2.aidl
index 1cb453a..b5ceee3 100644
--- a/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioHalCapCriterionV2.aidl
+++ b/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioHalCapCriterionV2.aidl
@@ -48,9 +48,8 @@
   }
   @VintfStability
   parcelable ForceConfigForUse {
-    android.media.audio.common.AudioPolicyForceUse forceUse = android.media.audio.common.AudioPolicyForceUse.MEDIA;
-    android.media.audio.common.AudioPolicyForcedConfig[] values;
-    android.media.audio.common.AudioPolicyForcedConfig defaultValue = android.media.audio.common.AudioPolicyForcedConfig.NONE;
+    android.media.audio.common.AudioPolicyForceUse[] values;
+    android.media.audio.common.AudioPolicyForceUse defaultValue;
     android.media.audio.common.AudioHalCapCriterionV2.LogicalDisjunction logic = android.media.audio.common.AudioHalCapCriterionV2.LogicalDisjunction.EXCLUSIVE;
   }
   @VintfStability
diff --git a/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForceUse.aidl b/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForceUse.aidl
index 7e69f85..eb883e9 100644
--- a/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForceUse.aidl
+++ b/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForceUse.aidl
@@ -33,14 +33,49 @@
 
 package android.media.audio.common;
 /* @hide */
-@Backing(type="int") @SuppressWarnings(value={"redundant-name"}) @VintfStability
-enum AudioPolicyForceUse {
-  COMMUNICATION = 0,
-  MEDIA = 1,
-  RECORD = 2,
-  DOCK = 3,
-  SYSTEM = 4,
-  HDMI_SYSTEM_AUDIO = 5,
-  ENCODED_SURROUND = 6,
-  VIBRATE_RINGING = 7,
+@SuppressWarnings(value={"redundant-name"}) @VintfStability
+union AudioPolicyForceUse {
+  android.media.audio.common.AudioPolicyForceUse.MediaDeviceCategory forMedia = android.media.audio.common.AudioPolicyForceUse.MediaDeviceCategory.NONE;
+  android.media.audio.common.AudioPolicyForceUse.CommunicationDeviceCategory forCommunication = android.media.audio.common.AudioPolicyForceUse.CommunicationDeviceCategory.NONE;
+  android.media.audio.common.AudioPolicyForceUse.CommunicationDeviceCategory forRecord = android.media.audio.common.AudioPolicyForceUse.CommunicationDeviceCategory.NONE;
+  android.media.audio.common.AudioPolicyForceUse.CommunicationDeviceCategory forVibrateRinging = android.media.audio.common.AudioPolicyForceUse.CommunicationDeviceCategory.NONE;
+  android.media.audio.common.AudioPolicyForceUse.DockType dock = android.media.audio.common.AudioPolicyForceUse.DockType.NONE;
+  boolean systemSounds = false;
+  boolean hdmiSystemAudio = false;
+  android.media.audio.common.AudioPolicyForceUse.EncodedSurroundConfig encodedSurround = android.media.audio.common.AudioPolicyForceUse.EncodedSurroundConfig.UNSPECIFIED;
+  @Backing(type="byte") @VintfStability
+  enum CommunicationDeviceCategory {
+    NONE = 0,
+    SPEAKER,
+    BT_SCO,
+    BT_BLE,
+    WIRED_ACCESSORY,
+  }
+  @Backing(type="byte") @VintfStability
+  enum MediaDeviceCategory {
+    NONE = 0,
+    SPEAKER,
+    HEADPHONES,
+    BT_A2DP,
+    ANALOG_DOCK,
+    DIGITAL_DOCK,
+    WIRED_ACCESSORY,
+    NO_BT_A2DP,
+  }
+  @Backing(type="byte") @VintfStability
+  enum DockType {
+    NONE = 0,
+    BT_CAR_DOCK,
+    BT_DESK_DOCK,
+    ANALOG_DOCK,
+    DIGITAL_DOCK,
+    WIRED_ACCESSORY,
+  }
+  @Backing(type="byte") @VintfStability
+  enum EncodedSurroundConfig {
+    UNSPECIFIED = 0,
+    NEVER,
+    ALWAYS,
+    MANUAL,
+  }
 }
diff --git a/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForcedConfig.aidl b/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForcedConfig.aidl
deleted file mode 100644
index 5135bcd..0000000
--- a/media/aidl_api/android.media.audio.common.types/current/android/media/audio/common/AudioPolicyForcedConfig.aidl
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL file. Do not edit it manually. There are
-// two cases:
-// 1). this is a frozen version file - do not edit this in any case.
-// 2). this is a 'current' file. If you make a backwards compatible change to
-//     the interface (from the latest frozen version), the build system will
-//     prompt you to update this file with `m <name>-update-api`.
-//
-// You must not make a backward incompatible change to any AIDL file built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.media.audio.common;
-/* @hide */
-@Backing(type="int") @SuppressWarnings(value={"redundant-name"}) @VintfStability
-enum AudioPolicyForcedConfig {
-  NONE = 0,
-  SPEAKER = 1,
-  HEADPHONES = 2,
-  BT_SCO = 3,
-  BT_A2DP = 4,
-  WIRED_ACCESSORY = 5,
-  BT_CAR_DOCK = 6,
-  BT_DESK_DOCK = 7,
-  ANALOG_DOCK = 8,
-  DIGITAL_DOCK = 9,
-  NO_BT_A2DP = 10,
-  SYSTEM_ENFORCED = 11,
-  HDMI_SYSTEM_AUDIO_ENFORCED = 12,
-  ENCODED_SURROUND_NEVER = 13,
-  ENCODED_SURROUND_ALWAYS = 14,
-  ENCODED_SURROUND_MANUAL = 15,
-  BT_BLE = 16,
-}