Adds alternative spam words for non-english speaking countries.

This CL adds alternative spam words and code for using these words in an experiment.

Test: Tap, Unit tests where alterntive experiment is provided and not provided.
PiperOrigin-RevId: 197444892
Change-Id: Iff042966f1728ac571699085f07d1325e756dd36
diff --git a/java/com/android/incallui/spam/SpamAlternativeExperimentUtil.java b/java/com/android/incallui/spam/SpamAlternativeExperimentUtil.java
new file mode 100644
index 0000000..52eadcf
--- /dev/null
+++ b/java/com/android/incallui/spam/SpamAlternativeExperimentUtil.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.incallui.spam;
+
+import android.content.Context;
+import com.android.dialer.common.LogUtil;
+import com.android.dialer.configprovider.ConfigProviderBindings;
+
+/** Returns resource id based on experiment number. */
+public final class SpamAlternativeExperimentUtil {
+
+  /**
+   * Returns the resource id using a resource name for an experiment where we want to use
+   * alternative words for the keyword spam.
+   */
+  public static int getResourceIdByName(String resourceName, Context context) {
+    long experiment =
+        ConfigProviderBindings.get(context).getLong("experiment_for_alternative_spam_word", 230150);
+    LogUtil.i(
+        "SpamAlternativeExperimentUtil.getResourceIdByName", "using experiment %d", experiment);
+    String modifiedResourceName = resourceName;
+    if (experiment != 230150) {
+      modifiedResourceName = resourceName + "_" + experiment;
+    }
+    int resourceId =
+        context
+            .getResources()
+            .getIdentifier(modifiedResourceName, "string", context.getPackageName());
+    if (resourceId == 0) {
+      LogUtil.i(
+          "SpamAlternativeExperimentUtil.getResourceIdByName",
+          "not found experiment %d",
+          experiment);
+      return context.getResources().getIdentifier(resourceName, "string", context.getPackageName());
+    }
+    return resourceId;
+  }
+}
diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java
index 350dd60..d030555 100644
--- a/java/com/android/incallui/spam/SpamCallListListener.java
+++ b/java/com/android/incallui/spam/SpamCallListListener.java
@@ -277,11 +277,15 @@
     Notification.Builder notificationBuilder =
         createAfterCallNotificationBuilder(call)
             .setContentText(
-                context.getString(R.string.spam_notification_non_spam_call_collapsed_text))
+                context.getString(
+                    SpamAlternativeExperimentUtil.getResourceIdByName(
+                        "spam_notification_non_spam_call_collapsed_text", context)))
             .setStyle(
                 new Notification.BigTextStyle()
                     .bigText(
-                        context.getString(R.string.spam_notification_non_spam_call_expanded_text)))
+                        context.getString(
+                            SpamAlternativeExperimentUtil.getResourceIdByName(
+                                "spam_notification_non_spam_call_expanded_text", context))))
             // Add contact
             .addAction(
                 new Notification.Action.Builder(
@@ -392,12 +396,17 @@
     Notification.Builder notificationBuilder =
         createAfterCallNotificationBuilder(call)
             .setLargeIcon(Icon.createWithResource(context, R.drawable.spam_notification_icon))
-            .setContentText(context.getString(R.string.spam_notification_spam_call_collapsed_text))
+            .setContentText(
+                context.getString(
+                    SpamAlternativeExperimentUtil.getResourceIdByName(
+                        "spam_notification_spam_call_collapsed_text", context)))
             // Not spam
             .addAction(
                 new Notification.Action.Builder(
                         R.drawable.quantum_ic_close_vd_theme_24,
-                        context.getString(R.string.spam_notification_was_not_spam_action_text),
+                        context.getString(
+                            SpamAlternativeExperimentUtil.getResourceIdByName(
+                                "spam_notification_was_not_spam_action_text", context)),
                         createNotSpamPendingIntent(call))
                     .build())
             // Block/report spam
@@ -408,11 +417,16 @@
                         createBlockReportSpamPendingIntent(call))
                     .build())
             .setContentTitle(
-                context.getString(R.string.spam_notification_title, getDisplayNumber(call)));
+                context.getString(
+                    SpamAlternativeExperimentUtil.getResourceIdByName(
+                        "spam_notification_title", context),
+                    getDisplayNumber(call)));
     DialerNotificationManager.notify(
         context, getNotificationTagForCall(call), NOTIFICATION_ID, notificationBuilder.build());
   }
 
+
+
   /**
    * Creates a pending intent for block/report spam action. If enabled, this intent is forwarded to
    * the {@link SpamNotificationActivity}, otherwise to the {@link SpamNotificationService}.
diff --git a/java/com/android/incallui/spam/SpamNotificationActivity.java b/java/com/android/incallui/spam/SpamNotificationActivity.java
index 37755fc..4c0c67c 100644
--- a/java/com/android/incallui/spam/SpamNotificationActivity.java
+++ b/java/com/android/incallui/spam/SpamNotificationActivity.java
@@ -406,7 +406,9 @@
           .setCancelable(false)
           .setTitle(
               getString(
-                  R.string.spam_notification_title, getFormattedNumber(number, applicationContext)))
+                  SpamAlternativeExperimentUtil.getResourceIdByName(
+                      "spam_notification_title", applicationContext),
+                  getFormattedNumber(number, applicationContext)))
           .setNeutralButton(
               getString(R.string.spam_notification_action_dismiss),
               new DialogInterface.OnClickListener() {
@@ -428,7 +430,9 @@
                 }
               })
           .setNegativeButton(
-              getString(R.string.spam_notification_was_not_spam_action_text),
+              getString(
+                  SpamAlternativeExperimentUtil.getResourceIdByName(
+                      "spam_notification_was_not_spam_action_text", applicationContext)),
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
@@ -494,7 +498,10 @@
           .setTitle(
               getString(R.string.non_spam_notification_title, getFormattedNumber(number, context)))
           .setCancelable(false)
-          .setMessage(getString(R.string.spam_notification_non_spam_call_expanded_text))
+          .setMessage(
+              getString(
+                  SpamAlternativeExperimentUtil.getResourceIdByName(
+                      "spam_notification_non_spam_call_expanded_text", context)))
           .setNeutralButton(
               getString(R.string.spam_notification_action_dismiss),
               new DialogInterface.OnClickListener() {
@@ -514,7 +521,9 @@
                 }
               })
           .setNegativeButton(
-              getString(R.string.spam_notification_dialog_block_report_spam_action_text),
+              getString(
+                  SpamAlternativeExperimentUtil.getResourceIdByName(
+                      "spam_notification_dialog_block_report_spam_action_text", context)),
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
diff --git a/java/com/android/incallui/spam/res/values/strings.xml b/java/com/android/incallui/spam/res/values/strings.xml
index e893f2a..7626754 100644
--- a/java/com/android/incallui/spam/res/values/strings.xml
+++ b/java/com/android/incallui/spam/res/values/strings.xml
@@ -44,6 +44,97 @@
   <!-- Text for the blocking spam action in the after call prompt. [CHAR LIMIT=40] -->
   <string name="spam_notification_block_spam_action_text">Yes, block number</string>
 
+  <!-- Strings for 'junk' spam word alternative-->
+  <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_title_230151">Was <xliff:g id="number">%1$s</xliff:g> a junk caller?</string>
+  <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_block_report_toast_text_230151"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as junk.</string>
+  <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_not_spam_toast_text_230151">Call from <xliff:g id="number">%1$s</xliff:g> reported as not junk.</string>
+  <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230151">Tap to add to contacts or block junk number.</string>
+  <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] -->
+  <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230151">This is the first time this number called you. If this call was junk, you can block this number and report it.</string>
+  <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_spam_call_collapsed_text_230151">Tap to report as not junk or block it</string>
+  <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230151">Block &amp; report junk</string>
+  <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_was_not_spam_action_text_230151">No, not junk</string>
+
+  <!-- Strings for 'junk/spam' spam word alternative-->
+  <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_title_230152">Was <xliff:g id="number">%1$s</xliff:g> a junk/spam caller?</string>
+  <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_block_report_toast_text_230152"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as junk/spam.</string>
+  <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_not_spam_toast_text_230152">Call from <xliff:g id="number">%1$s</xliff:g> reported as not junk/spam.</string>
+  <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230152">Tap to add to contacts or block junk/spam number.</string>
+  <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] -->
+  <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230152">This is the first time this number called you. If this call was junk/spam, you can block this number and report it.</string>
+  <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_spam_call_collapsed_text_230152">Tap to report as not junk/spam or block it</string>
+  <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230152">Block &amp; report junk/spam</string>
+  <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_was_not_spam_action_text_230152">No, not junk/spam</string>
+
+  <!-- Strings for 'unwanted' spam word alternative-->
+  <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_title_230153">Was <xliff:g id="number">%1$s</xliff:g> an unwanted caller?</string>
+  <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_block_report_toast_text_230153"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as unwanted.</string>
+  <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_not_spam_toast_text_230153">Call from <xliff:g id="number">%1$s</xliff:g> reported as useful.</string>
+  <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230153">Tap to add to contacts or block unwanted number.</string>
+  <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] -->
+  <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230153">This is the first time this number called you. If this call was unwanted, you can block this number and report it.</string>
+  <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_spam_call_collapsed_text_230153">Tap to report as useful or block it</string>
+  <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230153">Block &amp; report unwanted</string>
+  <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_was_not_spam_action_text_230153">No, not unwanted</string>
+
+  <!-- Strings for 'spam/unwanted' spam word alternative-->
+  <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_title_230154">Was <xliff:g id="number">%1$s</xliff:g> a spam/unwanted caller?</string>
+  <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_block_report_toast_text_230154"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as spam/unwanted.</string>
+  <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_not_spam_toast_text_230154">Call from <xliff:g id="number">%1$s</xliff:g> reported as not spam/unwanted.</string>
+  <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230154">Tap to add to contacts or block spam/unwanted number.</string>
+  <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] -->
+  <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230154">This is the first time this number called you. If this call was spam/unwanted, you can block this number and report it.</string>
+  <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_spam_call_collapsed_text_230154">Tap to report as not spam/unwanted or block it</string>
+  <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230154">Block &amp; report spam/unwanted</string>
+  <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_was_not_spam_action_text_230154">No, not spam/unwanted</string>
+
+  <!-- Strings for 'junk/unwanted' spam word alternative-->
+  <!-- Title for the notification to the user after a call from an spammer ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_title_230155">Was <xliff:g id="number">%1$s</xliff:g> a junk/unwanted caller?</string>
+  <!-- Text for the toast shown after the user presses block/report spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_block_report_toast_text_230155"><xliff:g id="number">%1$s</xliff:g> blocked and call was reported as junk/unwanted.</string>
+  <!-- Text for the toast shown after the user presses not spam. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_not_spam_toast_text_230155">Call from <xliff:g id="number">%1$s</xliff:g> reported as not junk/unwanted.</string>
+  <!-- Text displayed in the collapsed notification to the user after a non-spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_non_spam_call_collapsed_text_230155">Tap to add to contacts or block junk/unwanted number.</string>
+  <!-- Text displayed in the expanded notification to the user after a non-spam call ends. [CHAR LIMIT=NONE] -->
+  <string translatable="false" name="spam_notification_non_spam_call_expanded_text_230155">This is the first time this number called you. If this call was junk/unwanted, you can block this number and report it.</string>
+  <!-- Text displayed in the collapsed notification to the user after a spam call ends. [CHAR LIMIT=100] -->
+  <string translatable="false" name="spam_notification_spam_call_collapsed_text_230155">Tap to report as not junk/unwanted or block it</string>
+  <!-- Text for the blocking and reporting spam action in the after call dialog. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_dialog_block_report_spam_action_text_230155">Block &amp; report junk/unwanted</string>
+  <!-- Text for the marking a call as not spam in the after call prompt. [CHAR LIMIT=40] -->
+  <string translatable="false" name="spam_notification_was_not_spam_action_text_230155">No, not junk/unwanted</string>
+
+
   <!-- Label for "Dismiss" dialog action. [CHAR LIMIT=12] -->
   <string name="spam_notification_action_dismiss">Dismiss</string>