Merge "Bluetooth: add LE Audio COD constant definition"
diff --git a/core/api/current.txt b/core/api/current.txt
index 7a0ca94..62e35c7 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -32075,6 +32075,7 @@
 
   public final class SystemClock {
     method @NonNull public static java.time.Clock currentGnssTimeClock();
+    method @NonNull public static java.time.Clock currentNetworkTimeClock();
     method public static long currentThreadTimeMillis();
     method public static long elapsedRealtime();
     method public static long elapsedRealtimeNanos();
@@ -33870,6 +33871,7 @@
     field public static final int PRESENTATION_ALLOWED = 1; // 0x1
     field public static final int PRESENTATION_PAYPHONE = 4; // 0x4
     field public static final int PRESENTATION_RESTRICTED = 2; // 0x2
+    field public static final int PRESENTATION_UNAVAILABLE = 5; // 0x5
     field public static final int PRESENTATION_UNKNOWN = 3; // 0x3
     field public static final String PRIORITY = "priority";
     field public static final int PRIORITY_NORMAL = 0; // 0x0
@@ -40594,6 +40596,7 @@
     field public static final int PRESENTATION_ALLOWED = 1; // 0x1
     field public static final int PRESENTATION_PAYPHONE = 4; // 0x4
     field public static final int PRESENTATION_RESTRICTED = 2; // 0x2
+    field public static final int PRESENTATION_UNAVAILABLE = 5; // 0x5
     field public static final int PRESENTATION_UNKNOWN = 3; // 0x3
     field public static final int PRIORITY_NORMAL = 0; // 0x0
     field public static final int PRIORITY_URGENT = 1; // 0x1
@@ -42614,6 +42617,8 @@
     method @NonNull public java.util.List<android.net.Uri> getDeviceToDeviceStatusSharingContacts(int);
     method public int getDeviceToDeviceStatusSharingPreference(int);
     method @NonNull @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List<android.telephony.SubscriptionInfo> getOpportunisticSubscriptions();
+    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_NUMBERS, "android.permission.READ_PRIVILEGED_PHONE_STATE"}) public String getPhoneNumber(int, int);
+    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_NUMBERS, "android.permission.READ_PRIVILEGED_PHONE_STATE"}) public String getPhoneNumber(int);
     method public static int getSlotIndex(int);
     method @Nullable public int[] getSubscriptionIds(int);
     method @NonNull public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int);
@@ -42625,6 +42630,7 @@
     method public void removeOnOpportunisticSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener);
     method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener);
     method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void removeSubscriptionsFromGroup(@NonNull java.util.List<java.lang.Integer>, @NonNull android.os.ParcelUuid);
+    method public void setCarrierPhoneNumber(int, @NonNull String);
     method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDeviceToDeviceStatusSharingContacts(int, @NonNull java.util.List<android.net.Uri>);
     method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDeviceToDeviceStatusSharingPreference(int, int);
     method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setOpportunistic(boolean, int);
@@ -42651,6 +42657,9 @@
     field public static final String EXTRA_SUBSCRIPTION_INDEX = "android.telephony.extra.SUBSCRIPTION_INDEX";
     field public static final int INVALID_SIM_SLOT_INDEX = -1; // 0xffffffff
     field public static final int INVALID_SUBSCRIPTION_ID = -1; // 0xffffffff
+    field public static final int PHONE_NUMBER_SOURCE_CARRIER = 2; // 0x2
+    field public static final int PHONE_NUMBER_SOURCE_IMS = 3; // 0x3
+    field public static final int PHONE_NUMBER_SOURCE_UICC = 1; // 0x1
     field public static final int SUBSCRIPTION_TYPE_LOCAL_SIM = 0; // 0x0
     field public static final int SUBSCRIPTION_TYPE_REMOTE_SIM = 1; // 0x1
   }
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt
index a646a68..d13170bf 100644
--- a/core/api/module-lib-current.txt
+++ b/core/api/module-lib-current.txt
@@ -237,6 +237,43 @@
     field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStateSnapshot> CREATOR;
   }
 
+  public final class NetworkTemplate implements android.os.Parcelable {
+    method public int describeContents();
+    method public int getDefaultNetworkStatus();
+    method public int getMatchRule();
+    method public int getMeteredness();
+    method public int getOemManaged();
+    method public int getRatType();
+    method public int getRoaming();
+    method @NonNull public java.util.Set<java.lang.String> getSubscriberIds();
+    method @NonNull public java.util.Set<java.lang.String> getWifiNetworkKeys();
+    method public void writeToParcel(@NonNull android.os.Parcel, int);
+    field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkTemplate> CREATOR;
+    field public static final int MATCH_BLUETOOTH = 8; // 0x8
+    field public static final int MATCH_CARRIER = 10; // 0xa
+    field public static final int MATCH_ETHERNET = 5; // 0x5
+    field public static final int MATCH_MOBILE = 1; // 0x1
+    field public static final int MATCH_WIFI = 4; // 0x4
+    field public static final int NETWORK_TYPE_ALL = -1; // 0xffffffff
+    field public static final int OEM_MANAGED_ALL = -1; // 0xffffffff
+    field public static final int OEM_MANAGED_NO = 0; // 0x0
+    field public static final int OEM_MANAGED_PAID = 1; // 0x1
+    field public static final int OEM_MANAGED_PRIVATE = 2; // 0x2
+    field public static final int OEM_MANAGED_YES = -2; // 0xfffffffe
+  }
+
+  public static final class NetworkTemplate.Builder {
+    ctor public NetworkTemplate.Builder(int);
+    method @NonNull public android.net.NetworkTemplate build();
+    method @NonNull public android.net.NetworkTemplate.Builder setDefaultNetworkStatus(int);
+    method @NonNull public android.net.NetworkTemplate.Builder setMeteredness(int);
+    method @NonNull public android.net.NetworkTemplate.Builder setOemManaged(int);
+    method @NonNull public android.net.NetworkTemplate.Builder setRatType(int);
+    method @NonNull public android.net.NetworkTemplate.Builder setRoaming(int);
+    method @NonNull public android.net.NetworkTemplate.Builder setSubscriberIds(@NonNull java.util.Set<java.lang.String>);
+    method @NonNull public android.net.NetworkTemplate.Builder setWifiNetworkKeys(@NonNull java.util.Set<java.lang.String>);
+  }
+
   public class NetworkWatchlistManager {
     method @Nullable public byte[] getWatchlistConfigHash();
   }
@@ -321,6 +358,10 @@
     method @Nullable public android.os.IBinder getOrThrow() throws android.os.StatsServiceManager.ServiceNotFoundException;
   }
 
+  public final class StrictMode {
+    method public static void noteUntaggedSocket();
+  }
+
   public class SystemConfigManager {
     method @NonNull public java.util.List<android.content.ComponentName> getEnabledComponentOverrides(@NonNull String);
   }
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 9bca7fc..41ce6f6 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -7509,13 +7509,17 @@
     method @NonNull public android.net.NetworkStats subtract(@NonNull android.net.NetworkStats);
     method public void writeToParcel(@NonNull android.os.Parcel, int);
     field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStats> CREATOR;
+    field public static final int DEFAULT_NETWORK_ALL = -1; // 0xffffffff
     field public static final int DEFAULT_NETWORK_NO = 0; // 0x0
     field public static final int DEFAULT_NETWORK_YES = 1; // 0x1
     field public static final String IFACE_VT = "vt_data0";
+    field public static final int METERED_ALL = -1; // 0xffffffff
     field public static final int METERED_NO = 0; // 0x0
     field public static final int METERED_YES = 1; // 0x1
+    field public static final int ROAMING_ALL = -1; // 0xffffffff
     field public static final int ROAMING_NO = 0; // 0x0
     field public static final int ROAMING_YES = 1; // 0x1
+    field public static final int SET_ALL = -1; // 0xffffffff
     field public static final int SET_DEFAULT = 0; // 0x0
     field public static final int SET_FOREGROUND = 1; // 0x1
     field public static final int TAG_NONE = 0; // 0x0
@@ -13091,6 +13095,7 @@
     field public static final int OIR_PRESENTATION_NOT_RESTRICTED = 2; // 0x2
     field public static final int OIR_PRESENTATION_PAYPHONE = 4; // 0x4
     field public static final int OIR_PRESENTATION_RESTRICTED = 1; // 0x1
+    field public static final int OIR_PRESENTATION_UNAVAILABLE = 5; // 0x5
     field public static final int OIR_PRESENTATION_UNKNOWN = 3; // 0x3
     field public static final int PRIORITY_NORMAL = 0; // 0x0
     field public static final int PRIORITY_URGENT = 1; // 0x1
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java
index fe8d1ba..b531829 100644
--- a/core/java/android/bluetooth/BluetoothGatt.java
+++ b/core/java/android/bluetooth/BluetoothGatt.java
@@ -87,7 +87,7 @@
     private static final int CONN_STATE_CLOSED = 4;
 
     private static final int WRITE_CHARACTERISTIC_MAX_RETRIES = 5;
-    private static final int WRITE_CHARACTERISTIC_TIME_TO_WAIT = 1000; // milliseconds
+    private static final int WRITE_CHARACTERISTIC_TIME_TO_WAIT = 10; // milliseconds
 
     private List<BluetoothGattService> mServices;
 
diff --git a/core/java/android/bluetooth/BluetoothLeBroadcastAssistantCallback.java b/core/java/android/bluetooth/BluetoothLeBroadcastAssistantCallback.java
new file mode 100644
index 0000000..b866cce
--- /dev/null
+++ b/core/java/android/bluetooth/BluetoothLeBroadcastAssistantCallback.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2021 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.bluetooth;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.bluetooth.le.ScanResult;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This class provides a set of callbacks that are invoked when scanning for Broadcast Sources is
+ * offloaded to a Broadcast Assistant.
+ *
+ * <p>An LE Audio Broadcast Assistant can help a Broadcast Sink to scan for available Broadcast
+ * Sources. The Broadcast Sink achieves this by offloading the scan to a Broadcast Assistant. This
+ * is facilitated by the Broadcast Audio Scan Service (BASS). A BASS server is a GATT server that is
+ * part of the Scan Delegator on a Broadcast Sink. A BASS client instead runs on the Broadcast
+ * Assistant.
+ *
+ * <p>Once a GATT connection is established between the BASS client and the BASS server, the
+ * Broadcast Sink can offload the scans to the Broadcast Assistant. Upon finding new Broadcast
+ * Sources, the Broadcast Assistant then notifies the Broadcast Sink about these over the
+ * established GATT connection. The Scan Delegator on the Broadcast Sink can also notify the
+ * Assistant about changes such as addition and removal of Broadcast Sources.
+ *
+ * @hide
+ */
+public abstract class BluetoothLeBroadcastAssistantCallback {
+
+    /**
+     * Broadcast Audio Scan Service (BASS) codes returned by a BASS Server
+     *
+     * @hide
+     */
+    @IntDef(
+            prefix = "BASS_STATUS_",
+            value = {
+                BASS_STATUS_SUCCESS,
+                BASS_STATUS_FAILURE,
+                BASS_STATUS_INVALID_GATT_HANDLE,
+                BASS_STATUS_TXN_TIMEOUT,
+                BASS_STATUS_INVALID_SOURCE_ID,
+                BASS_STATUS_COLOCATED_SRC_UNAVAILABLE,
+                BASS_STATUS_INVALID_SOURCE_SELECTED,
+                BASS_STATUS_SOURCE_UNAVAILABLE,
+                BASS_STATUS_DUPLICATE_ADDITION,
+            })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface BassStatus {}
+
+    public static final int BASS_STATUS_SUCCESS = 0x00;
+    public static final int BASS_STATUS_FAILURE = 0x01;
+    public static final int BASS_STATUS_INVALID_GATT_HANDLE = 0x02;
+    public static final int BASS_STATUS_TXN_TIMEOUT = 0x03;
+
+    public static final int BASS_STATUS_INVALID_SOURCE_ID = 0x04;
+    public static final int BASS_STATUS_COLOCATED_SRC_UNAVAILABLE = 0x05;
+    public static final int BASS_STATUS_INVALID_SOURCE_SELECTED = 0x06;
+    public static final int BASS_STATUS_SOURCE_UNAVAILABLE = 0x07;
+    public static final int BASS_STATUS_DUPLICATE_ADDITION = 0x08;
+    public static final int BASS_STATUS_NO_EMPTY_SLOT = 0x09;
+    public static final int BASS_STATUS_INVALID_GROUP_OP = 0x10;
+
+    /**
+     * Callback invoked when a new LE Audio Broadcast Source is found.
+     *
+     * @param result {@link ScanResult} scan result representing a Broadcast Source
+     */
+    public void onBluetoothLeBroadcastSourceFound(@NonNull ScanResult result) {}
+
+    /**
+     * Callback invoked when the Broadcast Assistant synchronizes with Periodic Advertisements (PAs)
+     * of an LE Audio Broadcast Source.
+     *
+     * @param source the selected Broadcast Source
+     */
+    public void onBluetoothLeBroadcastSourceSelected(
+            @NonNull BluetoothLeBroadcastSourceInfo source, @BassStatus int status) {}
+
+    /**
+     * Callback invoked when the Broadcast Assistant loses synchronization with an LE Audio
+     * Broadcast Source.
+     *
+     * @param source the Broadcast Source with which synchronization was lost
+     */
+    public void onBluetoothLeBroadcastSourceLost(
+            @NonNull BluetoothLeBroadcastSourceInfo source, @BassStatus int status) {}
+
+    /**
+     * Callback invoked when a new LE Audio Broadcast Source has been successfully added to the Scan
+     * Delegator (within a Broadcast Sink, for example).
+     *
+     * @param sink Scan Delegator device on which a new Broadcast Source has been added
+     * @param source the added Broadcast Source
+     */
+    public void onBluetoothLeBroadcastSourceAdded(
+            @NonNull BluetoothDevice sink,
+            @NonNull BluetoothLeBroadcastSourceInfo source,
+            @BassStatus int status) {}
+
+    /**
+     * Callback invoked when an existing LE Audio Broadcast Source within a remote Scan Delegator
+     * has been updated.
+     *
+     * @param sink Scan Delegator device on which a Broadcast Source has been updated
+     * @param source the updated Broadcast Source
+     */
+    public void onBluetoothLeBroadcastSourceUpdated(
+            @NonNull BluetoothDevice sink,
+            @NonNull BluetoothLeBroadcastSourceInfo source,
+            @BassStatus int status) {}
+
+    /**
+     * Callback invoked when an LE Audio Broadcast Source has been successfully removed from the
+     * Scan Delegator (within a Broadcast Sink, for example).
+     *
+     * @param sink Scan Delegator device from which a Broadcast Source has been removed
+     * @param source the removed Broadcast Source
+     */
+    public void onBluetoothLeBroadcastSourceRemoved(
+            @NonNull BluetoothDevice sink,
+            @NonNull BluetoothLeBroadcastSourceInfo source,
+            @BassStatus int status) {}
+}
diff --git a/core/java/android/bluetooth/BluetoothLeBroadcastSourceInfo.java b/core/java/android/bluetooth/BluetoothLeBroadcastSourceInfo.java
new file mode 100644
index 0000000..cb47280
--- /dev/null
+++ b/core/java/android/bluetooth/BluetoothLeBroadcastSourceInfo.java
@@ -0,0 +1,788 @@
+/*
+ * Copyright 2021 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.bluetooth;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * This class represents an LE Audio Broadcast Source and the associated information that is needed
+ * by Broadcast Audio Scan Service (BASS) residing on a Scan Delegator.
+ *
+ * <p>For example, the Scan Delegator on an LE Audio Broadcast Sink can use the information
+ * contained within an instance of this class to synchronize with an LE Audio Broadcast Source in
+ * order to listen to a Broadcast Audio Stream.
+ *
+ * <p>BroadcastAssistant has a BASS client which facilitates scanning and discovery of Broadcast
+ * Sources on behalf of say a Broadcast Sink. Upon successful discovery of one or more Broadcast
+ * sources, this information needs to be communicated to the BASS Server residing within the Scan
+ * Delegator on a Broadcast Sink. This is achieved using the Periodic Advertising Synchronization
+ * Transfer (PAST) procedure. This procedure uses information contained within an instance of this
+ * class.
+ *
+ * @hide
+ */
+public final class BluetoothLeBroadcastSourceInfo implements Parcelable {
+    private static final String TAG = "BluetoothLeBroadcastSourceInfo";
+    private static final boolean DBG = true;
+
+    /**
+     * Constants representing Broadcast Source address types
+     *
+     * @hide
+     */
+    @IntDef(
+            prefix = "LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_",
+            value = {
+                LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_PUBLIC,
+                LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_RANDOM,
+                LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_INVALID
+            })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface LeAudioBroadcastSourceAddressType {}
+
+    /**
+     * Represents a public address used by an LE Audio Broadcast Source
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_PUBLIC = 0;
+
+    /**
+     * Represents a random address used by an LE Audio Broadcast Source
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_RANDOM = 1;
+
+    /**
+     * Represents an invalid address used by an LE Audio Broadcast Seurce
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_INVALID = 0xFFFF;
+
+    /**
+     * Periodic Advertising Synchronization state
+     *
+     * <p>Periodic Advertising (PA) enables the LE Audio Broadcast Assistant to discover broadcast
+     * audio streams as well as the audio stream configuration on behalf of an LE Audio Broadcast
+     * Sink. This information can then be transferred to the LE Audio Broadcast Sink using the
+     * Periodic Advertising Synchronizaton Transfer (PAST) procedure.
+     *
+     * @hide
+     */
+    @IntDef(
+            prefix = "LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_",
+            value = {
+                LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_IDLE,
+                LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_SYNCINFO_REQ,
+                LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_IN_SYNC,
+                LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_SYNC_FAIL,
+                LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_NO_PAST
+            })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface LeAudioBroadcastSinkPaSyncState {}
+
+    /**
+     * Indicates that the Broadcast Sink is not synchronized with the Periodic Advertisements (PA)
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_IDLE = 0;
+
+    /**
+     * Indicates that the Broadcast Sink requested the Broadcast Assistant to synchronize with the
+     * Periodic Advertisements (PA).
+     *
+     * <p>This is also known as scan delegation or scan offloading.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_SYNCINFO_REQ = 1;
+
+    /**
+     * Indicates that the Broadcast Sink is synchronized with the Periodic Advertisements (PA).
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_IN_SYNC = 2;
+
+    /**
+     * Indicates that the Broadcast Sink was unable to synchronize with the Periodic Advertisements
+     * (PA).
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_SYNC_FAIL = 3;
+
+    /**
+     * Indicates that the Broadcast Sink should be synchronized with the Periodic Advertisements
+     * (PA) using the Periodic Advertisements Synchronization Transfert (PAST) procedure.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_NO_PAST = 4;
+
+    /**
+     * Indicates that the Broadcast Sink synchornization state is invalid.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_INVALID = 0xFFFF;
+
+    /** @hide */
+    @IntDef(
+            prefix = "LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_",
+            value = {
+                LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_NOT_SYNCHRONIZED,
+                LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_SYNCHRONIZED
+            })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface LeAudioBroadcastSinkAudioSyncState {}
+
+    /**
+     * Indicates that the Broadcast Sink is not synchronized with a Broadcast Audio Stream.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_NOT_SYNCHRONIZED = 0;
+
+    /**
+     * Indicates that the Broadcast Sink is synchronized with a Broadcast Audio Stream.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_SYNCHRONIZED = 1;
+
+    /**
+     * Indicates that the Broadcast Sink audio synchronization state is invalid.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_INVALID = 0xFFFF;
+
+    /** @hide */
+    @IntDef(
+            prefix = "LE_AUDIO_BROADCAST_SINK_ENC_STATE_",
+            value = {
+                LE_AUDIO_BROADCAST_SINK_ENC_STATE_NOT_ENCRYPTED,
+                LE_AUDIO_BROADCAST_SINK_ENC_STATE_CODE_REQUIRED,
+                LE_AUDIO_BROADCAST_SINK_ENC_STATE_DECRYPTING,
+                LE_AUDIO_BROADCAST_SINK_ENC_STATE_BAD_CODE
+            })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface LeAudioBroadcastSinkEncryptionState {}
+
+    /**
+     * Indicates that the Broadcast Sink is synchronized with an unencrypted audio stream.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_ENC_STATE_NOT_ENCRYPTED = 0;
+
+    /**
+     * Indicates that the Broadcast Sink needs a Broadcast Code to synchronize with the audio
+     * stream.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_ENC_STATE_CODE_REQUIRED = 1;
+
+    /**
+     * Indicates that the Broadcast Sink is synchronized with an encrypted audio stream.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_ENC_STATE_DECRYPTING = 2;
+
+    /**
+     * Indicates that the Broadcast Sink is unable to decrypt an audio stream due to an incorrect
+     * Broadcast Code
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_ENC_STATE_BAD_CODE = 3;
+
+    /**
+     * Indicates that the Broadcast Sink encryption state is invalid.
+     *
+     * @hide
+     */
+    public static final int LE_AUDIO_BROADCAST_SINK_ENC_STATE_INVALID = 0xFF;
+
+    /**
+     * Represents an invalid LE Audio Broadcast Source ID
+     *
+     * @hide
+     */
+    public static final byte LE_AUDIO_BROADCAST_SINK_INVALID_SOURCE_ID = (byte) 0x00;
+
+    /**
+     * Represents an invalid Broadcast ID of a Broadcast Source
+     *
+     * @hide
+     */
+    public static final int INVALID_BROADCAST_ID = 0xFFFFFF;
+
+    private byte mSourceId;
+    private @LeAudioBroadcastSourceAddressType int mSourceAddressType;
+    private BluetoothDevice mSourceDevice;
+    private byte mSourceAdvSid;
+    private int mBroadcastId;
+    private @LeAudioBroadcastSinkPaSyncState int mPaSyncState;
+    private @LeAudioBroadcastSinkEncryptionState int mEncryptionStatus;
+    private @LeAudioBroadcastSinkAudioSyncState int mAudioSyncState;
+    private byte[] mBadBroadcastCode;
+    private byte mNumSubGroups;
+    private Map<Integer, Integer> mSubgroupBisSyncState = new HashMap<Integer, Integer>();
+    private Map<Integer, byte[]> mSubgroupMetadata = new HashMap<Integer, byte[]>();
+
+    private String mBroadcastCode;
+    private static final int BIS_NO_PREF = 0xFFFFFFFF;
+    private static final int BROADCAST_CODE_SIZE = 16;
+
+    /**
+     * Constructor to create an Empty object of {@link BluetoothLeBroadcastSourceInfo } with the
+     * given Source Id.
+     *
+     * <p>This is mainly used to represent the Empty Broadcast Source entries
+     *
+     * @param sourceId Source Id for this Broadcast Source info object
+     * @hide
+     */
+    public BluetoothLeBroadcastSourceInfo(byte sourceId) {
+        mSourceId = sourceId;
+        mSourceAddressType = LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_INVALID;
+        mSourceDevice = null;
+        mSourceAdvSid = (byte) 0x00;
+        mBroadcastId = INVALID_BROADCAST_ID;
+        mPaSyncState = LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_INVALID;
+        mAudioSyncState = LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_INVALID;
+        mEncryptionStatus = LE_AUDIO_BROADCAST_SINK_ENC_STATE_INVALID;
+        mBadBroadcastCode = null;
+        mNumSubGroups = 0;
+        mBroadcastCode = null;
+    }
+
+    /*package*/ BluetoothLeBroadcastSourceInfo(
+            byte sourceId,
+            @LeAudioBroadcastSourceAddressType int addressType,
+            @NonNull BluetoothDevice device,
+            byte advSid,
+            int broadcastId,
+            @LeAudioBroadcastSinkPaSyncState int paSyncstate,
+            @LeAudioBroadcastSinkEncryptionState int encryptionStatus,
+            @LeAudioBroadcastSinkAudioSyncState int audioSyncstate,
+            @Nullable byte[] badCode,
+            byte numSubGroups,
+            @NonNull Map<Integer, Integer> bisSyncState,
+            @Nullable Map<Integer, byte[]> subgroupMetadata,
+            @NonNull String broadcastCode) {
+        mSourceId = sourceId;
+        mSourceAddressType = addressType;
+        mSourceDevice = device;
+        mSourceAdvSid = advSid;
+        mBroadcastId = broadcastId;
+        mPaSyncState = paSyncstate;
+        mEncryptionStatus = encryptionStatus;
+        mAudioSyncState = audioSyncstate;
+
+        if (badCode != null && badCode.length != 0) {
+            mBadBroadcastCode = new byte[badCode.length];
+            System.arraycopy(badCode, 0, mBadBroadcastCode, 0, badCode.length);
+        }
+        mNumSubGroups = numSubGroups;
+        mSubgroupBisSyncState = new HashMap<Integer, Integer>(bisSyncState);
+        mSubgroupMetadata = new HashMap<Integer, byte[]>(subgroupMetadata);
+        mBroadcastCode = broadcastCode;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof BluetoothLeBroadcastSourceInfo) {
+            BluetoothLeBroadcastSourceInfo other = (BluetoothLeBroadcastSourceInfo) o;
+            return (other.mSourceId == mSourceId
+                    && other.mSourceAddressType == mSourceAddressType
+                    && other.mSourceDevice == mSourceDevice
+                    && other.mSourceAdvSid == mSourceAdvSid
+                    && other.mBroadcastId == mBroadcastId
+                    && other.mPaSyncState == mPaSyncState
+                    && other.mEncryptionStatus == mEncryptionStatus
+                    && other.mAudioSyncState == mAudioSyncState
+                    && Arrays.equals(other.mBadBroadcastCode, mBadBroadcastCode)
+                    && other.mNumSubGroups == mNumSubGroups
+                    && mSubgroupBisSyncState.equals(other.mSubgroupBisSyncState)
+                    && mSubgroupMetadata.equals(other.mSubgroupMetadata)
+                    && other.mBroadcastCode == mBroadcastCode);
+        }
+        return false;
+    }
+
+    /**
+     * Checks if an instance of {@link BluetoothLeBroadcastSourceInfo} is empty.
+     *
+     * @hide
+     */
+    public boolean isEmpty() {
+        boolean ret = false;
+        if (mSourceAddressType == LE_AUDIO_BROADCAST_SOURCE_ADDRESS_TYPE_INVALID
+                && mSourceDevice == null
+                && mSourceAdvSid == (byte) 0
+                && mPaSyncState == LE_AUDIO_BROADCAST_SINK_PA_SYNC_STATE_INVALID
+                && mEncryptionStatus == LE_AUDIO_BROADCAST_SINK_ENC_STATE_INVALID
+                && mAudioSyncState == LE_AUDIO_BROADCAST_SINK_AUDIO_SYNC_STATE_INVALID
+                && mBadBroadcastCode == null
+                && mNumSubGroups == 0
+                && mSubgroupBisSyncState.size() == 0
+                && mSubgroupMetadata.size() == 0
+                && mBroadcastCode == null) {
+            ret = true;
+        }
+        return ret;
+    }
+
+    /**
+     * Compares an instance of {@link BluetoothLeBroadcastSourceInfo} with the provided instance.
+     *
+     * @hide
+     */
+    public boolean matches(BluetoothLeBroadcastSourceInfo srcInfo) {
+        boolean ret = false;
+        if (srcInfo == null) {
+            ret = false;
+        } else {
+            if (mSourceDevice == null) {
+                if (mSourceAdvSid == srcInfo.getAdvertisingSid()
+                        && mSourceAddressType == srcInfo.getAdvAddressType()) {
+                    ret = true;
+                }
+            } else {
+                if (mSourceDevice.equals(srcInfo.getSourceDevice())
+                        && mSourceAdvSid == srcInfo.getAdvertisingSid()
+                        && mSourceAddressType == srcInfo.getAdvAddressType()
+                        && mBroadcastId == srcInfo.getBroadcastId()) {
+                    ret = true;
+                }
+            }
+        }
+        return ret;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(
+                mSourceId,
+                mSourceAddressType,
+                mSourceDevice,
+                mSourceAdvSid,
+                mBroadcastId,
+                mPaSyncState,
+                mEncryptionStatus,
+                mAudioSyncState,
+                mBadBroadcastCode,
+                mNumSubGroups,
+                mSubgroupBisSyncState,
+                mSubgroupMetadata,
+                mBroadcastCode);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public String toString() {
+        return "{BluetoothLeBroadcastSourceInfo : mSourceId"
+                + mSourceId
+                + " addressType: "
+                + mSourceAddressType
+                + " sourceDevice: "
+                + mSourceDevice
+                + " mSourceAdvSid:"
+                + mSourceAdvSid
+                + " mBroadcastId:"
+                + mBroadcastId
+                + " mPaSyncState:"
+                + mPaSyncState
+                + " mEncryptionStatus:"
+                + mEncryptionStatus
+                + " mAudioSyncState:"
+                + mAudioSyncState
+                + " mBadBroadcastCode:"
+                + mBadBroadcastCode
+                + " mNumSubGroups:"
+                + mNumSubGroups
+                + " mSubgroupBisSyncState:"
+                + mSubgroupBisSyncState
+                + " mSubgroupMetadata:"
+                + mSubgroupMetadata
+                + " mBroadcastCode:"
+                + mBroadcastCode
+                + "}";
+    }
+
+    /**
+     * Get the Source Id
+     *
+     * @return byte representing the Source Id, {@link
+     *     #LE_AUDIO_BROADCAST_ASSISTANT_INVALID_SOURCE_ID} if invalid
+     * @hide
+     */
+    public byte getSourceId() {
+        return mSourceId;
+    }
+
+    /**
+     * Set the Source Id
+     *
+     * @param sourceId source Id
+     * @hide
+     */
+    public void setSourceId(byte sourceId) {
+        mSourceId = sourceId;
+    }
+
+    /**
+     * Set the Broadcast Source device
+     *
+     * @param sourceDevice the Broadcast Source BluetoothDevice
+     * @hide
+     */
+    public void setSourceDevice(@NonNull BluetoothDevice sourceDevice) {
+        mSourceDevice = sourceDevice;
+    }
+
+    /**
+     * Get the Broadcast Source BluetoothDevice
+     *
+     * @return Broadcast Source BluetoothDevice
+     * @hide
+     */
+    public @NonNull BluetoothDevice getSourceDevice() {
+        return mSourceDevice;
+    }
+
+    /**
+     * Set the address type of the Broadcast Source advertisements
+     *
+     * @hide
+     */
+    public void setAdvAddressType(@LeAudioBroadcastSourceAddressType int addressType) {
+        mSourceAddressType = addressType;
+    }
+
+    /**
+     * Get the address type used by advertisements from the Broadcast Source.
+     * BluetoothLeBroadcastSourceInfo Object
+     *
+     * @hide
+     */
+    @LeAudioBroadcastSourceAddressType
+    public int getAdvAddressType() {
+        return mSourceAddressType;
+    }
+
+    /**
+     * Set the advertising SID of the Broadcast Source advertisement.
+     *
+     * @param advSid advertising SID of the Broadcast Source
+     * @hide
+     */
+    public void setAdvertisingSid(byte advSid) {
+        mSourceAdvSid = advSid;
+    }
+
+    /**
+     * Get the advertising SID of the Broadcast Source advertisement.
+     *
+     * @return advertising SID of the Broadcast Source
+     * @hide
+     */
+    public byte getAdvertisingSid() {
+        return mSourceAdvSid;
+    }
+
+    /**
+     * Get the Broadcast ID of the Broadcast Source.
+     *
+     * @return broadcast ID
+     * @hide
+     */
+    public int getBroadcastId() {
+        return mBroadcastId;
+    }
+
+    /**
+     * Set the Periodic Advertising (PA) Sync State.
+     *
+     * @hide
+     */
+    /*package*/ void setPaSyncState(@LeAudioBroadcastSinkPaSyncState int paSyncState) {
+        mPaSyncState = paSyncState;
+    }
+
+    /**
+     * Get the Periodic Advertising (PA) Sync State
+     *
+     * @hide
+     */
+    public @LeAudioBroadcastSinkPaSyncState int getMetadataSyncState() {
+        return mPaSyncState;
+    }
+
+    /**
+     * Set the audio sync state
+     *
+     * @hide
+     */
+    /*package*/ void setAudioSyncState(@LeAudioBroadcastSinkAudioSyncState int audioSyncState) {
+        mAudioSyncState = audioSyncState;
+    }
+
+    /**
+     * Get the audio sync state
+     *
+     * @hide
+     */
+    public @LeAudioBroadcastSinkAudioSyncState int getAudioSyncState() {
+        return mAudioSyncState;
+    }
+
+    /**
+     * Set the encryption status
+     *
+     * @hide
+     */
+    /*package*/ void setEncryptionStatus(
+            @LeAudioBroadcastSinkEncryptionState int encryptionStatus) {
+        mEncryptionStatus = encryptionStatus;
+    }
+
+    /**
+     * Get the encryption status
+     *
+     * @hide
+     */
+    public @LeAudioBroadcastSinkEncryptionState int getEncryptionStatus() {
+        return mEncryptionStatus;
+    }
+
+    /**
+     * Get the incorrect broadcast code that the Scan delegator used to decrypt the Broadcast Audio
+     * Stream and failed.
+     *
+     * <p>This code is valid only if {@link #getEncryptionStatus} returns {@link
+     * #LE_AUDIO_BROADCAST_SINK_ENC_STATE_BAD_CODE}
+     *
+     * @return byte array containing bad broadcast value, null if the current encryption status is
+     *     not {@link #LE_AUDIO_BROADCAST_SINK_ENC_STATE_BAD_CODE}
+     * @hide
+     */
+    public @Nullable byte[] getBadBroadcastCode() {
+        return mBadBroadcastCode;
+    }
+
+    /**
+     * Get the number of subgroups.
+     *
+     * @return number of subgroups
+     * @hide
+     */
+    public byte getNumberOfSubGroups() {
+        return mNumSubGroups;
+    }
+
+    public @NonNull Map<Integer, Integer> getSubgroupBisSyncState() {
+        return mSubgroupBisSyncState;
+    }
+
+    public void setSubgroupBisSyncState(@NonNull Map<Integer, Integer> bisSyncState) {
+        mSubgroupBisSyncState = new HashMap<Integer, Integer>(bisSyncState);
+    }
+
+    /*package*/ void setBroadcastCode(@NonNull String broadcastCode) {
+        mBroadcastCode = broadcastCode;
+    }
+
+    /**
+     * Get the broadcast code
+     *
+     * @return
+     * @hide
+     */
+    public @NonNull String getBroadcastCode() {
+        return mBroadcastCode;
+    }
+
+    /**
+     * Set the broadcast ID
+     *
+     * @param broadcastId broadcast ID of the Broadcast Source
+     * @hide
+     */
+    public void setBroadcastId(int broadcastId) {
+        mBroadcastId = broadcastId;
+    }
+
+    private void writeSubgroupBisSyncStateToParcel(
+            @NonNull Parcel dest, @NonNull Map<Integer, Integer> subgroupBisSyncState) {
+        dest.writeInt(subgroupBisSyncState.size());
+        for (Map.Entry<Integer, Integer> entry : subgroupBisSyncState.entrySet()) {
+            dest.writeInt(entry.getKey());
+            dest.writeInt(entry.getValue());
+        }
+    }
+
+    private static void readSubgroupBisSyncStateFromParcel(
+            @NonNull Parcel in, @NonNull Map<Integer, Integer> subgroupBisSyncState) {
+        int size = in.readInt();
+
+        for (int i = 0; i < size; i++) {
+            Integer key = in.readInt();
+            Integer value = in.readInt();
+            subgroupBisSyncState.put(key, value);
+        }
+    }
+
+    private void writeSubgroupMetadataToParcel(
+            @NonNull Parcel dest, @Nullable Map<Integer, byte[]> subgroupMetadata) {
+        if (subgroupMetadata == null) {
+            dest.writeInt(0);
+            return;
+        }
+
+        dest.writeInt(subgroupMetadata.size());
+        for (Map.Entry<Integer, byte[]> entry : subgroupMetadata.entrySet()) {
+            dest.writeInt(entry.getKey());
+            byte[] metadata = entry.getValue();
+            if (metadata != null) {
+                dest.writeInt(metadata.length);
+                dest.writeByteArray(metadata);
+            }
+        }
+    }
+
+    private static void readSubgroupMetadataFromParcel(
+            @NonNull Parcel in, @NonNull Map<Integer, byte[]> subgroupMetadata) {
+        int size = in.readInt();
+
+        for (int i = 0; i < size; i++) {
+            Integer key = in.readInt();
+            Integer metaDataLen = in.readInt();
+            byte[] metadata = null;
+            if (metaDataLen != 0) {
+                metadata = new byte[metaDataLen];
+                in.readByteArray(metadata);
+            }
+            subgroupMetadata.put(key, metadata);
+        }
+    }
+
+    public static final @NonNull Parcelable.Creator<BluetoothLeBroadcastSourceInfo> CREATOR =
+            new Parcelable.Creator<BluetoothLeBroadcastSourceInfo>() {
+                public @NonNull BluetoothLeBroadcastSourceInfo createFromParcel(
+                        @NonNull Parcel in) {
+                    final byte sourceId = in.readByte();
+                    final int sourceAddressType = in.readInt();
+                    final BluetoothDevice sourceDevice =
+                            in.readTypedObject(BluetoothDevice.CREATOR);
+                    final byte sourceAdvSid = in.readByte();
+                    final int broadcastId = in.readInt();
+                    final int paSyncState = in.readInt();
+                    final int audioSyncState = in.readInt();
+                    final int encryptionStatus = in.readInt();
+                    final int badBroadcastLen = in.readInt();
+                    byte[] badBroadcastCode = null;
+
+                    if (badBroadcastLen > 0) {
+                        badBroadcastCode = new byte[badBroadcastLen];
+                        in.readByteArray(badBroadcastCode);
+                    }
+                    final byte numSubGroups = in.readByte();
+                    final String broadcastCode = in.readString();
+                    Map<Integer, Integer> subgroupBisSyncState = new HashMap<Integer, Integer>();
+                    readSubgroupBisSyncStateFromParcel(in, subgroupBisSyncState);
+                    Map<Integer, byte[]> subgroupMetadata = new HashMap<Integer, byte[]>();
+                    readSubgroupMetadataFromParcel(in, subgroupMetadata);
+
+                    BluetoothLeBroadcastSourceInfo srcInfo =
+                            new BluetoothLeBroadcastSourceInfo(
+                                    sourceId,
+                                    sourceAddressType,
+                                    sourceDevice,
+                                    sourceAdvSid,
+                                    broadcastId,
+                                    paSyncState,
+                                    encryptionStatus,
+                                    audioSyncState,
+                                    badBroadcastCode,
+                                    numSubGroups,
+                                    subgroupBisSyncState,
+                                    subgroupMetadata,
+                                    broadcastCode);
+                    return srcInfo;
+                }
+
+                public @NonNull BluetoothLeBroadcastSourceInfo[] newArray(int size) {
+                    return new BluetoothLeBroadcastSourceInfo[size];
+                }
+            };
+
+    @Override
+    public void writeToParcel(@NonNull Parcel out, int flags) {
+        out.writeByte(mSourceId);
+        out.writeInt(mSourceAddressType);
+        out.writeTypedObject(mSourceDevice, 0);
+        out.writeByte(mSourceAdvSid);
+        out.writeInt(mBroadcastId);
+        out.writeInt(mPaSyncState);
+        out.writeInt(mAudioSyncState);
+        out.writeInt(mEncryptionStatus);
+
+        if (mBadBroadcastCode != null) {
+            out.writeInt(mBadBroadcastCode.length);
+            out.writeByteArray(mBadBroadcastCode);
+        } else {
+            // zero indicates that there is no "bad broadcast code"
+            out.writeInt(0);
+        }
+        out.writeByte(mNumSubGroups);
+        out.writeString(mBroadcastCode);
+        writeSubgroupBisSyncStateToParcel(out, mSubgroupBisSyncState);
+        writeSubgroupMetadataToParcel(out, mSubgroupMetadata);
+    }
+
+    private static void log(@NonNull String msg) {
+        if (DBG) {
+            Log.d(TAG, msg);
+        }
+    }
+}
+;
diff --git a/core/java/android/net/NetworkPolicy.java b/core/java/android/net/NetworkPolicy.java
index 8b3d49e..ab1f542 100644
--- a/core/java/android/net/NetworkPolicy.java
+++ b/core/java/android/net/NetworkPolicy.java
@@ -339,7 +339,8 @@
 
         out.writeInt(template.getMatchRule());
         BackupUtils.writeString(out, template.getSubscriberIds().iterator().next());
-        BackupUtils.writeString(out, template.getWifiNetworkKey());
+        BackupUtils.writeString(out, template.getWifiNetworkKeys().isEmpty()
+                ? null : template.getWifiNetworkKeys().iterator().next());
         out.writeInt(template.getMeteredness());
 
         return baos.toByteArray();
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 44c3d61..983a0aa 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -15,10 +15,13 @@
  */
 package android.os;
 
+import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
+
 import android.animation.ValueAnimator;
 import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.annotation.SystemApi;
 import android.annotation.TestApi;
 import android.app.ActivityManager;
 import android.app.ActivityThread;
@@ -2694,6 +2697,12 @@
         ((AndroidBlockGuardPolicy) policy).onCustomSlowCall(name);
     }
 
+    /** @hide */
+    @SystemApi(client = MODULE_LIBRARIES)
+    public static void noteUntaggedSocket() {
+        if (vmUntaggedSocketEnabled()) onUntaggedSocket();
+    }
+
     /**
      * For code to note that a resource was obtained using a type other than its defined type. This
      * is a no-op unless the current thread's {@link android.os.StrictMode.ThreadPolicy} has {@link
diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java
index d8f6344..b9252d6 100644
--- a/core/java/android/os/SystemClock.java
+++ b/core/java/android/os/SystemClock.java
@@ -311,7 +311,6 @@
      * time or throw.
      *
      * @throws DateTimeException when no accurate network time can be provided.
-     * @hide
      */
     public static @NonNull Clock currentNetworkTimeClock() {
         return new SimpleClock(ZoneOffset.UTC) {
diff --git a/core/java/android/provider/BlockedNumberContract.java b/core/java/android/provider/BlockedNumberContract.java
index dd2ea81..5d00b29 100644
--- a/core/java/android/provider/BlockedNumberContract.java
+++ b/core/java/android/provider/BlockedNumberContract.java
@@ -231,7 +231,7 @@
             prefix = { "STATUS_" },
             value = {STATUS_NOT_BLOCKED, STATUS_BLOCKED_IN_LIST, STATUS_BLOCKED_RESTRICTED,
                     STATUS_BLOCKED_UNKNOWN_NUMBER, STATUS_BLOCKED_PAYPHONE,
-                    STATUS_BLOCKED_NOT_IN_CONTACTS})
+                    STATUS_BLOCKED_NOT_IN_CONTACTS, STATUS_BLOCKED_UNAVAILABLE})
     public @interface BlockStatus {}
 
     /**
@@ -277,6 +277,13 @@
     public static final int STATUS_BLOCKED_NOT_IN_CONTACTS = 5;
 
     /**
+     * Integer reason code used with {@link #RES_BLOCK_STATUS} to indicate that a call was blocked
+     * because it is from a number not available.
+     * @hide
+     */
+    public static final int STATUS_BLOCKED_UNAVAILABLE = 6;
+
+    /**
      * Integer reason indicating whether a call was blocked, and if so why.
      * @hide
      */
@@ -441,6 +448,9 @@
         /* Preference key for whether should show an emergency call notification. */
         public static final String ENHANCED_SETTING_KEY_SHOW_EMERGENCY_CALL_NOTIFICATION =
                 "show_emergency_call_notification";
+        /* Preference key of block unavailable calls setting. */
+        public static final String ENHANCED_SETTING_KEY_BLOCK_UNAVAILABLE =
+                "block_unavailable_calls_setting";
 
         /**
          * Notifies the provider that emergency services were contacted by the user.
@@ -547,6 +557,7 @@
          *        {@link #ENHANCED_SETTING_KEY_BLOCK_PRIVATE}
          *        {@link #ENHANCED_SETTING_KEY_BLOCK_PAYPHONE}
          *        {@link #ENHANCED_SETTING_KEY_BLOCK_UNKNOWN}
+         *        {@link #ENHANCED_SETTING_KEY_BLOCK_UNAVAILABLE}
          *        {@link #ENHANCED_SETTING_KEY_EMERGENCY_CALL_NOTIFICATION_SHOWING}
          * @return {@code true} if the setting is enabled. {@code false} otherwise.
          */
@@ -574,6 +585,7 @@
          *        {@link #ENHANCED_SETTING_KEY_BLOCK_PRIVATE}
          *        {@link #ENHANCED_SETTING_KEY_BLOCK_PAYPHONE}
          *        {@link #ENHANCED_SETTING_KEY_BLOCK_UNKNOWN}
+         *        {@link #ENHANCED_SETTING_KEY_BLOCK_UNAVAILABLE}
          *        {@link #ENHANCED_SETTING_KEY_EMERGENCY_CALL_NOTIFICATION_SHOWING}
          * @param value the enabled statue of the setting to set.
          */
@@ -603,6 +615,8 @@
                     return "blocked - payphone";
                 case STATUS_BLOCKED_NOT_IN_CONTACTS:
                     return "blocked - not in contacts";
+                case STATUS_BLOCKED_UNAVAILABLE:
+                    return "blocked - unavailable";
             }
             return "unknown";
         }
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index b4acb67..54270bf 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -910,6 +910,7 @@
          * <li>{@link #PRESENTATION_RESTRICTED}</li>
          * <li>{@link #PRESENTATION_UNKNOWN}</li>
          * <li>{@link #PRESENTATION_PAYPHONE}</li>
+         * <li>{@link #PRESENTATION_UNAVAILABLE}</li>
          * </ul>
          * </p>
          *
@@ -925,6 +926,8 @@
         public static final int PRESENTATION_UNKNOWN = 3;
         /** Number is a pay phone. */
         public static final int PRESENTATION_PAYPHONE = 4;
+        /** Number is unavailable. */
+        public static final int PRESENTATION_UNAVAILABLE = 5;
 
         /**
          * The ISO 3166-1 two letters country code of the country where the
@@ -2028,6 +2031,10 @@
                 return presentation;
             }
 
+            if (presentation == TelecomManager.PRESENTATION_UNAVAILABLE) {
+                return PRESENTATION_UNAVAILABLE;
+            }
+
             if (TextUtils.isEmpty(number)
                     || presentation == TelecomManager.PRESENTATION_UNKNOWN) {
                 return PRESENTATION_UNKNOWN;
diff --git a/core/java/com/android/server/NetworkManagementSocketTagger.java b/core/java/com/android/server/NetworkManagementSocketTagger.java
index 26ff192..d89566c9 100644
--- a/core/java/com/android/server/NetworkManagementSocketTagger.java
+++ b/core/java/com/android/server/NetworkManagementSocketTagger.java
@@ -70,8 +70,8 @@
             Log.d(TAG, "tagSocket(" + fd.getInt$() + ") with statsTag=0x"
                     + Integer.toHexString(options.statsTag) + ", statsUid=" + options.statsUid);
         }
-        if (options.statsTag == -1 && StrictMode.vmUntaggedSocketEnabled()) {
-            StrictMode.onUntaggedSocket();
+        if (options.statsTag == -1) {
+            StrictMode.noteUntaggedSocket();
         }
         // TODO: skip tagging when options would be no-op
         tagSocketFd(fd, options.statsTag, options.statsUid);
diff --git a/omapi/aidl/Android.bp b/omapi/aidl/Android.bp
index 2b81200..d80317b 100644
--- a/omapi/aidl/Android.bp
+++ b/omapi/aidl/Android.bp
@@ -28,8 +28,5 @@
         rust: {
             enabled: true,
         },
-        ndk: {
-            separate_platform_variant: false,
-        },
     },
 }
diff --git a/packages/ConnectivityT/framework-t/src/android/net/NetworkStats.java b/packages/ConnectivityT/framework-t/src/android/net/NetworkStats.java
index 181a594..b00fea4 100644
--- a/packages/ConnectivityT/framework-t/src/android/net/NetworkStats.java
+++ b/packages/ConnectivityT/framework-t/src/android/net/NetworkStats.java
@@ -83,10 +83,7 @@
      */
     // TODO: Rename TAG_ALL to TAG_ANY.
     public static final int TAG_ALL = -1;
-    /**
-     * {@link #set} value for all sets combined, not including debug sets.
-     * @hide
-     */
+    /** {@link #set} value for all sets combined, not including debug sets. */
     public static final int SET_ALL = -1;
     /** {@link #set} value where background data is accounted. */
     public static final int SET_DEFAULT = 0;
@@ -114,9 +111,6 @@
             SET_ALL,
             SET_DEFAULT,
             SET_FOREGROUND,
-            SET_DEBUG_START,
-            SET_DBG_VPN_IN,
-            SET_DBG_VPN_OUT
     })
     public @interface State {
     }
@@ -131,10 +125,7 @@
     // TODO: Rename TAG_NONE to TAG_ALL.
     public static final int TAG_NONE = 0;
 
-    /**
-     * {@link #metered} value to account for all metered states.
-     * @hide
-     */
+    /** {@link #metered} value to account for all metered states. */
     public static final int METERED_ALL = -1;
     /** {@link #metered} value where native, unmetered data is accounted. */
     public static final int METERED_NO = 0;
@@ -152,10 +143,7 @@
     }
 
 
-    /**
-     * {@link #roaming} value to account for all roaming states.
-     * @hide
-     */
+    /** {@link #roaming} value to account for all roaming states. */
     public static final int ROAMING_ALL = -1;
     /** {@link #roaming} value where native, non-roaming data is accounted. */
     public static final int ROAMING_NO = 0;
@@ -172,10 +160,7 @@
     public @interface Roaming {
     }
 
-    /**
-     * {@link #onDefaultNetwork} value to account for all default network states.
-     * @hide
-     */
+    /** {@link #onDefaultNetwork} value to account for all default network states. */
     public static final int DEFAULT_NETWORK_ALL = -1;
     /** {@link #onDefaultNetwork} value to account for usage while not the default network. */
     public static final int DEFAULT_NETWORK_NO = 0;
diff --git a/packages/ConnectivityT/framework-t/src/android/net/NetworkTemplate.java b/packages/ConnectivityT/framework-t/src/android/net/NetworkTemplate.java
index 659ad06..e9084b0 100644
--- a/packages/ConnectivityT/framework-t/src/android/net/NetworkTemplate.java
+++ b/packages/ConnectivityT/framework-t/src/android/net/NetworkTemplate.java
@@ -16,6 +16,7 @@
 
 package android.net;
 
+import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
 import static android.net.ConnectivityManager.TYPE_BLUETOOTH;
 import static android.net.ConnectivityManager.TYPE_ETHERNET;
 import static android.net.ConnectivityManager.TYPE_MOBILE;
@@ -39,7 +40,9 @@
 import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.annotation.SystemApi;
 import android.compat.annotation.UnsupportedAppUsage;
+import android.net.wifi.WifiInfo;
 import android.os.Build;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -70,7 +73,7 @@
  *
  * @hide
  */
-// @SystemApi(client = MODULE_LIBRARIES)
+@SystemApi(client = MODULE_LIBRARIES)
 public final class NetworkTemplate implements Parcelable {
     /** @hide */
     @Retention(RetentionPolicy.SOURCE)
@@ -572,6 +575,7 @@
 
     /**
      * Get subscriber Id of the template.
+     * @hide
      */
     @Nullable
     @UnsupportedAppUsage
@@ -588,26 +592,19 @@
     }
 
     /**
-     * Get Wifi Network Key of the template. See {@link WifiInfo#getCurrentNetworkKey()}.
+     * Get the set of Wifi Network Keys of the template.
+     * See {@link WifiInfo#getCurrentNetworkKey()}.
      */
-    @Nullable
-    public String getWifiNetworkKey() {
-        return CollectionUtils.isEmpty(mMatchWifiNetworkKeys) ? null : mMatchWifiNetworkKeys[0];
-    }
-
-    /**
-     * Get set of Wifi Network Keys of the template.
-     */
-    @Nullable
+    @NonNull
     public Set<String> getWifiNetworkKeys() {
         return new ArraySet<>(Arrays.asList(mMatchWifiNetworkKeys));
     }
 
     /** @hide */
-    // TODO: Remove this and replace all callers with {@link #getWifiNetworkKey()}.
+    // TODO: Remove this and replace all callers with {@link #getWifiNetworkKeys()}.
     @Nullable
     public String getNetworkId() {
-        return getWifiNetworkKey();
+        return getWifiNetworkKeys().isEmpty() ? null : getWifiNetworkKeys().iterator().next();
     }
 
     /**
diff --git a/packages/ConnectivityT/service/src/com/android/server/IpSecService.java b/packages/ConnectivityT/service/src/com/android/server/IpSecService.java
index d1e432e..179d945 100644
--- a/packages/ConnectivityT/service/src/com/android/server/IpSecService.java
+++ b/packages/ConnectivityT/service/src/com/android/server/IpSecService.java
@@ -1236,37 +1236,53 @@
         int callingUid = Binder.getCallingUid();
         UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
         final int resourceId = mNextResourceId++;
-        FileDescriptor sockFd = null;
+
+        ParcelFileDescriptor pFd = null;
         try {
             if (!userRecord.mSocketQuotaTracker.isAvailable()) {
                 return new IpSecUdpEncapResponse(IpSecManager.Status.RESOURCE_UNAVAILABLE);
             }
 
-            sockFd = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-            mUidFdTagger.tag(sockFd, callingUid);
+            FileDescriptor sockFd = null;
+            try {
+                sockFd = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+                pFd = ParcelFileDescriptor.dup(sockFd);
+            } finally {
+                IoUtils.closeQuietly(sockFd);
+            }
 
+            mUidFdTagger.tag(pFd.getFileDescriptor(), callingUid);
             // This code is common to both the unspecified and specified port cases
             Os.setsockoptInt(
-                    sockFd,
+                    pFd.getFileDescriptor(),
                     OsConstants.IPPROTO_UDP,
                     OsConstants.UDP_ENCAP,
                     OsConstants.UDP_ENCAP_ESPINUDP);
 
-            mNetd.ipSecSetEncapSocketOwner(new ParcelFileDescriptor(sockFd), callingUid);
+            mNetd.ipSecSetEncapSocketOwner(pFd, callingUid);
             if (port != 0) {
                 Log.v(TAG, "Binding to port " + port);
-                Os.bind(sockFd, INADDR_ANY, port);
+                Os.bind(pFd.getFileDescriptor(), INADDR_ANY, port);
             } else {
-                port = bindToRandomPort(sockFd);
+                port = bindToRandomPort(pFd.getFileDescriptor());
             }
 
             userRecord.mEncapSocketRecords.put(
                     resourceId,
                     new RefcountedResource<EncapSocketRecord>(
-                            new EncapSocketRecord(resourceId, sockFd, port), binder));
-            return new IpSecUdpEncapResponse(IpSecManager.Status.OK, resourceId, port, sockFd);
+                            new EncapSocketRecord(resourceId, pFd.getFileDescriptor(), port),
+                            binder));
+            return new IpSecUdpEncapResponse(IpSecManager.Status.OK, resourceId, port,
+                    pFd.getFileDescriptor());
         } catch (IOException | ErrnoException e) {
-            IoUtils.closeQuietly(sockFd);
+            try {
+                if (pFd != null) {
+                    pFd.close();
+                }
+            } catch (IOException ex) {
+                // Nothing can be done at this point
+                Log.e(TAG, "Failed to close pFd.");
+            }
         }
         // If we make it to here, then something has gone wrong and we couldn't open a socket.
         // The only reasonable condition that would cause that is resource unavailable.
diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java
index ef84ce0..ced2e22 100644
--- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java
+++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java
@@ -42,7 +42,6 @@
 import static android.net.NetworkStatsHistory.FIELD_ALL;
 import static android.net.NetworkTemplate.buildTemplateMobileWildcard;
 import static android.net.NetworkTemplate.buildTemplateWifiWildcard;
-import static android.net.TetheringManager.ACTION_TETHER_STATE_CHANGED;
 import static android.net.TrafficStats.KB_IN_BYTES;
 import static android.net.TrafficStats.MB_IN_BYTES;
 import static android.net.TrafficStats.UNSUPPORTED;
@@ -107,13 +106,13 @@
 import android.net.NetworkStatsHistory;
 import android.net.NetworkTemplate;
 import android.net.TelephonyNetworkSpecifier;
+import android.net.TetheringManager;
 import android.net.TrafficStats;
 import android.net.UnderlyingNetworkInfo;
 import android.net.Uri;
 import android.net.netstats.provider.INetworkStatsProvider;
 import android.net.netstats.provider.INetworkStatsProviderCallback;
 import android.net.netstats.provider.NetworkStatsProvider;
-import android.os.BestClock;
 import android.os.Binder;
 import android.os.DropBoxManager;
 import android.os.Environment;
@@ -149,6 +148,7 @@
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.util.FileRotator;
+import com.android.net.module.util.BestClock;
 import com.android.net.module.util.BinderUtils;
 import com.android.net.module.util.CollectionUtils;
 import com.android.net.module.util.NetworkStatsUtils;
@@ -531,8 +531,9 @@
         }
 
         // watch for tethering changes
-        final IntentFilter tetherFilter = new IntentFilter(ACTION_TETHER_STATE_CHANGED);
-        mContext.registerReceiver(mTetherReceiver, tetherFilter, null, mHandler);
+        final TetheringManager tetheringManager = mContext.getSystemService(TetheringManager.class);
+        tetheringManager.registerTetheringEventCallback(
+                new HandlerExecutor(mHandler), mTetherListener);
 
         // listen for periodic polling events
         final IntentFilter pollFilter = new IntentFilter(ACTION_NETWORK_STATS_POLL);
@@ -588,7 +589,8 @@
 
     @GuardedBy("mStatsLock")
     private void shutdownLocked() {
-        mContext.unregisterReceiver(mTetherReceiver);
+        final TetheringManager tetheringManager = mContext.getSystemService(TetheringManager.class);
+        tetheringManager.unregisterTetheringEventCallback(mTetherListener);
         mContext.unregisterReceiver(mPollReceiver);
         mContext.unregisterReceiver(mRemovedReceiver);
         mContext.unregisterReceiver(mUserReceiver);
@@ -1152,14 +1154,15 @@
     }
 
     /**
-     * Receiver that watches for {@link Tethering} to claim interface pairs.
+     * Listener that watches for {@link TetheringManager} to claim interface pairs.
      */
-    private BroadcastReceiver mTetherReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            performPoll(FLAG_PERSIST_NETWORK);
-        }
-    };
+    private final TetheringManager.TetheringEventCallback mTetherListener =
+            new TetheringManager.TetheringEventCallback() {
+                @Override
+                public void onUpstreamChanged(@Nullable Network network) {
+                    performPoll(FLAG_PERSIST_NETWORK);
+                }
+            };
 
     private BroadcastReceiver mPollReceiver = new BroadcastReceiver() {
         @Override
diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsSubscriptionsMonitor.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsSubscriptionsMonitor.java
index 93d0ae7..9bb7bb8 100644
--- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsSubscriptionsMonitor.java
+++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsSubscriptionsMonitor.java
@@ -101,7 +101,8 @@
         // with empty IMSI. So filter the subs w/o a valid IMSI to prevent such registration.
         final List<Pair<Integer, String>> filteredNewSubs = new ArrayList<>();
         for (final int subId : newSubs) {
-            final String subscriberId = mTeleManager.getSubscriberId(subId);
+            final String subscriberId =
+                    mTeleManager.createForSubscriptionId(subId).getSubscriberId();
             if (!TextUtils.isEmpty(subscriberId)) {
                 filteredNewSubs.add(new Pair(subId, subscriberId));
             }
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index bb9740b..7066d56 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -1585,7 +1585,7 @@
 
     if (!inputChannel.ok()) {
         std::string message = inputChannel.error().message();
-        message += StringPrintf(" Status=%d", inputChannel.error().code());
+        message += StringPrintf(" Status=%d", static_cast<int>(inputChannel.error().code()));
         jniThrowRuntimeException(env, message.c_str());
         return nullptr;
     }
@@ -1619,7 +1619,7 @@
 
     if (!inputChannel.ok()) {
         std::string message = inputChannel.error().message();
-        message += StringPrintf(" Status=%d", inputChannel.error().code());
+        message += StringPrintf(" Status=%d", static_cast<int>(inputChannel.error().code()));
         jniThrowRuntimeException(env, message.c_str());
         return nullptr;
     }
diff --git a/telecomm/java/android/telecom/CallScreeningService.java b/telecomm/java/android/telecom/CallScreeningService.java
index 7861b11..37b4e65 100644
--- a/telecomm/java/android/telecom/CallScreeningService.java
+++ b/telecomm/java/android/telecom/CallScreeningService.java
@@ -632,8 +632,9 @@
      * post-dial digits are passed.
      * <p>
      * Calls with a {@link Call.Details#getHandlePresentation()} of
-     * {@link TelecomManager#PRESENTATION_RESTRICTED}, {@link TelecomManager#PRESENTATION_UNKNOWN}
-     * or {@link TelecomManager#PRESENTATION_PAYPHONE} presentation are not provided to the
+     * {@link TelecomManager#PRESENTATION_RESTRICTED}, {@link TelecomManager#PRESENTATION_UNKNOWN},
+     * {@link TelecomManager#PRESENTATION_UNAVAILABLE} or
+     * {@link TelecomManager#PRESENTATION_PAYPHONE} presentation are not provided to the
      * {@link CallScreeningService}.
      *
      * @param callDetails Information about a new call, see {@link Call.Details}.
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index e000265..c9cf2ff 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -987,6 +987,11 @@
      */
     public static final int PRESENTATION_PAYPHONE = 4;
 
+    /**
+     * Indicates that the address or number of a call is unavailable.
+     */
+    public static final int PRESENTATION_UNAVAILABLE = 5;
+
 
     /*
      * Values for the adb property "persist.radio.videocall.audio.output"
@@ -1003,7 +1008,7 @@
     @IntDef(
             prefix = { "PRESENTATION_" },
             value = {PRESENTATION_ALLOWED, PRESENTATION_RESTRICTED, PRESENTATION_UNKNOWN,
-            PRESENTATION_PAYPHONE})
+            PRESENTATION_PAYPHONE, PRESENTATION_UNAVAILABLE})
     public @interface Presentation {}
 
 
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 5851ee1..b109c46 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -2248,6 +2248,7 @@
      * android.provider.BlockedNumberContract.SystemContract#ENHANCED_SETTING_KEY_BLOCK_PRIVATE
      * android.provider.BlockedNumberContract.SystemContract#ENHANCED_SETTING_KEY_BLOCK_PAYPHONE
      * android.provider.BlockedNumberContract.SystemContract#ENHANCED_SETTING_KEY_BLOCK_UNKNOWN
+     * android.provider.BlockedNumberContract.SystemContract#ENHANCED_SETTING_KEY_BLOCK_UNAVAILABLE
      *
      * <p>
      * 1. For Single SIM(SS) device, it can be customized in both carrier_config_mccmnc.xml
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index d5315ac..1fab89e 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1128,6 +1128,52 @@
      */
     public static final String EXTRA_SLOT_INDEX = "android.telephony.extra.SLOT_INDEX";
 
+    /**
+     * A source of phone number: the EF-MSISDN (see 3GPP TS 31.102),
+     * or EF-MDN for CDMA (see 3GPP2 C.P0065-B), from UICC application.
+     *
+     * <p>The availability and a of the number depends on the carrier.
+     * The number may be updated by over-the-air update to UICC applications
+     * from the carrier, or by other means with physical access to the SIM.
+     */
+    public static final int PHONE_NUMBER_SOURCE_UICC = 1;
+
+    /**
+     * A source of phone number: provided by an app that has carrier privilege.
+     *
+     * <p>The number is intended to be set by a carrier app knowing the correct number
+     * which is, for example, different from the number in {@link #PHONE_NUMBER_SOURCE_UICC UICC}
+     * for some reason.
+     * The number is not available until a carrier app sets one via
+     * {@link #setCarrierPhoneNumber(int, String)}.
+     * The app can update the number with the same API should the number change.
+     */
+    public static final int PHONE_NUMBER_SOURCE_CARRIER = 2;
+
+    /**
+     * A source of phone number: provided by IMS (IP Multimedia Subsystem) implementation.
+     * When IMS service is registered (as indicated by
+     * {@link android.telephony.ims.RegistrationManager.RegistrationCallback#onRegistered(int)})
+     * the IMS implementation may return P-Associated-Uri SIP headers (RFC 3455). The URIs
+     * are the user’s public user identities known to the network (see 3GPP TS 24.229 5.4.1.2),
+     * and the phone number is typically one of them (see “global number” in 3GPP TS 23.003 13.4).
+     *
+     * <p>This source provides the phone number from the last IMS registration.
+     * IMS registration may happen on every device reboot or other network condition changes.
+     * The number will be updated should the associated URI change after an IMS registration.
+     */
+    public static final int PHONE_NUMBER_SOURCE_IMS = 3;
+
+    /** @hide */
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef(prefix = {"PHONE_NUMBER_SOURCE"},
+            value = {
+                    PHONE_NUMBER_SOURCE_UICC,
+                    PHONE_NUMBER_SOURCE_CARRIER,
+                    PHONE_NUMBER_SOURCE_IMS,
+            })
+    public @interface PhoneNumberSource {}
+
     private final Context mContext;
 
     // Cache of Resource that has been created in getResourcesForSubId. Key is a Pair containing
@@ -3763,4 +3809,132 @@
                 RESTORE_SIM_SPECIFIC_SETTINGS_METHOD_NAME,
                 null, bundle);
     }
+
+    /**
+     * Returns the phone number for the given {@code subId} and {@code source},
+     * or an empty string if not available.
+     *
+     * <p>Requires Permission:
+     * {@link android.Manifest.permission#READ_PHONE_NUMBERS READ_PHONE_NUMBERS}, or
+     * READ_PRIVILEGED_PHONE_STATE permission (can only be granted to apps preloaded on device),
+     * or that the calling app has carrier privileges
+     * (see {@link TelephonyManager#hasCarrierPrivileges}).
+     *
+     * @param subscriptionId the subscription ID, or {@link #DEFAULT_SUBSCRIPTION_ID}
+     *                       for the default one.
+     * @param source the source of the phone number, one of the PHONE_NUMBER_SOURCE_* constants.
+     * @return the phone number, or an empty string if not available.
+     * @throws IllegalArgumentException if {@code source} is invalid.
+     * @throws IllegalStateException if the telephony process is not currently available.
+     * @throws SecurityException if the caller doesn't have permissions required.
+     * @see #PHONE_NUMBER_SOURCE_UICC
+     * @see #PHONE_NUMBER_SOURCE_CARRIER
+     * @see #PHONE_NUMBER_SOURCE_IMS
+     */
+    @SuppressAutoDoc // No support for carrier privileges (b/72967236)
+    @RequiresPermission(anyOf = {
+            android.Manifest.permission.READ_PHONE_NUMBERS,
+            android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+    })
+    @NonNull
+    public String getPhoneNumber(int subscriptionId, @PhoneNumberSource int source) {
+        if (subscriptionId == DEFAULT_SUBSCRIPTION_ID) {
+            subscriptionId = getDefaultSubscriptionId();
+        }
+        if (source != PHONE_NUMBER_SOURCE_UICC
+                && source != PHONE_NUMBER_SOURCE_CARRIER
+                && source != PHONE_NUMBER_SOURCE_IMS) {
+            throw new IllegalArgumentException("invalid source " + source);
+        }
+        try {
+            ISub iSub = TelephonyManager.getSubscriptionService();
+            if (iSub != null) {
+                return iSub.getPhoneNumber(subscriptionId, source,
+                        mContext.getOpPackageName(), mContext.getAttributionTag());
+            } else {
+                throw new IllegalStateException("subscription service unavailable.");
+            }
+        } catch (RemoteException ex) {
+            throw ex.rethrowAsRuntimeException();
+        }
+    }
+
+    /**
+     * Returns the phone number for the given {@code subId}, or an empty string if
+     * not available.
+     *
+     * <p>This API is built up on {@link #getPhoneNumber(int, int)}, but picks
+     * from available sources in the following order: {@link #PHONE_NUMBER_SOURCE_CARRIER}
+     * > {@link #PHONE_NUMBER_SOURCE_UICC} > {@link #PHONE_NUMBER_SOURCE_IMS}.
+     *
+     * <p>Requires Permission:
+     * {@link android.Manifest.permission#READ_PHONE_NUMBERS READ_PHONE_NUMBERS}, or
+     * READ_PRIVILEGED_PHONE_STATE permission (can only be granted to apps preloaded on device),
+     * or that the calling app has carrier privileges
+     * (see {@link TelephonyManager#hasCarrierPrivileges}).
+     *
+     * @param subscriptionId the subscription ID, or {@link #DEFAULT_SUBSCRIPTION_ID}
+     *                       for the default one.
+     * @return the phone number, or an empty string if not available.
+     * @throws IllegalStateException if the telephony process is not currently available.
+     * @throws SecurityException if the caller doesn't have permissions required.
+     * @see #getPhoneNumber(int, int)
+     */
+    @SuppressAutoDoc // No support for carrier privileges (b/72967236)
+    @RequiresPermission(anyOf = {
+            android.Manifest.permission.READ_PHONE_NUMBERS,
+            android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+    })
+    @NonNull
+    public String getPhoneNumber(int subscriptionId) {
+        if (subscriptionId == DEFAULT_SUBSCRIPTION_ID) {
+            subscriptionId = getDefaultSubscriptionId();
+        }
+        try {
+            ISub iSub = TelephonyManager.getSubscriptionService();
+            if (iSub != null) {
+                return iSub.getPhoneNumberFromFirstAvailableSource(subscriptionId,
+                        mContext.getOpPackageName(), mContext.getAttributionTag());
+            } else {
+                throw new IllegalStateException("subscription service unavailable.");
+            }
+        } catch (RemoteException ex) {
+            throw ex.rethrowAsRuntimeException();
+        }
+    }
+
+    /**
+     * Sets the phone number for the given {@code subId} for source
+     * {@link #PHONE_NUMBER_SOURCE_CARRIER carrier}.
+     * Sets an empty string to remove the previously set phone number.
+     *
+     * <p>Requires Permission: the calling app has carrier privileges
+     * (see {@link TelephonyManager#hasCarrierPrivileges}).
+     *
+     * @param subscriptionId the subscription ID, or {@link #DEFAULT_SUBSCRIPTION_ID}
+     *                       for the default one.
+     * @param number the phone number, or an empty string to remove the previously set number.
+     * @throws IllegalStateException if the telephony process is not currently available.
+     * @throws NullPointerException if {@code number} is {@code null}.
+     * @throws SecurityException if the caller doesn't have permissions required.
+     */
+    public void setCarrierPhoneNumber(int subscriptionId, @NonNull String number) {
+        if (subscriptionId == DEFAULT_SUBSCRIPTION_ID) {
+            subscriptionId = getDefaultSubscriptionId();
+        }
+        if (number == null) {
+            throw new NullPointerException("invalid number null");
+        }
+        try {
+            ISub iSub = TelephonyManager.getSubscriptionService();
+            if (iSub != null) {
+                iSub.setPhoneNumber(subscriptionId, PHONE_NUMBER_SOURCE_CARRIER, number,
+                        mContext.getOpPackageName(), mContext.getAttributionTag());
+            } else {
+                throw new IllegalStateException("subscription service unavailable.");
+            }
+        } catch (RemoteException ex) {
+            throw ex.rethrowAsRuntimeException();
+        }
+    }
 }
diff --git a/telephony/java/android/telephony/ims/ImsCallProfile.java b/telephony/java/android/telephony/ims/ImsCallProfile.java
index 486f746..c04060d 100644
--- a/telephony/java/android/telephony/ims/ImsCallProfile.java
+++ b/telephony/java/android/telephony/ims/ImsCallProfile.java
@@ -317,6 +317,10 @@
      * Payphone presentation for Originating Identity.
      */
     public static final int OIR_PRESENTATION_PAYPHONE = 4;
+    /**
+     * Unavailable presentation for Originating Identity.
+     */
+    public static final int OIR_PRESENTATION_UNAVAILABLE = 5;
 
     //Values for EXTRA_DIALSTRING
     /**
@@ -989,6 +993,8 @@
                 return ImsCallProfile.OIR_PRESENTATION_PAYPHONE;
             case PhoneConstants.PRESENTATION_UNKNOWN:
                 return ImsCallProfile.OIR_PRESENTATION_UNKNOWN;
+            case PhoneConstants.PRESENTATION_UNAVAILABLE:
+                return ImsCallProfile.OIR_PRESENTATION_UNAVAILABLE;
             default:
                 return ImsCallProfile.OIR_DEFAULT;
         }
@@ -1017,6 +1023,8 @@
                 return PhoneConstants.PRESENTATION_ALLOWED;
             case ImsCallProfile.OIR_PRESENTATION_PAYPHONE:
                 return PhoneConstants.PRESENTATION_PAYPHONE;
+            case ImsCallProfile.OIR_PRESENTATION_UNAVAILABLE:
+                return PhoneConstants.PRESENTATION_UNAVAILABLE;
             case ImsCallProfile.OIR_PRESENTATION_UNKNOWN:
                 return PhoneConstants.PRESENTATION_UNKNOWN;
             default:
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index 6493772..a900c84 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -304,4 +304,13 @@
     int setDeviceToDeviceStatusSharing(int sharing, int subId);
 
     int setDeviceToDeviceStatusSharingContacts(String contacts, int subscriptionId);
+
+    String getPhoneNumber(int subId, int source,
+            String callingPackage, String callingFeatureId);
+
+    String getPhoneNumberFromFirstAvailableSource(int subId,
+            String callingPackage, String callingFeatureId);
+
+    void setPhoneNumber(int subId, int source, String number,
+            String callingPackage, String callingFeatureId);
 }
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
index f650246..813e80e 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -95,6 +95,7 @@
     public static final int PRESENTATION_UNKNOWN = 3;    // no specified or unknown by network
     @UnsupportedAppUsage
     public static final int PRESENTATION_PAYPHONE = 4;   // show pay phone info
+    public static final int PRESENTATION_UNAVAILABLE = 5;   // show unavailable
 
     public static final String PHONE_NAME_KEY = "phoneName";
     public static final String DATA_NETWORK_TYPE_KEY = "networkType";
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 866fd2c..ba95841 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -530,6 +530,8 @@
     int RIL_REQUEST_GET_SLICING_CONFIG = 224;
     int RIL_REQUEST_ENABLE_VONR = 225;
     int RIL_REQUEST_IS_VONR_ENABLED = 226;
+    int RIL_REQUEST_SET_USAGE_SETTING = 227;
+    int RIL_REQUEST_GET_USAGE_SETTING = 228;
 
     /* Responses begin */
     int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;