Adds a warning to the Default Phone App Dialog
This change adds a warning label to the Dialog that is displayed to the
user when an Intent is sent to Telecom to change the default Phone app.
Bug: 29278652
Change-Id: I5ff207bd2721822c400019cee73e1809ec15f5fe
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/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();