FM: Store tag num/value in sequence
Storing tag into mTag[] array should not depend on its index.
If one tag num/value are invalid and it will create empty string in
the tag array, which might return the empty string during query.
Change-Id: I35287e5dd1e97c6a7196d02b0aa7c9efcea4d3a3
diff --git a/qcom/fmradio/FmReceiver.java b/qcom/fmradio/FmReceiver.java
index b7baef2..711eba4 100644
--- a/qcom/fmradio/FmReceiver.java
+++ b/qcom/fmradio/FmReceiver.java
@@ -1658,7 +1658,7 @@
int bytes_read;
String rt = "";
int rt_len;
- int i, j = 2;
+ int i, count, avail_tag_num = 0;
byte tag_code, tag_len, tag_start_pos;
if (isCherokeeChip()) {
rt_plus = FmReceiverJNI.getPsBuffer(rt_plus);
@@ -1676,14 +1676,20 @@
if ((rt != "") && (rt != null)) {
rt_len = rt.length();
mRdsData.setTagNums(0);
- for (i = 1; (i <= 2) && (j < rt_plus[LEN_IND]); i++) {
- tag_code = rt_plus[j++];
- tag_start_pos = rt_plus[j++];
- tag_len = rt_plus[j++];
+ avail_tag_num = (rt_plus[LEN_IND] - 2)/3;
+ if (avail_tag_num > 2) {
+ avail_tag_num = 2;
+ }
+ count = 1;
+ for (i = 0; i < avail_tag_num; i++) {
+ tag_code = rt_plus[2+3*i];
+ tag_start_pos = rt_plus[3+3*i];
+ tag_len = rt_plus[4+3*i];
if (((tag_len + tag_start_pos) <= rt_len) && (tag_code > 0)) {
mRdsData.setTagValue(rt.substring(tag_start_pos,
- (tag_len + tag_start_pos)), i);
- mRdsData.setTagCode(tag_code, i);
+ (tag_len + tag_start_pos)), count);
+ mRdsData.setTagCode(tag_code, count);
+ count++;
}
}
} else {