Merge "Fix cert-dcl16-c clang-tidy warnings."
diff --git a/Android.bp b/Android.bp
index 9a815c6..cd7f98d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -621,6 +621,8 @@
         "core/java/com/android/server/DropboxLogTags.logtags",
         "core/java/org/chromium/arc/EventLogTags.logtags",
 
+        ":platform-properties",
+
         ":framework-statslog-gen",
     ],
 
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index e061b15..543f0ed 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,13 +1,5 @@
 [Hook Scripts]
 checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
-                  -fw core/java/android/
-                      graphics/java/android
-                      core/tests/coretests/src/android/
-                      packages/PrintRecommendationService/
-                      packages/PrintSpooler/
-                      services/print/
-                      services/usb/
-                      telephony/
 
 api_lint_hook = ${REPO_ROOT}/frameworks/base/tools/apilint/apilint_sha.sh ${PREUPLOAD_COMMIT}
 
diff --git a/api/current.txt b/api/current.txt
index 0eb6985..e4f95fd 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -41116,8 +41116,9 @@
     method public void swapConference();
     method public void unhold();
     method public void unregisterCallback(android.telecom.Call.Callback);
-    field public static final java.lang.String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts";
+    field public static final deprecated java.lang.String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts";
     field public static final java.lang.String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS = "android.telecom.extra.LAST_EMERGENCY_CALLBACK_TIME_MILLIS";
+    field public static final java.lang.String EXTRA_SUGGESTED_PHONE_ACCOUNTS = "android.telecom.extra.SUGGESTED_PHONE_ACCOUNTS";
     field public static final int STATE_ACTIVE = 4; // 0x4
     field public static final int STATE_CONNECTING = 9; // 0x9
     field public static final int STATE_DIALING = 1; // 0x1
@@ -41688,6 +41689,20 @@
     field public static final android.os.Parcelable.Creator<android.telecom.PhoneAccountHandle> CREATOR;
   }
 
+  public final class PhoneAccountSuggestion implements android.os.Parcelable {
+    method public int describeContents();
+    method public android.telecom.PhoneAccountHandle getPhoneAccountHandle();
+    method public int getReason();
+    method public boolean shouldAutoSelect();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.telecom.PhoneAccountSuggestion> CREATOR;
+    field public static final int REASON_FREQUENT = 2; // 0x2
+    field public static final int REASON_INTRA_CARRIER = 1; // 0x1
+    field public static final int REASON_NONE = 0; // 0x0
+    field public static final int REASON_OTHER = 4; // 0x4
+    field public static final int REASON_USER_SET = 3; // 0x3
+  }
+
   public final class RemoteConference {
     method public void disconnect();
     method public java.util.List<android.telecom.RemoteConnection> getConferenceableConnections();
@@ -43086,6 +43101,7 @@
     field public static final int NETWORK_TYPE_IDEN = 11; // 0xb
     field public static final int NETWORK_TYPE_IWLAN = 18; // 0x12
     field public static final int NETWORK_TYPE_LTE = 13; // 0xd
+    field public static final int NETWORK_TYPE_NR = 20; // 0x14
     field public static final int NETWORK_TYPE_TD_SCDMA = 17; // 0x11
     field public static final int NETWORK_TYPE_UMTS = 3; // 0x3
     field public static final int NETWORK_TYPE_UNKNOWN = 0; // 0x0
diff --git a/api/system-current.txt b/api/system-current.txt
index 4aaed7a..18ff66c 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5022,6 +5022,10 @@
     field public static final int CAPABILITY_MULTI_USER = 32; // 0x20
   }
 
+  public final class PhoneAccountSuggestion implements android.os.Parcelable {
+    ctor public PhoneAccountSuggestion(android.telecom.PhoneAccountHandle, int, boolean);
+  }
+
   public final class RemoteConference {
     method public deprecated void setAudioState(android.telecom.AudioState);
   }
@@ -5439,6 +5443,7 @@
     field public static final int NETWORK_TYPE_BITMASK_HSUPA = 512; // 0x200
     field public static final int NETWORK_TYPE_BITMASK_LTE = 8192; // 0x2000
     field public static final int NETWORK_TYPE_BITMASK_LTE_CA = 524288; // 0x80000
+    field public static final int NETWORK_TYPE_BITMASK_NR = 1048576; // 0x100000
     field public static final int NETWORK_TYPE_BITMASK_TD_SCDMA = 131072; // 0x20000
     field public static final int NETWORK_TYPE_BITMASK_UMTS = 8; // 0x8
     field public static final int NETWORK_TYPE_BITMASK_UNKNOWN = 1; // 0x1
@@ -6217,12 +6222,6 @@
     method public android.telephony.ims.ImsSsInfo.Builder setProvisionStatus(int);
   }
 
-  public static abstract class ImsSsInfo.ClirInterrogationStatus implements java.lang.annotation.Annotation {
-  }
-
-  public static abstract class ImsSsInfo.ClirOutgoingState implements java.lang.annotation.Annotation {
-  }
-
   public final class ImsStreamMediaProfile implements android.os.Parcelable {
     ctor public ImsStreamMediaProfile(int, int, int, int, int);
     method public void copyFrom(android.telephony.ims.ImsStreamMediaProfile);
diff --git a/api/test-current.txt b/api/test-current.txt
index 8466ef0..b5b128a 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -963,6 +963,10 @@
     ctor public CallAudioState(boolean, int, int, android.bluetooth.BluetoothDevice, java.util.Collection<android.bluetooth.BluetoothDevice>);
   }
 
+  public final class PhoneAccountSuggestion implements android.os.Parcelable {
+    ctor public PhoneAccountSuggestion(android.telecom.PhoneAccountHandle, int, boolean);
+  }
+
 }
 
 package android.telephony {
diff --git a/cmds/telecom/src/com/android/commands/telecom/Telecom.java b/cmds/telecom/src/com/android/commands/telecom/Telecom.java
index f3bf6e7..a39f5e3 100644
--- a/cmds/telecom/src/com/android/commands/telecom/Telecom.java
+++ b/cmds/telecom/src/com/android/commands/telecom/Telecom.java
@@ -46,6 +46,7 @@
     private static final String COMMAND_SET_PHONE_ACCOUNT_DISABLED = "set-phone-account-disabled";
     private static final String COMMAND_REGISTER_PHONE_ACCOUNT = "register-phone-account";
     private static final String COMMAND_REGISTER_SIM_PHONE_ACCOUNT = "register-sim-phone-account";
+    private static final String COMMAND_SET_TEST_CALL_REDIRECTION_APP = "set-test-call-redirection-app";
     private static final String COMMAND_SET_TEST_CALL_SCREENING_APP = "set-test-call-screening-app";
     private static final String COMMAND_ADD_OR_REMOVE_CALL_COMPANION_APP =
             "add-or-remove-call-companion-app";
@@ -68,6 +69,7 @@
                 "usage: telecom set-phone-account-enabled <COMPONENT> <ID> <USER_SN>\n" +
                 "usage: telecom set-phone-account-disabled <COMPONENT> <ID> <USER_SN>\n" +
                 "usage: telecom register-phone-account <COMPONENT> <ID> <USER_SN> <LABEL>\n" +
+                "usage: telecom set-test-call-redirection-app <PACKAGE>\n" +
                 "usage: telecom set-test-call-screening-app <PACKAGE>\n" +
                 "usage: telecom set-test-auto-mode-app <PACKAGE>\n" +
                 "usage: telecom add-or-remove-call-companion-app <PACKAGE> <1/0>\n" +
@@ -120,6 +122,9 @@
             case COMMAND_REGISTER_PHONE_ACCOUNT:
                 runRegisterPhoneAccount();
                 break;
+            case COMMAND_SET_TEST_CALL_REDIRECTION_APP:
+                runSetTestCallRedirectionApp();
+                break;
             case COMMAND_SET_TEST_CALL_SCREENING_APP:
                 runSetTestCallScreeningApp();
                 break;
@@ -189,6 +194,11 @@
         System.out.println("Success - " + handle + " registered.");
     }
 
+    private void runSetTestCallRedirectionApp() throws RemoteException {
+        final String packageName = nextArg();
+        mTelecomService.setTestDefaultCallRedirectionApp(packageName);
+    }
+
     private void runSetTestCallScreeningApp() throws RemoteException {
         final String packageName = nextArg();
         mTelecomService.setTestDefaultCallScreeningApp(packageName);
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index 1488b09..2aeb431 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1716,10 +1716,6 @@
 Landroid/widget/RelativeLayout$DependencyGraph$Node;-><init>()V
 Landroid/widget/RemoteViews$OnClickHandler;-><init>()V
 Landroid/widget/ScrollBarDrawable;-><init>()V
-Lcom/android/i18n/phonenumbers/Phonenumber$PhoneNumber$CountryCodeSource;->values()[Lcom/android/i18n/phonenumbers/Phonenumber$PhoneNumber$CountryCodeSource;
-Lcom/android/i18n/phonenumbers/PhoneNumberUtil$MatchType;->values()[Lcom/android/i18n/phonenumbers/PhoneNumberUtil$MatchType;
-Lcom/android/i18n/phonenumbers/PhoneNumberUtil$PhoneNumberFormat;->values()[Lcom/android/i18n/phonenumbers/PhoneNumberUtil$PhoneNumberFormat;
-Lcom/android/i18n/phonenumbers/PhoneNumberUtil$PhoneNumberType;->values()[Lcom/android/i18n/phonenumbers/PhoneNumberUtil$PhoneNumberType;
 Lcom/android/ims/ImsCall;->deflect(Ljava/lang/String;)V
 Lcom/android/ims/ImsCall;->isMultiparty()Z
 Lcom/android/ims/ImsCall;->reject(I)V
diff --git a/core/java/android/annotation/UnsupportedAppUsage.java b/core/java/android/annotation/UnsupportedAppUsage.java
index 65e3f25..ac3daaf 100644
--- a/core/java/android/annotation/UnsupportedAppUsage.java
+++ b/core/java/android/annotation/UnsupportedAppUsage.java
@@ -26,16 +26,32 @@
 import java.lang.annotation.Target;
 
 /**
- * Indicates that a class member, that is not part of the SDK, is used by apps.
- * Since the member is not part of the SDK, such use is not supported.
+ * Indicates that this non-SDK interface is used by apps. A non-SDK interface is a
+ * class member (field or method) that is not part of the public SDK. Since the
+ * member is not part of the SDK, usage by apps is not supported.
  *
- * <p>This annotation acts as a heads up that changing a given method or field
+ * <h2>If you are an Android App developer</h2>
+ *
+ * This annotation indicates that you may be able to access the member, but that
+ * this access is discouraged and not supported by Android. If there is a value
+ * for {@link #maxTargetSdk()} on the annotation, access will be restricted based
+ * on the {@code targetSdkVersion} value set in your manifest.
+ *
+ * <p>Fields and methods annotated with this are likely to be restricted, changed
+ * or removed in future Android releases. If you rely on these members for
+ * functionality that is not otherwise supported by Android, consider filing a
+ * <a href="http://g.co/dev/appcompat">feature request</a>.
+ *
+ * <h2>If you are an Android OS developer</h2>
+ *
+ * This annotation acts as a heads up that changing a given method or field
  * may affect apps, potentially breaking them when the next Android version is
  * released. In some cases, for members that are heavily used, this annotation
  * may imply restrictions on changes to the member.
  *
  * <p>This annotation also results in access to the member being permitted by the
- * runtime, with a warning being generated in debug builds.
+ * runtime, with a warning being generated in debug builds. Which apps can access
+ * the member is determined by the value of {@link #maxTargetSdk()}.
  *
  * <p>For more details, see go/UnsupportedAppUsage.
  *
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
old mode 100644
new mode 100755
index 9188894..6932aa7
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -1113,7 +1113,8 @@
      * null (if, for instance, the radio is not currently on).
      */
     public static String getRadioVersion() {
-        return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null);
+        String propVal = SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
+        return TextUtils.isEmpty(propVal) ? null : propVal;
     }
 
     private static String getString(String property) {
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index d072d02..6b59279 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -52,6 +52,7 @@
 import android.os.ServiceManager.ServiceNotFoundException;
 import android.os.SystemProperties;
 import android.provider.Settings;
+import android.sysprop.VoldProperties;
 import android.system.ErrnoException;
 import android.system.Os;
 import android.system.OsConstants;
@@ -1465,7 +1466,7 @@
      * framework, so no service needs to check for changes during their lifespan
      */
     public static boolean isBlockEncrypting() {
-        final String state = SystemProperties.get("vold.encrypt_progress", "");
+        final String state = VoldProperties.encrypt_progress().orElse("");
         return !"".equalsIgnoreCase(state);
     }
 
@@ -1481,7 +1482,7 @@
      * framework, so no service needs to check for changes during their lifespan
      */
     public static boolean inCryptKeeperBounce() {
-        final String status = SystemProperties.get("vold.decrypt");
+        final String status = VoldProperties.decrypt().orElse("");
         return "trigger_restart_min_framework".equals(status);
     }
 
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 7a3f49a..01105ba 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -273,15 +273,17 @@
     }
   }
 
-  // We don't want core dumps, though, so set the soft limit on core dump size
-  // to 0 without changing the hard limit.
-  rlimit rl;
-  if (getrlimit(RLIMIT_CORE, &rl) == -1) {
-    ALOGE("getrlimit(RLIMIT_CORE) failed");
-  } else {
-    rl.rlim_cur = 0;
-    if (setrlimit(RLIMIT_CORE, &rl) == -1) {
-      ALOGE("setrlimit(RLIMIT_CORE) failed");
+  // Set the core dump size to zero unless wanted (see also coredump_setup in build/envsetup.sh).
+  if (!GetBoolProperty("persist.zygote.core_dump", false)) {
+    // Set the soft limit on core dump size to 0 without changing the hard limit.
+    rlimit rl;
+    if (getrlimit(RLIMIT_CORE, &rl) == -1) {
+      ALOGE("getrlimit(RLIMIT_CORE) failed");
+    } else {
+      rl.rlim_cur = 0;
+      if (setrlimit(RLIMIT_CORE, &rl) == -1) {
+        ALOGE("setrlimit(RLIMIT_CORE) failed");
+      }
     }
   }
 }
diff --git a/core/proto/android/telephony/enums.proto b/core/proto/android/telephony/enums.proto
index fba2e51..4777169 100644
--- a/core/proto/android/telephony/enums.proto
+++ b/core/proto/android/telephony/enums.proto
@@ -51,6 +51,7 @@
     NETWORK_TYPE_TD_SCDMA = 17;
     NETWORK_TYPE_IWLAN = 18;
     NETWORK_TYPE_LTE_CA = 19;
+    NETWORK_TYPE_NR = 20;
 }
 
 // Signal strength levels, primarily used by android/telephony/SignalStrength.java.
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
index 8f254e9..a7de631 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
@@ -200,7 +200,7 @@
             }
             if (objectInfo.getFormat() != MtpConstants.FORMAT_ASSOCIATION) {
                 if (!device.sendObject(sendObjectInfoResult.getObjectHandle(),
-                        sendObjectInfoResult.getCompressedSize(), source)) {
+                        sendObjectInfoResult.getCompressedSizeLong(), source)) {
                     throw new IOException("Failed to send contents of a document");
                 }
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java
index 639e50c..9c099f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EncryptionHelper.java
@@ -16,7 +16,7 @@
 
 package com.android.systemui.statusbar.policy;
 
-import android.os.SystemProperties;
+import android.sysprop.VoldProperties;
 
 /**
  * Helper for determining whether the phone is decrypted yet.
@@ -26,7 +26,7 @@
     public static final boolean IS_DATA_ENCRYPTED = isDataEncrypted();
 
     private static boolean isDataEncrypted() {
-        String voldState = SystemProperties.get("vold.decrypt");
+        String voldState = VoldProperties.decrypt().orElse("");
         return "1".equals(voldState) || "trigger_restart_min_framework".equals(voldState);
     }
 }
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 14503f9..eda9fe1 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -902,6 +902,7 @@
         // Listen to package add and removal events for all users.
         intentFilter = new IntentFilter();
         intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
+        intentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
         intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
         intentFilter.addDataScheme("package");
         mContext.registerReceiverAsUser(
@@ -4203,12 +4204,46 @@
         mPermissionMonitor.onPackageAdded(packageName, uid);
     }
 
-    private void onPackageRemoved(String packageName, int uid) {
+    private void onPackageReplaced(String packageName, int uid) {
+        if (TextUtils.isEmpty(packageName) || uid < 0) {
+            Slog.wtf(TAG, "Invalid package in onPackageReplaced: " + packageName + " | " + uid);
+            return;
+        }
+        final int userId = UserHandle.getUserId(uid);
+        synchronized (mVpns) {
+            final Vpn vpn = mVpns.get(userId);
+            if (vpn == null) {
+                return;
+            }
+            // Legacy always-on VPN won't be affected since the package name is not set.
+            if (TextUtils.equals(vpn.getAlwaysOnPackage(), packageName)) {
+                Slog.d(TAG, "Restarting always-on VPN package " + packageName + " for user "
+                        + userId);
+                vpn.startAlwaysOnVpn();
+            }
+        }
+    }
+
+    private void onPackageRemoved(String packageName, int uid, boolean isReplacing) {
         if (TextUtils.isEmpty(packageName) || uid < 0) {
             Slog.wtf(TAG, "Invalid package in onPackageRemoved: " + packageName + " | " + uid);
             return;
         }
         mPermissionMonitor.onPackageRemoved(uid);
+
+        final int userId = UserHandle.getUserId(uid);
+        synchronized (mVpns) {
+            final Vpn vpn = mVpns.get(userId);
+            if (vpn == null) {
+                return;
+            }
+            // Legacy always-on VPN won't be affected since the package name is not set.
+            if (TextUtils.equals(vpn.getAlwaysOnPackage(), packageName) && !isReplacing) {
+                Slog.d(TAG, "Removing always-on VPN package " + packageName + " for user "
+                        + userId);
+                vpn.setAlwaysOnPackage(null, false);
+            }
+        }
     }
 
     private void onUserUnlocked(int userId) {
@@ -4245,8 +4280,12 @@
                 onUserUnlocked(userId);
             } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
                 onPackageAdded(packageName, uid);
+            } else if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) {
+                onPackageReplaced(packageName, uid);
             } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
-                onPackageRemoved(packageName, uid);
+                final boolean isReplacing = intent.getBooleanExtra(
+                        Intent.EXTRA_REPLACING, false);
+                onPackageRemoved(packageName, uid, isReplacing);
             }
         }
     };
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index a3e6ea2..371e517 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -99,6 +99,7 @@
 import android.os.storage.VolumeRecord;
 import android.provider.MediaStore;
 import android.provider.Settings;
+import android.sysprop.VoldProperties;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.util.ArrayMap;
@@ -973,7 +974,7 @@
 
         // On an encrypted device we can't see system properties yet, so pull
         // the system locale out of the mount service.
-        if ("".equals(SystemProperties.get("vold.encrypt_progress"))) {
+        if ("".equals(VoldProperties.encrypt_progress().orElse(""))) {
             copyLocaleFromMountService();
         }
     }
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index a411af2..5df2c64 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -364,6 +364,7 @@
 import android.provider.Settings;
 import android.service.voice.IVoiceInteractionSession;
 import android.service.voice.VoiceInteractionManagerInternal;
+import android.sysprop.VoldProperties;
 import android.telecom.TelecomManager;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
@@ -7958,8 +7959,8 @@
             SystemProperties.set("sys.boot_completed", "1");
 
             // And trigger dev.bootcomplete if we are not showing encryption progress
-            if (!"trigger_restart_min_framework".equals(SystemProperties.get("vold.decrypt"))
-                    || "".equals(SystemProperties.get("vold.encrypt_progress"))) {
+            if (!"trigger_restart_min_framework".equals(VoldProperties.decrypt().orElse(""))
+                    || "".equals(VoldProperties.encrypt_progress().orElse(""))){
                 SystemProperties.set("dev.bootcomplete", "1");
             }
             mUserController.sendBootCompleted(
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index 3c14393..d75601b 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -944,10 +944,11 @@
     public boolean hasTetherableConfiguration() {
         final TetheringConfiguration cfg = mConfig;
         final boolean hasDownstreamConfiguration =
-                (cfg.tetherableUsbRegexs.length != 0) ||
-                (cfg.tetherableWifiRegexs.length != 0) ||
-                (cfg.tetherableBluetoothRegexs.length != 0);
-        final boolean hasUpstreamConfiguration = !cfg.preferredUpstreamIfaceTypes.isEmpty();
+                (cfg.tetherableUsbRegexs.length != 0)
+                || (cfg.tetherableWifiRegexs.length != 0)
+                || (cfg.tetherableBluetoothRegexs.length != 0);
+        final boolean hasUpstreamConfiguration = !cfg.preferredUpstreamIfaceTypes.isEmpty()
+                || cfg.chooseUpstreamAutomatically;
 
         return hasDownstreamConfiguration && hasUpstreamConfiguration;
     }
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index b7ed2f9..602aedb 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -206,45 +206,6 @@
     // Handle of the user initiating VPN.
     private final int mUserHandle;
 
-    // Listen to package removal and change events (update/uninstall) for this user
-    private final BroadcastReceiver mPackageIntentReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            final Uri data = intent.getData();
-            final String packageName = data == null ? null : data.getSchemeSpecificPart();
-            if (packageName == null) {
-                return;
-            }
-
-            synchronized (Vpn.this) {
-                // Avoid race where always-on package has been unset
-                if (!packageName.equals(getAlwaysOnPackage())) {
-                    return;
-                }
-
-                final String action = intent.getAction();
-                Log.i(TAG, "Received broadcast " + action + " for always-on VPN package "
-                        + packageName + " in user " + mUserHandle);
-
-                switch(action) {
-                    case Intent.ACTION_PACKAGE_REPLACED:
-                        // Start vpn after app upgrade
-                        startAlwaysOnVpn();
-                        break;
-                    case Intent.ACTION_PACKAGE_REMOVED:
-                        final boolean isPackageRemoved = !intent.getBooleanExtra(
-                                Intent.EXTRA_REPLACING, false);
-                        if (isPackageRemoved) {
-                            setAlwaysOnPackage(null, false);
-                        }
-                        break;
-                }
-            }
-        }
-    };
-
-    private boolean mIsPackageIntentReceiverRegistered = false;
-
     public Vpn(Looper looper, Context context, INetworkManagementService netService,
             @UserIdInt int userHandle) {
         this(looper, context, netService, userHandle, new SystemServices(context));
@@ -500,7 +461,6 @@
             // Prepare this app. The notification will update as a side-effect of updateState().
             prepareInternal(packageName);
         }
-        maybeRegisterPackageChangeReceiverLocked(packageName);
         setVpnForcedLocked(mLockdown);
         return true;
     }
@@ -509,31 +469,6 @@
         return packageName == null || VpnConfig.LEGACY_VPN.equals(packageName);
     }
 
-    private void unregisterPackageChangeReceiverLocked() {
-        if (mIsPackageIntentReceiverRegistered) {
-            mContext.unregisterReceiver(mPackageIntentReceiver);
-            mIsPackageIntentReceiverRegistered = false;
-        }
-    }
-
-    private void maybeRegisterPackageChangeReceiverLocked(String packageName) {
-        // Unregister IntentFilter listening for previous always-on package change
-        unregisterPackageChangeReceiverLocked();
-
-        if (!isNullOrLegacyVpn(packageName)) {
-            mIsPackageIntentReceiverRegistered = true;
-
-            IntentFilter intentFilter = new IntentFilter();
-            // Protected intent can only be sent by system. No permission required in register.
-            intentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
-            intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
-            intentFilter.addDataScheme("package");
-            intentFilter.addDataSchemeSpecificPart(packageName, PatternMatcher.PATTERN_LITERAL);
-            mContext.registerReceiverAsUser(
-                    mPackageIntentReceiver, UserHandle.of(mUserHandle), intentFilter, null, null);
-        }
-    }
-
     /**
      * @return the package name of the VPN controller responsible for always-on VPN,
      *         or {@code null} if none is set or always-on VPN is controlled through
@@ -1302,7 +1237,6 @@
         setLockdown(false);
         mAlwaysOn = false;
 
-        unregisterPackageChangeReceiverLocked();
         // Quit any active connections
         agentDisconnect();
     }
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
index de0f298..25ca278 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
@@ -1082,13 +1082,14 @@
         assertRunOnServiceThread();
 
         if (!canStartArcUpdateAction(message.getSource(), true)) {
-            if (getAvrDeviceInfo() == null) {
+            HdmiDeviceInfo avrDeviceInfo = getAvrDeviceInfo();
+            if (avrDeviceInfo == null) {
                 // AVR may not have been discovered yet. Delay the message processing.
                 mDelayedMessageBuffer.add(message);
                 return true;
             }
             mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED);
-            if (!isConnectedToArcPort(message.getSource())) {
+            if (!isConnectedToArcPort(avrDeviceInfo.getPhysicalAddress())) {
                 displayOsd(OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT);
             }
             return true;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 80b0e6f..65ee52a 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -48,6 +48,7 @@
 import android.os.Trace;
 import android.os.UserHandle;
 import android.os.storage.IStorageManager;
+import android.sysprop.VoldProperties;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
 import android.util.Slog;
@@ -625,7 +626,7 @@
         traceEnd();
 
         // Only run "core" apps if we're encrypting the device.
-        String cryptState = SystemProperties.get("vold.decrypt");
+        String cryptState = VoldProperties.decrypt().orElse("");
         if (ENCRYPTING_STATE.equals(cryptState)) {
             Slog.w(TAG, "Detected encryption in progress - only parsing core apps");
             mOnlyCore = true;
diff --git a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
index 3b08505..4239099 100644
--- a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
@@ -34,10 +34,10 @@
 import android.os.Looper;
 import android.os.Message;
 import android.os.SystemClock;
-import android.os.SystemProperties;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.service.usb.UsbDebuggingManagerProto;
+import android.sysprop.VoldProperties;
 import android.util.Base64;
 import android.util.Slog;
 
@@ -263,7 +263,7 @@
 
                 case MESSAGE_ADB_CONFIRM: {
                     if ("trigger_restart_min_framework".equals(
-                            SystemProperties.get("vold.decrypt"))) {
+                            VoldProperties.decrypt().orElse(""))) {
                         Slog.d(TAG, "Deferring adb confirmation until after vold decrypt");
                         if (mThread != null) {
                             mThread.sendResponse("NO");
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index 4da7285..aa93c6b 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -69,6 +69,7 @@
 import android.provider.Settings;
 import android.service.usb.UsbDeviceManagerProto;
 import android.service.usb.UsbHandlerProto;
+import android.sysprop.VoldProperties;
 import android.util.Pair;
 import android.util.Slog;
 
@@ -285,7 +286,7 @@
         mControlFds.put(UsbManager.FUNCTION_PTP, ptpFd);
 
         boolean secureAdbEnabled = SystemProperties.getBoolean("ro.adb.secure", false);
-        boolean dataEncrypted = "1".equals(SystemProperties.get("vold.decrypt"));
+        boolean dataEncrypted = "1".equals(VoldProperties.decrypt().orElse(""));
         if (secureAdbEnabled && !dataEncrypted) {
             mDebuggingManager = new UsbDebuggingManager(context);
         }
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index cef99865..bf0ffb9 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -123,10 +123,21 @@
      * The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call
      * extras. Used to pass the phone accounts to display on the front end to the user in order to
      * select phone accounts to (for example) place a call.
+     * @deprecated Use the list from {@link #EXTRA_SUGGESTED_PHONE_ACCOUNTS} instead.
      */
+    @Deprecated
     public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts";
 
     /**
+     * Key for extra used to pass along a list of {@link PhoneAccountSuggestion}s to the in-call
+     * UI when a call enters the {@link #STATE_SELECT_PHONE_ACCOUNT} state. The list included here
+     * will have the same length and be in the same order as the list passed with
+     * {@link #AVAILABLE_PHONE_ACCOUNTS}.
+     */
+    public static final String EXTRA_SUGGESTED_PHONE_ACCOUNTS =
+            "android.telecom.extra.SUGGESTED_PHONE_ACCOUNTS";
+
+    /**
      * Extra key used to indicate the time (in milliseconds since midnight, January 1, 1970 UTC)
      * when the last outgoing emergency call was made.  This is used to identify potential emergency
      * callbacks.
diff --git a/telecomm/java/android/telecom/PhoneAccountSuggestion.java b/telecomm/java/android/telecom/PhoneAccountSuggestion.java
new file mode 100644
index 0000000..4e6a178
--- /dev/null
+++ b/telecomm/java/android/telecom/PhoneAccountSuggestion.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2018 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.telecom;
+
+import android.annotation.IntDef;
+import android.annotation.SystemApi;
+import android.annotation.TestApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+public final class PhoneAccountSuggestion implements Parcelable {
+
+    /** @hide */
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef(value = {REASON_NONE, REASON_INTRA_CARRIER, REASON_FREQUENT,
+            REASON_USER_SET, REASON_OTHER}, prefix = { "REASON_" })
+    public @interface SuggestionReason {}
+
+    /**
+     * Indicates that this account is not suggested for use, but is still available.
+     */
+    public static final int REASON_NONE = 0;
+
+    /**
+     * Indicates that the {@link PhoneAccountHandle} is suggested because the number we're calling
+     * is on the same carrier, and therefore may have lower rates.
+     */
+    public static final int REASON_INTRA_CARRIER = 1;
+
+    /**
+     * Indicates that the {@link PhoneAccountHandle} is suggested because the user uses it
+     * frequently for the number that we are calling.
+     */
+    public static final int REASON_FREQUENT = 2;
+
+    /**
+     * Indicates that the {@link PhoneAccountHandle} is suggested because the user explicitly
+     * specified that it be used for the number we are calling.
+     */
+    public static final int REASON_USER_SET = 3;
+
+    /**
+     * Indicates that the {@link PhoneAccountHandle} is suggested for a reason not otherwise
+     * enumerated here.
+     */
+    public static final int REASON_OTHER = 4;
+
+    private PhoneAccountHandle mHandle;
+    private int mReason;
+    private boolean mShouldAutoSelect;
+
+    /**
+     * @hide
+     */
+    @SystemApi
+    @TestApi
+    public PhoneAccountSuggestion(PhoneAccountHandle handle, @SuggestionReason int reason,
+            boolean shouldAutoSelect) {
+        this.mHandle = handle;
+        this.mReason = reason;
+        this.mShouldAutoSelect = shouldAutoSelect;
+    }
+
+    private PhoneAccountSuggestion(Parcel in) {
+        mHandle = in.readParcelable(PhoneAccountHandle.class.getClassLoader());
+        mReason = in.readInt();
+        mShouldAutoSelect = in.readByte() != 0;
+    }
+
+    public static final Creator<PhoneAccountSuggestion> CREATOR =
+            new Creator<PhoneAccountSuggestion>() {
+                @Override
+                public PhoneAccountSuggestion createFromParcel(Parcel in) {
+                    return new PhoneAccountSuggestion(in);
+                }
+
+                @Override
+                public PhoneAccountSuggestion[] newArray(int size) {
+                    return new PhoneAccountSuggestion[size];
+                }
+            };
+
+    /**
+     * @return The {@link PhoneAccountHandle} for this suggestion.
+     */
+    public PhoneAccountHandle getPhoneAccountHandle() {
+        return mHandle;
+    }
+
+    /**
+     * @return The reason for this suggestion
+     */
+    public @SuggestionReason int getReason() {
+        return mReason;
+    }
+
+    /**
+     * Suggests whether the dialer should automatically place the call using this account without
+     * user interaction. This may be set on multiple {@link PhoneAccountSuggestion}s, and the dialer
+     * is free to choose which one to use.
+     * @return {@code true} if the hint is to auto-select, {@code false} otherwise.
+     */
+    public boolean shouldAutoSelect() {
+        return mShouldAutoSelect;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeParcelable(mHandle, flags);
+        dest.writeInt(mReason);
+        dest.writeByte((byte) (mShouldAutoSelect ? 1 : 0));
+    }
+}
diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
index 143b323..d64efea 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -305,6 +305,8 @@
      */
     void handleCallIntent(in Intent intent);
 
+    void setTestDefaultCallRedirectionApp(String packageName);
+
     void setTestDefaultCallScreeningApp(String packageName);
 
     void addOrRemoveTestCallCompanionApp(String packageName, boolean isAdded);
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index a0064e2..e72d67b 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -78,6 +78,15 @@
     // system image, that can be added in packages/apps/CarrierConfig.
 
     /**
+     * Specifies a value that identifies the version of the carrier configuration that is
+     * currently in use. This string is displayed on the UI.
+     * The format of the string is not specified.
+     * @hide
+     */
+    public static final String KEY_CARRIER_CONFIG_VERSION_STRING =
+            "carrier_config_version_string";
+
+    /**
      * This flag specifies whether VoLTE availability is based on provisioning. By default this is
      * false.
      */
@@ -2328,6 +2337,7 @@
 
     static {
         sDefaults = new PersistableBundle();
+        sDefaults.putString(KEY_CARRIER_CONFIG_VERSION_STRING, "");
         sDefaults.putBoolean(KEY_ALLOW_HOLD_IN_IMS_CALL_BOOL, true);
         sDefaults.putBoolean(KEY_CARRIER_ALLOW_DEFLECT_IMS_CALL_BOOL, false);
         sDefaults.putBoolean(KEY_ALWAYS_PLAY_REMOTE_HOLD_TONE_BOOL, false);
diff --git a/telephony/java/android/telephony/DataSpecificRegistrationStates.java b/telephony/java/android/telephony/DataSpecificRegistrationStates.java
index b6e6cba..5d809d0 100644
--- a/telephony/java/android/telephony/DataSpecificRegistrationStates.java
+++ b/telephony/java/android/telephony/DataSpecificRegistrationStates.java
@@ -33,17 +33,31 @@
      */
     public final boolean isNrAvailable;
 
+    /**
+     * Indicates that if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving
+     * cell.
+     *
+     * True the primary serving cell is LTE cell and the plmn-InfoList-r15 is present in SIB2 and
+     * at least one bit in this list is true, otherwise this value should be false.
+     *
+     * Reference: 3GPP TS 36.331 v15.2.2 6.3.1 System information blocks.
+     */
+    public final boolean isEnDcAvailable;
+
     DataSpecificRegistrationStates(
-            int maxDataCalls, boolean isDcNrRestricted, boolean isNrAvailable) {
+            int maxDataCalls, boolean isDcNrRestricted, boolean isNrAvailable,
+            boolean isEnDcAvailable) {
         this.maxDataCalls = maxDataCalls;
         this.isDcNrRestricted = isDcNrRestricted;
         this.isNrAvailable = isNrAvailable;
+        this.isEnDcAvailable = isEnDcAvailable;
     }
 
     private DataSpecificRegistrationStates(Parcel source) {
         maxDataCalls = source.readInt();
         isDcNrRestricted = source.readBoolean();
         isNrAvailable = source.readBoolean();
+        isEnDcAvailable = source.readBoolean();
     }
 
     @Override
@@ -51,6 +65,7 @@
         dest.writeInt(maxDataCalls);
         dest.writeBoolean(isDcNrRestricted);
         dest.writeBoolean(isNrAvailable);
+        dest.writeBoolean(isEnDcAvailable);
     }
 
     @Override
@@ -65,13 +80,14 @@
                 .append(" maxDataCalls = " + maxDataCalls)
                 .append(" isDcNrRestricted = " + isDcNrRestricted)
                 .append(" isNrAvailable = " + isNrAvailable)
+                .append(" isEnDcAvailable = " + isEnDcAvailable)
                 .append(" }")
                 .toString();
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(maxDataCalls, isDcNrRestricted, isNrAvailable);
+        return Objects.hash(maxDataCalls, isDcNrRestricted, isNrAvailable, isEnDcAvailable);
     }
 
     @Override
@@ -83,7 +99,8 @@
         DataSpecificRegistrationStates other = (DataSpecificRegistrationStates) o;
         return this.maxDataCalls == other.maxDataCalls
                 && this.isDcNrRestricted == other.isDcNrRestricted
-                && this.isNrAvailable == other.isNrAvailable;
+                && this.isNrAvailable == other.isNrAvailable
+                && this.isEnDcAvailable == other.isEnDcAvailable;
     }
 
     public static final Parcelable.Creator<DataSpecificRegistrationStates> CREATOR =
diff --git a/telephony/java/android/telephony/NetworkRegistrationState.java b/telephony/java/android/telephony/NetworkRegistrationState.java
index aee744f..b00665e 100644
--- a/telephony/java/android/telephony/NetworkRegistrationState.java
+++ b/telephony/java/android/telephony/NetworkRegistrationState.java
@@ -219,12 +219,13 @@
     public NetworkRegistrationState(int domain, int transportType, int regState,
             int accessNetworkTechnology, int rejectCause, boolean emergencyOnly,
             int[] availableServices, @Nullable CellIdentity cellIdentity, int maxDataCalls,
-            boolean isDcNrRestricted, boolean isNrAvailable) {
+            boolean isDcNrRestricted, boolean isNrAvailable, boolean isEndcAvailable) {
         this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly,
                 availableServices, cellIdentity);
 
         mDataSpecificStates = new DataSpecificRegistrationStates(
-                maxDataCalls, isDcNrRestricted, isNrAvailable);
+                maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable);
+        updateNrStatus(mDataSpecificStates);
     }
 
     protected NetworkRegistrationState(Parcel source) {
@@ -448,6 +449,34 @@
         dest.writeInt(mNrStatus);
     }
 
+    /**
+     * Use the 5G NR Non-Standalone indicators from the network registration state to update the
+     * NR status. There are 3 indicators in the network registration state:
+     *
+     * 1. if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving cell.
+     * 2. if NR is supported by the selected PLMN.
+     * 3. if the use of dual connectivity with NR is restricted.
+     *
+     * The network has 5G NR capability if E-UTRA-NR Dual Connectivity is supported by the primary
+     * serving cell.
+     *
+     * The use of NR 5G is not restricted If the network has 5G NR capability and both the use of
+     * DCNR is not restricted and NR is supported by the selected PLMN. Otherwise the use of 5G
+     * NR is restricted.
+     *
+     * @param state data specific registration state contains the 5G NR indicators.
+     */
+    private void updateNrStatus(DataSpecificRegistrationStates state) {
+        mNrStatus = NR_STATUS_NONE;
+        if (state.isEnDcAvailable) {
+            if (!state.isDcNrRestricted && state.isNrAvailable) {
+                mNrStatus = NR_STATUS_NOT_RESTRICTED;
+            } else {
+                mNrStatus = NR_STATUS_RESTRICTED;
+            }
+        }
+    }
+
     public static final Parcelable.Creator<NetworkRegistrationState> CREATOR =
             new Parcelable.Creator<NetworkRegistrationState>() {
         @Override
diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java
index da3acc2..4482074 100644
--- a/telephony/java/android/telephony/RadioAccessFamily.java
+++ b/telephony/java/android/telephony/RadioAccessFamily.java
@@ -460,6 +460,9 @@
         if ((raf & (1 << ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA)) != 0) {
             networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_LTE_CA;
         }
+        if ((raf & (1 << ServiceState.RIL_RADIO_TECHNOLOGY_NR)) != 0) {
+            networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_NR;
+        }
 
         return (networkTypeRaf == 0) ? TelephonyManager.NETWORK_TYPE_UNKNOWN : networkTypeRaf;
     }
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 777d219..13fbeaa 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -223,9 +223,15 @@
     public static final int RIL_RADIO_TECHNOLOGY_LTE_CA = 19;
 
     /**
-     * Number of radio technologies for GSM, UMTS and CDMA.
+     * NR(New Radio) 5G.
+     * @hide
      */
-    private static final int NEXT_RIL_RADIO_TECHNOLOGY = 20;
+    public static final int  RIL_RADIO_TECHNOLOGY_NR = 20;
+
+    /**
+     * The number of the radio technologies.
+     */
+    private static final int NEXT_RIL_RADIO_TECHNOLOGY = 21;
 
     /** @hide */
     public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK =
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index bacfe61a..dacc5d8 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -155,6 +155,14 @@
     private boolean mIsMetered;
 
     /**
+     * Whether group of the subscription is disabled.
+     * This is only useful if it's a grouped opportunistic subscription. In this case, if all
+     * primary (non-opportunistic) subscriptions in the group are deactivated (unplugged pSIM
+     * or deactivated eSIM profile), we should disable this opportunistic subscription.
+     */
+    private boolean mIsGroupDisabled = false;
+
+    /**
      * @hide
      */
     public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
@@ -174,6 +182,18 @@
             Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
             @Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic,
             @Nullable String groupUUID, boolean isMetered) {
+        this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
+                roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardId,
+                isOpportunistic, groupUUID, isMetered, false);
+    }
+    /**
+     * @hide
+     */
+    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
+            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
+            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
+            @Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic,
+            @Nullable String groupUUID, boolean isMetered, boolean isGroupDisabled) {
         this.mId = id;
         this.mIccId = iccId;
         this.mSimSlotIndex = simSlotIndex;
@@ -193,6 +213,7 @@
         this.mIsOpportunistic = isOpportunistic;
         this.mGroupUUID = groupUUID;
         this.mIsMetered = isMetered;
+        this.mIsGroupDisabled = isGroupDisabled;
     }
 
 
@@ -494,6 +515,22 @@
         return this.mCardId;
     }
 
+    /**
+     * Set whether the subscription's group is disabled.
+     * @hide
+     */
+    public void setGroupDisabled(boolean isGroupDisabled) {
+        this.mIsGroupDisabled = isGroupDisabled;
+    }
+
+    /**
+     * Return whether the subscription's group is disabled.
+     * @hide
+     */
+    public boolean isGroupDisabled() {
+        return mIsGroupDisabled;
+    }
+
     public static final Parcelable.Creator<SubscriptionInfo> CREATOR = new Parcelable.Creator<SubscriptionInfo>() {
         @Override
         public SubscriptionInfo createFromParcel(Parcel source) {
@@ -516,10 +553,12 @@
             boolean isOpportunistic = source.readBoolean();
             String groupUUID = source.readString();
             boolean isMetered = source.readBoolean();
+            boolean isGroupDisabled = source.readBoolean();
 
             return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
                     nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
-                    isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered);
+                    isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered,
+                    isGroupDisabled);
         }
 
         @Override
@@ -549,6 +588,7 @@
         dest.writeBoolean(mIsOpportunistic);
         dest.writeString(mGroupUUID);
         dest.writeBoolean(mIsMetered);
+        dest.writeBoolean(mIsGroupDisabled);
     }
 
     @Override
@@ -582,14 +622,15 @@
                 + " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
                 + " accessRules " + Arrays.toString(mAccessRules)
                 + " cardId=" + cardIdToPrint + " isOpportunistic " + mIsOpportunistic
-                + " mGroupUUID=" + mGroupUUID + " isMetered=" + mIsMetered + "}";
+                + " mGroupUUID=" + mGroupUUID + " isMetered=" + mIsMetered
+                + " mIsGroupDisabled=" + mIsGroupDisabled + "}";
     }
 
     @Override
     public int hashCode() {
         return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
                 mIsOpportunistic, mGroupUUID, mIsMetered, mIccId, mNumber, mMcc, mMnc,
-                mCountryIso, mCardId, mDisplayName, mCarrierName, mAccessRules);
+                mCountryIso, mCardId, mDisplayName, mCarrierName, mAccessRules, mIsGroupDisabled);
     }
 
     @Override
@@ -611,6 +652,7 @@
                 && mDataRoaming == toCompare.mDataRoaming
                 && mIsEmbedded == toCompare.mIsEmbedded
                 && mIsOpportunistic == toCompare.mIsOpportunistic
+                && mIsGroupDisabled == toCompare.mIsGroupDisabled
                 && Objects.equals(mGroupUUID, toCompare.mGroupUUID)
                 && mIsMetered == toCompare.mIsMetered
                 && Objects.equals(mIccId, toCompare.mIccId)
@@ -623,4 +665,4 @@
                 && TextUtils.equals(mCarrierName, toCompare.mCarrierName)
                 && Arrays.equals(mAccessRules, toCompare.mAccessRules);
     }
-}
\ No newline at end of file
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 585c0e4..a976fe6 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2218,9 +2218,11 @@
     /** Current network is LTE_CA {@hide} */
     @UnsupportedAppUsage
     public static final int NETWORK_TYPE_LTE_CA = TelephonyProtoEnums.NETWORK_TYPE_LTE_CA; // = 19.
+    /** Current network is NR(New Radio) 5G. */
+    public static final int NETWORK_TYPE_NR = TelephonyProtoEnums.NETWORK_TYPE_NR; // 20.
 
     /** Max network type number. Update as new types are added. Don't add negative types. {@hide} */
-    public static final int MAX_NETWORK_TYPE = NETWORK_TYPE_LTE_CA;
+    public static final int MAX_NETWORK_TYPE = NETWORK_TYPE_NR;
 
     /** @hide */
     @IntDef({
@@ -2244,6 +2246,7 @@
             NETWORK_TYPE_TD_SCDMA,
             NETWORK_TYPE_IWLAN,
             NETWORK_TYPE_LTE_CA,
+            NETWORK_TYPE_NR,
     })
     @Retention(RetentionPolicy.SOURCE)
     public @interface NetworkType{}
@@ -9272,6 +9275,7 @@
                     NETWORK_TYPE_BITMASK_TD_SCDMA,
                     NETWORK_TYPE_BITMASK_LTE,
                     NETWORK_TYPE_BITMASK_LTE_CA,
+                    NETWORK_TYPE_BITMASK_NR,
             })
     public @interface NetworkTypeBitMask {}
 
@@ -9388,6 +9392,13 @@
     public static final int NETWORK_TYPE_BITMASK_LTE_CA = (1 << NETWORK_TYPE_LTE_CA);
 
     /**
+     * network type bitmask indicating the support of radio tech NR(New Radio) 5G.
+     * @hide
+     */
+    @SystemApi
+    public static final int NETWORK_TYPE_BITMASK_NR = (1 << NETWORK_TYPE_NR);
+
+    /**
      * @return Modem supported radio access family bitmask
      *
      * <p>Requires permission: {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} or
diff --git a/telephony/java/android/telephony/ims/ImsReasonInfo.java b/telephony/java/android/telephony/ims/ImsReasonInfo.java
index 8fcdb6e..f124595 100644
--- a/telephony/java/android/telephony/ims/ImsReasonInfo.java
+++ b/telephony/java/android/telephony/ims/ImsReasonInfo.java
@@ -16,11 +16,15 @@
 
 package android.telephony.ims;
 
+import android.annotation.IntDef;
 import android.annotation.SystemApi;
 import android.annotation.UnsupportedAppUsage;
 import android.os.Parcel;
 import android.os.Parcelable;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
 /**
  * This class enables an application to get details on why a method call failed.
  *
@@ -30,158 +34,292 @@
 public final class ImsReasonInfo implements Parcelable {
 
     /**
-     * Specific code of each types
+     * The Reason is unspecified.
      */
     public static final int CODE_UNSPECIFIED = 0;
 
-    /**
-     * LOCAL
-     */
+
+    // LOCAL
+
     // IMS -> Telephony
-    // The passed argument is an invalid
+    /**
+     * The passed argument is invalid.
+     */
     public static final int CODE_LOCAL_ILLEGAL_ARGUMENT = 101;
-    // The operation is invoked in invalid call state
+    /**
+     * The operation was invoked while in an invalid call state.
+     */
     public static final int CODE_LOCAL_ILLEGAL_STATE = 102;
-    // IMS service internal error
+    /**
+     * IMS service internal error
+     */
     public static final int CODE_LOCAL_INTERNAL_ERROR = 103;
-    // IMS service goes down (service connection is lost)
+    /**
+     * ImsService has crashed (service connection is lost).
+     */
     public static final int CODE_LOCAL_IMS_SERVICE_DOWN = 106;
-    // No pending incoming call exists
+    /**
+     * No pending incoming call exists
+     */
     public static final int CODE_LOCAL_NO_PENDING_CALL = 107;
-    // IMS Call ended during conference merge process
+    /**
+     * IMS Call ended during conference merge process
+     */
     public static final int CODE_LOCAL_ENDED_BY_CONFERENCE_MERGE = 108;
 
     // IMS -> Telephony
-    // Service unavailable; by power off
+    /**
+     * Service unavailable; radio power off
+     */
     public static final int CODE_LOCAL_POWER_OFF = 111;
-    // Service unavailable; by low battery
+    /**
+     * Service unavailable; low battery
+     */
     public static final int CODE_LOCAL_LOW_BATTERY = 112;
-    // Service unavailable; by out of service (data service state)
+    /**
+     * Service unavailable; out of service (data service state)
+     */
     public static final int CODE_LOCAL_NETWORK_NO_SERVICE = 121;
-    // Service unavailable; by no LTE coverage
-    // (VoLTE is not supported even though IMS is registered)
+    /**
+     * Service unavailable; no LTE coverage
+     * (VoLTE is not supported even though IMS is registered)
+     */
     public static final int CODE_LOCAL_NETWORK_NO_LTE_COVERAGE = 122;
-    // Service unavailable; by located in roaming area
+    /**
+     * Service unavailable; located in roaming area
+     */
     public static final int CODE_LOCAL_NETWORK_ROAMING = 123;
-    // Service unavailable; by IP changed
+    /**
+     * Service unavailable; IP changed
+     */
     public static final int CODE_LOCAL_NETWORK_IP_CHANGED = 124;
-    // Service unavailable; other
+    /**
+     * Service unavailable; for an unspecified reason
+     */
     public static final int CODE_LOCAL_SERVICE_UNAVAILABLE = 131;
-    // Service unavailable; IMS connection is lost (IMS is not registered)
+    /**
+     * Service unavailable; IMS is not registered
+     */
     public static final int CODE_LOCAL_NOT_REGISTERED = 132;
 
     // IMS <-> Telephony
-    // Max call exceeded
+    /**
+     * Maximum number of simultaneous calls exceeded
+     */
     public static final int CODE_LOCAL_CALL_EXCEEDED = 141;
     // IMS <- Telephony
-    // Call busy
+    /**
+     * The call is busy.
+     */
     public static final int CODE_LOCAL_CALL_BUSY = 142;
-    // Call decline
+    /**
+     * The Call has been declined locally on this device.
+     */
     public static final int CODE_LOCAL_CALL_DECLINE = 143;
     // IMS -> Telephony
-    // SRVCC is in progress
+    /**
+     * Can not complete call; an SRVCC is in progress.
+     */
     public static final int CODE_LOCAL_CALL_VCC_ON_PROGRESSING = 144;
-    // Resource reservation is failed (QoS precondition)
+    /**
+     * Can not complete call; resource reservation is failed (QoS precondition)
+     */
     public static final int CODE_LOCAL_CALL_RESOURCE_RESERVATION_FAILED = 145;
-    // Retry CS call; VoLTE service can't be provided by the network or remote end
-    // Resolve the extra code(EXTRA_CODE_CALL_RETRY_*) if the below code is set
+    /**
+     * VoLTE service can't be provided by the network or remote end, retry the call.
+     * Resolve the extra code provided in (EXTRA_CODE_CALL_RETRY_*) if the below code is set
+     */
     public static final int CODE_LOCAL_CALL_CS_RETRY_REQUIRED = 146;
-    // Retry VoLTE call; VoLTE service can't be provided by the network temporarily
+    /**
+     * VoLTE service can't be provided by the network temporarily, retry the call.
+     */
     public static final int CODE_LOCAL_CALL_VOLTE_RETRY_REQUIRED = 147;
-    // IMS call is already terminated (in TERMINATED state)
+    /**
+     * IMS call is already terminated (in TERMINATED state).
+     */
     public static final int CODE_LOCAL_CALL_TERMINATED = 148;
-    // Handover not feasible
+    /**
+     * Call was disconnected because a handover is not feasible due to network conditions.
+     */
     public static final int CODE_LOCAL_HO_NOT_FEASIBLE = 149;
 
-    /**
+    /*
      * TIMEOUT (IMS -> Telephony)
      */
-    // 1xx waiting timer is expired after sending INVITE request (MO only)
+    /**
+     * 1xx waiting timer is expired after sending INVITE request (MO calls only)
+     */
     public static final int CODE_TIMEOUT_1XX_WAITING = 201;
-    // User no answer during call setup operation (MO/MT)
-    // MO : 200 OK to INVITE request is not received,
-    // MT : No action from user after alerting the call
+    /**
+     * User didn't answer during call setup operation (MO/MT)
+     * MO : 200 OK to INVITE request is not received,
+     * MT : No action from user after alerting the call
+     */
     public static final int CODE_TIMEOUT_NO_ANSWER = 202;
-    // User no answer during call update operation (MO/MT)
-    // MO : 200 OK to re-INVITE request is not received,
-    // MT : No action from user after alerting the call
+    /**
+     * User no answer during call update operation (MO/MT)
+     * MO : 200 OK to re-INVITE request is not received,
+     * MT : No action from user after alerting the call
+     */
     public static final int CODE_TIMEOUT_NO_ANSWER_CALL_UPDATE = 203;
 
-    //Call was blocked by call barring
+    /**
+     * The call was blocked by call barring configuration.
+     */
     public static final int CODE_CALL_BARRED = 240;
 
-    //Call failures for FDN
+    /**
+     * The operation is restricted to fixed dialing numbers only.
+     */
     public static final int CODE_FDN_BLOCKED = 241;
 
-    // Network does not accept the emergency call request because IMEI was used as identification
-    // and this capability is not supported by the network.
+    /**
+     * Network rejected the emergency call request because IMEI was used as identification
+     * and this capability is not supported by the network.
+     */
     public static final int CODE_IMEI_NOT_ACCEPTED = 243;
 
     //STK CC errors
+    /**
+     * Stk Call Control modified DIAL request to USSD request.
+     */
     public static final int CODE_DIAL_MODIFIED_TO_USSD = 244;
+    /**
+     * Stk Call Control modified DIAL request to SS request.
+     */
     public static final int CODE_DIAL_MODIFIED_TO_SS = 245;
+    /**
+     * Stk Call Control modified DIAL request to DIAL with modified data.
+     */
     public static final int CODE_DIAL_MODIFIED_TO_DIAL = 246;
+    /**
+     * Stk Call Control modified DIAL request to Video DIAL request.
+     */
     public static final int CODE_DIAL_MODIFIED_TO_DIAL_VIDEO = 247;
+    /**
+     * Stk Call Control modified Video DIAL request to DIAL request.
+     */
     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_DIAL = 248;
+    /**
+     * Stk Call Control modified Video DIAL request to Video DIAL request.
+     */
     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO = 249;
+    /**
+     * Stk Call Control modified Video DIAL request to SS request.
+     */
     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_SS = 250;
+    /**
+     * Stk Call Control modified Video DIAL request to USSD request.
+     */
     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_USSD = 251;
 
-    /**
+    /*
      * STATUSCODE (SIP response code) (IMS -> Telephony)
      */
     // 3xx responses
-    // SIP request is redirected
+    /**
+     * SIP 3xx response: SIP request is redirected
+     */
     public static final int CODE_SIP_REDIRECTED = 321;
     // 4xx responses
-    // 400 : Bad Request
+    /**
+     * Sip 400 response : Bad Request
+     */
     public static final int CODE_SIP_BAD_REQUEST = 331;
-    // 403 : Forbidden
+    /**
+     * Sip 403 response : Forbidden
+     */
     public static final int CODE_SIP_FORBIDDEN = 332;
-    // 404 : Not Found
+    /**
+     * Sip 404 response : Not Found
+     */
     public static final int CODE_SIP_NOT_FOUND = 333;
-    // 415 : Unsupported Media Type
-    // 416 : Unsupported URI Scheme
-    // 420 : Bad Extension
+    /**
+     * Not supported, because of one of the following:
+     * SIP response 415 : Unsupported Media Type,
+     * SIP response 416 : Unsupported URI Scheme,
+     * SIP response 420 : Bad Extension
+     */
     public static final int CODE_SIP_NOT_SUPPORTED = 334;
-    // 408 : Request Timeout
+    /**
+     * SIP response 408 : Request Timeout.
+     */
     public static final int CODE_SIP_REQUEST_TIMEOUT = 335;
-    // 480 : Temporarily Unavailable
+    /**
+     * SIP response 480 : Temporarily Unavailable
+     */
     public static final int CODE_SIP_TEMPRARILY_UNAVAILABLE = 336;
-    // 484 : Address Incomplete
+    /**
+     * SIP response 484 : Address Incomplete
+     */
     public static final int CODE_SIP_BAD_ADDRESS = 337;
-    // 486 : Busy Here
-    // 600 : Busy Everywhere
+    /**
+     * Returned a busy response, may be one of the following:
+     * SIP response 486 : Busy Here,
+     * SIP response 600 : Busy Everywhere
+     */
     public static final int CODE_SIP_BUSY = 338;
-    // 487 : Request Terminated
+    /**
+     * SIP response 487 : Request Terminated
+     */
     public static final int CODE_SIP_REQUEST_CANCELLED = 339;
-    // 406 : Not Acceptable
-    // 488 : Not Acceptable Here
-    // 606 : Not Acceptable
+    /**
+     * Received a not acceptable response, will be one of the following:
+     * SIP response 406 : Not Acceptable
+     * SIP response 488 : Not Acceptable Here
+     * SIP response 606 : Not Acceptable
+     */
     public static final int CODE_SIP_NOT_ACCEPTABLE = 340;
-    // 410 : Gone
-    // 604 : Does Not Exist Anywhere
+    /**
+     * Received a not acceptable response, will be one of the following:
+     * SIP response 410 : Gone
+     * SIP response 604 : Does Not Exist Anywhere
+     */
     public static final int CODE_SIP_NOT_REACHABLE = 341;
-    // Others
+    /**
+     * Received another unspecified error SIP response from the client.
+     */
     public static final int CODE_SIP_CLIENT_ERROR = 342;
-    // 481 Transaction Does Not Exist
+    /**
+     * SIP response 481: Transaction Does Not Exist
+     */
     public static final int CODE_SIP_TRANSACTION_DOES_NOT_EXIST = 343;
     // 5xx responses
-    // 501 : Server Internal Error
+    /**
+     * SIP response 501 : Server Internal Error
+     */
     public static final int CODE_SIP_SERVER_INTERNAL_ERROR = 351;
-    // 503 : Service Unavailable
+    /**
+     * SIP response 503 : Service Unavailable
+     */
     public static final int CODE_SIP_SERVICE_UNAVAILABLE = 352;
-    // 504 : Server Time-out
+    /**
+     * SIP response 504 : Server Time-out
+     */
     public static final int CODE_SIP_SERVER_TIMEOUT = 353;
-    // Others
+    /**
+     * Received an unspecified SIP server error response.
+     */
     public static final int CODE_SIP_SERVER_ERROR = 354;
     // 6xx responses
-    // 603 : Decline
+    /**
+     * 603 : Decline
+     */
     public static final int CODE_SIP_USER_REJECTED = 361;
-    // Others
+    /**
+     * Unspecified 6xx error.
+     */
     public static final int CODE_SIP_GLOBAL_ERROR = 362;
-    // Emergency failure
+
+    /**
+     * Emergency call failed in the modem with a temporary fail cause and should be redialed on this
+     * slot.
+     */
     public static final int CODE_EMERGENCY_TEMP_FAILURE = 363;
+    /**
+     * Emergency call failed in the modem with a permanent fail cause and should not be redialed on
+     * this slot. If there are any other slots available for emergency calling, try those.
+     */
     public static final int CODE_EMERGENCY_PERM_FAILURE = 364;
 
     /**
@@ -193,82 +331,149 @@
      */
     public static final int CODE_SIP_USER_MARKED_UNWANTED = 365;
 
-    /**
+    /*
      * MEDIA (IMS -> Telephony)
      */
-    // Media resource initialization failed
+    /**
+     * Media resource initialization failed
+     */
     public static final int CODE_MEDIA_INIT_FAILED = 401;
-    // RTP timeout (no audio / video traffic in the session)
+    /**
+     * RTP timeout (no audio / video traffic in the session)
+     */
     public static final int CODE_MEDIA_NO_DATA = 402;
-    // Media is not supported; so dropped the call
+    /**
+     * Media is not supported; so dropped the call
+     */
     public static final int CODE_MEDIA_NOT_ACCEPTABLE = 403;
-    // Unknown media related errors
+    /**
+     * Unspecified media related error.
+     */
     public static final int CODE_MEDIA_UNSPECIFIED = 404;
 
-    /**
+    /*
      * USER
      */
     // Telephony -> IMS
-    // User triggers the call end
+    /**
+     * User triggers the call to be terminated.
+     */
     public static final int CODE_USER_TERMINATED = 501;
-    // No action while an incoming call is ringing
+    /**
+     * No action was taken while an incoming call was ringing.
+     */
     public static final int CODE_USER_NOANSWER = 502;
-    // User ignores an incoming call
+    /**
+     * User ignored an incoming call.
+     */
     public static final int CODE_USER_IGNORE = 503;
-    // User declines an incoming call
+    /**
+     * User declined an incoming call.
+     */
     public static final int CODE_USER_DECLINE = 504;
-    // Device declines/ends a call due to low battery
+    /**
+     * Device declined/ended a call due to a low battery condition.
+     */
     public static final int CODE_LOW_BATTERY = 505;
-    // Device declines call due to blacklisted call ID
+    /**
+     * Device declined a call due to a blacklisted caller ID.
+     */
     public static final int CODE_BLACKLISTED_CALL_ID = 506;
     // IMS -> Telephony
-    // The call is terminated by the network or remote user
+    /**
+     * The call has been terminated by the network or remote user.
+     */
     public static final int CODE_USER_TERMINATED_BY_REMOTE = 510;
 
-    /**
-     * Extra codes for the specific code value
-     * This value can be referred when the code is CODE_LOCAL_CALL_CS_RETRY_REQUIRED.
-     */
-    // Try to connect CS call; normal
-    public static final int EXTRA_CODE_CALL_RETRY_NORMAL = 1;
-    // Try to connect CS call without the notification to user
-    public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2;
-    // Try to connect CS call by the settings of the menu
-    public static final int EXTRA_CODE_CALL_RETRY_BY_SETTINGS = 3;
-
-    /**
+    /*
      * UT
      */
+    /**
+     * UT is currently not supported on this device.
+     */
     public static final int CODE_UT_NOT_SUPPORTED = 801;
+    /**
+     * UT services are currently not available on this device.
+     */
     public static final int CODE_UT_SERVICE_UNAVAILABLE = 802;
+    /**
+     * The requested UT operation is not allowed.
+     */
     public static final int CODE_UT_OPERATION_NOT_ALLOWED = 803;
+    /**
+     * The UT request resulted in a network error.
+     */
     public static final int CODE_UT_NETWORK_ERROR = 804;
+    /**
+     * The password entered for UT operations does not match the stored password.
+     */
     public static final int CODE_UT_CB_PASSWORD_MISMATCH = 821;
     //STK CC errors
+    /**
+     * Sim Toolkit Call Control modified the UT operation to a dial command.
+     */
     public static final int CODE_UT_SS_MODIFIED_TO_DIAL = 822;
+    /**
+     * Sim Toolkit Call Control modified the UT operation to a USSD command.
+     */
     public static final int CODE_UT_SS_MODIFIED_TO_USSD = 823;
+    /**
+     * Sim Toolkit Call Control modified the UT operation to another supplementary service command.
+     */
     public static final int CODE_UT_SS_MODIFIED_TO_SS = 824;
+    /**
+     * Sim Toolkit Call Control modified the UT operation to a video call dial command.
+     */
     public static final int CODE_UT_SS_MODIFIED_TO_DIAL_VIDEO = 825;
 
+    /**@hide*/
+    @IntDef(value = {
+            CODE_UT_NOT_SUPPORTED,
+            CODE_UT_SERVICE_UNAVAILABLE,
+            CODE_UT_OPERATION_NOT_ALLOWED,
+            CODE_UT_NETWORK_ERROR,
+            CODE_UT_CB_PASSWORD_MISMATCH,
+            CODE_UT_SS_MODIFIED_TO_DIAL,
+            CODE_UT_SS_MODIFIED_TO_USSD,
+            CODE_UT_SS_MODIFIED_TO_SS,
+            CODE_UT_SS_MODIFIED_TO_DIAL_VIDEO
+    }, prefix = "CODE_UT_")
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface UtReason {}
+
     /**
-     * ECBM
+     * Emergency callback mode is not supported.
      */
     public static final int CODE_ECBM_NOT_SUPPORTED = 901;
 
     /**
-     * Fail code used to indicate that Multi-endpoint is not supported by the Ims framework.
+     * Fail code used to indicate that Multi-endpoint is not supported by the IMS framework.
      */
     public static final int CODE_MULTIENDPOINT_NOT_SUPPORTED = 902;
 
     /**
-     * Ims Registration error code
+     * IMS Registration error code
      */
     public static final int CODE_REGISTRATION_ERROR = 1000;
 
-    /**
+    /*
      * CALL DROP error codes (Call could drop because of many reasons like Network not available,
      *  handover, failed, etc)
      */
+    /**
+     * MT call has ended due to a release from the network because the call was answered elsewhere.
+     */
+    public static final int CODE_ANSWERED_ELSEWHERE = 1014;
+
+    /**
+     * For MultiEndpoint - Call Pull request has failed.
+     */
+    public static final int CODE_CALL_PULL_OUT_OF_SYNC = 1015;
+
+    /**
+     * For MultiEndpoint - Call has been pulled from primary to secondary.
+     */
+    public static final int CODE_CALL_END_CAUSE_CALL_PULL = 1016;
 
     /**
      * CALL DROP error code for the case when a device is ePDG capable and when the user is on an
@@ -279,46 +484,35 @@
     public static final int CODE_CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE = 1100;
 
     /**
-     * MT call has ended due to a release from the network
-     * because the call was answered elsewhere
-     */
-    public static final int CODE_ANSWERED_ELSEWHERE = 1014;
-
-    /**
-     * For MultiEndpoint - Call Pull request has failed
-     */
-    public static final int CODE_CALL_PULL_OUT_OF_SYNC = 1015;
-
-    /**
-     * For MultiEndpoint - Call has been pulled from primary to secondary
-     */
-    public static final int CODE_CALL_END_CAUSE_CALL_PULL = 1016;
-
-    /**
-     * Supplementary services (HOLD/RESUME) failure error codes.
-     * Values for Supplemetary services failure - Failed, Cancelled and Re-Invite collision.
+     * Supplementary Services (HOLD/RESUME) - the command failed.
      */
     public static final int CODE_SUPP_SVC_FAILED = 1201;
+    /**
+     * Supplementary Services (HOLD/RESUME) - the command was cancelled.
+     */
     public static final int CODE_SUPP_SVC_CANCELLED = 1202;
+    /**
+     * Supplementary Services (HOLD/RESUME) - the command resulted in a re-invite collision.
+     */
     public static final int CODE_SUPP_SVC_REINVITE_COLLISION = 1203;
 
     /**
-     * DPD Procedure received no response or send failed
+     * DPD Procedure received no response or send failed.
      */
     public static final int CODE_IWLAN_DPD_FAILURE = 1300;
 
     /**
-     * Establishment of the ePDG Tunnel Failed
+     * Establishment of the ePDG Tunnel Failed.
      */
     public static final int CODE_EPDG_TUNNEL_ESTABLISH_FAILURE = 1400;
 
     /**
-     * Re-keying of the ePDG Tunnel Failed; may not always result in teardown
+     * Re-keying of the ePDG Tunnel Failed; may not always result in teardown.
      */
     public static final int CODE_EPDG_TUNNEL_REKEY_FAILURE = 1401;
 
     /**
-     * Connection to the packet gateway is lost
+     * Connection to the packet gateway is lost.
      */
     public static final int CODE_EPDG_TUNNEL_LOST_CONNECTION = 1402;
 
@@ -571,8 +765,10 @@
      */
     public static final int CODE_REJECT_ONGOING_CS_CALL = 1621;
 
-    /* OEM specific error codes. To be used by OEMs when they don't want to
-   reveal error code which would be replaced by ERROR_UNSPECIFIED */
+    /*
+     * OEM specific error codes. To be used by OEMs when they don't want to reveal error code which
+     * would be replaced by ERROR_UNSPECIFIED.
+     */
     public static final int CODE_OEM_CAUSE_1 = 0xf001;
     public static final int CODE_OEM_CAUSE_2 = 0xf002;
     public static final int CODE_OEM_CAUSE_3 = 0xf003;
@@ -597,6 +793,33 @@
             = "Forbidden. Not Authorized for Service";
 
 
+    /*
+     * Extra codes for the specific code value
+     * This value can be referred when the code is CODE_LOCAL_CALL_CS_RETRY_REQUIRED.
+     */
+    /**
+     * An extra that may be populated when the {@link CODE_LOCAL_CALL_CS_RETRY_REQUIRED} result has
+     * been returned.
+     * <p>
+     * Try to connect the call using CS
+     */
+    public static final int EXTRA_CODE_CALL_RETRY_NORMAL = 1;
+    /**
+     * An extra that may be populated when the {@link CODE_LOCAL_CALL_CS_RETRY_REQUIRED} result has
+     * been returned.
+     * <p>
+     * Try to connect the call using CS and do not notify the user.
+     */
+    public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2;
+    /**
+     * An extra that may be populated when the {@link CODE_LOCAL_CALL_CS_RETRY_REQUIRED} result has
+     * been returned.
+     * <p>
+     * Try to connect the call using CS by using the settings.
+     */
+    public static final int EXTRA_CODE_CALL_RETRY_BY_SETTINGS = 3;
+
+
     // For main reason code
     /** @hide */
     @UnsupportedAppUsage
@@ -638,29 +861,28 @@
     }
 
     /**
-     *
+     * @return an integer representing more information about the completion of an operation.
      */
     public int getCode() {
         return mCode;
     }
 
     /**
-     *
+     * @return an optional OEM specified code that provides extra information.
      */
     public int getExtraCode() {
         return mExtraCode;
     }
 
     /**
-     *
+     * @return an optional OEM specified string that provides extra information about the operation
+     * result.
      */
     public String getExtraMessage() {
         return mExtraMessage;
     }
 
     /**
-     * Returns the string format of {@link ImsReasonInfo}
-     *
      * @return the string format of {@link ImsReasonInfo}
      */
     public String toString() {
diff --git a/telephony/java/android/telephony/ims/ImsSsData.java b/telephony/java/android/telephony/ims/ImsSsData.java
index db5ba47..3a82517 100644
--- a/telephony/java/android/telephony/ims/ImsSsData.java
+++ b/telephony/java/android/telephony/ims/ImsSsData.java
@@ -65,6 +65,17 @@
     public static final int SS_INCOMING_BARRING_DN = 21;
     public static final int SS_INCOMING_BARRING_ANONYMOUS = 22;
 
+
+    /**@hide*/
+    @IntDef(flag = true, prefix = {"SS_"}, value = {
+            SS_ACTIVATION,
+            SS_DEACTIVATION,
+            SS_INTERROGATION,
+            SS_REGISTRATION,
+            SS_ERASURE})
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface RequestType{}
+
     //Supplementary Service Request Types
     public static final int SS_ACTIVATION = 0;
     public static final int SS_DEACTIVATION = 1;
@@ -72,6 +83,17 @@
     public static final int SS_REGISTRATION = 3;
     public static final int SS_ERASURE = 4;
 
+    /**@hide*/
+    @IntDef(flag = true, prefix = {"SS_"}, value = {
+            SS_ALL_TELE_AND_BEARER_SERVICES,
+            SS_ALL_TELESEVICES,
+            SS_TELEPHONY,
+            SS_ALL_DATA_TELESERVICES,
+            SS_SMS_SERVICES,
+            SS_ALL_TELESERVICES_EXCEPT_SMS})
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface TeleserviceType{}
+
     // Supplementary Service Teleservice Type
     public static final int SS_ALL_TELE_AND_BEARER_SERVICES = 0;
     public static final int SS_ALL_TELESEVICES = 1;
@@ -191,21 +213,6 @@
     @Retention(RetentionPolicy.SOURCE)
     public @interface ServiceType{}
 
-    /** @hide */
-    @IntDef(flag = true, prefix = { "SERVICE_CLASS" }, value = {
-            SERVICE_CLASS_NONE,
-            SERVICE_CLASS_VOICE,
-            SERVICE_CLASS_DATA,
-            SERVICE_CLASS_FAX,
-            SERVICE_CLASS_SMS,
-            SERVICE_CLASS_DATA_CIRCUIT_SYNC,
-            SERVICE_CLASS_DATA_CIRCUIT_ASYNC,
-            SERVICE_CLASS_DATA_PACKET_ACCESS,
-            SERVICE_CLASS_DATA_PAD
-    })
-    @Retention(RetentionPolicy.SOURCE)
-    public @interface ServiceClass{}
-
     /**
      * The Service type of this Supplementary service.
      * @hide
@@ -221,7 +228,7 @@
      *     {@link #SS_ERASURE}
      * @hide
      */
-    public final int requestType;
+    public final @RequestType int requestType;
 
     /**
      * Supplementary Service teleservice type:
@@ -234,14 +241,14 @@
      *
      * @hide
      */
-    public final int teleserviceType;
+    public final @TeleserviceType int teleserviceType;
 
     /**
      * Supplementary Service service class.
      *
      * @hide
      */
-    public final @ServiceClass int serviceClass;
+    public final @ServiceClassFlags int serviceClass;
 
     /**
      * Result of Supplementary Service operation. Valid values are:
@@ -285,7 +292,7 @@
          * @see #build()
          */
         public Builder(@ServiceType int serviceType, int requestType, int teleserviceType,
-                @ServiceClass int serviceClass, int result) {
+                @ServiceClassFlags int serviceClass, int result) {
             mImsSsData = new ImsSsData(serviceType, requestType, teleserviceType, serviceClass,
                     result);
         }
@@ -294,7 +301,7 @@
          * Set the array of {@link ImsSsInfo}s that are associated with this supplementary service
          * data.
          */
-        public Builder setSuppServiceInfo(@NonNull ImsSsInfo[] imsSsInfos) {
+        public @NonNull Builder setSuppServiceInfo(@NonNull ImsSsInfo[] imsSsInfos) {
             mImsSsData.mImsSsInfo = imsSsInfos;
             return this;
         }
@@ -303,7 +310,8 @@
          * Set the array of {@link ImsCallForwardInfo}s that are associated with this supplementary
          * service data.
          */
-        public Builder setCallForwardingInfo(@NonNull ImsCallForwardInfo[] imsCallForwardInfos) {
+        public @NonNull Builder setCallForwardingInfo(
+                @NonNull ImsCallForwardInfo[] imsCallForwardInfos) {
             mImsSsData.mCfInfo = imsCallForwardInfos;
             return this;
         }
@@ -311,7 +319,7 @@
         /**
          * @return an {@link ImsSsData} containing optional parameters.
          */
-        public ImsSsData build() {
+        public @NonNull ImsSsData build() {
             return mImsSsData;
         }
     }
@@ -337,7 +345,7 @@
      *               success, or ImsReasonInfo code if the result is a failure.
      */
     public ImsSsData(@ServiceType int serviceType, int requestType, int teleserviceType,
-            @ServiceClass int serviceClass, int result) {
+            @ServiceClassFlags int serviceClass, int result) {
         this.serviceType = serviceType;
         this.requestType = requestType;
         this.teleserviceType = teleserviceType;
@@ -449,14 +457,9 @@
     }
 
     /**
-     * Supplementary Service request Type:
-     *     {@link #SS_ACTIVATION),
-     *     {@link #SS_DEACTIVATION},
-     *     {@link #SS_INTERROGATION},
-     *     {@link #SS_REGISTRATION},
-     *     {@link #SS_ERASURE}
+     * Supplementary Service request Type.
      */
-    public int getRequestType() {
+    public @RequestType int getRequestType() {
         return requestType;
     }
 
@@ -468,31 +471,25 @@
     }
 
     /**
-     * Supplementary Service teleservice type:
-     *     {@link #SS_ALL_TELE_AND_BEARER_SERVICES},
-     *     {@link #SS_ALL_TELESEVICES},
-     *     {@link #SS_TELEPHONY},
-     *     {@link #SS_ALL_DATA_TELESERVICES},
-     *     {@link #SS_SMS_SERVICES},
-     *     {@link #SS_ALL_TELESERVICES_EXCEPT_SMS}
+     * Supplementary Service teleservice type.
      */
-    public int getTeleserviceType() {
+    public @TeleserviceType int getTeleserviceType() {
         return teleserviceType;
     }
 
     /**
      * Supplementary Service service class.
      */
-    public @ServiceClass int getServiceClass() {
+    public @ServiceClassFlags int getServiceClass() {
         return serviceClass;
     }
 
     /**
      * Result of Supplementary Service operation. Valid values are:
      *     {@link #RESULT_SUCCESS} if the result is success, or
-     *     {@link ImsReasonInfo} CODE_* code if the result is a failure.
+     *     {@link ImsReasonInfo.UtReason} code if the result is a failure.
      */
-    public int getResult() {
+    public @ImsReasonInfo.UtReason int getResult() {
         return result;
     }
 
diff --git a/telephony/java/android/telephony/ims/ImsSsInfo.java b/telephony/java/android/telephony/ims/ImsSsInfo.java
index 0af6e62..031f9e1 100644
--- a/telephony/java/android/telephony/ims/ImsSsInfo.java
+++ b/telephony/java/android/telephony/ims/ImsSsInfo.java
@@ -82,6 +82,7 @@
      */
     public static final int SERVICE_PROVISIONED = 1;
 
+    /**@hide*/
     @IntDef(value = {
             CLIR_OUTGOING_DEFAULT,
             CLIR_OUTGOING_INVOCATION,
@@ -141,6 +142,7 @@
      */
     public static final int CLIR_STATUS_TEMPORARILY_ALLOWED = 4;
 
+    /**@hide*/
     @IntDef(value = {
             CLIR_STATUS_NOT_PROVISIONED,
             CLIR_STATUS_PROVISIONED_PERMANENT,
@@ -184,7 +186,7 @@
          * Set the ICB number for IMS call barring.
          * @param number The number in E.164 international format.
          */
-        public Builder setIncomingCommunicationBarringNumber(@NonNull String number) {
+        public @NonNull Builder setIncomingCommunicationBarringNumber(@NonNull String number) {
             mImsSsInfo.mIcbNum = number;
             return this;
         }
@@ -192,7 +194,7 @@
         /**
          * Set the provisioning status for a Supplementary Service interrogation response.
          */
-        public Builder setProvisionStatus(@ServiceProvisionStatus int provisionStatus) {
+        public @NonNull Builder setProvisionStatus(@ServiceProvisionStatus int provisionStatus) {
             mImsSsInfo.mProvisionStatus = provisionStatus;
             return this;
         }
@@ -201,7 +203,7 @@
          * Set the Calling Line Identification Restriction (CLIR) status for a supplementary service
          * interrogation response.
          */
-        public Builder setClirInterrogationStatus(@ClirInterrogationStatus int status) {
+        public @NonNull Builder setClirInterrogationStatus(@ClirInterrogationStatus int status) {
             mImsSsInfo.mClirInterrogationStatus = status;
             return this;
         }
@@ -209,7 +211,7 @@
         /**
          * Set the Calling line identification Restriction (CLIR) state for outgoing calls.
          */
-        public Builder setClirOutgoingState(@ClirOutgoingState int state) {
+        public @NonNull Builder setClirOutgoingState(@ClirOutgoingState int state) {
             mImsSsInfo.mClirOutgoingState = state;
             return this;
         }
@@ -217,7 +219,7 @@
         /**
          * @return a built {@link ImsSsInfo} containing optional the parameters that were set.
          */
-        public ImsSsInfo build() {
+        public @NonNull ImsSsInfo build() {
             return mImsSsInfo;
         }
     }
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java
index 0abe45c..13539b8 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfo.java
@@ -17,6 +17,7 @@
 package com.android.internal.telephony;
 
 import android.annotation.UnsupportedAppUsage;
+import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.database.Cursor;
@@ -32,15 +33,15 @@
 import android.provider.ContactsContract.RawContacts;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.Rlog;
+import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Log;
 
-import com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder;
 import com.android.i18n.phonenumbers.NumberParseException;
 import com.android.i18n.phonenumbers.PhoneNumberUtil;
 import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
-import android.telephony.SubscriptionManager;
+import com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder;
 
 import java.util.Locale;
 
@@ -112,6 +113,9 @@
     public Uri contactRefUri;
     public String lookupKey;
 
+    public ComponentName preferredPhoneAccountComponent;
+    public String preferredPhoneAccountId;
+
     public long userType;
 
     /**
@@ -264,6 +268,17 @@
                     info.contactDisplayPhotoUri = null;
                 }
 
+                columnIndex = cursor.getColumnIndex(Data.PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME);
+                if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
+                    info.preferredPhoneAccountComponent =
+                            ComponentName.unflattenFromString(cursor.getString(columnIndex));
+                }
+
+                columnIndex = cursor.getColumnIndex(Data.PREFERRED_PHONE_ACCOUNT_ID);
+                if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
+                    info.preferredPhoneAccountId = cursor.getString(columnIndex);
+                }
+
                 // look for the custom ringtone, create from the string stored
                 // in the database.
                 // An empty string ("") in the database indicates a silent ringtone,
diff --git a/tools/hiddenapi/exclude.sh b/tools/hiddenapi/exclude.sh
index 2291e5a..4ffcf68 100755
--- a/tools/hiddenapi/exclude.sh
+++ b/tools/hiddenapi/exclude.sh
@@ -11,6 +11,7 @@
   android.system \
   com.android.bouncycastle \
   com.android.conscrypt \
+  com.android.i18n.phonenumbers \
   com.android.okhttp \
   com.sun \
   dalvik \