From 40fc026d32621bc7130051f63a2e8de7663aef88 Mon Sep 17 00:00:00 2001 From: Weilin Xu Date: Thu, 17 Oct 2024 10:30:30 -0700 Subject: Add language and remove scope in radio alert Add language field for radio alert to indicate the language of alert message. Remove scope since its value is always public in radio alert standard. Bug: 361348719 Flag: android.hardware.radio.hd_radio_emergency_alert_system Test: atest android.hardware.radio.RadioManagerTest Change-Id: I6a3e59249126767f344bb59e58d6d69a219e15cc --- core/java/android/hardware/radio/RadioAlert.java | 40 +++++++++++++++--------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/core/java/android/hardware/radio/RadioAlert.java b/core/java/android/hardware/radio/RadioAlert.java index b55dcd82ef7b..9b93e73555f0 100644 --- a/core/java/android/hardware/radio/RadioAlert.java +++ b/core/java/android/hardware/radio/RadioAlert.java @@ -332,6 +332,7 @@ public final class RadioAlert implements Parcelable { private final int mCertainty; private final String mTextualMessage; private final List mAreaList; + @Nullable private final String mLanguage; /** * Constructor for alert info. @@ -343,17 +344,19 @@ public final class RadioAlert implements Parcelable { * @param textualMessage Textual descriptions of the subject event * @param areaList The array of geographic areas to which the alert info segment in which * it appears applies + * @param language The optional language field of the alert info * @hide */ public AlertInfo(@NonNull List categoryList, int urgency, - int severity, int certainty, - String textualMessage, @NonNull List areaList) { + int severity, int certainty, String textualMessage, + @NonNull List areaList, @Nullable String language) { mCategoryList = Objects.requireNonNull(categoryList, "Category list can not be null"); mUrgency = urgency; mSeverity = severity; mCertainty = certainty; mTextualMessage = textualMessage; mAreaList = Objects.requireNonNull(areaList, "Area list can not be null"); + mLanguage = language; } private AlertInfo(Parcel in) { @@ -364,6 +367,12 @@ public final class RadioAlert implements Parcelable { mTextualMessage = in.readString8(); mAreaList = new ArrayList<>(); in.readTypedList(mAreaList, AlertArea.CREATOR); + boolean hasLanguage = in.readBoolean(); + if (hasLanguage) { + mLanguage = in.readString8(); + } else { + mLanguage = null; + } } public static final @NonNull Creator CREATOR = new Creator() { @@ -391,6 +400,12 @@ public final class RadioAlert implements Parcelable { dest.writeInt(mCertainty); dest.writeString8(mTextualMessage); dest.writeTypedList(mAreaList); + if (mLanguage == null) { + dest.writeBoolean(false); + } else { + dest.writeBoolean(true); + dest.writeString8(mLanguage); + } } @NonNull @@ -398,13 +413,14 @@ public final class RadioAlert implements Parcelable { public String toString() { return "AlertInfo [categoryList=" + mCategoryList + ", urgency=" + mUrgency + ", severity=" + mSeverity + ", certainty=" + mCertainty - + ", textualMessage=" + mTextualMessage + ", areaList=" + mAreaList + "]"; + + ", textualMessage=" + mTextualMessage + ", areaList=" + mAreaList + + ", language=" + mLanguage + "]"; } @Override public int hashCode() { return Objects.hash(mCategoryList, mUrgency, mSeverity, mCertainty, mTextualMessage, - mAreaList); + mAreaList, mLanguage); } @Override @@ -419,14 +435,14 @@ public final class RadioAlert implements Parcelable { return mCategoryList.equals(other.mCategoryList) && mUrgency == other.mUrgency && mSeverity == other.mSeverity && mCertainty == other.mCertainty && mTextualMessage.equals(other.mTextualMessage) - && mAreaList.equals(other.mAreaList); + && mAreaList.equals(other.mAreaList) + && Objects.equals(mLanguage, other.mLanguage); } } private final int mStatus; private final int mMessageType; private final List mInfoList; - private final int mScope; /** * Constructor of radio alert message. @@ -434,15 +450,13 @@ public final class RadioAlert implements Parcelable { * @param status Status of alert message * @param messageType Message type of alert message * @param infoList List of alert info - * @param scope Scope of alert message * @hide */ public RadioAlert(int status, int messageType, - @NonNull List infoList, int scope) { + @NonNull List infoList) { mStatus = status; mMessageType = messageType; mInfoList = Objects.requireNonNull(infoList, "Alert info list can not be null"); - mScope = scope; } private RadioAlert(Parcel in) { @@ -450,7 +464,6 @@ public final class RadioAlert implements Parcelable { mMessageType = in.readInt(); mInfoList = in.readParcelableList(new ArrayList<>(), AlertInfo.class.getClassLoader(), AlertInfo.class); - mScope = in.readInt(); } @Override @@ -458,7 +471,6 @@ public final class RadioAlert implements Parcelable { dest.writeInt(mStatus); dest.writeInt(mMessageType); dest.writeParcelableList(mInfoList, /* flags= */ 0); - dest.writeInt(mScope); } @Override @@ -470,12 +482,12 @@ public final class RadioAlert implements Parcelable { @Override public String toString() { return "RadioAlert [status=" + mStatus + ", messageType=" + mMessageType - + ", infoList= " + mInfoList + ", scope=" + mScope + "]"; + + ", infoList= " + mInfoList + "]"; } @Override public int hashCode() { - return Objects.hash(mStatus, mMessageType, mInfoList, mScope); + return Objects.hash(mStatus, mMessageType, mInfoList); } @Override @@ -488,7 +500,7 @@ public final class RadioAlert implements Parcelable { } return mStatus == other.mStatus && mMessageType == other.mMessageType - && mInfoList.equals(other.mInfoList) && mScope == other.mScope; + && mInfoList.equals(other.mInfoList); } public static final @NonNull Creator CREATOR = new Creator() { -- cgit v1.2.3-59-g8ed1b