Merge "Change subId to int from long" into lmp-mr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d1f8968..c086376 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -94,8 +94,8 @@
     <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
     <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
     <uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
-    <uses-permission
-            android:name="com.android.server.telecom.permission.REGISTER_PROVIDER_OR_SUBSCRIPTION" />
+    <uses-permission android:name="android.permission.DUMP" />
+    <uses-permission android:name="android.permission.REGISTER_PROVIDER_OR_SUBSCRIPTION" />
 
     <!-- This tells the activity manager to not delay any of our activity
          start requests, even if they happen immediately after the user
@@ -430,7 +430,6 @@
                 <action android:name="android.intent.action.VIEW" />
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.telecom.action.SHOW_CALL_SETTINGS" />
-                <action android:name="android.telecom.action.CHANGE_PHONE_ACCOUNTS" />
                 <action android:name="com.android.phone.CallFeaturesSetting.ADD_VOICEMAIL" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -537,6 +536,10 @@
         <activity android:name="com.android.phone.settings.PhoneAccountSettingsActivity"
             android:label="@string/phone_accounts"
             android:theme="@style/DialerSettingsLight">
+            <intent-filter>
+                <action android:name="android.telecom.action.CHANGE_PHONE_ACCOUNTS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
         </activity>
 
         <!-- BroadcastReceiver for receiving Intents from Notification mechanism. -->
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index eb74956..106484b 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -442,13 +442,10 @@
         switch (id) {
             case R.id.deleteButton: {
                 mDigits.getText().clear();
-                // TODO: The framework forgets to clear the pressed
-                // status of disabled button. Until this is fixed,
-                // clear manually the pressed status. b/2133127
-                mDelete.setPressed(false);
                 return true;
             }
             case R.id.zero: {
+                removePreviousDigitIfPossible();
                 keyPressed(KeyEvent.KEYCODE_PLUS);
                 return true;
             }
@@ -623,4 +620,16 @@
 
         mDelete.setEnabled(notEmpty);
     }
+
+    /**
+     * Remove the digit just before the current position. Used by various long pressed callbacks
+     * to remove the digit that was populated as a result of the short click.
+     */
+    private void removePreviousDigitIfPossible() {
+        final int currentPosition = mDigits.getSelectionStart();
+        if (currentPosition > 0) {
+            mDigits.setSelection(currentPosition);
+            mDigits.getText().delete(currentPosition - 1, currentPosition);
+        }
+    }
 }
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 6ed9cbc..5489c47 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -344,9 +344,11 @@
             final Notification notification = builder.build();
             List<UserInfo> users = mUserManager.getUsers(true);
             for (int i = 0; i < users.size(); i++) {
-                UserHandle userHandle = users.get(i).getUserHandle();
+                final UserInfo user = users.get(i);
+                final UserHandle userHandle = user.getUserHandle();
                 if (!mUserManager.hasUserRestriction(
-                        UserManager.DISALLOW_OUTGOING_CALLS, userHandle)) {
+                        UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
+                            && !user.isManagedProfile()) {
                     mNotificationManager.notifyAsUser(
                             null /* tag */, VOICEMAIL_NOTIFICATION, notification, userHandle);
                 }
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index c48812c..ba6871c 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -1,6 +1,7 @@
 package com.android.phone.settings;
 
 import android.content.ActivityNotFoundException;
+import android.content.Context;
 import android.content.Intent;
 import android.net.sip.SipManager;
 import android.os.Bundle;
@@ -45,6 +46,7 @@
     private String LOG_TAG = PhoneAccountSettingsFragment.class.getSimpleName();
 
     private TelecomManager mTelecomManager;
+    private Context mApplicationContext;
 
     private AccountSelectionPreference mDefaultOutgoingAccount;
     private AccountSelectionPreference mSelectCallAssistant;
@@ -59,6 +61,7 @@
         super.onCreate(icicle);
 
         mTelecomManager = TelecomManager.from(getActivity());
+        mApplicationContext = getActivity().getApplicationContext();
     }
 
     @Override
@@ -216,11 +219,11 @@
     private synchronized void handleSipReceiveCallsOption(boolean isEnabled) {
         mSipSharedPreferences.setReceivingCallsEnabled(isEnabled);
 
-        SipUtil.useSipToReceiveIncomingCalls(getActivity(), isEnabled);
+        SipUtil.useSipToReceiveIncomingCalls(mApplicationContext, isEnabled);
 
         // Restart all Sip services to ensure we reflect whether we are receiving calls.
         SipAccountRegistry sipAccountRegistry = SipAccountRegistry.getInstance();
-        sipAccountRegistry.restartSipService(getActivity());
+        sipAccountRegistry.restartSipService(mApplicationContext);
     }
 
     /**
diff --git a/src/com/android/services/telephony/CdmaConferenceController.java b/src/com/android/services/telephony/CdmaConferenceController.java
index d0cf6de..d6d5659 100644
--- a/src/com/android/services/telephony/CdmaConferenceController.java
+++ b/src/com/android/services/telephony/CdmaConferenceController.java
@@ -107,10 +107,10 @@
                 @Override
                 public void run() {
                     connection.forceAsDialing(false);
+                    addInternal(connection);
                     for (CdmaConnection current : connectionsToReset) {
                         current.resetStateForConference();
                     }
-                    addInternal(connection);
                 }
             }, ADD_OUTGOING_CONNECTION_DELAY_MILLIS);
         } else {