summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-02-28 10:10:38 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-02-28 10:10:38 -0800
commitb732b7b5e8192501360edc15fb8c6399d11fb97d (patch)
treea2fab9c785f055c9962e565896d5e4a1bdadc769 /location
parent1649d91f781445a78ce09ed5500503fd96eb9113 (diff)
parentce57a7f35344e76689d30f45964d1e37b78280cb (diff)
downloadframeworks_base-b732b7b5e8192501360edc15fb8c6399d11fb97d.zip
frameworks_base-b732b7b5e8192501360edc15fb8c6399d11fb97d.tar.gz
frameworks_base-b732b7b5e8192501360edc15fb8c6399d11fb97d.tar.bz2
am ce57a7f3: am 6504490c: am dff6b8e7: Merge "Add --non-constant-id to aapt."
* commit 'ce57a7f35344e76689d30f45964d1e37b78280cb': GpsLocationProvider: Clean up HAL initialization/cleanup sequence Fixed GSM encoded network initiated position request Ensuring thread-safe usage of DateFormat. Fixing infinite loop for zero duration. Fix for an infinite loop while scrolling lists. WAPPushManager, WAP Push over SMS message handler Add --non-constant-id to aapt.
Diffstat (limited to 'location')
-rwxr-xr-xlocation/java/com/android/internal/location/GpsNetInitiatedHandler.java67
1 files changed, 21 insertions, 46 deletions
diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
index d539833..ffc3346 100755
--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -29,6 +29,7 @@ import android.os.RemoteException;
import android.util.Log;
import com.android.internal.R;
+import com.android.internal.telephony.GsmAlphabet;
/**
* A GPS Network-initiated Handler class used by LocationManager.
@@ -288,58 +289,32 @@ public class GpsNetInitiatedHandler {
*/
static String decodeGSMPackedString(byte[] input)
{
- final char CHAR_CR = 0x0D;
- int nStridx = 0;
- int nPckidx = 0;
- int num_bytes = input.length;
- int cPrev = 0;
- int cCurr = 0;
- byte nShift;
- byte nextChar;
- byte[] stringBuf = new byte[input.length * 2];
- String result = "";
-
- while(nPckidx < num_bytes)
- {
- nShift = (byte) (nStridx & 0x07);
- cCurr = input[nPckidx++];
- if (cCurr < 0) cCurr += 256;
-
- /* A 7-bit character can be split at the most between two bytes of packed
- ** data.
- */
- nextChar = (byte) (( (cCurr << nShift) | (cPrev >> (8-nShift)) ) & 0x7F);
- stringBuf[nStridx++] = nextChar;
-
- /* Special case where the whole of the next 7-bit character fits inside
- ** the current byte of packed data.
- */
- if(nShift == 6)
- {
- /* If the next 7-bit character is a CR (0x0D) and it is the last
- ** character, then it indicates a padding character. Drop it.
- */
- if (nPckidx == num_bytes || (cCurr >> 1) == CHAR_CR)
- {
- break;
+ final char PADDING_CHAR = 0x00;
+ int lengthBytes = input.length;
+ int lengthSeptets = (lengthBytes * 8) / 7;
+ String decoded;
+
+ /* Special case where the last 7 bits in the last byte could hold a valid
+ * 7-bit character or a padding character. Drop the last 7-bit character
+ * if it is a padding character.
+ */
+ if (lengthBytes % 7 == 0) {
+ if (lengthBytes > 0) {
+ if ((input[lengthBytes - 1] >> 1) == PADDING_CHAR) {
+ lengthSeptets = lengthSeptets - 1;
}
-
- nextChar = (byte) (cCurr >> 1);
- stringBuf[nStridx++] = nextChar;
}
-
- cPrev = cCurr;
}
- try {
- result = new String(stringBuf, 0, nStridx, "US-ASCII");
- }
- catch (UnsupportedEncodingException e)
- {
- Log.e(TAG, e.getMessage());
+ decoded = GsmAlphabet.gsm7BitPackedToString(input, 0, lengthSeptets);
+
+ // Return "" if decoding of GSM packed string fails
+ if (null == decoded) {
+ Log.e(TAG, "Decoding of GSM packed string failed");
+ decoded = "";
}
- return result;
+ return decoded;
}
static String decodeUTF8String(byte[] input)