Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)

Bug: 166295507
Merged-In: I2d8f6032d2eb1b5cc8450c917c8aa1c9cd72ac0f
Change-Id: Id8b137d2a24f79c5dfcd8a5ebbdd232bcc134caa
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 31b4999..cf20002 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -213,7 +213,7 @@
     <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
     <uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
     <uses-permission android:name="android.permission.MANAGE_ROLE_HOLDERS" />
-    <!-- Allows us to whitelist receivers of the
+    <!-- Allows us to allow list receivers of the
          ACTION_SIM_SLOT_STATUS_CHANGED broadcast to start activities
          from the background.  -->
     <uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />
diff --git a/ecc/input/OWNERS b/ecc/input/OWNERS
new file mode 100644
index 0000000..d9ecbb7
--- /dev/null
+++ b/ecc/input/OWNERS
@@ -0,0 +1,5 @@
+set noparent
+
+djkrause@google.com
+satk@google.com
+somakala@google.com
\ No newline at end of file
diff --git a/ecc/output/OWNERS b/ecc/output/OWNERS
new file mode 100644
index 0000000..d9ecbb7
--- /dev/null
+++ b/ecc/output/OWNERS
@@ -0,0 +1,5 @@
+set noparent
+
+djkrause@google.com
+satk@google.com
+somakala@google.com
\ No newline at end of file
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index 40c2e53..71cd32a 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -122,6 +122,37 @@
             <TextView android:id="@+id/ul_kbps" style="@style/info_value" />
         </LinearLayout>
 
+
+        <!-- EN-DC Available -->
+        <LinearLayout style="@style/RadioInfo_entry_layout" android:orientation="horizontal">
+            <TextView android:id="@+id/endc_available_label" android:text="@string/radio_info_endc_available" style="@style/info_label" />
+            <TextView android:id="@+id/endc_available" style="@style/info_value" />
+        </LinearLayout>
+
+        <!-- DCNR Restricted -->
+        <LinearLayout style="@style/RadioInfo_entry_layout" android:orientation="horizontal">
+            <TextView android:id="@+id/dcnr_restricted_label" android:text="@string/radio_info_dcnr_restricted" style="@style/info_label" />
+            <TextView android:id="@+id/dcnr_restricted" style="@style/info_value" />
+        </LinearLayout>
+
+        <!-- NR Available -->
+        <LinearLayout style="@style/RadioInfo_entry_layout" android:orientation="horizontal">
+            <TextView android:id="@+id/nr_available_label" android:text="@string/radio_info_nr_available" style="@style/info_label" />
+            <TextView android:id="@+id/nr_available" style="@style/info_value" />
+        </LinearLayout>
+
+        <!-- NR State -->
+        <LinearLayout style="@style/RadioInfo_entry_layout" android:orientation="horizontal">
+            <TextView android:id="@+id/nr_state_label" android:text="@string/radio_info_nr_state" style="@style/info_label" />
+            <TextView android:id="@+id/nr_state" style="@style/info_value" />
+        </LinearLayout>
+
+        <!-- NR Frequency -->
+        <LinearLayout style="@style/RadioInfo_entry_layout" android:orientation="horizontal">
+            <TextView android:id="@+id/nr_frequency_label" android:text="@string/radio_info_nr_frequency" style="@style/info_label" />
+            <TextView android:id="@+id/nr_frequency" style="@style/info_value" />
+        </LinearLayout>
+
         <!-- Physical Channel Config -->
         <LinearLayout style="@style/RadioInfo_entry_layout">
             <TextView android:text="@string/radio_info_phy_chan_config" style="@style/info_label" />
diff --git a/res/layout/sim_ndp.xml b/res/layout/sim_ndp.xml
index 5f03d7b..e16f99a 100644
--- a/res/layout/sim_ndp.xml
+++ b/res/layout/sim_ndp.xml
@@ -35,6 +35,13 @@
                 android:layout_height="wrap_content"
                 android:text="@string/label_ndp"/>
 
+        <TextView
+                android:id="@+id/perso_phoneid_text"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/label_phoneid"/>
+
         <EditText android:id="@+id/pin_entry"
                 android:inputType="textPassword"
                 android:imeOptions="actionDone"
diff --git a/res/values/config.xml b/res/values/config.xml
index 7e71068..5ade479 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -211,9 +211,6 @@
     CarrierConfigManager.KEY_CARRIER_VVM_PACKAGE_NAME_STRING does not handle it -->
     <string name="system_visual_voicemail_client" translatable="false"/>
 
-    <!-- Flag to enable VVM3 visual voicemail. VVM3 is used by Verizon Wireless. -->
-    <bool name="vvm3_enabled">false</bool>
-
     <!-- Flag indicating whether to allow pstn phone accounts [DO NOT TRANSLATE] -->
     <bool name="config_pstn_phone_accounts_enabled">true</bool>
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 47652e8..d1ab127 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -107,6 +107,8 @@
     <!-- network depersonalization -->
     <!-- Label text for PIN entry widget on SIM Network Depersonalization panel -->
     <string name="label_ndp">SIM network unlock PIN</string>
+    <!-- Label text for Operator displayName on SIM Network Depersonalization panel -->
+    <string name="label_phoneid">SIM locked for operator</string>
     <!-- Button label on SIM Network Depersonalization panel -->
     <string name="sim_ndp_unlock_text">Unlock</string>
     <!-- Button label on SIM Network Depersonalization panel -->
@@ -2140,6 +2142,16 @@
     <string name="radio_info_toggle_dns_check_label">Toggle DNS Check</string>
     <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
     <string name="oem_radio_info_label">OEM-specific Info/Settings</string>
+    <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
+    <string name="radio_info_endc_available">EN-DC Available:</string>
+    <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
+    <string name="radio_info_dcnr_restricted">DCNR Restricted:</string>
+    <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
+    <string name="radio_info_nr_available">NR Available:</string>
+    <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
+    <string name="radio_info_nr_state">NR State:</string>
+    <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
+    <string name="radio_info_nr_frequency">NR Frequency:</string>
 
     <!-- Band Mode Selection -->
     <!-- Band mode screen.  Title of activity. -->
diff --git a/src/com/android/phone/IccNetworkDepersonalizationPanel.java b/src/com/android/phone/IccNetworkDepersonalizationPanel.java
index a26225e..a4ec8a4 100644
--- a/src/com/android/phone/IccNetworkDepersonalizationPanel.java
+++ b/src/com/android/phone/IccNetworkDepersonalizationPanel.java
@@ -23,6 +23,8 @@
 import android.os.Message;
 import android.os.PersistableBundle;
 import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.Editable;
 import android.text.Spannable;
@@ -68,6 +70,7 @@
     private static IccNetworkDepersonalizationPanel [] sNdpPanel =
             new IccNetworkDepersonalizationPanel[
                     TelephonyManager.getDefault().getSupportedModemCount()];
+    private SubscriptionInfo mSir;
 
     //UI elements
     private EditText     mPinEntry;
@@ -75,6 +78,7 @@
     private LinearLayout mStatusPanel;
     private TextView     mPersoSubtypeText;
     private PersoSubState mPersoSubState;
+    private TextView     mPhoneIdText;
     private TextView     mStatusText;
 
     private Button       mUnlockButton;
@@ -167,6 +171,8 @@
         super(context);
         mPhone = PhoneGlobals.getPhone();
         mPersoSubtype = PersoSubState.PERSOSUBSTATE_SIM_NETWORK.ordinal();
+        mSir = SubscriptionManager.from(context)
+                .getActiveSubscriptionInfoForSimSlotIndex(mPhone.getPhoneId());
     }
 
     //constructor
@@ -175,6 +181,8 @@
         super(context);
         mPhone = phone == null ? PhoneGlobals.getPhone() : phone;
         mPersoSubtype = subtype;
+        mSir = SubscriptionManager.from(context)
+                .getActiveSubscriptionInfoForSimSlotIndex(mPhone.getPhoneId());
     }
 
     @Override
@@ -194,6 +202,7 @@
 
         mEntryPanel = (LinearLayout) findViewById(R.id.entry_panel);
         mPersoSubtypeText = (TextView) findViewById(R.id.perso_subtype_text);
+        mPhoneIdText = (TextView) findViewById(R.id.perso_phoneid_text);
         displayStatus(statusType.ENTRY.name());
 
         mUnlockButton = (Button) findViewById(R.id.ndp_unlock);
@@ -282,6 +291,17 @@
             log ("Unsupported Perso Subtype :" + mPersoSubState.name());
             return;
         }
+        if(mSir != null) {
+            CharSequence displayName = mSir.getDisplayName();
+            log("Operator displayName is: " + displayName + "phoneId: " + mPhone.getPhoneId());
+
+            if(displayName != null && displayName != "") {
+                // Displaying Operator displayName  on UI
+                String phoneIdText = getContext().getString(R.string.label_phoneid)
+                        + ": " + displayName;
+                mPhoneIdText.setText(phoneIdText);
+            }
+        }
 
         if (type == statusType.ENTRY.name()) {
             String displayText = getContext().getString(label);
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 8f987b7..0d31671 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -266,7 +266,9 @@
                     // process.
                     EventSimStateChangedBag bag = (EventSimStateChangedBag)msg.obj;
                     if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(bag.mIccStatus)
-                            || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(bag.mIccStatus)) {
+                            || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(bag.mIccStatus)
+                            || IccCardConstants.INTENT_VALUE_ICC_NOT_READY.equals(bag.mIccStatus)
+                            || IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(bag.mIccStatus)) {
                         // when the right event is triggered and there
                         // are UI objects in the foreground, we close
                         // them to display the lock panel.
@@ -280,7 +282,7 @@
                             mPUKEntryProgressDialog.dismiss();
                             mPUKEntryProgressDialog = null;
                         }
-                        Log.i(LOG_TAG, "Dismissing depersonal panel");
+                        Log.i(LOG_TAG, "Dismissing depersonal panel" + (bag.mIccStatus));
                         IccNetworkDepersonalizationPanel.dialogDismiss(bag.mPhoneId);
                     }
                     break;
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index b25962a..88d8472 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -761,7 +761,9 @@
                     if (ar.exception == null && ar.result != null) {
                         request.result = ar.result;     // Integer
                     } else {
-                        request.result = null;
+                        // request.result must be set to something non-null
+                        // for the calling thread to unblock
+                        request.result = new int[]{-1};
                         if (ar.result == null) {
                             loge("getPreferredNetworkType: Empty response");
                         } else if (ar.exception instanceof CommandException) {
@@ -6575,6 +6577,8 @@
 
     @Override
     public @Nullable PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subscriptionId) {
+        enforceReadPrivilegedPermission("getPhoneAccountHandleForSubscriptionId, "
+                + "subscriptionId: " + subscriptionId);
         final long identity = Binder.clearCallingIdentity();
         try {
             Phone phone = getPhone(subscriptionId);
@@ -7725,7 +7729,7 @@
     private boolean getDefaultDataRoamingEnabled(int subId) {
         final CarrierConfigManager configMgr = (CarrierConfigManager)
                 mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE);
-        boolean isDataRoamingEnabled = TelephonyProperties.data_roaming().orElse(true);
+        boolean isDataRoamingEnabled = TelephonyProperties.data_roaming().orElse(false);
         isDataRoamingEnabled |= configMgr.getConfigForSubId(subId).getBoolean(
                 CarrierConfigManager.KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL);
         return isDataRoamingEnabled;
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index d0951e4..f20da59 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -41,6 +41,7 @@
 import android.os.PersistableBundle;
 import android.os.SystemProperties;
 import android.provider.Settings;
+import android.telephony.AccessNetworkConstants;
 import android.telephony.CarrierConfigManager;
 import android.telephony.CellIdentityCdma;
 import android.telephony.CellIdentityGsm;
@@ -56,6 +57,8 @@
 import android.telephony.CellSignalStrengthGsm;
 import android.telephony.CellSignalStrengthLte;
 import android.telephony.CellSignalStrengthWcdma;
+import android.telephony.DataSpecificRegistrationInfo;
+import android.telephony.NetworkRegistrationInfo;
 import android.telephony.PhoneStateListener;
 import android.telephony.PhysicalChannelConfig;
 import android.telephony.PreciseCallState;
@@ -240,6 +243,11 @@
     private TextView mDnsCheckState;
     private TextView mDownlinkKbps;
     private TextView mUplinkKbps;
+    private TextView mEndcAvailable;
+    private TextView mDcnrRestricted;
+    private TextView mNrAvailable;
+    private TextView mNrState;
+    private TextView mNrFrequency;
     private EditText mSmsc;
     private Switch mRadioPowerOnSwitch;
     private Button mCellInfoRefreshRateButton;
@@ -357,6 +365,7 @@
             updateRadioPowerState();
             updateNetworkType();
             updateImsProvisionedState();
+            updateNrStats(serviceState);
         }
 
     }
@@ -501,9 +510,28 @@
         mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
         mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
         mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
-
+        mEndcAvailable = (TextView) findViewById(R.id.endc_available);
+        mDcnrRestricted = (TextView) findViewById(R.id.dcnr_restricted);
+        mNrAvailable = (TextView) findViewById(R.id.nr_available);
+        mNrState = (TextView) findViewById(R.id.nr_state);
+        mNrFrequency = (TextView) findViewById(R.id.nr_frequency);
         mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
 
+        // hide 5G stats on devices that don't support 5G
+        if ((mTelephonyManager.getSupportedRadioAccessFamily()
+                & TelephonyManager.NETWORK_TYPE_BITMASK_NR) == 0) {
+            ((TextView) findViewById(R.id.endc_available_label)).setVisibility(View.GONE);
+            mEndcAvailable.setVisibility(View.GONE);
+            ((TextView) findViewById(R.id.dcnr_restricted_label)).setVisibility(View.GONE);
+            mDcnrRestricted.setVisibility(View.GONE);
+            ((TextView) findViewById(R.id.nr_available_label)).setVisibility(View.GONE);
+            mNrAvailable.setVisibility(View.GONE);
+            ((TextView) findViewById(R.id.nr_state_label)).setVisibility(View.GONE);
+            mNrState.setVisibility(View.GONE);
+            ((TextView) findViewById(R.id.nr_frequency_label)).setVisibility(View.GONE);
+            mNrFrequency.setVisibility(View.GONE);
+        }
+
         mPreferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
         ArrayAdapter<String> mPreferredNetworkTypeAdapter = new ArrayAdapter<String>(this,
                 android.R.layout.simple_spinner_item, PREFERRED_NETWORK_LABELS);
@@ -625,6 +653,7 @@
         updateProperties();
         updateDnsCheckState();
         updateNetworkType();
+        updateNrStats(null);
 
         updateLocation(mCellLocationResult);
         updateCellInfo(mCellInfoResult);
@@ -1132,6 +1161,32 @@
         }
     }
 
+    private void updateNrStats(ServiceState serviceState) {
+        if ((mTelephonyManager.getSupportedRadioAccessFamily()
+                & TelephonyManager.NETWORK_TYPE_BITMASK_NR) == 0) {
+            return;
+        }
+
+        ServiceState ss = serviceState;
+        if (ss == null && mPhone != null) {
+            ss = mPhone.getServiceState();
+        }
+        if (ss != null) {
+            NetworkRegistrationInfo nri = ss.getNetworkRegistrationInfo(
+                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+            if (nri != null) {
+                DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
+                if (dsri != null) {
+                    mEndcAvailable.setText(dsri.isEnDcAvailable ? "True" : "False");
+                    mDcnrRestricted.setText(dsri.isDcNrRestricted ? "True" : "False");
+                    mNrAvailable.setText(dsri.isNrAvailable ? "True" : "False");
+                }
+            }
+            mNrState.setText(NetworkRegistrationInfo.nrStateToString(ss.getNrState()));
+            mNrFrequency.setText(ServiceState.frequencyRangeToString(ss.getNrFrequencyRange()));
+        }
+    }
+
     private void updateProperties() {
         String s;
         Resources r = getResources();
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index 774968b..a389a86 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -268,7 +268,7 @@
 
                 @Override
                 public void onExtrasChanged(Connection c, Bundle extras) {
-                    Log.v(this, "onExtrasChanged: c=" + c + " Extras=" + extras);
+                    Log.v(this, "onExtrasChanged: c=" + c + " Extras=" + Rlog.pii(LOG_TAG, extras));
                     updateExtras(extras);
                 }
 
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 3b8f4fd..c59df33 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -119,7 +119,7 @@
         private ImsMmTelManager.CapabilityCallback mMmtelCapabilityCallback;
         private RegistrationManager.RegistrationCallback mImsRegistrationCallback;
         private ImsMmTelManager mMmTelManager;
-        private final boolean mIsDummy;
+        private final boolean mIsTestAccount;
         private boolean mIsVideoCapable;
         private boolean mIsVideoPresenceSupported;
         private boolean mIsVideoPauseSupported;
@@ -131,20 +131,20 @@
         private boolean mIsUsingSimCallManager;
         private boolean mIsShowPreciseFailedCause;
 
-        AccountEntry(Phone phone, boolean isEmergency, boolean isDummy) {
+        AccountEntry(Phone phone, boolean isEmergency, boolean isTest) {
             mPhone = phone;
             mIsEmergency = isEmergency;
-            mIsDummy = isDummy;
+            mIsTestAccount = isTest;
             mIsAdhocConfCapable = mPhone.isImsRegistered();
-            mAccount = registerPstnPhoneAccount(isEmergency, isDummy);
+            mAccount = registerPstnPhoneAccount(isEmergency, isTest);
             Log.i(this, "Registered phoneAccount: %s with handle: %s",
                     mAccount, mAccount.getAccountHandle());
             mIncomingCallNotifier = new PstnIncomingCallNotifier((Phone) mPhone);
             mPhoneCapabilitiesNotifier = new PstnPhoneCapabilitiesNotifier((Phone) mPhone,
                     this);
 
-            if (mIsDummy || isEmergency) {
-                // For dummy and emergency entries, there is no sub ID that can be assigned, so do
+            if (mIsTestAccount || isEmergency) {
+                // For test and emergency entries, there is no sub ID that can be assigned, so do
                 // not register for capabilities callbacks.
                 return;
             }
@@ -247,7 +247,7 @@
          * Trigger re-registration of this account.
          */
         public void reRegisterPstnPhoneAccount() {
-            PhoneAccount newAccount = buildPstnPhoneAccount(mIsEmergency, mIsDummy);
+            PhoneAccount newAccount = buildPstnPhoneAccount(mIsEmergency, mIsTestAccount);
             if (!newAccount.equals(mAccount)) {
                 Log.i(this, "reRegisterPstnPhoneAccount: subId: " + getSubId()
                         + " - re-register due to account change.");
@@ -258,8 +258,8 @@
             }
         }
 
-        private PhoneAccount registerPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) {
-            PhoneAccount account = buildPstnPhoneAccount(mIsEmergency, mIsDummy);
+        private PhoneAccount registerPstnPhoneAccount(boolean isEmergency, boolean isTestAccount) {
+            PhoneAccount account = buildPstnPhoneAccount(mIsEmergency, mIsTestAccount);
             // Register with Telecom and put into the account entry.
             mTelecomManager.registerPhoneAccount(account);
             return account;
@@ -268,13 +268,13 @@
         /**
          * Registers the specified account with Telecom as a PhoneAccountHandle.
          */
-        private PhoneAccount buildPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) {
-            String dummyPrefix = isDummyAccount ? "Dummy " : "";
+        private PhoneAccount buildPstnPhoneAccount(boolean isEmergency, boolean isTestAccount) {
+            String testPrefix = isTestAccount ? "Test " : "";
 
             // Build the Phone account handle.
             PhoneAccountHandle phoneAccountHandle =
                     PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
-                            mPhone, dummyPrefix, isEmergency);
+                            mPhone, testPrefix, isEmergency);
 
             // Populate the phone account data.
             int subId = mPhone.getSubId();
@@ -334,8 +334,8 @@
 
                 // The label is user-visible so let's use the display name that the user may
                 // have set in Settings->Sim cards.
-                label = dummyPrefix + subDisplayName;
-                description = dummyPrefix + mContext.getResources().getString(
+                label = testPrefix + subDisplayName;
+                description = testPrefix + mContext.getResources().getString(
                                 R.string.sim_description_default, slotIdString);
             }
 
@@ -767,7 +767,7 @@
                     // time we get here, the original phone account could have been torn down.
                     return;
                 }
-                mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);
+                mAccount = registerPstnPhoneAccount(mIsEmergency, mIsTestAccount);
             }
         }
 
@@ -786,7 +786,7 @@
                     Log.i(this, "updateAdhocConfCapability - changed, new value: "
                             + isAdhocConfCapable);
                     mIsAdhocConfCapable = isAdhocConfCapable;
-                    mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);
+                    mAccount = registerPstnPhoneAccount(mIsEmergency, mIsTestAccount);
                 }
             }
         }
@@ -805,7 +805,7 @@
                 if (mIsVideoPresenceSupported != isVideoPresenceSupported) {
                     Log.i(this, "updateVideoPresenceCapability for subId=" + mPhone.getSubId()
                             + ", new value= " + isVideoPresenceSupported);
-                    mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);
+                    mAccount = registerPstnPhoneAccount(mIsEmergency, mIsTestAccount);
                 }
             }
         }
@@ -814,7 +814,7 @@
             boolean isRttEnabled = isRttCurrentlySupported();
             if (isRttEnabled != mIsRttCapable) {
                 Log.i(this, "updateRttCapability - changed, new value: " + isRttEnabled);
-                mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);
+                mAccount = registerPstnPhoneAccount(mIsEmergency, mIsTestAccount);
             }
         }
 
@@ -823,7 +823,7 @@
                     activeDataSubId);
             if (isEmergencyPreferred != mIsEmergencyPreferred) {
                 Log.i(this, "updateDefaultDataSubId - changed, new value: " + isEmergencyPreferred);
-                mAccount = registerPstnPhoneAccount(mIsEmergency, mIsDummy);
+                mAccount = registerPstnPhoneAccount(mIsEmergency, mIsTestAccount);
             }
         }
 
@@ -1462,7 +1462,7 @@
                         }
 
                         mAccounts.add(new AccountEntry(phone, false /* emergency */,
-                                false /* isDummy */));
+                                false /* isTest */));
                     }
                 }
             } finally {
@@ -1473,14 +1473,14 @@
                     Log.i(this, "setupAccounts: adding default");
                     mAccounts.add(
                             new AccountEntry(PhoneFactory.getDefaultPhone(), true /* emergency */,
-                                    false /* isDummy */));
+                                    false /* isTest */));
                 }
             }
 
             // Add a fake account entry.
-            if (DBG && phones.length > 0 && "TRUE".equals(System.getProperty("dummy_sim"))) {
+            if (DBG && phones.length > 0 && "TRUE".equals(System.getProperty("test_sim"))) {
                 mAccounts.add(new AccountEntry(phones[0], false /* emergency */,
-                        true /* isDummy */));
+                        true /* isTest */));
             }
         }
 
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index ba3f0cc..953d415 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -1540,10 +1540,17 @@
         if (phone == null || TextUtils.isEmpty(number) || !phone.getServiceState().getRoaming()) {
             return false;
         }
+        boolean allowPrefixIms = true;
         String[] blockPrefixes = null;
         CarrierConfigManager cfgManager = (CarrierConfigManager)
                 phone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
         if (cfgManager != null) {
+            allowPrefixIms = cfgManager.getConfigForSubId(phone.getSubId()).getBoolean(
+                    CarrierConfigManager.KEY_SUPPORT_IMS_CALL_FORWARDING_WHILE_ROAMING_BOOL,
+                    true);
+            if (allowPrefixIms && useImsForAudioOnlyCall(phone)) {
+                return false;
+            }
             blockPrefixes = cfgManager.getConfigForSubId(phone.getSubId()).getStringArray(
                     CarrierConfigManager.KEY_CALL_FORWARDING_BLOCKS_WHILE_ROAMING_STRING_ARRAY);
         }
@@ -1558,6 +1565,14 @@
         return false;
     }
 
+    private boolean useImsForAudioOnlyCall(Phone phone) {
+        Phone imsPhone = phone.getImsPhone();
+
+        return imsPhone != null
+                && (imsPhone.isVolteEnabled() || imsPhone.isWifiCallingEnabled())
+                && (imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE);
+    }
+
     private boolean isRadioOn() {
         boolean result = false;
         for (Phone phone : mPhoneFactoryProxy.getPhones()) {