Format the service name with BidiFormatter

The dialog's title was shown incorrectly in RTL language when the
accessibility service name is in English while the rest of the text is
in RTL language.

Bug: 279491415
Test: manual
Change-Id: I17572c161d34eb0e4d1fa0c4cca1c23531655a38
This commit is contained in:
Chun-Ku Lin
2023-05-20 00:38:59 +00:00
parent 2db6db8804
commit a47404e14f

View File

@@ -131,18 +131,17 @@ public class AccessibilityServiceWarning {
/** Returns a {@link Dialog} to be shown to confirm that they want to disable a service. */ /** Returns a {@link Dialog} to be shown to confirm that they want to disable a service. */
public static Dialog createDisableDialog(Context context, public static Dialog createDisableDialog(Context context,
AccessibilityServiceInfo info, DialogInterface.OnClickListener listener) { AccessibilityServiceInfo info, DialogInterface.OnClickListener listener) {
final AlertDialog dialog = new AlertDialog.Builder(context) CharSequence serviceName = getServiceName(context, info);
.setTitle(context.getString(R.string.disable_service_title,
info.getResolveInfo().loadLabel(context.getPackageManager()))) return new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.disable_service_title, serviceName))
.setMessage(context.getString(R.string.disable_service_message, .setMessage(context.getString(R.string.disable_service_message,
context.getString(R.string.accessibility_dialog_button_stop), context.getString(R.string.accessibility_dialog_button_stop),
getServiceName(context, info))) serviceName))
.setCancelable(true) .setCancelable(true)
.setPositiveButton(R.string.accessibility_dialog_button_stop, listener) .setPositiveButton(R.string.accessibility_dialog_button_stop, listener)
.setNegativeButton(R.string.accessibility_dialog_button_cancel, listener) .setNegativeButton(R.string.accessibility_dialog_button_cancel, listener)
.create(); .create();
return dialog;
} }
// Get the service name and bidi wrap it to protect from bidi side effects. // Get the service name and bidi wrap it to protect from bidi side effects.