Merge "Check result after send request in PhoneInterfaceManager." into sc-dev
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 581b81b..8a0e770 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -303,7 +303,7 @@
     <string name="carrier_settings_euicc" msgid="1190237227261337749">"Оператор"</string>
     <string name="keywords_carrier_settings_euicc" msgid="8540160967922063745">"оператор, esim, sim, euicc, сменить оператора, добавить оператора"</string>
     <string name="carrier_settings_euicc_summary" msgid="2027941166597330117">"<xliff:g id="CARRIER_NAME">%1$s</xliff:g> – <xliff:g id="PHONE_NUMBER">%2$s</xliff:g>"</string>
-    <string name="mobile_data_settings_title" msgid="7228249980933944101">"Мобильный Интернет"</string>
+    <string name="mobile_data_settings_title" msgid="7228249980933944101">"Мобильный интернет"</string>
     <string name="mobile_data_settings_summary" msgid="5012570152029118471">"Доступ к Интернету по мобильной сети"</string>
     <string name="data_usage_disable_mobile" msgid="5669109209055988308">"Отключить мобильный Интернет?"</string>
     <string name="sim_selection_required_pref" msgid="6985901872978341314">"Выберите SIM-карту"</string>
diff --git a/res/values-ta/strings.xml b/res/values-ta/strings.xml
index 9ed730c..ab850a6 100644
--- a/res/values-ta/strings.xml
+++ b/res/values-ta/strings.xml
@@ -339,7 +339,7 @@
     <string name="maintenance_enable" msgid="2646784483222342290">"பராமரிப்பு இயக்கப்பட்டது"</string>
     <string name="maintenance_disable" msgid="2121032601497725602">"பராமரிப்பு முடக்கப்பட்டது"</string>
     <string name="general_news_settings" msgid="2670499575962080411">"பொது செய்திகள்"</string>
-    <string name="bf_news_settings" msgid="8571709425370794221">"வணிகம் மற்றும் நிதிசார்ந்த செய்திகள்"</string>
+    <string name="bf_news_settings" msgid="8571709425370794221">"பிசினஸ் மற்றும் நிதிசார்ந்த செய்திகள்"</string>
     <string name="sports_news_settings" msgid="2684364556989168438">"விளையாட்டுச் செய்திகள்"</string>
     <string name="entertainment_news_settings" msgid="4228527702346305543">"பொழுதுபோக்குச் செய்திகள்"</string>
     <string name="enable_disable_local" msgid="7654175079979415572">"உள்ளூர்"</string>
diff --git a/sip/res/values-kn/strings.xml b/sip/res/values-kn/strings.xml
index cf7cd59..99fe93e 100644
--- a/sip/res/values-kn/strings.xml
+++ b/sip/res/values-kn/strings.xml
@@ -19,7 +19,7 @@
     <string name="sip_settings" msgid="7452587325305604702">"ಎಸ್‌ಐಪಿ ಸೆಟ್ಟಿಂಗ್‌ಗಳು"</string>
     <string name="sip_accounts" msgid="7297896885665783239">"ಎಸ್‌ಐಪಿ ಖಾತೆಗಳು"</string>
     <string name="sip_accounts_title" msgid="3061686404598143943">"ಖಾತೆಗಳು"</string>
-    <string name="sip_receive_calls" msgid="3403644006618369349">"ಒಳಬರುವ ಕರೆಗಳನ್ನು ಸ್ವೀಕರಿಸು"</string>
+    <string name="sip_receive_calls" msgid="3403644006618369349">"ಒಳಬರುವ ಕರೆಗಳನ್ನು ಸ್ವೀಕರಿಸಿ"</string>
     <string name="sip_receive_calls_summary" msgid="5306603671778761443">"ಹೆಚ್ಚು ಬ್ಯಾಟರಿಯನ್ನು ಬಳಸುತ್ತದೆ"</string>
     <string name="sip_call_options_title" msgid="5027066677561068192">"ಎಸ್‌ಐಪಿ ಕರೆ ಮಾಡುವಿಕೆಯನ್ನು ಬಳಸಿ"</string>
     <string name="sip_call_options_wifi_only_title" msgid="6663105297927456484">"ಎಸ್‌ಐಪಿ ಕರೆ ಮಾಡುವಿಕೆಯನ್ನು ಬಳಸಿ (ವೈ-ಫೈ ಮಾತ್ರ)"</string>
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index bcc312c..90c9df4 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -94,7 +94,7 @@
         mApp = app;
         TelephonyFrameworkInitializer
                 .getTelephonyServiceManager().getTelephonyImsServiceRegisterer().register(this);
-        mImsResolver = mApp.getImsResolver();
+        mImsResolver = ImsResolver.getInstance();
     }
 
     /**
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index da3b08d..130c775 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -157,7 +157,6 @@
     CallNotifier notifier;
     CallerInfoCache callerInfoCache;
     NotificationMgr notificationMgr;
-    ImsResolver mImsResolver;
     TelephonyRcsService mTelephonyRcsService;
     public PhoneInterfaceManager phoneMgr;
     public ImsRcsController imsRcsController;
@@ -408,10 +407,10 @@
                         R.string.config_ims_mmtel_package);
                 String defaultImsRcsPackage = getResources().getString(
                         R.string.config_ims_rcs_package);
-                mImsResolver = new ImsResolver(this, defaultImsMmtelPackage,
+                ImsResolver.make(this, defaultImsMmtelPackage,
                         defaultImsRcsPackage, PhoneFactory.getPhones().length,
                         new ImsFeatureBinderRepository());
-                mImsResolver.initialize();
+                ImsResolver.getInstance().initialize();
 
                 // With the IMS phone created, load static config.xml values from the phone process
                 // so that it can be provided to the ImsPhoneCallTracker.
@@ -564,10 +563,6 @@
         return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
     }
 
-    public ImsResolver getImsResolver() {
-        return mImsResolver;
-    }
-
     /* package */ CallManager getCallManager() {
         return mCM;
     }
@@ -1033,7 +1028,7 @@
         pw.println("ImsResolver:");
         pw.increaseIndent();
         try {
-            if (mImsResolver != null) mImsResolver.dump(fd, pw, args);
+            if (ImsResolver.getInstance() != null) ImsResolver.getInstance().dump(fd, pw, args);
         } catch (Exception e) {
             e.printStackTrace();
         }
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index bf867cf..71abc31 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -140,6 +140,7 @@
 import com.android.internal.telephony.CallForwardInfo;
 import com.android.internal.telephony.CallManager;
 import com.android.internal.telephony.CallStateException;
+import com.android.internal.telephony.CallTracker;
 import com.android.internal.telephony.CarrierResolver;
 import com.android.internal.telephony.CellNetworkScanResult;
 import com.android.internal.telephony.CommandException;
@@ -2163,7 +2164,7 @@
     private PhoneInterfaceManager(PhoneGlobals app) {
         mApp = app;
         mCM = PhoneGlobals.getInstance().mCM;
-        mImsResolver = PhoneGlobals.getInstance().getImsResolver();
+        mImsResolver = ImsResolver.getInstance();
         mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE);
         mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE);
         mPm = app.getSystemService(PackageManager.class);
@@ -10254,6 +10255,32 @@
         }
     }
 
+    @Override
+    public void setDeviceToDeviceForceEnabled(boolean isForceEnabled) {
+        TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(),
+                "setDeviceToDeviceForceEnabled");
+
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            Arrays.stream(PhoneFactory.getPhones()).forEach(
+                    p -> {
+                        Phone thePhone = p.getImsPhone();
+                        if (thePhone != null && thePhone instanceof ImsPhone) {
+                            ImsPhone imsPhone = (ImsPhone) thePhone;
+                            CallTracker tracker = imsPhone.getCallTracker();
+                            if (tracker != null && tracker instanceof ImsPhoneCallTracker) {
+                                ImsPhoneCallTracker imsPhoneCallTracker =
+                                        (ImsPhoneCallTracker) tracker;
+                                imsPhoneCallTracker.setDeviceToDeviceForceEnabled(isForceEnabled);
+                            }
+                        }
+                    }
+            );
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
+
     /**
      * Gets the config of RCS VoLTE single registration enabled for the device.
      */
diff --git a/src/com/android/phone/SimPhonebookProvider.java b/src/com/android/phone/SimPhonebookProvider.java
index 4a15950..b921398 100644
--- a/src/com/android/phone/SimPhonebookProvider.java
+++ b/src/com/android/phone/SimPhonebookProvider.java
@@ -16,6 +16,9 @@
 
 package com.android.phone;
 
+import static com.android.internal.telephony.IccProvider.STR_NEW_TAG;
+import static com.android.internal.telephony.IccProvider.STR_NEW_NUMBER;
+
 import android.Manifest;
 import android.annotation.TestApi;
 import android.content.ContentProvider;
@@ -662,8 +665,11 @@
     private boolean updateRecord(PhonebookArgs args, AdnRecord existingRecord, String pin2,
             String newName, String newPhone) {
         try {
+            ContentValues values = new ContentValues();
+            values.put(STR_NEW_TAG, newName);
+            values.put(STR_NEW_NUMBER, newPhone);
             return mIccPhoneBookSupplier.get().updateAdnRecordsInEfByIndexForSubscriber(
-                    args.subscriptionId, existingRecord.getEfid(), newName, newPhone,
+                    args.subscriptionId, existingRecord.getEfid(), values,
                     existingRecord.getRecId(),
                     pin2);
         } catch (RemoteException e) {
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index d2a3c40..c83ea64 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -133,6 +133,7 @@
     private static final String D2D_SUBCOMMAND = "d2d";
     private static final String D2D_SEND = "send";
     private static final String D2D_TRANSPORT = "transport";
+    private static final String D2D_SET_DEVICE_SUPPORT = "set-device-support";
 
     private static final String BARRING_SUBCOMMAND = "barring";
     private static final String BARRING_SEND_INFO = "send";
@@ -383,6 +384,10 @@
         pw.println("  d2d transport TYPE");
         pw.println("    Forces the specified D2D transport TYPE to be active.  Use the");
         pw.println("    short class name of the transport; i.e. DtmfTransport or RtpTransport.");
+        pw.println("  d2d set-device-support true/default");
+        pw.println("    true - forces device support to be enabled for D2D.");
+        pw.println("    default - clear any previously set force-enable of D2D, reverting to ");
+        pw.println("    the current device's configuration.");
     }
 
     private void onHelpBarring() {
@@ -916,6 +921,9 @@
             case D2D_TRANSPORT: {
                 return handleD2dTransportCommand();
             }
+            case D2D_SET_DEVICE_SUPPORT: {
+                return handleD2dDeviceSupportedCommand();
+            }
         }
 
         return -1;
@@ -1067,6 +1075,26 @@
         return 0;
     }
 
+    private int handleD2dDeviceSupportedCommand() {
+        PrintWriter errPw = getErrPrintWriter();
+
+        String arg = getNextArg();
+        if (arg == null) {
+            onHelpD2D();
+            return 0;
+        }
+
+        boolean isEnabled = "true".equals(arg.toLowerCase());
+        try {
+            mInterface.setDeviceToDeviceForceEnabled(isEnabled);
+        } catch (RemoteException e) {
+            Log.w(LOG_TAG, "Error forcing D2D enabled: " + e.getMessage());
+            errPw.println("Exception: " + e.getMessage());
+            return -1;
+        }
+        return 0;
+    }
+
     // ims set-ims-service
     private int handleImsSetServiceCommand() {
         PrintWriter errPw = getErrPrintWriter();
diff --git a/tests/src/com/android/phone/SimPhonebookProviderTest.java b/tests/src/com/android/phone/SimPhonebookProviderTest.java
index 4ab92a7..f897fac 100644
--- a/tests/src/com/android/phone/SimPhonebookProviderTest.java
+++ b/tests/src/com/android/phone/SimPhonebookProviderTest.java
@@ -51,6 +51,7 @@
 import androidx.test.rule.provider.ProviderTestRule;
 
 import com.android.internal.telephony.IIccPhoneBook;
+import com.android.internal.telephony.uicc.AdnCapacity;
 import com.android.internal.telephony.uicc.AdnRecord;
 import com.android.internal.telephony.uicc.IccConstants;
 
@@ -1394,15 +1395,18 @@
         }
 
         @Override
-        public boolean updateAdnRecordsInEfBySearch(int efid, String oldTag, String oldPhoneNumber,
-                String newTag, String newPhoneNumber, String pin2) {
-            return updateAdnRecordsInEfBySearchForSubscriber(
-                    mDefaultSubscriptionId, efid,
-                    oldTag, oldPhoneNumber, newTag, newPhoneNumber, pin2);
+        public boolean updateAdnRecordsInEfBySearchForSubscriber(int subId, int efid,
+                ContentValues values, String pin2) {
+            final String oldTag = values.getAsString(IccProvider.STR_TAG);
+            final String oldPhoneNumber = values.getAsString(IccProvider.STR_NUMBER);
+            final String newTag = values.getAsString(IccProvider.STR_NEW_TAG);
+            final String newPhoneNumber = values.getAsString(IccProvider.STR_NEW_NUMBER);
+            return updateAdnRecordsInEfBySearchForSubscriber(subId, efid, oldTag, oldPhoneNumber,
+                    newTag, newPhoneNumber, pin2);
+
         }
 
-        @Override
-        public boolean updateAdnRecordsInEfBySearchForSubscriber(int subId, int efid, String oldTag,
+        private boolean updateAdnRecordsInEfBySearchForSubscriber(int subId, int efid, String oldTag,
                 String oldPhoneNumber, String newTag, String newPhoneNumber, String pin2) {
             if (!oldTag.isEmpty() || !oldPhoneNumber.isEmpty()) {
                 throw new IllegalArgumentException(
@@ -1413,14 +1417,16 @@
         }
 
         @Override
-        public boolean updateAdnRecordsInEfByIndex(int efid, String newTag, String newPhoneNumber,
-                int index, String pin2) {
-            return updateAdnRecordsInEfByIndexForSubscriber(mDefaultSubscriptionId,
-                    efid, newTag, newPhoneNumber, index, pin2);
+        public boolean updateAdnRecordsInEfByIndexForSubscriber(int subId, int efid,
+                ContentValues values, int index, String pin2) {
+            final String newTag = values.getAsString(IccProvider.STR_NEW_TAG);
+            final String newPhoneNumber = values.getAsString(IccProvider.STR_NEW_NUMBER);
+            return updateAdnRecordsInEfByIndexForSubscriber(subId, efid, newTag, newPhoneNumber,
+                    index, pin2);
+
         }
 
-        @Override
-        public boolean updateAdnRecordsInEfByIndexForSubscriber(int subId, int efid, String newTag,
+        private boolean updateAdnRecordsInEfByIndexForSubscriber(int subId, int efid, String newTag,
                 String newPhoneNumber, int index, String pin2) {
             AdnRecord[] records = mRecords.computeIfAbsent(Pair.create(subId, efid), unused ->
                     createEmptyRecords(efid, 100));
@@ -1443,6 +1449,11 @@
             int count = mRecords.get(key).length;
             return new int[]{recordSize, recordSize * count, count};
         }
+
+        @Override
+        public AdnCapacity getAdnRecordsCapacityForSubscriber(int subId) {
+            return new AdnCapacity(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+        }
     }
 
     /**