Merge "Check for PROPERTY_IS_DOWNGRADED_CONFERENCE in addExistingConnection" into nyc-mr1-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e46aa54..11b2d50 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -109,12 +109,13 @@
<!-- Title of dialog used to comfirm whether the user intends to change the default dialer
application [CHAR LIMIT=55]-->
- <string name="change_default_dialer_dialog_title">Change default Dialer app?</string>
- <!-- Text in dialog used to confirm whether or not the user intends to change the default dialer, if a different default dialer has been previously set. -->
- <string name="change_default_dialer_with_previous_app_set_text">Use <xliff:g id="new_app">%1$s</xliff:g> instead of <xliff:g id="current_app">%2$s</xliff:g> as your default dialer app?</string>
- <!-- Text in dialog used to confirm whether or not the user intends to change the default dialer, if a different default dialer has not been previously set. -->
- <string name="change_default_dialer_no_previous_app_set_text">Use <xliff:g id="new_app">%s</xliff:g> as your default dialer app?</string>
-
+ <string name="change_default_dialer_dialog_title">Make <xliff:g id="new_app">%s</xliff:g> your default Phone app?</string>
+ <!-- Confirmation text that a user taps on to change the Default Phone App-->
+ <string name="change_default_dialer_dialog_affirmative">Set Default</string>
+ <!-- Cancel text that a user taps on to not change the Default Phone App-->
+ <string name="change_default_dialer_dialog_negative">Cancel</string>
+ <!-- Warning message indicating what may happen if a user allows a 3rd party app to become the default dialer.-->
+ <string name="change_default_dialer_warning_message"><xliff:g id="new_app">%s</xliff:g> will be able to place and control all aspects of calls. Only apps you trust should be set as the default Phone app.</string>
<!-- Blocked numbers -->
<string name="blocked_numbers">Blocked numbers</string>
diff --git a/src/com/android/server/telecom/Analytics.java b/src/com/android/server/telecom/Analytics.java
index 6a22883..50ff14d 100644
--- a/src/com/android/server/telecom/Analytics.java
+++ b/src/com/android/server/telecom/Analytics.java
@@ -468,16 +468,25 @@
int prefixLength = CallsManager.TELECOM_CALL_ID_PREFIX.length();
List<String> callIds = new ArrayList<>(sCallIdToInfo.keySet());
// Sort the analytics in increasing order of call IDs
- Collections.sort(callIds, (id1, id2) -> {
- int i1, i2;
- try {
- i1 = Integer.valueOf(id1.substring(prefixLength));
- i2 = Integer.valueOf(id2.substring(prefixLength));
- } catch (NumberFormatException e) {
- return 0;
- }
- return i1 - i2;
- });
+ try {
+ Collections.sort(callIds, (id1, id2) -> {
+ int i1, i2;
+ try {
+ i1 = Integer.valueOf(id1.substring(prefixLength));
+ } catch (NumberFormatException e) {
+ i1 = Integer.MAX_VALUE;
+ }
+
+ try {
+ i2 = Integer.valueOf(id2.substring(prefixLength));
+ } catch (NumberFormatException e) {
+ i2 = Integer.MAX_VALUE;
+ }
+ return i1 - i2;
+ });
+ } catch (IllegalArgumentException e) {
+ // do nothing, leave the list in a partially sorted state.
+ }
for (String callId : callIds) {
writer.printf("Call %s: ", callId);
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 1139cc5..b3e36f9 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -577,6 +577,11 @@
return false;
}
+ // Only Redial a Call in the case of it being an Emergency Call.
+ if(!isEmergencyCall()) {
+ return false;
+ }
+
// Make sure that there are additional connection services to process.
if (mCreateConnectionProcessor == null
|| !mCreateConnectionProcessor.isProcessingComplete()
diff --git a/src/com/android/server/telecom/CreateConnectionProcessor.java b/src/com/android/server/telecom/CreateConnectionProcessor.java
index 22ec3c6..91a2c84 100644
--- a/src/com/android/server/telecom/CreateConnectionProcessor.java
+++ b/src/com/android/server/telecom/CreateConnectionProcessor.java
@@ -287,6 +287,7 @@
mPhoneAccountRegistrar.getSimCallManagerFromCall(mCall),
mAttemptRecords.get(0).targetPhoneAccount);
Log.v(this, "setConnectionManager, changing %s -> %s", mAttemptRecords.get(0), record);
+ mAttemptRecords.clear();
mAttemptRecords.add(0, record);
} else {
Log.v(this, "setConnectionManager, not changing");
diff --git a/src/com/android/server/telecom/TelecomSystem.java b/src/com/android/server/telecom/TelecomSystem.java
index 67321d4..9ed612a 100644
--- a/src/com/android/server/telecom/TelecomSystem.java
+++ b/src/com/android/server/telecom/TelecomSystem.java
@@ -176,7 +176,8 @@
SystemStateProvider systemStateProvider = new SystemStateProvider(mContext);
mMissedCallNotifier = missedCallNotifierImplFactory
- .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar);
+ .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar,
+ phoneNumberUtilsAdapter);
DefaultDialerManagerAdapter defaultDialerAdapter =
new TelecomServiceImpl.DefaultDialerManagerAdapterImpl();
diff --git a/src/com/android/server/telecom/VideoProviderProxy.java b/src/com/android/server/telecom/VideoProviderProxy.java
index c8adc6e..9b2cc7a 100644
--- a/src/com/android/server/telecom/VideoProviderProxy.java
+++ b/src/com/android/server/telecom/VideoProviderProxy.java
@@ -158,15 +158,17 @@
@Override
public void receiveSessionModifyResponse(int status, VideoProfile requestProfile,
VideoProfile responseProfile) {
+ logFromVideoProvider("receiveSessionModifyResponse: status=" + status +
+ " requestProfile=" + requestProfile + " responseProfile=" + responseProfile);
+ String eventMessage = "Status Code : " + status + " Video State: " +
+ (responseProfile != null ? responseProfile.getVideoState() : "null");
+ Log.event(mCall, Log.Events.RECEIVE_VIDEO_RESPONSE, eventMessage);
synchronized (mLock) {
- mCall.getAnalytics().addVideoEvent(
- Analytics.RECEIVE_REMOTE_SESSION_MODIFY_RESPONSE,
- requestProfile.getVideoState());
- logFromVideoProvider("receiveSessionModifyResponse: status=" + status +
- " requestProfile=" + requestProfile + " responseProfile=" +
- responseProfile);
- Log.event(mCall, Log.Events.RECEIVE_VIDEO_RESPONSE,
- VideoProfile.videoStateToString(responseProfile.getVideoState()));
+ if (status == Connection.VideoProvider.SESSION_MODIFY_REQUEST_SUCCESS) {
+ mCall.getAnalytics().addVideoEvent(
+ Analytics.RECEIVE_REMOTE_SESSION_MODIFY_RESPONSE,
+ requestProfile.getVideoState());
+ }
VideoProviderProxy.this.receiveSessionModifyResponse(status, requestProfile,
responseProfile);
}
diff --git a/src/com/android/server/telecom/components/ChangeDefaultDialerDialog.java b/src/com/android/server/telecom/components/ChangeDefaultDialerDialog.java
index 5fd7904..107389b 100644
--- a/src/com/android/server/telecom/components/ChangeDefaultDialerDialog.java
+++ b/src/com/android/server/telecom/components/ChangeDefaultDialerDialog.java
@@ -21,11 +21,18 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.graphics.Color;
+import android.graphics.Typeface;
import android.os.Bundle;
import android.telecom.DefaultDialerManager;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
import android.text.TextUtils;
+import android.text.style.ForegroundColorSpan;
+import android.text.style.StyleSpan;
import android.util.Log;
import com.android.internal.app.AlertActivity;
@@ -57,7 +64,7 @@
}
// Show dialog to require user confirmation.
- buildDialog(oldPackage, mNewPackage);
+ buildDialog(mNewPackage);
}
@Override
@@ -81,36 +88,26 @@
}
if (!DefaultDialerManager.getInstalledDialerApplications(this).contains(newPackage)) {
- Log.w(TAG, "Provided package name does not correspond to an installed Dialer "
+ Log.w(TAG, "Provided package name does not correspond to an installed Phone "
+ "application.");
return false;
}
if (!TextUtils.isEmpty(oldPackage) && TextUtils.equals(oldPackage, newPackage)) {
- Log.w(TAG, "Provided package name is already the current default Dialer application.");
+ Log.w(TAG, "Provided package name is already the current default Phone application.");
return false;
}
return true;
}
- private boolean buildDialog(String oldPackage, String newPackage) {
+ private boolean buildDialog(String newPackage) {
final PackageManager pm = getPackageManager();
- final String newPackageLabel =
- getApplicationLabelForPackageName(pm, newPackage);
+ final String newPackageLabel = getApplicationLabelForPackageName(pm, newPackage);
final AlertController.AlertParams p = mAlertParams;
- p.mTitle = getString(R.string.change_default_dialer_dialog_title);
- if (!TextUtils.isEmpty(oldPackage)) {
- String oldPackageLabel =
- getApplicationLabelForPackageName(pm, oldPackage);
- p.mMessage = getString(R.string.change_default_dialer_with_previous_app_set_text,
- newPackageLabel,
- oldPackageLabel);
- } else {
- p.mMessage = getString(R.string.change_default_dialer_no_previous_app_set_text,
- newPackageLabel);
- }
- p.mPositiveButtonText = getString(android.R.string.yes);
- p.mNegativeButtonText = getString(android.R.string.no);
+ p.mTitle = getString(R.string.change_default_dialer_dialog_title, newPackageLabel);
+ p.mMessage = getString(R.string.change_default_dialer_warning_message, newPackageLabel);
+ p.mPositiveButtonText = getString(R.string.change_default_dialer_dialog_affirmative);
+ p.mNegativeButtonText = getString(R.string.change_default_dialer_dialog_negative);
p.mPositiveButtonListener = this;
p.mNegativeButtonListener = this;
setupAlert();
diff --git a/src/com/android/server/telecom/components/TelecomService.java b/src/com/android/server/telecom/components/TelecomService.java
index a5790fd..9d846f3 100644
--- a/src/com/android/server/telecom/components/TelecomService.java
+++ b/src/com/android/server/telecom/components/TelecomService.java
@@ -36,6 +36,7 @@
import com.android.server.telecom.InCallWakeLockControllerFactory;
import com.android.server.telecom.CallAudioManager;
import com.android.server.telecom.PhoneAccountRegistrar;
+import com.android.server.telecom.PhoneNumberUtilsAdapter;
import com.android.server.telecom.PhoneNumberUtilsAdapterImpl;
import com.android.server.telecom.ProximitySensorManagerFactory;
import com.android.server.telecom.InCallWakeLockController;
@@ -79,9 +80,10 @@
@Override
public MissedCallNotifierImpl makeMissedCallNotifierImpl(
Context context,
- PhoneAccountRegistrar phoneAccountRegistrar) {
+ PhoneAccountRegistrar phoneAccountRegistrar,
+ PhoneNumberUtilsAdapter phoneNumberUtilsAdapter) {
return new MissedCallNotifierImpl(context,
- phoneAccountRegistrar);
+ phoneAccountRegistrar, phoneNumberUtilsAdapter);
}
},
new CallerInfoAsyncQueryFactory() {
diff --git a/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java b/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
index 1e97695..3786724 100644
--- a/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
+++ b/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
@@ -34,6 +34,7 @@
import com.android.server.telecom.Log;
import com.android.server.telecom.MissedCallNotifier;
import com.android.server.telecom.PhoneAccountRegistrar;
+import com.android.server.telecom.PhoneNumberUtilsAdapter;
import com.android.server.telecom.R;
import com.android.server.telecom.Runnable;
import com.android.server.telecom.TelecomBroadcastIntentProcessor;
@@ -93,7 +94,8 @@
public interface MissedCallNotifierImplFactory {
MissedCallNotifier makeMissedCallNotifierImpl(Context context,
- PhoneAccountRegistrar phoneAccountRegistrar);
+ PhoneAccountRegistrar phoneAccountRegistrar,
+ PhoneNumberUtilsAdapter phoneNumberUtilsAdapter);
}
public interface NotificationBuilderFactory {
@@ -132,20 +134,25 @@
private final NotificationManager mNotificationManager;
private final NotificationBuilderFactory mNotificationBuilderFactory;
private final ComponentName mNotificationComponent;
+ private final PhoneNumberUtilsAdapter mPhoneNumberUtilsAdapter;
private UserHandle mCurrentUserHandle;
// Used to track the number of missed calls.
private ConcurrentMap<UserHandle, AtomicInteger> mMissedCallCounts;
- public MissedCallNotifierImpl(Context context, PhoneAccountRegistrar phoneAccountRegistrar) {
- this(context, phoneAccountRegistrar, new DefaultNotificationBuilderFactory());
+ public MissedCallNotifierImpl(Context context, PhoneAccountRegistrar phoneAccountRegistrar,
+ PhoneNumberUtilsAdapter phoneNumberUtilsAdapter) {
+ this(context, phoneAccountRegistrar, phoneNumberUtilsAdapter,
+ new DefaultNotificationBuilderFactory());
}
public MissedCallNotifierImpl(Context context,
PhoneAccountRegistrar phoneAccountRegistrar,
+ PhoneNumberUtilsAdapter phoneNumberUtilsAdapter,
NotificationBuilderFactory notificationBuilderFactory) {
mContext = context;
mPhoneAccountRegistrar = phoneAccountRegistrar;
+ mPhoneNumberUtilsAdapter = phoneNumberUtilsAdapter;
mNotificationManager =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
final String notificationComponent = context.getString(R.string.notification_component);
@@ -600,8 +607,9 @@
// Convert the data to a call object
Call call = new Call(Call.CALL_ID_UNKNOWN, mContext, callsManager,
lock, null, contactsAsyncHelper,
- callerInfoAsyncQueryFactory, null, null, null, null, null,
- Call.CALL_DIRECTION_INCOMING, false, false);
+ callerInfoAsyncQueryFactory, mPhoneNumberUtilsAdapter, null,
+ null, null, null, Call.CALL_DIRECTION_INCOMING, false,
+ false);
call.setDisconnectCause(
new DisconnectCause(DisconnectCause.MISSED));
call.setState(CallState.DISCONNECTED, "throw away call");
diff --git a/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java b/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
index 2ac9c50..24c59ff 100644
--- a/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
@@ -36,6 +36,7 @@
import com.android.server.telecom.Constants;
import com.android.server.telecom.MissedCallNotifier;
import com.android.server.telecom.PhoneAccountRegistrar;
+import com.android.server.telecom.PhoneNumberUtilsAdapterImpl;
import com.android.server.telecom.TelecomBroadcastIntentProcessor;
import com.android.server.telecom.components.TelecomBroadcastReceiver;
import com.android.server.telecom.ui.MissedCallNotifierImpl;
@@ -166,7 +167,7 @@
makeNotificationBuilderFactory(builders);
MissedCallNotifier missedCallNotifier = new MissedCallNotifierImpl(mContext,
- mPhoneAccountRegistrar, fakeBuilderFactory);
+ mPhoneAccountRegistrar, new PhoneNumberUtilsAdapterImpl(), fakeBuilderFactory);
missedCallNotifier.showMissedCallNotification(fakeCall);
missedCallNotifier.showMissedCallNotification(fakeCall);
@@ -315,7 +316,7 @@
makeNotificationBuilderFactory(builder1);
MissedCallNotifier missedCallNotifier = new MissedCallNotifierImpl(mContext,
- mPhoneAccountRegistrar, fakeBuilderFactory);
+ mPhoneAccountRegistrar, new PhoneNumberUtilsAdapterImpl(), fakeBuilderFactory);
PhoneAccount phoneAccount = makePhoneAccount(PRIMARY_USER, NO_CAPABILITY);
Call fakeCall =
@@ -374,7 +375,7 @@
private MissedCallNotifier makeMissedCallNotifier(
NotificationBuilderFactory fakeBuilderFactory, UserHandle currentUser) {
MissedCallNotifier missedCallNotifier = new MissedCallNotifierImpl(mContext,
- mPhoneAccountRegistrar, fakeBuilderFactory);
+ mPhoneAccountRegistrar, new PhoneNumberUtilsAdapterImpl(), fakeBuilderFactory);
missedCallNotifier.setCurrentUserHandle(currentUser);
return missedCallNotifier;
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index 9c47d3f..c8a1285 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -349,7 +349,8 @@
new MissedCallNotifierImplFactory() {
@Override
public MissedCallNotifier makeMissedCallNotifierImpl(Context context,
- PhoneAccountRegistrar phoneAccountRegistrar) {
+ PhoneAccountRegistrar phoneAccountRegistrar,
+ PhoneNumberUtilsAdapter phoneNumberUtilsAdapter) {
return mMissedCallNotifier;
}
},
@@ -669,6 +670,8 @@
eq(false)/*isIncoming*/, anyBoolean());
// Wait for handleCreateConnectionComplete
waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
+ // Wait for the callback in ConnectionService#onAdapterAttached to execute.
+ waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
assertEquals(startingNumCalls + 1, mInCallServiceFixtureX.mCallById.size());
assertEquals(startingNumCalls + 1, mInCallServiceFixtureY.mCallById.size());