Start the configure intent with the right user
When opening the ConnectionService's CONFIGURE activity, make sure
to direct it to the correct user.
Additionally, register SIM/SIP PhoneAccounts as MULTI_USER so that
secondary users can use them.
Finally, differentiate between work profile PhoneAccounts so that
they can be correctly identified by the user.
Bug: 17421902
Bug: 17421044
Bug: 18278824
Change-Id: I673904a7ae038c88688bba62642e93174e55c308
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 30af301..6b35ada 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -161,7 +161,7 @@
<!-- Label for selectecting a Wi-Fi call manager -->
<string name="wifi_calling_select_call_assistant">Choose call assistant</string>
<!-- Summary for the label of a setting to select the SIM call managers to use.-->
- <string name="wifi_calling_select_call_assistant_summary">Choose an app or service to manage the networks used for calls</string>
+ <string name="wifi_calling_select_call_assistant_summary">Manage the networks used for calls with</string>
<!-- Summary for the label of a switch setting to enable/disable the use of SIM call managers. -->
<string name="wifi_calling_use_call_assistant_summary">Let apps or services manage networks used for calls</string>
<!-- Label for setting to configure the selected call assistant. -->
diff --git a/sip/src/com/android/services/telephony/sip/SipUtil.java b/sip/src/com/android/services/telephony/sip/SipUtil.java
index 54bdc1e..ea5ea46 100644
--- a/sip/src/com/android/services/telephony/sip/SipUtil.java
+++ b/sip/src/com/android/services/telephony/sip/SipUtil.java
@@ -116,7 +116,8 @@
}
PhoneAccount.Builder builder = PhoneAccount.builder(accountHandle, profile.getDisplayName())
- .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
+ .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER
+ | PhoneAccount.CAPABILITY_MULTI_USER)
.setAddress(Uri.parse(profile.getUriString()))
.setShortDescription(profile.getDisplayName())
.setIcon(context, R.drawable.ic_dialer_sip_black_24dp)
diff --git a/src/com/android/phone/settings/AccountSelectionPreference.java b/src/com/android/phone/settings/AccountSelectionPreference.java
index 7d1ede8..6872a16 100644
--- a/src/com/android/phone/settings/AccountSelectionPreference.java
+++ b/src/com/android/phone/settings/AccountSelectionPreference.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.os.UserHandle;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -76,10 +77,15 @@
mEntryValues = new String[mAccounts.length + 1];
mEntries = new CharSequence[mAccounts.length + 1];
+ PackageManager pm = mContext.getPackageManager();
+
int selectedIndex = mAccounts.length; // Points to nullSelectionString by default
int i = 0;
for ( ; i < mAccounts.length; i++) {
CharSequence label = telecomManager.getPhoneAccount(mAccounts[i]).getLabel();
+ if (label != null) {
+ label = pm.getUserBadgedLabel(label, mAccounts[i].getUserHandle());
+ }
mEntries[i] = label == null ? null : label.toString();
mEntryValues[i] = Integer.toString(i);
if (Objects.equals(currentSelection, mAccounts[i])) {
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 0085181..03374ce 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -5,6 +5,7 @@
import android.content.Intent;
import android.net.sip.SipManager;
import android.os.Bundle;
+import android.os.UserHandle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -223,8 +224,14 @@
if (pref == mConfigureCallAssistant) {
Intent intent = getConfigureCallAssistantIntent();
if (intent != null) {
+ PhoneAccountHandle handle = mTelecomManager.getSimCallManager();
+ UserHandle userHandle = handle.getUserHandle();
try {
- startActivity(intent);
+ if (userHandle != null) {
+ getActivity().startActivityAsUser(intent, userHandle);
+ } else {
+ startActivity(intent);
+ }
} catch (ActivityNotFoundException e) {
Log.d(LOG_TAG, "Could not resolve call assistant configure intent: " + intent);
}
@@ -311,10 +318,9 @@
* call assistants, and the currently selected call assistant.
*/
public void updateCallAssistantModel() {
- List<PhoneAccountHandle> simCallManagers = mTelecomManager.getSimCallManagers();
mSelectCallAssistant.setModel(
mTelecomManager,
- simCallManagers,
+ mTelecomManager.getSimCallManagers(),
mTelecomManager.getSimCallManager(),
getString(R.string.wifi_calling_call_assistant_none));
}
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index b36037e..13b3c94 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -141,7 +141,8 @@
// By default all SIM phone accounts can place emergency calls.
int capabilities = PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
PhoneAccount.CAPABILITY_CALL_PROVIDER |
- PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS;
+ PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS |
+ PhoneAccount.CAPABILITY_MULTI_USER;
if (iconBitmap == null) {
iconBitmap = BitmapFactory.decodeResource(