FM: QSSI changes
- remove redundant code
- remove items going into vendor image
- remove target specific tags
Change-Id: If3bd34bbdc353851a1007ff9fcb67cf44da8f61c
diff --git a/Android.mk b/Android.mk
index c5b42d9..be7cefc 100644
--- a/Android.mk
+++ b/Android.mk
@@ -4,10 +4,6 @@
LOCAL_MODULE_TAGS := optional
-#ifneq ($(TARGET_USES_AOSP),true)
-
-#ifeq ($(BOARD_HAVE_QCOM_FM),true)
-#ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
LOCAL_SRC_FILES := $(call all-java-files-under, qcom/fmradio)
LOCAL_JNI_SHARED_LIBRARIES := libqcomfm_jni
@@ -20,25 +16,13 @@
ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee")
LOCAL_CFLAGS += -DFM_SOC_TYPE_CHEROKEE
endif
+
include $(LOCAL_PATH)/jni/Android.mk
LOCAL_PATH := $(LOCAL_DIR_PATH)
include $(LOCAL_PATH)/fmapp2/Android.mk
-#LOCAL_PATH := $(LOCAL_DIR_PATH)
-#include $(LOCAL_PATH)/FMRecord/Android.mk
-
LOCAL_PATH := $(LOCAL_DIR_PATH)
include $(LOCAL_PATH)/fm_hci/Android.mk
LOCAL_PATH := $(LOCAL_DIR_PATH)
include $(LOCAL_PATH)/helium/Android.mk
-
-LOCAL_PATH := $(LOCAL_DIR_PATH)
-#include $(LOCAL_PATH)/fmhalService/Android.mk
-
-#endif # is-vendor-board-platform
-#endif # BOARD_HAVE_QCOM_FM
-#endif # Not (TARGET_USES_AOSP)
-
-LOCAL_PATH := $(LOCAL_DIR_PATH)
-include $(LOCAL_PATH)/libfm_jni/Android.mk
diff --git a/FMRecord/Android.mk b/FMRecord/Android.mk
deleted file mode 100644
index b248bc3..0000000
--- a/FMRecord/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-ifeq ($(BOARD_HAVE_QCOM_FM),true)
-ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src/com/codeaurora/fmrecording/)
-
-LOCAL_PACKAGE_NAME := FMRecord
-LOCAL_CERTIFICATE := platform
-LOCAL_PROGUARD_ENABLED := disabled
-include $(BUILD_PACKAGE)
-endif
-endif # BOARD_HAVE_QCOM_FM
diff --git a/FMRecord/AndroidManifest.xml b/FMRecord/AndroidManifest.xml
deleted file mode 100644
index c1df646..0000000
--- a/FMRecord/AndroidManifest.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 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.
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.codeaurora.fmrecording" >
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
- <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
- <uses-permission android:name="android.permission.REAL_GET_TASKS" />
-
-<application>
-
-<receiver android:name="FMRecordingReceiver">
- <intent-filter>
- <action android:name="codeaurora.intent.action.FM" />
- </intent-filter>
-</receiver>
-
-<service android:name="com.codeaurora.fmrecording.FMRecordingService"></service>
-</application>
-</manifest>
diff --git a/FMRecord/res/drawable/ic_menu_record.png b/FMRecord/res/drawable/ic_menu_record.png
deleted file mode 100755
index 60f7a01..0000000
--- a/FMRecord/res/drawable/ic_menu_record.png
+++ /dev/null
Binary files differ
diff --git a/FMRecord/res/layout/record_status_bar.xml b/FMRecord/res/layout/record_status_bar.xml
deleted file mode 100644
index 9651fd0..0000000
--- a/FMRecord/res/layout/record_status_bar.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2013-14, 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fmradio"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/record_label"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:textColor="#000000"
- android:text="@string/fm_record_progress"/>
-
-</RelativeLayout>
diff --git a/FMRecord/res/values-zh-rCN/strings.xml b/FMRecord/res/values-zh-rCN/strings.xml
deleted file mode 100644
index 660f743..0000000
--- a/FMRecord/res/values-zh-rCN/strings.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright (C) 2012-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 "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.
- */
- -->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="spaceIsLow_content">"USB 存储设备空间不足,请更改录音时长设置,或删除某些录音或者其他文件。</string>
-
- <!-- prompt message for stopping record -->
- <string name="save_record_file">"录音已保存至 "<xliff:g id="record_file">%1$s</xliff:g>"</string>
- <!-- all recordings will show up in the media database with this 'artist' name -->
- <string name="audio_db_artist_name">我的 FM 录音</string>
- <!-- all recordings will show up in the media database with this 'album' name -->
- <string name="audio_db_album_name">FM 录音</string>
- <!-- 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-zh-rTW/strings.xml b/FMRecord/res/values-zh-rTW/strings.xml
deleted file mode 100644
index 8820deb..0000000
--- a/FMRecord/res/values-zh-rTW/strings.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
-Copyright (c) 2012, 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 "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.
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="spaceIsLow_content">USB 存儲設備空間不足,請更改錄音時長設置,或刪除某些錄音或者其他檔案。</string>
- <string name="sdcard_no_space_cannot_recording">SD卡空間不足,不能錄音</string>
- <string name="recording_stop_no_space">SD卡空間不足,錄音停止</string>
- <string name="audio_db_artist_name">我的FM錄音</string>
- <!-- all recordings will show up in the media database with this 'album' name -->
- <string name="audio_db_album_name">FM 錄音</string>
- <!-- 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="unable_to_store">無法保存已錄音頻</string>
- <string name="FMRecording_reach_size_limit">已到達最長限制.</string>
- <!-- prompt message for stopping record -->
- <string name="save_record_file">錄音已保存至 "<xliff:g id="record_file">%1$s</xliff:g>"</string>
-</resources>
diff --git a/FMRecord/res/values/customize.xml b/FMRecord/res/values/customize.xml
deleted file mode 100644
index 1ef358c..0000000
--- a/FMRecord/res/values/customize.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Copyright (c) 2014, 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 "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.
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-
- <!-- enabled the prefix of recordings files name or not,default value is false -->
- <bool name="def_save_name_prefix_enabled">false</bool>
-
- <!-- the prefix of recordings files name.File name like this "FM-yyyy-MM-dd-HH-mm-ss.3gpp" -->
- <string name="def_save_name_prefix" translatable="false">FM</string>
-
- <!-- enabled the name format of recordings files or not,default value is false -->
- <bool name="def_save_name_format_enabled">false</bool>
-
- <!-- the name format of recordings files -->
- <string name="def_save_name_format" translatable="false">yyyy-MM-dd-HH-mm-ss</string>
-
- <!-- the save path of recordings files -->
- <string name="def_fmRecord_savePath" translatable="false">/SoundRecorder</string>
-
- <!-- the suffix of recordings files.default value is ".3gpp" -->
- <string name="def_save_name_suffix" translatable="false">.3gpp</string>
-
-</resources>
diff --git a/FMRecord/res/values/strings.xml b/FMRecord/res/values/strings.xml
deleted file mode 100644
index 244d41c..0000000
--- a/FMRecord/res/values/strings.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- alert to the user that USB storage must be available before using FM recording [CHAR LIMIT=NONE] -->
- <string name="no_storage">Mount SD card before start recording.</string>
- <!-- alert to the user that the USB storage is being disk-checked [CHAR LIMIT=30] -->
- <string name="preparing_sd">Preparing SD card</string>
- <!-- alert to the user that the FM fails to read or write the USB storage. [CHAR LIMIT=NONE] -->
- <string name="access_sd_fail">Couldn\'t access SD card.</string>
- <!-- Low-memory dialog message [CHAR LIMT=NONE] -->
- <string name="spaceIsLow_content">Your SD card storage is running out of space. Change the quality setting or delete some images or other files.</string>
- <!-- The messsage shown when FM record reaches size limit. -->
- <string name="FMRecording_reach_size_limit">Size limit reached.</string>
- <!-- the name under which recordings will be visible in the media database is formatted like this -->
- <string name="audio_db_title_format"><xliff:g id="format">yyyy-MM-dd HH:mm:ss</xliff:g></string>
- <!-- all recordings will show up in the media database with this 'artist' name -->
- <string name="audio_db_artist_name">My FM recordings</string>
- <!-- all recordings will show up in the media database with this 'album' name -->
- <string name="audio_db_album_name">FM recordings</string>
- <!-- all recordings will show up in the media database in a playlist with this name -->
- <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/FMRecordingReceiver.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingReceiver.java
deleted file mode 100644
index 9389f10..0000000
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingReceiver.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 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.fmrecording;
-
-import android.content.Intent;
-import android.content.BroadcastReceiver;
-import android.content.pm.PackageManager;
-import android.content.Context;
-import android.content.ComponentName;
-import android.util.Log;
-import java.lang.String;
-
-
-public class FMRecordingReceiver extends BroadcastReceiver {
-
- private static final String TAG = "FMRecordingReceiver";
- public static final String ACTION_FM =
- "codeaurora.intent.action.FM";
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- Log.d(TAG, "Received intent: " + action);
- if((action != null) && action.equals(ACTION_FM)) {
- Log.d(TAG, "FM intent received");
- Intent in = new Intent();
- in.putExtras(intent);
- in.setClass(context, FMRecordingService.class);
- int state = intent.getIntExtra("state", 0);
- boolean startService = true;
-
- if (state == 1) {
- Log.d(TAG, "FM ON intent received");
- startService = true;
- context.startService(in);
- } else if(state == 0){
- Log.d(TAG, "FM OFF intent received");
- startService = false;
- context.stopService(in);
- }
- }
- }
-}
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
deleted file mode 100644
index 2aa1684..0000000
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * Copyright (c) 2013-2014, 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.fmrecording;
-
-import java.util.*;
-import android.app.Service;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.BroadcastReceiver;
-import android.media.AudioManager;
-import android.media.AudioManager.OnAudioFocusChangeListener;
-import android.media.AudioSystem;
-import android.media.MediaRecorder;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.util.Log;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import android.provider.MediaStore;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.database.Cursor;
-import java.io.File;
-import android.widget.Toast;
-import android.os.UserHandle;
-import android.net.Uri;
-import android.content.res.Resources;
-import android.os.StatFs;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.widget.RemoteViews;
-import android.R.layout;
-import android.R.drawable;
-import android.content.ComponentName;
-import android.content.res.Resources;
-import android.os.Process;
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningAppProcessInfo;
-
-public class FMRecordingService extends Service {
- private static final String TAG = "FMRecordingService";
- private BroadcastReceiver mFmRecordingReceiver = null;
- private BroadcastReceiver mFmShutdownReceiver = null;
- public static final long UNAVAILABLE = -1L;
- public static final long PREPARING = -2L;
- public static final long UNKNOWN_SIZE = -3L;
- public static final long LOW_STORAGE_THRESHOLD = 50000000;
- private long mStorageSpace;
- private boolean mFmRecordingOn = false;
- public static final String ACTION_FM_RECORDING =
- "codeaurora.intent.action.FM_Recording";
- public static final String ACTION_FM_RECORDING_STATUS =
- "codeaurora.intent.action.FM.Recording.Status";
-
- private File mSampleFile = null;
- private MediaRecorder mRecorder = null;
- private long mSampleStart = 0;
- static final int START = 1;
- static final int STOP = 0;
- private int mRecordDuration = -1;
- private Thread mStatusCheckThread = null;
- private int clientPid = -1;
- private String clientProcessName = "";
- private String mAudioType = "audio/*";
- private long startTimerMs = 0;
- private long stopTimerMs = 0;
-
- public void onCreate() {
-
- super.onCreate();
- Log.d(TAG, "FMRecording Service onCreate");
- registerRecordingListner();
- registerShutdownListner();
- }
-
- public int onStartCommand(Intent intent, int flags, int startId) {
-
- Log.d(TAG, "FMRecording Service onCreate");
- return START_NOT_STICKY;
- }
-
- public void onDestroy() {
- Log.d(TAG, "FMRecording Service onDestroy");
- if (mFmRecordingOn == true) {
- Log.d(TAG, "Still recording on progress, Stoping it");
- stopRecord();
- }
- unregisterBroadCastReceiver(mFmRecordingReceiver);
- unregisterBroadCastReceiver(mFmShutdownReceiver);
- super.onDestroy();
- }
-
- public IBinder onBind(Intent intent) {
- Log.v(TAG, "FMRecording Service onBind");
- return null;
- }
-
- private void unregisterBroadCastReceiver(BroadcastReceiver myreceiver) {
-
- if (myreceiver != null) {
- unregisterReceiver(myreceiver);
- myreceiver = null;
- }
- }
-
- private void registerShutdownListner() {
- if (mFmShutdownReceiver == null) {
- mFmShutdownReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(TAG, "Received intent " +intent);
- String action = intent.getAction();
- Log.d(TAG, " action = " +action);
- if (action.equals("android.intent.action.ACTION_SHUTDOWN")) {
- Log.d(TAG, "android.intent.action.ACTION_SHUTDOWN Intent received");
- stopRecord();
- }
- }
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction("android.intent.action.ACTION_SHUTDOWN");
- registerReceiver(mFmShutdownReceiver, iFilter);
- }
- }
-
- private static long getAvailableSpace() {
- String state = Environment.getExternalStorageState();
- Log.d(TAG, "External storage state=" + state);
- if (Environment.MEDIA_CHECKING.equals(state)) {
- return PREPARING;
- }
- if (!Environment.MEDIA_MOUNTED.equals(state)) {
- return UNAVAILABLE;
- }
-
- try {
- File sampleDir = Environment.getExternalStorageDirectory();
- StatFs stat = new StatFs(sampleDir.getAbsolutePath());
- return stat.getAvailableBlocks() * (long) stat.getBlockSize();
- } catch (Exception e) {
- Log.i(TAG, "Fail to access external storage", e);
- }
- return UNKNOWN_SIZE;
- }
-
- private boolean updateAndShowStorageHint() {
- mStorageSpace = getAvailableSpace();
- return showStorageHint();
- }
-
- private boolean showStorageHint() {
- String errorMessage = null;
- if (mStorageSpace == UNAVAILABLE) {
- errorMessage = getString(R.string.no_storage);
- } else if (mStorageSpace == PREPARING) {
- errorMessage = getString(R.string.preparing_sd);
- } else if (mStorageSpace == UNKNOWN_SIZE) {
- errorMessage = getString(R.string.access_sd_fail);
- } else if (mStorageSpace < LOW_STORAGE_THRESHOLD) {
- errorMessage = getString(R.string.spaceIsLow_content);
- }
-
- if (errorMessage != null) {
- Toast.makeText(this, errorMessage,
- Toast.LENGTH_LONG).show();
- return false;
- }
- return true;
- }
-
- private void sendRecordingStatusIntent(int status) {
- Intent intent = new Intent(ACTION_FM_RECORDING_STATUS);
- intent.putExtra("state", status);
- Log.d(TAG, "posting intent for FM Recording status as = " +status);
- getApplicationContext().sendBroadcastAsUser(intent, UserHandle.ALL);
- }
- private boolean startRecord() {
-
- Log.d(TAG, "Enter startRecord");
- if (mRecorder != null) { /* Stop existing recording if any */
- Log.d(TAG, "Stopping existing record");
- try {
- mRecorder.stop();
- mRecorder.reset();
- mRecorder.release();
- mRecorder = null;
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- if (!updateAndShowStorageHint())
- return false;
- long maxFileSize = mStorageSpace - LOW_STORAGE_THRESHOLD;
- mRecorder = new MediaRecorder();
- try {
- mRecorder.setMaxFileSize(maxFileSize);
- if(mRecordDuration >= 0)
- mRecorder.setMaxDuration(mRecordDuration);
- } catch (RuntimeException exception) {
-
- }
- mSampleFile = null;
- File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording");
-
- if (getResources().getBoolean(R.bool.def_save_name_prefix_enabled)) {
- String fmRecordSavePath = getApplicationContext().getResources()
- .getString(R.string.def_fmRecord_savePath);
- sampleDir = new File(Environment.getExternalStorageDirectory().toString()
- + fmRecordSavePath);
- if (!sampleDir.exists()) {
- sampleDir.mkdirs();
- }
- }
- if(!(sampleDir.mkdirs() || sampleDir.isDirectory()))
- return false;
-
- try {
- mSampleFile = File.createTempFile("FMRecording", ".3gpp", sampleDir);
- if (getResources().getBoolean(R.bool.def_save_name_format_enabled)) {
- String suffix = getResources().getString(R.string.def_save_name_suffix);
- suffix = "".equals(suffix) ? ".3gpp" : suffix;
- mSampleFile = createTempFile("FMRecording", suffix, sampleDir);
- }
- } catch (IOException e) {
- Log.e(TAG, "Not able to access SD Card");
- Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show();
- }
- try {
- Log.d(TAG, "AudioSource.FM_RX" +MediaRecorder.AudioSource.FM_RX);
- mRecorder.setAudioSource(MediaRecorder.AudioSource.FM_RX);
- mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
- mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
- mAudioType = "audio/3gpp";
- } catch (RuntimeException exception) {
- Log.d(TAG, "RuntimeException while settings");
- mRecorder.reset();
- mRecorder.release();
- mRecorder = null;
- return false;
- }
- Log.d(TAG, "setOutputFile");
- mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
- try {
- mRecorder.prepare();
- Log.d(TAG, "start");
- mRecorder.start();
- startTimerMs = System.currentTimeMillis();
- } catch (IOException e) {
- Log.d(TAG, "IOException while start");
- mRecorder.reset();
- mRecorder.release();
- mRecorder = null;
- return false;
- } catch (RuntimeException e) {
- Log.d(TAG, "RuntimeException while start");
- mRecorder.reset();
- mRecorder.release();
- mRecorder = null;
- return false;
- }
- mFmRecordingOn = true;
- Log.d(TAG, "mSampleFile.getAbsolutePath() " +mSampleFile.getAbsolutePath());
- mRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
- public void onInfo(MediaRecorder mr, int what, int extra) {
- if ((what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) ||
- (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED)) {
- if (mFmRecordingOn) {
- Log.d(TAG, "Maximum file size/duration reached, stopping the recording");
- stopRecord();
- }
- 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
- public void onError(MediaRecorder mr, int what, int extra) {
- Log.e(TAG, "MediaRecorder error. what=" + what + ". extra=" + extra);
- if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) {
- // We may have run out of space on the sdcard.
- if (mFmRecordingOn) {
- stopRecord();
- }
- updateAndShowStorageHint();
- }
- }
- });
- mSampleStart = System.currentTimeMillis();
- sendRecordingStatusIntent(START);
- startNotification();
- return true;
- }
-
- private void startNotification() {
- RemoteViews views = new RemoteViews(getPackageName(), R.layout.record_status_bar);
- Notification status = new Notification();
- status.contentView = views;
- status.flags |= Notification.FLAG_ONGOING_EVENT;
- status.icon = R.drawable.ic_menu_record;
- startForeground(102, status);
- }
-
- private void stopRecord() {
- Log.d(TAG, "Enter stopRecord");
- mFmRecordingOn = false;
- if (mRecorder == null)
- return;
- try {
- mRecorder.stop();
- stopTimerMs = System.currentTimeMillis();
- mRecorder.reset();
- mRecorder.release();
- mRecorder = null;
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- sendRecordingStatusIntent(STOP);
- saveFile();
- stopForeground(true);
- stopClientStatusCheck();
- }
-
- private void saveFile() {
- int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 );
- Log.d(TAG, "Enter saveFile");
- if (sampleLength == 0)
- return;
- String state = Environment.getExternalStorageState();
- Log.d(TAG, "storage state is " + state);
-
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- try {
- this.addToMediaDB(mSampleFile);
- Toast.makeText(this,getString(R.string.save_record_file,
- mSampleFile.getAbsolutePath( )),
- Toast.LENGTH_LONG).show();
- } catch(Exception e) {
- e.printStackTrace();
- }
- } else {
- Log.e(TAG, "SD card must have removed during recording. ");
- Toast.makeText(this, "Recording aborted", Toast.LENGTH_SHORT).show();
- }
- return;
- }
-
- /*
- * Adds file and returns content uri.
- */
- private Uri addToMediaDB(File file) {
- Log.d(TAG, "In addToMediaDB");
- Resources res = getResources();
- ContentValues cv = new ContentValues();
- int audioId = -1;
- long current = System.currentTimeMillis();
- long modDate = file.lastModified();
- long recordDuration = stopTimerMs - startTimerMs;
- Date date = new Date(current);
- SimpleDateFormat formatter = new SimpleDateFormat(
- res.getString(R.string.audio_db_title_format));
- String title = formatter.format(date);
-
- // Lets label the recorded audio file as NON-MUSIC so that the file
- // won't be displayed automatically, except for in the playlist.
- cv.put(MediaStore.Audio.Media.IS_MUSIC, "1");
- cv.put(MediaStore.Audio.Media.TITLE, title);
- cv.put(MediaStore.Audio.Media.DATA, file.getAbsolutePath());
- cv.put(MediaStore.Audio.Media.DATE_ADDED, (int) (current / 1000));
- cv.put(MediaStore.Audio.Media.DATE_MODIFIED, (int) (modDate / 1000));
- cv.put(MediaStore.Audio.Media.DURATION, recordDuration);
- cv.put(MediaStore.Audio.Media.MIME_TYPE, mAudioType);
- cv.put(MediaStore.Audio.Media.ARTIST,
- res.getString(R.string.audio_db_artist_name));
- cv.put(MediaStore.Audio.Media.ALBUM,
- res.getString(R.string.audio_db_album_name));
- audioId = getFileIdInVideoDB(file);
- if (audioId != -1) {//remove the record if it is already added into video table.
- removeRecordInVideoDB(audioId);
- Log.d(TAG, "Remove audio record " + audioId + " in video database");
- }
- Log.d(TAG, "Inserting audio record: " + cv.toString());
- ContentResolver resolver = getContentResolver();
- Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
- Log.d(TAG, "ContentURI: " + base);
- Uri result = resolver.insert(base, cv);
- if (result == null) {
- Toast.makeText(this, R.string.unable_to_store, Toast.LENGTH_SHORT).show();
- return null;
- }
- if (getPlaylistId(res) == -1) {
- createPlaylist(res, resolver);
- }
- audioId = Integer.valueOf(result.getLastPathSegment());
- addToPlaylist(resolver, audioId, getPlaylistId(res));
-
- // Notify those applications such as Music listening to the
- // scanner events that a recorded audio file just created.
- sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, result));
- return result;
- }
-
- private int getFileIdInVideoDB(File file) {
- int id = -1;
- final String where = MediaStore.Video.Media.DATA + "=?";
- final String[] args = new String[] { file.getAbsolutePath() };
- final String[] ids = new String[] { MediaStore.Video.Media._ID };
- Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
-
- Cursor cursor = query(base, ids, where, args, null);
- if (cursor == null) {
- Log.v(TAG, "Data query returns null");
- } else {
- if (cursor.moveToNext() != false) {
- id = cursor.getInt(0);
- cursor.close();
- }
- }
- return id;
- }
-
- private void removeRecordInVideoDB(int id) {
- final String where = MediaStore.Video.Media._ID + "=" + id;
- Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
- ContentValues cv = new ContentValues();
- ContentResolver resolver = getContentResolver();
-
- cv.put(MediaStore.Video.Media.DATA, "null");
- resolver.update(base, cv, where, null);
- resolver.delete(base, where, null);
- }
-
- private int getPlaylistId(Resources res) {
- Uri uri = MediaStore.Audio.Playlists.getContentUri("external");
- final String[] ids = new String[] { MediaStore.Audio.Playlists._ID };
- final String where = MediaStore.Audio.Playlists.NAME + "=?";
- final String[] args = new String[] { res.getString(R.string.audio_db_playlist_name) };
- Cursor cursor = query(uri, ids, where, args, null);
- if (cursor == null) {
- Log.v(TAG, "query returns null");
- }
- int id = -1;
- if (cursor != null) {
- cursor.moveToFirst();
- if (!cursor.isAfterLast()) {
- id = cursor.getInt(0);
- }
- cursor.close();
- }
- return id;
- }
-
- private Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- try {
- ContentResolver resolver = getContentResolver();
- if (resolver == null) {
- return null;
- }
- return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
- } catch (UnsupportedOperationException ex) {
- return null;
- }
- }
-
- private Uri createPlaylist(Resources res, ContentResolver resolver) {
- ContentValues cv = new ContentValues();
- 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, R.string.unable_to_store, Toast.LENGTH_SHORT).show();
- }
- return uri;
- }
-
- private void addToPlaylist(ContentResolver resolver, int audioId, long playlistId) {
- String[] cols = new String[] {
- "count(*)"
- };
- Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId);
- Cursor cur = resolver.query(uri, cols, null, null, null);
- final int base;
- if (cur != null) {
- cur.moveToFirst();
- base = cur.getInt(0);
- cur.close();
- } else {
- base = 0;
- }
- ContentValues values = new ContentValues();
- values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Integer.valueOf(base + audioId));
- values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, audioId);
- resolver.insert(uri, values);
- }
-
- private void registerRecordingListner() {
- if (mFmRecordingReceiver == null) {
- mFmRecordingReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(TAG, "Received intent " +intent);
- String action = intent.getAction();
- Log.d(TAG, " action = " +action);
- if (action.equals(ACTION_FM_RECORDING)) {
- int state = intent.getIntExtra("state", STOP);
- Log.d(TAG, "ACTION_FM_RECORDING Intent received" + state);
- if (state == START) {
- Log.d(TAG, "Recording start");
- mRecordDuration = intent.getIntExtra("record_duration", mRecordDuration);
- if(startRecord()) {
- clientProcessName = intent.getStringExtra("process_name");
- clientPid = intent.getIntExtra("process_id", -1);
- startClientStatusCheck();
- }
- } else if (state == STOP) {
- Log.d(TAG, "Stop recording");
- stopRecord();
- }
- }
- }
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction(ACTION_FM_RECORDING);
- registerReceiver(mFmRecordingReceiver, iFilter);
- }
- }
-
- private boolean getClientStatus(int pid, String processName) {
- boolean status = false;
- ActivityManager actvityManager =
- (ActivityManager)this.getSystemService(
- this.ACTIVITY_SERVICE);
-
- List<RunningAppProcessInfo> procInfos =
- actvityManager.getRunningAppProcesses();
-
- for(RunningAppProcessInfo procInfo : procInfos) {
- if ((pid == procInfo.pid)
- &&
- (procInfo.processName.equals(processName))) {
- status = true;
- break;
- }
- }
- procInfos.clear();
- return status;
- }
-
- private Runnable clientStatusCheckThread = new Runnable() {
- @Override
- public void run() {
- while(!Thread.currentThread().isInterrupted()) {
- try {
- if(!getClientStatus(clientPid, clientProcessName)) {
- stopRecord();
- break;
- };
- Thread.sleep(500);
- }catch(Exception e) {
- Log.d(TAG, "Client status check thread interrupted");
- break;
- }
- }
- }
- };
-
- private void startClientStatusCheck() {
- if((mStatusCheckThread == null) ||
- (mStatusCheckThread.getState() == Thread.State.TERMINATED)) {
- mStatusCheckThread = new Thread(null,
- clientStatusCheckThread,
- "GetClientStatus");
- }
- if((mStatusCheckThread != null) &&
- (mStatusCheckThread.getState() == Thread.State.NEW)) {
- mStatusCheckThread.start();
- }
- }
-
- private void stopClientStatusCheck() {
- if(mStatusCheckThread != null) {
- mStatusCheckThread.interrupt();
- }
- }
-
- public File createTempFile(String prefix, String suffix, File directory)
- throws IOException {
- prefix = getResources().getString(R.string.def_save_name_prefix) + '-';
- // Force a prefix null check first
- if (prefix.length() < 3) {
- throw new IllegalArgumentException("prefix must be at least 3 characters");
- }
- if (suffix == null) {
- suffix = ".tmp";
- }
- File tmpDirFile = directory;
- if (tmpDirFile == null) {
- String tmpDir = System.getProperty("java.io.tmpdir", ".");
- tmpDirFile = new File(tmpDir);
- }
-
- String nameFormat = getResources().getString(R.string.def_save_name_format);
- SimpleDateFormat df = new SimpleDateFormat(nameFormat);
- String currentTime = df.format(System.currentTimeMillis());
-
- File result;
- do {
- result = new File(tmpDirFile, prefix + currentTime + suffix);
- } while (!result.createNewFile());
- return result;
- }
-}
diff --git a/fmapp/Android.mk b/fmapp/Android.mk
deleted file mode 100644
index cb1f066..0000000
--- a/fmapp/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-ifeq ($(BOARD_HAVE_QCOM_FM),true)
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src/com/codeaurora/fmradio) \
- src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl \
- src/com/codeaurora/fmradio/IFMRadioService.aidl \
- src/com/codeaurora/fmradio/IFMTransmitterServiceCallbacks.aidl \
- src/com/codeaurora/fmradio/IFMTransmitterService.aidl \
-
-
-ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= 11 ))" )))
-LOCAL_SRC_FILES += $(call all-java-files-under, src/com/codeaurora/hc_utils)
-else
-LOCAL_SRC_FILES += $(call all-java-files-under, src/com/codeaurora/utils)
-endif
-LOCAL_PACKAGE_NAME := FM
-LOCAL_CERTIFICATE := platform
-LOCAL_JNI_SHARED_LIBRARIES := libqcomfm_jni
-LOCAL_JAVA_LIBRARIES := qcom.fmradio
-include $(BUILD_PACKAGE)
-
-endif
diff --git a/fmapp/AndroidManifest.xml b/fmapp/AndroidManifest.xml
deleted file mode 100644
index ff31982..0000000
--- a/fmapp/AndroidManifest.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.codeaurora.fmradio"
- android:sharedUserId="android.uid.system" >
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
- <uses-permission android:name="android.permission.BLUETOOTH" />
- <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />
- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
- <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
-
- <application
- android:icon="@drawable/ic_launcher_fmradio"
- android:label="@string/app_name"
- android:name=".FMAdapterApp">
- <activity android:icon="@drawable/ic_launcher_fmradio"
- android:name=".FMRadio"
- android:label="@string/app_name"
- android:clearTaskOnLaunch="true"
- android:taskAffinity=""
- android:launchMode="singleTask"
- android:excludeFromRecents="false" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
-
- <intent-filter>
- <action android:name="com.codeaurora.fmradio.FMRADIO_ACTIVITY" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <receiver android:name="com.codeaurora.fmradio.FMMediaButtonIntentReceiver">
- <intent-filter>
- <action android:name="android.intent.action.MEDIA_BUTTON" />
- </intent-filter>
- </receiver>
-
- <activity android:name=".Settings"
- android:label="@string/settings_menu">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
-
- <activity android:icon="@drawable/ic_launcher_fm_tx"
- android:name=".FMTransmitterActivity"
- android:label="@string/tx_app_name"
- android:clearTaskOnLaunch="true"
- android:taskAffinity=""
- android:excludeFromRecents="false">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
-
- <intent-filter>
- <action android:name="com.codeaurora.fmradio.FMTRANSMITTER_ACTIVITY" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <receiver android:name="FMTransmitterConfigReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
-
- <service android:name=".FMTransmitterService" android:exported="true" />
- <activity android:name=".FMStats"
- android:label="@string/test_menu">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
- <activity android:name=".FmTags"
- android:label="@string/rt_plus_tags">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
- <service android:name=".FMRadioService" android:exported="true" />
-
- </application>
-</manifest>
diff --git a/fmapp/fmtransmitter.xml b/fmapp/fmtransmitter.xml
deleted file mode 100644
index 3331f6f..0000000
--- a/fmapp/fmtransmitter.xml
+++ /dev/null
@@ -1,223 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!--
- This LinearLayout contains Station Information display and the
- function buttons
- -->
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="horizontal">
-
- <LinearLayout android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="vertical"
- android:gravity="top|fill_vertical">
-
- <RelativeLayout android:id="@+id/station_layout"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!-- This included layout contains Station Information to display -->
- <LinearLayout android:id="@+id/stationinfo_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5px"
- android:layout_marginLeft="5px"
- android:layout_marginRight="5px"
- android:orientation="vertical"
- android:gravity="fill_vertical">
-
- <LinearLayout android:id="@+id/station_frequency_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingTop="25px"
- android:paddingBottom="25px"
- android:gravity="fill_vertical|center">
-
- <TextView android:id="@+id/transmit_msg_tv"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="15px"
- android:layout_centerHorizontal="true"
- android:layout_alignWithParentIfMissing="true"
- android:text="@string/transmit_msg_string" />
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_alignWithParentIfMissing="true"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:textSize="56px"
- android:text="@string/frequency_string" />
- </LinearLayout>
-
- <!-- Station Radio Text information display -->
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16sp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingBottom="2px"
- android:paddingLeft="5px"
- android:paddingRight="5px"
- android:gravity="center_horizontal"
- android:text="@string/radio_text_string" />
- <!-- android:gravity="center_horizontal" -->
- </LinearLayout>
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:paddingLeft="10px"
- android:paddingRight="2px"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_left" />
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:paddingLeft="2px"
- android:paddingRight="10px"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_right" />
-
- </RelativeLayout>
- </LinearLayout>
- <LinearLayout android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_gravity="center"
- android:layout_marginLeft="5px"
- android:layout_marginRight="5px"
- android:layout_marginBottom="2px">
- <!-- On-Off button -->
- <ImageButton android:id="@+id/btn_onoff"
- android:layout_width="75px"
- android:layout_height="75px"
- android:src="@drawable/ic_btn_onoff"
- android:layout_marginTop="15px"
- android:layout_marginBottom="15px" />
- </LinearLayout>
-
- </LinearLayout>
- <View
- android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="#ffffffff" />
-
- <!--
- Layout contains the Next/Previous Presets and Tune buttons and status
- msg text
- -->
- <LinearLayout android:id="@+id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_weight="0"
- android:layout_gravity="center"
- android:layout_marginTop="15dip"
- android:layout_marginBottom="10dip"
- android:gravity="center_horizontal">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_station"
- android:layout_marginLeft="20dip"
- android:layout_marginRight="20dip"
- android:textSize="24sp"
- android:singleLine="true"
- android:layout_width="110dip"
- android:layout_height="65dip" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_station"
- android:layout_marginRight="20dip"
- android:textSize="24sp"
- android:singleLine="true"
- android:layout_width="110dip"
- android:layout_height="65dip" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_station"
- android:layout_marginRight="20dip"
- android:textSize="24sp"
- android:singleLine="true"
- android:layout_width="110dip"
- android:layout_height="65dip" />
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:layout_marginRight="20dip"
- android:textSize="24sp"
- android:singleLine="true"
- android:layout_width="110dip"
- android:layout_height="65dip" />
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:layout_marginRight="20dip"
- android:textSize="24sp"
- android:singleLine="true"
- android:layout_width="110dip"
- android:layout_height="65dip" />
-
- <Button android:id="@+id/presets_button_6"
- android:text="@string/default_blank"
- android:layout_marginRight="20dip"
- android:textSize="24sp"
- android:singleLine="true"
- android:layout_width="110dip"
- android:layout_height="65dip"/>
-
- </LinearLayout>
-
-
-</LinearLayout>
diff --git a/fmapp/res/anim/preset_select.xml b/fmapp/res/anim/preset_select.xml
deleted file mode 100644
index 8fcf768..0000000
--- a/fmapp/res/anim/preset_select.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 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.
--->
-<scale xmlns:android="http://schemas.android.com/apk/res/android"
- android:fromXScale="0.75"
- android:toXScale="1.5"
- android:fromYScale="0.75"
- android:toYScale="1.5"
- android:pivotX="50%"
- android:pivotY="50%"
- android:startOffset="0"
- android:duration="500"
- android:fillBefore="true" />
diff --git a/fmapp/res/drawable/album_border_large.1.png b/fmapp/res/drawable/album_border_large.1.png
deleted file mode 100644
index e5ffbc7..0000000
--- a/fmapp/res/drawable/album_border_large.1.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/alert_dialog_icon.png b/fmapp/res/drawable/alert_dialog_icon.png
deleted file mode 100644
index 0a7de04..0000000
--- a/fmapp/res/drawable/alert_dialog_icon.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/application_border.xml b/fmapp/res/drawable/application_border.xml
deleted file mode 100644
index 479dd75..0000000
--- a/fmapp/res/drawable/application_border.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- * 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.
--->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <stroke android:width="1dp" android:color="#A0000000" />
- <padding android:left="1dp" android:top="1dp"
- android:right="1dp" android:bottom="1dp" />
- <corners android:radius="1dp" />
-</shape>
diff --git a/fmapp/res/drawable/btn_arrow_left.xml b/fmapp/res/drawable/btn_arrow_left.xml
deleted file mode 100644
index 260c62b..0000000
--- a/fmapp/res/drawable/btn_arrow_left.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:state_pressed="true"
- android:drawable="@drawable/btn_arrow_left_press" />
-
- <item android:state_window_focused="true" android:state_focused="true"
- android:drawable="@drawable/btn_arrow_left_selected" />
-
- <item
- android:drawable="@drawable/btn_arrow_left_default" />
-
-</selector>
diff --git a/fmapp/res/drawable/btn_arrow_left_default.png b/fmapp/res/drawable/btn_arrow_left_default.png
deleted file mode 100644
index 2a35952..0000000
--- a/fmapp/res/drawable/btn_arrow_left_default.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/btn_arrow_left_press.png b/fmapp/res/drawable/btn_arrow_left_press.png
deleted file mode 100644
index 8b72f0a..0000000
--- a/fmapp/res/drawable/btn_arrow_left_press.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/btn_arrow_left_selected.png b/fmapp/res/drawable/btn_arrow_left_selected.png
deleted file mode 100644
index 6cd3c9f..0000000
--- a/fmapp/res/drawable/btn_arrow_left_selected.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/btn_arrow_right.xml b/fmapp/res/drawable/btn_arrow_right.xml
deleted file mode 100644
index 1e37d0a..0000000
--- a/fmapp/res/drawable/btn_arrow_right.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-
- <item android:state_pressed="true"
- android:drawable="@drawable/btn_arrow_right_press" />
-
- <item android:state_window_focused="true" android:state_focused="true"
- android:drawable="@drawable/btn_arrow_right_selected" />
-
- <item
- android:drawable="@drawable/btn_arrow_right_default" />
-
-</selector>
diff --git a/fmapp/res/drawable/btn_arrow_right_default.png b/fmapp/res/drawable/btn_arrow_right_default.png
deleted file mode 100644
index ae6fd53..0000000
--- a/fmapp/res/drawable/btn_arrow_right_default.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/btn_arrow_right_press.png b/fmapp/res/drawable/btn_arrow_right_press.png
deleted file mode 100644
index a4ae45b..0000000
--- a/fmapp/res/drawable/btn_arrow_right_press.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/btn_arrow_right_selected.png b/fmapp/res/drawable/btn_arrow_right_selected.png
deleted file mode 100644
index 93bcc77..0000000
--- a/fmapp/res/drawable/btn_arrow_right_selected.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_btn_forward.png b/fmapp/res/drawable/ic_btn_forward.png
deleted file mode 100644
index 0936fac..0000000
--- a/fmapp/res/drawable/ic_btn_forward.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_btn_forward_dis.png b/fmapp/res/drawable/ic_btn_forward_dis.png
deleted file mode 100755
index cd9a2f5..0000000
--- a/fmapp/res/drawable/ic_btn_forward_dis.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_btn_onoff.png b/fmapp/res/drawable/ic_btn_onoff.png
deleted file mode 100644
index 4405b43..0000000
--- a/fmapp/res/drawable/ic_btn_onoff.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_btn_preset.png b/fmapp/res/drawable/ic_btn_preset.png
deleted file mode 100644
index 35449b3..0000000
--- a/fmapp/res/drawable/ic_btn_preset.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_btn_search.png b/fmapp/res/drawable/ic_btn_search.png
deleted file mode 100644
index 7eea584..0000000
--- a/fmapp/res/drawable/ic_btn_search.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_btn_search_stop.png b/fmapp/res/drawable/ic_btn_search_stop.png
deleted file mode 100644
index 0b8c4e8..0000000
--- a/fmapp/res/drawable/ic_btn_search_stop.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_launcher_fm_tx.png b/fmapp/res/drawable/ic_launcher_fm_tx.png
deleted file mode 100644
index c6e41b2..0000000
--- a/fmapp/res/drawable/ic_launcher_fm_tx.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_launcher_fmradio.png b/fmapp/res/drawable/ic_launcher_fmradio.png
deleted file mode 100644
index 2b1250c..0000000
--- a/fmapp/res/drawable/ic_launcher_fmradio.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_menu_record.png b/fmapp/res/drawable/ic_menu_record.png
deleted file mode 100644
index 60f7a01..0000000
--- a/fmapp/res/drawable/ic_menu_record.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_signal_2.png b/fmapp/res/drawable/ic_signal_2.png
deleted file mode 100644
index efe4b5f..0000000
--- a/fmapp/res/drawable/ic_signal_2.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_silent_mode.png b/fmapp/res/drawable/ic_silent_mode.png
deleted file mode 100644
index c89291a..0000000
--- a/fmapp/res/drawable/ic_silent_mode.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_silent_mode_off.png b/fmapp/res/drawable/ic_silent_mode_off.png
deleted file mode 100644
index 4748b9e..0000000
--- a/fmapp/res/drawable/ic_silent_mode_off.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_status_fm_tx.png b/fmapp/res/drawable/ic_status_fm_tx.png
deleted file mode 100644
index 29383c9..0000000
--- a/fmapp/res/drawable/ic_status_fm_tx.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/ic_stereo.png b/fmapp/res/drawable/ic_stereo.png
deleted file mode 100644
index b9bfec6..0000000
--- a/fmapp/res/drawable/ic_stereo.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/icon.png b/fmapp/res/drawable/icon.png
deleted file mode 100644
index 7502484..0000000
--- a/fmapp/res/drawable/icon.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/image_border_bg_normal.9.png b/fmapp/res/drawable/image_border_bg_normal.9.png
deleted file mode 100644
index 18e3607..0000000
--- a/fmapp/res/drawable/image_border_bg_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/preset_page_button.xml b/fmapp/res/drawable/preset_page_button.xml
deleted file mode 100644
index f208ae5..0000000
--- a/fmapp/res/drawable/preset_page_button.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2012,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.
--->
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:drawable="@drawable/ic_btn_forward_dis" /> <!-- disabled -->
- <item android:state_enabled="true"
- android:drawable="@drawable/ic_btn_forward" /> <!-- enabled -->
- <item android:drawable="@drawable/ic_btn_forward" /> <!-- default -->
- </selector>
diff --git a/fmapp/res/drawable/stat_notify_fm.png b/fmapp/res/drawable/stat_notify_fm.png
deleted file mode 100644
index 16ed9bc..0000000
--- a/fmapp/res/drawable/stat_notify_fm.png
+++ /dev/null
Binary files differ
diff --git a/fmapp/res/drawable/station_border.xml b/fmapp/res/drawable/station_border.xml
deleted file mode 100644
index df1e28a..0000000
--- a/fmapp/res/drawable/station_border.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- * 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.
--->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <stroke android:width="1dp" android:color="#FFFFFFFF" />
- <padding android:left="1dp" android:top="1dp"
- android:right="1dp" android:bottom="1dp" />
- <corners android:radius="1dp" />
-</shape>
diff --git a/fmapp/res/layout-normal-land-finger/fmradio.xml b/fmapp/res/layout-normal-land-finger/fmradio.xml
deleted file mode 100644
index 939dcc5..0000000
--- a/fmapp/res/layout-normal-land-finger/fmradio.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:orientation="horizontal"
- android:layout_height="fill_parent">
-
- <!-- This LinearLayout contains Station Information display and the function buttons -->
- <LinearLayout android:id="@+id/station_info_wrapper_layout"
- android:background="@drawable/station_border"
- android:orientation="vertical"
- android:layout_weight="0.6"
- android:layout_width="0dp"
- android:layout_height="fill_parent">
-
- <include layout="@layout/station_info" />
-
- </LinearLayout>
-
- <LinearLayout android:id="@+id/navigate_wrapper_layout"
- android:layout_height="fill_parent"
- android:layout_weight="0.4"
- android:layout_width="0dp"
- android:orientation="vertical"
- android:layout_alignTop="@id/station_info_wrapper_layout"
- android:layout_alignBottom="@id/station_info_wrapper_layout"
- android:layout_toRightOf="@id/station_info_wrapper_layout">
-
- <!-- Layout contains the Next/Previous Presets and Tune buttons and status msg text-->
- <include layout="@layout/navigate"/>
-
- </LinearLayout>
-
-</LinearLayout>
diff --git a/fmapp/res/layout-normal-land-finger/fmtransmitter.xml b/fmapp/res/layout-normal-land-finger/fmtransmitter.xml
deleted file mode 100644
index 3d6014c..0000000
--- a/fmapp/res/layout-normal-land-finger/fmtransmitter.xml
+++ /dev/null
@@ -1,214 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
-
- <!--
- This LinearLayout contains Station Information display and the
- function buttons
- -->
- <RelativeLayout android:id="@+id/station_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:weightSum="1.0">
-
- <!-- This included layout contains Station Information to display -->
- <RelativeLayout android:id="@+id/stationinfo_layout"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_marginTop="5dp"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp" >
-
- <RelativeLayout android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
-
- <RelativeLayout android:id="@+id/transmit_msg_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingTop="5dp"
- android:paddingBottom="5dp" >
-
- <TextView android:id="@+id/transmit_msg_tv"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="15dp"
- android:text="@string/transmit_msg_string" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/frequency_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/transmit_msg_layout" >
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="10dp"
- android:layout_alignParentLeft="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_left" />
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="56dp"
- android:text="@string/frequency_string" />
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="10dp"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_right" />
-
- </RelativeLayout>
-
- <!-- Station Radio Text information display -->
- <RelativeLayout android:id="@+id/radio_text_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/frequency_layout" >
-
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:layout_centerInParent="true"
- android:text="@string/radio_text_string" />
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/stationinfo_layout"
- android:layout_marginTop="15dp"
- android:layout_marginBottom="10dp" >
-
- <RelativeLayout android:layout_width="wrap_content"
- android:layout_centerInParent="true"
- android:layout_height="wrap_content" >
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_station"
- android:layout_marginLeft="10dp"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_station"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_station"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_6"
- android:text="@string/default_blank"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/layout_on_off"
- android:layout_below="@id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:layout_marginBottom="2dp">
-
- <!-- On-Off button -->
- <ImageButton android:id="@+id/btn_onoff"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_btn_onoff"
- android:layout_marginTop="5dp"
- android:layout_centerInParent="true"
- android:layout_marginBottom="5dp" />
-
- </RelativeLayout>
-
- </RelativeLayout>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-normal-land-finger/navigate.xml b/fmapp/res/layout-normal-land-finger/navigate.xml
deleted file mode 100644
index ddc650b..0000000
--- a/fmapp/res/layout-normal-land-finger/navigate.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <RelativeLayout android:id="@+id/message_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <TextView android:id="@+id/record_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:textSize="16dp"
- android:textStyle="bold"
- android:text="@string/default_record"/>
-
- <Button android:id="@+id/btn_presets_list"
- android:text= "@string/default_preset_list_name"
- android:textSize="24dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:layout_centerHorizontal="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView android:id="@+id/sleep_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:textSize="16dp"
- android:textStyle="bold"
- androidtext="@string/default_sleep"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_upper_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/message_row"
- android:layout_marginTop="1dp"
- android:layout_marginBottom="5dp">
-
- <RelativeLayout android:id="@+id/presets_upper_layout1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_station"
- android:textSize="24dp"
- android:layout_marginRight="10dp"
- android:singleLine="true"
- android:layout_width="75dp"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_station"
- android:layout_marginRight="10dp"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_alignTop="@id/presets_button_1"
- android:layout_alignBottom="@id/presets_button_1"
- android:layout_toRightOf="@id/presets_button_1"
- android:layout_width="75dp"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_station"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_alignTop="@id/presets_button_2"
- android:layout_alignBottom="@id/presets_button_2"
- android:layout_toRightOf="@id/presets_button_2"
- android:layout_width="75dp"
- android:layout_height="wrap_content" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_upper_layout2"
- android:layout_width="wrap_content"
- android:layout_below="@id/presets_upper_layout1"
- android:layout_height="wrap_content">
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:layout_marginRight="10dp"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="75dp"
- android:layout_height="wrap_content"/>
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:layout_marginRight="10dp"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_alignTop="@id/presets_button_4"
- android:layout_alignBottom="@id/presets_button_4"
- android:layout_toRightOf="@id/presets_button_4"
- android:layout_width="75dp"
- android:layout_height="wrap_content" />
-
- <ImageButton android:id="@+id/btn_preset_page"
- android:src="@drawable/ic_btn_forward"
- android:layout_alignTop="@id/presets_button_5"
- android:layout_alignBottom="@id/presets_button_5"
- android:layout_toRightOf="@id/presets_button_5"
- android:layout_width="75dp"
- android:layout_height="wrap_content"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/silent_on_off_layout"
- android:layout_width="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_below="@id/presets_upper_layout2"
- android:layout_height="wrap_content">
-
- <ImageButton android:id="@+id/btn_silent"
- android:src="@drawable/ic_silent_mode_off"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
-
- <ImageButton android:id="@+id/btn_onoff"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@id/btn_silent"
- android:src="@drawable/ic_btn_onoff"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
-</merge>
diff --git a/fmapp/res/layout-normal-land-finger/station_info.xml b/fmapp/res/layout-normal-land-finger/station_info.xml
deleted file mode 100644
index e2304d5..0000000
--- a/fmapp/res/layout-normal-land-finger/station_info.xml
+++ /dev/null
@@ -1,178 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <RelativeLayout android:id="@+id/stationinfo_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="1dip"
- android:layout_marginLeft="1dip"
- android:layout_marginRight="1dip">
-
- <RelativeLayout android:id="@+id/top_most"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dip"
- android:layout_alignParentTop="true"
- android:layout_marginRight="5dip">
-
- <ImageView android:id="@+id/signal_level"
- android:src="@drawable/ic_signal_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"/>
-
- <TextView android:id="@+id/prog_service_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="16dip"
- android:singleLine="true"
- android:textStyle="bold"
- android:text="@string/prog_service_string"/>
-
- <TextView android:id="@+id/stereo_text_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="16dip"
- android:text="@string/default_audio"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/station_id_row"
- android:layout_below="@id/top_most"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
-
- <TextView android:id="@+id/call_sign_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:layout_alignParentTop="true"
- android:textSize="16dip"
- android:paddingRight="5dip"
- android:paddingLeft="5dip"
- android:text="@string/station_id_string" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/frequency_layout"
- android:layout_width="fill_parent"
- android:layout_below="@id/station_id_row"
- android:layout_height="wrap_content">
-
- <ImageView
- android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_left"/>
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="50dip"
- android:text="@string/frequency_string" />
-
- <ImageView
- android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="2dip"
- android:paddingRight="10dip"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_right"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/pty_string_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/frequency_layout">
-
- <TextView android:id="@+id/pty_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="16dip"
- android:text="@string/pty_string" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/radio_text_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/pty_string_row">
-
- <!-- Station Radio Text information display -->
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:gravity="center_horizontal"
- android:text="@string/radio_text_string"/>
-
- <TextView android:id="@+id/eradio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dip"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dip"
- android:paddingRight="2dip"
- android:paddingBottom="5dip"
- android:gravity="center_horizontal"
- android:layout_below ="@id/radio_text_tv"
- android:text="@string/eradio_text_string"/>
-
- </RelativeLayout>
- </RelativeLayout>
-</merge>
diff --git a/fmapp/res/layout-normal/fmradio.xml b/fmapp/res/layout-normal/fmradio.xml
deleted file mode 100644
index 5b9197c..0000000
--- a/fmapp/res/layout-normal/fmradio.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fmradio"
- android:background="@drawable/application_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <!-- This LinearLayout contains Station Information display and the function buttons -->
-
- <RelativeLayout android:id="@+id/stationinfo_layout"
- android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true" >
-
- <!-- This included layout contains Station Information to display -->
- <include layout="@layout/station_info" />
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/preset_full_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/stationinfo_layout"
- android:layout_alignParentLeft="true">
-
- <!-- Layout contains the Next/Previous Presets and Tune buttons and status msg text-->
- <include layout="@layout/navigate" />
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/on_off_separator_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
- android:layout_below="@id/preset_full_layout">
-
- <View android:id="@+id/on_off_separator"
- android:layout_width="fill_parent"
- android:layout_height="1dp"
- android:background="#ffffffff"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/layout_on_off"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="1dp"
- android:layout_centerInParent="true"
- android:layout_below="@id/on_off_separator_layout">
-
- <ImageButton android:id="@+id/btn_silent"
- android:src="@drawable/ic_silent_mode_off"
- android:layout_width="120dp"
- android:layout_height="65dp" />
-
- <ImageButton android:id="@+id/btn_onoff"
- android:src="@drawable/ic_btn_onoff"
- android:layout_toRightOf="@id/btn_silent"
- android:layout_width="120dp"
- android:layout_height="65dp" />
- </RelativeLayout>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-normal/fmtags.xml b/fmapp/res/layout-normal/fmtags.xml
deleted file mode 100644
index 352320f..0000000
--- a/fmapp/res/layout-normal/fmtags.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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 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.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent">
-
- <ListView
- android:id="@+id/TagListView"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"/>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-normal/fmtransmitter.xml b/fmapp/res/layout-normal/fmtransmitter.xml
deleted file mode 100644
index 1cffca9..0000000
--- a/fmapp/res/layout-normal/fmtransmitter.xml
+++ /dev/null
@@ -1,239 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fmtransmitter"
- android:background="@drawable/application_border"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!-- This RelativeLayout contains Station Information display and the function buttons -->
- <RelativeLayout android:id="@+id/stationinfo_layout"
- android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="20dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true" >
-
- <RelativeLayout android:id="@+id/transmit_msg_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true" >
-
- <TextView android:id="@+id/transmit_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="15dp"
- android:layout_centerInParent="true"
- android:layout_alignWithParentIfMissing="true"
- android:text="@string/transmit_msg_string"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/frequency_layout"
- android:layout_below="@id/transmit_msg_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_alignParentLeft="true"
- android:paddingLeft="2dip"
- android:visibility="visible"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/btn_arrow_left"/>
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textSize="60dip"
- android:layout_centerInParent="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/frequency_string"/>
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:paddingRight="2dp"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/btn_arrow_right"/>
-
- </RelativeLayout>
-
- <!-- Station Radio Text information display -->
- <RelativeLayout android:id="@+id/radio_text_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/frequency_layout">
-
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="5dp"
- android:layout_marginTop="20dp"
- android:layout_marginBottom="10dp"
- android:layout_centerInParent="true"
- android:text="@string/radio_text_string"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/stationinfo_layout">
-
- <RelativeLayout android:id="@+id/presets_layout_center"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true">
-
- <!-- Upper Presets -->
- <RelativeLayout android:id="@+id/presets_upper_layout"
- android:gravity="top"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_1"
- android:layout_alignTop="@id/presets_button_1"
- android:layout_alignBottom="@id/presets_button_1"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_2"
- android:layout_alignTop="@id/presets_button_2"
- android:layout_alignBottom="@id/presets_button_2"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- </RelativeLayout>
-
- <!-- Lower Presets -->
- <RelativeLayout android:id="@+id/presets_lower_layout"
- android:layout_below="@id/presets_upper_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_4"
- android:layout_alignTop="@id/presets_button_4"
- android:layout_alignBottom="@id/presets_button_4"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- <Button android:id="@+id/presets_button_6"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_5"
- android:layout_alignTop="@id/presets_button_5"
- android:layout_alignBottom="@id/presets_button_5"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/on_off_separator_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
- android:layout_below="@id/presets_layout">
-
- <View android:id="@+id/on_off_separator"
- android:layout_width="fill_parent"
- android:layout_height="1dp"
- android:background="#ffffffff"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/layout_on_off"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/on_off_separator_layout"
- android:layout_marginBottom="20dp">
-
- <ImageButton android:id="@+id/btn_onoff"
- android:src="@drawable/ic_btn_onoff"
- android:layout_below="@id/on_off_separator"
- android:layout_centerInParent="true"
- android:layout_width="120dp"
- android:layout_height="65dp"/>
-
- </RelativeLayout>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-normal/navigate.xml b/fmapp/res/layout-normal/navigate.xml
deleted file mode 100644
index bd8cdea..0000000
--- a/fmapp/res/layout-normal/navigate.xml
+++ /dev/null
@@ -1,188 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <RelativeLayout android:id="@+id/message_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="1dp"
- android:paddingTop="1dp"
- android:paddingBottom="1dp">
-
- <TextView android:id="@+id/record_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:textSize="15dp"
- android:textStyle="bold"
- android:gravity="fill"
- android:text="@string/default_record" />
-
- <Button android:id="@+id/btn_presets_list"
- android:text="@string/default_preset_list_name"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textSize="24dp"
- android:textStyle="bold"
- android:singleLine="true"
- android:layout_centerHorizontal="true"
- android:layout_alignParentTop="true"
- android:layout_gravity="center"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_marginBottom="10dp"
- android:gravity="fill"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView android:id="@+id/sleep_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@+id/btn_presets_list"
- android:textSize="15dp"
- android:textStyle="bold"
- android:gravity="fill"
- android:text="@string/default_sleep" />
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/message_row"
- android:layout_centerInParent="true">
-
- <!-- Upper Presets -->
- <RelativeLayout android:id="@+id/presets_upper_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="top">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:gravity="fill"
- android:layout_width="85dp"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_1"
- android:layout_alignTop="@id/presets_button_1"
- android:layout_alignBottom="@id/presets_button_1"
- android:gravity="fill"
- android:layout_width="85dp"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_2"
- android:layout_alignTop="@id/presets_button_2"
- android:layout_alignBottom="@id/presets_button_2"
- android:layout_width="85dp"
- android:gravity="fill"
- android:layout_height="wrap_content" />
- </RelativeLayout>
-
-<!-- Lower Presets -->
- <RelativeLayout android:id="@+id/presets_lower_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/presets_upper_layout"
- android:layout_alignLeft="@id/presets_upper_layout"
- android:layout_alignRight="@id/presets_upper_layout">
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="85dp"
- android:gravity="fill"
- android:layout_alignLeft="@id/presets_button_1"
- android:layout_alignRight="@id/presets_button_1"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_4"
- android:layout_alignTop="@id/presets_button_4"
- android:layout_alignBottom="@id/presets_button_4"
- android:layout_alignLeft="@id/presets_button_2"
- android:layout_alignRight="@id/presets_button_2"
- android:gravity="fill"
- android:layout_width="85dp"
- android:layout_height="wrap_content" />
-
- <ImageButton android:id="@+id/btn_preset_page"
- android:src="@drawable/ic_btn_forward"
- android:layout_toRightOf="@id/presets_button_5"
- android:layout_alignTop="@id/presets_button_5"
- android:layout_alignBottom="@id/presets_button_5"
- android:layout_alignLeft="@id/presets_button_3"
- android:layout_alignRight="@id/presets_button_3"
- android:gravity="fill"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/scanning_stoplayout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone"
- android:gravity="center">
-
- <Button android:id="@+id/btn_scanning_stop"
- android:clickable="true"
- android:text="@string/stop_scanning"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="32dp"
- android:singleLine="true"
- android:padding="20dp"
- android:gravity="fill"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- </RelativeLayout>
-
-</merge>
diff --git a/fmapp/res/layout-normal/station_info.xml b/fmapp/res/layout-normal/station_info.xml
deleted file mode 100644
index e47f823..0000000
--- a/fmapp/res/layout-normal/station_info.xml
+++ /dev/null
@@ -1,182 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
-<RelativeLayout android:id="@+id/station_info"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:gravity="top">
-
- <RelativeLayout android:id="@+id/top_most"
- android:layout_width="fill_parent"
- android:gravity="top"
- android:layout_height="wrap_content">
-
- <ImageView android:id="@+id/signal_level"
- android:src="@drawable/ic_signal_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="5dp"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"/>
-
- <TextView android:id="@+id/prog_service_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="16dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:text="@string/prog_service_string" />
-
- <TextView android:id="@+id/stereo_text_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="5dp"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="16dp"
- android:text="@string/default_audio" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/station_id_row"
- android:layout_width="fill_parent"
- android:layout_below="@id/top_most"
- android:layout_height="wrap_content">
-
- <TextView android:id="@+id/call_sign_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="16dp"
- android:layout_centerInParent="true"
- android:text="@string/station_id_string" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/station_frequency_row"
- android:layout_width="fill_parent"
- android:layout_below="@id/station_id_row"
- android:layout_height="wrap_content"
- android:gravity="center" >
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="50dp"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/frequency_string"/>
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="100dp"
- android:paddingLeft="2dp"
- android:layout_alignParentLeft="true"
- android:visibility="visible"
- android:layout_alignWithParentIfMissing="true"
- android:src="@drawable/btn_arrow_left" />
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="100dp"
- android:paddingRight="2dp"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:layout_alignWithParentIfMissing="true"
- android:src="@drawable/btn_arrow_right" />
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/second_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@id/station_frequency_row"
- android:layout_alignRight="@id/station_frequency_row"
- android:layout_below="@id/station_frequency_row" >
-
- <TextView android:id="@+id/pty_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="16dp"
- android:layout_centerInParent="true"
- android:text="@string/pty_string" />
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/third_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_alignLeft="@id/second_layout"
- android:layout_alignRight="@id/second_layout"
- android:layout_below="@id/second_layout" >
-
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="5dp"
- android:gravity="center"
- android:text="@string/radio_text_string" />
-
- <TextView android:id="@+id/eradio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="5dp"
- android:layout_below="@id/radio_text_tv"
- android:gravity="center_horizontal"
- android:text="@string/eradio_text_string"/>
- </RelativeLayout>
- <!-- Station Radio Text information display -->
- </RelativeLayout>
-</merge>
diff --git a/fmapp/res/layout-small-land-finger/fmradio.xml b/fmapp/res/layout-small-land-finger/fmradio.xml
deleted file mode 100644
index e55c239..0000000
--- a/fmapp/res/layout-small-land-finger/fmradio.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!-- This LinearLayout contains Station Information display and the function buttons -->
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="horizontal">
-
- <LinearLayout
- android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:orientation="vertical"
- android:gravity="top|fill_vertical">
-
- <RelativeLayout android:id="@+id/station_layout"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!-- This included layout contains Station Information to display -->
- <include layout="@layout/station_info" />
-
- <ImageView
- android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:paddingLeft="10dip"
- android:paddingRight="2dip"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_left"/>
-
- <ImageView
- android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:paddingLeft="2dip"
- android:paddingRight="10dip"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_right"/>
-
- </RelativeLayout>
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_gravity="center"
- android:layout_marginLeft="5dip"
- android:layout_marginRight="5dip"
- android:layout_marginBottom="2dip">
-
- <!-- On-Off button -->
- <ImageButton android:id="@+id/btn_onoff"
- android:layout_width="70dip"
- android:layout_height="60dip"
- android:src="@drawable/ic_btn_onoff"
- android:layout_marginBottom="15dp"/>
-
- <ImageButton android:id="@+id/btn_silent"
- android:src="@drawable/ic_silent_mode_off"
- android:layout_width="70dip"
- android:layout_height="60dip"
- android:layout_marginBottom="15dip"/>
-
- </LinearLayout>
-
- </LinearLayout>
-
- <!-- Layout contains the Next/Previous Presets and Tune buttons and status msg text-->
- <include layout="@layout/navigate" />
-
-</LinearLayout>
diff --git a/fmapp/res/layout-small-land-finger/fmtransmitter.xml b/fmapp/res/layout-small-land-finger/fmtransmitter.xml
deleted file mode 100644
index f9a9853..0000000
--- a/fmapp/res/layout-small-land-finger/fmtransmitter.xml
+++ /dev/null
@@ -1,215 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
- <!--
-/*
- * 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.
- */
- -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <!--
- This LinearLayout contains Station Information display and the
- function buttons
- -->
- <RelativeLayout android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
-
- <RelativeLayout android:id="@+id/station_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <!-- This included layout contains Station Information to display -->
- <RelativeLayout android:id="@+id/stationinfo_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp" >
-
- <RelativeLayout android:id="@+id/transmit_msg_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingTop="20dp"
- android:paddingBottom="20dp" >
-
- <TextView android:id="@+id/transmit_msg_tv"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="15dp"
- android:text="@string/transmit_msg_string" />
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/frequency_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/transmit_msg_layout" >
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="10dp"
- android:layout_alignParentLeft="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_left" />
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="56dp"
- android:text="@string/frequency_string" />
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="10dp"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_right" />
-
- </RelativeLayout>
-
- <!-- Station Radio Text information display -->
- <RelativeLayout android:id="@+id/radio_text_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/frequency_layout" >
-
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:layout_centerInParent="true"
- android:text="@string/radio_text_string" />
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/stationinfo_layout"
- android:layout_marginTop="15dp"
- android:layout_marginBottom="10dp" >
-
- <RelativeLayout android:layout_width="wrap_content"
- android:layout_centerInParent="true"
- android:layout_height="wrap_content" >
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_station"
- android:layout_marginLeft="10dp"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_station"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_station"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/presets_button_6"
- android:text="@string/default_blank"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/layout_on_off"
- android:layout_below="@id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:layout_marginBottom="2dp">
-
- <!-- On-Off button -->
- <ImageButton android:id="@+id/btn_onoff"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_btn_onoff"
- android:layout_marginTop="5dp"
- android:layout_centerInParent="true"
- android:layout_marginBottom="5dp" />
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-small-land-finger/navigate.xml b/fmapp/res/layout-small-land-finger/navigate.xml
deleted file mode 100644
index 269793b..0000000
--- a/fmapp/res/layout-small-land-finger/navigate.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="#ffffffff" />
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="2dip"
- android:layout_marginLeft="5dip"
- android:layout_marginRight="5dip"
- android:layout_marginBottom="2dip"
- android:orientation="vertical"
- android:gravity="bottom"
- >
- <RelativeLayout android:id="@+id/message_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- >
-
- <TextView android:id="@+id/record_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_alignParentLeft="true"
- android:textSize="14dip"
- android:textStyle="bold"
- android:text="@string/default_record"
- />
-
- <Button android:id="@+id/btn_presets_list"
- android:text= "@string/default_preset_list_name"
- android:textStyle="bold"
- android:singleLine="true"
- android:layout_gravity="center"
- android:layout_centerHorizontal="true"
- android:layout_marginLeft="10dip"
- android:layout_marginRight="10dip"
- android:layout_width="140dip"
- android:layout_height="45dip" />
-
- <TextView android:id="@+id/sleep_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@+id/btn_presets_list"
- android:layout_gravity="center_vertical"
- android:textSize="14dip"
- android:textStyle="bold"
- android:text="@string/default_sleep"
- />
- </RelativeLayout>
- </LinearLayout>
-
- <LinearLayout android:id="@+id/presets_upper_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_gravity="center"
- android:layout_marginBottom="5dip"
- android:gravity="center_horizontal">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_station"
- android:layout_width="80dip"
- android:layout_height="50dip" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_station"
- android:layout_width="80dp"
- android:layout_height="50dp" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_station"
- android:layout_width="80dip"
- android:layout_height="50dip"
- android:visibility="visible" />
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:layout_width="80dip"
- android:layout_height="50dip" />
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:layout_width="80dip"
- android:layout_height="50dip" />
-
- <ImageButton android:id="@+id/btn_preset_page"
- android:src="@drawable/ic_btn_forward"
- android:layout_marginRight="2dp"
- android:layout_width="80dip"
- android:layout_height="50dip"
- android:visibility="visible" />
- </LinearLayout>
-</merge>
diff --git a/fmapp/res/layout-small-land-finger/station_info.xml b/fmapp/res/layout-small-land-finger/station_info.xml
deleted file mode 100644
index 48ce642..0000000
--- a/fmapp/res/layout-small-land-finger/station_info.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <LinearLayout android:id="@+id/stationinfo_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dip"
- android:layout_marginLeft="5dip"
- android:layout_marginRight="5dip"
- android:orientation="vertical"
- android:gravity="fill_vertical">
-
- <RelativeLayout android:id="@+id/top_most"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dip"
- android:layout_marginRight="5dip">
-
- <ImageView android:id="@+id/signal_level"
- android:src="@drawable/ic_signal_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"/>
-
- <TextView android:id="@+id/prog_service_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="20dip"
- android:singleLine="true"
- android:textStyle="bold"
- android:text="@string/prog_service_string"/>
-
- <TextView android:id="@+id/stereo_text_tv"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="14dip"
- android:text="@string/default_audio"/>
-
- </RelativeLayout>
-
- <LinearLayout android:id="@+id/station_frequency_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingTop="25dip"
- android:paddingBottom="25dip"
- android:gravity="fill_vertical|center">
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:textSize="56dip"
- android:text="@string/frequency_string" />
-
- <RelativeLayout android:id="@+id/second_row"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:layout_toRightOf="@id/prog_frequency_tv">
-
- <TextView android:id="@+id/call_sign_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:textSize="14dip"
- android:paddingRight="5dip"
- android:paddingBottom="2dip"
- android:paddingLeft="5dip"
- android:text="@string/station_id_string" />
-
- <TextView android:id="@+id/pty_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentBottom="true"
- android:textSize="16dip"
- android:paddingTop="5dip"
- android:paddingRight="5dip"
- android:paddingLeft="5dip"
- android:text="@string/pty_string" />
- </RelativeLayout>
- </LinearLayout>
-
- <!-- Station Radio Text information display -->
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="16dip"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingBottom="2dip"
- android:paddingLeft="5dip"
- android:paddingRight="5dip"
- android:gravity="center_horizontal"
- android:text="@string/radio_text_string"/>
-
- <TextView android:id="@+id/eradio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dip"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dip"
- android:paddingRight="2dip"
- android:paddingBottom="5dip"
- android:gravity="center_horizontal"
- android:layout_below="@id/radio_text_tv"
- android:text="@string/eradio_text_string"/>
-
- </LinearLayout>
-</merge>
diff --git a/fmapp/res/layout-small/alert_dialog_list.xml b/fmapp/res/layout-small/alert_dialog_list.xml
deleted file mode 100644
index 5d20985..0000000
--- a/fmapp/res/layout-small/alert_dialog_list.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <ListView android:id="@+id/list"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </ListView>
-
-</LinearLayout>
diff --git a/fmapp/res/layout-small/alert_dialog_text_entry.xml b/fmapp/res/layout-small/alert_dialog_text_entry.xml
deleted file mode 100644
index 828e914..0000000
--- a/fmapp/res/layout-small/alert_dialog_text_entry.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <EditText
- android:id="@+id/list_edit"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:scrollHorizontally="true"
- android:hint="Enter a name"
- android:singleLine="true"
- android:inputType="text"
- android:autoText="false"
- android:capitalize="none"
- android:gravity="fill_horizontal"
- android:textAppearance="?android:attr/textAppearanceMedium" android:saveEnabled="false"/>
-
-
-</LinearLayout>
diff --git a/fmapp/res/layout-small/fmradio.xml b/fmapp/res/layout-small/fmradio.xml
deleted file mode 100644
index e929965..0000000
--- a/fmapp/res/layout-small/fmradio.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fmradio"
- android:background="@drawable/application_border"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical">
-
- <!-- This LinearLayout contains Station Information display and the function buttons -->
- <LinearLayout android:id="@+id/stationinfo_layout"
- android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_marginTop="5dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true">
-
- <!-- This included layout contains Station Information to display -->
- <include layout="@layout/station_info" />
-
- </LinearLayout>
-
- <LinearLayout android:id="@+id/preset_full_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/stationinfo_layout"
- android:layout_weight="1"
- android:gravity="center">
-
- <!-- Layout contains the Next/Previous Presets and Tune buttons and status msg text-->
- <include layout="@layout/navigate" />
-
- </LinearLayout>
-
- <LinearLayout android:id="@+id/layout_on_off"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_gravity="center"
- android:layout_marginTop="2dp"
- android:layout_marginBottom="2dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentBottom="true"
- android:layout_weight="0"
- android:gravity="center_horizontal">
-
- <ImageButton android:id="@+id/btn_silent"
- android:src="@drawable/ic_silent_mode_off"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="20dp"
- android:layout_width="100dp"
- android:layout_height="50dp"/>
-
- <ImageButton android:id="@+id/btn_onoff"
- android:src="@drawable/ic_btn_onoff"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="10dp"
- android:layout_width="100dp"
- android:layout_height="50dp"/>
-
- </LinearLayout>
-
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dp"
- android:background="#ffffffff"
- android:layout_above="@+id/layout_on_off"/>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-small/fmstats.xml b/fmapp/res/layout-small/fmstats.xml
deleted file mode 100644
index 1cf8023..0000000
--- a/fmapp/res/layout-small/fmstats.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2011-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.
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:scrollbars="vertical"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical">
-
- <Spinner
- android:id="@+id/spinner"
- android:layout_width="fill_parent"
- android:layout_height="75dp"
- android:prompt="@string/test_prompt"
- android:textSize="25sp"/>
-
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="100dp">
-
- <Button
- android:id= "@+id/Runbutton"
- android:text="@string/band_sweep_setting"
- android:layout_width="wrap_content"
- android:layout_height="100dp"
- android:textSize="25dp"
- android:visibility="gone"/>
-
- <TextView
- android:id= "@+id/BandSweepSetting"
- android:text="@string/band_sweep_setting"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@id/Runbutton"
- android:textSize="25sp"
- android:visibility="gone"/>
-
- <ProgressBar android:id="@+id/progressbar"
- android:layout_width="100dp"
- android:layout_height="100dp"
- android:layout_toRightOf="@id/Runbutton"
- android:visibility="gone"/>
-
- <TextView
- android:id="@+id/label"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:text="@string/enter_rssi"
- android:visibility="gone"/>
-
- <EditText
- android:id="@+id/txtbox1"
- android:layout_width="100dp"
- android:layout_height="50dp"
- android:text="@string/type_rd"
- android:textSize="15sp"
- android:layout_alignParentRight="true"
- android:visibility="gone"/>
-
- <Button
- android:id= "@+id/Setbutton"
- android:text="@string/set_rmmsi_delta"
- android:layout_width="wrap_content"
- android:layout_height="100dp"
- android:layout_below="@id/txtbox1"
- android:textSize="15sp"
- android:visibility="gone"/>
-
- <Button
- android:id="@+id/SearchMpxDcc"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/search_algo_mpx"
- android:visibility="gone"/>
-
- <Button
- android:id="@+id/SearchSinrInt"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/search_algo_sinrint"
- android:layout_below="@id/SearchMpxDcc"
- android:visibility="gone"/>
-
- </RelativeLayout>
-
- <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/maintable"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:scrollbars="vertical">
-
- <TableRow
- android:id="@+id/mainrow">
- </TableRow>
-
- </TableLayout>
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/fmapp/res/layout-small/fmtags.xml b/fmapp/res/layout-small/fmtags.xml
deleted file mode 100644
index 352320f..0000000
--- a/fmapp/res/layout-small/fmtags.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012, 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 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.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent">
-
- <ListView
- android:id="@+id/TagListView"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"/>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-small/fmtransmitter.xml b/fmapp/res/layout-small/fmtransmitter.xml
deleted file mode 100644
index f9e7b08..0000000
--- a/fmapp/res/layout-small/fmtransmitter.xml
+++ /dev/null
@@ -1,235 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fmtransmitter"
- android:background="@drawable/application_border"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!-- This RelativeLayout contains Station Information display and the function buttons -->
- <RelativeLayout android:id="@+id/stationinfo_layout"
- android:background="@drawable/station_border"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_marginTop="5dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true">
-
- <RelativeLayout android:id="@+id/transmit_msg_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true" >
-
- <TextView android:id="@+id/transmit_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="15dp"
- android:layout_centerInParent="true"
- android:text="@string/transmit_msg_string"/>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/frequency_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
- android:layout_below="@id/transmit_msg_layout"
- android:layout_marginBottom="20dp">
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="2dp"
- android:layout_alignParentLeft="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_left"/>
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="60dp"
- android:layout_centerVertical="true"
- android:layout_toRightOf="@id/btn_back"
- android:text="@string/frequency_string"/>
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="2dp"
- android:layout_toRightOf="@id/prog_frequency_tv"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:src="@drawable/btn_arrow_right"/>
-
- </RelativeLayout>
-
- <!-- Station Radio Text information display -->
- <RelativeLayout android:id="@+id/radio_text_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/frequency_layout">
-
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:layout_centerInParent="true"
- android:text="@string/radio_text_string"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/presets_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/stationinfo_layout"
- android:layout_weight="1"
- android:layout_marginTop = "15dp"
- android:layout_marginBottom="15dp"
- android:gravity="center">
-
- <!-- Upper Presets -->
- <RelativeLayout android:id="@+id/presets_upper_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="90dp"
- android:layout_height="55dp"/>
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_1"
- android:layout_alignTop="@id/presets_button_1"
- android:layout_alignBottom="@id/presets_button_1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_2"
- android:layout_alignTop="@id/presets_button_2"
- android:layout_alignBottom="@id/presets_button_2"
- android:layout_width="90dp"
- android:layout_height="55dp"/>
-
- </RelativeLayout>
-
- <!-- Lower Presets -->
- <RelativeLayout android:id="@+id/presets_lower_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/presets_upper_layout"
- android:layout_centerVertical="true">
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_width="90dp"
- android:layout_height="55dp"/>
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_4"
- android:layout_alignTop="@id/presets_button_4"
- android:layout_alignBottom="@id/presets_button_4"
- android:layout_width="90dp"
- android:layout_height="55dp"/>
-
- <Button android:id="@+id/presets_button_6"
- android:text="@string/default_blank"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="24dp"
- android:singleLine="true"
- android:layout_toRightOf="@id/presets_button_5"
- android:layout_alignTop="@id/presets_button_5"
- android:layout_alignBottom="@id/presets_button_5"
- android:layout_width="90dp"
- android:layout_height="55dp"/>
-
- </RelativeLayout>
-
- </RelativeLayout>
-
- <RelativeLayout android:id="@+id/layout_on_off"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/presets_layout"
- android:layout_marginTop="20dp"
- android:layout_marginBottom="20dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentBottom="true"
- android:layout_weight="0">
-
- <View android:id="@+id/on_off_separator"
- android:layout_width="fill_parent"
- android:layout_height="1dp"
- android:background="#ffffffff"/>
-
- <ImageButton android:id="@+id/btn_onoff"
- android:src="@drawable/ic_btn_onoff"
- android:layout_marginLeft="25dp"
- android:layout_marginRight="25dp"
- android:layout_below="@id/on_off_separator"
- android:layout_centerVertical="true"
- android:layout_width="110dp"
- android:layout_height="65dp"/>
-
- </RelativeLayout>
-
-</RelativeLayout>
diff --git a/fmapp/res/layout-small/frequency_picker.xml b/fmapp/res/layout-small/frequency_picker.xml
deleted file mode 100644
index 2d89a62..0000000
--- a/fmapp/res/layout-small/frequency_picker.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- <!-- MHz -->
- <android.widget.NumberPicker
- android:id="@+id/mhz"
- android:layout_width="80dp"
- android:layout_height="wrap_content"
- android:layout_marginLeft="1dp"
- android:layout_marginRight="1dp"
- android:focusable="true"
- android:focusableInTouchMode="true" />
-
- <!-- KHz -->
- <android.widget.NumberPicker
- android:id="@+id/khz"
- android:layout_width="80dp"
- android:layout_height="wrap_content"
- android:layout_marginLeft="1dp"
- android:layout_marginRight="1dp"
- android:focusable="true"
- android:focusableInTouchMode="true"
- />
-</LinearLayout>
diff --git a/fmapp/res/layout-small/frequency_picker_dialog.xml b/fmapp/res/layout-small/frequency_picker_dialog.xml
deleted file mode 100644
index 89a6e4f..0000000
--- a/fmapp/res/layout-small/frequency_picker_dialog.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<com.codeaurora.utils.FrequencyPicker xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/frequencyPicker"
- android:padding="5dp"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
diff --git a/fmapp/res/layout-small/navigate.xml b/fmapp/res/layout-small/navigate.xml
deleted file mode 100644
index 8d7a603..0000000
--- a/fmapp/res/layout-small/navigate.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <RelativeLayout android:id="@+id/message_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:orientation="horizontal">
-
- <TextView android:id="@+id/record_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:textSize="14dp"
- android:textStyle="bold"
- android:text="@string/default_record"/>
-
- <Button android:id="@+id/btn_presets_list"
- android:text="@string/default_preset_list_name"
- android:textStyle="bold"
- android:singleLine="true"
- android:layout_centerHorizontal="true"
- android:layout_alignParentTop="true"
- android:layout_gravity="center"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_width="140dp"
- android:layout_height="45dp" />
-
- <TextView android:id="@+id/sleep_msg_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@+id/btn_presets_list"
- android:textSize="14dp"
- android:textStyle="bold"
- android:text="@string/default_sleep" />
-
- </RelativeLayout>
-
- <LinearLayout android:id="@+id/presets_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:orientation="vertical">
-
- <!-- Upper Presets -->
- <LinearLayout android:id="@+id/presets_upper_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_gravity="center"
- android:layout_marginBottom="5dp"
- android:gravity="center_horizontal">
-
- <Button android:id="@+id/presets_button_1"
- android:text="@string/default_station"
- android:layout_marginLeft="10dip"
- android:layout_width="90dp"
- android:layout_height="55dp" />
-
- <Button android:id="@+id/presets_button_2"
- android:text="@string/default_station"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_width="90dp"
- android:layout_height="55dp" />
-
- <Button android:id="@+id/presets_button_3"
- android:text="@string/default_station"
- android:layout_marginRight="10dp"
- android:layout_width="90dp"
- android:layout_height="55dp"
- android:visibility="visible" />
-
- </LinearLayout>
-
- <!-- Lower Presets -->
- <LinearLayout android:id="@+id/presets_lower_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_gravity="center"
- android:layout_marginBottom="5dp"
- android:gravity="center_horizontal">
-
- <Button android:id="@+id/presets_button_4"
- android:text="@string/default_blank"
- android:layout_marginLeft="10dp"
- android:layout_width="90dp"
- android:layout_height="55dp" />
-
- <Button android:id="@+id/presets_button_5"
- android:text="@string/default_blank"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_width="90dp"
- android:layout_height="55dp" />
-
- <ImageButton android:id="@+id/btn_preset_page"
- android:src="@drawable/preset_page_button"
- android:layout_marginRight="10dp"
- android:layout_width="90dp"
- android:layout_height="55dp"
- android:visibility="visible" />
-
- </LinearLayout>
-
- </LinearLayout>
-
- <LinearLayout android:id="@+id/scanning_stoplayout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone"
- android:gravity="center">
-
- <Button android:id="@+id/btn_scanning_stop"
- android:clickable="true"
- android:text="@string/stop_scanning"
- android:singleLine="true"
- android:padding="20dp"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
-
- </LinearLayout>
-
-</merge>
diff --git a/fmapp/res/layout-small/station_info.xml b/fmapp/res/layout-small/station_info.xml
deleted file mode 100644
index 0f3fce4..0000000
--- a/fmapp/res/layout-small/station_info.xml
+++ /dev/null
@@ -1,176 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <LinearLayout android:id="@+id/station_info"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:orientation="vertical"
- android:gravity="top">
-
- <RelativeLayout android:id="@+id/top_most"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <ImageView android:id="@+id/signal_level"
- android:src="@drawable/ic_signal_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="5dp"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"/>
-
- <TextView android:id="@+id/prog_service_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="20dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:text="@string/prog_service_string"/>
-
- <TextView android:id="@+id/stereo_text_tv"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="5dp"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@id/signal_level"
- android:textSize="14dp"
- android:text="@string/default_audio"/>
-
- </RelativeLayout>
-
- <LinearLayout android:id="@+id/station_frequency_row"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingTop="5dp"
- android:paddingBottom="5dp"
- android:layout_alignWithParentIfMissing="true"
- android:gravity="center">
-
- <TextView android:id="@+id/call_sign_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="14dp"
- android:paddingTop="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="2dp"
- android:paddingLeft="2dp"
- android:text="@string/station_id_string" />
-
- <RelativeLayout android:id="@+id/second_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="2dp"
- android:layout_marginBottom="2dp"
- android:layout_marginLeft="2dp"
- android:layout_marginRight="2dp">
-
- <TextView android:id="@+id/prog_frequency_tv"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="64dp"
- android:layout_centerHorizontal="true"
- android:text="@string/frequency_string"/>
-
- <ImageView android:id="@+id/btn_back"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="100dp"
- android:paddingLeft="2dp"
- android:layout_alignParentLeft="true"
- android:visibility="visible"
- android:layout_alignWithParentIfMissing="true"
- android:src="@drawable/btn_arrow_left"/>
-
- <ImageView android:id="@+id/btn_forward"
- android:clickable="true"
- android:focusable="true"
- android:layout_width="wrap_content"
- android:layout_height="100dp"
- android:paddingRight="2dp"
- android:layout_alignParentRight="true"
- android:visibility="visible"
- android:layout_alignWithParentIfMissing="true"
- android:src="@drawable/btn_arrow_right"/>
-
- </RelativeLayout>
-
- <TextView android:id="@+id/pty_tv"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="14dp"
- android:paddingTop="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="2dp"
- android:paddingLeft="2dp"
- android:text="@string/pty_string" />
-
- </LinearLayout>
-
- <!-- Station Radio Text information display -->
- <TextView android:id="@+id/radio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="5dp"
- android:gravity="center_horizontal"
- android:text="@string/radio_text_string"/>
-
- <TextView android:id="@+id/eradio_text_tv"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dp"
- android:singleLine="true"
- android:textStyle="bold"
- android:paddingLeft="2dp"
- android:paddingRight="2dp"
- android:paddingBottom="5dp"
- android:gravity="center_horizontal"
- android:text="@string/eradio_text_string"/>
- </LinearLayout>
-
-</merge>
diff --git a/fmapp/res/layout-small/statusbar.xml b/fmapp/res/layout-small/statusbar.xml
deleted file mode 100644
index b8a8189..0000000
--- a/fmapp/res/layout-small/statusbar.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="horizontal">
-
- <ImageView android:id="@+id/icon"
- android:padding="4dp"
- android:gravity="center"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- </ImageView>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView android:id="@+id/frequency"
- android:textAppearance="?android:attr/textAppearanceMediumInverse"
- android:focusable="true"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:layout_gravity="left"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </LinearLayout>
-</LinearLayout>
diff --git a/fmapp/res/layout/band_sweep_setting.xml b/fmapp/res/layout/band_sweep_setting.xml
deleted file mode 100644
index 777332c..0000000
--- a/fmapp/res/layout/band_sweep_setting.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 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.
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:scrollbars="vertical"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_gravity="center_horizontal"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <TextView
- android:id="@+id/lbl_band_sweep_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:text="@string/band_sweep_choose"/>
-
- <Spinner
- android:id="@+id/band_sweep_spinner"
- android:layout_width="fill_parent"
- android:layout_height="75dp"
- android:layout_below="@id/lbl_band_sweep_spinner"
- android:prompt="@string/band_method_prompt"
- android:textSize="25sp"/>
-
- <TextView
- android:id="@+id/LabelStartdelay"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:layout_below="@id/band_sweep_spinner"
- android:text="@string/enter_start_delay_time"/>
-
- <EditText
- android:id="@+id/txtboxDelayTime"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:inputType="number"
- android:layout_toRightOf="@id/LabelStartdelay"/>
-
- <TextView
- android:id="@+id/LabelDwellTime"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:layout_below="@id/LabelStartdelay"
- android:text="@string/enter_dwell_time"/>
-
- <EditText
- android:id="@+id/txtboxDwellTime"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="15sp"
- android:inputType="number"
- android:layout_toRightOf="@id/LabelDwellTime"/>
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/fmapp/res/menu/menu_rf_stats.xml b/fmapp/res/menu/menu_rf_stats.xml
deleted file mode 100644
index 505e49b..0000000
--- a/fmapp/res/menu/menu_rf_stats.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 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.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/menu_recording"
- android:icon="@drawable/ic_menu_record"
- android:showAsAction="ifRoom|withText" />
-
- <item android:id="@+id/menu_record_duration"
- android:showAsAction="ifRoom|withText"
- android:title=""/>
-
-</menu>
-
diff --git a/fmapp/res/values/arrays.xml b/fmapp/res/values/arrays.xml
deleted file mode 100644
index 3778be1..0000000
--- a/fmapp/res/values/arrays.xml
+++ /dev/null
@@ -1,391 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2011-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.
--->
-<resources>
-
- <string-array name="ster_mon_entries">
- <item>Stereo</item>
- <item>Mono</item>
- </string-array>
-
- <string-array name="ster_mon_values">
- <item>0</item>
- <item>1</item>
- </string-array>
-
- <string-array name="record_durations_entries">
- <item>5 minutes</item>
- <item>15 minutes</item>
- <item>30 minutes</item>
- <item>Until stopped</item>
- </string-array>
-
-
- <string-array name="record_duration_values">
- <item>5</item>
- <item>15</item>
- <item>30</item>
- <item>-1</item>
- </string-array>
-
- <string-array name="sleep_duration_values">
- <item>15 minutes</item>
- <item>30 minutes</item>
- <item>45 minutes</item>
- <item>1 Hour</item>
- </string-array>
-
- <!-- This array should be in seconds and should match the values above -->
- <string-array name="sleep_duration_values_seconds">
- <item>900</item>
- <item>1800</item>
- <item>2700</item>
- <item>3600</item>
- </string-array>
-
- <string-array name="search_category_rbds_entries">
- <item>All Stations</item>
- <item>Adult Hits</item>
- <item>Classical</item>
- <item>Classic Rock</item>
- <item>College</item>
- <item>Country</item>
- <item>Emergency</item>
- <item>Emergency Test</item>
- <item>Foreign Language</item>
- <item>Information</item>
- <item>Jazz</item>
- <item>News</item>
- <item>Nostalgia</item>
- <item>Oldies</item>
- <item>Personality</item>
- <item>Public</item>
- <item>Religious Music</item>
- <item>Religious Talk</item>
- <item>Rhythm and Blues</item>
- <item>Rock</item>
- <item>Soft</item>
- <item>Soft Rock</item>
- <item>Soft Rhythm and Blues</item>
- <item>Sports</item>
- <item>Talk</item>
- <item>Top 40</item>
- <item>Weather</item>
- </string-array>
-
- <string-array name="search_category_rbds_values">
- <item>0</item>
- <item>7</item>
- <item>15</item>
- <item>6</item>
- <item>23</item>
- <item>10</item>
- <item>31</item>
- <item>30</item>
- <item>18</item>
- <item>2</item>
- <item>14</item>
- <item>1</item>
- <item>13</item>
- <item>11</item>
- <item>21</item>
- <item>22</item>
- <item>19</item>
- <item>20</item>
- <item>16</item>
- <item>5</item>
- <item>12</item>
- <item>8</item>
- <item>17</item>
- <item>3</item>
- <item>4</item>
- <item>9</item>
- <item>29</item>
- </string-array>
-
-
- <string-array name="search_category_rds_entries">
- <item>All Stations</item>
- <item>Culture</item>
- <item>Current Affairs</item>
- <item>Children programs</item>
- <item>Country Music</item>
- <item>Documentary</item>
- <item>Drama</item>
- <item>Easy Listening Music</item>
- <item>Education</item>
- <item>Emergency</item>
- <item>Emergency Test</item>
- <item>Finance</item>
- <item>Folk Music</item>
- <item>Information</item>
- <item>Jazz Music</item>
- <item>Light classical</item>
- <item>Leisure</item>
- <item>News</item>
- <item>National Music</item>
- <item>Other Music</item>
- <item>Oldies Music</item>
- <item>Phone In</item>
- <item>Pop Music</item>
- <item>Religion</item>
- <item>Rock Music</item>
- <item>Science</item>
- <item>Serious classical</item>
- <item>Social Affairs</item>
- <item>Sport</item>
- <item>Travel</item>
- <item>Varied</item>
- <item>Weather</item>
- </string-array>
-
- <string-array name="search_category_rds_values">
- <item>0</item>
- <item>7</item>
- <item>2</item>
- <item>18</item>
- <item>25</item>
- <item>29</item>
- <item>6</item>
- <item>12</item>
- <item>5</item>
- <item>31</item>
- <item>30</item>
- <item>17</item>
- <item>28</item>
- <item>3</item>
- <item>24</item>
- <item>13</item>
- <item>23</item>
- <item>1</item>
- <item>26</item>
- <item>15</item>
- <item>27</item>
- <item>21</item>
- <item>10</item>
- <item>20</item>
- <item>11</item>
- <item>8</item>
- <item>14</item>
- <item>19</item>
- <item>4</item>
- <item>22</item>
- <item>9</item>
- <item>16</item>
- </string-array>
-
- <string-array name="presetlist_edit_category">
- <item>Rename</item>
- <item>Auto-Select</item>
- <item>Delete</item>
- </string-array>
-
-
- <string-array name="regional_band_entries">
- <item>North America</item>
- <item>Europe</item>
- <item>Japan</item>
- <item>Japan (Wide)</item>
- <item>Australia</item>
- <item>Austria</item>
- <item>Belgium</item>
- <item>Brazil</item>
- <item>China</item>
- <item>Czech</item>
- <item>Denmark</item>
- <item>Finland</item>
- <item>France</item>
- <item>Germany</item>
- <item>Greece</item>
- <item>Hong Kong</item>
- <item>India</item>
- <item>Ireland</item>
- <item>Italy</item>
- <item>Korea</item>
- <item>Mexico</item>
- <item>Netherlands</item>
- <item>New Zealand</item>
- <item>Norway</item>
- <item>Poland</item>
- <item>Portugal</item>
- <item>Russia</item>
- <item>Singapore</item>
- <item>Slovakia</item>
- <item>Spain</item>
- <item>Switzerland</item>
- <item>Sweden</item>
- <item>Taiwan</item>
- <item>Turkey</item>
- <item>United Kingdom </item>
- <item>United States</item>
- <item>User Defined Band</item>
- </string-array>
-
- <string-array name="regional_band_values">
- <item>0</item>
- <item>1</item>
- <item>2</item>
- <item>3</item>
- <item>4</item>
- <item>5</item>
- <item>6</item>
- <item>7</item>
- <item>8</item>
- <item>9</item>
- <item>10</item>
- <item>11</item>
- <item>12</item>
- <item>13</item>
- <item>14</item>
- <item>15</item>
- <item>16</item>
- <item>17</item>
- <item>18</item>
- <item>19</item>
- <item>20</item>
- <item>21</item>
- <item>22</item>
- <item>23</item>
- <item>24</item>
- <item>25</item>
- <item>26</item>
- <item>27</item>
- <item>28</item>
- <item>29</item>
- <item>30</item>
- <item>31</item>
- <item>32</item>
- <item>33</item>
- <item>34</item>
- <item>35</item>
- <item>36</item>
- </string-array>
-
- <string-array name="regional_band_summary">
- <item>North America (87.5MHz To 108.0MHz In 200 Khz Steps)</item>
- <item>Europe (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Japan (76.0MHz To 90.0MHz In 100 Khz Steps)</item>
- <item>Japan (Wide) (90.0MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Australia (87.7MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Austria (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Belgium (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Brazil (87.5MHz To 108.0MHz In 200 Khz Step)</item>
- <item>China (87.0MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Czech (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Denmark (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Finland (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>France (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Germany (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Greece (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Hong Kong (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>India (91.0MHz To 106.4MHz In 100 Khz Steps)</item>
- <item>Ireland (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Italy (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Korea (87.5MHz To 108.0MHz In 200 Khz Steps)</item>
- <item>Mexico (88.1MHz To 107.9MHz In 200 Khz Steps)</item>
- <item>Netherlands (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>New Zealand (88.0MHz To 107.0MHz In 100 Khz Steps)</item>
- <item>Norway (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Poland (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Portugal (87.5MHz To 108.0MHz In 50 Khz Steps)</item>
- <item>Russia (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Singapore (88.0MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Slovakia (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Spain (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Switzerland (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Sweden (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Taiwan (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>Turkey (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>United Kingdom (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
- <item>United States (88.1MHz To 107.9MHz In 200 Khz Steps)</item>
- <item>User Defined Band</item>
- </string-array>
-
- <string-array name="rf_cfg">
- <item> Get Current Station Parameters</item>
- <item> Get Station Parameters Repeat 20 times</item>
- <item> Get Search station parameters</item>
- <item> Get FM Band sweep parameters</item>
- <item> Configure Performance Parameters</item>
- </string-array>
-
- <string-array name="cfg_rf1">
- <item> Set FM RSSI Delta</item>
- <item> Set Signal Threshold</item>
- <item> RF Statistics</item>
- </string-array>
-
- <string-array name="cfg_rf2">
- <item> Set SINR Samples Count</item>
- <item> Set SINR Threshold</item>
- <item> Set IntfDetoutLow Threshold</item>
- <item> Set IntfDetoutHigh Threshold</item>
- <item> Set SinrFirstStage</item>
- <item> Set RmssiFirstStage</item>
- <item> Set CF0Th12</item>
- <item> Set SearchAlgo Type</item>
- <item> Get SINR Samples Count</item>
- <item> Get SINR Threshold</item>
- <item> Get SinrFirstStage</item>
- <item> Get RmssiFirstStage</item>
- <item> Get CF0Th12</item>
- <item> Get Search Algo Type</item>
- <item> Set AfJmpRmssi Threshold</item>
- <item> Set GoodChRmssi Threshold</item>
- <item> Set AfJmpRmssi Samples count</item>
- <item> Get AfJmpRmssi Threshold</item>
- <item> Get GoodChRmssi Threshold</item>
- <item> Get AfJmpRmssi Samples count</item>
- <item> RF Statistics</item>
- <item> Set RXREPEAT Count</item>
- </string-array>
-
- <string-array name="stats_options">
- <item> Select the option</item>
- <item> Configure Performance parameters</item>
- <item> RF Statistics</item>
- </string-array>
-
- <string-array name="channel_spacing_val">
- <item>2</item>
- <item>1</item>
- <item>0</item>
- </string-array>
-
- <string-array name="channel_spacing_entries">
- <item>50 Khz</item>
- <item>100 Khz</item>
- <item>200 Khz</item>
- </string-array>
-
- <string-array name="band_sweep_methods">
- <item>Manual</item>
- <item>From File</item>
- </string-array>
-
-</resources>
diff --git a/fmapp/res/values/strings.xml b/fmapp/res/values/strings.xml
deleted file mode 100644
index 995ae04..0000000
--- a/fmapp/res/values/strings.xml
+++ /dev/null
@@ -1,279 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name">FM Radio</string>
- <string name="tx_app_name">FM Transmitter</string>
-
- <string name="default_sleep">Sleep 12:34</string>
- <string name="menu_add_to_preset">Add to Presets</string>
- <string name="menu_settings">Settings</string>
- <string name="menu_record_start">Start Recording</string>
- <string name="menu_record_stop">Stop Recording</string>
- <string name="button_ok">OK</string>
- <string name="error_sdcard_access">Unable to access SD card</string>
- <string name="fm_service_started">FM Service</string>
- <string name="menu_sleep">Sleep</string>
- <string name="menu_sleep_cancel">Cancel Sleep</string>
- <string name="menu_wired_headset">Wired Headset</string>
- <string name="menu_speaker_on">Enable Speaker</string>
- <string name="menu_display_tags">Show Tags</string>
- <string name="menu_speaker_off">Disable Speaker</string>
- <string name="menu_scan_start">Scan</string>
- <string name="menu_scan_stop">Stop Searching</string>
- <string name="menu_stats">FM RF Stats</string>
- <string name="button_text_stop">Stop</string>
- <string name="msg_seeking">Searching FM Station</string>
- <string name="msg_scanning">Scanning for all FM Stations</string>
- <string name="msg_scanning_pty">Scanning for "<xliff:g id="pty_name">%1$s</xliff:g>"</string>
- <string name="msg_search_title">FM - <xliff:g id="frequency_string">%1$s</xliff:g></string>
- <string name="msg_searching">Searching for Strong Stations to create a Preset List </string>
- <string name="msg_searching_title">Auto-Select Presets</string>
- <string name="msg_weak_searching">Searching for frequencies to transmit</string>
-
- <string name="msg_noantenna">Please plug in a Headset to use FM
- Radio </string>
- <string name="msg_headsetpluggedin">Disconnect all Headsets for using FM Tx</string>
- <string name="msg_callactive">FM Tx is not supported when there is active voice call</string>
- <string name="dialog_sleep_title">Select Auto-Off Sleep Time</string>
- <string name="preset_select_name">Select "<xliff:g id="preset_name">%1$s</xliff:g>"</string>
- <string name="presetlist_select_name">Select "<xliff:g id="presetlist_name">%1$s</xliff:g>"</string>
- <string name="presetlist_add_new">Add New List</string>
- <string name="dialog_presetlist_title">Preset Lists</string>
- <string name="presetlist_prefix_name">FM - </string>
- <string name="dialog_presetlist_rename_title">Enter a name </string>
- <string name="dialog_preset_rename_title">Enter a name </string>
- <string name="presetlist_delete_name">Delete "<xliff:g id="presetlist_name">%1$s</xliff:g>" and its Stations?</string>
- <string name="presetlist_autoselect_title">Confirm Auto-Select</string>
- <string name="presetlist_autoselect_name">Auto-Select will delete all the Presets in the list "<xliff:g id="presetlist_name">%1$s</xliff:g>", Continue?</string>
- <string name="fmtx_autoselect_name">Auto-Select will delete all the Presets, Continue?</string>
-
- <string name="enter_frequency">Tune to Station</string>
- <string name="enter_new_frequency_title">Enter Frequency </string>
-
- <string name="preset_now_playing">Now Playing </string>
- <string name="preset_pref_title">"<xliff:g id="preset_name">%1$s</xliff:g>"
- (<xliff:g id="preset_freq">%2$s</xliff:g>)</string>
- <string name="preset_delete_title">Delete Preset</string>
-
- <string name="preset_delete_name">Delete "<xliff:g id="preset_name">%1$s</xliff:g>"
- from "<xliff:g id="presetlist_name">%2$s</xliff:g>"</string>
-
- <string name="preset_confirm_delete_name">Delete "<xliff:g id="preset_name">%1$s</xliff:g>"
- from "<xliff:g id="presetlist_name">%2$s</xliff:g>" ?</string>
-
- <string name="preset_name_dialog_title">Enter a name </string>
- <string name="preset_name_summary">"<xliff:g id="preset_name">%1$s</xliff:g>" </string>
- <string name="preset_name_title">Rename</string>
-
- <string name="preset_search_title">Search</string>
- <string name="preset_search_name">Search for "<xliff:g id="preset_name">%1$s</xliff:g>"</string>
-
- <string name="preset_preference_title">FM Stations in "<xliff:g id="preset_name">%1$s</xliff:g>" </string>
-
- <string name="preset_empty_title">No Stations in the List</string>
- <string name="preset_empty_add_summary">Add Stations</string>
-
- <string name="preset_add">Add</string>
- <string name="preset_replace">Replace</string>
- <string name="preset_tune">Tune</string>
- <string name="preset_rename">Rename</string>
- <string name="preset_delete">Delete</string>
- <string name="preset_search">Search for "<xliff:g id="preset_pi">%1$s</xliff:g>"
- </string>
-
- <string name="stat_notif_frequency">FM Radio Station "<xliff:g id="frequency">%1$s</xliff:g>"</string>
- <string name="stat_notif_tx_frequency">FM Transmitting at: "<xliff:g id="frequency">%1$s</xliff:g>"</string>
-
-
- <string name="sel_band_menu">Select Regional Band</string>
- <string name="test_menu">Select Test</string>
-
- <string name="settings_menu">Settings</string>
- <string name="regional_band">Regional Band</string>
-
- <string name="aud_output_mode">Audio Output Mode</string>
- <string name="sel_audio_output">Select Audio Output</string>
-
- <string name="record_dur">Record Duration</string>
- <string name="sel_rec_dur">Select Record Duration</string>
-
- <string name="auto_select_af">Alternate Frequency</string>
- <string name="auto_select_af_enabled">Auto Select Enabled</string>
- <string name="auto_select_af_disabled">Auto Select Disabled</string>
-
- <string name="fac_defaults">Revert to Factory Defaults</string>
- <string name="revert_to_fac">Revert to Factory Defaults</string>
- <string name="settings_back">Back</string>
-
- <string name="settings_revert_confirm_title">Confirm Reset Settings</string>
- <string name="settings_revert_confirm_msg">This will delete all settings including Presets</string>
-
- <string name="settings_back_summary">Return to previous view</string>
- <string name="settings_revert_defaults_title">Revert to Factory Defaults</string>
- <string name="settings_revert_defaults_summary">Reset all settings</string>
-
- <string name="audio_type_stereo">Stereo</string>
- <string name="audio_type_mono">Mono</string>
-
- <string name="default_band">United States</string>
- <string name="default_audio">Stereo</string>
- <string name="default_record_duration">5 minutes</string>
- <string name="factory_reset_dialog_title">Confirm Reset</string>
- <string name="factory_reset_dialog_message">This will delete all settings including Presets</string>
- <string name="station_move">Move</string>
- <string name="station_edit">Edit</string>
- <!-- alert to the user that USB storage must be available before using FM recording [CHAR LIMIT=NONE] -->
- <string name="no_storage">Mount SD card before start recording.</string>
- <!-- alert to the user that the USB storage is being disk-checked [CHAR LIMIT=30] -->
- <string name="preparing_sd">Preparing SD card</string>
- <!-- alert to the user that the FM fails to read or write the USB storage. [CHAR LIMIT=NONE] -->
- <string name="access_sd_fail">Couldn\'t access SD card.</string>
- <!-- Low-memory dialog message [CHAR LIMT=NONE] -->
- <string name="spaceIsLow_content">Your SD card storage is running out of space. Change the quality setting or delete some images or other files.</string>
- <!-- The messsage shown when FM record reaches size limit. -->
- <string name="FMRecording_reach_size_limit">Size limit reached.</string>
-
- <string name="delete_station_title">Delete</string>
- <string name="find_af_station">Find</string>
- <string name="menu_add_list">Add List</string>
- <string name="menu_rename_list">Rename List</string>
- <string name="menu_reorder_list">Reorder List</string>
- <string name="menu_scan_for_preset">Scan for Presets</string>
- <string name="menu_delete_list">Delete List</string>
- <string name="alert_dialog_ok">Ok</string>
- <string name="alert_dialog_cancel">Cancel</string>
-
- <string name="search_dialog_title">Scan Stations</string>
-
- <string name="search_category_key">search_category_type</string>
- <string name="search_category">Select Search Type</string>
- <string name="search_category_title">Search Type</string>
- <string name="default_search_category">Seek</string>
- <string name="search_category_tune">Tune</string>
-
- <string name="search_category_type_key">search_category_value_type</string>
- <string name="search_category_type">Select Search by Program Type</string>
- <string name="search_category_type_title">Search by Program Type</string>
- <string name="default_search_category_type">All Stations</string>
-
- <string name="presets_back">Back</string>
- <string name="presets_back_summary">Return to previous view</string>
-
- <string name="nav_mode_presets">Presets</string>
- <string name="nav_mode_stations">Stations</string>
-
- <string name="prog_service_string"></string>
- <string name="radio_text_string">This is the long Radio Text String Message that needs to scroll</string>
- <string name="eradio_text_string">Extended Radio Text Message</string>
- <string name="pty_string"></string>
- <string name="frequency_string"></string>
- <string name="station_id_string"></string>
-
-
- <string name="fm_command_timeout_title">Timeout</string>
- <string name="fm_tune_timeout_msg">No response received to Tune FM
- Station. If problem persists, please turn off FM and turn it back
- on.</string>
-
- <string name="fm_command_failed_title">FM Operation failed</string>
- <string name="fm_cmd_failed_msg">FM operation failed. If problem
- persists, please turn off FM and turn it back on.
- </string>
- <string name="fm_cmd_failed_msg_hdmi">FM operation failed. FM and HDMI concurrecny is not supported.
- </string>
- <string name="fm_cmd_failed_call_on">FM operation failed. FM audio is not allowed during call. </string>
-
- <skip/>
- <!-- Do not translate. Duration format. -->
- <string name="durationformat"><xliff:g id="format">%2$d:%5$02d</xliff:g></string>
-
- <string name="default_record"></string>
- <string name="default_preset_list_name"> FM List </string>
- <string name="default_station"> FM </string>
- <string name="default_blank"> </string>
- <string name="stop_scanning">Stop Scanning</string>
- <string name="transmit_msg_string">Transmitting at:</string>
- <!-- the name under which recordings will be visible in the media database is formatted like this -->
- <string name="audio_db_title_format"><xliff:g id="format">yyyy-MM-dd HH:mm:ss</xliff:g></string>
- <!-- all recordings will show up in the media database with this 'artist' name -->
- <string name="audio_db_artist_name">My FM recordings</string>
- <!-- all recordings will show up in the media database with this 'album' name -->
- <string name="audio_db_album_name">FM recordings</string>
- <!-- all recordings will show up in the media database in a playlist with this name -->
- <string name="audio_db_playlist_name">FM recordings</string>
- <string name="test_prompt">Choose a test</string>
- <string name="test_run">Run Test</string>
- <string name="set_rmmsi_delta">Configure RMSSI Delta</string>
- <string name="set_sigth">Configure Signal Th</string>
- <string name="type_rd"></string>
- <string name="srch_params">Configure RMSSI Delta</string>
- <string name="srch_params_1">Configure Signal Th </string>
- <string name="enter_rssi">Enter RMSSI Delta</string>
- <string name="enter_sigth">Enter Signal Th</string>
- <string name="enter_SinrSmplsCnt">Enter SINR Samples Count</string>
- <string name="set_SinrSmplsCnt">Configure SINR Samples</string>
- <string name="enter_SinrTh">Enter SINR Threshold</string>
- <string name="set_SinrTh">Configure SINR Threshold</string>
- <string name="enter_IntfLowTh">Enter Intf Det Low Threshold</string>
- <string name="set_IntfLowTh">Config Intf Det Low Threshold</string>
- <string name="enter_IntfHighTh">Enter Intf Det High Threshold</string>
- <string name="set_IntfHighTh">Config Intf Det High Threshold</string>
- <string name="enter_SinrFirstStage">Enter Sinr First Stage</string>
- <string name="set_SinrFirstStage">Config Sinr First Stage</string>
- <string name="enter_RmssiFirstStage">Enter Rmssi First Stage</string>
- <string name="set_RmssiFirstStage">Config Rmssi First Stage</string>
- <string name="enter_CF0Th12">Enter CF0 Threshold</string>
- <string name="set_CF0Th12">Config CF0 Threshold</string>
- <string name="search_algo_mpx">MPX_DCC Algo</string>
- <string name="search_algo_sinrint">SINR_INTF Algo</string>
- <string name="enter_AfJmpRmssiTh">Enter Af Jump Rmssi Threshold</string>
- <string name="set_AfJmpRmssiTh">Config Af Jump Rmssi Threshold</string>
- <string name="enter_GdChRmssiTh">Enter Good Channel Rmssi Threshold</string>
- <string name="set_GdChRmssiTh">Config Good Channel Rmssi Threshold</string>
- <string name="enter_AfJmpRmssiSmplsCnt">Enter Af Jump Rmssi Samples count</string>
- <string name="set_AfJmpRmssiSmplsCnt">Config Af Jump Rmssi Samples count</string>
- <string name="rt_plus_tags">Tags</string>
- <string name="enter_RxRePeatCount">Enter RxRePeat count</string>
- <string name="set_RxRePeatCount">Config RxRePeat count</string>
- <string name="save_record_file">FM Recorded file saved to "<xliff:g id="record_file">%1$s</xliff:g>"</string>
-
- <string name="usr_def_band_min">Lower Freq Limit(In Mhz)</string>
- <string name="usr_def_band_max">Higher Freq Limit(In Mhz)</string>
- <string name="sel_chanl_spacing">Select Channel Spacing</string>
- <string name="chanl_spacing">Channel Spacing</string>
-
- <string name="band_method_prompt">Select Method</string>
- <string name="enter_start_delay_time">Start Delay Time</string>
- <string name="enter_dwell_time">Dwell Time</string>
- <string name="band_sweep_setting">Sweep Setting</string>
- <string name="band_sweep_setting_set">Set</string>
- <string name="band_sweep_setting_cancel">Cancel</string>
- <string name="band_sweep_choose">Choose Band Sweep Method</string>
-
-</resources>
diff --git a/fmapp/res/values/styles.xml b/fmapp/res/values/styles.xml
deleted file mode 100644
index 5119c09..0000000
--- a/fmapp/res/values/styles.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2009, 2012,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.
--->
-<resources>
- <style name="FMStationSeekBar">
- <item name="android:indeterminateOnly">false</item>
- <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
- <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
- <item name="android:minHeight">20dp</item>
- <item name="android:maxHeight">20dp</item>
- <item name="android:thumbOffset">8dp</item>
- <item name="android:focusable">true</item>
- </style>
-</resources>
diff --git a/fmapp/src/com/codeaurora/fmradio/CommaSeparatedFreqFileReader.java b/fmapp/src/com/codeaurora/fmradio/CommaSeparatedFreqFileReader.java
deleted file mode 100644
index 0f4e1a2..0000000
--- a/fmapp/src/com/codeaurora/fmradio/CommaSeparatedFreqFileReader.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 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 android.util.Log;
-
-import java.io.*;
-
-public class CommaSeparatedFreqFileReader implements GetNextFreqInterface {
-
- private BufferedReader reader;
- private String fileName;
- private String [] freqList;
- private int index;
- private static final String LOGTAG = "COMMA_SEPARATED_FREQ_PARSER";
- private boolean errorHasOcurred;
-
- @Override
- public int getNextFreq() {
- int freq = Integer.MAX_VALUE;
-
- Log.d(LOGTAG, "Inside function get freq");
- if(!errorHasOcurred) {
- if(index < freqList.length) {
- try {
- freq = (int)(Float.parseFloat(freqList[index]) * 1000);
- }catch(NumberFormatException e) {
- Log.d(LOGTAG, "Format exception");
- }
- index++;
- if(index >= freqList.length) {
- index = 0;
- readLineAndParse();
- }
- return freq;
- }else {
- return Integer.MAX_VALUE;
- }
- }else {
- return Integer.MAX_VALUE;
- }
- }
-
- public CommaSeparatedFreqFileReader(String fileName) {
- this.fileName = fileName;
- try {
- reader = new BufferedReader(new FileReader(this.fileName));
- readLineAndParse();
- }catch(Exception e) {
- errorHasOcurred = true;
- Log.d(LOGTAG, "File not found");
- }
- }
-
- private void readLineAndParse() {
- String curLine;
- if(reader != null) {
- try {
- if((curLine = reader.readLine()) != null) {
- freqList = curLine.split(",");
- }else {
- reader.close();
- reader = null;
- errorHasOcurred = true;
- }
- }catch(Exception e) {
- errorHasOcurred = true;
- }
- }else {
- errorHasOcurred = true;
- }
- }
-
- @Override
- public void Stop() {
- if(reader != null) {
- try {
- reader.close();
- reader = null;
- }catch(Exception e) {
- }
- errorHasOcurred = true;
- }
- }
-
- @Override
- public boolean errorOccured() {
- return errorHasOcurred;
- }
-}
-
diff --git a/fmapp/src/com/codeaurora/fmradio/FMAdapterApp.java b/fmapp/src/com/codeaurora/fmradio/FMAdapterApp.java
deleted file mode 100644
index 87b0aeb..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMAdapterApp.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
- * Not a Contribution.
- *
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @hide
- */
-
-package com.codeaurora.fmradio;
-
-import android.app.Application;
-import android.util.Log;
-
-public class FMAdapterApp extends Application {
- private static final String TAG = "FMAdapterApp";
- private static final boolean DBG = true;
- //For Debugging only
- private static int sRefCount=0;
-
- static {
- if (DBG) Log.d(TAG,"Loading FM-JNI Library");
- System.loadLibrary("qcomfm_jni");
- }
-
- public FMAdapterApp() {
- super();
- if (DBG) {
- synchronized (FMAdapterApp.class) {
- sRefCount++;
- Log.d(TAG, "REFCOUNT: Constructed "+ this + " Instance Count = " + sRefCount);
- }
- }
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- }
-
- @Override
- protected void finalize() {
- if (DBG) {
- synchronized (FMAdapterApp.class) {
- sRefCount--;
- Log.d(TAG, "REFCOUNT: Finalized: " + this +", Instance Count = " + sRefCount);
- }
- }
- }
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMMediaButtonIntentReceiver.java b/fmapp/src/com/codeaurora/fmradio/FMMediaButtonIntentReceiver.java
deleted file mode 100644
index ca7f102..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMMediaButtonIntentReceiver.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 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 "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 android.content.Intent;
-import android.content.IntentFilter;
-import android.app.IntentService;
-import android.content.BroadcastReceiver;
-import android.content.pm.PackageManager;
-import android.content.Context;
-import android.content.ComponentName;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.os.Bundle;
-import java.lang.Object;
-
-public class FMMediaButtonIntentReceiver extends BroadcastReceiver {
-
-private static final String TAG = "FMMediaButtonIntentReceiver";
-public static final String FM_MEDIA_BUTTON = "com.codeaurora.fmradio.action.MEDIA_BUTTON";
-public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if ((action != null) && action.equals("android.intent.action.MEDIA_BUTTON")) {
- KeyEvent event = (KeyEvent)
- intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
-
- if (event == null) {
- return;
- }
- int keycode = event.getKeyCode();
- int key_action = event.getAction();
- if (((KeyEvent.KEYCODE_HEADSETHOOK == keycode) &&
- (key_action == KeyEvent.ACTION_DOWN)) ||
- (KeyEvent.KEYCODE_MEDIA_PAUSE == keycode) ||
- (KeyEvent.KEYCODE_MEDIA_PLAY == keycode)) {
-
- Log.d(TAG, "ACTION_MEDIA_BUTTON intent received for ACTION_DOWN");
- Intent i = new Intent(FM_MEDIA_BUTTON);
- i.putExtra(Intent.EXTRA_KEY_EVENT, event);
- context.sendBroadcast(i);
- }
- }
- }
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMRadio.java b/fmapp/src/com/codeaurora/fmradio/FMRadio.java
deleted file mode 100644
index f9b9e15..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMRadio.java
+++ /dev/null
@@ -1,3534 +0,0 @@
-/*
- * 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 android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.bluetooth.BluetoothA2dp;
-import android.bluetooth.BluetoothDevice;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnKeyListener;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.BroadcastReceiver;
-import android.media.AudioSystem;
-import android.media.AudioManager;
-import android.media.MediaRecorder;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.os.SystemProperties;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.view.KeyEvent;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-import android.text.TextUtils;
-
-import java.util.*;
-import java.io.File;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.Formatter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Locale;
-import java.util.ArrayList;
-
-import com.codeaurora.utils.FrequencyPicker;
-import com.codeaurora.utils.FrequencyPickerDialog;
-import android.content.ServiceConnection;
-import android.media.MediaRecorder;
-
-import qcom.fmradio.FmConfig;
-import android.os.ServiceManager;
-
-
-public class FMRadio extends Activity
-{
- public static final String LOGTAG = "FMRadio";
-
- public static final boolean RECORDING_ENABLE = true;
- MediaRecorder mRecorder = null;
-
- /* menu Identifiers */
- private static final int MENU_SCAN_START = Menu.FIRST + 2;
- private static final int MENU_SCAN_STOP = Menu.FIRST + 3;
- private static final int MENU_RECORD_START = Menu.FIRST + 4;
- private static final int MENU_RECORD_STOP = Menu.FIRST + 5;
- private static final int MENU_SLEEP = Menu.FIRST + 6;
- private static final int MENU_SLEEP_CANCEL = Menu.FIRST + 7;
- private static final int MENU_SETTINGS = Menu.FIRST + 8;
- private static final int MENU_SPEAKER = Menu.FIRST + 9;
- private static final int MENU_TAGS = Menu.FIRST + 10;
- private static final int MENU_STAT_TEST = Menu.FIRST + 11;
-
- /* Dialog Identifiers */
- private static final int DIALOG_SEARCH = 1;
- private static final int DIALOG_SLEEP = 2;
- private static final int DIALOG_SELECT_PRESET_LIST = 3;
- private static final int DIALOG_PRESETS_LIST = 4;
- private static final int DIALOG_PRESET_LIST_RENAME = 5;
- private static final int DIALOG_PRESET_LIST_DELETE = 6;
- private static final int DIALOG_PRESET_LIST_AUTO_SET = 7;
- private static final int DIALOG_PICK_FREQUENCY = 8;
- private static final int DIALOG_PROGRESS_PROGRESS = 9;
- private static final int DIALOG_PRESET_OPTIONS = 10;
- private static final int DIALOG_PRESET_RENAME = 11;
- private static final int DIALOG_CMD_TIMEOUT = 12;
- private static final int DIALOG_CMD_FAILED = 13;
- private static final int DIALOG_CMD_FAILED_HDMI_ON = 14;
- private static final int DIALOG_CMD_FAILED_CALL_ON = 15;
- private static final int DIALOG_TAGS = 16;
-
- /* Activity Return ResultIdentifiers */
- private static final int ACTIVITY_RESULT_SETTINGS = 1;
-
- /* Activity Return ResultIdentifiers */
- private static final int MAX_PRESETS_PER_PAGE = 5;
-
-
- /* Station's Audio is Stereo */
- private static final int FMRADIO_UI_STATION_AUDIO_STEREO = 1;
- /* Station's Audio is Mono */
- private static final int FMRADIO_UI_STATION_AUDIO_MONO = 2;
-
- /* The duration during which the "Sleep: xx:xx" string will be toggling
- */
- private static final int SLEEP_TOGGLE_SECONDS = 60;
-
- /* The number of Preset Stations to create.
- * The hardware supports a maximum of 12.
- */
- private static final int NUM_AUTO_PRESETS_SEARCH= 12;
- /*
- * Command time out: For asynchonous operations, if no response
- * is received with int this duration, a timeout msg will be displayed.
- */
- private static final int CMD_TIMEOUT_DELAY_MS = 5000;
- private static final int MSG_CMD_TIMEOUT = 101;
-
- private static final int CMD_NONE = 0;
- private static final int CMD_TUNE = 1;
- private static final int CMD_FMON = 2;
- private static final int CMD_FMOFF = 3;
- private static final int CMD_FMCONFIGURE = 4;
- private static final int CMD_MUTE = 5;
- private static final int CMD_SEEK = 6;
- private static final int CMD_SCAN = 7;
- private static final int CMD_SEEKPI = 8;
- private static final int CMD_SEARCHLIST = 9;
- private static final int CMD_CANCELSEARCH = 10;
- private static final int CMD_SET_POWER_MODE = 11;
- private static final int CMD_SET_AUDIO_MODE = 12;
- private static final int CMD_SET_AUTOAF = 13;
- private static final int CMD_GET_INTERNALANTENNA_MODE = 14;
-
- private static final int PRESETS_OPTIONS_TUNE = 0;
- private static final int PRESETS_OPTIONS_REPLACE = 1;
- private static final int PRESETS_OPTIONS_RENAME = 2;
- private static final int PRESETS_OPTIONS_DELETE = 3;
- private static final int PRESETS_OPTIONS_SEARCHPI = 4;
-
- private static IFMRadioService mService = null;
- private static FmSharedPreferences mPrefs;
-
- /* Button Resources */
- private ImageButton mOnOffButton;
- private ImageButton mMuteButton;
- /* Button to navigate Preset pages */
- private ImageButton mPresetPageButton;
- /* 6 Preset Buttons */
- private Button[] mPresetButtons = { null, null, null, null, null};
- private Button mPresetListButton;
- // private ImageButton mSearchButton;
- private ImageView mForwardButton;
- private ImageView mBackButton;
-
- /* Top row in the station info layout */
- private ImageView mRSSI;
- private TextView mProgramServiceTV;
- private TextView mStereoTV;
-
- /* Middle row in the station info layout */
- private TextView mTuneStationFrequencyTV;
- private TextView mStationCallSignTV;
- private TextView mProgramTypeTV;
-
- /* Bottom row in the station info layout */
- private TextView mRadioTextTV;
- private TextView mERadioTextTV;
-
- /* Sleep and Recording Messages */
- private TextView mSleepMsgTV;
- private TextView mRecordingMsgTV;
-
- private double mOutputFreq;
- private int mPresetPageNumber = 0;
- private int mStereo = -1;
-
- // default audio device - speaker
- private static int mAudioRoute = FMRadioService.RADIO_AUDIO_DEVICE_WIRED_HEADSET;
- private static boolean mFMStats = false;
-
-
- /* Current Status Indicators */
- private static boolean mRecording = false;
- private static boolean mIsScaning = false;
- private static boolean mIsSeeking = false;
- private static boolean mIsSearching = false;
- private static int mScanPty = 0;
-
- private Animation mAnimation = null;
- private ScrollerText mRadioTextScroller = null;
-
- private static PresetStation mTunedStation = new PresetStation("", 102100);
- private PresetStation mPresetButtonStation = null;
-
- /* Radio Vars */
- final Handler mHandler = new Handler();
- /* Search Progress Dialog */
- private ProgressDialog mProgressDialog=null;
-
- /* Asynchronous command active */
- private static int mCommandActive = 0;
-
- /* Command that failed (Sycnhronous or Asynchronous) */
- private static int mCommandFailed = 0;
-
- private LoadedDataAndState SavedDataAndState = null;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setVolumeControlStream(AudioManager.STREAM_MUSIC);
- mPrefs = new FmSharedPreferences(this);
- mCommandActive = CMD_NONE;
- mCommandFailed = CMD_NONE;
-
- Log.d(LOGTAG, "onCreate - Height : "+ getWindowManager().getDefaultDisplay().getHeight()
- + " - Width : "+ getWindowManager().getDefaultDisplay().getWidth());
-
- setContentView(R.layout.fmradio);
- SavedDataAndState = (LoadedDataAndState)getLastNonConfigurationInstance();
- mAnimation = AnimationUtils.loadAnimation(this,
- R.anim.preset_select);
-
- mMuteButton = (ImageButton) findViewById(R.id.btn_silent);
- if (mMuteButton != null)
- {
- mMuteButton.setOnClickListener(mMuteModeClickListener);
- }
-
- mOnOffButton = (ImageButton) findViewById(R.id.btn_onoff);
- if (mOnOffButton != null)
- {
- mOnOffButton.setOnClickListener(mTurnOnOffClickListener);
- }
-
- mForwardButton = (ImageView) findViewById(R.id.btn_forward);
- if (mForwardButton != null)
- {
- mForwardButton.setOnClickListener(mForwardClickListener);
- mForwardButton.setOnLongClickListener(mForwardLongClickListener);
- }
-
- mBackButton = (ImageView) findViewById(R.id.btn_back);
- if (mBackButton != null)
- {
- mBackButton.setOnClickListener(mBackClickListener);
- mBackButton.setOnLongClickListener(mBackLongClickListener);
- }
-
- mPresetPageButton = (ImageButton) findViewById(R.id.btn_preset_page);
- if (mPresetPageButton != null)
- {
- mPresetPageButton.setOnClickListener(mPresetsPageClickListener);
- }
-
- mPresetListButton = (Button) findViewById(R.id.btn_presets_list);
- if (mPresetListButton != null)
- {
- mPresetListButton.setOnClickListener(mPresetListClickListener);
- mPresetListButton
- .setOnLongClickListener(mPresetListButtonOnLongClickListener);
- }
-
- /* 6 Preset Buttons */
- mPresetButtons[0] = (Button) findViewById(R.id.presets_button_1);
- mPresetButtons[1] = (Button) findViewById(R.id.presets_button_2);
- mPresetButtons[2] = (Button) findViewById(R.id.presets_button_3);
- mPresetButtons[3] = (Button) findViewById(R.id.presets_button_4);
- mPresetButtons[4] = (Button) findViewById(R.id.presets_button_5);
- for (int nButton = 0; nButton < MAX_PRESETS_PER_PAGE; nButton++)
- {
- if (mPresetButtons[nButton] != null)
- {
- mPresetButtons[nButton]
- .setOnClickListener(mPresetButtonClickListener);
- mPresetButtons[nButton]
- .setOnLongClickListener(mPresetButtonOnLongClickListener);
- }
- }
-
- mTuneStationFrequencyTV = (TextView) findViewById(R.id.prog_frequency_tv);
- if (mTuneStationFrequencyTV != null)
- {
- mTuneStationFrequencyTV.setOnLongClickListener(mFrequencyViewClickListener);
- }
- mProgramServiceTV = (TextView) findViewById(R.id.prog_service_tv);
- mStereoTV = (TextView) findViewById(R.id.stereo_text_tv);
-
- mStationCallSignTV = (TextView) findViewById(R.id.call_sign_tv);
- mProgramTypeTV = (TextView) findViewById(R.id.pty_tv);
-
- mRadioTextTV = (TextView) findViewById(R.id.radio_text_tv);
- mERadioTextTV = (TextView) findViewById(R.id.eradio_text_tv);
- mSleepMsgTV = (TextView) findViewById(R.id.sleep_msg_tv);
- mRecordingMsgTV = (TextView) findViewById(R.id.record_msg_tv);
- /* Disable displaying RSSI */
- mRSSI = (ImageView) findViewById(R.id.signal_level);
- if (mRSSI != null)
- {
- mRSSI.setVisibility(View.INVISIBLE);
- }
-
- if ((mRadioTextScroller == null) && (mRadioTextTV != null))
- {
- mRadioTextScroller = new ScrollerText(mRadioTextTV);
- }
-
- enableRadioOnOffUI(false);
- //HDMI and FM concurrecny is not supported.
- if (isHdmiOn())
- {
- showDialog(DIALOG_CMD_FAILED_HDMI_ON);
- }
- else {
- if (false == bindToService(this, osc))
- {
- Log.d(LOGTAG, "onCreate: Failed to Start Service");
- } else
- {
- Log.d(LOGTAG, "onCreate: Start Service completed successfully");
- }
- }
- }
-
- @Override
- public void onRestart() {
- Log.d(LOGTAG, "FMRadio: onRestart");
- try {
- if (null != mService) {
- mService.requestFocus();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- super.onRestart();
- }
-
- @Override
- public void onStop() {
- Log.d(LOGTAG, "FMRadio: onStop");
- if(isSleepTimerActive() ) {
- mSleepUpdateHandlerThread.interrupt();
- long timeNow = ((SystemClock.elapsedRealtime()));
- if (timeNow < mSleepAtPhoneTime)
- {
- try {
- if (null != mService) {
- mService.delayedStop((mSleepAtPhoneTime - timeNow),FMRadioService.STOP_SERVICE);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- if(isRecording()) {
- try {
- if ( null != mRecordUpdateHandlerThread) {
- mRecordUpdateHandlerThread.interrupt();
- }
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
- super.onStop();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- Log.d(LOGTAG, "FMRadio: onStart");
- try
- {
- if(mService != null)
- {
- mService.registerCallbacks(mServiceCallbacks);
- }
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- if(isSleepTimerActive()) {
- Log.d(LOGTAG,"isSleepTimerActive is true");
- try {
- if (null != mService) {
- mService.cancelDelayedStop(FMRadioService.STOP_SERVICE);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- initiateSleepThread();
- }
- if(isRecording()) {
- Log.d(LOGTAG,"isRecordTimerActive is true");
- try {
- if (null != mService) {
- mService.cancelDelayedStop(FMRadioService.STOP_RECORD);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if(isRecording()) {
- initiateRecordThread();
- }
- }
-
- }
-
- @Override
- protected void onPause() {
- Log.d(LOGTAG, "FMRadio: onPause");
- super.onPause();
- mRadioTextScroller.stopScroll();
- FmSharedPreferences.setTunedFrequency(mTunedStation.getFrequency());
- mPrefs.Save();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- Log.d(LOGTAG, "FMRadio: onResume");
- mPrefs.Load();
- PresetStation station = new PresetStation("", FmSharedPreferences.getTunedFrequency());
- if (station != null) {
- mTunedStation.Copy(station);
- }
- mHandler.post(mUpdateProgramService);
- mHandler.post(mUpdateRadioText);
- mHandler.post(mOnStereo);
- updateStationInfoToUI();
- enableRadioOnOffUI();
- }
- private class LoadedDataAndState {
- public LoadedDataAndState(){};
- public boolean onOrOff;
- }
- @Override
- public Object onRetainNonConfigurationInstance() {
- final LoadedDataAndState data = new LoadedDataAndState();
- if(mService != null) {
- try {
- data.onOrOff = mService.isFmOn();
- } catch(RemoteException e) {
- data.onOrOff = false;
- e.printStackTrace();
- }
- } else {
- data.onOrOff = false;
- }
- return data;
- }
-
- @Override
- public void onDestroy() {
- Log.d(LOGTAG, "FMRadio: onDestroy");
- cleanupTimeoutHandler();
- if (mService != null) {
- try {
- if(!mService.isFmOn()) {
- endSleepTimer();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- unbindFromService(this);
- mService = null;
- Log.d(LOGTAG, "onDestroy: unbindFromService completed");
- super.onDestroy();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuItem item;
- boolean radioOn = isFmOn();
- boolean recording = isRecording();
- boolean mSpeakerPhoneOn = isSpeakerEnabled();
- boolean sleepActive = isSleepTimerActive();
- boolean searchActive = isScanActive() || isSeekActive();
-
- item = menu.add(0, MENU_SCAN_START, 0, R.string.menu_scan_start).setIcon(
- R.drawable.ic_btn_search);
- if (item != null)
- {
- item.setVisible(!searchActive && radioOn);
- }
- item = menu.add(0, MENU_SCAN_STOP, 0, R.string.menu_scan_stop).setIcon(
- R.drawable.ic_btn_search);
- if (item != null)
- {
- item.setVisible(searchActive && radioOn);
- }
-
- if (RECORDING_ENABLE)
- {
- item = menu.add(0, MENU_RECORD_START, 0, R.string.menu_record_start)
- .setIcon(R.drawable.ic_menu_record);
- if (item != null)
- {
- item.setVisible(true);
- item.setEnabled(!recording && radioOn);
- }
- item = menu.add(0, MENU_RECORD_STOP, 0, R.string.menu_record_stop)
- .setIcon(R.drawable.ic_menu_record);
- if (item != null)
- {
- item.setVisible(true);
- item.setEnabled(recording && radioOn);
- }
- }
- /* Settings can be active */
- item = menu.add(0, MENU_SETTINGS, 0, R.string.menu_settings).setIcon(
- android.R.drawable.ic_menu_preferences);
-
- item = menu.add(0, MENU_SLEEP, 0, R.string.menu_sleep)
- .setTitle(R.string.menu_sleep);
- if (item != null)
- {
- item.setVisible(!sleepActive && radioOn);
- }
- item = menu.add(0, MENU_SLEEP_CANCEL, 0, R.string.menu_sleep_cancel)
- .setTitle(R.string.menu_sleep_cancel);
- if (item != null)
- {
- item.setVisible(sleepActive && radioOn);
- }
- mFMStats = SystemProperties.getBoolean("persist.fm.stats",false);
- if(mFMStats) {
- item = menu.add(0, MENU_STAT_TEST, 0,R.string.menu_stats).setIcon(
- android.R.drawable.ic_menu_info_details);
- }
- if (!mSpeakerPhoneOn) {
- item = menu.add(0, MENU_SPEAKER, 0, R.string.menu_speaker_on);
- }
- else {
- item = menu.add(0, MENU_SPEAKER, 0, R.string.menu_speaker_off);
- }
- item = menu.add(0, MENU_TAGS, 0, R.string.menu_display_tags);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
-
- super.onPrepareOptionsMenu(menu);
-
- MenuItem item;
- boolean radioOn = isFmOn();
- boolean recording = isRecording();
- boolean mSpeakerPhoneOn = isSpeakerEnabled();
- boolean searchActive = isScanActive() || isSeekActive();
-
- item = menu.findItem(MENU_SCAN_START);
- if (item != null)
- {
- item.setVisible(!searchActive && radioOn);
- }
- item = menu.findItem(MENU_SCAN_STOP);
- if (item != null)
- {
- item.setVisible(searchActive && radioOn);
- }
- if (RECORDING_ENABLE)
- {
- item = menu.findItem(MENU_RECORD_START);
- if (item != null)
- {
- item.setVisible(true);
- item.setEnabled(!recording && radioOn && !isAnalogModeEnabled());
- }
- item = menu.findItem(MENU_RECORD_STOP);
- if (item != null)
- {
- item.setVisible(true);
- item.setEnabled(recording && radioOn && !isAnalogModeEnabled());
- }
- }
-
- boolean sleepActive = isSleepTimerActive();
- item = menu.findItem(MENU_SLEEP);
- if (item != null)
- {
- item.setVisible(!sleepActive && radioOn);
- }
- item = menu.findItem(MENU_SLEEP_CANCEL);
- if (item != null)
- {
- item.setVisible(sleepActive && radioOn);
- }
-
- if (radioOn)
- {
- if (menu.findItem(MENU_SPEAKER) == null)
- {
- if (!mSpeakerPhoneOn) {
- item = menu.add(0, MENU_SPEAKER, 0, R.string.menu_speaker_on);
- }
- else {
- item = menu.add(0, MENU_SPEAKER, 0, R.string.menu_speaker_off);
- }
- }
- else {
- menu.removeItem(MENU_SPEAKER);
- if (!mSpeakerPhoneOn) {
- item = menu.add(0, MENU_SPEAKER, 0, R.string.menu_speaker_on);
- }
- else {
- item = menu.add(0, MENU_SPEAKER, 0, R.string.menu_speaker_off);
- }
- }
- } else
- {
- menu.removeItem(MENU_SPEAKER);
- }
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId())
- {
- case MENU_SETTINGS:
- Intent launchPreferencesIntent = new Intent().setClass(this,
- Settings.class);
- launchPreferencesIntent.putExtra(Settings.RX_MODE,true);
- startActivityForResult(launchPreferencesIntent,
- ACTIVITY_RESULT_SETTINGS);
- //startActivity(launchPreferencesIntent);
- return true;
- case MENU_STAT_TEST:
- Intent launchFMStatIntent = new Intent().setClass(this,
- FMStats.class);
- startActivity(launchFMStatIntent);
- return true;
-
- case MENU_SCAN_START:
- showDialog(DIALOG_SEARCH);
- return true;
-
- case MENU_SCAN_STOP:
- cancelSearch();
- return true;
-
- case MENU_RECORD_START:
- startRecording();
- return true;
-
- case MENU_RECORD_STOP:
- stopRecording();
- return true;
-
- case MENU_SLEEP:
- showDialog(DIALOG_SLEEP);
- return true;
-
- case MENU_SLEEP_CANCEL:
- DebugToasts("Sleep Cancelled", Toast.LENGTH_SHORT);
- endSleepTimer();
- return true;
-
- case MENU_SPEAKER:
- /* Call the mm interface to route the wired headset*/
- enableSpeaker();
- return true;
- case MENU_TAGS:
- Intent launchFMTagsIntent = new Intent().setClass(this,
- FmTags.class);
- startActivity(launchFMTagsIntent);
- return true;
- default:
- break;
- }
- return super.onOptionsItemSelected(item);
- }
-
- private boolean isHdmiOn() {
- //HDMI and FM concurrecny is not supported.
- try {
- String hdmiUserOption = android.provider.Settings.System.getString(
- getContentResolver(), "HDMI_USEROPTION");
- }
- catch (Exception ex){
- }
- return false;
- }
-
- private void enableSpeaker() {
- //This method with toggle Speaker phone based on existing state .
- boolean bSpeakerPhoneOn = isSpeakerEnabled();
- if(mService != null)
- {
- try {
- if(bSpeakerPhoneOn){ // as Speaker is already on turn it off.
- mService.enableSpeaker(false);
- Log.d(LOGTAG, "Speaker phone is turned off");
- }else{ // as Speaker is off turn it on.
- mService.enableSpeaker(true);
- Log.d(LOGTAG, "Speaker phone is turned on");
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- private static final int RECORDTIMER_EXPIRED = 0x1003;
- private static final int RECORDTIMER_UPDATE = 0x1004;
-
- private void updateExpiredRecordTime() {
- int vis = View.VISIBLE;
- if(isRecording())
- {
- long timeNow = ((SystemClock.elapsedRealtime()));
- long seconds = (timeNow - getRecordingStartTime()) / 1000;
- String Msg = makeTimeString(seconds);
- mRecordingMsgTV.setText(Msg);
- mRecordingMsgTV.setVisibility(vis);
- }
- }
-
- /* Recorder Thread processing */
- private Runnable doRecordProcessing = new Runnable() {
- public void run() {
- while (isRecording() &&
- (!Thread.currentThread().isInterrupted()))
- {
- try
- {
- Thread.sleep(500);
- Message statusUpdate = new Message();
- statusUpdate.what = RECORDTIMER_UPDATE;
- mUIUpdateHandlerHandler.sendMessage(statusUpdate);
- } catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
- if(!isRecording()) {
- Message finished = new Message();
- finished.what = RECORDTIMER_EXPIRED;
- mUIUpdateHandlerHandler.sendMessage(finished);
- }
- }
- }
- };
-
- private Thread mRecordUpdateHandlerThread = null;
-
- private long getRecordingStartTime() {
-
- if(mService == null)
- return 0;
-
- try {
- return mService.getRecordingStartTime();
- }catch(RemoteException e) {
- return 0;
- }
- }
-
- private void initiateRecordDurationTimer(long mins ) {
- Log.d(LOGTAG, "Stop Recording in mins : " + mins);
- initiateRecordThread();
- }
- private void initiateRecordThread() {
- if (mRecordUpdateHandlerThread == null)
- {
- mRecordUpdateHandlerThread = new Thread(null, doRecordProcessing,
- "RecordUpdateThread");
- }
- /* Launch the dummy thread to simulate the transfer progress */
- Log.d(LOGTAG, "Thread State: " + mRecordUpdateHandlerThread.getState());
- if (mRecordUpdateHandlerThread.getState() == Thread.State.TERMINATED)
- {
- mRecordUpdateHandlerThread = new Thread(null, doRecordProcessing,
- "RecordUpdateThread");
- }
- /* If the thread state is "new" then the thread has not yet started */
- if (mRecordUpdateHandlerThread.getState() == Thread.State.NEW)
- {
- mRecordUpdateHandlerThread.start();
- }
- }
-
-
-
- private void audioRoute (int audioDevice)
- {
- boolean bStatus;
- if(mService != null)
- {
- try
- {
- bStatus = mService.routeAudio(audioDevice);
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
-
- }
-
- @Override
- protected Dialog onCreateDialog(int id) {
- AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
- dlgBuilder.setOnKeyListener(new OnKeyListener() {
- public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
- Log.d(LOGTAG, "OnKeyListener event received"+keyCode);
- switch (keyCode) {
- case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
- case 126: //KeyEvent.KEYCODE_MEDIA_PLAY:
- case 127: //KeyEvent.KEYCODE_MEDIA_PAUSE:
- case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
- case KeyEvent.KEYCODE_MEDIA_NEXT:
- case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
- case KeyEvent.KEYCODE_MEDIA_REWIND:
- case KeyEvent.KEYCODE_MEDIA_STOP:
- return true;
- }
- return false;
- }
- });
- switch (id)
- {
- case DIALOG_SELECT_PRESET_LIST: {
- return createSelectPresetListDlg(id, dlgBuilder);
- }
- case DIALOG_PRESETS_LIST: {
- return createPresetListEditDlg(id, dlgBuilder);
- }
- case DIALOG_PRESET_LIST_RENAME: {
- return createPresetListRenameDlg(id, dlgBuilder);
- }
- case DIALOG_PRESET_LIST_DELETE: {
- return createPresetListDeleteDlg(id, dlgBuilder);
- }
- case DIALOG_PRESET_LIST_AUTO_SET: {
- return createPresetListAutoSelectWarnDlg(id, dlgBuilder);
- }
- case DIALOG_SEARCH: {
- return createSearchDlg(id, dlgBuilder);
- }
- case DIALOG_SLEEP: {
- return createSleepDlg(id, dlgBuilder);
- }
- case DIALOG_PICK_FREQUENCY: {
- FmConfig fmConfig = FmSharedPreferences.getFMConfiguration();
- return new FrequencyPickerDialog(this, fmConfig, mTunedStation.getFrequency(), mFrequencyChangeListener);
- }
- case DIALOG_PROGRESS_PROGRESS: {
- return createProgressDialog(id);
- }
- case DIALOG_PRESET_OPTIONS: {
- return createPresetOptionsDlg(id, dlgBuilder);
- }
- case DIALOG_PRESET_RENAME: {
- return createPresetRenameDlg(id, dlgBuilder);
- }
- case DIALOG_CMD_TIMEOUT:{
- return createCmdTimeoutDlg(id, dlgBuilder);
- }
- case DIALOG_CMD_FAILED:{
- return createCmdFailedDlg(id, dlgBuilder);
- }
- case DIALOG_CMD_FAILED_HDMI_ON:{
- return createCmdFailedDlgHdmiOn(id);
- }
- case DIALOG_CMD_FAILED_CALL_ON:{
- return createCmdFailedDlgCallOn(id);
- }
- default:
- break;
- }
- return null;
- }
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- super.onPrepareDialog(id, dialog);
- int curListIndex = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(curListIndex);
- switch (id)
- {
- case DIALOG_PRESET_LIST_RENAME: {
- EditText et = (EditText) dialog.findViewById(R.id.list_edit);
- if (et != null && curList != null)
- {
- et.setText(curList.getName());
- }
- break;
- }
- case DIALOG_PRESET_LIST_DELETE: {
- AlertDialog alertDlg = ((AlertDialog) dialog);
- if (alertDlg != null && curList != null)
- {
- alertDlg.setTitle(curList.getName());
- alertDlg.setMessage(getString(R.string.presetlist_delete_name, curList.getName()));
- }
- break;
- }
-
- case DIALOG_PRESET_LIST_AUTO_SET: {
- AlertDialog alertDlg = ((AlertDialog) dialog);
- if (alertDlg != null && curList != null)
- {
- alertDlg.setTitle(curList.getName());
- ((AlertDialog) dialog)
- .setMessage(getString(R.string.presetlist_autoselect_name, curList.getName()));
- }
- break;
- }
- case DIALOG_SELECT_PRESET_LIST: {
- AlertDialog alertDlg = ((AlertDialog) dialog);
- ListView lv = (ListView) alertDlg.findViewById(R.id.list);
- if (lv != null)
- {
- updateSelectPresetListDlg(lv);
- }
- break;
- }
- case DIALOG_PRESETS_LIST: {
- AlertDialog alertDlg = ((AlertDialog) dialog);
- if(alertDlg != null && curList != null)
- {
- alertDlg.setTitle(curList.getName());
- }
- break;
- }
- case DIALOG_PICK_FREQUENCY:
- {
- if (dialog != null && mTunedStation != null)
- {
- FmConfig fmConfig = FmSharedPreferences.getFMConfiguration();
- ((FrequencyPickerDialog) dialog).updateSteps(fmConfig.getChSpacing());
- ((FrequencyPickerDialog) dialog).updateMinFreq(fmConfig.getLowerLimit());
- ((FrequencyPickerDialog) dialog).updateMaxFreq(fmConfig.getUpperLimit());
- ((FrequencyPickerDialog) dialog).UpdateFrequency(mTunedStation.getFrequency());
- }
- break;
- }
- case DIALOG_PRESET_RENAME:
- {
- EditText et = (EditText) dialog.findViewById(R.id.list_edit);
- if ((et != null) && (mPresetButtonStation != null))
- {
- et.setText(mPresetButtonStation.getName());
- }
- break;
- }
- case DIALOG_PRESET_OPTIONS: {
- AlertDialog alertDlg = ((AlertDialog) dialog);
- if ((alertDlg != null) && (mPresetButtonStation != null))
- {
- alertDlg.setTitle(mPresetButtonStation.getName());
- }
- break;
- }
-
- default:
- break;
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- Log.d(LOGTAG, "onActivityResult : requestCode -> "+ requestCode);
- Log.d(LOGTAG, "onActivityResult : resultCode -> "+ resultCode);
- if (requestCode ==ACTIVITY_RESULT_SETTINGS)
- {
- if (resultCode == RESULT_OK)
- {
- /* */
- if (data != null)
- {
- String action = data.getAction();
- if (action != null)
- {
- if (action.equals(Settings.RESTORE_FACTORY_DEFAULT_ACTION))
- {
- RestoreDefaults();
- enableRadioOnOffUI();
- }
- }
- }
- } //if ACTIVITY_RESULT_SETTINGS
- }//if (resultCode == RESULT_OK)
- }
-
-
-
- /**
- * @return true if a wired headset is connected.
- */
- boolean isWiredHeadsetAvailable() {
- boolean bAvailable = false;
- if(mService != null)
- {
- try
- {
- bAvailable = mService.isWiredHeadsetAvailable();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- Log.e(LOGTAG, "isWiredHeadsetAvailable: " + bAvailable);
- return bAvailable;
- }
-
- /**
- * @return true if a internal antenna is available.
- *
- */
- boolean isAntennaAvailable() {
- boolean bAvailable = false;
- if(mService != null)
- {
- try
- {
- bAvailable = mService.isAntennaAvailable();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return bAvailable;
-
- }
- boolean isCallActive(){
- boolean bCallActive = false;
- if( mService != null)
- {
- try
- {
- bCallActive = mService.isCallActive();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return bCallActive;
- }
-
- private Dialog createSearchDlg(int id, AlertDialog.Builder dlgBuilder) {
- String[] items;
- dlgBuilder.setIcon(R.drawable.ic_btn_search);
- dlgBuilder.setTitle(getString(R.string.search_dialog_title));
- /* Pick RBDS or RDS */
- if(FmSharedPreferences.isRBDSStd())
- {
- items = getResources().getStringArray(R.array.search_category_rbds_entries);
- } else // if(FmSharedPreferences.isRDSStd())
- {
- items = getResources().getStringArray(R.array.search_category_rds_entries);
- }
-
- dlgBuilder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- String[] items;
- String[] values;
-
- /* Pick RBDS or RDS */
- if(FmSharedPreferences.isRBDSStd())
- {
- items = getResources().getStringArray(R.array.search_category_rbds_entries);
- values = getResources().
- getStringArray(R.array.search_category_rbds_values);
- } else // if(FmSharedPreferences.isRDSStd())
- {
- items = getResources().getStringArray(R.array.search_category_rds_entries);
- values = getResources().
- getStringArray(R.array.search_category_rds_values);
- }
- if ((items != null) &&
- (values != null) &&
- (item >= 0))
- {
- if ( (item>=0) && (item <= items.length) && (item <= items.length) )
- {
- DebugToasts("Search Stations for : " + items[item]
- +" ("+values[item]+")",
- Toast.LENGTH_SHORT);
- int pty = Integer.parseInt(values[item]);
- initiateSearch(pty);
- }
- }
- removeDialog (DIALOG_SEARCH);
- }
- });
-
- return dlgBuilder.create();
- }
-
- private Dialog createPresetOptionsDlg(int id, AlertDialog.Builder dlgBuilder) {
- if(mPresetButtonStation != null)
- {
- dlgBuilder.setTitle(mPresetButtonStation.getName());
- ArrayList<String> arrayList = new ArrayList<String>();
- //PRESETS_OPTIONS_TUNE=0
- arrayList.add(getResources().getString(R.string.preset_tune));
- //PRESETS_OPTIONS_REPLACE=1
- arrayList.add(getResources().getString(R.string.preset_replace));
- //PRESETS_OPTIONS_RENAME=2
- arrayList.add(getResources().getString(R.string.preset_rename));
- //PRESETS_OPTIONS_DELETE=3
- arrayList.add(getResources().getString(R.string.preset_delete));
- String piString = mPresetButtonStation.getPIString();
- if (!TextUtils.isEmpty(piString))
- {
- //PRESETS_OPTIONS_SEARCHPI=4
- arrayList.add(getResources().getString(R.string.preset_search, piString));
- }
-
- dlgBuilder.setCancelable(true);
- dlgBuilder.setOnCancelListener (new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- mPresetButtonStation = null;
- removeDialog(DIALOG_PRESET_OPTIONS);
- }
- });
- String[] items = new String [arrayList.size ()];
- arrayList.toArray(items);
- dlgBuilder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- if(mPresetButtonStation != null)
- {
- switch(item)
- {
- case PRESETS_OPTIONS_TUNE:
- {
- // Tune to the station
- tuneRadio(mPresetButtonStation.getFrequency());
- mPresetButtonStation = null;
- break;
- }
- case PRESETS_OPTIONS_REPLACE:
- {
- // Replace preset Station with currently tuned station
- Log.d(LOGTAG, "station - " + mPresetButtonStation.getName() + " ("
- + mPresetButtonStation.getFrequency() + ")");
- mPresetButtonStation.Copy(mTunedStation);
- mPresetButtonStation = null;
- setupPresetLayout();
- mPrefs.Save();
- break;
- }
- case PRESETS_OPTIONS_RENAME:
- {
- // Rename
- showDialog(DIALOG_PRESET_RENAME);
- break;
- }
- case PRESETS_OPTIONS_DELETE:
- {
- // Delete
- int curListIndex = FmSharedPreferences.getCurrentListIndex();
- FmSharedPreferences.removeStation(curListIndex, mPresetButtonStation);
- mPresetButtonStation = null;
- setupPresetLayout();
- mPrefs.Save();
- break;
- }
- case PRESETS_OPTIONS_SEARCHPI:
- {
- // SearchPI
- String piString = mPresetButtonStation.getPIString();
- int pi = mPresetButtonStation.getPI();
- if ((!TextUtils.isEmpty(piString)) && (pi>0))
- {
- initiatePISearch(pi);
- }
- mPresetButtonStation = null;
- break;
- }
- default:
- {
- // Should not happen
- mPresetButtonStation = null;
- break;
- }
- }//switch item
- }//if(mPresetButtonStation != null)
- removeDialog (DIALOG_PRESET_OPTIONS);
- }//onClick
- });
- return dlgBuilder.create();
- }
- return null;
- }
-
- private Dialog createSleepDlg(int id, AlertDialog.Builder dlgBuilder) {
- dlgBuilder.setTitle(R.string.dialog_sleep_title);
- String[] items = getResources().getStringArray(R.array.sleep_duration_values);
-
- dlgBuilder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- String[] items = getResources().getStringArray(R.array.sleep_duration_values);
- Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
- if ((item>=0) && (item <= items.length))
- {
- long seconds = (long) (900 * (item + 1));
- initiateSleepTimer(seconds);
- }
- removeDialog (DIALOG_SLEEP);
- }
- });
-
- return dlgBuilder.create();
- }
-
-
- private Dialog createProgressDialog(int id) {
- String msgStr="";
- String titleStr="";
- double frequency = mTunedStation.getFrequency() / 1000.0;
- boolean bSearchActive = false;
-
- if(isSeekActive())
- {
- msgStr = getString(R.string.msg_seeking);
- bSearchActive=true;
- }
- else if(isScanActive())
- {
- String ptyStr = PresetStation.parsePTY(mScanPty);
- if (!TextUtils.isEmpty(ptyStr))
- {
- msgStr = getString(R.string.msg_scanning_pty, ptyStr);
- }
- else
- {
- msgStr = getString(R.string.msg_scanning);
- }
- titleStr = getString(R.string.msg_search_title, ("" + frequency));
- bSearchActive=true;
- }
- else if(isSearchActive())
- {
- msgStr = getString(R.string.msg_searching);
- titleStr = getString(R.string.msg_searching_title);
- bSearchActive=true;
- }
-
- if(bSearchActive) {
- mProgressDialog = new ProgressDialog(FMRadio.this);
- if (mProgressDialog != null) {
- mProgressDialog.setTitle(titleStr);
- mProgressDialog.setMessage(msgStr);
- mProgressDialog.setIcon(R.drawable.ic_launcher_fmradio);
- mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- mProgressDialog.setButton(DialogInterface.BUTTON_POSITIVE,
- getText(R.string.button_text_stop),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- cancelSearch();
- }
- }
- );
- mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- cancelSearch();
- }
- }
- );
- mProgressDialog.setOnKeyListener(new OnKeyListener() {
- public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
- Log.d(LOGTAG, "OnKeyListener event received in ProgressDialog"+keyCode);
- switch (keyCode) {
- case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
- case 126: //KeyEvent.KEYCODE_MEDIA_PLAY:
- case 127: //KeyEvent.KEYCODE_MEDIA_PAUSE:
- case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
- case KeyEvent.KEYCODE_MEDIA_NEXT:
- case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
- case KeyEvent.KEYCODE_MEDIA_REWIND:
- case KeyEvent.KEYCODE_MEDIA_STOP:
- return true;
- }
- return false;
- }
- }
- );
- }
-
- Message msg = new Message();
- msg.what = TIMEOUT_PROGRESS_DLG;
- mSearchProgressHandler.sendMessageDelayed(msg, SHOWBUSY_TIMEOUT);
- }
- return mProgressDialog;
- }
-
- private void updateSelectPresetListDlg(ListView lv) {
- if (lv != null)
- {
- List<PresetList> presetLists = FmSharedPreferences.getPresetLists();
- ListIterator<PresetList> presetIter;
- presetIter = presetLists.listIterator();
- int numLists = presetLists.size();
- int curIndex = FmSharedPreferences.getCurrentListIndex();
- ArrayAdapter<String> typeAdapter = new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_single_choice);
- for (int stationIter = 0; stationIter < numLists; stationIter++)
- {
- PresetList temp = presetIter.next();
- if (temp != null)
- {
- typeAdapter.add(getString(R.string.presetlist_select_name, temp.getName()));
- }
- }
- typeAdapter.add(getString(R.string.presetlist_add_new));
- lv.setAdapter(typeAdapter);
- lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- lv.clearChoices();
- if (curIndex >= numLists)
- {
- curIndex = 0;
- }
- if (lv.getCount() >= curIndex)
- {
- lv.setItemChecked(curIndex, true);
- lv.setSelection(curIndex);
- } else
- {
- lv.setItemChecked(0, true);
- lv.setSelection(0);
- }
- }
- }
-
-
- private Dialog createPresetListEditDlg(int id, AlertDialog.Builder dlgBuilder) {
- String[] items = getResources().getStringArray(R.array.presetlist_edit_category);
-
- int currentList = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(currentList);
-
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon);
- dlgBuilder.setTitle("\"" + ((curList == null)?"":curList.getName()) + "\"");
- dlgBuilder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- switch(item)
- {
- case 0:
- {
- // Rename
- showDialog(DIALOG_PRESET_LIST_RENAME);
- break;
- }
- case 1:
- {
- // Auto-Select - Build Preset List
- int currentList =
- FmSharedPreferences.getCurrentListIndex();
- PresetList curList =
- FmSharedPreferences.getStationList(currentList);
- if (curList != null && curList.getStationCount() > 0)
- {
- /* Show a autoselect- deletes presets warning */
- showDialog(DIALOG_PRESET_LIST_AUTO_SET);
- }
- else
- {
- if (curList != null) {
- curList.clear();
- }
- /* Since the presets will be changed,
- * reset the page number
- */
- mPresetPageNumber = 0;
- initiateSearchList();
- //curList.addDummyStations();
- setupPresetLayout();
- mPrefs.Save();
- }
-
- break;
- }
- case 2:
- {
- // Delete
- showDialog(DIALOG_PRESET_LIST_DELETE);
- break;
- }
- }//switch item
- removeDialog(DIALOG_PRESETS_LIST);
- }//onClick
- });
- return dlgBuilder.create();
- }
-
- private Dialog createSelectPresetListDlg(int id, AlertDialog.Builder dlgBuilder) {
- LayoutInflater factory = LayoutInflater.from(this);
- final View listView = factory.inflate(R.layout.alert_dialog_list, null);
- ListView lv = (ListView) listView.findViewById(R.id.list);
-
- if (lv != null)
- {
- updateSelectPresetListDlg(lv);
- } else
- {
- return null;
- }
- dlgBuilder.setView(listView);
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon);
- dlgBuilder.setTitle(R.string.dialog_presetlist_title);
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- ListView lv = (ListView) listView
- .findViewById(R.id.list);
- int selectedPos = -1;
- if (lv != null)
- {
- selectedPos = lv.getCheckedItemPosition();
- }
- if (selectedPos >= 0)
- {
- if (selectedPos < FmSharedPreferences.getNumList())
- {
- /* If the preset List was changed, reset the page number */
- if(selectedPos != FmSharedPreferences.getCurrentListIndex())
- {
- mPresetPageNumber = 0;
- }
- FmSharedPreferences.setListIndex(selectedPos);
- mPrefs.Save();
- }
- else
- {
- String presetListName = getString(R.string.presetlist_prefix_name)
- + (FmSharedPreferences.getNumList() + 1);
- int newIndex = FmSharedPreferences
- .createPresetList(presetListName);
- FmSharedPreferences.setListIndex(newIndex);
- showDialog(DIALOG_PRESET_LIST_RENAME);
- }
- }
- setupPresetLayout();
- removeDialog(DIALOG_SELECT_PRESET_LIST);
- }
- });
- dlgBuilder.setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- removeDialog(DIALOG_SELECT_PRESET_LIST);
- }
- });
- return dlgBuilder.create();
- }
-
- private Dialog createPresetRenameDlg(int id, AlertDialog.Builder dlgBuilder) {
- if(mPresetButtonStation == null)
- {
- return null;
- }
- LayoutInflater factory = LayoutInflater.from(this);
- final View textEntryView = factory.inflate(
- R.layout.alert_dialog_text_entry, null);
- dlgBuilder.setTitle(R.string.dialog_presetlist_rename_title);
- dlgBuilder.setView(textEntryView);
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- //int curList = FmSharedPreferences.getCurrentListIndex();
-
- EditText mTV = (EditText) textEntryView
- .findViewById(R.id.list_edit);
- CharSequence newName = null;
- if (mTV != null) {
- newName = mTV.getEditableText();
- }
- String nName = String.valueOf(newName);
- mPresetButtonStation.setName(nName);
- mPresetButtonStation=null;
- setupPresetLayout();
- mPrefs.Save();
- removeDialog(DIALOG_PRESET_RENAME);
- }
- });
- dlgBuilder.setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- removeDialog(DIALOG_PRESET_RENAME);
- }
- });
- return(dlgBuilder.create());
- }
-
- private Dialog createPresetListRenameDlg(int id, AlertDialog.Builder dlgBuilder) {
- LayoutInflater factory = LayoutInflater.from(this);
- final View textEntryView = factory.inflate(
- R.layout.alert_dialog_text_entry, null);
- dlgBuilder.setTitle(R.string.dialog_presetlist_rename_title);
- dlgBuilder.setView(textEntryView);
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- int curList = FmSharedPreferences.getCurrentListIndex();
-
- EditText mTV = (EditText) textEntryView
- .findViewById(R.id.list_edit);
- CharSequence newName = null;
- if (mTV != null) {
- newName = mTV.getEditableText();
- }
- String nName = String.valueOf(newName);
- FmSharedPreferences.renamePresetList(nName, curList);
- setupPresetLayout();
- mPrefs.Save();
- removeDialog(DIALOG_PRESET_LIST_RENAME);
- }
- });
- dlgBuilder.setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- removeDialog(DIALOG_PRESET_LIST_RENAME);
- }
- });
- return(dlgBuilder.create());
- }
-
- private Dialog createPresetListDeleteDlg(int id, AlertDialog.Builder dlgBuilder) {
- int currentList = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(currentList);
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon).setTitle(
- (curList == null)?"":curList.getName());
- dlgBuilder.setMessage(getString(R.string.presetlist_delete_name,
- (curList == null)?"":curList.getName()));
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- int currentList = FmSharedPreferences.getCurrentListIndex();
- FmSharedPreferences.removeStationList(currentList);
- /* Since the presets will be changed,
- * reset the page number
- */
- mPresetPageNumber = 0;
- setupPresetLayout();
- mPrefs.Save();
- removeDialog(DIALOG_PRESET_LIST_DELETE);
- }
- });
- dlgBuilder.setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- removeDialog(DIALOG_PRESET_LIST_DELETE);
- }
- });
- return(dlgBuilder.create());
- }
-
- private Dialog createPresetListAutoSelectWarnDlg(int id, AlertDialog.Builder dlgBuilder) {
- int currentList = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(currentList);
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon)
- .setTitle(R.string.presetlist_autoselect_title);
- dlgBuilder.setMessage(getString(R.string.presetlist_autoselect_name,
- (curList == null)?"":curList.getName()));
-
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- int currentList =
- FmSharedPreferences.getCurrentListIndex();
- PresetList curList =
- FmSharedPreferences.getStationList(currentList);
- initiateSearchList();
- //curList.addDummyStations();
- setupPresetLayout();
- mPrefs.Save();
- removeDialog(DIALOG_PRESET_LIST_AUTO_SET);
- }
- });
-
- dlgBuilder.setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- removeDialog(DIALOG_PRESET_LIST_AUTO_SET);
- }
- });
- return(dlgBuilder.create());
- }
-
-
- private Dialog createCmdTimeoutDlg(int id, AlertDialog.Builder dlgBuilder) {
- if(mCommandActive > 0)
- {
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon)
- .setTitle(R.string.fm_command_timeout_title);
- dlgBuilder.setMessage(R.string.fm_tune_timeout_msg);
-
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- cleanupTimeoutHandler();
- removeDialog(DIALOG_CMD_TIMEOUT);
- }
- });
-
- return(dlgBuilder.create());
- }
- else
- {
- return (null);
- }
- }
-
- private Dialog createCmdFailedDlg(int id, AlertDialog.Builder dlgBuilder) {
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon)
- .setTitle(R.string.fm_command_failed_title);
- dlgBuilder.setMessage(R.string.fm_cmd_failed_msg);
-
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- removeDialog(DIALOG_CMD_TIMEOUT);
- mCommandFailed = CMD_NONE;
- }
- });
-
- return(dlgBuilder.create());
- }
-
- private Dialog createCmdFailedDlgHdmiOn(int id) {
- AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon)
- .setTitle(R.string.fm_command_failed_title);
- dlgBuilder.setMessage(R.string.fm_cmd_failed_msg_hdmi);
-
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- removeDialog(DIALOG_CMD_TIMEOUT);
- mCommandFailed = CMD_NONE;
- }
- });
-
- return(dlgBuilder.create());
- }
-
- private Dialog createCmdFailedDlgCallOn(int id) {
- AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon)
- .setTitle(R.string.fm_command_failed_title);
- dlgBuilder.setMessage(R.string.fm_cmd_failed_call_on);
-
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- removeDialog(DIALOG_CMD_TIMEOUT);
- mCommandFailed = CMD_NONE;
- }
- });
-
- return(dlgBuilder.create());
- }
- private void RestoreDefaults() {
- FmSharedPreferences.SetDefaults();
- mPrefs.Save();
- }
-
- private View.OnLongClickListener mFrequencyViewClickListener = new View.OnLongClickListener() {
- public boolean onLongClick(View v) {
- showDialog(DIALOG_PICK_FREQUENCY);
- return true;
- }
- };
-
- private View.OnClickListener mForwardClickListener
- = new View.OnClickListener() {
- public void onClick(View v) {
- int frequency = FmSharedPreferences.getNextTuneFrequency();
- Log.d(LOGTAG, "Tune Up: to " + frequency);
- tuneRadio(frequency);
- }
- };
-
- private View.OnClickListener mBackClickListener
- = new View.OnClickListener() {
- public void onClick(View v) {
- int frequency = FmSharedPreferences.getPrevTuneFrequency();
- Log.d(LOGTAG, "Tune Down: to " + frequency);
- tuneRadio(frequency);
- }
- };
-
- private View.OnLongClickListener mForwardLongClickListener
- = new View.OnLongClickListener() {
- public boolean onLongClick(View view) {
- //mForwardButton.startAnimation(mAnimation);
- SeekNextStation();
- //enableScanningOnOffUI();
- return true;
- }
- };
-
- private View.OnLongClickListener mBackLongClickListener = new View.OnLongClickListener() {
- public boolean onLongClick(View view) {
- //mBackButton.startAnimation(mAnimation);
- SeekPreviousStation();
- //enableScanningOnOffUI();
- return true;
- }
- };
-
- private View.OnClickListener mPresetListClickListener = new View.OnClickListener() {
- public void onClick(View v) {
- showDialog(DIALOG_SELECT_PRESET_LIST);
- }
- };
- private View.OnLongClickListener mPresetListButtonOnLongClickListener = new View.OnLongClickListener() {
- public boolean onLongClick(View view) {
- showDialog(DIALOG_PRESETS_LIST);
- return true;
- }
- };
-
- private View.OnClickListener mPresetsPageClickListener = new View.OnClickListener() {
- public void onClick(View v) {
- mPresetPageNumber++;
- setupPresetLayout();
- }
- };
-
- private View.OnClickListener mPresetButtonClickListener = new View.OnClickListener() {
- public void onClick(View view) {
- PresetStation station = (PresetStation) view.getTag();
- if (station != null)
- {
- Log.d(LOGTAG, "station - " + station.getName() + " ("
- + station.getFrequency() + ")");
- //mTunedStation.Copy(station);
- tuneRadio(station.getFrequency());
- view.startAnimation(mAnimation);
- }
- }
- };
-
- private View.OnLongClickListener mPresetButtonOnLongClickListener = new View.OnLongClickListener() {
- public boolean onLongClick(View view) {
- PresetStation station = (PresetStation) view.getTag();
- mPresetButtonStation = station;
- if (station != null)
- {
- showDialog(DIALOG_PRESET_OPTIONS);
- } else
- {
- addToPresets();
- view.startAnimation(mAnimation);
- }
- return true;
- }
- };
-
- final FrequencyPickerDialog.OnFrequencySetListener mFrequencyChangeListener
- = new FrequencyPickerDialog.OnFrequencySetListener() {
- public void onFrequencySet(FrequencyPicker view, int frequency) {
- Log.d(LOGTAG, "mFrequencyChangeListener: onFrequencyChanged to : "+frequency);
- tuneRadio(frequency);
- }
- };
-
- private View.OnClickListener mMuteModeClickListener
- = new View.OnClickListener() {
- public void onClick(View v) {
- boolean bStatus = false;
- if(mService != null)
- {
- try
- {
- if (true == isMuted())
- {
- bStatus = mService.unMute();
- } else
- {
- bStatus = mService.mute();
- }
-
- if(bStatus)
- {
- setMuteModeButtonImage(true);
- v.startAnimation(mAnimation);
- }
- else
- {
- mCommandFailed = CMD_MUTE;
- if( isCallActive() ) {
- showDialog(DIALOG_CMD_FAILED_CALL_ON);
- } else {
- showDialog(DIALOG_CMD_FAILED);
- }
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- };
-
- private Handler mEnableRadioHandler = new Handler();
- private Handler mDisableRadioHandler = new Handler();
- private Runnable mEnableRadioTask = new Runnable() {
- public void run() {
- enableRadio();
- mOnOffButton.setEnabled(true);
- mOnOffButton.setClickable(true);
- mOnOffButton.setOnClickListener(mTurnOnOffClickListener);
- }
- };
- private Runnable mDisableRadioTask = new Runnable() {
- public void run() {
- disableRadio();
- mOnOffButton.setEnabled(true);
- mOnOffButton.setClickable(true);
- mOnOffButton.setOnClickListener(mTurnOnOffClickListener);
- }
- };
- private View.OnClickListener mTurnOnOffClickListener
- = new View.OnClickListener() {
- public void onClick(View v) {
- mOnOffButton.setEnabled(false);
- mOnOffButton.setClickable(false);
- mOnOffButton.setOnClickListener(null);
- if (isFmOn())
- {
- mEnableRadioHandler.removeCallbacks(mEnableRadioTask);
- mDisableRadioHandler.removeCallbacks(mDisableRadioTask);
- mDisableRadioHandler.postDelayed(mDisableRadioTask, 0);
-
- } else
- {
- mDisableRadioHandler.removeCallbacks(mDisableRadioTask);
- mEnableRadioHandler.removeCallbacks(mEnableRadioTask);
- mEnableRadioHandler.postDelayed(mEnableRadioTask, 0);
- }
- cleanupTimeoutHandler();
- }
- };
- private void setTurnOnOffButtonImage() {
- if (isFmOn() == true)
- {
- mOnOffButton.setImageResource(R.drawable.ic_btn_onoff);
- } else
- {
- /* Find a icon to indicate off */
- mOnOffButton.setImageResource(R.drawable.ic_btn_onoff);
- }
- }
-
-
- private void setMuteModeButtonImage(boolean notify) {
- String fmMutedString;
- if (isMuted() == true)
- {
- mMuteButton.setImageResource(R.drawable.ic_silent_mode);
- fmMutedString = "FM Radio Muted";
- } else
- {
- /* Find a icon for Stations */
- mMuteButton.setImageResource(R.drawable.ic_silent_mode_off);
- fmMutedString = "FM Radio Playing";
- }
- if (notify)
- {
- //Toast.makeText(this, fmMutedString, Toast.LENGTH_SHORT).show();
- Log.d(LOGTAG, fmMutedString);
- }
- }
-
- private void enableRadio() {
- mIsScaning = false;
- mIsSeeking = false;
- mIsSearching=false;
- boolean bStatus = false;
- if (isHdmiOn())
- {
- showDialog(DIALOG_CMD_FAILED_HDMI_ON);
- } else
- {
- if(mService != null)
- {
- try
- {
- if( false == mService.isFmOn() && isAntennaAvailable()) {
- bStatus = mService.fmOn();
- if(bStatus)
- {
- tuneRadio(FmSharedPreferences.getTunedFrequency());
- enableRadioOnOffUI();
- }
- else
- {
- Log.e(LOGTAG, " mService.fmOn failed");
- mCommandFailed = CMD_FMON;
- if( isCallActive() ) {
- enableRadioOnOffUI();
- showDialog(DIALOG_CMD_FAILED_CALL_ON);
- } else {
- showDialog(DIALOG_CMD_FAILED);
- }
- }
- } else {
- enableRadioOnOffUI();
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
-
- private void disableRadio() {
- boolean bStatus = false;
- boolean bSpeakerPhoneOn = isSpeakerEnabled();
- cancelSearch();
- endSleepTimer();
- if( mRecording )
- {
- //Stop if there is an ongoing Record
- stopRecording();
- }
- if(mService != null)
- {
- try
- {
- if( bSpeakerPhoneOn )
- {
- mService.enableSpeaker(false);
- }
- bStatus = mService.fmOff();
- enableRadioOnOffUI();
- if(bStatus == false)
- {
- mCommandFailed = CMD_FMOFF;
- Log.e(LOGTAG, " mService.fmOff failed");
- //showDialog(DIALOG_CMD_FAILED);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- private void resetRadio() {
- boolean bSpeakerPhoneOn = isSpeakerEnabled();
- resetSearch();
- endSleepTimer();
- if(mRecording)
- {
- //Stop if there is an ongoing Record
- stopRecording();
- }
- if(mService != null)
- {
- try
- {
- if(bSpeakerPhoneOn)
- {
- mService.enableSpeaker(false);
- }
- mService.fmRadioReset();
- enableRadioOnOffUI(false);
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public static boolean fmConfigure() {
- boolean bStatus = true;
- if(mService != null)
- {
- try
- {
- bStatus = mService.fmReconfigure();
- if(bStatus == false)
- {
- mCommandFailed = CMD_FMCONFIGURE;
- Log.e(LOGTAG, " mService.fmReconfigure failed");
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return bStatus;
- }
- public static void fmAutoAFSwitch() {
- boolean bStatus = false;
- if(mService != null)
- {
- try
- {
- bStatus = mService.enableAutoAF(FmSharedPreferences.getAutoAFSwitch());
- if(bStatus == false)
- {
- mCommandFailed = CMD_SET_AUTOAF;
- Log.e(LOGTAG, " mService.enableAutoAF failed");
- //showDialog(DIALOG_CMD_FAILED);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static void fmAudioOutputMode() {
- boolean bStatus = false;
- if(mService != null)
- {
- try
- {
- bStatus = mService.enableStereo(FmSharedPreferences.getAudioOutputMode());
- if(bStatus == false)
- {
- mCommandFailed = CMD_SET_AUDIO_MODE;
- Log.e(LOGTAG, " mService.enableStereo failed");
- //showDialog(DIALOG_CMD_FAILED);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- private void startRecording() {
- if(mService != null)
- {
- try
- {
- mService.startRecording();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- private void startRecordingTimer() {
- mRecording = true;
- int durationInMins = FmSharedPreferences.getRecordDuration();
- Log.e(LOGTAG, " Fected duration:" + durationInMins );
- initiateRecordDurationTimer( durationInMins );
- invalidateOptionsMenu();
- }
- private void stopRecording() {
- mRecording = false;
- DebugToasts("Stopped Recording", Toast.LENGTH_SHORT);
- if( null != mRecordUpdateHandlerThread) {
- mRecordUpdateHandlerThread.interrupt();
- }
- if( null != mRecordingMsgTV ) {
- mRecordingMsgTV.setVisibility(View.INVISIBLE);
- }
- if(mService != null) {
- try
- {
- mService.stopRecording();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- invalidateOptionsMenu();
- }
-
- private boolean isRecording() {
- mRecording = false;
- if(mService != null)
- {
- try
- {
- mRecording = mService.isFmRecordingOn();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return(mRecording);
- }
-
- private boolean isSpeakerEnabled() {
- boolean speakerEnabled = false;
- if(mService != null)
- {
- try
- {
- speakerEnabled = mService.isSpeakerEnabled();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return(speakerEnabled);
- }
-
- private void addToPresets() {
- int currentList = FmSharedPreferences.getCurrentListIndex();
- PresetStation selectedStation = getCurrentTunedStation();
- FmSharedPreferences.addStation(selectedStation.getName(), selectedStation
- .getFrequency(), currentList);
- setupPresetLayout();
- }
-
- private void enableRadioOnOffUI() {
- boolean bEnable = isFmOn();
- /* Disable if no antenna/headset is available */
- if(!isAntennaAvailable() )
- {
- bEnable = false;
- }
- enableRadioOnOffUI(bEnable);
- }
-
- private void enableRadioOnOffUI(boolean bEnable) {
-
- if (mMuteButton != null) {
- mMuteButton.setEnabled(bEnable);
- setMuteModeButtonImage(false);
- }
- if (bEnable)
- {
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV.setOnLongClickListener(mFrequencyViewClickListener);
- }
- if (mRadioTextScroller != null) {
- mRadioTextScroller.startScroll();
- }
- if (mSleepMsgTV != null && !isSleepTimerActive())
- {
- mSleepMsgTV.setText("");
- }
- if (mRecordingMsgTV != null && !isRecording())
- {
- mRecordingMsgTV.setText("");
- }
- } else
- {
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV.setOnLongClickListener(null);
- }
- if (mRadioTextScroller != null) {
- mRadioTextScroller.stopScroll();
- }
- }
-
- if (mForwardButton != null) {
- mForwardButton.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mBackButton != null) {
- mBackButton.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mStationCallSignTV != null) {
- mStationCallSignTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mProgramTypeTV != null) {
- mProgramTypeTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mSleepMsgTV != null) {
- mSleepMsgTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mRecordingMsgTV != null) {
- mRecordingMsgTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mRadioTextTV != null) {
- mRadioTextTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if(mERadioTextTV != null) {
- mERadioTextTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mProgramServiceTV != null) {
- mProgramServiceTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
-
- if (!isAntennaAvailable())
- {
- if (mRadioTextTV != null) {
- mRadioTextTV.setVisibility(View.VISIBLE);
- mRadioTextTV.setText(getString(R.string.msg_noantenna));
- mRadioTextScroller.mOriginalString = getString(R.string.msg_noantenna);
- }
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(false);
- }
- }
- else if (isCallActive())
- {
- if (mRadioTextTV != null) {
- mRadioTextTV.setText("");
- mRadioTextScroller.mOriginalString = "";
- }
- if (mERadioTextTV != null)
- mERadioTextTV.setText("");
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(false);
- }
- }
- else
- {
- if (mRadioTextTV != null) {
- mRadioTextTV.setText("");
- mRadioTextScroller.mOriginalString = "";
- }
- if (mERadioTextTV != null)
- mERadioTextTV.setText("");
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(true);
- }
- }
-
- /* Disable displaying RSSI */
- //mRSSI.setVisibility(((bEnable == true) ? View.VISIBLE
- // : View.INVISIBLE));
- if (mStereoTV != null) {
- mStereoTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- for (int nButton = 0; nButton < MAX_PRESETS_PER_PAGE; nButton++)
- {
- if (mPresetButtons[nButton] != null) {
- mPresetButtons[nButton].setEnabled(bEnable);
- }
- }
- if (mPresetListButton != null) {
- mPresetListButton.setEnabled(bEnable);
- }
- if (mPresetPageButton != null) {
- mPresetPageButton.setEnabled(bEnable &&
- (FmSharedPreferences.getListStationCount() >= MAX_PRESETS_PER_PAGE));
- }
- }
-
- private void resetSearchProgress() {
- Message msg = new Message();
- msg.what = END_PROGRESS_DLG;
- mSearchProgressHandler.sendMessage(msg);
- }
-
- private void updateSearchProgress() {
- boolean searchActive = isScanActive() || isSeekActive() || isSearchActive();
- if(searchActive)
- {
- synchronized (this)
- {
- if(mProgressDialog == null)
- {
- showDialog(DIALOG_PROGRESS_PROGRESS);
- }
- else
- {
- Message msg = new Message();
- msg.what = UPDATE_PROGRESS_DLG;
- mSearchProgressHandler.sendMessage(msg);
- }
- }
- }
- else
- {
- Message msg = new Message();
- msg.what = END_PROGRESS_DLG;
- mSearchProgressHandler.sendMessage(msg);
- }
- }
-
- private void setupPresetLayout() {
- int numStations = FmSharedPreferences.getListStationCount();
- int addedStations = 0;
-
- /*
- * Validate mPresetPageNumber (Preset Page Number)
- */
- if (mPresetPageNumber > ((numStations) / MAX_PRESETS_PER_PAGE))
- {
- mPresetPageNumber = 0;
- }
-
- /*
- * For every station, save the station as a tag and update the display
- * on the preset Button.
- */
- for (int buttonIndex = 0; (buttonIndex < MAX_PRESETS_PER_PAGE); buttonIndex++)
- {
- if (mPresetButtons[buttonIndex] != null)
- {
- int stationIdex = (mPresetPageNumber * MAX_PRESETS_PER_PAGE)
- + buttonIndex;
- PresetStation station = FmSharedPreferences.getStationInList(stationIdex);
- String display = "";
- if (station != null)
- {
- display = station.getName();
- mPresetButtons[buttonIndex].setText(display);
- mPresetButtons[buttonIndex].setTag(station);
- addedStations++;
- } else
- {
- mPresetButtons[buttonIndex].setText(display);
- mPresetButtons[buttonIndex].setTag(station);
- }
- }
- }
- /*
- * Enable "Next" Page: Only if more than 4 presets are added,
- * else there is nothing more
- */
- mPresetPageButton.setEnabled(isFmOn() && (numStations >= MAX_PRESETS_PER_PAGE));
- mPresetListButton.setText(FmSharedPreferences.getListName(FmSharedPreferences
- .getCurrentListIndex()));
- }
-
- private void updateStationInfoToUI() {
- double frequency = mTunedStation.getFrequency() / 1000.0;
- mTuneStationFrequencyTV.setText("" + frequency);
- mStationCallSignTV.setText(mTunedStation.getPIString());
- mProgramTypeTV.setText(mTunedStation.getPtyString());
- mRadioTextTV.setText("");
- mERadioTextTV.setText("");
- mRadioTextScroller.mOriginalString = "";
- mRadioTextScroller.mStringlength = 0;
- mRadioTextScroller.mIteration = 0;
- mProgramServiceTV.setText("");
- mStereoTV.setText("");
- setupPresetLayout();
- }
-
-
- private boolean isFmOn() {
- boolean bOn = false;
- if(mService != null)
- {
- try
- {
- bOn = mService.isFmOn();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return(bOn);
- }
-
- private boolean isAnalogModeEnabled() {
- boolean aEnabled = false;
- if (mService != null)
- {
- try
- {
- aEnabled = mService.isAnalogModeEnabled();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return (aEnabled);
- }
-
- private boolean isMuted() {
- boolean bMuted = false;
- if(mService != null)
- {
- try
- {
- bMuted = mService.isMuted();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return(bMuted);
- }
-
- private boolean isScanActive() {
- return(mIsScaning);
- }
-
- private boolean isSeekActive() {
- return(mIsSeeking);
- }
- private boolean isSearchActive() {
- return(mIsSearching);
- }
-
- public static PresetStation getCurrentTunedStation() {
- return mTunedStation;
- }
-
- private void SeekPreviousStation() {
- Log.d(LOGTAG, "SeekPreviousStation");
- if(mService != null)
- {
- try
- {
- if(!isSeekActive())
- {
- mIsSeeking = mService.seek(false);
- if(mIsSeeking == false)
- {
- mCommandFailed = CMD_SEEK;
- Log.e(LOGTAG, " mService.seek failed");
- showDialog(DIALOG_CMD_FAILED);
- }
-
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- updateSearchProgress();
- }
-
- private void SeekNextStation() {
- Log.d(LOGTAG, "SeekNextStation");
- if(mService != null)
- {
- try
- {
- if(!isSeekActive())
- {
- mIsSeeking = mService.seek(true);
- if(mIsSeeking == false)
- {
- mCommandFailed = CMD_SEEK;
- Log.e(LOGTAG, " mService.seek failed");
- showDialog(DIALOG_CMD_FAILED);
- }
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- updateSearchProgress();
- }
-
- /** Scan related */
- private void initiateSearch(int pty) {
- synchronized (this)
- {
- mIsScaning = true;
- if(mService != null)
- {
- try
- {
- mIsScaning = mService.scan(pty);
- if(mIsScaning == false)
- {
- mCommandFailed = CMD_SCAN;
- Log.e(LOGTAG, " mService.scan failed");
- showDialog(DIALOG_CMD_FAILED);
- }
- else
- {
- mScanPty = pty;
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- updateSearchProgress();
- }
- }
- }
-
- /** SEEK Station with the matching PI */
- private void initiatePISearch(int pi) {
- Log.d(LOGTAG, "initiatePISearch");
- if(mService != null)
- {
- try
- {
- if(!isSeekActive())
- {
- mIsSeeking = mService.seekPI(pi);
- if(mIsSeeking == false)
- {
- mCommandFailed = CMD_SEEKPI;
- Log.e(LOGTAG, " mService.seekPI failed");
- showDialog(DIALOG_CMD_FAILED);
- }
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- updateSearchProgress();
- }
-
- private void resetSearch() {
- mIsScaning = false;
- mIsSeeking = false;
- mIsSearching = false;
- resetSearchProgress();
- }
-
- private void cancelSearch() {
- synchronized (this)
- {
- if(mService != null)
- {
- try
- {
- if( (mIsScaning == true)
- || (mIsSeeking == true)
- || (mIsSearching == true))
- {
- mService.cancelSearch();
- mIsScaning = false;
- mIsSeeking = false;
- mIsSearching=false;
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- updateSearchProgress();
- }
-
- /** get Strongest Stations */
- private void initiateSearchList() {
- synchronized (this)
- {
- mIsSearching = false;
- if(mService != null)
- {
- try
- {
- mIsSearching = mService.searchStrongStationList(NUM_AUTO_PRESETS_SEARCH);
- if(mIsSearching == false)
- {
- mCommandFailed = CMD_SEARCHLIST;
- Log.e(LOGTAG, " mService.searchStrongStationList failed");
- showDialog(DIALOG_CMD_FAILED);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- updateSearchProgress();
- }
- }
- }
-
- private static final int UPDATE_PROGRESS_DLG = 1;
- private static final int END_PROGRESS_DLG = 2;
- private static final int TIMEOUT_PROGRESS_DLG = 3;
- private static final int SHOWBUSY_TIMEOUT = 300000;
- private Handler mSearchProgressHandler = new Handler() {
- public void handleMessage(Message msg) {
- if (msg.what == UPDATE_PROGRESS_DLG) {
- //Log.d(LOGTAG, "mTimeoutHandler: UPDATE_PROGRESS_DLG");
- if(mProgressDialog != null)
- {
- double frequency = mTunedStation.getFrequency() / 1000.0;
- String titleStr = getString(R.string.msg_search_title, ("" + frequency));
-
- mProgressDialog.setTitle(titleStr);
- }
- }
- else if (msg.what == END_PROGRESS_DLG) {
- //Log.d(LOGTAG, "mTimeoutHandler: END_PROGRESS_DLG");
- mSearchProgressHandler.removeMessages(END_PROGRESS_DLG);
- mSearchProgressHandler.removeMessages(UPDATE_PROGRESS_DLG);
- mSearchProgressHandler.removeMessages(TIMEOUT_PROGRESS_DLG);
- removeDialog(DIALOG_PROGRESS_PROGRESS);
- mProgressDialog=null;
- }
- else if(msg.what == TIMEOUT_PROGRESS_DLG) {
- cancelSearch();
- }
- }
- };
-
- /** Sleep Handling: After the timer expires, the app needs to shut down */
- private static final int SLEEPTIMER_EXPIRED = 0x1001;
- private static final int SLEEPTIMER_UPDATE = 0x1002;
- private Thread mSleepUpdateHandlerThread = null;
- /*
- * Phone time when the App has to be shut down, calculated based on what the
- * user configured
- */
- private static long mSleepAtPhoneTime = 0;
-
- private void initiateSleepTimer(long seconds) {
- mSleepAtPhoneTime = (SystemClock.elapsedRealtime()) + (seconds * 1000);
- Log.d(LOGTAG, "Sleep in seconds : " + seconds);
- initiateSleepThread();
- }
- private void initiateSleepThread() {
- if (mSleepUpdateHandlerThread == null)
- {
- mSleepUpdateHandlerThread = new Thread(null, doSleepProcessing,
- "SleepUpdateThread");
- }
- /* Launch he dummy thread to simulate the transfer progress */
- Log.d(LOGTAG, "Thread State: " + mSleepUpdateHandlerThread.getState());
- if (mSleepUpdateHandlerThread.getState() == Thread.State.TERMINATED)
- {
- mSleepUpdateHandlerThread = new Thread(null, doSleepProcessing,
- "SleepUpdateThread");
- }
- /* If the thread state is "new" then the thread has not yet started */
- if (mSleepUpdateHandlerThread.getState() == Thread.State.NEW)
- {
- mSleepUpdateHandlerThread.start();
- }
- }
-
- private void endSleepTimer() {
- mSleepAtPhoneTime = 0;
- if( null != mSleepUpdateHandlerThread) {
- mSleepUpdateHandlerThread.interrupt();
- }
- if( null != mSleepMsgTV ) {
- mSleepMsgTV.setVisibility(View.INVISIBLE);
- }
- // Log.d(LOGTAG, "endSleepTimer");
- }
-
- private boolean hasSleepTimerExpired() {
- boolean expired = true;
- if (isSleepTimerActive())
- {
- long timeNow = ((SystemClock.elapsedRealtime()));
- //Log.d(LOGTAG, "hasSleepTimerExpired - " + mSleepAtPhoneTime + " now: "+ timeNow);
- if (timeNow < mSleepAtPhoneTime)
- {
- expired = false;
- }
- }
- return expired;
- }
-
- private boolean isSleepTimerActive() {
- boolean active = false;
- if (mSleepAtPhoneTime > 0)
- {
- active = true;
- }
- return active;
- }
-
- private void updateExpiredSleepTime() {
- int vis = View.INVISIBLE;
- if (isSleepTimerActive())
- {
- long timeNow = ((SystemClock.elapsedRealtime()));
- if (mSleepAtPhoneTime >= timeNow)
- {
- long seconds = (mSleepAtPhoneTime - timeNow) / 1000;
- String sleepMsg = makeTimeString(seconds);
- //Log.d(LOGTAG, "updateExpiredSleepTime: " + sleepMsg);
- mSleepMsgTV.setText(sleepMsg);
- if (seconds < SLEEP_TOGGLE_SECONDS)
- {
- int nowVis = mSleepMsgTV.getVisibility();
- vis = (nowVis == View.INVISIBLE) ? View.VISIBLE
- : View.INVISIBLE;
- } else
- {
- vis = View.VISIBLE;
- }
- } else
- {
- /* Clean up timer */
- mSleepAtPhoneTime = 0;
- }
- }
- mSleepMsgTV.setVisibility(vis);
- }
-
- private Handler mUIUpdateHandlerHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what)
- {
- case SLEEPTIMER_EXPIRED: {
- mSleepAtPhoneTime = 0;
- //Log.d(LOGTAG, "mUIUpdateHandlerHandler - SLEEPTIMER_EXPIRED");
- DebugToasts("Turning Off FM Radio", Toast.LENGTH_SHORT);
- disableRadio();
- return;
- }
- case SLEEPTIMER_UPDATE: {
- //Log.d(LOGTAG, "mUIUpdateHandlerHandler - SLEEPTIMER_UPDATE");
- updateExpiredSleepTime();
- break;
- }
- case RECORDTIMER_EXPIRED: {
- Log.d(LOGTAG, "mUIUpdateHandlerHandler - RECORDTIMER_EXPIRED");
- //Clear the Recorder text
- mRecordingMsgTV.setText("");
- if (mRecording != false)
- {
- DebugToasts("Stop Recording", Toast.LENGTH_SHORT);
- stopRecording();
- }
- return;
- }
- case RECORDTIMER_UPDATE: {
- Log.d(LOGTAG, "mUIUpdateHandlerHandler - RECORDTIMER_UPDATE");
- updateExpiredRecordTime();
- break;
- }
- default:
- break;
- }
- super.handleMessage(msg);
- }
- };
-
- /* Thread processing */
- private Runnable doSleepProcessing = new Runnable() {
- public void run() {
- boolean sleepTimerExpired = hasSleepTimerExpired();
- while ((sleepTimerExpired == false)&& (!Thread.currentThread().isInterrupted()) )
- {
- try
- {
- Thread.sleep(500);
- Message statusUpdate = new Message();
- statusUpdate.what = SLEEPTIMER_UPDATE;
- mUIUpdateHandlerHandler.sendMessage(statusUpdate);
- sleepTimerExpired = hasSleepTimerExpired();
- }catch ( Exception ex ) {
- Log.d( LOGTAG, "RunningThread InterruptedException");
- Thread.currentThread().interrupt();
- }//try
- }
- if( true == sleepTimerExpired) {
- Message finished = new Message();
- finished.what = SLEEPTIMER_EXPIRED;
- mUIUpdateHandlerHandler.sendMessage(finished);
- }
- }
- };
-
- private static StringBuilder sFormatBuilder = new StringBuilder();
- private static Formatter sFormatter = new Formatter(sFormatBuilder, Locale
- .getDefault());
- private static final Object[] sTimeArgs = new Object[5];
-
- private String makeTimeString(long secs) {
- String durationformat = getString(R.string.durationformat);
-
- /*
- * Provide multiple arguments so the format can be changed easily by
- * modifying the xml.
- */
- sFormatBuilder.setLength(0);
-
- final Object[] timeArgs = sTimeArgs;
- timeArgs[0] = secs / 3600;
- timeArgs[1] = secs / 60;
- timeArgs[2] = (secs / 60) % 60;
- timeArgs[3] = secs;
- timeArgs[4] = secs % 60;
-
- return sFormatter.format(durationformat, timeArgs).toString();
- }
-
- private void tuneRadio(int frequency){
- /* Issue the tune command only if tuneCommand is already not active */
- if( (mService != null) && (mCommandActive != CMD_TUNE) && isFmOn() )
- {
- boolean bStatus = false;
- try
- {
-
- bStatus = mService.tune(frequency);
- if(bStatus)
- {
- postTimeoutHandler(CMD_TUNE);
- }
- else
- {
- if(isFmOn())
- {
- mCommandFailed = CMD_TUNE;
- Log.e(LOGTAG, " mService.tune failed");
- showDialog(DIALOG_CMD_FAILED);
- }
- }
- mTunedStation.setName("");
- mTunedStation.setPI(0);
- mTunedStation.setPty(0);
- updateStationInfoToUI();
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- Log.e(LOGTAG, "Delayed Tune handler stopped");
- }
- }
-
- /* Start a Command timeout
- */
- private synchronized void postTimeoutHandler(int cmd){
-
- mCommandActive = cmd;
- mCommandTimeoutHandler.sendEmptyMessageDelayed (MSG_CMD_TIMEOUT, CMD_TIMEOUT_DELAY_MS);
- }
-
- /* Stop the Command timeout
- */
- private synchronized void cleanupTimeoutHandler(){
- mCommandActive = CMD_NONE;
- mCommandTimeoutHandler.removeMessages(MSG_CMD_TIMEOUT);
- }
- /* Command timeout Handler
- Routine to handle the Command timeouts for FM operations
- that return asynchronous event callbacks
- */
- private Handler mCommandTimeoutHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what)
- {
- case MSG_CMD_TIMEOUT:
- {
- if (mCommandActive>0)
- {
- Log.d(LOGTAG, "mCommandTimeoutHandler: Cmd failed : "+mCommandActive);
- mCommandTimeoutHandler.removeMessages(MSG_CMD_TIMEOUT);
- showDialog(DIALOG_CMD_TIMEOUT);
- return;
- }
- break;
- }//case MSG_CMD_TIMEOUT
- }//switch
- }//handleMessage
- };
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- Log.d(LOGTAG, "KEY event received"+keyCode);
- switch (keyCode) {
- case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
- case 126: //KeyEvent.KEYCODE_MEDIA_PLAY:
- case 127: //KeyEvent.KEYCODE_MEDIA_PAUSE:
- case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
- case KeyEvent.KEYCODE_MEDIA_NEXT:
- case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
- case KeyEvent.KEYCODE_MEDIA_REWIND:
- case KeyEvent.KEYCODE_MEDIA_STOP:
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
- private void resetFMStationInfoUI()
- {
- mTunedStation.setFrequency(FmSharedPreferences.getTunedFrequency());
- mTunedStation.setName("");
- mTunedStation.setPI(0);
- mTunedStation.setRDSSupported(false);
- //mTunedStation.setPI(20942);
- mTunedStation.setPty(0);
- mRadioTextTV.setText("");
- mERadioTextTV.setText("");
- mRadioTextScroller.mOriginalString = "";
- mProgramServiceTV.setText("");
- mRadioTextScroller.stopScroll();
- updateStationInfoToUI();
- }
-
- final Runnable mRadioEnabled = new Runnable() {
- public void run() {
- /* Update UI to FM On State */
- enableRadioOnOffUI(true);
- /* Tune to the last tuned frequency */
- tuneRadio(FmSharedPreferences.getTunedFrequency());
- }
- };
-
- final Runnable mRadioDisabled = new Runnable() {
- public void run() {
- /* Update UI to FM Off State */
- cleanupTimeoutHandler();
- endSleepTimer();
- stopRecording();
- cancelSearch();
- enableRadioOnOffUI(false);
- }
- };
- final Runnable mRadioReset = new Runnable() {
- public void run() {
- /* Update UI to FM Reset (Off) State */
- resetRadio();
- }
- };
-
- final Runnable mUpdateStationInfo = new Runnable() {
- public void run() {
- cleanupTimeoutHandler();
- PresetStation station = new PresetStation("", FmSharedPreferences.getTunedFrequency());
- if (station != null) {
- mTunedStation.Copy(station);
- }
- updateSearchProgress();
- resetFMStationInfoUI();
- }
- };
-
- final Runnable mSearchComplete = new Runnable() {
- public void run() {
- Log.d(LOGTAG, "mSearchComplete: ");
- mScanPty=0;
- mIsScaning = false;
- mIsSeeking = false;
- mIsSearching = false;
- updateSearchProgress();
- resetFMStationInfoUI();
- }
- };
-
- final Runnable mSearchListComplete = new Runnable() {
- public void run() {
- Log.d(LOGTAG, "mSearchListComplete: ");
- mIsSearching = false;
-
- /* Now get the list*/
- if(mService != null)
- {
- try
- {
- int[] searchList = mService.getSearchList();
- if (searchList != null)
- {
- /* Add the stations into the preset list */
- int currentList = FmSharedPreferences.getCurrentListIndex();
- PresetList curList =
- FmSharedPreferences.getStationList(currentList);
- if (curList != null) {
- curList.clear();
- }
- mPresetPageNumber = 0;
-
- for( int station=0;
- (station < searchList.length) && (station < NUM_AUTO_PRESETS_SEARCH);
- station++)
- {
- int frequency = searchList[station];
- Log.d(LOGTAG, "mSearchListComplete: [" + station + "] = " + frequency);
- if( (frequency <= FmSharedPreferences.getUpperLimit())
- && (frequency >= FmSharedPreferences.getLowerLimit()))
- {
- FmSharedPreferences.addStation("", searchList[station],currentList);
- }
-
- if(frequency == 0)
- {
- break;
- }
- }
- mPrefs.Save();
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- updateSearchProgress();
- resetFMStationInfoUI();
- setupPresetLayout();
- }
- };
-
- final Runnable mOnMute = new Runnable() {
- public void run() {
- setMuteModeButtonImage(true);
- }
- };
-
- final Runnable mOnStereo = new Runnable() {
- public void run() {
- if(FMRADIO_UI_STATION_AUDIO_STEREO == mStereo)
- {
- mStereoTV.setText(R.string.audio_type_stereo);
- }
- else if(FMRADIO_UI_STATION_AUDIO_MONO == mStereo)
- {
- mStereoTV.setText(R.string.audio_type_mono);
- }
- else
- {
- mStereoTV.setText("");
- }
- }
- };
-
- final Runnable mUpdateRadioText = new Runnable() {
- public void run() {
- String str = "";
- if(mService != null && isFmOn())
- {
- try
- {
- /* Get Radio Text and update the display */
- str = mService.getRadioText();
-
- /* Update only if all the characters are printable */
- if (TextUtils.isPrintableAsciiOnly(str))
- {
- Log.d(LOGTAG, "mUpdateRadioText: Updatable string: [" + str + "]");
- mRadioTextTV.setText(str);
- mRadioTextScroller.mOriginalString = str;
- }
- /* Rest the string to empty*/
- else if (TextUtils.isEmpty(str))
- {
- mRadioTextTV.setText("");
- mRadioTextScroller.mOriginalString = "";
- } else
- {
- //Log.d(LOGTAG, "mUpdateRadioText: Leaving old string " + mRadioTextTV.getText());
- }
-
- /* Get PTY and PI and update the display */
- int tempInt =mService.getProgramType();
- /* Save PTY */
- mTunedStation.setPty(tempInt);
- mProgramTypeTV.setText(PresetStation.parsePTY(tempInt));
- tempInt =mService.getProgramID();
- mStationCallSignTV.setText(PresetStation.parsePI(tempInt));
- if(tempInt != 0)
- {
- mTunedStation.setPI(tempInt);
- }
- /* For non-Empty, non-Printable string, just leave the
- existing old string
- */
- mRadioTextScroller.startScroll();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- };
-
- final Runnable mUpdateExtenRadioText = new Runnable() {
- public void run() {
- String str = "";
- if(mService != null && isFmOn())
- {
- try
- {
- /* Get Extended Radio Text and update the display */
- str = mService.getExtenRadioText();
- if (TextUtils.isEmpty(str))
- mERadioTextTV.setText("");
- else
- mERadioTextTV.setText(str);
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- };
-
- /* Create runnable for posting */
- final Runnable mUpdateProgramService = new Runnable() {
- public void run() {
- String str = "";
- if(mService != null)
- {
- try
- {
- /* Get the Station PS and update the display */
- str = mService.getProgramService();
- /* Update only if all the characters are printable */
- //if(isStringPrintable(str))
- if (TextUtils.isPrintableAsciiOnly(str))
- {
- Log.d(LOGTAG, "mUpdateProgramService: Updatable string: [" + str + "]");
- mProgramServiceTV.setText(str);
- }
- /* Rest the string to empty*/
- else if (TextUtils.isEmpty(str))
- {
- mProgramServiceTV.setText("");
- } else
- {
- /* For non-Empty, non-Printable string, just leave the
- existing old string
- */
- //Log.d(LOGTAG, "mUpdateProgramService: Leaving old string " + mProgramServiceTV.getText());
- }
- /* Get PTY and PI and update the display */
- int tempInt =mService.getProgramType();
- /* Save PTY */
- mTunedStation.setPty(tempInt);
-
- mProgramTypeTV.setText(PresetStation.parsePTY(tempInt));
- tempInt =mService.getProgramID();
- /* Save the program ID */
- if(tempInt != 0)
- {
- mTunedStation.setPI(tempInt);
- }
- mStationCallSignTV.setText(PresetStation.parsePI(tempInt));
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- };
-
- private void DebugToasts(String str, int duration) {
- //Toast.makeText(this, str, duration).show();
- Log.d(LOGTAG, "Debug:" + str);
- }
-
- /**
- * This Handler will scroll the text view.
- * On startScroll, the scrolling starts after SCROLLER_START_DELAY_MS
- * The Text View is scrolled left one character after every
- * SCROLLER_UPDATE_DELAY_MS
- * When the entire text is scrolled, the scrolling will restart
- * after SCROLLER_RESTART_DELAY_MS
- */
- private static final class ScrollerText extends Handler
- {
-
- private static final byte SCROLLER_STOPPED = 0x51;
- private static final byte SCROLLER_STARTING = 0x52;
- private static final byte SCROLLER_RUNNING = 0x53;
-
- private static final int SCROLLER_MSG_START = 0xF1;
- private static final int SCROLLER_MSG_TICK = 0xF2;
- private static final int SCROLLER_MSG_RESTART = 0xF3;
-
- private static final int SCROLLER_START_DELAY_MS = 1000;
- private static final int SCROLLER_RESTART_DELAY_MS = 3000;
- private static final int SCROLLER_UPDATE_DELAY_MS = 200;
-
- private final WeakReference<TextView> mView;
-
- private byte mStatus = SCROLLER_STOPPED;
- String mOriginalString;
- int mStringlength=0;
- int mIteration=0;
-
- ScrollerText(TextView v) {
- mView = new WeakReference<TextView>(v);
- }
-
- /**
- * Scrolling Message Handler
- */
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what)
- {
- case SCROLLER_MSG_START:
- mStatus = SCROLLER_RUNNING;
- updateText();
- break;
- case SCROLLER_MSG_TICK:
- updateText();
- break;
- case SCROLLER_MSG_RESTART:
- if (mStatus == SCROLLER_RUNNING)
- {
- startScroll();
- }
- break;
- }
- }
-
- /**
- * Moves the text left by one character and posts a
- * delayed message for next update after SCROLLER_UPDATE_DELAY_MS.
- * If the entire string is scrolled, then it displays the entire string
- * and waits for SCROLLER_RESTART_DELAY_MS for scrolling restart
- */
- void updateText() {
- if (mStatus != SCROLLER_RUNNING)
- {
- return;
- }
-
- removeMessages(SCROLLER_MSG_TICK);
-
- final TextView textView = mView.get();
- if (textView != null)
- {
- String szStr2 = "";
- if (mStringlength > 0)
- {
- mIteration++;
- if (mIteration >= mStringlength)
- {
- mIteration = 0;
- sendEmptyMessageDelayed(SCROLLER_MSG_RESTART, SCROLLER_RESTART_DELAY_MS);
- } else
- {
- sendEmptyMessageDelayed(SCROLLER_MSG_TICK, SCROLLER_UPDATE_DELAY_MS);
- }
- //String szStr1 = mOriginalString.substring(0, mTick);
- if ((mOriginalString !=null) && (mOriginalString.length() >= mIteration))
- szStr2 = mOriginalString.substring(mIteration);
- }
- //textView.setText(szStr2+" "+szStr1);
- textView.setText(szStr2);
- }
- }
-
- /**
- * Stops the scrolling
- * The textView will be set to the original string.
- */
- void stopScroll() {
- mStatus = SCROLLER_STOPPED;
- removeMessages(SCROLLER_MSG_TICK);
- removeMessages(SCROLLER_MSG_RESTART);
- removeMessages(SCROLLER_MSG_START);
- resetScroll();
- }
-
- /**
- * Resets the scroll to display the original string.
- */
- private void resetScroll() {
- mIteration = 0;
- final TextView textView = mView.get();
- if (textView != null)
- {
- textView.setText(mOriginalString);
- }
- }
-
- /** Starts the Scrolling of the TextView after a
- * delay of SCROLLER_START_DELAY_MS
- * Starts only if Length > 0
- */
- void startScroll() {
- final TextView textView = mView.get();
- if (textView != null)
- {
- mOriginalString = (String) textView.getText();
- mStringlength = mOriginalString.length();
- if (mStringlength > 0)
- {
- mStatus = SCROLLER_STARTING;
- sendEmptyMessageDelayed(SCROLLER_MSG_START, SCROLLER_START_DELAY_MS);
- }
- }
- }
- }
-
-
- public static IFMRadioService sService = null;
- private static HashMap<Context, ServiceBinder> sConnectionMap = new HashMap<Context, ServiceBinder>();
-
- public static boolean bindToService(Context context) {
- Log.e(LOGTAG, "bindToService: Context");
- return bindToService(context, null);
- }
-
- public static boolean bindToService(Context context, ServiceConnection callback) {
- Log.e(LOGTAG, "bindToService: Context with serviceconnection callback");
- context.startService(new Intent(context, FMRadioService.class));
- ServiceBinder sb = new ServiceBinder(callback);
- sConnectionMap.put(context, sb);
- return context.bindService((new Intent()).setClass(context,
- FMRadioService.class), sb, 0);
- }
-
- public static void unbindFromService(Context context) {
- ServiceBinder sb = (ServiceBinder) sConnectionMap.remove(context);
- Log.e(LOGTAG, "unbindFromService: Context");
- if (sb == null)
- {
- Log.e(LOGTAG, "Trying to unbind for unknown Context");
- return;
- }
- context.unbindService(sb);
- if (sConnectionMap.isEmpty())
- {
- // presumably there is nobody interested in the service at this point,
- // so don't hang on to the ServiceConnection
- sService = null;
- }
- }
-
- private static class ServiceBinder implements ServiceConnection
- {
- ServiceConnection mCallback;
- ServiceBinder(ServiceConnection callback) {
- mCallback = callback;
- }
-
- public void onServiceConnected(ComponentName className, android.os.IBinder service) {
- sService = IFMRadioService.Stub.asInterface(service);
- if (mCallback != null)
- {
- Log.e(LOGTAG, "onServiceConnected: mCallback");
- mCallback.onServiceConnected(className, service);
- }
- }
-
- public void onServiceDisconnected(ComponentName className) {
- if (mCallback != null)
- {
- mCallback.onServiceDisconnected(className);
- }
- sService = null;
- }
- }
-
- private ServiceConnection osc = new ServiceConnection() {
- public void onServiceConnected(ComponentName classname, IBinder obj) {
- mService = IFMRadioService.Stub.asInterface(obj);
- Log.e(LOGTAG, "ServiceConnection: onServiceConnected: ");
- if (mService != null)
- {
- try
- {
- mService.registerCallbacks(mServiceCallbacks);
- if(SavedDataAndState == null) {
- enableRadio();
- } else if(SavedDataAndState.onOrOff){
- enableRadioOnOffUI(true);
- } else {
- enableRadioOnOffUI(false);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- if(isRecording()) {
- initiateRecordThread();
- }
- return;
- } else
- {
- Log.e(LOGTAG, "IFMRadioService onServiceConnected failed");
- }
- if (getIntent().getData() == null)
- {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClass(FMRadio.this, FMRadio.class);
- startActivity(intent);
- }
- finish();
- }
- public void onServiceDisconnected(ComponentName classname) {
- }
- };
-
- private IFMRadioServiceCallbacks.Stub mServiceCallbacks = new IFMRadioServiceCallbacks.Stub()
- {
- public void onEnabled()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onEnabled :");
- mHandler.post(mRadioEnabled);
- }
-
- public void onDisabled()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onDisabled :");
- mHandler.post(mRadioDisabled);
- }
- public void onRadioReset()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRadioReset :");
- mHandler.post(mRadioReset);
- }
-
- public void onTuneStatusChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onTuneStatusChanged :");
- cleanupTimeoutHandler();
- mHandler.post(mUpdateStationInfo);
- }
-
- public void onProgramServiceChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onProgramServiceChanged :");
- mHandler.post(mUpdateProgramService);
- }
-
- public void onRadioTextChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRadioTextChanged :");
- mHandler.post(mUpdateRadioText);
- }
- public void onExtenRadioTextChanged()
- {
- mHandler.post(mUpdateExtenRadioText);
- }
- public void onAlternateFrequencyChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onAlternateFrequencyChanged :");
- }
-
- public void onSignalStrengthChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onSignalStrengthChanged :");
- }
-
- public void onSearchComplete()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onSearchComplete :");
- mHandler.post(mSearchComplete);
- }
- public void onSearchListComplete()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onSearchListComplete :");
- mHandler.post(mSearchListComplete);
- }
-
- public void onMute(boolean bMuted)
- {
- Log.d(LOGTAG, "mServiceCallbacks.onMute :" + bMuted);
- mHandler.post(mOnMute);
- }
-
- public void onAudioUpdate(boolean bStereo)
- {
- if((bStereo) && (FmSharedPreferences.getAudioOutputMode()))
- {
- mStereo = FMRADIO_UI_STATION_AUDIO_STEREO;
- }
- else
- {
- mStereo = FMRADIO_UI_STATION_AUDIO_MONO;
-
- }
- Log.d(LOGTAG, "mServiceCallbacks.onAudioUpdate :" + mStereo);
- mHandler.post(mOnStereo);
- }
-
- public void onStationRDSSupported(boolean bRDSSupported)
- {
- Log.d(LOGTAG, "mServiceCallbacks.onStationRDSSupported :" + bRDSSupported);
- /*
- * Depending on the signal strength etc, RDS Lock Sync/Supported may toggle,
- * Since if a station Supports RDS, it will not change its support intermittently
- * just save the status and ignore any "unsupported" state.
- */
- if(bRDSSupported)
- {
- mTunedStation.setRDSSupported(true);
- }
- }
- public void onRecordingStopped()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRecordingStopped:");
- stopRecording();
- }
- public void onRecordingStarted()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRecordingStarted:");
- startRecordingTimer();
- }
- };
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMRadioService.java b/fmapp/src/com/codeaurora/fmradio/FMRadioService.java
deleted file mode 100644
index db64782..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMRadioService.java
+++ /dev/null
@@ -1,2998 +0,0 @@
-/*
- * 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.io.File;
-import java.util.*;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-
-import android.app.AlarmManager;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.BroadcastReceiver;
-import android.media.AudioManager;
-import android.media.AudioManager.OnAudioFocusChangeListener;
-import android.media.AudioSystem;
-import android.media.MediaRecorder;
-import android.os.Environment;
-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.telephony.PhoneStateListener;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-import android.widget.RemoteViews;
-import android.widget.Toast;
-import android.view.KeyEvent;
-import android.os.SystemProperties;
-
-import qcom.fmradio.FmReceiver;
-import qcom.fmradio.FmRxEvCallbacksAdaptor;
-import qcom.fmradio.FmRxRdsData;
-import qcom.fmradio.FmConfig;
-import android.net.Uri;
-import android.content.res.Resources;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import android.provider.MediaStore;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.database.Cursor;
-import com.codeaurora.utils.A2dpDeviceStatus;
-import android.media.AudioManager;
-import android.content.ComponentName;
-import android.os.StatFs;
-import android.os.SystemClock;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.app.IntentService;
-import android.os.UserHandle;
-import android.os.Process;
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningAppProcessInfo;
-
-/**
- * Provides "background" FM Radio (that uses the hardware) capabilities,
- * allowing the user to switch between activities without stopping playback.
- */
-public class FMRadioService extends Service
-{
-
- public static final int RADIO_AUDIO_DEVICE_WIRED_HEADSET = 0;
- public static final int RADIO_AUDIO_DEVICE_SPEAKER = 1;
-
- private static final int FMRADIOSERVICE_STATUS = 101;
- private static final String FMRADIO_DEVICE_FD_STRING = "/dev/radio0";
- private static final String LOGTAG = "FMService";//FMRadio.LOGTAG;
-
- private FmReceiver mReceiver;
- private BroadcastReceiver mHeadsetReceiver = null;
- private BroadcastReceiver mSdcardUnmountReceiver = null;
- private BroadcastReceiver mMusicCommandListener = null;
- private BroadcastReceiver mSleepExpiredListener = null;
- private BroadcastReceiver mRecordTimeoutListener = null;
- private BroadcastReceiver mDelayedServiceStopListener = null;
- private boolean mOverA2DP = false;
- private BroadcastReceiver mFmMediaButtonListener;
- private IFMRadioServiceCallbacks mCallbacks;
- private static FmSharedPreferences mPrefs;
- private boolean mHeadsetPlugged = false;
- private boolean mInternalAntennaAvailable = false;
- private WakeLock mWakeLock;
- private int mServiceStartId = -1;
- private boolean mServiceInUse = false;
- private static boolean mMuted = false;
- private static boolean mResumeAfterCall = false;
- private static String mAudioDevice="headset";
- MediaRecorder mRecorder = null;
- MediaRecorder mA2dp = null;
- private boolean mFMOn = false;
- private boolean mFmRecordingOn = false;
- private boolean mSpeakerPhoneOn = false;
- private int mCallStatus = 0;
- private BroadcastReceiver mScreenOnOffReceiver = null;
- final Handler mHandler = new Handler();
- private boolean misAnalogModeSupported = false;
- private boolean misAnalogPathEnabled = false;
- private boolean mA2dpDisconnected = false;
- //PhoneStateListener instances corresponding to each
-
- private FmRxRdsData mFMRxRDSData=null;
- // interval after which we stop the service when idle
- private static final int IDLE_DELAY = 60000;
- private File mA2DPSampleFile = null;
- //Track FM playback for reenter App usecases
- private boolean mPlaybackInProgress = false;
- private boolean mStoppedOnFocusLoss = false;
- private File mSampleFile = null;
- long mSampleStart = 0;
- // Messages handled in FM Service
- private static final int FM_STOP =1;
- private static final int RESET_NOTCH_FILTER =2;
- private static final int STOPSERVICE_ONSLEEP = 3;
- private static final int STOPRECORD_ONTIMEOUT = 4;
- private static final int FOCUSCHANGE = 5;
- //Track notch filter settings
- private boolean mNotchFilterSet = false;
- public static final int STOP_SERVICE = 0;
- public static final int STOP_RECORD = 1;
- // A2dp Device Status will be queried through this class
- A2dpDeviceStatus mA2dpDeviceState = null;
- private boolean mA2dpDeviceSupportInHal = false;
- //on shutdown not to send start Intent to AudioManager
- private boolean mAppShutdown = false;
- private boolean mSingleRecordingInstanceSupported = false;
- private AudioManager mAudioManager;
- public static final long UNAVAILABLE = -1L;
- public static final long PREPARING = -2L;
- public static final long UNKNOWN_SIZE = -3L;
- public static final long LOW_STORAGE_THRESHOLD = 50000000;
- private long mStorageSpace;
- private static final String IOBUSY_UNVOTE = "com.android.server.CpuGovernorService.action.IOBUSY_UNVOTE";
- private static final String SLEEP_EXPIRED_ACTION = "com.codeaurora.fmradio.SLEEP_EXPIRED";
- private static final String RECORD_EXPIRED_ACTION = "com.codeaurora.fmradio.RECORD_TIMEOUT";
- private static final String SERVICE_DELAYED_STOP_ACTION = "com.codeaurora.fmradio.SERVICE_STOP";
- public static final String ACTION_FM =
- "codeaurora.intent.action.FM";
- public static final String ACTION_FM_RECORDING =
- "codeaurora.intent.action.FM_Recording";
- public static final String ACTION_FM_RECORDING_STATUS =
- "codeaurora.intent.action.FM.Recording.Status";
- private String mFilePath = "";
- private BroadcastReceiver mFmRecordingStatus = null;
- static final int RECORD_START = 1;
- static final int RECORD_STOP = 0;
-
- public FMRadioService() {
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- mPrefs = new FmSharedPreferences(this);
- mCallbacks = null;
- TelephonyManager tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- tmgr.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE |
- PhoneStateListener.LISTEN_DATA_ACTIVITY);
- PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
- mWakeLock.setReferenceCounted(false);
- misAnalogModeSupported = SystemProperties.getBoolean("ro.fm.analogpath.supported",false);
- /* Register for Screen On/off broadcast notifications */
- mA2dpDeviceState = new A2dpDeviceStatus(getApplicationContext());
- registerScreenOnOffListener();
- registerHeadsetListener();
- registerSleepExpired();
- registerRecordTimeout();
- registerDelayedServiceStop();
- registerFMRecordingStatus();
- // registering media button receiver seperately as we need to set
- // different priority for receiving media events
- registerFmMediaButtonReceiver();
- if ( false == SystemProperties.getBoolean("ro.fm.mulinst.recording.support",true)) {
- mSingleRecordingInstanceSupported = true;
- }
-
- // Register for pause commands from other apps to stop FM
- registerMusicServiceCommandReceiver();
-
- // If the service was idle, but got killed before it stopped itself, the
- // system will relaunch it. Make sure it gets stopped again in that case.
- setAlarmDelayedServiceStop();
- /* Query to check is a2dp supported in Hal */
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- String valueStr = audioManager.getParameters("isA2dpDeviceSupported");
- mA2dpDeviceSupportInHal = valueStr.contains("=true");
- Log.d(LOGTAG, " is A2DP device Supported In HAL"+mA2dpDeviceSupportInHal);
- }
-
- @Override
- public void onDestroy() {
- Log.d(LOGTAG, "onDestroy");
- if (isFmOn())
- {
- Log.e(LOGTAG, "Service being destroyed while still playing.");
- }
-
- // make sure there aren't any other messages coming
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- cancelAlarms();
- //release the audio focus listener
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if (isMuted()) {
- mMuted = false;
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false);
- }
- audioManager.abandonAudioFocus(mAudioFocusListener);
- /* Remove the Screen On/off listener */
- if (mScreenOnOffReceiver != null) {
- unregisterReceiver(mScreenOnOffReceiver);
- mScreenOnOffReceiver = null;
- }
- /* Unregister the headset Broadcase receiver */
- if (mHeadsetReceiver != null) {
- unregisterReceiver(mHeadsetReceiver);
- mHeadsetReceiver = null;
- }
- if( mMusicCommandListener != null ) {
- unregisterReceiver(mMusicCommandListener);
- mMusicCommandListener = null;
- }
- if( mFmMediaButtonListener != null ) {
- unregisterReceiver(mFmMediaButtonListener);
- mFmMediaButtonListener = null;
- }
- if (mSleepExpiredListener != null ) {
- unregisterReceiver(mSleepExpiredListener);
- mSleepExpiredListener = null;
- }
- if (mRecordTimeoutListener != null) {
- unregisterReceiver(mRecordTimeoutListener);
- mRecordTimeoutListener = null;
- }
- if (mDelayedServiceStopListener != null) {
- unregisterReceiver(mDelayedServiceStopListener);
- mDelayedServiceStopListener = null;
- }
- if (mFmRecordingStatus != null ) {
- unregisterReceiver(mFmRecordingStatus);
- mFmRecordingStatus = null;
- }
- /* Since the service is closing, disable the receiver */
- fmOff();
-
- TelephonyManager tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- tmgr.listen(mPhoneStateListener, 0);
-
- Log.d(LOGTAG, "onDestroy: unbindFromService completed");
-
- //unregisterReceiver(mIntentReceiver);
- mWakeLock.release();
- super.onDestroy();
- }
-
- public void registerFMRecordingStatus() {
- if (mFmRecordingStatus == null) {
- mFmRecordingStatus = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "received intent " +intent);
- String action = intent.getAction();
- if (action.equals(ACTION_FM_RECORDING_STATUS)) {
- Log.d(LOGTAG, "ACTION_FM_RECORDING_STATUS Intent received");
- int state = intent.getIntExtra("state", 0);
- if (state == RECORD_START) {
- Log.d(LOGTAG, "FM Recording started");
- mFmRecordingOn = true;
- mSampleStart = SystemClock.elapsedRealtime();
- try {
- if ((mServiceInUse) && (mCallbacks != null) ) {
- Log.d(LOGTAG, "start recording thread");
- mCallbacks.onRecordingStarted();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- } else if (state == RECORD_STOP) {
- Log.d(LOGTAG, "FM Recording stopped");
- mFmRecordingOn = false;
- try {
- if ((mServiceInUse) && (mCallbacks != null) ) {
- mCallbacks.onRecordingStopped();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- mSampleStart = 0;
- }
- }
- }
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction(ACTION_FM_RECORDING_STATUS);
- registerReceiver(mFmRecordingStatus , iFilter);
- }
- }
-
- /**
- * Registers an intent to listen for ACTION_HEADSET_PLUG
- * notifications. This intent is called to know if the headset
- * was plugged in/out
- */
- public void registerHeadsetListener() {
- if (mHeadsetReceiver == null) {
- mHeadsetReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
- Log.d(LOGTAG, "ACTION_HEADSET_PLUG Intent received");
- // Listen for ACTION_HEADSET_PLUG broadcasts.
- Log.d(LOGTAG, "mReceiver: ACTION_HEADSET_PLUG");
- Log.d(LOGTAG, "==> intent: " + intent);
- Log.d(LOGTAG, " state: " + intent.getIntExtra("state", 0));
- Log.d(LOGTAG, " name: " + intent.getStringExtra("name"));
- mHeadsetPlugged = (intent.getIntExtra("state", 0) == 1);
- // if headset is plugged out it is required to disable
- // in minimal duration to avoid race conditions with
- // audio policy manager switch audio to speaker.
- mHandler.removeCallbacks(mHeadsetPluginHandler);
- mHandler.post(mHeadsetPluginHandler);
- } else if(mA2dpDeviceState.isA2dpStateChange(action) ) {
- boolean bA2dpConnected =
- mA2dpDeviceState.isConnected(intent);
- if (!bA2dpConnected) {
- Log.d(LOGTAG, "A2DP device is dis-connected!");
- mA2dpDisconnected = true;
- } else {
- mA2dpDisconnected = false;
- }
- if (isAnalogModeEnabled()) {
- Log.d(LOGTAG, "FM Audio Path is Analog Mode: FM Over BT not allowed");
- return ;
- }
- //when playback is overA2Dp and A2dp disconnected
- //when playback is not overA2DP and A2DP Connected
- // In above two cases we need to Stop and Start FM which
- // will take care of audio routing
- if( (isFmOn()) &&
- (true == ((bA2dpConnected)^(mOverA2DP))) &&
- (false == mStoppedOnFocusLoss) &&
- (!isSpeakerEnabled())) {
- stopFM();
- startFM();
- }
- } else if (action.equals("HDMI_CONNECTED")) {
- //FM should be off when HDMI is connected.
- 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();
- }
- } else if( action.equals(Intent.ACTION_SHUTDOWN)) {
- mAppShutdown = true;
- }
-
- }
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction(Intent.ACTION_HEADSET_PLUG);
- iFilter.addAction(mA2dpDeviceState.getActionSinkStateChangedString());
- iFilter.addAction("HDMI_CONNECTED");
- iFilter.addAction(Intent.ACTION_SHUTDOWN);
- iFilter.addCategory(Intent.CATEGORY_DEFAULT);
- registerReceiver(mHeadsetReceiver, iFilter);
- }
- }
-
- public void registerFmMediaButtonReceiver() {
- if (mFmMediaButtonListener == null) {
- mFmMediaButtonListener = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "FMMediaButtonIntentReceiver.FM_MEDIA_BUTTON");
- Log.d(LOGTAG, "KeyEvent = " +intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT));
- String action = intent.getAction();
- if (action.equals(FMMediaButtonIntentReceiver.FM_MEDIA_BUTTON)) {
- KeyEvent event = (KeyEvent)
- intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
- int keycode = event.getKeyCode();
- switch (keycode) {
- case KeyEvent.KEYCODE_HEADSETHOOK :
- if (isFmOn()){
- //FM should be off when Headset hook pressed.
- fmOff();
- if (isOrderedBroadcast()) {
- abortBroadcast();
- }
- 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();
- }
- } else if( mServiceInUse ) {
- fmOn();
- if (isOrderedBroadcast()) {
- abortBroadcast();
- }
- try {
- /* Notify the UI/Activity, only if the service is "bound"
- by an activity and if Callbacks are registered
- */
- if (mCallbacks != null ) {
- mCallbacks.onEnabled();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- break;
- case KeyEvent.KEYCODE_MEDIA_PAUSE :
- if (isFmOn()){
- //FM should be off when Headset hook pressed.
- fmOff();
- if (isOrderedBroadcast()) {
- abortBroadcast();
- }
- 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();
- }
- }
- break;
- case KeyEvent.KEYCODE_MEDIA_PLAY:
- if (isAntennaAvailable() && mServiceInUse ) {
- fmOn();
- if (isOrderedBroadcast()) {
- abortBroadcast();
- }
- try {
- /* Notify the UI/Activity, only if the service is "bound"
- by an activity and if Callbacks are registered
- */
- if (mCallbacks != null ) {
- mCallbacks.onEnabled();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- break;
- } // end of switch
- } // end of FMMediaButtonIntentReceiver.FM_MEDIA_BUTTON
- } // end of onReceive
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction(FMMediaButtonIntentReceiver.FM_MEDIA_BUTTON);
- registerReceiver(mFmMediaButtonListener, iFilter);
- }
- }
-
- public void registerMusicServiceCommandReceiver() {
- if (mMusicCommandListener == null) {
- mMusicCommandListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
-
- if (action.equals("com.android.music.musicservicecommand")) {
- String cmd = intent.getStringExtra("command");
- Log.d(LOGTAG, "Music Service command : "+cmd+ " received");
- if (cmd != null && cmd.equals("pause")) {
- if (mA2dpDisconnected) {
- Log.d(LOGTAG, "not to pause,this is a2dp disconnected's pause");
- mA2dpDisconnected = false;
- return;
- }
- if(isFmOn()){
- fmOff();
- if (isOrderedBroadcast()) {
- abortBroadcast();
- }
- 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 commandFilter = new IntentFilter();
- commandFilter.addAction("com.android.music.musicservicecommand");
- registerReceiver(mMusicCommandListener, commandFilter);
- }
- }
- public void registerSleepExpired() {
- if (mSleepExpiredListener == null) {
- mSleepExpiredListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "registerSleepExpired");
- mWakeLock.acquire(10 * 1000);
- fmOff();
- }
- };
- IntentFilter intentFilter = new IntentFilter(SLEEP_EXPIRED_ACTION);
- registerReceiver(mSleepExpiredListener, intentFilter);
- }
- }
- public void registerRecordTimeout() {
- if (mRecordTimeoutListener == null) {
- mRecordTimeoutListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "registerRecordTimeout");
- mWakeLock.acquire(5 * 1000);
- stopRecording();
- }
- };
- IntentFilter intentFilter = new IntentFilter(RECORD_EXPIRED_ACTION);
- registerReceiver(mRecordTimeoutListener, intentFilter);
- }
- }
- public void registerDelayedServiceStop() {
- if (mDelayedServiceStopListener == null) {
- mDelayedServiceStopListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "registerDelayedServiceStop");
- mWakeLock.acquire(5 * 1000);
- if (isFmOn() || mServiceInUse) {
- return;
- }
- stopSelf(mServiceStartId);
- }
- };
- IntentFilter intentFilter = new IntentFilter(SERVICE_DELAYED_STOP_ACTION);
- registerReceiver(mDelayedServiceStopListener, intentFilter);
- }
- }
-
-
-
- final Runnable mHeadsetPluginHandler = new Runnable() {
- public void run() {
- /* Update the UI based on the state change of the headset/antenna*/
- if(!isAntennaAvailable())
- {
- /* 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();
- }
- }
- else
- {
- /* headset is plugged back in,
- So turn on FM if:
- - FM is not already ON.
- - If the FM UI/Activity is in the foreground
- (the service is "bound" by an activity
- and if Callbacks are registered)
- */
- if ((!isFmOn()) && (mServiceInUse)
- && (mCallbacks != null))
- {
- if( true != fmOn() ) {
- return;
- }
- try
- {
- mCallbacks.onEnabled();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
- };
-
-
- @Override
- public IBinder onBind(Intent intent) {
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- cancelAlarms();
- mServiceInUse = true;
- /* Application/UI is attached, so get out of lower power mode */
- setLowPowerMode(false);
- Log.d(LOGTAG, "onBind");
- return mBinder;
- }
-
- @Override
- public void onRebind(Intent intent) {
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- cancelAlarms();
- mServiceInUse = true;
- /* Application/UI is attached, so get out of lower power mode */
- setLowPowerMode(false);
- Log.d(LOGTAG, "onRebind");
- }
-
- @Override
- public void onStart(Intent intent, int startId) {
- Log.d(LOGTAG, "onStart");
- mServiceStartId = startId;
- // make sure the service will shut down on its own if it was
- // just started but not bound to and nothing is playing
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- cancelAlarms();
- setAlarmDelayedServiceStop();
- }
-
- @Override
- public boolean onUnbind(Intent intent) {
- mServiceInUse = false;
- Log.d(LOGTAG, "onUnbind");
-
- /* Application/UI is not attached, so go into lower power mode */
- unregisterCallbacks();
- setLowPowerMode(true);
- if (isFmOn())
- {
- // something is currently playing, or will be playing once
- // an in-progress call ends, so don't stop the service now.
- return true;
- }
- gotoIdleState();
- return true;
- }
-
- private String getProcessName() {
- int id = Process.myPid();
- String myProcessName = this.getPackageName();
-
- ActivityManager actvityManager =
- (ActivityManager)this.getSystemService(this.ACTIVITY_SERVICE);
- List<RunningAppProcessInfo> procInfos =
- actvityManager.getRunningAppProcesses();
-
- for(RunningAppProcessInfo procInfo : procInfos) {
- if (id == procInfo.pid) {
- myProcessName = procInfo.processName;
- }
- }
- procInfos.clear();
- return myProcessName;
- }
-
- private void sendRecordIntent(int action) {
- Intent intent = new Intent(ACTION_FM_RECORDING);
- intent.putExtra("state", action);
- if(action == RECORD_START) {
- int mRecordDuration = -1;
- if(FmSharedPreferences.getRecordDuration() !=
- FmSharedPreferences.RECORD_DUR_INDEX_3_VAL) {
- mRecordDuration = (FmSharedPreferences.getRecordDuration() * 60 * 1000);
- }
- intent.putExtra("record_duration", mRecordDuration);
- intent.putExtra("process_name", getProcessName());
- intent.putExtra("process_id", Process.myPid());
- }
- Log.d(LOGTAG, "Sending Recording intent for = " +action);
- getApplicationContext().sendBroadcast(intent);
- }
-
- private void sendRecordServiceIntent(int action) {
- Intent intent = new Intent(ACTION_FM);
- intent.putExtra("state", action);
- Log.d(LOGTAG, "Sending Recording intent for = " +action);
- getApplicationContext().sendBroadcast(intent);
- }
-
- private void startFM(){
- Log.d(LOGTAG, "In startFM");
- if(true == mAppShutdown) { // not to send intent to AudioManager in Shutdown
- return;
- }
- if (isCallActive()) { // when Call is active never let audio playback
- mResumeAfterCall = true;
- return;
- }
- mResumeAfterCall = false;
- if ( true == mPlaybackInProgress ) // no need to resend event
- return;
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- audioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
- AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
- Log.d(LOGTAG,"FM registering for registerMediaButtonEventReceiver");
- mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- ComponentName fmRadio = new ComponentName(this.getPackageName(),
- FMMediaButtonIntentReceiver.class.getName());
- mAudioManager.registerMediaButtonEventReceiver(fmRadio);
- mStoppedOnFocusLoss = false;
-
- if (!mA2dpDeviceSupportInHal && (true == mA2dpDeviceState.isDeviceAvailable()) &&
- (!isSpeakerEnabled()) && !isAnalogModeEnabled()
- && (true == startA2dpPlayback())) {
- mOverA2DP=true;
- } else {
- Log.d(LOGTAG, "FMRadio: Requesting to start FM");
- //reason for resending the Speaker option is we are sending
- //ACTION_FM=1 to AudioManager, the previous state of Speaker we set
- //need not be retained by the Audio Manager.
- if (isSpeakerEnabled()) {
- mSpeakerPhoneOn = true;
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_SPEAKER);
- } else {
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
- }
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM,
- AudioSystem.DEVICE_STATE_AVAILABLE, "");
- sendRecordServiceIntent(RECORD_START);
- }
- mPlaybackInProgress = true;
- }
-
- private void stopFM(){
- Log.d(LOGTAG, "In stopFM");
- if (mOverA2DP==true){
- mOverA2DP=false;
- stopA2dpPlayback();
- }else{
- Log.d(LOGTAG, "FMRadio: Requesting to stop FM");
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM,
- AudioSystem.DEVICE_STATE_UNAVAILABLE, "");
- }
- mPlaybackInProgress = false;
- }
-
- private void resetFM(){
- Log.d(LOGTAG, "resetFM");
- if (mOverA2DP==true){
- mOverA2DP=false;
- resetA2dpPlayback();
- }else{
- Log.d(LOGTAG, "FMRadio: Requesting to stop FM");
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM,
- AudioSystem.DEVICE_STATE_UNAVAILABLE, "");
- sendRecordServiceIntent(RECORD_STOP);
- }
- mPlaybackInProgress = false;
- }
-
- public void startRecording() {
-
- Log.d(LOGTAG, "In startRecording of Recorder");
- if ((true == mSingleRecordingInstanceSupported) &&
- (true == mOverA2DP )) {
- Toast.makeText( this,
- "playback on BT in progress,can't record now",
- Toast.LENGTH_SHORT).show();
- return;
- }
- sendRecordIntent(RECORD_START);
- }
-
- public boolean startA2dpPlayback() {
- Log.d(LOGTAG, "In startA2dpPlayback");
- if( (true == mSingleRecordingInstanceSupported) &&
- (true == mFmRecordingOn )) {
- Toast.makeText(this,
- "Recording already in progress,can't play on BT",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- if(mOverA2DP)
- stopA2dpPlayback();
- mA2dp = new MediaRecorder();
- if (mA2dp == null) {
- Toast.makeText(this,"A2dpPlayback failed to create an instance",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- try {
- mA2dp.setAudioSource(MediaRecorder.AudioSource.FM_RX_A2DP);
- mA2dp.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
- mA2dp.setAudioEncoder(MediaRecorder.OutputFormat.DEFAULT);
- File sampleDir = new File(getFilesDir().getAbsolutePath());
- try {
- mA2DPSampleFile = File
- .createTempFile("FMRecording", ".3gpp", sampleDir);
- } catch (IOException e) {
- Log.e(LOGTAG, "Not able to access Phone's internal memory");
- Toast.makeText(this, "Not able to access Phone's internal memory",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- mA2dp.setOutputFile(mA2DPSampleFile.getAbsolutePath());
- mA2dp.prepare();
- mA2dp.start();
- } catch (Exception exception) {
- mA2dp.reset();
- mA2dp.release();
- mA2dp = null;
- return false;
- }
- return true;
- }
-
- public void stopA2dpPlayback() {
- if (mA2dp == null)
- return;
- if(mA2DPSampleFile != null)
- {
- try {
- mA2DPSampleFile.delete();
- } catch (Exception e) {
- Log.e(LOGTAG, "Not able to delete file");
- }
- }
- try {
- mA2dp.stop();
- mA2dp.reset();
- mA2dp.release();
- mA2dp = null;
- } catch (Exception exception ) {
- Log.e( LOGTAG, "Stop failed with exception"+ exception);
- }
- return;
- }
-
- private void resetA2dpPlayback() {
- if (mA2dp == null)
- return;
- if(mA2DPSampleFile != null)
- {
- try {
- mA2DPSampleFile.delete();
- } catch (Exception e) {
- Log.e(LOGTAG, "Not able to delete file");
- }
- }
- try {
- // Send Intent for IOBUSY VOTE, because MediaRecorder.stop
- // gets Activity context which might not be always available
- // and would thus fail to send the intent.
- Intent ioBusyUnVoteIntent = new Intent(IOBUSY_UNVOTE);
- // Remove vote for io_is_busy to be turned off.
- ioBusyUnVoteIntent.putExtra("com.android.server.CpuGovernorService.voteType", 0);
- sendBroadcast(ioBusyUnVoteIntent);
-
- mA2dp.stop();
-
- mA2dp.reset();
- mA2dp.release();
- mA2dp = null;
- } catch (Exception exception ) {
- Log.e( LOGTAG, "Stop failed with exception"+ exception);
- }
- return;
- }
-
- public void stopRecording() {
- if (!mFmRecordingOn)
- return;
- sendRecordIntent(RECORD_STOP);
- return;
- }
-
- private void fmActionOnCallState( int state ) {
- //if Call Status is non IDLE we need to Mute FM as well stop recording if
- //any. Similarly once call is ended FM should be unmuted.
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- mCallStatus = state;
-
- if((TelephonyManager.CALL_STATE_OFFHOOK == state)||
- (TelephonyManager.CALL_STATE_RINGING == state)) {
- if (state == TelephonyManager.CALL_STATE_RINGING) {
- int ringvolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
- if (ringvolume == 0) {
- return;
- }
- }
- boolean bTempSpeaker = mSpeakerPhoneOn; //need to restore SpeakerPhone
- boolean bTempMute = mMuted;// need to restore Mute status
- int bTempCall = mCallStatus;//need to restore call status
- if (isFmOn() && fmOff()) {
- if((mServiceInUse) && (mCallbacks != null)) {
- try {
- mCallbacks.onDisabled();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- mResumeAfterCall = true;
- mSpeakerPhoneOn = bTempSpeaker;
- mCallStatus = bTempCall;
- mMuted = bTempMute;
- } else if (!mResumeAfterCall) {
- mResumeAfterCall = false;
- mSpeakerPhoneOn = bTempSpeaker;
- mCallStatus = bTempCall;
- mMuted = bTempMute;
- }
- }
- else if (state == TelephonyManager.CALL_STATE_IDLE) {
- // start playing again
- if (mResumeAfterCall)
- {
- // resume playback only if FM Radio was playing
- // when the call was answered
- if (isAntennaAvailable() && (!isFmOn()) && mServiceInUse)
- {
- Log.d(LOGTAG, "Resuming after call:");
- if(true != fmOn()) {
- return;
- }
- mResumeAfterCall = false;
- if(mCallbacks != null) {
- try {
- mCallbacks.onEnabled();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }//idle
- }
-
- /* Handle Phone Call + FM Concurrency */
- private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
- Log.d(LOGTAG, "onCallStateChanged: State - " + state );
- Log.d(LOGTAG, "onCallStateChanged: incomingNumber - " + incomingNumber );
- fmActionOnCallState(state );
- }
-
- @Override
- public void onDataActivity (int direction) {
- Log.d(LOGTAG, "onDataActivity - " + direction );
- if (direction == TelephonyManager.DATA_ACTIVITY_NONE ||
- direction == TelephonyManager.DATA_ACTIVITY_DORMANT) {
- if (mReceiver != null) {
- Message msg = mDelayedStopHandler.obtainMessage(RESET_NOTCH_FILTER);
- mDelayedStopHandler.sendMessageDelayed(msg, 10000);
- }
- } else {
- if (mReceiver != null) {
- if( true == mNotchFilterSet )
- {
- mDelayedStopHandler.removeMessages(RESET_NOTCH_FILTER);
- }
- else
- {
- mReceiver.setNotchFilter(true);
- mNotchFilterSet = true;
- }
- }
- }
- }
- };
-
-private Handler mSpeakerDisableHandler = new Handler();
-
-private Runnable mSpeakerDisableTask = new Runnable() {
- public void run() {
- Log.v(LOGTAG, "Disabling Speaker");
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
- }
-};
-
- private Handler mDelayedStopHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case FM_STOP:
- // Check again to make sure nothing is playing right now
- if (isFmOn() || mServiceInUse)
- {
- return;
- }
- Log.d(LOGTAG, "mDelayedStopHandler: stopSelf");
- stopSelf(mServiceStartId);
- break;
- case RESET_NOTCH_FILTER:
- if (mReceiver != null) {
- mReceiver.setNotchFilter(false);
- mNotchFilterSet = false;
- }
- break;
- case STOPSERVICE_ONSLEEP:
- fmOff();
- break;
- case STOPRECORD_ONTIMEOUT:
- stopRecording();
- break;
- case FOCUSCHANGE:
- if( false == isFmOn() ) {
- Log.v(LOGTAG, "FM is not running, not handling change");
- return;
- }
- switch (msg.arg1) {
- 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) {
- mSpeakerDisableHandler.removeCallbacks(mSpeakerDisableTask);
- mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
- }
- if (true == mPlaybackInProgress) {
- fmOff();
- }
- mStoppedOnFocusLoss = true;
- break;
- case AudioManager.AUDIOFOCUS_GAIN:
- Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_GAIN");
- if(false == mPlaybackInProgress)
- startFM();
- mStoppedOnFocusLoss = false;
- break;
- case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
- default:
- Log.e(LOGTAG, "Unknown audio focus change code"+msg.arg1);
- }
- break;
- }
- }
- };
-
-
- /**
- * Registers an intent to listen for
- * ACTION_SCREEN_ON/ACTION_SCREEN_OFF notifications. This intent
- * is called to know iwhen the screen is turned on/off.
- */
- public void registerScreenOnOffListener() {
- if (mScreenOnOffReceiver == null) {
- mScreenOnOffReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_SCREEN_ON)) {
- Log.d(LOGTAG, "ACTION_SCREEN_ON Intent received");
- //Screen turned on, set FM module into normal power mode
- mHandler.post(mScreenOnHandler);
- }
- else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
- Log.d(LOGTAG, "ACTION_SCREEN_OFF Intent received");
- //Screen turned on, set FM module into low power mode
- mHandler.post(mScreenOffHandler);
- }
- }
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction(Intent.ACTION_SCREEN_ON);
- iFilter.addAction(Intent.ACTION_SCREEN_OFF);
- registerReceiver(mScreenOnOffReceiver, iFilter);
- }
- }
-
- /* Handle all the Screen On actions:
- Set FM Power mode to Normal
- */
- final Runnable mScreenOnHandler = new Runnable() {
- public void run() {
- setLowPowerMode(false);
- }
- };
- /* Handle all the Screen Off actions:
- Set FM Power mode to Low Power
- This will reduce all the interrupts coming up from the SoC, saving power
- */
- final Runnable mScreenOffHandler = new Runnable() {
- public void run() {
- setLowPowerMode(true);
- }
- };
-
- /* Show the FM Notification */
- public void startNotification() {
- RemoteViews views = new RemoteViews(getPackageName(), R.layout.statusbar);
- views.setImageViewResource(R.id.icon, R.drawable.stat_notify_fm);
- if (isFmOn())
- {
- views.setTextViewText(R.id.frequency, getTunedFrequencyString());
- } else
- {
- views.setTextViewText(R.id.frequency, "");
- }
-
- Notification status = new Notification();
- status.contentView = views;
- status.flags |= Notification.FLAG_ONGOING_EVENT;
- status.icon = R.drawable.stat_notify_fm;
- status.contentIntent = PendingIntent.getActivity(this, 0,
- new Intent("com.codeaurora.fmradio.FMRADIO_ACTIVITY"), 0);
- startForeground(FMRADIOSERVICE_STATUS, status);
- //NotificationManager nm = (NotificationManager)
- // getSystemService(Context.NOTIFICATION_SERVICE);
- //nm.notify(FMRADIOSERVICE_STATUS, status);
- //setForeground(true);
- mFMOn = true;
- }
-
- private void stop() {
- Log.d(LOGTAG,"in stop");
- if (!mServiceInUse) {
- Log.d(LOGTAG,"calling unregisterMediaButtonEventReceiver in stop");
- mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- ComponentName fmRadio = new ComponentName(this.getPackageName(),
- FMMediaButtonIntentReceiver.class.getName());
- mAudioManager.unregisterMediaButtonEventReceiver(fmRadio);
- }
- gotoIdleState();
- mFMOn = false;
- }
-
- private void gotoIdleState() {
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- cancelAlarms();
- setAlarmDelayedServiceStop();
- stopForeground(true);
- }
-
- /** Read's the internal Antenna available state from the FM
- * Device.
- */
- public void readInternalAntennaAvailable()
- {
- mInternalAntennaAvailable = false;
- if (mReceiver != null)
- {
- mInternalAntennaAvailable = mReceiver.getInternalAntenna();
- Log.d(LOGTAG, "getInternalAntenna: " + mInternalAntennaAvailable);
- }
- }
-
- /*
- * By making this a static class with a WeakReference to the Service, we
- * ensure that the Service can be GCd even when the system process still
- * has a remote reference to the stub.
- */
- static class ServiceStub extends IFMRadioService.Stub
- {
- WeakReference<FMRadioService> mService;
-
- ServiceStub(FMRadioService service)
- {
- mService = new WeakReference<FMRadioService>(service);
- }
-
- public boolean fmOn() throws RemoteException
- {
- return(mService.get().fmOn());
- }
-
- public boolean fmOff() throws RemoteException
- {
- return(mService.get().fmOff());
- }
-
- public boolean fmRadioReset() throws RemoteException
- {
- return true;
- }
-
- public boolean isFmOn()
- {
- return(mService.get().isFmOn());
- }
-
- public boolean isAnalogModeEnabled()
- {
- return(mService.get().isAnalogModeEnabled());
- }
-
- public boolean isFmRecordingOn()
- {
- return(mService.get().isFmRecordingOn());
- }
-
- public boolean isSpeakerEnabled()
- {
- return(mService.get().isSpeakerEnabled());
- }
-
- public boolean fmReconfigure()
- {
- return(mService.get().fmReconfigure());
- }
-
- public void registerCallbacks(IFMRadioServiceCallbacks cb) throws RemoteException
- {
- mService.get().registerCallbacks(cb);
- }
-
- public void unregisterCallbacks() throws RemoteException
- {
- mService.get().unregisterCallbacks();
- }
-
- public boolean routeAudio(int device)
- {
- return(mService.get().routeAudio(device));
- }
-
- public boolean mute()
- {
- return(mService.get().mute());
- }
-
- public boolean unMute()
- {
- return(mService.get().unMute());
- }
-
- public boolean isMuted()
- {
- return(mService.get().isMuted());
- }
-
- public void startRecording()
- {
- mService.get().startRecording();
- }
-
- public void stopRecording()
- {
- mService.get().stopRecording();
- }
-
- public boolean tune(int frequency)
- {
- return(mService.get().tune(frequency));
- }
-
- public boolean seek(boolean up)
- {
- return(mService.get().seek(up));
- }
-
- public void enableSpeaker(boolean speakerOn)
- {
- mService.get().enableSpeaker(speakerOn);
- }
-
- public boolean scan(int pty)
- {
- return(mService.get().scan(pty));
- }
-
- public boolean seekPI(int piCode)
- {
- return(mService.get().seekPI(piCode));
- }
- public boolean searchStrongStationList(int numStations)
- {
- return(mService.get().searchStrongStationList(numStations));
- }
-
- public boolean cancelSearch()
- {
- return(mService.get().cancelSearch());
- }
-
- public String getProgramService()
- {
- return(mService.get().getProgramService());
- }
- public String getRadioText()
- {
- return(mService.get().getRadioText());
- }
- public String getExtenRadioText()
- {
- return(mService.get().getExtenRadioText());
- }
- public int getProgramType()
- {
- return(mService.get().getProgramType());
- }
- public int getProgramID()
- {
- return(mService.get().getProgramID());
- }
- public int[] getSearchList()
- {
- return(mService.get().getSearchList());
- }
-
- public boolean setLowPowerMode(boolean enable)
- {
- return(mService.get().setLowPowerMode(enable));
- }
-
- public int getPowerMode()
- {
- return(mService.get().getPowerMode());
- }
- public boolean enableAutoAF(boolean bEnable)
- {
- return(mService.get().enableAutoAF(bEnable));
- }
- public boolean enableStereo(boolean bEnable)
- {
- return(mService.get().enableStereo(bEnable));
- }
- public boolean isAntennaAvailable()
- {
- return(mService.get().isAntennaAvailable());
- }
- public boolean isWiredHeadsetAvailable()
- {
- return(mService.get().isWiredHeadsetAvailable());
- }
- public boolean isCallActive()
- {
- return(mService.get().isCallActive());
- }
- public int getRssi()
- {
- return (mService.get().getRssi());
- }
- public int getIoC()
- {
- return (mService.get().getIoC());
- }
- public int getMpxDcc()
- {
- return (mService.get().getMpxDcc());
- }
- public int getIntDet()
- {
- return (mService.get().getIntDet());
- }
- public void setHiLoInj(int inj)
- {
- mService.get().setHiLoInj(inj);
- }
- public void delayedStop(long duration, int nType)
- {
- mService.get().delayedStop(duration, nType);
- }
- public void cancelDelayedStop(int nType)
- {
- mService.get().cancelDelayedStop(nType);
- }
- public void requestFocus()
- {
- mService.get().requestFocus();
- }
- public int getSINR()
- {
- return (mService.get().getSINR());
- }
- public boolean setSinrSamplesCnt(int samplesCnt)
- {
- return (mService.get().setSinrSamplesCnt(samplesCnt));
- }
- public boolean setSinrTh(int sinr)
- {
- return (mService.get().setSinrTh(sinr));
- }
- public boolean setIntfDetLowTh(int intfLowTh)
- {
- return (mService.get().setIntfDetLowTh(intfLowTh));
- }
- public boolean setIntfDetHighTh(int intfHighTh)
- {
- return (mService.get().setIntfDetHighTh(intfHighTh));
- }
- public int getSearchAlgoType()
- {
- return (mService.get().getSearchAlgoType());
- }
- public boolean setSearchAlgoType(int searchType)
- {
- return (mService.get().setSearchAlgoType(searchType));
- }
- public int getSinrFirstStage()
- {
- return (mService.get().getSinrFirstStage());
- }
- public boolean setSinrFirstStage(int sinr)
- {
- return (mService.get().setSinrFirstStage(sinr));
- }
- public int getRmssiFirstStage()
- {
- return (mService.get().getRmssiFirstStage());
- }
- public boolean setRmssiFirstStage(int rmssi)
- {
- return (mService.get().setRmssiFirstStage(rmssi));
- }
- public int getCFOMeanTh()
- {
- return (mService.get().getCFOMeanTh());
- }
- public boolean setCFOMeanTh(int th)
- {
- return (mService.get().setCFOMeanTh(th));
- }
- public int getSinrSamplesCnt()
- {
- return (mService.get().getSinrSamplesCnt());
- }
- public int getSinrTh()
- {
- return (mService.get().getSinrTh());
- }
- public int getAfJmpRmssiTh()
- {
- return (mService.get().getAfJmpRmssiTh());
- }
- public boolean setAfJmpRmssiTh(int afJmpRmssiTh)
- {
- return (mService.get().setAfJmpRmssiTh(afJmpRmssiTh));
- }
- public int getGoodChRmssiTh()
- {
- return (mService.get().getGoodChRmssiTh());
- }
- public boolean setGoodChRmssiTh(int gdChRmssiTh)
- {
- return (mService.get().setGoodChRmssiTh(gdChRmssiTh));
- }
- public int getAfJmpRmssiSamplesCnt()
- {
- return (mService.get().getAfJmpRmssiSamplesCnt());
- }
- public boolean setAfJmpRmssiSamplesCnt(int afJmpRmssiSmplsCnt)
- {
- return (mService.get().setAfJmpRmssiSamplesCnt(afJmpRmssiSmplsCnt));
- }
- public boolean setRxRepeatCount(int count)
- {
- return (mService.get().setRxRepeatCount(count));
- }
- public long getRecordingStartTime()
- {
- return (mService.get().getRecordingStartTime());
- }
- }
- private final IBinder mBinder = new ServiceStub(this);
-
- private boolean setAudioPath(boolean analogMode) {
-
- if (mReceiver == null) {
- return false;
- }
- if (isAnalogModeEnabled() == analogMode) {
- Log.d(LOGTAG,"Analog Path already is set to "+analogMode);
- return false;
- }
- if (!isAnalogModeSupported()) {
- Log.d(LOGTAG,"Analog Path is not supported ");
- return false;
- }
- if (SystemProperties.getBoolean("hw.fm.digitalpath",false)) {
- return false;
- }
-
- boolean state = mReceiver.setAnalogMode(analogMode);
- if (false == state) {
- Log.d(LOGTAG, "Error in toggling analog/digital path " + analogMode);
- return false;
- }
- misAnalogPathEnabled = analogMode;
- return true;
- }
- /*
- * Turn ON FM: Powers up FM hardware, and initializes the FM module
- * .
- * @return true if fm Enable api was invoked successfully, false if the api failed.
- */
- private boolean fmOn() {
- boolean bStatus=false;
- mWakeLock.acquire(10*1000);
- if ( TelephonyManager.CALL_STATE_IDLE != getCallState() ) {
- return bStatus;
- }
-
- if(mReceiver == null)
- {
- try {
- mReceiver = new FmReceiver(FMRADIO_DEVICE_FD_STRING, fmCallbacks);
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException("FmReceiver service not available!");
- }
- }
-
- if (mReceiver != null)
- {
- if (isFmOn())
- {
- /* FM Is already on,*/
- bStatus = true;
- Log.d(LOGTAG, "mReceiver.already enabled");
- }
- else
- {
- // This sets up the FM radio device
- FmConfig config = FmSharedPreferences.getFMConfiguration();
- Log.d(LOGTAG, "fmOn: RadioBand :"+ config.getRadioBand());
- Log.d(LOGTAG, "fmOn: Emphasis :"+ config.getEmphasis());
- Log.d(LOGTAG, "fmOn: ChSpacing :"+ config.getChSpacing());
- Log.d(LOGTAG, "fmOn: RdsStd :"+ config.getRdsStd());
- Log.d(LOGTAG, "fmOn: LowerLimit :"+ config.getLowerLimit());
- Log.d(LOGTAG, "fmOn: UpperLimit :"+ config.getUpperLimit());
- bStatus = mReceiver.enable(FmSharedPreferences.getFMConfiguration());
- if (isSpeakerEnabled()) {
- setAudioPath(false);
- } else {
- setAudioPath(true);
- }
- Log.d(LOGTAG, "mReceiver.enable done, Status :" + bStatus);
- }
-
- if (bStatus == true)
- {
- /* Put the hardware into normal mode */
- bStatus = setLowPowerMode(false);
- Log.d(LOGTAG, "setLowPowerMode done, Status :" + bStatus);
-
-
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if( (audioManager != null) &&(false == mPlaybackInProgress) )
- {
- Log.d(LOGTAG, "mAudioManager.setFmRadioOn = true \n" );
- //audioManager.setParameters("FMRadioOn="+mAudioDevice);
- int state = getCallState();
- if ( TelephonyManager.CALL_STATE_IDLE != getCallState() )
- {
- fmActionOnCallState(state);
- } else {
- startFM(); // enable FM Audio only when Call is IDLE
- }
- Log.d(LOGTAG, "mAudioManager.setFmRadioOn done \n" );
- }
- if (mReceiver != null) {
- bStatus = mReceiver.registerRdsGroupProcessing(FmReceiver.FM_RX_RDS_GRP_RT_EBL|
- FmReceiver.FM_RX_RDS_GRP_PS_EBL|
- FmReceiver.FM_RX_RDS_GRP_AF_EBL|
- FmReceiver.FM_RX_RDS_GRP_PS_SIMPLE_EBL);
- Log.d(LOGTAG, "registerRdsGroupProcessing done, Status :" + bStatus);
- }
- bStatus = enableAutoAF(FmSharedPreferences.getAutoAFSwitch());
- Log.d(LOGTAG, "enableAutoAF done, Status :" + bStatus);
-
- /* There is no internal Antenna*/
- bStatus = mReceiver.setInternalAntenna(false);
- Log.d(LOGTAG, "setInternalAntenna done, Status :" + bStatus);
-
- /* Read back to verify the internal Antenna mode*/
- readInternalAntennaAvailable();
-
- startNotification();
- bStatus = true;
- }
- else
- {
- mReceiver = null; // as enable failed no need to disable
- // failure of enable can be because handle
- // already open which gets effected if
- // we disable
- stop();
- }
- }
- return(bStatus);
- }
-
- /*
- * Turn OFF FM Operations: This disables all the current FM operations .
- */
- private void fmOperationsOff() {
- if ( mSpeakerPhoneOn)
- {
- mSpeakerPhoneOn = false;
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
- }
- if (isFmRecordingOn())
- {
- stopRecording();
- }
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if(audioManager != null)
- {
- Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" );
- unMute();
- stopFM();
- //audioManager.setParameters("FMRadioOn=false");
- Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" );
- }
-
- sendRecordServiceIntent(RECORD_STOP);
- if (isAnalogModeEnabled()) {
- SystemProperties.set("hw.fm.isAnalog","false");
- misAnalogPathEnabled = false;
- }
- }
-
- /*
- * Reset (OFF) FM Operations: This resets all the current FM operations .
- */
- private void fmOperationsReset() {
- if ( mSpeakerPhoneOn)
- {
- mSpeakerPhoneOn = false;
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
- }
-
- if (isFmRecordingOn())
- {
- stopRecording();
- }
-
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if(audioManager != null)
- {
- Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" );
- unMute();
- resetFM();
- //audioManager.setParameters("FMRadioOn=false");
- Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" );
- }
-
- if (isAnalogModeEnabled()) {
- SystemProperties.set("hw.fm.isAnalog","false");
- misAnalogPathEnabled = false;
- }
- }
-
- /*
- * Turn OFF FM: Disable the FM Host and hardware .
- * .
- * @return true if fm Disable api was invoked successfully, false if the api failed.
- */
- private boolean fmOff() {
- boolean bStatus=false;
-
- fmOperationsOff();
-
- // This will disable the FM radio device
- if (mReceiver != null)
- {
- bStatus = mReceiver.disable();
- mReceiver = null;
- }
- stop();
- return(bStatus);
- }
-
- /*
- * Turn OFF FM: Disable the FM Host when hardware resets asynchronously .
- * .
- * @return true if fm Reset api was invoked successfully, false if the api failed .
- */
- private boolean fmRadioReset() {
- boolean bStatus=false;
-
- Log.v(LOGTAG, "fmRadioReset");
-
- fmOperationsReset();
-
- // This will reset the FM radio receiver
- if (mReceiver != null)
- {
- bStatus = mReceiver.reset();
- mReceiver = null;
- }
- stop();
- return(bStatus);
- }
-
- /* Returns whether FM hardware is ON.
- *
- * @return true if FM was tuned, searching. (at the end of
- * the search FM goes back to tuned).
- *
- */
- public boolean isFmOn() {
- return mFMOn;
- }
-
- /* Returns true if Analog Path is enabled */
- public boolean isAnalogModeEnabled() {
- return misAnalogPathEnabled;
- }
-
- public boolean isAnalogModeSupported() {
- return misAnalogModeSupported;
- }
-
- public boolean isFmRecordingOn() {
- return mFmRecordingOn;
- }
-
- public boolean isSpeakerEnabled() {
- return mSpeakerPhoneOn;
- }
- public boolean isExternalStorageAvailable() {
- boolean mStorageAvail = false;
- String state = Environment.getExternalStorageState();
-
- if(Environment.MEDIA_MOUNTED.equals(state)){
- Log.d(LOGTAG, "device available");
- mStorageAvail = true;
- }
- return mStorageAvail;
- }
- public void enableSpeaker(boolean speakerOn) {
- if(isCallActive())
- return ;
- mSpeakerPhoneOn = speakerOn;
- boolean analogmode = isAnalogModeSupported();
- if (false == speakerOn) {
- if (analogmode) {
- if (isFmRecordingOn())
- stopRecording();
- stopFM();
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
- if (mMuted) {
- setAudioPath(true);
- } else {
- mute();
- setAudioPath(true);
- unMute();
- }
- } else {
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
- }
- if (analogmode)
- startFM();
- }
-
-
- //Need to turn off BT path when Speaker is set on vice versa.
- if( !mA2dpDeviceSupportInHal && !analogmode && true == mA2dpDeviceState.isDeviceAvailable()) {
- if( ((true == mOverA2DP) && (true == speakerOn)) ||
- ((false == mOverA2DP) && (false == speakerOn)) ) {
- //disable A2DP playback for speaker option
- stopFM();
- startFM();
- }
- }
- if (speakerOn) {
- if (analogmode) {
- stopFM();
- if (mMuted) {
- setAudioPath(false);
- } else {
- mute();
- setAudioPath(false);
- unMute();
- }
- }
- AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_SPEAKER);
- if (analogmode)
- startFM();
- }
-
- }
- /*
- * ReConfigure the FM Setup parameters
- * - Band
- * - Channel Spacing (50/100/200 KHz)
- * - Emphasis (50/75)
- * - Frequency limits
- * - RDS/RBDS standard
- *
- * @return true if configure api was invoked successfully, false if the api failed.
- */
- public boolean fmReconfigure() {
- boolean bStatus=false;
- Log.d(LOGTAG, "fmReconfigure");
- if (mReceiver != null)
- {
- // This sets up the FM radio device
- FmConfig config = FmSharedPreferences.getFMConfiguration();
- Log.d(LOGTAG, "RadioBand :"+ config.getRadioBand());
- Log.d(LOGTAG, "Emphasis :"+ config.getEmphasis());
- Log.d(LOGTAG, "ChSpacing :"+ config.getChSpacing());
- Log.d(LOGTAG, "RdsStd :"+ config.getRdsStd());
- Log.d(LOGTAG, "LowerLimit :"+ config.getLowerLimit());
- Log.d(LOGTAG, "UpperLimit :"+ config.getUpperLimit());
- bStatus = mReceiver.configure(config);
- }
- return(bStatus);
- }
-
- /*
- * Register UI/Activity Callbacks
- */
- public void registerCallbacks(IFMRadioServiceCallbacks cb)
- {
- mCallbacks = cb;
- }
-
- /*
- * unRegister UI/Activity Callbacks
- */
- public void unregisterCallbacks()
- {
- mCallbacks=null;
- }
-
- /*
- * Route Audio to headset or speaker phone
- * @return true if routeAudio call succeeded, false if the route call failed.
- */
- public boolean routeAudio(int audioDevice) {
- boolean bStatus=false;
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
-
- //Log.d(LOGTAG, "routeAudio: " + audioDevice);
-
- switch (audioDevice) {
-
- case RADIO_AUDIO_DEVICE_WIRED_HEADSET:
- mAudioDevice = "headset";
- break;
-
- case RADIO_AUDIO_DEVICE_SPEAKER:
- mAudioDevice = "speaker";
- break;
-
- default:
- mAudioDevice = "headset";
- break;
- }
-
- if (mReceiver != null)
- {
- //audioManager.setParameters("FMRadioOn=false");
- //Log.d(LOGTAG, "mAudioManager.setFmRadioOn =" + mAudioDevice );
- //audioManager.setParameters("FMRadioOn="+mAudioDevice);
- //Log.d(LOGTAG, "mAudioManager.setFmRadioOn done \n");
- }
-
- return bStatus;
- }
-
- /*
- * Mute FM Hardware (SoC)
- * @return true if set mute mode api was invoked successfully, false if the api failed.
- */
- public boolean mute() {
- boolean bCommandSent=true;
- if(isMuted())
- return bCommandSent;
- if(isCallActive())
- return false;
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- Log.d(LOGTAG, "mute:");
- if (audioManager != null)
- {
- mMuted = true;
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC,true);
- }
- return bCommandSent;
- }
-
- /*
- * UnMute FM Hardware (SoC)
- * @return true if set mute mode api was invoked successfully, false if the api failed.
- */
- public boolean unMute() {
- boolean bCommandSent=true;
- if(!isMuted())
- return bCommandSent;
- if(isCallActive())
- return false;
- Log.d(LOGTAG, "unMute:");
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if (audioManager != null)
- {
- mMuted = false;
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false);
- if (mResumeAfterCall)
- {
- //We are unmuting FM in a voice call. Need to enable FM audio routing.
- startFM();
- }
- }
- return bCommandSent;
- }
-
- /* Returns whether FM Hardware(Soc) Audio is Muted.
- *
- * @return true if FM Audio is muted, false if not muted.
- *
- */
- public boolean isMuted() {
- return mMuted;
- }
-
- /* Tunes to the specified frequency
- *
- * @return true if Tune command was invoked successfully, false if not muted.
- * Note: Callback FmRxEvRadioTuneStatus will be called when the tune
- * is complete
- */
- public boolean tune(int frequency) {
- boolean bCommandSent=false;
- double doubleFrequency = frequency/1000.00;
-
- Log.d(LOGTAG, "tuneRadio: " + doubleFrequency);
- if (mReceiver != null)
- {
- mReceiver.setStation(frequency);
- bCommandSent = true;
- }
- return bCommandSent;
- }
-
- /* Seeks (Search for strong station) to the station in the direction specified
- * relative to the tuned station.
- * boolean up: true - Search in the forward direction.
- * false - Search in the backward direction.
- * @return true if Seek command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvSearchComplete will be called when the Search
- * is complete
- * 2. Callback FmRxEvRadioTuneStatus will also be called when tuned to a station
- * at the end of the Search or if the seach was cancelled.
- */
- public boolean seek(boolean up)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- if (up == true)
- {
- Log.d(LOGTAG, "seek: Up");
- mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SEEK,
- FmReceiver.FM_RX_DWELL_PERIOD_1S,
- FmReceiver.FM_RX_SEARCHDIR_UP);
- }
- else
- {
- Log.d(LOGTAG, "seek: Down");
- mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SEEK,
- FmReceiver.FM_RX_DWELL_PERIOD_1S,
- FmReceiver.FM_RX_SEARCHDIR_DOWN);
- }
- bCommandSent = true;
- }
- return bCommandSent;
- }
-
- /* Scan (Search for station with a "preview" of "n" seconds)
- * FM Stations. It always scans in the forward direction relative to the
- * current tuned station.
- * int pty: 0 or a reserved PTY value- Perform a "strong" station search of all stations.
- * Valid/Known PTY - perform RDS Scan for that pty.
- *
- * @return true if Scan command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvRadioTuneStatus will be called when tuned to various stations
- * during the Scan.
- * 2. Callback FmRxEvSearchComplete will be called when the Search
- * is complete
- * 3. Callback FmRxEvRadioTuneStatus will also be called when tuned to a station
- * at the end of the Search or if the seach was cancelled.
- *
- */
- public boolean scan(int pty)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "scan: PTY: " + pty);
- if(FmSharedPreferences.isRBDSStd())
- {
- /* RBDS : Validate PTY value?? */
- if( ((pty > 0) && (pty <= 23)) || ((pty >= 29) && (pty <= 31)) )
- {
- bCommandSent = mReceiver.searchStations(FmReceiver.FM_RX_SRCHRDS_MODE_SCAN_PTY,
- FmReceiver.FM_RX_DWELL_PERIOD_2S,
- FmReceiver.FM_RX_SEARCHDIR_UP,
- pty,
- 0);
- }
- else
- {
- bCommandSent = mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SCAN,
- FmReceiver.FM_RX_DWELL_PERIOD_2S,
- FmReceiver.FM_RX_SEARCHDIR_UP);
- }
- }
- else
- {
- /* RDS : Validate PTY value?? */
- if( (pty > 0) && (pty <= 31) )
- {
- bCommandSent = mReceiver.searchStations(FmReceiver.FM_RX_SRCHRDS_MODE_SCAN_PTY,
- FmReceiver.FM_RX_DWELL_PERIOD_2S,
- FmReceiver.FM_RX_SEARCHDIR_UP,
- pty,
- 0);
- }
- else
- {
- bCommandSent = mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SCAN,
- FmReceiver.FM_RX_DWELL_PERIOD_2S,
- FmReceiver.FM_RX_SEARCHDIR_UP);
- }
- }
- }
- return bCommandSent;
- }
-
- /* Search for the 'numStations' number of strong FM Stations.
- *
- * It searches in the forward direction relative to the current tuned station.
- * int numStations: maximum number of stations to search.
- *
- * @return true if Search command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvSearchListComplete will be called when the Search
- * is complete
- * 2. Callback FmRxEvRadioTuneStatus will also be called when tuned to
- * the previously tuned station.
- */
- public boolean searchStrongStationList(int numStations)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "searchStrongStationList: numStations: " + numStations);
- bCommandSent = mReceiver.searchStationList(FmReceiver.FM_RX_SRCHLIST_MODE_STRONG,
- FmReceiver.FM_RX_SEARCHDIR_UP,
- numStations,
- 0);
- }
- return bCommandSent;
- }
-
- /* Search for the FM Station that matches the RDS PI (Program Identifier) code.
- * It always scans in the forward direction relative to the current tuned station.
- * int piCode: PI Code of the station to search.
- *
- * @return true if Search command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvSearchComplete will be called when the Search
- * is complete
- * 2. Callback FmRxEvRadioTuneStatus will also be called when tuned to a station
- * at the end of the Search or if the seach was cancelled.
- */
- public boolean seekPI(int piCode)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "seekPI: piCode: " + piCode);
- bCommandSent = mReceiver.searchStations(FmReceiver.FM_RX_SRCHRDS_MODE_SEEK_PI,
- FmReceiver.FM_RX_DWELL_PERIOD_1S,
- FmReceiver.FM_RX_SEARCHDIR_UP,
- 0,
- piCode
- );
- }
- return bCommandSent;
- }
-
-
- /* Cancel any ongoing Search (Seek/Scan/SearchStationList).
- *
- * @return true if Search command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvSearchComplete will be called when the Search
- * is complete/cancelled.
- * 2. Callback FmRxEvRadioTuneStatus will also be called when tuned to a station
- * at the end of the Search or if the seach was cancelled.
- */
- public boolean cancelSearch()
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "cancelSearch");
- bCommandSent = mReceiver.cancelSearch();
- }
- return bCommandSent;
- }
-
- /* Retrieves the RDS Program Service (PS) String.
- *
- * @return String - RDS PS String.
- * Note: 1. This is a synchronous call that should typically called when
- * Callback FmRxEvRdsPsInfo is invoked.
- * 2. Since PS contains multiple fields, this Service reads all the fields and "caches"
- * the values and provides this helper routine for the Activity to get only the information it needs.
- * 3. The "cached" data fields are always "cleared" when the tune status changes.
- */
- public String getProgramService() {
- String str = "";
- if (mFMRxRDSData != null)
- {
- str = mFMRxRDSData.getPrgmServices();
- if(str == null)
- {
- str= "";
- }
- }
- Log.d(LOGTAG, "Program Service: [" + str + "]");
- return str;
- }
-
- /* Retrieves the RDS Radio Text (RT) String.
- *
- * @return String - RDS RT String.
- * Note: 1. This is a synchronous call that should typically called when
- * Callback FmRxEvRdsRtInfo is invoked.
- * 2. Since RT contains multiple fields, this Service reads all the fields and "caches"
- * the values and provides this helper routine for the Activity to get only the information it needs.
- * 3. The "cached" data fields are always "cleared" when the tune status changes.
- */
- public String getRadioText() {
- String str = "";
- if (mFMRxRDSData != null)
- {
- str = mFMRxRDSData.getRadioText();
- if(str == null)
- {
- str= "";
- }
- }
- Log.d(LOGTAG, "Radio Text: [" + str + "]");
- return str;
- }
-
- public String getExtenRadioText() {
- String str = "";
- if (mFMRxRDSData != null)
- {
- str = mFMRxRDSData.getERadioText();
- if(str == null)
- {
- str= "";
- }
- }
- Log.d(LOGTAG, "eRadio Text:[" + str +"]");
- return str;
- }
- /* Retrieves the RDS Program Type (PTY) code.
- *
- * @return int - RDS PTY code.
- * Note: 1. This is a synchronous call that should typically called when
- * Callback FmRxEvRdsRtInfo and or FmRxEvRdsPsInfo is invoked.
- * 2. Since RT/PS contains multiple fields, this Service reads all the fields and "caches"
- * the values and provides this helper routine for the Activity to get only the information it needs.
- * 3. The "cached" data fields are always "cleared" when the tune status changes.
- */
- public int getProgramType() {
- int pty = -1;
- if (mFMRxRDSData != null)
- {
- pty = mFMRxRDSData.getPrgmType();
- }
- Log.d(LOGTAG, "PTY: [" + pty + "]");
- return pty;
- }
-
- /* Retrieves the RDS Program Identifier (PI).
- *
- * @return int - RDS PI code.
- * Note: 1. This is a synchronous call that should typically called when
- * Callback FmRxEvRdsRtInfo and or FmRxEvRdsPsInfo is invoked.
- * 2. Since RT/PS contains multiple fields, this Service reads all the fields and "caches"
- * the values and provides this helper routine for the Activity to get only the information it needs.
- * 3. The "cached" data fields are always "cleared" when the tune status changes.
- */
- public int getProgramID() {
- int pi = -1;
- if (mFMRxRDSData != null)
- {
- pi = mFMRxRDSData.getPrgmId();
- }
- Log.d(LOGTAG, "PI: [" + pi + "]");
- return pi;
- }
-
-
- /* Retrieves the station list from the SearchStationlist.
- *
- * @return Array of integers that represents the station frequencies.
- * Note: 1. This is a synchronous call that should typically called when
- * Callback onSearchListComplete.
- */
- public int[] getSearchList()
- {
- int[] frequencyList = null;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "getSearchList: ");
- frequencyList = mReceiver.getStationList();
- }
- return frequencyList;
- }
-
- /* Set the FM Power Mode on the FM hardware SoC.
- * Typically used when UI/Activity is in the background, so the Host is interrupted less often.
- *
- * boolean bLowPower: true: Enable Low Power mode on FM hardware.
- * false: Disable Low Power mode on FM hardware. (Put into normal power mode)
- * @return true if set power mode api was invoked successfully, false if the api failed.
- */
- public boolean setLowPowerMode(boolean bLowPower)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "setLowPowerMode: " + bLowPower);
- if(bLowPower)
- {
- bCommandSent = mReceiver.setPowerMode(FmReceiver.FM_RX_LOW_POWER_MODE);
- }
- else
- {
- bCommandSent = mReceiver.setPowerMode(FmReceiver.FM_RX_NORMAL_POWER_MODE);
- }
- }
- return bCommandSent;
- }
-
- /* Get the FM Power Mode on the FM hardware SoC.
- *
- * @return the device power mode.
- */
- public int getPowerMode()
- {
- int powerMode=FmReceiver.FM_RX_NORMAL_POWER_MODE;
- if (mReceiver != null)
- {
- powerMode = mReceiver.getPowerMode();
- Log.d(LOGTAG, "getLowPowerMode: " + powerMode);
- }
- return powerMode;
- }
-
- /* Set the FM module to auto switch to an Alternate Frequency for the
- * station if one the signal strength of that frequency is stronger than the
- * current tuned frequency.
- *
- * boolean bEnable: true: Auto switch to stronger alternate frequency.
- * false: Do not switch to alternate frequency.
- *
- * @return true if set Auto AF mode api was invoked successfully, false if the api failed.
- * Note: Callback FmRxEvRadioTuneStatus will be called when tune
- * is complete to a different frequency.
- */
- public boolean enableAutoAF(boolean bEnable)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "enableAutoAF: " + bEnable);
- bCommandSent = mReceiver.enableAFjump(bEnable);
- }
- return bCommandSent;
- }
-
- /* Set the FM module to Stereo Mode or always force it to Mono Mode.
- * Note: The stereo mode will be available only when the station is broadcasting
- * in Stereo mode.
- *
- * boolean bEnable: true: Enable Stereo Mode.
- * false: Always stay in Mono Mode.
- *
- * @return true if set Stereo mode api was invoked successfully, false if the api failed.
- */
- public boolean enableStereo(boolean bEnable)
- {
- boolean bCommandSent=false;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "enableStereo: " + bEnable);
- bCommandSent = mReceiver.setStereoMode(bEnable);
- }
- return bCommandSent;
- }
-
- /** Determines if an internal Antenna is available.
- * Returns the cached value initialized on FMOn.
- *
- * @return true if internal antenna is available or wired
- * headset is plugged in, false if internal antenna is
- * not available and wired headset is not plugged in.
- */
- public boolean isAntennaAvailable()
- {
- boolean bAvailable = false;
- if ((mInternalAntennaAvailable) || (mHeadsetPlugged) )
- {
- bAvailable = true;
- }
- return bAvailable;
- }
-
- public static long getAvailableSpace() {
- String state = Environment.getExternalStorageState();
- Log.d(LOGTAG, "External storage state=" + state);
- if (Environment.MEDIA_CHECKING.equals(state)) {
- return PREPARING;
- }
- if (!Environment.MEDIA_MOUNTED.equals(state)) {
- return UNAVAILABLE;
- }
-
- try {
- File sampleDir = Environment.getExternalStorageDirectory();
- StatFs stat = new StatFs(sampleDir.getAbsolutePath());
- return stat.getAvailableBlocks() * (long) stat.getBlockSize();
- } catch (Exception e) {
- Log.i(LOGTAG, "Fail to access external storage", e);
- }
- return UNKNOWN_SIZE;
- }
-
- private boolean updateAndShowStorageHint() {
- mStorageSpace = getAvailableSpace();
- return showStorageHint();
- }
-
- private boolean showStorageHint() {
- String errorMessage = null;
- if (mStorageSpace == UNAVAILABLE) {
- errorMessage = getString(R.string.no_storage);
- } else if (mStorageSpace == PREPARING) {
- errorMessage = getString(R.string.preparing_sd);
- } else if (mStorageSpace == UNKNOWN_SIZE) {
- errorMessage = getString(R.string.access_sd_fail);
- } else if (mStorageSpace < LOW_STORAGE_THRESHOLD) {
- errorMessage = getString(R.string.spaceIsLow_content);
- }
-
- if (errorMessage != null) {
- Toast.makeText(this, errorMessage,
- Toast.LENGTH_LONG).show();
- return false;
- }
- return true;
- }
-
- /** Determines if a Wired headset is plugged in. Returns the
- * cached value initialized on broadcast receiver
- * initialization.
- *
- * @return true if wired headset is plugged in, false if wired
- * headset is not plugged in.
- */
- public boolean isWiredHeadsetAvailable()
- {
- return (mHeadsetPlugged);
- }
- public boolean isCallActive()
- {
- //Non-zero: Call state is RINGING or OFFHOOK on the available subscriptions
- //zero: Call state is IDLE on all the available subscriptions
- if(0 != getCallState()) return true;
- return false;
- }
- public int getCallState()
- {
- return mCallStatus;
- }
-
- public void clearStationInfo() {
- if(mFMRxRDSData != null) {
- mFMRxRDSData.setRadioText("");
- mFMRxRDSData.setPrgmId(0);
- mFMRxRDSData.setPrgmType(0);
- mFMRxRDSData.setPrgmServices("");
- mFMRxRDSData.setERadioText("");
- mFMRxRDSData.setTagValue("", 1);
- mFMRxRDSData.setTagValue("", 2);
- mFMRxRDSData.setTagCode((byte)0, 1);
- mFMRxRDSData.setTagCode((byte)0, 2);
- Log.d(LOGTAG, "clear tags data");
- FmSharedPreferences.clearTags();
- }
- }
-
- /* Receiver callbacks back from the FM Stack */
- FmRxEvCallbacksAdaptor fmCallbacks = new FmRxEvCallbacksAdaptor()
- {
- public void FmRxEvEnableReceiver() {
- Log.d(LOGTAG, "FmRxEvEnableReceiver");
- mReceiver.setRawRdsGrpMask();
- }
- public void FmRxEvDisableReceiver()
- {
- Log.d(LOGTAG, "FmRxEvDisableReceiver");
- mFMOn = false;
- FmSharedPreferences.clearTags();
- }
- public void FmRxEvRadioReset()
- {
- Log.d(LOGTAG, "FmRxEvRadioReset");
- if(isFmOn()) {
- // Received radio reset event while FM is ON
- Log.d(LOGTAG, "FM Radio reset");
- fmRadioReset();
- try
- {
- /* Notify the UI/Activity, only if the service is "bound"
- by an activity and if Callbacks are registered
- */
- if((mServiceInUse) && (mCallbacks != null) )
- {
- mCallbacks.onRadioReset();
- }
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
- public void FmRxEvConfigReceiver()
- {
- Log.d(LOGTAG, "FmRxEvConfigReceiver");
- }
- public void FmRxEvMuteModeSet()
- {
- Log.d(LOGTAG, "FmRxEvMuteModeSet");
- }
- public void FmRxEvStereoModeSet()
- {
- Log.d(LOGTAG, "FmRxEvStereoModeSet");
- }
- public void FmRxEvRadioStationSet()
- {
- Log.d(LOGTAG, "FmRxEvRadioStationSet");
- }
- public void FmRxEvPowerModeSet()
- {
- Log.d(LOGTAG, "FmRxEvPowerModeSet");
- }
- public void FmRxEvSetSignalThreshold()
- {
- Log.d(LOGTAG, "FmRxEvSetSignalThreshold");
- }
-
- public void FmRxEvRadioTuneStatus(int frequency)
- {
- Log.d(LOGTAG, "FmRxEvRadioTuneStatus: Tuned Frequency: " +frequency);
- try
- {
- FmSharedPreferences.setTunedFrequency(frequency);
- mPrefs.Save();
- //Log.d(LOGTAG, "Call mCallbacks.onTuneStatusChanged");
- /* Since the Tuned Status changed, clear out the RDSData cached */
- if(mReceiver != null) {
- clearStationInfo();
- }
- if(mCallbacks != null)
- {
- mCallbacks.onTuneStatusChanged();
- }
- /* Update the frequency in the StatusBar's Notification */
- startNotification();
-
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
-
- public void FmRxEvStationParameters()
- {
- Log.d(LOGTAG, "FmRxEvStationParameters");
- }
-
- public void FmRxEvRdsLockStatus(boolean bRDSSupported)
- {
- Log.d(LOGTAG, "FmRxEvRdsLockStatus: " + bRDSSupported);
- try
- {
- if(mCallbacks != null)
- {
- mCallbacks.onStationRDSSupported(bRDSSupported);
- }
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
-
- public void FmRxEvStereoStatus(boolean stereo)
- {
- Log.d(LOGTAG, "FmRxEvStereoStatus: " + stereo);
- try
- {
- if(mCallbacks != null)
- {
- mCallbacks.onAudioUpdate(stereo);
- }
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- public void FmRxEvServiceAvailable(boolean signal)
- {
- Log.d(LOGTAG, "FmRxEvServiceAvailable");
- if(signal) {
- Log.d(LOGTAG, "FmRxEvServiceAvailable: Tuned frequency is above signal threshold level");
- }
- else {
- Log.d(LOGTAG, "FmRxEvServiceAvailable: Tuned frequency is below signal threshold level");
- }
- }
- public void FmRxEvGetSignalThreshold()
- {
- Log.d(LOGTAG, "FmRxEvGetSignalThreshold");
- }
- public void FmRxEvSearchInProgress()
- {
- Log.d(LOGTAG, "FmRxEvSearchInProgress");
- }
- public void FmRxEvSearchRdsInProgress()
- {
- Log.d(LOGTAG, "FmRxEvSearchRdsInProgress");
- }
- public void FmRxEvSearchListInProgress()
- {
- Log.d(LOGTAG, "FmRxEvSearchListInProgress");
- }
- public void FmRxEvSearchComplete(int frequency)
- {
- Log.d(LOGTAG, "FmRxEvSearchComplete: Tuned Frequency: " +frequency);
- try
- {
- FmSharedPreferences.setTunedFrequency(frequency);
- //Log.d(LOGTAG, "Call mCallbacks.onSearchComplete");
- /* Since the Tuned Status changed, clear out the RDSData cached */
- if(mReceiver != null) {
- clearStationInfo();
- }
- if(mCallbacks != null)
- {
- mCallbacks.onSearchComplete();
- }
- /* Update the frequency in the StatusBar's Notification */
- startNotification();
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
-
- public void FmRxEvSearchRdsComplete()
- {
- Log.d(LOGTAG, "FmRxEvSearchRdsComplete");
- }
-
- public void FmRxEvSearchListComplete()
- {
- Log.d(LOGTAG, "FmRxEvSearchListComplete");
- try
- {
- if(mCallbacks != null)
- {
- mCallbacks.onSearchListComplete();
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
-
- public void FmRxEvSearchCancelled()
- {
- Log.d(LOGTAG, "FmRxEvSearchCancelled: Cancelled the on-going search operation.");
- }
- public void FmRxEvRdsGroupData()
- {
- Log.d(LOGTAG, "FmRxEvRdsGroupData");
- }
-
- public void FmRxEvRdsPsInfo() {
- Log.d(LOGTAG, "FmRxEvRdsPsInfo: ");
- try
- {
- if(mReceiver != null)
- {
- mFMRxRDSData = mReceiver.getPSInfo();
- if(mFMRxRDSData != null)
- {
- Log.d(LOGTAG, "PI: [" + mFMRxRDSData.getPrgmId() + "]");
- Log.d(LOGTAG, "PTY: [" + mFMRxRDSData.getPrgmType() + "]");
- Log.d(LOGTAG, "PS: [" + mFMRxRDSData.getPrgmServices() + "]");
- }
- if(mCallbacks != null)
- {
- mCallbacks.onProgramServiceChanged();
- }
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
-
- public void FmRxEvRdsRtInfo() {
- Log.d(LOGTAG, "FmRxEvRdsRtInfo");
- try
- {
- //Log.d(LOGTAG, "Call mCallbacks.onRadioTextChanged");
- if(mReceiver != null)
- {
- mFMRxRDSData = mReceiver.getRTInfo();
- if(mFMRxRDSData != null)
- {
- Log.d(LOGTAG, "PI: [" + mFMRxRDSData.getPrgmId() + "]");
- Log.d(LOGTAG, "PTY: [" + mFMRxRDSData.getPrgmType() + "]");
- Log.d(LOGTAG, "RT: [" + mFMRxRDSData.getRadioText() + "]");
- }
- if(mCallbacks != null)
- {
- mCallbacks.onRadioTextChanged();
- }
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
-
- }
-
- public void FmRxEvRdsAfInfo()
- {
- Log.d(LOGTAG, "FmRxEvRdsAfInfo");
- mReceiver.getAFInfo();
- }
- public void FmRxEvRTPlus()
- {
- int tag_nums;
- Log.d(LOGTAG, "FmRxEvRTPlusInfo");
- if (mReceiver != null) {
- mFMRxRDSData = mReceiver.getRTPlusInfo();
- tag_nums = mFMRxRDSData.getTagNums();
- if (tag_nums >= 1) {
- Log.d(LOGTAG, "tag1 is: " + mFMRxRDSData.getTagCode(1) + "value: "
- + mFMRxRDSData.getTagValue(1));
- FmSharedPreferences.addTags(mFMRxRDSData.getTagCode(1), mFMRxRDSData.getTagValue(1));
- }
- if(tag_nums == 2) {
- Log.d(LOGTAG, "tag2 is: " + mFMRxRDSData.getTagCode(2) + "value: "
- + mFMRxRDSData.getTagValue(2));
- FmSharedPreferences.addTags(mFMRxRDSData.getTagCode(2), mFMRxRDSData.getTagValue(2));
- }
- }
- }
- public void FmRxEvERTInfo()
- {
- Log.d(LOGTAG, "FmRxEvERTInfo");
- try {
- if (mReceiver != null) {
- mFMRxRDSData = mReceiver.getERTInfo();
- if(mCallbacks != null)
- mCallbacks.onExtenRadioTextChanged();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- public void FmRxEvRdsPiMatchAvailable()
- {
- Log.d(LOGTAG, "FmRxEvRdsPiMatchAvailable");
- }
- public void FmRxEvRdsGroupOptionsSet()
- {
- Log.d(LOGTAG, "FmRxEvRdsGroupOptionsSet");
- }
- public void FmRxEvRdsProcRegDone()
- {
- Log.d(LOGTAG, "FmRxEvRdsProcRegDone");
- }
- public void FmRxEvRdsPiMatchRegDone()
- {
- Log.d(LOGTAG, "FmRxEvRdsPiMatchRegDone");
- }
- };
-
-
- /*
- * Read the Tuned Frequency from the FM module.
- */
- private String getTunedFrequencyString() {
-
- double frequency = FmSharedPreferences.getTunedFrequency() / 1000.0;
- String frequencyString = getString(R.string.stat_notif_frequency, (""+frequency));
- return frequencyString;
- }
- public int getRssi() {
- if (mReceiver != null)
- return mReceiver.getRssi();
- else
- return Integer.MAX_VALUE;
- }
- public int getIoC() {
- if (mReceiver != null)
- return mReceiver.getIoverc();
- else
- return Integer.MAX_VALUE;
- }
- public int getIntDet() {
- if (mReceiver != null)
- return mReceiver.getIntDet();
- else
- return Integer.MAX_VALUE;
- }
- public int getMpxDcc() {
- if (mReceiver != null)
- return mReceiver.getMpxDcc();
- else
- return Integer.MAX_VALUE;
- }
- public void setHiLoInj(int inj) {
- if (mReceiver != null)
- mReceiver.setHiLoInj(inj);
- }
- public int getSINR() {
- if (mReceiver != null)
- return mReceiver.getSINR();
- else
- return Integer.MAX_VALUE;
- }
- public boolean setSinrSamplesCnt(int samplesCnt) {
- if(mReceiver != null)
- return mReceiver.setSINRsamples(samplesCnt);
- else
- return false;
- }
- public boolean setSinrTh(int sinr) {
- if(mReceiver != null)
- return mReceiver.setSINRThreshold(sinr);
- else
- return false;
- }
- public boolean setIntfDetLowTh(int intfLowTh) {
- if(mReceiver != null)
- return mReceiver.setOnChannelThreshold(intfLowTh);
- else
- return false;
- }
- public boolean setIntfDetHighTh(int intfHighTh) {
- if(mReceiver != null)
- return mReceiver.setOffChannelThreshold(intfHighTh);
- else
- return false;
- }
- public int getSearchAlgoType() {
- if(mReceiver != null)
- return mReceiver.getSearchAlgoType();
- else
- return -1;
- }
- public boolean setSearchAlgoType(int searchType) {
- if(mReceiver != null)
- return mReceiver.setSearchAlgoType(searchType);
- else
- return false;
- }
- public int getSinrFirstStage() {
- if(mReceiver != null)
- return mReceiver.getSinrFirstStage();
- else
- return Integer.MAX_VALUE;
- }
- public boolean setSinrFirstStage(int sinr) {
- if(mReceiver != null)
- return mReceiver.setSinrFirstStage(sinr);
- else
- return false;
- }
- public int getRmssiFirstStage() {
- if(mReceiver != null)
- return mReceiver.getRmssiFirstStage();
- else
- return Integer.MAX_VALUE;
- }
- public boolean setRmssiFirstStage(int rmssi) {
- if(mReceiver != null)
- return mReceiver.setRmssiFirstStage(rmssi);
- else
- return false;
- }
- public int getCFOMeanTh() {
- if(mReceiver != null)
- return mReceiver.getCFOMeanTh();
- else
- return Integer.MAX_VALUE;
- }
- public boolean setCFOMeanTh(int th) {
- if(mReceiver != null)
- return mReceiver.setCFOMeanTh(th);
- else
- return false;
- }
- public int getSinrSamplesCnt() {
- if(mReceiver != null)
- return mReceiver.getSINRsamples();
- else
- return Integer.MAX_VALUE;
- }
- public int getSinrTh() {
- if(mReceiver != null)
- return mReceiver.getSINRThreshold();
- else
- return Integer.MAX_VALUE;
- }
-
- boolean setAfJmpRmssiTh(int afJmpRmssiTh) {
- if(mReceiver != null)
- return mReceiver.setAFJumpRmssiTh(afJmpRmssiTh);
- else
- return false;
- }
- boolean setGoodChRmssiTh(int gdChRmssiTh) {
- if(mReceiver != null)
- return mReceiver.setGdChRmssiTh(gdChRmssiTh);
- else
- return false;
- }
- boolean setAfJmpRmssiSamplesCnt(int afJmpRmssiSmplsCnt) {
- if(mReceiver != null)
- return mReceiver.setAFJumpRmssiSamples(afJmpRmssiSmplsCnt);
- else
- return false;
- }
- int getAfJmpRmssiTh() {
- if(mReceiver != null)
- return mReceiver.getAFJumpRmssiTh();
- else
- return Integer.MIN_VALUE;
- }
- int getGoodChRmssiTh() {
- if(mReceiver != null)
- return mReceiver.getGdChRmssiTh();
- else
- return Integer.MAX_VALUE;
- }
- int getAfJmpRmssiSamplesCnt() {
- if(mReceiver != null)
- return mReceiver.getAFJumpRmssiSamples();
- else
- return Integer.MIN_VALUE;
- }
- private void setAlarmSleepExpired (long duration) {
- Intent i = new Intent(SLEEP_EXPIRED_ACTION);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- Log.d(LOGTAG, "delayedStop called" + SystemClock.elapsedRealtime() + duration);
- am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + duration, pi);
- }
- private void cancelAlarmSleepExpired() {
- Intent i = new Intent(SLEEP_EXPIRED_ACTION);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- am.cancel(pi);
- }
- private void setAlarmRecordTimeout(long duration) {
- Intent i = new Intent(RECORD_EXPIRED_ACTION);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- Log.d(LOGTAG, "delayedStop called" + SystemClock.elapsedRealtime() + duration);
- am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + duration, pi);
- }
- private void cancelAlarmRecordTimeout() {
- Intent i = new Intent(RECORD_EXPIRED_ACTION);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- am.cancel(pi);
- }
- private void setAlarmDelayedServiceStop() {
- Intent i = new Intent(SERVICE_DELAYED_STOP_ACTION);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + IDLE_DELAY, pi);
- }
- private void cancelAlarmDealyedServiceStop() {
- Intent i = new Intent(SERVICE_DELAYED_STOP_ACTION);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- am.cancel(pi);
- }
- private void cancelAlarms() {
- cancelAlarmSleepExpired();
- cancelAlarmRecordTimeout();
- cancelAlarmDealyedServiceStop();
- }
- public boolean setRxRepeatCount(int count) {
- if(mReceiver != null)
- return mReceiver.setPSRxRepeatCount(count);
- else
- return false;
- }
-
- public long getRecordingStartTime() {
- return mSampleStart;
- }
- //handling the sleep and record stop when FM App not in focus
- private void delayedStop(long duration, int nType) {
- int whatId = (nType == STOP_SERVICE) ? STOPSERVICE_ONSLEEP: STOPRECORD_ONTIMEOUT;
- if (nType == STOP_SERVICE)
- setAlarmSleepExpired(duration);
- else
- setAlarmRecordTimeout(duration);
- }
- private void cancelDelayedStop(int nType) {
- int whatId = (nType == STOP_SERVICE) ? STOPSERVICE_ONSLEEP: STOPRECORD_ONTIMEOUT;
- if (nType == STOP_SERVICE)
- cancelAlarmSleepExpired();
- else
- cancelAlarmRecordTimeout();
- }
- private void requestFocus() {
- if( (false == mPlaybackInProgress) &&
- (true == mStoppedOnFocusLoss) ) {
- // adding code for audio focus gain.
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- audioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
- AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
- startFM();
- mStoppedOnFocusLoss = false;
- }
- }
- private OnAudioFocusChangeListener mAudioFocusListener = new OnAudioFocusChangeListener() {
- public void onAudioFocusChange(int focusChange) {
- mDelayedStopHandler.obtainMessage(FOCUSCHANGE, focusChange, 0).sendToTarget();
- }
- };
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMStats.java b/fmapp/src/com/codeaurora/fmradio/FMStats.java
deleted file mode 100644
index 6d6c516..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMStats.java
+++ /dev/null
@@ -1,2554 +0,0 @@
-/*
- * Copyright (c) 2011-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 android.app.Activity;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Handler;
-import android.os.Message;
-import android.os.RemoteException;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.RadioButton;
-import android.widget.EditText;
-import android.widget.ProgressBar;
-import android.widget.Spinner;
-import android.widget.TableLayout;
-import android.widget.TableRow;
-import android.widget.TextView;
-import android.widget.AdapterView.OnItemSelectedListener;
-import qcom.fmradio.FmReceiver;
-import android.os.SystemProperties;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.view.LayoutInflater;
-import android.content.DialogInterface;
-import android.os.PowerManager;
-import android.os.PowerManager.WakeLock;
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.IntentFilter;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.MenuInflater;
-import android.os.SystemClock;
-
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.util.HashMap;
-import android.os.SystemProperties;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.util.Formatter;
-import java.util.Locale;
-
-public class FMStats extends Activity {
-
- EditText txtbox1;
- Button button1;
- Button button2;
- TextView tv1;
- Button SetButton;
- Button RunButton;
- ProgressBar pbar;
- TableLayout tLayout;
-
- private FmReceiver mReceiver;
-
- TextView bandSweepSettingButton;
-
- /*Data structure for band*/
- private class Band {
- public int lFreq;
- public int hFreq;
- public int Spacing;
- public int cur_freq;
- }
- /* Data structure for Result*/
- private class Result {
-
- private String mFreq;
- private String mRSSI;
- private String mIoC;
- private String mIntDet;
- private String mMpxDcc;
- private String mSINR;
-
-
- public void setFreq(String aFreq) {
- this.mFreq = aFreq;
- }
-
- public String getFreq() {
- return mFreq;
- }
-
- public void setRSSI(String aRSSI) {
- this.mRSSI = aRSSI;
- }
-
- public String getRSSI() {
- return mRSSI;
- }
-
- public void setIoC(String aIoC) {
- this.mIoC = aIoC;
- }
-
- public String getIoC() {
- return mIoC;
- }
-
- public void setIntDet(String aIntDet) {
- this.mIntDet = aIntDet;
- }
-
- public String getIntDet() {
- return mIntDet;
- }
-
- public void setMpxDcc(String aMpxDcc) {
- this.mMpxDcc = aMpxDcc;
- }
-
- public String getMpxDcc() {
- return mMpxDcc;
- }
- public void setSINR(String aSINR) {
- this.mSINR = aSINR;
- }
-
- public String getSINR() {
- return mSINR;
- }
- };
-
- /*constant column header*/
- Result mColumnHeader = new Result();
-
- boolean mTestRunning = false;
- FmRfItemSelectedListener mSpinFmRfListener =
- new FmRfItemSelectedListener();
- RfCfgItemSelectedListener mSpinRfCfgListener =
- new RfCfgItemSelectedListener();
- CfgRfItemSelectedListener1 mSpinCfgRfListener1 = null;
- CfgRfItemSelectedListener2 mSpinCfgRfListener2 = null;
- BandSweepMthdsSelectedListener mSweepMthdsListener =
- new BandSweepMthdsSelectedListener();
-
- int mTestSelected = 0;
- boolean mIsSearching = false;
- private static String LOGTAG = "FMStats";
- private static IFMRadioService mService = null;
- private Thread mMultiUpdateThread = null;
- private static final int STATUS_UPDATE = 1;
- private static final int STATUS_DONE = 2;
- private static final int RECORDTIMER_UPDATE = 3;
- private static final int RECORDTIMER_EXPIRED = 4;
- private static final int STOP_ROW_ID = 200;
- private static final int NEW_ROW_ID = 300;
- private int mStopIds = STOP_ROW_ID;
- private int mNewRowIds = NEW_ROW_ID;
- private static final int SCAN_DWELL_PERIOD = 1;
-
- private static final int CUR_FREQ_TEST = 0;
- private static final int CUR_MULTI_TEST = 1;
- private static final int SEARCH_TEST =2;
- private static final int SWEEP_TEST = 3;
- private Band mBand = null;
- private Band mSync = null;
- int Lo = 1, Auto = 0;
-
- private FileOutputStream mFileCursor = null;
- private String mCurrentFileName = null;
-
- Spinner spinOptionFmRf;
- Spinner spinOptionBandSweepMthds;
- ArrayAdapter<CharSequence> adaptCfgRf;
- ArrayAdapter<CharSequence> adaptRfCfg;
- ArrayAdapter<CharSequence> adaptFmRf;
- ArrayAdapter<CharSequence> bandSweepMthds;
-
- private static boolean mIsTransportSMD = false;
-
- private static final int MPX_DCC = 0;
- private static final int SINR_INTF = 1;
- private static final int MIN_SINR_FIRST_STAGE = -128;
- private static final int MAX_SINR_FIRST_STAGE = 127;
- private static final int MIN_RMSSI_FIRST_STAGE = -128;
- private static final int MAX_RMSSI_FIRST_STAGE = 127;
- private static final int MIN_CF0TH12 = -2147483648;
- private static final int MAX_CF0TH12 = 2147483647;
- private static final int MIN_SINR_TH = -128;
- private static final int MAX_SINR_TH = 127;
- private static final int MIN_SINR_SAMPLES = 0;
- private static final int MAX_SINR_SAMPLES = 255;
- private static final int MIN_AF_JMP_RMSSI_TH = 0;
- private static final int MAX_AF_JMP_RMSSI_TH = 65535;
- private static final int MIN_GD_CH_RMSSI_TH = -128;
- private static final int MAX_GD_CH_RMSSI_TH = 127;
- private static final int MIN_AF_JMP_RMSSI_SAMPLES = 0;
- private static final int MAX_AF_JMP_RMSSI_SAMPLES = 255;
-
- private static final int DIALOG_BAND_SWEEP_SETTING = 1;
-
- private int prevDwellTime = 2; //2secs
- private int prevDelayTime = 0;//0secs
- private int prevSweepMthd = 0; //Manual (using band min, max)
-
- private int curSweepMthd = 0;
-
- private Thread mRecordUpdateHandlerThread = null;
- boolean mRecording = false;
-
-
- private static StringBuilder sFormatBuilder = new StringBuilder();
- private static Formatter sFormatter = new Formatter(sFormatBuilder, Locale
- .getDefault());
- private static final Object[] sTimeArgs = new Object[5];
-
- private final String FREQ_LIST_FILE_NAME = "/freq_list_comma_separated.txt";
- private static final String BAND_SWEEP_START_DELAY_TIMEOUT = "com.codeaurora.fmradio.SWEEP_START_DELAY_EXP";
- private static final String BAND_SWEEP_DWELL_DELAY_TIMEOUT = "com.codeaurora.fmradio.SWEEP_DWELL_DELAY_EXP";
-
- private BroadcastReceiver mBandSweepDelayExprdListener = null;
- private BroadcastReceiver mBandSweepDwellExprdListener = null;
-
- private WakeLock mWakeLock;
-
- private GetNextFreqInterface mNextFreqInterface;
- private CommaSeparatedFreqFileReader mFreqFileReader;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.setContentView(R.layout.fmstats);
-
- spinOptionFmRf = (Spinner)findViewById(R.id.spinner);
- adaptFmRf = ArrayAdapter.createFromResource
- (this, R.array.stats_options
- , android.R.layout.simple_spinner_item);
- adaptFmRf.setDropDownViewResource
- (android.R.layout.simple_spinner_dropdown_item);
- if (spinOptionFmRf != null) {
- spinOptionFmRf.setAdapter(adaptFmRf);
- spinOptionFmRf.setOnItemSelectedListener(mSpinFmRfListener);
- }
-
- bandSweepMthds = ArrayAdapter.createFromResource
- (this, R.array.band_sweep_methods,
- android.R.layout.simple_spinner_item);
-
- checkTransportLayer();
- if (!isTransportLayerSMD()) {
- mSpinCfgRfListener1 = new CfgRfItemSelectedListener1();
- adaptCfgRf = ArrayAdapter.createFromResource(
- this, R.array.cfg_rf1,
- android.R.layout.simple_spinner_item);
- }else {
- mSpinCfgRfListener2 = new CfgRfItemSelectedListener2();
- adaptCfgRf = ArrayAdapter.createFromResource(
- this, R.array.cfg_rf2,
- android.R.layout.simple_spinner_item);
- }
- adaptRfCfg = ArrayAdapter.createFromResource(
- this, R.array.rf_cfg, android.R.layout.simple_spinner_item);
-
- tLayout = (TableLayout) findViewById(R.id.maintable);
-
- if(mReceiver == null)
- mReceiver = new FmReceiver();
-
- long curTime = System.currentTimeMillis();
- mCurrentFileName = "FMStats_".concat(
- Long.toString(curTime).concat(".txt")
- );
- Log.e(LOGTAG,"Filename is " + mCurrentFileName);
- try {
- mFileCursor = openFileOutput(
- mCurrentFileName,
- Context.MODE_PRIVATE);
- if(null != mFileCursor) {
- Log.e(LOGTAG, "location of the file is"+getFilesDir());
- }
- }catch (IOException e) {
- e.printStackTrace();
- Log.e(LOGTAG,"Couldn't create the file to writeLog");
- mCurrentFileName = null;
- }
-
- if (false == bindToService(this, osc)) {
- Log.d(LOGTAG, "onCreate: Failed to Start Service");
- }else {
- Log.d(LOGTAG, "onCreate: Start Service completed successfully");
- }
-
- /*Initialize the column header with
- constant values*/
- mColumnHeader.setFreq("Freq");
- mColumnHeader.setRSSI("RMSSI");
- mColumnHeader.setIoC("IoC");
- mColumnHeader.setSINR("SINR");
- mColumnHeader.setMpxDcc("Offset");
- mColumnHeader.setIntDet("IntDet");
-
- bandSweepSettingButton = (TextView)findViewById(R.id.BandSweepSetting);
- if(bandSweepSettingButton != null) {
- bandSweepSettingButton.setOnClickListener(mClicktBandSweepSettingListener);
- }
-
- PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
- mWakeLock.setReferenceCounted(false);
-
- registerBandSweepDelayExprdListener();
- registerBandSweepDwellExprdListener();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- if(isRecording()) {
- Log.d(LOGTAG, "onStart");
- initiateRecordThread();
- }
- }
-
- @Override
- public void onStop() {
- super.onStop();
- if(isRecording()) {
- try {
- if(null != mRecordUpdateHandlerThread) {
- mRecordUpdateHandlerThread.interrupt();
- }
- }catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void onDestroy() {
-
- stopCurTest();
-
- unRegisterBroadcastReceiver(mBandSweepDelayExprdListener);
- unRegisterBroadcastReceiver(mBandSweepDwellExprdListener);
-
- if(null != mFileCursor ) {
- try {
- mFileCursor.close();
- }catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- unbindFromService(this);
- Log.d(LOGTAG, "onDestroy: unbindFromService completed");
- mReceiver = null;
- mService = null;
- removeDialog(DIALOG_BAND_SWEEP_SETTING);
- mWakeLock.release();
- super.onDestroy();
- }
-
- private View.OnClickListener mOnRunListener = new View.OnClickListener() {
- public void onClick(View v) {
- if(false == mTestRunning) {
- clearPreviousTestResults();
- mTestRunning = true;
- if(mTestSelected == SWEEP_TEST) {
- disableBandSweepSetting();
- }
- runCurrentTest();
- }else {
- mTestRunning = false;
- /*Stop the thread by interrupting it*/
- if(mMultiUpdateThread != null) {
- mMultiUpdateThread.interrupt();
- mMultiUpdateThread = null;
- }
-
- if(SEARCH_TEST == mTestSelected) {
- try {
- mService.cancelSearch();
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- if(mTestSelected == SWEEP_TEST) {
- stopBandSweep();
- sendStatusDoneMsg();
- enableBandSweepSetting();
- }
- }
- }
- };
-
- private void clearPreviousTestResults() {
- TableLayout tl = (TableLayout)findViewById(R.id.maintable);
- if (tl != null) {
- tl.removeAllViewsInLayout();
- }
- mNewRowIds = NEW_ROW_ID;
- }
-
- private void SetButtonState(boolean state) {
- // Get the TableRow
- Button RunButton = (Button)findViewById(R.id.Runbutton);
- ProgressBar pbar = (ProgressBar)findViewById(R.id.progressbar);
- /*Update the state of the button based on
- state*/
- if(state) {
- if(RunButton != null) {
- RunButton.setText(R.string.test_run);
- }
- if(pbar != null) {
- pbar.setVisibility(View.INVISIBLE);
- }
- if(mTestSelected == SWEEP_TEST) {
- enableBandSweepSetting();
- }
- }else {
- if(RunButton != null) {
- RunButton.setText("Stop Test");
- }
- if(pbar != null) {
- pbar.setVisibility(View.VISIBLE);
- }
- }
- }
-
- private void chooseFMRFoption(){
- String[] szTestInformation = getResources().getStringArray(
- R.array.stats_options);
- final StringBuilder szbTestHeader = new StringBuilder();
- szbTestHeader.append("running test:").append
- (szTestInformation[mTestSelected]);
- String szTestHeader = new String(szbTestHeader);
- switch(mTestSelected)
- {
- case 1:
- RunButton = (Button)findViewById(R.id.Runbutton);
- if(RunButton != null) {
- RunButton.setVisibility(View.INVISIBLE);
- }
- pbar = (ProgressBar) findViewById(R.id.progressbar);
- if(pbar != null) {
- pbar.setVisibility(View.INVISIBLE);
- }
- adaptCfgRf.setDropDownViewResource
- (android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptCfgRf);
- if(isTransportLayerSMD())
- spinOptionFmRf.setOnItemSelectedListener
- (mSpinCfgRfListener2);
- else
- spinOptionFmRf.setOnItemSelectedListener
- (mSpinCfgRfListener1);
- break;
- case 2:
- txtbox1 = (EditText)findViewById(R.id.txtbox1);
- tv1 = (TextView)findViewById(R.id.label);
- if(txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if(tv1 != null) {
- tv1.setVisibility(View.INVISIBLE);
- }
- Button SetButton = (Button)findViewById(R.id.Setbutton);
- if(SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- adaptRfCfg.setDropDownViewResource
- (android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptRfCfg);
- spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
- break;
- }
- }
-
- private View.OnClickListener mOnSetRmssitListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rdel = Integer.parseInt(a);
- Log.d(LOGTAG, "Value of RMSSI DELTA is : " + rdel);
- mReceiver.setRmssiDel(rdel);
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format: " + a);
- txtbox1.setText("");
- }catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
- };
-
- private View.OnClickListener mOnSetRxRePeatCount = new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int count = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for mOnSetRxRePeatCount: " + count);
- if((count < 0) ||
- (count > 255))
- return;
- if(mService != null) {
- try {
- mService.setRxRepeatCount(count);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- } catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetSigThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rdel = Integer.parseInt(a);
- Log.d(LOGTAG, "Value of Signal Th. is : " + rdel);
- mReceiver.setSignalThreshold(rdel);
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format: " + a);
- txtbox1.setText("");
- }catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
- };
-
- private View.OnClickListener mOnSetSinrSmplCntListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rdel = Integer.parseInt(a);
- Log.d(LOGTAG, "Value of Sinr Samples count is : " + rdel);
- if(mService != null) {
- try {
- mService.setSinrSamplesCnt(rdel);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format: " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetSinrThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rdel = Integer.parseInt(a);
- Log.d(LOGTAG, "Value of Sinr Th is : " + rdel);
- if(mService != null) {
- try {
- mService.setSinrTh(rdel);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format: " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetIntfLowThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rdel = Integer.parseInt(a);
- Log.d(LOGTAG, "Value of Intf Det Low Th is : " + rdel);
- if(mService != null) {
- try {
- mService.setIntfDetLowTh(rdel);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format: " + a);
- txtbox1.setText("");
- }
- }
- };
- private View.OnClickListener mOnSetIntfHighThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rdel = Integer.parseInt(a);
- Log.d(LOGTAG, "Value of Intf Det Low Th is : " + rdel);
- if(mService != null) {
- try {
- mService.setIntfDetHighTh(rdel);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetSinrFirstStageListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int sinr = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for SINR FIRST STAGE is : " + sinr);
- if((sinr < MIN_SINR_FIRST_STAGE) ||
- (sinr > MAX_SINR_FIRST_STAGE))
- return;
- if(mService != null) {
- try {
- mService.setSinrFirstStage(sinr);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetRmssiFirstStageListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int rmssi = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for RMSSI FIRST STAGE is: " + rmssi);
- if((rmssi < MIN_RMSSI_FIRST_STAGE) ||
- (rmssi > MAX_RMSSI_FIRST_STAGE))
- return;
- if(mService != null) {
- try {
- mService.setRmssiFirstStage(rmssi);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetCFOMeanThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int cf0 = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for CF0TH12 is: " + cf0);
- if((cf0 < MIN_CF0TH12) ||
- (cf0 > MAX_CF0TH12))
- return;
- if(mService != null) {
- try {
- mService.setCFOMeanTh(cf0);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetSearchMPXDCCListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- Log.d(LOGTAG, "Value entered for search is: MPX DCC");
- if(mService != null) {
- try {
- mService.setSearchAlgoType(MPX_DCC);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- };
-
- private View.OnClickListener mOnSetSearchSinrIntfListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- Log.d(LOGTAG, "Value entered for search is: SINR INTF");
- if(mService != null) {
- try {
- mService.setSearchAlgoType(SINR_INTF);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- };
-
- private View.OnClickListener mOnSetAfJmpRmssiThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int th = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for AfJmpRmssiTh is: " + th);
- if((th < MIN_AF_JMP_RMSSI_TH) ||
- (th > MAX_AF_JMP_RMSSI_TH))
- return;
- if(mService != null) {
- try {
- mService.setAfJmpRmssiTh(th);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetGdChRmssiThListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int th = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for Good channel Rmssi Th is: " + th);
- if((th < MIN_GD_CH_RMSSI_TH) ||
- (th > MAX_GD_CH_RMSSI_TH))
- return;
- if(mService != null) {
- try {
- mService.setGoodChRmssiTh(th);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- private View.OnClickListener mOnSetAfJmpRmssiSmplsCntListener =
- new View.OnClickListener() {
- public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int cnt = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for AfJmpRmssiSamples is: " + cnt);
- if((cnt < MIN_AF_JMP_RMSSI_SAMPLES) ||
- (cnt > MAX_AF_JMP_RMSSI_SAMPLES))
- return;
- if(mService != null) {
- try {
- mService.setAfJmpRmssiSamplesCnt(cnt);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
- }
- };
-
- public class CfgRfItemSelectedListener1 implements OnItemSelectedListener {
- public void onItemSelected(
- AdapterView<?> parent, View view, int pos, long id) {
- Log.d("Table","onItemSelected is hit with " + pos);
- txtbox1 = (EditText)findViewById(R.id.txtbox1);
- tv1 = (TextView)findViewById(R.id.label);
- Button SetButton = (Button)findViewById(R.id.Setbutton);
- tLayout.setVisibility(View.INVISIBLE);
- switch(pos)
- {
- case 0:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_rssi);
- tv1.setVisibility(View.VISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_rmmsi_delta);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetRmssitListener);
- }
- break;
- case 1:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_sigth);
- tv1.setVisibility(View.VISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_sigth);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetSigThListener);
- }
- break;
- case 2:
- tLayout.removeAllViewsInLayout();
- mNewRowIds = NEW_ROW_ID;
- tLayout.setVisibility(View.VISIBLE);
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- adaptRfCfg.setDropDownViewResource(
- android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptRfCfg);
- spinOptionFmRf.setOnItemSelectedListener(
- mSpinRfCfgListener);
- break;
- }
- }
-
- public void onNothingSelected(AdapterView<?> parent) {
- // Do Nothing
- }
- }
-
- public class CfgRfItemSelectedListener2 implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent,
- View view, int pos, long id) {
- Log.d("Table","onItemSelected is hit with " + pos);
- int ret = Integer.MAX_VALUE;
- txtbox1 = (EditText) findViewById(R.id.txtbox1);
- tv1 = (TextView) findViewById(R.id.label);
- button1 = (Button)findViewById(R.id.SearchMpxDcc);
- button2 = (Button)findViewById(R.id.SearchSinrInt);
- Button SetButton = (Button)findViewById(R.id.Setbutton);
- tLayout.setVisibility(View.INVISIBLE);
- switch(pos)
- {
- case 0:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_SinrSmplsCnt);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_SinrSmplsCnt);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetSinrSmplCntListener);
- }
- break;
- case 1:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_SinrTh);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_SinrTh);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetSinrThListener);
- }
- break;
- case 2:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_IntfLowTh);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_IntfLowTh);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetIntfLowThListener);
- }
- break;
- case 3:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_IntfHighTh);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_IntfHighTh);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetIntfHighThListener);
- }
- break;
- case 4:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_SinrFirstStage);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_SinrFirstStage);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetSinrFirstStageListener);
- }
- break;
- case 5:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_RmssiFirstStage);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_RmssiFirstStage);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetRmssiFirstStageListener);
- }
- break;
- case 6:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_CF0Th12);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_CF0Th12);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetCFOMeanThListener);
- }
- break;
- case 7:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- if(button1 != null) {
- button1.setText(R.string.search_algo_mpx);
- button1.setVisibility(View.VISIBLE);
- button1.setOnClickListener(mOnSetSearchMPXDCCListener);
- }
- if(button2 != null) {
- button2.setText(R.string.search_algo_sinrint);
- button2.setVisibility(View.VISIBLE);
- button2.setOnClickListener(mOnSetSearchSinrIntfListener);
- }
- break;
- case 8:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null)
- ret = mService.getSinrSamplesCnt();
- Log.d(LOGTAG, "Get Sinr Samples Count: " + ret);
- if((ret >= MIN_SINR_SAMPLES) &&
- (ret <= MAX_SINR_SAMPLES))
- tv1.setText(" " + String.valueOf(ret));
- }catch (RemoteException e) {
- }
- break;
- case 9:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null)
- ret = mService.getSinrTh();
- Log.d(LOGTAG, "Get Sinr Threshold: " + ret);
- if((ret >= MIN_SINR_TH) &&
- (ret <= MAX_SINR_TH))
- tv1.setText(" " + String.valueOf(ret));
- }catch (RemoteException e) {
-
- }
- break;
- case 10:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getSinrFirstStage();
- Log.d(LOGTAG, "Get Sinr First Stage: " + ret);
- if (ret >= MIN_SINR_FIRST_STAGE &&
- ret <= MAX_SINR_FIRST_STAGE)
- tv1.setText(" " + String.valueOf(ret));
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 11:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getRmssiFirstStage();
- Log.d(LOGTAG, "Get Rmssi First Stage: " + ret);
- if (ret >= MIN_RMSSI_FIRST_STAGE &&
- ret <= MAX_RMSSI_FIRST_STAGE)
- tv1.setText(" " + String.valueOf(ret));
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 12:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getCFOMeanTh();
- Log.d(LOGTAG, "Get CF0 Threshold: " + ret);
- if (ret >= MIN_CF0TH12 &&
- ret <= MAX_CF0TH12)
- tv1.setText(" " + String.valueOf(ret));
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 13:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getSearchAlgoType();
- Log.d(LOGTAG, "Search Type: " + ret);
- if (ret == MPX_DCC)
- tv1.setText(R.string.search_algo_mpx);
- else if(ret == SINR_INTF)
- tv1.setText(R.string.search_algo_sinrint);
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 14:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_AfJmpRmssiTh);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_AfJmpRmssiTh);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetAfJmpRmssiThListener);
- }
- break;
- case 15:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_GdChRmssiTh);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_GdChRmssiTh);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetGdChRmssiThListener);
- }
- break;
- case 16:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_AfJmpRmssiSmplsCnt);
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_AfJmpRmssiSmplsCnt);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetAfJmpRmssiSmplsCntListener);
- }
- break;
- case 17:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getAfJmpRmssiTh();
- Log.d(LOGTAG, "Get Af Jmp Rmssi Th: " + ret);
- if ((ret >= MIN_AF_JMP_RMSSI_TH) &&
- (ret <= MAX_AF_JMP_RMSSI_TH))
- tv1.setText(" " + String.valueOf(ret));
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 18:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getGoodChRmssiTh();
- Log.d(LOGTAG, "Get GoodChRmssi Threshold: " + ret);
- if ((ret >= MIN_GD_CH_RMSSI_TH) &&
- (ret <= MAX_GD_CH_RMSSI_TH))
- tv1.setText(" " + String.valueOf(ret));
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 19:
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setText("");
- tv1.setVisibility(View.VISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- try {
- if(mService != null) {
- ret = mService.getAfJmpRmssiSamplesCnt();
- Log.d(LOGTAG, "Get AfJmpRmssiSamples count: " + ret);
- if ((ret >= MIN_AF_JMP_RMSSI_SAMPLES) &&
- (ret <= MAX_AF_JMP_RMSSI_SAMPLES))
- tv1.setText(" " + String.valueOf(ret));
- }
- }catch (RemoteException e) {
-
- }
- break;
- case 20:
- tLayout.removeAllViewsInLayout();
- mNewRowIds = NEW_ROW_ID;
- tLayout.setVisibility(View.VISIBLE);
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- if(button1 != null) {
- button1.setVisibility(View.INVISIBLE);
- }
- if(button2 != null) {
- button2.setVisibility(View.INVISIBLE);
- }
- adaptRfCfg.setDropDownViewResource(
- android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptRfCfg);
- spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
- break;
- case 21:
- if (txtbox1 != null) {
- txtbox1.setText(R.string.type_rd);
- txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
- tv1.setText(R.string.enter_RxRePeatCount);
- tv1.setVisibility(View.VISIBLE);
- }
- if (SetButton != null) {
- SetButton.setText(R.string.set_RxRePeatCount);
- SetButton.setVisibility(View.VISIBLE);
- SetButton.setOnClickListener(mOnSetRxRePeatCount);
- }
- break;
- }
- }
- public void onNothingSelected(AdapterView<?> parent) {
- // Do Nothing
- }
- }
-
- public class RfCfgItemSelectedListener implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent,
- View view, int pos, long id) {
- Log.d("Table","onItemSelected is hit with "+pos);
- tLayout.setVisibility(View.INVISIBLE);
- if (mTestRunning)
- stopCurTest();
- switch(pos)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- mTestSelected = pos;
- tLayout.removeAllViewsInLayout();
- mNewRowIds = NEW_ROW_ID;
- tLayout.setVisibility(View.VISIBLE);
- RunButton = (Button)findViewById(R.id.Runbutton);
- if (RunButton != null) {
- RunButton.setText(R.string.test_run);
- RunButton.setVisibility(View.VISIBLE);
- RunButton.setOnClickListener(mOnRunListener);
- }
- if(mTestSelected == SWEEP_TEST) {
- enableBandSweepSetting();
- }else {
- disableBandSweepSetting();
- }
- break;
- case 4:
- RunButton = (Button)findViewById(R.id.Runbutton);
- if (RunButton != null) {
- RunButton.setVisibility(View.INVISIBLE);
- }
- pbar = (ProgressBar) findViewById(R.id.progressbar);
- if (pbar != null) {
- pbar.setVisibility(View.INVISIBLE);
- }
- adaptCfgRf.setDropDownViewResource(
- android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptCfgRf);
- if(isTransportLayerSMD())
- spinOptionFmRf.setOnItemSelectedListener(mSpinCfgRfListener2);
- else
- spinOptionFmRf.setOnItemSelectedListener(mSpinCfgRfListener1);
- disableBandSweepSetting();
- break;
- }
- }
-
- public void onNothingSelected(AdapterView<?> parent) {
- // Do Nothing
- }
- }
- public class FmRfItemSelectedListener implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- Log.d("Table","onItemSelected is hit with "+pos);
- mTestSelected = pos;
- tLayout.setVisibility(View.INVISIBLE);
- chooseFMRFoption();
- }
- public void onNothingSelected(AdapterView<?> parent) {
- // Do Nothing
- }
- }
- private void checkTransportLayer() {
- String transportLayer = "";
-
- transportLayer = SystemProperties.get("ro.qualcomm.bt.hci_transport");
- if(transportLayer.equals("smd"))
- mIsTransportSMD = true;
- }
- private boolean isTransportLayerSMD() {
- return mIsTransportSMD;
- }
- private void createResult(Result aRes) {
- // Get the TableLayout
- TableLayout tl = (TableLayout) findViewById(R.id.maintable);
- if (tl == null) {
- return;
- }
-
- /* Create a new row to be added. */
- mNewRowIds++;
- TableRow tr2 = new TableRow(getApplicationContext());
- int width = getWindowManager().getDefaultDisplay().getWidth();
- tr2.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- tr2.setId(mNewRowIds);
- /* Create a Button to be the row-content. */
- TextView colFreq = new TextView(getApplicationContext());
- colFreq.setText(aRes.getFreq());
- colFreq.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
- colFreq.setWidth(width/4);
- /* Add Button to row. */
- tr2.addView(colFreq);
-
- TextView colRMSSI = new TextView(getApplicationContext());
- colRMSSI.setText(aRes.getRSSI());
- colRMSSI.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
- colRMSSI.setWidth(width/4);
- tr2.addView(colRMSSI);
-
- TextView colIoC = new TextView(getApplicationContext());
- colIoC.setText(aRes.getIoC());
- colIoC.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
- colIoC.setWidth(width/4);
- tr2.addView(colIoC);
- if(isTransportLayerSMD())
- {
- TextView colSINR = new TextView(getApplicationContext());
- colSINR.setText(aRes.getSINR());
- colSINR.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
- colSINR.setWidth(width/4);
- tr2.addView(colSINR);
- } else
- {
- TextView colMpxDcc = new TextView(getApplicationContext());
- colMpxDcc.setText(aRes.getMpxDcc());
- colMpxDcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
- colMpxDcc.setWidth(width/4);
- tr2.addView(colMpxDcc);
- }
- /* Add row to TableLayout. */
- /* Add row to TableLayout. */
- tl.addView(tr2,new TableLayout.LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- if(null != mFileCursor)
- {
- try {
- StringBuilder tempStr = new StringBuilder();
- tempStr.append(String.format("%10s", aRes.getFreq()));
- tempStr.append(String.format("%10s", aRes.getRSSI()));
- tempStr.append(String.format("%10s", aRes.getIoC()));
- tempStr.append(String.format("%10s", aRes.getIntDet()));
- if(isTransportLayerSMD())
- {
- tempStr.append(String.format("%10s", aRes.getSINR()));
- } else
- {
- tempStr.append(String.format("%10s", aRes.getMpxDcc()));
- }
- tempStr.append("\r\n");
- String testStr = new String(tempStr);
- mFileCursor.write(testStr.getBytes());
- } catch(IOException ioe) {
- ioe.printStackTrace();
- }
- }
- }
-
- private void runCurrentTest() {
- Log.d(LOGTAG, "The test being run is" +mTestSelected);
-
- //get test summary
- String[] szTestInformation = getResources().getStringArray(
- R.array.rf_cfg);
- final StringBuilder szbTestHeader = new StringBuilder();
- szbTestHeader.append("running test:").append(szTestInformation[mTestSelected]);
- szbTestHeader.append("\r\n");
- String szTestHeader = new String(szbTestHeader);
- if(null != mFileCursor ) {
- try {
- mFileCursor.write(szTestHeader.getBytes());
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
- switch(mTestSelected)
- {
- case CUR_FREQ_TEST:
- Log.d(LOGTAG,"Current Freq test is going to run");
- int freq = FmSharedPreferences.getTunedFrequency();
- Result res = GetFMStatsForFreq(freq);
- createResult(mColumnHeader);
- if(res != null)
- createResult(res);
- mTestRunning = false;
- break;
- case CUR_MULTI_TEST:
- /*Set it to ready to Stop*/
- SetButtonState(false);
- createResult(mColumnHeader);
-
- if(mMultiUpdateThread == null) {
- mMultiUpdateThread = new Thread(null, getMultipleResults,
- "MultiResultsThread");
- }
- /* Launch dummy thread to simulate the transfer progress */
- Log.d(LOGTAG, "Thread State: " + mMultiUpdateThread.getState());
- if(mMultiUpdateThread.getState() == Thread.State.TERMINATED) {
- mMultiUpdateThread = new Thread(null, getMultipleResults,
- "MultiResultsThread");
- }
- /* If the thread state is "new" then the thread has not yet started */
- if(mMultiUpdateThread.getState() == Thread.State.NEW) {
- mMultiUpdateThread.start();
- }
- // returns and UI in different thread.
- break;
- case SEARCH_TEST:
- try {
- Log.d(LOGTAG, "start scanning\n");
- if(isTransportLayerSMD()) {
- Log.d(LOGTAG,"Scanning with 0 scan time");
- if (mReceiver != null)
- mIsSearching = mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SCAN,
- SCAN_DWELL_PERIOD, FmReceiver.FM_RX_SEARCHDIR_UP);
- }else {
- mIsSearching = mService.scan(0);
- }
- }catch (RemoteException e) {
- e.printStackTrace();
- }
-
- if(mIsSearching) {
- /*Set it to Ready to Stop*/
- SetButtonState(false);
- createResult(mColumnHeader);
- Log.d(LOGTAG, "Created the results and cancel UI\n");
- }else {
- mTestRunning = false;
- }
- break;
- case SWEEP_TEST:
- int Spacing = FmSharedPreferences.getChSpacing();
- int lowerFreq = FmSharedPreferences.getLowerLimit();
- int higherFreq = FmSharedPreferences.getUpperLimit();
- try {
- Log.d(LOGTAG, "Going to set low side injection\n");
- mService.setHiLoInj(Lo);
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- /* Set it to Ready to stop*/
- SetButtonState(false);
- createResult(mColumnHeader);
- getFMStatsInBand(lowerFreq, higherFreq, Spacing);
- break;
- }
- }
-
- /* Thread processing */
- private Runnable getMultipleResults = new Runnable() {
- public void run() {
- /*Collect the data for the current frequency
- 20 times*/
- int freq = FmSharedPreferences.getTunedFrequency();
-
- for(int i = 0; i < 20; i++) {
- try {
- Thread.sleep(500);
- Message updateUI = new Message();
- updateUI.what = STATUS_UPDATE;
- updateUI.obj = (Object)GetFMStatsForFreq(freq);
- if(updateUI.obj == null)
- break;
- mUIUpdateHandlerHandler.sendMessage(updateUI);
- }catch (InterruptedException e) {
- /*break the loop*/
- break;
- }
- }
- mTestRunning = false;
- Message updateStop = new Message();
- updateStop.what = STATUS_DONE;
- mUIUpdateHandlerHandler.sendMessage(updateStop);
- }
- };
-
- private void getFMStatsInBand(int lFreq, int hFreq, int Spacing) {
- if(null == mBand) {
- mBand = new Band();
- }
- mBand.lFreq = lFreq;
- mBand.hFreq = hFreq;
- mBand.cur_freq = lFreq;
- if(Spacing == 0) {
- mBand.Spacing = 200; // 200KHz
- }else if(Spacing == 1) {
- mBand.Spacing = 100; // 100KHz
- }else {
- mBand.Spacing = 50;
- }
-
- setAlarm(prevDelayTime * 1000, BAND_SWEEP_START_DELAY_TIMEOUT);
- }
-
- /* Thread processing */
- private Runnable getManualSweepResults = new Runnable() {
- public void run() {
- mWakeLock.acquire(10 * 1000);
- if(mBand.cur_freq <= mBand.hFreq) {
- if(!tuneAndUpdateSweepResult(mBand.cur_freq)) {
- sendStatusDoneMsg();
- }
- mBand.cur_freq += mBand.Spacing;
- if(mBand.cur_freq > mBand.hFreq) {
- sendStatusDoneMsg();
- }else {
- setAlarm(prevDwellTime * 1000, BAND_SWEEP_DWELL_DELAY_TIMEOUT);
- }
- }else {
- sendStatusDoneMsg();
- }
- }
- };
-
- private void sendStatusDoneMsg() {
- mTestRunning = false;
- Message updateStop = new Message();
- updateStop.what = STATUS_DONE;
- try {
- Log.d(LOGTAG, "Going to set auto hi-lo injection\n");
- mService.setHiLoInj(Auto);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- if(mUIUpdateHandlerHandler != null) {
- Log.d(LOGTAG, "Sending message to stop test");
- mUIUpdateHandlerHandler.sendMessage(updateStop);
- }
- }
-
- private Runnable getFileSweepResults = new Runnable() {
- public void run() {
- boolean status = true;
- int freq;
-
- mWakeLock.acquire(10 * 1000);
- freq = mNextFreqInterface.getNextFreq();
-
- for(; (status = (!mNextFreqInterface.errorOccured()) & (!Thread.currentThread().isInterrupted()));
- freq = mNextFreqInterface.getNextFreq()) {
- if(validFreq(freq)) {
- if(!tuneAndUpdateSweepResult(freq)) {
- status = false;
- break;
- }else {
- setAlarm(prevDwellTime * 1000, BAND_SWEEP_DWELL_DELAY_TIMEOUT);
- break;
- }
- }
- }
- if(!status) {
- sendStatusDoneMsg();
- mNextFreqInterface.Stop();
- mNextFreqInterface = null;
- }
- }
- };
-
- private boolean validFreq(int freq) {
- if((freq >= mBand.lFreq) &&
- (((freq - mBand.lFreq) / mBand.Spacing) >= 0)) {
- return true;
- }else {
- return false;
- }
- }
-
- private boolean tuneAndUpdateSweepResult(int freq) {
- try {
- if(!mService.tune(freq)) {
- Log.e(LOGTAG, "tune failed");
- return false;
- }
- mSync = new Band();
- synchronized(mSync) {
- mSync.wait(); //wait till notified
- }
- mSync = null;
- Message updateUI = new Message();
- updateUI.what = STATUS_UPDATE;
- updateUI.obj = (Object)GetFMStatsForFreq(freq);
- if(updateUI.obj == null) {
- return false;
- }else {
- mUIUpdateHandlerHandler.sendMessage(updateUI);
- Log.d(LOGTAG,"highFerq is " + mBand.hFreq);
- }
- }catch (RemoteException e) {
- Log.e(LOGTAG, "SweepResults:Tune failed\n");
- return false;
- }catch (InterruptedException e) {
- return false;
- }
- return true;
- }
-
- private Result GetFMStatsForFreq(int freq)
- {
- Result result = new Result();
- Log.d(LOGTAG,"freq is "+freq);
- result.setFreq(Integer.toString(freq));
- byte nRssi = 0;
- int nIoC = 0;
- int dummy = 0;
- int nIntDet = 0;
- int nMpxDcc = 0;
- byte nSINR = 0;
- if((null != mService)) {
- try {
- dummy = mService.getRssi();
- if (dummy != Integer.MAX_VALUE) {
- nRssi = (byte)dummy;
- result.setRSSI(Byte.toString(nRssi));
- } else {
- return null;
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
- try {
- nIoC = mService.getIoC();
- if (nIoC != Integer.MAX_VALUE)
- result.setIoC(Integer.toString(nIoC));
- else
- return null;
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
- if(isTransportLayerSMD()) {
- try {
- dummy = mService.getSINR();
- if (dummy != Integer.MAX_VALUE) {
- nSINR = (byte)dummy;
- result.setSINR(Integer.toString(nSINR));
- } else {
- return null;
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- } else {
- try {
- nMpxDcc = mService.getMpxDcc();
- if (nMpxDcc != Integer.MAX_VALUE)
- result.setMpxDcc(Integer.toString(nMpxDcc));
- else
- return null;
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
-
- try {
- nIntDet = mService.getIntDet();
- if (nIntDet != Integer.MAX_VALUE)
- result.setIntDet(Integer.toString(nIntDet));
- else
- return null;
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- } else {
- return null;
- }
- return result;
- }
-
-
- private Handler mUIUpdateHandlerHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what)
- {
- case STATUS_UPDATE:
- Result myRes = (Result) msg.obj;
- Log.d(LOGTAG,"Status update is" +myRes.mFreq);
- createResult(myRes);
- break;
- case STATUS_DONE:
- SetButtonState(true);
- break;
- case RECORDTIMER_EXPIRED:
- Log.d(LOGTAG, "mUIUpdateHandlerHandler - RECORDTIMER_EXPIRED");
- if(!isRecording()) {
- Log.d(LOGTAG, "Stop Recording");
- stopRecording();
- }
- break;
- case RECORDTIMER_UPDATE:
- Log.d(LOGTAG, "mUIUpdateHandlerHandler - RECORDTIMER_UPDATE");
- updateExpiredRecordTime();
- break;
- }
- }
- };
-
- public static IFMRadioService sService = null;
- private static HashMap<Context, ServiceBinder> sConnectionMap = new HashMap<Context, ServiceBinder>();
-
- public static boolean bindToService(Context context) {
- Log.e(LOGTAG, "bindToService: Context");
- return bindToService(context, null);
- }
-
- public static boolean bindToService(Context context, ServiceConnection callback) {
- Log.e(LOGTAG, "bindToService: Context with serviceconnection callback");
- context.startService(new Intent(context, FMRadioService.class));
- ServiceBinder sb = new ServiceBinder(callback);
- sConnectionMap.put(context, sb);
- return context.bindService((new Intent()).setClass(context,
- FMRadioService.class), sb, 0);
- }
-
- public static void unbindFromService(Context context) {
- ServiceBinder sb = (ServiceBinder) sConnectionMap.remove(context);
- Log.e(LOGTAG, "unbindFromService: Context");
- if (sb == null)
- {
- Log.e(LOGTAG, "Trying to unbind for unknown Context");
- return;
- }
- context.unbindService(sb);
- if (sConnectionMap.isEmpty())
- {
- // presumably there is nobody interested in the service at this point,
- // so don't hang on to the ServiceConnection
- sService = null;
- }
- }
-
- private static class ServiceBinder implements ServiceConnection
- {
- ServiceConnection mCallback;
- ServiceBinder(ServiceConnection callback) {
- mCallback = callback;
- }
-
- public void onServiceConnected(ComponentName className, android.os.IBinder service) {
- sService = IFMRadioService.Stub.asInterface(service);
- if (mCallback != null)
- {
- Log.e(LOGTAG, "onServiceConnected: mCallback");
- mCallback.onServiceConnected(className, service);
- }
- }
-
- public void onServiceDisconnected(ComponentName className) {
- if (mCallback != null)
- {
- mCallback.onServiceDisconnected(className);
- }
- sService = null;
- }
- }
-
-
- private ServiceConnection osc = new ServiceConnection() {
- public void onServiceConnected(ComponentName classname, IBinder obj) {
- mService = IFMRadioService.Stub.asInterface(obj);
- Log.e(LOGTAG, "ServiceConnection: onServiceConnected: ");
- if (mService != null)
- {
- try
- {
- mService.registerCallbacks(mServiceCallbacks);
-
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- if(isRecording()) {
- initiateRecordThread();
- }
- return;
- } else
- {
- Log.e(LOGTAG, "IFMRadioService onServiceConnected failed");
- }
- finish();
- }
- public void onServiceDisconnected(ComponentName classname) {
- }
- };
-
-
- private IFMRadioServiceCallbacks.Stub mServiceCallbacks = new IFMRadioServiceCallbacks.Stub()
- {
- public void onEnabled()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onEnabled :");
- invalidateOptionsMenu();
- }
-
- public void onDisabled()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onDisabled :");
- stopAllOperations();
- }
-
- public void onRadioReset()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRadioReset :");
- stopAllOperations();
- }
-
- public void onTuneStatusChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onTuneStatusChanged :");
- if (mTestRunning)
- mHandler.post(mTuneComplete);
- }
-
- public void onProgramServiceChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onProgramServiceChanged :");
- }
-
- public void onRadioTextChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRadioTextChanged :");
- }
- public void onExtenRadioTextChanged()
- {
- Log.d(LOGTAG, "Extended Radio Text changed:");
- }
- public void onAlternateFrequencyChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onAlternateFrequencyChanged :");
- }
-
- public void onSignalStrengthChanged()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onSignalStrengthChanged :");
- }
-
- public void onSearchComplete()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onSearchComplete :");
- /*Stop the update*/
- mTestRunning = false;
- Message updateStop = new Message();
- updateStop.what = STATUS_DONE;
- mUIUpdateHandlerHandler.sendMessage(updateStop);
- }
- public void onSearchListComplete()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onSearchListComplete :");
-
- }
-
- public void onMute(boolean bMuted)
- {
- Log.d(LOGTAG, "mServiceCallbacks.onMute :" + bMuted);
- }
-
- public void onAudioUpdate(boolean bStereo)
- {
- Log.d(LOGTAG, "mServiceCallbacks.onAudioUpdate :" + bStereo);
- }
-
- public void onStationRDSSupported(boolean bRDSSupported)
- {
- Log.d(LOGTAG, "mServiceCallbacks.onStationRDSSupported :" + bRDSSupported);
- }
- public void onRecordingStopped()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onDisabled :");
- stopRecording();
- }
- public void onFinishActivity()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onFinishActivity:");
- }
- public void onRecordingStarted()
- {
- Log.d(LOGTAG, "mServiceCallbacks.onRecordingStarted:");
- int durationInMins = FmSharedPreferences.getRecordDuration();
- Log.e(LOGTAG, " Fected duration: " + durationInMins);
- initiateRecordDurationTimer(durationInMins);
- invalidateOptionsMenu();
- }
- };
- /* Radio Vars */
- final Handler mHandler = new Handler();
-
- final Runnable mTuneComplete = new Runnable(){
- public void run(){
- if((null != mMultiUpdateThread) &&(null != mSync))
- {
- synchronized(mSync){
- mSync.notify();
- }
- }
- if((mTestSelected == SEARCH_TEST) && (mService != null)) {
- /* On every Tune Complete generate the result for the current
- Frequency*/
- Message updateUI = new Message();
- updateUI.what = STATUS_UPDATE;
- int freq = FmSharedPreferences.getTunedFrequency();
- updateUI.obj = (Object)GetFMStatsForFreq(freq);
- if (updateUI.obj == null)
- updateUI.what = STATUS_DONE;
- mUIUpdateHandlerHandler.sendMessage(updateUI);
- }
- }
- };
-
- private void stopCurTest() {
- if (mTestRunning) {
- switch(mTestSelected) {
- case CUR_FREQ_TEST:
- break;
- case SWEEP_TEST:
- stopBandSweep();
- sendStatusDoneMsg();
- break;
- case CUR_MULTI_TEST:
- if (mMultiUpdateThread != null)
- mMultiUpdateThread.interrupt();
- break;
- case SEARCH_TEST:
- mHandler.removeCallbacks(mTuneComplete);
- if (mService != null) {
- try {
- Message updateStop = new Message();
- updateStop.what = STATUS_DONE;
- mUIUpdateHandlerHandler.sendMessage(updateStop);
- mService.cancelSearch();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- break;
- }
- mTestRunning = false;
- }
- }
-
- @Override
- protected Dialog onCreateDialog(int id) {
- AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
- switch(id)
- {
- case DIALOG_BAND_SWEEP_SETTING:
- return createBandSweepDialog(id, dlgBuilder);
- }
- return null;
- }
-
- private Dialog createBandSweepDialog(int id, AlertDialog.Builder dlgBuilder) {
- LayoutInflater inflater = LayoutInflater.from(this);
- final View listview = inflater.inflate(R.layout.band_sweep_setting, null);
- spinOptionBandSweepMthds = (Spinner)listview.findViewById(R.id.band_sweep_spinner);
- final EditText delayBox = (EditText)listview.findViewById(R.id.txtboxDelayTime);
- final EditText dwellBox = (EditText)listview.findViewById(R.id.txtboxDwellTime);
-
- if(delayBox != null) {
- delayBox.setText("" + prevDelayTime);
- }
- if(dwellBox != null) {
- dwellBox.setText("" + prevDwellTime);
- }
- if(spinOptionBandSweepMthds != null) {
- spinOptionBandSweepMthds.setAdapter(bandSweepMthds);
- spinOptionBandSweepMthds.setOnItemSelectedListener(mSweepMthdsListener);
- spinOptionBandSweepMthds.setSelection(prevSweepMthd);
- }else {
- Log.e(LOGTAG, "could not find spinner for methods\n");
- }
- dlgBuilder.setView(listview)
- .setPositiveButton(R.string.band_sweep_setting_set, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- prevSweepMthd = curSweepMthd;
- if(delayBox != null) {
- String s = delayBox.getText().toString();
- prevDelayTime = Integer.parseInt(s);
- }
- if(dwellBox != null) {
- String s = dwellBox.getText().toString();
- prevDwellTime = Integer.parseInt(s);
- }
- removeDialog(DIALOG_BAND_SWEEP_SETTING);
- }
- })
- .setNegativeButton(R.string.band_sweep_setting_cancel, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- removeDialog(DIALOG_BAND_SWEEP_SETTING);
- }
- });
- return dlgBuilder.create();
- }
-
- private View.OnClickListener mClicktBandSweepSettingListener = new View.OnClickListener() {
- public void onClick(View v) {
- showDialog(DIALOG_BAND_SWEEP_SETTING);
- }
- };
-
- private void enableBandSweepSetting() {
- if(bandSweepSettingButton != null) {
- bandSweepSettingButton.setEnabled(true);
- bandSweepSettingButton.setVisibility(View.VISIBLE);
- }
- }
-
- private void disableBandSweepSetting() {
- if(bandSweepSettingButton != null) {
- bandSweepSettingButton.setEnabled(false);
- bandSweepSettingButton.setVisibility(View.INVISIBLE);
- }
- }
-
- public class BandSweepMthdsSelectedListener implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- Log.d("Band Sweep Methods","onItemSelected is hit with " + pos);
- curSweepMthd = pos;
- }
-
- public void onNothingSelected(AdapterView<?> parent) {
- // Do Nothing
- }
- }
-
- private void registerBandSweepDelayExprdListener() {
- if(mBandSweepDelayExprdListener == null) {
- mBandSweepDelayExprdListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "Received Band sweep delay expired");
- mWakeLock.acquire(5 * 1000);
- StartBandSweep();
- }
- };
- IntentFilter intentFilter = new IntentFilter(BAND_SWEEP_START_DELAY_TIMEOUT);
- registerReceiver(mBandSweepDelayExprdListener, intentFilter);
- }
- }
-
- private void registerBandSweepDwellExprdListener() {
- if(mBandSweepDwellExprdListener == null) {
- mBandSweepDwellExprdListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(LOGTAG, "received Band sweep Dwell expired");
- mWakeLock.acquire(5 * 1000);
- ResumeBandSweep();
- }
- };
- IntentFilter intentFilter = new IntentFilter(BAND_SWEEP_DWELL_DELAY_TIMEOUT);
- registerReceiver(mBandSweepDwellExprdListener, intentFilter);
- }
- }
-
- private void unRegisterBroadcastReceiver(BroadcastReceiver receiver) {
- if(receiver != null) {
- unregisterReceiver(receiver);
- receiver = null;
- }
- }
-
- private void setAlarm(long duration, String action) {
- Intent i = new Intent(action);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + duration, pi);
- }
-
- private void cancelAlarm(String action) {
- Intent i = new Intent(action);
- AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
- am.cancel(pi);
- }
-
- private void StartBandSweep() {
- if(mMultiUpdateThread == null ||
- (mMultiUpdateThread.getState() == Thread.State.TERMINATED)) {
- if(prevSweepMthd == 0) {
- mMultiUpdateThread = new Thread(null, getManualSweepResults,
- "MultiResultsThread");
- }else {
- mNextFreqInterface = new CommaSeparatedFreqFileReader(getFilesDir() + FREQ_LIST_FILE_NAME);
- mMultiUpdateThread = new Thread(null, getFileSweepResults,
- "MultiResultsThread");
- }
- }
-
- /* If the thread state is "new" then the thread has not yet started */
- if(mMultiUpdateThread.getState() == Thread.State.NEW) {
- mMultiUpdateThread.start();
- }
- }
-
- private void ResumeBandSweep() {
- if(mMultiUpdateThread == null ||
- (mMultiUpdateThread.getState() == Thread.State.TERMINATED)) {
- if(prevSweepMthd == 0) {
- mMultiUpdateThread = new Thread(null, getManualSweepResults,
- "MultiResultsThread");
- }else {
- mMultiUpdateThread = new Thread(null, getFileSweepResults,
- "MultiResultsThread");
- }
- }
-
- /* If the thread state is "new" then the thread has not yet started */
- if(mMultiUpdateThread.getState() == Thread.State.NEW) {
- mMultiUpdateThread.start();
- }
- }
-
- private void stopBandSweep() {
- cancelAlarm(BAND_SWEEP_START_DELAY_TIMEOUT);
- cancelAlarm(BAND_SWEEP_DWELL_DELAY_TIMEOUT);
- if(mMultiUpdateThread != null) {
- mMultiUpdateThread.interrupt();
- }
- if(mNextFreqInterface != null) {
- mNextFreqInterface.Stop();
- mNextFreqInterface = null;
- }
- }
-
- public boolean isRecording() {
- if(mService == null)
- return false;
- try {
- return mService.isFmRecordingOn();
- }catch(RemoteException e) {
- return false;
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu_rf_stats, menu);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
- MenuItem item;
-
- item = menu.findItem(R.id.menu_recording);
- if(item != null && !isRecording()) {
- item.setTitle(R.string.menu_record_start);
- item.setEnabled(isFmOn());
- }else if(item != null) {
- item.setTitle(R.string.menu_record_stop);
- setRecordDurationDisplay(menu, R.id.menu_record_duration);
- }
- return true;
- }
-
- private void setRecordDurationDisplay(Menu menu, int id) {
- MenuItem item;
- long timeNow;
- long seconds;
-
- if(menu == null)
- return;
- item = menu.findItem(id);
- if(item != null) {
- timeNow = SystemClock.elapsedRealtime();
- seconds = (timeNow - getRecordingStartTime()) / 1000;
- item.setTitle(makeTimeString(seconds));
- }
- }
-
- private void startRecording() {
- if(isFmOn()) {
- try {
- mService.startRecording();
- }catch(RemoteException e) {
- e.printStackTrace();
- }
- }
- }
-
- private void stopRecording() {
- if(null != mRecordUpdateHandlerThread) {
- mRecordUpdateHandlerThread.interrupt();
- }
- if(mService != null) {
- try {
- mService.stopRecording();
- }catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- invalidateOptionsMenu();
- }
-
- private long getRecordingStartTime() {
- if(mService == null)
- return 0;
- try {
- return mService.getRecordingStartTime();
- }catch(RemoteException e) {
- return 0;
- }
- }
-
- private void initiateRecordDurationTimer(long mins ) {
- Log.d(LOGTAG, "Stop Recording in mins : " + mins);
- initiateRecordThread();
- }
-
- private void initiateRecordThread() {
- if(mRecordUpdateHandlerThread == null) {
- mRecordUpdateHandlerThread = new Thread(null, doRecordProcessing,
- "RecordUpdateThread");
- }
- /* Launch the dummy thread to simulate the transfer progress */
- Log.d(LOGTAG, "Thread State: " + mRecordUpdateHandlerThread.getState());
- if(mRecordUpdateHandlerThread.getState() == Thread.State.TERMINATED) {
- mRecordUpdateHandlerThread = new Thread(null, doRecordProcessing,
- "RecordUpdateThread");
- }
- /* If the thread state is "new" then the thread has not yet started */
- if(mRecordUpdateHandlerThread.getState() == Thread.State.NEW) {
- mRecordUpdateHandlerThread.start();
- }
- }
-
- /* Recorder Thread processing */
- private Runnable doRecordProcessing = new Runnable() {
- public void run() {
- while(isRecording() &&
- (!Thread.currentThread().isInterrupted())) {
- try {
- Thread.sleep(500);
- Message statusUpdate = new Message();
- statusUpdate.what = RECORDTIMER_UPDATE;
- mUIUpdateHandlerHandler.sendMessage(statusUpdate);
- }catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- if(!isRecording()) {
- Message finished = new Message();
- finished.what = RECORDTIMER_EXPIRED;
- mUIUpdateHandlerHandler.sendMessage(finished);
- }
- }
- }
- };
-
- private void updateExpiredRecordTime() {
- int vis = View.VISIBLE;
- if(isRecording()) {
- invalidateOptionsMenu();
- }
- }
-
- private String makeTimeString(long secs) {
- String durationformat = getString(R.string.durationformat);
-
- /** Provide multiple arguments so the format can be changed easily by
- * modifying the xml.
- **/
- sFormatBuilder.setLength(0);
-
- final Object[] timeArgs = sTimeArgs;
- timeArgs[0] = secs / 3600;
- timeArgs[1] = secs / 60;
- timeArgs[2] = (secs / 60) % 60;
- timeArgs[3] = secs;
- timeArgs[4] = secs % 60;
-
- return sFormatter.format(durationformat, timeArgs).toString();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch(item.getItemId())
- {
- case R.id.menu_recording:
- if(isRecording()) {
- stopRecording();
- }else {
- startRecording();
- }
- break;
- }
- return true;
- }
-
- private boolean isFmOn() {
- boolean status = false;
-
- if(mService != null) {
- try {
- status = mService.isFmOn();
- }catch(RemoteException e) {
- }
- }
- return status;
- }
-
- private void stopAllOperations() {
- stopCurTest();
- stopRecording();
- }
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java b/fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java
deleted file mode 100644
index f21ed00..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java
+++ /dev/null
@@ -1,1477 +0,0 @@
-/*
- * 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 android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.BroadcastReceiver;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.media.AudioManager;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageButton;
-import android.widget.ImageView; //import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-import android.text.TextUtils; //import android.app.ProgressDialog;
-
-import java.lang.ref.WeakReference; //import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.ArrayList;
-
-import com.codeaurora.utils.FrequencyPicker;
-import com.codeaurora.utils.FrequencyPickerDialog;
-import android.content.ServiceConnection;
-
-import qcom.fmradio.FmConfig;
-import android.os.ServiceManager;
-
-public class FMTransmitterActivity extends Activity {
- public static final String LOGTAG = "FMTransmitterActivity";
-
- /* menu Identifiers */
- private static final int MENU_SCAN_START = Menu.FIRST + 1;
- private static final int MENU_SCAN_STOP = Menu.FIRST + 2;
- private static final int MENU_SETTINGS = Menu.FIRST + 3;
-
- /* Dialog Identifiers */
- private static final int DIALOG_PRESET_LIST_AUTO_SET = 1;
- private static final int DIALOG_PICK_FREQUENCY = 2;
- private static final int DIALOG_PRESET_OPTIONS = 3;
- private static final int DIALOG_PROGRESS_PROGRESS = 5;
- private static final int DIALOG_CMD_FAILED_HDMI_ON = 14;
- /* Activity Return ResultIdentifiers */
- private static final int ACTIVITY_RESULT_SETTINGS = 1;
-
- private static final int MAX_PRESETS = 6;
- private static IFMTransmitterService mService = null;
- private static FmSharedPreferences mPrefs;
-
- /* Button Resources */
- private ImageButton mOnOffButton;
- /* 6 Preset Buttons */
- private Button[] mPresetButtons = { null, null, null, null, null, null };
- private int[] mPresetFrequencies = { 0, 0, 0, 0, 0, 0 };
- // private ImageButton mSearchButton;
- private ImageView mForwardButton;
- private ImageView mBackButton;
-
- /* row in the station info layout */
- private TextView mTransmitStaticMsgTV;
- private TextView mTuneStationFrequencyTV;
-
- /* Bottom row in the station info layout */
- private TextView mRadioTextTV;
-
- /* Current Status Indicators */
- private static boolean mIsSearching = false;
- private static boolean mSearchingResultStatus = false;
-
-
- private boolean mInternalAntennaAvailable = false;
-
- private Animation mAnimation = null;
- private ScrollerText mRadioTextScroller = null;
-
- private static int mTunedFrequency = 0;;
- private int mPresetButtonIndex = -1;
- private String mMetaData = null;
- private String mPSData = null;
-
- /* Radio Vars */
- final Handler mHandler = new Handler();
- private final Handler enableRadioHandler = new Handler();
- private final Handler disableRadioHandler = new Handler();
-
- /* Search Progress Dialog */
- private ProgressDialog mProgressDialog = null;
-
- private LoadedDataAndState SavedDataAndState = null;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- mPrefs = new FmSharedPreferences(this);
- Log.d(LOGTAG, "onCreate - Height : "
- + getWindowManager().getDefaultDisplay().getHeight()
- + " - Width : "
- + getWindowManager().getDefaultDisplay().getWidth());
- setContentView(R.layout.fmtransmitter);
- SavedDataAndState = (LoadedDataAndState)getLastNonConfigurationInstance();
- mAnimation = AnimationUtils.loadAnimation(this, R.anim.preset_select);
-
- mOnOffButton = (ImageButton) findViewById(R.id.btn_onoff);
- if (mOnOffButton != null) {
- mOnOffButton.setOnClickListener(mTurnOnOffClickListener);
- }
-
- mForwardButton = (ImageView) findViewById(R.id.btn_forward);
- if (mForwardButton != null) {
- mForwardButton.setOnClickListener(mForwardClickListener);
- }
-
- mBackButton = (ImageView) findViewById(R.id.btn_back);
- if (mBackButton != null) {
- mBackButton.setOnClickListener(mBackClickListener);
- }
-
- /* Preset Buttons */
- mPresetButtons[0] = (Button) findViewById(R.id.presets_button_1);
- mPresetButtons[1] = (Button) findViewById(R.id.presets_button_2);
- mPresetButtons[2] = (Button) findViewById(R.id.presets_button_3);
- mPresetButtons[3] = (Button) findViewById(R.id.presets_button_4);
- mPresetButtons[4] = (Button) findViewById(R.id.presets_button_5);
- mPresetButtons[5] = (Button) findViewById(R.id.presets_button_6);
- for (int nButton = 0; nButton < MAX_PRESETS; nButton++) {
- if (mPresetButtons[nButton] != null) {
- mPresetButtons[nButton]
- .setOnClickListener(mPresetButtonClickListener);
- mPresetButtons[nButton]
- .setOnLongClickListener(mPresetButtonOnLongClickListener);
- }
- }
-
- mTransmitStaticMsgTV = (TextView) findViewById(R.id.transmit_msg_tv);
- String str = getString(R.string.transmit_msg_string);
- if(null != mPSData ) {
- str = mPSData.concat("\n").concat(str);
- }
- if (mTransmitStaticMsgTV != null) {
- mTransmitStaticMsgTV.setText(str);
- }
-
- mTuneStationFrequencyTV = (TextView) findViewById(R.id.prog_frequency_tv);
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV
- .setOnLongClickListener(mFrequencyViewClickListener);
- }
-
- mRadioTextTV = (TextView) findViewById(R.id.radio_text_tv);
-
- if ((mRadioTextScroller == null) && (mRadioTextTV != null)) {
- mRadioTextScroller = new ScrollerText(mRadioTextTV);
- }
-
- enableRadioOnOffUI(false);
- //HDMI and FM concurrecny is not supported.
- if (isHdmiOn())
- {
- showDialog(DIALOG_CMD_FAILED_HDMI_ON);
- }
- else {
- if (false == bindToService(this, osc))
- {
- Log.d(LOGTAG, "onCreate: Failed to Start Service");
- } else
- {
- Log.d(LOGTAG, "onCreate: Start Service completed successfully");
- }
- }
- }
-
- @Override
- public void onRestart() {
- Log.d(LOGTAG, "onRestart");
- super.onRestart();
- }
-
- @Override
- public void onStop() {
- Log.d(LOGTAG, "onStop");
- super.onStop();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- Log.d(LOGTAG, "onStart");
- try {
- if (mService != null) {
- mService.registerCallbacks(mServiceCallbacks);
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mRadioTextScroller.stopScroll();
- SavePreferences();
- }
-
- private static final String TX_PREF_LAST_TUNED_FREQUENCY = "last_tx_frequency";
- private static final String TX_PRESET_FREQUENCY = "tx_preset_freq_";
- private static final int DEFAULT_NO_FREQUENCY = 98100;
-
- public void SavePreferences() {
- Log.d(LOGTAG, "Save preferences ");
- SharedPreferences sp = getPreferences(Context.MODE_PRIVATE);
- SharedPreferences.Editor ed = sp.edit();
-
- ed.putInt(TX_PREF_LAST_TUNED_FREQUENCY, mTunedFrequency);
-
- for (int presetIndex = 0; presetIndex < MAX_PRESETS; presetIndex++) {
- ed.putInt(TX_PRESET_FREQUENCY + presetIndex,
- mPresetFrequencies[presetIndex]);
- }
- ed.commit();
- }
-
- public void LoadPreferences() {
- SharedPreferences sp = getPreferences(Context.MODE_PRIVATE);
- mTunedFrequency = sp.getInt(TX_PREF_LAST_TUNED_FREQUENCY, DEFAULT_NO_FREQUENCY);
- for (int presetIndex = 0; presetIndex < MAX_PRESETS; presetIndex++) {
- mPresetFrequencies[presetIndex] =
- sp.getInt(TX_PRESET_FREQUENCY + presetIndex, DEFAULT_NO_FREQUENCY);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- LoadPreferences();
- try {
- if((null != mService )&&mService.isFmOn()) {
- mHandler.post(mUpdateRadioText);
- }
- } catch(RemoteException ex){
- Log.d(LOGTAG,"expection for service");
- }
- mHandler.post(mUpdateRadioText);
- updateStationInfoToUI();
- enableRadioOnOffUI();
- }
-
- @Override
- public void onDestroy() {
- unbindFromService(this);
- mService = null;
-
- Log.d(LOGTAG, "onDestroy: unbindFromService completed");
- super.onDestroy();
- }
-
- private class LoadedDataAndState {
- public LoadedDataAndState(){};
- public boolean onOrOff;
- }
-
- @Override
- public Object onRetainNonConfigurationInstance() {
- final LoadedDataAndState data = new LoadedDataAndState();
- if(mService != null) {
- try {
- data.onOrOff = mService.isFmOn();
- } catch(RemoteException e) {
- data.onOrOff = false;
- e.printStackTrace();
- }
- } else {
- data.onOrOff = false;
- }
- return data;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuItem item;
- boolean radioOn = isFmOn();
- boolean searchActive = isSearchActive();
-
- item = menu.add(0, MENU_SCAN_START, 0, R.string.menu_scan_for_preset)
- .setIcon(R.drawable.ic_btn_search);
- if (item != null) {
- item.setVisible(!searchActive && radioOn);
- }
- item = menu.add(0, MENU_SCAN_STOP, 0, R.string.menu_scan_stop).setIcon(
- R.drawable.ic_btn_search);
- if (item != null) {
- item.setVisible(searchActive && radioOn);
- }
-
- /* Settings can be active */
- item = menu.add(0, MENU_SETTINGS, 0, R.string.menu_settings).setIcon(
- android.R.drawable.ic_menu_preferences);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
-
- MenuItem item;
- boolean radioOn = isFmOn();
- boolean searchActive = isSearchActive();
-
- item = menu.findItem(MENU_SCAN_START);
- if (item != null) {
- item.setVisible(!searchActive && radioOn);
- }
- item = menu.findItem(MENU_SCAN_STOP);
- if (item != null) {
- item.setVisible(searchActive && radioOn);
- }
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case MENU_SETTINGS:
- Intent launchPreferencesIntent = new Intent().setClass(this,
- Settings.class);
- launchPreferencesIntent.putExtra(Settings.RX_MODE,false);
- startActivityForResult(launchPreferencesIntent,
- ACTIVITY_RESULT_SETTINGS);
-
- // startActivity(launchPreferencesIntent);
- return true;
-
- case MENU_SCAN_START:
- showDialog(DIALOG_PRESET_LIST_AUTO_SET);
- return true;
-
- case MENU_SCAN_STOP:
- cancelSearch();
- return true;
-
- default:
- break;
- }
- return super.onOptionsItemSelected(item);
- }
-
- private boolean isHdmiOn() {
- //HDMI and FM concurrecny is not supported.
- try {
- String hdmiUserOption = android.provider.Settings.System.getString(
- getContentResolver(), "HDMI_USEROPTION");
- }
- catch (Exception ex){
- Log.d(LOGTAG,"Get HDMI open failed");
- }
- return false;
- }
- @Override
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case DIALOG_PRESET_LIST_AUTO_SET: {
- return createPresetListAutoSelectWarnDlg(id);
- }
- case DIALOG_PICK_FREQUENCY: {
- FmConfig fmConfig = FmSharedPreferences.getFMConfiguration();
- return new FrequencyPickerDialog(this, fmConfig, mTunedFrequency,
- mFrequencyChangeListener);
- }
- case DIALOG_PROGRESS_PROGRESS: {
- return createProgressDialog(id);
- }
- case DIALOG_PRESET_OPTIONS: {
- return createPresetOptionsDlg(id);
- }
- default:
- break;
- }
- return null;
- }
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- super.onPrepareDialog(id, dialog);
- switch (id) {
- case DIALOG_PICK_FREQUENCY: {
- ((FrequencyPickerDialog) dialog).UpdateFrequency(mTunedFrequency);
- break;
- }
- case DIALOG_PRESET_OPTIONS: {
- AlertDialog alertDlg = ((AlertDialog) dialog);
- if ((alertDlg != null) && (mPresetButtonIndex >= 0)
- && (mPresetButtonIndex <= MAX_PRESETS)) {
- int frequency = mPresetFrequencies[mPresetButtonIndex];
- alertDlg.setTitle(PresetStation.getFrequencyString(frequency));
- }
- break;
- }
-
- default:
- break;
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- Log.d(LOGTAG, "onActivityResult : requestCode -> " + requestCode);
- Log.d(LOGTAG, "onActivityResult : resultCode -> " + resultCode);
- if (requestCode ==ACTIVITY_RESULT_SETTINGS)
- {
- if (resultCode == RESULT_OK)
- {
- /* */
- if (data != null)
- {
- String action = data.getAction();
- if (action != null)
- {
- if (action.equals(Settings.RESTORE_FACTORY_DEFAULT_ACTION))
- {
- RestoreDefaults();
- enableRadioOnOffUI();
- tuneRadio(mTunedFrequency);
- }
- }
- }
- } //if ACTIVITY_RESULT_SETTINGS
- }//if (resultCode == RESULT_OK)
- }
-
-
-
-
- /**
- * @return true if a internal antenna is available.
- *
- */
- boolean isInternalAntennaAvailable() {
- return mInternalAntennaAvailable;
- }
-
- private Dialog createPresetOptionsDlg(int id) {
- if ((mPresetButtonIndex >= 0) && (mPresetButtonIndex <= MAX_PRESETS)) {
- int frequency = mPresetFrequencies[mPresetButtonIndex];
- AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
- dlgBuilder.setTitle(PresetStation.getFrequencyString(frequency));
- ArrayList<String> arrayList = new ArrayList<String>();
- arrayList.add(getResources().getString(R.string.preset_tune));
- arrayList.add(getResources().getString(R.string.preset_replace));
- arrayList.add(getResources().getString(R.string.preset_delete));
- dlgBuilder.setCancelable(true);
- dlgBuilder
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- mPresetButtonIndex = -1;
- removeDialog(DIALOG_PRESET_OPTIONS);
- }
- });
- String[] items = new String[arrayList.size()];
- arrayList.toArray(items);
- dlgBuilder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- if ((mPresetButtonIndex >= 0)
- && (mPresetButtonIndex <= MAX_PRESETS)) {
- int frequency = mPresetFrequencies[mPresetButtonIndex];
- switch (item) {
- case 0: {
- // Tune to this station
- mPresetButtonIndex = -1;
- tuneRadio(frequency);
- break;
- }
- case 1: {
- // Replace preset Station with currently tuned
- // station
- Log.d(LOGTAG, "Replace station - " + frequency
- + " with " + mTunedFrequency);
- mPresetFrequencies[mPresetButtonIndex] = mTunedFrequency;
- mPresetButtonIndex = -1;
- setupPresetLayout();
- SavePreferences();
- break;
- }
- case 2: {
- // Delete
- mPresetFrequencies[mPresetButtonIndex] = 0;
- mPresetButtonIndex = -1;
- setupPresetLayout();
- SavePreferences();
- break;
- }
- default: {
- // Should not happen
- mPresetButtonIndex = -1;
- break;
- }
- }// switch item
- }// if(mPresetButtonStation != null)
- removeDialog(DIALOG_PRESET_OPTIONS);
- }// onClick
- });
- return dlgBuilder.create();
- }
- return null;
- }
-
- private Dialog createProgressDialog(int id) {
- String msgStr = "";
- String titleStr = "";
- boolean bSearchActive = false;
-
- if (isSearchActive()) {
- msgStr = getString(R.string.msg_weak_searching);
- titleStr = getString(R.string.msg_searching_title);
- bSearchActive = true;
- }
-
- if (bSearchActive) {
- mProgressDialog = new ProgressDialog(FMTransmitterActivity.this);
- if (mProgressDialog != null) {
- mProgressDialog.setTitle(titleStr);
- mProgressDialog.setMessage(msgStr);
- mProgressDialog.setIcon(R.drawable.ic_launcher_fm_tx);
- mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- mProgressDialog.setButton(DialogInterface.BUTTON_POSITIVE,
- getText(R.string.button_text_stop),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- cancelSearch();
- }
- });
- mProgressDialog
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- cancelSearch();
- }
- });
- }
-
- Message msg = new Message();
- msg.what = TIMEOUT_PROGRESS_DLG;
- mSearchProgressHandler.sendMessageDelayed(msg, SHOWBUSY_TIMEOUT);
- }
- return mProgressDialog;
- }
-
- private Dialog createPresetListAutoSelectWarnDlg(int id) {
- AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
- dlgBuilder.setIcon(R.drawable.alert_dialog_icon).setTitle(
- R.string.presetlist_autoselect_title);
- dlgBuilder.setMessage(getString(R.string.fmtx_autoselect_name));
-
- dlgBuilder.setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- /*
- * Since the presets will be changed, reset the page
- * number
- */
- initiateSearchList();
- setupPresetLayout();
- SavePreferences();
- removeDialog(DIALOG_PRESET_LIST_AUTO_SET);
- }
- });
-
- dlgBuilder.setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- removeDialog(DIALOG_PRESET_LIST_AUTO_SET);
- }
- });
- return (dlgBuilder.create());
- }
-
- private void RestoreDefaults() {
- for (int index = 0; index < MAX_PRESETS; index++) {
- mPresetFrequencies[index] = FmSharedPreferences.getLowerLimit();
- }
- mTunedFrequency = FmSharedPreferences.getLowerLimit();
- SavePreferences();
- }
-
- private View.OnLongClickListener mFrequencyViewClickListener = new View.OnLongClickListener() {
- public boolean onLongClick(View v) {
- showDialog(DIALOG_PICK_FREQUENCY);
- return true;
- }
- };
-
- private View.OnClickListener mForwardClickListener = new View.OnClickListener() {
- public void onClick(View v) {
- int frequency = FmSharedPreferences
- .getNextTuneFrequency(mTunedFrequency);
- Log.d(LOGTAG, "Tune Up: to " + frequency);
- tuneRadio(frequency);
- }
- };
-
- private View.OnClickListener mBackClickListener = new View.OnClickListener() {
- public void onClick(View v) {
- int frequency = FmSharedPreferences
- .getPrevTuneFrequency(mTunedFrequency);
- Log.d(LOGTAG, "Tune Down: to " + frequency);
- tuneRadio(frequency);
- }
- };
-
- private View.OnClickListener mPresetButtonClickListener = new View.OnClickListener() {
- public void onClick(View view) {
- Integer indexInteger = (Integer) view.getTag();
- int index = indexInteger.intValue();
- if ((index >= 0) && (index <= MAX_PRESETS)) {
- Log.d(LOGTAG, "station - " + index);
- if(mPresetFrequencies[index] != 0)
- {
- mTunedFrequency = mPresetFrequencies[index];
- tuneRadio(mTunedFrequency);
- view.startAnimation(mAnimation);
- }
- }
- }
- };
-
- private View.OnLongClickListener mPresetButtonOnLongClickListener = new View.OnLongClickListener() {
- public boolean onLongClick(View view) {
- Integer indexInteger = (Integer) view.getTag();
- int index = indexInteger.intValue();
- if ((index >= 0) && (index <= MAX_PRESETS)) {
- int frequency = mPresetFrequencies[index];
- mPresetButtonIndex = index;
- if (frequency > 0) {
- showDialog(DIALOG_PRESET_OPTIONS);
- } else {
- mPresetFrequencies[index] = mTunedFrequency;
- view.startAnimation(mAnimation);
- setupPresetLayout();
- SavePreferences();
- }
- }
- return true;
- }
- };
-
- final FrequencyPickerDialog.OnFrequencySetListener mFrequencyChangeListener = new FrequencyPickerDialog.OnFrequencySetListener() {
- public void onFrequencySet(FrequencyPicker view, int frequency) {
- Log.d(LOGTAG, "mFrequencyChangeListener: onFrequencyChanged to : "
- + frequency);
- tuneRadio(frequency);
- }
- };
-
- private View.OnClickListener mTurnOnOffClickListener = new View.OnClickListener() {
- public void onClick(View v) {
-
- if (isFmOn()) {
- enableRadioHandler.removeCallbacks(enableRadioTask);
- disableRadioHandler.removeCallbacks(disableRadioTask);
- disableRadioHandler.postDelayed(disableRadioTask, 0);
- } else {
- enableRadioHandler.removeCallbacks(enableRadioTask);
- disableRadioHandler.removeCallbacks(disableRadioTask);
- enableRadioHandler.postDelayed(enableRadioTask, 0);
- }
- setTurnOnOffButtonImage();
- }
- };
-
- private void setTurnOnOffButtonImage() {
- if (isFmOn() == true) {
- mOnOffButton.setImageResource(R.drawable.ic_btn_onoff);
- } else {
- /* Find a icon to indicate off */
- mOnOffButton.setImageResource(R.drawable.ic_btn_onoff);
- }
- }
-
- private void enableRadioOnOffButton() {
- if(mOnOffButton != null) {
- mOnOffButton.setEnabled(true);
- mOnOffButton.setClickable(true);
- }
- }
-
- private void disableRadioOnOffButton() {
- if(mOnOffButton != null) {
- mOnOffButton.setEnabled(false);
- mOnOffButton.setClickable(false);
- }
- }
- private void setHsPluggedInMsg() {
- if (mRadioTextTV != null) {
- mRadioTextTV.setVisibility(View.VISIBLE);
- mRadioTextTV.setText(getString(R.string.msg_headsetpluggedin));
- }
- }
- private Runnable enableRadioTask = new Runnable() {
- public void run() {
- enableRadio();
- }
- };
-
- private Runnable disableRadioTask = new Runnable() {
- public void run() {
- disableRadio();
- }
- };
-
- private void enableRadio() {
- mIsSearching = false;
- disableRadioOnOffButton();
- if (mService != null) {
- try {
- if(mService.isHeadsetPlugged()) {
- setHsPluggedInMsg();
- enableRadioOnOffButton();
- } else if(mService.isCallActive()) {
- enableRadioOnOffButton();
- } else if(!mService.fmOn()) {
- enableRadioOnOffButton();
- }
- } catch (RemoteException e) {
- enableRadioOnOffButton();
- e.printStackTrace();
- }
- }
-
- }
-
- private void disableRadio() {
- enableRadioOnOffUI(false);
- cancelSearch();
- if (mService != null) {
- try {
- if(!mService.fmOff()) {
- enableRadioOnOffButton();
- }
- } catch (RemoteException e) {
- enableRadioOnOffButton();
- e.printStackTrace();
- }
- }
- }
-
- public static void fmConfigure() {
- if (mService != null) {
- try {
- mService.fmReconfigure();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
-
- private void enableRadioOnOffUI() {
- boolean bEnable = true;
- //decide enable or disable UI based on
- //Tx Service status.This is valid only
- // when search is not in progress. When
- // search is in progress UI should be active
- if( false == isSearchActive() ) {
- bEnable = isFmOn();
- }
- /* Disable if no antenna/headset is available */
- if (!readInternalAntennaAvailable()) {
- Log.d(LOGTAG,"finding internal antenna avialable as false");
- bEnable = false;
- }
- enableRadioOnOffUI(bEnable);
- }
-
- private void enableRadioOnOffUI(boolean bEnable) {
- if (bEnable) {
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV
- .setOnLongClickListener(mFrequencyViewClickListener);
- }
- if (mRadioTextScroller != null) {
- mRadioTextScroller.startScroll();
- }
- } else {
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV.setOnLongClickListener(null);
- }
- if (mRadioTextScroller != null) {
- mRadioTextScroller.stopScroll();
- }
- }
-
- if (mForwardButton != null) {
- mForwardButton.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mBackButton != null) {
- mBackButton.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mTransmitStaticMsgTV != null) {
- mTransmitStaticMsgTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mTuneStationFrequencyTV != null) {
- mTuneStationFrequencyTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
- if (mRadioTextTV != null) {
- mRadioTextTV.setVisibility(((bEnable == true) ? View.VISIBLE
- : View.INVISIBLE));
- }
-
- try {
- if( null != mService) {
- if ( mService.isHeadsetPlugged()) {
- Log.d(LOGTAG,"headset plugged in");
- if (mRadioTextTV != null) {
- mRadioTextTV.setVisibility(View.VISIBLE);
- mRadioTextTV.setText(getString(R.string.msg_headsetpluggedin));
- }
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(false);
- }
- } else if (mService.isCallActive()) {
- Log.d(LOGTAG,"call active");
- if (mRadioTextTV != null) {
- mRadioTextTV.setVisibility(View.VISIBLE);
- mRadioTextTV.setText(getString(R.string.msg_callactive));
- }
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(false);
- }
- } else {
- if (mRadioTextTV != null) {
- mRadioTextTV.setText("");
- }
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(true);
- }
- }
- } else {
- Log.d(LOGTAG,"Service null");
- if (mRadioTextTV != null) {
- mRadioTextTV.setText("");
- }
- if (mOnOffButton != null) {
- mOnOffButton.setEnabled(true);
- }
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
- for (int nButton = 0; nButton < MAX_PRESETS; nButton++) {
- if (mPresetButtons[nButton] != null) {
- mPresetButtons[nButton].setEnabled(bEnable);
- }
- }
- }
-
- private void updateSearchProgress() {
- boolean searchActive = isSearchActive();
- if (searchActive) {
- synchronized (this) {
- if (mProgressDialog == null) {
- showDialog(DIALOG_PROGRESS_PROGRESS);
- } else {
- Message msg = new Message();
- msg.what = UPDATE_PROGRESS_DLG;
- mSearchProgressHandler.sendMessage(msg);
- }
- }
- } else {
- Message msg = new Message();
- msg.what = END_PROGRESS_DLG;
- mSearchProgressHandler.sendMessage(msg);
- }
- }
-
- private void resetSearchProgress() {
- Message msg = new Message();
- msg.what = END_PROGRESS_DLG;
- mSearchProgressHandler.sendMessage(msg);
- }
-
- private void setupPresetLayout() {
- /*
- * For every station, save the station as a tag and update the display
- * on the preset Button.
- */
- for (int buttonIndex = 0; (buttonIndex < MAX_PRESETS); buttonIndex++) {
- if (mPresetButtons[buttonIndex] != null) {
- String display = "";
- int frequency = mPresetFrequencies[buttonIndex];
- if (frequency != 0) {
- display = PresetStation.getFrequencyString(frequency);
- }
- mPresetButtons[buttonIndex].setText(display);
- mPresetButtons[buttonIndex].setTag(new Integer(buttonIndex));
- }
- }
- }
-
- private void updateStationInfoToUI() {
- mTuneStationFrequencyTV.setText(PresetStation.getFrequencyString(mTunedFrequency));
- mRadioTextTV.setText("");
- setupPresetLayout();
- }
-
- private boolean isFmOn() {
- boolean bOn = false;
- if (mService != null) {
- try {
- bOn = mService.isFmOn();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- return (bOn);
- }
-
- private boolean isSearchActive() {
- return (mIsSearching);
- }
-
- public static int getCurrentTunedFrequency() {
- return mTunedFrequency;
- }
-
- private void cancelSearch() {
- synchronized (this) {
- if (mService != null) {
- try {
- if (mIsSearching == true) {
- if (true == mService.cancelSearch()) {
- }
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- updateSearchProgress();
- }
-
- /** get Weakest Stations */
- private void initiateSearchList() {
- synchronized (this) {
- mIsSearching = true;
- if (mService != null) {
- try {
- mSearchingResultStatus = false;
- mIsSearching = mService.searchWeakStationList(MAX_PRESETS);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- updateSearchProgress();
- }
- }
- }
-
- /** get Internal Antenna Available mode Stations */
- private boolean readInternalAntennaAvailable() {
- mInternalAntennaAvailable = false;
- if (mService != null) {
- try {
- mInternalAntennaAvailable = mService
- .isInternalAntennaAvailable();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- Log.e(LOGTAG, "readInternalAntennaAvailable: internalAntenna : "
- + mInternalAntennaAvailable);
- return mInternalAntennaAvailable;
- }
-
- private static final int UPDATE_PROGRESS_DLG = 1;
- private static final int END_PROGRESS_DLG = 2;
- private static final int TIMEOUT_PROGRESS_DLG = 3;
- private static final int SHOWBUSY_TIMEOUT = 300000;
- private Handler mSearchProgressHandler = new Handler() {
- public void handleMessage(Message msg) {
- if (msg.what == UPDATE_PROGRESS_DLG) {
- // Log.d(LOGTAG, "mTimeoutHandler: UPDATE_PROGRESS_DLG");
- if (mProgressDialog != null) {
- mTuneStationFrequencyTV.setText(PresetStation.getFrequencyString(mTunedFrequency));
- String titleStr = getString( R.string.msg_search_title,
- PresetStation.getFrequencyString(mTunedFrequency));
-
- mProgressDialog.setTitle(titleStr);
- }
- } else if (msg.what == END_PROGRESS_DLG) {
- // Log.d(LOGTAG, "mTimeoutHandler: END_PROGRESS_DLG");
- mSearchProgressHandler.removeMessages(END_PROGRESS_DLG);
- mSearchProgressHandler.removeMessages(UPDATE_PROGRESS_DLG);
- mSearchProgressHandler.removeMessages(TIMEOUT_PROGRESS_DLG);
- removeDialog(DIALOG_PROGRESS_PROGRESS);
- mProgressDialog = null;
- } else if (msg.what == TIMEOUT_PROGRESS_DLG) {
- cancelSearch();
- }
- }
- };
-
- private void tuneRadio(int frequency) {
- if (mService != null) {
- try {
- // Set Tune Frequency
- mService.tune(frequency);
- updateStationInfoToUI();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
-
- private void resetFMStationInfoUI() {
- mRadioTextTV.setText("");
- mRadioTextScroller.stopScroll();
- updateStationInfoToUI();
- }
-
-
- final Runnable mUpdateStationInfo = new Runnable() {
- public void run() {
- updateSearchProgress();
- resetFMStationInfoUI();
- }
- };
-
- final Runnable mSearchListComplete = new Runnable() {
- public void run() {
- Log.d(LOGTAG, "mSearchListComplete: ");
- mIsSearching = false;
-
- /* Now get the list */
- if (mService != null) {
- try {
- if(mSearchingResultStatus) {
- int[] searchList = mService.getSearchList();
- if (searchList != null) {
- for (int station = 0; (station < searchList.length)
- && (station < MAX_PRESETS); station++) {
- Log.d(LOGTAG, "mSearchListComplete: [" + station
- + "] = " + searchList[station]);
- mPresetFrequencies[station] = searchList[station];
- }
- }
- }
- /* Restart FM into Transmit mode */
- if(!mService.isHeadsetPlugged()) {
- mService.fmRestart();
- /* Tune to last tuned frequency */
- tuneRadio(mTunedFrequency);
- updateSearchProgress();
- resetFMStationInfoUI();
- setupPresetLayout();
- SavePreferences();
- } else {
- updateSearchProgress();
- enableRadioHandler.removeCallbacks(enableRadioTask);
- disableRadioHandler.removeCallbacks(disableRadioTask);
- disableRadioHandler.postDelayed(disableRadioTask, 0);
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- };
-
-
-
- final Runnable mUpdateRadioText = new Runnable() {
- public void run() {
- String str = "";
- if ((mService != null) && isFmOn()) {
- try {
- /* Get Radio Text and update the display */
- str = mService.getRadioText();
- if(null != mMetaData) {
- Log.d(LOGTAG,"meta data is "+mMetaData);
- str = str.concat(mMetaData);
- } else {
- str = str.concat("...");
- }
- /* Update only if all the characters are printable */
- if (TextUtils.isGraphic(str))
- {
- Log.d(LOGTAG, "mUpdateRadioText: Updatable string: ["
- + str + "]");
- mRadioTextTV.setText(str);
- }
- /* Rest the string to empty */
- else if (TextUtils.isEmpty(str)) {
- mRadioTextTV.setText("");
- } else {
- Log.d(LOGTAG, "RDS has non printable stuff");
- mRadioTextTV.setText("");
- }
-
- mRadioTextScroller.startScroll();
- String szRTStr = getString(R.string.transmit_msg_string);
- mPSData = mService.getPSData();
- if(null != mPSData ) {
- szRTStr = mPSData.concat("\n").concat(szRTStr);
- }
- else
- Log.d(LOGTAG, "mPSData is NULL");
- mTransmitStaticMsgTV.setText(szRTStr);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- };
-
- private void DebugToasts(String str, int duration) {
- Toast.makeText(this, str, duration).show();
- }
-
- /**
- * This Handler will scroll the text view. On startScroll, the scrolling
- * starts after SCROLLER_START_DELAY_MS The Text View is scrolled left one
- * character after every SCROLLER_UPDATE_DELAY_MS When the entire text is
- * scrolled, the scrolling will restart after SCROLLER_RESTART_DELAY_MS
- */
- private static final class ScrollerText extends Handler {
-
- private static final byte SCROLLER_STOPPED = 0x51;
- private static final byte SCROLLER_STARTING = 0x52;
- private static final byte SCROLLER_RUNNING = 0x53;
-
- private static final int SCROLLER_MSG_START = 0xF1;
- private static final int SCROLLER_MSG_TICK = 0xF2;
- private static final int SCROLLER_MSG_RESTART = 0xF3;
-
- private static final int SCROLLER_START_DELAY_MS = 1000;
- private static final int SCROLLER_RESTART_DELAY_MS = 3000;
- private static final int SCROLLER_UPDATE_DELAY_MS = 200;
-
- private final WeakReference<TextView> mView;
-
- private byte mStatus = SCROLLER_STOPPED;
- String mOriginalString;
- int mStringlength = 0;
- int mIteration = 0;
-
- ScrollerText(TextView v) {
- mView = new WeakReference<TextView>(v);
- }
-
- /**
- * Scrolling Message Handler
- */
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SCROLLER_MSG_START:
- mStatus = SCROLLER_RUNNING;
- updateText();
- break;
- case SCROLLER_MSG_TICK:
- updateText();
- break;
- case SCROLLER_MSG_RESTART:
- if (mStatus == SCROLLER_RUNNING) {
- startScroll();
- }
- break;
- }
- }
-
- /**
- * Moves the text left by one character and posts a delayed message for
- * next update after SCROLLER_UPDATE_DELAY_MS. If the entire string is
- * scrolled, then it displays the entire string and waits for
- * SCROLLER_RESTART_DELAY_MS for scrolling restart
- */
- void updateText() {
- if (mStatus != SCROLLER_RUNNING) {
- return;
- }
-
- removeMessages(SCROLLER_MSG_TICK);
-
- final TextView textView = mView.get();
- if (textView != null) {
- String szStr2 = "";
- if (mStringlength > 0) {
- mIteration++;
- if (mIteration >= mStringlength) {
- mIteration = 0;
- sendEmptyMessageDelayed(SCROLLER_MSG_RESTART,
- SCROLLER_RESTART_DELAY_MS);
- } else {
- sendEmptyMessageDelayed(SCROLLER_MSG_TICK,
- SCROLLER_UPDATE_DELAY_MS);
- }
- // String szStr1 = mOriginalString.substring(0, mTick);
- szStr2 = mOriginalString.substring(mIteration);
- }
- // textView.setText(szStr2+" "+szStr1);
- textView.setText(szStr2);
- }
- }
-
- /**
- * Stops the scrolling The textView will be set to the original string.
- */
- void stopScroll() {
- mStatus = SCROLLER_STOPPED;
- removeMessages(SCROLLER_MSG_TICK);
- removeMessages(SCROLLER_MSG_RESTART);
- removeMessages(SCROLLER_MSG_START);
- resetScroll();
- }
-
- /**
- * Resets the scroll to display the original string.
- */
- private void resetScroll() {
- mIteration = 0;
- final TextView textView = mView.get();
- if (textView != null) {
- textView.setText(mOriginalString);
- }
- }
-
- /**
- * Starts the Scrolling of the TextView after a delay of
- * SCROLLER_START_DELAY_MS Starts only if Length > 0
- */
- void startScroll() {
- final TextView textView = mView.get();
- if (textView != null) {
- mOriginalString = (String) textView.getText();
- mStringlength = mOriginalString.length();
- if (mStringlength > 0) {
- mStatus = SCROLLER_STARTING;
- sendEmptyMessageDelayed(SCROLLER_MSG_START,
- SCROLLER_START_DELAY_MS);
- }
- }
- }
- }
-
- public static IFMTransmitterService sService = null;
- private static HashMap<Context, ServiceBinder> sConnectionMap = new HashMap<Context, ServiceBinder>();
-
- public static boolean bindToService(Context context) {
- Log.e(LOGTAG, "bindToService: Context");
- return bindToService(context, null);
- }
-
- public static boolean bindToService(Context context,
- ServiceConnection callback) {
- Log.e(LOGTAG, "bindToService: Context with serviceconnection callback");
- context.startService(new Intent(context, FMTransmitterService.class));
- ServiceBinder sb = new ServiceBinder(callback);
- sConnectionMap.put(context, sb);
- return context.bindService((new Intent()).setClass(context,
- FMTransmitterService.class), sb, 0);
- }
-
- public static void unbindFromService(Context context) {
- ServiceBinder sb = (ServiceBinder) sConnectionMap.remove(context);
- Log.e(LOGTAG, "unbindFromService: Context");
- if (sb == null) {
- Log.e(LOGTAG, "Trying to unbind for unknown Context");
- return;
- }
- context.unbindService(sb);
- if (sConnectionMap.isEmpty()) {
- // presumably there is nobody interested in the service at this
- // point,
- // so don't hang on to the ServiceConnection
- sService = null;
- }
- }
-
- private static class ServiceBinder implements ServiceConnection {
- ServiceConnection mCallback;
-
- ServiceBinder(ServiceConnection callback) {
- mCallback = callback;
- }
-
- public void onServiceConnected(ComponentName className,
- android.os.IBinder service) {
- sService = IFMTransmitterService.Stub.asInterface(service);
- if (mCallback != null) {
- Log.e(LOGTAG, "onServiceConnected: mCallback");
- mCallback.onServiceConnected(className, service);
- }
- }
-
- public void onServiceDisconnected(ComponentName className) {
- if (mCallback != null) {
- mCallback.onServiceDisconnected(className);
- }
- sService = null;
- }
- }
-
- private ServiceConnection osc = new ServiceConnection() {
- public void onServiceConnected(ComponentName classname, IBinder obj) {
- mService = IFMTransmitterService.Stub.asInterface(obj);
- Log.e(LOGTAG, "ServiceConnection: onServiceConnected: ");
- if (mService != null) {
- try {
- mService.registerCallbacks(mServiceCallbacks);
- if(false == mService.isHeadsetPlugged()) {
- Log.e(LOGTAG, "return for isHeadsetPlugged is false");
- if (SavedDataAndState == null) {
- enableRadioHandler.removeCallbacks(enableRadioTask);
- disableRadioHandler.removeCallbacks(disableRadioTask);
- enableRadioHandler.postDelayed(enableRadioTask, 0);
- } else if (SavedDataAndState.onOrOff) {
- enableRadioOnOffUI(true);
- } else {
- enableRadioOnOffUI(false);
- }
- } else {
- enableRadioOnOffUI(false);
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- return;
- } else {
- Log.e(LOGTAG,
- "IFMTransmitterService onServiceConnected failed");
- }
- // startPlayback();
- // Service is dead or not playing anything. If we got here as part
- // of a "play this file" Intent, exit. Otherwise go to the Music
- // app start screen.
- if (getIntent().getData() == null) {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClass(FMTransmitterActivity.this,
- FMTransmitterActivity.class);
- startActivity(intent);
- }
- finish();
- }
-
- public void onServiceDisconnected(ComponentName classname) {
- }
- };
-
- private IFMTransmitterServiceCallbacks.Stub mServiceCallbacks = new IFMTransmitterServiceCallbacks.Stub() {
-
- public void onDisabled() throws RemoteException {
- mHandler.post(mRadioStateUpdated);
- }
-
- public void onRadioReset() throws RemoteException {
- mHandler.post(mRadioReset);
- }
-
- public void onEnabled(boolean status) throws RemoteException {
- mHandler.post(mRadioStateUpdated);
- }
-
- public void onRadioTextChanged() throws RemoteException {
- }
-
- public void onSearchListComplete(boolean status) throws RemoteException {
- mIsSearching = false;
- mSearchingResultStatus = status;
- mHandler.post(mSearchListComplete);
- }
-
- public void onTuneStatusChanged(int frequency) throws RemoteException {
- mTunedFrequency = frequency;
- Log.d(LOGTAG, "onTuneStatusChanged: Frequency : " + mTunedFrequency);
- FmSharedPreferences.setTunedFrequency(mTunedFrequency);
- SavePreferences();
- mHandler.post(mUpdateStationInfo);
- }
- public void onReconfigured() throws RemoteException {
- RestoreDefaults();
- }
- public void onMetaDataChanged(String metaStr) throws RemoteException {
- Log.d(LOGTAG,"meta data is "+metaStr);
- mMetaData = new String (metaStr);
- mHandler.post(mUpdateRadioText);
- }
- public void onPSInfoSent(String psStr ) throws RemoteException {
- Log.d(LOGTAG,"PS String data is "+psStr);
- mPSData = new String (psStr);
- mHandler.post(mUpdateRadioText);
- }
- };
- final Runnable mRadioStateUpdated = new Runnable() {
- public void run() {
- enableRadioOnOffButton();
- /* Update UI to FM On State */
- if(isFmOn()) {
- enableRadioOnOffUI(true);
- /* Tune to the last tuned frequency */
- LoadPreferences();
- tuneRadio(mTunedFrequency);
- } else {
- /* Save the existing frequency */
- FmSharedPreferences.setTunedFrequency(mTunedFrequency);
- SavePreferences();
- removeDialog(DIALOG_PRESET_LIST_AUTO_SET);
- enableRadioOnOffUI(false);
- }
-
- }
- };
- final Runnable mRadioReset = new Runnable() {
- public void run() {
- /* Save the existing frequency */
- resetSearchProgress();
- FmSharedPreferences.setTunedFrequency(mTunedFrequency);
- SavePreferences();
- enableRadioOnOffUI(false);
- }
- };
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMTransmitterConfigReceiver.java b/fmapp/src/com/codeaurora/fmradio/FMTransmitterConfigReceiver.java
deleted file mode 100644
index d64852a..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMTransmitterConfigReceiver.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2011-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 android.content.Intent;
-import android.content.BroadcastReceiver;
-import android.content.pm.PackageManager;
-import android.content.Context;
-import android.content.ComponentName;
-import android.util.Log;
-import android.os.SystemProperties;
-import java.io.FileReader;
-import java.io.File;
-import java.lang.String;
-
-
-public class FMTransmitterConfigReceiver extends BroadcastReceiver {
-
- private static FileReader socinfo_fd;
- private static char[] socinfo = new char[20];
- private static String build_id = "1";
-
- private static final String TAG = "FMFolderConfigReceiver";
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- Log.d(TAG, "Received intent: " + action);
- if((action != null) && action.equals("android.intent.action.BOOT_COMPLETED")) {
- Log.d(TAG, "boot complete intent received");
- boolean isFmTransmitterSupported = SystemProperties.getBoolean("ro.fm.transmitter",true);
-
- if ("msm7630_surf".equals(SystemProperties.get("ro.board.platform"))) {
- Log.d(TAG,"this is msm7630_surf");
- try {
- File f = new File("/sys/devices/soc0/build_id");
- if (f.exists()) {
- socinfo_fd = new FileReader("/sys/devices/soc0/build_id");
- } else {
- socinfo_fd = new FileReader("/sys/devices/system/soc/soc0/build_id");
- }
- socinfo_fd.read(socinfo,0,20);
- socinfo_fd.close();
- } catch(Exception e) {
- Log.e(TAG,"Exception in FileReader");
- }
- Log.d(TAG, "socinfo=" +socinfo);
- build_id = new String(socinfo,17,1);
- Log.d(TAG, "build_id=" +build_id);
- }
- if ((!isFmTransmitterSupported) || (build_id.equals("0"))) {
- PackageManager pManager = context.getPackageManager();
- if (pManager != null) {
- Log.d(TAG, "disableing the FM Transmitter");
- ComponentName fmTransmitter = new ComponentName("com.codeaurora.fmradio", "com.codeaurora.fmradio.FMTransmitterActivity");
- pManager.setComponentEnabledSetting(fmTransmitter, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- PackageManager.DONT_KILL_APP);
- }
- }
- }
- }
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMTransmitterService.java b/fmapp/src/com/codeaurora/fmradio/FMTransmitterService.java
deleted file mode 100644
index bbe2b4a..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FMTransmitterService.java
+++ /dev/null
@@ -1,1243 +0,0 @@
-/*
- * 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.lang.ref.WeakReference;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.media.AudioManager;
-import android.media.AudioSystem;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.PowerManager;
-import android.os.SystemProperties;
-import android.os.PowerManager.WakeLock;
-import android.os.RemoteException;
-import android.telephony.PhoneStateListener;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-import android.widget.RemoteViews;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.BroadcastReceiver;
-
-import qcom.fmradio.FmReceiver;
-import qcom.fmradio.FmTransmitter;
-import qcom.fmradio.FmRxEvCallbacksAdaptor;
-import qcom.fmradio.FmTransmitterCallbacksAdaptor;
-import qcom.fmradio.FmRxRdsData;
-import qcom.fmradio.FmConfig;
-import com.codeaurora.utils.A2dpDeviceStatus;
-
-import android.media.IRemoteControlDisplay;
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.graphics.Bitmap;
-import android.media.IAudioService;
-import android.media.MediaMetadataRetriever;
-/**
- * Provides "background" FM Radio (that uses the hardware) capabilities,
- * allowing the user to switch between activities without stopping playback.
- */
-public class FMTransmitterService extends Service
-{
- private static final int FMTRANSMITTERSERVICE_STATUS = 102;
- private static final int FM_TX_PROGRAM_TYPE = 0;
- private static final int FM_TX_PROGRAM_ID = 0x1234;
- private static final int FM_TX_PS_REPEAT_COUNT = 1;
-
- private static final String FMRADIO_DEVICE_FD_STRING = "/dev/radio0";
- private static final String LOGTAG = "FMTxService";//FMRadio.LOGTAG;
- private static final String QFM_STRING ="QFMRADIO";
-
- private static FmReceiver mReceiver;
- private static FmTransmitter mTransmitter;
- private int mTunedFrequency = 0;
-
- private static FmSharedPreferences mPrefs;
- private IFMTransmitterServiceCallbacks mCallbacks;
- private WakeLock mWakeLock;
- private int mServiceStartId = -1;
- private boolean mServiceInUse = false;
- private boolean mMuted = false;
- private boolean mResumeAfterCall = false;
-
- private boolean mFMOn = false;
- private int mFMSearchStations = 0;
-
- private FmRxRdsData mFMRxRDSData=null;
- final Handler mHandler = new Handler();
- private BroadcastReceiver mHeadsetReceiver = null;
- boolean mHeadsetPlugged = false;
- // Track A2dp Device status changes
- private A2dpDeviceStatus mA2dpDeviceState = null;
- // interval after which we stop the service when idle
- private static final int IDLE_DELAY = 60000;
- private IAudioService mAudioService;
- private AudioManager mAudioManager;
- private Metadata mMetadata;
- RdsDisplay mRds;
-
- private static String RText = " ";
-
- public FMTransmitterService() {
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- mCallbacks = null;
- mPrefs = new FmSharedPreferences(this);
-
- PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
- mWakeLock.setReferenceCounted(false);
-
- // If the service was idle, but got killed before it stopped itself, the
- // system will relaunch it. Make sure it gets stopped again in that case.
-
- TelephonyManager tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- tmgr.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
-
- //register for A2DP utility interface
- mA2dpDeviceState = new A2dpDeviceStatus(getApplicationContext());
- Message msg = mDelayedStopHandler.obtainMessage();
- mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY);
- mAudioManager = new AudioManager(getApplicationContext());
- mMetadata = new Metadata();
- registerHeadsetListener();
- mRds = new RdsDisplay();
- mAudioManager.registerRemoteControlDisplay(mRds);
- }
-
- @Override
- public void onDestroy() {
- Log.d(LOGTAG, "onDestroy");
- if (isFmOn())
- {
- Log.e(LOGTAG, "Service being destroyed while still playing.");
- }
-
- // make sure there aren't any other messages coming
- mDelayedStopHandler.removeCallbacksAndMessages(null);
-
- mAudioManager.unregisterRemoteControlDisplay(mRds);
- /* Unregister the headset Broadcase receiver */
- if (mHeadsetReceiver != null) {
- unregisterReceiver(mHeadsetReceiver);
- mHeadsetReceiver = null;
- }
- /* Since the service is closing, disable the receiver */
- fmOff();
-
- TelephonyManager tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- tmgr.listen(mPhoneStateListener, 0);
-
- mWakeLock.release();
- super.onDestroy();
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- mServiceInUse = true;
- /* Application/UI is attached, so get out of lower power mode */
- setLowPowerMode(false);
- Log.d(LOGTAG, "onBind");
- return mBinder;
- }
-
- @Override
- public void onRebind(Intent intent) {
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- mServiceInUse = true;
- /* Application/UI is attached, so get out of lower power mode */
- setLowPowerMode(false);
- Log.d(LOGTAG, "onRebind");
- }
-
- @Override
- public void onStart(Intent intent, int startId) {
- Log.d(LOGTAG, "onStart");
- mServiceStartId = startId;
- mDelayedStopHandler.removeCallbacksAndMessages(null);
-
- // make sure the service will shut down on its own if it was
- // just started but not bound to and nothing is playing
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- Message msg = mDelayedStopHandler.obtainMessage();
- mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY);
- }
-
- @Override
- public boolean onUnbind(Intent intent) {
- mServiceInUse = false;
- Log.d(LOGTAG, "onUnbind");
-
- /* Application/UI is not attached, so go into lower power mode */
- unregisterCallbacks();
- setLowPowerMode(true);
- if (isFmOn())
- {
- // something is currently playing, or will be playing once
- // an in-progress call ends, so don't stop the service now.
- return true;
- }
-
- stopSelf(mServiceStartId);
- return true;
- }
-
- /* Handle Phone Call + FM Concurrency */
- private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
- Log.d(LOGTAG, "onCallStateChanged: State - " + state );
- Log.d(LOGTAG, "onCallStateChanged: incomingNumber - " + incomingNumber );
- fmActionOnCallState(state );
- }
-
- // NEED TO CHECK ACTION TO BE TAKEN ON DATA ACTIVITY
- };
- private void fmActionOnCallState( int state ) {
- //if Call Status is non IDLE we need to Mute FM as well stop recording if
- //any. Similarly once call is ended FM should be unmuted.
- AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if((TelephonyManager.CALL_STATE_OFFHOOK == state)||
- (TelephonyManager.CALL_STATE_RINGING == state)) {
- if (state == TelephonyManager.CALL_STATE_RINGING) {
- int ringvolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
- if (ringvolume == 0) {
- return;
- }
- }
- if( mFMOn == true) {
- Log.d(LOGTAG, "posting for call state change");
- mHandler.post(mChangeFMTxState);
- mResumeAfterCall = true;
- }
- }
- else if (state == TelephonyManager.CALL_STATE_IDLE) {
- // start playing again
- if (mResumeAfterCall)
- {
- Log.d(LOGTAG, "posting for call state change");
- mHandler.post(mChangeFMTxState);
- mResumeAfterCall = false;
- }
- }//idle
- }
-
- private Handler mDelayedStopHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- // Check again to make sure nothing is playing right now
- if (isFmOn() || mServiceInUse)
- {
- return;
- }
- Log.d(LOGTAG, "mDelayedStopHandler: stopSelf");
- stopSelf(mServiceStartId);
- }
- };
-
- /* Show the FM Notification */
- public void startNotification() {
- RemoteViews views = new RemoteViews(getPackageName(), R.layout.statusbar);
- views.setImageViewResource(R.id.icon, R.drawable.ic_status_fm_tx);
- if (isFmOn())
- {
- views.setTextViewText(R.id.frequency, getTunedFrequencyString());
- } else
- {
- views.setTextViewText(R.id.frequency, "");
- }
-
- Notification status = new Notification();
- status.contentView = views;
- status.flags |= Notification.FLAG_ONGOING_EVENT;
- status.icon = R.drawable.ic_status_fm_tx;
- status.contentIntent = PendingIntent.getActivity(this, 0,
- new Intent("com.codeaurora.fmradio.FMTRANSMITTER_ACTIVITY"), 0);
- startForeground(FMTRANSMITTERSERVICE_STATUS, status);
- //NotificationManager nm = (NotificationManager)
- // getSystemService(Context.NOTIFICATION_SERVICE);
- //nm.notify(FMTRANSMITTERSERVICE_STATUS, status);
- //setForeground(true);
- mFMOn = true;
- }
-
- private void stop() {
- gotoIdleState();
- mFMOn = false;
- }
-
- private void gotoIdleState() {
- mDelayedStopHandler.removeCallbacksAndMessages(null);
- Message msg = mDelayedStopHandler.obtainMessage();
- mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY);
- //NotificationManager nm =
- //(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- //nm.cancel(FMTRANSMITTERSERVICE_STATUS);
- //setForeground(false);
- stopForeground(true);
- }
-
- /*
- * By making this a static class with a WeakReference to the Service, we
- * ensure that the Service can be GCd even when the system process still
- * has a remote reference to the stub.
- */
- static class ServiceStub extends IFMTransmitterService.Stub
- {
- WeakReference<FMTransmitterService> mService;
-
- ServiceStub(FMTransmitterService service)
- {
- mService = new WeakReference<FMTransmitterService>(service);
- }
-
- public boolean fmOn() throws RemoteException
- {
- return(mService.get().fmOn());
- }
-
- public boolean fmOff() throws RemoteException
- {
- return(mService.get().fmOff());
- }
- public boolean fmRadioReset() throws RemoteException
- {
- return(mService.get().fmRadioReset());
- }
- public boolean fmRestart() throws RemoteException
- {
- return(mService.get().fmRestart());
- }
-
- public boolean isFmOn()
- {
- return(mService.get().isFmOn());
- }
- public boolean fmReconfigure()
- {
- return(mService.get().fmReconfigure());
- }
-
- public void registerCallbacks(IFMTransmitterServiceCallbacks cb)
- throws RemoteException {
- mService.get().registerCallbacks(cb);
- }
-
- public boolean searchWeakStationList(int numStations)
- throws RemoteException {
- return(mService.get().searchWeakStationList(numStations));
- }
-
- public void unregisterCallbacks() throws RemoteException
- {
- mService.get().unregisterCallbacks();
- }
-
- public boolean tune(int frequency)
- {
- return(mService.get().tune(frequency));
- }
-
- public boolean cancelSearch()
- {
- return(mService.get().cancelSearch());
- }
-
- public String getRadioText()
- {
- return(mService.get().getRadioText());
- }
-
- public int[] getSearchList()
- {
- return(mService.get().getSearchList());
- }
-
- public boolean isInternalAntennaAvailable()
- {
- return(mService.get().isInternalAntennaAvailable());
- }
- public boolean isHeadsetPlugged()
- {
- return(mService.get().isHeadsetPlugged());
- }
- public boolean isCallActive()
- {
- return(mService.get().isCallActive());
- }
- public String getPSData()
- {
- return(mService.get().getPSData());
- }
- }
-
- private final IBinder mBinder = new ServiceStub(this);
- /*
- * Turn ON FM: Powers up FM hardware, and initializes the FM module
- * .
- * @return true if fm Enable api was invoked successfully, false if the api failed.
- */
- private boolean fmOn() {
- boolean bStatus=false;
-
- Log.d(LOGTAG, "fmOn");
- mWakeLock.acquire(10*1000);
- if (mTransmitter == null) {
- try {
- mTransmitter = new FmTransmitter(FMRADIO_DEVICE_FD_STRING, transmitCallbacks);
- Log.d(LOGTAG, "new transmitter created");
- } catch (InstantiationException e) {
- throw new RuntimeException("FmTx service not available!");
- }
- }
- if (mTransmitter != null)
- {
- if (isFmOn())
- {
- /* FM Is already on,*/
- bStatus = true;
- try {
- if(mCallbacks != null) {
- mCallbacks.onEnabled(true);
- }
- } catch(RemoteException e) {
- e.printStackTrace();
- }
- Log.d(LOGTAG, "mTransmitter is enabled");
- }
- else
- {
- // This sets up the FM radio device
- FmConfig config = FmSharedPreferences.getFMConfiguration();
- Log.d(LOGTAG, "fmOn: RadioBand :"+ config.getRadioBand());
- Log.d(LOGTAG, "fmOn: Emphasis :"+ config.getEmphasis());
- Log.d(LOGTAG, "fmOn: ChSpacing :"+ config.getChSpacing());
- Log.d(LOGTAG, "fmOn: RdsStd :"+ config.getRdsStd());
- Log.d(LOGTAG, "fmOn: LowerLimit :"+ config.getLowerLimit());
- Log.d(LOGTAG, "fmOn: UpperLimit :"+ config.getUpperLimit());
-
- boolean bFmRxEnabled = false;
-
- if (!mA2dpDeviceState.isDeviceAvailable()) {
- bStatus = mTransmitter.enable(config);
- }
- if( false == bStatus ) {
- Log.e(LOGTAG,"FM Enable failed");
- return bStatus;
- }
- bStatus = mTransmitter.setTxPowerLevel(FmTransmitter.FM_TX_PWR_LEVEL_7);
-
- if( false == bStatus ) {
- Log.e(LOGTAG,"FM setPowerLevel failed");
- return bStatus;
- }
-
- Log.e(LOGTAG, "FMTx is on: Requesting to start FM Tx");
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM_TX,
- AudioSystem.DEVICE_STATE_AVAILABLE, "");
-
- }
-
- if(true == bStatus )
- {
- bStatus = mTransmitter.setRdsOn();
- if( true != bStatus ) {
- Log.d(LOGTAG, "FMTx setRdsOn failed");
- } else {
- if(false == mTransmitter.getInternalAntenna()) {
- Log.d(LOGTAG, "Setting internal antenna explicitly");
- mTransmitter.setInternalAntenna(true);
- }
- startNotification();
- }
- }
- else
- {
- stop();
- }
- }
- return(bStatus);
- }
-
- /*
- * Turn OFF FM Operations: This disables all the current FM operations .
- */
- private void fmOperationsOff() {
-
- Log.d(LOGTAG, "fmOperationsOff" );
-
- Log.e(LOGTAG, "FMTx is off: requesting to stop FM Tx");
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM_TX,
- AudioSystem.DEVICE_STATE_UNAVAILABLE, "");
- }
- /*
- * Turn OFF FM: Disable the FM Host and hardware .
- * .
- * @return true if fm Disable api was invoked successfully, false if the api failed.
- */
- private boolean fmOff() {
- boolean bStatus=false;
- Log.d(LOGTAG, "fmOff");
-
- fmOperationsOff();
-
- // This will disable the FM radio device
- if (mTransmitter != null)
- {
- bStatus = mTransmitter.disable();
- mTransmitter = null;
- }
- /* Disable Receiver */
- if (mReceiver != null)
- {
- bStatus = mReceiver.disable();
- mReceiver = null;
- }
- RText = " ";
- stop();
- return(bStatus);
- }
- /*
- * Turn OFF FM: Disable the FM Host when hardware resets asynchronously .
- * .
- * @return true if fm Reset api was invoked successfully, false if the api failed .
- */
- private boolean fmRadioReset() {
- boolean bStatus=false;
- Log.d(LOGTAG, "fmRadioReset");
- fmOperationsOff();
-
- // This will disable the FM radio device
- if (mTransmitter != null)
- {
- bStatus = mTransmitter.reset();
- mTransmitter = null;
- }
- /* Disable Receiver */
- if (mReceiver != null)
- {
- bStatus = mReceiver.reset();
- mReceiver = null;
- }
- stop();
- return(bStatus);
- }
-
- /*
- * Restart FM Transmitter: Disables FM receiver mode or transmitter is already active
- * and Powers up FM hardware, and initializes the FM module
- *
- * @return true if fm Enable api was invoked successfully, false if the api failed.
- */
-
- private boolean fmRestart() {
- boolean bStatus=false;
- Log.d(LOGTAG, "fmRestart");
-
- /* First Disable Transmitter, if enabled */
- if (mTransmitter != null)
- {
- bStatus = mTransmitter.disable();
- mTransmitter = null;
- mFMOn = false;
- }
-
- /* Disable Receiver */
- if (mReceiver != null)
- {
- bStatus = mReceiver.disable();
- mReceiver = null;
- }
- try {
- Thread.sleep(100);//sleep needed for SoC to switch mode
- }
- catch ( Exception ex ) {
- Log.d( LOGTAG, "RunningThread InterruptedException");
- }
- bStatus = fmOn();
- return(bStatus);
- }
-
- /* Returns whether FM hardware is ON.
- *
- * @return true if FM was tuned, searching. (at the end of
- * the search FM goes back to tuned).
- *
- */
- public boolean isFmOn() {
- return mFMOn;
- }
-
- /*
- * ReConfigure the FM Setup parameters
- * - Band
- * - Channel Spacing (50/100/200 KHz)
- * - Emphasis (50/75)
- * - Frequency limits
- * - RDS/RBDS standard
- *
- * @return true if configure api was invoked successfully, false if the api failed.
- */
- public boolean fmReconfigure() {
- boolean bStatus=false;
- Log.d(LOGTAG, "fmReconfigure");
- if (mTransmitter != null)
- {
- // This sets up the FM radio device
- FmConfig config = FmSharedPreferences.getFMConfiguration();
- Log.d(LOGTAG, "RadioBand :"+ config.getRadioBand());
- Log.d(LOGTAG, "Emphasis :"+ config.getEmphasis());
- Log.d(LOGTAG, "ChSpacing :"+ config.getChSpacing());
- Log.d(LOGTAG, "RdsStd :"+ config.getRdsStd());
- Log.d(LOGTAG, "LowerLimit :"+ config.getLowerLimit());
- Log.d(LOGTAG, "UpperLimit :"+ config.getUpperLimit());
- bStatus = mTransmitter.configure(config);
- }
- if (mCallbacks != null)
- {
- try
- {
- mCallbacks.onReconfigured();
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return(bStatus);
- }
-
- /*
- * Register UI/Activity Callbacks
- */
- public void registerCallbacks(IFMTransmitterServiceCallbacks cb)
- {
- mCallbacks = cb;
- }
-
- /*
- * unRegister UI/Activity Callbacks
- */
- public void unregisterCallbacks()
- {
- mCallbacks=null;
- }
-
- /* Tunes to the specified frequency
- *
- * @return true if Tune command was invoked successfully, false if not muted.
- * Note: Callback FmRxEvRadioTuneStatus will be called when the tune
- * is complete
- */
- public boolean tune(int frequency) {
- boolean bCommandSent=false;
- double doubleFrequency = frequency/1000.00;
-
- Log.d(LOGTAG, "tune: " + doubleFrequency);
- if (mTransmitter != null)
- {
- mTransmitter.setStation(frequency);
- mTunedFrequency = frequency;
- bCommandSent = true;
- }
- return bCommandSent;
- }
-
- /* Search for the weakest 12 FM Stations in the current band.
- *
- * It searches in the forward direction relative to the current tuned station.
- * int numStations: maximum number of stations to search.
- *
- * @return true if Search command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvSearchListComplete will be called when the Search
- * is complete
- * 2. Callback FmRxEvRadioTuneStatus will also be called when tuned to
- * the previously tuned station.
- */
- public boolean searchWeakStationList(int numStations)
- {
-
- boolean bStatus=false;
- FmConfig config = FmSharedPreferences.getFMConfiguration();
-
- if(null != mTransmitter) {
- mTransmitter.disable();
- mTransmitter = null;
- mFMOn = false;
- }
- if(null != mReceiver) {
- mReceiver.disable();
- mReceiver = null;
- }
- try {
- Thread.sleep(100);//SoC needs a delay to switch mode
- } catch (Exception ex) {
- Log.d( LOGTAG, "RunningThread InterruptedException");
- }
-
-
- if(null == mReceiver) {
- try {
- mReceiver = new FmReceiver(FMRADIO_DEVICE_FD_STRING, fmCallbacks);
- }
- catch (InstantiationException e){
- throw new RuntimeException("FmTx service not available!");
- }
- if (mReceiver.getFMState() == mReceiver.FMState_Turned_Off) {
- bStatus = mReceiver.enable(config);
- } else {
- try {
- Thread.sleep(100);
- } catch (Exception ex) {
- Log.d( LOGTAG, "RunningThread InterruptedException");
- }
- bStatus = mReceiver.enable(config);
- }
- if (!bStatus) {
- Log.e( LOGTAG, "Search for weak station failed");
- return false;
- }
- }
-
- bStatus = mReceiver.setStation(config.getLowerLimit());
-
- Log.d(LOGTAG, "mReceiver.setStation: bStatus: " + bStatus);
- bStatus = mReceiver.searchStationList( FmReceiver.FM_RX_SRCHLIST_MODE_WEAKEST,
- FmReceiver.FM_RX_SEARCHDIR_UP,
- numStations,
- 0);
-
- mFMSearchStations = 0;//numStations;
- if(bStatus == false)
- {
- try
- {
- if (mCallbacks != null)
- {
- mCallbacks.onSearchListComplete(false);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- return bStatus;
- }
-
- /* Cancel any ongoing Search (Seek/Scan/SearchStationList).
- *
- * @return true if Search command was invoked successfully, false if not muted.
- * Note: 1. Callback FmRxEvSearchComplete will be called when the Search
- * is complete/cancelled.
- * 2. Callback FmRxEvRadioTuneStatus will also be called when tuned to a station
- * at the end of the Search or if the seach was cancelled.
- */
- public boolean cancelSearch()
- {
- boolean bStatus=false;
- if (mReceiver != null)
- {
- bStatus = mReceiver.cancelSearch();
- Log.d(LOGTAG, "mReceiver.cancelSearch: bStatus: " + bStatus);
- try
- {
- if (mCallbacks != null)
- {
- mCallbacks.onSearchListComplete(false);
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
-
- }
- return bStatus;
- }
-
- /* Retrieves the basic String to be displayed on UI
- * Other than this static string the RDS String will be
- * queried by Tx Activity to update on UI
- */
- public String getRadioText() {
- String str = "Radio Text: Transmitting ";
- Log.d(LOGTAG, "Radio Text: [" + str + "]");
- return str;
- }
-
- /* Retrieves the station list from the SearchStationlist.
- *
- * @return Array of integers that represents the station frequencies.
- * Note: 1. This is a synchronous call that should typically called when
- * Callback onSearchListComplete.
- */
- public int[] getSearchList()
- {
- int[] frequencyList = null;
- if (mReceiver != null)
- {
- Log.d(LOGTAG, "getSearchList: ");
- frequencyList = mReceiver.getStationList();
- }
- return frequencyList;
- }
- /* Set the FM Power Mode on the FM hardware SoC.
- * Typically used when UI/Activity is in the background, so the Host is interrupted less often.
- *
- * boolean bLowPower: true: Enable Low Power mode on FM hardware.
- * false: Disable Low Power mode on FM hardware. (Put into normal power mode)
- * @return true if set power mode api was invoked successfully, false if the api failed.
- */
- public boolean setLowPowerMode(boolean bLowPower)
- {
- boolean bCommandSent=false;
- if (mTransmitter != null)
- {
- Log.d(LOGTAG, "setLowPowerMode: " + bLowPower);
- if(bLowPower)
- {
- bCommandSent = mTransmitter.setPowerMode(FmTransmitter.FM_TX_LOW_POWER_MODE);
- }
- else
- {
- bCommandSent = mTransmitter.setPowerMode(FmTransmitter.FM_TX_NORMAL_POWER_MODE);
- }
- }
- return bCommandSent;
- }
- /** Determines if an internal Antenna is available.
- *
- * @return true if internal antenna is available, false if
- * internal antenna is not available.
- */
- public boolean isInternalAntennaAvailable()
- {
- boolean bAvailable = false;
- /* Update this when the API is available */
-
- if(null != mTransmitter ) {
- bAvailable = mTransmitter.getInternalAntenna();
- Log.d(LOGTAG, "internalAntennaAvailable: " + bAvailable);
- } else if( null != mReceiver ) {
- bAvailable = mReceiver.getInternalAntenna();
- Log.d(LOGTAG, "internalAntennaAvailable: " + bAvailable);
- }
- return bAvailable;
- }
-
-
- private FmTransmitterCallbacksAdaptor transmitCallbacks = new FmTransmitterCallbacksAdaptor() {
- public void FmTxEvRDSGroupsAvailable() {
- // Do nothing
- }
-
- public void FmTxEvRDSGroupsComplete() {
- // Do nothing
- }
- public void FmTxEvContRDSGroupsComplete() {
- }
-
- public void FmTxEvTuneStatusChange(int freq) {
-
- Log.d(LOGTAG, "onTuneStatusChange\n");
- if (mCallbacks != null)
- {
- try
- {
- mCallbacks.onTuneStatusChanged(freq);
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- /* Update the frequency in the StatusBar's Notification */
- startNotification();
-
- String s = getPSData();
- if( true == mTransmitter.startPSInfo(
- s, FM_TX_PROGRAM_TYPE, FM_TX_PROGRAM_ID, FM_TX_PS_REPEAT_COUNT ) ) {
- if (mCallbacks != null)
- {
- try
- {
- mCallbacks.onPSInfoSent(s);
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- if (mTransmitter != null ){
- mTransmitter.startRTInfo(RText, FM_TX_PROGRAM_TYPE, FM_TX_PROGRAM_ID );
- }
-
- try {
- if (mCallbacks != null ) {
- mCallbacks.onMetaDataChanged(RText);
- } else {
- Log.d(LOGTAG, "callback is not there");
- }
- } catch (RemoteException ex){
- ex.printStackTrace();
- }
-
- }
-
- public void FmTxEvRadioDisabled() {
- Log.d(LOGTAG, "onRadioDisabled");
- mFMOn = false;
- if((mServiceInUse) && (mCallbacks != null) ) {
- try {
- mCallbacks.onDisabled();
- } catch(RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- public void FmTxEvRadioEnabled() {
- mFMOn = true;
- if((mServiceInUse) && (mCallbacks != null) ) {
- try {
- mCallbacks.onEnabled(true);
- } catch(RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- public void FmTxEvRadioReset() {
- if(isFmOn()) {
- // Received Radio Disable event unexpectedly
- Log.d(LOGTAG, "FM is ON, reset FM");
- fmRadioReset();
- try {
- /* Notify the UI/Activity, only if the service is "bound"
- by an activity and if Callbacks are registered
- */
- if((mServiceInUse) && (mCallbacks != null)) {
- mCallbacks.onRadioReset();
- }
- }
- catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- };
-
- /* Receiver callbacks back from the FM Stack */
- FmRxEvCallbacksAdaptor fmCallbacks = new FmRxEvCallbacksAdaptor()
- {
- public void FmRxEvEnableReceiver()
- {
- Log.d(LOGTAG, "FmRxEvEnableReceiver");
- }
- public void FmRxEvDisableReceiver()
- {
- Log.d(LOGTAG, "FmRxEvDisableReceiver");
- }
- public void FmRxEvRadioReset()
- {
- Log.d(LOGTAG, "FmRxEvRadioReset");
- if(isFmOn()) {
- // Received Radio Reset event
- Log.d(LOGTAG, "FM is ON, reset FM");
- fmRadioReset();
- try
- {
- /* Notify the UI/Activity, only if the service is "bound"
- by an activity and if Callbacks are registered
- */
- if((mServiceInUse) && (mCallbacks != null) )
- {
- mCallbacks.onRadioReset();
- }
- }
- catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public void FmRxEvRadioTuneStatus(int frequency)
- {
- Log.d(LOGTAG, "FmRxEvRadioTuneStatus: Tuned Frequency: " +frequency);
- }
-
- public void FmRxEvSearchListComplete()
- {
- Log.d(LOGTAG, "FmRxEvSearchListComplete");
- try
- {
- if (mCallbacks != null) {
- mCallbacks.onSearchListComplete(true);
- } else if(mReceiver != null) {
- mReceiver.disable();
- }
- } catch (RemoteException e)
- {
- e.printStackTrace();
- }
- }
- };
-
-
- /*
- * Read the Tuned Frequency from the FM module.
- */
- private String getTunedFrequencyString() {
- double frequency = mTunedFrequency / 1000.0;
- String frequencyString = getString(R.string.stat_notif_tx_frequency, (""+frequency));
- return frequencyString;
- }
- /**
- * Registers an intent to listen for ACTION_HEADSET_PLUG
- * notifications. This intent is called to know if the headset
- * was plugged in/out
- */
- public void registerHeadsetListener() {
- if (mHeadsetReceiver == null) {
- mHeadsetReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
- Log.d(LOGTAG, "ACTION_HEADSET_PLUG Intent received");
- // Listen for ACTION_HEADSET_PLUG broadcasts.
- Log.d(LOGTAG, "mTransmitter: ACTION_HEADSET_PLUG");
- Log.d(LOGTAG, "==> intent: " + intent);
- Log.d(LOGTAG, " state: " + intent.getIntExtra("state", 0));
- Log.d(LOGTAG, " name: " + intent.getStringExtra("name"));
- mHeadsetPlugged = (intent.getIntExtra("state", 0) == 1);
- mHandler.post(mChangeFMTxState);
-
- } else if (mA2dpDeviceState.isA2dpStateChange(action)) {
- if (mA2dpDeviceState.isConnected(intent)){
- Log.d(LOGTAG, " A2DP connected");
- mHeadsetPlugged = true;
- if( mFMOn == true)
- {
- mHandler.post(mChangeFMTxState);
- }
- } else if( !mA2dpDeviceState.isConnected(intent)) {
- Log.d(LOGTAG, "A2DP disconnected");
- mHeadsetPlugged = false;
- if( mFMOn == false) // when FM Tx App open, DISC BT
- {
- Log.d(LOGTAG, "posting for a2dp state change");
- mHandler.post(mChangeFMTxState);
- }
- }
- } else if (action.equals("HDMI_CONNECTED")) {
- if( mFMOn == true) {
- Log.d(LOGTAG, "posting for hdmi state change");
- mHandler.post(mChangeFMTxState);
- }
- }
- }
- };
- IntentFilter iFilter = new IntentFilter();
- iFilter.addAction(Intent.ACTION_HEADSET_PLUG);
- iFilter.addAction(mA2dpDeviceState.getActionSinkStateChangedString());
- iFilter.addAction(mA2dpDeviceState.getActionPlayStateChangedString());
- iFilter.addAction("HDMI_CONNECTED");
- iFilter.addCategory(Intent.CATEGORY_DEFAULT);
- registerReceiver(mHeadsetReceiver, iFilter);
- }
- }
- final Runnable mChangeFMTxState = new Runnable() {
- public void run() {
- boolean bStatus = false;
-
- Log.d(LOGTAG, "Enter change FM Tx State");
- /* Update the UI based on the state change of the headset/antenna*/
- if(mHeadsetPlugged) {
- bStatus = cancelSearch();
- if(bStatus == false)
- Log.e(LOGTAG, "Error in cancelling the search");
- if(isFmOn()) {
- Log.d(LOGTAG, "disable called from headset handler");
- bStatus = fmOff();
- if(mServiceInUse && (mCallbacks != null) && (bStatus == true)) {
- try {
- mCallbacks.onDisabled();
- } catch(RemoteException e) {
- e.printStackTrace();
- }
- } else if(bStatus == false) {
- Log.e(LOGTAG, "Error in turning off the FM TX ");
- }
- } else if(mReceiver != null) {
- bStatus = mReceiver.disable();
- if(bStatus == true)
- mReceiver = null;
- else
- Log.e(LOGTAG, "Error in disabling the FM RX");
- }
- }else {
- if(!isFmOn()) {
- bStatus = fmOn();
- if(mServiceInUse && (mCallbacks != null) && (bStatus == true)) {
- try {
- mCallbacks.onEnabled(true);
- } catch(RemoteException e) {
- e.printStackTrace();
- }
- } else if(bStatus == false) {
- Log.e(LOGTAG, "Error in enabling the FM TX");
- }
- }
- }
- }
- };
-
- private class RdsDisplay extends IRemoteControlDisplay.Stub {
- RdsDisplay() {
- }
-
- @Override
- public void setPlaybackState(int generationId, int state, long stateChangeTimeMs,
- long currentPosMs, float speed) {
- }
-
- @Override
- public void setMetadata(int generationId, Bundle metadata) {
- updateMetadata(metadata);
- }
-
- @Override
- public void setTransportControlInfo(int generationId, int flags, int posCapabilities) {
- }
-
- @Override
- public void setArtwork(int generationId, Bitmap bitmap) {
- }
-
- @Override
- public void setAllMetadata(int generationId, Bundle metadata, Bitmap bitmap) {
- }
-
- @Override
- public void setCurrentClientId(int clientGeneration, PendingIntent clientMediaIntent,
- boolean clearing) {
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- }
-
- @Override
- public void updateFolderInfoBrowsedPlayer(String stringUri) {
- }
-
- @Override
- public void updateNowPlayingContentChange() {
- }
-
- @Override
- public void playItemResponse(boolean success) {
- }
-
- @Override
- public void updateNowPlayingEntries(long[] playList) {
- }
- }
-
- class Metadata {
- private String artist;
- private String trackTitle;
- private String albumTitle;
-
- public Metadata() {
- artist = null;
- trackTitle = null;
- albumTitle = null;
- }
-
- public String toString() {
- return "Metadata[artist=" + artist + " trackTitle=" + trackTitle + " albumTitle=" +
- albumTitle + "]";
- }
- }
-
- private String getMdString(Bundle data, int id) {
- return data.getString(Integer.toString(id));
- }
-
- private void updateMetadata(Bundle data) {
- String oldMetadata = mMetadata.toString();
- mMetadata.artist = getMdString(data, MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST);
- mMetadata.trackTitle = getMdString(data, MediaMetadataRetriever.METADATA_KEY_TITLE);
- mMetadata.albumTitle = getMdString(data, MediaMetadataRetriever.METADATA_KEY_ALBUM);
- Log.v(LOGTAG, "mMetadata=" + mMetadata.toString());
- if (mTransmitter != null ){
- RText = mMetadata.albumTitle +":" + mMetadata.trackTitle +":"+ mMetadata.artist;
- Log.d(LOGTAG,"RT string size is "+RText.length());
- mTransmitter.startRTInfo(RText, FM_TX_PROGRAM_TYPE, FM_TX_PROGRAM_ID );
- }
-
- try {
- if (mCallbacks != null ) {
- mCallbacks.onMetaDataChanged(RText);
- } else {
- Log.d(LOGTAG, "callback is not there");
- }
- } catch (RemoteException ex){
- ex.printStackTrace();
- }
- }
- public boolean isHeadsetPlugged() {
- if (mA2dpDeviceState.isDeviceAvailable())
- mHeadsetPlugged = true;
- return mHeadsetPlugged;
- }
- public boolean isCallActive() {
- TelephonyManager tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- if( TelephonyManager.CALL_STATE_IDLE !=tmgr.getCallState() )
- return true;
- return false;
- }
- public String getPSData(){
- return QFM_STRING;
- }
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java b/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
deleted file mode 100644
index 7fcb6a5..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
+++ /dev/null
@@ -1,1158 +0,0 @@
-/*
- * 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;
- }
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/FmTags.java b/fmapp/src/com/codeaurora/fmradio/FmTags.java
deleted file mode 100644
index c54196a..0000000
--- a/fmapp/src/com/codeaurora/fmradio/FmTags.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2011-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 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 android.app.Activity;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Handler;
-import android.os.Message;
-import android.os.RemoteException;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ProgressBar;
-import android.widget.Spinner;
-import android.widget.TableLayout;
-import android.widget.TableRow;
-import android.widget.TextView;
-import android.widget.ListView;
-
-
-public class FmTags extends Activity {
- private ListView la;
- private ArrayAdapter<String> adapter;
- private final Handler mHandler = new Handler();
- private Iterator itr;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.fmtags);
- la = (ListView)findViewById(R.id.TagListView);
- }
- @Override
- public void onStart() {
- super.onStart();
- }
- @Override
- public void onResume() {
- super.onResume();
- mHandler.post(mDisplayTagList);
- }
- final Runnable mDisplayTagList = new Runnable() {
- public void run() {
- String[] tags;
- int l = 0;
-
- tags = new String[FmSharedPreferences.num_tags];
- for(int i = 0; i < FmSharedPreferences.MAX_NUM_TAG_TYPES; i++) {
- if (FmSharedPreferences.tagList[i] != null) {
- itr = FmSharedPreferences.tagList[i].iterator();
- while(itr.hasNext())
- tags[l++] = ((FmSharedPreferences.TAG_NAMES[i]) + "\n" +
- "\t" + (String)itr.next());
- }
- }
- adapter = new ArrayAdapter(la.getContext(), android.R.layout.simple_list_item_1, tags);
- la.setAdapter(adapter);
- }
- };
-}
-
-
diff --git a/fmapp/src/com/codeaurora/fmradio/GetNextFreqInterface.java b/fmapp/src/com/codeaurora/fmradio/GetNextFreqInterface.java
deleted file mode 100644
index 3330887..0000000
--- a/fmapp/src/com/codeaurora/fmradio/GetNextFreqInterface.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 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;
-
-public interface GetNextFreqInterface {
- public int getNextFreq();
- public void Stop();
- public boolean errorOccured();
-}
-
diff --git a/fmapp/src/com/codeaurora/fmradio/IFMRadioService.aidl b/fmapp/src/com/codeaurora/fmradio/IFMRadioService.aidl
deleted file mode 100644
index 317a176..0000000
--- a/fmapp/src/com/codeaurora/fmradio/IFMRadioService.aidl
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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 com.codeaurora.fmradio.IFMRadioServiceCallbacks;
-
-interface IFMRadioService
-{
- boolean fmOn();
- boolean fmOff();
- boolean fmRadioReset();
- boolean isFmOn();
- boolean isAnalogModeEnabled();
- boolean isFmRecordingOn();
- boolean isSpeakerEnabled();
- boolean fmReconfigure();
- void registerCallbacks(IFMRadioServiceCallbacks cb);
- void unregisterCallbacks();
- boolean mute();
- boolean routeAudio(int device);
- boolean unMute();
- boolean isMuted();
- void startRecording();
- void stopRecording();
- boolean tune(int frequency);
- boolean seek(boolean up);
- void enableSpeaker(boolean speakerOn);
- boolean scan(int pty);
- boolean seekPI(int piCode);
- boolean searchStrongStationList(int numStations);
- int[] getSearchList();
- boolean cancelSearch();
- String getProgramService();
- String getRadioText();
- int getProgramType();
- int getProgramID();
- boolean setLowPowerMode(boolean bLowPower);
- int getPowerMode();
- boolean enableAutoAF(boolean bEnable);
- boolean enableStereo(boolean bEnable);
- boolean isAntennaAvailable();
- boolean isWiredHeadsetAvailable();
- boolean isCallActive();
- int getRssi();
- int getIoC();
- int getMpxDcc();
- int getIntDet();
- int getSINR();
- void setHiLoInj(int inj);
- void delayedStop(long nDuration, int nType);
- void cancelDelayedStop (int nType);
- void requestFocus();
- boolean setSinrSamplesCnt(int samplesCnt);
- boolean setSinrTh(int sinr);
- boolean setIntfDetLowTh(int intfLowTh);
- boolean setIntfDetHighTh(int intfHighTh);
- String getExtenRadioText();
- int getSinrSamplesCnt();
- int getSinrTh();
- int getSearchAlgoType();
- boolean setSearchAlgoType(int searchType);
- int getSinrFirstStage();
- boolean setSinrFirstStage(int sinr);
- int getRmssiFirstStage();
- boolean setRmssiFirstStage(int rmssi);
- int getCFOMeanTh();
- boolean setCFOMeanTh(int cf0);
- boolean setAfJmpRmssiTh(int afJmpRmssiTh);
- boolean setGoodChRmssiTh(int gdChRmssiTh);
- boolean setAfJmpRmssiSamplesCnt(int afJmpRmssiSmplsCnt);
- int getAfJmpRmssiTh();
- int getGoodChRmssiTh();
- int getAfJmpRmssiSamplesCnt();
- boolean setRxRepeatCount(int count);
- long getRecordingStartTime();
-}
-
diff --git a/fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl b/fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl
deleted file mode 100644
index 4d116ec..0000000
--- a/fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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;
-
-interface IFMRadioServiceCallbacks
-{
- void onEnabled();
- void onDisabled();
- void onRadioReset();
- void onTuneStatusChanged();
- void onProgramServiceChanged();
- void onRadioTextChanged();
- void onAlternateFrequencyChanged();
- void onSignalStrengthChanged();
- void onSearchComplete();
- void onSearchListComplete();
- void onMute(boolean bMuted);
- void onAudioUpdate(boolean bStereo);
- void onStationRDSSupported(boolean bRDSSupported);
- void onRecordingStopped();
- void onExtenRadioTextChanged();
- void onRecordingStarted();
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl b/fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl
deleted file mode 100644
index 39bc70b..0000000
--- a/fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 com.codeaurora.fmradio.IFMTransmitterServiceCallbacks;
-interface IFMTransmitterService
-{
- boolean fmOn();
- boolean fmOff();
- boolean fmRestart();
- boolean isFmOn();
- boolean fmReconfigure();
- void registerCallbacks(IFMTransmitterServiceCallbacks cb);
- void unregisterCallbacks();
- boolean tune(int frequency);
- boolean searchWeakStationList(int numStations);
- int[] getSearchList();
- boolean cancelSearch();
- String getRadioText();
- boolean isInternalAntennaAvailable();
- boolean isHeadsetPlugged();
- boolean isCallActive();
- String getPSData();
-}
-
diff --git a/fmapp/src/com/codeaurora/fmradio/IFMTransmitterServiceCallbacks.aidl b/fmapp/src/com/codeaurora/fmradio/IFMTransmitterServiceCallbacks.aidl
deleted file mode 100644
index 27a7249..0000000
--- a/fmapp/src/com/codeaurora/fmradio/IFMTransmitterServiceCallbacks.aidl
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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;
-
-interface IFMTransmitterServiceCallbacks
-{
- void onEnabled(boolean bStatus);
- void onDisabled();
- void onRadioReset();
- void onTuneStatusChanged(int frequency);
- void onRadioTextChanged();
- void onSearchListComplete(boolean bStatus);
- void onReconfigured();
- void onMetaDataChanged(String str);
- void onPSInfoSent(String str);
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/PresetList.java b/fmapp/src/com/codeaurora/fmradio/PresetList.java
deleted file mode 100644
index a2fd1a9..0000000
--- a/fmapp/src/com/codeaurora/fmradio/PresetList.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * 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.ArrayList;
-import java.util.List;
-
-public class PresetList{
- private List<PresetStation> mPresetList = new ArrayList<PresetStation>();
- private int mCurrentStation = 0;
- private String mListName = "";
-
- public PresetList(String name) {
- mListName = name;
- }
-
- public String getName(){
- return mListName;
- }
-
- public String toString(){
- return mListName;
- }
-
- public synchronized int getStationCount(){
- return mPresetList.size();
- }
-
- public synchronized String getStationName(int stationNum){
- String name = "";
- if (mPresetList.size() > stationNum){
- name = mPresetList.get(stationNum).getName();
- }
- return name;
- }
-
- public synchronized int getStationFrequency(int stationNum){
- int frequency = 102100;
- if (mPresetList.size() > stationNum){
- frequency = mPresetList.get(stationNum).getFrequency();
- }
- return frequency;
- }
-
- public void setName(String name){
- mListName = name;
- }
-
- public synchronized void setStationFrequency(int stationNum, int frequency){
- PresetStation mStation = mPresetList.get(stationNum);
- mStation.setFrequency(frequency);
- }
-
- public synchronized void setStationName(int stationNum, String name){
- PresetStation mStation = mPresetList.get(stationNum);
- mStation.setName(name);
- }
-
- public synchronized PresetStation getStationFromIndex(int index){
- int totalPresets = mPresetList.size();
- PresetStation station = null;
- if (index < totalPresets) {
- station = mPresetList.get(index);
- }
- return station;
- }
-
- public synchronized PresetStation getStationFromFrequency(int frequency){
- int totalPresets = mPresetList.size();
- for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
- PresetStation station = mPresetList.get(presetNum);
- if (station != null) {
- if(frequency == station.getFrequency()) {
- return station;
- }
- }
- }
- return null;
- }
-
- public synchronized PresetStation addStation(String name, int freq){
- PresetStation addStation = new PresetStation(name, freq);
- if(addStation != null) {
- mPresetList.add(addStation);
- }
- return addStation;
- }
-
- public synchronized PresetStation addStation(PresetStation station){
- PresetStation addStation = null;
- if(station != null) {
- addStation = new PresetStation (station);
- mPresetList.add(addStation);
- }
- return addStation;
- }
-
- public synchronized void removeStation(int index){
- int totalPresets = mPresetList.size();
- if((index >= 0) && (index < totalPresets))
- {
- mPresetList.remove(index);
- }
- }
-
- public synchronized void removeStation(PresetStation station){
- int index = mPresetList.indexOf(station);
- int totalPresets = mPresetList.size();
- if((index >= 0) && (index < totalPresets))
- {
- mPresetList.remove(index);
- }
- }
- public synchronized void clear(){
- mPresetList.clear();
- }
-
- /* If a user selects a new station in this list, this routine will be called to
- * to update the list.
- */
- public synchronized boolean setSelectedStation(PresetStation selectStation){
- int totalPresets = mPresetList.size();
- if (selectStation != null) {
- for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
- PresetStation station = mPresetList.get(presetNum);
- if (station != null) {
- if(selectStation.getFrequency() == station.getFrequency()) {
- if(selectStation.getName().equalsIgnoreCase(station.getName())) {
- mCurrentStation = presetNum;
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- /* Check if the same station already exists in a List
- * to update the list.
- */
- public synchronized boolean sameStationExists(PresetStation compareStation){
- int totalPresets = mPresetList.size();
- if (compareStation != null) {
- for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
- PresetStation station = mPresetList.get(presetNum);
- if (station != null) {
- if(compareStation.getFrequency() == station.getFrequency()) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /* If a user selects a new station in this list, this routine will be called to
- * to update the list.
- */
- public synchronized boolean setSelectedStation(int stationIndex){
- boolean foundStation = false;
- int totalPresets = mPresetList.size();
- if (stationIndex < totalPresets) {
- mCurrentStation = stationIndex;
- foundStation = true;
- }
- return foundStation;
- }
-
- public synchronized PresetStation getSelectedStation(){
- int totalPresets = mPresetList.size();
- PresetStation station = null;
- if (mCurrentStation < totalPresets) {
- station = mPresetList.get(mCurrentStation);
- }
- return station;
- }
-
- public synchronized PresetStation selectNextStation(){
- int totalPresets = mPresetList.size();
- PresetStation station = null;
- if(totalPresets > 0) {
- mCurrentStation ++;
- if ( (mCurrentStation) >= totalPresets) {
- mCurrentStation =0;
- }
- station = mPresetList.get(mCurrentStation);
- }
- return station;
- }
-
- public synchronized PresetStation selectPrevStation(){
- int totalPresets = mPresetList.size();
- PresetStation station = null;
- if(totalPresets > 0) {
- mCurrentStation --;
- if ( mCurrentStation < 0) {
- mCurrentStation = totalPresets-1;
- }
- station = mPresetList.get(mCurrentStation);
- }
- return station;
- }
-
- public synchronized void selectStation(PresetStation selectStation){
- int totalPresets = mPresetList.size();
- if (selectStation != null) {
- for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
- PresetStation station = mPresetList.get(presetNum);
- if (station != null) {
- if(selectStation.getFrequency() == station.getFrequency()) {
- mCurrentStation = presetNum;
- return;
- }
- }
- }
- }
- }
-
- /* Test Code */
- public void addDummyStations() {
- PresetStation station;
- int freq;
- String name ;
- int pty ;
-
- mPresetList.clear();
- freq = 89500;
- name = "KPBS";
- pty = 22; //public
- station = addStation(name, freq);
- if(station != null) {
- station.setPty(pty);
- station.setPI(0);
- station.setRDSSupported(false);
- }
-
- freq = 96500;
- name = "KYXY";
- //pty = "Soft Rock";
- pty = 8;
-
- station = addStation(name, freq);
- if(station != null) {
- station.setPty(pty);
- station.setPI(0);
- station.setRDSSupported(false);
- }
-
- freq = 98100;
- name = "KIFM";
- //pty = "Smooth Jazz";
- pty = 14;
-
- station = addStation(name, freq);
- if(station != null) {
- station.setPty(pty);
- station.setPI(0);
- station.setRDSSupported(false);
- }
-
- freq = 101500;
- name = "KGB";
- //pty = "Classic Rock";
- pty = 6;
-
- station = addStation(name, freq);
- if(station != null) {
- station.setPty(pty);
- station.setPI(0);
- station.setRDSSupported(false);
- }
-
- freq = 102100;
- name = "KPRI";
- //pty = "Rock";
- pty = 5;
- station = addStation(name, freq);
- if(station != null) {
- station.setPty(pty);
- station.setPI(0);
- station.setRDSSupported(true);
- }
-
- freq = 105300;
- name = "KIOZ";
- //pty = "Rock";
- pty = 5;
- station = addStation(name, freq);
- if(station != null) {
- station.setPty(pty);
- station.setPI(0);
- station.setRDSSupported(true);
- }
- }
-
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/PresetStation.java b/fmapp/src/com/codeaurora/fmradio/PresetStation.java
deleted file mode 100644
index 01a3ba0..0000000
--- a/fmapp/src/com/codeaurora/fmradio/PresetStation.java
+++ /dev/null
@@ -1,951 +0,0 @@
-/*
- * 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 qcom.fmradio.FmReceiver;
-
-import android.text.TextUtils;
-//import android.util.Log;
-
-public class PresetStation
-{
- private String mName = "";
- private int mFrequency = 102100;
- private int mPty = 0;
- private int mPI = 0;
- private String mPtyStr = "";
- private String mPIStr = "";
- private boolean mRDSSupported = false;
-
- public PresetStation(String name, int frequency) {
- mName = name;
- /*
- * setFrequency set the name to
- * "Frequency" String if Name is empty
- */
- setFrequency(frequency);
- }
-
- public PresetStation(PresetStation station) {
- Copy(station);
- /*
- * setFrequency set the name to
- * "Frequency" String if Name is empty
- */
- setFrequency(station.getFrequency());
- }
-
- public void Copy(PresetStation station) {
- /* Let copy just do a copy
- * without any manipulation
- */
- mName = station.getName();
- mFrequency = station.getFrequency();
- mPI = station.getPI();
- mPty = station.getPty();
- mRDSSupported = station.getRDSSupported();
-
- mPtyStr = station.getPtyString();
- mPIStr = station.getPIString();
- }
-
- public boolean equals(PresetStation station) {
- boolean equal = false;
- if (mFrequency == station.getFrequency())
- {
- if (mPty == (station.getPty()))
- {
- if (mPI == (station.getPI()))
- {
- if (mRDSSupported == (station.getRDSSupported()))
- {
- equal = true;
- }
- }
- }
- }
- return equal;
- }
-
- public void setName(String name){
- if (!TextUtils.isEmpty(name))
- {
- mName = name;
- } else
- {
- mName = ""+mFrequency/1000.0;
- }
- }
-
- public void setFrequency(int freq){
- mFrequency = freq;
- /* If no name set it to the frequency */
- if (TextUtils.isEmpty(mName))
- {
- mName = ""+mFrequency/1000.0;
- }
- return;
- }
-
- public void setPty(int pty){
- mPty = pty;
- mPtyStr = PresetStation.parsePTY(mPty);
- }
-
- public void setPI(int pi){
- mPI = pi;
- mPIStr = PresetStation.parsePI(mPI);
- }
-
- public void setRDSSupported(boolean rds){
- mRDSSupported = rds;
- }
-
- public String getName(){
- return mName;
- }
-
- public int getFrequency(){
- return mFrequency;
- }
-
- /**
- * Routine to get the Frequency in String from an integer
- *
- * @param frequency : Frequency to be converted (ex: 96500)
- *
- * @return String : Frequency in String form (ex: 96.5)
- */
- public static String getFrequencyString(int frequency) {
- double frequencyDbl = frequency / 1000.0;
- String frequencyString =""+frequencyDbl;
- return frequencyString;
- }
-
- public int getPty(){
- return mPty;
- }
-
- public String getPtyString(){
- return mPtyStr;
- }
-
- public int getPI(){
- return mPI;
- }
-
- public String getPIString(){
- return mPIStr;
- }
-
- public boolean getRDSSupported(){
- return mRDSSupported;
- }
-
- /** Routine parses the PI Code from Integer to Call Sign String
- * Example: 0x54A6 -> KZZY
- */
- public static String parsePI(int piCode)
- {
- String callSign = "";
- if ( (piCode >> 8) == 0xAF)
- {//CALL LETTERS THAT MAP TO PI CODES = _ _ 0 0.
- piCode = ((piCode & 0xFF) << 8);
- }
- /* Run the second exception
- NOTE: For 9 special cases 1000,2000,..,9000 a double mapping
- occurs utilizing exceptions 1 and 2:
- 1000->A100->AFA1;2000->A200->AFA2; ... ;
- 8000->A800->AFA8;9000->A900->AFA9
- */
- if ( (piCode >> 12) == 0xA)
- {//CALL LETTERS THAT MAP TO PI CODES = _ 0 _ _.
- piCode = ((piCode & 0xF00) << 4) + (piCode & 0xFF);
- }
- if ( (piCode >= 0x1000) && (piCode <= 0x994E))
- {
- String ShartChar;
- /* KAAA - KZZZ */
- if ( (piCode >= 0x1000) && (piCode <= 0x54A7))
- {
- piCode -= 0x1000;
- ShartChar = "K";
- } else
- { /* WAAA - WZZZ*/
- piCode -= 0x54A8;
- ShartChar = "W";
- }
- int CharDiv = piCode / 26;
- int CharPos = piCode - (CharDiv * 26);
- char c3 = (char)('A'+CharPos);
-
- piCode = CharDiv;
- CharDiv = piCode / 26;
- CharPos = piCode - (CharDiv * 26);
- char c2 = (char)('A'+CharPos);
-
- piCode = CharDiv;
- CharDiv = piCode / 26;
- CharPos = piCode - (CharDiv * 26);
- char c1 = (char)('A'+CharPos);
- callSign = ShartChar + c1+ c2+ c3;
- } else if ( (piCode >= 0x9950) && (piCode <= 0x9EFF))
- {//3-LETTER-ONLY CALL LETTERS
- callSign = get3LetterCallSign(piCode);
- } else
- {//NATIONALLY-LINKED RADIO STATIONS CARRYING DIFFERENT CALL LETTERS
- callSign = getOtherCallSign(piCode);
- }
- return callSign;
- }
-
- private static String getOtherCallSign(int piCode)
- {
- String callSign = "";
- if ( (piCode >= 0xB001) && (piCode <= 0xBF01))
- {
- callSign = "NPR";
- } else if ( (piCode >= 0xB002) && (piCode <= 0xBF02))
- {
- callSign = "CBC English";
- } else if ( (piCode >= 0xB003) && (piCode <= 0xBF03))
- {
- callSign = "CBC French";
- }
- return callSign;
- }
-
- private static String get3LetterCallSign(int piCode)
- {
- String callSign = "";
- switch (piCode)
- {
- case 0x99A5:
- {
- callSign = "KBW";
- break;
- }
- case 0x9992:
- {
- callSign = "KOY";
- break;
- }
- case 0x9978:
- {
- callSign = "WHO";
- break;
- }
- case 0x99A6:
- {
- callSign = "KCY";
- break;
- }
- case 0x9993:
- {
- callSign = "KPQ";
- break;
- }
- case 0x999C:
- {
- callSign = "WHP";
- break;
- }
- case 0x9990:
- {
- callSign = "KDB";
- break;
- }
- case 0x9964:
- {
- callSign = "KQV";
- break;
- }
- case 0x999D:
- {
- callSign = "WIL";
- break;
- }
- case 0x99A7:
- {
- callSign = "KDF";
- break;
- }
- case 0x9994:
- {
- callSign = "KSD";
- break;
- }
- case 0x997A:
- {
- callSign = "WIP";
- break;
- }
- case 0x9950:
- {
- callSign = "KEX";
- break;
- }
- case 0x9965:
- {
- callSign = "KSL";
- break;
- }
- case 0x99B3:
- {
- callSign = "WIS";
- break;
- }
- case 0x9951:
- {
- callSign = "KFH";
- break;
- }
- case 0x9966:
- {
- callSign = "KUJ";
- break;
- }
- case 0x997B:
- {
- callSign = "WJR";
- break;
- }
- case 0x9952:
- {
- callSign = "KFI";
- break;
- }
- case 0x9995:
- {
- callSign = "KUT";
- break;
- }
- case 0x99B4:
- {
- callSign = "WJW";
- break;
- }
- case 0x9953:
- {
- callSign = "KGA";
- break;
- }
- case 0x9967:
- {
- callSign = "KVI";
- break;
- }
- case 0x99B5:
- {
- callSign = "WJZ";
- break;
- }
- case 0x9991:
- {
- callSign = "KGB";
- break;
- }
- case 0x9968:
- {
- callSign = "KWG";
- break;
- }
- case 0x997C:
- {
- callSign = "WKY";
- break;
- }
- case 0x9954:
- {
- callSign = "KGO";
- break;
- }
- case 0x9996:
- {
- callSign = "KXL";
- break;
- }
- case 0x997D:
- {
- callSign = "WLS";
- break;
- }
- case 0x9955:
- {
- callSign = "KGU";
- break;
- }
- case 0x9997:
- {
- callSign = "KXO";
- break;
- }
- case 0x997E:
- {
- callSign = "WLW";
- break;
- }
- case 0x9956:
- {
- callSign = "KGW";
- break;
- }
- case 0x996B:
- {
- callSign = "KYW";
- break;
- }
- case 0x999E:
- {
- callSign = "WMC";
- break;
- }
- case 0x9957:
- {
- callSign = "KGY";
- break;
- }
- case 0x9999:
- {
- callSign = "WBT";
- break;
- }
- case 0x999F:
- {
- callSign = "WMT";
- break;
- }
- case 0x99AA:
- {
- callSign = "KHQ";
- break;
- }
- case 0x996D:
- {
- callSign = "WBZ";
- break;
- }
- case 0x9981:
- {
- callSign = "WOC";
- break;
- }
- case 0x9958:
- {
- callSign = "KID";
- break;
- }
- case 0x996E:
- {
- callSign = "WDZ";
- break;
- }
- case 0x99A0:
- {
- callSign = "WOI";
- break;
- }
- case 0x9959:
- {
- callSign = "KIT";
- break;
- }
- case 0x996F:
- {
- callSign = "WEW";
- break;
- }
- case 0x9983:
- {
- callSign = "WOL";
- break;
- }
- case 0x995A:
- {
- callSign = "KJR";
- break;
- }
- case 0x999A:
- {
- callSign = "WGH";
- break;
- }
- case 0x9984:
- {
- callSign = "WOR";
- break;
- }
- case 0x995B:
- {
- callSign = "KLO";
- break;
- }
- case 0x9971:
- {
- callSign = "WGL";
- break;
- }
- case 0x99A1:
- {
- callSign = "WOW";
- break;
- }
- case 0x995C:
- {
- callSign = "KLZ";
- break;
- }
- case 0x9972:
- {
- callSign = "WGN";
- break;
- }
- case 0x99B9:
- {
- callSign = "WRC";
- break;
- }
- case 0x995D:
- {
- callSign = "KMA";
- break;
- }
- case 0x9973:
- {
- callSign = "WGR";
- break;
- }
- case 0x99A2:
- {
- callSign = "WRR";
- break;
- }
- case 0x995E:
- {
- callSign = "KMJ";
- break;
- }
- case 0x999B:
- {
- callSign = "WGY";
- break;
- }
- case 0x99A3:
- {
- callSign = "WSB";
- break;
- }
- case 0x995F:
- {
- callSign = "KNX";
- break;
- }
- case 0x9975:
- {
- callSign = "WHA";
- break;
- }
- case 0x99A4:
- {
- callSign = "WSM";
- break;
- }
- case 0x9960:
- {
- callSign = "KOA";
- break;
- }
- case 0x9976:
- {
- callSign = "WHB";
- break;
- }
- case 0x9988:
- {
- callSign = "WWJ";
- break;
- }
- case 0x99AB:
- {
- callSign = "KOB";
- break;
- }
- case 0x9977:
- {
- callSign = "WHK";
- break;
- }
- case 0x9989:
- {
- callSign = "WWL";
- break;
- }
- }
- return callSign;
- }
-
- /**
- * Get the Text String for the Program type Code
- */
- public static String parsePTY(int pty)
- {
- String ptyStr="";
- int rdsStd = FmSharedPreferences.getFMConfiguration().getRdsStd();
- if(rdsStd == FmReceiver.FM_RDS_STD_RBDS)
- {
- ptyStr = getRBDSPtyString(pty);
- }
- else if(rdsStd == FmReceiver.FM_RDS_STD_RDS)
- {
- ptyStr = getRDSPtyString(pty);
- }
- return (ptyStr);
- }
-
- /**
- * get the Text String for the RBDS Program type Code
- */
- public static String getRBDSPtyString(int pty)
- {
- String ptyStr = "";
- switch (pty)
- {
- case 1:
- {
- ptyStr = "News";
- break;
- }
- case 2:
- {
- ptyStr = "Information";
- break;
- }
- case 3:
- {
- ptyStr = "Sports";
- break;
- }
- case 4:
- {
- ptyStr = "Talk";
- break;
- }
- case 5:
- {
- ptyStr = "Rock";
- break;
- }
- case 6:
- {
- ptyStr = "Classic Rock";
- break;
- }
- case 7:
- {
- ptyStr = "Adult Hits";
- break;
- }
- case 8:
- {
- ptyStr = "Soft Rock";
- break;
- }
- case 9:
- {
- ptyStr = "Top 40";
- break;
- }
- case 10:
- {
- ptyStr = "Country";
- break;
- }
- case 11:
- {
- ptyStr = "Oldies";
- break;
- }
- case 12:
- {
- ptyStr = "Soft";
- break;
- }
- case 13:
- {
- ptyStr = "Nostalgia";
- break;
- }
- case 14:
- {
- ptyStr = "Jazz";
- break;
- }
- case 15:
- {
- ptyStr = "Classical";
- break;
- }
- case 16:
- {
- ptyStr = "Rhythm and Blues";
- break;
- }
- case 17:
- {
- ptyStr = "Soft Rhythm and Blues";
- break;
- }
- case 18:
- {
- ptyStr = "Foreign Language";
- break;
- }
- case 19:
- {
- ptyStr = "Religious Music";
- break;
- }
- case 20:
- {
- ptyStr = "Religious Talk";
- break;
- }
- case 21:
- {
- ptyStr = "Personality";
- break;
- }
- case 22:
- {
- ptyStr = "Public";
- break;
- }
- case 23:
- {
- ptyStr = "College";
- break;
- }
- case 29:
- {
- ptyStr = "Weather";
- break;
- }
- case 30:
- {
- ptyStr = "Emergency Test";
- break;
- }
- case 31:
- {
- ptyStr = "Emergency";
- break;
- }
- default:
- {
- ptyStr = "";
- //Log.e(FMRadio.LOGTAG, "Unknown RBDS ProgramType [" + pty + "]");
- break;
- }
- }
- return ptyStr;
- }
-
- /** get the Text String for the Program type Code */
- public static String getRDSPtyString(int pty)
- {
- String ptyStr = "";
- switch (pty)
- {
- case 1:
- {
- ptyStr = "News";
- break;
- }
- case 2:
- {
- ptyStr = "Current Affairs";
- break;
- }
- case 3:
- {
- ptyStr = "Information";
- break;
- }
- case 4:
- {
- ptyStr = "Sport";
- break;
- }
- case 5:
- {
- ptyStr = "Education";
- break;
- }
- case 6:
- {
- ptyStr = "Drama";
- break;
- }
- case 7:
- {
- ptyStr = "Culture";
- break;
- }
- case 8:
- {
- ptyStr = "Science";
- break;
- }
- case 9:
- {
- ptyStr = "Varied";
- break;
- }
- case 10:
- {
- ptyStr = "Pop Music";
- break;
- }
- case 11:
- {
- ptyStr = "Rock Music";
- break;
- }
- case 12:
- {
- ptyStr = "Easy Listening Music";
- break;
- }
- case 13:
- {
- ptyStr = "Light classical";
- break;
- }
- case 14:
- {
- ptyStr = "Serious classical";
- break;
- }
- case 15:
- {
- ptyStr = "Other Music";
- break;
- }
- case 16:
- {
- ptyStr = "Weather";
- break;
- }
- case 17:
- {
- ptyStr = "Finance";
- break;
- }
- case 18:
- {
- ptyStr = "Children programs";
- break;
- }
- case 19:
- {
- ptyStr = "Social Affairs";
- break;
- }
- case 20:
- {
- ptyStr = "Religion";
- break;
- }
- case 21:
- {
- ptyStr = "Phone In";
- break;
- }
- case 22:
- {
- ptyStr = "Travel";
- break;
- }
- case 23:
- {
- ptyStr = "Leisure";
- break;
- }
- case 24:
- {
- ptyStr = "Jazz Music";
- break;
- }
- case 25:
- {
- ptyStr = "Country Music";
- break;
- }
- case 26:
- {
- ptyStr = "National Music";
- break;
- }
- case 27:
- {
- ptyStr = "Oldies Music";
- break;
- }
- case 28:
- {
- ptyStr = "Folk Music";
- break;
- }
- case 29:
- {
- ptyStr = "Documentary";
- break;
- }
- case 30:
- {
- ptyStr = "Emergency Test";
- break;
- }
- case 31:
- {
- ptyStr = "Emergency";
- break;
- }
- default:
- {
- ptyStr = "";
- //Log.e(FMRadio.LOGTAG, "Unknown RDS ProgramType [" + pty + "]");
- break;
- }
- }
- return ptyStr;
- }
-
-
-}
diff --git a/fmapp/src/com/codeaurora/fmradio/Settings.java b/fmapp/src/com/codeaurora/fmradio/Settings.java
deleted file mode 100644
index f29c3df..0000000
--- a/fmapp/src/com/codeaurora/fmradio/Settings.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * 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 android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.content.Intent;
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceScreen;
-import android.preference.ListPreference;
-import android.preference.CheckBoxPreference;
-import android.preference.PreferenceCategory;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.EditTextPreference;
-import android.text.InputType;
-import android.widget.Toast;
-
-import android.util.Log;
-
-public class Settings extends PreferenceActivity implements
- OnSharedPreferenceChangeListener, OnPreferenceClickListener {
- public static final String RX_MODE = "rx_mode";
-
-
- public static final String REGIONAL_BAND_KEY = "regional_band";
- public static final String AUDIO_OUTPUT_KEY = "audio_output_mode";
- public static final String RECORD_DURATION_KEY = "record_duration";
- public static final String AUTO_AF = "af_checkbox_preference";
- public static final String RESTORE_FACTORY_DEFAULT = "revert_to_fac";
- public static final int RESTORE_FACTORY_DEFAULT_INT = 1;
- public static final String USER_DEFINED_BAND_MIN_KEY = "user_defined_band_min";
- public static final String USER_DEFINED_BAND_MAX_KEY = "user_defined_band_max";
- public static final String CHAN_SPACING_KEY = "chanl_spacing";
- public static final String RESTORE_FACTORY_DEFAULT_ACTION = "com.codeaurora.fmradio.settings.revert_to_defaults";
-
- private static final String LOGTAG = FMRadio.LOGTAG;
- private static final String USR_BAND_MSG = "Enter Freq from range 76.0 - 108.0";
-
- private ListPreference mBandPreference;
- private ListPreference mAudioPreference;
- private ListPreference mRecordDurPreference;
- private CheckBoxPreference mAfPref;
- private EditTextPreference mUserBandMinPref;
- private EditTextPreference mUserBandMaxPref;
- private ListPreference mChannelSpacingPref;
- private Preference mRestoreDefaultPreference;
-
- private FmSharedPreferences mPrefs = null;
- private boolean mRxMode = false;
-
- private int min_freq;
- private int max_freq;
- private int chan_spacing;
- private String[] summaryBandItems;
- private String[] chSpacingItems;
- private String[] summaryAudioModeItems;
- private String[] summaryRecordItems;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Intent intent = getIntent();
- if (intent != null) {
- mRxMode = intent.getBooleanExtra(RX_MODE, false);
- }
- mPrefs = new FmSharedPreferences(this);
- if (mPrefs != null) {
- setPreferenceScreen(createPreferenceHierarchy());
- }
- }
- private PreferenceScreen createPreferenceHierarchy() {
- int index = 0;
- if (mPrefs == null) {
- return null;
- }
- // Root
- PreferenceScreen root = getPreferenceManager().createPreferenceScreen(
- this);
-
- summaryBandItems = getResources().getStringArray(
- R.array.regional_band_summary);
- chSpacingItems = getResources().getStringArray(
- R.array.channel_spacing_entries);
- mBandPreference = new ListPreference(this);
- mBandPreference.setEntries(R.array.regional_band_entries);
- mBandPreference.setEntryValues(R.array.regional_band_values);
- mBandPreference.setDialogTitle(R.string.sel_band_menu);
- mBandPreference.setKey(REGIONAL_BAND_KEY);
- mBandPreference.setTitle(R.string.regional_band);
- index = FmSharedPreferences.getCountry();
- Log.d(LOGTAG, "createPreferenceHierarchy: Country: " + index);
- // Get the preference and list the value.
- if ((index < 0) || (index >= summaryBandItems.length)) {
- index = 0;
- }
- mBandPreference.setValueIndex(index);
- root.addPreference(mBandPreference);
-
- mChannelSpacingPref = new ListPreference(this);
- mChannelSpacingPref.setEntries(R.array.channel_spacing_entries);
- mChannelSpacingPref.setEntryValues(R.array.channel_spacing_val);
- mChannelSpacingPref.setDialogTitle(R.string.sel_chanl_spacing);
- mChannelSpacingPref.setTitle(R.string.chanl_spacing);
- mChannelSpacingPref.setKey(CHAN_SPACING_KEY);
-
- mUserBandMinPref = new EditTextPreference(this);
- mUserBandMinPref.setKey(USER_DEFINED_BAND_MIN_KEY);
- mUserBandMinPref.setTitle(R.string.usr_def_band_min);
- mUserBandMinPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER |
- InputType.TYPE_NUMBER_FLAG_DECIMAL);
- mUserBandMinPref.setDialogTitle(R.string.usr_def_band_min);
-
- mUserBandMaxPref = new EditTextPreference(this);
- mUserBandMaxPref.setKey(USER_DEFINED_BAND_MAX_KEY);
- mUserBandMaxPref.setTitle(R.string.usr_def_band_max);
- mUserBandMaxPref.setDialogTitle(R.string.usr_def_band_max);
- mUserBandMaxPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER |
- InputType.TYPE_NUMBER_FLAG_DECIMAL);
-
- setBandSummary(index);
-
- root.addPreference(mChannelSpacingPref);
- root.addPreference(mUserBandMinPref);
- root.addPreference(mUserBandMaxPref);
-
- if (mRxMode) {
- // Audio Output (Stereo or Mono)
- summaryAudioModeItems = getResources().getStringArray(
- R.array.ster_mon_entries);
- mAudioPreference = new ListPreference(this);
- mAudioPreference.setEntries(R.array.ster_mon_entries);
- mAudioPreference.setEntryValues(R.array.ster_mon_values);
- mAudioPreference.setDialogTitle(R.string.sel_audio_output);
- mAudioPreference.setKey(AUDIO_OUTPUT_KEY);
- mAudioPreference.setTitle(R.string.aud_output_mode);
- boolean audiomode = FmSharedPreferences.getAudioOutputMode();
- if (audiomode) {
- index = 0;
- } else {
- index = 1;
- }
- Log.d(LOGTAG, "createPreferenceHierarchy: audiomode: " + audiomode);
- mAudioPreference.setSummary(summaryAudioModeItems[index]);
- mAudioPreference.setValueIndex(index);
- root.addPreference(mAudioPreference);
-
- // AF Auto Enable (Checkbox)
- mAfPref = new CheckBoxPreference(this);
- mAfPref.setKey(AUTO_AF);
- mAfPref.setTitle(R.string.auto_select_af);
- mAfPref.setSummaryOn(R.string.auto_select_af_enabled);
- mAfPref.setSummaryOff(R.string.auto_select_af_disabled);
- boolean bAFAutoSwitch = FmSharedPreferences.getAutoAFSwitch();
- Log.d(LOGTAG, "createPreferenceHierarchy: bAFAutoSwitch: "
- + bAFAutoSwitch);
- mAfPref.setChecked(bAFAutoSwitch);
- root.addPreference(mAfPref);
-
-
- if(FMRadio.RECORDING_ENABLE) {
- summaryRecordItems = getResources().getStringArray(
- R.array.record_durations_entries);
- int nRecordDuration = 0;
- mRecordDurPreference = new ListPreference(this);
- mRecordDurPreference.setEntries(R.array.record_durations_entries);
- mRecordDurPreference.setEntryValues(R.array.record_duration_values);
- mRecordDurPreference.setDialogTitle(R.string.sel_rec_dur);
- mRecordDurPreference.setKey(RECORD_DURATION_KEY);
- mRecordDurPreference.setTitle(R.string.record_dur);
- nRecordDuration = FmSharedPreferences.getRecordDuration();
- Log.d(LOGTAG, "createPreferenceHierarchy: recordDuration: "
- + nRecordDuration);
- switch( nRecordDuration ) {
- case FmSharedPreferences.RECORD_DUR_INDEX_0_VAL:
- index = 0;
- break;
- case FmSharedPreferences.RECORD_DUR_INDEX_1_VAL:
- index = 1;
- break;
- case FmSharedPreferences.RECORD_DUR_INDEX_2_VAL:
- index = 2;
- break;
- case FmSharedPreferences.RECORD_DUR_INDEX_3_VAL:
- index = 3;
- break;
- }
- // Get the preference and list the value.
- if ((index < 0) || (index >= summaryRecordItems.length)) {
- index = 0;
- }
- Log.d(LOGTAG, "createPreferenceHierarchy: recordDurationSummary: "
- + summaryRecordItems[index]);
- mRecordDurPreference.setSummary(summaryRecordItems[index]);
- mRecordDurPreference.setValueIndex(index);
- root.addPreference(mRecordDurPreference);
- }
- }
-
- // Add a new category
- PreferenceCategory prefCat = new PreferenceCategory(this);
- root.addPreference(prefCat);
-
- mRestoreDefaultPreference = new Preference(this);
- mRestoreDefaultPreference
- .setTitle(R.string.settings_revert_defaults_title);
- mRestoreDefaultPreference.setKey(RESTORE_FACTORY_DEFAULT);
- mRestoreDefaultPreference
- .setSummary(R.string.settings_revert_defaults_summary);
- mRestoreDefaultPreference.setOnPreferenceClickListener(this);
- root.addPreference(mRestoreDefaultPreference);
- return root;
- }
-
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key) {
- int mTunedFreq = 0;
- boolean bStatus = false;
- if (key.equals(REGIONAL_BAND_KEY)) {
- int curListIndex = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(curListIndex);
- String valueStr = sharedPreferences.getString(key, "");
- int index = 0;
- if (valueStr != null) {
- index = mBandPreference.findIndexOfValue(valueStr);
- }
- if ((index < 0) || (index >= summaryBandItems.length)) {
- index = 0;
- mBandPreference.setValueIndex(0);
- }else if((index + 1) == summaryBandItems.length) {
- mChannelSpacingPref.setEnabled(true);
- }else {
- mChannelSpacingPref.setEnabled(false);
- }
- Log.d(LOGTAG, "onSharedPreferenceChanged: Country Change: "
- + index);
- FmSharedPreferences.setCountry(index);
- setBandSummary(index);
- bStatus = FMRadio.fmConfigure();
- FMTransmitterActivity.fmConfigure();
- if (curList != null) {
- curList.clear();
- }
- }else if(key.equals(CHAN_SPACING_KEY)) {
- int curListIndex = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(curListIndex);
- String valStr = mChannelSpacingPref.getValue();
- int index = 0;
- if(valStr != null) {
- index = mChannelSpacingPref.findIndexOfValue(valStr);
- }
- if ((index < 0) || (index >= summaryRecordItems.length)) {
- index = 0;
- mChannelSpacingPref.setValueIndex(0);
- }
- mChannelSpacingPref.setSummary(chSpacingItems[index]);
- FmSharedPreferences.setChSpacing(2 - index);
- FMRadio.fmConfigure();
- FMTransmitterActivity.fmConfigure();
- if(curList != null) {
- curList.clear();
- }
- }else if(key.equals(USER_DEFINED_BAND_MIN_KEY)) {
- String valStr = mUserBandMinPref.getText();
- double freq = 0;
- try {
- freq = Double.parseDouble(valStr) * 1000;
- }catch(NumberFormatException e) {
- e.printStackTrace();
- return;
- }
- max_freq = FmSharedPreferences.getUpperLimit();
- min_freq = FmSharedPreferences.getLowerLimit();
- if((freq > 0) && (freq < max_freq) && (freq >= 76000)) {
- FmSharedPreferences.setLowerLimit((int)freq);
- FMRadio.fmConfigure();
- FMTransmitterActivity.fmConfigure();
- setBandSummary(summaryBandItems.length - 1);
- }else {
- displayToast(USR_BAND_MSG);
- }
- }else if(key.equals(USER_DEFINED_BAND_MAX_KEY)) {
- String valStr = mUserBandMaxPref.getText();
- double freq = 0;
- try {
- freq = Double.parseDouble(valStr) * 1000;
- }catch(NumberFormatException e) {
- e.printStackTrace();
- return;
- }
- min_freq = FmSharedPreferences.getLowerLimit();
- max_freq = FmSharedPreferences.getUpperLimit();
- if((freq > 0) && (freq > min_freq) && (freq <= 108000)) {
- FmSharedPreferences.setUpperLimit((int)freq);
- FMRadio.fmConfigure();
- FMTransmitterActivity.fmConfigure();
- setBandSummary(summaryBandItems.length - 1);
- }else {
- displayToast(USR_BAND_MSG);
- }
- }else {
- if (mRxMode) {
- if (key.equals(AUTO_AF)) {
- boolean bAFAutoSwitch = mAfPref.isChecked();
- Log.d(LOGTAG, "onSharedPreferenceChanged: Auto AF Enable: "
- + bAFAutoSwitch);
- FmSharedPreferences.setAutoAFSwitch(bAFAutoSwitch);
- FMRadio.fmAutoAFSwitch();
- mPrefs.Save();
- } else if (key.equals(RECORD_DURATION_KEY)) {
- if(FMRadio.RECORDING_ENABLE) {
- String valueStr = mRecordDurPreference.getValue();
- int index = 0;
- if (valueStr != null) {
- index = mRecordDurPreference.findIndexOfValue(valueStr);
- }
- if ((index < 0) || (index >= summaryRecordItems.length)) {
- index = 0;
- mRecordDurPreference.setValueIndex(index);
- }
- Log.d(LOGTAG, "onSharedPreferenceChanged: recorddur: "
- + summaryRecordItems[index]);
- mRecordDurPreference.setSummary(summaryRecordItems[index]);
- FmSharedPreferences.setRecordDuration(index);
- }
- } else if (key.equals(AUDIO_OUTPUT_KEY)) {
- String valueStr = mAudioPreference.getValue();
- int index = 0;
- if (valueStr != null) {
- index = mAudioPreference.findIndexOfValue(valueStr);
- }
- if (index != 1) {
- if (index != 0) {
- index = 0;
- /* It shud be 0(Stereo) or 1(Mono) */
- mAudioPreference.setValueIndex(index);
- }
- }
- Log.d(LOGTAG, "onSharedPreferenceChanged: audiomode: "
- + summaryAudioModeItems[index]);
- mAudioPreference.setSummary(summaryAudioModeItems[index]);
- if (index == 0) {
- // Stereo
- FmSharedPreferences.setAudioOutputMode(true);
- } else {
- // Mono
- FmSharedPreferences.setAudioOutputMode(false);
- }
- FMRadio.fmAudioOutputMode();
- }
- }
- }
- if (mPrefs != null) {
- if(bStatus) {
- mPrefs.Save();
- }else {
- mTunedFreq = FmSharedPreferences.getTunedFrequency();
- if ((mTunedFreq > FmSharedPreferences.getUpperLimit())
- || mTunedFreq < FmSharedPreferences.getLowerLimit()) {
-
- FmSharedPreferences.setTunedFrequency(FmSharedPreferences.getLowerLimit());
- }
- mPrefs.Save();
- }
- }
- }
-
- public boolean onPreferenceClick(Preference preference) {
- boolean handled = false;
- if (preference == mRestoreDefaultPreference) {
- showDialog(RESTORE_FACTORY_DEFAULT_INT);
- }
- return handled;
- }
-
- @Override
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case RESTORE_FACTORY_DEFAULT_INT:
- return new AlertDialog.Builder(this).setIcon(
- R.drawable.alert_dialog_icon).setTitle(
- R.string.settings_revert_confirm_title).setMessage(
- R.string.settings_revert_confirm_msg).setPositiveButton(
- R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- Intent data = new Intent(
- RESTORE_FACTORY_DEFAULT_ACTION);
- setResult(RESULT_OK, data);
- restoreSettingsDefault();
- finish();
- }
-
- }).setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- }).create();
- default:
- break;
- }
- return null;
- }
-
- private void restoreSettingsDefault() {
- if (mPrefs != null) {
- mBandPreference.setValueIndex(0);
- if (mRxMode) {
- mAudioPreference.setValueIndex(0);
- if(FMRadio.RECORDING_ENABLE) {
- mRecordDurPreference.setValueIndex(0);
- }
- mAfPref.setChecked(false);
- FmSharedPreferences.SetDefaults();
- } else {
- FmSharedPreferences.setCountry(FmSharedPreferences.REGIONAL_BAND_NORTH_AMERICA);
- }
- mPrefs.Save();
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- SharedPreferences sharedPreferences = null;
- if (preferenceScreen != null) {
- sharedPreferences = preferenceScreen.getSharedPreferences();
- }
- if (sharedPreferences != null) {
- sharedPreferences.registerOnSharedPreferenceChangeListener(this);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- SharedPreferences sharedPreferences = null;
- if (preferenceScreen != null) {
- sharedPreferences = preferenceScreen.getSharedPreferences();
- }
- if (sharedPreferences != null) {
- sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
- }
- }
- private void setBandSummary(int index) {
- if((index + 1) == summaryBandItems.length) {
- min_freq = FmSharedPreferences.getLowerLimit();
- max_freq = FmSharedPreferences.getUpperLimit();
- chan_spacing = FmSharedPreferences.getChSpacing();
- if(chan_spacing < 0) {
- chan_spacing = 0;
- }
- mBandPreference.setSummary(summaryBandItems[index] + "( "
- + (min_freq / 1000.0) +"Mhz To " + (max_freq / 1000.0) +
- "Mhz)");
- mChannelSpacingPref.setValueIndex(2 - chan_spacing);
- mChannelSpacingPref.setSummary(chSpacingItems[2 - chan_spacing]);
- mChannelSpacingPref.setEnabled(true);
- mUserBandMinPref.setEnabled(true);
- mUserBandMaxPref.setEnabled(true);
- mUserBandMinPref.setSummary((min_freq / 1000.0) + "Mhz");
- mUserBandMaxPref.setSummary((max_freq / 1000.0) + "Mhz");
- }else {
- mBandPreference.setSummary(summaryBandItems[index]);
- mChannelSpacingPref.setEnabled(false);
- mUserBandMinPref.setEnabled(false);
- mUserBandMaxPref.setEnabled(false);
- }
- }
-
- private void displayToast(String msg) {
- Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
- }
-}
diff --git a/fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java b/fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java
deleted file mode 100644
index 46bcecd..0000000
--- a/fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2011-2012, 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.utils;
-
-import android.bluetooth.BluetoothA2dp;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothProfile;
-import android.content.Intent;
-import android.content.Context;
-
-public class A2dpDeviceStatus {
- private BluetoothAdapter mAdapter;
- private BluetoothA2dp mA2dp = null;
- public String getActionSinkStateChangedString (){
- return BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED;
- }
- public String getActionPlayStateChangedString (){
- return BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED;
- }
- public boolean isA2dpStateChange( String action) {
- if(action.equals(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED) ) {
- return true;
- }
- return false;
- }
- public boolean isA2dpPlayStateChange( String action) {
- if(action.equals(BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED) ) {
- return true;
- }
- return false;
- }
- public boolean isConnected(Intent intent) {
- boolean isConnected = false;
- int state = intent.getIntExtra(BluetoothA2dp.EXTRA_STATE,
- BluetoothA2dp.STATE_DISCONNECTED);
- if((state == BluetoothA2dp.STATE_CONNECTED) || (state == BluetoothProfile.STATE_CONNECTED)) {
- isConnected = true;
- }
- return isConnected;
- }
- public boolean isPlaying(Intent intent) {
- boolean isPlaying = false;
- int state = intent.getIntExtra(BluetoothA2dp.EXTRA_STATE,
- BluetoothA2dp.STATE_DISCONNECTED);
- if(state == BluetoothA2dp.STATE_PLAYING ) {
- isPlaying = true;
- }
- return isPlaying;
- }
- public boolean isDeviceAvailable() {
- if(null != mA2dp) {
- if( 0 != mA2dp.getConnectedDevices().size() ) {
- return true;
- }
- }
- return false;
- }
-
- public A2dpDeviceStatus(Context mContext) {
- mAdapter = BluetoothAdapter.getDefaultAdapter();
- mAdapter.getProfileProxy(mContext, mProfileListener,
- BluetoothProfile.A2DP);
- }
- private BluetoothProfile.ServiceListener mProfileListener =
- new BluetoothProfile.ServiceListener() {
- public void onServiceConnected(int profile, BluetoothProfile proxy) {
- if (profile == BluetoothProfile.A2DP) {
- mA2dp = (BluetoothA2dp) proxy;
- }
- }
- public void onServiceDisconnected(int profile) {
- if (profile == BluetoothProfile.A2DP) {
- mA2dp = null;
- }
- }
-};
-}
-
diff --git a/fmapp/src/com/codeaurora/hc_utils/FrequencyPicker.java b/fmapp/src/com/codeaurora/hc_utils/FrequencyPicker.java
deleted file mode 100644
index 8a1deaa..0000000
--- a/fmapp/src/com/codeaurora/hc_utils/FrequencyPicker.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
- * Not a Contribution.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.codeaurora.utils;
-
-
-import android.content.Context;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.SparseArray;
-import android.view.LayoutInflater;
-import android.widget.FrameLayout;
-
-import com.codeaurora.fmradio.R;
-import android.widget.NumberPicker;
-import android.widget.NumberPicker.OnValueChangeListener;
-
-/**
- * A view for selecting the frequency
- *
- * For a dialog using this view, see {FrequencyPickerDialog}.
- */
-
-public class FrequencyPicker extends FrameLayout {
-
- /* UI Components */
- private final NumberPicker mMHzPicker;
- private final NumberPicker mKHzPicker;
-
- /**
- * How we notify users the Frequency has changed.
- */
- private OnFrequencyChangedListener mOnFrequencyChangedListener;
-
- private int mFrequency;
- private int mMin;
- private int mMax;
- private int mStep;
- private int mMhz;
- private int mKhz;
-
- /**
- * The callback used to indicate the user changes the Frequency.
- */
- public interface OnFrequencyChangedListener {
-
- /**
- * @param view The view associated with this listener.
- * @param frequency The Frequency that was set.
- */
- void onFrequencyChanged(FrequencyPicker view, int frequency);
- }
-
- public FrequencyPicker(Context context) {
- this(context, null);
- }
-
- public FrequencyPicker(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public FrequencyPicker(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- inflater.inflate(R.layout.frequency_picker, this, true);
-
- mMHzPicker = (NumberPicker) findViewById(R.id.mhz);
- if (mMHzPicker != null) {
- mMHzPicker.setOnLongPressUpdateInterval(100);
-
- mMHzPicker.setOnValueChangedListener(new OnValueChangeListener() {
- public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
- mMhz = newVal;
- mFrequency = (mMhz*1000) + (getFrequencyKHz(mKhz, mMin, mStep));
- validateFrequencyRange();
- if (mOnFrequencyChangedListener != null) {
- mOnFrequencyChangedListener.onFrequencyChanged(FrequencyPicker.this, mFrequency);
- }
- }
- });
- }
- mKHzPicker = (NumberPicker) findViewById(R.id.khz);
- if (mKHzPicker != null) {
- mKHzPicker.setOnLongPressUpdateInterval(100);
- mKHzPicker.setOnValueChangedListener(new OnValueChangeListener() {
- public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
- mKhz = newVal;
- mFrequency = (mMhz*1000) + (getFrequencyKHz(mKhz, mMin, mStep));
-
- validateFrequencyRange();
-
- if (mOnFrequencyChangedListener != null) {
- mOnFrequencyChangedListener.onFrequencyChanged(FrequencyPicker.this, mFrequency);
- }
- }
- });
- }
-
- updateSpinnerRange();
-
- if (!isEnabled()) {
- setEnabled(false);
- }
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- mMHzPicker.setEnabled(enabled);
- mKHzPicker.setEnabled(enabled);
- }
-
-
- public void updateFrequency(int frequency) {
- mFrequency = frequency;
- updateSpinners();
- }
-
- private static class SavedState extends BaseSavedState {
-
- private final int mMHZ;
- private final int mKHZ;
-
- /**
- * Constructor called from {@link FrequencyPicker#onSaveInstanceState()}
- */
- private SavedState(Parcelable superState, int mhz, int khz) {
- super(superState);
- mMHZ = mhz;
- mKHZ = khz;
- }
-
- /**
- * Constructor called from {@link #CREATOR}
- */
- private SavedState(Parcel in) {
- super(in);
- mMHZ = in.readInt();
- mKHZ = in.readInt();
- }
-
- public int getMHz() {
- return mMHZ;
- }
-
- public int getKHz() {
- return mKHZ;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mMHZ);
- dest.writeInt(mKHZ);
- }
-
- public static final Parcelable.Creator<SavedState> CREATOR =
- new Creator<SavedState>() {
-
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
-
- /**
- * Override so we are in complete control of save / restore for this widget.
- */
- @Override
- protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
- dispatchThawSelfOnly(container);
- }
-
- @Override
- protected Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
-
- return new SavedState(superState, mMhz, mKhz);
- }
-
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
- super.onRestoreInstanceState(ss.getSuperState());
- mMhz = ss.getMHz();
- mKhz = ss.getKHz();
- }
-
- private String[] getKHzStrings(int min, int stepSize)
- {
- if(stepSize == 100)
- {
- return (get100KHzStrings());
- }
- else if(stepSize == 50)
- {
- return (get50KHzStrings());
- }
- return (get200KHzStrings(min));
- }
-
- private int getKHzCount(int stepSize)
- {
- if(stepSize == 100)
- {
- return (10);
- }
- else if(stepSize == 50)
- {
- return (20);
- }
- return (5);
- }
- private int getCurrentKHz(int frequency, int min, int stepSize)
- {
- if(stepSize == 100)
- {
- return (getCurrent100KHz(frequency));
- }
- else if(stepSize == 50)
- {
- return (getCurrent50KHz(frequency));
- }
- return (getCurrent200KHz(frequency, min));
- }
-
- private int getFrequencyKHz(int kHz, int min, int stepSize)
- {
- if(stepSize == 100)
- {
- return (getFrequency100KHz(kHz));
- }
- else if(stepSize == 50)
- {
- return (getFrequency50KHz(kHz));
- }
- return (getFrequency200KHz(kHz, min));
- }
-
- private int getFrequency100KHz(int kHz)
- {
- int frequencykhz = ((kHz-1)*100) ;
- //Log.d("FMRadio", "FP: getCurrent100KHz: " + frequencykhz);
- return (frequencykhz);
- }
-
- private int getFrequency50KHz(int kHz)
- {
- int frequencykhz = ((kHz-1)*50) ;
- //Log.d("FMRadio", "FP: getCurrent100KHz: " + frequencykhz);
- return (frequencykhz);
- }
-
- private int getFrequency200KHz(int kHz, int min)
- {
- int frequencykhz = ((kHz-1)*200) ;
- if(min%200 != 0)
- {
- frequencykhz = ((kHz-1)*200)+100 ;
- }
- //Log.d("FMRadio", "FP: getCurrent200KHz: " + frequencykhz);
- return (frequencykhz);
- }
-
- private int getCurrent100KHz(int frequency)
- {
- int khz = ((frequency%1000)/100) ;
- //Log.d("FMRadio", "FP: getCurrent100KHz: " + khz);
- return (khz+1);
- }
-
- private int getCurrent50KHz(int frequency)
- {
- int khz = ((frequency%1000)/50) ;
- //Log.d("FMRadio", "FP: getCurrent50KHz: " + khz);
- return (khz+1);
- }
-
- private int getCurrent200KHz(int frequency, int min)
- {
- int khz = ((frequency%1000)/200);
- //Log.d("FMRadio", "FP: getCurrent200KHz: " + khz);
- return (khz+1);
- }
-
- private String[] get50KHzStrings()
- {
- String[] khzStrings= {"00","05","10","15","20","25","30","35","40","45",
- "50","55","60","65","70","75","80","85","90","95"};
- //Log.d("FMRadio", "FP: get50KHzStrings");
- return khzStrings;
- }
-
- private String[] get100KHzStrings()
- {
- String[] khzStrings= {"0","1","2","3","4","5",
- "6","7","8","9"};
- //Log.d("FMRadio", "FP: get100KHzStrings");
- return khzStrings;
- }
-
- private String[] get200KHzStrings(int min)
- {
- if(min%200 == 0)
- {
- return (getEven200KHzStrings());
- }
- return (getOdd200KHzStrings());
- }
-
- private String[] getEven200KHzStrings()
- {
- String[] khzStrings= {"0","2","4","6","8"};
- //Log.d("FMRadio", "FP: getEven200KHzStrings");
- return khzStrings;
- }
- private String[] getOdd200KHzStrings()
- {
- String[] khzStrings= {"1","3","5","7","9"};
- //Log.d("FMRadio", "FP: getOdd200KHzStrings");
- return khzStrings;
- }
- public void updateSteps(int steps)
- {
- mStep = steps;
- }
- public void updateMinFreq(int freq)
- {
- mMin = freq;
- }
- public void updateMaxFreq(int freq)
- {
- mMax = freq;
- }
- /**
- * Initialize the state.
- * @param year The initial year.
- * @param monthOfYear The initial month.
- * @param dayOfMonth The initial day of the month.
- * @param onDateChangedListener How user is notified date is changed by user, can be null.
- */
- public void init(int min, int max, int step, int frequency,
- OnFrequencyChangedListener onFrequencyChangedListener) {
-
- mMin = min;
- mMax = max;
- mStep = step;
- mFrequency = frequency;
- mOnFrequencyChangedListener = onFrequencyChangedListener;
-
- updateSpinners();
- }
- private void updateSpinnerRange() {
- String[] khzStrings = getKHzStrings(mMin, mStep);
- int khzNumSteps = getKHzCount(mStep);
-
- if (mMHzPicker != null) {
- mMHzPicker.setMinValue(mMin/1000);
- mMHzPicker.setMaxValue(mMax/1000);
- }
- if (mKHzPicker != null) {
- mKHzPicker.setDisplayedValues(get50KHzStrings());
- mKHzPicker.setMinValue(1);
- mKHzPicker.setMaxValue(khzNumSteps);
- mKHzPicker.setDisplayedValues(khzStrings);
- }
- }
-
- private void updateSpinners() {
- int khzNumSteps = getKHzCount(mStep);
- updateSpinnerRange();
- mMhz = (int)(mFrequency/1000);
- mKhz = getCurrentKHz(mFrequency, mMin, mStep) ;
- if((mMin/1000 <=mMhz) && (mMax/1000 >=mMhz))
- {
- mMHzPicker.setValue(mMhz);
- }
- if(mKhz <= khzNumSteps)
- {
- mKHzPicker.setValue(mKhz);
- }
- }
- private void validateFrequencyRange()
- {
- boolean bUpdateSpinner=false;
- if(mFrequency < mMin)
- {
- mFrequency = mMin;
- bUpdateSpinner = true;
- }
- if(mFrequency > mMax)
- {
- mFrequency = mMax;
- bUpdateSpinner = true;
- }
- if(bUpdateSpinner == true)
- {
- updateSpinners();
- }
- }
-
- public int getFrequency() {
- return (mFrequency);
- }
-}
diff --git a/fmapp/src/com/codeaurora/hc_utils/FrequencyPickerDialog.java b/fmapp/src/com/codeaurora/hc_utils/FrequencyPickerDialog.java
deleted file mode 100644
index 06ac7b3..0000000
--- a/fmapp/src/com/codeaurora/hc_utils/FrequencyPickerDialog.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- * Not a Contribution.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.codeaurora.utils;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import qcom.fmradio.FmConfig;
-import qcom.fmradio.FmReceiver;
-
-import com.codeaurora.fmradio.R;
-import com.codeaurora.utils.FrequencyPicker.OnFrequencyChangedListener;
-
-/**
- * A simple dialog containing an FrequencyPicker.
- */
-public class FrequencyPickerDialog extends AlertDialog implements OnClickListener,
-OnFrequencyChangedListener {
-
- private static final String FREQUENCY = "FREQUENCY";
- private static final String FREQ_MIN = "FREQ_MIN";
- private static final String FREQ_MAX = "FREQ_MAX";
- private static final String FREQ_STEP = "FREQ_STEP";
-
- private final FrequencyPicker mFrequencyPicker;
- private final OnFrequencySetListener mCallBack;
- private int mMinFrequency;
- private int mMaxFrequency;
- private int mChannelSpacing;
-
- /**
- * The callback used to indicate the user is done filling in the date.
- */
- public interface OnFrequencySetListener {
-
- void onFrequencySet(FrequencyPicker view, int frequency);
- }
- /**
- */
- public FrequencyPickerDialog(Context context,
- FmConfig fmConfig,
- int frequency,
- OnFrequencySetListener callback) {
- //this(context, android.R.style.Theme_Dialog, fmConfig, frequency, callback);
- this(context, com.android.internal.R.style.Theme_Dialog_Alert, fmConfig, frequency, callback);
- }
-
- /**
- */
- public FrequencyPickerDialog(Context context,
- int theme,
- FmConfig fmConfig,
- int frequency,
- OnFrequencySetListener callback) {
- super(context, theme);
- mMinFrequency = fmConfig.getLowerLimit();
- mMaxFrequency = fmConfig.getUpperLimit();
- mChannelSpacing = 200;
- if(FmReceiver.FM_CHSPACE_200_KHZ == fmConfig.getChSpacing())
- {
- mChannelSpacing = 200;
- }
- else if(FmReceiver.FM_CHSPACE_100_KHZ == fmConfig.getChSpacing())
- {
- mChannelSpacing = 100;
- }
- else if(FmReceiver.FM_CHSPACE_50_KHZ == fmConfig.getChSpacing())
- {
- mChannelSpacing = 50;
- }
- int MHz = frequency/1000;
- int KHz = (frequency%1000)/100;
- setTitle("FM - "+MHz+"."+KHz);
- mCallBack = callback;
-
- setButton("Set", this);
- setButton2("Cancel", (OnClickListener) null);
- setIcon(R.drawable.alert_dialog_icon);
-
- LayoutInflater inflater =
- (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View view = inflater.inflate(R.layout.frequency_picker_dialog, null);
- setView(view);
- mFrequencyPicker = (FrequencyPicker) view.findViewById(R.id.frequencyPicker);
- if(mFrequencyPicker != null)
- {
- mFrequencyPicker.init(mMinFrequency, mMaxFrequency, mChannelSpacing, frequency, this);
- }
- else
- {
- Log.e("fmRadio", "Failed to find ID: R.id.frequencyPicker");
- }
- }
-
- public void UpdateFrequency(int frequency)
- {
- int MHz = frequency/1000;
- int KHz = (frequency%1000)/100;
- setTitle("FM - "+MHz+"."+KHz);
- mFrequencyPicker.updateFrequency(frequency);
- }
-
- public void onClick(DialogInterface dialog, int which) {
- if (mCallBack != null) {
- mFrequencyPicker.clearFocus();
- int frequency = mFrequencyPicker.getFrequency();
- mCallBack.onFrequencySet(mFrequencyPicker, frequency);
- }
- }
-
- public void onFrequencyChanged(FrequencyPicker view, int frequency) {
- UpdateFrequency(frequency);
- }
-
- @Override
- public Bundle onSaveInstanceState() {
- Bundle state = super.onSaveInstanceState();
- state.putInt(FREQUENCY, mFrequencyPicker.getFrequency());
- state.putInt(FREQ_MIN, mMinFrequency);
- state.putInt(FREQ_MAX, mMaxFrequency);
- state.putInt(FREQ_STEP, mChannelSpacing);
- return state;
- }
-
- @Override
- public void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- int frequency = savedInstanceState.getInt(FREQUENCY);
- mMinFrequency = savedInstanceState.getInt(FREQ_MIN);
- mMaxFrequency = savedInstanceState.getInt(FREQ_MAX );
- mChannelSpacing = savedInstanceState.getInt(FREQ_STEP);
- mFrequencyPicker.init(mMinFrequency, mMaxFrequency, mChannelSpacing, frequency, this);
- int MHz = frequency/1000;
- int KHz = (frequency%1000)/100;
- setTitle("FM - "+MHz+"."+KHz);
- }
- public void updateSteps(int steps)
- {
- mChannelSpacing = 200;
- if(FmReceiver.FM_CHSPACE_200_KHZ == steps)
- {
- mChannelSpacing = 200;
- }
- else if(FmReceiver.FM_CHSPACE_100_KHZ == steps)
- {
- mChannelSpacing = 100;
- }
- else if(FmReceiver.FM_CHSPACE_50_KHZ == steps)
- {
- mChannelSpacing = 50;
- }
- mFrequencyPicker.updateSteps(mChannelSpacing);
- }
- public void updateMinFreq(int freq)
- {
- mMinFrequency = freq;
- mFrequencyPicker.updateMinFreq(mMinFrequency);
- }
- public void updateMaxFreq(int freq)
- {
- mMaxFrequency = freq;
- mFrequencyPicker.updateMaxFreq(mMaxFrequency);
- }
-}
diff --git a/fmapp/src/com/codeaurora/utils/A2dpDeviceStatus.java b/fmapp/src/com/codeaurora/utils/A2dpDeviceStatus.java
deleted file mode 100644
index b6d5a88..0000000
--- a/fmapp/src/com/codeaurora/utils/A2dpDeviceStatus.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2011, 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.utils;
-
-import android.bluetooth.BluetoothA2dp;
-import android.bluetooth.BluetoothDevice;
-import android.content.Context;
-import android.content.Intent;
-
-import java.util.Set;
-
-
-public class A2dpDeviceStatus {
- private BluetoothA2dp mA2dp = null;
- public String getActionSinkStateChangedString (){
- return BluetoothA2dp.ACTION_SINK_STATE_CHANGED;
- }
- public String getActionPlayStateChangedString (){
- return BluetoothA2dp.ACTION_SINK_STATE_CHANGED;
- }
- public boolean isA2dpStateChange( String action) {
- if(action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED) ) {
- return true;
- }
- return false;
- }
- public boolean isA2dpPlayStateChange( String action) {
- return isA2dpStateChange(action);
- }
- public boolean isConnected(Intent intent) {
- boolean isConnected = false;
- int state = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,
- BluetoothA2dp.STATE_DISCONNECTED);
- if (state == BluetoothA2dp.STATE_CONNECTED ||
- state == BluetoothA2dp.STATE_PLAYING){
- isConnected = true;
- }
- return isConnected;
- }
- public boolean isPlaying(Intent intent) {
- boolean isPlaying = false;
- int state = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,
- BluetoothA2dp.STATE_DISCONNECTED);
- if(state == BluetoothA2dp.STATE_PLAYING){
- isPlaying = true;
- }
- return isPlaying;
- }
- public boolean isDeviceAvailable() {
- if(null == mA2dp) return false;
- Set<BluetoothDevice> sinks = mA2dp.getConnectedSinks();
- if (sinks != null && sinks.size() != 0) {
- return true;
- }
- return false;
- }
-
- public A2dpDeviceStatus(Context mContext) {
- mA2dp = new BluetoothA2dp(mContext);
- }
-
-}
diff --git a/fmapp/src/com/codeaurora/utils/FrequencyPicker.java b/fmapp/src/com/codeaurora/utils/FrequencyPicker.java
deleted file mode 100644
index 845ed90..0000000
--- a/fmapp/src/com/codeaurora/utils/FrequencyPicker.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.codeaurora.utils;
-
-
-import android.content.Context;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.AttributeSet;
-//import android.util.Log;
-import android.util.SparseArray;
-import android.view.LayoutInflater;
-import android.widget.FrameLayout;
-
-import com.codeaurora.fmradio.R;
-import android.widget.NumberPicker;
-import android.widget.NumberPicker.OnChangedListener;
-
-/**
- * A view for selecting the frequency
- *
- * For a dialog using this view, see {FrequencyPickerDialog}.
- */
-
-public class FrequencyPicker extends FrameLayout {
-
- /* UI Components */
- private final NumberPicker mMHzPicker;
- private final NumberPicker mKHzPicker;
-
- /**
- * How we notify users the Frequency has changed.
- */
- private OnFrequencyChangedListener mOnFrequencyChangedListener;
-
- private int mFrequency;
- private int mMin;
- private int mMax;
- private int mStep;
- private int mMhz;
- private int mKhz;
-
- /**
- * The callback used to indicate the user changes the Frequency.
- */
- public interface OnFrequencyChangedListener {
-
- /**
- * @param view The view associated with this listener.
- * @param frequency The Frequency that was set.
- */
- void onFrequencyChanged(FrequencyPicker view, int frequency);
- }
-
- public FrequencyPicker(Context context) {
- this(context, null);
- }
-
- public FrequencyPicker(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public FrequencyPicker(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- inflater.inflate(R.layout.frequency_picker, this, true);
-
- mMHzPicker = (NumberPicker) findViewById(R.id.mhz);
- if (mMHzPicker != null) {
- mMHzPicker.setSpeed(100);
- mMHzPicker.setOnChangeListener(new OnChangedListener() {
- public void onChanged(NumberPicker picker, int oldVal, int newVal) {
- mMhz = newVal;
- mFrequency = (mMhz*1000) + (getFrequencyKHz(mKhz, mMin, mStep));
- validateFrequencyRange();
- if (mOnFrequencyChangedListener != null) {
- mOnFrequencyChangedListener.onFrequencyChanged(FrequencyPicker.this, mFrequency);
- }
- }
- });
- }
- mKHzPicker = (NumberPicker) findViewById(R.id.khz);
- if (mKHzPicker != null) {
- mKHzPicker.setSpeed(100);
- mKHzPicker.setOnChangeListener(new OnChangedListener() {
- public void onChanged(NumberPicker picker, int oldVal, int newVal) {
- mKhz = newVal;
- mFrequency = (mMhz*1000) + (getFrequencyKHz(mKhz, mMin, mStep));
-
- validateFrequencyRange();
-
- if (mOnFrequencyChangedListener != null) {
- mOnFrequencyChangedListener.onFrequencyChanged(FrequencyPicker.this, mFrequency);
- }
- }
- });
- }
-
- updateSpinnerRange();
-
- if (!isEnabled()) {
- setEnabled(false);
- }
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- if (mMHzPicker != null) {
- mMHzPicker.setEnabled(enabled);
- }
- if (mKHzPicker != null) {
- mKHzPicker.setEnabled(enabled);
- }
- }
-
-
- public void updateFrequency(int frequency) {
- mFrequency = frequency;
- updateSpinners();
- }
-
- private static class SavedState extends BaseSavedState {
-
- private final int mMHZ;
- private final int mKHZ;
-
- /**
- * Constructor called from {@link FrequencyPicker#onSaveInstanceState()}
- */
- private SavedState(Parcelable superState, int mhz, int khz) {
- super(superState);
- mMHZ = mhz;
- mKHZ = khz;
- }
-
- /**
- * Constructor called from {@link #CREATOR}
- */
- private SavedState(Parcel in) {
- super(in);
- mMHZ = in.readInt();
- mKHZ = in.readInt();
- }
-
- public int getMHz() {
- return mMHZ;
- }
-
- public int getKHz() {
- return mKHZ;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(mMHZ);
- dest.writeInt(mKHZ);
- }
-
- public static final Parcelable.Creator<SavedState> CREATOR =
- new Creator<SavedState>() {
-
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
-
- /**
- * Override so we are in complete control of save / restore for this widget.
- */
- @Override
- protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
- dispatchThawSelfOnly(container);
- }
-
- @Override
- protected Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
-
- return new SavedState(superState, mMhz, mKhz);
- }
-
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
- super.onRestoreInstanceState(ss.getSuperState());
- mMhz = ss.getMHz();
- mKhz = ss.getKHz();
- }
-
- private String[] getKHzStrings(int min, int stepSize)
- {
- if(stepSize == 100)
- {
- return (get100KHzStrings());
- }
- else if(stepSize == 50)
- {
- return (get50KHzStrings());
- }
- return (get200KHzStrings(min));
- }
-
- private int getKHzCount(int stepSize)
- {
- if(stepSize == 100)
- {
- return (10);
- }
- else if(stepSize == 50)
- {
- return (20);
- }
- return (5);
- }
- private int getCurrentKHz(int frequency, int min, int stepSize)
- {
- if(stepSize == 100)
- {
- return (getCurrent100KHz(frequency));
- }
- else if(stepSize == 50)
- {
- return (getCurrent50KHz(frequency));
- }
- return (getCurrent200KHz(frequency, min));
- }
-
- private int getFrequencyKHz(int kHz, int min, int stepSize)
- {
- if(stepSize == 100)
- {
- return (getFrequency100KHz(kHz));
- }
- else if(stepSize == 50)
- {
- return (getFrequency50KHz(kHz));
- }
- return (getFrequency200KHz(kHz, min));
- }
-
- private int getFrequency100KHz(int kHz)
- {
- int frequencykhz = ((kHz-1)*100) ;
- //Log.d("FMRadio", "FP: getCurrent100KHz: " + frequencykhz);
- return (frequencykhz);
- }
-
- private int getFrequency50KHz(int kHz)
- {
- int frequencykhz = ((kHz-1)*50) ;
- //Log.d("FMRadio", "FP: getCurrent100KHz: " + frequencykhz);
- return (frequencykhz);
- }
-
- private int getFrequency200KHz(int kHz, int min)
- {
- int frequencykhz = ((kHz-1)*200) ;
- if(min%200 != 0)
- {
- frequencykhz = ((kHz-1)*200)+100 ;
- }
- //Log.d("FMRadio", "FP: getCurrent200KHz: " + frequencykhz);
- return (frequencykhz);
- }
-
- private int getCurrent100KHz(int frequency)
- {
- int khz = ((frequency%1000)/100) ;
- //Log.d("FMRadio", "FP: getCurrent100KHz: " + khz);
- return (khz+1);
- }
-
- private int getCurrent50KHz(int frequency)
- {
- int khz = ((frequency%1000)/50) ;
- //Log.d("FMRadio", "FP: getCurrent50KHz: " + khz);
- return (khz+1);
- }
-
- private int getCurrent200KHz(int frequency, int min)
- {
- int khz = ((frequency%1000)/200);
- //Log.d("FMRadio", "FP: getCurrent200KHz: " + khz);
- return (khz+1);
- }
-
- private String[] get50KHzStrings()
- {
- String[] khzStrings= {"00","05","10","15","20","25","30","35","40","45",
- "50","55","60","65","70","75","80","85","90","95"};
- //Log.d("FMRadio", "FP: get50KHzStrings");
- return khzStrings;
- }
-
- private String[] get100KHzStrings()
- {
- String[] khzStrings= {"0","1","2","3","4","5",
- "6","7","8","9"};
- //Log.d("FMRadio", "FP: get100KHzStrings");
- return khzStrings;
- }
-
- private String[] get200KHzStrings(int min)
- {
- if(min%200 == 0)
- {
- return (getEven200KHzStrings());
- }
- return (getOdd200KHzStrings());
- }
-
- private String[] getEven200KHzStrings()
- {
- String[] khzStrings= {"0","2","4","6","8"};
- //Log.d("FMRadio", "FP: getEven200KHzStrings");
- return khzStrings;
- }
- private String[] getOdd200KHzStrings()
- {
- String[] khzStrings= {"1","3","5","7","9"};
- //Log.d("FMRadio", "FP: getOdd200KHzStrings");
- return khzStrings;
- }
-
- /**
- * Initialize the state.
- * @param year The initial year.
- * @param monthOfYear The initial month.
- * @param dayOfMonth The initial day of the month.
- * @param onDateChangedListener How user is notified date is changed by user, can be null.
- */
- public void init(int min, int max, int step, int frequency,
- OnFrequencyChangedListener onFrequencyChangedListener) {
-
- mMin = min;
- mMax = max;
- mStep = step;
- mFrequency = frequency;
- mOnFrequencyChangedListener = onFrequencyChangedListener;
-
- updateSpinners();
- }
- private void updateSpinnerRange() {
- String[] khzStrings = getKHzStrings(mMin, mStep);
- int khzNumSteps = getKHzCount(mStep);
-
- if (mMHzPicker != null) {
- mMHzPicker.setRange(mMin/1000, mMax/1000);
- }
- if (mKHzPicker != null) {
- mKHzPicker.setRange(1, khzNumSteps, khzStrings);
- }
- }
-
- private void updateSpinners() {
- int khzNumSteps = getKHzCount(mStep);
- updateSpinnerRange();
- mMhz = (int)(mFrequency/1000);
- mKhz = getCurrentKHz(mFrequency, mMin, mStep) ;
- if((mMin/1000 <=mMhz) && (mMax/1000 >=mMhz))
- {
- mMHzPicker.setCurrent(mMhz);
- }
- if(mKhz <= khzNumSteps)
- {
- mKHzPicker.setCurrent(mKhz);
- }
- }
- private void validateFrequencyRange()
- {
- boolean bUpdateSpinner=false;
- if(mFrequency < mMin)
- {
- mFrequency = mMin;
- bUpdateSpinner = true;
- }
- if(mFrequency > mMax)
- {
- mFrequency = mMax;
- bUpdateSpinner = true;
- }
- if(bUpdateSpinner == true)
- {
- updateSpinners();
- }
- }
-
- public int getFrequency() {
- return (mFrequency);
- }
-}
diff --git a/fmapp/src/com/codeaurora/utils/FrequencyPickerDialog.java b/fmapp/src/com/codeaurora/utils/FrequencyPickerDialog.java
deleted file mode 100644
index 6078208..0000000
--- a/fmapp/src/com/codeaurora/utils/FrequencyPickerDialog.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.codeaurora.utils;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import qcom.fmradio.FmConfig;
-import qcom.fmradio.FmReceiver;
-
-import com.codeaurora.fmradio.R;
-import com.codeaurora.utils.FrequencyPicker.OnFrequencyChangedListener;
-
-/**
- * A simple dialog containing an FrequencyPicker.
- */
-public class FrequencyPickerDialog extends AlertDialog implements OnClickListener,
-OnFrequencyChangedListener {
-
- private static final String FREQUENCY = "FREQUENCY";
- private static final String FREQ_MIN = "FREQ_MIN";
- private static final String FREQ_MAX = "FREQ_MAX";
- private static final String FREQ_STEP = "FREQ_STEP";
-
- private final FrequencyPicker mFrequencyPicker;
- private final OnFrequencySetListener mCallBack;
- private int mMinFrequency;
- private int mMaxFrequency;
- private int mChannelSpacing;
-
- /**
- * The callback used to indicate the user is done filling in the date.
- */
- public interface OnFrequencySetListener {
-
- void onFrequencySet(FrequencyPicker view, int frequency);
- }
- /**
- */
- public FrequencyPickerDialog(Context context,
- FmConfig fmConfig,
- int frequency,
- OnFrequencySetListener callback) {
- //this(context, android.R.style.Theme_Dialog, fmConfig, frequency, callback);
- this(context, com.android.internal.R.style.Theme_Dialog_Alert, fmConfig, frequency, callback);
- }
-
- /**
- */
- public FrequencyPickerDialog(Context context,
- int theme,
- FmConfig fmConfig,
- int frequency,
- OnFrequencySetListener callback) {
- super(context, theme);
- mMinFrequency = fmConfig.getLowerLimit();
- mMaxFrequency = fmConfig.getUpperLimit();
- mChannelSpacing = 200;
- if(FmReceiver.FM_CHSPACE_200_KHZ == fmConfig.getChSpacing())
- {
- mChannelSpacing = 200;
- }
- else if(FmReceiver.FM_CHSPACE_100_KHZ == fmConfig.getChSpacing())
- {
- mChannelSpacing = 100;
- }
- else if(FmReceiver.FM_CHSPACE_50_KHZ == fmConfig.getChSpacing())
- {
- mChannelSpacing = 50;
- }
- int MHz = frequency/1000;
- int KHz = (frequency%1000)/100;
- setTitle("FM - "+MHz+"."+KHz);
- mCallBack = callback;
-
- setButton("Set", this);
- setButton2("Cancel", (OnClickListener) null);
- setIcon(R.drawable.alert_dialog_icon);
-
- LayoutInflater inflater =
- (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View view = inflater.inflate(R.layout.frequency_picker_dialog, null);
- setView(view);
- mFrequencyPicker = (FrequencyPicker) view.findViewById(R.id.frequencyPicker);
- if(mFrequencyPicker != null)
- {
- mFrequencyPicker.init(mMinFrequency, mMaxFrequency, mChannelSpacing, frequency, this);
- }
- else
- {
- Log.e("fmRadio", "Failed to find ID: R.id.frequencyPicker");
- }
- }
-
- public void UpdateFrequency(int frequency)
- {
- int MHz = frequency/1000;
- int KHz = (frequency%1000)/100;
- setTitle("FM - "+MHz+"."+KHz);
- mFrequencyPicker.updateFrequency(frequency);
- }
-
- public void onClick(DialogInterface dialog, int which) {
- if (mCallBack != null) {
- mFrequencyPicker.clearFocus();
- int frequency = mFrequencyPicker.getFrequency();
- mCallBack.onFrequencySet(mFrequencyPicker, frequency);
- }
- }
-
- public void onFrequencyChanged(FrequencyPicker view, int frequency) {
- UpdateFrequency(frequency);
- }
-
- @Override
- public Bundle onSaveInstanceState() {
- Bundle state = super.onSaveInstanceState();
- state.putInt(FREQUENCY, mFrequencyPicker.getFrequency());
- state.putInt(FREQ_MIN, mMinFrequency);
- state.putInt(FREQ_MAX, mMaxFrequency);
- state.putInt(FREQ_STEP, mChannelSpacing);
- return state;
- }
-
- @Override
- public void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- int frequency = savedInstanceState.getInt(FREQUENCY);
- mMinFrequency = savedInstanceState.getInt(FREQ_MIN);
- mMaxFrequency = savedInstanceState.getInt(FREQ_MAX );
- mChannelSpacing = savedInstanceState.getInt(FREQ_STEP);
- mFrequencyPicker.init(mMinFrequency, mMaxFrequency, mChannelSpacing, frequency, this);
- int MHz = frequency/1000;
- int KHz = (frequency%1000)/100;
- setTitle("FM - "+MHz+"."+KHz);
- }
-}
diff --git a/fmhalService/Android.mk b/fmhalService/Android.mk
deleted file mode 100644
index cf0bdc0..0000000
--- a/fmhalService/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Setup bdroid local make variables for handling configuration
-ifneq ($(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR),)
- bdroid_C_INCLUDES := $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)
- bdroid_CFLAGS += -DHAS_BDROID_BUILDCFG
-else
- bdroid_C_INCLUDES :=
- bdroid_CFLAGS += -DHAS_NO_BDROID_BUILDCFG
-endif
-
-BDROID_DIR:= system/bt
-
-LOCAL_CFLAGS += $(bdroid_CFLAGS)
-
-LOCAL_SRC_FILES := \
- main.c
-
-LOCAL_SHARED_LIBRARIES := \
- libdl \
- libcutils \
- liblog
-
-LOCAL_CFLAGS := -Wno-unused-parameter
-
-LOCAL_C_INCLUDES += \
- $(BDROID_DIR)/hci/include \
- $(BDROID_DIR)/stack/include \
- $(BDROID_DIR)/osi/include \
- $(LOCAL_PATH)/../helium \
- $(LOCAL_PATH)/../fm_hci
-
-LOCAL_MODULE := fmhal_service
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_EXECUTABLE)
diff --git a/fmhalService/main.c b/fmhalService/main.c
deleted file mode 100644
index 6647f8b..0000000
--- a/fmhalService/main.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (c) 2016, 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 "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.
- */
-
-/*
- * FMhal service used to access RFKILL
-
-**/
-
-#include <cutils/log.h>
-#include <sys/socket.h>
-#include <cutils/sockets.h>
-#include <pthread.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <sys/un.h>
-#include <sys/eventfd.h>
-#include <errno.h>
-#include <string.h>
-
-#include <cutils/properties.h>
-#include "private/android_filesystem_config.h"
-
-
-//#include "bt_hci_bdroid.h"
-#include "bt_vendor_lib.h"
-#include "fm_hci.h"
-#include "wcnss_fmhci.h"
-#include <dlfcn.h>
-
-
-#define LOG_TAG "FMHalService"
-
-#define FM_HAL_SOCK "fmhal_sock"
-
-
-#define BT_SSR_TRIGGERED 0xee
-
-#define FM_POWER_OFF 0x01
-#define FM_POWER_ON 0x02
-#define FM_USERIAL_OPEN 0x03
-#define FM_USERIAL_CLOSE 0x04
-
-#define FM_CMD_PACKET_TYPE 0x11
-#define FM_EVT_PACKET_TYPE 0x14
-
-#ifndef BLUETOOTH_UID
-#define BLUETOOTH_UID 1002
-#endif
-#ifndef SYSTEM_UID
-#define SYSTEM_UID 1000
-#endif
-
-#ifndef ROOT_UID
-#define ROOT_UID 0
-#endif
-
-pthread_mutex_t signal_mutex;
-
-bt_vendor_interface_t *fm_if = NULL;
-int remote_fm_hal_fd;
-
-int do_write(int fd, unsigned char *buf,int len);
-
-unsigned char reset_cmpl[] = {0x04, 0x0e, 0x04, 0x01,0x03, 0x0c, 0x00};
-
-static int extract_uid(int uuid)
-{
- int userid;
- int appid;
-
- appid = userid = uuid % AID_USER;
- if (userid > BLUETOOTH_UID)
- {
- appid = userid % AID_APP;
- }
- ALOGD("%s appid = %d",__func__,appid);
- return appid;
-}
- void service_cleanup()
-{
- char ref_count[PROPERTY_VALUE_MAX];
- char cleanup[PROPERTY_VALUE_MAX];
- int ref_val,clean;
-
- ALOGE("Service is stopped ");
- property_get("wc_transport.clean_up", cleanup, "0");
- property_set("wc_transport.fm_service_status", "0");
- property_set("wc_transport.start_fmhci", "0");
- property_set("wc_transport.fm_power_status", "0");
- clean = atoi(cleanup);
- ALOGE("clean Value = %d",clean);
-}
-
-static int establish_fm_remote_socket(char *name)
-{
- int fd = -1;
- struct sockaddr_un client_address;
- socklen_t clen;
- int sock_id, ret;
- struct ucred creds;
- int c_uid;
- ALOGI("%s(%s) Entry ", __func__, name);
-
- sock_id = socket(AF_LOCAL, SOCK_STREAM, 0);
- if (sock_id < 0) {
- ALOGE("%s: server Socket creation failure", __func__);
- return fd;
- }
-
- ALOGI("convert name to android abstract name:%s %d", name, sock_id);
- if (socket_local_server_bind(sock_id,
- name, ANDROID_SOCKET_NAMESPACE_ABSTRACT) >= 0) {
- if (listen(sock_id, 5) == 0) {
- ALOGI("listen to local socket:%s, fd:%d", name, sock_id);
- } else {
- ALOGE("listen to local socket:failed");
- close(sock_id);
- return fd;
- }
- } else {
- close(sock_id);
- ALOGE("%s: server bind failed for socket : %s", __func__, name);
- return fd;
- }
-
- clen = sizeof(client_address);
- /*Indicate that, server is ready to accept*/
- property_set("wc_transport.fm_service_status", "1");
- ALOGI("%s: wc_transport.fm_service_status set to 1 ", __func__);
- ALOGI("%s: before accept_server_socket", name);
- fd = accept(sock_id, (struct sockaddr *)&client_address, &clen);
- if (fd > 0) {
- ALOGI("%s accepted fd:%d for server fd:%d", name, fd, sock_id);
- close(sock_id);
-
- memset(&creds, 0, sizeof(creds));
- socklen_t szCreds = sizeof(creds);
- ret = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
- if (ret < 0) {
- ALOGE("%s: error getting remote socket creds: %d\n", __func__, ret);
- close(fd);
- return -1;
- }
- c_uid = creds.uid;
- if (c_uid > BLUETOOTH_UID)
- c_uid = extract_uid(creds.uid);
- if (c_uid != BLUETOOTH_UID && c_uid != SYSTEM_UID
- && c_uid != ROOT_UID) {
- ALOGE("%s: client doesn't have required credentials", __func__);
- ALOGE("<%s req> client uid: %d", name, creds.uid);
- close(fd);
- return -1;
- }
-
- ALOGI("%s: Remote socket credentials: %d\n", __func__, creds.uid);
- return fd;
- } else {
- ALOGE("BTC accept failed fd:%d sock d:%d error %s", fd, sock_id, strerror(errno));
- close(sock_id);
- return fd;
- }
-
- close(sock_id);
- return fd;
-}
-
-
-int handle_fmcommand_writes(int fd) {
- ALOGI("%s: ", __func__);
- unsigned char first_byte;
- int retval,val;
- int fd_array[CH_MAX];
-
- ALOGE("%s: FMHAL: read 1st byte to determine the power on/off ", __func__);
-
- retval = read (fd, &first_byte, 1);
- if (retval < 0) {
- ALOGE("%s:read returns err: %d\n", __func__,retval);
- return -1;
- }
- if (retval == 0) {
- ALOGE("%s: This indicates the close of other end", __func__);
- return -99;
- }
-
- ALOGE("%s: FM command type: 0x%x", __func__, first_byte);
- switch(first_byte) {
- case FM_POWER_OFF:
- ALOGE("%s: Received power off command from FM stack: %d", __func__, first_byte);
- val = 0;
- retval = fm_if->op(BT_VND_OP_POWER_CTRL, &val);
- if (retval < 0)
- {
- ALOGE("Failed to turn off power from bt vendor interface");
- // return -1;
- }
- else {
- property_set("wc_transport.fm_power_status", "0");
- retval = -99;
- }
- break;
-
- case FM_POWER_ON:
- ALOGE("%s: Received power ON command from FM stack: %d", __func__, first_byte);
- val = 1;
- retval =fm_if->op(FM_VND_OP_POWER_CTRL, &val);
- if (retval < 0)
- {
- ALOGE("Failed to turn on power from bt vendor interface");
- }
- else
- property_set("wc_transport.fm_power_status", "1");
- break;
- default:
- ALOGE("%s: Unexpected data format!!",__func__);
- retval = -1;
- }
- return retval;
-}
-
-
-int do_read(int fd, unsigned char* buf, size_t len) {
- int bytes_left, bytes_read = 0, read_offset;
-
- bytes_left = len;
- read_offset = 0;
-
- do {
- bytes_read = read(fd, buf+read_offset, bytes_left);
- if (bytes_read < 0) {
- ALOGE("%s: Read error: %d (%s)", __func__, bytes_left, strerror(errno));
- return -1;
- } else if (bytes_read == 0) {
- ALOGE("%s: read returned 0, err = %s, read bytes: %d, expected: %d",
- __func__, strerror(errno), (len-bytes_left), len);
- return (len-bytes_left);
- }
- else {
- if (bytes_read < bytes_left) {
- ALOGV("Still there are %d bytes to read", bytes_left-bytes_read);
- bytes_left = bytes_left-bytes_read;
- read_offset = read_offset+bytes_read;
- } else {
- ALOGV("%s: done with read",__func__);
- break;
- }
- }
- }while(1);
- return len;
-}
-
-int do_write(int fd, unsigned char *buf,int len)
-{
- int ret = 0;
- int write_offset = 0;
- int write_len = len;
- do {
- ret = write(fd, buf+write_offset, write_len);
- if (ret < 0)
- {
- ALOGE("%s: write failed ret = %d err = %s",__func__,ret,strerror(errno));
- return -1;
-
- } else if (ret == 0) {
- ALOGE("%s: Write returned 0, err = %s, Written bytes: %d, expected: %d",
- __func__, strerror(errno), (len-write_len), len);
- return (len-write_len);
-
- } else {
- if (ret < write_len)
- {
- ALOGD("%s, Write pending,do write ret = %d err = %s",__func__,ret,
- strerror(errno));
- write_len = write_len - ret;
- write_offset = ret;
- } else if (ret > write_len) {
- ALOGE("%s: FATAL wrote more than expected: written bytes: %d expected: %d",
- __func__, write_len, ret);
- break;
- } else {
- ALOGV("Write successful");
- break;
- }
- }
- } while(1);
- return len;
-}
-
-void vnd_load_if()
-{
- void *dlhandle;
- unsigned char bdaddr[] = {0xaa, 0xbb, 0xcc, 0x11, 0x22, 0x33};
-
- dlhandle = dlopen("libbt-vendor.so", RTLD_NOW);
- if (!dlhandle)
- {
- ALOGE("!!! Failed to load libbt-vendor.so !!!");
- return;
- }
-
- fm_if = (bt_vendor_interface_t *) dlsym(dlhandle, "BLUETOOTH_VENDOR_LIB_INTERFACE");
- if (!fm_if)
- {
- ALOGE("!!! Failed to get bt vendor interface !!!");
- return;
- }
-
- ALOGI("FM-HCI: Registering the WCNSS HAL library by passing CBs and BD addr.");
- fm_if->init(&fmhci_vendor_callbacks, bdaddr);
-}
-
-
-int main() {
- fd_set client_fds;
- int retval = -1, n;
-
- ALOGI("%s: Entry ", __func__);
- ALOGI("FM HAL SERVICE: Loading the WCNSS HAL library...");
- vnd_load_if();
- ALOGI("create socket");
- remote_fm_hal_fd = establish_fm_remote_socket(FM_HAL_SOCK);
- if (remote_fm_hal_fd < 0) {
- ALOGE("%s: invalid remote socket", __func__);
- return -1;
- }
-
- FD_ZERO(&client_fds);
- FD_SET(remote_fm_hal_fd, &client_fds);
-
- do {
- ALOGI("%s: Step 1-FM-HAL SERVICE: Waiting for FM HAL cmd ", __func__);
- n = select(remote_fm_hal_fd+1, &client_fds, NULL, NULL, NULL);
- if(n < 0){
- ALOGE("Select: failed: %s", strerror(errno));
- break;
- }
- ALOGI("%s: Step 2-FM-HAL SERVICE: FM POWER CMD available for processing...\n", __func__);
- if (FD_ISSET(remote_fm_hal_fd, &client_fds)) {
- retval = handle_fmcommand_writes(remote_fm_hal_fd);
- ALOGI("%s: handle_fmcommand_writes . %d", __func__, retval);
- if(retval < 0) {
- if (retval == -99) {
- ALOGI("%s:End of wait loop", __func__);
- break;
- }
- ALOGI("%s: handle_fmcommand_writes returns: %d: ", __func__, retval);
- // break;
- }
- }
- } while(1);
-
- service_cleanup();
- ALOGI("%s: FM turned off or power off failed .service kill itself", __func__);
- close(remote_fm_hal_fd);
- remote_fm_hal_fd = 0;
-
- ALOGI("%s: Exit: %d", __func__, retval);
- return retval;
-}
-
diff --git a/fmhalService/wcnss_fmhci.h b/fmhalService/wcnss_fmhci.h
deleted file mode 100644
index 22029bf..0000000
--- a/fmhalService/wcnss_fmhci.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2016, 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 "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.
- */
-
-#ifndef __WCNSS_FMHCI__
-#define __WCNSS_FMHCI__
-static void vendor_fwcfg_cb(bt_vendor_op_result_t result) {
-}
-
-static void vendor_scocfg_cb(bt_vendor_op_result_t result) {
-}
-
-static void vendor_lpm_vnd_cb(bt_vendor_op_result_t result) {
-}
-
-static void sco_audiostate_cb(bt_vendor_op_result_t result) {
-}
-
-static void* vendor_alloc(int size) {
- return NULL;
-}
-
-static void vendor_dealloc(void *p_buf) {
-}
-
-static uint8_t vendor_xmit_cb(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback) {
- return 0;
-}
-
-static void vendor_epilog_cb(bt_vendor_op_result_t result) {
-}
-
-
-static const bt_vendor_callbacks_t fmhci_vendor_callbacks = {
- sizeof(fmhci_vendor_callbacks),
- vendor_fwcfg_cb,
- vendor_scocfg_cb,
- vendor_lpm_vnd_cb,
- sco_audiostate_cb,
- vendor_alloc,
- vendor_dealloc,
- vendor_xmit_cb,
- vendor_epilog_cb
-};
-#endif
diff --git a/helium/Android.mk b/helium/Android.mk
index 4008dd6..737ed3f 100644
--- a/helium/Android.mk
+++ b/helium/Android.mk
@@ -1,6 +1,3 @@
-#ifeq ($(BOARD_HAVE_QCOM_FM),true)
-#ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
-
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
@@ -15,7 +12,7 @@
libnativehelper \
libcutils
-FM_HCI_DIR:= vendor/qcom/opensource/fm
+FM_HCI_DIR:= vendor/qcom/opensource/commonsys/fm
LOCAL_C_INCLUDES += $(FM_HCI_DIR)/fm_hci
@@ -23,8 +20,3 @@
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
-
-#endif # is-vendor-board-platform
-#endif # BOARD_HAVE_QCOM_FM
-
-
diff --git a/jni/Android.mk b/jni/Android.mk
index 1a8326d..4c64481 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -3,6 +3,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee")
+LOCAL_CFLAGS += -DFM_SOC_TYPE_CHEROKEE
+endif
+
LOCAL_SRC_FILES:= \
android_hardware_fm.cpp \
ConfFileParser.cpp \
@@ -10,9 +14,6 @@
FmIoctlsInterface.cpp \
FmPerformanceParams.cpp
-ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee")
-LOCAL_CFLAGS += -DFM_SOC_TYPE_CHEROKEE
-endif
LOCAL_LDLIBS += -ldl
LOCAL_SHARED_LIBRARIES := \
libandroid_runtime \
@@ -29,16 +30,6 @@
include $(BUILD_SHARED_LIBRARY)
-include $(CLEAR_VARS)
-LOCAL_MODULE := init.qti.fm.sh
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := ETC
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
-
-LOCAL_INIT_RC := init.qti.fm.rc
-
-include $(BUILD_PREBUILT)
endif # is-vendor-board-platform
endif # BOARD_HAVE_QCOM_FM
diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp
index e60fe3d..6964271 100644
--- a/jni/android_hardware_fm.cpp
+++ b/jni/android_hardware_fm.cpp
@@ -83,7 +83,6 @@
namespace android {
-#ifdef FM_SOC_TYPE_CHEROKEE
char *FM_LIBRARY_NAME = "fm_helium.so";
char *FM_LIBRARY_SYMBOL_NAME = "FM_HELIUM_LIB_INTERFACE";
void *lib_handle;
@@ -649,7 +648,6 @@
fm_enable_slimbus_cb,
fm_enable_softmute_cb
};
-#endif
/* native interface */
static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative
(JNIEnv* env, jobject thiz, jstring path)
@@ -740,6 +738,23 @@
return FM_JNI_SUCCESS;
}
+static bool is_soc_cherokee() {
+ char value[PROPERTY_VALUE_MAX] = {'\0'};
+ property_get("vendor.bluetooth.soc", value, NULL);
+ ALOGD("BT soc is %s\n", value);
+
+ // Need to rework on property
+ /*if(strcmp(value, "cherokee") == 0)
+ return true;
+ else
+ return false;*/
+#ifdef FM_SOC_TYPE_CHEROKEE
+ ALOGD("BT soc is CHEROKEE");
+ return true;
+#else
+ return false;
+#endif
+}
/********************************************************************
* Current JNI
*******************************************************************/
@@ -750,29 +765,32 @@
{
int err;
long freq;
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_FREQ, (int *)&freq);
- if (err == FM_JNI_SUCCESS) {
- err = freq;
- } else {
- err = FM_JNI_FAILURE;
- ALOGE("%s: get freq failed\n", LOG_TAG);
- }
-#else
- if (fd >= 0) {
- err = FmIoctlsInterface :: get_cur_freq(fd, freq);
- if(err < 0) {
- err = FM_JNI_FAILURE;
- ALOGE("%s: get freq failed\n", LOG_TAG);
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_FREQ, (int *)&freq);
+ if (err == FM_JNI_SUCCESS) {
+ err = freq;
} else {
- err = freq;
+ err = FM_JNI_FAILURE;
+ ALOGE("%s: get freq failed\n", LOG_TAG);
}
- } else {
- ALOGE("%s: get freq failed because fd is negative, fd: %d\n",
- LOG_TAG, fd);
- err = FM_JNI_FAILURE;
}
-#endif
+ else
+ {
+ if (fd >= 0) {
+ err = FmIoctlsInterface :: get_cur_freq(fd, freq);
+ if(err < 0) {
+ err = FM_JNI_FAILURE;
+ ALOGE("%s: get freq failed\n", LOG_TAG);
+ } else {
+ err = freq;
+ }
+ } else {
+ ALOGE("%s: get freq failed because fd is negative, fd: %d\n",
+ LOG_TAG, fd);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -781,23 +799,26 @@
(JNIEnv * env, jobject thiz, jint fd, jint freq)
{
int err;
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_FREQ, freq);
-#else
- if ((fd >= 0) && (freq > 0)) {
- err = FmIoctlsInterface :: set_freq(fd, freq);
- if (err < 0) {
- ALOGE("%s: set freq failed, freq: %d\n", LOG_TAG, freq);
- err = FM_JNI_FAILURE;
- } else {
- err = FM_JNI_SUCCESS;
- }
- } else {
- ALOGE("%s: set freq failed because either fd/freq is negative,\
- fd: %d, freq: %d\n", LOG_TAG, fd, freq);
- err = FM_JNI_FAILURE;
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_FREQ, freq);
}
-#endif
+ else
+ {
+ if ((fd >= 0) && (freq > 0)) {
+ err = FmIoctlsInterface :: set_freq(fd, freq);
+ if (err < 0) {
+ ALOGE("%s: set freq failed, freq: %d\n", LOG_TAG, freq);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = FM_JNI_SUCCESS;
+ }
+ } else {
+ ALOGE("%s: set freq failed because either fd/freq is negative,\
+ fd: %d, freq: %d\n", LOG_TAG, fd, freq);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -807,23 +828,26 @@
{
int err;
ALOGE("id(%x) value: %x\n", id, value);
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->set_fm_ctrl(id, value);
-#else
- if ((fd >= 0) && (id >= 0)) {
- err = FmIoctlsInterface :: set_control(fd, id, value);
- if (err < 0) {
- ALOGE("%s: set control failed, id: %d\n", LOG_TAG, id);
- err = FM_JNI_FAILURE;
- } else {
- err = FM_JNI_SUCCESS;
- }
- } else {
- ALOGE("%s: set control failed because either fd/id is negavtive,\
- fd: %d, id: %d\n", LOG_TAG, fd, id);
- err = FM_JNI_FAILURE;
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->set_fm_ctrl(id, value);
}
-#endif
+ else
+ {
+ if ((fd >= 0) && (id >= 0)) {
+ err = FmIoctlsInterface :: set_control(fd, id, value);
+ if (err < 0) {
+ ALOGE("%s: set control failed, id: %d\n", LOG_TAG, id);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = FM_JNI_SUCCESS;
+ }
+ } else {
+ ALOGE("%s: set control failed because either fd/id is negavtive,\
+ fd: %d, id: %d\n", LOG_TAG, fd, id);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -856,29 +880,32 @@
long val;
ALOGE("id(%x)\n", id);
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->get_fm_ctrl(id, (int *)&val);
- if (err < 0) {
- ALOGE("%s: get control failed, id: %d\n", LOG_TAG, id);
- err = FM_JNI_FAILURE;
- } else {
- err = val;
- }
-#else
- if ((fd >= 0) && (id >= 0)) {
- err = FmIoctlsInterface :: get_control(fd, id, val);
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->get_fm_ctrl(id, (int *)&val);
if (err < 0) {
ALOGE("%s: get control failed, id: %d\n", LOG_TAG, id);
err = FM_JNI_FAILURE;
} else {
err = val;
}
- } else {
- ALOGE("%s: get control failed because either fd/id is negavtive,\
- fd: %d, id: %d\n", LOG_TAG, fd, id);
- err = FM_JNI_FAILURE;
}
-#endif
+ else
+ {
+ if ((fd >= 0) && (id >= 0)) {
+ err = FmIoctlsInterface :: get_control(fd, id, val);
+ if (err < 0) {
+ ALOGE("%s: get control failed, id: %d\n", LOG_TAG, id);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = val;
+ }
+ } else {
+ ALOGE("%s: get control failed because either fd/id is negavtive,\
+ fd: %d, id: %d\n", LOG_TAG, fd, id);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -888,30 +915,33 @@
(JNIEnv * env, jobject thiz, jint fd, jint dir)
{
int err;
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_SEEK, dir);
- if (err < 0) {
- ALOGE("%s: search failed, dir: %d\n", LOG_TAG, dir);
- err = FM_JNI_FAILURE;
- } else {
- err = FM_JNI_SUCCESS;
- }
-#else
- if ((fd >= 0) && (dir >= 0)) {
- ALOGD("startSearchNative: Issuing the VIDIOC_S_HW_FREQ_SEEK");
- err = FmIoctlsInterface :: start_search(fd, dir);
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_SEEK, dir);
if (err < 0) {
ALOGE("%s: search failed, dir: %d\n", LOG_TAG, dir);
err = FM_JNI_FAILURE;
} else {
err = FM_JNI_SUCCESS;
}
- } else {
- ALOGE("%s: search failed because either fd/dir is negative,\
- fd: %d, dir: %d\n", LOG_TAG, fd, dir);
- err = FM_JNI_FAILURE;
}
-#endif
+ else
+ {
+ if ((fd >= 0) && (dir >= 0)) {
+ ALOGD("startSearchNative: Issuing the VIDIOC_S_HW_FREQ_SEEK");
+ err = FmIoctlsInterface :: start_search(fd, dir);
+ if (err < 0) {
+ ALOGE("%s: search failed, dir: %d\n", LOG_TAG, dir);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = FM_JNI_SUCCESS;
+ }
+ } else {
+ ALOGE("%s: search failed because either fd/dir is negative,\
+ fd: %d, dir: %d\n", LOG_TAG, fd, dir);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -921,29 +951,32 @@
{
int err;
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_SRCHON, 0);
- if (err < 0) {
- ALOGE("%s: cancel search failed\n", LOG_TAG);
- err = FM_JNI_FAILURE;
- } else {
- err = FM_JNI_SUCCESS;
- }
-#else
- if (fd >= 0) {
- err = FmIoctlsInterface :: set_control(fd, V4L2_CID_PRV_SRCHON, 0);
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_SRCHON, 0);
if (err < 0) {
ALOGE("%s: cancel search failed\n", LOG_TAG);
err = FM_JNI_FAILURE;
} else {
err = FM_JNI_SUCCESS;
}
- } else {
- ALOGE("%s: cancel search failed because fd is negative, fd: %d\n",
- LOG_TAG, fd);
- err = FM_JNI_FAILURE;
}
-#endif
+ else
+ {
+ if (fd >= 0) {
+ err = FmIoctlsInterface :: set_control(fd, V4L2_CID_PRV_SRCHON, 0);
+ if (err < 0) {
+ ALOGE("%s: cancel search failed\n", LOG_TAG);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = FM_JNI_SUCCESS;
+ }
+ } else {
+ ALOGE("%s: cancel search failed because fd is negative, fd: %d\n",
+ LOG_TAG, fd);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -954,29 +987,32 @@
int err;
long rmssi;
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_RMSSI, (int *)&rmssi);
- if (err < 0) {
- ALOGE("%s: Get Rssi failed", LOG_TAG);
- err = FM_JNI_FAILURE;
- } else {
- err = FM_JNI_SUCCESS;
- }
-#else
- if (fd >= 0) {
- err = FmIoctlsInterface :: get_rmssi(fd, rmssi);
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_RMSSI, (int *)&rmssi);
if (err < 0) {
- ALOGE("%s: get rmssi failed\n", LOG_TAG);
+ ALOGE("%s: Get Rssi failed", LOG_TAG);
err = FM_JNI_FAILURE;
} else {
- err = rmssi;
+ err = FM_JNI_SUCCESS;
}
- } else {
- ALOGE("%s: get rmssi failed because fd is negative, fd: %d\n",
- LOG_TAG, fd);
- err = FM_JNI_FAILURE;
}
-#endif
+ else
+ {
+ if (fd >= 0) {
+ err = FmIoctlsInterface :: get_rmssi(fd, rmssi);
+ if (err < 0) {
+ ALOGE("%s: get rmssi failed\n", LOG_TAG);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = rmssi;
+ }
+ } else {
+ ALOGE("%s: get rmssi failed because fd is negative, fd: %d\n",
+ LOG_TAG, fd);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -985,36 +1021,39 @@
(JNIEnv * env, jobject thiz, jint fd, jint low, jint high)
{
int err;
-#ifdef FM_SOC_TYPE_CHEROKEE
- err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_UPPER_BAND, high);
- if (err < 0) {
- ALOGE("%s: set band failed, high: %d\n", LOG_TAG, high);
- err = FM_JNI_FAILURE;
- return err;
- }
- err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_LOWER_BAND, low);
- if (err < 0) {
- ALOGE("%s: set band failed, low: %d\n", LOG_TAG, low);
- err = FM_JNI_FAILURE;
- } else {
- err = FM_JNI_SUCCESS;
- }
-#else
- if ((fd >= 0) && (low >= 0) && (high >= 0)) {
- err = FmIoctlsInterface :: set_band(fd, low, high);
+ if (is_soc_cherokee())
+ {
+ err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_UPPER_BAND, high);
if (err < 0) {
- ALOGE("%s: set band failed, low: %d, high: %d\n",
- LOG_TAG, low, high);
+ ALOGE("%s: set band failed, high: %d\n", LOG_TAG, high);
+ err = FM_JNI_FAILURE;
+ return err;
+ }
+ err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_LOWER_BAND, low);
+ if (err < 0) {
+ ALOGE("%s: set band failed, low: %d\n", LOG_TAG, low);
err = FM_JNI_FAILURE;
} else {
err = FM_JNI_SUCCESS;
}
- } else {
- ALOGE("%s: set band failed because either fd/band is negative,\
- fd: %d, low: %d, high: %d\n", LOG_TAG, fd, low, high);
- err = FM_JNI_FAILURE;
}
-#endif
+ else
+ {
+ if ((fd >= 0) && (low >= 0) && (high >= 0)) {
+ err = FmIoctlsInterface :: set_band(fd, low, high);
+ if (err < 0) {
+ ALOGE("%s: set band failed, low: %d, high: %d\n",
+ LOG_TAG, low, high);
+ err = FM_JNI_FAILURE;
+ } else {
+ err = FM_JNI_SUCCESS;
+ }
+ } else {
+ ALOGE("%s: set band failed because either fd/band is negative,\
+ fd: %d, low: %d, high: %d\n", LOG_TAG, fd, low, high);
+ err = FM_JNI_FAILURE;
+ }
+ }
return err;
}
@@ -1024,7 +1063,8 @@
{
int err;
ULINT freq;
-#ifdef FM_SOC_TYPE_CHEROKEE
+if (is_soc_cherokee())
+{
err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_LOWER_BAND, (int *)&freq);
if (err < 0) {
ALOGE("%s: get lower band failed\n", LOG_TAG);
@@ -1033,7 +1073,9 @@
err = freq;
}
return err;
-#endif
+}
+else
+{
if (fd >= 0) {
err = FmIoctlsInterface :: get_lowerband_limit(fd, freq);
if (err < 0) {
@@ -1047,7 +1089,7 @@
fd: %d\n", LOG_TAG, fd);
err = FM_JNI_FAILURE;
}
-
+}
return err;
}
@@ -1057,8 +1099,8 @@
{
int err;
ULINT freq;
-#ifdef FM_SOC_TYPE_CHEROKEE
-
+if (is_soc_cherokee())
+{
err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_UPPER_BAND, (int *)&freq);
if (err < 0) {
ALOGE("%s: get upper band failed\n", LOG_TAG);
@@ -1067,7 +1109,9 @@
err = freq;
}
return err;
-#endif
+}
+else
+{
if (fd >= 0) {
err = FmIoctlsInterface :: get_upperband_limit(fd, freq);
if (err < 0) {
@@ -1081,6 +1125,7 @@
fd: %d\n", LOG_TAG, fd);
err = FM_JNI_FAILURE;
}
+}
return err;
}
@@ -1089,7 +1134,8 @@
{
int err;
-#ifdef FM_SOC_TYPE_CHEROKEE
+if (is_soc_cherokee())
+{
err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_AUDIO_MODE, val);
if (err < 0) {
ALOGE("%s: set audio mode failed\n", LOG_TAG);
@@ -1098,7 +1144,9 @@
err = FM_JNI_SUCCESS;
}
return err;
-#endif
+}
+else
+{
if (fd >= 0) {
err = FmIoctlsInterface :: set_audio_mode(fd, (enum AUDIO_MODE)val);
if (err < 0) {
@@ -1109,6 +1157,7 @@
} else {
err = FM_JNI_FAILURE;
}
+}
return err;
}
@@ -1593,9 +1642,9 @@
{
ALOGD("%s: val = %d\n", __func__, val);
int err = JNI_ERR;
-#ifdef FM_SOC_TYPE_CHEROKEE
+if (is_soc_cherokee()) {
err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_ENABLE_SLIMBUS, val);
-#endif
+}
return err;
}
@@ -1604,16 +1653,15 @@
{
ALOGD("%s: val = %d\n", __func__, val);
int err = JNI_ERR;
-#ifdef FM_SOC_TYPE_CHEROKEE
+if (is_soc_cherokee()) {
err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_SOFT_MUTE, val);
-#endif
+}
return err;
}
static void classInitNative(JNIEnv* env, jclass clazz) {
ALOGI("ClassInit native called \n");
-#ifdef FM_SOC_TYPE_CHEROKEE
jclass dataClass = env->FindClass("qcom/fmradio/FmReceiverJNI");
javaClassRef = (jclass) env->NewGlobalRef(dataClass);
lib_handle = dlopen(FM_LIBRARY_NAME, RTLD_NOW);
@@ -1662,12 +1710,11 @@
if (lib_handle)
dlclose(lib_handle);
lib_handle = NULL;
-#endif
}
static void initNative(JNIEnv *env, jobject object) {
-#ifdef FM_SOC_TYPE_CHEROKEE
+if (is_soc_cherokee()) {
int status;
ALOGI("Init native called \n");
@@ -1681,17 +1728,17 @@
ALOGI("***** FM HAL Initialization complete *****\n");
}
mCallbacksObj = env->NewGlobalRef(object);
-#endif
+}
}
static void cleanupNative(JNIEnv *env, jobject object) {
-#ifdef FM_SOC_TYPE_CHEROKEE
- if (mCallbacksObj != NULL) {
- env->DeleteGlobalRef(mCallbacksObj);
- mCallbacksObj = NULL;
+ if (is_soc_cherokee()) {
+ if (mCallbacksObj != NULL) {
+ env->DeleteGlobalRef(mCallbacksObj);
+ mCallbacksObj = NULL;
+ }
}
-#endif
}
/*
* JNI registration.
diff --git a/jni/init.qti.fm.rc b/jni/init.qti.fm.rc
deleted file mode 100644
index 5d52259..0000000
--- a/jni/init.qti.fm.rc
+++ /dev/null
@@ -1,6 +0,0 @@
-service fm_dl /vendor/bin/init.qti.fm.sh
- class late_start
- user system
- group system
- disabled
- oneshot
diff --git a/jni/init.qti.fm.sh b/jni/init.qti.fm.sh
deleted file mode 100644
index e484753..0000000
--- a/jni/init.qti.fm.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/vendor/bin/sh
-# Copyright (c) 2009-2011, 2015, 2017 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.
-#
-
-setprop hw.fm.init 0
-
-mode=`getprop hw.fm.mode`
-version=199217
-
-LOG_TAG="qti-fm"
-LOG_NAME="${0}:"
-
-loge ()
-{
- /vendor/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
-}
-
-logi ()
-{
- /vendor/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
-}
-
-failed ()
-{
- loge "$1: exit code $2"
- exit $2
-}
-
-logi "In FM shell Script"
-logi "mode: $mode"
-logi "Version : $version"
-
-#$fm_qsoc_patches <fm_chipVersion> <enable/disable WCM>
-#
-case $mode in
- "normal")
- logi "inserting the radio transport module"
- echo 1 > /sys/module/radio_iris_transport/parameters/fmsmd_set
- /vendor/bin/fm_qsoc_patches $version 0
- ;;
- "wa_enable")
- /vendor/bin/fm_qsoc_patches $version 1
- ;;
- "wa_disable")
- /vendor/bin/fm_qsoc_patches $version 2
- ;;
- *)
- logi "Shell: Default case"
- /vendor/bin/fm_qsoc_patches $version 0
- ;;
-esac
-
-exit_code_fm_qsoc_patches=$?
-
-case $exit_code_fm_qsoc_patches in
- 0)
- logi "FM QSoC calibration and firmware download succeeded"
- ;;
- *)
- failed "FM QSoC firmware download and/or calibration failed" $exit_code_fm_qsoc_patches
- ;;
-esac
-
-setprop hw.fm.init 1
-
-exit 0
diff --git a/libfm_jni/Android.mk b/libfm_jni/Android.mk
deleted file mode 100644
index af66eb5..0000000
--- a/libfm_jni/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- FmIoctlsInterface.cpp \
- ConfigFmThs.cpp \
- FmPerformanceParams.cpp \
- ConfFileParser.cpp \
- FmRadioController.cpp \
- LibfmJni.cpp
-
-LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) \
- frameworks/base/include/media
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libdl \
- liblog \
- libmedia \
- libnativehelper \
-
-#LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
-#LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
-
-LOCAL_MODULE := libfmjni
-#include $(BUILD_SHARED_LIBRARY)
-
-endif
diff --git a/libfm_jni/ConfFileParser.cpp b/libfm_jni/ConfFileParser.cpp
deleted file mode 100644
index 1817ad7..0000000
--- a/libfm_jni/ConfFileParser.cpp
+++ /dev/null
@@ -1,926 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <math.h>
-#include <utils/Log.h>
-#include "ConfFileParser.h"
-
-//declaration of functions only specific to this file
-static char parse_line
-(
- group_table *key_file,
- const char *line,
- char **cur_grp
-);
-
-static char parse_load_frm_fhandler
-(
- group_table *key_file,
- FILE *fp
-);
-
-static char line_is_grp
-(
- group_table *key_file,
- const char *str,
- char **cur_grp
-);
-
-static void free_grp_list
-(
- group *a
-);
-
-static void free_key_list
-(
- key_value_pair_list *a
-);
-
-static char line_is_key_value_pair
-(
- group_table *key_file,
- const char *str,
- const char *cur_grp
-);
-
-static char line_is_comment
-(
- const char *str
-);
-
-static char grp_exist
-(
- const group_table *key_file,
- const char *new_grp
-);
-
-static char add_grp
-(
- group_table *key_file,
- const char *new_grp
-);
-
-static group *alloc_group
-(
- void
-);
-
-static key_value_pair_list *alloc_key_value_pair
-(
- void
-);
-
-static char add_key_value_pair
-(
- group_table *key_file,
- const char *cur_grp,
- const char *key,
- const char *val
-);
-
-
-//Definitions
-void free_strs
-(
- char **str_array
-)
-{
- char **str_array_cpy = str_array;
- if(str_array != NULL) {
- while(*str_array != NULL) {
- free(*str_array);
- str_array++;
- }
- }
- free(str_array_cpy);
-}
-//ToDo: Come up with code hashing
-//function
-unsigned int get_hash_code
-(
- const char *str
-)
-{
-
- unsigned len = strlen(str);
- unsigned int i;
- unsigned int hash_code = 0;
-
- for(i = 0; len > 0; len--, i++) {
- hash_code += (int)((str[i] * pow(2, len))) % INT_MAX;
- hash_code %= INT_MAX;
- }
- return hash_code;
-}
-
-static key_value_pair_list *alloc_key_value_pair
-(
- void
-)
-{
- key_value_pair_list *key_list = NULL;
-
- key_list = (key_value_pair_list *)malloc(
- sizeof(key_value_pair_list));
- if(key_list != NULL) {
- key_list->key = NULL;
- key_list->next = NULL;
- key_list->value = NULL;
- }
- return key_list;
-}
-
-static group * alloc_group
-(
- void
-)
-{
- group *grp = NULL;
- unsigned int i;
-
- grp = (group *)malloc(sizeof(group));
- if(grp != NULL) {
- grp->grp_name = NULL;
- grp->grp_next = NULL;
- grp->num_of_keys = 0;
- grp->keys_hash_size = MAX_UNIQ_KEYS;
- grp->list = (key_value_pair_list **)malloc
- (sizeof(key_value_pair_list *) * grp->keys_hash_size);
- if(grp->list == NULL) {
- ALOGE("Could not alloc group\n");
- free(grp);
- grp = NULL;
- }else {
- for(i = 0; i < grp->keys_hash_size; i++) {
- grp->list[i] = NULL;
- }
- }
- }
- return grp;
-}
-
-group_table *get_key_file
-(
-)
-{
- group_table *t = NULL;
- unsigned int i;
-
- t = (group_table *)malloc(sizeof(group_table));
- if (t != NULL) {
- t->grps_hash_size = MAX_UNIQ_GRPS;
- t->num_of_grps = 0;
- t->grps_hash = (group **)malloc(sizeof(group *)
- * t->grps_hash_size);
- if (t->grps_hash == NULL) {
- free(t);
- return NULL;
- }
- for(i = 0; i < t->grps_hash_size; i++) {
- t->grps_hash[i] = NULL;
- }
- }
- return t;
-}
-
-void free_key_file(
- group_table *key_file
-)
-{
- unsigned int i;
-
- if(key_file != NULL) {
- if(key_file->grps_hash != NULL) {
- for(i = 0; i < key_file->grps_hash_size; i++) {
- free_grp_list(key_file->grps_hash[i]);
- }
- }
- free(key_file->grps_hash);
- free(key_file);
- }
-}
-
-static void free_grp_list
-(
- group *a
-)
-{
- group *next;
- unsigned int i;
-
- while(a != NULL) {
- next = a->grp_next;
- if(a->list != NULL) {
- for(i = 0; i < a->keys_hash_size; i++) {
- free_key_list(a->list[i]);
- }
- }
- free(a->grp_name);
- free(a->list);
- free(a);
- a = next;
- }
-}
-
-static void free_key_list
-(
- key_value_pair_list *a
-)
-{
- key_value_pair_list *next;
-
- while(a != NULL) {
- next = a->next;
- free(a->key);
- free(a->value);
- free(a);
- a = next;
- }
-}
-//return all the groups
-//present in the file
-char **get_grps
-(
- const group_table *key_file
-)
-{
- char **grps = NULL;
- unsigned int i = 0;
- unsigned int j = 0;
- unsigned int grp_len;
- group *grp_list;
-
- if((key_file == NULL)
- || (key_file->grps_hash == NULL)
- || (key_file->grps_hash_size == 0)
- || (key_file->num_of_grps == 0)) {
- return grps;
- }
- grps = (char **)calloc((key_file->num_of_grps + 1),
- sizeof(char *));
- if(grps == NULL) {
- return grps;
- }
- for(i = 0; i < key_file->grps_hash_size; i++) {
- grp_list = key_file->grps_hash[i];
- while(grp_list != NULL) {
- grp_len = strlen(grp_list->grp_name);
- grps[j] = (char *)malloc(sizeof(char) *
- (grp_len + 1));
- if(grps[j] == NULL) {
- free_strs(grps);
- grps = NULL;
- return grps;
- }
- memcpy(grps[j], grp_list->grp_name,
- (grp_len + 1));
- grp_list = grp_list->grp_next;
- j++;
- }
- }
- grps[j] = NULL;
- return grps;
-}
-
-//returns the list of keys
-//associated with group name
-char **get_keys
-(
- const group_table *key_file,
- const char *grp_name
-)
-{
- unsigned int grp_hash_code;
- unsigned int grp_index;
- unsigned int num_of_keys;
- unsigned int i;
- unsigned int j = 0;
- unsigned int key_len;
- group *grp;
- key_value_pair_list *key_val_list;
- char **keys = NULL;
-
- if((key_file == NULL) || (grp_name == NULL)
- || (key_file->num_of_grps == 0) ||
- (key_file->grps_hash_size == 0) ||
- (key_file->grps_hash == NULL) ||
- (!strcmp(grp_name, ""))) {
- return keys;
- }
- grp_hash_code = get_hash_code(grp_name);
- grp_index = (grp_hash_code % key_file->grps_hash_size);
- grp = key_file->grps_hash[grp_index];
- while(grp != NULL) {
- if(!strcmp(grp_name, grp->grp_name)) {
- if((grp->num_of_keys == 0)
- || (grp->keys_hash_size == 0)
- || (grp->list == 0)) {
- return keys;
- }
- keys = (char **)calloc((grp->num_of_keys + 1),
- sizeof(char *));
- if(keys == NULL) {
- return keys;
- }
- for(i = 0; i < grp->keys_hash_size; i++) {
- key_val_list = grp->list[i];
- while(key_val_list != NULL) {
- key_len = strlen(key_val_list->key);
- keys[j] = (char *)malloc(sizeof(char) *
- (key_len + 1));
- if(keys[j] == NULL) {
- free_strs(keys);
- keys = NULL;
- return keys;
- }
- memcpy(keys[j], key_val_list->key,
- (key_len + 1));
- j++;
- key_val_list = key_val_list->next;
- }
- }
- keys[j] = NULL;
- return keys;
- }
- grp = grp->grp_next;
- }
- return keys;
-}
-
-char *get_value
-(
- const group_table *key_file,
- const char *grp_name,
- const char *key
-)
-{
- unsigned int grp_hash_code;
- unsigned int key_hash_code;
- unsigned int grp_index;
- unsigned int key_index;
- unsigned val_len;
- char *val = NULL;
- group *grp;
- key_value_pair_list *list;
-
- if((key_file == NULL) || (grp_name == NULL)
- || (key == NULL) || (key_file->grps_hash == NULL)
- || (key_file->grps_hash_size == 0) || !strcmp(grp_name, "")
- ||(!strcmp(key, ""))) {
- return NULL;
- }
- grp_hash_code = get_hash_code(grp_name);
- key_hash_code = get_hash_code(key);
- grp_index = (grp_hash_code % key_file->grps_hash_size);
- grp = key_file->grps_hash[grp_index];
- while(grp != NULL) {
- if(!strcmp(grp_name, grp->grp_name) && grp->keys_hash_size
- && grp->list) {
- key_index = (key_hash_code % grp->keys_hash_size);
- list = grp->list[key_index];
- while((list != NULL) && (strcmp(list->key, key))) {
- list = list->next;
- }
- if(list != NULL) {
- val_len = strlen(list->value);
- val = (char *)malloc(sizeof(char) * (val_len + 1));
- if(val != NULL) {
- memcpy(val, list->value, val_len);
- val[val_len] = '\0';
- }
- }
- return val;
- }
- grp = grp->grp_next;
- }
- return val;
-}
-//open the file,
-//read, parse and load
-//returns PARSE_SUCCESS if successfully
-//loaded else PARSE_FAILED
-char parse_load_file
-(
- group_table *key_file,
- const char *file
-)
-{
- FILE *fp;
- char ret = FALSE;
-
- if((file == NULL) || !strcmp(file, "")) {
- ALOGE("File name is null or empty \n");
- return ret;
- }
-
- fp = fopen(file, "r");
- if(fp == NULL) {
- ALOGE("could not open file for read\n");
- return ret;
- }
-
- ret = parse_load_frm_fhandler(key_file, fp);
- fclose(fp);
-
- return ret;
-}
-
-//Read block of data from file handler
-//extract each line, check kind of line(comment,
-//group, key value pair)
-static char parse_load_frm_fhandler
-(
- group_table *key_file,
- FILE *fp
-)
-{
- char buf[MAX_LINE_LEN];
- char ret = TRUE;
- char *line = NULL;
- void *new_line;
- char *cur_grp = NULL;
- unsigned line_len = 0;
- unsigned line_allocated = 0;
- unsigned int bytes_read = 0;
- unsigned int i;
- bool has_carriage_rtn = false;
-
- while((bytes_read = fread(buf, 1, MAX_LINE_LEN, fp))) {
- for(i = 0; i < bytes_read; i++) {
- if(line_len == line_allocated) {
- line_allocated += 25;
- new_line = realloc(line, line_allocated);
- if(new_line == NULL) {
- ret = FALSE;
- ALOGE("memory allocation failed for line\n");
- break;
- }
- line = (char *)new_line;
- }
- if((buf[i] == '\n')) {
- has_carriage_rtn = false;
- line[line_len] = '\0';
- ret = parse_line(key_file, line, &cur_grp);
- line_len = 0;
- if(ret == FALSE) {
- ALOGE("could not parse the line, line not proper\n");
- break;
- }
- }else if(buf[i] == '\r') {
- ALOGE("File has carriage return\n");
- has_carriage_rtn = true;
- }else if(has_carriage_rtn) {
- ALOGE("File format is not proper, no line character\
- after carraige return\n");
- ret = FALSE;
- break;
- }else {
- line[line_len] = buf[i];
- line_len++;
- }
- }
- if (!ret) {
- break;
- }
- }
- free(line);
- free(cur_grp);
-
- return ret;
-}
-
-//checks whether a line is
-//comment or grp or key pair value
-//and accordingly adds to list
-static char parse_line
-(
- group_table *key_file,
- const char *line,
- char **cur_grp
-)
-{
- const char *line_begin;
- char *grp_name;
- unsigned int len;
-
- if((line == NULL) || (key_file == NULL)) {
- ALOGE("key file or line is null\n");
- return FALSE;
- }
-
- for(line_begin = line; isspace(*line_begin);
- line_begin++);
-
- if(line_is_comment(line_begin)) {
- ALOGE("line is comment\n");
- return TRUE;
- }else if(line_is_grp(key_file, line_begin, cur_grp)) {
- ALOGE("line is grp\n");
- return TRUE;
- }else if(line_is_key_value_pair(key_file, line_begin, *cur_grp)) {
- ALOGE("line is key value pair\n");
- return TRUE;
- }else {
- ALOGE("line is neither comment, grp nor key value pair\n");
- return FALSE;
- }
-}
-
-static char line_is_comment
-(
- const char *str
-)
-{
- if(str == NULL) {
- return FALSE;
- }else if(((*str) == '#') || ((*str) == '\0')
- || ((*str) == '\n')) {
- return TRUE;
- }else {
- ALOGE("line is not comment\n");
- return FALSE;
- }
-}
-
-//return true if a group
-//name already exist
-//else false
-static char grp_exist
-(
- const group_table *key_file,
- const char *new_grp
-)
-{
- unsigned hash_code;
- unsigned int index;
- group *grp;
-
- if((key_file == NULL) || (new_grp == NULL)
- || (!key_file->grps_hash_size)) {
- return FALSE;
- }else {
- hash_code = get_hash_code(new_grp);
- index = hash_code % key_file->grps_hash_size;
- grp = key_file->grps_hash[index];
- while(grp != NULL) {
- if (!strcmp(grp->grp_name, new_grp))
- return TRUE;
- grp = grp->grp_next;
- }
- return FALSE;
- }
-}
-
-//Add a group to group
-//table if it does not exist
-static char add_grp
-(
- group_table *key_file,
- const char *new_grp
-)
-{
- unsigned int hash_code;
- unsigned int index;
- unsigned int grp_name_len;
- group *grp;
-
- if(!grp_exist(key_file, new_grp)) {
- if((key_file == NULL) || (new_grp == NULL)
- || !key_file->grps_hash_size) {
- return FALSE;
- }
- hash_code = get_hash_code(new_grp);
- ALOGE("group hash code is: %u\n", hash_code);
- index = hash_code % key_file->grps_hash_size;
- ALOGE("group index is: %u\n", index);
- grp = alloc_group();
- if(grp == NULL) {
- return FALSE;
- }
- grp_name_len = strlen(new_grp);
- grp->grp_name = (char *)malloc(
- sizeof(char) * (grp_name_len + 1));
- if(grp->grp_name == NULL) {
- ALOGE("could not alloc memory for group name\n");
- ALOGE("Add group failed\n");
- free_grp_list(grp);
- return FALSE;
- }else {
- memcpy(grp->grp_name, new_grp, (grp_name_len + 1));
- }
- grp->grp_next = key_file->grps_hash[index];
- key_file->grps_hash[index] = grp;
- key_file->num_of_grps++;
- return TRUE;
- }else {
- return FALSE;
- }
-}
-
-//checks validity of a group
-//a valid group is
-//inside [] group name must be
-//alphanumeric
-//Example: [grpName]
-static char line_is_grp
-(
- group_table *key_file,
- const char *str,
- char **cur_grp
-)
-{
- const char *g_start;
- const char *g_end;
- char *new_grp;
- unsigned int grp_len;
-
- if ((str == NULL) || (key_file == NULL)) {
- ALOGE("str is null or key file is null\n");
- return FALSE;
- }
- //checks start mark char ']'
- if(((*str) != '[')) {
- ALOGE("start mark is not '['\n");
- return FALSE;
- }else {
- str++;
- g_start = str;
- }
- //checks the end char '['
- while((*str != '\0') && ((*str) != ']')) {
- str++;
- }
- //if end mark group not found
- if ((*str) != ']') {
- ALOGE("grp end mark is not '['\n");
- return FALSE;
- }else {
- g_end = (str - 1);
- }
-
- str++;
- //if end mark found checks the rest chars as well
- //rest chars should be space
- while(((*str) == ' ') || ((*str) == '\t')) {
- str++;
- }
- if(*str) {
- ALOGE("after ']' there are some character\n");
- return FALSE;
- }
-
- str = g_start;
- while((*g_start != '\0') && (g_start != g_end)
- && isalnum(*g_start)) {
- g_start++;
- }
- if((g_start == g_end) && isalnum(*g_start)) {
- //look up if already exist
- //return false else insert the grp in grp table
- grp_len = (g_end - str + 1);
- new_grp = (char *)malloc(sizeof(char) * (grp_len + 1));
- if (new_grp == NULL) {
- ALOGE("could not alloc memory for new group\n");
- return FALSE;
- }
- memcpy(new_grp, str, grp_len);
- new_grp[grp_len] = '\0';
-
- if(add_grp(key_file, new_grp)) {
- free(*cur_grp);
- *cur_grp = new_grp;
- return TRUE;
- }else {
- ALOGE("could not add group to group table\n");
- return FALSE;
- }
- }else {
- return FALSE;
- }
-}
-
-static char key_exist
-(
- const group_table *key_file,
- const char *cur_grp,
- const char *key
-)
-{
- unsigned int grp_hash_code;
- unsigned int key_hash_code;
- unsigned int grp_index;
- unsigned int key_index;
- group *grp = NULL;
- key_value_pair_list *list = NULL;
-
- if((key_file != NULL) && (cur_grp != NULL)
- && (key != NULL) && ((key_file->grps_hash != NULL))
- && (strcmp(key, ""))) {
- grp_hash_code = get_hash_code(cur_grp);
- grp_index = (grp_hash_code % key_file->grps_hash_size);
- grp = key_file->grps_hash[grp_index];
- key_hash_code = get_hash_code(key);
- while((grp != NULL)) {
- if(!strcmp(cur_grp, grp->grp_name)) {
- key_index = (key_hash_code % grp->keys_hash_size);
- if(grp->list)
- list = grp->list[key_index];
- while((list != NULL) && strcmp(key, list->key)) {
- list = list->next;
- }
- if(list != NULL){
- return TRUE;
- }else{
- return FALSE;
- }
- }
- grp = grp->grp_next;
- }
- if(!grp) {
- return TRUE;
- }else {
- return FALSE;
- }
- }else {
- return FALSE;
- }
-}
-
-//checks validity of key
-//a valid key must start in
-//a seperate line and key must
-//be alphanumeric and before '='
-//there must not be any space
-//Example: key=value
-static char line_is_key_value_pair
-(
- group_table *key_file,
- const char *str,
- const char *cur_grp
-)
-{
- char *equal_start;
- char *key = NULL;
- char *val = NULL;
- unsigned key_len;
- unsigned val_len;
-
- if((str == NULL) || (cur_grp == NULL) ||
- !strcmp(cur_grp, "") || (key_file == NULL)) {
- ALOGE("line is null or cur group or key file is null or empty\n");
- return FALSE;
- }
- equal_start = strchr(str, '=');
- key_len = (equal_start - str);
- if((equal_start == NULL) || (equal_start == str)) {
- ALOGE("line does not have '=' character or no key\n");
- return FALSE;
- }
- while((str != equal_start) && isalnum(*str))
- str++;
- if((str == equal_start)) {
- key = (char *)malloc(sizeof(char) * (key_len + 1));
- if(key == NULL) {
- ALOGE("could not alloc memory for new key\n");
- return FALSE;
- }
- equal_start++;
- val_len = strlen(equal_start);
- val = (char *)malloc(sizeof(char) * (val_len + 1));
- if(val == NULL) {
- ALOGE("could not alloc memory for value\n");
- if(key){
- free(key);
- key = NULL;
- }
- return FALSE;
- }
- memcpy(key, (str - key_len), key_len);
- memcpy(val, equal_start, val_len);
- key[key_len] = '\0';
- val[val_len] = '\0';
- ALOGE("Grp: %s, key: %s, value: %s\n", cur_grp, key, val);
- return add_key_value_pair(key_file,
- cur_grp, key, val);
- }else {
- ALOGE("key name doesnot have alpha numeric char\n");
- return FALSE;
- }
-}
-
-static char add_key_value_pair
-(
- group_table *key_file,
- const char *cur_grp,
- const char *key,
- const char *val
-)
-{
- unsigned int grp_hash_code;
- unsigned int key_hash_code;
- unsigned int grp_index;
- unsigned int key_index;
- unsigned key_len, val_len;
- group *grp = NULL;
- key_value_pair_list *list = NULL;
-
- if((key_file != NULL) && (cur_grp != NULL)
- && (key != NULL) && ((key_file->grps_hash != NULL))
- && (strcmp(key, ""))) {
- grp_hash_code = get_hash_code(cur_grp);
- ALOGE("grp hash code is %u\n", grp_hash_code);
- grp_index = (grp_hash_code % key_file->grps_hash_size);
- ALOGE("grp index is %u\n", grp_index);
- grp = key_file->grps_hash[grp_index];
- key_hash_code = get_hash_code(key);
- while((grp != NULL)) {
- if(!strcmp(cur_grp, grp->grp_name)) {
- key_index = (key_hash_code % grp->keys_hash_size);
- if(grp->list) {
- list = grp->list[key_index];
- }else {
- ALOGE("group list is null\n");
- goto err;
- }
- while((list != NULL) && strcmp(key, list->key)) {
- list = list->next;
- }
- if(list != NULL) {
- ALOGE("group already contains the key\n");
- goto err;
- }else{
- list = alloc_key_value_pair();
- if(list == NULL) {
- ALOGE("add key value failed as could not alloc memory for key\
- val pair\n");
- goto err;
- }
- key_len = strlen(key);
- list->key = (char *)malloc(sizeof(char) *
- (key_len + 1));
- if(list->key == NULL) {
- ALOGE("could not alloc memory for key\n");
- free(list);
- goto err;
- }
- val_len = strlen(val);
- list->value = (char *)malloc(sizeof(char) *
- (val_len + 1));
- if(!list->value) {
- free(list->key);
- free(list);
- goto err;
- }
- memcpy(list->key, key, key_len);
- memcpy(list->value, val, val_len);
- if (key) free((char*)key);
- if (val) free((char*)val);
- list->key[key_len] = '\0';
- list->value[val_len] = '\0';
- list->next = grp->list[key_index];
- grp->list[key_index] = list;
- grp->num_of_keys++;
- return TRUE;
- }
- }
- grp = grp->grp_next;
- }
- ALOGE("group does not exist\n");
- goto err;
- }
-err:
- if (key) free((char*)key);
- if (val) free((char*)val);
- return FALSE;
-}
diff --git a/libfm_jni/ConfFileParser.h b/libfm_jni/ConfFileParser.h
deleted file mode 100644
index 88f67e0..0000000
--- a/libfm_jni/ConfFileParser.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#ifndef __CONF_FILE_PARSER_H__
-#define __CONF_FILE_PARSER_H__
-
-#define MAX_LINE_LEN 512
-#define MAX_UNIQ_KEYS 5
-#define MAX_UNIQ_GRPS 10
-#define TRUE 1
-#define FALSE 0
-
-struct key_value_pair_list
-{
- char *key;
- char *value;
- key_value_pair_list *next;
-};
-
-struct group
-{
- char *grp_name;
- unsigned int num_of_keys;
- unsigned int keys_hash_size;
- key_value_pair_list **list;
- group *grp_next;
-};
-
-struct group_table
-{
- unsigned int grps_hash_size;
- unsigned int num_of_grps;
- group **grps_hash;
-};
-
-enum CONF_PARSE_ERRO_CODE
-{
- PARSE_SUCCESS,
- INVALID_FILE_NAME,
- FILE_OPEN_FAILED,
- FILE_NOT_PROPER,
- MEMORY_ALLOC_FAILED,
- PARSE_FAILED,
-};
-
-unsigned int get_hash_code(const char *str);
-group_table *get_key_file();
-void free_strs(char **str_array);
-void free_key_file(group_table *key_file);
-char parse_load_file(group_table *key_file, const char *file);
-char **get_grps(const group_table *key_file);
-char **get_keys(const group_table *key_file, const char *grp);
-char *get_value(const group_table *key_file, const char *grp,
- const char *key);
-
-#endif //__CONF_FILE_PARSER_H__
diff --git a/libfm_jni/ConfigFmThs.cpp b/libfm_jni/ConfigFmThs.cpp
deleted file mode 100644
index dd6b283..0000000
--- a/libfm_jni/ConfigFmThs.cpp
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#include <cstdlib>
-#include <cstring>
-#include <utils/Log.h>
-#include "ConfigFmThs.h"
-#include "FmPerformanceParams.h"
-#include "FmRadioController.h"
-
-static int compare_name
-(
- const void *name1, const void *name2
-)
-{
- char *first = (char *)name1;
- struct NAME_MAP *second = (struct NAME_MAP *)name2;
-
- return(strcmp(first, second->name));
-}
-
-ConfigFmThs :: ConfigFmThs
-(
-)
-{
- keyfile = NULL;
-}
-
-ConfigFmThs :: ~ConfigFmThs
-(
-)
-{
- free_key_file(keyfile);
-}
-
-void ConfigFmThs :: set_band_cfgs
-(
- UINT fd
-)
-{
- signed char ret = FM_SUCCESS;
- char **keys;
- char **keys_cpy;
- char *key_value;
- int value;
- FmPerformanceParams perf_params;
- struct NAME_MAP *found;
-
- if(keyfile != NULL) {
- keys_cpy = keys = get_keys(keyfile, GRPS_MAP[1].name);
- if(keys != NULL) {
- while(*keys != NULL) {
- ALOGE("key found is: %s\n", *keys);
- found = (NAME_MAP *)bsearch(*keys, BAND_CFG_MAP,
- MAX_BAND_PARAMS, sizeof(NAME_MAP), compare_name);
- if(found != NULL) {
- key_value = get_value(keyfile,
- GRPS_MAP[1].name, found->name);
- if((key_value != NULL) && strcmp(key_value, "")) {
- value = atoi(key_value);
- switch(found->num) {
- case RADIO_BAND:
- ALOGE("RADIO_BAND\n");
- if((value >= BAND_87500_108000)
- && (value <= BAND_76000_90000)) {
- ALOGE("%s:Set band as: %d\n",__func__, value);
- ret = perf_params.SetBand(fd, value);
- if(ret == FM_FAILURE)
- ALOGE("Error in setting band\n");
- }
- break;
- case EMPHASIS:
- ALOGE("EMPHASIS\n");
- if((value >= DE_EMP75)
- && (value <= DE_EMP50)) {
- ALOGE("%s:Set Emphasis as: %d\n",__func__, value);
- ret = perf_params.SetEmphsis(fd, value);
- if(ret == FM_FAILURE)
- ALOGE("Error in setting Emphasis\n");
- }
- break;
- case CHANNEL_SPACING:
- ALOGE("CHANNEL_SPACING\n");
- if((value >= CHAN_SPACE_200)
- && (value <= CHAN_SPACE_50)) {
- ALOGE("%s:Set CH space as: %d\n",__func__, value);
- ret = perf_params.SetChannelSpacing(fd, value);
- if(ret == FM_FAILURE)
- ALOGE("Error in setting channel spacing\n");
- }
- break;
- }
- }else {
- ALOGE("key_val for key: %s is empty\n",
- *keys);
- }
- free(key_value);
- }
- keys++;
- }
- }else {
- ALOGE("No of keys found is zero\n");
- }
- free_strs(keys_cpy);
- }else {
- ALOGE("key file is null\n");
- }
-}
-
-void ConfigFmThs :: set_af_ths
-(
- UINT fd
-)
-{
- signed char ret = FM_SUCCESS;
- char **keys;
- char **keys_cpy;
- char *key_value;
- int value;
- FmPerformanceParams perf_params;
- struct NAME_MAP *found;
-
- if(keyfile != NULL) {
- keys_cpy = keys = get_keys(keyfile, GRPS_MAP[0].name);
- if(keys != NULL) {
- while(*keys != NULL) {
- ALOGE("key found is: %s\n", *keys);
- found = (NAME_MAP *)bsearch(*keys, AF_PARAMS_MAP,
- MAX_AF_PARAMS, sizeof(NAME_MAP), compare_name);
- if(found != NULL) {
- key_value = get_value(keyfile,
- GRPS_MAP[0].name, found->name);
- if((key_value != NULL) && strcmp(key_value, "")) {
- value = atoi(key_value);
- switch(found->num) {
- case AF_RMSSI_TH:
- if((value >= AF_RMSSI_TH_MIN)
- && (value <= AF_RMSSI_TH_MAX)) {
- ALOGE("Set af rmssi th: %d\n", value);
- ret = perf_params.SetAfRmssiTh(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting Af Rmssi th\n");
- break;
- }
- unsigned short th;
- ret = perf_params.GetAfRmssiTh(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read af rmssith: %hd\n", th);
- }else {
- ALOGE("Error in reading Af Rmssi th\n");
- }
- }
- break;
- case AF_RMSSI_SAMPLES:
- if((value >= AF_RMSSI_SAMPLES_MIN)
- && (value <= AF_RMSSI_SAMPLES_MAX)) {
- ALOGE("Set af rmssi samples cnt: %d\n", value);
- ret = perf_params.SetAfRmssiSamplesCnt(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting af rmssi samples\n");
- break;
- }
- unsigned char cnt;
- ret = perf_params.GetAfRmssiSamplesCnt(fd, cnt);
- if(ret == FM_SUCCESS) {
- ALOGE("Read af rmssi samples cnt: %hhd\n", cnt);
- }else {
- ALOGE("Error in reading rmssi samples\n");
- }
- }
- break;
- case GOOD_CH_RMSSI_TH:
- if((value >= GOOD_CH_RMSSI_TH_MIN)
- && (value <= GOOD_CH_RMSSI_TH_MAX)) {
- ALOGE("Set Good channle rmssi th: %d\n", value);
- ret = perf_params.SetGoodChannelRmssiTh(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting Good channle rmssi th\n");
- break;
- }
- signed char th;
- ret = perf_params.GetGoodChannelRmssiTh(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read good channel rmssi th: %d\n", th);
- }else {
- ALOGE("Error in reading Good channle rmssi th\n");
- }
- }
- break;
- }
- }else {
- ALOGE("key_val for key: %s is empty\n",
- *keys);
- }
- free(key_value);
- }
- keys++;
- }
- }else {
- ALOGE("No of keys found is zero\n");
- }
- free_strs(keys_cpy);
- }else {
- ALOGE("key file is null\n");
- }
-}
-
-void ConfigFmThs :: set_srch_ths
-(
- UINT fd
-)
-{
- signed char ret = FM_SUCCESS;
- char **keys = NULL;
- char **keys_cpy = NULL;
- char *key_value = NULL;
- int value;
- FmPerformanceParams perf_params;
- struct NAME_MAP *found = NULL;
-
- if(keyfile != NULL) {
- keys_cpy = keys = get_keys(keyfile, GRPS_MAP[3].name);
- if(keys != NULL) {
- while(*keys != NULL) {
- found = (NAME_MAP *)bsearch(*keys, SEACH_PARAMS_MAP,
- MAX_SRCH_PARAMS, sizeof(NAME_MAP), compare_name);
- if(found != NULL) {
- key_value = get_value(keyfile, GRPS_MAP[2].name, found->name);
- ALOGE("found srch ths: %s: %s\n", found->name, key_value);
- if((key_value != NULL) && strcmp(key_value, "")) {
- value = atoi(key_value);
- switch(found->num) {
- case SINR_FIRST_STAGE:
- if((value >= SINR_FIRST_STAGE_MIN)
- && (value <= SINR_FIRST_STAGE_MAX)) {
- ALOGE("Set sinr first stage: %d\n", value);
- ret = perf_params.SetSinrFirstStage(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting sinr first stage\n");
- break;
- }
- signed char th;
- ret = perf_params.GetSinrFirstStage(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read sinr first stage: %d\n", th);
- }else {
- ALOGE("Error in reading sinr first stage\n");
- }
- }
- break;
- case RMSSI_FIRST_STAGE:
- if((value >= RMSSI_FIRST_STAGE_MIN)
- && (value <= RMSSI_FIRST_STAGE_MAX)) {
- ALOGE("Set rmssi first stage: %d\n", value);
- ret = perf_params.SetRmssiFirstStage(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting rmssi first stage\n");
- break;
- }
- signed char th;
- ret = perf_params.GetRmssiFirstStage(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read rmssi first stage: %d\n", th);
- }else {
- ALOGE("Error in reading rmssi first stage\n");
- }
- }
- break;
- case INTF_LOW_TH:
- if((value >= INTF_LOW_TH_MIN)
- && (value <= INTF_LOW_TH_MAX)) {
- ALOGE("Set intf low th: %d\n", value);
- ret = perf_params.SetIntfLowTh(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting intf low th\n");
- break;
- }
- unsigned char th;
- ret = perf_params.GetIntfLowTh(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read intf low th: %u\n", th);
- }else {
- ALOGE("Error in reading intf low th\n");
- }
- }
- break;
- case INTF_HIGH_TH:
- if((value >= INTF_HIGH_TH_MIN)
- && (value <= INTF_HIGH_TH_MAX)) {
- ALOGE("Set intf high th: %d\n", value);
- ret = perf_params.SetIntfHighTh(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting intf high th\n");
- break;
- }
- unsigned char th;
- ret = perf_params.GetIntfHighTh(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read intf high th: %u\n", th);
- }else {
- ALOGE("Error in reading intf high th\n");
- }
- }
- break;
- case CF0_TH:
- ALOGE("Set cf0 th: %d\n", value);
- ret = perf_params.SetCf0Th12(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting cf0 th\n");
- break;
- }
- int th;
- ret = perf_params.GetCf0Th12(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read CF012 th: %d\n", th);
- }else {
- ALOGE("Error in reading cf0 th\n");
- }
- break;
- case SRCH_ALGO_TYPE:
- if((value >= SRCH_ALGO_TYPE_MIN)
- && (value <= SRCH_ALGO_TYPE_MAX)) {
- ALOGE("Set search algo type: %d\n", value);
- ret = perf_params.SetSrchAlgoType(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting search algo type\n");
- break;
- }
- unsigned char algo;
- ret = perf_params.GetSrchAlgoType(fd, algo);
- if(ret == FM_SUCCESS) {
- ALOGE("Read algo type: %u\n", algo);
- }else {
- ALOGE("Error in reading search algo type\n");
- }
- }
- break;
- case SINR_SAMPLES:
- if((value >= SINR_SAMPLES_CNT_MIN)
- && (value <= SINR_SAMPLES_CNT_MAX)) {
- ALOGE("Set sinr samples count: %d\n", value);
- ret = perf_params.SetSinrSamplesCnt(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting sinr samples count\n");
- break;
- }
- unsigned char cnt;
- ret = perf_params.GetSinrSamplesCnt(fd, cnt);
- if(ret == FM_SUCCESS) {
- ALOGE("Read sinr samples cnt: %u\n", cnt);
- }else {
- ALOGE("Error in reading sinr samples count\n");
- }
- }
- break;
- case SINR:
- if((value >= SINR_FINAL_STAGE_MIN)
- && (value <= SINR_FINAL_STAGE_MAX)) {
- ALOGE("Set final stage sinr: %d\n", value);
- ret = perf_params.SetSinrFinalStage(fd, value);
- if(ret == FM_FAILURE) {
- ALOGE("Error in setting final stage sinr\n");
- break;
- }
- signed char th;
- ret = perf_params.GetSinrFinalStage(fd, th);
- if(ret == FM_SUCCESS) {
- ALOGE("Read final stage sinr: %d\n", th);
- }else {
- ALOGE("Error in reading final stage sinr\n");
- }
- }
- break;
- }
- }else {
- ALOGE("key_value for key: %s is empty\n",
- *keys);
- }
- free(key_value);
- }
- keys++;
- }
- }else {
- ALOGE("No of keys found is zero\n");
- }
- free_strs(keys_cpy);
- }else {
- ALOGE("key file is null\n");
- }
-}
-
-void ConfigFmThs :: set_hybrd_list
-(
- UINT fd
-)
-{
- signed char ret = FM_SUCCESS;
- char **keys = NULL;
- char **keys_cpy = NULL;
- char *key_value = NULL;
- char *freqs = NULL;
- unsigned int *freqs_array = NULL;
- signed char *sinrs_array = NULL;
- char *sinrs = NULL;
- int value;
- unsigned int freq_cnt = 0;
- unsigned int sinr_cnt = 0;
- FmPerformanceParams perf_params;
- struct NAME_MAP *found;
-
- ALOGE("Inside hybrid srch list\n");
- if(keyfile != NULL) {
- keys_cpy = keys = get_keys(keyfile, GRPS_MAP[2].name);
- if(keys != NULL) {
- while(*keys != NULL) {
- found = (NAME_MAP *)bsearch(*keys, HYBRD_SRCH_MAP,
- MAX_HYBRID_SRCH_PARAMS, sizeof(NAME_MAP), compare_name);
- if(found != NULL) {
- key_value = get_value(keyfile, GRPS_MAP[1].name, found->name);
- if((key_value != NULL) && strcmp(key_value, "")) {
- switch(found->num) {
- case FREQ_LIST:
- freqs = key_value;
- break;
- case SINR_LIST:
- sinrs = key_value;
- break;
- default:
- free(key_value);
- break;
- }
- }
- }
- keys++;
- }
- free_strs(keys_cpy);
- }else {
- ALOGE("No of keys found is zero\n");
- }
- }else {
- ALOGE("key file is null\n");
- }
-
- freq_cnt = extract_comma_sep_freqs(freqs, &freqs_array, ",");
- sinr_cnt = extract_comma_sep_sinrs(sinrs, &sinrs_array, ",");
-
- if((freq_cnt == sinr_cnt) && (sinr_cnt > 0)) {
- perf_params.SetHybridSrchList(fd, freqs_array, sinrs_array, freq_cnt);
- }
-
- free(freqs);
- free(sinrs);
- free(freqs_array);
- free(sinrs_array);
-}
-
-unsigned int ConfigFmThs :: extract_comma_sep_freqs
-(
- char *freqs,
- unsigned int **freqs_arr,
- const char *str
-)
-{
- char *next_freq;
- char *saveptr;
- unsigned int freq;
- unsigned int *freqs_new_arr;
- unsigned int size = 0;
- unsigned int len = 0;
-
- next_freq = strtok_r(freqs, str, &saveptr);
- while(next_freq != NULL) {
- freq = atoi(next_freq);
- ALOGD("HYBRID_SRCH freq: %u\n", freq);
- if(size == len) {
- size <<= 1;
- if(size == 0)
- size = 1;
- freqs_new_arr = (unsigned int *)realloc(*freqs_arr,
- size * sizeof(unsigned int));
- if(freqs_new_arr == NULL) {
- free(*freqs_arr);
- *freqs_arr = NULL;
- break;
- }
- *freqs_arr = freqs_new_arr;
- }
- (*freqs_arr)[len] = freq;
- len++;
- next_freq = strtok_r(NULL, str, &saveptr);
- }
- return len;
-}
-
-unsigned int ConfigFmThs :: extract_comma_sep_sinrs
-(
- char *sinrs,
- signed char **sinrs_arr,
- const char *str
-)
-{
- char *next_sinr;
- char *saveptr;
- signed char *sinrs_new_arr;
- unsigned int size = 0;
- unsigned int len = 0;
- signed char sinr;
-
- next_sinr = strtok_r(sinrs, str, &saveptr);
- while(next_sinr != NULL) {
- sinr = atoi(next_sinr);
- ALOGD("HYBRID_SRCH sinr: %d\n", sinr);
- if(size == len) {
- size <<= 1;
- if(size == 0)
- size = 1;
- sinrs_new_arr = (signed char *)realloc(*sinrs_arr,
- size * sizeof(signed char));
- if(sinrs_new_arr == NULL) {
- free(*sinrs_arr);
- *sinrs_arr = NULL;
- break;
- }
- *sinrs_arr = sinrs_new_arr;
- }
- (*sinrs_arr)[len] = sinr;
- len++;
- next_sinr = strtok_r(NULL, str,&saveptr);
- }
- return len;
-}
-
-void ConfigFmThs :: SetRxSearchAfThs
-(
- const char *file, UINT fd
-)
-{
- int index;
- struct NAME_MAP *found;
- char **grps = NULL;
- char **grps_cpy = NULL;
-
- keyfile = get_key_file();
-
- ALOGE("file name is: %s\n", file);
- if(!parse_load_file(keyfile, file)) {
- ALOGE("Error in loading threshold file\n");
- }else {
- grps_cpy = grps = get_grps(keyfile);
- if(grps != NULL) {
- while(*grps != NULL) {
- ALOGE("Search grp: %s\n", *grps);
- found = (NAME_MAP *)bsearch(*grps, GRPS_MAP, MAX_GRPS,
- sizeof(NAME_MAP), compare_name);
- if(found != NULL) {
- ALOGE("Found group: %s\n", found->name);
- switch(found->num) {
- case AF_THS:
- set_af_ths(fd);
- break;
- case SRCH_THS:
- set_srch_ths(fd);
- break;
- case HYBRD_SRCH_LIST:
- set_hybrd_list(fd);
- break;
- case BAND_CFG:
- set_band_cfgs(fd);
- break;
- }
- }
- grps++;
- }
- }else {
- ALOGE("No of groups found is zero\n");
- }
- free_strs(grps_cpy);
- }
- free_key_file(keyfile);
- keyfile = NULL;
-}
diff --git a/libfm_jni/ConfigFmThs.h b/libfm_jni/ConfigFmThs.h
deleted file mode 100644
index 19bf86c..0000000
--- a/libfm_jni/ConfigFmThs.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#ifndef __CONFIG_FM_THS_H__
-#define __CONFIG_FM_THS_H__
-
-#include <cstring>
-#include "FM_Const.h"
-#include "ConfFileParser.h"
-
-#define MAX_GRPS 4
-#define MAX_SRCH_PARAMS 8
-#define MAX_AF_PARAMS 3
-#define MAX_BAND_PARAMS 3
-
-#define SINR_SAMPLES_CNT_MIN 0
-#define SINR_SAMPLES_CNT_MAX 255
-#define SINR_FIRST_STAGE_MIN -128
-#define SINR_FIRST_STAGE_MAX 127
-#define RMSSI_FIRST_STAGE_MIN -128
-#define RMSSI_FIRST_STAGE_MAX 127
-#define INTF_LOW_TH_MIN 0
-#define INTF_LOW_TH_MAX 255
-#define INTF_HIGH_TH_MIN 0
-#define INTF_HIGH_TH_MAX 255
-#define SRCH_ALGO_TYPE_MIN 0
-#define SRCH_ALGO_TYPE_MAX 1
-#define SINR_FINAL_STAGE_MIN -128
-#define SINR_FINAL_STAGE_MAX 127
-
-#define AF_RMSSI_TH_MIN 0
-#define AF_RMSSI_TH_MAX 65535
-#define AF_RMSSI_SAMPLES_MIN 0
-#define AF_RMSSI_SAMPLES_MAX 255
-#define GOOD_CH_RMSSI_TH_MIN -128
-#define GOOD_CH_RMSSI_TH_MAX 127
-#define FM_DE_EMP75 0
-#define FM_DE_EMP50 1
-#define FM_CHSPACE_200_KHZ 0
-#define FM_CHSPACE_100_KHZ 1
-#define FM_CHSPACE_50_KHZ 2
-
-const unsigned char MAX_HYBRID_SRCH_PARAMS = 2;
-
-struct NAME_MAP
-{
- const char name[50];
- const int num;
-};
-
-enum PERFORMANCE_GRPS
-{
- AF_THS,
- SRCH_THS,
- HYBRD_SRCH_LIST,
- BAND_CFG,
-};
-
-enum BAND_CFG_PARAMS
-{
- RADIO_BAND,
- EMPHASIS,
- CHANNEL_SPACING,
-};
-
-enum PERFORMANCE_SRCH_PARAMS
-{
- SRCH_ALGO_TYPE,
- CF0_TH,
- SINR_FIRST_STAGE,
- SINR,
- RMSSI_FIRST_STAGE,
- INTF_LOW_TH,
- INTF_HIGH_TH,
- SINR_SAMPLES,
-};
-
-enum PERFORMANCE_AF_PARAMS
-{
- AF_RMSSI_TH,
- AF_RMSSI_SAMPLES,
- GOOD_CH_RMSSI_TH,
-};
-
-enum HYBRID_SRCH_PARAMS
-{
- FREQ_LIST,
- SINR_LIST,
-};
-
-//Keep this list in sorted order (ascending order in terms of "name")
-//Don't change the name of GRPS, if changed please also change accordingly
-//file: fm_srch_af_th.conf
-static struct NAME_MAP GRPS_MAP[] =
-{
- {"AFTHRESHOLDS", AF_THS},
- {"BANDCONFIG", BAND_CFG},
- {"HYBRIDSEARCHLIST", HYBRD_SRCH_LIST},
- {"SEARCHTHRESHOLDS", SRCH_THS},
-};
-
-static struct NAME_MAP BAND_CFG_MAP[] =
-{
- {"ChSpacing", CHANNEL_SPACING},
- {"Emphasis", EMPHASIS},
- {"RadioBand", RADIO_BAND},
-};
-
-//Keep this list in sorted order (ascending order in terms of "name")
-//Don't change the name of SEARCH thresholds,
-//if changed please also change accordingly
-//file: fm_srch_af_th.conf
-static struct NAME_MAP SEACH_PARAMS_MAP[] =
-{
- {"Cf0Th12", CF0_TH},
- {"IntfHighTh", INTF_HIGH_TH},
- {"IntfLowTh", INTF_LOW_TH},
- {"RmssiFirstStage", RMSSI_FIRST_STAGE},
- {"SearchAlgoType", SRCH_ALGO_TYPE},
- {"Sinr", SINR},
- {"SinrFirstStage", SINR_FIRST_STAGE},
- {"SinrSamplesCnt", SINR_SAMPLES},
-};
-
-//Keep this list in sorted order (ascending order in terms of "name")
-//Don't change the name of SEARCH thresholds,
-//if changed please also change accordingly
-//file: fm_srch_af_th.conf
-static struct NAME_MAP AF_PARAMS_MAP[] =
-{
- {"AfRmssiSamplesCnt", AF_RMSSI_SAMPLES},
- {"AfRmssiTh", AF_RMSSI_TH},
- {"GoodChRmssiTh", GOOD_CH_RMSSI_TH},
-};
-
-static struct NAME_MAP HYBRD_SRCH_MAP[] =
-{
- {"Freqs", FREQ_LIST},
- {"Sinrs", SINR_LIST},
-};
-
-class ConfigFmThs {
- private:
- group_table *keyfile;
- void set_srch_ths(UINT fd);
- void set_af_ths(UINT fd);
- unsigned int extract_comma_sep_freqs(char *freqs, unsigned int **freqs_arr, const char *str);
- unsigned int extract_comma_sep_sinrs(char *sinrs, signed char **sinrs_arr, const char *str);
- void set_hybrd_list(UINT fd);
- void set_band_cfgs(UINT fd);
- public:
- ConfigFmThs();
- ~ConfigFmThs();
- void SetRxSearchAfThs(const char *file, UINT fd);
-};
-
-#endif //__CONFIG_FM_THS_H__
diff --git a/libfm_jni/FM_Const.h b/libfm_jni/FM_Const.h
deleted file mode 100644
index b0cc684..0000000
--- a/libfm_jni/FM_Const.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#ifndef __FM_CONST_H__
-#define __FM_CONST_H__
-
-//return related
-#define IOCTL_SUCC 0
-#define FM_SUCCESS 0
-#define FM_FAILURE -1
-#define PROP_SET_SUCC 0
-
-#define MAX_VER_STR_LEN 40
-#define INIT_LOOP_CNT 45
-
-//Time in us
-#define INIT_WAIT_TIMEOUT 200000
-#define RDS_AVL_INT_WAIT_TIMEOUT 200000
-//Time in secs
-#define READY_EVENT_TIMEOUT 5
-#define SCAN_COMPL_TIMEOUT 1280
-#define TUNE_EVENT_TIMEOUT 2
-#define SEEK_COMPL_TIMEOUT 60
-#define FM_SCAN_CH_SIZE_MAX 25
-
-#define TUNE_MULT 16
-#define CAL_DATA_SIZE 23
-#define STD_BUF_SIZE 256
-
-//RDS GROUPS
-#define GRP_3A 64
-
-//data related to enabling various
-//rds data RT, PS, AF LIST, AF JMP
-#define RDS_GRP_RT_EN 1
-#define RDS_GRP_PS_EN 2
-#define RDS_AF_JMP_LIST_EN 8
-#define RDS_GRP_AFJMP_EN 16
-
-//Data for PS received
-#define MAX_PS_LEN 8
-#define PS_STR_NUM_IND 0
-#define PS_DATA_OFFSET_IND 5
-
-//RT related
-#define MAX_RT_LEN 64
-#define RT_LEN_IND 0
-#define RT_DATA_OFFSET_IND 5
-#define RT_A_B_FLAG_IND 4
-
-//ERT related
-#define ERT_LEN_IND 0
-#define ERT_DATA_OFFSET_IND 3
-
-//Common to RT, PS
-#define FIRST_CTRL_CHAR 0
-#define LAST_CTRL_CHAR 31
-#define FIRST_NON_PRNT_CHAR 127
-#define SPACE_CHAR 32
-
-//RT PLUS related constanst
-#define RT_OR_ERT_IND 1
-#define RT_PLUS_TAGS_NUM_IND 0
-#define MAX_RT_PLUS_TAGS 2
-#define TAGS_DATA_BEGIN_OFFSET 4
-#define ITEM_TOGGLE_IND 2
-#define ITEM_RUNNING_IND 3
-#define DUMMY_TAG_CODE 0
-
-#define FM_RX_RDS_GRP_RT_EBL 1
-#define FM_RX_RDS_GRP_PS_EBL 2
-#define FM_RX_RDS_GRP_AF_EBL 4
-#define FM_RX_RDS_GRP_PS_SIMPLE_EBL 16
-
-#define FREQ_MULT 1000
-#define HYBRID_SRCH_DATA_LEN 3
-#define HYBRID_SRCH_DATA_INDEX 3
-#define HYBRID_SRCH_MODE 0x40
-#define STARTING_FREQ 76000
-#define FREQ_MULTIPLEX 50
-#define NO_OF_BYTES_EACH_FREQ 2
-#define EXTRACT_FIRST_BYTE 0x03
-#define SRCH_DIV 100
-#define AF_SIZE_IDX 6
-#define NO_OF_BYTES_AF 4
-#define MAX_AF_LIST_SIZE 25
-
-typedef unsigned int UINT;
-typedef unsigned long ULINT;
-
-//STRING LITERALS
-const char *const FM_MODE_PROP = "hw.fm.mode";
-const char *const FM_VERSION_PROP = "hw.fm.version";
-const char *const FM_INIT_PROP = "hw.fm.init";
-const char *const SCRIPT_START_PROP = "ctl.start";
-const char *const FM_SOC_DL_SCRIPT = "fm_dl";
-const char *const SCRIPT_STOP_PROP = "ctl.stOP";
-const char *const CALIB_DATA_NAME = "/data/misc/fm/Riva_fm_cal";
-const char *const SOC_PATCH_DL_SCRPT = "fm_dl";
-const char *const FM_DEVICE_PATH = "/dev/radio0";
-const char *const FM_PERFORMANCE_PARAMS = "/etc/fm/fm_srch_af_th.conf";
-
-const UINT V4L2_CTRL_CLASS_USER = 0x00980000;
-const UINT V4L2_CID_BASE = (V4L2_CTRL_CLASS_USER | 0x900);
-const UINT V4L2_CID_AUDIO_MUTE = (V4L2_CID_BASE + 9);
-const UINT SEARCH_DWELL_TIME = 2;
-const UINT SEEK_DWELL_TIME = 0;
-
-//BAND LIMITS
-const UINT US_BAND_LOW = 87500;
-const UINT US_BAND_HIGH = 108000;
-const UINT EU_BAND_LOW = 87500;
-const UINT EU_BAND_HIGH = 108000;
-const UINT JAP_BAND_STD_LOW = 76000;
-const UINT JAP_BAND_STD_HIGH = 90000;
-const UINT JAP_BAND_WIDE_LOW = 90000;
-const UINT JAP_BAND_WIDE_HIGH = 108000;
-const UINT USR_DEF_BAND_LOW = 87500;
-const UINT USR_DEF_BAND_HIGH = 108000;
-const UINT FM_RX_SRCHLIST_MAX_STATIONS =20;
-
-//RDS standard type
-enum RDS_STD
-{
- RBDS,
- RDS,
- NO_RDS_RBDS,
-};
-
-enum DE_EMPHASIS
-{
- DE_EMP75,
- DE_EMP50,
-};
-
-//Band Type
-enum FM_REGION
-{
- BAND_87500_108000 = 1,
- BAND_76000_108000,
- BAND_76000_90000,
-};
-
-enum FM_AUDIO_PATH
-{
- AUDIO_DIGITAL_PATH,
- AUDIO_ANALOG_PATH,
-};
-
-enum FM_DEVICE
-{
- FM_DEV_NONE,
- FM_RX,
- FM_TX,
-};
-
-enum fm_rds_onoff {
- FM_RDS_ON,
- FM_RDS_OFF,
- FM_MAX
-};
-
-typedef enum {
- FM_LONG_ANA = 0,
- FM_SHORT_ANA
-} fm_antenna_type;
-
-enum BUFF_INDEXES
-{
- STATION_LIST_IND,
- EVENT_IND,
- RT_IND,
- PS_IND,
- AF_LIST_IND = PS_IND + 2,
- RT_PLUS_IND = 11,
- ERT_IND,
-};
-
-typedef enum {
- RDS_EVT_UPDATE = 0x0001,
- RDS_EVT_PI_UPDATE = 0x0002,
- RDS_EVT_PTY_UPDATE = 0x0004,
- RDS_EVT_PS_UPDATE = 0x0008,
- RDS_EVT_RT_UPDATE = 0x0040,
- RDS_EVT_AF_JUMP = 0x0080,
- RDS_EVT_AF_LIST = 0x0100,
- RDS_EVT_AF_LIST_UPDATE = 0x0200,
- RDS_EVT_RDS_AVL = 0x2000,
- RDS_EVT_RDS_NOT_AVL = 0x4000,
-} RdsEvts;
-
-enum SEARCH_MODE
-{
- SEEK_MODE,
- SCAN_MODE,
- SRCHLIST_MODE_STRONG,
- SRCHLIST_MODE_WEAK,
- SRCHRDS_MODE_SEEK_PTY,
- SRCHRDS_MODE_SCAN_PTY,
- SRCHRDS_MODE_SEEK_PI,
- SRCHRDS_MODE_SEEK_AF,
- SRCHLIST_MODE_STRONGEST,
- SRCHLIST_MODE_WEAKEST,
-};
-
-enum SEARCH_DIR
-{
- SEARCH_DOWN,
- SEARCH_UP,
-};
-
-//CHANNEL SPACING for samsung
-enum SS_CHAN_SPACING
-{
- SS_CHAN_SPACE_200 = 20,
- SS_CHAN_SPACE_100 = 10,
- SS_CHAN_SPACE_50 = 5,
-};
-
-enum CHAN_SPACING
-{
- CHAN_SPACE_200,
- CHAN_SPACE_100,
- CHAN_SPACE_50,
-};
-
-enum AUDIO_MODE
-{
- MONO,
- STEREO,
-};
-
-//HARD MUTE MODE
-enum HARD_MUTE_MODE
-{
- UNMUTE_L_R_CHAN,
- MUTE_L_CHAN,
- MUTE_R_CHAN,
- MUTE_L_R_CHAN,
-};
-
-//SOFT MUTE STATES
-enum SOFT_MUTE_MODE
-{
- SMUTE_DISABLED,
- SMUTE_ENABLED,
-};
-
-//FM EVENTS FROM KERNEL
-enum FM_EVENTS
-{
- READY_EVENT,
- TUNE_EVENT,
- SEEK_COMPLETE_EVENT,
- SCAN_NEXT_EVENT,
- RAW_RDS_EVENT,
- RT_EVENT,
- PS_EVENT,
- ERROR_EVENT,
- BELOW_TH_EVENT,
- ABOVE_TH_EVENT,
- STEREO_EVENT,
- MONO_EVENT,
- RDS_AVAL_EVENT,
- RDS_NOT_AVAL_EVENT,
- SRCH_LIST_EVENT,
- AF_LIST_EVENT,
- DISABLED_EVENT = 18,
- RDS_GRP_MASK_REQ_EVENT,
- RT_PLUS_EVENT,
- ERT_EVENT,
- AF_JMP_EVENT,
-};
-
-//FM STATES
-enum fm_states
-{
- FM_OFF,
- FM_OFF_IN_PROGRESS,
- FM_ON_IN_PROGRESS,
- FM_ON,
- FM_TUNE_IN_PROGRESS,
- SEEK_IN_PROGRESS,
- SCAN_IN_PROGRESS,
-};
-
-//V4L2 CONTROLS FOR FM DRIVER
-enum FM_V4L2_PRV_CONTROLS
-{
- V4L2_CID_PRV_BASE = 0x8000000,
- V4L2_CID_PRV_SRCHMODE,
- V4L2_CID_PRV_SCANDWELL,
- V4L2_CID_PRV_SRCHON,
- V4L2_CID_PRV_STATE,
- V4L2_CID_PRV_TRANSMIT_MODE,
- V4L2_CID_PRV_RDSGROUP_MASK,
- V4L2_CID_PRV_REGION,
- V4L2_CID_PRV_SIGNAL_TH,
- V4L2_CID_PRV_SRCH_PTY,
- V4L2_CID_PRV_SRCH_PI,
- V4L2_CID_PRV_SRCH_CNT,
- V4L2_CID_PRV_EMPHASIS,
- V4L2_CID_PRV_RDS_STD,
- V4L2_CID_PRV_CHAN_SPACING,
- V4L2_CID_PRV_RDSON,
- V4L2_CID_PRV_RDSGROUP_PROC,
- V4L2_CID_PRV_LP_MODE,
- V4L2_CID_PRV_ANTENNA,
- V4L2_CID_PRV_INTDET = V4L2_CID_PRV_BASE + 25,
- V4L2_CID_PRV_AF_JUMP = V4L2_CID_PRV_BASE + 27,
- V4L2_CID_PRV_SOFT_MUTE = V4L2_CID_PRV_BASE + 30,
- V4L2_CID_PRV_AUDIO_PATH = V4L2_CID_PRV_BASE + 41,
- V4L2_CID_PRV_SINR = V4L2_CID_PRV_BASE + 44,
- V4L2_CID_PRV_ON_CHANNEL_THRESHOLD = V4L2_CID_PRV_BASE + 0x2D,
- V4L2_CID_PRV_OFF_CHANNEL_THRESHOLD,
- V4L2_CID_PRV_SINR_THRESHOLD,
- V4L2_CID_PRV_SINR_SAMPLES,
- V4L2_CID_PRV_SPUR_FREQ,
- V4L2_CID_PRV_SPUR_FREQ_RMSSI,
- V4L2_CID_PRV_SPUR_SELECTION,
- V4L2_CID_PRV_AF_RMSSI_TH = V4L2_CID_PRV_BASE + 0x36,
- V4L2_CID_PRV_AF_RMSSI_SAMPLES,
- V4L2_CID_PRV_GOOD_CH_RMSSI_TH,
- V4L2_CID_PRV_SRCHALGOTYPE,
- V4L2_CID_PRV_CF0TH12,
- V4L2_CID_PRV_SINRFIRSTSTAGE,
- V4L2_CID_PRV_RMSSIFIRSTSTAGE,
- V4L2_CID_PRV_SOFT_MUTE_TH,
- V4L2_CID_PRV_IRIS_RDSGRP_RT,
- V4L2_CID_PRV_IRIS_RDSGRP_PS_SIMPLE,
- V4L2_CID_PRV_IRIS_BLEND_SINRHI,
- V4L2_CID_PRV_IRIS_BLEND_RMSSIHI,
- V4L2_CID_PRV_IRIS_RDSGRP_AFLIST,
- V4L2_CID_PRV_IRIS_RDSGRP_ERT,
- V4L2_CID_PRV_IRIS_RDSGRP_RT_PLUS,
- V4L2_CID_PRV_IRIS_RDSGRP_3A,
-
- V4L2_CID_PRV_IRIS_READ_DEFAULT = V4L2_CTRL_CLASS_USER + 0x928,
- V4L2_CID_PRV_IRIS_WRITE_DEFAULT,
- V4L2_CID_PRV_SET_CALIBRATION = V4L2_CTRL_CLASS_USER + 0x92A,
-};
-#endif
diff --git a/libfm_jni/FmIoctlsInterface.cpp b/libfm_jni/FmIoctlsInterface.cpp
deleted file mode 100644
index fbe035c..0000000
--- a/libfm_jni/FmIoctlsInterface.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#include "FmIoctlsInterface.h"
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <fcntl.h>
-#include <cutils/properties.h>
-#include <sys/ioctl.h>
-#include <linux/videodev2.h>
-#include <math.h>
-#include <utils/Log.h>
-
-int FmIoctlsInterface :: start_fm_patch_dl
-(
- UINT fd
-)
-{
- int ret;
- int init_success = 0;
- char versionStr[MAX_VER_STR_LEN] = {'\0'};
- char prop_value[PROPERTY_VALUE_MAX] = {'\0'};
- struct v4l2_capability cap;
-
- ALOGE("start_fm_patch_dl = %d\n",fd);
- ret = ioctl(fd, VIDIOC_QUERYCAP, &cap);
- ALOGE("executed cmd\n");
- if(ret == IOCTL_SUCC) {
- ret = snprintf(versionStr, MAX_VER_STR_LEN, "%d", cap.version);
- if(ret >= MAX_VER_STR_LEN) {
- return FM_FAILURE;
- }else {
- ret = property_set(FM_VERSION_PROP, versionStr);
- ALOGE("set versionStr done");
- if(ret != PROP_SET_SUCC)
- return FM_FAILURE;
- ret = property_set(FM_MODE_PROP, "normal");
- ALOGE("set FM_MODE_PROP done");
- if(ret != PROP_SET_SUCC)
- return FM_FAILURE;
- ret = property_set(FM_INIT_PROP, "0");
- ALOGE("set FM_INIT_PROP done");
- if(ret != PROP_SET_SUCC)
- return FM_FAILURE;
- ret = property_set(SCRIPT_START_PROP, SOC_PATCH_DL_SCRPT);
- if(ret != PROP_SET_SUCC)
- return FM_FAILURE;
- for(int i = 0; i < INIT_LOOP_CNT; i++) {
- property_get(FM_INIT_PROP, prop_value, NULL);
- if (strcmp(prop_value, "1") == 0) {
- init_success = 1;
- break;
- }else {
- usleep(INIT_WAIT_TIMEOUT);
- }
- }
- if(!init_success) {
- property_set(SCRIPT_STOP_PROP, SOC_PATCH_DL_SCRPT);
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
- }
- }else {
- return FM_FAILURE;
- }
-}
-
-int FmIoctlsInterface :: close_fm_patch_dl
-(
- void
-)
-{
- int ret;
-
- ret = property_set(SCRIPT_STOP_PROP, SOC_PATCH_DL_SCRPT);
- if(ret != PROP_SET_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: get_cur_freq
-(
- UINT fd, long &freq
-)
-{
- int ret;
- struct v4l2_frequency channel;
-
- channel.type = V4L2_TUNER_RADIO;
- ret = ioctl(fd, VIDIOC_G_FREQUENCY, &channel);
-
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- freq = (channel.frequency / TUNE_MULT);
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: set_freq
-(
- UINT fd, ULINT freq
-)
-{
- int ret;
- struct v4l2_frequency channel;
-
- channel.type = V4L2_TUNER_RADIO;
- channel.frequency = (freq * TUNE_MULT);
-
- ret = ioctl(fd, VIDIOC_S_FREQUENCY, &channel);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: set_control
-(
- UINT fd, UINT id, int val
-)
-{
- int ret;
- struct v4l2_control control;
-
- control.value = val;
- control.id = id;
-
- ret = ioctl(fd, VIDIOC_S_CTRL, &control);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: set_calibration
-(
- UINT fd
-)
-{
- int ret;
- FILE *cal_fp;
- struct v4l2_ext_control ext_ctl;
- struct v4l2_ext_controls v4l2_ctls;
- char cal_data[CAL_DATA_SIZE] = {0};
-
- cal_fp = fopen(CALIB_DATA_NAME, "r");
- if(cal_fp != NULL) {
- if(fread(&cal_data[0], 1, CAL_DATA_SIZE, cal_fp)
- < CAL_DATA_SIZE) {
- fclose(cal_fp);
- return FM_FAILURE;
- }
- fclose(cal_fp);
- ext_ctl.string = cal_data;
- ext_ctl.size = CAL_DATA_SIZE;
- v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_USER;
- v4l2_ctls.count = 1;
- v4l2_ctls.controls = &ext_ctl;
- ret = ioctl(fd, VIDIOC_S_EXT_CTRLS, &v4l2_ctls);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
- }else {
- return FM_FAILURE;
- }
-}
-
-int FmIoctlsInterface :: get_control
-(
- UINT fd, UINT id, long &val
-)
-{
- int ret;
- struct v4l2_control control;
-
- control.id = id;
- ret = ioctl(fd, VIDIOC_G_CTRL, &control);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- val = control.value;
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: start_search
-(
- UINT fd, UINT dir
-)
-{
- int ret;
- struct v4l2_hw_freq_seek hw_seek;
-
- hw_seek.seek_upward = dir;
- hw_seek.type = V4L2_TUNER_RADIO;
-
- ret = ioctl(fd, VIDIOC_S_HW_FREQ_SEEK, &hw_seek);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: set_band
-(
- UINT fd, ULINT low, ULINT high
-)
-{
- int ret;
- struct v4l2_tuner tuner;
-
- tuner.index = 0;
- tuner.signal = 0;
- tuner.rangelow = (low * TUNE_MULT);
- tuner.rangehigh = (high * TUNE_MULT);
-
- ret = ioctl(fd, VIDIOC_S_TUNER, &tuner);
- ret = set_control(fd, V4L2_CID_PRV_REGION, 0);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: get_rmssi
-(
- UINT fd, long &rmssi
-)
-{
- struct v4l2_tuner tuner;
- int ret;
-
- tuner.index = 0;
- tuner.signal = 0;
- ret = ioctl(fd, VIDIOC_G_TUNER, &tuner);
- if(ret < IOCTL_SUCC) {
- ret = FM_FAILURE;
- }else {
- rmssi = tuner.signal;
- ret = FM_SUCCESS;
- }
- return ret;
-}
-
-int FmIoctlsInterface :: get_upperband_limit
-(
- UINT fd, ULINT &freq
-)
-{
- int ret;
- struct v4l2_tuner tuner;
-
- tuner.index = 0;
- ret = ioctl(fd, VIDIOC_G_TUNER, &tuner);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- freq = (tuner.rangehigh / TUNE_MULT);
- ALOGE("high freq: %d\n",freq);
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: get_lowerband_limit
-(
- UINT fd, ULINT &freq
-)
-{
- int ret;
- struct v4l2_tuner tuner;
-
- tuner.index = 0;
- ret = ioctl(fd, VIDIOC_G_TUNER, &tuner);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- freq = (tuner.rangelow / TUNE_MULT);
- ALOGE("low freq: %d\n",freq);
- return FM_SUCCESS;
- }
-}
-
-int FmIoctlsInterface :: set_audio_mode
-(
- UINT fd, enum AUDIO_MODE mode
-)
-{
- int ret;
- struct v4l2_tuner tuner;
-
- tuner.index = 0;
- ret = ioctl(fd, VIDIOC_G_TUNER, &tuner);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- tuner.audmode = mode;
- ret = ioctl(fd, VIDIOC_S_TUNER, &tuner);
- if(ret != IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
- }
-}
-
-int FmIoctlsInterface :: get_buffer
-(
- UINT fd, char *buff, UINT len, UINT index
-)
-{
- int ret;
- struct v4l2_buffer v4l2_buf;
-
- if((len < STD_BUF_SIZE) || (buff == NULL)) {
- return FM_FAILURE;
- }else {
- memset(&v4l2_buf, 0, sizeof(v4l2_buf));
- v4l2_buf.index = index;
- v4l2_buf.type = V4L2_BUF_TYPE_PRIVATE;
- v4l2_buf.length = STD_BUF_SIZE;
- v4l2_buf.m.userptr = (ULINT)buff;
- ret = ioctl(fd, VIDIOC_DQBUF, &v4l2_buf);
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return v4l2_buf.bytesused;
- }
- }
-}
-
-int FmIoctlsInterface :: set_ext_control
-(
- UINT fd,
- struct v4l2_ext_controls *v4l2_ctls
-)
-{
- int ret;
-
- ret = ioctl(fd, VIDIOC_S_EXT_CTRLS, v4l2_ctls);
-
- if(ret < IOCTL_SUCC) {
- return FM_FAILURE;
- }else {
- return FM_SUCCESS;
- }
-}
-
diff --git a/libfm_jni/FmIoctlsInterface.h b/libfm_jni/FmIoctlsInterface.h
deleted file mode 100644
index e2ae601..0000000
--- a/libfm_jni/FmIoctlsInterface.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#ifndef __FM_IOCTL_INTERFACE_H__
-#define __FM_IOCTL_INTERFACE_H__
-
-#include "FM_Const.h"
-
-#include <linux/videodev2.h>
-
-class FmIoctlsInterface
-{
- public:
- static int start_fm_patch_dl(UINT fd);
- static int close_fm_patch_dl(void);
- static int get_cur_freq(UINT fd, long &freq);
- static int set_freq(UINT fd, ULINT freq);
- static int set_control(UINT fd, UINT id, int val);
- static int set_calibration(UINT fd);
- static int get_control(UINT fd, UINT id, long &val);
- static int start_search(UINT fd, UINT dir);
- static int set_band(UINT fd, ULINT low, ULINT high);
- static int get_upperband_limit(UINT fd, ULINT &freq);
- static int get_lowerband_limit(UINT fd, ULINT &freq);
- static int set_audio_mode(UINT fd, enum AUDIO_MODE mode);
- static int get_buffer(UINT fd, char *buff, UINT len, UINT index);
- static int get_rmssi(UINT fd, long &rmssi);
- static int set_ext_control(UINT fd, struct v4l2_ext_controls *v4l2_ctls);
-};
-
-#endif //__FM_IOCTL_INTERFACE_H__
diff --git a/libfm_jni/FmPerformanceParams.cpp b/libfm_jni/FmPerformanceParams.cpp
deleted file mode 100644
index dc22432..0000000
--- a/libfm_jni/FmPerformanceParams.cpp
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#include <cstdio>
-#include <utils/Log.h>
-#include "FmPerformanceParams.h"
-#include "FmIoctlsInterface.h"
-#include <linux/videodev2.h>
-
-signed char FmPerformanceParams :: SetBand
-(
- UINT fd, unsigned char band
-)
-{
- signed char ret = FM_FAILURE;
-
- switch(band) {
- case BAND_87500_108000:
- ret = FmIoctlsInterface::set_band(fd,
- 87500, 108000);
- break;
- case BAND_76000_108000:
- ret = FmIoctlsInterface::set_band(fd,
- 76000, 108000);
- break;
- case BAND_76000_90000:
- ret = FmIoctlsInterface::set_band(fd,
- 76000, 90000);
- break;
- default:
- ALOGE("Band type: %ld is invalid\n", band);
- ret = FM_FAILURE;
- break;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: SetEmphsis
-(
- UINT fd, unsigned char emph
-)
-{
- signed char ret = FM_FAILURE;
-
- switch(emph) {
- case DE_EMP75:
- case DE_EMP50:
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_EMPHASIS, emph);
- break;
- default:
- ALOGE("invalid de-emphasis value\n");
- ret = FM_FAILURE;
- break;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: SetChannelSpacing
-(
- UINT fd, unsigned char spacing
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_CHAN_SPACING, spacing);
- return ret;
-}
-
-signed char FmPerformanceParams :: SetAfRmssiTh
-(
- UINT fd, unsigned short th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_AF_RMSSI_TH, th);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetAfRmssiSamplesCnt
-(
- UINT fd, unsigned char cnt
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_AF_RMSSI_SAMPLES, cnt);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetGoodChannelRmssiTh
-(
- UINT fd, signed char th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_GOOD_CH_RMSSI_TH, th);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetSrchAlgoType
-(
- UINT fd, unsigned char algo
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_SRCHALGOTYPE, algo);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetSinrFirstStage
-(
- UINT fd, signed char th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_SINRFIRSTSTAGE, th);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetRmssiFirstStage
-(
- UINT fd, signed char th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_RMSSIFIRSTSTAGE, th);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetCf0Th12
-(
- UINT fd, int th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_CF0TH12, th);
- return ret;
-}
-
-signed char FmPerformanceParams :: SetSinrSamplesCnt
-(
- UINT fd, unsigned char cnt
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_SINR_SAMPLES, cnt);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetIntfLowTh
-(
- UINT fd, unsigned char th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_ON_CHANNEL_THRESHOLD, th);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetIntfHighTh
-(
- UINT fd, unsigned char th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_OFF_CHANNEL_THRESHOLD, th);
- return ret;
-}
-
-signed char FmPerformanceParams :: SetSinrFinalStage
-(
- UINT fd, signed char th
-)
-{
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_SINR_THRESHOLD, th);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: GetAfRmssiTh
-(
- UINT fd, unsigned short &th
-)
-{
- long int af_rmssi_th;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_AF_RMSSI_TH, af_rmssi_th);
- if(ret == FM_SUCCESS) {
- th = af_rmssi_th;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetAfRmssiSamplesCnt
-(
- UINT fd, unsigned char &cnt
-)
-{
- long int af_samples_cnt;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_AF_RMSSI_SAMPLES, af_samples_cnt);
- if(ret == FM_SUCCESS) {
- cnt = af_samples_cnt;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetGoodChannelRmssiTh
-(
- UINT fd, signed char &th
-)
-{
- long int gd_chan_rmssi_th;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_GOOD_CH_RMSSI_TH, gd_chan_rmssi_th);
- if(ret == FM_SUCCESS) {
- th = gd_chan_rmssi_th;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetSrchAlgoType
-(
- UINT fd, unsigned char &algo
-)
-{
- long int srch_algo_type;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_SRCHALGOTYPE, srch_algo_type);
- if(ret == FM_SUCCESS) {
- algo = srch_algo_type;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetSinrFirstStage
-(
- UINT fd, signed char &th
-)
-{
- long int sinr_first_stage;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_SINRFIRSTSTAGE, sinr_first_stage);
- if(ret == FM_SUCCESS) {
- th = sinr_first_stage;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetRmssiFirstStage
-(
- UINT fd, signed char &th
-)
-{
- long int rmssi_first_stage;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_RMSSIFIRSTSTAGE, rmssi_first_stage);
- if(ret == FM_SUCCESS) {
- th = rmssi_first_stage;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetCf0Th12
-(
- UINT fd, int &th
-)
-{
- long int cf0th12;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_CF0TH12, cf0th12);
- if(ret == FM_SUCCESS) {
- th = cf0th12;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetSinrSamplesCnt
-(
- UINT fd, unsigned char &cnt
-)
-{
- long int sinr_samples_cnt;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_SINR_SAMPLES, sinr_samples_cnt);
- if(ret == FM_SUCCESS) {
- cnt = sinr_samples_cnt;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetIntfLowTh
-(
- UINT fd, unsigned char &th
-)
-{
- long int intf_low_th;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_ON_CHANNEL_THRESHOLD, intf_low_th);
- if(ret == FM_SUCCESS) {
- th = intf_low_th;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetIntfHighTh
-(
- UINT fd, unsigned char &th
-)
-{
- long int intf_high_th;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_OFF_CHANNEL_THRESHOLD, intf_high_th);
- if(ret == FM_SUCCESS) {
- th = intf_high_th;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: GetIntfDet
-(
- UINT fd, unsigned char &th
-)
-{
- long int int_det;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_INTDET, int_det);
- if(ret == FM_SUCCESS) {
- th = int_det;
- }
- return ret;
-}
-signed char FmPerformanceParams :: GetSinrFinalStage
-(
- UINT fd, signed char &th
-)
-{
- signed char ret = FM_FAILURE;
- long int sinr;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_SINR_THRESHOLD, sinr);
-
- if(ret == FM_SUCCESS) {
- th = sinr;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: SetHybridSrchList
-(
- UINT fd,
- unsigned int *freqs,
- signed char *sinrs,
- unsigned int n
-)
-{
- struct v4l2_ext_control ext_ctl;
- struct v4l2_ext_controls v4l2_ctls;
- unsigned int freq;
- signed char sinr;
- unsigned int size = 0;
- char *data = NULL;
- signed char ret = FM_FAILURE;
-
- if(n <= 0) {
- return ret;
- }
- data = new char[(n * HYBRID_SRCH_DATA_LEN + HYBRID_SRCH_DATA_INDEX)];
-
- if(data != NULL) {
- data[size++] = HYBRID_SRCH_MODE;
- data[size++] = ((n * HYBRID_SRCH_DATA_LEN) + 1);
- data[size++] = n;
- while((size < (n * HYBRID_SRCH_DATA_LEN + 2)) && (freqs != NULL)
- && (sinrs != NULL)) {
- freq = (*freqs - STARTING_FREQ) / FREQ_MULTIPLEX;
- data[size++] = (freq & 0xff);
- data[size++] = ((freq >> 8) & 0xff);
- data[size++] = *sinrs;
- freqs++;
- sinrs++;
- }
- if(size == (n * HYBRID_SRCH_DATA_LEN + HYBRID_SRCH_DATA_INDEX)) {
- ext_ctl.id = V4L2_CID_PRV_IRIS_WRITE_DEFAULT;
- ext_ctl.string = data;
- ext_ctl.size = size;
- v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_USER;
- v4l2_ctls.count = 1;
- v4l2_ctls.controls = &ext_ctl;
- ret = FmIoctlsInterface::set_ext_control(fd, &v4l2_ctls);
- if(ret == FM_SUCCESS) {
- ALOGE("hybrid srch list sent successfully\n");
- }else {
- ALOGE("hybrid srch list setting failed\n");
- }
- }
- }
-
- delete []data;
-
- return ret;
-}
-
-signed char FmPerformanceParams :: SetBlendSinr
-(
- UINT fd, signed char bsinr
-)
-{
- signed char ret = FM_FAILURE;
-
- if ((bsinr >= MIN_BLEND_SINRHI) &&
- (bsinr <= MAX_BLEND_SINRHI))
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_IRIS_BLEND_SINRHI, bsinr);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: GetBlendSinr
-(
- UINT fd, signed char &bsinr
-)
-{
- long int blend_sinr_hi;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_IRIS_BLEND_SINRHI, blend_sinr_hi);
- if(ret == FM_SUCCESS) {
- bsinr = blend_sinr_hi;
- }
- return ret;
-}
-
-signed char FmPerformanceParams :: SetBlendRmssi
-(
- UINT fd, signed char brmssi
-)
-{
- signed char ret = FM_FAILURE;
-
- if ((brmssi >= MIN_BLEND_RMSSIHI) &&
- (brmssi <= MAX_BLEND_RMSSIHI))
- ret = FmIoctlsInterface::set_control(fd,
- V4L2_CID_PRV_IRIS_BLEND_RMSSIHI, brmssi);
-
- return ret;
-}
-
-signed char FmPerformanceParams :: GetBlendRmssi
-(
- UINT fd, signed char &brmssi
-)
-{
- long int blend_rmssi_hi;
- signed char ret = FM_FAILURE;
-
- ret = FmIoctlsInterface::get_control(fd,
- V4L2_CID_PRV_IRIS_BLEND_RMSSIHI, blend_rmssi_hi);
- if(ret == FM_SUCCESS) {
- brmssi = blend_rmssi_hi;
- }
- return ret;
-}
diff --git a/libfm_jni/FmPerformanceParams.h b/libfm_jni/FmPerformanceParams.h
deleted file mode 100644
index 88e53cc..0000000
--- a/libfm_jni/FmPerformanceParams.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#ifndef __FM_PERFORMANCE_PARAMS_H__
-#define __FM_PERFORMANCE_PARAMS_H__
-
-#include "FM_Const.h"
-
-#define MIN_BLEND_SINRHI -128
-#define MAX_BLEND_SINRHI 127
-#define MIN_BLEND_RMSSIHI -128
-#define MAX_BLEND_RMSSIHI 127
-
-class FmPerformanceParams
-{
- private:
- public:
- signed char SetBand(UINT fd, unsigned char band);
- signed char SetEmphsis(UINT fd, unsigned char emph);
- signed char SetChannelSpacing(UINT fd, unsigned char spacing);
- signed char SetAfRmssiTh(UINT fd, unsigned short th);
- signed char SetAfRmssiSamplesCnt(UINT fd, unsigned char cnt);
- signed char SetGoodChannelRmssiTh(UINT fd, signed char th);
- signed char SetSrchAlgoType(UINT fd, unsigned char algo);
- signed char SetSinrFirstStage(UINT fd, signed char th);
- signed char SetRmssiFirstStage(UINT fd, signed char th);
- signed char SetCf0Th12(UINT fd, int th);
- signed char SetSinrSamplesCnt(UINT fd, unsigned char cnt);
- signed char SetIntfLowTh(UINT fd, unsigned char th);
- signed char SetIntfHighTh(UINT fd, unsigned char th);
- signed char SetSinrFinalStage(UINT fd, signed char th);
- signed char SetHybridSrchList(UINT fd, unsigned int *freqs, signed char *sinrs, unsigned int n);
- signed char SetBlendSinr(UINT fd, signed char bsinr);
- signed char SetBlendRmssi(UINT fd, signed char brmssi);
-
- signed char GetAfRmssiTh(UINT fd, unsigned short &th);
- signed char GetAfRmssiSamplesCnt(UINT fd, unsigned char &cnt);
- signed char GetGoodChannelRmssiTh(UINT fd, signed char &th);
- signed char GetSrchAlgoType(UINT fd, unsigned char &algo);
- signed char GetSinrFirstStage(UINT fd, signed char &th);
- signed char GetRmssiFirstStage(UINT fd, signed char &th);
- signed char GetCf0Th12(UINT fd, int &th);
- signed char GetSinrSamplesCnt(UINT fd, unsigned char &cnt);
- signed char GetIntfLowTh(UINT fd, unsigned char &th);
- signed char GetIntfHighTh(UINT fd, unsigned char &th);
- signed char GetIntfDet(UINT fd, unsigned char &th);
- signed char GetSinrFinalStage(UINT fd, signed char &th);
- signed char GetBlendSinr(UINT fd, signed char &bsinr);
- signed char GetBlendRmssi(UINT fd, signed char &brmssi);
-};
-
-#endif //__FM_PERFORMANCE_PARAMS_H__
diff --git a/libfm_jni/FmRadioController.cpp b/libfm_jni/FmRadioController.cpp
deleted file mode 100644
index 613a062..0000000
--- a/libfm_jni/FmRadioController.cpp
+++ /dev/null
@@ -1,1444 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <fcntl.h>
-#include <utils/Log.h>
-#include <cutils/properties.h>
-#include <sys/ioctl.h>
-#include <math.h>
-#include "FmRadioController.h"
-#include "FmIoctlsInterface.h"
-#include "ConfigFmThs.h"
-#include <linux/videodev2.h>
-
-//Reset all variables to default value
-static FmIoctlsInterface * FmIoct;
-FmRadioController :: FmRadioController
-(
-)
-{
- cur_fm_state = FM_OFF;
- prev_freq = -1;
- seek_scan_canceled = false;
- af_enabled = 0;
- rds_enabled = 0;
- event_listener_canceled = false;
- is_rds_support = false;
- is_ps_event_received = false;
- is_rt_event_received = false;
- is_af_jump_received = false;
- mutex_fm_state = PTHREAD_MUTEX_INITIALIZER;
- mutex_seek_compl_cond = PTHREAD_MUTEX_INITIALIZER;
- mutex_scan_compl_cond = PTHREAD_MUTEX_INITIALIZER;
- mutex_tune_compl_cond = PTHREAD_MUTEX_INITIALIZER;
- mutex_turn_on_cond = PTHREAD_MUTEX_INITIALIZER;
- turn_on_cond = PTHREAD_COND_INITIALIZER;
- seek_compl_cond = PTHREAD_COND_INITIALIZER;
- scan_compl_cond = PTHREAD_COND_INITIALIZER;
- tune_compl_cond = PTHREAD_COND_INITIALIZER;
- event_listener_thread = 0;
- fd_driver = -1;
- FmIoct = new FmIoctlsInterface();
-}
-
-/* Turn off FM */
-FmRadioController :: ~FmRadioController
-(
-)
-{
- if((cur_fm_state != FM_OFF)) {
- Stop_Scan_Seek();
- set_fm_state(FM_OFF_IN_PROGRESS);
- FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_STATE, FM_DEV_NONE);
- }
- if(event_listener_thread != 0) {
- event_listener_canceled = true;
- pthread_join(event_listener_thread, NULL);
- }
-}
-
-int FmRadioController ::open_dev()
-{
- int ret = FM_SUCCESS;
-
- fd_driver = open(FM_DEVICE_PATH, O_RDONLY, O_NONBLOCK);
-
- if (fd_driver < 0) {
- ALOGE("%s failed, [fd=%d] %s\n", __func__, fd_driver, FM_DEVICE_PATH);
- return FM_FAILURE;
- }
-
- ALOGD("%s, [fd=%d] \n", __func__, fd_driver);
- return ret;
-}
-
-int FmRadioController ::close_dev()
-{
- int ret = 0;
-
- if (fd_driver > 0) {
- close(fd_driver);
- fd_driver = -1;
- }
- ALOGD("%s, [fd=%d] [ret=%d]\n", __func__, fd_driver, ret);
- return ret;
-}
-
-struct timespec FmRadioController :: set_time_out
-(
- int secs
-)
-{
- struct timespec ts;
- struct timeval tp;
-
- gettimeofday(&tp, NULL);
- ts.tv_sec = tp.tv_sec;
- ts.tv_nsec = tp.tv_usec * 1000;
- ts.tv_sec += secs;
-
- return ts;
-}
-
-//Get current tuned frequency
-//Return -1 if failed to get freq
-long FmRadioController :: GetChannel
-(
- void
-)
-{
- long freq = -1;
- int ret;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::get_cur_freq(fd_driver, freq);
- if(ret == FM_SUCCESS) {
- ALOGI("FM get freq is successfull, freq is: %ld\n", freq);
- }else {
- ALOGE("FM get frequency failed, freq is: %ld\n", freq);
- }
- }else {
- ALOGE("FM get freq is not valid in current state\n");
- }
- return freq;
-}
-
-int FmRadioController ::Pwr_Up(int freq)
-{
- int ret = FM_SUCCESS;
- struct timespec ts;
- ConfigFmThs thsObj;
- char value[PROPERTY_VALUE_MAX] = {'\0'};
-
- ALOGI("%s,[freq=%d]\n", __func__, freq);
- property_get("qcom.bluetooth.soc", value, NULL);
- ALOGD("BT soc is %s\n", value);
- if (fd_driver < 0) {
- ret = open_dev();
- if (ret != FM_SUCCESS) {
- ALOGE("Dev open failed\n");
- return FM_FAILURE;
- }
- }
-
- if (cur_fm_state == FM_OFF) {
- ALOGE("cur_fm_state = %d\n",cur_fm_state);
- if (strcmp(value, "rome") != 0) {
- ret = FmIoctlsInterface::start_fm_patch_dl(fd_driver);
- if (ret != FM_SUCCESS) {
- ALOGE("FM patch downloader failed: %d\n", ret);
- close_dev();
- set_fm_state(FM_OFF);
- return FM_FAILURE;
- }
- }
- if (event_listener_thread == 0) {
- ret = pthread_create(&event_listener_thread, NULL,
- handle_events, this);
- if (ret == 0) {
- ALOGI("Lock the mutex for FM turn on cond\n");
- pthread_mutex_lock(&mutex_turn_on_cond);
- ts = set_time_out(READY_EVENT_TIMEOUT);
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_STATE, FM_RX);
- if (ret == FM_SUCCESS) {
- ALOGI("Waiting for timedout or FM on\n");
- pthread_cond_timedwait(&turn_on_cond,
- &mutex_turn_on_cond, &ts);
- ALOGI("Unlocked mutex & timedout or condition satisfied\n");
- pthread_mutex_unlock(&mutex_turn_on_cond);
- if (cur_fm_state == FM_ON) {//after READY event
- ret = SetBand(BAND_87500_108000);
- if (ret != FM_SUCCESS) {
- ALOGE("set band failed\n");
- ret = FM_FAILURE;
- goto exit;
- }
- ret = SetChannelSpacing(CHAN_SPACE_100);
- if (ret != FM_SUCCESS) {
- ALOGE("set channel spacing failed\n");
- ret = FM_FAILURE;
- goto exit;
- }
- ret = SetDeConstant(DE_EMP50);
- if (ret != FM_SUCCESS) {
- ALOGE("set Emphasis failed\n");
- ret = FM_FAILURE;
- goto exit;
- }
- thsObj.SetRxSearchAfThs(FM_PERFORMANCE_PARAMS, fd_driver);
- SetStereo();
- ret = TuneChannel(freq);
- if (ret != FM_SUCCESS) {
- ALOGI("FM set freq command failed\n");
- ret = FM_FAILURE;
- goto exit;
- }
- return FM_SUCCESS;
- } else { //if time out
- ret = FM_FAILURE;
- goto exit;
- }
- } else {
- ALOGE("Set FM on control failed\n");
- pthread_mutex_unlock(&mutex_turn_on_cond);
- ALOGI("Unlocked the FM on cond mutex\n");
- ret = FM_FAILURE;
- goto close_fd;
- }
- } else {
- ALOGE("FM event listener thread failed: %d\n", ret);
- set_fm_state(FM_OFF);
- return FM_FAILURE;
- }
- } else {
- ALOGE("FM event listener threadi existed\n");
- return FM_SUCCESS;
- }
- } else if(cur_fm_state != FM_ON_IN_PROGRESS) {
- return FM_SUCCESS;
- } else {
- return FM_FAILURE;
- }
-
-exit:
- FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_STATE, FM_DEV_NONE);
-close_fd:
- event_listener_canceled = true;
- pthread_join(event_listener_thread, NULL);
- close(fd_driver);
- fd_driver = -1;
- set_fm_state(FM_OFF);
-
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret;
-}
-
-int FmRadioController ::Pwr_Down()
-{
- int ret = 0;
-
- if((cur_fm_state != FM_OFF)) {
- Stop_Scan_Seek();
- set_fm_state(FM_OFF_IN_PROGRESS);
- FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_STATE, FM_DEV_NONE);
- }
- if(event_listener_thread != 0) {
- ALOGD("%s, event_listener_thread canceeled\n", __func__);
- event_listener_canceled = true;
- pthread_join(event_listener_thread, NULL);
- }
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret;
-}
-//Tune to a Freq
-//Return FM_SUCCESS on success FM_FAILURE
-//on failure
-int FmRadioController :: TuneChannel
-(
- long freq
-)
-{
- int ret = FM_SUCCESS;
- struct timespec ts;
-
- if((cur_fm_state == FM_ON) &&
- (freq > 0)) {
- set_fm_state(FM_TUNE_IN_PROGRESS);
- ret = FmIoctlsInterface::set_freq(fd_driver,
- freq);
- if(ret == FM_SUCCESS) {
- ALOGI("FM set frequency command set successfully\n");
- pthread_mutex_lock(&mutex_tune_compl_cond);
- ts = set_time_out(TUNE_EVENT_TIMEOUT);
- ret = pthread_cond_timedwait(&tune_compl_cond, &mutex_tune_compl_cond, &ts);
- pthread_mutex_unlock(&mutex_tune_compl_cond);
- }else {
- if((cur_fm_state != FM_OFF)) {
- set_fm_state(FM_ON);
- }
- ALOGE("FM set freq command failed\n");
- }
- }else {
- ALOGE("Fm is not in proper state for tuning to a freq\n");
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: Seek(int dir)
-{
- int ret = 0;
- int freq = -1;
- struct timespec ts;
-
- if (cur_fm_state != FM_ON) {
- ALOGE("%s error Fm state: %d\n", __func__,cur_fm_state);
- return FM_FAILURE;
- }
-
- ALOGI("FM seek started\n");
- set_fm_state(SEEK_IN_PROGRESS);
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_SRCHMODE, SEEK_MODE);
- if (ret != FM_SUCCESS) {
- set_fm_state(FM_ON);
- return FM_FAILURE;
- }
-
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_SCANDWELL, SEEK_DWELL_TIME);
- if (ret != FM_SUCCESS) {
- set_fm_state(FM_ON);
- return FM_FAILURE;
- }
-
- if (dir == 1) {
- ret = FmIoctlsInterface::start_search(fd_driver,
- SEARCH_UP);
- } else {
- ret = FmIoctlsInterface::start_search(fd_driver,
- SEARCH_DOWN);
- }
-
- if (ret != FM_SUCCESS) {
- set_fm_state(FM_ON);
- return FM_FAILURE;
- }
- pthread_mutex_lock(&mutex_seek_compl_cond);
- ts = set_time_out(SEEK_COMPL_TIMEOUT);
- ret = pthread_cond_timedwait(&seek_compl_cond, &mutex_seek_compl_cond, &ts);
- pthread_mutex_unlock(&mutex_seek_compl_cond);
- if ((cur_fm_state != SEEK_IN_PROGRESS) && !seek_scan_canceled) {
- ALOGI("Seek completed without timeout\n");
- freq = GetChannel();
- }
- seek_scan_canceled = false;
- return freq;
-}
-
-bool FmRadioController ::IsRds_support
-(
- void
-)
-{
- is_rds_support = true;
- ALOGI("is_rds_support: \n", is_rds_support);
- return is_rds_support;
-}
-
-//HardMute both audio channels
-int FmRadioController ::MuteOn()
-{
- int ret;
-
- ALOGE("cur_fm_state = %d\n", cur_fm_state);
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_AUDIO_MUTE, MUTE_L_R_CHAN);
- ALOGE("CMD executed mute\n");
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-//Unmute both audio channel
-int FmRadioController ::MuteOff()
-{
- int ret;
-
- ALOGE("cur_fm_state = %d\n", cur_fm_state);
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_AUDIO_MUTE, UNMUTE_L_R_CHAN);
- ALOGE("CMD executed for unmute\n");
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-//
-int FmRadioController ::SetSoftMute(bool mode)
-{
- int ret;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_SOFT_MUTE, mode);
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: Set_mute(bool mute)
-{
- int ret = 0;
-
- if (mute) {
- ret = MuteOn();
- } else {
- ret = MuteOff();
- }
-
- if (ret)
- ALOGE("%s failed, %d\n", __func__, ret);
- ALOGD("%s, [mute=%d] [ret=%d]\n", __func__, mute, ret);
- return ret;
-}
-
-int FmRadioController :: Stop_Scan_Seek
-(
-)
-{
- int ret;
-
- if((cur_fm_state == SEEK_IN_PROGRESS) ||
- (cur_fm_state == SCAN_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_SRCHON, 0);
- if (ret == FM_SUCCESS) {
- ALOGI("FM Seek cancel command set successfully\n");
- seek_scan_canceled = true;
- } else {
- ALOGE("FM Seek cancel command sent failed\n");
- }
- } else {
- ALOGE("FM is not in proper state for cancelling Seek operation\n");
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: ReadRDS() //todo define each RDS flag
-{
- int ret = 0;
-
- if (is_ps_event_received)
- ret |= RDS_EVT_PS_UPDATE;
- if (is_rt_event_received)
- ret |= RDS_EVT_RT_UPDATE;
- if (is_af_jump_received)
- ret |= RDS_EVT_AF_JUMP;
-
- return ret;
-}
-
-int FmRadioController :: Get_ps(char *ps, int *ps_len)
-{
- int ret = 0;
- int len = 0;
- char raw_rds[STD_BUF_SIZE];
-
- ret = FmIoctlsInterface::get_buffer(fd_driver,
- raw_rds, STD_BUF_SIZE, PS_IND);
- if (ret <= 0) {
- return FM_FAILURE;
- } else {
- if (raw_rds[PS_STR_NUM_IND] > 0) {
- if (ps != NULL) {
- for(int i = 0; i < MAX_PS_LEN; i++) {
- ps[i] = raw_rds[PS_DATA_OFFSET_IND + i];
- if (ps[i] == 0) {
- break;
- } else if((ps[len] <= LAST_CTRL_CHAR) ||
- (ps[len] >= FIRST_NON_PRNT_CHAR)) {
- ps[i] = SPACE_CHAR;
- continue;
- }
- len++;
- }
- if (len < (MAX_PS_LEN - 1)) {
- ps[len] = '\0';
- *ps_len = len + 1;
- } else {
- *ps_len = len;
- }
- ALOGI("PS is: %s\n", ps);
- } else {
- return FM_FAILURE;
- }
- }
- }
- is_ps_event_received = false;
- ALOGD("%s, [ps_len=%d]\n", __func__, *ps_len);
- return FM_SUCCESS;
-}
-
-int FmRadioController :: Get_rt(char *rt, int *rt_len)
-{
- int ret = 0;
- int len = 0;
- char raw_rds[STD_BUF_SIZE];
-
- ret = FmIoctlsInterface::get_buffer(fd_driver,
- raw_rds, STD_BUF_SIZE, RT_IND);
- if (ret <= 0) {
- return FM_FAILURE;
- } else {
- if (rt != NULL) {
- if ((raw_rds[RT_LEN_IND] > 0) &&
- (raw_rds[RT_LEN_IND] <= MAX_RT_LEN)) {
- for(len = 0; len < raw_rds[RT_LEN_IND]; len++) {
- rt[len] = raw_rds[RT_DATA_OFFSET_IND + len];
- ALOGI("Rt byte[%d]: %d\n", len, rt[len]);
- if ((rt[len] <= LAST_CTRL_CHAR) ||
- (rt[len] >= FIRST_NON_PRNT_CHAR)) {
- rt[len] = SPACE_CHAR;
- continue;
- }
- }
- if (len < (MAX_RT_LEN - 1)) {
- rt[len] = '\0';
- *rt_len = len + 1;
- } else {
- *rt_len = len;
- }
- ALOGI("Rt is: %s\n", rt);
- ALOGI("RT text A / B: %d\n", raw_rds[RT_A_B_FLAG_IND]);
- } else {
- return FM_FAILURE;
- }
- } else {
- return FM_FAILURE;
- }
- }
- is_rt_event_received = false;
- ALOGD("%s, [rt_len=%d]\n", __func__, *rt_len);
- return FM_SUCCESS;
-}
-
-int FmRadioController :: Get_AF_freq(uint16_t *ret_freq)
-{
- int ret =0;
- ULINT lowBand, highBand;
- float real_freq = 0;
-
- ALOGI("get_AF_freq\n");
- ret = FmIoctlsInterface::get_lowerband_limit(fd_driver,
- lowBand);
- if (ret != FM_SUCCESS) {
- ALOGE("failed to get lowerband: %d\n", ret);
- return FM_FAILURE;
- }
- ALOGI("lowBand = %ld\n",lowBand);
- ret = FmIoctlsInterface::get_upperband_limit(fd_driver,
- highBand);
- if (ret != FM_SUCCESS) {
- ALOGE("failed to getgherband: %d\n", ret);
- return FM_FAILURE;
- }
- ALOGI("highBand = %ld\n",highBand);
- real_freq = GetChannel();
- if ((real_freq < lowBand ) || (real_freq > highBand)) {
- ALOGE("AF freq is not in band limits\ni");
- return FM_FAILURE;
- } else {
- *ret_freq = real_freq/100;
- }
- is_af_jump_received = false;
- return FM_SUCCESS;
-}
-
-//Emphasis:
-//75microsec: 0, 50 microsec: 1
-//return FM_SUCCESS on success, FM_FAILURE
-//on failure
-int FmRadioController :: SetDeConstant
-(
- long emphasis
-)
-{
- int ret;
-
- ALOGE("cur_fm_state: %d, emphasis: %d\n", cur_fm_state, emphasis);
- if(cur_fm_state == FM_ON) {
- switch(emphasis) {
- case DE_EMP75:
- case DE_EMP50:
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_EMPHASIS, emphasis);
- break;
- default:
- ALOGE("FM value pass for set Deconstant is invalid\n");
- ret = FM_FAILURE;
- break;
- }
- }else {
- ALOGE("FM is not in proper state to set De constant\n");
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: GetStationList
-(
- uint16_t *scan_tbl, int *max_cnt
-)
-{
- char srch_list[STD_BUF_SIZE];
- int ret;
- ULINT lowBand, highBand;
- int station_num = 0;
- int stationList[FM_RX_SRCHLIST_MAX_STATIONS];
- int tmpFreqByte1=0;
- int tmpFreqByte2=0;
- int freq = 0;
- float real_freq = 0;
- int i = 0, j = 0;
-
- ALOGI("getstationList\n");
- ret = FmIoctlsInterface::get_lowerband_limit(fd_driver,
- lowBand);
- if (ret != FM_SUCCESS) {
- ALOGE("failed to get lowerband: %d\n", ret);
- return FM_FAILURE;
- }
- ALOGI("lowBand = %ld\n",lowBand);
- ret = FmIoctlsInterface::get_upperband_limit(fd_driver,
- highBand);
- if (ret != FM_SUCCESS) {
- ALOGE("failed to getgherband: %d\n", ret);
- return FM_FAILURE;
- }
- ALOGI("highBand = %ld\n",highBand);
- ret = FmIoctlsInterface::get_buffer(fd_driver,
- srch_list, STD_BUF_SIZE, STATION_LIST_IND);
- if ((int)srch_list[0] >0) {
- station_num = (int)srch_list[0];
- }
- ALOGI("station_num: %d ", station_num);
- *max_cnt = station_num;
- for (i=0;i<station_num;i++) {
- freq = 0;
- ALOGI(" Byte1 = %d", srch_list[i * NO_OF_BYTES_EACH_FREQ + 1]);
- ALOGI(" Byte2 = %d", srch_list[i * NO_OF_BYTES_EACH_FREQ + 2]);
- tmpFreqByte1 = srch_list[i * NO_OF_BYTES_EACH_FREQ + 1] & 0xFF;
- tmpFreqByte2 = srch_list[i * NO_OF_BYTES_EACH_FREQ + 2] & 0xFF;
- ALOGI(" tmpFreqByte1 = %d", tmpFreqByte1);
- ALOGI(" tmpFreqByte2 = %d", tmpFreqByte2);
- freq = (tmpFreqByte1 & EXTRACT_FIRST_BYTE) << 8;
- freq |= tmpFreqByte2;
- ALOGI(" freq: %d", freq);
- real_freq = (freq * FREQ_MULTIPLEX) + lowBand;
- ALOGI(" real_freq: %d", real_freq);
- if ( (real_freq < lowBand ) || (real_freq > highBand) ) {
- ALOGI("Frequency out of band limits");
- } else {
- scan_tbl[j] = (real_freq/SRCH_DIV);
- ALOGI(" scan_tbl: %d", scan_tbl[j]);
- j++;
- }
- }
- return FM_SUCCESS;
-}
-
-int FmRadioController ::ScanList
-(
- uint16_t *scan_tbl, int *max_cnt
-)
-{
- int ret;
- struct timespec ts;
-
- /* Check current state of FM device */
- if (cur_fm_state == FM_ON) {
- ALOGI("FM searchlist started\n");
- set_fm_state(SCAN_IN_PROGRESS);
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_SRCHMODE, SRCHLIST_MODE_STRONG);
- if (ret != FM_SUCCESS) {
- set_fm_state(FM_ON);
- return FM_FAILURE;
- }
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_SRCH_CNT, FM_RX_SRCHLIST_MAX_STATIONS);
- if (ret != FM_SUCCESS) {
- set_fm_state(FM_ON);
- return FM_FAILURE;
- }
- ret = FmIoctlsInterface::start_search(fd_driver,
- SEARCH_UP);
- if (ret != FM_SUCCESS) {
- set_fm_state(FM_ON);
- return FM_FAILURE;
- }
- pthread_mutex_lock(&mutex_scan_compl_cond);
- ts = set_time_out(SCAN_COMPL_TIMEOUT);
- ALOGI("Wait for Scan Timeout or scan complete");
- ret = pthread_cond_timedwait(&scan_compl_cond, &mutex_scan_compl_cond, &ts);
- ALOGI("Scan complete or timedout");
- pthread_mutex_unlock(&mutex_scan_compl_cond);
- if (cur_fm_state == FM_ON && !seek_scan_canceled) {
- GetStationList(scan_tbl, max_cnt);
- } else {
- seek_scan_canceled = false;
- return FM_FAILURE;
- }
- } else {
- ALOGI("Scanlist: not proper state %d\n",cur_fm_state );
- return FM_FAILURE;
- }
- return FM_SUCCESS;
-}
-
-long FmRadioController :: GetCurrentRSSI
-(
- void
-)
-{
- int ret;
- long rmssi = -129;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::get_rmssi(fd_driver, rmssi);
- }else {
- }
- return rmssi;
-}
-
-//enable, disable value to receive data of a RDS group
-//return FM_SUCCESS on success, FM_FAILURE on failure
-int FmRadioController :: SetRdsGrpProcessing
-(
- int grps
-)
-{
- int ret;
- long mask;
-
- if(cur_fm_state == FM_ON) {
- ret = FmIoctlsInterface::get_control(fd_driver,
- V4L2_CID_PRV_RDSGROUP_PROC, mask);
- if(ret != FM_SUCCESS) {
- return ret;
- }
- mask &= 0xC7;
- mask |= ((grps & 0x07) << 3);
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_RDSGROUP_PROC, (int)mask);
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-//Enable RDS data receiving
-//Enable RT, PS, AF Jump, RTPLUS, ERT etc
-int FmRadioController :: EnableRDS
-(
- void
-)
-{
- int ret = FM_FAILURE;
-
- ALOGE("%s:cur_fm_state = %d\n", __func__, cur_fm_state);
- if (cur_fm_state == FM_ON) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_RDSON, 1);
- if (ret != FM_SUCCESS) {
- ALOGE("RDS ON failed\n");
- return ret;
- }
- ret = SetRdsGrpProcessing(FM_RX_RDS_GRP_RT_EBL |
- FM_RX_RDS_GRP_PS_EBL |
- FM_RX_RDS_GRP_AF_EBL |
- FM_RX_RDS_GRP_PS_SIMPLE_EBL);
- if (ret != FM_SUCCESS) {
- ALOGE("Set RDS grp processing\n");
- return ret;
- }
- ret = FM_SUCCESS;
- rds_enabled = 1;
- EnableAF();
- } else {
- ALOGE("%s:not in proper state cur_fm_state = %d\n", cur_fm_state);
- return ret;
- }
- return ret;
-}
-
-//Disable all RDS data processing
-//RT, ERT, RT PLUS, PS
-int FmRadioController :: DisableRDS
-(
- void
-)
-{
- int ret = FM_FAILURE;
-
- ALOGE("%s:cur_fm_state = %d\n", __func__, cur_fm_state);
- if (cur_fm_state == FM_ON) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_RDSON, 2);
- if (ret != FM_SUCCESS) {
- ALOGE("Disable RDS failed\n");
- return ret;
- }
- ret = FM_SUCCESS;
- rds_enabled = 0;
- DisableAF();
- } else {
- ALOGE("%s:not in proper state cur_fm_state = %d\n", cur_fm_state);
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: Turn_On_Off_Rds(bool onoff)
-{
- int ret = 0;
-
- if (onoff) {
- ret = EnableRDS();
- } else {
- ret = DisableRDS();
- }
-
- if (ret) {
- ALOGE("%s, failed\n", __func__);
- }
- ALOGD("%s, [onoff=%d] [ret=%d]\n", __func__, onoff, ret);
- return ret;
-}
-
-//Enables Alternate Frequency switching
-int FmRadioController :: EnableAF
-(
- void
-)
-{
- int ret;
- long rdsgrps;
-
- if(cur_fm_state == FM_ON) {
- ret = FmIoctlsInterface::get_control(fd_driver,
- V4L2_CID_PRV_RDSGROUP_PROC, rdsgrps);
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_RDSON, 1);
- if(ret == FM_SUCCESS) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_AF_JUMP, 1);
- if(ret == FM_SUCCESS) {
- af_enabled = 1;
- }
- } else {
- }
- } else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-//Disables Alternate Frequency switching
-int FmRadioController :: DisableAF
-(
- void
-)
-{
- int ret;
- long rdsgrps;
-
- if(cur_fm_state == FM_ON) {
- ret = FmIoctlsInterface::get_control(fd_driver,
- V4L2_CID_PRV_RDSGROUP_PROC, rdsgrps);
- if(ret == FM_SUCCESS) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_AF_JUMP, 0);
- if(ret == FM_SUCCESS) {
- af_enabled = 0;
- }
- }else {
- }
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-//Set regional band
-int FmRadioController :: SetBand
-(
- long band
-)
-{
- int ret;
-
- if(cur_fm_state == FM_ON) {
- switch(band) {
- case BAND_87500_108000:
- ret = FmIoctlsInterface::set_band(fd_driver,
- 87500, 108000);
- break;
- case BAND_76000_108000:
- ret = FmIoctlsInterface::set_band(fd_driver,
- 76000, 108000);
- break;
- case BAND_76000_90000:
- ret = FmIoctlsInterface::set_band(fd_driver,
- 76000, 90000);
- break;
- default:
- ALOGE("Band type: %ld is invalid\n", band);
- ret = FM_FAILURE;
- break;
- }
- }else {
- ALOGE("FM is not in proper state to set band type\n");
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-//set spacing for successive channels
-int FmRadioController :: SetChannelSpacing
-(
- long spacing
-)
-{
- int ret;
-
- if (cur_fm_state == FM_ON) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_CHAN_SPACING, spacing);
- } else {
- ALOGE("FM is not in proper state to set the channel spacing\n");
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: SetStereo
-(
-)
-{
- int ret;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_audio_mode(fd_driver,
- STEREO);
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-int FmRadioController :: SetMono
-(
-)
-{
- int ret;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_audio_mode(fd_driver,
- MONO);
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-bool FmRadioController :: GetSoftMute
-(
-)
-{
- int ret = FM_SUCCESS;
- long mode = SMUTE_DISABLED;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::get_control(fd_driver,
- V4L2_CID_PRV_SOFT_MUTE, mode);
- if(ret == FM_SUCCESS) {
- ALOGI("FM Get soft mute is successful: %ld\n", mode);
- }else {
- ALOGE("FM Get soft mute failed");
- }
- }else {
- ALOGE("FM is not in proper state for getting soft mute\n");
- ret = FM_FAILURE;
- }
- return mode;
-}
-
-int FmRadioController :: Antenna_Switch(int antenna)
-{
- int ret = 0;
-
- if (antenna) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_ANTENNA, 1);
- } else {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_ANTENNA, 0);
- }
- ALOGD("%s, antenna type = %d [ret=%d]\n", __func__, antenna, ret);
- return ret;
-}
-
-int FmRadioController :: get_fm_state
-(
-)
-{
- return cur_fm_state;
-}
-
-void FmRadioController :: set_fm_state
-(
- int state
-)
-{
- pthread_mutex_lock(&mutex_fm_state);
- cur_fm_state = state;
- pthread_mutex_unlock(&mutex_fm_state);
-}
-
-void* FmRadioController :: handle_events
-(
- void *arg
-)
-{
- int bytesread;
- char event_buff[STD_BUF_SIZE];
- bool status = true;
- FmRadioController *obj_p = static_cast<FmRadioController*>(arg);
-
- while(status && !obj_p->event_listener_canceled) {
- bytesread = FmIoctlsInterface::get_buffer(obj_p->fd_driver,
- event_buff, STD_BUF_SIZE, EVENT_IND);
- for(int i = 0; i < bytesread; i++) {
- status = obj_p->process_radio_events(event_buff[i]);
- if(status == false) {
- break;
- }
- }
- }
- return NULL;
-}
-
-int FmRadioController :: SetRdsGrpMask
-(
- int mask
-)
-{
- int ret;
-
- if((cur_fm_state != FM_OFF) &&
- (cur_fm_state != FM_OFF_IN_PROGRESS) &&
- (cur_fm_state != FM_ON_IN_PROGRESS)) {
- ret = FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_RDSGROUP_MASK, mask);
- }else {
- ret = FM_FAILURE;
- }
- return ret;
-}
-
-void FmRadioController :: handle_enabled_event
-(
- void
-)
-{
- char value[PROPERTY_VALUE_MAX] = {'\0'};
-
- ALOGI("FM handle ready Event\n");
- FmIoctlsInterface::set_control(fd_driver,
- V4L2_CID_PRV_AUDIO_PATH, AUDIO_DIGITAL_PATH);
- property_get("qcom.bluetooth.soc", value, NULL);
- if (strcmp(value, "rome") != 0) {
- FmIoctlsInterface::set_calibration(fd_driver);
- }
- pthread_mutex_lock(&mutex_turn_on_cond);
- set_fm_state(FM_ON);
- pthread_cond_broadcast(&turn_on_cond);
- pthread_mutex_unlock(&mutex_turn_on_cond);
-}
-
-void FmRadioController :: handle_tuned_event
-(
- void
-)
-{
- long freq = -1;
-
- ALOGI("FM handle Tune event\n");
- freq = GetChannel();
- switch(cur_fm_state) {
- case FM_ON:
- if(af_enabled && (freq != prev_freq)
- && (prev_freq > 0)) {
- ALOGI("AF jump happened\n");
- is_af_jump_received = true;
- }
- break;
- case FM_TUNE_IN_PROGRESS:
- pthread_mutex_lock(&mutex_tune_compl_cond);
- set_fm_state(FM_ON);
- pthread_cond_broadcast(&tune_compl_cond);
- pthread_mutex_unlock(&mutex_tune_compl_cond);
- break;
- case SEEK_IN_PROGRESS:
- pthread_mutex_lock(&mutex_seek_compl_cond);
- set_fm_state(FM_ON);
- pthread_cond_broadcast(&seek_compl_cond);
- pthread_mutex_unlock(&mutex_seek_compl_cond);
- break;
- case SCAN_IN_PROGRESS:
- break;
- }
- prev_freq = freq;
-}
-
-void FmRadioController :: handle_seek_next_event
-(
- void
-)
-{
- ALOGI("FM handle seek next event\n");
-}
-
-void FmRadioController :: handle_seek_complete_event
-(
- void
-)
-{
- ALOGI("FM handle seek complete event\n");
-}
-
-void FmRadioController :: handle_raw_rds_event
-(
- void
-)
-{
-
-}
-
-void FmRadioController :: handle_rt_event
-(
- void
-)
-{
- ALOGI("FM handle RT event\n");
- is_rt_event_received = true;
-}
-
-void FmRadioController :: handle_ps_event
-(
- void
-)
-{
- ALOGI("FM handle PS event\n");
- is_ps_event_received = true;
-}
-
-void FmRadioController :: handle_error_event
-(
- void
-)
-{
-
-}
-
-void FmRadioController :: handle_below_th_event
-(
- void
-)
-{
-
-}
-
-void FmRadioController :: handle_above_th_event
-(
- void
-)
-{
-
-}
-
-void FmRadioController :: handle_stereo_event
-(
- void
-)
-{
-
-}
-void FmRadioController :: handle_mono_event
-(
- void
-)
-{
-
-}
-
-void FmRadioController :: handle_rds_aval_event
-(
- void
-)
-{
- ALOGI("Got rds_aval_event\n");
- is_rds_support = true;
-}
-
-void FmRadioController :: handle_rds_not_aval_event
-(
- void
-)
-{
- ALOGI("Got rds_not_aval_event\n");
-}
-
-void FmRadioController :: handle_srch_list_event
-(
- void
-)
-{
- ALOGI("Got srch list event\n");
- if (cur_fm_state == SCAN_IN_PROGRESS) {
- pthread_mutex_lock(&mutex_scan_compl_cond);
- set_fm_state(FM_ON);
- pthread_cond_broadcast(&scan_compl_cond);
- pthread_mutex_unlock(&mutex_scan_compl_cond);
- }
-}
-
-void FmRadioController :: handle_af_list_event
-(
- void
-)
-{
- char raw_rds[STD_BUF_SIZE];
- int ret;
- int aflist_size;
- ULINT lower_band;
- int AfList[MAX_AF_LIST_SIZE];
-
- ALOGI("Got af list event\n");
- ret = FmIoctlsInterface::get_buffer(fd_driver,
- raw_rds, STD_BUF_SIZE, AF_LIST_IND);
- lower_band = FmIoctlsInterface::get_lowerband_limit(fd_driver,
- lower_band);
- ALOGI("raw_rds[0]: %d\n", (raw_rds[0] & 0xff));
- ALOGI("raw_rds[1]: %d\n", (raw_rds[1] & 0xff));
- ALOGI("raw_rds[2]: %d\n", (raw_rds[2] & 0xff));
- ALOGI("raw_rds[3]: %d\n", (raw_rds[3] & 0xff));
- ALOGI("raw_rds[4]: %d\n", (raw_rds[4] & 0xff));
- ALOGI("raw_rds[5]: %d\n", (raw_rds[5] & 0xff));
- ALOGI("raw_rds[6]: %d\n", (raw_rds[6] & 0xff));
-
- aflist_size = raw_rds[AF_SIZE_IDX] & 0xff;
- for(int i = 0; i < aflist_size; i++) {
- AfList[i] = (raw_rds[AF_SIZE_IDX + i * NO_OF_BYTES_AF + 1] & 0xFF) |
- ((raw_rds[AF_SIZE_IDX + i * NO_OF_BYTES_AF + 2] & 0xFF) << 8) |
- ((raw_rds[AF_SIZE_IDX + i * NO_OF_BYTES_AF + 3] & 0xFF) << 16) |
- ((raw_rds[AF_SIZE_IDX + i * NO_OF_BYTES_AF + 4] & 0xFF) << 24);
- ALOGI("AF: %d\n", AfList[i]);
- }
-}
-
-void FmRadioController :: handle_disabled_event
-(
- void
-)
-{
- //Expected disabled
- if(cur_fm_state == FM_OFF_IN_PROGRESS) {
- ALOGI("Expected disabled event\n");
- }else {//Enexpected disabled
- ALOGI("Unexpected disabled event\n");
- }
-
- set_fm_state(FM_OFF);
- close(fd_driver);
- fd_driver = -1;
-
- //allow tune function to exit
- pthread_mutex_lock(&mutex_tune_compl_cond);
- pthread_cond_broadcast(&tune_compl_cond);
- pthread_mutex_unlock(&mutex_tune_compl_cond);
- //allow scan function to exit
- pthread_mutex_lock(&mutex_scan_compl_cond);
- pthread_cond_broadcast(&scan_compl_cond);
- pthread_mutex_unlock(&mutex_scan_compl_cond);
- //Allow seek function to exit
- pthread_mutex_lock(&mutex_seek_compl_cond);
- pthread_cond_broadcast(&seek_compl_cond);
- pthread_mutex_unlock(&mutex_seek_compl_cond);
-}
-
-void FmRadioController :: handle_rds_grp_mask_req_event
-(
- void
-)
-{
- SetRdsGrpMask(0);
-}
-
-void FmRadioController :: handle_rt_plus_event
-(
- void
-)
-{
- ALOGI("FM handle RT Plus event\n");
-}
-
-void FmRadioController :: handle_af_jmp_event
-(
- void
-)
-{
- long freq = -1;
-
- freq = GetChannel();
- ALOGI("FM handle AF Jumped event\n");
- if(af_enabled && (freq != prev_freq)) {
- ALOGI("AF Jump occured, prevfreq is: %ld, af freq is: %ld\n", prev_freq, freq);
- }
- prev_freq = freq;
-}
-
-void FmRadioController :: handle_ert_event
-(
- void
-)
-{
- ALOGI("FM handle ERT event\n");
-}
-
-bool FmRadioController :: process_radio_events
-(
- int event
-)
-{
- bool ret = true;
-
- switch(event) {
- case READY_EVENT:
- handle_enabled_event();
- break;
- case TUNE_EVENT:
- handle_tuned_event();
- break;
- case SEEK_COMPLETE_EVENT:
- handle_seek_complete_event();
- break;
- case SCAN_NEXT_EVENT:
- handle_seek_next_event();
- break;
- case RAW_RDS_EVENT:
- handle_raw_rds_event();
- break;
- case RT_EVENT:
- handle_rt_event();
- break;
- case PS_EVENT:
- handle_ps_event();
- break;
- case ERROR_EVENT:
- handle_error_event();
- break;
- case BELOW_TH_EVENT:
- handle_below_th_event();
- break;
- case ABOVE_TH_EVENT:
- handle_above_th_event();
- break;
- case STEREO_EVENT:
- handle_stereo_event();
- break;
- case MONO_EVENT:
- handle_mono_event();
- break;
- case RDS_AVAL_EVENT:
- handle_rds_aval_event();
- break;
- case RDS_NOT_AVAL_EVENT:
- handle_rds_not_aval_event();
- break;
- case SRCH_LIST_EVENT:
- handle_srch_list_event();
- break;
- case AF_LIST_EVENT:
- handle_af_list_event();
- break;
- case DISABLED_EVENT:
- handle_disabled_event();
- ret = false;
- break;
- case RDS_GRP_MASK_REQ_EVENT:
- handle_rds_grp_mask_req_event();
- break;
- case RT_PLUS_EVENT:
- handle_rt_plus_event();
- break;
- case ERT_EVENT:
- handle_ert_event();
- break;
- case AF_JMP_EVENT:
- handle_af_jmp_event();
- break;
- default:
- break;
- }
- return ret;
-}
diff --git a/libfm_jni/FmRadioController.h b/libfm_jni/FmRadioController.h
deleted file mode 100644
index 6ce906e..0000000
--- a/libfm_jni/FmRadioController.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#ifndef __FM_RADIO_CTRL_H__
-#define __FM_RADIO_CTRL_H___
-
-#include <pthread.h>
-#include <ctime>
-
-class FmRadioController
-{
- private:
- int cur_fm_state;
- char af_enabled;
- bool seek_scan_canceled;
- bool is_rds_support;
- bool is_ps_event_received = false;
- bool is_rt_event_received = false;
- bool is_af_jump_received = false;
- bool event_listener_canceled;
- pthread_mutex_t mutex_fm_state;
- pthread_mutex_t mutex_turn_on_cond;
- pthread_mutex_t mutex_seek_compl_cond;
- pthread_mutex_t mutex_scan_compl_cond;
- pthread_mutex_t mutex_tune_compl_cond;
- pthread_cond_t turn_on_cond;
- pthread_cond_t seek_compl_cond;
- pthread_cond_t scan_compl_cond;
- pthread_cond_t tune_compl_cond;
- char rds_enabled;
- long int prev_freq;
- int fd_driver;
- pthread_t event_listener_thread;
- int SetRdsGrpMask(int mask);
- int SetRdsGrpProcessing(int grps);
- void handle_enabled_event(void);
- void handle_tuned_event(void);
- void handle_seek_next_event(void);
- void handle_seek_complete_event(void);
- void handle_raw_rds_event(void);
- void handle_rt_event(void);
- void handle_ps_event(void);
- void handle_error_event(void);
- void handle_below_th_event(void);
- void handle_above_th_event(void);
- void handle_stereo_event(void);
- void handle_mono_event(void);
- void handle_rds_aval_event(void);
- void handle_rds_not_aval_event(void);
- void handle_srch_list_event(void);
- void handle_af_list_event(void);
- void handle_disabled_event(void);
- void handle_rds_grp_mask_req_event(void);
- void handle_rt_plus_event(void);
- void handle_ert_event(void);
- void handle_af_jmp_event(void);
- void set_fm_state(int state);
- struct timespec set_time_out(int secs);
- int GetStationList(uint16_t *scan_tbl, int *max_cnt);
- int EnableRDS(void);
- int DisableRDS(void);
- int EnableAF(void);
- int DisableAF(void);
- int SetStereo(void);
- int SetMono(void);
- int MuteOn(void);
- int MuteOff(void);
- int get_fm_state(void);
- long GetCurrentRSSI(void);
- bool GetSoftMute(void);
- public:
- FmRadioController();
- ~FmRadioController();
- int open_dev(void);
- int close_dev();
- int Pwr_Up(int freq);
- int Pwr_Down(void);
- long GetChannel(void);
- int TuneChannel(long);
- bool IsRds_support();
- int ScanList(uint16_t *scan_tbl, int *max_cnt);
- int Seek(int dir);
- int ReadRDS(void);
- int Get_ps(char *ps, int *ps_len);
- int Get_rt(char *rt, int *rt_len);
- int Get_AF_freq(uint16_t *ret_freq);
- int SetDeConstant(long );
- int SetSoftMute(bool mode);
- int Set_mute(bool mute);
- int SetBand(long);
- int SetChannelSpacing(long);
- int Stop_Scan_Seek(void);
- int Turn_On_Off_Rds(bool onoff);
- int Antenna_Switch(int antenna);
- static void* handle_events(void *arg);
- bool process_radio_events(int event);
-};
-
-#endif
diff --git a/libfm_jni/LibfmJni.cpp b/libfm_jni/LibfmJni.cpp
deleted file mode 100644
index 52ad029..0000000
--- a/libfm_jni/LibfmJni.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-Copyright (c) 2015, 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 "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.
-*/
-
-#include <jni.h>
-#include "JNIHelp.h"
-#include "android_runtime/AndroidRuntime.h"
-#include <utils/Log.h>
-#include "FmRadioController.h"
-#include "FM_Const.h"
-
-static FmRadioController * pFMRadio;
-
-jboolean OpenFd(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
- pFMRadio = new FmRadioController();
- if (pFMRadio)
- ret = pFMRadio->open_dev();
- else
- ret = JNI_FALSE;
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret? JNI_FALSE: JNI_TRUE;
-}
-
-jboolean CloseFd(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
-
- if (pFMRadio)
- ret = pFMRadio->close_dev();
- else
- ret = JNI_FALSE;
-
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret? JNI_FALSE: JNI_TRUE;
-}
-
-jboolean TurnOn(JNIEnv *env, jobject thiz, jfloat freq)
-{
- int ret = 0;
- int tmp_freq;
-
- ALOGI("%s, [freq=%d]\n", __func__, (int)freq);
- tmp_freq = (int)(freq * FREQ_MULT); //Eg, 87.5 * 1000 --> 87500
- if (!pFMRadio) {
- pFMRadio = new FmRadioController();
- }
- if (pFMRadio)
- ret = pFMRadio->Pwr_Up(tmp_freq);
- else
- ret = JNI_FALSE;
-
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret?JNI_FALSE:JNI_TRUE;
-}
-
-jboolean TurnOff(JNIEnv *env, jobject thiz, jint type)
-{
- int ret = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Pwr_Down();
- else
- ret = JNI_FALSE;
-
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- if (pFMRadio) {
- delete pFMRadio;
- pFMRadio = NULL;
- }
- return ret?JNI_FALSE:JNI_TRUE;
-}
-
-jboolean SetFreq(JNIEnv *env, jobject thiz, jfloat freq)
-{
- int ret = 0;
- int tmp_freq;
-
- tmp_freq = (int)(freq * FREQ_MULT); //Eg, 87.5 * 10 --> 875
- if (pFMRadio)
- ret = pFMRadio->TuneChannel(tmp_freq);
- else
- ret = JNI_FALSE;
-
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret?JNI_FALSE:JNI_TRUE;
-}
-
-jfloat Seek(JNIEnv *env, jobject thiz, jfloat freq, jboolean isUp)
-{
- int ret = JNI_FALSE;
- float val = freq;
-
- if (pFMRadio) {
- ret = pFMRadio->Set_mute(true);
- ALOGD("%s, [mute] [ret=%d]\n", __func__, ret);
- ret = pFMRadio->Seek((int)isUp);
- ALOGD("%s, [freq=%f] [ret=%d]\n", __func__, freq, ret);
- if (ret > 0)
- val = (float)ret/FREQ_MULT; //Eg, 8755 / 100 --> 87.55
- }
-
- return val;
-}
-
-jshortArray ScanList(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
- jshortArray scanList;
- int chl_cnt = FM_SCAN_CH_SIZE_MAX;
- uint16_t ScanTBL[FM_SCAN_CH_SIZE_MAX];
-
- if (pFMRadio)
- ret = pFMRadio->ScanList(ScanTBL, &chl_cnt);
- else
- ret = JNI_FALSE;
- if (ret < 0) {
- ALOGE("scan failed!\n");
- scanList = NULL;
- goto out;
- }
- if (chl_cnt > 0) {
- scanList = env->NewShortArray(chl_cnt);
- env->SetShortArrayRegion(scanList, 0, chl_cnt, (const jshort*)&ScanTBL[0]);
- } else {
- ALOGE("cnt error, [cnt=%d]\n", chl_cnt);
- scanList = NULL;
- }
-
-out:
- ALOGD("%s, [cnt=%d] [ret=%d]\n", __func__, chl_cnt, ret);
- return scanList;
-}
-
-jshort GetRdsEvent(JNIEnv *env, jobject thiz)
-{
- int ret = JNI_FALSE;
-
- if (pFMRadio)
- ret = pFMRadio->ReadRDS();
-
- return ret;
-}
-
-jbyteArray GetPsText(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
- jbyteArray PS;
- char ps[MAX_PS_LEN];
- int ps_len = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Get_ps(ps, &ps_len);
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- return NULL;
- }
- PS = env->NewByteArray(ps_len);
- env->SetByteArrayRegion(PS, 0, ps_len, (const jbyte*)ps);
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return PS;
-}
-
-jbyteArray GetRtText(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
- jbyteArray RadioText;
- char rt[MAX_RT_LEN];
- int rt_len = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Get_rt(rt, &rt_len);
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- return NULL;
- }
- RadioText = env->NewByteArray(rt_len);
- env->SetByteArrayRegion(RadioText, 0, rt_len, (const jbyte*)rt);
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return RadioText;
-}
-
-jshort GetAfFreq(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
- jshort ret_freq = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Get_AF_freq((uint16_t*)&ret_freq);
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- return 0;
- }
- ALOGD("%s, [ret_freq=%d]\n", __func__, ret_freq);
- return ret_freq;
-}
-
-jint SetRds(JNIEnv *env, jobject thiz, jboolean rdson)
-{
- int ret = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Turn_On_Off_Rds(rdson);
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- }
- ALOGD("%s, [rdson=%d] [ret=%d]\n", __func__, rdson, ret);
- return ret?JNI_FALSE:JNI_TRUE;
-}
-
-jboolean StopSrch(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Stop_Scan_Seek();
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- }
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret?JNI_FALSE:JNI_TRUE;
-}
-
-jint SetMute(JNIEnv *env, jobject thiz, jboolean mute)
-{
- int ret = 0;
-
- if (pFMRadio)
- ret = pFMRadio->Set_mute(mute);
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- }
- ALOGD("%s, [mute=%d] [ret=%d]\n", __func__, (int)mute, ret);
- return ret?JNI_FALSE:JNI_TRUE;
-}
-
-/******************************************
- * Inquiry if RDS is support in driver.
- * Parameter:
- * None
- *Return Value:
- * 1: support
- * 0: NOT support
- * -1: error
- ******************************************/
-jint IsRdsSupport(JNIEnv *env, jobject thiz)
-{
- int ret = 0;
-
- if (pFMRadio)
- ret = pFMRadio->IsRds_support();
- else
- ret = JNI_FALSE;
- if (!ret) {
- ALOGE("%s, error, [ret=%d]\n", __func__, ret);
- }
- ALOGD("%s, [ret=%d]\n", __func__, ret);
- return ret;
-}
-
-/******************************************
- * SwitchAntenna
- * Parameter:
- * antenna:
- 0 : switch to long antenna
- 1: switch to short antenna
- *Return Value:
- * 0: Success
- * 1: Failed
- * 2: Not support
- ******************************************/
-jint SetAntenna(JNIEnv *env, jobject thiz, jint antenna)
-{
- int ret = 0;
- jint jret = 0;
- int ana = -1;
-
- if (0 == antenna) {
- ana = FM_LONG_ANA;
- } else if (1 == antenna) {
- ana = FM_SHORT_ANA;
- } else {
- ALOGE("%s:fail, para error\n", __func__);
- jret = JNI_FALSE;
- goto out;
- }
- if (pFMRadio)
- ret = pFMRadio->Antenna_Switch(ana);
- else
- ret = JNI_FALSE;
- if (ret) {
- ALOGE("switchAntenna(), error\n");
- jret = 1;
- } else {
- jret = 0;
- }
-out:
- ALOGD("%s: [antenna=%d] [ret=%d]\n", __func__, ana, ret);
- return jret;
-}
-
-static const char *classPathNameFM = "com/android/fmradio/FmNative";
-
-static JNINativeMethod gMethods[] = {
- {"openDev", "()Z", (void*)OpenFd },
- {"closeDev", "()Z", (void*)CloseFd },
- {"powerUp", "(F)Z", (void*)TurnOn },
- {"powerDown", "(I)Z", (void*)TurnOff },
- {"tune", "(F)Z", (void*)SetFreq },
- {"seek", "(FZ)F", (void*)Seek },
- {"autoScan", "()[S", (void*)ScanList },
- {"stopScan", "()Z", (void*)StopSrch },
- {"setRds", "(Z)I", (void*)SetRds },
- {"readRds", "()S", (void*)GetRdsEvent },
- {"getPs", "()[B", (void*)GetPsText },
- {"getLrText", "()[B", (void*)GetRtText},
- {"activeAf", "()S", (void*)GetAfFreq},
- {"setMute", "(Z)I", (void*)SetMute},
- {"isRdsSupport", "()I", (void*)IsRdsSupport},
- {"switchAntenna", "(I)I", (void*)SetAntenna},
-};
-
-int register_android_hardware_fm(JNIEnv* env)
-{
- return jniRegisterNativeMethods(env, classPathNameFM, gMethods, NELEM(gMethods));
-}
-
-jint JNI_OnLoad(JavaVM *jvm, void *reserved)
-{
- JNIEnv *e;
- int status;
- ALOGE("FM : loading FM-JNI\n");
-
- if(jvm->GetEnv((void **)&e, JNI_VERSION_1_6)) {
- ALOGE("JNI version mismatch error");
- return JNI_ERR;
- }
-
- if ((status = register_android_hardware_fm(e)) < 0) {
- ALOGE("jni adapter service registration failure, status: %d", status);
- return JNI_ERR;
- }
- return JNI_VERSION_1_6;
-}
-