summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryoungtaecha <youngtaecha@google.com>2021-10-08 02:16:05 +0000
committerYoungtae Cha <youngtaecha@google.com>2021-10-08 03:13:56 +0000
commit5213977b0dd64b06aba186c98fdb9011f5e5eb91 (patch)
tree21ced4f311a600208f77d091269356b874adf4a1
parent90db87e81358998772a996c5d5ee2dc52df74cf8 (diff)
downloadCellBroadcastReceiver-5213977b0dd64b06aba186c98fdb9011f5e5eb91.tar.gz
Update the logic to check the language code of the channel
Restore the change for 167366175 to fix the issue of dialog title in Arabic for primary language channels Bug: 202309236 Test: Manual Change-Id: Ifdc18759d71839eae429ffd48f3181051da8e8a7
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java14
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java11
2 files changed, 23 insertions, 2 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
index 13d9fc233..00b6d688f 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
@@ -680,7 +680,19 @@ public class CellBroadcastAlertDialog extends Activity {
int titleId = CellBroadcastResources.getDialogTitleResource(context, message);
Resources res = CellBroadcastSettings.getResources(context, message.getSubscriptionId());
- String title = overrideTranslation(titleId, res, message.getLanguageCode());
+
+ CellBroadcastChannelManager channelManager = new CellBroadcastChannelManager(
+ this, message.getSubscriptionId());
+ CellBroadcastChannelRange range = channelManager
+ .getCellBroadcastChannelRangeFromMessage(message);
+ String languageCode;
+ if (range != null && !TextUtils.isEmpty(range.mLanguageCode)) {
+ languageCode = range.mLanguageCode;
+ } else {
+ languageCode = message.getLanguageCode();
+ }
+
+ String title = overrideTranslation(titleId, res, languageCode);
TextView titleTextView = findViewById(R.id.alertTitle);
if (titleTextView != null) {
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java b/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
index 830a97959..1873e923c 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
@@ -114,6 +114,9 @@ public class CellBroadcastChannelManager {
private static final String KEY_DISMISS_ON_OUTSIDE_TOUCH = "dismiss_on_outside_touch";
/** Define whether to enable this only in userdebug/eng build. */
private static final String KEY_DEBUG_BUILD_ONLY = "debug_build";
+ /** Define the ISO-639-1 language code associated with the alert message. */
+ private static final String KEY_LANGUAGE_CODE = "language";
+
/**
* Defines whether the channel needs language filter or not. True indicates that the alert
@@ -158,6 +161,8 @@ public class CellBroadcastChannelManager {
public boolean mDismissOnOutsideTouch = false;
// Whether the channels are disabled
public boolean mIsDebugBuildOnly = false;
+ // This is used to override dialog title language
+ public String mLanguageCode;
public CellBroadcastChannelRange(Context context, int subId, String channelRange) {
mAlertType = AlertType.DEFAULT;
@@ -269,6 +274,9 @@ public class CellBroadcastChannelManager {
mIsDebugBuildOnly = true;
}
break;
+ case KEY_LANGUAGE_CODE:
+ mLanguageCode = value;
+ break;
}
}
@@ -303,7 +311,8 @@ public class CellBroadcastChannelManager {
+ ",display=" + mDisplay + ",testMode=" + mTestMode + ",mAlwaysOn="
+ mAlwaysOn + ",ScreenOnDuration=" + mScreenOnDuration + ", displayIcon="
+ mDisplayIcon + "dismissOnOutsideTouch=" + mDismissOnOutsideTouch
- + ", mIsDebugBuildOnly =" + mIsDebugBuildOnly + "]";
+ + ", mIsDebugBuildOnly =" + mIsDebugBuildOnly
+ + ", languageCode=" + mLanguageCode + "]";
}
}