Merge "FM: Fix the issue with audio routing"
diff --git a/FMRecord/res/values-zh-rCN/strings.xml b/FMRecord/res/values-zh-rCN/strings.xml
index a55ae4b..660f743 100644
--- a/FMRecord/res/values-zh-rCN/strings.xml
+++ b/FMRecord/res/values-zh-rCN/strings.xml
@@ -41,4 +41,6 @@
     <!-- all recordings will show up in the media database in a playlist with this name -->
     <string name="audio_db_playlist_name">FM 录音</string>
     <string name="fm_record_progress">FM 录音进行中</string>
+    <string name="FMRecording_reach_size_limit">已到达最长限制.</string>
+    <string name="unable_to_store">无法保存已录音频</string>
 </resources>
diff --git a/FMRecord/res/values/strings.xml b/FMRecord/res/values/strings.xml
index ff11d19..244d41c 100644
--- a/FMRecord/res/values/strings.xml
+++ b/FMRecord/res/values/strings.xml
@@ -47,4 +47,5 @@
     <string name="audio_db_playlist_name">FM recordings</string>
     <string name="save_record_file">FM Recorded file saved to "<xliff:g id="record_file">%1$s</xliff:g>"</string>
     <string name="fm_record_progress">FM Recording in progress</string>
+    <string name="unable_to_store">Unable to save recorded audio</string>
 </resources>
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
index fc0fc21..62f4a94 100644
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
@@ -259,7 +259,10 @@
 
         }
         mSampleFile = null;
-        File sampleDir = Environment.getExternalStorageDirectory();
+        File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording");
+
+        if(!(sampleDir.mkdirs() || sampleDir.isDirectory()))
+            return false;
 
         try {
              mSampleFile = File.createTempFile("FMRecording", ".3gpp", sampleDir);
@@ -309,9 +312,12 @@
                          Log.d(TAG, "Maximum file size/duration reached, stopping the recording");
                          stopRecord();
                      }
-                     // Show the toast.
-                     Toast.makeText(FMRecordingService.this, R.string.FMRecording_reach_size_limit,
-                               Toast.LENGTH_LONG).show();
+                     if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) {
+                         // Show the toast.
+                         Toast.makeText(FMRecordingService.this,
+                                        R.string.FMRecording_reach_size_limit,
+                                        Toast.LENGTH_LONG).show();
+                     }
                  }
              }
              // from MediaRecorder.OnErrorListener
@@ -417,7 +423,7 @@
         Log.d(TAG, "ContentURI: " + base);
         Uri result = resolver.insert(base, cv);
         if (result == null) {
-            Toast.makeText(this, "Unable to save recorded audio", Toast.LENGTH_SHORT).show();
+            Toast.makeText(this, R.string.unable_to_store, Toast.LENGTH_SHORT).show();
             return null;
         }
         if (getPlaylistId(res) == -1) {
@@ -469,7 +475,7 @@
         cv.put(MediaStore.Audio.Playlists.NAME, res.getString(R.string.audio_db_playlist_name));
         Uri uri = resolver.insert(MediaStore.Audio.Playlists.getContentUri("external"), cv);
         if (uri == null) {
-            Toast.makeText(this, "Unable to save recorded audio", Toast.LENGTH_SHORT).show();
+            Toast.makeText(this, R.string.unable_to_store, Toast.LENGTH_SHORT).show();
         }
         return uri;
     }
diff --git a/fmapp2/AndroidManifest.xml b/fmapp2/AndroidManifest.xml
index aeb3a1c..a0ed3ca 100644
--- a/fmapp2/AndroidManifest.xml
+++ b/fmapp2/AndroidManifest.xml
@@ -74,6 +74,7 @@
         <receiver android:name="com.caf.fmradio.FMMediaButtonIntentReceiver">
             <intent-filter>
                  <action android:name="android.intent.action.MEDIA_BUTTON" />
+                 <action android:name="android.media.AUDIO_BECOMING_NOISY" />
             </intent-filter>
         </receiver>
 
diff --git a/fmapp2/res/values-zh-rCN/strings.xml b/fmapp2/res/values-zh-rCN/strings.xml
index 76936b7..d32c0cd 100644
--- a/fmapp2/res/values-zh-rCN/strings.xml
+++ b/fmapp2/res/values-zh-rCN/strings.xml
@@ -115,5 +115,6 @@
     <string name="chanl_spacing">信道间隔</string>
     <string name="set">设置</string>
     <string name="cancel">取消</string>
-	<string name="rt_plus_tags">标签</string>
+    <string name="rt_plus_tags">标签</string>
+    <string name="user_defind_band_msg">请输入有效的频段范围 76.0 - 108.0</string>
 </resources>
diff --git a/fmapp2/res/values/strings.xml b/fmapp2/res/values/strings.xml
index 146866a..a2bf1d4 100644
--- a/fmapp2/res/values/strings.xml
+++ b/fmapp2/res/values/strings.xml
@@ -263,5 +263,6 @@
     <string name="band_sweep_choose">Choose Band Sweep Method</string>
     <string name="set">Set</string>
     <string name="cancel">Cancel</string>
+    <string name="user_defind_band_msg">Enter Freq from range 76.0 - 108.0</string>
 
 </resources>
diff --git a/fmapp2/src/com/caf/fmradio/FMMediaButtonIntentReceiver.java b/fmapp2/src/com/caf/fmradio/FMMediaButtonIntentReceiver.java
index 9bc4d77..949453f 100644
--- a/fmapp2/src/com/caf/fmradio/FMMediaButtonIntentReceiver.java
+++ b/fmapp2/src/com/caf/fmradio/FMMediaButtonIntentReceiver.java
@@ -36,6 +36,7 @@
 import android.content.pm.PackageManager;
 import android.content.Context;
 import android.content.ComponentName;
+import android.media.AudioManager;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.os.Bundle;
@@ -45,9 +46,14 @@
 
 private static final String TAG = "FMMediaButtonIntentReceiver";
 public static final String FM_MEDIA_BUTTON = "com.caf.fmradio.action.MEDIA_BUTTON";
+public static final String AUDIO_BECOMING_NOISY = "com.caf.fmradio.action.AUDIO_BECOMING_NOISY";
 public void onReceive(Context context, Intent intent) {
-        String action = intent.getAction();
-       if ((action != null) && action.equals("android.intent.action.MEDIA_BUTTON")) {
+       String action = intent.getAction();
+       if ((action != null) && action.equals(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
+           Log.d(TAG, "ACTION_AUDIO_BECOMING_NOISY intent received for ACTION_HEADSET_PLUG");
+           Intent i = new Intent(AUDIO_BECOMING_NOISY);
+           context.sendBroadcast(i);
+       } else if ((action != null) && action.equals("android.intent.action.MEDIA_BUTTON")) {
            KeyEvent event = (KeyEvent)
                     intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
 
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 9d48888..870df8c 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -962,6 +962,7 @@
                       RestoreDefaults();
                       enableRadioOnOffUI();
                       tuneRadio(FmSharedPreferences.DEFAULT_NO_FREQUENCY);
+                      FmSharedPreferences.addStation("", FmSharedPreferences.DEFAULT_NO_FREQUENCY, 0);
                   }
                }
             }
@@ -2046,11 +2047,9 @@
             String display = "";
             if (station != null) {
                display = station.getName();
-                Log.e(LOGTAG, "Venkat:before" + display );
                 if (display.length() > 6)
-		 display = display.substring(0,6)+"...";
-	       Log.e(LOGTAG, "Venkat: after" + display );
-		mPresetButtons[buttonIndex].setEllipsize(TextUtils.TruncateAt.END);
+                    display = display.substring(0,6)+"...";
+	       mPresetButtons[buttonIndex].setEllipsize(TextUtils.TruncateAt.END);
                mPresetButtons[buttonIndex].setText(display);
                mPresetButtons[buttonIndex].setTag(station);
                mPresetButtons[buttonIndex].setHeight(-1);
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 005bdff..3ed64bc 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -106,6 +106,7 @@
    private boolean mSleepActive = false;
    private BroadcastReceiver mRecordTimeoutListener = null;
    private BroadcastReceiver mDelayedServiceStopListener = null;
+   private BroadcastReceiver mAudioBecomeNoisyListener = null;
    private boolean mOverA2DP = false;
    private BroadcastReceiver mFmMediaButtonListener;
    private IFMRadioServiceCallbacks mCallbacks;
@@ -204,6 +205,7 @@
       // registering media button receiver seperately as we need to set
       // different priority for receiving media events
       registerFmMediaButtonReceiver();
+      registerAudioBecomeNoisy();
       if ( false == SystemProperties.getBoolean("ro.fm.mulinst.recording.support",true)) {
            mSingleRecordingInstanceSupported = true;
       }
@@ -257,6 +259,10 @@
           unregisterReceiver(mFmMediaButtonListener);
           mFmMediaButtonListener = null;
       }
+      if (mAudioBecomeNoisyListener != null) {
+          unregisterReceiver(mAudioBecomeNoisyListener);
+          mAudioBecomeNoisyListener = null;
+      }
       if (mSleepExpiredListener != null ) {
           unregisterReceiver(mSleepExpiredListener);
           mSleepExpiredListener = null;
@@ -505,6 +511,40 @@
          }
      }
 
+    public void registerAudioBecomeNoisy() {
+        if (mAudioBecomeNoisyListener == null) {
+            mAudioBecomeNoisyListener = new BroadcastReceiver() {
+                @Override
+                public void onReceive(Context context, Intent intent) {
+                    Log.d(LOGTAG, "FMMediaButtonIntentReceiver.AUDIO_BECOMING_NOISY");
+                    String intentAction = intent.getAction();
+                    if (FMMediaButtonIntentReceiver.AUDIO_BECOMING_NOISY.equals(intentAction)) {
+                       if (isFmOn())
+                       {
+                           /* Disable FM and let the UI know */
+                           fmOff();
+                           try
+                           {
+                              /* Notify the UI/Activity, only if the service is "bound"
+                              by an activity and if Callbacks are registered
+                              */
+                              if((mServiceInUse) && (mCallbacks != null) )
+                              {
+                                  mCallbacks.onDisabled();
+                              }
+                           } catch (RemoteException e)
+                           {
+                               e.printStackTrace();
+                           }
+                       }
+                    }
+                }
+            };
+            IntentFilter intentFilter = new IntentFilter(FMMediaButtonIntentReceiver.AUDIO_BECOMING_NOISY);
+            registerReceiver(mAudioBecomeNoisyListener, intentFilter);
+        }
+    }
+
     public void registerMusicServiceCommandReceiver() {
         if (mMusicCommandListener == null) {
             mMusicCommandListener = new BroadcastReceiver() {
@@ -599,6 +639,8 @@
             /* Update the UI based on the state change of the headset/antenna*/
             if(!isAntennaAvailable())
             {
+                if (!isFmOn())
+                    return;
                 /* Disable FM and let the UI know */
                 fmOff();
                 try
@@ -1142,11 +1184,26 @@
               switch (msg.arg1) {
                   case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
                       Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
+                  case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
+                      Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT");
+                      if (mSpeakerPhoneOn) {
+                         mSpeakerDisableHandler.removeCallbacks(mSpeakerDisableTask);
+                         mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
+                      }
+                      if (true == mPlaybackInProgress) {
+                          if(mMuted)
+                             unMute();
+                          stopFM();
+                      }
+                      if (mSpeakerPhoneOn) {
+                          if (isAnalogModeSupported())
+                              setAudioPath(false);
+                      }
+                      mStoppedOnFocusLoss = true;
+                      break;
                   case AudioManager.AUDIOFOCUS_LOSS:
                       Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS");
                       //intentional fall through.
-                  case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
-                      Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT");
                       if (true == isFmRecordingOn())
                           stopRecording();
                       if (mSpeakerPhoneOn) {
@@ -1739,6 +1796,12 @@
       if (isFmRecordingOn())
       {
           stopRecording();
+          try {
+               Thread.sleep(300);
+          } catch (Exception ex) {
+               Log.d( LOGTAG, "RunningThread InterruptedException");
+               return;
+          }
       }
       AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
       if(audioManager != null)
diff --git a/fmapp2/src/com/caf/fmradio/HorizontalNumberPicker.java b/fmapp2/src/com/caf/fmradio/HorizontalNumberPicker.java
index ac886bb..505097f 100644
--- a/fmapp2/src/com/caf/fmradio/HorizontalNumberPicker.java
+++ b/fmapp2/src/com/caf/fmradio/HorizontalNumberPicker.java
@@ -1600,7 +1600,11 @@
         for (int i = 0; i < mSelectorIndices.length; i++) {
             int selectorIndex = current + (i - mSelectorMiddleItemIndex);
             if (mWrapSelectorWheel) {
-                selectorIndex = getWrappedSelectorIndex(selectorIndex);
+                try {
+                    selectorIndex = getWrappedSelectorIndex(selectorIndex);
+                } catch(RuntimeException e) {
+                    e.printStackTrace();
+                }
             }
             mSelectorIndices[i] = selectorIndex;
             ensureCachedScrollSelectorValue(mSelectorIndices[i]);
@@ -1622,7 +1626,11 @@
         }
         // Wrap around the values if we go past the start or end
         if (mWrapSelectorWheel) {
-            current = getWrappedSelectorIndex(current);
+            try {
+                current = getWrappedSelectorIndex(current);
+            } catch(RuntimeException e) {
+                e.printStackTrace();
+            }
         }
         int previous = mValue;
         setValue(current);
diff --git a/fmapp2/src/com/caf/fmradio/PresetStation.java b/fmapp2/src/com/caf/fmradio/PresetStation.java
index 77bf648..bcbb55e 100644
--- a/fmapp2/src/com/caf/fmradio/PresetStation.java
+++ b/fmapp2/src/com/caf/fmradio/PresetStation.java
@@ -29,7 +29,7 @@
 package com.caf.fmradio;
 
 import qcom.fmradio.FmReceiver;
-
+import java.util.Locale;
 import android.text.TextUtils;
 //import android.util.Log;
 
@@ -638,132 +638,236 @@
       {
          case 1:
          {
-            ptyStr = "News";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "新闻";
+            else
+                ptyStr = "News";
             break;
          }
          case 2:
          {
-            ptyStr = "Information";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "信息频道";
+            else
+                ptyStr = "Information";
             break;
          }
          case 3:
          {
-            ptyStr = "Sports";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "体育";
+            else
+                ptyStr = "Sports";
             break;
          }
          case 4:
          {
-            ptyStr = "Talk";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "交流";
+            else
+                ptyStr = "Talk";
             break;
          }
          case 5:
          {
-            ptyStr = "Rock";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "摇滚";
+            else
+                ptyStr = "Rock";
             break;
          }
          case 6:
          {
-            ptyStr = "Classic Rock";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "经典摇滚";
+            else
+                ptyStr = "Classic Rock";
             break;
          }
          case 7:
          {
-            ptyStr = "Adult Hits";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "成人点击";
+            else
+                ptyStr = "Adult Hits";
             break;
          }
          case 8:
          {
-            ptyStr = "Soft Rock";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "轻摇滚";
+            else
+                ptyStr = "Soft Rock";
             break;
          }
          case 9:
          {
-            ptyStr = "Top 40";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "前40";
+            else
+                ptyStr = "Top 40";
             break;
          }
          case 10:
          {
-            ptyStr = "Country";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "乡村";
+            else
+                ptyStr = "Country";
             break;
          }
          case 11:
          {
-            ptyStr = "Oldies";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "老歌";
+            else
+                ptyStr = "Oldies";
             break;
          }
          case 12:
          {
-            ptyStr = "Soft";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "轻音乐";
+            else
+                ptyStr = "Soft";
             break;
          }
          case 13:
          {
-            ptyStr = "Nostalgia";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "怀旧";
+            else
+                ptyStr = "Nostalgia";
             break;
          }
          case 14:
          {
-            ptyStr = "Jazz";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "爵士";
+            else
+                ptyStr = "Jazz";
             break;
          }
          case 15:
          {
-            ptyStr = "Classical";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "古典";
+            else
+                ptyStr = "Classical";
             break;
          }
          case 16:
          {
-            ptyStr = "Rhythm and Blues";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "节奏布鲁斯";
+            else
+                ptyStr = "Rhythm and Blues";
             break;
          }
          case 17:
          {
-            ptyStr = "Soft Rhythm and Blues";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "轻节奏布鲁斯";
+            else
+                ptyStr = "Soft Rhythm and Blues";
             break;
          }
          case 18:
          {
-            ptyStr = "Foreign Language";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "外语频道";
+            else
+                ptyStr = "Foreign Language";
             break;
          }
          case 19:
          {
-            ptyStr = "Religious Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "宗教音乐";
+            else
+                ptyStr = "Religious Music";
             break;
          }
          case 20:
          {
-            ptyStr = "Religious Talk";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "宗教交流";
+            else
+                ptyStr = "Religious Talk";
             break;
          }
          case 21:
          {
-            ptyStr = "Personality";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "个性";
+            else
+                ptyStr = "Personality";
             break;
          }
          case 22:
          {
-            ptyStr = "Public";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "公共频道";
+            else
+                ptyStr = "Public";
             break;
          }
          case 23:
          {
-            ptyStr = "College";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "校园";
+            else
+                ptyStr = "College";
             break;
          }
          case 29:
          {
-            ptyStr = "Weather";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "天气";
+            else
+                ptyStr = "Weather";
             break;
          }
          case 30:
          {
-            ptyStr = "Emergency Test";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "紧急 测试";
+            else
+                ptyStr = "Emergency Test";
             break;
          }
          case 31:
          {
-            ptyStr = "Emergency";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "紧急";
+            else
+                ptyStr = "Emergency";
             break;
          }
          default:
@@ -784,157 +888,281 @@
       {
          case 1:
          {
-            ptyStr = "News";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "新闻";
+            else
+                ptyStr = "News";
             break;
          }
          case 2:
          {
-            ptyStr = "Current Affairs";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "新闻时事";
+            else
+                ptyStr = "Current Affairs";
             break;
          }
          case 3:
          {
-            ptyStr = "Information";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "信息";
+            else
+                ptyStr = "Information";
             break;
          }
          case 4:
          {
-            ptyStr = "Sport";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "体育";
+            else
+                ptyStr = "Sport";
             break;
          }
          case 5:
          {
-            ptyStr = "Education";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "教育";
+            else
+                ptyStr = "Education";
             break;
          }
          case 6:
          {
-            ptyStr = "Drama";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "戏剧";
+            else
+                ptyStr = "Drama";
             break;
          }
          case 7:
          {
-            ptyStr = "Culture";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "文化";
+            else
+                ptyStr = "Culture";
             break;
          }
          case 8:
          {
-            ptyStr = "Science";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "科学";
+            else
+                ptyStr = "Science";
             break;
          }
          case 9:
          {
-            ptyStr = "Varied";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "变奏";
+            else
+                ptyStr = "Varied";
             break;
          }
          case 10:
          {
-            ptyStr = "Pop Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "流行音乐";
+            else
+                ptyStr = "Pop Music";
             break;
          }
          case 11:
          {
-            ptyStr = "Rock Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "摇滚音乐";
+            else
+                ptyStr = "Rock Music";
             break;
          }
          case 12:
          {
-            ptyStr = "Easy Listening Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "轻音乐";
+            else
+                ptyStr = "Easy Listening Music";
             break;
          }
          case 13:
          {
-            ptyStr = "Light classical";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "轻古典音乐";
+            else
+                ptyStr = "Light classical";
             break;
          }
          case 14:
          {
-            ptyStr = "Serious classical";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "古典";
+            else
+                ptyStr = "Serious classical";
             break;
          }
          case 15:
          {
-            ptyStr = "Other Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "其他音乐";
+            else
+                ptyStr = "Other Music";
             break;
          }
          case 16:
          {
-            ptyStr = "Weather";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "天气";
+            else
+                ptyStr = "Weather";
             break;
          }
          case 17:
          {
-            ptyStr = "Finance";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "经济";
+            else
+                ptyStr = "Finance";
             break;
          }
          case 18:
          {
-            ptyStr = "Children programs";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "儿童节目";
+            else
+                ptyStr = "Children programs";
             break;
          }
          case 19:
          {
-            ptyStr = "Social Affairs";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "社会事务";
+            else
+                ptyStr = "Social Affairs";
             break;
          }
          case 20:
          {
-            ptyStr = "Religion";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "宗教";
+            else
+                ptyStr = "Religion";
             break;
          }
          case 21:
          {
-            ptyStr = "Phone In";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "听众来电";
+            else
+                ptyStr = "Phone In";
             break;
          }
          case 22:
          {
-            ptyStr = "Travel";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "旅行";
+            else
+                ptyStr = "Travel";
             break;
          }
          case 23:
          {
-            ptyStr = "Leisure";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "休闲";
+            else
+                ptyStr = "Leisure";
             break;
          }
          case 24:
          {
-            ptyStr = "Jazz Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "爵士音乐";
+            else
+                ptyStr = "Jazz Music";
             break;
          }
          case 25:
          {
-            ptyStr = "Country Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "乡村音乐";
+            else
+                ptyStr = "Country Music";
             break;
          }
          case 26:
          {
-            ptyStr = "National Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "民族音乐";
+            else
+                ptyStr = "National Music";
             break;
          }
          case 27:
          {
-            ptyStr = "Oldies Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "怀旧";
+            else
+                ptyStr = "Oldies Music";
             break;
          }
          case 28:
          {
-            ptyStr = "Folk Music";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "民族音乐";
+            else
+                ptyStr = "Folk Music";
             break;
          }
          case 29:
          {
-            ptyStr = "Documentary";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "记录";
+            else
+                ptyStr = "Documentary";
             break;
          }
          case 30:
          {
-            ptyStr = "Emergency Test";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "紧急测试";
+            else
+                ptyStr = "Emergency Test";
             break;
          }
          case 31:
          {
-            ptyStr = "Emergency";
+            if ((Locale.getDefault().getLanguage().equals("zh"))
+                || (Locale.getDefault().getLanguage().equals("zh_CN")))
+                ptyStr = "紧急";
+            else
+                ptyStr = "Emergency";
             break;
          }
          default:
diff --git a/fmapp2/src/com/caf/fmradio/Settings.java b/fmapp2/src/com/caf/fmradio/Settings.java
index d64621b..03f88c1 100644
--- a/fmapp2/src/com/caf/fmradio/Settings.java
+++ b/fmapp2/src/com/caf/fmradio/Settings.java
@@ -317,7 +317,8 @@
                   setBandSummary(summaryBandItems.length - 1);
                   clearStationList();
                }else {
-                  displayToast(USR_BAND_MSG);
+                  Toast.makeText(this, getString(R.string.user_defind_band_msg),
+                                                            Toast.LENGTH_SHORT).show();
                }
            }else if(key.equals(USER_DEFINED_BAND_MAX_KEY)) {
                String valStr = mUserBandMaxPref.getText();
@@ -336,7 +337,8 @@
                   setBandSummary(summaryBandItems.length - 1);
                   clearStationList();
                }else {
-                  displayToast(USR_BAND_MSG);
+                  Toast.makeText(this, getString(R.string.user_defind_band_msg),
+                                                            Toast.LENGTH_SHORT).show();
                }
           }else {
               if(mRxMode) {