Search in sources :

Example 26 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ParanoidAndroid.

the class BitwiseStreamsTest method testFour.

@SmallTest
public void testFour() throws Exception {
    int offset = 7;
    byte[] inBuf = HexDump.hexStringToByteArray("00031040900112488ea794e0");
    BitwiseOutputStream outStream = new BitwiseOutputStream(30);
    outStream.skip(offset);
    for (int i = 0; i < inBuf.length; i++) {
        outStream.write(5, inBuf[i] >>> 3);
        outStream.write(3, inBuf[i] & 0x07);
    }
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    inStream.skip(offset);
    byte[] inBufDup = new byte[inBuf.length];
    for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
    assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 27 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ParanoidAndroid.

the class BitwiseStreamsTest method testSix.

@SmallTest
public void testSix() throws Exception {
    int num_runs = 10;
    long start = android.os.SystemClock.elapsedRealtime();
    for (int run = 0; run < num_runs; run++) {
        int offset = run % 8;
        byte[] inBuf = HexDump.hexStringToByteArray("00031040900112488ea794e0");
        BitwiseOutputStream outStream = new BitwiseOutputStream(30);
        outStream.skip(offset);
        for (int i = 0; i < inBuf.length; i++) {
            outStream.write(5, inBuf[i] >>> 3);
            outStream.write(3, inBuf[i] & 0x07);
        }
        BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
        inStream.skip(offset);
        byte[] inBufDup = new byte[inBuf.length];
        for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
        assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
    }
    long end = android.os.SystemClock.elapsedRealtime();
    Log.d(LOG_TAG, "repeated encode-decode took " + (end - start) + " ms");
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 28 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project platform_frameworks_base by android.

the class BitwiseStreamsTest method testTwo.

@SmallTest
public void testTwo() throws Exception {
    int offset = 3;
    byte[] inBuf = HexDump.hexStringToByteArray("11d4f29c0e9ad3c36e72584e064d9b53");
    BitwiseOutputStream outStream = new BitwiseOutputStream(30);
    outStream.skip(offset);
    for (int i = 0; i < inBuf.length; i++) outStream.write(8, inBuf[i]);
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    inStream.skip(offset);
    byte[] inBufDup = new byte[inBuf.length];
    for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
    assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 29 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project platform_frameworks_base by android.

the class BitwiseStreamsTest method testSix.

@SmallTest
public void testSix() throws Exception {
    int num_runs = 10;
    long start = android.os.SystemClock.elapsedRealtime();
    for (int run = 0; run < num_runs; run++) {
        int offset = run % 8;
        byte[] inBuf = HexDump.hexStringToByteArray("00031040900112488ea794e0");
        BitwiseOutputStream outStream = new BitwiseOutputStream(30);
        outStream.skip(offset);
        for (int i = 0; i < inBuf.length; i++) {
            outStream.write(5, inBuf[i] >>> 3);
            outStream.write(3, inBuf[i] & 0x07);
        }
        BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
        inStream.skip(offset);
        byte[] inBufDup = new byte[inBuf.length];
        for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
        assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
    }
    long end = android.os.SystemClock.elapsedRealtime();
    Log.d(LOG_TAG, "repeated encode-decode took " + (end - start) + " ms");
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 30 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project platform_frameworks_base by android.

the class BitwiseStreamsTest method testFour.

@SmallTest
public void testFour() throws Exception {
    int offset = 7;
    byte[] inBuf = HexDump.hexStringToByteArray("00031040900112488ea794e0");
    BitwiseOutputStream outStream = new BitwiseOutputStream(30);
    outStream.skip(offset);
    for (int i = 0; i < inBuf.length; i++) {
        outStream.write(5, inBuf[i] >>> 3);
        outStream.write(3, inBuf[i] & 0x07);
    }
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    inStream.skip(offset);
    byte[] inBufDup = new byte[inBuf.length];
    for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
    assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)50 SmallTest (android.test.suitebuilder.annotation.SmallTest)45 BitwiseInputStream (com.android.internal.util.BitwiseInputStream)42 Random (java.util.Random)13 CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)5 FlakyTest (android.support.test.filters.FlakyTest)3 Test (org.junit.Test)3 CdmaSmsCbProgramData (android.telephony.cdma.CdmaSmsCbProgramData)2 SmsCbMessage (android.telephony.SmsCbMessage)1