Merge "Add unit tests for SlicePurchaseController"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bf6872e..3d80246 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -159,9 +159,6 @@
     <!-- Needed to block unwanted malicious pop up overlays -->
     <uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/>
 
-    <!-- Needed to set user association to a certain sim -->
-    <uses-permission android:name="android.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION"/>
-
     <permission android:name="com.android.phone.permission.ACCESS_LAST_KNOWN_CELL_ID"
                 android:label="Access last known cell identity."
                 android:protectionLevel="signature"/>
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index a4ee836..d0aad4a 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -31,7 +31,6 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.PersistableBundle;
-import android.os.UserHandle;
 import android.os.VibrationEffect;
 import android.os.Vibrator;
 import android.telecom.PhoneAccount;
@@ -703,7 +702,7 @@
     }
 
     public static PhoneAccountHandle makePstnPhoneAccountHandle(String id) {
-        return makePstnPhoneAccountHandleWithPrefix(id, "", false, null);
+        return makePstnPhoneAccountHandleWithPrefix(id, "", false);
     }
 
     public static PhoneAccountHandle makePstnPhoneAccountHandle(int phoneId) {
@@ -711,26 +710,22 @@
     }
 
     public static PhoneAccountHandle makePstnPhoneAccountHandle(Phone phone) {
-        return makePstnPhoneAccountHandleWithPrefix(phone, "", false, null);
+        return makePstnPhoneAccountHandleWithPrefix(phone, "", false);
     }
 
     public static PhoneAccountHandle makePstnPhoneAccountHandleWithPrefix(
-            Phone phone, String prefix, boolean isEmergency, UserHandle userHandle) {
+            Phone phone, String prefix, boolean isEmergency) {
         // TODO: Should use some sort of special hidden flag to decorate this account as
         // an emergency-only account
         String id = isEmergency ? EMERGENCY_ACCOUNT_HANDLE_ID : prefix +
                 String.valueOf(phone.getSubId());
-        return makePstnPhoneAccountHandleWithPrefix(id, prefix, isEmergency, userHandle);
+        return makePstnPhoneAccountHandleWithPrefix(id, prefix, isEmergency);
     }
 
     public static PhoneAccountHandle makePstnPhoneAccountHandleWithPrefix(
-            String id, String prefix, boolean isEmergency, UserHandle userHandle) {
+            String id, String prefix, boolean isEmergency) {
         ComponentName pstnConnectionServiceName = getPstnConnectionServiceName();
-        // If user handle is null, resort to default constructor to use phone process's
-        // user handle
-        return userHandle == null
-                ? new PhoneAccountHandle(pstnConnectionServiceName, id)
-                : new PhoneAccountHandle(pstnConnectionServiceName, id, userHandle);
+        return new PhoneAccountHandle(pstnConnectionServiceName, id);
     }
 
     public static int getSubIdForPhoneAccount(PhoneAccount phoneAccount) {
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index b6aaebe..49e1379 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -387,7 +387,7 @@
 
     private PhoneAccountHandle getEmergencyPhoneAccount() {
         return PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
-                (Phone) null, "" /* prefix */, true /* isEmergency */, null /* userHandle */);
+                (Phone) null, "" /* prefix */, true /* isEmergency */);
     }
 
     public static Intent buildPhoneAccountConfigureIntent(
diff --git a/src/com/android/services/telephony/PstnIncomingCallNotifier.java b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
index 453cb55..8615325 100644
--- a/src/com/android/services/telephony/PstnIncomingCallNotifier.java
+++ b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
@@ -403,7 +403,7 @@
         // receives an MT call while in ECM. Use the Emergency PhoneAccount to receive the account
         // if it exists.
         PhoneAccountHandle emergencyHandle =
-                PhoneUtils.makePstnPhoneAccountHandleWithPrefix(mPhone, "", true, null);
+                PhoneUtils.makePstnPhoneAccountHandleWithPrefix(mPhone, "", true);
         if(telecomAccountRegistry.hasAccountEntryForPhoneAccount(emergencyHandle)) {
             Log.i(this, "Receiving MT call in ECM. Using Emergency PhoneAccount Instead.");
             return emergencyHandle;
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index f112d33..115c32b 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -285,19 +285,13 @@
         private PhoneAccount buildPstnPhoneAccount(boolean isEmergency, boolean isTestAccount) {
             String testPrefix = isTestAccount ? "Test " : "";
 
-            // Check if we are registering another user. If we are, ensure that the account
-            // is registered to that user handle.
-            int subId = mPhone.getSubId();
-            UserHandle userToRegister = mSubscriptionManager.isActiveSubscriptionId(subId)
-                    ? mSubscriptionManager.getSubscriptionUserHandle(subId)
-                    : null;
-
             // Build the Phone account handle.
             PhoneAccountHandle phoneAccountHandle =
                     PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
-                            mPhone, testPrefix, isEmergency, userToRegister);
+                            mPhone, testPrefix, isEmergency);
 
             // Populate the phone account data.
+            int subId = mPhone.getSubId();
             String subscriberId = mPhone.getSubscriberId();
             int color = PhoneAccount.NO_HIGHLIGHT_COLOR;
             int slotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
@@ -361,12 +355,8 @@
 
             // By default all SIM phone accounts can place emergency calls.
             int capabilities = PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
-                    PhoneAccount.CAPABILITY_CALL_PROVIDER;
-
-            // This is enabled by default. To support work profiles, it should not be enabled.
-            if (userToRegister == null) {
-                capabilities |= PhoneAccount.CAPABILITY_MULTI_USER;
-            }
+                    PhoneAccount.CAPABILITY_CALL_PROVIDER |
+                    PhoneAccount.CAPABILITY_MULTI_USER;
 
             if (mContext.getResources().getBoolean(R.bool.config_pstnCanPlaceEmergencyCalls)) {
                 capabilities |= PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS;
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 5b1f463..da918ad 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -360,8 +360,7 @@
         @Override
         public PhoneAccountHandle makePstnPhoneAccountHandleWithPrefix(Phone phone, String prefix,
                 boolean isEmergency) {
-            return PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
-                    phone, prefix, isEmergency, null);
+            return PhoneUtils.makePstnPhoneAccountHandleWithPrefix(phone, prefix, isEmergency);
         }
     };
 
diff --git a/tests/src/com/android/phone/PhoneUtilsTest.java b/tests/src/com/android/phone/PhoneUtilsTest.java
index b5ff0dc..521a0bb 100644
--- a/tests/src/com/android/phone/PhoneUtilsTest.java
+++ b/tests/src/com/android/phone/PhoneUtilsTest.java
@@ -22,7 +22,6 @@
 import static org.mockito.Mockito.when;
 
 import android.content.ComponentName;
-import android.os.UserHandle;
 import android.telecom.PhoneAccountHandle;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
@@ -83,15 +82,6 @@
         PhoneAccountHandle phoneAccountHandleTest = new PhoneAccountHandle(
                 PSTN_CONNECTION_SERVICE_COMPONENT, mPhoneAccountHandleIdString);
         assertEquals(phoneAccountHandleTest, PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
-                mPhoneAccountHandleIdString, "", false, null));
-    }
-
-    @Test
-    public void testMakePstnPhoneAccountHandleWithPrefixForAnotherUser() throws Exception {
-        UserHandle userHandle = new UserHandle(10);
-        PhoneAccountHandle phoneAccountHandleTest = new PhoneAccountHandle(
-                PSTN_CONNECTION_SERVICE_COMPONENT, mPhoneAccountHandleIdString, userHandle);
-        assertEquals(phoneAccountHandleTest, PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
-                mPhoneAccountHandleIdString, "", false, userHandle));
+                mPhoneAccountHandleIdString, "", false));
     }
 }