summaryrefslogtreecommitdiffstats
path: root/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
blob: 7fcb6a548acf343cabe1a045d0a8f1cd314847b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
/*
 * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *        * Redistributions of source code must retain the above copyright
 *            notice, this list of conditions and the following disclaimer.
 *        * Redistributions in binary form must reproduce the above copyright
 *            notice, this list of conditions and the following disclaimer in the
 *            documentation and/or other materials provided with the distribution.
 *        * Neither the name of The Linux Foundation nor
 *            the names of its contributors may be used to endorse or promote
 *            products derived from this software without specific prior written
 *            permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NON-INFRINGEMENT ARE DISCLAIMED.    IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.codeaurora.fmradio;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;
import qcom.fmradio.FmReceiver;
import qcom.fmradio.FmConfig;
import android.util.Log;

public class FmSharedPreferences
{
   public static final int REGIONAL_BAND_NORTH_AMERICA   = 0;
   public static final int REGIONAL_BAND_EUROPE          = 1;
   public static final int REGIONAL_BAND_JAPAN           = 2;
   public static final int REGIONAL_BAND_JAPAN_WIDE      = 3;
   public static final int REGIONAL_BAND_AUSTRALIA       = 4;
   public static final int REGIONAL_BAND_AUSTRIA         = 5;
   public static final int REGIONAL_BAND_BELGIUM         = 6;
   public static final int REGIONAL_BAND_BRAZIL          = 7;
   public static final int REGIONAL_BAND_CHINA           = 8;
   public static final int REGIONAL_BAND_CZECH           = 9;
   public static final int REGIONAL_BAND_DENMARK         = 10;
   public static final int REGIONAL_BAND_FINLAND         = 11;
   public static final int REGIONAL_BAND_FRANCE          = 12;
   public static final int REGIONAL_BAND_GERMANY         = 13;
   public static final int REGIONAL_BAND_GREECE          = 14;
   public static final int REGIONAL_BAND_HONGKONG        = 15;
   public static final int REGIONAL_BAND_INDIA           = 16;
   public static final int REGIONAL_BAND_IRELAND         = 17;
   public static final int REGIONAL_BAND_ITALY           = 18;
   public static final int REGIONAL_BAND_KOREA           = 19;
   public static final int REGIONAL_BAND_MEXICO          = 20;
   public static final int REGIONAL_BAND_NETHERLANDS     = 21;
   public static final int REGIONAL_BAND_NEWZEALAND      = 22;
   public static final int REGIONAL_BAND_NORWAY          = 23;
   public static final int REGIONAL_BAND_POLAND          = 24;
   public static final int REGIONAL_BAND_PORTUGAL        = 25;
   public static final int REGIONAL_BAND_RUSSIA          = 26;
   public static final int REGIONAL_BAND_SINGAPORE       = 27;
   public static final int REGIONAL_BAND_SLOVAKIA        = 28;
   public static final int REGIONAL_BAND_SPAIN           = 29;
   public static final int REGIONAL_BAND_SWITZERLAND     = 30;
   public static final int REGIONAL_BAND_SWEDEN          = 31;
   public static final int REGIONAL_BAND_TAIWAN          = 32;
   public static final int REGIONAL_BAND_TURKEY          = 33;
   public static final int REGIONAL_BAND_UNITEDKINGDOM   = 34;
   public static final int REGIONAL_BAND_UNITED_STATES   = 35;
   public static final int REGIONAL_BAND_USER_DEFINED    = 36;

   public static final int RECORD_DUR_INDEX_0_VAL        = 5;
   public static final int RECORD_DUR_INDEX_1_VAL       = 15;
   public static final int RECORD_DUR_INDEX_2_VAL       = 30;
   public static final int RECORD_DUR_INDEX_3_VAL       = -1;

   private static final String LOGTAG = FMRadio.LOGTAG;

   private static final String SHARED_PREFS = "fmradio_prefs";
   private static final String LIST_NUM = "list_number";
   private static final String LIST_NAME = "list_name";
   private static final String STATION_NAME = "station_name";
   private static final String STATION_FREQUENCY = "station_freq";
   private static final String STATION_ID = "station_id";
   private static final String STATION_PTY = "station_pty";
   private static final String STATION_RDS = "station_rds";
   private static final String STATION_NUM = "preset_number";

   private static final String FMCONFIG_COUNTRY = "fmconfig_country";
   //private static final String FMCONFIG_BAND = "fmconfig_band";
   private static final String FMCONFIG_MIN = "fmconfig_min";
   private static final String FMCONFIG_MAX = "fmconfig_max";
   private static final String FMCONFIG_STEP = "fmconfig_step";
   //private static final String FMCONFIG_EMPH = "fmconfig_emphasis";
   //private static final String FMCONFIG_RDSSTD = "fmconfig_rdsstd";
   /* Storage key String */
   private static final String LAST_LIST_INDEX = "last_list_index";
   public static final int MAX_NUM_TAG_TYPES = 64;
   public static final int NUM_TAG_CATEGORY = 8;
   public static final String []TAG_CATEGORIES = { "DUMMY", "ITEM", "INFO", "PROGRAMME",
                                                      "INTERACTIVITY", "RFU", "PRIVATE_CLASSES",
                                                      "DESCRIPTOR" };
   public static final int [][]TAG_CATEGORY_RANGE  = { {0, 0}, {1, 11}, {12, 30},
                                                         {31, 40}, {41, 53}, {54, 55},
                                                         {56, 58}, {59, 63} };
   public static final String []TAG_NAMES = { "DUMMY", "ITEM.TITLE", "ITEM.ALBUM", "ITEM.TRACKNUM",
                                                  "ITEM.ARTIST", "ITEM.COMPOSITION", "ITEM.MOVEMENT",
                                                  "ITEM.CONDUCTOR", "ITEM.COMPOSER", "ITEM.BAND", "ITEM.COMMENT",
                                                  "ITEM.GENERE", "INFO.NEWS", "INFO.NEWS_LOCAL", "INFO.STOCK",
                                                  "INFO.SPORT", "INFO.LOTTERY", "INFO.HOROSCOPE",
                                                  "INFO.DAILY_DIVERSION", "INFO.HEALTH", "INFO.EVENT",
                                                  "INFO.SCENE", "INFO.CINEMA", "INFO.TV", "INFO.DATE_TIME",
                                                  "INFO.WEATHER", "INFO.TRAFFIC", "INFO.ALARM", "INFO.ADS",
                                                  "INFO.URL", "INFO.OTHER", "PROGRAMME.STATIONNAME_SHORT",
                                                  "PROGRAMME.NOW", "PROGRAMME.NEXT", "PROGRAMME.PART",
                                                  "PROGRAMME.HOST", "PROGRAMME.EDITORIAL_STAFF",
                                                  "PROGRAMME.FREQUENCY", "PROGRAMME.HOMEPAGE",
                                                  "PROGRAMME.SUBCHANNEL", "PHONE.HOTLINE", "PHONE.STUDIO",
                                                  "PHONE.OTHER", "SMS.STUDIO", "SMS.OTHER", "EMAIL.HOTLINE",
                                                  "EMAIL.STUDIO", "EMAIL.OTHER", "MMS.OTHER", "CHAT",
                                                  "CHAT.CENTRE", "VOTE.QUESTION", "VOTE.CENTRE", "RFU.1",
                                                  "RFU.2", "PRIVATE.1", "PRIVATE.2", "PRIVATE.3",
                                                  "PLACE", "APPOINTMENT", "IDENTIFIER", "PURCHASE", "GET_DATA" };

   private static final String PREF_LAST_TUNED_FREQUENCY = "last_frequency";
   private static final String LAST_RECORD_DURATION = "last_record_duration";
   private static String  LAST_AF_JUMP_VALUE = "last_af_jump_value";

   private static Map<String, String> mNameMap = new HashMap<String, String>();
   private static List<PresetList> mListOfPlists = new ArrayList<PresetList>();
   public static Set[] tagList = new TreeSet[FmSharedPreferences.MAX_NUM_TAG_TYPES];
   public static int num_tags = 0;
   private static FmConfig mFMConfiguration;

   private static final String DEFAULT_NO_NAME = "";
   private static final int DEFAULT_NO_FREQUENCY = 98100;
   private static final int DEFAULT_NO_PTY = 0;
   private static final int DEFAULT_NO_STATIONID = 0;
   private static final int DEFAULT_NO_RDSSUP = 0;
   private static CharSequence[] mListEntries;
   private static CharSequence[] mListValues;
   private static int mListIndex;
   private Context mContext;
   private static int mTunedFrequency = 98100;
   private static int mBandMinFreq = 76000;
   private static int mBandMaxFreq = 108000;
   private static int mChanSpacing = 0;
   private static int mFrequencyBand_Stepsize = 200;

   private static int mCountry = 0;
   /* true = Stereo and false = "force Mono" even if Station is transmitting a
    * Stereo signal
    */
   private static boolean mAudioOutputMode=true;
   private static boolean mAFAutoSwitch=true;
   private static int mRecordDuration=0;

   FmSharedPreferences(Context context){
      mContext = context.getApplicationContext();
      mFMConfiguration = new FmConfig();
      Load();
   }

   public static void removeStation(int listIndex, int stationIndex){
      if (listIndex < getNumList())
      {
         mListOfPlists.get(listIndex).removeStation(stationIndex);
      }
   }
   public static void removeStation(int listIndex, PresetStation station){
      if (listIndex < getNumList())
      {
         mListOfPlists.get(listIndex).removeStation(station);
      }
   }

   public static void setListName(int listIndex, String name){
      if (listIndex < getNumList())
      {
         mListOfPlists.get(listIndex).setName(name);
      }
   }

   public static void setStationName(int listIndex, int stationIndex, String name){
      if (listIndex < getNumList())
      {
         mListOfPlists.get(listIndex).setStationName(stationIndex, name);
      }
   }

   public static String getListName(int listIndex){
      String name = "";
      addListIfEmpty(listIndex);
      if (listIndex < getNumList())
      {
         name= mListOfPlists.get(listIndex).getName();
      }
      return name;
   }

   public static String getStationName(int listIndex, int stationIndex){
      String name = "";
      if (listIndex < getNumList())
      {
         name = mListOfPlists.get(listIndex).getStationName(stationIndex);
      }
      return name;
   }

   public static double getStationFrequency(int listIndex, int stationIndex){
      double frequency = 0;
      if (listIndex < getNumList())
      {
         frequency =  mListOfPlists.get(listIndex).getStationFrequency(stationIndex);
      }
      return frequency;
   }

   public static PresetList getStationList(int listIndex){
      if (listIndex < getNumList())
      {
         return mListOfPlists.get(listIndex);
      }
      return null;
   }

   public static PresetStation getselectedStation(){
      int listIndex = getCurrentListIndex();
      PresetStation station = null;
      if (listIndex < getNumList())
      {
         station = mListOfPlists.get(listIndex).getSelectedStation();
      }
      return station;
   }

   public static PresetStation getStationInList(int index){
      int listIndex = getCurrentListIndex();
      PresetStation station = null;
      if (listIndex < getNumList())
      {
         station = mListOfPlists.get(listIndex).getStationFromIndex(index);
      }
      return station;
   }
   public static PresetStation getStationFromFrequency(int frequency){
      int listIndex = getCurrentListIndex();
      PresetStation station = null;
      if (listIndex < getNumList())
      {
         station = mListOfPlists.get(listIndex).getStationFromFrequency(frequency);
      }
      return station;
   }

   public static PresetStation selectNextStation(){
      int listIndex = getCurrentListIndex();
      PresetStation station = null;
      if (listIndex < getNumList())
      {
         station = mListOfPlists.get(listIndex).selectNextStation();
      }
      return station;
   }

   public static PresetStation selectPrevStation(){
      int listIndex = getCurrentListIndex();
      PresetStation station = null;
      if (listIndex < getNumList())
      {
         station = mListOfPlists.get(listIndex).selectPrevStation();
      }
      return station;
   }

   public static void selectStation(PresetStation station){
      int listIndex = getCurrentListIndex();
      if (listIndex < getNumList())
      {
         mListOfPlists.get(listIndex).selectStation(station);
      }
   }

   public static int getNumList(){
      return mListOfPlists.size();
   }

   public static int getCurrentListIndex(){
      return mListIndex;
   }

   public static void setListIndex(int index){
      mListIndex = index;
   }

   public static Map<String, String> getNameMap(){
      return mNameMap;
   }

   private static void addListIfEmpty(int listIndex){
      if ( (listIndex < 1) && (getNumList() == 0))
      {
         createPresetList("FM");
      }
   }

   public static void addStation(String name, int freq, int listIndex){
      /* If no lists exists and a new station is added, add a new Preset List
       * if "listIndex" requested was "0"
       */
      addListIfEmpty(listIndex);
      if (getNumList() > listIndex)
      {
         mListOfPlists.get(listIndex).addStation(name, freq);
      }
   }

   /** Add "station" into the Preset List indexed by "listIndex" */
   public static void addStation(int listIndex, PresetStation station){
      /* If no lists exists and a new station is added, add a new Preset List
       * if "listIndex" requested was "0"
       */
      addListIfEmpty(listIndex);
      if (getNumList() > listIndex)
      {
         mListOfPlists.get(listIndex).addStation(station);
      }
   }
   public static void addTags(int index, String s) {
     if ((index >= 0) && (index <FmSharedPreferences.MAX_NUM_TAG_TYPES)) {
          if(tagList[index] == null) {
             tagList[index] = new TreeSet<String>();
          }
          if (tagList[index].add(s))
              num_tags++;
     }
   }
   public static void clearTags() {
       for(int i = 0; i <FmSharedPreferences.MAX_NUM_TAG_TYPES; i++) {
           if(tagList[i] != null) {
              tagList[i].clear();
              Log.d(LOGTAG, "cleared tags of type" + i);
           }
       }
       num_tags = 0;
   }

   /** Does "station" already exist in the Preset List indexed by "listIndex" */
   public static boolean sameStationExists(int listIndex, PresetStation station){
      boolean exists = false;
      if (getNumList() > listIndex)
      {
         exists = mListOfPlists.get(listIndex).sameStationExists(station);
      }
      return exists;
   }

   /** Does "station" already exist in the current Preset List*/
   public static boolean sameStationExists( PresetStation station){
      int listIndex = getCurrentListIndex();
      boolean exists = false;
      if (getNumList() > listIndex)
      {
         exists = mListOfPlists.get(listIndex).sameStationExists(station);
      }
      return exists;
   }

   /** Does "station" already exist in the current Preset List*/
   public static int getListStationCount( ){
      int listIndex = getCurrentListIndex();
      int numStations = 0;
      if (getNumList() > listIndex)
      {
         numStations = mListOfPlists.get(listIndex).getStationCount();
      }
      return numStations;
   }

   public static void renamePresetList(String newName, int listIndex){
      PresetList curList =    mListOfPlists.get(listIndex);
      if (curList != null)
      {
         String oldListName = curList.getName();
         curList.setName(newName);
         String index = mNameMap.get(oldListName);
         mNameMap.remove(oldListName);
         mNameMap.put((String) newName, index);
         repopulateEntryValueLists();
      }
   }

   /* Returns the index of the list just created */
   public static int createPresetList(String name) {
      int numLists = mListOfPlists.size();
      mListOfPlists.add(new PresetList(name));
      String index = String.valueOf(numLists);
      mNameMap.put(name, index);
      repopulateEntryValueLists();
      return numLists;
   }


   public static void createFirstPresetList(String name) {
      mListIndex = 0;
      createPresetList(name);
   }

   public static CharSequence[] repopulateEntryValueLists() {
      ListIterator<PresetList> presetIter;
      presetIter = mListOfPlists.listIterator();
      int numLists = mListOfPlists.size();

      mListEntries = new CharSequence[numLists];
      mListValues = new CharSequence[numLists];
      for (int i = 0; i < numLists; i++)
      {
         PresetList temp = presetIter.next();
         mListEntries[i] = temp.getName();
         mListValues[i] = temp.getName();
      }
      return mListEntries;
   }

   public static List<PresetList> getPresetLists() {
      return mListOfPlists;
   }


   public void  Load(){
      Log.d(LOGTAG, "Load preferences ");
      if(mContext == null)
      {
         return;
      }
      SharedPreferences sp = mContext.getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE);
      mTunedFrequency = sp.getInt(PREF_LAST_TUNED_FREQUENCY, DEFAULT_NO_FREQUENCY);
      mRecordDuration = sp.getInt(LAST_RECORD_DURATION, RECORD_DUR_INDEX_0_VAL);
      mAFAutoSwitch = sp.getBoolean(LAST_AF_JUMP_VALUE, true);
      if(sp.getInt(FMCONFIG_COUNTRY, 0) == REGIONAL_BAND_USER_DEFINED) {
         mBandMinFreq = sp.getInt(FMCONFIG_MIN, mBandMinFreq);
         mBandMaxFreq = sp.getInt(FMCONFIG_MAX, mBandMaxFreq);
         mChanSpacing = sp.getInt(FMCONFIG_STEP, mChanSpacing);
      }
      int num_lists = sp.getInt(LIST_NUM, 1);
      if (mListOfPlists.size() == 0) {

         for (int listIter = 0; listIter < num_lists; listIter++)
         {
             String listName = sp.getString(LIST_NAME + listIter, "FM - " + (listIter+1));
             int numStations = sp.getInt(STATION_NUM + listIter, 1);
             if (listIter == 0)
             {
                 createFirstPresetList(listName);
             } else
             {
                 createPresetList(listName);
             }

             PresetList curList = mListOfPlists.get(listIter);
             for (int stationIter = 0; stationIter < numStations; stationIter++)
             {
                  String stationName = sp.getString(STATION_NAME + listIter + "x" + stationIter,
                                                      DEFAULT_NO_NAME);
                  int stationFreq = sp.getInt(STATION_FREQUENCY + listIter + "x" + stationIter,
                                                   DEFAULT_NO_FREQUENCY);
                  PresetStation station = curList.addStation(stationName, stationFreq);

                  int stationId = sp.getInt(STATION_ID + listIter + "x" + stationIter,
                                              DEFAULT_NO_STATIONID);
                  station.setPI(stationId);

                  int pty = sp.getInt(STATION_PTY + listIter + "x" + stationIter, DEFAULT_NO_PTY);
                  station.setPty(pty);

                  int rdsSupported = sp.getInt(STATION_RDS + listIter + "x" + stationIter,
                                                 DEFAULT_NO_RDSSUP);
                  if (rdsSupported != 0)
                  {
                      station.setRDSSupported(true);
                  } else
                  {
                      station.setRDSSupported(false);
                  }
             }
         }
      }
      /* Load Configuration */
      if (Locale.getDefault().equals(Locale.CHINA)) {
          setCountry(sp.getInt(FMCONFIG_COUNTRY, REGIONAL_BAND_CHINA));
      } else {
          setCountry(sp.getInt(FMCONFIG_COUNTRY, REGIONAL_BAND_NORTH_AMERICA));
      }
      /* Last list the user was navigating */
      mListIndex = sp.getInt(LAST_LIST_INDEX, 0);
      if(mListIndex >= num_lists)
      {
         mListIndex=0;
      }
   }

   public void Save() {
      if(mContext == null)
      {
         return;
      }
      Log.d(LOGTAG, "Save preferences ");

      int numLists = mListOfPlists.size();
      SharedPreferences sp = mContext.getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE);
      SharedPreferences.Editor ed = sp.edit();

      ed.putInt(PREF_LAST_TUNED_FREQUENCY, mTunedFrequency);

      ed.putInt(LIST_NUM, numLists);
      /* Last list the user was navigating */
      ed.putInt(LAST_LIST_INDEX, mListIndex);

      for (int listIter = 0; listIter < numLists; listIter++)
      {
         PresetList curList = mListOfPlists.get(listIter);
         ed.putString(LIST_NAME + listIter, curList.getName());
         int numStations = curList.getStationCount();
         ed.putInt(STATION_NUM + listIter, numStations);
         int numStation = 0;
         for (int stationIter = 0; stationIter < numStations; stationIter++)
         {
            PresetStation station = curList.getStationFromIndex(stationIter);
            if (station != null)
            {
               ed.putString(STATION_NAME + listIter + "x" + numStation,
                            station.getName());
               ed.putInt(STATION_FREQUENCY + listIter + "x" + numStation,
                         station.getFrequency());
               ed.putInt(STATION_ID + listIter + "x" + numStation,
                         station.getPI());
               ed.putInt(STATION_PTY + listIter + "x" + numStation,
                         station.getPty());
               ed.putInt(STATION_RDS + listIter + "x" + numStation,
                         (station.getRDSSupported() == true? 1:0));
               numStation ++;
            }
         }
      }

      /* Save Configuration */
      ed.putInt(FMCONFIG_COUNTRY, mCountry);
      if(mCountry == REGIONAL_BAND_USER_DEFINED) {
         ed.putInt(FMCONFIG_MIN, mBandMinFreq);
         ed.putInt(FMCONFIG_MAX, mBandMaxFreq);
         ed.putInt(FMCONFIG_STEP, mChanSpacing);
      }
      ed.putInt(LAST_RECORD_DURATION, mRecordDuration);
      ed.putBoolean(LAST_AF_JUMP_VALUE, mAFAutoSwitch);
      ed.commit();
   }

   public static void SetDefaults() {
      mListIndex=0;
      mListOfPlists.clear();
      if (Locale.getDefault().equals(Locale.CHINA)){
          setCountry(REGIONAL_BAND_CHINA);
          //Others set north America.
      } else {
          setCountry(REGIONAL_BAND_NORTH_AMERICA);
      }
   }

   public static void removeStationList(int listIndex) {
      mListIndex = listIndex;
      PresetList toRemove = mListOfPlists.get(mListIndex);

      mNameMap.remove(toRemove.getName());
      mListOfPlists.remove(mListIndex);
      int numLists = mListOfPlists.size();

      /* Remove for others */
      for (int i = mListIndex; i < numLists; i++)
      {
         PresetList curList = mListOfPlists.get(i);
         if (curList!=null)
         {
            String listName = curList.getName();
            /* Removals */
            mNameMap.remove(listName);
            mNameMap.put(listName, String.valueOf(i));
         }
      }
      mListIndex = 0;
      repopulateEntryValueLists();
   }


   public static void setTunedFrequency(int frequency) {
      mTunedFrequency = frequency;
   }

   public static int getTunedFrequency() {
      return mTunedFrequency;
   }

   public static int getNextTuneFrequency(int frequency) {
              int nextFrequency = (frequency + mFrequencyBand_Stepsize);
              if (nextFrequency > getUpperLimit())
              {
                 nextFrequency = getLowerLimit();
              }
              return nextFrequency;
           }

   public static int getNextTuneFrequency() {
      int nextFrequency = (mTunedFrequency + mFrequencyBand_Stepsize);
      if (nextFrequency > getUpperLimit())
      {
         nextFrequency = getLowerLimit();
      }
      return nextFrequency;
   }

   public static int getPrevTuneFrequency(int frequency) {
              int prevFrequency = (frequency - mFrequencyBand_Stepsize);
              if (prevFrequency < getLowerLimit())
              {
                 prevFrequency = getUpperLimit();
              }
              return prevFrequency;
           }

   public static int getPrevTuneFrequency() {
      int prevFrequency = (mTunedFrequency - mFrequencyBand_Stepsize);
      if (prevFrequency < getLowerLimit())
      {
         prevFrequency = getUpperLimit();
      }
      return prevFrequency;
   }

   /**
    * @param mFMConfiguration the mFMConfiguration to set
    */
   public static void setFMConfiguration(FmConfig mFMConfig) {
      FmSharedPreferences.mFMConfiguration = mFMConfig;
   }

   /**
    * @return the mFMConfiguration
    */
   public static FmConfig getFMConfiguration() {
      return mFMConfiguration;
   }

   public static void setRadioBand(int band)
   {
      switch (band)
      {
      case FmReceiver.FM_JAPAN_WIDE_BAND:
         {
            mFrequencyBand_Stepsize = 50;
            mFMConfiguration.setLowerLimit(76000);
            mFMConfiguration.setUpperLimit(108000);
            break;
         }
      case FmReceiver.FM_JAPAN_STANDARD_BAND:
         {
            mFrequencyBand_Stepsize = 100;
            mFMConfiguration.setLowerLimit(76000);
            mFMConfiguration.setUpperLimit(90000);
            break;
         }
      case FmReceiver.FM_USER_DEFINED_BAND:
         {
            break;
         }
      case FmReceiver.FM_US_BAND:
      case FmReceiver.FM_EU_BAND:
      default:
         {
            band =  FmReceiver.FM_US_BAND;
            mFMConfiguration.setLowerLimit(87500);
            mFMConfiguration.setUpperLimit(107900);
            mFrequencyBand_Stepsize = 100;
         }
      }
      mFMConfiguration.setRadioBand(band);
   }

   public static int getRadioBand()
   {
      return mFMConfiguration.getRadioBand();
   }

   public static void setChSpacing(int spacing)
   {
      if( (spacing >= FmReceiver.FM_CHSPACE_200_KHZ)
          && (spacing <= FmReceiver.FM_CHSPACE_50_KHZ))
      {
         mFrequencyBand_Stepsize = 200;
         switch (spacing)
         {
         case FmReceiver.FM_CHSPACE_100_KHZ:
            {
               mFrequencyBand_Stepsize = 100;
               break;
            }
         case FmReceiver.FM_CHSPACE_50_KHZ:
            {
               mFrequencyBand_Stepsize = 50;
               break;
            }
         }
         mChanSpacing = spacing;
         mFMConfiguration.setChSpacing(spacing);
      }
   }

   public static int getChSpacing()
   {
      return mFMConfiguration.getChSpacing();
   }

   public static void setRdsStd(int std)
   {
      if( (std>=FmReceiver.FM_RDS_STD_RBDS)
          && (std<=FmReceiver.FM_RDS_STD_NONE))
      {
         mFMConfiguration.setRdsStd(std);
      }
   }

   public static int getRdsStd()
   {
      return mFMConfiguration.getRdsStd();
   }

   /* North America */
   public static boolean isRDSStd()
   {
      return(FmReceiver.FM_RDS_STD_RDS == mFMConfiguration.getRdsStd());
   }

   public static boolean isRBDSStd()
   {
      return(FmReceiver.FM_RDS_STD_RBDS == mFMConfiguration.getRdsStd());
   }

   public static void setEmphasis(int emph)
   {
      if( (emph>=FmReceiver.FM_DE_EMP75)
          && (emph<=FmReceiver.FM_DE_EMP50))
      {
         mFMConfiguration.setEmphasis(emph);
      }
   }

   public static int getEmphasis()
   {
      return mFMConfiguration.getEmphasis();
   }

   public static int getUpperLimit()
   {
      return mFMConfiguration.getUpperLimit();
   }

   public static int getLowerLimit()
   {
      return mFMConfiguration.getLowerLimit();
   }

   public static void setLowerLimit(int lowLimit) {
      mFMConfiguration.setLowerLimit(lowLimit);
      if(mCountry == REGIONAL_BAND_USER_DEFINED) {
         mBandMinFreq = lowLimit;
      }
   }

   public static void setUpperLimit(int upLimit){
      mFMConfiguration.setUpperLimit(upLimit);
      if(mCountry == REGIONAL_BAND_USER_DEFINED) {
         mBandMaxFreq = upLimit;
      }
   }

   public static void setCountry(int nCountryCode){

      // Default: 87500  TO 10800 IN 100 KHZ STEPS
      mFMConfiguration.setRadioBand(FmReceiver.FM_USER_DEFINED_BAND);
      mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_100_KHZ);
      mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP50);
      mFMConfiguration.setRdsStd(FmReceiver.FM_RDS_STD_RDS);
      mFMConfiguration.setLowerLimit(87500);
      mFMConfiguration.setUpperLimit(108000);

      switch(nCountryCode)
      {
        case REGIONAL_BAND_NORTH_AMERICA:
        {
          /*NORTH_AMERICA : 87500 TO 108000 IN 200 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_US_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_200_KHZ);
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
          mFMConfiguration.setRdsStd(FmReceiver.FM_RDS_STD_RBDS);
          mFMConfiguration.setLowerLimit(87500);
          mFMConfiguration.setUpperLimit(107900);
          mFrequencyBand_Stepsize = 200;
          break;
        }
        case REGIONAL_BAND_EUROPE:
        {
          /*EUROPE/Default : 87500 TO 10800 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }

        case REGIONAL_BAND_JAPAN:
        {
          /*JAPAN : 76000  TO 90000 IN 100 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_JAPAN_STANDARD_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_100_KHZ);
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
          mFMConfiguration.setLowerLimit(76000);
          mFMConfiguration.setUpperLimit(90000);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_JAPAN_WIDE:
        {
          /*JAPAN_WB : 90000 TO 108000 IN 50 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_JAPAN_WIDE_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
          mFMConfiguration.setLowerLimit(90000);
          mFMConfiguration.setUpperLimit(108000);
          mFrequencyBand_Stepsize = 50;
          break;
        }

        /* Country specific */
        case REGIONAL_BAND_AUSTRALIA:
        {
          /*AUSTRALIA : 87700 TO 108000 IN 100 KHZ STEPS*/
          mFMConfiguration.setLowerLimit(87700);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_AUSTRIA:
        {
          /*AUSTRIA : 87500 TO 108000 IN 50 KHZ STEPS*/
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP50);
          mFrequencyBand_Stepsize = 50;
          break;
        }
        case REGIONAL_BAND_BELGIUM:
       {
         /*BELGIUM : 87500 TO 108000 IN 100 KHZ STEPS*/
         mFrequencyBand_Stepsize = 100;
         break;
       }
       case REGIONAL_BAND_BRAZIL:
       {
         /*BRAZIL : 87500 TO 108000 IN 200 KHZ STEP*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_US_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_200_KHZ);
          mFMConfiguration.setLowerLimit(87500);
          mFMConfiguration.setUpperLimit(107900);
          mFrequencyBand_Stepsize = 200;
          break;
        }
        case REGIONAL_BAND_CHINA:
        {
          /*CHINA : 87000 TO 108000 IN 100 KHZ STEPS*/
          mFMConfiguration.setLowerLimit(87000);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_CZECH:
        {
          /*CZECH : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_DENMARK:
        {
          /*DENMARK : 87500 TO 108000 IN 50 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
          mFrequencyBand_Stepsize = 50;
          break;
        }
        case REGIONAL_BAND_FINLAND:
        {
          /*FINLAND : 87500  TO 108000  IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_FRANCE:
        {
          /* FRANCE : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_GERMANY:
          /*GERMANY : 87500 TO 108000 IN 50 KHZ STEPS*/
        case REGIONAL_BAND_GREECE:
          /*GREECE : 87500 TO 108000 IN 50 KHZ STEPS*/
        {
          mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
          mFrequencyBand_Stepsize = 50;
          break;
        }
        case REGIONAL_BAND_HONGKONG:
        {
          /*HONG KONG : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_INDIA:
        {
          /*INDIA : 91000 TO 106400 IN 100 KHZ STEPS*/
          mFMConfiguration.setLowerLimit(91000);
          mFMConfiguration.setUpperLimit(106400);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_IRELAND:
        {
          /*IRELAND : 87500 TO 108000 IN 50 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
          mFrequencyBand_Stepsize = 50;
          break;
        }
        case REGIONAL_BAND_ITALY:
        {
          /*ITALY : 87500 TO 108000 IN 50 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
          mFrequencyBand_Stepsize = 50;
          break;
        }
        case REGIONAL_BAND_KOREA:
        {
          /*KOREA : 87500 TO 108000 IN 200 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_US_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_200_KHZ);
          mFMConfiguration.setUpperLimit(107900);
          mFrequencyBand_Stepsize = 200;
          break;
        }
        case REGIONAL_BAND_MEXICO:
        {
          /*MEXICO : 88100 TO 107900 IN 200 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_US_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_200_KHZ);
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
          mFMConfiguration.setRdsStd(FmReceiver.FM_RDS_STD_RBDS);
          mFMConfiguration.setLowerLimit(88100);
          mFMConfiguration.setUpperLimit(107900);
          mFrequencyBand_Stepsize = 200;
          break;
        }
        case REGIONAL_BAND_NETHERLANDS:
        {
          /*NETHERLANDS : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_NEWZEALAND:
        {
          /*NEW ZEALAND : 88000 TO 107000 IN 100 KHZ STEPS*/
          mFMConfiguration.setLowerLimit(88000);
          mFMConfiguration.setUpperLimit(107000);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_NORWAY:
        {
          /*NORWAY : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_POLAND:
        {
          /*POLAND : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_100_KHZ);
          mFMConfiguration.setLowerLimit(87500);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_PORTUGAL:
        {
          /*PORTUGAL : 87500 TO 108000 IN 50 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
          mFrequencyBand_Stepsize = 50;
          break;
        }
        case REGIONAL_BAND_RUSSIA:
        {
          /*RUSSIA : 87500 TO 108000  IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_SINGAPORE:
        {
          /*SINGAPORE : 88000 TO 108000 IN 100 KHZ STEPS*/
          mFMConfiguration.setLowerLimit(88000);
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_SLOVAKIA:
        {
          /*SLOVAKIA : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_SPAIN:
        {
          /*SPAIN : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_SWITZERLAND:
        {
          /*SWITZERLAND : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_SWEDEN:
        {
          /*SWEDEN : 87500 TO 108000  IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_TAIWAN:
        {
          /*TAIWAN : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_TURKEY:
        {
          /*TURKEY : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_UNITEDKINGDOM:
        {
          /*UNITED KINGDOM : 87500 TO 108000 IN 100 KHZ STEPS*/
          mFrequencyBand_Stepsize = 100;
          break;
        }
        case REGIONAL_BAND_UNITED_STATES:
        {
          /*UNITED STATES : 88100 TO 107900 IN 200 KHZ STEPS*/
          mFMConfiguration.setRadioBand(FmReceiver.FM_US_BAND);
          mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_200_KHZ);
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
          mFMConfiguration.setRdsStd(FmReceiver.FM_RDS_STD_RBDS);
          mFMConfiguration.setLowerLimit(88100);
          mFMConfiguration.setUpperLimit(107900);
          mFrequencyBand_Stepsize = 200;
          break;
        }
        case REGIONAL_BAND_USER_DEFINED:
        {
          mFMConfiguration.setRadioBand(FmReceiver.FM_USER_DEFINED_BAND);
          mFMConfiguration.setChSpacing(mChanSpacing);
          mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
          mFMConfiguration.setRdsStd(FmReceiver.FM_RDS_STD_RDS);
          mFMConfiguration.setLowerLimit(mBandMinFreq);
          mFMConfiguration.setUpperLimit(mBandMaxFreq);
          if(mChanSpacing == 0) {
             mFrequencyBand_Stepsize = 200;
          }else if(mChanSpacing == 1) {
             mFrequencyBand_Stepsize = 100;
          }else {
             mFrequencyBand_Stepsize = 50;
          }
          break;
        }
        default:
        {
          Log.d(LOGTAG, "Invalid: countryCode: "+nCountryCode);
          nCountryCode=0;
        }
      }
    mCountry = nCountryCode;
    Log.d(LOGTAG, "=====================================================");
    Log.d(LOGTAG, "Country     :"+nCountryCode);
    Log.d(LOGTAG, "RadioBand   :"+ mFMConfiguration.getRadioBand());
    Log.d(LOGTAG, "Emphasis    :"+ mFMConfiguration.getEmphasis());
    Log.d(LOGTAG, "ChSpacing   :"+ mFMConfiguration.getChSpacing());
    Log.d(LOGTAG, "RdsStd      :"+ mFMConfiguration.getRdsStd());
    Log.d(LOGTAG, "LowerLimit  :"+ mFMConfiguration.getLowerLimit());
    Log.d(LOGTAG, "UpperLimit  :"+ mFMConfiguration.getUpperLimit());
    Log.d(LOGTAG, "=====================================================");
   }


   public static int getCountry() {
      return mCountry;
   }


   public static void setAudioOutputMode(boolean bStereo) {
      mAudioOutputMode = bStereo;
   }

   public static boolean getAudioOutputMode() {
      return mAudioOutputMode;
   }

   public static void setRecordDuration(int durationIndex) {

      Log.d(LOGTAG, "setRecordDuration "+durationIndex);
      switch( durationIndex ) {

      case 0: mRecordDuration = RECORD_DUR_INDEX_0_VAL; break;
      case 1: mRecordDuration = RECORD_DUR_INDEX_1_VAL; break;
      case 2: mRecordDuration = RECORD_DUR_INDEX_2_VAL; break;
      case 3: mRecordDuration = RECORD_DUR_INDEX_3_VAL; break;
      default:
        {
           Log.d(LOGTAG, "Invalid: durationIndex "+durationIndex);
        }

      }
      return;
   }

   public static int getRecordDuration() {
      return mRecordDuration;
   }


   public static void setAutoAFSwitch(boolean bAFAutoSwitch) {
      mAFAutoSwitch = bAFAutoSwitch;
   }

   public static boolean getAutoAFSwitch() {
      return mAFAutoSwitch;
   }
}