summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSridhar Dubbaka <sdubbaka@codeaurora.org>2015-10-07 08:32:43 (GMT)
committerSteve Kondik <steve@cyngn.com>2016-07-01 12:06:13 (GMT)
commit1389da58856fc53291dbe0f77e14be42e6b523a2 (patch)
tree09b014ffa110d6017aa4dacbcd7c38b8b196796c
parent9dd2dfcad8aa12f38361a12c93452df719e26f29 (diff)
downloadandroid_packages_apps_CellBroadcastReceiver-1389da58856fc53291dbe0f77e14be42e6b523a2.zip
android_packages_apps_CellBroadcastReceiver-1389da58856fc53291dbe0f77e14be42e6b523a2.tar.gz
android_packages_apps_CellBroadcastReceiver-1389da58856fc53291dbe0f77e14be42e6b523a2.tar.bz2
Fix duplicate detection for ETWS primary and secondary notifications.
Add ETWS warning info when hashing to distinguish ETWS primary and secondary notifications. Change-Id: I40b3ce70a0187a6bbc1443517669fbccda8ba6f4 CRs-Fixed: 764424
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index 8607217..98f8960 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -32,6 +32,7 @@ import android.os.SystemProperties;
import android.provider.Telephony;
import android.telephony.CellBroadcastMessage;
import android.telephony.SmsCbCmasInfo;
+import android.telephony.SmsCbEtwsInfo;
import android.telephony.SmsCbLocation;
import android.telephony.SmsCbMessage;
import android.telephony.SubscriptionManager;
@@ -74,6 +75,7 @@ public class CellBroadcastAlertService extends Service {
private final int mSerialNumber;
private final SmsCbLocation mLocation;
private final int mBodyHash;
+ private final SmsCbEtwsInfo mEtwsWarningInfo;
MessageServiceCategoryAndScope(int serviceCategory, int serialNumber,
SmsCbLocation location, int bodyHash) {
@@ -81,10 +83,23 @@ public class CellBroadcastAlertService extends Service {
mSerialNumber = serialNumber;
mLocation = location;
mBodyHash = bodyHash;
+ mEtwsWarningInfo = null;
+ }
+ MessageServiceCategoryAndScope(int serviceCategory, int serialNumber,
+ SmsCbLocation location, int bodyHash, SmsCbEtwsInfo etwsWarningInfo) {
+ mServiceCategory = serviceCategory;
+ mSerialNumber = serialNumber;
+ mLocation = location;
+ mBodyHash = bodyHash;
+ mEtwsWarningInfo = etwsWarningInfo;
}
@Override
public int hashCode() {
+ if (mEtwsWarningInfo != null) {
+ return mEtwsWarningInfo.hashCode() + mLocation.hashCode() + 5 * mServiceCategory
+ + 7 * mSerialNumber + 13 * mBodyHash;
+ }
return mLocation.hashCode() + 5 * mServiceCategory + 7 * mSerialNumber + 13 * mBodyHash;
}
@@ -95,6 +110,14 @@ public class CellBroadcastAlertService extends Service {
}
if (o instanceof MessageServiceCategoryAndScope) {
MessageServiceCategoryAndScope other = (MessageServiceCategoryAndScope) o;
+ if (mEtwsWarningInfo == null && other.mEtwsWarningInfo != null) {
+ return false;
+ } else if (mEtwsWarningInfo != null && other.mEtwsWarningInfo == null) {
+ return false;
+ } else if (mEtwsWarningInfo != null && other.mEtwsWarningInfo != null
+ && !mEtwsWarningInfo.equals(other.mEtwsWarningInfo)) {
+ return false;
+ }
return (mServiceCategory == other.mServiceCategory &&
mSerialNumber == other.mSerialNumber &&
mLocation.equals(other.mLocation) &&
@@ -105,8 +128,10 @@ public class CellBroadcastAlertService extends Service {
@Override
public String toString() {
- return "{mServiceCategory: " + mServiceCategory + " serial number: " + mSerialNumber +
- " location: " + mLocation.toString() + " body hash: " + mBodyHash + '}';
+ return "{mServiceCategory: " + mServiceCategory + " serial number: " + mSerialNumber
+ + " location: " + mLocation.toString() + " mEtwsWarningInfo: "
+ + (mEtwsWarningInfo == null ? "NULL" : mEtwsWarningInfo.toString())
+ + " body hash: " + mBodyHash +'}';
}
}
@@ -187,7 +212,9 @@ public class CellBroadcastAlertService extends Service {
// message ID of the oldest message is deleted from the list.
MessageServiceCategoryAndScope newCmasId = new MessageServiceCategoryAndScope(
message.getServiceCategory(), message.getSerialNumber(), message.getLocation(),
- hashCode);
+ hashCode, message.getEtwsWarningInfo());
+ Log.v(TAG,"newCmasId:" + newCmasId + " hash: " + newCmasId.hashCode()
+ + "body hash:" + hashCode);
// Add the new message ID to the list. It's okay if this is a duplicate message ID,
// because the list is only used for removing old message IDs from the hash set.