diff options
author | Jake Hamby <jhamby@google.com> | 2012-02-06 14:53:43 -0800 |
---|---|---|
committer | Jake Hamby <jhamby@google.com> | 2012-03-13 15:31:33 -0700 |
commit | 3e3c3f80a90b156ff500076f8655647dfb317acf (patch) | |
tree | 27be104fb2617213805f4da4774f2a232d655921 /core/tests | |
parent | 9dc348d75688faba645c03ecd6e72de7cecc87ba (diff) | |
download | frameworks_base-3e3c3f80a90b156ff500076f8655647dfb317acf.zip frameworks_base-3e3c3f80a90b156ff500076f8655647dfb317acf.tar.gz frameworks_base-3e3c3f80a90b156ff500076f8655647dfb317acf.tar.bz2 |
Add support for CMAS warning notifications over CDMA.
Refactor SMS Cell Broadcast support to enable receiving CMAS warning
notifications over CDMA. The CellBroadcastReceiver app must also be
updated with the corresponding change. All cell broadcasts are now
delivered as a Parcelable SmsCbMessage object in the "message" extra
of the SMS_CB_RECEIVED_ACTION or SMS_EMERGENCY_CB_RECEIVED_ACTION,
instead of as a GSM/UMTS "pdu" byte array.
Existing functionality for ETWS and CMAS alerts over GSM/UMTS continues
to be supported using the new radio-technology independent SmsCbMessage
and related objects. Test cases are added to verify that valid and
invalid broadcast data is handled appropriately.
Unit testing discovered a bug in the BitwiseOutputStream utility class
used by the added test cases. When the BitwiseOutputStream object must be
expanded (in the private possExpand() method), the mEnd field is not
updated to the new array size. This causes a new array to be allocated
on every new write, and for all data beyond the original array allocation
to be replaced with zeroes. Fixed by adding a line to possExpand() to
update mEnd. Added a test case to BitwiseStreamsTest to verify the fix.
Besides the test cases, BitwiseOutputStream is only used by BearerData in
two places, both of which allocate a sufficient initial buffer. So the
bug in BitwiseOutputStream is not critical to fix for normal operation,
but should be fixed so that the test cases using it function correctly.
Bug: 5856308
Change-Id: I201ecbf11607fd200aaae3cbb32561efabf65672
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/com/android/internal/util/BitwiseStreamsTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/tests/coretests/src/com/android/internal/util/BitwiseStreamsTest.java b/core/tests/coretests/src/com/android/internal/util/BitwiseStreamsTest.java index a304b68..306f58f 100644 --- a/core/tests/coretests/src/com/android/internal/util/BitwiseStreamsTest.java +++ b/core/tests/coretests/src/com/android/internal/util/BitwiseStreamsTest.java @@ -133,4 +133,25 @@ public class BitwiseStreamsTest extends AndroidTestCase { long end = android.os.SystemClock.elapsedRealtime(); Log.d(LOG_TAG, "repeated encode-decode took " + (end - start) + " ms"); } + + @SmallTest + public void testExpandArray() throws Exception { + Random random = new Random(); + int iterations = 10000; + int[] sizeArr = new int[iterations]; + int[] valueArr = new int[iterations]; + BitwiseOutputStream outStream = new BitwiseOutputStream(8); + for (int i = 0; i < iterations; i++) { + int x = random.nextInt(); + int size = (x & 0x07) + 1; + int value = x & (-1 >>> (32 - size)); + sizeArr[i] = size; + valueArr[i] = value; + outStream.write(size, value); + } + BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray()); + for (int i = 0; i < iterations; i++) { + assertEquals(valueArr[i], inStream.read(sizeArr[i])); + } + } } |