gt:                 return new AtCommandResult("1");               
context: /* Copyright Statement:
   *
   * This software/firmware and related documentation ("MediaTek Software") are
   * protected under relevant copyright laws. The information contained herein is
   * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
   * the prior written permission of MediaTek inc. and/or its licensors, any
   * reproduction, modification, use or disclosure of MediaTek Software, and
   * information contained herein, in whole or in part, shall be strictly
   * prohibited.
   * 
   * MediaTek Inc. (C) 2010. All rights reserved.
   * 
   * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
   * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
   * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
   * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
   * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
   * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
   * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
   * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
   * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
   * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
   * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
   * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
   * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
   * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
   * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
   * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
   * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
   * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
   * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
   *
   * The following software/firmware and/or related documentation ("MediaTek
   * Software") have been modified by MediaTek Inc. All revisions are subject to
   * any receiver's applicable license agreements with MediaTek Inc.
   */
  
  /**
   *
   */
  package com.mediatek.atci.service;
  
  import android.app.Service;
  
  import android.bluetooth.AtCommandHandler;
  import android.bluetooth.AtCommandResult;
  import android.bluetooth.AtParser;
  import android.bluetooth.BluetoothAdapter;
  
  import android.content.BroadcastReceiver;
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.content.ServiceConnection;
  
  import android.database.SQLException;
  import android.database.sqlite.SQLiteDatabase;
  import android.location.LocationManager;
  import android.media.AudioManager;
  
  import android.net.LocalSocket;
  import android.net.LocalSocketAddress;
  import android.net.Uri;
  import android.net.wifi.WifiManager;
  
  import android.os.Build;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.IBinder;
  import android.os.Message;
  import android.os.PowerManager;
  import android.os.PowerManager.WakeLock;
  import android.os.RemoteException;
  import android.os.ServiceManager;
  import android.os.SystemProperties;
  import android.os.storage.StorageEventListener;
  import android.os.storage.StorageManager;
  import android.os.storage.StorageVolume;
  
  //import android.os.SystemProperties;
  
  import android.provider.Settings;
  import android.util.Log;
  
  import com.android.internal.os.storage.ExternalStorageFormatter;
  import com.android.internal.telephony.ITelephony;
  import com.mediatek.common.featureoption.FeatureOption;
  
  import java.io.IOException;
  import java.io.InterruptedIOException;
  import java.nio.channels.ClosedByInterruptException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  import java.util.Arrays;
  import java.util.Locale;
  
  
  /**
   * @author mtk03594
   *
   */
  public class AtciService extends Service {
      static final String LOG_TAG = "ATCIJ";
      static final String SOCKET_NAME_ATCI = "atci-serv-fw";
      private static final String EMERGENCY_CALL_ACTION = "android.location.agps.EMERGENCY_CALL";
      private static final boolean DBG = true;
  
      private static final char[] HEX_EX_STRING = new char[] {0x02,0x03};
  
      static final int SOCKET_OPEN_RETRY_MILLIS = 4 * 1000;
      static final int ATCI_MAX_BUFFER_BYTES = 1024;
  
      static final int NUM_ZERO = 0;
      static final int NUM_ONE = 1;
      static final int NUM_TWO = 2;
      static final int NUM_THREE = 3;
      static final int NUM_FOUR = 4;
      static final int NUM_FIVE = 5;
      static final int NUM_SIX = 6;
      static final int NUM_SEVEN = 7;
      static final int NUM_TEN = 10;
      static final int NUM_ELEVEN = 11;
      static final int NUM_TWELVE = 12;
      static final int NUM_SIXTEEN = 16;
      static final int NUM_FORTY_TWO = 42;
      static final int THREAD_SLEEP_ONE = 2000;
      static final int THREAD_SLEEP_TWO = 4000;
      
      static final String ECALL_NUMBER = "112";
  
      LocalSocket mSocket;
      Thread mReceiverThread;
      AtciReceiver mReceiver;
      AtParser mAtParser;
      Context mContext;
      private WakeLock mWakeLock;  // held while processing an AT command    
      private WakeLock mFullWakeLock;
      private int mEcallState = 0; //The ECALL is in Idle state
      private char mMp3PlayerMode = '0';
  
      private IFMRadioService mFMRadioService = null;
      private boolean mIsFMRadioPlaying = false;
      public static final int FIRST_FREQUENCY = 901;
      public static final int SECOND_FREQUENCY = 1063;
      public static final int LOWEST_STATION = 875;
      public static final int HIGHEST_STATION = 1080;
      public static final int DEFAULT_FREQUENCY = 1000;
      private int mCurrentStation = DEFAULT_FREQUENCY;
      private boolean mIsFMRadioServiceStarted = false;
      private boolean mIsFMRadioServiceBinded = false;
      private AudioManager mAudioManager = null;
      private boolean mIsFMRadioSeeking = false;
      private boolean mIsFMRadioDoSeek = false;
      private boolean mIsFMRadioSeekUp = false;
      private AtCommandResult mFMRadioAtCommandResult = null;
      private Thread mFMRadioSeekThread = null;
      public static final String TYPE_MSGID = "MSGID";
      public static final String TYPE_SEEK_STATION = "SEEK_STATION";
      public static final int MSGID_SEEK_FINISH = 6;
      public static final int MSGID_SEEK_FAIL = 7;
      private static final int FMRADIO_POWER_OFF = 0;
      private static final int FMRADIO_FIRST_STATION = 1;
      private static final int FMRADIO_SECOND_STATION = 2;
      private static final int FMRADIO_SEEK_UP = 3;
      private static final int FMRADIO_SEEK_DOWN = 4; 
   // frequency is float,in database as int, use to convert
      private static final int FREQUENCY_CONVERT_RATE = 10;  
      private static final int WAIT_TIME = 1000; 
      static {
          System.loadLibrary("atciserv_jni");
      }
  
      /* (non-Javadoc)
       * @see android.app.Service#onBind(android.content.Intent)
       */
      @Override
      public IBinder onBind(Intent arg0) {
          // TODO Auto-generated method stub
          return null;
      }
  
      @Override
      public void onCreate() {
          // TODO Auto-generated method stub
          super.onCreate();
          mReceiver = new AtciReceiver();
          mReceiverThread = new Thread(mReceiver, "AtciReceiver");
          mReceiverThread.start();
  
          mContext = getApplicationContext();
          PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
          mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AtciService");
          mWakeLock.setReferenceCounted(false);
          mFullWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
                          PowerManager.ACQUIRE_CAUSES_WAKEUP, "AtciService");
  
          //Construct one At command parser
          mAtParser = new AtParser();
  
          initializeAtParser();
          
          IntentFilter atciIntentFilter = new IntentFilter();
          atciIntentFilter.addAction(EMERGENCY_CALL_ACTION);
          mContext.registerReceiver(mEccStateReceiver, atciIntentFilter);
      }
  
      private String formatResponse(String res) {
          return String.format("%c%s%c", HEX_EX_STRING[0],res,HEX_EX_STRING[1]);
      }
  
      protected void initializeAtDB() {
          //AT% Commands Name : INITDB 
          //Description : Apply to all the model used in DB Creation
          //Commands Syntax :  AT%INITDB / AT% INITDB?
          mAtParser.register("%INITDB", new AtCommandHandler() {
              private SQLiteDatabase mDb;
              private static final String AT_DB_TABLE = "at_table";
              private static final String STR_ID = "_id";
              private static final String NAME = "name";
              private static final String DESCRIPTION = "description";
  
              private AtCommandResult initDB() {
                  try {
                      mDb = SQLiteDatabase.create(null);
                      mDb.execSQL("CREATE TABLE IF NOT EXISTS " + AT_DB_TABLE + " (" +
                          STR_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
                          NAME + " TEXT COLLATE LOCALIZED," +
                          DESCRIPTION + " description TEXT" +
                          ");");
                  } catch (SQLException e) {
                      Log.e(LOG_TAG, "error when initDB! Exception = " + e);
                  }
                  
                  if (mDb.isOpen()) {
                      mDb.close();
                      return new AtCommandResult("1");
                  } else {
                      return new AtCommandResult("0");
                  }                
              }
  
              @Override
              public AtCommandResult handleActionCommand() {
                  return initDB();
              }
  
              @Override
              public AtCommandResult handleReadCommand() {
                  return initDB();
              }
          });
  
          //AT% Commands Name : DBCHK 
          //Description : DB Check sum Check
          //Commands Syntax :  AT%DBCHK / AT% DBCHK?
          mAtParser.register("%DBCHK", new AtCommandHandler() {
              private AtCommandResult checkDB() {
  