From 47abd376fa60845965192080fdb63606b8738892 Mon Sep 17 00:00:00 2001
From: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
Date: Mon, 1 Jul 2013 14:38:07 +0530
Subject: [PATCH] fm: Move FM APP source tree to vendor project
- FM APP source moved from packages/apps to vendor/qcom-opensource/
repository
- Remove META data change intent handler
Change-Id: I669ee82b5ab2a3a4717387e4ce0c1452423497e9
---
Android.mk | 5 +-
fmapp/Android.mk | 24 +
fmapp/AndroidManifest.xml | 119 +
fmapp/fmtransmitter.xml | 223 +
fmapp/res/anim/preset_select.xml | 38 +
fmapp/res/drawable/album_border_large.1.png | Bin 0 -> 1349 bytes
fmapp/res/drawable/alert_dialog_icon.png | Bin 0 -> 3645 bytes
fmapp/res/drawable/application_border.xml | 33 +
fmapp/res/drawable/btn_arrow_left.xml | 40 +
fmapp/res/drawable/btn_arrow_left_default.png | Bin 0 -> 1203 bytes
fmapp/res/drawable/btn_arrow_left_press.png | Bin 0 -> 1545 bytes
.../res/drawable/btn_arrow_left_selected.png | Bin 0 -> 1581 bytes
fmapp/res/drawable/btn_arrow_right.xml | 41 +
.../res/drawable/btn_arrow_right_default.png | Bin 0 -> 1228 bytes
fmapp/res/drawable/btn_arrow_right_press.png | Bin 0 -> 1634 bytes
.../res/drawable/btn_arrow_right_selected.png | Bin 0 -> 1663 bytes
fmapp/res/drawable/ic_btn_forward.png | Bin 0 -> 1228 bytes
fmapp/res/drawable/ic_btn_forward_dis.png | Bin 0 -> 1182 bytes
fmapp/res/drawable/ic_btn_onoff.png | Bin 0 -> 1709 bytes
fmapp/res/drawable/ic_btn_preset.png | Bin 0 -> 807 bytes
fmapp/res/drawable/ic_btn_search.png | Bin 0 -> 1747 bytes
fmapp/res/drawable/ic_btn_search_stop.png | Bin 0 -> 2290 bytes
fmapp/res/drawable/ic_launcher_fm_tx.png | Bin 0 -> 3612 bytes
fmapp/res/drawable/ic_launcher_fmradio.png | Bin 0 -> 1289 bytes
fmapp/res/drawable/ic_menu_record.png | Bin 0 -> 798 bytes
fmapp/res/drawable/ic_signal_2.png | Bin 0 -> 1358 bytes
fmapp/res/drawable/ic_silent_mode.png | Bin 0 -> 1362 bytes
fmapp/res/drawable/ic_silent_mode_off.png | Bin 0 -> 1555 bytes
fmapp/res/drawable/ic_status_fm_tx.png | Bin 0 -> 802 bytes
fmapp/res/drawable/ic_stereo.png | Bin 0 -> 742 bytes
fmapp/res/drawable/icon.png | Bin 0 -> 3180 bytes
.../res/drawable/image_border_bg_normal.9.png | Bin 0 -> 3423 bytes
fmapp/res/drawable/preset_page_button.xml | 35 +
fmapp/res/drawable/stat_notify_fm.png | Bin 0 -> 350 bytes
fmapp/res/drawable/station_border.xml | 33 +
fmapp/res/layout-800x480/fmradio.xml | 91 +
fmapp/res/layout-800x480/fmtags.xml | 40 +
fmapp/res/layout-800x480/fmtransmitter.xml | 239 ++
fmapp/res/layout-800x480/navigate.xml | 188 +
fmapp/res/layout-800x480/station_info.xml | 182 +
.../layout-land-finger-800x480/fmradio.xml | 53 +
.../fmtransmitter.xml | 214 +
.../layout-land-finger-800x480/navigate.xml | 152 +
.../station_info.xml | 178 +
fmapp/res/layout-land-finger/fmradio.xml | 115 +
.../res/layout-land-finger/fmtransmitter.xml | 215 +
fmapp/res/layout-land-finger/navigate.xml | 128 +
fmapp/res/layout-land-finger/station_info.xml | 156 +
fmapp/res/layout/alert_dialog_list.xml | 39 +
fmapp/res/layout/alert_dialog_text_entry.xml | 50 +
fmapp/res/layout/fmradio.xml | 99 +
fmapp/res/layout/fmstats.xml | 122 +
fmapp/res/layout/fmtags.xml | 40 +
fmapp/res/layout/fmtransmitter.xml | 235 ++
fmapp/res/layout/frequency_picker.xml | 54 +
fmapp/res/layout/frequency_picker_dialog.xml | 34 +
fmapp/res/layout/navigate.xml | 158 +
fmapp/res/layout/station_info.xml | 176 +
fmapp/res/layout/statusbar.xml | 56 +
fmapp/res/values/arrays.xml | 371 ++
fmapp/res/values/strings.xml | 265 ++
fmapp/res/values/styles.xml | 39 +
.../com/codeaurora/fmradio/FMAdapterApp.java | 64 +
.../fmradio/FMMediaButtonIntentReceiver.java | 71 +
fmapp/src/com/codeaurora/fmradio/FMRadio.java | 3595 +++++++++++++++++
.../codeaurora/fmradio/FMRadioService.java | 3187 +++++++++++++++
fmapp/src/com/codeaurora/fmradio/FMStats.java | 2013 +++++++++
.../fmradio/FMTransmitterActivity.java | 1477 +++++++
.../fmradio/FMTransmitterConfigReceiver.java | 81 +
.../fmradio/FMTransmitterService.java | 1192 ++++++
.../fmradio/FmSharedPreferences.java | 1117 +++++
fmapp/src/com/codeaurora/fmradio/FmTags.java | 99 +
.../codeaurora/fmradio/IFMRadioService.aidl | 102 +
.../fmradio/IFMRadioServiceCallbacks.aidl | 48 +
.../fmradio/IFMTransmitterService.aidl | 51 +
.../IFMTransmitterServiceCallbacks.aidl | 42 +
.../com/codeaurora/fmradio/PresetList.java | 323 ++
.../com/codeaurora/fmradio/PresetStation.java | 951 +++++
.../src/com/codeaurora/fmradio/Settings.java | 388 ++
.../codeaurora/hc_utils/A2dpDeviceStatus.java | 105 +
.../codeaurora/hc_utils/FrequencyPicker.java | 428 ++
.../hc_utils/FrequencyPickerDialog.java | 184 +
.../codeaurora/utils/A2dpDeviceStatus.java | 88 +
.../com/codeaurora/utils/FrequencyPicker.java | 414 ++
.../utils/FrequencyPickerDialog.java | 156 +
85 files changed, 20455 insertions(+), 1 deletion(-)
create mode 100644 fmapp/Android.mk
create mode 100644 fmapp/AndroidManifest.xml
create mode 100644 fmapp/fmtransmitter.xml
create mode 100644 fmapp/res/anim/preset_select.xml
create mode 100644 fmapp/res/drawable/album_border_large.1.png
create mode 100644 fmapp/res/drawable/alert_dialog_icon.png
create mode 100644 fmapp/res/drawable/application_border.xml
create mode 100644 fmapp/res/drawable/btn_arrow_left.xml
create mode 100644 fmapp/res/drawable/btn_arrow_left_default.png
create mode 100644 fmapp/res/drawable/btn_arrow_left_press.png
create mode 100644 fmapp/res/drawable/btn_arrow_left_selected.png
create mode 100644 fmapp/res/drawable/btn_arrow_right.xml
create mode 100644 fmapp/res/drawable/btn_arrow_right_default.png
create mode 100644 fmapp/res/drawable/btn_arrow_right_press.png
create mode 100644 fmapp/res/drawable/btn_arrow_right_selected.png
create mode 100644 fmapp/res/drawable/ic_btn_forward.png
create mode 100755 fmapp/res/drawable/ic_btn_forward_dis.png
create mode 100644 fmapp/res/drawable/ic_btn_onoff.png
create mode 100644 fmapp/res/drawable/ic_btn_preset.png
create mode 100644 fmapp/res/drawable/ic_btn_search.png
create mode 100644 fmapp/res/drawable/ic_btn_search_stop.png
create mode 100644 fmapp/res/drawable/ic_launcher_fm_tx.png
create mode 100644 fmapp/res/drawable/ic_launcher_fmradio.png
create mode 100644 fmapp/res/drawable/ic_menu_record.png
create mode 100644 fmapp/res/drawable/ic_signal_2.png
create mode 100644 fmapp/res/drawable/ic_silent_mode.png
create mode 100644 fmapp/res/drawable/ic_silent_mode_off.png
create mode 100644 fmapp/res/drawable/ic_status_fm_tx.png
create mode 100644 fmapp/res/drawable/ic_stereo.png
create mode 100644 fmapp/res/drawable/icon.png
create mode 100644 fmapp/res/drawable/image_border_bg_normal.9.png
create mode 100644 fmapp/res/drawable/preset_page_button.xml
create mode 100644 fmapp/res/drawable/stat_notify_fm.png
create mode 100644 fmapp/res/drawable/station_border.xml
create mode 100644 fmapp/res/layout-800x480/fmradio.xml
create mode 100644 fmapp/res/layout-800x480/fmtags.xml
create mode 100644 fmapp/res/layout-800x480/fmtransmitter.xml
create mode 100644 fmapp/res/layout-800x480/navigate.xml
create mode 100644 fmapp/res/layout-800x480/station_info.xml
create mode 100644 fmapp/res/layout-land-finger-800x480/fmradio.xml
create mode 100644 fmapp/res/layout-land-finger-800x480/fmtransmitter.xml
create mode 100644 fmapp/res/layout-land-finger-800x480/navigate.xml
create mode 100644 fmapp/res/layout-land-finger-800x480/station_info.xml
create mode 100644 fmapp/res/layout-land-finger/fmradio.xml
create mode 100644 fmapp/res/layout-land-finger/fmtransmitter.xml
create mode 100644 fmapp/res/layout-land-finger/navigate.xml
create mode 100644 fmapp/res/layout-land-finger/station_info.xml
create mode 100644 fmapp/res/layout/alert_dialog_list.xml
create mode 100644 fmapp/res/layout/alert_dialog_text_entry.xml
create mode 100644 fmapp/res/layout/fmradio.xml
create mode 100644 fmapp/res/layout/fmstats.xml
create mode 100644 fmapp/res/layout/fmtags.xml
create mode 100644 fmapp/res/layout/fmtransmitter.xml
create mode 100644 fmapp/res/layout/frequency_picker.xml
create mode 100644 fmapp/res/layout/frequency_picker_dialog.xml
create mode 100644 fmapp/res/layout/navigate.xml
create mode 100644 fmapp/res/layout/station_info.xml
create mode 100644 fmapp/res/layout/statusbar.xml
create mode 100644 fmapp/res/values/arrays.xml
create mode 100644 fmapp/res/values/strings.xml
create mode 100644 fmapp/res/values/styles.xml
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMAdapterApp.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMMediaButtonIntentReceiver.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMRadio.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMRadioService.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMStats.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMTransmitterConfigReceiver.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FMTransmitterService.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/FmTags.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/IFMRadioService.aidl
create mode 100644 fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl
create mode 100644 fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl
create mode 100644 fmapp/src/com/codeaurora/fmradio/IFMTransmitterServiceCallbacks.aidl
create mode 100644 fmapp/src/com/codeaurora/fmradio/PresetList.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/PresetStation.java
create mode 100644 fmapp/src/com/codeaurora/fmradio/Settings.java
create mode 100644 fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java
create mode 100644 fmapp/src/com/codeaurora/hc_utils/FrequencyPicker.java
create mode 100644 fmapp/src/com/codeaurora/hc_utils/FrequencyPickerDialog.java
create mode 100644 fmapp/src/com/codeaurora/utils/A2dpDeviceStatus.java
create mode 100644 fmapp/src/com/codeaurora/utils/FrequencyPicker.java
create mode 100644 fmapp/src/com/codeaurora/utils/FrequencyPickerDialog.java
diff --git a/Android.mk b/Android.mk
index 1fb20d5..53064ac 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,10 +1,11 @@
ifeq ($(call is-vendor-board-platform,QCOM),true)
LOCAL_PATH:= $(call my-dir)
+LOCAL_DIR_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_SRC_FILES := $(call all-java-files-under, qcom/fmradio)
LOCAL_JNI_SHARED_LIBRARIES := libqcomfm_jni
LOCAL_MODULE:= qcom.fmradio
@@ -12,4 +13,6 @@ LOCAL_MODULE:= qcom.fmradio
include $(BUILD_JAVA_LIBRARY)
include $(LOCAL_PATH)/jni/Android.mk
+LOCAL_PATH := $(LOCAL_DIR_PATH)
+include $(LOCAL_PATH)/fmapp/Android.mk
endif # is-vendor-board-platform
diff --git a/fmapp/Android.mk b/fmapp/Android.mk
new file mode 100644
index 0000000..8692b8c
--- /dev/null
+++ b/fmapp/Android.mk
@@ -0,0 +1,24 @@
+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 ($(call is-android-codename-in-list,JELLY_BEAN ICECREAM_SANDWICH HONEYCOMB),true)
+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
new file mode 100644
index 0000000..d0232bc
--- /dev/null
+++ b/fmapp/AndroidManifest.xml
@@ -0,0 +1,119 @@
+<?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"/>
+
+ <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="singleTop"
+ android:excludeFromRecents="true" >
+ <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="true">
+ <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
new file mode 100644
index 0000000..3331f6f
--- /dev/null
+++ b/fmapp/fmtransmitter.xml
@@ -0,0 +1,223 @@
+<?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
new file mode 100644
index 0000000..8fcf768
--- /dev/null
+++ b/fmapp/res/anim/preset_select.xml
@@ -0,0 +1,38 @@
+<?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
new file mode 100644
index 0000000000000000000000000000000000000000..e5ffbc750af370c5431c6aa1abefa11b527075bc
GIT binary patch
literal 1349
zcmeAS@N?(olHy`uVBq!ia0y~yU|0ph9Bd2>47O!gniv=uBuiW)N`mv#O3D+9QW+dm
z@{>{(JaZG%Q-e|yQz{EjrrIztusrv4aSW-r_2yP!(Pa;j*2JxEEI4<cxV%Q|c7otd
zx3VKa&lo*qyptWd^Q`V}n%NcP`sr`z_Lf{pu8+lj+ozcHCAVK!Tw1bcPI8fI*p6+J
zR~+ZQ^XJcz><9mi=KYK_x7-ywVRKndE!&^Y8Oas4^OWC~IbO1;eSCe%(Vb0wy^>Pz
zmutM<rkE+;_c^EQ`bwh%nx5^aWSTZO|2U@~ncaCSoaOGbn=LCjxv!+iYA2ohJjHfa
ze0l4d^Fmw0z6M_CHn{yEa^?mHPoGm7&+X*pKO36vyRNJHYMH<nqx0(~m@Qi!;;QYN
z-1P3V&9j%EH~xwHlBsijg=ygWPchFQ>%3VPAtWGb8rZJny1eql=e3uPIoIVEUYEbV
zw0Kh7-TU|JJvDQ)cK<e(m#F!g|83pRl2<LK_WpYL@PvwgeRcJ3|K!DAtBp-<eKl8E
zFMFx->g&;?N58#$mv?nPhn<Xl&F?=yi>KeVT9-I~>6<4R^W}doO*(F`{z~t<?FO~*
zM9rNmbya^0&(>V@NOy;hi*M?xZ|OP9%GN1|spXyd?bTo={55jbFHY?>Wzi3oM?Zag
zPQ3p`c4yS?hx}_iH8bn8dT)7!CitE@{wX&64%^z$|J~LMtK_xA>wlIQZ@sqSY5USO
z2WDNVlgckN4qcXgy;7&^tL0DOioZ<@Qf-*CL;puk<o+X?&HSLYW7V&PzZg5YI=MVT
zJVIc!!&l~2@<O4DoE9+&iOL%Xc5+?i2gy4ua$4jS;t_&O3yH3h5BNJ_MT1MLi>g+L
z{eoYLVD&5NK<b#xf&>0GylTggTI2+_W9ka9^egrddxgM-zZe%at<V!)6Uca#e-RVN
zT(B&X=0!}`R%~#C>6*SG;IG1}SM4C}5TC&GDQGSD#dwwfDnG~>AaC99X<V^N9%Lj~
zs*|fzD=^WRb<wK26?G0EZwiS{SOM|{>peBF`_cUicFu$qLZUE*tu9knROEMR*?kNT
z{r|&y?#}Me)%84^HL@x%{i!;^yyj%U39ETtS2ilWJXm_<l#JG<d0X9jC)us6TNCrQ
zUEy`WZSAkznZKMb*&LYlrg=^B#C2z1$#VtD$GY!nT(NXbvd^`B8yjb-&fWKC#jlM;
zU+vqzt;>55-6?hX%kI;iQ!6<(P5b)a=gKX=di!oGp2Pdssa|{V;+kT6qR7@Y|MQ|(
z{)_lM`Q=~3dF%7@^8Ai|KXZM`rRB!wkFtL^`Taq+d)NDU_gBrD>zQfwQ6ucs%UkJ{
z`k&tP6;FL`C9nVa_wJf^CbJ(ev2n=O+{w@QV*=~ndFku^i=VXG7<<FV_2aYe-+!9V
zb-nlGWoK90isT9J1XAWM)nS!A<)XWK{~!5)--o{`I&N2Nt)8?f^nGi%VeI@a+5f>C
z?f!1{yUQl&9l84$oA$B{pP)ranxXB7mTKhI{B`fVRr*yuwAMLb(IVB%vr88$<@wwz
z^t@tt+HAf|{oVG`?45GD{RcE7y$iG7m#@7YymZaSuMU2DCT)myJ+`sXZ}YF+T}wW4
zA2}lRNN?}=;626p2bNE{v-0@s+g5$)t@rDhco;HOX055XY>~>qz`)??>gTe~DWM4f
D`tXw_
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/alert_dialog_icon.png b/fmapp/res/drawable/alert_dialog_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..0a7de04767eef7e88ef8e47c30076b29e2db639b
GIT binary patch
literal 3645
zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}oCO|{#S9GG!XV7ZFl&wk
z0|S?Trn7TEKt_H^esM;Afr6*AvqC{pep+TuDg#5st+~PJA;B-jY`@?8;^f`YFvUAR
zNR&e%$f>(QWTKjuBBy{?hvLGUqJakmU0qqEPb}zQ?(1vl5e?Mg>EgP<{zP$6U-ROQ
zu2a7sRxi%Jw&(k^v;VeUw|l<k^W4qn*$;5=O!F`fG;QEn=_Dukp!xWbV-KI`IW%&q
z6fg*IY)(-u{;SN$@T1PgMqB9s`#uK7ip$&_3<rE?A25(<|Ih!*X=V&#Lkr`9l8F}H
z91S824pn_l%NQKo7#rr!Pzz>Qz`~GlIyvbvLx3(rf_nY4%M1;3f6T0AWQd-kD9X5C
zB7=f(YKIF$hBd>Q^I=`C3=swlB5B@7EE#U-G8lM<r+F}J*v@d^oB;PG1`ZwugTRhf
zO$L@~hJ+K!$`uSPGZ{qOK84$S)Ltj>T#JFBV&*2Bohp{DjnN#sh3w(sdU6`)JjJy|
z%o3RrXF2E{s+=il)M�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
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/application_border.xml b/fmapp/res/drawable/application_border.xml
new file mode 100644
index 0000000..479dd75
--- /dev/null
+++ b/fmapp/res/drawable/application_border.xml
@@ -0,0 +1,33 @@
+<!--
+ * 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
new file mode 100644
index 0000000..260c62b
--- /dev/null
+++ b/fmapp/res/drawable/btn_arrow_left.xml
@@ -0,0 +1,40 @@
+<?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
new file mode 100644
index 0000000000000000000000000000000000000000..2a359523ea5c117212f7674dd83d3a912a393c47
GIT binary patch
literal 1203
zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eU<l=4V_;wqWp97Lz`!6`;u=vBoS#-wo>-L1
z;Fyx1l&avFo0y&&l$w}QS$HzlhJk@4)YHW=q~g|_Io|%lfg;DP`BnA>Ja&rZ?n<g*
zSu8E0DcZYa57)~k*82z6z7ud#u!-h)$jd3uV9!{X`{>+}xw|g4cJA8XTREl7X8FDD
z?bBzzWXOH)SFQeYdFnF7&$ItqKA%?|6u@)%!_><Qf1P?W;eb#ClXn8APNV7umTAZw
zy}i!Q{WZECo$3|I-nOiZ;q|J+m3ALE=P`sfo|{lyctQSxo>a8g0gh^}645IhyFAYQ
zXWGkL%b2@+l66RBn=S7u_PtTj(YJk6gxI+5AKp2A!RaT(?C%y&&|)#*{#{jCT52rU
zFTFA1%z<!`IrYrD4qls(#Q2((>v7bD%TuRLb@2E1FSeR{uRV!Nxz3My>E2m~BR8Br
zeL8Z3ns(zmH~9tP%+r=}Z-0}S!&l8|!CjV_sVTtKIxBePmBu!v#=CK^zt$Ym)6+{!
zs7&`>`td|lY(xY{Nona!t7tC1^n>TlpJ%tSw$4r5%QJ`7+T474<57dMP4iZ-dZn2l
zwk@@+%<RI&ix1t?&nBGZ5<8iHl>30ro6R$4N|tQvEWehxFvyiXEpfj4;)~C|efzd7
z#pvY@-KBh!Cy3oj6#M3?BJ`2@jqqxNZMQB2Cltj+v`5~!cJicWOK!=e&6ZkQCh!GE
z+_}1?uebN-?OV6xta+2Q+g;B+^a|kBu&}ba#j>IQ+qZ8ziN&@ITs{k0nUC$>)o`_<
zqT+@;51aIg%{w2wnZ>6QvFMor>pmuLf97XvE+0E|vZVFRloqCA(yJWQ1*S0tzfk_V
z=)d-s)qJbX_})J#DNIg&{5SDgQr|PLCb6{=FP!V^|3?;tHHv*&=$Rp>)jl))p_9~m
zE5=`3tE40(0vKHyO@A<Qr+mHlhOywlA<H>RihqT_aOM{j6a+9Y57kKeZa7_&;r+J5
zGUAsW#tL22dfU_1)+WM}f8)jV&7rqX-qP81n60pK_JMcXJvQiNGc@_#f4s2xse$pb
zt1dcGB30e{4UCK?6-q65e{1I%Yn`IU6NRO2`S!Mamwgqt?ikDZiHr?uS{r1y7}?p)
z<18=uWwzV$LHm2P(=$IXGk7m&oE7#yTIAZ9%)BFuJNa_Bd4H#{Ue9b;ci3iY)3-^7
zEf+3dw#?`(=aVnKljl60u6~~3wv)S(U`v?u!T?>~{JhHwIgbldUSyce$_!!nwJS1P
z^V5;X5f>!x-MxGF`i~9Yl02-VHZ5DeT-4^!!vbF2q=*Y9zMoAth<<T@wPoFFul)Rc
z)3fPp7EePHqF;1&a<VR{t*x!S%CTqPzJHQ_^`HO#{uOkQ|7ebT@tphaS|2<wSYA*K
zkX^z0Jo$<7eaHO59S+;(Tesf`<9fVd>g6xb<rjQ@^8EghL>Yr6d!;UgUHD?#man>V
zpX;}qxAUG9F5K67{N3`)PqsG2cuz7Yd%C*)=efkqbCy-EE#N<#(71Qj;WR(#yeF%a
v9~AwlXZYmLpn{fz!P$Ab@`rdvHU@dkj4N-W!`Cn{Ffe$!`njxgN@xNA)}||D
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/btn_arrow_left_press.png b/fmapp/res/drawable/btn_arrow_left_press.png
new file mode 100644
index 0000000000000000000000000000000000000000..8b72f0a72de293367b2c9088e4b550744f38714a
GIT binary patch
literal 1545
zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eU<l=4V_;wqWp97Lz`!6`;u=vBoS#-wo>-L1
z;Fyx1l&avFo0y&&l$w}QS$HzlhJk@~wWo_?NX4x;vtxZ^LPd_h-?>?2mtOW(whZZw
z7n7oIZ~6NBVAL+_%?<~zvBx*4O4&bhzoM}+*SAMa?U+g35`8V5z~r3Y7sTajw$++_
z^nE;AN@s1?!TxPi`ftvywk?0gcjsoTn96~32j)IWDc|?t-?RF2JD<m}J(x3j>z2Sx
z$IN)wG@5Q;yLLb-f;l?@ne*W4_M=_=3=W}en}V{lO?WnhhE{Z%e`LA7Q1znFryCZx
zLQSGMcF$^H&5?P_w<T;#@24N}8R8e}+-67V9<Y1EXY%^Y%6C5BPQ(Sv*!}*>|NQr_
z^Gz)Bv6)j}8XZnMS94?L$+EjilMZnxo>QGvyM*)L$+H>eC$p8;76^Q6-ZJ&=osJF3
zE0hm!X0v-_^*^dmR!%`@)d9yF-{qZd@TwIGOnbWba)5I2)idvx1%_I1{J!@$>|21)
z)W7Ug=elVx;4HnqQZd`*>eA*7>hCvhdiz!FWW1wU$h6ywR(<&K=RC*x!;CjBtACH&
zE9*Jg`nqb)z3$lXP!qYyzb~@z9oo11_^Y!jKJ(<KuhQD!6!~CY_T(CsM&=Fi`!?Tx
zmAU)ilh#7jG|`Cve2m<FPa3)t%9Y+!g?yV8B9=IFv5LB=#A9);iA-UMxA#?4@4lLQ
zZRyO0)NST}cbwX!u%=!;ElYtlsQ1kti3HJYe?M=JS~IUCx9jGMV`s{fk2mXPe%(>N
zU2)l6r_kRYZYU*K+f{!q+kAYDCuizTuGMKzZn}jB&Tw-|6y5guviYpbwkvNq=Eb{;
zS$;KG`Nn6`Bh?2o=b5=qALQG5NGs?1h1b!S?ylW3^=5d0PwBkWck23#VIs?9(wEJc
zzr|_g2L9c_2l(W&og&H>h)mNywQ1*U+jq7i3v{+{U0<|yfvlXxF3YRc4K`<%uRlE_
zw7culACq)tt7zMHK8ck5xBeB{AIs5xQ=T)YYEGu)cAqdm?v_v?(+dU6`LBFczZw6I
z_c>DObENP2uI|XhCHIUcy>4;4(QvdO>rROB@=(bp)y?Pr>qSSDiY^mvGt&(d_pdL0
z8-4KH-Dj~|DgtJuOx+WD?aASwIm%N!xtpied_U!`{PoODmfE$Y{6eozw5(2hap{Nd
z>yI^MtN0dscPIKT_}et?jr<Q;?KZa;))Ms%%$oeXPw&qCyg=N+L$qv(cmKk_8f-W0
zEwT*mdC2=8fB)D{ezk$E=ElHh)f%GPmPQBHuW>J4tP!AWlX&dCs8{gu=4Vf*e5>cu
z*dlPRa)$TR<xGc<yxn?d#X(Qz+Dl#c-+tOLGyKZsy39zHlc$-a6MdrWzNCEYOx|f<
zc!T%D6w&+YQmXyh{U0TLQuc7f*~ln7JbUT0qx2l}gO_JMiHn=zAh71p5haG1u?!4X
zw=YbY$DdnmA#Nfg|BIQy?6C37BXV&DclPU4be;)R_<N%-F*5VV*3=i`3|bn0rM339
z+TEUb=dG6RtK4b&x~Daml0Pz;h*h;dZ?&^4k>t3;bzXMWebp&!CAsfzIA$>BNX$DW
z7*J97;tq$C$>Gm)J9l>&ds-ZgUA876h~F&hz-Nc}B`n)6iSH7!K47@#-pz^c-X3le
zl$;(X@#TTR(;DqP6+7yzEsXrRml{SkdPKz4dn{&)5&Y$n7oowcFY9?v^GD3myU*lX
zO?yr-h0odK$HVt{N~!doKN+>$i3X3a1+vfM{#AW_FMFNq(%BEM9-nmkj<?GnDMR@i
zomvH{FZ}hGB+f3`zdLdE1Dn#kH|jPuofYf#*ZyF8C0*eCAxY{4&mOtAZd=^8#Af6s
z)%wI0OTN|KxI^Lg`ONk2o=ps@&|CVq_G8s0ww?dChg3AJ`M|AvnlXmwZN2!rXzla<
zr|ha%Nfqvi(O<UmugT>3rk`Tsb`^%k*~Yw*&=bF07vp^KFvpq(SJSrBnrBxFuI3J^
q(9QW3&tQVBG+gic;6IB5L+brmogM!+o@QWRVDNPHb6Mw<&;$U)yxhS6
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/btn_arrow_left_selected.png b/fmapp/res/drawable/btn_arrow_left_selected.png
new file mode 100644
index 0000000000000000000000000000000000000000..6cd3c9fa8bcd4d9aceef525c01414d8f782c5cd4
GIT binary patch
literal 1581
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
Y$?n329Vd+#7#J8lUHx3vIVCg!01lhs^Z)<=
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/btn_arrow_right.xml b/fmapp/res/drawable/btn_arrow_right.xml
new file mode 100644
index 0000000..1e37d0a
--- /dev/null
+++ b/fmapp/res/drawable/btn_arrow_right.xml
@@ -0,0 +1,41 @@
+<?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
new file mode 100644
index 0000000000000000000000000000000000000000..ae6fd538c53d6c228c15079569b1dee3905e3dec
GIT binary patch
literal 1228
zcmeAS@N?(olHy`uVBq!ia0y~yV6b6eU<l=4V_;wqWp97Lz`!6`;u=vBoS#-wo>-L1
z;Fyx1l&avFo0y&&l$w}QS$HzlhJk@4&(p;*q~g|_Ig$Rtfg;DPgI7gNKcX7AIN$DP
zPEB!Z`Zl3`jMW~@iVNG+6<M5a*fZ>z=y2#$!j&CrQoan1Vvd0q)rC#77HwJC6l=45
zp7*-PTS{hri#s*<$$ZIoCAa?lvj0A>IDdJ@!-5;zW}DsJcG`?}O@rtLrmzEC5scai
z$eagnZWkH-Oq#Wfv+>FGw_kGFMPC`5=fA~l#bV`<Yj?paL)iDE*@L|cj2GBk2+aD;
zR>e}q{%JX{)MIO5qaD>uPvoSecD?`p`>=*hn;HKLnGAc|b46}~2Q2dDu*QD>S(7;B
z`s>~|?Ck7<zh+&%@aMOH;H9z&lk1h=>{zo#NB;ZMr%&H(TpiZFog-oH-aHKvqh0%1
zV*>*xioK9=RNnG;|3251-Il%e%bBCDXyiVYeHNScbJvzFCXY%|Q<pBi;M91Q&D18%
z&-lfvRa&PPEG@qAV$12LT@K;l;n7UGx(58QK|w-|>sGGxl#H@4$l5I>b96y=c6M-+
z80VUge6x9D++I9-^r&Ws+v?S;FHdR}<6Psu`dH7090ld&p9OBcEmLRJz4P$xuZ=S=
zySloDf86!!*RPg^tyVHTY>S!PXWM_iP|$nr!i5FuOna4O`mQZ!{KeH)o}8R~$B(;I
zBJtu=7a21raWS#Dw&xdS&6;JR6&-)HNsLb>U*7CD!v@~<>@U0}?#cDDAGUVz`#*`#
zLV)8&#S53~hi+Kj5f>4Oaalfl_Uwyy&oA&#)9a2|w)Obtf&+E}#v2{`IfJgTR@|Gs
z;P6E;{v|ICZ<Og%4}G~S&*Y+G@P!L~8a6^NkN+{Vv$J#6o-b`=mGk_t;XJ#XH3xna
z3kwTh*45QDF8IOoWU862WMi-1tgV}q!;1X;{LXFJwoU1U&WpWkGEd6o1|B$*xNlxs
z?u~NBvTbYE=Jq9oJH%@)X|_J}Fe5RiL@sgR`Ey&hZ&!X{k}>m=VB6<qQ}~Xr+H$5y
zck<ml_ZvU^`ud(1WOX&iE^kuSNL_mL`K<^(>4l7C3pZ~TKKw(I{WtR$W3e?Ne8-LD
zpRsP}j*X4|T=2?s(S}RU6W=Vi(OEK2wW)Rv&l(fH*-sPA3=jPCay?q)?|**L+xO-@
z`jZ-`UQ2wYQ7kbh_T}5Ru?@le!HuGPIbm8x9(NWqd`pdwm$&+@5E}84i~nBasm-hZ
z{{8D+@M@muhC{Mur?<+y$!^-4EV?E{@$BKg-rl{E5)uw4ZigM>VlT6h5p<C0mHhDH
z#f#{sy{V>aJQ8XiSLNls3(M@>aQN`yY=L7l;`5uPt!We8d8B!}My-UTWMr|`Tr&}i
z-Pi8k?cHF0iB<Zg)y!X|n%Cn$PFtG1;Io4G3z4n$EO(b`&Re?S|C0*F13T`um@k%P
zpUWn@@ac^AEWcXQY^PajOGT(p7yPA=A-^?0V8!okvmY&G(n-3&b(ux>VBO@$W>)u9
zBH6SLYxF887MUDatJh|EVa@LAMrRt+OHNB{(D|S3@R!8_En|ao`G-7~f650K&i(u!
V#eL-9b_NCp22WQ%mvv4FO#u6oG^qdp
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/btn_arrow_right_press.png b/fmapp/res/drawable/btn_arrow_right_press.png
new file mode 100644
index 0000000000000000000000000000000000000000..a4ae45b8ec161f20a8ecfac34fe8b13dde6c13e1
GIT binary patch
literal 1634
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
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/btn_arrow_right_selected.png b/fmapp/res/drawable/btn_arrow_right_selected.png
new file mode 100644
index 0000000000000000000000000000000000000000..93bcc779ddd33574fff531c31c958697bc00716c
GIT binary patch
literal 1663
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
KxvX<aXaWEQ{1?Ii
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_btn_forward.png b/fmapp/res/drawable/ic_btn_forward.png
new file mode 100644
index 0000000000000000000000000000000000000000..0936fac4e49aa7fc5879b869ec189c38ac509245
GIT binary patch
literal 1228
zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F<YIk|nMYCBgY=CFO}lsSJ)O
z`AMk?p1FzXsX?iUDV2pMQ*9U+Sn@nw978H@y@~YCxtu2Qf6|V%XD=l>tKZaOx4Gq|
z`AFafqrbM$o$3fJ2k)(N%d*%zCNyw$Zfj_%dK#pvpynv(;Tqg;yMFeO`P>|fWoK?N
z$keg)$qwKyQ@pb0`_tk_E~Sqwbh8h7&bNDR`SVZR``>%-e}B`ab6P3-rzjT#3j-4a
zV*|s1G*$s7?q=5;AGK~+o8@sbNLcWzZFsCSgK^s-hlts-4(vC+U7UDP-R<Iwu<9!(
zSDp^ue&D;%nUvKRKOH?R?csl>s$HY|Zr7R#fA0TWdGh1Q%MWfdZsYAqzH(~|gTW57
zdCxmnt-A85_0P>KD?_CISRb@I{CRB?M?J?<2Z2v|GmlgyM{qW;ln*ZcmHgM+LX<T-
zU$w8Gna67Ck^ZUA^rxwXxU{Y?6g^q2@HzO|x_=?}nctlYb7*<}!*ZFzjHTymBc}Yj
zccjbo<r20%M^|_xZIpOuxliAC?$4*k&h$D*yz$wn^m?h2$&Z^eZ|>b$Uu;{F)R%hc
zF~^q7_Qw;}y}thVqs7v|O4A3{%Q7duk&g`05Sex*?(3l=KRYd#1!$kum?F)vXO=}t
zjt2Y8PyTg%7ng;vWq6=9<<QiVsl_Vu&nNfBFwNY1(m^85aR;Nr%->0G&fF;Woa80`
zHTu8=2D?+j+g)b3GE6+Z@XVv{X_qg*EG!T|5NEt1tXXEKn88xsv~_d#ip5E+kalnl
z?6{ydA;)aC&s>jEzJ8wgD|}h?h64Gox5}4l&v#cVT#|I;@W-gM^IMN)FbnT?*%j`P
z%d>3#vifgYn@br3zG_VBDwOMsJ;S#pYt7F-jjoV1R=*dgW6qvQTbIfvbuy>;R`i#G
zHxIw(l`PUe*j;w<yX~IuAIutl%<AmoXW-kqVe6feJ%8)meqEWTzuw~ZPQjKds->^`
zzgVv^>@f*G5_(i!?C2`)n~XpHzFCs-)^fT2KK;JmE&t<IoC)78c4O6==g*DiW}SQ7
zr|Z(1{&D@I!+qa&{}j~_m;7n4SogNXo@JSyrQ3haVT|}1%j{Q|_u|AiS&llnCVRev
z|2daWd;OM`H=IG*V3wr&!?i~f*Vk<qyvkml!(;a|_LImC@x5=3<!L7bo)eY)Cbe!?
z;f?P7a=8wr>l{9)AN(D^dM%6I^{z!u%4)0kRWEcco+z|nL(Gb-N2^NgqfYHn@fH_u
z?wo!0p7HhE<>Ga*H@K7ezi0|BnZ%I4Uir+0JP9|Byr^}vPp2J?7q&6s_Wu3-?SICq
z`M)1T6^Z0{zui(Re(l%+ml_=gx822W?%a64#XvAdx}ie*LS*Gc_j~^@%fI%|yr01z
z@ge`tlS}-qI@?|-&Nsg&al-739n%8shJ%OYgV;9xe{<rY@?jsf>5(6N?Z2!#p0_&f
z3v+_#`#l#jy!EDVg>`D}&t$$O$srg0EW9@=Z9l`cuc{nOPxq*JeLneqrH`1*-+k}d
zW289`Y;uiwH6`Oi*P0kl8DF2x4|w&Be%3QNaIJNy|L^o}(r(4ilRNW;U;oQ6tl06}
r&_3?|r~eN)pqbpC;XpMb8^e!76@2e+%fDt|U|{fc^>bP0l+XkKP@qWc
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_btn_forward_dis.png b/fmapp/res/drawable/ic_btn_forward_dis.png
new file mode 100755
index 0000000000000000000000000000000000000000..cd9a2f5bb8da3cb15859f5116aed80338b2fa739
GIT binary patch
literal 1182
zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F<YIjKx9jP7LeL$-HD>U|>mi
z^mSxl*x1kgCy|wbfq}EYBeIx*f$uN~Gak=hk;1^hAX(xXQ4*Y=R#Ki=l*-_klAn~S
z;F+74o*I;zm{M7IGS!BGfrZc0#W5tq`EA5qKPg9%bz!U52INlFUAgJfv4l&zw%U7m
zM!D)IWG_-U#^vjCU`dtcMDB~Tr1oxCRIF{aYuMuuzd--M-de`^gsOdsZ4Z`doYr%j
zq-r_yZfe=H-{<Cho;!1I@$sLQas@UIDh_;Xc-&}Ku^>jTeBxcz-Q{Iv*W7dUBg>_i
zWu2eE;D3O9h3vv_oHq?(?FE+Xx@Ek&ck!XuDP2Y@=IoBmGy9tLYQj7B&W7$a?Aj@h
zOTO{5<_jmpCm0=I5@uZ1qv2D%aPFnzsq^eb6icf;J3dsd^Ue0@f2AYBW0>lb_-aSg
zvj6i08x@}%UmM$5#nkzf#al&KXOlqUs~M+4*8h6`;>8Qyua!DNcm6#Q(_&J6Db~sE
znt4k=Ek!t@@kr8C2dkNB6Emi^9DluX&YU@C6i%M}l^d$TD7C5G!flV8QTCU6!A8Eb
zmk2~%v1H8T(3}v^HnqFLXdl<qNnEMkW=^UZ0pEYUs;a0ft4n@&I3_Kx@r;YN!uF)@
zjk!lx$EYbB;#^WuB;5JncY>cl+ncCxjg3q0-TN2E#+h@o?T*d^{tqh8Disc#&aRD2
zzvaDlRlwz2f)gd0AL~pOSZK`0?`Z4v@S3iX^vZP&DhU}M<v+2g)YRSAS2FPX%pWx=
za;3tB0=@>DjFTKH4gbzN@SNXyMu@XCL|2@v_4<jO(?nOPHBM=mu<zCp1*JxlU3n~1
zrgW@tS-4hR)pG~?-KmcsKQ2%Dofx-JY8}IYlUFlJYOiLUEPr+1^b7ylu<%31k5;<a
zyM}XgAK!B3mYfsYgcYpettv%)Mz5s`Vqff<ClI=Od1mKY!38RAd<jmLEB9<G;{R~$
zyT0w>4NpUF$FCJlGQWLYh_S*segWsv1vctAd(8Vn?d^o-$lS1EtYBcVs91A^cN@ce
zujN`hWAY+TtokYNh{fZc#Sdwt$S(~0er!H5^~9Drr(_(IJedO6CuC%MYoD?GuNta1
z)obnbrYfeWfYoh*GY)ij<viUL80xO)@j=9>&iiUao@&PZbEj?QhvaGAx}dZ@;K8QZ
zH-qOq(wTqbNgCgQjqU#Rd1p67HmB=PG`Dc5vioiNdv3$+;<RbEU)I>kpL<#?&0ftu
zbMD@`Ju|m`Si52C?%lh2-#0PvyEd#hZs^xNs`rim`}GXJ^&GJ>v)0U=`qt(`g7b;P
z1yK_gOyg!2J^mx;kG`d<=K;}8zb!tR#;#fSnnR!CwOR3$DYZ{03VE?HO=1yeVVWP|
z8Pat$X~M7D^-K2j#TfthRy}-d%{Hz@8q2~j?f16#%3tCCoA2w{hCQqLCo<fhbU{vI
z>ole1#WVNZogdmF@_PeQM`gqLycFwKhsFMHvG`p0OeS90X!gv$-&=0nlrL{>Dt-67
pbhXlhJ@3IelkqsS`J=}A+eteLJQuCpz`(%3;OXk;vd$@?2>_D+7lQx*
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_btn_onoff.png b/fmapp/res/drawable/ic_btn_onoff.png
new file mode 100644
index 0000000000000000000000000000000000000000..4405b437e59c37607c357c985529aeeefe094fd5
GIT binary patch
literal 1709
zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}k|nMYCBgY=CFO}lsSJ)O
z`AMk?p1FzXsX?iUDV2pMQ*9U+*!(?R978H@9SN`X2u+u;e||@Q@2jtyjl8ornB-oG
zUv!SOw#g^yM3U}tG0SbC8%~A^_{dCg-SL$*Xw$<CN3(13Pb0K7#az}3O5_CSwEp2U
z{P_EE)%&k+zFSxK?TLHO+kKGFW=`?@%KOiM+U|e;+ICmwtXtf1Y$_j5OjOR_zHQq)
z4z}jBxVX5~(9lrffAVc-_N>^{8nbInsl%KJJ1$<l=)7{}%6%>|v9Yo3Kj!Z#?$Ghr
zUd-6G^32jTOCQbX>EV&D=i%qiPEJl<S<xf9QIpq+smMIOjd5SG^CLyg<9)K)cQ>b>
z&-{2LRif=#iIr*l;e|V6j-)sCtY5L>$HHB^e%abAKNWZW^Bb3H$Mwky`&Ngq-xn4c
zdGo`Ii;Lye)zq|D8Wuj|bNsNsonL-gyVJr=-@bj@yu1AUzpsZ{xmm9$?vml=ZFCO!
z-6wA!$Cqka@l7v&U(Dj`k5*b58!vvjYn@<6gJE)Va;%5P+4tYGWo2cv8UB5mtnSa(
zG;#iiI+jQ6E%S~yD6$D<WoMTw?%Wr-r(&bIwRLoNfB$?_5!1wyyFK0AmnY1*wJLP=
zmM2eA_-9yiGVERvTq1pu;RdI8`M*CuzwX_;*VG_SCwAABu8rrPFFwS$XMWnsoAV}f
za@j`jEP84z;>ymbqN<uXbLLEz<Skpb%C1_!KHgvLXqy~w!}FJymuvFN*;sHk>uD`2
zVq#$azCG`5RF|pnnVj1e?>lzS{rY&ed48R+PK<Iw!^KONFPr}Pc4uGh@09ZL@>MP7
zN(|4O-|Q@YZs%B*t{1f>;~K-d-PUDqD(dg<D((Mh<I0wEUi0#0m7`e>!5Zi1<=)=*
zw!5=)=b?g%y>Z+upVT+6TlY>`Gc?_TA@<Q@*Vz5eU#58<R1jXZeaDU;#VQf@wo`7I
zg)$s!(A1f*(9z(d>VfTo4Bw&@-@JZZ9e(J+mPmsuPn_S}ckoOVvNWzNDw?#>X723S
zw--u<Gp-0-(8Tcfe8QLLu&�w=qm;HBLV#;#qI_jPb?$_xfz5VU-uFx7<GX_V)J8
z$Ng6w)9iX!z+l#Ka?+$p^9AQIGJUA95t}e?-aMwQQXvd}61A<qt%j=1JKi<-avJ9G
zOWtet@Ua)&B>m`}_~PPg4ZjL4itigK%oRSHv$f?wfb>Mu9EVIJaW*DKy%eU>cFk)`
zCi>_`Z+oL;^MA?}rZ=vhep^qTIq^Qu$|Wq)_r&xR!*%Chw?sVI_;UWNS&PyeIeOc@
z)XU!8sr+$mZS?e=Wv8d<)_Z+wJ#=kWg}lOS9^sp;4E{^Pa*pze^xiyq)K^(q`Q^i2
z=W9`CGY+@$eisRN7<@h}=fvWYSBnZ06J1VDwPbMmu%mn4?atOoG0KwJ%^S?ylw@qq
zaKv8aRo^68{o85M_Y-x&zD`=)3reCgW>g+vIXtI+>&A_RzEd*O+D`6iymsZv7Ac-5
zTwldDzgVZ66?C34AS9%O+2rTjO^N~<Kb_b-uS}FmouY1HZeH(pEBDvKIr2Y?l!X|y
z*I8Ox)@tmIzroGXz?@oBQ}eiyncd>-q$y^r+%0V_Q+<<seb2Ig*w+&3^!_DJiTV22
z-P`<MY8Ep@$m-bJ{}*}xrtOZ8fW%6R;;^ZoQ&e(}c;)SIx${Z>{!$s+sx30?*RtL%
zRsJIPg`JC=`}LBjXN)ss)mT|s*GlZ>WtlKx!h%8#Me~>$6Sh8m`gD2Ty*)GAOEV{=
zB&vGOyBsjBvikcwTgC(N#j}JM^xI5yb=U6OvgM1u<&-mO8|2D#wm+VJ>B5B%vXeHX
zWMp*c-n6PonsGtc{=najDJLgY2iQ2hci5Ppkg!02cR7RP`-y@!xBm)U%KrWR{r?%x
zUbm_=q!@PB?6H`T60^VVuTD?CjEqc*UIcGfdDFzOT*<^qH`NuZr*$Nr%1=#A{k>_^
zrmCrFscy^y^L#v~>&5=!(y8$f3%Go3&W7(71YFN`{Vy|<c*e1;u;oLwj358w_lh5D
z?g_^Be@b1l`f17Yb94WkJ9n;G;{5tzm&vSVI+pAaJQoz6+fC-X`|e$rsCJfl?yVz^
zCacbL{=8@R{IX9t-^!H3w=Z3q)ZF|k+90l_wv)qi+m|25cknYGd2eAG@2K=&x5Qt|
zRQ~2=)*9(m@$Pv`|IA73J@Zd!mKdkY=U=XjEyjzw)_s{c(;#v}(qGkmeg7|?zVPq)
eYk5XC2F_;^za@?wu4Z6hVDNPHb6Mw<&;$Si1|^&T
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_btn_preset.png b/fmapp/res/drawable/ic_btn_preset.png
new file mode 100644
index 0000000000000000000000000000000000000000..35449b308fa3d40d2dca57acf9db909891fe833d
GIT binary patch
literal 807
zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}k|nMYCBgY=CFO}lsSJ)O
z`AMk?p1FzXsX?iUDV2pMQ*9U+m`-}SIEGZ*dNciewv?mD@y)9ZLoRbMn!1^Mbgz?f
z%Isb)bLElZ1P>m?xE3#cC&dfF3opn`N}e4oxM%B)W#Yf(MP@CIaPmIk`l#Q<#nW|V
z(-Oh8yR-KxFKcltFk8EoU7pAKOmX_Y_h)~fS>v<$rp&A58=Y&nH8%VYZaA8BQG$of
z`#wugZ?7$rY`&VB+Pv3ae_f2@nouSc6Bn1JH1Wjr7`^iKQES__M!o%AWB32zA$wcf
zwa0e!J+^2oTR3r|pyKSaasiwZJXCZR>1UbDdjGN{DqcfG&d1mHW~$N6Fr%3|vwW7R
z_N+IR;+0&>(3Uu>xVYH=(Z`B4s~KF(T27wy-g7bIi~{q0KR>@MX0y+-lo!_4#_rs`
zTY9S3Qk%66j~_qwTz@^=W&3W1dCxmL;@y|r&D+0o*RCw5#A~-+J_%5^5!6&-mSN!z
ziEd!6n{;yGD`{zI>GF?f5`Gxo68!kPW}k8U;llWoy(a|^+}1v1b(gi%<<ZfXFIV2n
z+A8D~w@9{R#)m!+MteP`7g`H!e_Gr+9yg!)Olh98DNpngVU|WI=S}|?Xt2&Xzw4Sq
zwIHilWoy!&UZzz%{QUXTyq2Cn!fq5L;nX0(v-9T7o4O_YgE$MU=C&O^d{{-y(#dv3
zsMb}XwrHk1dE1R-_}n9>Ej_j&M$cbQPp>aH&>^R~I(p;g&5KutXvM4zOSX|azt;Pu
zOOi$0nQe*!d`+x|rVj5KmcLcsSUx?YVush!m_>TB)27Zo`z(FG@X<d9)g%24|D>z!
zJ?CwqdG$uHET;ntD^t{}xb>G4Io^nzIG1fw#Q3qIQn>Yd=Z}IVdZ|V;O@FK~Jd(fj
z=g-P29&s_TFV)r6zhAsljxxPbzTm#lhE1Cm@vt=qD*3RmPS%^=Eq6FT!$gXM#l)h9
zqey7~efz4Fi(HdEj6Q@L_8d)GWN>8Ksr0loHVM9eGk92HHWo9oF-$LWICJP?!(Ijk
O1_n=8KbLh*2~7YnG+b-|
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_btn_search.png b/fmapp/res/drawable/ic_btn_search.png
new file mode 100644
index 0000000000000000000000000000000000000000..7eea584a2c6299e45969bbdf6ef5d7d1b879cde0
GIT binary patch
literal 1747
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
U-@93ofq{X+)78&qol`;+06%R!3IG5A
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_btn_search_stop.png b/fmapp/res/drawable/ic_btn_search_stop.png
new file mode 100644
index 0000000000000000000000000000000000000000..0b8c4e8f99ab406208fd8b65732371c0381e7d1d
GIT binary patch
literal 2290
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
P7#KWV{an^LB{Ts5(ke1o
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_launcher_fm_tx.png b/fmapp/res/drawable/ic_launcher_fm_tx.png
new file mode 100644
index 0000000000000000000000000000000000000000..c6e41b205adf9eded727dba04cd4bfcd30907cf3
GIT binary patch
literal 3612
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
GXaWGI@Bdx^
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_launcher_fmradio.png b/fmapp/res/drawable/ic_launcher_fmradio.png
new file mode 100644
index 0000000000000000000000000000000000000000..2b1250cc5cba92eb9782af10ca0144702138d375
GIT binary patch
literal 1289
zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F<YIjKx9jP7LeL$-HD>U|>t~
zc6VX81A_ZDRQE72FmM)lL>4nJa0`PlBg3pY5)2Fs>?NMQuIx9t*#(5uFIjb{GcYi4
zl(<HeIOpf)rskC}d^<C3KLZ0xsi%u$NXEUlGva+Fhl?DjclFAiSf4ieVL;6f9;<-o
zho@L5L@Eia{NR|LB(PPB>&%M_FXpx1K3sA{<FJNE?3abFE|gt!S@J_ki)Yfw?mUU_
zwi!$&9ZTnKi_M(+&M~v$YDSXv>1&_Ae4TUq^WFP<pWi8d$1Yg8U1|2J2`ZV20em&G
zX~nh-G2$!_cd2;3=WO~Qp-^?`$X2Pq96^?c{j=`w?mkqoQUAKR$(MaK+xoQ^tMmNO
zQ&c=y^z6(`R_;ref({8R_|!aQ3bUuDr|W_B4(~%6ru0wOH~;^%=wo75mPK3j)m5RZ
zSM{(lum1e$&qI0ByOS-L1Q>tpXLi}Ymbq7h?TWOon#rOQZ*Fe3TzFY=`su&hHf}V`
zDtnuhkif9`<d;0gW9q-PK344AGW+a`>+8P0-eqN7`RU2YFC2;+m#{28*l_$Y<ALX&
z3qKxW^)i|Dk})76qT~AOrF+-%Hq3jM_r^>*n~VFfGJD)q_Q#2)!AloKh!{%oJP{Qs
z*toQH(xsp&Ua3DA_UH*-%`%;?AG_$?1;sUC+SylLy)5lH7qU`AOK;itZ@EV<1&MIE
zzUaF+@7=qPX__k*>1ie9<mhB<{O{G!Z)D`OiCb%G*Vok4h3k(L78W{o|G)n9*ln?m
z9{M7T9SklEP1oz%*G!%9!)a-d=dVSsA#ZLtW(n+z$#D62e<#0$uUd_ryx#K3^XAFz
zv#*#S-zUpm$uD{(%};Hzpmny`{IvAN**SAkelOZIY2rk|dG_^wul7{FS+Pb%+4!^T
z`}>y;UA-12!^hq&uFtoFId1)QdH;D&p7lyIq&$BXw6XU0lIT0p%s*=EWcb+UZqNI8
zvP*Pwj(Uj|!#vw+x7{~=oNH}+&z_Ajn^{qRPR8#=iHoai;rjLc*5&X19R41;cixjH
zDSmV9cn@6F4!2l-eRJjMX%AF3x{3VUv!vy1^!B8U5i9QPH2#p~;yyV(;J{+{euj+f
z+|<-CF|JmooiXPoE%j#p_dd;?z4GTz4G}I8F4onbKkvMFQSgt9MNIhdJ3EUzdwaj$
zc3TtXqbB_Q*RKj2n=_Y}`~Thc@Zm%AT{~{PEejE@Srwx7rmVW4KX9hcvFX*{K6r<V
z^UK?Oc)fq+T2(i_<*RnhI_%!R$iDtwes_QW@ux+5ua!F`Dd{c0{QvgLl1VdWNc^!9
z5EeeX@9%HR)z=@F?T&xbaQ4`w)YCKOPiwpVcG=FAC++J}!^EziNwbmTR}Rx&K5I7f
zud^plK8&iiUc7j5PhVfr*&H=>b90kc9X-2wYehx>d?{M`{motP%O4-FiQnFrpPlXL
z@Bh93?vkrT|NqsR<=!|D{`;Gux~1iU^SsjLMj0D7_^wW!9d`P{1%cG3PxHkjAM;OA
z`T43}Mp4<=SjBu(!U>0Zd$;DsyQZcbO#(mn$T4;>{JGA+$HT|>>Gs{-m$?#>v_I}X
zo2K16&oKG3Lw$Xwg<n}l#*6gnr<XFzv8`ebZBj6KyJp=y&FQCO6L&q}el0Df;yGzb
zlfsVWOeReAOq>p(Gni`F?yx@NZo1&@a>(Hyn^F6mpq+O!{TLV+7(8A5T-G@yGywqG
C&03oP
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_menu_record.png b/fmapp/res/drawable/ic_menu_record.png
new file mode 100644
index 0000000000000000000000000000000000000000..60f7a01afcea0bfbcc9f4c21bc5e3b9b4b7841c7
GIT binary patch
literal 798
zcmeAS@N?(olHy`uVBq!ia0y~yV31;9U=ZP8V_;yI?4Y}kfq_A?#5JNMI6tkVJh3R1
z!7(L2DOJHUH!(dmC^a#qvhZZ84Fdzy0Z$jlkcwM-LSsE92TIiKdw;wCcj0|6^Xbw$
z=IsI|CW+yt!7LMV!W+w3C7TmC?scWGG=?9FaBT}JQIF$kS@-JL>;yNV%`DgJW~mfU
zlg^f({o8h~@?DqWy0D4|4<FC@Z1=u+-}gQ5D=nQk{E{@DNcHvha(XQ-nvpc&Z1&b$
zReR&=?d|R3ryhRZ_e**I{q>h#fBo(f$RokS7P$DL%$n(^Q$@O6R|aU<OjgOv%FA2#
z=ekp)L&Aj|v;A9czkOa^U48N9O-@t&hHRk_i$g6FPNq!oTW-Gj=9{wt8e6Jz7It=a
zI%<8m_OvMT*A}I!Mez%we=_Wgu)2}|$|_*ji(~It)q_MiH%6@SV%0x;?%cXlVp8(*
z;g)mH`R8rly?_6OhL<0We%$Gw#-26L?7{C?eW6$_m&F&~R@l7bVr#B%nV9do?BOSV
z9-c4OC2lj)rX4uG*<sxsp`7)<A1cYrVVjbidMC^-n(JoHw!qa_xsolI?4~htJ>B*o
zc(=gx`;B*%AD<GMHE*7nj#zhlnxvIj9CMJX*p>758ww?+{|b<ebT_G8xp&1S2Znu5
z6?V@l4$bf~mFRVITzxg_#i_7p#a5@lu+>+;XfJ5{wQ*Iv0E@voucebxQt#fn6?N%h
z!56{f8Xj?zR1ZmRd2q?wV`)&dv$Jzq<VlCs|3VjEbh!N9S=2W&<DMkrV}o^X*4(~*
zn>)xUw6dC|G}>J2N}%<XGfGpouS>44-+yq&rq&v}_&Gvy6Xpe9(DhlAXnZkv^0bUO
zFPr`y6)CuOh|l8j*DCYqW7F<lO!QC@Qv5Y<Vp2_a&i#5XGoA30R^~Mgyq85c+5YSh
zv8z)%qc+pWj<fynp~QW+xC}3tzlpM&??25;)yes@bVdc|-QTBj`aT^#nOQT@!^NNb
zW1HXd-9EoB?u`GNF}Z8~n>TNCs%+*Rvj4vLziGvs3qLduFgQiOQ*Q8S<X~W6VDNPH
Kb6Mw<&;$T>%x~8K
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_signal_2.png b/fmapp/res/drawable/ic_signal_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..efe4b5fa48572a8c9878a17b315ed70458851599
GIT binary patch
literal 1358
zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}k|nMYCBgY=CFO}lsSJ)O
z`AMk?p1FzXsX?iUDV2pMQ*9U+SUz~VIEGZ*x)K(fArmTM*Lk^w?Yfolwq4FqXQr@h
zKG?KUX_?!v1^hy5m%9DAxm3wl>%_74S+AU9yKlKn6pDJI*J!qJflElwA_XliA&y?%
zEumSP7o;vXT)BChqOlpbv9Hoc>&@1)_vhW%5_?oS@7<ZZ#@}nc&v{?-ecG8bXD-y=
z^qR)J;N`_-p(+zLCER-Vd&~PnrR)sp+8#@+T^!d;bMb6`>}4}OsYH6-$(dyx%T7wW
zzsdY9WBEn<o<H-H+E9jB^D<Tmxqhs34SD4f8ME@v5`lZgf4zDcEiy}vD;6Jm@;uWx
zcizG3`uoRg)47-!j!!Mv75eS8Y1g6&I;T~BxlCf=ynXgf#mQ;CEpKn=NoeOzth}gl
zdQ%(Yv(GgSF$@pW5B0C8E8V;)YGH%D!zBMx79!6qXB_%(|3Ia;(8l_8bF8JCeNKK1
zi(0NRgOQ$8%90-Ws{61176>+6xUA?Hy;wHDw6s-8`}3h50kw@cINxYp+_U)SpCHB#
z`M&#$I8MFoxTdydW7#<=J%QNkp7zVPf2+G-y;Xy0?r-b+Y#cZ58kTkSvk7c_uXNu1
zn9bp7&!Z-AuW|?%|FP{r-@_XVZ>Z)kdS2i!+VNYV;Y#XtmD-T~7q)GFd$sjItIjFr
z6VZ!(zgZmncY=H3$2GyC^7pw{TebWO+cwR0rp!Ub!l*NX7m9SYJ<YFkv%gon;<wJR
z%^%lQSUTh!+1ygPUw;SB;oFC|d#c#730*Ugyz9lFDE=|YZ=dCrzD_NV***sn|9p~c
zP?;9nrh7Yj+kwc%t5%6jFm6d%9$sR{&SHMq(D-Rbo&=llhvV<cclV3%D9CWF54yhM
zcT>~^mB?ATwg>M%Ws&J!{GadO!vcQ=ucr!g<<GxPc>Vp;SwTbH$vuM2o!_N8(w{IJ
z<on-voBHO@rbppnN%C=h!Vzy~pXfU==^@L<YmF8B3>WV5$fTaV@3-_=(DZ3jo6c>w
zTK%NqkHCVzodJ9cgkrvY{QHsN#B~O>E6IuR*Z$;xaXiE8Qs!22UC(*X?+EENhO76#
zUApawsjQpE#cF|TwhxXT?#gGB6jWKqz-R7JA!977u~mQF?aYo085fhNg@Q-4G=HZ!
z%_u&}EFL2e!?>nw<wX(gd+HYahu-FI@fTxKkYB$tIp4i@gW8Q%tfuDk*EywmKI`4Y
z;Je^VC&xX3@V*%W^5u1fRS6%znld{4{l7F*Dw9z+oz<^~JMvw-^SSRT&$I<5vMou`
z4k~WeYN)u{acspzEerNJO*MaCJh+&vu{8PQ#3u(A20Oq0d~>c%=_aL>>hbMw!+$)x
zx%67h4ex*9;hV0BN3Rxmm-gYI-kxb6JvndI+JEzVvwRWrjjh$!C(l|X8_2xs$n)lE
zo=2A&Yc{{xcjsT)?|q9HJKpu(TN#>tJga$YYE9xpX`z%Gy3QK1FZaJRnIciewe<VN
zB1Vo@iIv$`!_8RCr>vZs<<}DNUi8mKy$>?0lKFk6^DfvTpv-YmjpI^|<sr*27p^k+
ze@_gSzAGIYE5fj2$-Osmez9LmpWW~HDSJT0RVgN`)|Ihg_N9P#cgoZHW8Pc-mW~fQ
zFV4!4XJr`vJ$-KKxyCgrpF{7=+pxRfldl-7!{cYi<Yd;yZwh{Yel^oOjpLVBhG<op
zrba}qNObbgVeHT-vzh75ZnZ8pR^xE*!rX-?7illN&c@DmeY4Ot^DFazgfHD8@m8LZ
Zjp5w86ZtJghM>}t!PC{xWt~$(69BUKf&Tyi
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_silent_mode.png b/fmapp/res/drawable/ic_silent_mode.png
new file mode 100644
index 0000000000000000000000000000000000000000..c89291a2073168c418a91fb0045a0adb5dd8c09a
GIT binary patch
literal 1362
zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}k|nMYCBgY=CFO}lsSJ)O
z`AMk?p1FzXsX?iUDV2pMQ*9U+SiX3=IEGZ*dJ>-Pu_RQ&?*18z$EkaoE2LY4E>B~1
z6#oCli)&?qQqy$#Q<E+%5}Eqo{IA3S#hH4$^lqkwbyuF2{u>dYv;K$o^ngTHb(N`C
zuk5j2Y<$k#_WgCsPnOcAuZ?~zX4ZfHoA0^x`|5emEAJQEoqSocX?2cN+0nPBm@mYB
zvhHNp|5*MgaNWw4g|pB9`t{43eZj-~k`?-g{SwP&9KI}ap~m)1eNvLrx<!i?$$zuG
zSDO&!AEcnLJoa~adHH@bE2}F1X{o^p2@52X?-{&KHS&7CtXQ{P=)$E-llE`f@}*Tj
zs-nWe+R{?+wZ}XMheyRViH%#gZZ-Y=`}g~nmX?gB=4Q!xS3loK6`T-q=+dgPBEH|B
zJ{3h|XTMHgzI=JUo2#o~QQp?5nccxF7cO*sbl=m)c+S<USI-?gb}aqaPE9{knK=7<
zs{=3k`ue(l|MJBo(_~h*p`oFUf`UUK*T3^;T^CgS^N~z!E}ofxru#eJJj0Yteb!&J
z_4WUY*0x0WuD)utH|{(STXWLJjT_J0z8zh-g0DeYVb1R>SFhfUiHXrUb@F7Uj+WN1
zUh7NSw{G2QWoh{{E-LEQ^w7}Ie#0^!My?xsA3uJq{O8Y~8Ghf*8E$O+q~kd$>B^Bj
zSB5K}88Ue9FI%>3_UF%^zn?#Mu7;hBE$_#VA9qfjKK*;|_U+%Ne*E|`|7}_IiyJp?
zypCAEXVa#lt_uQE7ZQz{H_R98Jaw|wu#th^&)US~%ch$-`{c#Mo_S}lUAxxx+t;tP
z+js5yb@I)dH^&_v9T&RX|MjcNU_wPhr8yTj_u1z)yFdI~@5|!q782Oq(J?_-SU6Q*
zUw_;7?aME0+q_x0b3s&qw#3pkXVa417EhFwmp{$%B1vjear@ziWeg_a5{{gC(<e%9
z-}rcaXW!z*%Fo`vUmu{kPqF3V`(?|P-8*&WOpRBb={gRZ^^M`jrq)iHIMGm2Qu3$X
zG2N`Y4#HlylAiB&SgED0-Ob`JdgkLH#tV;D3194t+Q@%nt;h_AsSB1b+PYyw0ZSL3
z3-68siIs|_*F&~U6yTXVckXq?J?jJJImbQ^THtWt%AGrRZr#8CU&ub(M8BuuMAO8H
z6IVQZ_>g^t=t6-dhio|~8Z}*--Lp#Ln6Ip?ti6xFKl`O}tLs;)?&%09F`scPEG%RU
zS<{hU#3%S}md~=?+S=MzXC$ep2nh*Eut@FNyEj)P^1+j<r`{^Kh^+_;KX>k29n*37
zoZQ^Ijkoq1?3+DhO31`{^Zv0MWoLhJ$u=ZR`B}uI$&>H9Ev?b=GMrc;B`dqP$yx2#
zRY8}de0+R29zI+c@Tb-3$Z?O(YfVi}^6c#FxdJhgpZ*0~sBgVJQMO-4>~!?(*|Xm#
z|Iy>Rpl>q2#yi4iwN($#p9>cDLS|-WD{8JSTCvA*XK$;>@e=+83pOYhS65eyJ$v`T
z;Y-YvFFB8;udF;KTXRS4Rl}L$Nqpb!6YE#xFbnEWoigPP+jRLwRgo*^1bzM8E~NX}
z_2mT1mdF=-*Q|Ndb6@i455xNK9h3h(7E;V}Zs{pZOMCX~&Ye554mG?n#zr0f3L8SB
zqOwZAD_y#J_35>xS2Ta9wgd$Q$vuDmTwLkwzJqH!I;+k-x3I0$6b;X3m$}{D-ECj>
z<HJLVkiV9nYT_MUt@K{0Ep_B=WM1Aoe~Y5}W2L_OB5z+ZxCrolRBpOr+tzv5V;>Le
irT_ol|IlY-W0;nks2t)k{X7E$1B0ilpUXO@geCx{`Iu|~
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_silent_mode_off.png b/fmapp/res/drawable/ic_silent_mode_off.png
new file mode 100644
index 0000000000000000000000000000000000000000..4748b9ed7a6c4e2ef684286a5a6a352ab80a912d
GIT binary patch
literal 1555
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
Xy7XktB8v$O3=9mOu6{1-oD!M<X{+7>
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_status_fm_tx.png b/fmapp/res/drawable/ic_status_fm_tx.png
new file mode 100644
index 0000000000000000000000000000000000000000..29383c9d46749511196cfe3591da9e5acf6f3f43
GIT binary patch
literal 802
zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s77>k44ofy`glX=O&z`&N|
z?e4<x9|RZdT|SwCfq}EYBeIx*fm;}a85w5Hkzin8U@!6Xb!ETF!z3)F!V+}w9RmXc
zM~Q1hiF1B#Zfaf$!?!cj_A@Xr^?ABDhFF}=owV0`Q=r7L`u?bdj0InKodR9rT?BXq
z1x;2q=AGsH%NXeB=<V(7Xd>d`y~T|;H_*i7OGiSJi$ec}02ikzSDXcHi_ZP!+js2t
z?CTZhcGkyyFO_w6X{lFHl4x@@4c+}Yq*_7g$>&NrIk^C@i#Kj~R99O!Iy?}6!S0~x
zsy6xIix(Zsm#goI)0gXKzrAhc>eb0PIXx9NezmoK&5umjbRlZ<_U-OQGgA^08Zu10
zG(-+P{urPmwsX%Om8o6}rzEAOKE2%=cv4~V$qjq=`dY}S33X05o3?ZRes>oRwq_na
zz90<|3mcmyTenW#xzmy%W-3pAfB(z3Z&jswi^|H}f`f(gw$Fa{EKTP4!T^m6*RCDA
zaz*6&_3L-;-kr+WmiXb{zjL2I8!Ia--`IBc#}A8>DU%{}j=gxHu`r<H`t|U<{Cr6%
zsYTniO{=l{Z|%Zx*q}g$egFOQuU=_w%Qd#O?Y;imRr6^5+UemRe%6?nm`w0n&dI{G
zBuMj5oxQxg{FW_S3W|%HgS!6xtJ`!_r|<EFyLbQI-P_R-6C3NPG;u<6GxJ6r@3!{#
zr=LFu%N(EB*~w|>8+_^I79Aa(6UUCZrTWxe&6uV3{Q2{kn3xBje_n|C{PpY6Cr?y9
zR>%mhj7xUi7}2wRyZN>2*EOel?TFFaa&67pwShWfhQ6Pl=ZgqljOy+<ap}^eoV>iQ
zjuW3gecFEZ=uuZe!J9X4PW<_^@@M(63sK#P5_9Iwn{@i=jJb1J4{Xwrla~+lx_I%T
zV|uzeLv(a>NolEIr^_il7Z;t=N-}(#_wVmN{gi3JvSn>|@5bKAGdDIip5mp-u;rSH
z5T~D?-;0+oHJOWc%INFsXRNI+`y(Fq)<%No()H`d<wJf>b+tbbD9ymYz~JfX=d#Wz
Gp$Py(LuUE_
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/ic_stereo.png b/fmapp/res/drawable/ic_stereo.png
new file mode 100644
index 0000000000000000000000000000000000000000..b9bfec6d04d50b7053f77f430e53cdba103b1bee
GIT binary patch
literal 742
zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4mJh`h6m-gKNuJoBuiW)N`mv#O3D+9QW+dm
z@{>{(JaZG%Q-e|yQz{EjrrIztFm-skIEGZ*dNcKW_M-rS<MBybwq@~NT_tiPV5!^^
zf&a|>_sX^ZF@B4RUi81g{)582FZLIT^~(egIww|tS-~!N<dz)E(V)%?-x6{+8z%+_
zwdS6E7dK6|V#1TNziaN#HaA|V;;B@Bc}0EngEwz_j3szBu3fuUUu|+{d%Dx*EjHhO
z{kk>l{PX*A^77t0WBg*G6()M5tO;BFplIify?bpp?cVKuCe1ie!fjr>j@Xlj4;y{d
zgbOWX()|7Xz2}R0s7+2?ep%Am!b0Kq@83o>#l@Rl14FpW&NXo_zx=YILe1abU&D#5
z*-=%hS8n}*00&zZM~!EnD_6#?_r8Ap`lY{rYb#Bp3QyOaO`H6>Z1>fV6+L!A`|nTB
z+8UL1^Zi{;g=dPp@BW+nyt1gG!eiU^?fnn;ep>ClXV0FVLYeTi$Z2QNj4$PFZ=UF}
zWa*j9S<icWd$-(vs}{Fj{Nc_12N@3wb}(HKn$vV(uHgLh)5Fg1=bSTVPQe2Kr^dN+
z=SDZA+s*Ep>!*JE^;ee@8cCaP?lY6(Epuhi=PhSQ@HyIDT4X!btJB=vT)e!zyl5I@
zbG+b%*I)M>O*)vPsIRZTu$0?N#8r-Moh#dSKLxpdaYda>ANL*XOfOGlYedN{YRH}#
zxGrq9>z@-2Z;bicl^=fp-Ff`6qT6D@!&}W{ofofZJ$3w-=bZWT&r4)5GNti~iN;J&
z`w@Nh&^uAX9<~_`Ohwua0w-(PRtI-$wk}=cE@lwvR%^1hU~9*$MjyAe|I{CxmXW&j
z>ebJmk?;CmEa<t<Ink)0($(4Arip3i(QB*UIGoO$Hd|)Hgi052E>=OSL;<%ltGQht
zgb#WKHaGkzetyCs%s_yn<I4Z}|J=VhH!w1+PHnsL{-Qi10|Nttr>mdKI;Vst0JC3H
AvH$=8
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/icon.png b/fmapp/res/drawable/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..75024841d327c4fbaefef7c8e9c8d0e892895f93
GIT binary patch
literal 3180
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
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/image_border_bg_normal.9.png b/fmapp/res/drawable/image_border_bg_normal.9.png
new file mode 100644
index 0000000000000000000000000000000000000000..18e360791ee9414e6939cf54df3840303d180524
GIT binary patch
literal 3423
zcmeAS@N?(olHy`uVBq!ia0y~yV9*0$0X7B(26oNwB@7G<oCO|{#S9GG!XV7ZFl&wk
z0|S?Trn7TEKt_H^esM;Afr6*AvqC{pep+TuDg#5st+~PJA;B-jY`@?8;^f`YFvUAR
zNR&e%$f>(QWTKjuBBy{?hvLGUqJakmU0qqEPb}zQ?(1vl5e?Mg>EgP<{zP$6U-ROQ
zu2a7sRxi%Jw&(k^v;VeUw|l<k^W4qn*$;5=O!F`fG;QEn=_Dukp!xWbV-KI`IW%&q
z6fg*IY)(-u{;SN$@T1PgMqB9s`#uK7ip$&_3<rE?A25(<|Ih!*X=V&#Lkr`9l8F}H
z91S824pn_l%NQKo7#rr!Pzz>Qz`~GlIyvbvLx3(rf_nY4%M1;3f6T0AWQd-kD9X5C
zB7=f(YKIF$hBd>Q^I=`C3=swlB5B@7EE#U-G8lM<r+F}J*v@d^oB;PG1`ZwugTRhf
zO$L@~hJ+K!$`uSPGZ{qOK84$S)Ltj>T#JFBV&*2Bohp{DjnN#sh3w(sdU6`)JjJy|
z%o3RrXF2E{s+=il)M�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
I=akR{0D}%|6951J
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/preset_page_button.xml b/fmapp/res/drawable/preset_page_button.xml
new file mode 100644
index 0000000..f208ae5
--- /dev/null
+++ b/fmapp/res/drawable/preset_page_button.xml
@@ -0,0 +1,35 @@
+<?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
new file mode 100644
index 0000000000000000000000000000000000000000..16ed9bcbbc82d7374eb255d47e0e0ec75021eff7
GIT binary patch
literal 350
zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s77>k44ofy`glX=O&z`&N|
z?e4<x9|RZdT|SwCfq}EYBeIx*fm;}a85w5Hkzin8U@!6Xb!ETF%_(Rtxs5?QnSp_U
zqr^3$#5q4VH#M(>;oF&M`xzJ*PI<aGhFF}wI{9E%i-CYkyh^)AM>#9M(+BrI|2MOL
ze5Svpg44D=antO(XEr^^<YIE&6+G2XkXgh0LV@sh);HZ-a=kCtyj(hE$2#u!wn{-V
zpY9dUQ(txdrRW8zWtpe`q~G79!<Av^bpN|V@~0}xD-(i#{bh^2{&3D=%kZAVmv?DJ
zl&pQ-)uEttlQCi5^E1gk?^%<2BC<DLOX@lK`}VffeebJnTlcTyH0Vp-n)ZM8_d=Qc
xY|D89PJP@L1e^pPe!rI}ArkQUXZ^!%2bcwt8`)gVT0tSm;OXk;vd$@?2>_7wihlqA
literal 0
HcmV?d00001
diff --git a/fmapp/res/drawable/station_border.xml b/fmapp/res/drawable/station_border.xml
new file mode 100644
index 0000000..df1e28a
--- /dev/null
+++ b/fmapp/res/drawable/station_border.xml
@@ -0,0 +1,33 @@
+<!--
+ * 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-800x480/fmradio.xml b/fmapp/res/layout-800x480/fmradio.xml
new file mode 100644
index 0000000..b3dbccb
--- /dev/null
+++ b/fmapp/res/layout-800x480/fmradio.xml
@@ -0,0 +1,91 @@
+<?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="fill_parent">
+
+ <!-- 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="5dp"
+ 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-800x480/fmtags.xml b/fmapp/res/layout-800x480/fmtags.xml
new file mode 100644
index 0000000..352320f
--- /dev/null
+++ b/fmapp/res/layout-800x480/fmtags.xml
@@ -0,0 +1,40 @@
+<?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-800x480/fmtransmitter.xml b/fmapp/res/layout-800x480/fmtransmitter.xml
new file mode 100644
index 0000000..1cffca9
--- /dev/null
+++ b/fmapp/res/layout-800x480/fmtransmitter.xml
@@ -0,0 +1,239 @@
+<?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-800x480/navigate.xml b/fmapp/res/layout-800x480/navigate.xml
new file mode 100644
index 0000000..7e60d32
--- /dev/null
+++ b/fmapp/res/layout-800x480/navigate.xml
@@ -0,0 +1,188 @@
+<?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="5dp"
+ android:paddingTop="5dp"
+ android:paddingBottom="5dp">
+
+ <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="28dp"
+ 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="28dp"
+ 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="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:gravity="fill"
+ 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:gravity="fill"
+ android:layout_height="65dp" />
+ </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="120dp"
+ android:gravity="fill"
+ android:layout_alignLeft="@id/presets_button_1"
+ android:layout_alignRight="@id/presets_button_1"
+ 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_alignLeft="@id/presets_button_2"
+ android:layout_alignRight="@id/presets_button_2"
+ android:gravity="fill"
+ android:layout_width="120dp"
+ android:layout_height="65dp" />
+
+ <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="120dp"
+ android:layout_height="65dp" />
+ </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="32dip"
+ android:singleLine="true"
+ android:padding="20dip"
+ android:gravity="fill"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ </RelativeLayout>
+
+</merge>
diff --git a/fmapp/res/layout-800x480/station_info.xml b/fmapp/res/layout-800x480/station_info.xml
new file mode 100644
index 0000000..475d42a
--- /dev/null
+++ b/fmapp/res/layout-800x480/station_info.xml
@@ -0,0 +1,182 @@
+<?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="5dip"
+ 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:paddingRight="5dip"
+ 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_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="16dip"
+ 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="50dip"
+ 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="100dip"
+ android:paddingLeft="2dip"
+ 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="100dip"
+ android:paddingRight="2dip"
+ 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="16dip"
+ 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="16dip"
+ android:singleLine="true"
+ android:textStyle="bold"
+ android:paddingLeft="2dip"
+ android:paddingRight="2dip"
+ android:paddingBottom="5dip"
+ 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="16dip"
+ android:singleLine="true"
+ android:textStyle="bold"
+ android:paddingLeft="2dip"
+ android:paddingRight="2dip"
+ android:paddingBottom="5dip"
+ 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-land-finger-800x480/fmradio.xml b/fmapp/res/layout-land-finger-800x480/fmradio.xml
new file mode 100644
index 0000000..f2289fd
--- /dev/null
+++ b/fmapp/res/layout-land-finger-800x480/fmradio.xml
@@ -0,0 +1,53 @@
+<?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_info_wrapper_layout"
+ android:background="@drawable/station_border"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <include layout="@layout/station_info" />
+
+ </RelativeLayout>
+
+ <RelativeLayout android:id="@+id/navigate_wrapper_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/station_info_wrapper_layout">
+
+ <!-- Layout contains the Next/Previous Presets and Tune buttons and status msg text-->
+ <include layout="@layout/navigate"/>
+
+ </RelativeLayout>
+
+</RelativeLayout>
diff --git a/fmapp/res/layout-land-finger-800x480/fmtransmitter.xml b/fmapp/res/layout-land-finger-800x480/fmtransmitter.xml
new file mode 100644
index 0000000..3d6014c
--- /dev/null
+++ b/fmapp/res/layout-land-finger-800x480/fmtransmitter.xml
@@ -0,0 +1,214 @@
+<?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-land-finger-800x480/navigate.xml b/fmapp/res/layout-land-finger-800x480/navigate.xml
new file mode 100644
index 0000000..fab276a
--- /dev/null
+++ b/fmapp/res/layout-land-finger-800x480/navigate.xml
@@ -0,0 +1,152 @@
+<?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="16dip"
+ android:textStyle="bold"
+ android:text="@string/default_record"/>
+
+ <ImageButton android:id="@+id/btn_silent"
+ android:src="@drawable/ic_silent_mode_off"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toLeftOf="@id/btn_presets_list"/>
+
+ <Button android:id="@+id/btn_presets_list"
+ android:text= "@string/default_preset_list_name"
+ android:textSize="24dip"
+ android:singleLine="true"
+ android:textStyle="bold"
+ android:layout_centerHorizontal="true"
+ 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_presets_list"
+ android:src="@drawable/ic_btn_onoff"/>
+
+ <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="16dip"
+ 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="1dip"
+ android:layout_marginBottom="5dip">
+
+ <RelativeLayout android:id="@+id/presets_upper_layout1"
+ 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="10dip"
+ android:layout_marginRight="25dip"
+ android:textSize="24dip"
+ 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:layout_marginRight="25dip"
+ android:textSize="24dip"
+ 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="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <Button android:id="@+id/presets_button_3"
+ android:text="@string/default_station"
+ android:layout_marginRight="25dip"
+ android:textSize="24dip"
+ 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="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <Button android:id="@+id/presets_button_4"
+ android:text="@string/default_blank"
+ android:layout_marginRight="25dip"
+ android:textSize="24dip"
+ android:singleLine="true"
+ android:layout_alignTop="@id/presets_button_3"
+ android:layout_alignBottom="@id/presets_button_3"
+ 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:layout_marginRight="25dip"
+ android:textSize="24dip"
+ 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="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ImageButton android:id="@+id/btn_preset_page"
+ android:src="@drawable/ic_btn_forward"
+ android:layout_marginRight="10dip"
+ android:layout_alignTop="@id/presets_button_5"
+ android:layout_alignBottom="@id/presets_button_5"
+ android:layout_toRightOf="@id/presets_button_5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ </RelativeLayout>
+ </RelativeLayout>
+</merge>
diff --git a/fmapp/res/layout-land-finger-800x480/station_info.xml b/fmapp/res/layout-land-finger-800x480/station_info.xml
new file mode 100644
index 0000000..e2304d5
--- /dev/null
+++ b/fmapp/res/layout-land-finger-800x480/station_info.xml
@@ -0,0 +1,178 @@
+<?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-land-finger/fmradio.xml b/fmapp/res/layout-land-finger/fmradio.xml
new file mode 100644
index 0000000..e55c239
--- /dev/null
+++ b/fmapp/res/layout-land-finger/fmradio.xml
@@ -0,0 +1,115 @@
+<?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-land-finger/fmtransmitter.xml b/fmapp/res/layout-land-finger/fmtransmitter.xml
new file mode 100644
index 0000000..f9a9853
--- /dev/null
+++ b/fmapp/res/layout-land-finger/fmtransmitter.xml
@@ -0,0 +1,215 @@
+<?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-land-finger/navigate.xml b/fmapp/res/layout-land-finger/navigate.xml
new file mode 100644
index 0000000..269793b
--- /dev/null
+++ b/fmapp/res/layout-land-finger/navigate.xml
@@ -0,0 +1,128 @@
+<?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-land-finger/station_info.xml b/fmapp/res/layout-land-finger/station_info.xml
new file mode 100644
index 0000000..48ce642
--- /dev/null
+++ b/fmapp/res/layout-land-finger/station_info.xml
@@ -0,0 +1,156 @@
+<?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/alert_dialog_list.xml b/fmapp/res/layout/alert_dialog_list.xml
new file mode 100644
index 0000000..5d20985
--- /dev/null
+++ b/fmapp/res/layout/alert_dialog_list.xml
@@ -0,0 +1,39 @@
+<?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/alert_dialog_text_entry.xml b/fmapp/res/layout/alert_dialog_text_entry.xml
new file mode 100644
index 0000000..828e914
--- /dev/null
+++ b/fmapp/res/layout/alert_dialog_text_entry.xml
@@ -0,0 +1,50 @@
+<?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/fmradio.xml b/fmapp/res/layout/fmradio.xml
new file mode 100644
index 0000000..e67bde1
--- /dev/null
+++ b/fmapp/res/layout/fmradio.xml
@@ -0,0 +1,99 @@
+<?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="5dip"
+ 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="2dip"
+ android:layout_marginBottom="2dip"
+ 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="10dip"
+ android:layout_marginRight="20dip"
+ android:layout_width="100dip"
+ android:layout_height="50dip"/>
+
+ <ImageButton android:id="@+id/btn_onoff"
+ android:src="@drawable/ic_btn_onoff"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="10dip"
+ android:layout_width="100dip"
+ android:layout_height="50dip"/>
+
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="#ffffffff"
+ android:layout_above="@+id/layout_on_off"/>
+
+</RelativeLayout>
diff --git a/fmapp/res/layout/fmstats.xml b/fmapp/res/layout/fmstats.xml
new file mode 100644
index 0000000..2501a51
--- /dev/null
+++ b/fmapp/res/layout/fmstats.xml
@@ -0,0 +1,122 @@
+<?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/test_run"
+ android:layout_width="wrap_content"
+ android:layout_height="100dp"
+ 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/fmtags.xml b/fmapp/res/layout/fmtags.xml
new file mode 100644
index 0000000..352320f
--- /dev/null
+++ b/fmapp/res/layout/fmtags.xml
@@ -0,0 +1,40 @@
+<?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/fmtransmitter.xml b/fmapp/res/layout/fmtransmitter.xml
new file mode 100644
index 0000000..f9e7b08
--- /dev/null
+++ b/fmapp/res/layout/fmtransmitter.xml
@@ -0,0 +1,235 @@
+<?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/frequency_picker.xml b/fmapp/res/layout/frequency_picker.xml
new file mode 100644
index 0000000..2d89a62
--- /dev/null
+++ b/fmapp/res/layout/frequency_picker.xml
@@ -0,0 +1,54 @@
+<?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/frequency_picker_dialog.xml b/fmapp/res/layout/frequency_picker_dialog.xml
new file mode 100644
index 0000000..89a6e4f
--- /dev/null
+++ b/fmapp/res/layout/frequency_picker_dialog.xml
@@ -0,0 +1,34 @@
+<?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/navigate.xml b/fmapp/res/layout/navigate.xml
new file mode 100644
index 0000000..30cff7e
--- /dev/null
+++ b/fmapp/res/layout/navigate.xml
@@ -0,0 +1,158 @@
+<?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="5dip"
+ 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="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_centerHorizontal="true"
+ android:layout_alignParentTop="true"
+ android:layout_gravity="center"
+ 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_alignParentTop="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignBaseline="@+id/btn_presets_list"
+ android:textSize="14dip"
+ 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="5dip"
+ android:gravity="center_horizontal">
+
+ <Button android:id="@+id/presets_button_1"
+ android:text="@string/default_station"
+ android:layout_marginLeft="10dip"
+ android:layout_width="90dip"
+ android:layout_height="55dip" />
+
+ <Button android:id="@+id/presets_button_2"
+ android:text="@string/default_station"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip"
+ android:layout_width="90dip"
+ android:layout_height="55dip" />
+
+ <Button android:id="@+id/presets_button_3"
+ android:text="@string/default_station"
+ android:layout_marginRight="10dip"
+ android:layout_width="90dip"
+ android:layout_height="55dip"
+ 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="5dip"
+ android:gravity="center_horizontal">
+
+ <Button android:id="@+id/presets_button_4"
+ android:text="@string/default_blank"
+ android:layout_marginLeft="10dip"
+ android:layout_width="90dip"
+ android:layout_height="55dip" />
+
+ <Button android:id="@+id/presets_button_5"
+ android:text="@string/default_blank"
+ android:layout_marginLeft="10dip"
+ android:layout_marginRight="10dip"
+ android:layout_width="90dip"
+ android:layout_height="55dip" />
+
+ <ImageButton android:id="@+id/btn_preset_page"
+ android:src="@drawable/preset_page_button"
+ android:layout_marginRight="10dip"
+ android:layout_width="90dip"
+ android:layout_height="55dip"
+ 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="20dip"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+</merge>
diff --git a/fmapp/res/layout/station_info.xml b/fmapp/res/layout/station_info.xml
new file mode 100644
index 0000000..876026a
--- /dev/null
+++ b/fmapp/res/layout/station_info.xml
@@ -0,0 +1,176 @@
+<?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="5dip"
+ 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:paddingRight="5dip"
+ 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="vertical"
+ android:paddingTop="5dip"
+ android:paddingBottom="5dip"
+ 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="14dip"
+ android:paddingTop="2dip"
+ android:paddingRight="2dip"
+ android:paddingBottom="2dip"
+ android:paddingLeft="2dip"
+ 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="2dip"
+ android:layout_marginBottom="2dip"
+ android:layout_marginLeft="2dip"
+ android:layout_marginRight="2dip">
+
+ <TextView android:id="@+id/prog_frequency_tv"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="64dip"
+ 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="100dip"
+ android:paddingLeft="2dip"
+ 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="100dip"
+ android:paddingRight="2dip"
+ 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="14dip"
+ android:paddingTop="2dip"
+ android:paddingRight="2dip"
+ android:paddingBottom="2dip"
+ android:paddingLeft="2dip"
+ 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="20dip"
+ android:singleLine="true"
+ android:textStyle="bold"
+ android:paddingLeft="2dip"
+ android:paddingRight="2dip"
+ android:paddingBottom="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:text="@string/eradio_text_string"/>
+ </LinearLayout>
+
+</merge>
diff --git a/fmapp/res/layout/statusbar.xml b/fmapp/res/layout/statusbar.xml
new file mode 100644
index 0000000..b8a8189
--- /dev/null
+++ b/fmapp/res/layout/statusbar.xml
@@ -0,0 +1,56 @@
+<?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/values/arrays.xml b/fmapp/res/values/arrays.xml
new file mode 100644
index 0000000..d7904be
--- /dev/null
+++ b/fmapp/res/values/arrays.xml
@@ -0,0 +1,371 @@
+<?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>
+ </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>
+ </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.8MHz 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 (88.0MHz To 108.0MHz In 50 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>
+ </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>
+
+</resources>
diff --git a/fmapp/res/values/strings.xml b/fmapp/res/values/strings.xml
new file mode 100644
index 0000000..b1dd448
--- /dev/null
+++ b/fmapp/res/values/strings.xml
@@ -0,0 +1,265 @@
+<?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>
+
+</resources>
diff --git a/fmapp/res/values/styles.xml b/fmapp/res/values/styles.xml
new file mode 100644
index 0000000..5119c09
--- /dev/null
+++ b/fmapp/res/values/styles.xml
@@ -0,0 +1,39 @@
+<?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/FMAdapterApp.java b/fmapp/src/com/codeaurora/fmradio/FMAdapterApp.java
new file mode 100644
index 0000000..87b0aeb
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMAdapterApp.java
@@ -0,0 +1,64 @@
+/*
+ * 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
new file mode 100644
index 0000000..ca7f102
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMMediaButtonIntentReceiver.java
@@ -0,0 +1,71 @@
+/*
+ * 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
new file mode 100644
index 0000000..d592bc2
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMRadio.java
@@ -0,0 +1,3595 @@
+/*
+ * 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(isRecordTimerActive() ) {
+ try {
+ if ( null != mRecordUpdateHandlerThread) {
+ mRecordUpdateHandlerThread.interrupt();
+ }
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ long rtimeNow = ((SystemClock.elapsedRealtime()));
+ if (rtimeNow < mRecordDuration)
+ {
+ try {
+ if (null != mService) {
+ mService.delayedStop((mRecordDuration - rtimeNow), FMRadioService.STOP_RECORD);
+ }
+ } catch (Exception 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(isRecordTimerActive()) {
+ 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 boolean hasRecordTimerExpired() {
+ boolean expired = true;
+
+ /* If record duration is 'until stopped' then return false and exit */
+ if ( mRecordUntilStopped )
+ return false;
+
+ if (isRecordTimerActive())
+ {
+ long timeNow = ((SystemClock.elapsedRealtime()));
+ //Log.d(LOGTAG, "hasSleepTimerExpired - " + mSleepAtPhoneTime + " now: "+ timeNow);
+ if (mRecording == false || timeNow < mRecordDuration)
+ {
+ expired = false;
+ }
+ }
+ return expired;
+ }
+
+ private boolean isRecordTimerActive() {
+ boolean active = false;
+ if (mRecordDuration > 0)
+ {
+ active = true;
+ }
+ return active;
+ }
+
+ private void updateExpiredRecordTime() {
+ int vis = View.VISIBLE;
+ if ( mRecordUntilStopped || isRecordTimerActive())
+ {
+ long timeNow = ((SystemClock.elapsedRealtime()));
+ if (mRecordUntilStopped || mRecordDuration >= timeNow)
+ {
+ long seconds = (timeNow - mRecordStartTime) / 1000;
+ String Msg = makeTimeString(seconds);
+ mRecordingMsgTV.setText(Msg);
+ } else
+ {
+ /* Clean up timer */
+ mRecordDuration = 0;
+ }
+ }
+ mRecordingMsgTV.setVisibility(vis);
+ }
+
+ /* Recorder Thread processing */
+ private Runnable doRecordProcessing = new Runnable() {
+ public void run() {
+ boolean recordTimerExpired;
+ if( mRecordUntilStopped )
+ {
+ recordTimerExpired = false;
+ }
+ else
+ {
+ recordTimerExpired = hasRecordTimerExpired();
+ }
+ while (recordTimerExpired == false && (!Thread.currentThread().isInterrupted()) )
+ {
+ try
+ {
+ Thread.sleep(500);
+ Message statusUpdate = new Message();
+ statusUpdate.what = RECORDTIMER_UPDATE;
+ mUIUpdateHandlerHandler.sendMessage(statusUpdate);
+ recordTimerExpired = hasRecordTimerExpired();
+ } catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ if( true == recordTimerExpired) {
+ Message finished = new Message();
+ finished.what = RECORDTIMER_EXPIRED;
+ mUIUpdateHandlerHandler.sendMessage(finished);
+ }
+ }
+ }
+ };
+
+ private static long mRecordDuration = 0;
+ private static long mRecordStartTime = 0;
+ private static boolean mRecordUntilStopped =false;
+ private Thread mRecordUpdateHandlerThread = null;
+
+ private void initiateRecordDurationTimer(long mins ) {
+
+ if( mins == FmSharedPreferences.RECORD_DUR_INDEX_3_VAL )
+ {
+ mRecordUntilStopped = true;
+ mRecordStartTime = SystemClock.elapsedRealtime();
+ }
+ else
+ {
+ mRecordUntilStopped = false;
+ mRecordDuration = ( mRecordStartTime = SystemClock.elapsedRealtime()) + (mins * 60 * 1000);
+ }
+
+ 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
+ {
+ mRecording = mService.startRecording();
+ } catch (RemoteException e)
+ {
+ e.printStackTrace();
+ }
+ //Initiate record timer thread here
+ if( mRecording == true ) {
+ int durationInMins = FmSharedPreferences.getRecordDuration();
+ Log.e(LOGTAG, " Fected duration:" + durationInMins );
+ initiateRecordDurationTimer( durationInMins );
+ }
+ }
+ }
+
+ 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();
+ }
+ }
+ mRecordDuration = 0;
+ }
+
+ 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");
+ mRecordDuration = 0;
+ //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();
+ }
+ else if((mRecordDuration > 0) &&
+ (mRecordUpdateHandlerThread != null)) {
+ mRecordUpdateHandlerThread.interrupt();
+ if(mRecordingMsgTV != null) {
+ mRecordingMsgTV.setVisibility(View.INVISIBLE);
+ }
+ mRecordDuration = 0;
+ }
+ 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();
+ }
+ };
+}
diff --git a/fmapp/src/com/codeaurora/fmradio/FMRadioService.java b/fmapp/src/com/codeaurora/fmradio/FMRadioService.java
new file mode 100644
index 0000000..0bf8f1e
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMRadioService.java
@@ -0,0 +1,3187 @@
+/*
+ * 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;
+
+/**
+ * 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 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();
+ registerExternalStorageListener();
+ // 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( mSdcardUnmountReceiver != null ) {
+ unregisterReceiver(mSdcardUnmountReceiver);
+ mSdcardUnmountReceiver = 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;
+ }
+ /* 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();
+ }
+
+/**
+ * Registers an intent to listen for ACTION_MEDIA_UNMOUNTED notifications.
+ * The intent will call closeExternalStorageFiles() if the external media
+ * is going to be ejected, so applications can clean up.
+ */
+ public void registerExternalStorageListener() {
+ if (mSdcardUnmountReceiver == null) {
+ mSdcardUnmountReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if ((action.equals(Intent.ACTION_MEDIA_UNMOUNTED))
+ || (action.equals(Intent.ACTION_MEDIA_EJECT))) {
+ Log.d(LOGTAG, "ACTION_MEDIA_UNMOUNTED Intent received");
+ if (mFmRecordingOn == true) {
+ try {
+ stopRecording();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ };
+ IntentFilter iFilter = new IntentFilter();
+ iFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
+ iFilter.addAction(Intent.ACTION_MEDIA_EJECT);
+ iFilter.addDataScheme("file");
+ registerReceiver(mSdcardUnmountReceiver, 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 (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);
+ if((mPlaybackInProgress == false) && isWiredHeadsetAvailable())
+ startFM();
+ 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 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);
+ }
+ AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM,
+ AudioSystem.DEVICE_STATE_AVAILABLE, "");
+ }
+ 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, "");
+ }
+ mPlaybackInProgress = false;
+ }
+
+ public boolean 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 false;
+ }
+ stopRecording();
+
+ if (!updateAndShowStorageHint())
+ return false;
+ long maxFileSize = mStorageSpace - LOW_STORAGE_THRESHOLD;
+ mRecorder = new MediaRecorder();
+ try {
+ mRecorder.setMaxFileSize(maxFileSize);
+ } catch (RuntimeException exception) {
+
+ }
+
+ mSampleFile = null;
+ File sampleDir = Environment.getExternalStorageDirectory();
+ if (!sampleDir.canWrite()) // Workaround for broken sdcard support on
+ // the device.
+ sampleDir = new File("/sdcard/sdcard");
+ try {
+ mSampleFile = File
+ .createTempFile("FMRecording", ".3gpp", sampleDir);
+ } catch (IOException e) {
+ Log.e(LOGTAG, "Not able to access SD Card");
+ Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ if (mRecorder == null) {
+ Toast.makeText(this,"MediaRecorder failed to create an instance",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+
+ try {
+ mRecorder.setAudioSource(MediaRecorder.AudioSource.FM_RX);
+ mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+ mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
+ } catch (RuntimeException exception) {
+ mRecorder.reset();
+ mRecorder.release();
+ mRecorder = null;
+ return false;
+ }
+ mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
+ try {
+ mRecorder.prepare();
+ mRecorder.start();
+ } catch (IOException e) {
+ mRecorder.reset();
+ mRecorder.release();
+ mRecorder = null;
+ return false;
+ } catch (RuntimeException e) {
+ mRecorder.reset();
+ mRecorder.release();
+ mRecorder = null;
+ return false;
+ }
+ mFmRecordingOn = true;
+ 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(LOGTAG, "Maximum file size/duration reached, stopping the recording");
+ stopRecording();
+ }
+ // Show the toast.
+ Toast.makeText(FMRadioService.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(LOGTAG, "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) {
+ stopRecording();
+ }
+ updateAndShowStorageHint();
+ }
+ }
+ });
+
+ mSampleStart = System.currentTimeMillis();
+ return true;
+ }
+
+ 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;
+ }
+
+ private void resetRecording() {
+
+ Log.v(LOGTAG, "resetRecording()");
+
+ mFmRecordingOn = false;
+ if (mRecorder == null)
+ return;
+
+ // 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);
+
+ mRecorder.stop();
+
+ mRecorder.reset();
+ mRecorder.release();
+ mRecorder = null;
+ int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 );
+ if (sampleLength == 0)
+ return;
+ String state = Environment.getExternalStorageState();
+ Log.d(LOGTAG, "storage state is " + state);
+
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
+ this.addToMediaDB(mSampleFile);
+ }
+ else{
+ Log.e(LOGTAG, "SD card must have removed during recording. ");
+ Toast.makeText(this, "Recording aborted", Toast.LENGTH_SHORT).show();
+ }
+ return;
+ }
+
+ public void stopRecording() {
+ mFmRecordingOn = false;
+ if (mRecorder == null)
+ return;
+ try {
+ mRecorder.stop();
+ mRecorder.reset();
+ mRecorder.release();
+ mRecorder = null;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 );
+ if (sampleLength == 0)
+ return;
+ String state = Environment.getExternalStorageState();
+ Log.d(LOGTAG, "storage state is " + state);
+
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
+ try {
+ this.addToMediaDB(mSampleFile);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ else{
+ Log.e(LOGTAG, "SD card must have removed during recording. ");
+ Toast.makeText(this, "Recording aborted", Toast.LENGTH_SHORT).show();
+ }
+ try
+ {
+ if((mServiceInUse) && (mCallbacks != null) ) {
+ mCallbacks.onRecordingStopped();
+ }
+ } catch (RemoteException e)
+ {
+ e.printStackTrace();
+ }
+ return;
+ }
+
+ /*
+ * Adds file and returns content uri.
+ */
+ private Uri addToMediaDB(File file) {
+ Log.d(LOGTAG, "In addToMediaDB");
+ Resources res = getResources();
+ ContentValues cv = new ContentValues();
+ long current = System.currentTimeMillis();
+ long modDate = file.lastModified();
+ 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.MIME_TYPE, "AUDIO_AAC_MP4");
+ 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));
+ Log.d(LOGTAG, "Inserting audio record: " + cv.toString());
+ ContentResolver resolver = getContentResolver();
+ Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+ Log.d(LOGTAG, "ContentURI: " + base);
+ Uri result = resolver.insert(base, cv);
+ if (result == null) {
+ Toast.makeText(this, "Unable to save recorded audio", Toast.LENGTH_SHORT).show();
+ return null;
+ }
+ if (getPlaylistId(res) == -1) {
+ createPlaylist(res, resolver);
+ }
+ int 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 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(LOGTAG, "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, "Unable to save recorded audio", 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 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 (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)
+ stopFM();
+ if (mSpeakerPhoneOn) {
+ mSpeakerPhoneOn = false;
+ if (isAnalogModeSupported())
+ setAudioPath(true);
+ }
+ 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 boolean startRecording()
+ {
+ return(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));
+ }
+ }
+ 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" );
+ }
+
+ 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())
+ {
+ resetRecording();
+ }
+
+ 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");
+ }
+ 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;
+ }
+
+ //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
new file mode 100644
index 0000000..00cd56f
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMStats.java
@@ -0,0 +1,2013 @@
+/*
+ * 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 java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import android.os.SystemProperties;
+
+
+public class FMStats extends Activity {
+
+ EditText txtbox1;
+ Button button1;
+ Button button2;
+ TextView tv1;
+ Button SetButton;
+ Button RunButton;
+ ProgressBar pbar;
+ TableLayout tLayout;
+
+ private FmReceiver mReceiver;
+
+ /*Data structure for band*/
+ private class Band {
+
+ public int lFreq;
+ public int hFreq;
+ public int Spacing;
+ }
+ /* 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;
+
+
+ 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 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;
+ ArrayAdapter<CharSequence> adaptCfgRf;
+ ArrayAdapter<CharSequence> adaptRfCfg;
+ ArrayAdapter<CharSequence> adaptFmRf;
+
+ 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;
+
+ @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);
+ }
+
+ 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");
+ }
+
+ public void onDestroy() {
+ if (null != mFileCursor ) {
+ try {
+ mFileCursor.close();
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ }
+ }
+ /*Stop the thread by interrupting it*/
+ if (mMultiUpdateThread != null) {
+ mMultiUpdateThread.interrupt();
+ mMultiUpdateThread = null;
+ }
+ /*Stop the search/scan if there is an ongoing*/
+ if (SEARCH_TEST == mTestSelected)
+ {
+ Log.d(LOGTAG, "Stop Search\n");
+ try {
+ mService.cancelSearch();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ unbindFromService(this);
+ Log.d(LOGTAG, "onDestroy: unbindFromService completed");
+ mReceiver = null;
+ mService = null;
+ super.onDestroy();
+ }
+
+ private View.OnClickListener mOnRunListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ if(false == mTestRunning)
+ {
+ clearPreviousTestResults();
+ mTestRunning = true;
+ runCurrentTest();
+ }
+ else
+ {
+ mTestRunning = false;
+ /*Set it back to ready to Run*/
+ SetButtonState(true);
+ /*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();
+ }
+ }
+ }
+ }
+ };
+
+ 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);
+ }
+ }
+ 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);
+ }
+ 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);
+ 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;
+ if(Spacing == 0)
+ {
+ mBand.Spacing = 200; // 200KHz
+ }
+ else if( Spacing == 1)
+ {
+ mBand.Spacing = 100; // 100KHz
+ }
+ else
+ {
+ mBand.Spacing = 50;
+ }
+
+ if (mMultiUpdateThread == null)
+ {
+ mMultiUpdateThread = new Thread(null, getSweepResults,
+ "MultiResultsThread");
+ }
+ /* Launch he dummy thread to simulate the transfer progress */
+ Log.d(LOGTAG, "Thread State: " + mMultiUpdateThread.getState());
+ if (mMultiUpdateThread.getState() == Thread.State.TERMINATED)
+ {
+ mMultiUpdateThread = new Thread(null, getSweepResults,
+ "MultiResultsThread");
+ }
+ /* If the thread state is "new" then the thread has not yet started */
+ if (mMultiUpdateThread.getState() == Thread.State.NEW)
+ {
+ mMultiUpdateThread.start();
+ }
+ }
+
+ /* Thread processing */
+ private Runnable getSweepResults = new Runnable() {
+ public void run() {
+ for (int i = mBand.lFreq; (i <= mBand.hFreq) && (mService != null);
+ i += mBand.Spacing)
+ {
+ try {
+ if (!mService.tune(i)) {
+ Log.e(LOGTAG, "tune failed");
+ break;
+ }
+ mSync = new Band();
+ synchronized(mSync) {
+ mSync.wait(); //wait till notified
+ }
+ mSync = null;
+ Message updateUI = new Message();
+ updateUI.what = STATUS_UPDATE;
+ updateUI.obj = (Object)GetFMStatsForFreq(i);
+ if (updateUI.obj == null) {
+ break;
+ } else {
+ mUIUpdateHandlerHandler.sendMessage(updateUI);
+ Log.d(LOGTAG,"highFerq is "+mBand.hFreq);
+ }
+ }
+ catch (RemoteException e) {
+ Log.e(LOGTAG, "SweepResults:Tune failed\n");
+ }
+
+ catch (InterruptedException e) {
+ /*Stop the thrad*/
+ break;
+ }
+ }
+ 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();
+ }
+ mUIUpdateHandlerHandler.sendMessage(updateStop);
+ }
+ };
+
+ 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;
+ }
+ }
+ };
+
+ 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();
+ }
+ 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 :");
+ }
+
+ public void onDisabled()
+ {
+ Log.d(LOGTAG, "mServiceCallbacks.onDisabled :");
+ stopCurTest();
+ }
+
+ public void onRadioReset()
+ {
+ Log.d(LOGTAG, "mServiceCallbacks.onRadioReset :");
+ }
+
+ 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 :");
+ }
+ public void onFinishActivity()
+ {
+ Log.d(LOGTAG, "mServiceCallbacks.onFinishActivity:");
+ }
+ };
+ /* 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:
+ 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;
+ }
+ }
+ }
diff --git a/fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java b/fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java
new file mode 100644
index 0000000..f21ed00
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMTransmitterActivity.java
@@ -0,0 +1,1477 @@
+/*
+ * 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
new file mode 100644
index 0000000..2abd3ca
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMTransmitterConfigReceiver.java
@@ -0,0 +1,81 @@
+/*
+ * 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.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 {
+ 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
new file mode 100644
index 0000000..df1de6d
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FMTransmitterService.java
@@ -0,0 +1,1192 @@
+/*
+ * 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;
+
+/**
+ * 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 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);
+ registerHeadsetListener();
+ }
+
+ @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);
+/*
+ if (mMetaStatusListener != null) {
+ unregisterReceiver(mMetaStatusListener);
+ mMetaStatusListener = null;
+ } */
+
+ /* 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");
+ }
+
+ /*
+ *Listen to Meta data events
+ */
+/* private BroadcastReceiver mMetaStatusListener = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action.equals("com.android.music.metachanged")) {
+ // redraw the artist/title info and
+ // set new max for progress bar
+ Log.d(LOGTAG, " MetaData changed\n ");
+ Log.d(LOGTAG, "Service: artist: "+ intent.getStringExtra("artist"));
+ Log.d(LOGTAG, " Service:Album: "+ intent.getStringExtra("album"));
+ Log.d(LOGTAG, " Service:Track: "+ intent.getStringExtra("track"));
+
+ //Set if PI and PTY
+ //as desired
+ if( mTransmitter != null ){
+ RText = intent.getStringExtra("album") +":" + intent.getStringExtra("track") +":"
+ + intent.getStringExtra("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();
+ }
+ }
+ else if ( action.equals("com.android.music.playstatechanged")){
+ // current "command" extra string is not supported
+ // but found in open source this info will be filled
+ // for this intent, in that case long pause can be handled
+ // for turning of FM Tx. Yet to be implemented
+ String cmd = intent.getStringExtra("command");
+ Log.d(LOGTAG, "playstatechanged event received");
+ }
+ else if (action.equals("com.android.music.playbackcomplete")){
+ // need to implement timer logic to turn off FM.
+ Log.d(LOGTAG,"playbackcomplete event received");
+ }
+
+ }
+ }; */
+ @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);
+/*
+ IntentFilter f = new IntentFilter();
+ f.addAction("com.android.music.metachanged");
+ f.addAction("com.android.music.playstatechanged");
+ f.addAction("com.android.music.playbackcomplete");
+ registerReceiver(mMetaStatusListener, f); */
+
+ }
+
+ @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");
+ }
+ }
+ }
+ }
+ };
+ 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
new file mode 100644
index 0000000..0e5484c
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
@@ -0,0 +1,1117 @@
+/*
+ * 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.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 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 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);
+
+ 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 */
+ setCountry(sp.getInt(FMCONFIG_COUNTRY, 0));
+ /* 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);
+ ed.putInt(LAST_RECORD_DURATION, mRecordDuration);
+ ed.putBoolean(LAST_AF_JUMP_VALUE, mAFAutoSwitch);
+ ed.commit();
+ }
+
+ public static void SetDefaults() {
+ mListIndex=0;
+ mListOfPlists.clear();
+ setCountry(REGIONAL_BAND_NORTH_AMERICA);
+ setRadioBand(0);
+ setChSpacing(0);
+ setEmphasis(0);
+ setRdsStd(0);
+ mFMConfiguration.setLowerLimit(87500);
+ mFMConfiguration.setUpperLimit(107900);
+ }
+
+ 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;
+ }
+ }
+ 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);
+ }
+
+ public static void setUpperLimit(int upLimit){
+ mFMConfiguration.setUpperLimit(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 50 KHZ STEPS*/
+ mFMConfiguration.setRadioBand(FmReceiver.FM_EU_BAND);
+ mFMConfiguration.setChSpacing(FmReceiver.FM_CHSPACE_50_KHZ);
+ mFMConfiguration.setLowerLimit(87500);
+ mFrequencyBand_Stepsize = 50;
+ 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;
+ }
+ 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
new file mode 100644
index 0000000..c54196a
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/FmTags.java
@@ -0,0 +1,99 @@
+/*
+ * 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/IFMRadioService.aidl b/fmapp/src/com/codeaurora/fmradio/IFMRadioService.aidl
new file mode 100644
index 0000000..79d83f7
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/IFMRadioService.aidl
@@ -0,0 +1,102 @@
+/*
+ * 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();
+ boolean 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);
+}
+
diff --git a/fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl b/fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl
new file mode 100644
index 0000000..eb782e8
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/IFMRadioServiceCallbacks.aidl
@@ -0,0 +1,48 @@
+/*
+ * 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();
+}
diff --git a/fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl b/fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl
new file mode 100644
index 0000000..39bc70b
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/IFMTransmitterService.aidl
@@ -0,0 +1,51 @@
+/*
+ * 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
new file mode 100644
index 0000000..27a7249
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/IFMTransmitterServiceCallbacks.aidl
@@ -0,0 +1,42 @@
+/*
+ * 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
new file mode 100644
index 0000000..a2fd1a9
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/PresetList.java
@@ -0,0 +1,323 @@
+/*
+ * 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
new file mode 100644
index 0000000..01a3ba0
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/PresetStation.java
@@ -0,0 +1,951 @@
+/*
+ * 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
new file mode 100644
index 0000000..b721a15
--- /dev/null
+++ b/fmapp/src/com/codeaurora/fmradio/Settings.java
@@ -0,0 +1,388 @@
+/*
+ * 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.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 RESTORE_FACTORY_DEFAULT_ACTION = "com.codeaurora.fmradio.settings.revert_to_defaults";
+
+ private static final String LOGTAG = FMRadio.LOGTAG;
+
+ private ListPreference mBandPreference;
+ private ListPreference mAudioPreference;
+ private ListPreference mRecordDurPreference;
+ private CheckBoxPreference mAfPref;
+ private Preference mRestoreDefaultPreference;
+
+ private FmSharedPreferences mPrefs = null;
+ private boolean mRxMode = false;
+
+ @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);
+
+ // Band/Country
+ String[] summaryBandItems = getResources().getStringArray(
+ R.array.regional_band_summary);
+ 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;
+ }
+ Log.d(LOGTAG, "createPreferenceHierarchy: CountrySummary: "
+ + summaryBandItems[index]);
+ mBandPreference.setSummary(summaryBandItems[index]);
+ mBandPreference.setValueIndex(index);
+ root.addPreference(mBandPreference);
+
+ if (mRxMode) {
+ // Audio Output (Stereo or Mono)
+ String[] 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)
+ {
+ String[] 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[] summaryBandItems = getResources().getStringArray(
+ R.array.regional_band_summary);
+ 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);
+ }
+ Log.d(LOGTAG, "onSharedPreferenceChanged: Country Change: "
+ + index);
+ mBandPreference.setSummary(summaryBandItems[index]);
+ FmSharedPreferences.setCountry(index);
+ bStatus = FMRadio.fmConfigure();
+ FMTransmitterActivity.fmConfigure();
+ if (curList != null) {
+ curList.clear();
+ }
+ } 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[] recordItems = getResources().getStringArray(
+ R.array.record_durations_entries);
+ String valueStr = mRecordDurPreference.getValue();
+ int index = 0;
+ if (valueStr != null) {
+ index = mRecordDurPreference.findIndexOfValue(valueStr);
+ }
+ if ((index < 0) || (index >= recordItems.length)) {
+ index = 0;
+ mRecordDurPreference.setValueIndex(index);
+ }
+ Log.d(LOGTAG, "onSharedPreferenceChanged: recorddur: "
+ + recordItems[index]);
+ mRecordDurPreference.setSummary(recordItems[index]);
+ FmSharedPreferences.setRecordDuration(index);
+ }
+ } else if (key.equals(AUDIO_OUTPUT_KEY)) {
+ String[] bandItems = getResources().getStringArray(
+ R.array.ster_mon_entries);
+ 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: "
+ + bandItems[index]);
+ mAudioPreference.setSummary(bandItems[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);
+ }
+ }
+
+}
diff --git a/fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java b/fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java
new file mode 100644
index 0000000..46bcecd
--- /dev/null
+++ b/fmapp/src/com/codeaurora/hc_utils/A2dpDeviceStatus.java
@@ -0,0 +1,105 @@
+/*
+ * 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
new file mode 100644
index 0000000..8a1deaa
--- /dev/null
+++ b/fmapp/src/com/codeaurora/hc_utils/FrequencyPicker.java
@@ -0,0 +1,428 @@
+/*
+ * 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
new file mode 100644
index 0000000..06ac7b3
--- /dev/null
+++ b/fmapp/src/com/codeaurora/hc_utils/FrequencyPickerDialog.java
@@ -0,0 +1,184 @@
+/*
+ * 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
new file mode 100644
index 0000000..b6d5a88
--- /dev/null
+++ b/fmapp/src/com/codeaurora/utils/A2dpDeviceStatus.java
@@ -0,0 +1,88 @@
+/*
+ * 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
new file mode 100644
index 0000000..845ed90
--- /dev/null
+++ b/fmapp/src/com/codeaurora/utils/FrequencyPicker.java
@@ -0,0 +1,414 @@
+/*
+ * 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
new file mode 100644
index 0000000..6078208
--- /dev/null
+++ b/fmapp/src/com/codeaurora/utils/FrequencyPickerDialog.java
@@ -0,0 +1,156 @@
+/*
+ * 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);
+ }
+}
--
GitLab