summaryrefslogtreecommitdiffstats
path: root/telephony/java/com
diff options
context:
space:
mode:
authorJake Hamby <jhamby@google.com>2011-06-07 16:32:10 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-06-07 16:32:10 -0700
commit22165bb54af1cd3cb636c1d65da7c643d854c385 (patch)
tree2c920b3c38596abb4b5cec99297413b08fec967e /telephony/java/com
parent229d3a0cbce70db82003705abf6844deec136d20 (diff)
parentae62b7b0bca9c46dea30ee81a7aada3e7576638b (diff)
downloadframeworks_base-22165bb54af1cd3cb636c1d65da7c643d854c385.zip
frameworks_base-22165bb54af1cd3cb636c1d65da7c643d854c385.tar.gz
frameworks_base-22165bb54af1cd3cb636c1d65da7c643d854c385.tar.bz2
am ae62b7b0: resolved conflicts for merge of 66040bbb to gingerbread-plus-aosp
* commit 'ae62b7b0bca9c46dea30ee81a7aada3e7576638b': Fixes for SMS Cell Broadcast support.
Diffstat (limited to 'telephony/java/com')
-rw-r--r--telephony/java/com/android/internal/telephony/IntRangeManager.java122
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java38
2 files changed, 101 insertions, 59 deletions
diff --git a/telephony/java/com/android/internal/telephony/IntRangeManager.java b/telephony/java/com/android/internal/telephony/IntRangeManager.java
index 889e2b1..970bc44 100644
--- a/telephony/java/com/android/internal/telephony/IntRangeManager.java
+++ b/telephony/java/com/android/internal/telephony/IntRangeManager.java
@@ -290,54 +290,53 @@ public abstract class IntRangeManager {
return true;
} else {
// find last range that can coalesce into the new combined range
- for (int endIndex = startIndex+1; endIndex < len; endIndex++) {
- IntRange endRange = mRanges.get(endIndex);
- if ((endId + 1) < endRange.startId) {
- // add range from range.endId+1 to endId,
- // values from startId to range.endId are already enabled
- if (tryAddSingleRange(range.endId + 1, endId, true)) {
- range.endId = endId;
- // insert new ClientRange in place
- range.insert(new ClientRange(startId, endId, client));
- // coalesce range with following ranges up to endIndex-1
- // remove each range after adding its elements, so the index
- // of the next range to join is always startIndex+1.
- // i is the index if no elements were removed: we only care
- // about the number of loop iterations, not the value of i.
- int joinIndex = startIndex + 1;
- for (int i = joinIndex; i < endIndex; i++) {
- IntRange joinRange = mRanges.get(joinIndex);
- range.clients.addAll(joinRange.clients);
- mRanges.remove(joinRange);
- }
- return true;
- } else {
- return false; // failed to update radio
- }
- } else if (endId <= endRange.endId) {
- // add range from range.endId+1 to start of last overlapping range,
- // values from endRange.startId to endId are already enabled
- if (tryAddSingleRange(range.endId + 1, endRange.startId - 1, true)) {
- range.endId = endRange.endId;
- // insert new ClientRange in place
- range.insert(new ClientRange(startId, endId, client));
- // coalesce range with following ranges up to endIndex
- // remove each range after adding its elements, so the index
- // of the next range to join is always startIndex+1.
- // i is the index if no elements were removed: we only care
- // about the number of loop iterations, not the value of i.
- int joinIndex = startIndex + 1;
- for (int i = joinIndex; i <= endIndex; i++) {
- IntRange joinRange = mRanges.get(joinIndex);
- range.clients.addAll(joinRange.clients);
- mRanges.remove(joinRange);
- }
- return true;
- } else {
- return false; // failed to update radio
- }
+ int endIndex = startIndex;
+ for (int testIndex = startIndex+1; testIndex < len; testIndex++) {
+ IntRange testRange = mRanges.get(testIndex);
+ if ((endId + 1) < testRange.startId) {
+ break;
+ } else {
+ endIndex = testIndex;
+ }
+ }
+ // no adjacent IntRanges to combine
+ if (endIndex == startIndex) {
+ // add range from range.endId+1 to endId,
+ // values from startId to range.endId are already enabled
+ if (tryAddSingleRange(range.endId + 1, endId, true)) {
+ range.endId = endId;
+ range.insert(new ClientRange(startId, endId, client));
+ return true;
+ } else {
+ return false; // failed to update radio
}
}
+ // get last range to coalesce into start range
+ IntRange endRange = mRanges.get(endIndex);
+ // Values from startId to range.endId have already been enabled.
+ // if endId > endRange.endId, then enable range from range.endId+1 to endId,
+ // else enable range from range.endId+1 to endRange.startId-1, because
+ // values from endRange.startId to endId have already been added.
+ int newRangeEndId = (endId <= endRange.endId) ? endRange.startId - 1 : endId;
+ if (tryAddSingleRange(range.endId + 1, newRangeEndId, true)) {
+ range.endId = endId;
+ // insert new ClientRange in place
+ range.insert(new ClientRange(startId, endId, client));
+ // coalesce range with following ranges up to endIndex-1
+ // remove each range after adding its elements, so the index
+ // of the next range to join is always startIndex+1 (joinIndex).
+ // i is the index if no elements had been removed: we only care
+ // about the number of loop iterations, not the value of i.
+ int joinIndex = startIndex + 1;
+ for (int i = joinIndex; i < endIndex; i++) {
+ IntRange joinRange = mRanges.get(joinIndex);
+ range.clients.addAll(joinRange.clients);
+ mRanges.remove(joinRange);
+ }
+ return true;
+ } else {
+ return false; // failed to update radio
+ }
}
}
}
@@ -435,6 +434,8 @@ public abstract class IntRangeManager {
addRange(range.startId, nextStartId - 1, false);
rangeCopy.startId = nextStartId;
}
+ // init largestEndId
+ largestEndId = clients.get(1).endId;
}
// go through remaining ClientRanges, creating new IntRanges when
@@ -442,7 +443,6 @@ public abstract class IntRangeManager {
// remove the original IntRange and append newRanges to mRanges.
// Otherwise, leave the original IntRange in mRanges and return false.
ArrayList<IntRange> newRanges = new ArrayList<IntRange>();
- newRanges.add(rangeCopy);
IntRange currentRange = rangeCopy;
for (int nextIndex = crIndex + 1; nextIndex < crLength; nextIndex++) {
@@ -454,6 +454,7 @@ public abstract class IntRangeManager {
}
addRange(largestEndId + 1, nextCr.startId - 1, false);
currentRange.endId = largestEndId;
+ newRanges.add(currentRange);
currentRange = new IntRange(nextCr);
} else {
currentRange.clients.add(nextCr);
@@ -463,18 +464,25 @@ public abstract class IntRangeManager {
}
}
- if (updateStarted) {
- if (!finishUpdate()) {
- return false; // failed to update radio
- } else {
- // remove the original IntRange and insert newRanges in place.
- mRanges.remove(crIndex);
- mRanges.addAll(crIndex, newRanges);
- return true;
+ // remove any channels between largestEndId and endId
+ if (largestEndId < endId) {
+ if (!updateStarted) {
+ startUpdate();
+ updateStarted = true;
}
- } else {
- return true;
+ addRange(largestEndId + 1, endId, false);
+ currentRange.endId = largestEndId;
+ }
+ newRanges.add(currentRange);
+
+ if (updateStarted && !finishUpdate()) {
+ return false; // failed to update radio
}
+
+ // replace the original IntRange with newRanges
+ mRanges.remove(i);
+ mRanges.addAll(i, newRanges);
+ return true;
} else {
// not the ClientRange to remove; save highest end ID seen so far
if (cr.endId > largestEndId) {
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java b/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java
index ea4d684..8e6b79b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java
@@ -35,6 +35,11 @@ public class SmsCbHeader implements SmsCbConstants {
public static final int FORMAT_UMTS = 2;
/**
+ * GSM pdu format, as defined in 3gpp TS 23.041, section 9.4.1.3
+ */
+ public static final int FORMAT_ETWS_PRIMARY = 3;
+
+ /**
* Message type value as defined in 3gpp TS 25.324, section 11.1.
*/
private static final int MESSAGE_TYPE_CBS_MESSAGE = 1;
@@ -42,7 +47,12 @@ public class SmsCbHeader implements SmsCbConstants {
/**
* Length of GSM pdus
*/
- private static final int PDU_LENGTH_GSM = 88;
+ public static final int PDU_LENGTH_GSM = 88;
+
+ /**
+ * Maximum length of ETWS primary message GSM pdus
+ */
+ public static final int PDU_LENGTH_ETWS = 56;
public final int geographicalScope;
@@ -60,12 +70,30 @@ public class SmsCbHeader implements SmsCbConstants {
public final int format;
+ public final boolean etwsEmergencyUserAlert;
+
+ public final boolean etwsPopup;
+
+ public final int etwsWarningType;
+
public SmsCbHeader(byte[] pdu) throws IllegalArgumentException {
if (pdu == null || pdu.length < PDU_HEADER_LENGTH) {
throw new IllegalArgumentException("Illegal PDU");
}
- if (pdu.length <= PDU_LENGTH_GSM) {
+ if (pdu.length <= PDU_LENGTH_ETWS) {
+ format = FORMAT_ETWS_PRIMARY;
+ geographicalScope = -1; //not applicable
+ messageCode = -1;
+ updateNumber = -1;
+ messageIdentifier = ((pdu[2] & 0xff) << 8) | (pdu[3] & 0xff);
+ dataCodingScheme = -1;
+ pageIndex = -1;
+ nrOfPages = -1;
+ etwsEmergencyUserAlert = (pdu[4] & 0x1) != 0;
+ etwsPopup = (pdu[5] & 0x80) != 0;
+ etwsWarningType = (pdu[4] & 0xfe) >> 1;
+ } else if (pdu.length <= PDU_LENGTH_GSM) {
// GSM pdus are no more than 88 bytes
format = FORMAT_GSM;
geographicalScope = (pdu[0] & 0xc0) >> 6;
@@ -85,6 +113,9 @@ public class SmsCbHeader implements SmsCbConstants {
this.pageIndex = pageIndex;
this.nrOfPages = nrOfPages;
+ etwsEmergencyUserAlert = false;
+ etwsPopup = false;
+ etwsWarningType = -1;
} else {
// UMTS pdus are always at least 90 bytes since the payload includes
// a number-of-pages octet and also one length octet per page
@@ -107,6 +138,9 @@ public class SmsCbHeader implements SmsCbConstants {
// actual payload may contain several pages.
pageIndex = 1;
nrOfPages = 1;
+ etwsEmergencyUserAlert = false;
+ etwsPopup = false;
+ etwsWarningType = -1;
}
}