diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2012-03-05 15:01:57 -0800 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2012-03-06 10:25:40 -0800 |
commit | 3ece7d9e08052989401e008bc397dbcd2557cfd0 (patch) | |
tree | 4d894cc607b4cc436049628ee4a279758950feb6 | |
parent | 12ddecd1fa87e02a12de5993e2ad31e3ebb9648e (diff) | |
download | wpan-3ece7d9e08052989401e008bc397dbcd2557cfd0.tar.gz |
Initial import of ti/wpan code from upstream.
This is a snapshot of commit baac05664390c2476d113d1eb586d6167ab2d01e
from git://git.omapzoom.org/platform/hardware/ti/wpan
Change-Id: I541234356495a1f19f7a571ddab8e9acd96d9402
141 files changed, 32380 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3dce3c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# +# NOTE! Don't add files that are generated in specific +# subdirectories here. Add them in the ".gitignore" file +# in that subdirectory instead. +# +# NOTE! Please use 'git ls-files -i --exclude-standard' +# command after changing this file, to see if there are +# any tracked files which get ignored after the change. +# +# Normal rules +# +.* +*.o +*.o.* +*.out + +# +# Top-level generic files +# +tags +TAGS +!.gitignore +!.mailmap + +# stgit generated dirs +patches-* + +# quilt's files +patches +series + +# cscope files +cscope.* +ncscope.* +target +target/* +# gnu global files +GPATH +GRTAGS +GSYMS +GTAGS + +*.orig +*~ +\#*# diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..12f684e --- /dev/null +++ b/Android.mk @@ -0,0 +1,2 @@ +#wpan utilties and TI ST user space manager +include $(call first-makefiles-under,$(call my-dir)) @@ -0,0 +1,18 @@ +wpan.git contains the Bluetooth, FM code by Texas Instruments for +WiLink connectivity chipsets on OMAP Platforms + +Android.mk - Root Makefile calling all subdir makefiles +bt_sco_app - Command line application to send PCM configuruations to WL12xx chip(optional) +and connect to BT headset via SCO. +bt_voice_call_set - Derived from bt_sco_app for Modem purposes. +fmradio - Stack and Command line application for FM on WiLink chipsets +fmradio_omap3 - Derived from fmradio (older version) on OMAP3 platforms +README - This file +ti_st - + kfmapp/ - V4L2 FM application to be used with V4L2 drivers for FM on WL. + uim/ - User-Space Initilization Manager for TI Shared Transport Drivers (to be + used with kernel version 2.6.32 and below drivers) + uim-rfkill/ - Derived from uim/ to be used with K32 and above TI ST drivers. + uim-sysfs/ - User-Space Init Manager for TI Shared Transport Drivers (per kernel.org) +tools - + BluetoothSCOApp/ - BT SCO UI App for connect to BT headset via SCO diff --git a/bt_sco_app/Android.mk b/bt_sco_app/Android.mk new file mode 100644 index 0000000..0533563 --- /dev/null +++ b/bt_sco_app/Android.mk @@ -0,0 +1,30 @@ +ifeq ($(BOARD_HAVE_BLUETOOTH),true) +LOCAL_PATH:= $(call my-dir) + +# +# bt_sco_app +# + +include $(CLEAR_VARS) + +LOCAL_C_INCLUDES:= \ + $(call include-path-for, bluez-libs) \ + external/bluetooth/bluez/lib + +LOCAL_CFLAGS:= \ + -DVERSION=\"3.36\" + +LOCAL_SRC_FILES:= \ + bt_sco_app.c + +LOCAL_SHARED_LIBRARIES := \ + libbluetooth libcutils +#LOCAL_STATIC_LIBRARIES := \ +# libbluez-common-static +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) +LOCAL_MODULE_TAGS := eng +LOCAL_MODULE:=bt_sco_app + +include $(BUILD_EXECUTABLE) + +endif diff --git a/bt_sco_app/bt_sco_app.c b/bt_sco_app/bt_sco_app.c new file mode 100644 index 0000000..e955466 --- /dev/null +++ b/bt_sco_app/bt_sco_app.c @@ -0,0 +1,312 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2008-2009 Texas Instruments, Inc. + * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> + * Copyright (C) 2002-2008 Marcel Holtmann <marcel@holtmann.org> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <errno.h> +#include <ctype.h> +#include <unistd.h> +#include <stdlib.h> +#include <getopt.h> +#include <syslog.h> +#include <signal.h> +#include <sys/time.h> +#include <sys/socket.h> + +#include <bluetooth/bluetooth.h> +#include <bluetooth/hci.h> +#include <bluetooth/hci_lib.h> +#include <bluetooth/sco.h> + +/* Static Local variables */ + +/* BD Address of the BT head set */ +static bdaddr_t bdaddr; + +/* Buffer to receive data feom headset */ +static unsigned char *buffer; + +/* Default data size */ +static long data_size = 672; + +/* Handling termination of process through signals */ +static volatile int terminate = 0; + +/* Static functions declerations */ +static void send_hciCmd(int dev_id, int command_length, char **command); + + +/** Function to handle signal terminations */ +static void sig_term(int sig) { + terminate = 1; +} + +/** do_connect Function + * This function Creates the SCO connection to the BT headset + * + * Parameters : + * @ svr : BD address of headset + * Returns SCO socket id on success + * suitable error code + */ +static int do_connect(char *svr) +{ + struct sockaddr_sco addr; + struct sco_conninfo conn; + socklen_t optlen; + int sk; + + /* Create socket */ + sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); + if (sk < 0) { + syslog(LOG_ERR, "Can't create socket: %s (%d)", + strerror(errno), errno); + return -1; + } + + /* Bind to local address */ + memset(&addr, 0, sizeof(addr)); + addr.sco_family = AF_BLUETOOTH; + bacpy(&addr.sco_bdaddr, &bdaddr); + + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + syslog(LOG_ERR, "Can't bind socket: %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Connect to remote device */ + memset(&addr, 0, sizeof(addr)); + addr.sco_family = AF_BLUETOOTH; + str2ba(svr, &addr.sco_bdaddr); + + if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + syslog(LOG_ERR, "Can't connect: %s (%d)", + strerror(errno), errno); + goto error; + } + + /* Get connection information */ + memset(&conn, 0, sizeof(conn)); + optlen = sizeof(conn); + + if (getsockopt(sk, SOL_SCO, SCO_CONNINFO, &conn, &optlen) < 0) { + syslog(LOG_ERR, "Can't get SCO connection information: %s (%d)", + strerror(errno), errno); + goto error; + } + + syslog(LOG_INFO, "Connected [handle %d, class 0x%02x%02x%02x]", + conn.hci_handle, + conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]); + + return sk; + +error: + close(sk); + return -1; +} + +/** dump_mode Function + * This function waits till disconnection is intiated from headset or from + * the application. + * + * Parameters : + * @ sk : SCO socket id + * Returns VOID + */ +static void dump_mode(int sk) +{ + int len; + + /* Wait till disconnect is issued from the headset OR + * IF the application is killed using signals + */ + while ( ((len = read(sk, buffer, data_size)) > 0) && (!terminate) ) + syslog(LOG_INFO, "Recevied %d bytes", len); +} + +/** send_hciCmd Function + * This function takes the hci commands for the BT chip configurations, creates + * a hci channel to send the commadns through UART to configure BT chip + * + * Parameters : + * @ dev_id : HCI device ID + * @ command_length : Number of arguments of the command + * @ command : Pointer to command list + * Returns 0 upon success + * , different error messages depending upon the error. + */ +static void send_hciCmd(int dev_id, int command_length, char **command) +{ + unsigned char buf[HCI_MAX_EVENT_SIZE], *ptr = buf; + struct hci_filter flt; + hci_event_hdr *hdr; + int i, opt, len, dd; + uint16_t ocf; + uint8_t ogf; + + if (dev_id < 0) + dev_id = hci_get_route(NULL); + + errno = 0; + ogf = strtol(command[0], NULL, 16); + ocf = strtol(command[1], NULL, 16); + + for (i = 2, len = 0; i < command_length && len < sizeof(buf); i++, len++) + *ptr++ = (uint8_t) strtol(command[i], NULL, 16); + + dd = hci_open_dev(dev_id); + if (dd < 0) { + perror("Device open failed"); + return; + } + + /* Setup filter */ + hci_filter_clear(&flt); + hci_filter_set_ptype(HCI_EVENT_PKT, &flt); + hci_filter_all_events(&flt); + if (setsockopt(dd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) { + perror("HCI filter setup failed"); + return; + } + + /* Send the BT chip configuration commands */ + if (hci_send_cmd(dd, ogf, ocf, len, buf) < 0) { + perror("Send failed"); + return; + } + + /* Wait for the command completion event */ + len = read(dd, buf, sizeof(buf)); + if (len < 0) { + perror("Read failed"); + return; + } + + hdr = (void *)(buf + 1); + ptr = buf + (1 + HCI_EVENT_HDR_SIZE); + len -= (1 + HCI_EVENT_HDR_SIZE); + + hci_close_dev(dd); +} + +/** USAGE Function + * This function displays the usage of the bt_sco_app application. + * + * Parameters : + * @ VOID + * Returns VOID + */ +static void usage(void) +{ + printf("bt_scoapp\n" + "Usage:\n"); + printf("\tbt_scoapp [bd_addr]\n"); +} + +/** Main Function + * The main function takes the command line BD adress of headset as inputs , + * Calls the hci send configuration function and then creates a SCO connection. + * + * Parameters : + * @ argc : Number of arguments on the command line + * @ argv : Pointer to argument list - BD addr is the only valid argument. + * Returns 0 upon success + * , different error messages depending upon the error. + */ +int main(int argc ,char *argv[]) +{ + struct sigaction sa; + int opt, i = 0, sk; + + /* BT PCM configurations commands */ + char *command[] = { "0x3f", "0x106", /* OCF and OGF */ + "0x80", "0x00", /* Bit clock - 128KHz*/ + "0x00", /* BT chip as Master*/ + "0x40", "0x1f", "0x00", "0x00", /* Sampling rate - 8KHz*/ + "0x01", "0x00", /* 50% Duty cycle*/ + "0x00", /* Frame sync at falling edge*/ + "0x00", /* FS Active high polarity*/ + "0x00", /* FS direction - [Reserved]*/ + "0x10", "0x00", /* CH1 16 -bit OUT size*/ + "0x01", "0x00", /* One Clock delay */ + "0x00", /* Data driven at rising edge*/ + "0x10", "0x00", /* CH1 16 -bit IN size */ + "0x01", "0x00", /* CH1 DAta IN One Clock delay*/ + "0x00", /* Data driven at sampling edge*/ + "0x00", /* Reserved bit*/ + "0x10", "0x00", /* CH2 16 -bit OUT size*/ + "0x11", "0x00", /* CH2 data OUT off set*/ + "0x00", /* Data driven at rising edge*/ + "0x10", "0x00", /* CH2 16 -bit IN size*/ + "0x11", "0x00", /* CH2 data IN off set*/ + "0x00", /* Data Sampled at rising edge*/ + "0x00" /* Reserved bit*/ + }; + int command_length = 36; /* Length of the BT configuration commands */ + + /* Check if the number of arguemts mentioned is 2 */ + if (argc != 2) + { + printf("\n Wrong input - No BD headset address specified"); + usage(); + exit(1); + } + + memset(&sa, 0, sizeof(sa)); + sa.sa_flags = SA_NOCLDSTOP; + sa.sa_handler = sig_term; + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGCHLD, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); + + openlog("bt_sco_app", LOG_PERROR | LOG_PID, LOG_LOCAL0); + + /* Allocate memory for the buffer */ + if (!(buffer = malloc(data_size))) { + perror("Can't allocate data buffer"); + exit(1); + } + /* send the BT configuration commands */ + send_hciCmd(-1,command_length,command); + + sleep(2); /* wait for some time while BT chip is configured */ + + sk = do_connect(argv[1]); + if (sk < 0) + exit(1); + dump_mode(sk); + + syslog(LOG_INFO, "Exit"); + + closelog(); + + return 0; +} diff --git a/ti-wpan-products.mk b/ti-wpan-products.mk new file mode 100644 index 0000000..d7b8e6a --- /dev/null +++ b/ti-wpan-products.mk @@ -0,0 +1,28 @@ +# This file lists the firmware, software that are specific to +# WiLink connectivity chip on OMAPx platforms. + +PRODUCT_PACKAGES += uim-sysfs \ + bt_sco_app \ + kfmapp \ + BluetoothSCOApp \ + FmRxApp \ + FmTxApp \ + FmService \ + libfmradio \ + fmradioif \ + com.ti.fm.fmradioif.xml + +#copy firmware +PRODUCT_COPY_FILES += \ + device/ti/proprietary-open/wl12xx/wpan/bluetooth/TIInit_10.6.15.bts:system/etc/firmware/TIInit_10.6.15.bts \ + device/ti/proprietary-open/wl12xx/wpan/bluetooth/TIInit_7.2.31.bts:system/etc/firmware/TIInit_7.2.31.bts \ + device/ti/proprietary-open/wl12xx/wpan/bluetooth/TIInit_7.6.15.bts:system/etc/firmware/TIInit_7.6.15.bts \ + device/ti/proprietary-open/wl12xx/wpan/bluetooth/TIInit_12.7.27.bts:system/etc/firmware/TIInit_12.7.27.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fmc_ch8_1283.2.bts:system/etc/firmware/fmc_ch8_1283.2.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fm_rx_ch8_1283.2.bts:system/etc/firmware/fm_rx_ch8_1283.2.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fm_tx_ch8_1283.2.bts:system/etc/firmware/fm_tx_ch8_1283.2.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fmc_init_1273.2.bts:system/etc/firmware/fmc_init_1273.2.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fm_rx_init_1273.2.bts:system/etc/firmware/fm_rx_init_1273.2.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fm_tx_init_1273.2.bts:system/etc/firmware/fm_tx_init_1273.2.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fm_tx_ch8_1273.1.bts:system/etc/firmware/fm_tx_ch8_1273.1.bts \ + device/ti/proprietary-open/wl12xx/wpan/fmradio/fm_tx_ch8_1273.2.bts:system/etc/firmware/fm_tx_ch8_1273.2.bts diff --git a/ti_st/Android.mk b/ti_st/Android.mk new file mode 100644 index 0000000..b43eca9 --- /dev/null +++ b/ti_st/Android.mk @@ -0,0 +1,16 @@ +# +# Copyright (C) 2008 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. +# +include $(all-subdir-makefiles) diff --git a/ti_st/uim-sysfs/Android.mk b/ti_st/uim-sysfs/Android.mk new file mode 100644 index 0000000..32c6823 --- /dev/null +++ b/ti_st/uim-sysfs/Android.mk @@ -0,0 +1,18 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# +# UIM Application +# + +LOCAL_C_INCLUDES:= uim.h + +LOCAL_SRC_FILES:= \ + uim.c +LOCAL_CFLAGS:= -g -c -W -Wall -O2 -D_POSIX_SOURCE +LOCAL_SHARED_LIBRARIES:= libnetutils libcutils +LOCAL_MODULE:=uim-sysfs +LOCAL_MODULE_TAGS:= eng +include $(BUILD_EXECUTABLE) + + diff --git a/ti_st/uim-sysfs/uim.c b/ti_st/uim-sysfs/uim.c new file mode 100644 index 0000000..60e3400 --- /dev/null +++ b/ti_st/uim-sysfs/uim.c @@ -0,0 +1,828 @@ +/* + * User Mode Init manager - For TI shared transport + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program;if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <stdio.h> +#include <errno.h> +#include <fcntl.h> +#include <string.h> +#include <signal.h> +#include <sys/ioctl.h> +#include <termios.h> +#include <poll.h> +#include <stdint.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/utsname.h> +#include "uim.h" +#ifdef ANDROID +#include <private/android_filesystem_config.h> +#include <cutils/log.h> +#endif + + +/* Maintains the exit state of UIM*/ +static int exiting; + +/* BD address as string and a pointer to array of hex bytes */ +char uim_bd_address[17]; +bdaddr_t *bd_addr; + +/* File descriptor for the UART device*/ +int dev_fd; + +static inline void cleanup(int failed) +{ + /* for future use */ + (void)failed; + + if (dev_fd == -1) + return; + + UIM_DBG("%s", __func__); + + close(dev_fd); + dev_fd = -1; + /* unused failed for future reference */ +} + +/*****************************************************************************/ +#ifdef UIM_DEBUG +/* Function to Read the firmware version + * module into the system. Currently used for + * debugging purpose, whenever the baud rate is changed + */ +void read_firmware_version() +{ + int index = 0; + char resp_buffer[20] = { 0 }; + unsigned char buffer[] = { 0x01, 0x01, 0x10, 0x00 }; + + UIM_START_FUNC(); + UIM_VER(" wrote %d bytes", (int)write(dev_fd, buffer, 4)); + UIM_VER(" reading %d bytes", (int)read(dev_fd, resp_buffer, 15)); + + for (index = 0; index < 15; index++) + UIM_VER(" %x ", resp_buffer[index]); + + printf("\n"); +} +#endif /* UIM_DEBUG */ + +/*****************************************************************************/ +#ifdef ANDROID /* library for android to do insmod/rmmod */ + +/* Function to insert the kernel module into the system*/ +static int insmod(const char *filename, const char *args) +{ + void *module; + unsigned int size; + int ret = -1; + + UIM_START_FUNC(); + + module = (void *)load_file(filename, &size); + if (!module) + return ret; + + ret = init_module(module, size, args); + free(module); + + return ret; +} + +/* Function to remove the kernel module from the system*/ +static int rmmod(const char *modname) +{ + int ret = -1; + int maxtry = MAX_TRY; + + UIM_START_FUNC(); + + /* Retry MAX_TRY number of times in case of + * failure + */ + while (maxtry-- > 0) { + ret = delete_module(modname, O_NONBLOCK | O_EXCL); + if (ret < 0 && errno == EAGAIN) + sleep(1); + else + break; + } + + /* Failed to remove the module + */ + if (ret != 0) + UIM_ERR("Unable to unload driver module \"%s\": %s", + modname, strerror(errno)); + return ret; +} +#endif /* ANDROID */ + +/*****************************************************************************/ +/* Function to read the HCI event from the given file descriptor + * + * This will parse the response received and returns error + * if the required response is not received + */ +int read_hci_event(int fd, unsigned char *buf, int size) +{ + int remain, rd; + int count = 0; + int reading = 1; + int rd_retry_count = 0; + struct timespec tm = {0, 50*1000*1000}; + + UIM_START_FUNC(); + + UIM_VER(" read_hci_event"); + if (size <= 0) + return -1; + + /* The first byte identifies the packet type. For HCI event packets, it + * should be 0x04, so we read until we get to the 0x04. */ + while (reading) { + rd = read(fd, buf, 1); + if (rd <= 0 && rd_retry_count++ < 4) { + nanosleep(&tm, NULL); + continue; + } else if (rd_retry_count >= 4) { + return -1; + } + + if (buf[0] == RESP_PREFIX) { + break; + } + } + count++; + + /* The next two bytes are the event code and parameter total length. */ + while (count < 3) { + rd = read(fd, buf + count, 3 - count); + if (rd <= 0) + return -1; + count += rd; + } + + /* Now we read the parameters. */ + if (buf[2] < (size - 3)) + remain = buf[2]; + else + remain = size - 3; + + while ((count - 3) < remain) { + rd = read(fd, buf + count, remain - (count - 3)); + if (rd <= 0) + return -1; + count += rd; + } + + return count; +} + +/* Function to read the Command complete event + * + * This will read the response for the change speed + * command that was sent to configure the UART speed + * with the custom baud rate + */ +static int read_command_complete(int fd, unsigned short opcode) +{ + command_complete_t resp; + + UIM_START_FUNC(); + + UIM_VER(" Command complete started"); + if (read_hci_event(fd, (unsigned char *)&resp, sizeof(resp)) < 0) { + UIM_ERR(" Invalid response"); + return -1; + } + + /* Response should be an event packet */ + if (resp.uart_prefix != HCI_EVENT_PKT) { + UIM_ERR + (" Error in response: not an event packet, but 0x%02x!", + resp.uart_prefix); + return -1; + } + + /* Response should be a command complete event */ + if (resp.hci_hdr.evt != EVT_CMD_COMPLETE) { + /* event must be event-complete */ + UIM_ERR + (" Error in response: not a cmd-complete event,but 0x%02x!", + resp.hci_hdr.evt); + return -1; + } + + if (resp.hci_hdr.plen < 4) { + /* plen >= 4 for EVT_CMD_COMPLETE */ + UIM_ERR(" Error in response: plen is not >= 4, but 0x%02x!", + resp.hci_hdr.plen); + return -1; + } + + if (resp.cmd_complete.opcode != (unsigned short)opcode) { + UIM_ERR(" Error in response: opcode is 0x%04x, not 0x%04x!", + resp.cmd_complete.opcode, opcode); + return -1; + } + + UIM_DBG(" Command complete done"); + return resp.status == 0 ? 0 : -1; +} + +/* Function to set the default baud rate + * + * The default baud rate of 115200 is set to the UART from the host side + * by making a call to this function.This function is also called before + * making a call to set the custom baud rate + */ +static int set_baud_rate() +{ + struct termios ti; + + UIM_START_FUNC(); + + tcflush(dev_fd, TCIOFLUSH); + + /* Get the attributes of UART */ + if (tcgetattr(dev_fd, &ti) < 0) { + UIM_ERR(" Can't get port settings"); + return -1; + } + + /* Change the UART attributes before + * setting the default baud rate*/ + cfmakeraw(&ti); + + ti.c_cflag |= 1; + ti.c_cflag |= CRTSCTS; + + /* Set the attributes of UART after making + * the above changes + */ + tcsetattr(dev_fd, TCSANOW, &ti); + + /* Set the actual default baud rate */ + cfsetospeed(&ti, B115200); + cfsetispeed(&ti, B115200); + tcsetattr(dev_fd, TCSANOW, &ti); + + tcflush(dev_fd, TCIOFLUSH); + UIM_DBG(" set_baud_rate() done"); + + return 0; +} + +/* Function to set the UART custom baud rate. + * + * The UART baud rate has already been + * set to default value 115200 before calling this function. + * The baud rate is then changed to custom baud rate by this function*/ +static int set_custom_baud_rate(int cust_baud_rate, unsigned char flow_ctrl) +{ + UIM_START_FUNC(); + + struct termios ti; + struct termios2 ti2; + + /* Get the attributes of UART */ + if (tcgetattr(dev_fd, &ti) < 0) { + UIM_ERR(" Can't get port settings"); + return -1; + } + + UIM_VER(" Changing baud rate to %u, flow control to %u", + cust_baud_rate, flow_ctrl); + + /* Flush non-transmitted output data, + * non-read input data or both*/ + tcflush(dev_fd, TCIOFLUSH); + + /*Set the UART flow control */ + if (flow_ctrl) + ti.c_cflag |= CRTSCTS; + else + ti.c_cflag &= ~CRTSCTS; + + /* + * Set the parameters associated with the UART + * The change will occur immediately by using TCSANOW + */ + if (tcsetattr(dev_fd, TCSANOW, &ti) < 0) { + UIM_ERR(" Can't set port settings"); + return -1; + } + + tcflush(dev_fd, TCIOFLUSH); + + /*Set the actual baud rate */ + ioctl(dev_fd, TCGETS2, &ti2); + ti2.c_cflag &= ~CBAUD; + ti2.c_cflag |= BOTHER; + ti2.c_ospeed = cust_baud_rate; + ioctl(dev_fd, TCSETS2, &ti2); + + UIM_DBG(" set_custom_baud_rate() done"); + return 0; +} + +/* + * Handling the Signals sent from the Kernel Init Manager. + * After receiving the indication from rfkill subsystem, configure the + * baud rate, flow control and Install the N_TI_WL line discipline + */ +int st_uart_config(unsigned char install) +{ + int ldisc, len, fd; + unsigned char uart_dev_name[32]; + unsigned char buf[32]; + unsigned long cust_baud_rate; + unsigned int flow_ctrl; + + uim_speed_change_cmd cmd; + uim_bdaddr_change_cmd addr_cmd; + + UIM_START_FUNC(); + + if (install == '1') { + UIM_DBG("install set to 1"); + memset(buf, 0, 32); + fd = open(DEV_NAME_SYSFS, O_RDONLY); + if (fd < 0) { + UIM_ERR("Can't open %s", DEV_NAME_SYSFS); + return -1; + } + len = read(fd, buf, 32); + if (len < 0) { + UIM_ERR("read err (%s)", strerror(errno)); + close(fd); + return len; + } + sscanf((const char*)buf, "%s", uart_dev_name); + close(fd); + + memset(buf, 0, 32); + fd = open(BAUD_RATE_SYSFS, O_RDONLY); + if (fd < 0) { + UIM_ERR("Can't open %s", BAUD_RATE_SYSFS); + return -1; + } + len = read(fd, buf, 32); + if (len < 0) { + UIM_ERR("read err (%s)", strerror(errno)); + close(fd); + return len; + } + close(fd); + sscanf((const char*)buf, "%ld", &cust_baud_rate); + + memset(buf, 0, 32); + fd = open(FLOW_CTRL_SYSFS, O_RDONLY); + if (fd < 0) { + UIM_ERR("Can't open %s", FLOW_CTRL_SYSFS); + close(fd); + return -1; + } + len = read(fd, buf, 32); + if (len < 0) { + UIM_ERR("read err (%s)", strerror(errno)); + close(fd); + return len; + } + close(fd); + sscanf((const char*)buf, "%u", &flow_ctrl); + + if (dev_fd != -1) { + UIM_ERR("opening %s, while already open", uart_dev_name); + cleanup(-1); + } + + dev_fd = open((const char*) uart_dev_name, O_RDWR); + if (dev_fd < 0) { + UIM_ERR(" Can't open %s", uart_dev_name); + return -1; + } + /* + * Set only the default baud rate. + * This will set the baud rate to default 115200 + */ + if (set_baud_rate() < 0) { + UIM_ERR(" set_baudrate() failed"); + cleanup(-1); + return -1; + } + + fcntl(dev_fd, F_SETFL,fcntl(dev_fd, F_GETFL) | O_NONBLOCK); + /* Set only thecustom baud rate */ + if (cust_baud_rate != 115200) { + + /* Forming the packet for Change speed command */ + cmd.uart_prefix = HCI_COMMAND_PKT; + cmd.hci_hdr.opcode = HCI_HDR_OPCODE; + cmd.hci_hdr.plen = sizeof(unsigned long); + cmd.speed = cust_baud_rate; + + /* Writing the change speed command to the UART + * This will change the UART speed at the controller + * side + */ + UIM_VER(" Setting speed to %ld", cust_baud_rate); + len = write(dev_fd, &cmd, sizeof(cmd)); + if (len < 0) { + UIM_ERR(" Failed to write speed-set command"); + cleanup(-1); + return -1; + } + + /* Read the response for the Change speed command */ + if (read_command_complete(dev_fd, HCI_HDR_OPCODE) < 0) { + cleanup(-1); + return -1; + } + + UIM_VER(" Speed changed to %ld", cust_baud_rate); + + /* Set the actual custom baud rate at the host side */ + if (set_custom_baud_rate(cust_baud_rate, flow_ctrl) < 0) { + UIM_ERR(" set_custom_baud_rate() failed"); + cleanup(-1); + return -1; + } + + /* Set the uim BD address */ + if (uim_bd_address[0] != 0) { + + memset(&addr_cmd, 0, sizeof(addr_cmd)); + /* Forming the packet for change BD address command*/ + addr_cmd.uart_prefix = HCI_COMMAND_PKT; + addr_cmd.hci_hdr.opcode = WRITE_BD_ADDR_OPCODE; + addr_cmd.hci_hdr.plen = sizeof(bdaddr_t); + memcpy(&addr_cmd.addr, bd_addr, sizeof(bdaddr_t)); + + /* Writing the change BD address command to the UART + * This will change the change BD address at the controller + * side + */ + len = write(dev_fd, &addr_cmd, sizeof(addr_cmd)); + if (len < 0) { + UIM_ERR(" Failed to write BD address command"); + cleanup(-1); + return -1; + } + + /* Read the response for the change BD address command */ + if (read_command_complete(dev_fd, WRITE_BD_ADDR_OPCODE) < 0) { + cleanup(-1); + return -1; + } + + UIM_VER(" BD address changed to %s", uim_bd_address); + } +#ifdef UIM_DEBUG + read_firmware_version(); +#endif + } + + /* After the UART speed has been changed, the IOCTL is + * is called to set the line discipline to N_TI_WL + */ + ldisc = 22; + if (ioctl(dev_fd, TIOCSETD, &ldisc) < 0) { + UIM_ERR(" Can't set line discipline"); + cleanup(-1); + return -1; + } + UIM_DBG(" Installed N_TI_WL Line displine"); + } + else { + UIM_DBG(" Un-Installed N_TI_WL Line displine"); + /* UNINSTALL_N_TI_WL - When the Signal is received from KIM */ + /* closing UART fd */ + cleanup(0); + dev_fd = -1; + } + return 0; +} + +int remove_modules() +{ + int err = 0; + +#ifdef ANDROID + UIM_VER(" Removing gps_drv "); + if (rmmod("gps_drv") != 0) { + UIM_ERR(" Error removing gps_drv module"); + err = -1; + } else { + UIM_DBG(" Removed gps_drv module"); + } + + UIM_VER(" Removing fm_drv "); + if (rmmod("fm_drv") != 0) { + UIM_ERR(" Error removing fm_drv module"); + err = -1; + } else { + UIM_DBG(" Removed fm_drv module"); + } + UIM_DBG(" Removed fm_drv module"); + + UIM_VER(" Removing btwilink "); + if (rmmod("btwilink") != 0) { + UIM_ERR(" Error removing btwilink module"); + err = -1; + } else { + UIM_DBG(" Removed btwilink module"); + } + UIM_DBG(" Removed btwilink module"); + + /*Remove the Shared Transport */ + UIM_VER(" Removing st_drv "); + if (rmmod("st_drv") != 0) { + UIM_ERR(" Error removing st_drv module"); + err = -1; + } else { + UIM_DBG(" Removed st_drv module "); + } + UIM_DBG(" Removed st_drv module "); +#else + UIM_VER(" Removing btwilink "); + if (system("rmmod btwilink") != 0) { + UIM_ERR(" Error removing btwilink module"); + err = -1; + } else { + UIM_DBG(" Removed btwilink module"); + } + + UIM_VER(" Removing fm_drv "); + if (system("rmmod fm_drv") != 0) { + UIM_ERR(" Error removing fm_drv module"); + err = -1; + } else { + UIM_DBG(" Removed fm_drv module "); + } + + /*Remove the Shared Transport */ + UIM_VER(" Removing st_drv "); + if (system("rmmod st_drv") != 0) { + UIM_ERR(" Error removing st_drv module"); + err = -1; + } else { + UIM_DBG(" Removed st_drv module "); + } +#endif + return err; +} + +int change_rfkill_perms(void) +{ + int fd, id, sz; + char path[64]; + char buf[16]; + for (id = 0; id < 50; id++) { + snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id); + fd = open(path, O_RDONLY); + if (fd < 0) { + UIM_DBG("open(%s) failed: %s (%d)\n", path, strerror(errno), errno); + continue; + } + sz = read(fd, &buf, sizeof(buf)); + close(fd); + if (sz >= 9 && memcmp(buf, "bluetooth", 9) == 0) { + UIM_DBG("found bluetooth rfkill entry @ %d\n", id); + break; + } + } + if (id == 50) { + return -1; + } +#ifdef ANDROID + sprintf(path, "/sys/class/rfkill/rfkill%d/state", id); + sz = chown(path, AID_BLUETOOTH, AID_BLUETOOTH); + if (sz < 0) { + UIM_ERR("change mode failed for %s (%d)\n", path, errno); + return -1; + } +#endif + /* + * bluetooth group's user system needs write permission + */ + sz = chmod(path, 0660); + if (sz < 0) { + UIM_ERR("change mode failed for %s (%d)\n", path, errno); + return -1; + } + UIM_DBG("changed permissions for %s(%d) \n", path, sz); + /* end of change_perms */ + + return 0; +} + +void *bt_malloc(size_t size) +{ + return malloc(size); +} + +/* Function to convert the BD address from ascii to hex value */ +bdaddr_t *strtoba(const char *str) +{ + const char *ptr = str; + int i; + + uint8_t *ba = bt_malloc(sizeof(bdaddr_t)); + if (!ba) + return NULL; + + for (i = 0; i < 6; i++) { + ba[i] = (uint8_t) strtol(ptr, NULL, 16); + if (i != 5 && !(ptr = strchr(ptr, ':'))) + ptr = ":00:00:00:00:00"; + ptr++; + } + + return (bdaddr_t *) ba; +} + +/*****************************************************************************/ +int main(int argc, char *argv[]) +{ + int st_fd,err; + struct stat file_stat; +#ifndef ANDROID /* used on ubuntu */ + char *tist_ko_path; + struct utsname name; +#endif + struct pollfd p; + unsigned char install; + + UIM_START_FUNC(); + err = 0; + + /* Parse the user input */ + if (argc == 2) { + memset(&uim_bd_address, 0, sizeof(uim_bd_address)); + /* BD address passed as string in xx:xx:xx:xx:xx:xx format */ + strcpy(uim_bd_address, argv[1]); + bd_addr = strtoba(uim_bd_address); + } else if (argc != 1) { + UIM_ERR(" Invalid arguements"); + UIM_ERR(" Usage: uim <bd address>"); + return -1; + } + +#ifndef ANDROID + if (uname (&name) == -1) { + UIM_ERR("cannot get kernel release name"); + return -1; + } +#else /* if ANDROID */ + + if (0 == lstat("/st_drv.ko", &file_stat)) { + if (insmod("/st_drv.ko", "") < 0) { + UIM_ERR(" Error inserting st_drv module"); + return -1; + } else { + UIM_DBG(" Inserted st_drv module"); + } + } else { + if (0 == lstat(INSTALL_SYSFS_ENTRY, &file_stat)) { + UIM_DBG("ST built into the kernel ?"); + } else { + UIM_ERR("BT/FM/GPS would be unavailable on system"); + return -1; + } + } + + if (0 == lstat("/btwilink.ko", &file_stat)) { + if (insmod("/btwilink.ko", "") < 0) { + UIM_ERR(" Error inserting btwilink module, NO BT? "); + } else { + UIM_DBG(" Inserted btwilink module"); + } + } else { + UIM_DBG("BT driver module un-available... "); + UIM_DBG("BT driver built into the kernel ?"); + } + + if (0 == lstat("/fm_drv.ko", &file_stat)) { + if (insmod("/fm_drv.ko", "") < 0) { + UIM_ERR(" Error inserting fm_drv module, NO FM? "); + } else { + UIM_DBG(" Inserted fm_drv module"); + } + } else { + UIM_DBG("FM driver module un-available... "); + UIM_DBG("FM driver built into the kernel ?"); + } + + if (0 == lstat("/gps_drv.ko", &file_stat)) { + if (insmod("/gps_drv.ko", "") < 0) { + UIM_ERR(" Error inserting gps_drv module, NO GPS? "); + } else { + UIM_DBG(" Inserted gps_drv module"); + } + } else { + UIM_DBG("GPS driver module un-available... "); + UIM_DBG("GPS driver built into the kernel ?"); + } + + if (0 == lstat("/fm_v4l2_drv.ko", &file_stat)) { + if (insmod("/fm_v4l2_drv.ko", "") < 0) { + UIM_ERR(" Error inserting fm_v4l2_drv module, NO FM? "); + } else { + UIM_DBG(" Inserted fm_v4l2_drv module"); + } + } else { + UIM_DBG("FM V4L2 driver module un-available... "); + UIM_DBG("FM V4L2 driver built into the kernel ?"); + } + /* Change the permissions for v4l2 Fm device node */ + if ((0 == lstat("/dev/radio0", &file_stat)) && chmod("/dev/radio0", 0666) < 0) { + UIM_ERR("unable to chmod /dev/radio0, might not exist"); + } + if ((0 == lstat("/dev/tifm", &file_stat)) && chmod("/dev/tifm", 0666) < 0) { + UIM_ERR("unable to chmod /dev/tifm, might not exist"); + } + /* change rfkill perms after insertion of BT driver which asks + * the Bluetooth sub-system to create the rfkill device of type + * "bluetooth" + */ + if (change_rfkill_perms() < 0) { + /* possible error condition */ + UIM_ERR("rfkill not enabled in st_drv - BT on from UI might fail\n"); + } + +#endif /* ANDROID */ + /* rfkill device's open/poll/read */ + st_fd = open(INSTALL_SYSFS_ENTRY, O_RDONLY); + if (st_fd < 0) { + UIM_DBG("unable to open %s (%s)", INSTALL_SYSFS_ENTRY, + strerror(errno)); + remove_modules(); + return -1; + } + +RE_POLL: + err = read(st_fd, &install, 1); + if ((err > 0) && (install == '1')) { + UIM_DBG("install already set"); + st_uart_config(install); + } + + memset(&p, 0, sizeof(p)); + p.fd = st_fd; + /* sysfs entries can only break poll for following events */ + p.events = POLLERR | POLLHUP; + + while (!exiting) { + p.revents = 0; + err = poll(&p, 1, -1); + if (err < 0 && errno == EINTR) + continue; + if (err) + break; + } + + close(st_fd); + st_fd = open(INSTALL_SYSFS_ENTRY, O_RDONLY); + if (st_fd < 0) { + UIM_ERR("re-opening %s failed: %s", INSTALL_SYSFS_ENTRY, + strerror(errno)); + return -1; + } + + if (!exiting) + { + err = read(st_fd, &install, 1); + if (err <= 0) { + UIM_ERR("reading %s failed: %s", INSTALL_SYSFS_ENTRY, + strerror(errno)); + goto RE_POLL; + } + st_uart_config(install); + goto RE_POLL; + } + + if(remove_modules() < 0) { + UIM_ERR(" Error removing modules "); + close(st_fd); + return -1; + } + + close(st_fd); + return 0; +} diff --git a/ti_st/uim-sysfs/uim.h b/ti_st/uim-sysfs/uim.h new file mode 100644 index 0000000..b7d981d --- /dev/null +++ b/ti_st/uim-sysfs/uim.h @@ -0,0 +1,147 @@ +/* + * User Mode Init manager - For shared transport + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program;if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef UIM_H +#define UIM_H + +/* Paramaters to set the baud rate*/ +#define FLOW_CTL 0x0001 +#define BOTHER 0x00001000 +#define ARM_NCCS 19 + +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) + +/*HCI Command and Event information*/ +#define HCI_HDR_OPCODE 0xff36 +#define WRITE_BD_ADDR_OPCODE 0xFC06 +#define RESP_PREFIX 0x04 +#define MAX_TRY 10 + +/* HCI Packet types */ +#define HCI_COMMAND_PKT 0x01 +#define HCI_EVENT_PKT 0x04 + +/* HCI command macros*/ +#define HCI_EVENT_HDR_SIZE 2 +#define HCI_COMMAND_HDR_SIZE 3 +#define UIM_WRITE_BD_ADDR_CP_SIZE 6 + + +/* HCI event macros*/ +#define EVT_CMD_COMPLETE_SIZE 3 +#define EVT_CMD_STATUS_SIZE 4 +#define EVT_CMD_COMPLETE 0x0E +#define EVT_CMD_STATUS 0x0F + + +#define VERBOSE +#ifdef ANDROID +#define LOG_TAG "uim-sysfs" +#define UIM_ERR(fmt, arg...) LOGE("uim:"fmt"\n" , ##arg) +#if defined(UIM_DEBUG) /* limited debug messages */ +#define UIM_START_FUNC() LOGE("uim: Inside %s", __FUNCTION__) +#define UIM_DBG(fmt, arg...) LOGE("uim:"fmt"\n" , ## arg) +#define UIM_VER(fmt, arg...) +#elif defined(VERBOSE) /* very verbose */ +#define UIM_START_FUNC() LOGE("uim: Inside %s", __FUNCTION__) +#define UIM_DBG(fmt, arg...) LOGE("uim:"fmt"\n" , ## arg) +#define UIM_VER(fmt, arg...) LOGE("uim:"fmt"\n" , ## arg) +#else /* error msgs only */ +#define UIM_START_FUNC() +#define UIM_DBG(fmt, arg...) +#define UIM_VER(fmt, arg...) +#endif +#endif /* ANDROID */ + +/*Termios2 structure for setting the Custom baud rate*/ +struct termios2 { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[ARM_NCCS]; /* control characters */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + +/* HCI command header*/ +typedef struct { + uint16_t opcode; /* OCF & OGF */ + uint8_t plen; +} __attribute__ ((packed)) hci_command_hdr; + +/* HCI event header*/ +typedef struct { + uint8_t evt; + uint8_t plen; +} __attribute__ ((packed)) hci_event_hdr; + +/* HCI command complete event*/ +typedef struct { + uint8_t ncmd; + uint16_t opcode; +} __attribute__ ((packed)) evt_cmd_complete; + +/* HCI event status*/ +typedef struct { + uint8_t status; + uint8_t ncmd; + uint16_t opcode; +} __attribute__ ((packed)) evt_cmd_status; + +/* HCI Event structure to set the cusrom baud rate*/ +typedef struct { + uint8_t uart_prefix; + hci_event_hdr hci_hdr; + evt_cmd_complete cmd_complete; + uint8_t status; + uint8_t data[16]; +} __attribute__ ((packed)) command_complete_t; + +/* HCI Command structure to set the cusrom baud rate*/ +typedef struct { + uint8_t uart_prefix; + hci_command_hdr hci_hdr; + uint32_t speed; +} __attribute__ ((packed)) uim_speed_change_cmd; + +/* BD address structure to set the uim BD address*/ +typedef struct { + unsigned char b[6]; +} __attribute__((packed)) bdaddr_t; + +/* HCI Command structure to set the uim BD address*/ +typedef struct { + uint8_t uart_prefix; + hci_command_hdr hci_hdr; + bdaddr_t addr; +} __attribute__ ((packed)) uim_bdaddr_change_cmd; + +#define INSTALL_SYSFS_ENTRY "/sys/devices/platform/kim/install" +#define DEV_NAME_SYSFS "/sys/devices/platform/kim/dev_name" +#define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate" +#define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl" + +/* Functions to insert and remove the kernel modules from the system*/ +extern int init_module(void *, unsigned int, const char *); +extern int delete_module(const char *, unsigned int); +extern int load_file(const char *, unsigned int *); + +#endif /* UIM_H */ diff --git a/tools/BluetoothSCOApp/Android.mk b/tools/BluetoothSCOApp/Android.mk new file mode 100644 index 0000000..810bea0 --- /dev/null +++ b/tools/BluetoothSCOApp/Android.mk @@ -0,0 +1,18 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := BluetoothSCOApp +LOCAL_SDK_VERSION := current +LOCAL_CERTIFICATE := shared + + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) + + diff --git a/tools/BluetoothSCOApp/AndroidManifest.xml b/tools/BluetoothSCOApp/AndroidManifest.xml new file mode 100644 index 0000000..ac57300 --- /dev/null +++ b/tools/BluetoothSCOApp/AndroidManifest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.ti.bluetoothSCOapp" > + <uses-permission android:name="android.permission.BLUETOOTH" /> + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> + <uses-permission android:name="android.permission.BROADCAST_STICKY" /> + + <application android:icon="@drawable/icon" android:label="@string/app_name"> + <activity android:name=".connect" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + </application> + +</manifest> diff --git a/tools/BluetoothSCOApp/CleanSpec.mk b/tools/BluetoothSCOApp/CleanSpec.mk new file mode 100644 index 0000000..169d6aa --- /dev/null +++ b/tools/BluetoothSCOApp/CleanSpec.mk @@ -0,0 +1,52 @@ +# 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. +# + + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS//BluetoothSCOApp*) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/BluetoothSCOApp*) + +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ diff --git a/tools/BluetoothSCOApp/default.properties b/tools/BluetoothSCOApp/default.properties new file mode 100644 index 0000000..e2e8061 --- /dev/null +++ b/tools/BluetoothSCOApp/default.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 diff --git a/tools/BluetoothSCOApp/gen/com/ti/bluetoothSCOapp/R.java b/tools/BluetoothSCOApp/gen/com/ti/bluetoothSCOapp/R.java new file mode 100644 index 0000000..e45ec40 --- /dev/null +++ b/tools/BluetoothSCOApp/gen/com/ti/bluetoothSCOapp/R.java @@ -0,0 +1,31 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.ti.bluetoothSCOapp; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int icon=0x7f020000; + } + public static final class id { + public static final int CheckBox01=0x7f050002; + public static final int TextView01=0x7f050000; + public static final int TextView02=0x7f050001; + } + public static final class layout { + public static final int main=0x7f030000; + } + public static final class string { + public static final int BTenable=0x7f040002; + public static final int Copyright=0x7f040003; + public static final int Version=0x7f040004; + public static final int app_name=0x7f040001; + public static final int hello=0x7f040000; + } +} diff --git a/tools/BluetoothSCOApp/res/drawable-hdpi/icon.png b/tools/BluetoothSCOApp/res/drawable-hdpi/icon.png Binary files differnew file mode 100644 index 0000000..6ca35af --- /dev/null +++ b/tools/BluetoothSCOApp/res/drawable-hdpi/icon.png diff --git a/tools/BluetoothSCOApp/res/drawable-ldpi/icon.png b/tools/BluetoothSCOApp/res/drawable-ldpi/icon.png Binary files differnew file mode 100644 index 0000000..6ca35af --- /dev/null +++ b/tools/BluetoothSCOApp/res/drawable-ldpi/icon.png diff --git a/tools/BluetoothSCOApp/res/drawable-mdpi/icon.png b/tools/BluetoothSCOApp/res/drawable-mdpi/icon.png Binary files differnew file mode 100644 index 0000000..6ca35af --- /dev/null +++ b/tools/BluetoothSCOApp/res/drawable-mdpi/icon.png diff --git a/tools/BluetoothSCOApp/res/layout/main.xml b/tools/BluetoothSCOApp/res/layout/main.xml new file mode 100644 index 0000000..108b108 --- /dev/null +++ b/tools/BluetoothSCOApp/res/layout/main.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > +<TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" android:capitalize="words"/> +<TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="@string/Copyright"></TextView> +<TextView android:text="@string/Version" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> +<CheckBox android:id="@+id/CheckBox01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="@string/BTenable" android:checked="false" android:clickable="true" android:onClick="@string/BTenable"></CheckBox> + +</LinearLayout> diff --git a/tools/BluetoothSCOApp/res/values/strings.xml b/tools/BluetoothSCOApp/res/values/strings.xml new file mode 100644 index 0000000..409ea9b --- /dev/null +++ b/tools/BluetoothSCOApp/res/values/strings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="hello">Bluetooth SCO Music Enable</string> + <string name="app_name">BluetoothSCOApp</string> + +<string name="BTenable">Enable Music via Media Player</string> +<string name="Copyright">Texas Instruments</string> +<string name="Version">Ver 2.0</string> +</resources> diff --git a/tools/BluetoothSCOApp/src/com/ti/bluetoothSCOapp/connect.java b/tools/BluetoothSCOApp/src/com/ti/bluetoothSCOapp/connect.java new file mode 100644 index 0000000..3a95954 --- /dev/null +++ b/tools/BluetoothSCOApp/src/com/ti/bluetoothSCOapp/connect.java @@ -0,0 +1,172 @@ +/* + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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. + */ + +/* Bluetooth SCO App: The app establishes a SCO connection for non-voice call + * use case, for eg. Music streaming(mono) on BT SCO link. Also, BT SCO voice record + * can also be tested from sound recorder after running this app. + * + * Version: 2.0 + */ + +package com.ti.bluetoothSCOapp; + +import java.util.Set; + +import android.app.Activity; +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.media.AudioManager; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.CheckBox; +import android.widget.Toast; + + +public class connect extends Activity { + private static final String TAG = "BluetoothSCO"; + private static final boolean DEBUG = true; + private AudioManager mAudioManager = null; + private Context mContext = null; + /* Broadcast receiver for the SCO State broadcast intent.*/ + private final BroadcastReceiver mSCOHeadsetAudioState = new BroadcastReceiver() { + + public void onReceive(Context context, Intent intent) { + //if(DEBUG) + // Log.e(TAG, " mSCOHeadsetAudioState--->onReceive"); + + int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1); + + if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) { + DisplayToast("BT SCO Music is now enabled. Play song in Media Player"); + } else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) { + DisplayToast("BT SCO Music is now disabled"); + } + } + }; + + // Local Bluetooth adapter + private BluetoothAdapter mBluetoothAdapter = null; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + // Get local Bluetooth adapter + mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + + // If the adapter is null, then Bluetooth is not supported + if (mBluetoothAdapter == null) { + Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); + finish(); + return; + } + mContext = this; + IntentFilter newintent = new IntentFilter(); + newintent.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED); + mContext.registerReceiver(mSCOHeadsetAudioState, newintent); + + // Check whether BT is enabled + if (!mBluetoothAdapter.isEnabled()) { + Toast.makeText(this, "Bluetooth is not enabled", Toast.LENGTH_LONG).show(); + finish(); + return; + } + + // get the Audio Service context + mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); + if (mAudioManager == null){ + Log.e(TAG, "mAudiomanager is null"); + finish(); + return; + } + // Android 2.2 onwards supports BT SCO for non-voice call use case + // Check the Android version whether it supports or not. + if(!mAudioManager.isBluetoothScoAvailableOffCall()) { + Toast.makeText(this, "Platform does not support use of SCO for off call", Toast.LENGTH_LONG).show(); + finish(); + return; + } + + // Check list of bonded devices + Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices(); + // If there are paired devices + if (pairedDevices.size() > 0) { + // Loop through paired devices + for (BluetoothDevice device : pairedDevices) { + Log.e(TAG, "BT Device :"+device.getName()+ " , BD_ADDR:" + device.getAddress()); + } + // To do: + // Need to check from the paired devices which supports BT HF profile + // and take action based on that. + } else { + Toast.makeText(this, "No Paired Headset, Pair and connect to phone audio", Toast.LENGTH_LONG).show(); + finish(); + return; + } + + // Check whether BT A2DP (media) is connected + // If yes, ask user to disconnect + if(mAudioManager.isBluetoothA2dpOn ()){ + Toast.makeText(this, "Disconnect A2DP (media audio) to headset from Bluetooth Settings", Toast.LENGTH_LONG).show(); + finish(); + return; + } + + // Check whether it is connected to phone audio + // TO DO: + Toast.makeText(this, "Make sure:Device is connected to Headset & Connected to Phone Audio only!", Toast.LENGTH_LONG).show(); + + // Ok everything seems to be fine + // start now + CheckBox checkBox = (CheckBox) findViewById(R.id.CheckBox01); + + checkBox.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + if (((CheckBox)v).isChecked()) { + if(DEBUG) + Log.e(TAG, "BTSCOApp: Checkbox Checked "); + mAudioManager.setBluetoothScoOn(true); + mAudioManager.startBluetoothSco(); + // OMAP4 has dedicated support for MM playback on BT SCO + // so just establish SCO connection and play music in media player + // OMAP4 ABE takes care of 44.1 to 8k conversion. + + // For other platform or omap3, the user + // needs to play mono 8k sample using aplay on shell + } else { + if(DEBUG) + Log.e(TAG, "BTSCOApp Checkbox Unchecked "); + mAudioManager.setBluetoothScoOn(false); + mAudioManager.stopBluetoothSco(); + } + } + }); + } + + private void DisplayToast(String msg) + { + Toast.makeText(getBaseContext(), msg, + Toast.LENGTH_SHORT).show(); + } + +} diff --git a/tools/BluetoothSCOApp/strings.xml b/tools/BluetoothSCOApp/strings.xml new file mode 100644 index 0000000..0619a58 --- /dev/null +++ b/tools/BluetoothSCOApp/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="hello">Bluetooth SCO Music Enable</string> + <string name="app_name">BluetoothSCOApp</string> + +<string name="BTenable">Enable Music via Media Player</string> +<string name="Copyright">Texas Instruments</string> +</resources> diff --git a/tools/FM/Android.mk b/tools/FM/Android.mk new file mode 100644 index 0000000..731361c --- /dev/null +++ b/tools/FM/Android.mk @@ -0,0 +1,24 @@ +# +# +# Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ +# +# 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. +# +#TO Check whether we need any flags to enable FM +#ifeq ($(CFG_FM_SERVICE_TI),yes) + include hardware/ti/wpan/tools/FM/FmRxApp/Android.mk + include hardware/ti/wpan/tools/FM/FmTxApp/Android.mk + include hardware/ti/wpan/tools/FM/service/Android.mk + include hardware/ti/wpan/tools/FM/FmRadioIf/Android.mk + include hardware/ti/wpan/tools/FM/service/src/jni/Android.mk +#endif diff --git a/tools/FM/FmRadioIf/Android.mk b/tools/FM/FmRadioIf/Android.mk new file mode 100644 index 0000000..5be232f --- /dev/null +++ b/tools/FM/FmRadioIf/Android.mk @@ -0,0 +1,35 @@ +# +# +# Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ +# +# 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. +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := fmradioif +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := $(call all-java-files-under, src) \ + src/java/com/ti/fm/IFmRadio.aidl + +include $(BUILD_JAVA_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := com.ti.fm.fmradioif.xml +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions +LOCAL_SRC_FILES := $(LOCAL_MODULE) + +LOCAL_CERTIFICATE := platform +include $(BUILD_PREBUILT) + diff --git a/tools/FM/FmRadioIf/com.ti.fm.fmradioif.xml b/tools/FM/FmRadioIf/com.ti.fm.fmradioif.xml new file mode 100644 index 0000000..411f13c --- /dev/null +++ b/tools/FM/FmRadioIf/com.ti.fm.fmradioif.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> + +<permissions> + <library name="fmradioif" + file="/system/framework/fmradioif.jar"/> +</permissions> diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/IJFmEnum.java b/tools/FM/FmRadioIf/src/java/com/ti/core/IJFmEnum.java new file mode 100644 index 0000000..69ed3f4 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/IJFmEnum.java @@ -0,0 +1,22 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +public interface IJFmEnum<V> { + V getValue(); +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmCcmVacUnavailResourceList.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmCcmVacUnavailResourceList.java new file mode 100644 index 0000000..f5fadbf --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmCcmVacUnavailResourceList.java @@ -0,0 +1,56 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import com.ti.jfm.core.JFmRxCcmVacResourceOwner; + +public class JFmCcmVacUnavailResourceList { + + final int MAX_NUM_OF_PROPERTIES_PER_RESOURCE = 5; + + private JFmRxCcmVacResourceOwner[] ccmVacResourceOwner = new JFmRxCcmVacResourceOwner[MAX_NUM_OF_PROPERTIES_PER_RESOURCE]; + + private long uNumOfUnavailResources; + + public JFmCcmVacUnavailResourceList() { + this.uNumOfUnavailResources = 0; + } + + public JFmCcmVacUnavailResourceList(JFmRxCcmVacResourceOwner[] ccmVacResourceOwner, + long uNumOfUnavailResources) { + this.ccmVacResourceOwner = ccmVacResourceOwner; + this.uNumOfUnavailResources = uNumOfUnavailResources; + } + + public JFmRxCcmVacResourceOwner[] getResourceOwner() { + return ccmVacResourceOwner; + } + + public void setResourceOwner(JFmRxCcmVacResourceOwner[] resource) { + this.ccmVacResourceOwner = resource; + } + + public long getNumOfUnavailResources() { + return uNumOfUnavailResources; + } + + public void setNumOfUnavailResources(Long numUnavailableResource) { + this.uNumOfUnavailResources = numUnavailableResource; + } + +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmContext.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmContext.java new file mode 100644 index 0000000..38ea067 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmContext.java @@ -0,0 +1,58 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import android.util.Log; + +public class JFmContext { + private long value = 0; + + public static final long INVALID_CONTEXT_VALUE = -1; + + public JFmContext() { + value = INVALID_CONTEXT_VALUE; + } + + public JFmContext(long contextValue) { + value = contextValue; + } + + @Override + public boolean equals(Object otherContextAsObject) { + if (otherContextAsObject instanceof JFmContext) { + return (value == ((JFmContext) otherContextAsObject).getValue()); + } else { + return false; + } + } + + @Override + public int hashCode() { + return (int) value; + } + + public final long getValue() { + return value; + } + + public final void setValue(int value) { + Log.d("JFmContext()", "setValue: setValue called, value:" + value); + this.value = value; + } + +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmLog.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmLog.java new file mode 100644 index 0000000..43152d5 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmLog.java @@ -0,0 +1,43 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import android.util.Log; + +public final class JFmLog { + + public static int v(String tag, String msg) { + return Log.v(tag, msg); + } + + public static int d(String tag, String msg) { + return Log.d(tag, msg); + } + + public static int i(String tag, String msg) { + return Log.i(tag, msg); + } + + public static int w(String tag, String msg) { + return Log.w(tag, msg); + } + + public static int e(String tag, String msg) { + return Log.e(tag, msg); + } +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRx.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRx.java new file mode 100644 index 0000000..fc91d95 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRx.java @@ -0,0 +1,2744 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import java.util.HashMap; //import com.ti.jbtl.core.*; +import com.ti.jfm.core.*; + +/** Class for providing connection with JFmRxNative.cpp module */ + +public class JFmRx { + + private static final String TAG = "JFmRx"; + + private ICallback callback = null; + + private static JFmContext context; + + /** Hash table to store JFmContext handles based upon JFmRx. */ + private static HashMap<JFmContext, JFmRx> mRxContextsTable = new HashMap<JFmContext, JFmRx>(); + + static { + try { + JFmLog.i(TAG, "Loading libfmradio.so"); + System.loadLibrary("fmradio"); + nativeJFmRx_ClassInitNative(); + } + catch (UnsatisfiedLinkError ule) { + JFmLog.e(TAG, "WARNING: Could not load libfmradio.so"); + } + catch (Exception e) { + JFmLog.e("JFmRx", "Exception during NativeJFmRx_ClassInitNative (" + + e.toString() + ")"); + } + } + + + + public interface ICallback { + + void fmRxRawRDS(JFmRx context, JFmRxStatus status, JFmRxRdsGroupTypeMask bitInMaskValue, + byte[] groupData); + + void fmRxRadioText(JFmRx context, JFmRxStatus status, boolean resetDisplay, byte[] msg1, + int len, int startIndex, JFmRxRepertoire repertoire); + + void fmRxPiCodeChanged(JFmRx context, JFmRxStatus status, JFmRxRdsPiCode pi); + + void fmRxPtyCodeChanged(JFmRx context, JFmRxStatus status, JFmRxRdsPtyCode pty); + + void fmRxPsChanged(JFmRx context, JFmRxStatus status, JFmRxFreq frequency, byte[] name, + JFmRxRepertoire repertoire); + + void fmRxMonoStereoModeChanged(JFmRx context, JFmRxStatus status, JFmRxMonoStereoMode mode); + + void fmRxAudioPathChanged(JFmRx context, JFmRxStatus status); + + void fmRxAfSwitchFreqFailed(JFmRx context, JFmRxStatus status, JFmRxRdsPiCode pi, + JFmRxFreq tunedFreq, JFmRxAfFreq afFreq); + + void fmRxAfSwitchStart(JFmRx context, JFmRxStatus status, JFmRxRdsPiCode pi, + JFmRxFreq tunedFreq, JFmRxAfFreq afFreq); + + void fmRxAfSwitchComplete(JFmRx context, JFmRxStatus status, JFmRxRdsPiCode pi, + JFmRxFreq tunedFreq, JFmRxAfFreq afFreq); + + void fmRxAfListChanged(JFmRx context, JFmRxStatus status, JFmRxRdsPiCode pi, int[] afList, + JFmRxAfListSize afListSize); + + void fmRxCmdEnable(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdDisable(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetBand(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetBand(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetMonoStereoMode(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetMonoStereoMode(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetMuteMode(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetMuteMode(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetRfDependentMuteMode(JFmRx context, JFmRxStatus status, int command, + long value); + + void fmRxCmdGetRfDependentMuteMode(JFmRx context, JFmRxStatus status, int command, + long value); + + void fmRxCmdSetRssiThreshhold(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetRssiThreshhold(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetDeemphasisFilter(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetDeemphasisFilter(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetVolume(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetVolume(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdTune(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetTunedFrequency(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSeek(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdStopSeek(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetRssi(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdEnableRds(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdDisableRds(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetRdsSystem(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetRdsSystem(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetRdsGroupMask(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetRdsGroupMask(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdSetRdsAfSwitchMode(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetRdsAfSwitchMode(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdDisableAudio(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdDestroy(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdChangeDigitalAudioConfiguration(JFmRx context, JFmRxStatus status, int command, + long value); + + void fmRxCmdEnableAudio(JFmRx context, JFmRxStatus status, int command, long AudioCmd); + + void fmRxCmdChangeAudioTarget(JFmRx context, JFmRxStatus status, int command, long AudioCmd); + + void fmRxCmdSetChannelSpacing(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetChannelSpacing(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCompleteScanDone(JFmRx context, JFmRxStatus status, int numOfChannels, + int[] channelsData); + + void fmRxCmdStopCompleteScan(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdIsValidChannel(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetFwVersion(JFmRx context, JFmRxStatus status, int command, long value); + + void fmRxCmdGetCompleteScanProgress(JFmRx context, JFmRxStatus status, int command, + long value); + + } + + /** + * Datatype Classes + */ + + public static class JFmRxRdsPiCode { + private int value = 0; + + public JFmRxRdsPiCode(int val) { + this.value = val; + } + + public int getValue() { + return value; + } + } + + public static class JFmRxRdsPtyCode { + private int value = 0; + + public JFmRxRdsPtyCode(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + public static class JFmRxAfFreq { + + private int value = 0; + + public JFmRxAfFreq(int value) { + this.value = value; + } + + public int getAfFreq() { + return value; + } + } + + public static class JFmRxAfListSize { + private int value = 0; + + public JFmRxAfListSize(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + } + + /* + * public static enum JFmRxEcalResource implements IJFmEnum<Integer> { + * CAL_RESOURCE_I2SH(0x00), CAL_RESOURCE_PCMH(0x01), + * CAL_RESOURCE_PCMT_1(0x02), CAL_RESOURCE_PCMT_2(0x03), + * CAL_RESOURCE_PCMT_3(0x04), CAL_RESOURCE_PCMT_4(0x05), + * CAL_RESOURCE_PCMT_5(0x06), CAL_RESOURCE_PCMT_6(0x07), + * CAL_RESOURCE_FM_ANALOG(0x08), CAL_RESOURCE_LAST_EL_RESOURCE(0x08), + * CAL_RESOURCE_PCMIF(0x09), CAL_RESOURCE_FMIF(0x0A), + * CAL_RESOURCE_CORTEX(0x0B), CAL_RESOURCE_FM_CORE(0x0C), + * CAL_RESOURCE_MAX_NUM(0x0D), CAL_RESOURCE_INVALID(0x0E); private final int + * ecalResource; private JFmRxEcalResource(int ecalResource) { + * this.ecalResource = ecalResource; } public Integer getValue() { return + * ecalResource; } } public static enum JFmRxEcalOperation implements + * IJFmEnum<Integer> { CAL_OPERATION_FM_TX(0x00), CAL_OPERATION_FM_RX(0x01), + * CAL_OPERATION_A3DP(0x02), CAL_OPERATION_BT_VOICE(0x03), + * CAL_OPERATION_WBS(0x04), CAL_OPERATION_AWBS(0x05), + * CAL_OPERATION_FM_RX_OVER_SCO(0x06), CAL_OPERATION_FM_RX_OVER_A3DP(0x07), + * CAL_OPERATION_MAX_NUM(0x08), CAL_OPERATION_INVALID(0x09); private final + * int ecalOperation; private JFmRxEcalOperation(int ecalOperation) { + * this.ecalOperation = ecalOperation; } public Integer getValue() { return + * ecalOperation; } } + */ + public static enum JFmRxEcalSampleFrequency implements IJFmEnum<Integer> { + CAL_SAMPLE_FREQ_8000(0x00), CAL_SAMPLE_FREQ_11025(0x01), CAL_SAMPLE_FREQ_12000(0x02), CAL_SAMPLE_FREQ_16000( + 0x03), CAL_SAMPLE_FREQ_22050(0x04), CAL_SAMPLE_FREQ_24000(0x05), CAL_SAMPLE_FREQ_32000( + 0x06), CAL_SAMPLE_FREQ_44100(0x07), CAL_SAMPLE_FREQ_48000(0x08); + + private final int ecalSampleFreq; + + private JFmRxEcalSampleFrequency(int ecalSampleFreq) { + this.ecalSampleFreq = ecalSampleFreq; + } + + public Integer getValue() { + return ecalSampleFreq; + } + } + + public static enum JFmRxRdsGroupTypeMask implements IJFmEnum<Long> { + + FM_RDS_GROUP_TYPE_MASK_0A(0x00000001), FM_RDS_GROUP_TYPE_MASK_0B(0x00000002), FM_RDS_GROUP_TYPE_MASK_1A( + 0x00000004), FM_RDS_GROUP_TYPE_MASK_1B(0x00000008), FM_RDS_GROUP_TYPE_MASK_2A( + 0x00000010), FM_RDS_GROUP_TYPE_MASK_2B(0x00000020), FM_RDS_GROUP_TYPE_MASK_3A( + 0x00000040), FM_RDS_GROUP_TYPE_MASK_3B(0x00000080), FM_RDS_GROUP_TYPE_MASK_4A( + 0x00000100), FM_RDS_GROUP_TYPE_MASK_4B(0x00000200), FM_RDS_GROUP_TYPE_MASK_5A( + 0x00000400), FM_RDS_GROUP_TYPE_MASK_5B(0x00000800), FM_RDS_GROUP_TYPE_MASK_6A( + 0x00001000), FM_RDS_GROUP_TYPE_MASK_6B(0x00002000), FM_RDS_GROUP_TYPE_MASK_7A( + 0x00004000), FM_RDS_GROUP_TYPE_MASK_7B(0x00008000), FM_RDS_GROUP_TYPE_MASK_8A( + 0x00010000), FM_RDS_GROUP_TYPE_MASK_8B(0x00020000), FM_RDS_GROUP_TYPE_MASK_9A( + 0x00040000), FM_RDS_GROUP_TYPE_MASK_9B(0x00080000), FM_RDS_GROUP_TYPE_MASK_10A( + 0x00100000), FM_RDS_GROUP_TYPE_MASK_10B(0x00200000), FM_RDS_GROUP_TYPE_MASK_11A( + 0x00400000), FM_RDS_GROUP_TYPE_MASK_11B(0x00800000), FM_RDS_GROUP_TYPE_MASK_12A( + 0x01000000), FM_RDS_GROUP_TYPE_MASK_12B(0x02000000), FM_RDS_GROUP_TYPE_MASK_13A( + 0x04000000), FM_RDS_GROUP_TYPE_MASK_13B(0x08000000), FM_RDS_GROUP_TYPE_MASK_14A( + 0x10000000), FM_RDS_GROUP_TYPE_MASK_14B(0x20000000), FM_RDS_GROUP_TYPE_MASK_15A( + 0x40000000), FM_RDS_GROUP_TYPE_MASK_15B(0x80000000), FM_RDS_GROUP_TYPE_MASK_NONE( + 0x0), FM_RDS_GROUP_TYPE_MASK_ALL(0xFFFFFFFF); + + private final long rdsGroupTypeMask; + + private JFmRxRdsGroupTypeMask(long rdsGroupTypeMask) { + this.rdsGroupTypeMask = rdsGroupTypeMask; + } + + public Long getValue() { + return rdsGroupTypeMask; + } + } + + public static enum JFmRxRdsSystem implements IJFmEnum<Integer> { + FM_RDS_SYSTEM_RDS(0x00), FM_RDS_SYSTEM_RBDS(0x01); + + private final int rdsSystem; + + private JFmRxRdsSystem(int rdsSystem) { + this.rdsSystem = rdsSystem; + } + + public Integer getValue() { + return rdsSystem; + } + } + + /* + * public static enum JFmRxAudioRouteMask implements IJFmEnum<Integer> { + * FMC_AUDIO_ROUTE_MASK_I2S(0x00000001), + * FMC_AUDIO_ROUTE_MASK_ANALOG(0x00000002), + * FMC_AUDIO_ROUTE_MASK_NONE(0x00000000), + * FMC_AUDIO_ROUTE_MASK_ALL(0x00000003); private final int audioRouteMask; + * private JFmRxAudioRouteMask(int audioRouteMask) { this.audioRouteMask = + * audioRouteMask; } public Integer getValue() { return audioRouteMask; } } + */ + public static class JFmRxRssi { + + private int jFmRssi; + + public JFmRxRssi(int jFmRssi) { + this.jFmRssi = jFmRssi; + } + + public int getRssi() { + return jFmRssi; + } + + public void setRssi(int jFmRssi) { + this.jFmRssi = jFmRssi; + } + } + + public static class JFmRxVolume { + + private int jFmVolume; + + public JFmRxVolume(int jFmVolume) { + this.jFmVolume = jFmVolume; + } + + public int getVolume() { + return jFmVolume; + } + + public void setVolume(int jFmVolume) { + this.jFmVolume = jFmVolume; + } + } + + public static class JFmRxFreq { + + private int value = 0; + + public JFmRxFreq(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + } + + public static enum JFmRxMuteMode implements IJFmEnum<Integer> { + FMC_MUTE(0x00), FMC_NOT_MUTE(0x01), FMC_ATTENUATE(0x02); + + private final int muteMode; + + private JFmRxMuteMode(int muteMode) { + this.muteMode = muteMode; + } + + public Integer getValue() { + return muteMode; + } + } + + public static enum JFmRxChannelSpacing implements IJFmEnum<Integer> { + FMC_CHANNEL_SPACING_50_KHZ(0x01), FMC_CHANNEL_SPACING_100_KHZ(0x02), FMC_CHANNEL_SPACING_200_KHZ( + 0x04); + + private final int channelSpace; + + private JFmRxChannelSpacing(int channelSpace) { + this.channelSpace = channelSpace; + } + + public Integer getValue() { + return channelSpace; + } + } + + public static enum JFmRxBand implements IJFmEnum<Integer> { + FMC_BAND_EUROPE_US(0x00), FMC_BAND_JAPAN(0x01); + + private final int band; + + private JFmRxBand(int band) { + this.band = band; + } + + public Integer getValue() { + return band; + } + } + + public static enum JFmRxAudioTargetMask implements IJFmEnum<Integer> { + FM_RX_TARGET_MASK_INVALID(0), FM_RX_TARGET_MASK_I2SH(1), FM_RX_TARGET_MASK_PCMH(2), FM_RX_TARGET_MASK_FM_OVER_SCO( + 4), FM_RX_TARGET_MASK_FM_OVER_A3DP(8), FM_RX_TARGET_MASK_FM_ANALOG(16); + + private final int audioTargetMask; + + private JFmRxAudioTargetMask(int audioTargetMask) { + this.audioTargetMask = audioTargetMask; + } + + public Integer getValue() { + return audioTargetMask; + } + } + + public static enum JFmRxRfDependentMuteMode implements IJFmEnum<Integer> { + FM_RX_RF_DEPENDENT_MUTE_ON(0x01), FM_RX_RF_DEPENDENT_MUTE_OFF(0x00); + + private final int rfDependentMuteMode; + + private JFmRxRfDependentMuteMode(int rfDependentMuteMode) { + this.rfDependentMuteMode = rfDependentMuteMode; + } + + public Integer getValue() { + return rfDependentMuteMode; + } + } + + public static enum JFmRxRdsAfSwitchMode implements IJFmEnum<Integer> { + FM_RX_RDS_AF_SWITCH_MODE_ON(0x01), FM_RX_RDS_AF_SWITCH_MODE_OFF(0x00); + + private final int rdsAfSwitchMode; + + private JFmRxRdsAfSwitchMode(int rdsAfSwitchMode) { + this.rdsAfSwitchMode = rdsAfSwitchMode; + } + + public Integer getValue() { + return rdsAfSwitchMode; + } + } + + /* + * public static enum JFmRxAudioPath implements IJFmEnum<Integer> { + * FM_RX_AUDIO_PATH_OFF(0x00), FM_RX_AUDIO_PATH_HEADSET(0x01), + * FM_RX_AUDIO_PATH_HANDSET(0x02); private final int audioPath; private + * JFmRxAudioPath(int audioPath) { this.audioPath = audioPath; } public + * Integer getValue() { return audioPath; } } + */ + public static enum JFmRxMonoStereoMode implements IJFmEnum<Integer> { + FM_RX_MONO(0x01), FM_RX_STEREO(0x00); + + private final int monoStereoModer; + + private JFmRxMonoStereoMode(int monoStereoModer) { + this.monoStereoModer = monoStereoModer; + } + + public Integer getValue() { + return monoStereoModer; + } + } + + public static enum JFmRxEmphasisFilter implements IJFmEnum<Integer> { + FM_RX_EMPHASIS_FILTER_NONE(0x00), FM_RX_EMPHASIS_FILTER_50_USEC(0x01), FM_RX_EMPHASIS_FILTER_75_USEC( + 0x02); + + private final int emphasisFilter; + + private JFmRxEmphasisFilter(int emphasisFilter) { + this.emphasisFilter = emphasisFilter; + } + + public Integer getValue() { + return emphasisFilter; + } + } + + public static enum JFmRxRepertoire implements IJFmEnum<Integer> { + FMC_RDS_REPERTOIRE_G0_CODE_TABLE(0x00), FMC_RDS_REPERTOIRE_G1_CODE_TABLE(0x01), FMC_RDS_REPERTOIRE_G2_CODE_TABLE( + 0x02); + + private final int repertoire; + + private JFmRxRepertoire(int repertoire) { + this.repertoire = repertoire; + } + + public Integer getValue() { + return repertoire; + } + } + + public static enum JFmRxSeekDirection implements IJFmEnum<Integer> { + FM_RX_SEEK_DIRECTION_DOWN(0x00), FM_RX_SEEK_DIRECTION_UP(0x01); + + private final int direction; + + private JFmRxSeekDirection(int direction) { + this.direction = direction; + } + + public Integer getValue() { + return direction; + } + } + + /******************************************************************************* + * Class Methods + *******************************************************************************/ + + public JFmRxStatus create(ICallback callback) { + JFmRxStatus jFmRxStatus; + // JBtlStatus jBtlStatus; + try { + + context = new JFmContext(); + + //JFmLog.d(TAG, "Calling nativeJFmRx_Create"); + int fmStatus = nativeJFmRx_Create(context); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + + JFmLog.d(TAG, "After nativeJFmRx_Create, status = " + jFmRxStatus.toString() + + ", Context = " + context.getValue()); + + /** + *Record the caller's callback and returned native context for + * nativeJFmRx_create + */ + + this.callback = callback; + mRxContextsTable.put(context, this); + + } catch (Exception e) { + JFmLog.e(TAG, "create: exception during nativeJFmRx_create (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + return jFmRxStatus; + } + + public JFmRxStatus destroy() { + //JFmLog.d(TAG, "destroy: entered"); + JFmRxStatus jFmRxStatus; + // JBtlStatus jBtlStatus; + + try { + int fmStatus = nativeJFmRx_Destroy(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_Destroy, status = " + jFmRxStatus.toString()); + + /* + * Remove a pair of JFmContext-JFmRx related to the destroyed + * context from the HashMap + */ + + mRxContextsTable.remove(context); + + } catch (Exception e) { + JFmLog.e(TAG, "destroy: exception during nativeJFmRx_Destroy (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "destroy: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus enable() { + //JFmLog.d(TAG, "enable: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_Enable(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_Enable, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "enable: exception during nativeJFmRx_enable (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "enable: exiting"); + + return jFmRxStatus; + } + + public JFmRxStatus disable() { + //JFmLog.d(TAG, "disable: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_Disable(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_Disable, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "disable: exception during nativeJFmRx_Disable (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "disable: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus setBand(JFmRxBand jFmRxBand) { + JFmLog.d(TAG, "setBand: entered"); + JFmRxStatus jFmRxStatus; + + try { + + int status = nativeJFmRx_SetBand(context.getValue(), jFmRxBand.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_SetBand, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setBand: exception during nativeJFmRx_SetBand (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + JFmLog.d(TAG, "setBand: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus getBand() { + JFmLog.d(TAG, "getBand: entered"); + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetBand(context.getValue()); + + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_GetBand, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getBand: exception during nativeJFmRx_GetBand (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + JFmLog.d(TAG, "getBand: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus setChannelSpacing(JFmRxChannelSpacing jFmRxChannelSpacing) { + JFmLog.d(TAG, "setChannelSpacing: entered"); + JFmRxStatus jFmRxStatus; + + try { + + int status = nativeJFmRx_SetChannelSpacing(context.getValue(), jFmRxChannelSpacing + .getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmRx_SetChannelSpacing, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setBand: exception during nativeJFmRx_SetChannelSpacing (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + JFmLog.d(TAG, "setChannelSpacing: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus getChannelSpacing() { + JFmLog.d(TAG, "getChannelSpacing: entered"); + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetChannelSpacing(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmRx_GetChannelSpacing, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getChannelSpacing: exception during nativeJFmRx_GetChannelSpacing (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + JFmLog.d(TAG, "getChannelSpacing: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus isValidChannel() { + //JFmLog.d(TAG, "isValidChannel: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_IsValidChannel(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_IsValidChannel, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "isValidChannel: exception during nativeJFmRx_IsValidChannel (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "isValidChannel: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus completeScan() { + JFmLog.d(TAG, "completeScan: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_CompleteScan(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_CompleteScan, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "completeScan: exception during nativeJFmRx_CompleteScan (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + JFmLog.d(TAG, "completeScan: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getFwVersion() { + //JFmLog.d(TAG, "getFwVersion: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetFwVersion(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_GetFwVersion, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getFwVersion: exception during nativeJFmRx_GetFwVersion (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getFwVersion: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getCompleteScanProgress() { + JFmLog.d(TAG, "getCompleteScanProgress: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetCompleteScanProgress(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_GetCompleteScanProgress, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "getCompleteScanProgress: exception during nativeJFmRx_GetCompleteScanProgress (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + JFmLog.d(TAG, "getCompleteScanProgress: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus stopCompleteScan() { + JFmLog.d(TAG, "stopCompleteScan: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_StopCompleteScan(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_StopCompleteScan, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "stopCompleteScan: exception during nativeJFmRx_StopCompleteScan (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + JFmLog.d(TAG, "stopCompleteScan: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus tune(JFmRxFreq jfmRxFreq) { + + //JFmLog.d(TAG, "tune: entered"); + + JFmRxStatus jFmRxStatus; + + try { + + int status = nativeJFmRx_Tune(context.getValue(), jfmRxFreq.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_Tune, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "tune: exception during nativeJFmRx_Tune (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "tune: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus getTunedFrequency() { + //JFmLog.d(TAG, "getTunedFrequency: entered"); + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetTunedFrequency(context.getValue()); + + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmRx_GetTunedFrequency, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getTunedFrequency: exception during nativeJFmRx_GetTunedFrequency (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "getTunedFrequency: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus setMonoStereoMode(JFmRxMonoStereoMode jFmRxMonoStereoMode) { + //JFmLog.d(TAG, "setMonoStereoMode: entered"); + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_SetMonoStereoMode(context.getValue(), jFmRxMonoStereoMode + .getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmRx_SetMonoStereoMode, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setMonoStereoMode: exception during nativeJFmRx_SetMonoStereoMode (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "setMonoStereoMode: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getMonoStereoMode() { + //JFmLog.d(TAG, "getMonoStereoMode: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetMonoStereoMode(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmRx_GetMonoStereoMode, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getMonoStereoMode: exception during nativeJFmRx_GetMonoStereoMode (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getMonoStereoMode: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus setMuteMode(JFmRxMuteMode jFmRxMuteMode) { + //JFmLog.d(TAG, "setMuteMode: entered"); + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_SetMuteMode(context.getValue(), jFmRxMuteMode.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_SetMuteMode, status = " + jFmRxStatus.toString()); + + } catch (Exception e) { + JFmLog.e(TAG, "setMuteMode: exception during nativeJFmRx_SetMuteMode (" + e.toString() + + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "setMuteMode: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getMuteMode() { + //JFmLog.d(TAG, "getMuteMode: entered"); + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_GetMuteMode(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_GetMuteMode, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getMuteMode: exception during nativeJFmRx_GetMuteMode (" + e.toString() + + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getMuteMode: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus setRssiThreshold(JFmRxRssi jFmRssi) { + //JFmLog.d(TAG, "setRssiThreshold: entered"); + + JFmRxStatus jFmRxStatus; + + try { + int status = nativeJFmRx_SetRssiThreshold(context.getValue(), jFmRssi.getRssi()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmRx_SetRssiThreshold, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setRssiThreshold: exception during nativeJFmRx_SetRssiThreshold (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "setRssiThreshold: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getRssiThreshold() { + //JFmLog.d(TAG, "getRssiThreshold: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetRssiThreshold(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetRssiThreshold, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getRssiThreshold: exception during nativeJFmRx_GetRssiThreshold (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getRssiThreshold: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus getRssi() { + //JFmLog.d(TAG, "getRssi: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetRssi(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetRssi, status = " + jFmRxStatus.toString()); + + } catch (Exception e) { + JFmLog.e(TAG, "getRssi: exception during nativeJFmRx_GetRssi (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getRssi: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus setVolume(JFmRxVolume jFmVolume) { + //JFmLog.d(TAG, "setVolume: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_SetVolume(context.getValue(), jFmVolume.getVolume()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_SetVolume, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setVolume: exception during nativeJFmRx_SetVolume (" + e.toString() + + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "setVolume: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getVolume() { + //JFmLog.d(TAG, "getVolume: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetVolume(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetVolume, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getVolume: exception during nativeJFmRx_GetVolume (" + e.toString() + + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "getVolume: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus SetDeEmphasisFilter(JFmRxEmphasisFilter jFmRxEmphasisFilter) { + //JFmLog.d(TAG, "SetDeEmphasisFilter: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_SetDeEmphasisFilter(context.getValue(), jFmRxEmphasisFilter + .getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_SetDeEmphasisFilter, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "SetDeEmphasisFilter: exception during nativeJFmRx_SetDeEmphasisFilter (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "SetDeEmphasisFilter: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus GetDeEmphasisFilter() { + //JFmLog.d(TAG, "GetDeEmphasisFilter: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetDeEmphasisFilter(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetDeEmphasisFilter, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "GetDeEmphasisFilter: exception during nativeJFmRx_GetDeEmphasisFilter (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "GetDeEmphasisFilter: exiting"); + + return jFmRxStatus; + } + + public JFmRxStatus seek(JFmRxSeekDirection jFmRxSeekDirection) { + //JFmLog.d(TAG, "seek: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_Seek(context.getValue(), jFmRxSeekDirection.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_Seek, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "seek: exception during nativeJFmRx_Seek (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "seek: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus stopSeek() { + //JFmLog.d(TAG, "stopSeek: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_StopSeek(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_StopSeek, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "stopSeek: exception during nativeJFmRx_StopSeek (" + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "stopSeek: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus enableRDS() { + //JFmLog.d(TAG, "enableRDS: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_EnableRDS(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_EnableRDS, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "enableRDS: exception during nativeJFmRx_EnableRDS (" + e.toString() + + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "enableRDS: exiting"); + + return jFmRxStatus; + } + + public JFmRxStatus DisableRDS() { + //JFmLog.d(TAG, "DisableRDS: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_DisableRDS(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_DisableRDS, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "DisableRDS: exception during nativeJFmRx_DisableRDS (" + e.toString() + + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "DisableRDS: exiting"); + + return jFmRxStatus; + } + + public JFmRxStatus enableAudioRouting() { + //JFmLog.d(TAG, "enableAudioRouting: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_EnableAudioRouting(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_EnableAudioRouting, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "enableAudioRouting: exception during nativeJFmRx_EnableAudioRouting (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "enableAudioRouting: exiting"); + return jFmRxStatus; + } + + public JFmRxStatus disableAudioRouting() { + //JFmLog.d(TAG, "disableAudioRouting: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_DisableAudioRouting(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_DisableAudioRouting, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "disableAudioRouting: exception during nativeJFmRx_DisableAudioRouting (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "disableAudioRouting: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus setRdsAfSwitchMode(JFmRxRdsAfSwitchMode jRdsAfSwitchMode) { + //JFmLog.d(TAG, "setRdsAfSwitchMode: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_SetRdsAfSwitchMode(context.getValue(), jRdsAfSwitchMode + .getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_SetRdsAfSwitchMode, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setRdsAfSwitchMode: exception during nativeJFmRx_SetRdsAfSwitchMode (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + + //JFmLog.d(TAG, "setRdsAfSwitchMode: exiting"); + return jFmRxStatus; + + } + + public JFmRxStatus getRdsAfSwitchMode() { + //JFmLog.d(TAG, "getRdsAfSwitchMode: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetRdsAfSwitchMode(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetRdsAfSwitchMode, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getRdsAfSwitchMode: exception during nativeJFmRx_GetRdsAfSwitchMode (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getRdsAfSwitchMode: exiting"); + + return jFmRxStatus; + } + + public JFmRxStatus changeAudioTarget(JFmRxAudioTargetMask jFmRxAudioTargetMask, + JFmRxEcalSampleFrequency digitalConfig) { + //JFmLog.d(TAG, "changeAudioTarget: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_ChangeAudioTarget(context.getValue(), jFmRxAudioTargetMask + .getValue(), digitalConfig.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog + .d(TAG, "After nativeJFmRx_ChangeAudioTarget, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "changeAudioTarget: exception during nativeJFmRx_ChangeAudioTarget (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "changeAudioTarget: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus changeDigitalTargetConfiguration(JFmRxEcalSampleFrequency digitalConfig) { + //JFmLog.d(TAG, "changeDigitalTargetConfiguration: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_ChangeDigitalTargetConfiguration(context.getValue(), + digitalConfig.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_ChangeDigitalTargetConfiguration, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "changeDigitalTargetConfiguration: exception during nativeJFmRx_ChangeDigitalTargetConfiguration (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "changeDigitalTargetConfiguration: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus setRfDependentMuteMode(JFmRxRfDependentMuteMode mode) { + //JFmLog.d(TAG, "setRfDependentMuteMode: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_SetRfDependentMuteMode(context.getValue(), mode.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_SetRfDependentMuteMode, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "setRfDependentMuteMode: exception during nativeJFmRx_SetRfDependentMuteMode (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "setRfDependentMuteMode: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus getRfDependentMute() { + //JFmLog.d(TAG, "getRfDependentMute: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetRfDependentMute(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetRfDependentMute, status = " + + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getRfDependentMute: exception during nativeJFmRx_GetRfDependentMute (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getRfDependentMute: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus setRdsSystem(JFmRxRdsSystem rdsSystem) { + //JFmLog.d(TAG, "setRdsSystem: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_SetRdsSystem(context.getValue(), rdsSystem.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_SetRdsSystem, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setRdsSystem: exception during nativeJFmRx_SetRdsSystem (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "setRdsSystem: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus getRdsSystem() { + //JFmLog.d(TAG, "getRdsSystem: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetRdsSystem(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetRdsSystem, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getRdsSystem: exception during nativeJFmRx_GetRdsSystem (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getRdsSystem: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus setRdsGroupMask(JFmRxRdsGroupTypeMask groupMask) { + //JFmLog.d(TAG, "setRdsGroupMask: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_SetRdsGroupMask(context.getValue(), groupMask.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_SetRdsGroupMask, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "setRdsGroupMask: exception during nativeJFmRx_SetRdsGroupMask (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "setRdsGroupMask: exiting"); + + return jFmRxStatus; + + } + + public JFmRxStatus getRdsGroupMask() { + //JFmLog.d(TAG, "getRdsGroupMask: entered"); + JFmRxStatus jFmRxStatus; + + try { + int fmStatus = nativeJFmRx_GetRdsGroupMask(context.getValue()); + jFmRxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmRx_GetRdsGroupMask, status = " + jFmRxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "getRdsGroupMask: exception during nativeJFmRx_GetRdsGroupMask (" + + e.toString() + ")"); + jFmRxStatus = JFmRxStatus.FAILED; + } + //JFmLog.d(TAG, "getRdsGroupMask: exiting"); + + return jFmRxStatus; + + } + + /*-------------------------------------------------------------------------- + * NATIVE PART + *------------------------------------------------------------------------*/ + + /* RBTL Calls */ + private static native void nativeJFmRx_ClassInitNative(); + + private static native int nativeJFmRx_Create(JFmContext contextValue); + + private static native int nativeJFmRx_Destroy(long contextValue); + + private static native int nativeJFmRx_Enable(long contextValue); + + private static native int nativeJFmRx_Disable(long contextValue); + + private static native int nativeJFmRx_SetBand(long contextValue, int jFmBand); + + private static native int nativeJFmRx_GetBand(long contextValue); + + private static native int nativeJFmRx_Tune(long contextValue, int jFmFreq); + + private static native int nativeJFmRx_GetTunedFrequency(long contextValue); + + private static native int nativeJFmRx_SetMonoStereoMode(long contextValue, int jFmMonoStereoMode); + + private static native int nativeJFmRx_GetMonoStereoMode(long contextValue); + + private static native int nativeJFmRx_SetMuteMode(long contextValue, int jFmMuteMode); + + private static native int nativeJFmRx_GetMuteMode(long contextValue); + + private static native int nativeJFmRx_SetRssiThreshold(long contextValue, int jFmRssi); + + private static native int nativeJFmRx_GetRssiThreshold(long contextValue); + + private static native int nativeJFmRx_GetRssi(long contextValue); + + private static native int nativeJFmRx_SetVolume(long contextValue, int jFmVolume); + + private static native int nativeJFmRx_GetVolume(long contextValue); + + private static native int nativeJFmRx_SetDeEmphasisFilter(long contextValue, + int jFmEmphasisFilter); + + private static native int nativeJFmRx_GetDeEmphasisFilter(long contextValue); + + private static native int nativeJFmRx_Seek(long contextValue, int jFmDirection); + + private static native int nativeJFmRx_StopSeek(long contextValue); + + private static native int nativeJFmRx_EnableRDS(long contextValue); + + private static native int nativeJFmRx_DisableRDS(long contextValue); + + private static native int nativeJFmRx_EnableAudioRouting(long contextValue); + + private static native int nativeJFmRx_DisableAudioRouting(long contextValue); + + private static native int nativeJFmRx_SetRdsAfSwitchMode(long contextValue, int jRdsAfSwitchMode); + + private static native int nativeJFmRx_GetRdsAfSwitchMode(long contextValue); + + private static native int nativeJFmRx_ChangeAudioTarget(long contextValue, int audioTargetMask, + int digitalConfig); + + private static native int nativeJFmRx_ChangeDigitalTargetConfiguration(long contextValue, + int digitalConfig); + + private static native int nativeJFmRx_SetRfDependentMuteMode(long contextValue, int mode); + + private static native int nativeJFmRx_GetRfDependentMute(long contextValue); + + private static native int nativeJFmRx_SetRdsSystem(long contextValue, int rdsSystem); + + private static native int nativeJFmRx_GetRdsSystem(long contextValue); + + private static native int nativeJFmRx_SetRdsGroupMask(long contextValue, long groupMask); + + private static native int nativeJFmRx_GetRdsGroupMask(long contextValue); + + private static native int nativeJFmRx_SetChannelSpacing(long contextValue, int fmChannelSpacing); + + private static native int nativeJFmRx_GetChannelSpacing(long contextValue); + + private static native int nativeJFmRx_IsValidChannel(long contextValue); + + private static native int nativeJFmRx_CompleteScan(long contextValue); + + private static native int nativeJFmRx_GetFwVersion(long contextValue); + + private static native int nativeJFmRx_GetCompleteScanProgress(long contextValue); + + private static native int nativeJFmRx_StopCompleteScan(long contextValue); + + /*--------------------------------------------------------------------------- + * -------------------------------- NATIVE PART-------------------------------- + * --------------------------------------------------------------------------- + */ + + /*--------------------------------------------------------------------------- + * ---------------------------------------------- Callbacks from the------------- + * JFmRxNative.cpp module ----------------------------------------------------- + */ + + @SuppressWarnings("unused") + public static void nativeCb_fmRxRawRDS(long contextValue, int status, int bitInMaskValue, + byte[] groupData) { + + //JFmLog.d(TAG, "nativeCb_fmRxRawRDS: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxRawRDS: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRdsGroupTypeMask bitInMask = JFmUtils.getEnumConst(JFmRxRdsGroupTypeMask.class, + (long) bitInMaskValue); + + //JFmLog.d(TAG, "nativeCb_fmRxRawRDS: calling callback"); + + callback.fmRxRawRDS(mJFmRx, rxStatus, bitInMask, groupData); + + } + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxRadioText(long contextValue, int status, boolean resetDisplay, + byte[] msg1, int len, int startIndex, int repertoire) { + + //JFmLog.d(TAG, "nativeCb_fmRxRadioText: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxRadioText: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRepertoire jRepertoire = JFmUtils.getEnumConst(JFmRxRepertoire.class, repertoire); + + //JFmLog.d(TAG, "nativeCb_fmRxRadioText: calling callback"); + + callback.fmRxRadioText(mJFmRx, rxStatus, resetDisplay, msg1, len, startIndex, + jRepertoire); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxPiCodeChanged(long contextValue, int status, int piValue) { + + //JFmLog.d(TAG, "nativeCb_fmRxPiCodeChanged: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxPiCodeChanged: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRdsPiCode pi = new JFmRxRdsPiCode(piValue); + + //JFmLog.d(TAG, "nativeCb_fmRxPiCodeChanged: calling callback"); + + callback.fmRxPiCodeChanged(mJFmRx, rxStatus, pi); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxPtyCodeChanged(long contextValue, int status, int ptyValue) { + + //JFmLog.d(TAG, "nativeCb_fmRxPtyCodeChanged: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxPtyCodeChanged: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRdsPtyCode pty = new JFmRxRdsPtyCode(ptyValue); + + //JFmLog.d(TAG, "nativeCb_fmRxPtyCodeChanged: calling callback"); + + callback.fmRxPtyCodeChanged(mJFmRx, rxStatus, pty); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxPsChanged(long contextValue, int status, int frequency, + byte[] name, int repertoire) { + + //JFmLog.d(TAG, "nativeCb_fmRxPsChanged: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxPsChanged: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRepertoire jRepertoire = JFmUtils.getEnumConst(JFmRxRepertoire.class, repertoire); + + JFmRxFreq jFreq = new JFmRxFreq(frequency); + + //JFmLog.d(TAG, "nativeCb_fmRxPsChanged: calling callback"); + + callback.fmRxPsChanged(mJFmRx, rxStatus, jFreq, name, jRepertoire); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxMonoStereoModeChanged(long contextValue, int status, + int modeValue) { + + //JFmLog.d(TAG, "nativeCb_fmRxMonoStereoModeChanged: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxMonoStereoModeChanged: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxMonoStereoMode monoStereoMode = JFmUtils.getEnumConst(JFmRxMonoStereoMode.class, + modeValue); + + //JFmLog.d(TAG, "nativeCb_fmRxMonoStereoModeChanged: calling callback"); + + callback.fmRxMonoStereoModeChanged(mJFmRx, rxStatus, monoStereoMode); + + } + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxAudioPathChanged(long contextValue, int status) { + + //JFmLog.d(TAG, "nativeCb_fmRxAudioPathChanged: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxAudioPathChanged: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxAudioPathChanged: calling callback"); + + callback.fmRxAudioPathChanged(mJFmRx, rxStatus); + + } + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxAfSwitchFreqFailed(long contextValue, int status, int piValue, + int tunedFreq, int afFreqValue) { + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchFreqFailed: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxAfSwitchFreqFailed: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRdsPiCode pi = new JFmRxRdsPiCode(piValue); + + JFmRxFreq tuneFreq = new JFmRxFreq(tunedFreq); + + JFmRxAfFreq afFreq = new JFmRxAfFreq(afFreqValue); + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchFreqFailed: calling callback"); + + callback.fmRxAfSwitchFreqFailed(mJFmRx, rxStatus, pi, tuneFreq, afFreq); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxAfSwitchStart(long contextValue, int status, int piValue, + int tunedFreq, int afFreq) { + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchStart: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxAfSwitchStart: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + JFmRxRdsPiCode pi = new JFmRxRdsPiCode(piValue); + + JFmRxFreq tuneFreq = new JFmRxFreq(tunedFreq); + + JFmRxAfFreq aFreq = new JFmRxAfFreq(afFreq); + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchStart: calling callback"); + + callback.fmRxAfSwitchStart(mJFmRx, rxStatus, pi, tuneFreq, aFreq); + + } + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxAfListChanged(long contextValue, int status, int piValue, + int[] afList, int afListSize) { + + //JFmLog.d(TAG, "nativeCb_fmRxAfListChanged: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxAfListChanged: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRdsPiCode pi = new JFmRxRdsPiCode(piValue); + + JFmRxAfListSize jafListSize = new JFmRxAfListSize(afListSize); + + //JFmLog.d(TAG, "nativeCb_fmRxAfListChanged: calling callback"); + + callback.fmRxAfListChanged(mJFmRx, rxStatus, pi, afList, jafListSize); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxAfSwitchComplete(long contextValue, int status, int piValue, + int tunedFreq, int afFreq) { + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchComplete: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchComplete: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + JFmRxRdsPiCode pi = new JFmRxRdsPiCode(piValue); + + JFmRxFreq tuneFreq = new JFmRxFreq(tunedFreq); + + JFmRxAfFreq aFreq = new JFmRxAfFreq(afFreq); + + //JFmLog.d(TAG, "nativeCb_fmRxAfSwitchComplete: calling callback"); + + callback.fmRxAfSwitchComplete(mJFmRx, rxStatus, pi, tuneFreq, aFreq); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdEnable(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdEnable: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxCmdEnable: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdEnable: calling callback"); + + callback.fmRxCmdEnable(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdDisable(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdDisable: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxCmdDisable: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdDisable: calling callback"); + + callback.fmRxCmdDisable(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdEnableAudio(long contextValue, int status, int cmd, + long audioCmd) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdEnableAudio: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxCmdEnableAudio: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdEnableAudio: calling callback"); + + callback.fmRxCmdEnableAudio(mJFmRx, rxStatus, cmd, audioCmd); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdChangeAudioTarget(long contextValue, int status, int cmd, + long audioCmd) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdChangeAudioTarget: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxCmdChangeAudioTarget: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdChangeAudioTarget: calling callback"); + + callback.fmRxCmdChangeAudioTarget(mJFmRx, rxStatus, cmd, audioCmd); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetBand(long contextValue, int status, int cmd, long value) { + + JFmLog.d(TAG, "nativeCb_fmRxCmdSetBand: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetBand: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetBand: calling callback"); + + callback.fmRxCmdSetBand(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetBand(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetBand: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetBand: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetBand: calling callback"); + + callback.fmRxCmdGetBand(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetMonoStereoMode(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetMonoStereoMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetMonoStereoMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetMonoStereoMode: calling callback"); + + callback.fmRxCmdSetMonoStereoMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetMonoStereoMode(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetMonoStereoMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetMonoStereoMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetMonoStereoMode: calling callback"); + + callback.fmRxCmdGetMonoStereoMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetMuteMode(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetMuteMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetMuteMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetMuteMode: calling callback"); + + callback.fmRxCmdGetMuteMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetMuteMode(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdSetMuteMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetMuteMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetMuteMode: calling callback"); + + callback.fmRxCmdSetMuteMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetRfDependentMuteMode(long contextValue, int status, + int cmd, long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRfDependentMuteMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRfDependentMuteMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRfDependentMuteMode: calling callback"); + + callback.fmRxCmdSetRfDependentMuteMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetRfDependentMuteMode(long contextValue, int status, + int cmd, long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdGetRfDependentMuteMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRfDependentMuteMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRfDependentMuteMode: calling callback"); + + callback.fmRxCmdGetRfDependentMuteMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetRssiThreshhold(long contextValue, int status, int cmd, + long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRssiThreshhold: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRssiThreshhold: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRssiThreshhold: calling callback"); + + callback.fmRxCmdSetRssiThreshhold(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetRssiThreshhold(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetRssiThreshhold: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRssiThreshhold: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetRssiThreshhold: calling callback"); + + callback.fmRxCmdGetRssiThreshhold(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetDeemphasisFilter(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetDeemphasisFilter: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetDeemphasisFilter: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetDeemphasisFilter: calling callback"); + + callback.fmRxCmdSetDeemphasisFilter(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetDeemphasisFilter(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetDeemphasisFilter: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetDeemphasisFilter: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetDeemphasisFilter: calling callback"); + + callback.fmRxCmdGetDeemphasisFilter(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetChannelSpacing(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetChannelSpacing: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetChannelSpacing: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSetChannelSpacing: calling callback"); + + callback.fmRxCmdSetChannelSpacing(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetChannelSpacing(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdGetChannelSpacing: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetChannelSpacing: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetChannelSpacing: calling callback"); + + callback.fmRxCmdGetChannelSpacing(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetVolume(long contextValue, int status, int cmd, long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetVolume: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetVolume: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetVolume: calling callback"); + + callback.fmRxCmdSetVolume(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetVolume(long contextValue, int status, int cmd, long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetVolume: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetVolume: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetVolume: calling callback"); + + callback.fmRxCmdGetVolume(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdTune(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdTune: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdTune: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdTune: calling callback"); + + callback.fmRxCmdTune(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetTunedFrequency(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetTunedFrequency: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetTunedFrequency: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetTunedFrequency: calling callback"); + + callback.fmRxCmdGetTunedFrequency(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSeek(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSeek: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSeek: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdSeek: calling callback"); + + callback.fmRxCmdSeek(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdStopSeek(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdStopSeek: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdStopSeek: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdStopSeek: calling callback"); + + callback.fmRxCmdStopSeek(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetRssi(long contextValue, int status, int cmd, long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetRssi: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRssi: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetRssi: calling callback"); + + callback.fmRxCmdGetRssi(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdEnableRds(long contextValue, int status, int cmd, long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdEnableRds: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdEnableRds: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdEnableRds: calling callback"); + + callback.fmRxCmdEnableRds(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdDisableRds(long contextValue, int status, int cmd, long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDisableRds: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDisableRds: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDisableRds: calling callback"); + + callback.fmRxCmdDisableRds(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetRdsSystem(long contextValue, int status, int cmd, + long value) { + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsSystem: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsSystem: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsSystem: calling callback"); + + callback.fmRxCmdGetRdsSystem(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetRdsSystem(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsSystem: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsSystem: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsSystem: calling callback"); + + callback.fmRxCmdSetRdsSystem(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetRdsGroupMask(long contextValue, int status, int cmd, + long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsGroupMask: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsGroupMask: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsGroupMask: calling callback"); + + callback.fmRxCmdSetRdsGroupMask(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetRdsGroupMask(long contextValue, int status, int cmd, + long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsGroupMask: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsGroupMask: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsGroupMask: calling callback"); + + callback.fmRxCmdGetRdsGroupMask(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdSetRdsAfSwitchMode(long contextValue, int status, int cmd, + long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsAfSwitchMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsAfSwitchMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdSetRdsAfSwitchMode: calling callback"); + + callback.fmRxCmdSetRdsAfSwitchMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetRdsAfSwitchMode(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsAfSwitchMode: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsAfSwitchMode: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + +// JFmLog.d(TAG, "nativeCb_fmRxCmdGetRdsAfSwitchMode: calling callback"); + + callback.fmRxCmdGetRdsAfSwitchMode(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdDisableAudio(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdDisableAudio: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDisableAudio: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDisableAudio: calling callback"); + + callback.fmRxCmdDisableAudio(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdDestroy(long contextValue, int status, int cmd, long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDestroy: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDestroy: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdDestroy: calling callback"); + + callback.fmRxCmdDestroy(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdChangeDigitalAudioConfiguration(long contextValue, + int status, int cmd, long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdChangeDigitalAudioConfiguration: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, + // "nativeCb_fmRxCmdChangeDigitalAudioConfiguration: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdChangeDigitalAudioConfiguration: calling callback"); + + callback.fmRxCmdChangeDigitalAudioConfiguration(mJFmRx, rxStatus, cmd, value); + + } + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCompleteScanDone(long contextValue, int status, + int numOfChannels, int[] channelsData) { + + //JFmLog.d(TAG, "nativeCb_fmRxCompleteScanDone: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCompleteScanDone: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + //JFmLog.d(TAG, "nativeCb_fmRxCompleteScanDone: calling callback"); + + callback.fmRxCompleteScanDone(mJFmRx, rxStatus, numOfChannels, channelsData); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdStopCompleteScan(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdStopCompleteScan: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdStopCompleteScan: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdStopCompleteScan: calling callback"); + + callback.fmRxCmdStopCompleteScan(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdIsValidChannel(long contextValue, int status, int cmd, + long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdIsValidChannel: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdIsValidChannel: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxIsValidChannel: calling callback"); + + callback.fmRxCmdIsValidChannel(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetFwVersion(long contextValue, int status, int cmd, + long value) { + +// JFmLog.d(TAG, "nativeCb_fmRxCmdGetFwVersion: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetFwVersion: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetFwVersion: calling callback"); + + callback.fmRxCmdGetFwVersion(mJFmRx, rxStatus, cmd, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmRxCmdGetCompleteScanProgress(long contextValue, int status, + int cmd, long value) { + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetCompleteScanProgress: entered"); + + JFmRx mJFmRx = getJFmRx(contextValue); + + if (mJFmRx != null) { + + ICallback callback = mJFmRx.callback; + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetCompleteScanProgress: converting callback args"); + + JFmRxStatus rxStatus = JFmUtils.getEnumConst(JFmRxStatus.class, status); + + // JFmLog.d(TAG, "nativeCb_fmRxCmdGetCompleteScanProgress: calling callback"); + + callback.fmRxCmdGetCompleteScanProgress(mJFmRx, rxStatus, cmd, value); + + } + + } + + /****************************************************************************************** + * Private utility functions + *******************************************************************************************/ + + private static JFmRx getJFmRx(long contextValue) { + JFmRx jFmRx; + + JFmContext profileContext = new JFmContext(contextValue); + + if (mRxContextsTable.containsKey(profileContext)) { + jFmRx = mRxContextsTable.get(profileContext); + } else { + JFmLog.e(TAG, "JFmRx: Failed mapping context " + contextValue + " to a callback"); + jFmRx = null; + } + + return jFmRx; + } + +} /* End class */ diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxCcmVacResourceOwner.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxCcmVacResourceOwner.java new file mode 100644 index 0000000..ba79faf --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxCcmVacResourceOwner.java @@ -0,0 +1,86 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import com.ti.jfm.core.*; + +public class JFmRxCcmVacResourceOwner { + + public static enum JFmRxEcalResource implements IJFmEnum<Integer> { + + CAL_RESOURCE_I2SH(0x00), CAL_RESOURCE_PCMH(0x01), CAL_RESOURCE_PCMT_1(0x02), CAL_RESOURCE_PCMT_2( + 0x03), CAL_RESOURCE_PCMT_3(0x04), CAL_RESOURCE_PCMT_4(0x05), CAL_RESOURCE_PCMT_5( + 0x06), CAL_RESOURCE_PCMT_6(0x07), CAL_RESOURCE_FM_ANALOG(0x08), CAL_RESOURCE_LAST_EL_RESOURCE( + 0x08), CAL_RESOURCE_PCMIF(0x09), CAL_RESOURCE_FMIF(0x0A), CAL_RESOURCE_CORTEX(0x0B), CAL_RESOURCE_FM_CORE( + 0x0C), CAL_RESOURCE_MAX_NUM(0x0D), CAL_RESOURCE_INVALID(0x0E); + + private final int ecalResource; + + private JFmRxEcalResource(int ecalResource) { + this.ecalResource = ecalResource; + } + + public Integer getValue() { + return ecalResource; + } + } + + public static enum JFmRxEcalOperation implements IJFmEnum<Integer> { + + CAL_OPERATION_FM_TX(0x00), CAL_OPERATION_FM_RX(0x01), CAL_OPERATION_A3DP(0x02), CAL_OPERATION_BT_VOICE( + 0x03), CAL_OPERATION_WBS(0x04), CAL_OPERATION_AWBS(0x05), CAL_OPERATION_FM_RX_OVER_SCO( + 0x06), CAL_OPERATION_FM_RX_OVER_A3DP(0x07), CAL_OPERATION_MAX_NUM(0x08), CAL_OPERATION_INVALID( + 0x09); + + private final int ecalOperation; + + private JFmRxEcalOperation(int ecalOperation) { + this.ecalOperation = ecalOperation; + } + + public Integer getValue() { + return ecalOperation; + } + } + + private JFmRxEcalResource resource; + + private JFmRxEcalOperation operation; + + public JFmRxCcmVacResourceOwner(JFmRxEcalResource resource, JFmRxEcalOperation operation) { + this.resource = resource; + this.operation = operation; + } + + public JFmRxEcalResource getResource() { + return resource; + } + + public void setResource(JFmRxEcalResource resource) { + this.resource = resource; + } + + public JFmRxEcalOperation getOperation() { + return operation; + } + + public void setOperation(JFmRxEcalOperation operation) { + this.operation = operation; + } + +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxCcmVacUnavailResourceList.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxCcmVacUnavailResourceList.java new file mode 100644 index 0000000..7f62f33 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxCcmVacUnavailResourceList.java @@ -0,0 +1,52 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import com.ti.jfm.core.JFmRxCcmVacResourceOwner; + +public class JFmRxCcmVacUnavailResourceList { + + final int MAX_NUM_OF_PROPERTIES_PER_RESOURCE = 5; + + private JFmRxCcmVacResourceOwner[] ccmVacResourceOwner = new JFmRxCcmVacResourceOwner[MAX_NUM_OF_PROPERTIES_PER_RESOURCE]; + + private long uNumOfUnavailResources; + + public JFmRxCcmVacUnavailResourceList(JFmRxCcmVacResourceOwner[] ccmVacResourceOwner, + long uNumOfUnavailResources) { + this.ccmVacResourceOwner = ccmVacResourceOwner; + this.uNumOfUnavailResources = uNumOfUnavailResources; + } + + public JFmRxCcmVacResourceOwner[] getResourceOwner() { + return ccmVacResourceOwner; + } + + public void setResourceOwner(JFmRxCcmVacResourceOwner[] resource) { + this.ccmVacResourceOwner = resource; + } + + public long getNumOfUnavailResources() { + return uNumOfUnavailResources; + } + + public void setNumOfUnavailResources(Long numUnavailableResource) { + this.uNumOfUnavailResources = numUnavailableResource; + } + +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxStatus.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxStatus.java new file mode 100644 index 0000000..d2ebdc2 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmRxStatus.java @@ -0,0 +1,45 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +public enum JFmRxStatus implements IJFmEnum<Integer> { + + SUCCESS(0), FAILED(1), PENDING(2), INVALID_PARM(3), IN_PROGRESS(4), NOT_APPLICABLE(5), NOT_SUPPORTED( + 6), INTERNAL_ERROR(7), TRANSPORT_INIT_ERR(8), HARDWARE_ERR(9), NO_VALUE_AVAILABLE(10), CONTEXT_DOESNT_EXIST( + 11), CONTEXT_NOT_DESTROYED(12), CONTEXT_NOT_ENABLED(13), CONTEXT_NOT_DISABLED(14), NOT_DE_INITIALIZED( + 15), NOT_INITIALIZED(16), TOO_MANY_PENDING_CMDS(17), DISABLING_IN_PROGRESS(18), SCRIPT_EXEC_FAILED( + 21), FAILED_BT_NOT_INITIALIZED(23), AUDIO_OPERATION_UNAVAILIBLE_RESOURCES(24), FM_TX_ALREADY_ENABLED( + 101), SEEK_IN_PROGRESS(102), SEEK_IS_NOT_IN_PROGRESS(103), AF_IN_PROGRESS(104), RDS_IS_NOT_ENABLED( + 105), SEEK_REACHED_BAND_LIMIT(106), SEEK_STOPPED(107), SEEK_SUCCESS(108), STOP_SEEK(109), /* + * Internal + * use + */ + PENDING_UPDATE_CMD_PARAMS(110), FAILED_ALREADY_PENDING(111), INVALID_TYPE(112), CMD_TYPE_WAS_ALREADY_ALLOCATED( + 113), AF_SWITCH_FAILED_LIST_EXHAUSTED(114), COMPLETE_SCAN_IS_NOT_IN_PROGRESS(115), COMPLETE_SCAN_STOPPED( + 116), NO_VALUE(100); + + private final int value; + + private JFmRxStatus(int value) { + this.value = value; + } + + public Integer getValue() { + return value; + } +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmTx.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmTx.java new file mode 100644 index 0000000..ad3457b --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmTx.java @@ -0,0 +1,2745 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import java.util.HashMap; //import com.ti.jbtl.core.*; +import com.ti.jfm.core.*; + +/** Class for providing connection with JFmTxNative.cpp module */ + +public class JFmTx { + + private static final String TAG = "JFmTx"; + + private ICallback callback = null; + + private static JFmContext txContext; + + /** Hash table to store JFmContext handles based upon JFmTx. */ + private static HashMap<JFmContext, JFmTx> mTxContextsTable = new HashMap<JFmContext, JFmTx>(); + + /** Events path */ + +static { + try { + // JFmLog.i(TAG, "Loading libfmradio.so"); + // System.loadLibrary("fmradio"); + nativeJFmTx_ClassInitNative(); + } + catch (UnsatisfiedLinkError ule) { + JFmLog.e(TAG, "WARNING: Could not load libfmradio.so"); + } + catch (Exception e) { + JFmLog.e("JFmRx", "Exception during NativeJFmRx_ClassInitNative (" + + e.toString() + ")"); + } + } + + + public interface ICallback { + + /* Fm TX call backs */ + void fmTxCmdEnable(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdDisable(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdDestroy(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdTune(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetTunedFrequency(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdStartTransmission(JFmTx context, JFmTxStatus status/* + * , + * JFmCcmVacUnavailResourceList + * ccmVacUnavailResourceList + */); + + void fmTxCmdStopTransmission(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetPowerLevel(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetPowerLevel(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdEnableRds(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdDisableRds(JFmTx context, JFmTxStatus status, long value); + + // void fmTxCmdDone(JFmTx context, JFmTxStatus status, long value); + void fmTxCmdSetRdsTransmissionMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsTransmissionMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetMonoStereoMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetMonoStereoMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetPreEmphasisFilter(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetPreEmphasisFilter(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetMuteMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetMuteMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsAfCode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsAfCode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsPiCode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsPiCode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsPtyCode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsPtyCode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsTextRepertoire(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsTextRepertoire(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsPsDisplayMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsPsDisplayMode(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsPsScrollSpeed(JFmTx context, JFmTxStatus status, long value); + + // void fmTxCmdGetRdsPsScrollSpeed(JFmTx context, JFmTxStatus status, + // long value); + void fmTxCmdSetRdsTextRtMsg(JFmTx context, JFmTxStatus status, int msgType, int msgLen, + byte[] msg); + + void fmTxCmdGetRdsTextRtMsg(JFmTx context, JFmTxStatus status, int msgType, int msgLen, + byte[] msg); + + void fmTxCmdSetRdsTransmittedMask(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsTransmittedMask(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdSetRdsTextPsMsg(JFmTx context, JFmTxStatus status, int msgLen, byte[] msg); + + void fmTxCmdGetRdsTextPsMsg(JFmTx context, JFmTxStatus status, int msgLen, byte[] msg); + + void fmTxCmdSetRdsTrafficCodes(JFmTx context, JFmTxStatus status, int taCode, int tpCode); + + void fmTxCmdGetRdsTrafficCodes(JFmTx context, JFmTxStatus status, int taCode, int tpCode); + + void fmTxCmdSetRdsMusicSpeechFlag(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdGetRdsMusicSpeechFlag(JFmTx context, JFmTxStatus status, long value); + + // void fmTxCmdSetRdsECC(JFmTx context, JFmTxStatus status, long value); + void fmTxCmdChangeAudioSource(JFmTx context, JFmTxStatus status, + JFmCcmVacUnavailResourceList ccmVacUnavailResourceList); + + // void fmTxCmdChangeDigitalSourceConfiguration(JFmTx context, + // JFmTxStatus status, JFmCcmVacUnavailResourceList + // ccmVacUnavailResourceList); + void fmTxCmdSetInterruptMask(JFmTx context, JFmTxStatus status, long value); + + void fmTxCmdWriteRdsRawData(JFmTx contextValue, JFmTxStatus status, int len, byte[] msg); + + void fmTxCmdReadRdsRawData(JFmTx contextValue, JFmTxStatus status, int len, byte[] msg); + + void fmTxCmdSetRdsPsDisplaySpeed(JFmTx contextValue, JFmTxStatus status, long value); + + void fmTxCmdGetRdsPsDisplaySpeed(JFmTx contextValue, JFmTxStatus status, long value); + + void fmTxCmdSetRdsExtendedCountryCode(JFmTx contextValue, JFmTxStatus status, long value); + + void fmTxCmdGetRdsExtendedCountryCode(JFmTx contextValue, JFmTxStatus status, long value); + + void fmTxCmdChangeDigitalAudioConfiguration(JFmTx contextValue, JFmTxStatus status, + long value); + + void fmTxCmdSetRdsPsDispalyMode(JFmTx contextValue, JFmTxStatus status, long value); + + void fmTxCmdGetRdsPsDispalyMode(JFmTx contextValue, JFmTxStatus status, long value); + + } + + /** + * Datatype Classes + */ + + public static class JFmTxRdsPiCode { + private int value = 0; + + public JFmTxRdsPiCode(int val) { + this.value = val; + } + + public int getValue() { + return value; + } + } + + public static enum JFmTxEcalResource implements IJFmEnum<Integer> { + + CAL_RESOURCE_I2SH(0x00), CAL_RESOURCE_PCMH(0x01), CAL_RESOURCE_PCMT_1(0x02), CAL_RESOURCE_PCMT_2( + 0x03), CAL_RESOURCE_PCMT_3(0x04), CAL_RESOURCE_PCMT_4(0x05), CAL_RESOURCE_PCMT_5( + 0x06), CAL_RESOURCE_PCMT_6(0x07), CAL_RESOURCE_FM_ANALOG(0x08), CAL_RESOURCE_LAST_EL_RESOURCE( + 0x08), CAL_RESOURCE_PCMIF(0x09), CAL_RESOURCE_FMIF(0x0A), CAL_RESOURCE_CORTEX(0x0B), CAL_RESOURCE_FM_CORE( + 0x0C), CAL_RESOURCE_MAX_NUM(0x0D), CAL_RESOURCE_INVALID(0x0E); + + private final int ecalResource; + + private JFmTxEcalResource(int ecalResource) { + this.ecalResource = ecalResource; + } + + public Integer getValue() { + return ecalResource; + } + } + + public static enum JFmTxEcalOperation implements IJFmEnum<Integer> { + + CAL_OPERATION_FM_TX(0x00), CAL_OPERATION_FM_RX(0x01), CAL_OPERATION_A3DP(0x02), CAL_OPERATION_BT_VOICE( + 0x03), CAL_OPERATION_WBS(0x04), CAL_OPERATION_AWBS(0x05), CAL_OPERATION_FM_RX_OVER_SCO( + 0x06), CAL_OPERATION_FM_RX_OVER_A3DP(0x07), CAL_OPERATION_MAX_NUM(0x08), CAL_OPERATION_INVALID( + 0x09); + + private final int ecalOperation; + + private JFmTxEcalOperation(int ecalOperation) { + this.ecalOperation = ecalOperation; + } + + public Integer getValue() { + return ecalOperation; + } + } + + public static enum JFmTxEcalSampleFrequency implements IJFmEnum<Integer> { + CAL_SAMPLE_FREQ_8000(0x00), CAL_SAMPLE_FREQ_11025(0x01), CAL_SAMPLE_FREQ_12000(0x02), CAL_SAMPLE_FREQ_16000( + 0x03), CAL_SAMPLE_FREQ_22050(0x04), CAL_SAMPLE_FREQ_24000(0x05), CAL_SAMPLE_FREQ_32000( + 0x06), CAL_SAMPLE_FREQ_44100(0x07), CAL_SAMPLE_FREQ_48000(0x08); + + private final int ecalSampleFreq; + + private JFmTxEcalSampleFrequency(int ecalSampleFreq) { + this.ecalSampleFreq = ecalSampleFreq; + } + + public Integer getValue() { + return ecalSampleFreq; + } + } + + public static enum JFmTxRdsSystem implements IJFmEnum<Integer> { + FM_RDS_SYSTEM_RDS(0x00), FM_RDS_SYSTEM_RBDS(0x01); + + private final int rdsSystem; + + private JFmTxRdsSystem(int rdsSystem) { + this.rdsSystem = rdsSystem; + } + + public Integer getValue() { + return rdsSystem; + } + } + + public static enum JFmTxAudioRouteMask implements IJFmEnum<Integer> { + + FMC_AUDIO_ROUTE_MASK_I2S(0x00000001), FMC_AUDIO_ROUTE_MASK_ANALOG(0x00000002), FMC_AUDIO_ROUTE_MASK_NONE( + 0x00000000), FMC_AUDIO_ROUTE_MASK_ALL(0x00000003); + + private final int audioRouteMask; + + private JFmTxAudioRouteMask(int audioRouteMask) { + this.audioRouteMask = audioRouteMask; + } + + public Integer getValue() { + return audioRouteMask; + } + } + + public static class JFmTxPowerLevel { + + private int jFmTxPowerLevel; + + public JFmTxPowerLevel(int jFmTxPowerLevel) { + this.jFmTxPowerLevel = jFmTxPowerLevel; + } + + public int getvalue() { + return jFmTxPowerLevel; + } + + public void setvalue(int jFmTxPowerLevel) { + this.jFmTxPowerLevel = jFmTxPowerLevel; + } + } + + public static class JFmTxFreq { + + private long value = 0; + + public JFmTxFreq(long value) { + this.value = value; + } + + public long getValue() { + return value; + } + + public void setValue(long value) { + this.value = value; + } + } + + public static enum JFmTxMuteMode implements IJFmEnum<Integer> { + FMC_MUTE(0x00), FMC_NOT_MUTE(0x01), FMC_ATTENUATE(0x02); + + private final int muteMode; + + private JFmTxMuteMode(int muteMode) { + this.muteMode = muteMode; + } + + public Integer getValue() { + return muteMode; + } + } + + /* + * public static enum JFmTxAudioTargetMask implements IJFmEnum<Integer> { + * FM_RX_TARGET_MASK_INVALID(0), FM_RX_TARGET_MASK_I2SH(1), + * FM_RX_TARGET_MASK_PCMH(2), FM_RX_TARGET_MASK_FM_OVER_SCO(4), + * FM_RX_TARGET_MASK_FM_OVER_A3DP(8), FM_RX_TARGET_MASK_FM_ANALOG(16); + * private final int audioTargetMask; private JFmTxAudioTargetMask(int + * audioTargetMask) { this.audioTargetMask = audioTargetMask; } public + * Integer getValue() { return audioTargetMask; } } public static enum + * JFmTxRfDependentMuteMode implements IJFmEnum<Integer> { + * FM_RX_RF_DEPENDENT_MUTE_ON(0x01), FM_RX_RF_DEPENDENT_MUTE_OFF(0x00); + * private final int rfDependentMuteMode; private + * JFmTxRfDependentMuteMode(int rfDependentMuteMode) { + * this.rfDependentMuteMode = rfDependentMuteMode; } public Integer + * getValue() { return rfDependentMuteMode; } } + */ + + public static enum JFmTxMonoStereoMode implements IJFmEnum<Integer> { + FM_TX_MONO(0x00), FM_TX_STEREO(0x01); + + private final int monoStereoModer; + + private JFmTxMonoStereoMode(int monoStereoModer) { + this.monoStereoModer = monoStereoModer; + } + + public Integer getValue() { + return monoStereoModer; + } + } + + public static enum JFmTxEmphasisFilter implements IJFmEnum<Integer> { + FM_RX_EMPHASIS_FILTER_NONE(0x00), FM_RX_EMPHASIS_FILTER_50_USEC(0x01), FM_RX_EMPHASIS_FILTER_75_USEC( + 0x02); + + private final int emphasisFilter; + + private JFmTxEmphasisFilter(int emphasisFilter) { + this.emphasisFilter = emphasisFilter; + } + + public Integer getValue() { + return emphasisFilter; + } + } + + public static enum JFmTxRepertoire implements IJFmEnum<Integer> { + FMC_RDS_REPERTOIRE_G0_CODE_TABLE(0x00), FMC_RDS_REPERTOIRE_G1_CODE_TABLE(0x01), FMC_RDS_REPERTOIRE_G2_CODE_TABLE( + 0x02); + + private final int repertoire; + + private JFmTxRepertoire(int repertoire) { + this.repertoire = repertoire; + } + + public Integer getValue() { + return repertoire; + } + } + + public static enum JFmTxRdsTransmissionMode implements IJFmEnum<Integer> { + RDS_TRANSMISSION_MANUAL(0x00), RDS_TRANSMISSION_AUTOMATIC(0x01); + + private final int rdsTransmissionMode; + + private JFmTxRdsTransmissionMode(int rdsTransmissionMode) { + this.rdsTransmissionMode = rdsTransmissionMode; + } + + public Integer getValue() { + return rdsTransmissionMode; + } + } + + public static class JFmTxRdsPtyCode { + + private int rdsPtyCode = 0; + + public JFmTxRdsPtyCode(int rdsPtyCode) { + this.rdsPtyCode = rdsPtyCode; + } + + public int getValue() { + return rdsPtyCode; + } + + public void setValue(int rdsPtyCode) { + this.rdsPtyCode = rdsPtyCode; + } + } + + public static enum JFmMusicSpeechFlag implements IJFmEnum<Integer> { + FMC_RDS_SPEECH(0x00), FMC_RDS_MUSIC(0x01); + + private final int musicSpeechFlag; + + private JFmMusicSpeechFlag(int musicSpeechFlag) { + this.musicSpeechFlag = musicSpeechFlag; + } + + public Integer getValue() { + return musicSpeechFlag; + } + } + + public static enum JFmTaCode implements IJFmEnum<Integer> { + FMC_RDS_TA_OFF(0x00), FMC_RDS_TA_ON(0x01); + + private final int taCode; + + private JFmTaCode(int taCode) { + this.taCode = taCode; + } + + public Integer getValue() { + return taCode; + } + } + + public static enum JFmTpCode implements IJFmEnum<Integer> { + FMC_RDS_TP_OFF(0x00), FMC_RDS_TP_ON(0x01); + + private final int tpCode; + + private JFmTpCode(int tpCode) { + this.tpCode = tpCode; + } + + public Integer getValue() { + return tpCode; + } + } + + public static enum JFmRdsRtMsgType implements IJFmEnum<Integer> { + FMC_RDS_TEXT_TYPE_PS(0x01), FMC_RDS_TEXT_TYPE_AUTO(0x02), FMC_RDS_TEXT_TYPE_A(0x03), FMC_RDS_TEXT_TYPE_B( + 0x04); + + private final int msgType; + + private JFmRdsRtMsgType(int msgType) { + this.msgType = msgType; + } + + public Integer getValue() { + return msgType; + } + } + + public static enum JFmRdsPsDisplayMode implements IJFmEnum<Integer> { + FMC_RDS_PS_DISPLAY_MODE_STATIC(0x00), FMC_RDS_PS_DISPLAY_MODE_SCROLL(0x01); + + private final int displayMode; + + private JFmRdsPsDisplayMode(int displayMode) { + this.displayMode = displayMode; + } + + public Integer getValue() { + return displayMode; + } + } + + /******************************************************************************* + * Class Methods + *******************************************************************************/ + + /* Fm Tx */ + + public JFmTxStatus txCreate(ICallback callback) { + JFmTxStatus jFmTxStatus; + + JFmLog.i(TAG, " nativeJFmTx_create()-Entered "); + + try { + + txContext = new JFmContext(); + + JFmLog.d(TAG, "Calling nativeJFmTx_Create"); + int fmStatus = nativeJFmTx_Create(txContext); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmTx_Create, status = " + jFmTxStatus.toString() + + ", txContext = " + txContext.getValue()); + + /** + *Record the caller's callback and returned native context for + * nativeJFmTx_create + */ + + this.callback = callback; + mTxContextsTable.put(txContext, this); + + } catch (Exception e) { + JFmLog.e(TAG, "create: exception during nativeJFmTx_create (" + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + + return jFmTxStatus; + } + + public JFmTxStatus txDestroy() { + JFmLog.i(TAG, "txDestroy: entered"); + JFmTxStatus jFmTxStatus; + + try { + int fmStatus = nativeJFmTx_Destroy(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmTx_Destroy, status = " + jFmTxStatus.toString()); + + /* + * Remove a pair of JFmContext-JFmTx related to the destroyed + * context from the HashMap + */ + + mTxContextsTable.remove(txContext); + + } catch (Exception e) { + JFmLog.e(TAG, "txDestroy: exception during nativeJFmTx_Destroy (" + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + + JFmLog.d(TAG, "txDestroy: exiting"); + + return jFmTxStatus; + + } + + public JFmTxStatus txEnable() { + JFmLog.d(TAG, "txEnable: entered"); + JFmTxStatus jFmTxStatus; + + try { + int fmStatus = nativeJFmTx_Enable(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, fmStatus); + JFmLog.d(TAG, "After nativeJFmTx_Enable, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txEnable: exception during nativeJFmTx_Enable (" + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txEnable: exiting"); + + return jFmTxStatus; + + } + + public JFmTxStatus txDisable() { + JFmLog.d(TAG, "txDisable: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_Disable(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_Disable, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txDisable: exception during nativeJFmTx_Disable (" + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txDisable: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txTune(JFmTxFreq jfmTxFreq) { + + JFmLog.d(TAG, "txTune: entered"); + + JFmTxStatus jFmTxStatus; + + try { + + int status = nativeJFmTx_Tune(txContext.getValue(), jfmTxFreq.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_Tune, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txTune: exception during nativeJFmTx_Tune (" + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txTune: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetTunedFrequency() { + + JFmLog.d(TAG, "txGetTunedFrequency: entered"); + + JFmTxStatus jFmTxStatus; + + try { + + int status = nativeJFmTx_GetTunedFrequency(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_Tune, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetTunedFrequency: exception during nativeJFmTx_Tune (" + e.toString() + + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetTunedFrequency: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txStartTransmission() { + JFmLog.d(TAG, "txStartTransmission: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_StartTransmission(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmTx_StartTransmission, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "disable: exception during nativeJFmTx_StartTransmission (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txStartTransmission: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txStopTransmission() { + JFmLog.d(TAG, "txStopTransmission: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_StopTransmission(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_StopTransmission, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txStopTransmission: exception during nativeJFmTx_StopTransmission (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txStopTransmission: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetPowerLevel(JFmTxPowerLevel jFmTxPowerLevel) { + JFmLog.d(TAG, "txSetPowerLevel: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetPowerLevel(txContext.getValue(), jFmTxPowerLevel.getvalue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmnativeJFmTx_SetPowerLevel, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetPowerLevel: exception during nativeJFmTx_SetPowerLevel (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetPowerLevel: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetPowerLevel() { + JFmLog.d(TAG, "txGetPowerLevel: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetPowerLevel(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmnativeJFmTx_GetPowerLevel, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetPowerLevel: exception during nativeJFmnativeJFmTx_GetPowerLevel (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetPowerLevel: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txEnableRds() { + JFmLog.d(TAG, "txEnableRds: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_EnableRds(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_EnableRds, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txEnableRds: exception during nativeJFmTx_EnableRds (" + e.toString() + + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txEnableRds: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txDisableRds() { + JFmLog.d(TAG, "txDisableRds: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_DisableRds(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_DisableRds, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txDisableRds: exception during nativeJFmTx_DisableRds (" + e.toString() + + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txDisableRds: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsTransmissionMode(JFmTxRdsTransmissionMode mode) { + JFmLog.d(TAG, "txSetRdsTransmissionMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsTransmissionMode(txContext.getValue(), mode.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsTransmissionMode, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetRdsTransmissionMode: exception during nativeJFmTx_SetRdsTransmissionMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsTransmissionMode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsTransmissionMode() { + JFmLog.d(TAG, "txGetRdsTransmissionMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsTransmissionMode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsTransmissionMode, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txGetRdsTransmissionMode: exception during nativeJFmTx_GetRdsTransmissionMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsTransmissionMode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsTextPsMsg(String psString, int length) { + JFmLog.d(TAG, "txSetRdsTextPsMsg: entered"); + JFmLog.d(TAG, "txSetRdsTextPsMsg psString => " + psString + " length = " + length); + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsTextPsMsg(txContext.getValue(), psString, length); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsTextPsMsg, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsTextPsMsg: exception during nativeJFmTx_SetRdsTextPsMsg (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsTextPsMsg: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsTextPsMsg() { + JFmLog.d(TAG, "txGetRdsTextPsMsg: entered"); + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsTextPsMsg(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsTextPsMsg, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsTextPsMsg: exception during nativeJFmTx_GetRdsTextPsMsg (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsTextPsMsg: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txWriteRdsRawData(String msg, int length) { + JFmLog.d(TAG, "txWriteRdsRawData: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_WriteRdsRawData(txContext.getValue(), msg, length); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_WriteRdsRawData, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txWriteRdsRawData: exception during nativeJFmTx_WriteRdsRawData (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txWriteRdsRawData: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txChangeDigitalSourceConfiguration(int ecalSampleFreq) { + JFmLog.d(TAG, "txChangeDigitalSourceConfiguration: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_ChangeDigitalSourceConfiguration(txContext.getValue(), + ecalSampleFreq); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_ChangeDigitalSourceConfiguration, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog + .e( + TAG, + "txChangeDigitalSourceConfiguration: exception during nativeJFmTx_ChangeDigitalSourceConfiguration (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txChangeDigitalSourceConfiguration: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txChangeAudioSource(JFmTxEcalResource audioSrc, + JFmTxEcalSampleFrequency ecalSampleFreq) { + JFmLog.d(TAG, "txChangeAudioSource: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_ChangeAudioSource(txContext.getValue(), audioSrc.getValue(), + ecalSampleFreq.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmTx_ChangeAudioSource, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txChangeAudioSource: exception during nativeJFmTx_ChangeAudioSource (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txChangeAudioSource: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsECC(int ecc) { + JFmLog.d(TAG, "txSetRdsECC: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsExtendedCountryCode(txContext.getValue(), ecc); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsECC, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsECC: exception during nativeJFmTx_SetRdsECC (" + e.toString() + + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsECC: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsECC() { + JFmLog.d(TAG, "txGetRdsECC: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsExtendedCountryCode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsECC, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsECC: exception during nativeJFmTx_GetRdsECC (" + e.toString() + + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsECC: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetMonoStereoMode(JFmTxMonoStereoMode mode) { + JFmLog.d(TAG, "txSetMonoStereoMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetMonoStereoMode(txContext.getValue(), mode.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmTx_SetMonoStereoMode, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetMonoStereoMode: exception during nativeJFmTx_SetMonoStereoMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetMonoStereoMode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetMonoStereoMode() { + JFmLog.d(TAG, "txGetMonoStereoMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetMonoStereoMode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog + .d(TAG, "After nativeJFmTx_GetMonoStereoMode, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsECC: exception during nativeJFmTx_GetMonoStereoMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetMonoStereoMode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetPreEmphasisFilter(JFmTxEmphasisFilter preEmpFilter) { + JFmLog.d(TAG, "txSetPreEmphasisFilter: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetPreEmphasisFilter(txContext.getValue(), preEmpFilter + .getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetPreEmphasisFilter, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetPreEmphasisFilter: exception during nativeJFmTx_SetPreEmphasisFilter (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetPreEmphasisFilter: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetPreEmphasisFilter() { + JFmLog.d(TAG, "txGetPreEmphasisFilter: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetPreEmphasisFilter(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetPreEmphasisFilter, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetPreEmphasisFilter: exception during nativeJFmTx_GetPreEmphasisFilter (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetPreEmphasisFilter: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetMuteMode(JFmTxMuteMode muteMode) { + JFmLog.d(TAG, "txSetMuteMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetMuteMode(txContext.getValue(), muteMode.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetMuteMode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetMuteMode: exception during nativeJFmTx_SetMuteMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetMuteMode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetMuteMode() { + JFmLog.d(TAG, "txGetMuteMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetMuteMode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetMuteMode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetMuteMode: exception during nativeJFmTx_GetMuteMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetMuteMode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsAfCode(int afCode) { + JFmLog.d(TAG, "txSetRdsAfCode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsAfCode(txContext.getValue(), afCode); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsAfCode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsAfCode: exception during nativeJFmTx_SetRdsAfCode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsAfCode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsAfCode() { + JFmLog.d(TAG, "txGetRdsAfCode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsAfCode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsAfCode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsAfCode: exception during nativeJFmTx_GetRdsAfCode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsAfCode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsPiCode(JFmTxRdsPiCode piCode) { + JFmLog.d(TAG, "txSetRdsPiCode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsPiCode(txContext.getValue(), piCode.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsPiCode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsPiCode: exception during nativeJFmTx_SetRdsPiCode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsPiCode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsPiCode() { + JFmLog.d(TAG, "txGetRdsPiCode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsPiCode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsPiCode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsPiCode: exception during nativeJFmTx_SetRdsPiCode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsPiCode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsPtyCode(JFmTxRdsPtyCode ptyCode) { + JFmLog.d(TAG, "txSetRdsPtyCode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsPtyCode(txContext.getValue(), ptyCode.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsPtyCode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsPtyCode: exception during nativeJFmTx_SetRdsPtyCode(" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsPtyCode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsPtyCode() { + JFmLog.d(TAG, "txGetRdsPtyCode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsPtyCode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsPtyCode, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsPtyCode: exception during nativeJFmTx_GetRdsPtyCode(" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsPtyCode: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsTextRepertoire(JFmTxRepertoire repertoire) { + JFmLog.d(TAG, "txSetRdsTextRepertoire: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsTextRepertoire(txContext.getValue(), repertoire + .getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsTextRepertoire, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetRdsTextRepertoire: exception during nativeJFmTx_SetRdsTextRepertoire (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsTextRepertoire: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsTextRepertoire() { + JFmLog.d(TAG, "txGetRdsTextRepertoire: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsTextRepertoire(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsTextRepertoire, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txGetRdsTextRepertoire: exception during nativeJFmTx_GetRdsTextRepertoire (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsTextRepertoire: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsPsDisplayMode(JFmRdsPsDisplayMode dispalyMode) { + JFmLog.d(TAG, "txSetRdsPsDisplayMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsPsDisplayMode(txContext.getValue(), dispalyMode + .getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsECC, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsECC: exception during nativeJFmTx_SetRdsECC (" + e.toString() + + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsECC: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsPsDisplayMode() { + JFmLog.d(TAG, "txGetRdsPsDisplayMode: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsPsDisplayMode(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsPsDisplayMode, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsECC: exception during nativeJFmTx_GetRdsPsDisplayMode (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsECC: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsPsScrollSpeed(int scrollSpeed) { + JFmLog.d(TAG, "txSetRdsPsScrollSpeed: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsPsScrollSpeed(txContext.getValue(), scrollSpeed); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsPsScrollSpeed, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetRdsPsScrollSpeed: exception during nativeJFmTx_SetRdsPsScrollSpeed (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsPsScrollSpeed: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsPsScrollSpeed() { + JFmLog.d(TAG, "txGetRdsPsScrollSpeed: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsPsScrollSpeed(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsPsScrollSpeed, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txGetRdsPsScrollSpeed: exception during nativeJFmTx_GetRdsPsScrollSpeed (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsPsScrollSpeed: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsTextRtMsg(JFmRdsRtMsgType msgType, String msg, int msgLength) { + JFmLog.d(TAG, "txSetRdsTextRtMsg: entered"); + JFmLog.d(TAG, "txSetRdsTextRtMsg msg = " + msg + " msgLength = " + msgLength); + JFmTxStatus jFmTxStatus; + // byte[] message = msg.getBytes(); + try { + int status = nativeJFmTx_SetRdsTextRtMsg(txContext.getValue(), msgType.getValue(), msg, + msgLength); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsTextRtMsg, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsTextRtMsg: exception during nativeJFmTx_SetRdsECC (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsTextRtMsg: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsTextRtMsg() { + JFmLog.d(TAG, "txGetRdsTextRtMsg: entered"); + + JFmTxStatus jFmTxStatus; + // byte[] message = msg.getBytes(); + try { + int status = nativeJFmTx_GetRdsTextRtMsg(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsTextRtMsg, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsTextRtMsg: exception during nativeJFmTx_GetRdsECC (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsTextRtMsg: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsTransmittedGroupsMask(long rdsTrasmittedGrpMask) { + JFmLog.d(TAG, "txSetRdsTransmittedGroupsMask: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsTransmittedGroupsMask(txContext.getValue(), + rdsTrasmittedGrpMask); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsTransmittedGroupsMask, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetRdsTransmittedGroupsMask: exception during nativeJFmTx_SetRdsTransmittedGroupsMask (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsTransmittedGroupsMask: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsTransmittedGroupsMask() { + JFmLog.d(TAG, "txGetRdsTransmittedGroupsMask: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsTransmittedGroupsMask(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsTransmittedGroupsMask, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txGetRdsTransmittedGroupsMask: exception during nativeJFmTx_getRdsTransmittedGroupsMask (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsTransmittedGroupsMask: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsTrafficCodes(JFmTaCode taCode, JFmTpCode tpCode) { + JFmLog.d(TAG, "txSetRdsTransmittedGroupsMask: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsTrafficCodes(txContext.getValue(), taCode.getValue(), + tpCode.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsTrafficCodes, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txSetRdsTransmittedGroupsMask: exception during nativeJFmTx_SetRdsTrafficCodes (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsTransmittedGroupsMask: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsTrafficCodes() { + JFmLog.d(TAG, "txGetRdsTrafficCodes: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsTrafficCodes(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsTrafficCodes, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txGetRdsTrafficCodes: exception during nativeJFmTx_GetRdsTrafficCodes (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsTrafficCodes: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txSetRdsMusicSpeechFlag(JFmMusicSpeechFlag musicSpeechFlag) { + JFmLog.d(TAG, "txSetRdsMusicSpeechFlag: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_SetRdsMusicSpeechFlag(txContext.getValue(), musicSpeechFlag + .getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_SetRdsECC, status = " + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, "txSetRdsMusicSpeechFlag: exception during nativeJFmTx_SetRdsECC (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txSetRdsMusicSpeechFlag: exiting"); + return jFmTxStatus; + } + + public JFmTxStatus txGetRdsMusicSpeechFlag() { + JFmLog.d(TAG, "txGetRdsMusicSpeechFlag: entered"); + + JFmTxStatus jFmTxStatus; + + try { + int status = nativeJFmTx_GetRdsMusicSpeechFlag(txContext.getValue()); + jFmTxStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + JFmLog.d(TAG, "After nativeJFmTx_GetRdsMusicSpeechFlag, status = " + + jFmTxStatus.toString()); + } catch (Exception e) { + JFmLog.e(TAG, + "txGetRdsMusicSpeechFlag: exception during nativeJFmTx_GetRdsMusicSpeechFlag (" + + e.toString() + ")"); + jFmTxStatus = JFmTxStatus.FAILED; + } + JFmLog.d(TAG, "txGetRdsMusicSpeechFlag: exiting"); + return jFmTxStatus; + } + + /*-------------------------------------------------------------------------- + * NATIVE PART + *------------------------------------------------------------------------*/ + + /* RBTL Calls */ + + /* FM TX */ + private static native void nativeJFmTx_ClassInitNative(); + + private static native int nativeJFmTx_Create(JFmContext contextValue); + + private static native int nativeJFmTx_Enable(long contextValue); + + private static native int nativeJFmTx_Tune(long contextValue, long jFmTxFreq); + + private static native int nativeJFmTx_GetTunedFrequency(long contextValue); + + private static native int nativeJFmTx_StartTransmission(long contextValue); + + private static native int nativeJFmTx_Disable(long contextValue); + + private static native int nativeJFmTx_Destroy(long contextValue); + + private static native int nativeJFmTx_StopTransmission(long contextValue); + + private static native int nativeJFmTx_SetPowerLevel(long contextValue, int powerLevel); + + private static native int nativeJFmTx_GetPowerLevel(long contextValue); + + private static native int nativeJFmTx_EnableRds(long contextValue); + + private static native int nativeJFmTx_DisableRds(long contextValue); + + private static native int nativeJFmTx_SetRdsTransmissionMode(long contextValue, int mode); + + private static native int nativeJFmTx_GetRdsTransmissionMode(long contextValue); + + private static native int nativeJFmTx_SetRdsTextPsMsg(long contextValue, + java.lang.String psString, int length); + + private static native int nativeJFmTx_GetRdsTextPsMsg(long contextValue); + + private static native int nativeJFmTx_WriteRdsRawData(long contextValue, java.lang.String msg, + int length); + + private static native int nativeJFmTx_ChangeDigitalSourceConfiguration(long contextValue, + int ecalSampleFreq); + + private static native int nativeJFmTx_ChangeAudioSource(long contextValue, int audioSrc, + int ecalSampleFreq); + + private static native int nativeJFmTx_SetRdsExtendedCountryCode(long contextValue, int ecc); + + private static native int nativeJFmTx_GetRdsExtendedCountryCode(long contextValue); + + private static native int nativeJFmTx_SetRdsMusicSpeechFlag(long contextValue, + int musicSpeechFlag); + + private static native int nativeJFmTx_GetRdsMusicSpeechFlag(long contextValue); + + private static native int nativeJFmTx_SetRdsTrafficCodes(long contextValue, int taCode, + int tpCode); + + private static native int nativeJFmTx_GetRdsTrafficCodes(long contextValue); + + private static native int nativeJFmTx_SetRdsTransmittedGroupsMask(long contextValue, long taCode); + + private static native int nativeJFmTx_GetRdsTransmittedGroupsMask(long contextValue); + + private static native int nativeJFmTx_SetRdsTextRtMsg(long contextValue, int msgType, + java.lang.String msg, int msgLength); + + private static native int nativeJFmTx_GetRdsTextRtMsg(long contextValue); + + private static native int nativeJFmTx_SetRdsPsScrollSpeed(long contextValue, int scrollSpeed); + + private static native int nativeJFmTx_GetRdsPsScrollSpeed(long contextValue); + + private static native int nativeJFmTx_SetMuteMode(long contextValue, int muteMode); + + private static native int nativeJFmTx_GetMuteMode(long contextValue); + + private static native int nativeJFmTx_SetRdsAfCode(long contextValue, int afCode); + + private static native int nativeJFmTx_GetRdsAfCode(long contextValue); + + private static native int nativeJFmTx_SetRdsPiCode(long contextValue, int piCode); + + private static native int nativeJFmTx_GetRdsPiCode(long contextValue); + + private static native int nativeJFmTx_SetRdsPtyCode(long contextValue, int ptyCode); + + private static native int nativeJFmTx_GetRdsPtyCode(long contextValue); + + private static native int nativeJFmTx_SetRdsPsDisplayMode(long contextValue, int displayMode); + + private static native int nativeJFmTx_GetRdsPsDisplayMode(long contextValue); + + private static native int nativeJFmTx_SetRdsTextRepertoire(long contextValue, int reprtoire); + + private static native int nativeJFmTx_GetRdsTextRepertoire(long contextValue); + + private static native int nativeJFmTx_SetPreEmphasisFilter(long contextValue, int preEmpFilter); + + private static native int nativeJFmTx_GetPreEmphasisFilter(long contextValue); + + private static native int nativeJFmTx_GetMonoStereoMode(long contextValue); + + private static native int nativeJFmTx_SetMonoStereoMode(long contextValue, int mode); + + private static native int nativeJFmTx_ReadRdsRawData(long contextValue); + + /*--------------------------------------------------------------------------- + * -------------------------------- NATIVE PART-------------------------------- + * --------------------------------------------------------------------------- + */ + + /*--------------------------------------------------------------------------- + * ---------------------------------------------- Callbacks from the------------- + * JFmTxNative.cpp module ----------------------------------------------------- + */ + + /********* FM TX ***********/ + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdEnable(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdEnable: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdEnable: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdEnable: calling callback"); + + callback.fmTxCmdEnable(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdDisable(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdDisable: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdDisable: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdDisable: calling callback"); + + callback.fmTxCmdDisable(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdDestroy(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdDestroy: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdDestroy: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdDestroy: calling callback"); + + callback.fmTxCmdDestroy(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdTune(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdTune: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdTune: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdTune: calling callback"); + + callback.fmTxCmdTune(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetTunedFrequency(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetTunedFrequency: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetTunedFrequency: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetTunedFrequency: calling callback"); + + callback.fmTxCmdGetTunedFrequency(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdStopTransmission(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdStopTransmission: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdStopTransmission: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdStopTransmission: calling callback"); + + callback.fmTxCmdStopTransmission(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdStartTransmission(long contextValue, int status/* + * , + * JFmCcmVacUnavailResourceList + * ccmVacUnavailResourceList + */) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdStartTransmission: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdStartTransmission: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdStartTransmission: calling callback"); + + callback.fmTxCmdStartTransmission(mJFmTx, txStatus/* + * , + * ccmVacUnavailResourceList + */); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdEnableRds(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdEnableRds: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdEnableRds: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdEnableRds: calling callback"); + + callback.fmTxCmdEnableRds(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdDisableRds(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdDisableRds: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdDisableRds: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdDisableRds: calling callback"); + + callback.fmTxCmdDisableRds(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsTransmissionMode(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTransmissionMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTransmissionMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTransmissionMode: calling callback"); + + callback.fmTxCmdSetRdsTransmissionMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsTransmissionMode(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTransmissionMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTransmissionMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTransmissionMode: calling callback"); + + callback.fmTxCmdGetRdsTransmissionMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetMonoStereoMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetMonoStereoMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetMonoStereoMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetMonoStereoMode: calling callback"); + + callback.fmTxCmdSetMonoStereoMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetMonoStereoMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetMonoStereoMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetMonoStereoMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetMonoStereoMode: calling callback"); + + callback.fmTxCmdGetMonoStereoMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetPreEmphasisFilter(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetPreEmphasisFilter: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetPreEmphasisFilter: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetPreEmphasisFilter: calling callback"); + + callback.fmTxCmdSetPreEmphasisFilter(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetPreEmphasisFilter(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetPreEmphasisFilter: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetPreEmphasisFilter: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetPreEmphasisFilter: calling callback"); + + callback.fmTxCmdGetPreEmphasisFilter(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetMuteMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetMuteMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetMuteMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetMuteMode: calling callback"); + + callback.fmTxCmdSetMuteMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetMuteMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetMuteMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetMuteMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetMuteMode: calling callback"); + + callback.fmTxCmdGetMuteMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsAfCode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsAfCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsAfCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsAfCode: calling callback"); + + callback.fmTxCmdSetMuteMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsAfCode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsAfCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsAfCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsAfCode: calling callback"); + + callback.fmTxCmdGetRdsAfCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsPiCode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPiCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPiCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPiCode: calling callback"); + + callback.fmTxCmdSetRdsPiCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsPiCode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPiCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPiCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPiCode: calling callback"); + + callback.fmTxCmdGetRdsPiCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsPtyCode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPtyCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPtyCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPtyCode: calling callback"); + + callback.fmTxCmdSetRdsPtyCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsPtyCode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPtyCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPtyCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPtyCode: calling callback"); + + callback.fmTxCmdGetRdsPtyCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsTextRepertoire(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextRepertoire: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextRepertoire: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextRepertoire: calling callback"); + + callback.fmTxCmdSetRdsTextRepertoire(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsTextRepertoire(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextRepertoire: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextRepertoire: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextRepertoire: calling callback"); + + callback.fmTxCmdGetRdsTextRepertoire(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsPsDisplayMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDisplayMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDisplayMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDisplayMode: calling callback"); + + callback.fmTxCmdSetRdsPsDisplayMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsPsDisplayMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDisplayMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDisplayMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDisplayMode: calling callback"); + + callback.fmTxCmdGetRdsPsDisplayMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsPsDisplaySpeed(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDisplaySpeed: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDisplaySpeed: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDisplaySpeed: calling callback"); + + callback.fmTxCmdSetRdsPsDisplaySpeed(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsPsDisplaySpeed(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDisplaySpeed: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDisplaySpeed: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDisplaySpeed: calling callback"); + + callback.fmTxCmdGetRdsPsDisplaySpeed(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsTransmittedMask(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTransmittedMask: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTransmittedMask: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTransmittedMask: calling callback"); + + callback.fmTxCmdSetRdsTransmittedMask(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsTransmittedMask(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTransmittedMask: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTransmittedMask: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTransmittedMask: calling callback"); + + callback.fmTxCmdGetRdsTransmittedMask(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsMusicSpeechFlag(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsMusicSpeechFlag: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsMusicSpeechFlag: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsMusicSpeechFlag: calling callback"); + + callback.fmTxCmdSetRdsMusicSpeechFlag(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsMusicSpeechFlag(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsMusicSpeechFlag: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsMusicSpeechFlag: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsMusicSpeechFlag: calling callback"); + + callback.fmTxCmdGetRdsMusicSpeechFlag(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdChangeAudioSource(long contextValue, int status, + JFmCcmVacUnavailResourceList ccmVacUnavailResourceList) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdChangeAudioSource: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdChangeAudioSource: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdChangeAudioSource: calling callback"); + + callback.fmTxCmdChangeAudioSource(mJFmTx, txStatus, ccmVacUnavailResourceList); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsTrafficCodes(long contextValue, int status, + int taCode, int tpCode) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTrafficCodes: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTrafficCodes: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTrafficCodes: calling callback"); + + callback.fmTxCmdSetRdsTrafficCodes(mJFmTx, txStatus, taCode, tpCode); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsTrafficCodes(long contextValue, int status, + int taCode, int tpCode) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTrafficCodes: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTrafficCodes: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTrafficCodes: calling callback"); + + callback.fmTxCmdGetRdsTrafficCodes(mJFmTx, txStatus, taCode, tpCode); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsTextPsMsg(long contextValue, int status, int msgLen, + byte[] msg) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextPsMsg: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextPsMsg: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextPsMsg: calling callback"); + + callback.fmTxCmdSetRdsTextPsMsg(mJFmTx, txStatus, msgLen, msg); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsTextPsMsg(long contextValue, int status, int msgLen, + byte[] msg) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextPsMsg: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextPsMsg: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextPsMsg: calling callback"); + + callback.fmTxCmdGetRdsTextPsMsg(mJFmTx, txStatus, msgLen, msg); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsTextRtMsg(long contextValue, int status, int msgType, + int msgLen, byte[] msg) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextRtMsg: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextRtMsg: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsTextRtMsg: calling callback"); + + callback.fmTxCmdSetRdsTextRtMsg(mJFmTx, txStatus, msgType, msgLen, msg); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsTextRtMsg(long contextValue, int status, int msgType, + int msgLen, byte[] msg) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextRtMsg: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextRtMsg: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsTextRtMsg: calling callback"); + + callback.fmTxCmdGetRdsTextRtMsg(mJFmTx, txStatus, msgType, msgLen, msg); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetInterruptMask(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetInterruptMask: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetInterruptMask: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetInterruptMask: calling callback"); + + callback.fmTxCmdSetInterruptMask(mJFmTx, txStatus, value); + + } + + } + + /* + * @SuppressWarnings("unused") public static void + * nativeCb_fmTxCmdGetInterruptMask(long contextValue, int status, long + * value) { JFmLog.d(TAG, "nativeCb_fmTxCmdGetInterruptMask: entered"); + * JFmTx mJFmTx = getJFmTx(contextValue); if (mJFmTx != null) { ICallback + * callback = mJFmTx.callback; JFmLog.d(TAG, + * "nativeCb_fmTxCmdGetInterruptMask: converting callback args"); + * JFmLog.d(TAG, "nativeCb_fmTxCmdGetInterruptMask: calling callback"); + * callback.fmTxCmdGetInterruptMask(mJFmTx, status, value); } } + */ + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsExtendedCountryCode(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsExtendedCountryCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsExtendedCountryCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsExtendedCountryCode: calling callback"); + + callback.fmTxCmdSetRdsExtendedCountryCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsExtendedCountryCode(long contextValue, int status, + long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsExtendedCountryCode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsExtendedCountryCode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsExtendedCountryCode: calling callback"); + + callback.fmTxCmdGetRdsExtendedCountryCode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdChangeDigitalAudioConfiguration(long contextValue, + int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdChangeDigitalAudioConfiguration: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, + "nativeCb_fmTxCmdChangeDigitalAudioConfiguration: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdChangeDigitalAudioConfiguration: calling callback"); + + callback.fmTxCmdChangeDigitalAudioConfiguration(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdWriteRdsRawData(long contextValue, int status, int len, + byte[] msg) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdWriteRdsRawData: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdWriteRdsRawData: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdWriteRdsRawData: calling callback"); + + callback.fmTxCmdWriteRdsRawData(mJFmTx, txStatus, len, msg); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdReadRdsRawData(long contextValue, int status, int len, + byte[] msg) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdReadRdsRawData: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdReadRdsRawData: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdReadRdsRawData: calling callback"); + + callback.fmTxCmdReadRdsRawData(mJFmTx, txStatus, len, msg); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetPowerLevel(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetPowerLevel: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetPowerLevel: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetPowerLevel: calling callback"); + + callback.fmTxCmdSetPowerLevel(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetPowerLevel(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetPowerLevel: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetPowerLevel: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetPowerLevel: calling callback"); + + callback.fmTxCmdGetPowerLevel(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdSetRdsPsDispalyMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDispalyMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDispalyMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdSetRdsPsDispalyMode: calling callback"); + + callback.fmTxCmdSetRdsPsDispalyMode(mJFmTx, txStatus, value); + + } + + } + + @SuppressWarnings("unused") + public static void nativeCb_fmTxCmdGetRdsPsDispalyMode(long contextValue, int status, long value) { + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDispalyMode: entered"); + + JFmTx mJFmTx = getJFmTx(contextValue); + + if (mJFmTx != null) { + + ICallback callback = mJFmTx.callback; + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDispalyMode: converting callback args"); + + JFmTxStatus txStatus = JFmUtils.getEnumConst(JFmTxStatus.class, status); + + JFmLog.d(TAG, "nativeCb_fmTxCmdGetRdsPsDispalyMode: calling callback"); + + callback.fmTxCmdGetRdsPsDispalyMode(mJFmTx, txStatus, value); + + } + + } + + /****************************************************************************************** + * Private utility functions + *******************************************************************************************/ + + private static JFmTx getJFmTx(long contextValue) { + JFmTx jFmTx; + + JFmContext profileContext = new JFmContext(contextValue); + + if (mTxContextsTable.containsKey(profileContext)) { + jFmTx = mTxContextsTable.get(profileContext); + } else { + JFmLog.e(TAG, "JFmTx: Failed mapping context " + contextValue + " to a callback"); + jFmTx = null; + } + + return jFmTx; + } + +} /* End class */ diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmTxStatus.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmTxStatus.java new file mode 100644 index 0000000..0a8e55a --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmTxStatus.java @@ -0,0 +1,42 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +public enum JFmTxStatus implements IJFmEnum<Integer> { + + SUCCESS(0), FAILED(1), PENDING(2), INVALID_PARM(3), IN_PROGRESS(4), NOT_APPLICABLE(5), NOT_SUPPORTED( + 6), INTERNAL_ERROR(7), TRANSPORT_INIT_ERR(8), HARDWARE_ERR(9), NO_VALUE_AVAILABLE(10), CONTEXT_DOESNT_EXIST( + 11), CONTEXT_NOT_DESTROYED(12), CONTEXT_NOT_ENABLED(13), CONTEXT_NOT_DISABLED(14), NOT_DE_INITIALIZED( + 15), NOT_INITIALIZED(16), TOO_MANY_PENDING_CMDS(17), DISABLING_IN_PROGRESS(18), NO_RESOURCES( + 19), FM_COMMAND_FAILED(20), SCRIPT_EXEC_FAILED(21), PROCESS_TIMEOUT_FAILURE(22), + + FAILED_BT_NOT_INITIALIZED(23), AUDIO_OPERATION_UNAVAILIBLE_RESOURCES(24), + /* LAST (AUDIO_OPERATION_UNAVAILIBLE_RESOURCES), */ + + FMC_FIRST_FM_RX_STATUS_CODE(100), FMC_FIRST_FM_TX_STATUS_CODE(200); + + private final int value; + + private JFmTxStatus(int value) { + this.value = value; + } + + public Integer getValue() { + return value; + } +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/core/JFmUtils.java b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmUtils.java new file mode 100644 index 0000000..0abedcc --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/core/JFmUtils.java @@ -0,0 +1,48 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.jfm.core; + +import java.lang.Enum; +import java.util.EnumSet; //import com.ti.jbtl.core.*; + +import com.ti.jfm.core.*; + +public final class JFmUtils { + + private static final String TAG = "JFmUtils"; + + public static <V, E extends Enum<E> & IJFmEnum<V>> E getEnumConst(Class<E> enumType, + V constValue) { + EnumSet<E> es = EnumSet.allOf(enumType); + + E matchingConst = null; + + for (E enumConst : es) { + if (enumConst.getValue().equals(constValue)) { + matchingConst = enumConst; + break; + } + } + + if (matchingConst == null) { + JFmLog.e(TAG, "getEnumConst: Invalid const (" + constValue + ") for " + + enumType.toString()); + } + return matchingConst; + } +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/fm/FmRadio.java b/tools/FM/FmRadioIf/src/java/com/ti/fm/FmRadio.java new file mode 100644 index 0000000..b8dd989 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/fm/FmRadio.java @@ -0,0 +1,1886 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fm; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.os.IBinder; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.content.ServiceConnection; +import android.util.Log; + +/** + * The Android FmRadio API is not finalized, and *will* change. Use at your own + * risk. Public API for controlling the FmRadio Service. FmRadio is a proxy + * object for controlling the Fm Reception/Transmission Service via IPC. + * Creating a FmRadio object will create a binding with the FMRX service. Users + * of this object should call close() when they are finished with the FmRadio, + * so that this proxy object can unbind from the service. + * + * @hide + */ +public class FmRadio { + + private static final String TAG = "FmRadio"; + + private static final boolean DBG = true; + + private IFmRadio mService; + + private Context mContext; + + private ServiceListener mServiceListener; + + public static final int STATE_ENABLED = 0; + + public static final int STATE_DISABLED = 1; + + public static final int STATE_ENABLING = 2; + + public static final int STATE_DISABLING = 3; + + public static final int STATE_PAUSE = 4; + + public static final int STATE_RESUME = 5; + + public static final int STATE_DEFAULT = 6; + + private static FmRadio INSTANCE; + + /** Used when obtaining a reference to the singleton instance. */ + private static Object INSTANCE_LOCK = new Object(); + + private boolean mInitialized = false; + + // Constructor + private FmRadio() { + + } + + private ServiceConnection mConnection = new ServiceConnection() { + public void onServiceConnected(ComponentName className, IBinder service) { + // This is called when the connection with the service has been + // established, giving us the service object we can use to + // interact with the service. We are communicating with our + // service through an IDL interface, so get a client-side + // representation of that from the raw service object. + Log.i(TAG, "Service connected"); + mService = IFmRadio.Stub.asInterface(service); + if (mServiceListener != null) { + Log.i(TAG, "Sending callback"); + mServiceListener.onServiceConnected(); + } else { + Log.e(TAG, "mService is NULL"); + } + } + + public void onServiceDisconnected(ComponentName className) { + // This is called when the connection with the service has been + // unexpectedly disconnected -- that is, its process crashed. + Log.i(TAG, "Service disconnected"); + mService = null; + if (mServiceListener != null) { + mServiceListener.onServiceDisconnected(); + } + } + }; + + public FmRadio(Context context, ServiceListener listener) { + // This will be around as long as this process is + mContext = context.getApplicationContext(); + mServiceListener = listener; + Log.i(TAG, "FmRadio:Creating a FmRadio proxy object: " + mConnection); + mContext.bindService(new Intent("com.ti.server.FmService"), mConnection, + Context.BIND_AUTO_CREATE); + } + + /** + * An interface for notifying FmRadio IPC clients when they have been + * connected to the FMRX service. + */ + public interface ServiceListener { + /** + * Called to notify the client when this proxy object has been connected + * to the FMRX service. Clients must wait for this callback before + * making IPC calls on the FMRX service. + */ + public void onServiceConnected(); + + /** + * Called to notify the client that this proxy object has been + * disconnected from the FMRX service. Clients must not make IPC calls + * on the FMRX service after this callback. This callback will currently + * only occur if the application hosting the BluetoothAg service, but + * may be called more often in future. + */ + public void onServiceDisconnected(); + } + + protected void finalize() throws Throwable { + if (DBG) + Log.d(TAG, "FmRadio:finalize"); + try { + close(); + } finally { + super.finalize(); + } + } + + /** + * Close the connection to the backing service. Other public functions of + * BluetoothAg will return default error results once close() has been + * called. Multiple invocations of close() are ok. + */ + public synchronized void close() { + Log.i(TAG, "FmRadio:close"); + + mContext.unbindService(mConnection); + } + + /** + * Returns true if the FM RX is enabled. Returns false if not enabled, or if + * this proxy object if not currently connected to the FmRadio service. + */ + public boolean rxIsEnabled() { + if (DBG) + Log.d(TAG, "FmRadio:rxIsEnabled"); + if (mService != null) { + try { + return mService.rxIsEnabled(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + /** + * Returns the current FM RX state + */ + + public int rxGetFMState() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetFMState"); + if (mService != null) { + try { + return mService.rxGetFMState(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return -1; + } + + /** + * Returns true if the FM RX is paused. Returns false if not paused, or if + * this proxy object if not currently connected to the FmRadio service. + */ + + public boolean rxIsFMPaused() { + if (DBG) + Log.d(TAG, "FmRadio:rxIsFMPaused"); + if (mService != null) { + try { + return mService.rxIsFMPaused(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + /** + * Returns true if the FM RX is enabled. Returns false if not enabled, or if + * this proxy object if not currently connected to the FmRadio service. + */ + public boolean rxEnable() { + if (DBG) + Log.d(TAG, "FmRadio:rxEnable"); + if (mService != null) { + try { + return mService.rxEnable(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + /** + * Returns true if the EM RX is disabled. Returns false if not enabled, or + * if this proxy object if not currently connected to the FmRadio service. + */ + public boolean rxDisable() { + if (DBG) + Log.d(TAG, "FmRadio:rxDisable"); + if (mService != null) { + try { + return mService.rxDisable(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean resumeFm() { + if (DBG) + Log.d(TAG, "FmRadio:resumeFm"); + if (mService != null) { + try { + return mService.resumeFm(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetBand(int band) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetBand"); + if (mService != null) { + try { + return mService.rxSetBand(band); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetBand_nb(int band) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetBand_nb"); + if (mService != null) { + try { + return mService.rxSetBand_nb(band); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetBand() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetBand"); + if (mService != null) { + try { + return mService.rxGetBand(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetBand_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetBand_nb"); + if (mService != null) { + try { + return mService.rxGetBand_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetMonoStereoMode(int mode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetMonoStereoMode"); + if (mService != null) { + try { + return mService.rxSetMonoStereoMode(mode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetMonoStereoMode_nb(int mode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetMonoStereoMode_nb"); + if (mService != null) { + try { + return mService.rxSetMonoStereoMode_nb(mode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxIsValidChannel() { + if (DBG) + Log.d(TAG, "FmRadio:rxIsValidChannel"); + if (mService != null) { + try { + return mService.rxIsValidChannel(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxCompleteScan_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxCompleteScan_nb"); + if (mService != null) { + try { + return mService.rxCompleteScan_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxStopCompleteScan_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxStopCompleteScan_nb"); + if (mService != null) { + try { + return mService.rxStopCompleteScan_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxStopCompleteScan() { + if (DBG) + Log.d(TAG, "FmRadio:rxStopCompleteScan"); + if (mService != null) { + try { + return mService.rxStopCompleteScan(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public double rxGetFwVersion() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetFwVersion"); + if (mService != null) { + try { + return mService.rxGetFwVersion(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public int rxGetCompleteScanProgress() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetCompleteScanProgress"); + if (mService != null) { + try { + return mService.rxGetCompleteScanProgress(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetCompleteScanProgress_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetCompleteScanProgress_nb"); + if (mService != null) { + try { + return mService.rxGetCompleteScanProgress_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetMonoStereoMode() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetMonoStereoMode"); + if (mService != null) { + try { + return mService.rxGetMonoStereoMode(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetMonoStereoMode_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetMonoStereoMode_nb"); + if (mService != null) { + try { + return mService.rxGetMonoStereoMode_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetMuteMode(int muteMode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetMuteMode"); + if (mService != null) { + try { + return mService.rxSetMuteMode(muteMode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetMuteMode_nb(int muteMode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetMuteMode_nb"); + if (mService != null) { + try { + return mService.rxSetMuteMode_nb(muteMode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetMuteMode() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetMuteMode"); + if (mService != null) { + try { + return mService.rxGetMuteMode(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetMuteMode_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetMuteMode_nb"); + if (mService != null) { + try { + return mService.rxGetMuteMode_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRfDependentMuteMode(int rfMuteMode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRfDependentMuteMode"); + if (mService != null) { + try { + return mService.rxSetRfDependentMuteMode(rfMuteMode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRfDependentMuteMode_nb(int rfMuteMode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRfDependentMuteMode_nb"); + if (mService != null) { + try { + return mService.rxSetRfDependentMuteMode_nb(rfMuteMode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetRfDependentMuteMode() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRfDependentMuteMode"); + if (mService != null) { + try { + return mService.rxGetRfDependentMuteMode(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetRfDependentMuteMode_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRfDependentMuteMode_nb"); + if (mService != null) { + try { + return mService.rxGetRfDependentMuteMode_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRssiThreshold(int threshhold) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRssiThreshold"); + if (mService != null) { + try { + return mService.rxSetRssiThreshold(threshhold); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRssiThreshold_nb(int threshhold) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRssiThreshold_nb"); + if (mService != null) { + try { + return mService.rxSetRssiThreshold_nb(threshhold); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetRssiThreshold() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRssiThreshold"); + if (mService != null) { + try { + return mService.rxGetRssiThreshold(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetRssiThreshold_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRssiThreshold_nb"); + if (mService != null) { + try { + return mService.rxGetRssiThreshold_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetDeEmphasisFilter(int filter) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetDeEmphasisFilter"); + if (mService != null) { + try { + return mService.rxSetDeEmphasisFilter(filter); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetDeEmphasisFilter_nb(int filter) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetDeEmphasisFilter_nb"); + if (mService != null) { + try { + return mService.rxSetDeEmphasisFilter_nb(filter); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetDeEmphasisFilter() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetDeEmphasisFilter"); + if (mService != null) { + try { + return mService.rxGetDeEmphasisFilter(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetDeEmphasisFilter_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetDeEmphasisFilter_nb"); + if (mService != null) { + try { + return mService.rxGetDeEmphasisFilter_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetVolume(int volume) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetVolume"); + if (mService != null) { + try { + return mService.rxSetVolume(volume); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetChannelSpacing(int channelSpace) { + + if (DBG) + Log.d(TAG, "FmRadio:rxSetChannelSpacing"); + if (mService != null) { + try { + return mService.rxSetChannelSpacing(channelSpace); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetChannelSpacing_nb(int channelSpace) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetChannelSpacing_nb"); + if (mService != null) { + try { + return mService.rxSetChannelSpacing_nb(channelSpace); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetVolume() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetVolume"); + if (mService != null) { + try { + return mService.rxGetVolume(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetVolume_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetVolume_nb"); + if (mService != null) { + try { + return mService.rxGetVolume_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetChannelSpacing() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetChannelSpacing"); + if (mService != null) { + try { + return mService.rxGetChannelSpacing(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetChannelSpacing_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetChannelSpacing"); + if (mService != null) { + try { + return mService.rxGetChannelSpacing_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxTune_nb(int freq) { + if (DBG) + Log.d(TAG, "FmRadio:rxTune_nb"); + if (mService != null) { + try { + return mService.rxTune_nb(freq); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetTunedFrequency() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetTunedFrequency"); + if (mService != null) { + try { + return mService.rxGetTunedFrequency(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetTunedFrequency_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetTunedFrequency_nb"); + if (mService != null) { + try { + return mService.rxGetTunedFrequency_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSeek_nb(int direction) { + if (DBG) + Log.d(TAG, "FmRadio:rxSeek_nb"); + if (mService != null) { + try { + return mService.rxSeek_nb(direction); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxStopSeek() { + if (DBG) + Log.d(TAG, "FmRadio:rxStopSeek"); + if (mService != null) { + try { + return mService.rxStopSeek(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxStopSeek_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxStopSeek_nb"); + if (mService != null) { + try { + return mService.rxStopSeek_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetRdsSystem() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRdsSystem"); + if (mService != null) { + try { + return mService.rxGetRdsSystem(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetRdsSystem_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRdsSystem_nb"); + if (mService != null) { + try { + return mService.rxGetRdsSystem_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetRssi() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRssi"); + if (mService != null) { + try { + return mService.rxGetRssi(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetRssi_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRssi_nb"); + if (mService != null) { + try { + return mService.rxGetRssi_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRdsSystem(int system) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsSystem"); + if (mService != null) { + try { + return mService.rxSetRdsSystem(system); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRdsSystem_nb(int system) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsSystem_nb"); + if (mService != null) { + try { + return mService.rxSetRdsSystem_nb(system); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxEnableRds() { + if (DBG) + Log.d(TAG, "FmRadio:rxEnableRds"); + if (mService != null) { + try { + return mService.rxEnableRds(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxDisableRds() { + if (DBG) + Log.d(TAG, "FmRadio:rxDisableRds"); + if (mService != null) { + try { + return mService.rxDisableRds(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxEnableRds_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxEnableRds_nb"); + if (mService != null) { + try { + return mService.rxEnableRds_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxDisableRds_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxDisableRds_nb"); + if (mService != null) { + try { + return mService.rxDisableRds_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRdsGroupMask(int mask) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsGroupMask"); + if (mService != null) { + try { + return mService.rxSetRdsGroupMask(mask); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRdsGroupMask_nb(int mask) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsGroupMask_nb"); + if (mService != null) { + try { + return mService.rxSetRdsGroupMask_nb(mask); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public long rxGetRdsGroupMask() { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsGroupMask"); + if (mService != null) { + try { + return mService.rxGetRdsGroupMask(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetRdsGroupMask_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRdsGroupMask_nb"); + if (mService != null) { + try { + return mService.rxGetRdsGroupMask_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRdsAfSwitchMode(int mode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsAfSwitchMode"); + if (mService != null) { + try { + return mService.rxSetRdsAfSwitchMode(mode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxSetRdsAfSwitchMode_nb(int mode) { + if (DBG) + Log.d(TAG, "FmRadio:rxSetRdsAfSwitchMode_nb"); + if (mService != null) { + try { + return mService.rxSetRdsAfSwitchMode_nb(mode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public int rxGetRdsAfSwitchMode() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRdsAfSwitchMode"); + if (mService != null) { + try { + return mService.rxGetRdsAfSwitchMode(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return 0; + } + + public boolean rxGetRdsAfSwitchMode_nb() { + if (DBG) + Log.d(TAG, "FmRadio:rxGetRdsAfSwitchMode_nb"); + if (mService != null) { + try { + return mService.rxGetRdsAfSwitchMode_nb(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxChangeAudioTarget(int mask, int digitalConfig) { + if (DBG) + Log.d(TAG, "FmRadio:rxChangeAudioTarget"); + if (mService != null) { + try { + return mService.rxChangeAudioTarget(mask, digitalConfig); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxChangeDigitalTargetConfiguration(int digitalConfig) { + if (DBG) + Log.d(TAG, "FmRadio:rxChangeDigitalTargetConfiguration"); + if (mService != null) { + try { + return mService.rxChangeDigitalTargetConfiguration(digitalConfig); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxEnableAudioRouting() { + if (DBG) + Log.d(TAG, "FmRadio:rxEnableAudioRouting"); + if (mService != null) { + try { + return mService.rxEnableAudioRouting(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean rxDisableAudioRouting() { + if (DBG) + Log.d(TAG, "FmRadio:rxDisableAudioRouting"); + if (mService != null) { + try { + return mService.rxDisableAudioRouting(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + /************** Fm TX *****************/ + public boolean txEnable() { + if (DBG) + Log.d(TAG, "FmRadio:txEnable"); + if (mService != null) { + try { + return mService.txEnable(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + /** + * Returns true if the EM RX is disabled. Returns false if not enabled, or + * if this proxy object if not currently connected to the FmRadio service. + */ + public boolean txDisable() { + if (DBG) + Log.d(TAG, "FmRadio:txDisable"); + if (mService != null) { + try { + return mService.txDisable(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txStartTransmission() { + if (DBG) + Log.d(TAG, "FmRadio:txStartTransmission"); + if (mService != null) { + try { + return mService.txStartTransmission(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txStopTransmission() { + if (DBG) + Log.d(TAG, "FmRadio:txStopTransmission"); + if (mService != null) { + try { + return mService.txStopTransmission(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txTune(long freq) { + if (DBG) + Log.d(TAG, "FmRadio:txTune"); + if (mService != null) { + try { + return mService.txTune(freq); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetPowerLevel(int powerLevel) { + if (DBG) + Log.d(TAG, "FmRadio:txSetPowerLevel"); + if (mService != null) { + try { + return mService.txSetPowerLevel(powerLevel); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txEnableRds() { + if (DBG) + Log.d(TAG, "FmRadio:txEnableRds"); + if (mService != null) { + try { + return mService.txEnableRds(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txDisableRds() { + if (DBG) + Log.d(TAG, "FmRadio:txDisableRds"); + if (mService != null) { + try { + return mService.txDisableRds(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsTransmissionMode(int mode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsTransmissionMode"); + if (mService != null) { + try { + return mService.txSetRdsTransmissionMode(mode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsTextPsMsg(String psString) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsTextPsMsg"); + if (mService != null) { + try { + return mService.txSetRdsTextPsMsg(psString); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txWriteRdsRawData(String rawData) { + if (DBG) + Log.d(TAG, "FmRadio:txWriteRdsRawData"); + if (mService != null) { + try { + return mService.txWriteRdsRawData(rawData); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetMonoStereoMode(int mode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetMonoStereoMode"); + if (mService != null) { + try { + return mService.txSetMonoStereoMode(mode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetPreEmphasisFilter(int preEmpFilter) { + if (DBG) + Log.d(TAG, "FmRadio:txSetPreEmphasisFilter"); + if (mService != null) { + try { + return mService.txSetPreEmphasisFilter(preEmpFilter); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetMuteMode(int muteMode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetMuteMode"); + if (mService != null) { + try { + return mService.txSetMuteMode(muteMode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsAfCode(int afCode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsAfCode"); + if (mService != null) { + try { + return mService.txSetRdsAfCode(afCode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsPiCode(int piCode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsPiCode"); + if (mService != null) { + try { + return mService.txSetRdsPiCode(piCode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsPtyCode(int ptyCode) { + Log.d(TAG, "FmRadio:txSetRdsPtyCode"); + if (mService != null) { + try { + return mService.txSetRdsPtyCode(ptyCode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsTextRepertoire(int repertoire) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsTextRepertoire"); + if (mService != null) { + try { + return mService.txSetRdsTextRepertoire(repertoire); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsPsDisplayMode(int dispalyMode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsPsDisplayMode"); + if (mService != null) { + try { + return mService.txSetRdsPsDisplayMode(dispalyMode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsPsScrollSpeed(int scrollSpeed) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsPsScrollSpeed"); + if (mService != null) { + try { + return mService.txSetRdsPsScrollSpeed(scrollSpeed); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsTextRtMsg(int msgType, String msg, int msgLength) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsTextRtMsg"); + if (mService != null) { + try { + return mService.txSetRdsTextRtMsg(msgType, msg, msgLength); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsTransmittedGroupsMask(long rdsTrasmittedGrpMask) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsTransmittedGroupsMask"); + if (mService != null) { + try { + return mService.txSetRdsTransmittedGroupsMask(rdsTrasmittedGrpMask); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsTrafficCodes(int taCode, int tpCode) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsTrafficCodes"); + if (mService != null) { + try { + return mService.txSetRdsTrafficCodes(taCode, tpCode); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsMusicSpeechFlag(int musicSpeechFlag) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsMusicSpeechFlag"); + if (mService != null) { + try { + return mService.txSetRdsMusicSpeechFlag(musicSpeechFlag); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txSetRdsECC(int ecc) { + if (DBG) + Log.d(TAG, "FmRadio:txSetRdsECC"); + if (mService != null) { + try { + return mService.txSetRdsECC(ecc); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txChangeAudioSource(int audioSrc, int ecalSampleFreq) { + if (DBG) + Log.d(TAG, "FmRadio:txChangeAudioSource"); + if (mService != null) { + try { + return mService.txChangeAudioSource(audioSrc, ecalSampleFreq); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + public boolean txChangeDigitalSourceConfiguration(int ecalSampleFreq) { + if (DBG) + Log.d(TAG, "FmRadio:txChangeDigitalSourceConfiguration"); + if (mService != null) { + try { + return mService.txChangeDigitalSourceConfiguration(ecalSampleFreq); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return false; + } + + /** + * Returns the current FM TX state + */ + public int txGetFMState() { + if (DBG) + Log.d(TAG, "FmRadio:txGetFMState"); + if (mService != null) { + try { + return mService.txGetFMState(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) + Log.d(TAG, Log.getStackTraceString(new Throwable())); + } + return -1; + } + +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/fm/FmRadioIntent.java b/tools/FM/FmRadioIf/src/java/com/ti/fm/FmRadioIntent.java new file mode 100644 index 0000000..246f56e --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/fm/FmRadioIntent.java @@ -0,0 +1,304 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fm; + +import android.annotation.SdkConstant; +import android.annotation.SdkConstant.SdkConstantType; + +/** + * Manages the FM Reception + * + * @hide + */ +public interface FmRadioIntent { + + public static final String VOLUME = "fm.rx.intent.VOLUME"; + + public static final String MODE_MONO_STEREO = "fm.rx.intent.MODE_MONO_STEREO"; + + public static final String TUNED_FREQUENCY = "fm.rx.intent.TUNED_FREQUENCY"; + + public static final String SEEK_FREQUENCY = "fm.rx.intent.SEEK_FREQUENCY"; + + public static final String RDS = "fm.rx.intent.RDS"; + + public static final String PS = "fm.rx.intent.PS"; + + public static final String PI = "fm.rx.intent.PI"; + + public static final String REPERTOIRE = "fm.rx.intent.REPERTOIRE"; + + public static final String MUTE = "fm.rx.intent.MUTE"; + + public static final String STATUS = "fm.rx.intent.STATUS"; + + public static final String MASTER_VOLUME = "fm.rx.intent.MASTER_VOLUME"; + + public static final String CHANNEL_SPACE = "fm.rx.intent.CHANNEL_SPACE"; + + public static final String SCAN_LIST = "fm.rx.intent.SCAN_LIST"; + + public static final String SCAN_LIST_COUNT = "fm.rx.intent.SCAN_LIST_COUNT"; + + public static final String RADIOTEXT_CONVERTED = "fm.rx.intent.RADIOTEXT_CONVERTED_VALUE"; + + public static final String PS_CONVERTED = "fm.rx.intent.PS_CONVERTED_VALUE"; + + public static final String GET_BAND = "fm.rx.intent.GET_BAND"; + + public static final String GET_VOLUME = "fm.rx.intent.GET_VOLUME"; + + public static final String GET_MODE = "fm.rx.intent.GET_MODE"; + + public static final String GET_MUTE_MODE = "fm.rx.intent.GET_MUTE_MODE"; + + public static final String GET_RF_MUTE_MODE = "fm.rx.intent.GET_RF_MUTE_MODE"; + + public static final String GET_RSSI_THRESHHOLD = "fm.rx.intent.GET_RSSI_THRESHHOLD"; + + public static final String GET_DEEMPHASIS_FILTER = "fm.rx.intent.GET_DEEMPHASIS_FILTER"; + + public static final String GET_RSSI = "fm.rx.intent.GET_RSSI"; + + public static final String GET_RDS_SYSTEM = "fm.rx.intent.GET_RDS_SYSTEM"; + + public static final String GET_RDS_GROUPMASK = "fm.rx.intent.GET_RDS_GROUPMASK"; + + public static final String GET_RDS_AF_SWITCHMODE = "fm.rx.intent.GET_RDS_AF_SWITCHMODE"; + + public static final String GET_CHANNEL_SPACE = "fm.rx.intent.GET_CHANNEL_SPACE"; + + public static final String LAST_SCAN_CHANNEL = "fm.rx.intent.LAST_SCAN_CHANNEL"; + + public static final String SCAN_PROGRESS = "fm.rx.intent.SCAN_PROGRESS"; + + /*********** fM tx ******************/ + public static final String TX_MODE = "fm.tx.intent.TX_MODE"; + + public static final String MUSIC_SPEECH_FLAG = "fm.tx.intent.MUSIC_SPEECH_FLAG"; + + public static final String MONO_STEREO = "fm.tx.intent.MONO_STEREO"; + + public static final String DISPLAY_MODE = "fm.tx.intent.DISPLAY_MODE"; + + public static final String TX_REPERTOIRE = "fm.tx.intent.REPERTOIRE"; + + public static final String PS_MSG = "fm.tx.intent.PSMSG"; + + public static final String RDS_GRP_MASK = "fm.tx.intent.RDS_GRP_MASK"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_ENABLED_ACTION = "fm.rx.intent.action.FM_ENABLED"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_DISABLED_ACTION = "fm.rx.intent.action.FM_DISABLED"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_FREQUENCY_ACTION = "fm.rx.intent.action.GET_FREQUENCY"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SEEK_ACTION = "fm.rx.intent.action.SEEK_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_MODE_MONO_STEREO_ACTION = "fm.rx.intent.action.SET_MODE_MONOSTEREO"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String VOLUME_CHANGED_ACTION = "fm.rx.intent.action.VOLUME_CHANGED_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String RDS_TEXT_CHANGED_ACTION = "fm.rx.intent.action.RDS_TEXT_CHANGED"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String PS_CHANGED_ACTION = "fm.rx.intent.action.PS_CHANGED"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String AUDIO_PATH_CHANGED_ACTION = "fm.rx.intent.action.AUDIO_PATH_CHANGED_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String TUNE_COMPLETE_ACTION = "fm.rx.intent.action.TUNE_COMPLETE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String MUTE_CHANGE_ACTION = "fm.rx.intent.action.MUTE_CHANGE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SEEK_STOP_ACTION = "fm.rx.intent.action.SEEK_STOP_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String BAND_CHANGE_ACTION = "fm.rx.intent.action.BAND_CHANGE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_CHANNEL_SPACE_ACTION = "fm.rx.intent.action.GET_CHANNEL_SPACE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ENABLE_RDS_ACTION = "fm.rx.intent.action.ENABLE_RDS_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String DISABLE_RDS_ACTION = "fm.rx.intent.action.DISABLE_RDS_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_RDS_AF_ACTION = "fm.rx.intent.action.SET_RDS_AF_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_RDS_SYSTEM_ACTION = "fm.rx.intent.action.SET_RDS_SYSTEM_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_DEEMP_FILTER_ACTION = "fm.rx.intent.action.SET_DEEMP_FILTER_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String DISPLAY_MODE_MONO_STEREO_ACTION = "fm.rx.intent.action.DISPLAY_MODE_MONO_STEREO_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_RSSI_THRESHHOLD_ACTION = "fm.rx.intent.action.SET_RSSI_THRESHHOLD_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_RF_DEPENDENT_MUTE_ACTION = "fm.rx.intent.action.SET_RF_DEPENDENT_MUTE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String PI_CODE_CHANGED_ACTION = "fm.rx.intent.action.PI_CODE_CHANGED_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String MASTER_VOLUME_CHANGED_ACTION = "fm.rx.intent.action.MASTER_VOLUME_CHANGED_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_BAND_ACTION = "fm.rx.intent.action.GET_BAND_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_MONO_STEREO_MODE_ACTION = "fm.rx.intent.action.GET_MONO_STEREO_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_MUTE_MODE_ACTION = "fm.rx.intent.action.GET_MUTE_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_RF_MUTE_MODE_ACTION = "fm.rx.intent.action.GET_RF_MUTE_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_RSSI_THRESHHOLD_ACTION = "fm.rx.intent.action.GET_RSSI_THRESHHOLD_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_DEEMPHASIS_FILTER_ACTION = "fm.rx.intent.action.GET_DEEMPHASIS_FILTER_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_RSSI_ACTION = "fm.rx.intent.action.GET_RSSI_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_VOLUME_ACTION = "fm.rx.intent.action.GET_VOLUME_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_RDS_SYSTEM_ACTION = "fm.rx.intent.action.GET_RDS_SYSTEM_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_RDS_GROUPMASK_ACTION = "fm.rx.intent.action.GET_RDS_GROUPMASK_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String GET_RDS_AF_SWITCH_MODE_ACTION = "fm.rx.intent.action.GET_RDS_AF_SWITCH_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String CHANNEL_SPACING_CHANGED_ACTION = "fm.rx.intent.action.CHANNEL_SPACING_CHANGED_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String COMPLETE_SCAN_DONE_ACTION = "fm.rx.intent.action.COMPLETE_SCAN_DONE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String COMPLETE_SCAN_STOP_ACTION = "fm.rx.intent.action.COMPLETE_SCAN_STOP_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_RDS_GROUP_MASK_ACTION = "fm.rx.intent.action.SET_RDS_GROUP_MASK_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String COMPLETE_SCAN_PROGRESS_ACTION = "fm.rx.intent.action.COMPLETE_SCAN_PROGRESS_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SET_CHANNEL_SPACE_ACTION = "fm.rx.intent.action.SET_CHANNEL_SPACE_ACTION"; + + /*** Fm TX Intents ***/ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_ENABLED_ACTION = "fm.tx.intent.action.FM_TX_ENABLED"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_TUNE_ACTION = "fm.tx.intent.action.FM_TX_TUNE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_DISABLED_ACTION = "fm.tx.intent.action.FM_TX_DISABLED"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_START_TRANSMISSION_ACTION = "fm.tx.intent.action.FM_TX_START_TRANSMISSION_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_STOP_TRANSMISSION_ACTION = "fm.tx.intent.action.FM_TX_STOP_TRANSMISSION_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_DESTROY_ACTION = "fm.tx.intent.action.FM_TX_DESTROY_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_ENABLE_RSD_ACTION = "fm.tx.intent.action.FM_TX_ENABLE_RSD_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_DISABLE_RSD_ACTION = "fm.tx.intent.action.FM_TX_DISABLE_RSD_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_TRAFFIC_CODES_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_TRAFFIC_CODES"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_TEXT_PS_MSG_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_TEXT_PS_MSG_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_TEXT_RT_MSG_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_TEXT_RT_MSG_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_WRITE_RDS_RAW_DATA_ACTION = "fm.tx.intent.action.FM_TX_WRITE_RDS_RAW_DATA_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_READ_RDS_RAW_DATA_ACTION = "fm.tx.intent.action.FM_TX_READ_RDS_RAW_DATA_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_MONO_STEREO_MODE_ACTION = "fm.tx.intent.action.FM_TX_SET_MONO_STEREO_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_POWER_LEVEL_ACTION = "fm.tx.intent.action.FM_TX_SET_POWER_LEVEL_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_MUTE_MODE_ACTION = "fm.tx.intent.action.FM_TX_SET_MUTE_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_AF_CODE_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_AF_CODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_RDS_PI_CODE_ACTION = "fm.tx.intent.action.FM_TX_RDS_PI_CODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_RDS_PTY_CODE_ACTION = "fm.tx.intent.action.FM_TX_RDS_PTY_CODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_PS_DISPLAY_MODE_ACTION = "fm.tx.intent.action.FM_TX_PS_DISPLAY_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_PS_DISPLAY_SPEED_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_PS_DISPLAY_SPEED_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_TRANSMISSION_MODE_ACTION = "fm.tx.intent.action.FM_TX_SET_TRANSMISSION_MODE_ACTION"; + + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION = "fm.tx.intent.action.FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION"; + +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/fm/IFmConstants.java b/tools/FM/FmRadioIf/src/java/com/ti/fm/IFmConstants.java new file mode 100644 index 0000000..f256594 --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/fm/IFmConstants.java @@ -0,0 +1,323 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fm; + +public interface IFmConstants { + + /* + * By setting this flag true, FM APIS can be used in blocking mode. else FM + * APIS will be non blocking + */ + public static final boolean MAKE_FM_APIS_BLOCKING = false; + + /* + * By setting this flag true, FM RDS data(PS and RDS Text) can be sent to + * the application as bytearray. else FM RDS data(PS and RDS Text) will be + * sent to the application as String + */ + + public static final boolean FM_SEND_RDS_IN_BYTEARRAY = false; + + public static final int FM_SEEK_IN_PROGRESS = 0xFF; + + public static final int FM_BAND_EUROPE_US = 0; + + public static final int FM_BAND_JAPAN = 1; + + /* Europe / US band limits */ + public static final int FM_FIRST_FREQ_US_EUROPE_KHZ = 87500; + + public static final int FM_LAST_FREQ_US_EUROPE_KHZ = 108000; + + /* Japan band limits */ + public static final int FM_FIRST_FREQ_JAPAN_KHZ = 76000; + + public static final int FM_LAST_FREQ_JAPAN_KHZ = 90000; + + public static final int DEF_VOL = 1; + + public static final int FM_MAX_VOLUME = 16383; //32767,//65535; + + /* volume states */ + + public static final boolean VOL_REQ_STATE_IDLE = true; + + public static final boolean VOL_REQ_STATE_PENDING = false; + + public static final int FM_CHANNEL_SPACE = 2; + + public static final int FM_NOT_MUTE = 1; + + public static final int FM_RF_DEP_MUTE_OFF = 0; + + public static final int FM_RSSI_THRESHHOLD = 7; + + /* Mute constants */ + + public static final int FM_MUTE = 0; + + public static final int FM_UNMUTE = 1; + + public static final int FM_ATT = 2; + + /* Fm Radio State */ + public static final int STATE_ENABLED = 0; + + public static final int STATE_DISABLED = 1; + + public static final int STATE_ENABLING = 2; + + public static final int STATE_DISABLING = 3; + + public static final int STATE_PAUSE = 4; + + public static final int STATE_RESUME = 5; + + public static final int STATE_DEFAULT = 6; + + // public static final int FM_SUCCESS = 0 ; + /* FM Error Returns */ + public static final int FM_FAILED = 0xFFF; + + public static final int FM_UNDEFINED_FREQ = 0xFFFFFFFF; + + public static final int FM_COMPLETE_SCAN_IS_NOT_IN_PROGRESS = 115; + + public static final int FM_COMPLETE_SCAN_STOPPED = 116; + + /* Recovery Params */ + // must be a long time to account for turning off stale btipsd + turning on + // new one + public static final long FM_RADIO_ON_TIMEOUT_MSEC = 20 * 1000; + + public static final long FM_RADIO_OFF_TIMEOUT_MSEC = 10 * 1000; + + /*********************************************************************************************** + * Look up tables for RDS data conversion + ***********************************************************************************************/ + public static char[][] lookUpTable_G0 = { + /* 0 */{ + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + '\u0008', '\u0009', '\u0000', '\u000b', '\u000c', '\u0000', '\u000e', '\u000f' + }, + /* 1 */{ + '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', + '\u0018', '\u0019', '\u001a', '\u001b', '\u001c', '\u001d', '\u001e', '\u001f' + }, + /* 2 */{ + '\u0020', '\u0021', '\u0022', '\u0023', '\u00A4', '\u0025', '\u0026', '\u0000', + '\u0028', '\u0029', '\u002a', '\u002b', '\u002c', '\u002d', '\u002e', '\u2044' + }, + /* 3 */{ + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + '\u0038', '\u0039', '\u003a', '\u003b', '\u003c', '\u003d', '\u003e', '\u003f' + }, + /* 4 */{ + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + '\u0048', '\u0049', '\u004a', '\u004b', '\u004c', '\u004d', '\u004e', '\u004f' + }, + /* 5 */{ + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + '\u0058', '\u0059', '\u005a', '\u005b', '\u0000', '\u005d', '\u005e', '\u005f' + }, + /* 6 */{ + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + '\u0068', '\u0069', '\u006a', '\u006b', '\u006c', '\u006d', '\u006e', '\u006f' + }, + /* 7 */{ + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + '\u0078', '\u0079', '\u007a', '\u007b', '\u007c', '\u007d', '\u0020', '\u0020' + }, + /* 8 */{ + '\u00E1', '\u00E0', '\u00E9', '\u00E8', '\u00ED', '\u00EC', '\u00F3', '\u00F2', + '\u00FA', '\u00F9', '\u00D1', '\u00C7', '\u015E', '\u03B2', '\u03AF', '\u0132' + }, + /* 9 */{ + '\u00E2', '\u00E4', '\u00EA', '\u00EB', '\u00EE', '\u00EF', '\u00F4', '\u00F6', + '\u00FB', '\u00FC', '\u00F1', '\u00E7', '\u015F', '\u0020', '\u00B9', '\u0133' + }, + /* a */{ + '\u00AA', '\u03B1', '\u00A9', '\u2030', '\u011E', '\u0115', '\u0148', '\u0151', + '\u03C0', '\u0020', '\u00A3', '\u0024', '\u2190', '\u2191', '\u2192', '\u2193' + }, + /* b */{ + '\u00b0', '\u00B9', '\u00B2', '\u00B3', '\u00B1', '\u0130', '\u0144', '\u0171', + '\u00B5', '\u00BF', '\u00F7', '\u00B0', '\u00BC', '\u00BD', '\u00BE', '\u00A7' + }, + /* c */{ + '\u00C1', '\u00C0', '\u00C9', '\u00C8', '\u00CD', '\u00CC', '\u00D3', '\u00D2', + '\u00DA', '\u00D9', '\u0158', '\u010C', '\u0160', '\u017D', '\u0110', '\u013F' + }, + /* d */{ + '\u00C2', '\u00C4', '\u00CA', '\u00CB', '\u00CE', '\u00CF', '\u00D4', '\u00D6', + '\u00DB', '\u00DC', '\u0159', '\u010D', '\u0161', '\u017E', '\u0111', '\u0140' + }, + /* e */{ + '\u00C3', '\u00C5', '\u01FC', '\u0152', '\u0177', '\u00DD', '\u00D5', '\u00D8', + '\u00FE', '\u014A', '\u0154', '\u0106', '\u015A', '\u0179', '\u0166', '\u00F0' + }, + /* f */{ + '\u00E3', '\u00E5', '\u01FD', '\u0153', '\u0175', '\u00FD', '\u00F5', '\u00F8', + '\u00DE', '\u014B', '\u0155', '\u0107', '\u015B', '\u017A', '\u0167', '\u0020' + } + }; + + public static char[][] lookUpTable_G1 = { + /* 0 */{ + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + '\u0008', '\u0009', '\u0000', '\u000b', '\u000c', '\u0000', '\u000e', '\u000f' + }, + /* 1 */{ + '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', + '\u0018', '\u0019', '\u001a', '\u001b', '\u001c', '\u001d', '\u001e', '\u001f' + }, + /* 2 */{ + '\u0020', '\u0021', '\u0022', '\u0023', '\u00A4', '\u0025', '\u0026', '\u0000', + '\u0028', '\u0029', '\u002a', '\u002b', '\u002c', '\u002d', '\u002e', '\u2044' + }, + /* 3 */{ + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + '\u0038', '\u0039', '\u003a', '\u003b', '\u003c', '\u003d', '\u003e', '\u003f' + }, + /* 4 */{ + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + '\u0048', '\u0049', '\u004a', '\u004b', '\u004c', '\u004d', '\u004e', '\u004f' + }, + /* 5 */{ + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + '\u0058', '\u0059', '\u005a', '\u005b', '\u0000', '\u005d', '\u005e', '\u005f' + }, + /* 6 */{ + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + '\u0068', '\u0069', '\u006a', '\u006b', '\u006c', '\u006d', '\u006e', '\u006f' + }, + /* 7 */{ + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + '\u0078', '\u0079', '\u007a', '\u007b', '\u007c', '\u007d', '\u0020', '\u0020' + }, + /* 8 */{ + '\u00E1', '\u00E0', '\u00E9', '\u00E8', '\u00ED', '\u00EC', '\u00F3', '\u00F2', + '\u00FA', '\u00F9', '\u00D1', '\u00C7', '\u015E', '\u03B2', '\u03AF', '\u0132' + }, + /* 9 */{ + '\u00E2', '\u00E4', '\u00EA', '\u00EB', '\u00EE', '\u00EF', '\u00D4', '\u00D6', + '\u00FB', '\u00FC', '\u00F1', '\u00E7', '\u015F', '\u0020', '\u00B9', '\u0133' + }, + /* a */{ + '\u00AA', '\u00a1', '\u00A9', '\u2030', '\u01CE', '\u0115', '\u0148', '\u0151', + '\u0165', '\u0020', '\u00A3', '\u0024', '\u2190', '\u2191', '\u2192', '\u2193' + }, + /* b */{ + '\u00BA', '\u00B9', '\u00B2', '\u00B3', '\u00B1', '\u0130', '\u0144', '\u0171', + '\u0163', '\u00BF', '\u00F7', '\u00B0', '\u00BC', '\u00BD', '\u00BE', '\u00A7' + }, + /* c */{ + '\u0404', '\u042F', '\u0020', '\u0427', '\u0414', '\u042D', '\u0444', '\u0403', + '\u00c8', '\u0418', '\u0436', '\u045C', '\u041B', '\u045B', '\u0452', '\u044B' + }, + /* d */{ + '\u00FD', '\u0459', '\u00d2', '\u0448', '\u0446', '\u042E', '\u0449', '\u040A', + '\u040F', '\u0419', '\u0417', '\u010D', '\u0161', '\u017E', '\u00de', '\u00df' + }, + /* e */{ + '\u03A0', '\u03B1', '\u00e2', '\u00e3', '\u03B4', '\u03B5', '\u03C6', '\u03B3', + '\u00e8', '\u03B9', '\u2140', '\u03F0', '\u03BB', '\u03BC', '\u03B3', '\u03C9' + }, + /* f */{ + '\u03C0', '\u03A9', '\u037B', '\u00f3', '\u03C4', '\u03BE', '\u0398', '\u0393', + '\u039E', '\u03C5', '\u03B6', '\u03DB', '\u039B', '\u03A8', '\u0394', '\u0020' + } + }; + + public static char[][] lookUpTable_G2 = { + /* 0 */{ + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + '\u0008', '\u0009', '\u0000', '\u000b', '\u000c', '\u0000', '\u000e', '\u000f' + }, + /* 1 */{ + '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', + '\u0018', '\u0019', '\u001a', '\u001b', '\u001c', '\u001d', '\u001e', '\u001f' + }, + /* 2 */{ + '\u0020', '\u0021', '\u0022', '\u0023', '\u00A4', '\u0025', '\u0026', '\u0000', + '\u0028', '\u0029', '\u002a', '\u002b', '\u002c', '\u002d', '\u002e', '\u2044' + }, + /* 3 */{ + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + '\u0038', '\u0039', '\u003a', '\u003b', '\u003c', '\u003d', '\u003e', '\u003f' + }, + /* 4 */{ + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + '\u0048', '\u0049', '\u004a', '\u004b', '\u004c', '\u004d', '\u004e', '\u004f' + }, + /* 5 */{ + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + '\u0058', '\u0059', '\u005a', '\u005b', '\u0000', '\u005d', '\u005e', '\u005f' + }, + /* 6 */{ + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + '\u0068', '\u0069', '\u006a', '\u006b', '\u006c', '\u006d', '\u006e', '\u006f' + }, + /* 7 */{ + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + '\u0078', '\u0079', '\u007a', '\u007b', '\u007c', '\u007d', '\u0020', '\u0020' + }, + /* 8 */{ + '\uEE92', '\uEE98', '\u0629', '\uEE9C', '\uFEA0', '\uFEA4', '\ufea8', '\u062f', + '\u0630', '\ufe8d', '\ufe83', '\ufeb3', '\ufeb7', '\ufebb', '\ufebf', '\ufec1' + }, + /* 9 */{ + '\ufec5', '\ufecb', '\ufecf', '\ufed3', '\ufed7', '\ufedb', '\ufedd', '\ufee3', + '\ufee7', '\ufeeb', '\ufeed', '\ufef3', '\u2190', '\u2191', '\u2192', '\u2193' + }, + /* a */{ + '\u05d0', '\u05d1', '\u05d2', '\u05d3', '\u05d4', '\u05d5', '\u05d6', '\u05d7', + '\u05d8', '\u05d9', '\u05db', '\u05da', '\u05dc', '\u05de', '\u05dd', '\u05e0' + }, + /* b */{ + '\u05df', '\u05e1', '\u05e2', '\u05e4', '\u05e3', '\u05e6', '\u05e5', '\u05e7', + '\u05e8', '\u05e9', '\u05ea', '\u00B0', '\u00BC', '\u00BD', '\u00BE', '\u00A7' + }, + /* c */{ + '\u0404', '\u042F', '\u0020', '\u0427', '\u0414', '\u042D', '\u0444', '\u0403', + '\u00c8', '\u0418', '\u0436', '\u045C', '\u041B', '\u045B', '\u0452', '\u044B' + }, + /* d */{ + '\u00FD', '\u0459', '\u00d2', '\u0448', '\u0446', '\u042E', '\u0449', '\u040A', + '\u040F', '\u0419', '\u0417', '\u010D', '\u0161', '\u017E', '\u00de', '\u00df' + }, + /* e */{ + '\u03A0', '\u00C5', '\u01FC', '\u0152', '\u0177', '\u00DD', '\u00D5', '\u00D8', + '\u00FE', '\u014A', '\u03A3', '\u0106', '\u03BB', '\u03BC', '\u03B3', '\u03C9' + }, + /* f */{ + '\u03C0', '\u03A9', '\u037B', '\u00f3', '\u03C4', '\u03BE', '\u0398', '\u0393', + '\u039E', '\u03C5', '\u03B6', '\u03DB', '\u039B', '\u03A8', '\u0394', '\u0020' + } + }; + + /********* FM TX *************/ + + public static final int FM_AF_CODE_NO_AF_AVAILABLE = 224; + + public static final int FM_RDS_PTY_CODE_NO_PROGRAM_UNDEFINED = 0; + + public static final int FM_RDS_PTY_CODE_MAX_VALUE = 31; + + public static final int FM_RDS_SCROLL_SPEED_DEFUALT = 3; +} diff --git a/tools/FM/FmRadioIf/src/java/com/ti/fm/IFmRadio.aidl b/tools/FM/FmRadioIf/src/java/com/ti/fm/IFmRadio.aidl new file mode 100644 index 0000000..8f770ea --- /dev/null +++ b/tools/FM/FmRadioIf/src/java/com/ti/fm/IFmRadio.aidl @@ -0,0 +1,149 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fm; + +/** + * System private API for FM Receiver service + * + * {@hide} + */ +interface IFmRadio { + boolean rxEnable(); + boolean rxDisable(); + boolean rxIsEnabled() ; + boolean rxIsFMPaused(); + int rxGetFMState(); + boolean resumeFm(); + boolean rxSetBand(int band); + boolean rxSetBand_nb(int band); + int rxGetBand(); + boolean rxGetBand_nb(); + boolean rxSetChannelSpacing(int channelSpace); + boolean rxSetChannelSpacing_nb(int channelSpace); + int rxGetChannelSpacing(); + boolean rxGetChannelSpacing_nb(); + boolean rxSetMonoStereoMode(int mode); + boolean rxSetMonoStereoMode_nb(int mode); + int rxGetMonoStereoMode(); + boolean rxGetMonoStereoMode_nb(); + boolean rxSetMuteMode(int muteMode); + boolean rxSetMuteMode_nb(int muteMode); + int rxGetMuteMode(); + boolean rxGetMuteMode_nb(); + boolean rxSetRfDependentMuteMode(int rfMuteMode); + boolean rxSetRfDependentMuteMode_nb(int rfMuteMode); + int rxGetRfDependentMuteMode(); + boolean rxGetRfDependentMuteMode_nb(); + boolean rxSetRssiThreshold(int threshhold); + boolean rxSetRssiThreshold_nb(int threshhold); + int rxGetRssiThreshold(); + boolean rxGetRssiThreshold_nb(); + boolean rxSetDeEmphasisFilter(int filter); + boolean rxSetDeEmphasisFilter_nb(int filter); + int rxGetDeEmphasisFilter(); + boolean rxGetDeEmphasisFilter_nb(); + boolean rxSetVolume(int volume); + int rxGetVolume(); + boolean rxGetVolume_nb(); + boolean rxTune_nb(int freq); + int rxGetTunedFrequency(); + boolean rxGetTunedFrequency_nb(); + boolean rxSeek_nb(int direction); + boolean rxStopSeek(); + boolean rxStopSeek_nb(); + int rxGetRssi(); + boolean rxGetRssi_nb(); + int rxGetRdsSystem(); + boolean rxGetRdsSystem_nb(); + boolean rxSetRdsSystem(int system); + boolean rxSetRdsSystem_nb(int system); + boolean rxEnableRds(); + boolean rxEnableRds_nb(); + boolean rxDisableRds(); + boolean rxDisableRds_nb(); + boolean rxSetRdsGroupMask(int mask); + boolean rxSetRdsGroupMask_nb(int mask); + long rxGetRdsGroupMask(); + boolean rxGetRdsGroupMask_nb(); + boolean rxSetRdsAfSwitchMode(int mode); + boolean rxSetRdsAfSwitchMode_nb(int mode); + int rxGetRdsAfSwitchMode(); + boolean rxGetRdsAfSwitchMode_nb(); + boolean rxChangeAudioTarget(int mask,int digitalConfig); + boolean rxChangeDigitalTargetConfiguration(int digitalConfig); + boolean rxEnableAudioRouting(); + boolean rxDisableAudioRouting(); + boolean rxIsValidChannel(); + boolean rxCompleteScan_nb(); + double rxGetFwVersion(); + int rxGetCompleteScanProgress(); + boolean rxGetCompleteScanProgress_nb(); + int rxStopCompleteScan(); + boolean rxStopCompleteScan_nb(); + + +/* FM TX */ + + boolean txEnable(); + boolean txDisable(); + boolean txStartTransmission(); + boolean txStopTransmission(); + boolean txTune(long freq); + + boolean txSetPowerLevel(int powerLevel); + + boolean txEnableRds(); + boolean txDisableRds(); + boolean txSetRdsTransmissionMode(int mode); + + boolean txSetRdsTextPsMsg(String psString); + + boolean txWriteRdsRawData(String rawData); + boolean txSetMonoStereoMode(int mode); + + boolean txSetPreEmphasisFilter(int preEmpFilter); + + boolean txSetMuteMode(int muteMode); + + boolean txSetRdsAfCode(int afCode); + + boolean txSetRdsPiCode(int piCode); + + boolean txSetRdsPtyCode(int ptyCode); + + boolean txSetRdsTextRepertoire(int repertoire); + + boolean txSetRdsPsDisplayMode(int dispalyMode); + + boolean txSetRdsPsScrollSpeed(int scrollSpeed); + + boolean txSetRdsTextRtMsg(int msgType, String msg, int msgLength); + + boolean txSetRdsTransmittedGroupsMask(long rdsTrasmittedGrpMask); + + boolean txSetRdsTrafficCodes(int taCode, int tpCode); + + boolean txSetRdsMusicSpeechFlag(int musicSpeechFlag); + + boolean txSetRdsECC(int ecc); + + boolean txChangeAudioSource(int audioSrc,int ecalSampleFreq); + boolean txChangeDigitalSourceConfiguration(int ecalSampleFreq); + int txGetFMState(); + +} diff --git a/tools/FM/FmRxApp/Android.mk b/tools/FM/FmRxApp/Android.mk new file mode 100644 index 0000000..89e2c13 --- /dev/null +++ b/tools/FM/FmRxApp/Android.mk @@ -0,0 +1,37 @@ +# +# +# +# Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ +# +# 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. +# + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := FmRxApp +LOCAL_CERTIFICATE := shared +LOCAL_JAVA_LIBRARIES := fmradioif + +include $(BUILD_PACKAGE) +# Use the folloing include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) + + + + + diff --git a/tools/FM/FmRxApp/AndroidManifest.xml b/tools/FM/FmRxApp/AndroidManifest.xml new file mode 100644 index 0000000..4a05987 --- /dev/null +++ b/tools/FM/FmRxApp/AndroidManifest.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.ti.fmrxapp" + android:versionCode="1" + android:versionName="1.0.0"> + <uses-permission android:name="ti.permission.FMRX" /> + <uses-permission android:name="ti.permission.FMRX_ADMIN" /> + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + + <application android:icon="@drawable/radio" android:label="@string/app_name"> + <uses-library android:name="fmradioif" /> + <activity android:name=".FmRxApp" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + <intent-filter> + <action android:name="android.intent.action.FM_PLAYBACK" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + <activity android:name=".FmRxApp" + android:label="@string/app_rx"> + <intent-filter> + <action android:name="android.intent.action.START_FMRX" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + + <activity android:name=".FmRxHelp" + android:label="@string/app_rxhelp"> + <intent-filter> + <action android:name="android.intent.action.START_RXHELP" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <activity android:name=".FmRxFreqInput" android:theme="@android:style/Theme.Dialog" + android:label="@string/enterFreq_Dialog"> + <intent-filter> + <action android:name="android.intent.action.START_RXFREQ" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <activity android:name=".FmRxRdsConfig" + android:label="@string/app_rds"> + <intent-filter> + <action android:name="android.intent.action.RDS_CONFIG" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + <activity android:name=".FmPresetList" + android:label="@string/stations"> + <intent-filter> + <action android:name="android.intent.action.PRESET" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/tools/FM/FmRxApp/NOTICE b/tools/FM/FmRxApp/NOTICE new file mode 100644 index 0000000..6ca3f9b --- /dev/null +++ b/tools/FM/FmRxApp/NOTICE @@ -0,0 +1,196 @@ + + + + Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + + 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. + + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/tools/FM/FmRxApp/res/drawable/background.png b/tools/FM/FmRxApp/res/drawable/background.png Binary files differnew file mode 100644 index 0000000..5efab8f --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/background.png diff --git a/tools/FM/FmRxApp/res/drawable/background1.png b/tools/FM/FmRxApp/res/drawable/background1.png Binary files differnew file mode 100644 index 0000000..3294905 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/background1.png diff --git a/tools/FM/FmRxApp/res/drawable/btn_bgd.xml b/tools/FM/FmRxApp/res/drawable/btn_bgd.xml new file mode 100644 index 0000000..cc49d93 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/btn_bgd.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true" android:state_pressed="false" + android:drawable="@drawable/btn_bgd_default" /> + <item android:state_focused="false" android:state_pressed="true" + android:drawable="@drawable/btn_bgd_pressed" /> + <item android:drawable="@drawable/btn_bgd_default" /> +</selector> diff --git a/tools/FM/FmRxApp/res/drawable/btn_bgd_default.png b/tools/FM/FmRxApp/res/drawable/btn_bgd_default.png Binary files differnew file mode 100644 index 0000000..f7eb14d --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/btn_bgd_default.png diff --git a/tools/FM/FmRxApp/res/drawable/btn_bgd_pressed.png b/tools/FM/FmRxApp/res/drawable/btn_bgd_pressed.png Binary files differnew file mode 100644 index 0000000..c502db4 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/btn_bgd_pressed.png diff --git a/tools/FM/FmRxApp/res/drawable/configure.png b/tools/FM/FmRxApp/res/drawable/configure.png Binary files differnew file mode 100644 index 0000000..a2f1038 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/configure.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_menu_help.png b/tools/FM/FmRxApp/res/drawable/fm_menu_help.png Binary files differnew file mode 100644 index 0000000..e2eea4a --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_menu_help.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_menu_manage.png b/tools/FM/FmRxApp/res/drawable/fm_menu_manage.png Binary files differnew file mode 100644 index 0000000..41c514b --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_menu_manage.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_menu_preferences.png b/tools/FM/FmRxApp/res/drawable/fm_menu_preferences.png Binary files differnew file mode 100644 index 0000000..9c3d416 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_menu_preferences.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_mono.png b/tools/FM/FmRxApp/res/drawable/fm_mono.png Binary files differnew file mode 100644 index 0000000..0789d84 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_mono.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_seek_down.png b/tools/FM/FmRxApp/res/drawable/fm_seek_down.png Binary files differnew file mode 100644 index 0000000..013aa2e --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_seek_down.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_seek_up.png b/tools/FM/FmRxApp/res/drawable/fm_seek_up.png Binary files differnew file mode 100644 index 0000000..ce7a864 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_seek_up.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_stereo.png b/tools/FM/FmRxApp/res/drawable/fm_stereo.png Binary files differnew file mode 100644 index 0000000..79a15e4 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_stereo.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_volume.png b/tools/FM/FmRxApp/res/drawable/fm_volume.png Binary files differnew file mode 100644 index 0000000..0faf1a0 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_volume.png diff --git a/tools/FM/FmRxApp/res/drawable/fm_volume_mute.PNG b/tools/FM/FmRxApp/res/drawable/fm_volume_mute.PNG Binary files differnew file mode 100644 index 0000000..5d4431f --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/fm_volume_mute.PNG diff --git a/tools/FM/FmRxApp/res/drawable/headset.png b/tools/FM/FmRxApp/res/drawable/headset.png Binary files differnew file mode 100644 index 0000000..a00e2fc --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/headset.png diff --git a/tools/FM/FmRxApp/res/drawable/icon.png b/tools/FM/FmRxApp/res/drawable/icon.png Binary files differnew file mode 100644 index 0000000..7502484 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/icon.png diff --git a/tools/FM/FmRxApp/res/drawable/poweron.png b/tools/FM/FmRxApp/res/drawable/poweron.png Binary files differnew file mode 100644 index 0000000..b0a55b7 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/poweron.png diff --git a/tools/FM/FmRxApp/res/drawable/radio.png b/tools/FM/FmRxApp/res/drawable/radio.png Binary files differnew file mode 100644 index 0000000..9de7e9a --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/radio.png diff --git a/tools/FM/FmRxApp/res/drawable/radio_bg.png b/tools/FM/FmRxApp/res/drawable/radio_bg.png Binary files differnew file mode 100644 index 0000000..50a2096 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/radio_bg.png diff --git a/tools/FM/FmRxApp/res/drawable/robot.png b/tools/FM/FmRxApp/res/drawable/robot.png Binary files differnew file mode 100644 index 0000000..8a9e698 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/robot.png diff --git a/tools/FM/FmRxApp/res/drawable/seek_down_bgd.xml b/tools/FM/FmRxApp/res/drawable/seek_down_bgd.xml new file mode 100644 index 0000000..009024d --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/seek_down_bgd.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true" android:state_pressed="false" + android:drawable="@drawable/fm_seek_down" /> + <item android:state_focused="false" android:state_pressed="true" + android:drawable="@drawable/seek_down_pressed" /> + <item android:drawable="@drawable/fm_seek_down" /> +</selector> diff --git a/tools/FM/FmRxApp/res/drawable/seek_down_pressed.png b/tools/FM/FmRxApp/res/drawable/seek_down_pressed.png Binary files differnew file mode 100644 index 0000000..ad397b5 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/seek_down_pressed.png diff --git a/tools/FM/FmRxApp/res/drawable/seek_up_bgd.xml b/tools/FM/FmRxApp/res/drawable/seek_up_bgd.xml new file mode 100644 index 0000000..5248a24 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/seek_up_bgd.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true" android:state_pressed="false" + android:drawable="@drawable/fm_seek_up" /> + <item android:state_focused="false" android:state_pressed="true" + android:drawable="@drawable/seek_up_pressed" /> + <item android:drawable="@drawable/fm_seek_up" /> +</selector> diff --git a/tools/FM/FmRxApp/res/drawable/seek_up_pressed.png b/tools/FM/FmRxApp/res/drawable/seek_up_pressed.png Binary files differnew file mode 100644 index 0000000..a5e6713 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/seek_up_pressed.png diff --git a/tools/FM/FmRxApp/res/drawable/speaker.png b/tools/FM/FmRxApp/res/drawable/speaker.png Binary files differnew file mode 100644 index 0000000..03112d7 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/speaker.png diff --git a/tools/FM/FmRxApp/res/drawable/vol_control.png b/tools/FM/FmRxApp/res/drawable/vol_control.png Binary files differnew file mode 100644 index 0000000..d278b77 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/vol_control.png diff --git a/tools/FM/FmRxApp/res/drawable/volume.png b/tools/FM/FmRxApp/res/drawable/volume.png Binary files differnew file mode 100644 index 0000000..d278b77 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/volume.png diff --git a/tools/FM/FmRxApp/res/drawable/wallpaper11.png b/tools/FM/FmRxApp/res/drawable/wallpaper11.png Binary files differnew file mode 100644 index 0000000..92d2a00 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/wallpaper11.png diff --git a/tools/FM/FmRxApp/res/drawable/wallpaper22.png b/tools/FM/FmRxApp/res/drawable/wallpaper22.png Binary files differnew file mode 100644 index 0000000..d04a788 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/wallpaper22.png diff --git a/tools/FM/FmRxApp/res/drawable/wallpaper33.png b/tools/FM/FmRxApp/res/drawable/wallpaper33.png Binary files differnew file mode 100644 index 0000000..126c7a3 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/wallpaper33.png diff --git a/tools/FM/FmRxApp/res/drawable/wallpaper4.png b/tools/FM/FmRxApp/res/drawable/wallpaper4.png Binary files differnew file mode 100644 index 0000000..ea83620 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/wallpaper4.png diff --git a/tools/FM/FmRxApp/res/drawable/wallpaper7.PNG b/tools/FM/FmRxApp/res/drawable/wallpaper7.PNG Binary files differnew file mode 100644 index 0000000..4c813a2 --- /dev/null +++ b/tools/FM/FmRxApp/res/drawable/wallpaper7.PNG diff --git a/tools/FM/FmRxApp/res/layout/fmrxfreq.xml b/tools/FM/FmRxApp/res/layout/fmrxfreq.xml new file mode 100644 index 0000000..dae6034 --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/fmrxfreq.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper7"> + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + <LinearLayout android:id="@+id/widget28" + android:layout_width="fill_parent" android:layout_height="fill_parent"> + <TextView android:id="@+id/freqRange" android:text="@string/freqRangeEurope" + android:textSize="16sp" android:layout_width="wrap_content" + android:layout_height="50dip" android:paddingBottom="20dip"> + </TextView> + <EditText android:id="@+id/txtFrequency" android:text="@string/empty" + android:textSize="16sp" android:layout_below="@+id/freqRange" + android:layout_width="100dip" android:layout_height="50dip" + android:inputType="numberDecimal" android:layout_weight="1"> + </EditText> + <TextView android:id="@+id/label" android:layout_width="wrap_content" + android:text="@string/label" android:layout_alignBottom="@+id/txtFrequency" + android:layout_height="40dip" android:textSize="16sp"> + </TextView> + </LinearLayout> + </ScrollView> + <LinearLayout android:layout_height="50dip" + android:layout_width="fill_parent"> + <Button android:layout_width="wrap_content" + android:layout_height="fill_parent" android:text="@string/btnOk" + android:id="@+id/btnOk" android:layout_weight="1"> + </Button> + <Button android:id="@+id/btnCancel" android:layout_width="wrap_content" + android:layout_height="fill_parent" android:text="@string/btnCancel" + android:layout_weight="1"> + </Button> + </LinearLayout> +</LinearLayout> diff --git a/tools/FM/FmRxApp/res/layout/fmrxhelp.xml b/tools/FM/FmRxApp/res/layout/fmrxhelp.xml new file mode 100644 index 0000000..50d4730 --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/fmrxhelp.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper7"> + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + + <LinearLayout android:id="@+id/widget224" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="fill_parent"> + <LinearLayout android:id="@+id/widget224" + android:layout_alignParentTop="true" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_height="120dip"> + <ImageView android:id="@+id/imgFTP" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginLeft="30dip" android:src="@drawable/radio"> + </ImageView> + <TextView android:id="@+id/lblFmRx" android:layout_width="fill_parent" + android:layout_height="30dip" android:layout_marginTop="15dip" + android:text="@string/app_rx" android:textSize="24sp" + android:textStyle="bold" android:layout_marginLeft="20dip" + android:layout_gravity="center"> + </TextView> + </LinearLayout> + <LinearLayout android:id="@+id/widget233" + android:layout_below="@+id/widget224" android:layout_width="fill_parent" + android:layout_alignParentLeft="false" android:layout_height="100dip"> + <TextView android:id="@+id/lblFmApp" android:layout_width="wrap_content" + android:text="@string/fmapp" android:textSize="24sp" + android:textStyle="bold" android:layout_height="50dip" + android:layout_marginTop="20dip" android:paddingLeft="50dip"> + </TextView> + <TextView android:id="@+id/txtplatform" + android:layout_width="wrap_content" android:text="@string/txtplatform" + android:paddingLeft="10dip" android:textSize="24sp" + android:layout_height="50dip" android:layout_marginTop="20dip" + android:textStyle="bold"> + </TextView> + </LinearLayout> + <LinearLayout android:id="@+id/widget243" + android:layout_below="@+id/widget233" android:layout_width="fill_parent" + android:layout_alignParentLeft="false" android:layout_height="50dip"> + <TextView android:id="@+id/lblversion" + android:layout_width="wrap_content" android:text="@string/lblversion" + android:layout_height="40dip" android:textSize="24sp" + android:layout_marginLeft="30dip" android:paddingLeft="50dip"> + </TextView> + <TextView android:id="@+id/txtversion" + android:layout_width="wrap_content" android:text="@string/txtversion" + android:paddingLeft="30dip" android:layout_height="40dip" + android:textSize="24sp"> + </TextView> + </LinearLayout> + + </LinearLayout> + </ScrollView> + + <LinearLayout android:id="@+id/widget244" + android:layout_alignParentBottom="true" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:gravity="right"> + + <Button android:id="@+id/btnBack" android:layout_width="150dip" + android:layout_height="50dip" android:text="@string/btnCancel" + android:layout_alignParentRight="true" android:layout_gravity="center"> + </Button> + </LinearLayout> +</LinearLayout> diff --git a/tools/FM/FmRxApp/res/layout/fmrxmain.xml b/tools/FM/FmRxApp/res/layout/fmrxmain.xml new file mode 100644 index 0000000..94984c6 --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/fmrxmain.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper7"> + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + <LinearLayout android:id="@+id/widget224" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="fill_parent"> + <LinearLayout android:id="@+id/widget30" + android:layout_alignParentTop="true" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_height="120dip"> + + <ImageView android:id="@+id/imgMute" + android:layout_gravity="center" android:layout_height="wrap_content" + android:layout_width="fill_parent" android:layout_weight="1"> + </ImageView> + <ImageView android:id="@+id/imgMode" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="center"> + </ImageView> + <ImageView android:id="@+id/imgPower" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:adjustViewBounds="true" android:layout_gravity="center" + android:baselineAlignBottom="true" android:cropToPadding="true" + android:drawingCacheQuality="auto" android:src="@drawable/poweron" + android:layout_weight="1"> + </ImageView> + </LinearLayout> + <LinearLayout android:id="@+id/widget35" + android:layout_below="@+id/widget30" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="70dip"> + <TextView android:id="@+id/txtRadioText" + android:scrollHorizontally="false" android:lines="1" android:text="@string/radioTxt" + android:textStyle="bold" android:textSize="20sp" + android:layout_width="fill_parent" android:layout_gravity="center" + android:paddingLeft="30dip" android:layout_height="50dip"> + </TextView> + <TextView android:id="@+id/txtPsText" + android:scrollHorizontally="false" android:lines="1" android:text="@string/pstxt" + android:layout_gravity="center" android:textStyle="bold" + android:textSize="20sp" android:layout_width="fill_parent" + android:paddingLeft="30dip" android:layout_height="50dip"> + </TextView> + + </LinearLayout> + + <LinearLayout android:id="@+id/widget36" + android:layout_below="@+id/widget35" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_centerInParent="true" + android:layout_height="30dip"> + <TextView android:id="@+id/txtStatusMsg" + android:layout_width="fill_parent" android:scrollHorizontally="false" + android:lines="1" android:text="@string/statusMsg" + android:paddingLeft="120dip" android:textSize="20sp" + android:layout_height="30dip"> + </TextView> + </LinearLayout> + + <LinearLayout android:layout_width="fill_parent" + android:layout_height="100dip" + android:id="@+id/widget67" android:layout_marginLeft="25dip"> + + <TableLayout android:id="@+id/TableLayout01" + android:layout_width="wrap_content" android:layout_weight="1" + android:layout_height="wrap_content" android:paddingLeft="40dip"> + <TableRow android:layout_margin="1dip"> + <ImageButton android:id="@+id/imgseekdown" + android:layout_height="80dip" android:layout_width="wrap_content" + android:background="@drawable/seek_down_bgd"> + </ImageButton> + </TableRow> + </TableLayout> + + <TableLayout android:id="@+id/TableLayout02" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1"> + <TableRow> + <TextView android:id="@+id/txtStationName" android:text="@string/name" + android:visibility="visible" android:layout_gravity="center" + android:layout_height="30dip" android:textSize="22dip"> + </TextView> + </TableRow> + <TableLayout android:id="@+id/widget39" + android:layout_width="144dip" android:orientation="horizontal" + android:layout_height="40dip"> + <TableRow> + <TextView android:id="@+id/txtRxFreq" + android:text="@string/rx_freq_val" + android:textStyle="bold" android:visibility="visible" + android:layout_height="wrap_content" android:textSize="30dip" android:layout_width="fill_parent" android:layout_weight="1"> + </TextView> + <TextView android:id="@+id/txtLabel" + android:layout_height="wrap_content" android:text="@string/labelhz" + android:layout_marginLeft="4dip" android:textSize="26dip" android:layout_width="wrap_content" android:layout_weight="1" android:layout_marginRight="1dip"> + </TextView> + </TableRow> + </TableLayout> + + </TableLayout> + + <TableLayout android:id="@+id/TableLayout03" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1"> + <TableRow android:layout_margin="1dip"> + <ImageButton android:id="@+id/imgseekup" + android:background="@drawable/seek_up_bgd" android:layout_height="80dip" + android:layout_width="wrap_content"> + </ImageButton> + </TableRow> + </TableLayout> + </LinearLayout> + <LinearLayout android:id="@+id/widget95" + android:layout_below="@+id/widget72" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:paddingTop="40dip" + android:layout_height="100dip"> + <Button android:id="@+id/station1" android:layout_height="50dip" + android:text="@string/station1" android:textSize="30sp" + android:background="@drawable/btn_bgd" android:clickable="true" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginLeft="20dip" android:layout_marginRight="20dip"> + </Button> + <Button android:id="@+id/station2" android:layout_marginLeft="20dip" + android:layout_height="50dip" android:text="@string/station2" + android:textSize="30sp" android:background="@drawable/btn_bgd" android:clickable="true" android:layout_width="fill_parent" android:layout_weight="1" android:layout_marginRight="20dip"> + </Button> + <Button android:id="@+id/station3" android:layout_marginLeft="20dip" + android:layout_height="50dip" android:text="@string/station3" + android:editable="true" android:textSize="30sp" + android:background="@drawable/btn_bgd" + android:clickable="true" android:layout_width="fill_parent" android:layout_weight="1" android:layout_marginRight="20dip"> + </Button> + </LinearLayout> + <LinearLayout android:id="@+id/widget99" + android:layout_below="@+id/widget95" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:paddingTop="20dip" + android:layout_height="100dip"> + <Button android:id="@+id/station4" android:layout_height="50dip" + android:text="@string/station4" android:textSize="30sp" + android:layout_marginLeft="20dip" + android:layout_gravity="center" android:background="@drawable/btn_bgd" + android:clickable="true" android:layout_width="fill_parent" android:layout_weight="1" android:layout_marginRight="20dip"> + </Button> + <Button android:id="@+id/station5" android:layout_height="50dip" + android:layout_marginLeft="20dip" android:text="@string/station5" + android:textSize="30sp" android:layout_gravity="center" android:background="@drawable/btn_bgd" + android:clickable="true" android:layout_marginRight="20dip" android:layout_width="fill_parent" android:layout_weight="1"> + </Button> + <Button android:id="@+id/station6" android:layout_height="50dip" + android:layout_marginLeft="20dip" android:text="@string/station6" + android:textSize="30sp" android:layout_gravity="center" android:background="@drawable/btn_bgd" + android:clickable="true" android:layout_width="fill_parent" android:layout_weight="1" android:layout_marginRight="20dip"> + </Button> + </LinearLayout> + </LinearLayout> + </ScrollView> + +</LinearLayout> + + + + diff --git a/tools/FM/FmRxApp/res/layout/fmrxrdsconfig.xml b/tools/FM/FmRxApp/res/layout/fmrxrdsconfig.xml new file mode 100644 index 0000000..6fcfab0 --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/fmrxrdsconfig.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper7"> + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + + <LinearLayout android:id="@+id/widget224" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="fill_parent"> + <LinearLayout android:id="@+id/widget29" + android:layout_below="@+id/widget28" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_height="50dip"> + <CheckBox android:id="@+id/chbRdsmode" android:text="@string/rdsmode" + android:layout_marginLeft="15dip" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:textSize="20sp" android:layout_weight="1"> + </CheckBox> + <CheckBox android:id="@+id/chbSetRdsAf" android:text="@string/rdsaf" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:textSize="20sp" android:layout_weight="1"> + </CheckBox> + </LinearLayout> + + <LinearLayout android:id="@+id/widget171" + android:layout_below="@+id/widget29" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_height="50dip" android:layout_marginTop="10dip"> + <TextView android:id="@+id/txtRdsSystem" android:text="@string/rdssystem" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginLeft="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </TextView> + <Spinner android:id="@+id/spnRdsSystem" + android:layout_height="fill_parent" android:layout_marginRight="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </Spinner> + + </LinearLayout> + + + <LinearLayout android:id="@+id/widget170" + android:layout_below="@+id/widget171" + android:layout_alignParentLeft="true" android:layout_width="fill_parent" + android:layout_height="50dip"> + <TextView android:id="@+id/txtBand" android:text="@string/band" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginLeft="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </TextView> + <Spinner android:id="@+id/spnBand" + android:layout_height="fill_parent" android:layout_marginRight="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </Spinner> + </LinearLayout> + + + <LinearLayout android:id="@+id/widget174" + android:layout_below="@+id/widget170" + android:layout_alignParentLeft="true" android:layout_width="fill_parent" + android:layout_height="50dip"> + <TextView android:id="@+id/txtMode" android:text="@string/mode" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginLeft="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </TextView> + <Spinner android:id="@+id/spnMode" android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginRight="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </Spinner> + </LinearLayout> + + + <LinearLayout android:id="@+id/widget173" + android:layout_below="@+id/widget172" + android:layout_alignParentLeft="true" android:layout_width="fill_parent" + android:layout_height="50dip"> + <TextView android:id="@+id/txtChannelSpacing" android:text="@string/channelSpace" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginLeft="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </TextView> + <Spinner android:id="@+id/spnChannelSpace" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginRight="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </Spinner> + </LinearLayout> + + + + <LinearLayout android:id="@+id/widget207" + android:layout_below="@+id/widget173" android:layout_width="fill_parent" + android:paddingRight="10dip" android:layout_alignParentLeft="true" + android:layout_height="50dip"> + <TextView android:id="@+id/txtRssi" android:text="@string/rssi" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_marginLeft="15dip" + android:layout_width="fill_parent" android:layout_weight="1"> + </TextView> + <EditText android:id="@+id/Rssi" android:text="@string/empty" + android:textSize="18sp" + android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:layout_marginLeft="8dip" android:layout_marginRight="8dip"> + </EditText> + </LinearLayout> + </LinearLayout> + </ScrollView> + <LinearLayout android:layout_height="50dip" android:id="@+id/widget173" + android:layout_width="fill_parent"> + <Button android:layout_width="wrap_content" + android:layout_height="fill_parent" android:text="@string/btnOk" + android:id="@+id/btnOk" android:layout_weight="1"> + </Button> + <Button android:id="@+id/btnCancel" android:layout_width="wrap_content" + android:layout_height="fill_parent" android:text="@string/btnCancel" + android:layout_weight="1"> + </Button> + </LinearLayout> +</LinearLayout> diff --git a/tools/FM/FmRxApp/res/layout/preset.xml b/tools/FM/FmRxApp/res/layout/preset.xml new file mode 100644 index 0000000..36b3bef --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/preset.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper7"> +<ScrollView +android:id="@+id/scrollview1" +android:layout_width="fill_parent" +android:layout_height="fill_parent" android:layout_weight="1"> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="fill_parent" + android:layout_height="fill_parent" android:background="@drawable/wallpaper7"> + <ListView android:id="@+id/android:list" android:layout_width="fill_parent" + android:layout_height="0px" android:layout_weight="1" + android:cacheColorHint="#00000000" android:textSize="10sp"> + </ListView> + +</LinearLayout> +</ScrollView> +<LinearLayout android:id="@+id/widget244" + android:layout_alignParentBottom="true" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:gravity="right"> + <Button android:id="@+id/btnBack" android:layout_width="150dip" + android:layout_height="wrap_content" android:text="@string/btnBack" + android:layout_gravity="right"> + </Button> + </LinearLayout> +</LinearLayout> + diff --git a/tools/FM/FmRxApp/res/layout/row.xml b/tools/FM/FmRxApp/res/layout/row.xml new file mode 100644 index 0000000..538a152 --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/row.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="wrap_content" + android:background="#00000000" android:orientation="horizontal"> + + <TextView android:id="@+id/list_key" android:layout_height="40dip" + android:textStyle="bold" android:textSize="24sp" android:text="@string/index" + android:layout_width="80dip" /> + + <TextView android:id="@+id/list_value" android:textSize="24sp" + android:textStyle="bold" android:layout_height="40dip" android:text="@string/freq" + android:layout_width="80dip" /> + + <TextView android:id="@+id/list_name" android:textSize="24sp" + android:textStyle="bold" android:layout_height="40dip" android:text="@string/name" + android:layout_width="140dip" /> +</LinearLayout> diff --git a/tools/FM/FmRxApp/res/layout/toast.xml b/tools/FM/FmRxApp/res/layout/toast.xml new file mode 100644 index 0000000..7d931b0 --- /dev/null +++ b/tools/FM/FmRxApp/res/layout/toast.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/toast_layout" android:orientation="horizontal" + android:layout_width="fill_parent" android:layout_height="wrap_content" + android:padding="10dp" android:background="#DAAA"> + <TextView android:id="@+id/text" android:layout_width="wrap_content" + android:layout_height="fill_parent" android:textColor="#FFF" /> +</LinearLayout> diff --git a/tools/FM/FmRxApp/res/values/color.xml b/tools/FM/FmRxApp/res/values/color.xml new file mode 100644 index 0000000..db85511 --- /dev/null +++ b/tools/FM/FmRxApp/res/values/color.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> + +<resources> + <drawable name="red">#7f00</drawable> + <drawable name="blue">#770000ff</drawable> + <drawable name="green">#7700ff00</drawable> + <drawable name="yellow">#77ffff00</drawable> + + <drawable name="screen_background_black">#ff000000</drawable> + <drawable name="translucent_background">#e0000000</drawable> + <drawable name="transparent_background">#00000000</drawable> + + <color name="solid_red">#f00</color> + <color name="solid_blue">#0000ff</color> + <color name="solid_green">#f0f0</color> + <color name="solid_yellow">#ffffff00</color> + + <color name="black">#000</color> + <color name="magic_flame">#00ff2222</color> + <color name="button_text">#ffffffff</color> + +</resources> + + + + + diff --git a/tools/FM/FmRxApp/res/values/strings.xml b/tools/FM/FmRxApp/res/values/strings.xml new file mode 100644 index 0000000..91bceac --- /dev/null +++ b/tools/FM/FmRxApp/res/values/strings.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">FM Radio</string> + <string name="app_rx">FM Radio</string> + <string name="app_tx">FM TX App</string> + <string name="fmapp">FM Radio</string> + <string name="stations">FM Radio Stations</string> + <string name="txtplatform">V4L2 based solution for Android </string> + <string name="lblversion">Version:</string> + <string name="txtversion">0.1</string> + <string name="app_rxtune">Enter Frequency</string> + <string name="app_rxhelp">About</string> + <string name="radioTxt"> </string> + <string name="mono">Mono</string> + <string name="pgmSrv">Program Service</string> + <string name="statusMsg"></string> + <string name="notiMsg">Notification Message</string> + <string name="btnOk">OK</string> + <string name="btnCancel">Cancel</string> + <string name="btnBack">Back</string> + <string name="japaneseBand">Japanese Band</string> + <string name="preEmphasis">Pre Emphasis Filter(Usec):</string> + <string name="radioData">Radio data(RDS)</string> + <string name="advanced">Advanced</string> + <string name="rdsTransmit">RDS Transmit:</string> + <string name="sec50">50</string> + <string name="sec75">75</string> + <string name="none">None</string> + <string name="PS">PS</string> + <string name="PS:">PS:</string> + <string name="RT">RT</string> + <string name="RT:">RT:</string> + <string name="TP">TP</string> + <string name="TP:">TP:</string> + <string name="stereo">Stereo</string> + <string name="rdsAf">RDS AF</string> + <string name="app_rds">FM Configurations</string> + <string name="freqRangeEurope"> 87.50MHz - 108.00MHz </string> + <string name="freqRangeJapan"> 76MHz - 90MHz </string> + <string name="label"> MHz </string> + <string name="labelhz"> MHz </string> + <string name="rx_freq_val"> </string> + <string name="Manual">Manual</string> + <string name="Configure">Configure</string> + <string name="Help">Help</string> + <string name="enterFreq_Dialog">Enter Frequency</string> + <string name="Stereo">Stereo</string> + <string name="empty"></string> + <string name="pty">Dynamic PTY</string> + <string name="comp">Compression</string> + <string name="picode">PI Code:</string> + <string name="speed">Speed:</string> + <string name="size">Size:</string> + <string name="rdsmode">Enable Rds</string> + <string name="ptycode">PTY Code:</string> + <string name="dicode">Dicodes:</string> + <string name="mute">Mute</string> + <string name="unmute">Unmute</string> + <string name="att">Att</string> + <string name="station1">1</string> + <string name="station2">2</string> + <string name="station3">3</string> + <string name="station4">4</string> + <string name="station5">5</string> + <string name="station6">6</string> + <string name="station">Station</string> + <string name="configure">Configure</string> + <string name="exit">Exit</string> + <string name="about">About</string> + <string name="preset">Preset</string> + <string name="rdsaf">Set RDS AF</string> + <string name="announcement">Announcement</string> + <string name="TA">TA</string> + <string name="connecting ">Connecting ....</string> + <string name="seraching">Searching ....</string> + <string name="tuning">Tuning</string> + <string name="notsupported">Not supported!!!!</string> + <string name="setfreq">Set Frequency</string> + <string name="wait">Please wait!!!!</string> + <string name="startFm">Starting FM!!!!</string> + <string name="volume">Volume :</string> + <string name="rssi">RSSI :</string> + <string name="band">Band :</string> + <string name="mode">Mode :</string> + <string name="deemphasis">DEmp Filter:</string> + <string name="rdssystem">RDS System:</string> + <string name="number">Enter valid number</string> + <string name="seeking">Seeking ....</string> + <string name="playing">Playing ....</string> + <string name="pstxt"></string> + <string name="index">Index</string> + <string name="freq">Freq</string> + <string name="name">""</string> + <string name="channelSpace">Ch Space</string> +</resources> diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/DBAdapter.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/DBAdapter.java new file mode 100644 index 0000000..cf0c92d --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/DBAdapter.java @@ -0,0 +1,175 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + + +import java.util.HashMap; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +public class DBAdapter +{ + public static final String KEY_ROWID = "_id"; + public static final String ITEM_KEY = "id"; + public static final String ITEM_VALUE = "channel"; + public static final String ITEM_NAME = "name"; + private static final String TAG = "DBAdapter"; + private static final String DATABASE_NAME = "presets.db"; + private static final String DATABASE_TABLE = "presets"; + private static final int DATABASE_VERSION = 1; + + private static final String DATABASE_CREATE = + "create table presets (_id integer primary key autoincrement, " + + "id text not null, channel text not null, " + + "name text not null);"; + + private final Context context; + + private DatabaseHelper DBHelper; + private SQLiteDatabase db; + + public DBAdapter(Context ctx) + { + this.context = ctx; + DBHelper = new DatabaseHelper(context); + Log.d(TAG," DBAdapter const"); + } + + private static class DatabaseHelper extends SQLiteOpenHelper + { + DatabaseHelper(Context context) + { + + super(context, DATABASE_NAME, null, DATABASE_VERSION); + Log.d(TAG," DatabaseHelper con"); + } + + @Override + public void onCreate(SQLiteDatabase db) + { + Log.d(TAG," DatabaseHelper onCreate"); + db.execSQL(DATABASE_CREATE); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, + int newVersion) + { + Log.w(TAG, "Upgrading database from version " + oldVersion + + " to " + + newVersion + ", which will destroy all old data"); + db.execSQL("DROP TABLE IF EXISTS presets"); + onCreate(db); + } + } + + //---opens the database--- + public DBAdapter open() throws SQLException + { + db = DBHelper.getWritableDatabase(); + Log.d(TAG," DatabaseHelper open"); + return this; + } + + //---closes the database--- + public void close() + { + DBHelper.close(); + Log.d(TAG," DatabaseHelper close"); + } + + //---insert a station into the database--- + public long insertStation(String itemkey, String itemValue, String itemName) + { + + Log.d(TAG," DatabaseHelper insertStation"); + ContentValues initialValues = new ContentValues(); + initialValues.put(ITEM_KEY, itemkey); + initialValues.put(ITEM_VALUE, itemValue); + initialValues.put(ITEM_NAME, itemName); + return db.insert(DATABASE_TABLE, null, initialValues); + } + + //---deletes a particular station--- + public boolean deleteStation(long rowId) + { + Log.d(TAG," DatabaseHelper deleteStation"); + return db.delete(DATABASE_TABLE, KEY_ROWID + + "=" + rowId, null) > 0; + } + + //---retrieves all the Stations--- + public Cursor getAllStations() + { + Log.d(TAG," DatabaseHelper getAllStations"); + return db.query(DATABASE_TABLE, new String[] { + KEY_ROWID, + ITEM_KEY, + ITEM_VALUE, + ITEM_NAME}, + null, + null, + null, + null, + null); + } + + //---retrieves a particular station--- + public Cursor getStation(long rowId) throws SQLException + { + + Log.d(TAG," DatabaseHelper getStation"); + Cursor mCursor = + db.query(true, DATABASE_TABLE, new String[] { + KEY_ROWID, + ITEM_KEY, + ITEM_VALUE, + ITEM_NAME}, + KEY_ROWID + "=" + rowId, + null, + null, + null, + null, + null); + if (mCursor != null) { + mCursor.moveToFirst(); + } + return mCursor; + } + + //---updates a station--- + public boolean updateStation(int index, String itemKey, + String itemValue, String itemName) + { + Log.d(TAG," DatabaseHelper updateStation"); + ContentValues args = new ContentValues(); + args.put(ITEM_KEY, itemKey); + args.put(ITEM_VALUE, itemValue); + args.put(ITEM_NAME, itemName); + return db.update(DATABASE_TABLE, args, + KEY_ROWID + "=" + index, null) > 0; + } + + +} diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmPresetList.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmPresetList.java new file mode 100644 index 0000000..909fb2a --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmPresetList.java @@ -0,0 +1,212 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + +import java.util.HashMap; +import android.app.AlertDialog; +import android.app.ListActivity; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.os.Bundle; +import android.text.Editable; +import android.util.Log; +import android.view.ContextMenu; +import android.view.KeyEvent; +import android.view.MenuItem; +import android.view.View; +import android.view.ContextMenu.ContextMenuInfo; +import android.widget.EditText; +import android.widget.SimpleAdapter; +import android.widget.AdapterView.AdapterContextMenuInfo; +import java.util.HashMap; +import android.widget.Button; +import android.content.Intent; +import android.content.IntentFilter; + +public class FmPresetList extends ListActivity implements FmRxAppConstants, + View.OnClickListener { + + public static SimpleAdapter adapter; + + // =========================================================== + // Final Fields + // =========================================================== + protected static final int MENU_SET_STATION = 0; + protected static final int MENU_UNSET_STATION = 1; + protected static final int MENU_RENAME_STATION = 2; + public static final String TAG = "FmPresetList"; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.preset); + + // Now build the list adapter + this.adapter = new SimpleAdapter( + // the Context + this, + // the data to display + FmRxApp.stations, + // The layout to use for each item + R.layout.row, + // The list item attributes to display + new String[] { ITEM_KEY, ITEM_VALUE, ITEM_NAME }, + // And the ids of the views where they should be displayed (same + // order) + new int[] { R.id.list_key, R.id.list_value, R.id.list_name }); + + setListAdapter(this.adapter); + adapter.notifyDataSetChanged(); + /* Add Context-Menu listener to the ListView. */ + registerForContextMenu(getListView()); + initControls(); + Log.i(TAG, "onCreate: Presets...."); + } + + private void initControls() { + Button btnBack = (Button) findViewById(R.id.btnBack); + btnBack.setOnClickListener(this); + + } + + public void onClick(View v) { + int id = v.getId(); + switch (id) { + case R.id.btnBack: + setResult(RESULT_OK); + Log.i(TAG, "RESULT_OK"); + finish(); + break; + } + } + + + public boolean onKeyDown(int keyCode, KeyEvent event) { + + switch (keyCode) { + + case KeyEvent.KEYCODE_BACK: + { + setResult(RESULT_OK); + return true; + } + } + return true; + } + + private void refreshFavListItems() { + this.setListAdapter(this.adapter); + + } + + public void onCreateContextMenu(ContextMenu menu, View v, + ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + menu.setHeaderTitle("ContextMenu"); + menu.add(0, MENU_SET_STATION, 0, "Set Station"); + menu.add(0, MENU_UNSET_STATION, 0, "Unset Station"); + menu.add(0, MENU_RENAME_STATION, 0, "Rename Station"); + + } + + // =========================================================== + // Methods from SuperClass/Interfaces + // =========================================================== + + public boolean onContextItemSelected(MenuItem aItem) { + AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem + .getMenuInfo(); + /* Get the selected item out of the Adapter by its position. */ + final Integer index = menuInfo.position; + final Integer i = new Integer(index.intValue() + 1); + + /* Switch on the ID of the item, to get what the user selected. */ + switch (aItem.getItemId()) { + + case MENU_RENAME_STATION: + + AlertDialog.Builder alert = new AlertDialog.Builder(this); + + alert.setTitle("Rename"); + alert.setMessage("Rename Station?"); + + // Set an EditText view to get user input + final EditText input = new EditText(this); + alert.setView(input); + + alert.setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + String value = input.getText().toString(); + FmRxApp.UpdateRenameStation(index, value); + refreshFavListItems(); + } + }); + + alert.setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + // Canceled. + } + }); + + alert.show(); + + return true; /* true means: "we handled the event". */ + + case MENU_SET_STATION: + OnClickListener okButtonListener = new OnClickListener() { + + public void onClick(DialogInterface arg0, int arg1) { + FmRxApp.updateSetStation(index, FmRxApp.txtFmRxTunedFreq + .getText().toString(), ""); + refreshFavListItems(); + + } + }; + + new AlertDialog.Builder(this).setTitle("Set Station").setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Set Station?").setNegativeButton(android.R.string.cancel, + null).setPositiveButton(android.R.string.ok, + okButtonListener).show(); + return true; /* true means: "we handled the event". */ + + case MENU_UNSET_STATION: + + OnClickListener okUnsetButtonListener = new OnClickListener() { + + public void onClick(DialogInterface arg0, int arg1) { + FmRxApp.updateUnSetStation(index); + refreshFavListItems(); + + } + }; + + new AlertDialog.Builder(this).setTitle("Unseet Station").setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Unset Station?").setNegativeButton( + android.R.string.cancel, null).setPositiveButton( + android.R.string.ok, okUnsetButtonListener).show(); + return true; + } + return false; + + } +} diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxApp.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxApp.java new file mode 100644 index 0000000..b4fbc93 --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxApp.java @@ -0,0 +1,2559 @@ +/* + * + * Copyright 2001-2010 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; +import android.view.OrientationListener; +import android.view.View; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; +import com.ti.fm.FmRadio; +import com.ti.fm.FmRadioIntent; +import com.ti.fm.IFmConstants; +import android.app.AlertDialog; +import android.os.Bundle; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.database.Cursor; +import android.database.SQLException; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.view.Window; +import android.media.AudioManager; +import android.widget.Toast; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.ViewGroup; + +/* + FM Boot up Sequence: + + FM APIS NON Blocking: + + sFmRadio.rxEnable() is called from FM application, when the user selects FM radio icon from main menu. + + Once the callback for sFmRadio.rxEnable() is received (EVENT_FM_ENABLED), + the default configurations which have been saved in the preference will be loaded using loadDefaultConfiguration() function . + After this sFmRadio.rxSetVolume() with default volume will be called. + + Once the callback for sFmRadio.rxSetVolume() is received(EVENT_VOLUME_CHANGE), + sFmRadio.rxSetBand() with default band will be called. + + Once the callback for sFmRadio.rxSetBand() is received(EVENT_BAND_CHANGE), sFmRadio.rxTune_nb() + with default frequency will be called. + + Once the callback for sFmRadio.rxTune_nb()is received (EVENT_TUNE_COMPLETE) + sFmRadio.rxEnableAudioRouting() will be called to enable audio. + + After these sequences user can hear the FM audio. + + + The rest of the APIS will be called based on the user actions like when user presses seek up or down + sFmRadio.rxSeek_nb() will be called and the callback for the same will be EVENT_SEEK_STARTED. + + To increase decrease the volume sFmRadio.rxSetVolume() will be called and the callback for + the same will be EVENT_VOLUME_CHANGE. + + To mute /unmute, sFmRadio.rxSetMuteMode() will be called and the callback + for the same will be EVENT_MUTE_CHANGE. + + + FM APIS Blocking: + +In case of blocking FM APIS, the above sequence holds good. The difference will be the FM Events will not posted +as intents and the usage of FM APIS will be sequential. + */ + +public class FmRxApp extends Activity implements View.OnClickListener, + IFmConstants, FmRxAppConstants , FmRadio.ServiceListener { + public static final String TAG = "FmRxApp"; + private static final boolean DBG = false; + + /******************************************** + * Widgets + ********************************************/ + + private ImageView imgFmPower, imgFmMode, imgFmVolume, imgFmAudiopath; + private ImageButton imgFmSeekUp, imgFmSeekDown; + private TextView txtStatusMsg, txtRadioText; + private TextView txtPsText; + static TextView txtStationName; + private static Button btnStation1, btnStation2, btnStation3; + private static Button btnStation4, btnStation5, btnStation6; + private ProgressDialog pd = null, configPd; + + /******************************************** + * Menu Constants + ********************************************/ + public static final int MENU_CONFIGURE = Menu.FIRST + 1; + public static final int MENU_EXIT = Menu.FIRST + 2; + public static final int MENU_ABOUT = Menu.FIRST + 3; + public static final int MENU_PRESET = Menu.FIRST + 4; + public static final int MENU_SETFREQ = Menu.FIRST + 5; + + public boolean mPreset = false; + + /******************************************** + * private variables + ********************************************/ + private int mToggleMode = 0; // To toggle between the mono/stereo + private int mToggleAudio = 1; // To toggle between the speaker/headset + private boolean mToggleMute = false; // To toggle between the mute/unmute + + private boolean mRdsState = false; + /* Default values */ + private int mVolume = DEF_VOLUME; + private int mMode = DEFAULT_MODE; + private boolean mRds = DEFAULT_RDS; + private boolean mRdsAf = DEFAULT_RDS_AF; + private int mRdsSystem = INITIAL_VAL; + private int mDeEmpFilter = INITIAL_VAL; + private int mRssi = INITIAL_RSSI; + // Seek up/down direction + private int mDirection = FM_SEEK_UP; + + /* State values */ + + // variable to make sure that the next configuration change happens after + // the current configuration request has been completed. + private int configurationState = CONFIGURATION_STATE_IDLE; + // variable to make sure that the next volume change happens after the + // current volume request has been completed. + private boolean mVolState = VOL_REQ_STATE_IDLE; + // variable to make sure that the next seek happens after the current seek + // request has been completed. + private boolean mSeekState = SEEK_REQ_STATE_IDLE; + + private boolean mStatus; + private int mIndex = 0; + private int mStationIndex; + + + /* + * Variable to identify whether we need to do the default setting when + * entering the FM application. Based on this variable,the default + * configurations for the FM will be done for the first time + */ + + private static boolean sdefaultSettingOn = false; + + private static boolean mIsDbPresent = false; + + private NotificationManager mNotificationManager; + + static final String FM_INTERRUPTED_KEY = "fm_interrupted"; + static final String FM_STATE_KEY = "fm_state"; + /* Flag to know whether FM App was interrupted due to orientation change */ + boolean mFmInterrupted = false; + + /*Flag to check if service is connected*/ + boolean mFmServiceConnected = false; + /******************************************** + * public variables + ********************************************/ + public static int sBand = DEFAULT_BAND; + public static int sChannelSpace = DEFAULT_CHANNELSPACE; + + public static Float lastTunedFrequency = (float) DEFAULT_FREQ_EUROPE; + public static FmRadio sFmRadio; + + /** Arraylist of stations */ + public static ArrayList<HashMap<String, String>> stations = new ArrayList<HashMap<String, String>>( + 6); + public static TextView txtFmRxTunedFreq; + private OrientationListener mOrientationListener; + + Context mContext; + + DBAdapter db; + + /** Called when the activity is first created. */ + + public void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + mContext = this; + /* Retrieve the fm_state and find out whether FM App was interrupted */ + + if (savedInstanceState != null) { + Bundle fmState = savedInstanceState.getBundle(FM_STATE_KEY); + if (fmState != null) { + mFmInterrupted = fmState.getBoolean(FM_INTERRUPTED_KEY, false); + + } + } + + // Create orientation listenter. + + + //requestWindowFeature(Window.FEATURE_NO_TITLE); + setVolumeControlStream(AudioManager.STREAM_MUSIC); + + // Register for FM intent broadcasts. + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(FmRadioIntent.FM_ENABLED_ACTION); + intentFilter.addAction(FmRadioIntent.FM_DISABLED_ACTION); + intentFilter.addAction(FmRadioIntent.GET_FREQUENCY_ACTION); + intentFilter.addAction(FmRadioIntent.SEEK_ACTION); + intentFilter.addAction(FmRadioIntent.BAND_CHANGE_ACTION); + intentFilter.addAction(FmRadioIntent.GET_CHANNEL_SPACE_ACTION); + intentFilter.addAction(FmRadioIntent.SET_MODE_MONO_STEREO_ACTION); + intentFilter.addAction(FmRadioIntent.VOLUME_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.RDS_TEXT_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.PS_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.AUDIO_PATH_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.TUNE_COMPLETE_ACTION); + intentFilter.addAction(FmRadioIntent.SEEK_STOP_ACTION); + intentFilter.addAction(FmRadioIntent.MUTE_CHANGE_ACTION); + intentFilter.addAction(FmRadioIntent.DISPLAY_MODE_MONO_STEREO_ACTION); + intentFilter.addAction(FmRadioIntent.ENABLE_RDS_ACTION); + intentFilter.addAction(FmRadioIntent.DISABLE_RDS_ACTION); + intentFilter.addAction(FmRadioIntent.SET_RDS_AF_ACTION); + intentFilter.addAction(FmRadioIntent.SET_RDS_SYSTEM_ACTION); + intentFilter.addAction(FmRadioIntent.SET_DEEMP_FILTER_ACTION); + intentFilter.addAction(FmRadioIntent.SET_RSSI_THRESHHOLD_ACTION); + intentFilter.addAction(FmRadioIntent.SET_RF_DEPENDENT_MUTE_ACTION); + intentFilter.addAction(FmRadioIntent.PI_CODE_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.MASTER_VOLUME_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.CHANNEL_SPACING_CHANGED_ACTION); + intentFilter.addAction(FmRadioIntent.COMPLETE_SCAN_DONE_ACTION); + intentFilter.addAction(FmRadioIntent.COMPLETE_SCAN_STOP_ACTION); + intentFilter.addAction(FmRadioIntent.GET_BAND_ACTION); + intentFilter.addAction(FmRadioIntent.GET_MONO_STEREO_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.GET_MUTE_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.GET_RF_MUTE_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.GET_RSSI_THRESHHOLD_ACTION); + intentFilter.addAction(FmRadioIntent.GET_DEEMPHASIS_FILTER_ACTION); + intentFilter.addAction(FmRadioIntent.GET_VOLUME_ACTION); + intentFilter.addAction(FmRadioIntent.GET_RDS_SYSTEM_ACTION); + intentFilter.addAction(FmRadioIntent.GET_RDS_GROUPMASK_ACTION); + intentFilter.addAction(FmRadioIntent.GET_RDS_AF_SWITCH_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.GET_RSSI_ACTION); + intentFilter.addAction(FmRadioIntent.COMPLETE_SCAN_PROGRESS_ACTION); + intentFilter.addAction(FmRadioIntent.SET_RDS_AF_ACTION); + intentFilter.addAction(FmRadioIntent.SET_RF_DEPENDENT_MUTE_ACTION); + intentFilter.addAction(FmRadioIntent.SET_CHANNEL_SPACE_ACTION); + + registerReceiver(mReceiver, intentFilter); + + db = new DBAdapter(this); + createEmptyList(); + /* + * Need to enable the FM if it is not enabled earlier + */ + + sFmRadio = new FmRadio(this, this); +} + private void setButtonLabels() { + + //Log.d(TAG, "setButtonLabels"); + Iterator<HashMap<String, String>> stationIterator = stations.iterator(); + while (stationIterator.hasNext()) { + HashMap<String, String> item = (HashMap<String, String>) stationIterator.next(); + + //Log.d(TAG, "setButtonLabels item " + item); + String freq = item.get(ITEM_VALUE); + int iButtonNo = Integer.parseInt(item.get(ITEM_KEY)); + switch (iButtonNo) { + case 1: + if (freq.equals("")) + btnStation1.setEnabled(false); + else { + btnStation1.setEnabled(true); + btnStation1.setText(freq); + } + break; + case 2: + if (freq.equals("")) + btnStation2.setEnabled(false); + else { + btnStation2.setEnabled(true); + btnStation2.setText(freq); + } + break; + case 3: + if (freq.equals("")) + btnStation3.setEnabled(false); + else { + btnStation3.setEnabled(true); + btnStation3.setText(freq); + } + break; + case 4: + if (freq.equals("")) + btnStation4.setEnabled(false); + else { + btnStation4.setEnabled(true); + btnStation4.setText(freq); + } + break; + case 5: + if (freq.equals("")) + btnStation5.setEnabled(false); + else { + btnStation5.setEnabled(true); + btnStation5.setText(freq); + } + break; + case 6: + if (freq.equals("")) + btnStation6.setEnabled(false); + else { + btnStation6.setEnabled(true); + btnStation6.setText(freq); + } + break; + + } + + } + + } +private void startup() { + //Log.i(TAG, "startup"); + + + switch (sFmRadio.rxGetFMState()) { + /* FM is alreary enabled. Just update the UI. */ + case FmRadio.STATE_ENABLED: + Log.i(TAG, "FmRadio.STATE_ENABLED "); + // Fm app is on and we are entering from the other screens + loadDefaultConfiguration(); + setContentView(R.layout.fmrxmain); + initControls(); + setButtonLabels(); + if (sFmRadio.rxIsFMPaused()) { + Log.i(TAG, "FmRadio.STATE_PAUSE "); + mStatus = sFmRadio.resumeFm(); + if (mStatus == false) { + showAlert(this, "FmRadio", "Cannot resume Radio!!!!"); + } + } + + break; + + case FmRadio.STATE_DISABLED: + Log.i(TAG, "FmRadio.STATE_DISABLED "); + sdefaultSettingOn = false; + + mStatus = sFmRadio.rxEnable(); + if (mStatus == false) { + showAlert(this, "FmRadio", "Cannot enable Radio!!!!"); + + } + + else { /* Display the dialog till FM is enabled */ + pd = ProgressDialog.show(this, "Please wait..", + "Powering on Radio", true, false); + } + + break; + /* FM has not been started. Start the FM */ + case FmRadio.STATE_DEFAULT: + + Log.i(TAG, "FmRadio.STATE_DEFAULT "); + sdefaultSettingOn = false; + /* + * Make sure not to start the FM_Enable() again, if it has been + * already called before orientation change + */ + if (mFmInterrupted == false) { + + mStatus = sFmRadio.rxEnable(); + if (mStatus == false) { + showAlert(this, "FmRadio", "Cannot enable Radio!!!!"); + + } + + else { /* Display the dialog till FM is enabled */ + pd = ProgressDialog.show(this, "Please wait..", + "Powering on Radio", true, false); + } + } else { + Log.w(TAG, "mFmInterrupted is true dont call enable"); + + } + break; + } + } + + public void onServiceConnected() { + //Log.i(TAG, "onServiceConnected"); + mFmServiceConnected = true; + startup(); + } + + public void onServiceDisconnected() { + //Log.d(TAG, "Lost connection to service"); + mFmServiceConnected = false ; + sFmRadio = null; + } + + + /* + * Set the arraylist with the selected station name and display the name on + * main screen + */ + public static void UpdateRenameStation(int index, String name) { + txtStationName.setText(name.toString()); + // Store the name in the selected index in Arraylist + SetStation(index, "", name); + + } + + /* + * Set the arraylist and the buttons with the selected station and make the + * button enabled so that user can select it to select the stored stations + */ + public static void updateSetStation(int index, String freq, String name) { + switch (index) { + case 0: + if (freq.equals("")) + btnStation1.setEnabled(false); + else { + btnStation1.setEnabled(true); + btnStation1.setText(freq); + } + + break; + case 1: + if (freq.equals("")) + btnStation2.setEnabled(false); + else { + btnStation2.setEnabled(true); + btnStation2.setText(freq); + } + + break; + case 2: + if (freq.equals("")) + btnStation3.setEnabled(false); + else { + btnStation3.setEnabled(true); + btnStation3.setText(freq); + } + break; + case 3: + if (freq.equals("")) + btnStation4.setEnabled(false); + else { + btnStation4.setEnabled(true); + btnStation4.setText(freq); + } + + break; + case 4: + if (freq.equals("")) + btnStation5.setEnabled(false); + else { + btnStation5.setEnabled(true); + btnStation5.setText(freq); + } + + break; + case 5: + if (freq.equals("")) + btnStation6.setEnabled(false); + else { + btnStation6.setEnabled(true); + btnStation6.setText(freq); + } + break; + } + // Store the freq in the selected index in Arraylist + SetStation(index, freq, ""); + + } + + /* + * Unset the arraylist and the button with the empty station and make the + * button disabled so that user cannot select it + */ + + public static void updateUnSetStation(int index) { + switch (index) { + case 0: + btnStation1.setEnabled(false); + btnStation1.setText("1"); + break; + case 1: + btnStation2.setEnabled(false); + btnStation2.setText("2"); + break; + case 2: + btnStation3.setEnabled(false); + btnStation3.setText("3"); + break; + case 3: + btnStation4.setEnabled(false); + btnStation4.setText("4"); + break; + case 4: + + btnStation5.setEnabled(false); + btnStation5.setText("4"); + break; + case 5: + btnStation6.setEnabled(false); + btnStation6.setText("6"); + break; + } + + UnSetStation(index, "", ""); + + } + + /* Set particular station name or frequency in the stations arraylist */ + public static void SetStation(Integer index, String freq, String name) { + Log.i(TAG, "SetStation"); + Integer pos = new Integer(index.intValue() + 1); + try { + HashMap<String, String> item = stations.get(index.intValue()); + item.put(ITEM_KEY, pos.toString()); + // Update the name only + if ((freq.equals(""))) { + item.put(ITEM_NAME, name); + + // Empty name string is passed. Update the name + if ((name.equals(""))) + item.put(ITEM_NAME, name); + } + + // Update the frequency only + else if ((name.equals(""))) { + item.put(ITEM_VALUE, freq); + + } + stations.set(index.intValue(), item); + } catch (NullPointerException e) { + Log.e(TAG, "Tried to add null value"); + } + } + + /* UnSet particular station name and frequency in the stations arraylist */ + public static void UnSetStation(Integer index, String freq, String name) { + Log.i(TAG, "UnSetStation"); + Integer pos = new Integer(index.intValue() + 1); + try { + HashMap<String, String> item = stations.get(index.intValue()); + item.put(ITEM_KEY, pos.toString()); + item.put(ITEM_VALUE, freq); + item.put(ITEM_NAME, name); + stations.set(index.intValue(), item); + } catch (NullPointerException e) { + Log.e(TAG, "Tried to add null value"); + } + } + + /* Get particular station from the stations arraylist */ + + public static String GetStation(Integer index) { + Log.i(TAG, "GetStation"); + Integer pos = new Integer(index.intValue() + 1); + try { + HashMap<String, String> item = stations.get(index.intValue()); + Object freq = item.get(ITEM_VALUE); + Object name = item.get(ITEM_NAME); + if (name != null) { + txtStationName.setText(name.toString()); + } else { + Log.w(TAG, "There is no name in the HashMap."); + } + + if (freq != null) { + return freq.toString(); + } else { + Log.w(TAG, "There is no key in the HashMap."); + } + } catch (NullPointerException e) { + Log.e(TAG, "Tried to add null value"); + } + return null; + } + + /* + * Handler for all the FM related events. The events will be handled only + * when we are in the FM application main menu + */ + + private Handler mHandler = new Handler() { + StringBuilder sb ; + StringBuilder sbPs ; + + public void handleMessage(Message msg) { + + switch (msg.what) { + + /* + * After FM is enabled dismiss the progress dialog and display the + * FM main screen. Set the default volume. + */ + + case EVENT_FM_ENABLED: + + Log.i(TAG, "enter handleMessage ----EVENT_FM_ENABLED"); + if (pd != null) + pd.dismiss(); + + loadDefaultConfiguration(); + setContentView(R.layout.fmrxmain); + /* At Power up, FM should be always unmuted. */ + mToggleMute = false; + //Log.i(TAG, " handleMessage init mToggleMute" + mToggleMute); + initControls(); + setButtonLabels(); + imgFmPower.setImageResource(R.drawable.poweron); + + break; + + /* + * Update the icon on main screen with appropriate mono/stereo + * icon + */ + case EVENT_MONO_STEREO_CHANGE: + + Log.i(TAG, "enter handleMessage ---EVENT_MONO_STEREO_CHANGE"); + if (mMode == 0) { + imgFmMode.setImageResource(R.drawable.fm_stereo); + } else { + imgFmMode.setImageResource(R.drawable.fm_mono); + } + break; + + /* + * Update the icon on main screen with appropriate mono/stereo + * icon + */ + case EVENT_MONO_STEREO_DISPLAY: + + Log.i(TAG, "enter handleMessage ---EVENT_MONO_STEREO_DISPLAY"); + + Integer mode = (Integer) msg.obj; + //Log.i(TAG, "enter handleMessage ---mode" + mode.intValue()); + if (mode.intValue() == 0) { + imgFmMode.setImageResource(R.drawable.fm_stereo); + } else { + imgFmMode.setImageResource(R.drawable.fm_mono); + } + break; + + /* + * Update the icon on main screen with appropriate mute/unmute icon + */ + case EVENT_MUTE_CHANGE: + Log.i(TAG,"enter handleMessage ---EVENT_MUTE_CHANGE "); + + break; + + case EVENT_SEEK_STOPPED: + + Log.i(TAG, "enter handleMessage ---EVENT_SEEK_STOPPED"); + Integer seekFreq = (Integer) msg.obj; + //Log.i(TAG, "enter handleMessage ----EVENT_SEEK_STOPPED seekFreq" + seekFreq); + lastTunedFrequency = (float) seekFreq / 1000; + txtStatusMsg.setText(R.string.playing); + txtFmRxTunedFreq.setText(lastTunedFrequency.toString()); + + break; + + case EVENT_FM_DISABLED: + + Log.i(TAG, "enter handleMessage ----EVENT_FM_DISABLED"); + + /* + * we have exited the FM App. Set the sdefaultSettingOn flag to + * false Save the default configuration in the preference + */ + sdefaultSettingOn = false; + saveDefaultConfiguration(); + finish(); + break; + + case EVENT_SEEK_STARTED: + + Integer freq = (Integer) msg.obj; + //Log.i(TAG, "enter handleMessage ----EVENT_SEEK_STARTED freq" + freq); + lastTunedFrequency = (float) freq / 1000; + txtStatusMsg.setText(R.string.playing); + txtFmRxTunedFreq.setText(lastTunedFrequency.toString()); + // clear the RDS text + txtRadioText.setText(null); + + // clear the PS text + txtPsText.setText(null); + + /* + * Seek up/down will be completed here. So set the state to + * idle, so that user can seek to other frequency. + */ + + mSeekState = SEEK_REQ_STATE_IDLE; + + break; + + /* + * Set the default band , if the fm app is getting started first + * time + */ + case EVENT_VOLUME_CHANGE: + Log.i(TAG, "enter handleMessage ----EVENT_VOLUME_CHANGE"); + + /* + * volume change will be completed here. So set the state to + * idle, so that user can set other volume. + */ + mVolState = VOL_REQ_STATE_IDLE; + /* + * Setting the default band after the volume change when FM app + * is started for the first time + */ + if (sdefaultSettingOn == false) { + /* Set the default band */ + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + mStatus = sFmRadio.rxSetBand(sBand); + if (mStatus == false) { + showAlert(getParent(), "FmRadio","Not able to setband!!!!"); + } else { + lastTunedFrequency = (float) lastTunedFrequency ; + mStatus = sFmRadio.rxTune_nb((int)(lastTunedFrequency.floatValue()* 1000)); + if (mStatus == false) { + showAlert(getParent(), "FmRadio","Not able to tune!!!!"); + } + } + + } else { + // Code for non blocking call + mStatus = sFmRadio.rxSetBand_nb(sBand); + if (mStatus == false) { + showAlert(getParent(), "FmRadio","Not able to setband!!!!"); + } + } + + + + } + break; + + case EVENT_COMPLETE_SCAN_PROGRESS: + Log.i(TAG, "enter handleMessage ----EVENT_COMPLETE_SCAN_PROGRESS"); + + Integer progress = (Integer) msg.obj; + // Log.i(TAG,"enter handleMessage ----EVENT_COMPLETE_SCAN_PROGRESS progress"+ progress); + break; + + /* + * enable audio routing , if the fm app is getting started first + * time + */ + case EVENT_TUNE_COMPLETE: + Integer tuneFreq = (Integer) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_TUNE_COMPLETE tuneFreq" + + tuneFreq); + lastTunedFrequency = (float) tuneFreq / 1000; + txtStatusMsg.setText(R.string.playing); + txtFmRxTunedFreq.setText(lastTunedFrequency.toString()); + // clear the RDS text + txtRadioText.setText(null); + // clear the PS text + txtPsText.setText(null); + + //Log.d(TAG, "sdefaultSettingOn" + sdefaultSettingOn); + + /* + * Enable the Audio routing after the tune complete , when FM + * app is started for the first time or after reentering the Fm + * app + */ + if (sdefaultSettingOn == false) { +/* + mStatus = sFmRadio.rxEnableAudioRouting(); + if (mStatus == false) { + showAlert(getParent(), "FmRadio", + "Not able to enable audio!!!!"); + } +*/ + /* + * The default setting for the FMApp are completed here. If + * the user selects back and goes out of the FM App, when he + * reenters we dont have to do the default configurations + */ + sdefaultSettingOn = true; + } + + // clear the RDS text + txtRadioText.setText(null); + + // clear the PS text + txtPsText.setText(null); + + break; + + /* Display the RDS text on UI */ + case EVENT_RDS_TEXT: + Log.i(TAG, "enter handleMessage ----EVENT_RDS_TEXT"); + if (FM_SEND_RDS_IN_BYTEARRAY == true) { + byte[] rdsText = (byte[]) msg.obj; + + for (int i = 0; i < 4; i++) + Log.i(TAG, "rdsText" + rdsText[i]); + } else { + String rds = (String) msg.obj; + Log.i(TAG, "enter handleMessage ----EVENT_RDS_TEXT rds" + rds); + sb = new StringBuilder("[RDS] "); + sb.append(rds); + Log.i(TAG, "enter handleMessage ----EVENT_RDS_TEXT sb.toString()"+ sb.toString()); + txtRadioText.setText(sb.toString()); + } + break; + + /* Display the RDS text on UI */ + case EVENT_PI_CODE: + String pi = (String) msg.obj; + Log.i(TAG, "enter handleMessage ----EVENT_PI_CODE rds" + pi); + + break; + + case EVENT_SET_CHANNELSPACE: + Log.i(TAG, "enter handleMessage ----EVENT_SET_CHANNELSPACE"); + break; + + + case EVENT_GET_CHANNEL_SPACE_CHANGE: + Log.i(TAG, "enter handleMessage ----EVENT_GET_CHANNEL_SPACE_CHANGE"); + Long gChSpace = (Long) msg.obj; + //Log.d(TAG, "enter handleMessage ----gChSpace" + gChSpace); + break; + + /* tune to default frequency after the band change callback . */ + + case EVENT_BAND_CHANGE: + Log.i(TAG, "enter handleMessage ----EVENT_BAND_CHANGE"); + /* + * Tune to the last stored frequency at the + * enable/re-enable,else tune to the default frequency when band + * changes + */ + + if (sdefaultSettingOn == true) { + /* Set the default frequency */ + if (sBand == FM_BAND_EUROPE_US) + lastTunedFrequency = (float) DEFAULT_FREQ_EUROPE; + else + lastTunedFrequency = (float) DEFAULT_FREQ_JAPAN; + } + + mStatus = sFmRadio.rxTune_nb((int)(lastTunedFrequency.floatValue()*1000)); + if (mStatus == false) { + showAlert(getParent(), "FmRadio", "Not able to tune!!!!"); + } + + break; + + /* Enable RDS system after enale RDS callback . */ + + case EVENT_ENABLE_RDS: + Log.i(TAG, "enter handleMessage ----EVENT_ENABLE_RDS"); + break; + + /* Set RSSI after SET_RDS_AF callback */ + case EVENT_SET_RDS_AF: + Log.i(TAG, "enter handleMessage ----EVENT_SET_RDS_AF"); + break; + /* Set RDS AF after SET_RDS_SYSTEM callback */ + case EVENT_SET_RDS_SYSTEM: + Log.i(TAG, "enter handleMessage ----EVENT_SET_RDS_SYSTEM"); + break; + /* Set RSSI after disable RDS callback */ + case EVENT_DISABLE_RDS: + Log.i(TAG, "enter handleMessage ----EVENT_DISABLE_RDS"); + txtPsText.setText(null); + txtRadioText.setText(null); + break; + + case EVENT_SET_DEEMP_FILTER: + Log.i(TAG, "enter handleMessage ----EVENT_SET_DEEMP_FILTER"); + break; + + /* Display the PS text on UI */ + case EVENT_PS_CHANGED: + Log.i(TAG, "enter handleMessage ----EVENT_PS_CHANGED"); + + if (FM_SEND_RDS_IN_BYTEARRAY == true) { + byte[] psName = (byte[]) msg.obj; + + for (int i = 0; i < 4; i++) + Log.i(TAG, "psName" + psName[i]); + } else { + String ps = (String) msg.obj; + Log.i(TAG, "ps String is " + ps); + sbPs = new StringBuilder("[PS] "); + sbPs.append(ps); + //Log.i(TAG, "enter handleMessage ----EVENT_PS_CHANGED sbPs.toString()"+ sbPs.toString()); + txtPsText.setText(sbPs.toString()); + } + + break; + + case EVENT_SET_RSSI_THRESHHOLD: + Log.i(TAG, "enter handleMessage ----EVENT_SET_RSSI_THRESHHOLD"); + /* + * All the configurations will be completed here. So set the + * state to idle, so that user can configure again + */ + configurationState = CONFIGURATION_STATE_IDLE; + break; + case EVENT_SET_RF_DEPENDENT_MUTE: + Log.i(TAG,"enter handleMessage ----EVENT_SET_RF_DEPENDENT_MUTE"); + break; + + case EVENT_COMPLETE_SCAN_STOP: + Log.i(TAG, "enter handleMessage ----EVENT_COMPLETE_SCAN_STOP"); + break; + + case EVENT_COMPLETE_SCAN_DONE: + Log.i(TAG, "enter handleMessage ----EVENT_COMPLETE_SCAN_DONE"); + + int[] channelList = (int[]) msg.obj; + int noOfChannels = (int) msg.arg2; + + Log.i(TAG, "noOfChannels" + noOfChannels); + + for (int i = 0; i < noOfChannels; i++) + Log.i(TAG, "channelList" + channelList[i]); + + break; + + case EVENT_GET_BAND : + + Long gBand = (Long) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_BAND"); + Log.d(TAG, "enter handleMessage ----gBand" + gBand); + break; + + case EVENT_GET_FREQUENCY : + + Integer gFreq = (Integer) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_FREQUENCY"); + //Log.d(TAG, "enter handleMessage ----gFreq" + gFreq); + break; + case EVENT_GET_VOLUME : + Long gVol = (Long) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_VOLUME"); + Log.d(TAG, "enter handleMessage ----gVol" + gVol); + break; + case EVENT_GET_MODE : + Long gMode = (Long) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_MODE"); + Log.d(TAG, "enter handleMessage ----gMode" + gMode); + break; + case EVENT_GET_MUTE_MODE : + + Long gMuteMode = (Long) msg.obj; + + if(gMuteMode ==(long) FM_UNMUTE) + imgFmVolume.setImageResource(R.drawable.fm_volume); + else if (gMuteMode ==(long) FM_MUTE) + imgFmVolume.setImageResource(R.drawable.fm_volume_mute); + + Log.i(TAG,"enter handleMessage ----EVENT_GET_MUTE_MODE"); + //Log.d(TAG, "enter handleMessage ----gMuteMode" + gMuteMode); + break; + case EVENT_GET_RF_MUTE_MODE : + + Long gRfMuteMode = (Long) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_RF_MUTE_MODE"); + //Log.d(TAG, "enter handleMessage ----gRfMuteMode" + gRfMuteMode); + break; + case EVENT_GET_RSSI_THRESHHOLD : + Long gRssi = (Long) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_RSSI_THRESHHOLD"); + Log.d(TAG, "enter handleMessage ----gRssi" + gRssi); + break; + + case EVENT_GET_RSSI : + Integer rssi = (Integer) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_RSSI"); + Log.d(TAG, "enter handleMessage ----rssi" + rssi); + break; + case EVENT_GET_DEEMPHASIS_FILTER : + Long gFilter= (Long) msg.obj; + Log.i(TAG,"enter handleMessage ----EVENT_GET_DEEMPHASIS_FILTER"); + Log.d(TAG, "enter handleMessage ----gFilter" + gFilter); + break; + + case EVENT_GET_RDS_SYSTEM : + Long gRdsSys= (Long) msg.obj; + Log.i(TAG, "enter handleMessage ----EVENT_GET_RDS_SYSTEM"); + Log.d(TAG, "enter handleMessage ----gRdsSys" + gRdsSys); + break; + case EVENT_GET_RDS_GROUPMASK : + Long gRdsMask= (Long) msg.obj; + Log.i(TAG, "enter handleMessage ----EVENT_GET_RDS_GROUPMASK"); + Log.d(TAG, "enter handleMessage ----gRdsMask" + gRdsMask); + break; + + case EVENT_MASTER_VOLUME_CHANGED: + Integer vol = (Integer) msg.obj; + mVolume = vol; + Log.i(TAG, "enter handleMessage ----EVENT_MASTER_VOLUME_CHANGED"); + Log.d(TAG, "enter handleMessage ----mVolume" + vol); + } + } + }; + + /* Display alert dialog */ + public void showAlert(Context context, String title, String msg) { + + new AlertDialog.Builder(context).setTitle(title).setIcon( + android.R.drawable.ic_dialog_alert).setMessage(msg) + .setNegativeButton(android.R.string.cancel, null).show(); + + } + + + private void setRdsConfig() { + Log.i(TAG, "setRdsConfig()-entered"); + configurationState = CONFIGURATION_STATE_PENDING; + SharedPreferences fmConfigPreferences = getSharedPreferences( + "fmConfigPreferences", MODE_PRIVATE); + + // Set Band + int band = fmConfigPreferences.getInt(BAND, DEFAULT_BAND); + Log.i(TAG, "setRdsConfig()--- band= " + band); + if (band != sBand) // If Band is same as the one set already donot set + // it again + { + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + mStatus = sFmRadio.rxSetBand(band); + if (mStatus == false) { + Log.e(TAG, "setRdsConfig()-- setBand ->Erorr"); + showAlert(this, "FmRadio", + "Cannot setBand to selected Value!!!!"); + } else { + sBand = band; + if (sdefaultSettingOn == true) { + /* Set the default frequency */ + if (sBand == FM_BAND_EUROPE_US) + lastTunedFrequency = (float) DEFAULT_FREQ_EUROPE; + else + lastTunedFrequency = (float) DEFAULT_FREQ_JAPAN; + } + + lastTunedFrequency = (float) lastTunedFrequency ; + mStatus = sFmRadio.rxTune_nb((int)(lastTunedFrequency.floatValue()*1000)); + if (mStatus == false) { + showAlert(getParent(), "FmRadio", "Not able to tune!!!!"); + } + + } + + } + + else + { + + mStatus = sFmRadio.rxSetBand_nb(band); + if (mStatus == false) { + Log.e(TAG, "setRdsConfig()-- setBand ->Erorr"); + showAlert(this, "FmRadio", + "Cannot setBand to selected Value!!!!"); + } else { + sBand = band; + if (sdefaultSettingOn == true) { + /* Set the default frequency */ + if (sBand == FM_BAND_EUROPE_US) + lastTunedFrequency = (float) DEFAULT_FREQ_EUROPE; + else + lastTunedFrequency = (float) DEFAULT_FREQ_JAPAN; + } + + } + } +} + + + // Set De-emp Filter + int deEmp = fmConfigPreferences.getInt(DEEMP, DEFAULT_DEEMP); + if (mDeEmpFilter != deEmp)// If De-Emp filter is same as the one set + // already donot set it again + { + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxSetDeEmphasisFilter(deEmp); + else + mStatus = sFmRadio.rxSetDeEmphasisFilter_nb(deEmp); + + Log.i(TAG, "setRdsConfig()--- DeEmp= " + deEmp); + + if (mStatus == false) { + Log.e(TAG, "setRdsConfig()-- setDeEmphasisFilter ->Erorr"); + showAlert(this, "FmRadio", + "Cannot set De-Emp Fileter to selected Value!!!!"); + + } + mDeEmpFilter = deEmp; + + } + + + // Set Mode + int mode = fmConfigPreferences.getInt(MODE, DEFAULT_MODE); + if (mMode != mode)// If Mode is same as the one set already donot set it + // again + { + + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxSetMonoStereoMode(mode); + else + mStatus = sFmRadio.rxSetMonoStereoMode_nb(mode); + if (mStatus == false) { + showAlert(this, "FmRadio", "Not able to setmode!!!!"); + } else { + mMode = mode; + if (mMode == 0) { + imgFmMode.setImageResource(R.drawable.fm_stereo); + } else { + imgFmMode.setImageResource(R.drawable.fm_mono); + } + } + + } + + + /** Set channel spacing to the one selected by the user */ + int channelSpace = fmConfigPreferences.getInt(CHANNELSPACE, + DEFAULT_CHANNELSPACE); + Log.i(TAG, "setChannelSpacing()--- channelSpace= " + channelSpace); + if (channelSpace != sChannelSpace) // If channelSpace is same as the one + // set already donot set + // it again + { + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxSetChannelSpacing(channelSpace); + else + mStatus = sFmRadio.rxSetChannelSpacing_nb(channelSpace); + + if (mStatus == false) { + Log.e(TAG, "setChannelSpacing()-- setChannelSpacing ->Erorr"); + showAlert(this, "FmRadio", + "Cannot setChannelSpacing to selected Value!!!!"); + } + sChannelSpace = channelSpace; + } + + + // set RDS related configuration + boolean rdsEnable = fmConfigPreferences.getBoolean(RDS, DEFAULT_RDS); + Log.i(TAG, "setRDS()--- rdsEnable= " + rdsEnable); + if (mRds != rdsEnable) { + + if (rdsEnable) { + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxEnableRds(); + else + mStatus = sFmRadio.rxEnableRds_nb(); + if (mStatus == false) { + Log.e(TAG, "setRDS()-- enableRds() ->Erorr"); + showAlert(this, "FmRadio", "Cannot enable RDS!!!!"); + } + + } else { + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxDisableRds(); + else + mStatus = sFmRadio.rxDisableRds_nb(); + + if (mStatus == false) { + Log.e(TAG, "setRDS()-- disableRds() ->Erorr"); + showAlert(this, "FmRadio", "Cannot disable RDS!!!!"); + } else { + Log.e(TAG, "setRDS()-- disableRds() ->success"); + /* clear the PS and RDS text */ + txtPsText.setText(null); + txtRadioText.setText(null); + } + } + mRds = rdsEnable; + } + + // setRdssystem + int rdsSystem = fmConfigPreferences.getInt(RDSSYSTEM, + DEFAULT_RDS_SYSTEM); + if (DBG) + Log.d(TAG, "setRdsSystem()--- rdsSystem= " + rdsSystem); + if (mRdsSystem != rdsSystem) { + // Set RDS-SYSTEM if a new choice is made by the user + + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxSetRdsSystem(fmConfigPreferences.getInt( + RDSSYSTEM, DEFAULT_RDS_SYSTEM)); + else + mStatus = sFmRadio.rxSetRdsSystem_nb(fmConfigPreferences.getInt( + RDSSYSTEM, DEFAULT_RDS_SYSTEM)); + + if (mStatus == false) { + Log.e(TAG, " setRdsSystem()-- setRdsSystem ->Erorr"); + showAlert(this, "FmRadio", + "Cannot set Rds System to selected Value!!!!"); + } + mRdsSystem = rdsSystem; + } + + boolean rdsAfSwitch = fmConfigPreferences.getBoolean(RDSAF, + DEFAULT_RDS_AF); + int rdsAf = 0; + rdsAf = rdsAfSwitch ? 1 : 0; + if (DBG) + Log.d(TAG, "setRdsAf()--- rdsAfSwitch= " + rdsAf); + if (mRdsAf != rdsAfSwitch) { + // Set RDS-AF if a new choice is made by the user + + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxSetRdsAfSwitchMode(rdsAf); + else + mStatus = sFmRadio.rxSetRdsAfSwitchMode_nb(rdsAf); + if (mStatus == false) { + Log.e(TAG, "setRdsAf()-- setRdsAfSwitchMode(1) ->Erorr"); + showAlert(this, "FmRadio", "Cannot set RDS AF Mode ON!!!!"); + } + mRdsAf = rdsAfSwitch; + } + // Set Rssi + int rssiThreshHold = fmConfigPreferences.getInt(RSSI, DEFAULT_RSSI); + Log.i(TAG, "setRssi()-ENTER --- rssiThreshHold= " + rssiThreshHold); + + // Set RSSI if a new value is entered by the user + + if (MAKE_FM_APIS_BLOCKING == true) + mStatus = sFmRadio.rxSetRssiThreshold(rssiThreshHold); + else + mStatus = sFmRadio.rxSetRssiThreshold_nb(rssiThreshHold); + + if (mStatus == false) { + showAlert(this, "FmRadio", "Not able to setRssiThreshold!!!!"); + } + + mRssi = rssiThreshHold; + + + Log.i(TAG, "setRdsConfig()-exit"); + + } + + /* Load the Default values from the preference when the application starts */ + private void loadDefaultConfiguration() { + + Log.i(TAG, "loadDefaultConfiguration()-entered"); + SharedPreferences fmConfigPreferences = getSharedPreferences("fmConfigPreferences", + MODE_PRIVATE); + + if (mPreset) + saveObject(); + + /* Read the stations stored in DB and update the UI */ + try { + db.open(); + Cursor c = db.getStation(1); + if (c != null && c.moveToFirst()) + mIsDbPresent = true; + else + mIsDbPresent = false; + c.close(); + db.close(); + } catch (SQLException e) { + mIsDbPresent = false; + } catch (Exception ex) { + mIsDbPresent = false; + } + + if (mIsDbPresent == false) { + + Log.d(TAG, " mIsDbPresent writeobject" + mIsDbPresent); + writeObject(); + mIsDbPresent = true; + } else { + Log.d(TAG, " mIsDbPresent readobject" + mIsDbPresent); + readObject(); + } + + Log.d(TAG, " mIsDbPresent " + mIsDbPresent); + sBand = fmConfigPreferences.getInt(BAND, DEFAULT_BAND); + lastTunedFrequency = fmConfigPreferences.getFloat(FREQUENCY, + (sBand == FM_BAND_EUROPE_US ? DEFAULT_FREQ_EUROPE + : DEFAULT_FREQ_JAPAN)); + mMode = fmConfigPreferences.getInt(MODE, DEFAULT_MODE); + mToggleMute = fmConfigPreferences.getBoolean(MUTE, false); + mRdsState = fmConfigPreferences.getBoolean(RDS, false); + + if (DBG) + Log.d(TAG, " Load default band " + sBand + "default volume" + mVolume + "last fre" + + lastTunedFrequency + "mode" + mMode + "mToggleMute" + mToggleMute +"mRdsState"+mRdsState); + + } + + private void createEmptyList() { + + Log.d(TAG, " createEmptyList "); + stations = new ArrayList<HashMap<String, String>>(6); + for (int i = 1; i < 7; i++) { + HashMap<String, String> stationsMap = new HashMap<String, String>(); + + stationsMap.put(ITEM_KEY, String.valueOf(i)); + stationsMap.put(ITEM_VALUE, ""); + stationsMap.put(ITEM_NAME, ""); + stations.add(i - 1, stationsMap); + } + + } + /* Save the Default values to the preference when the application exits */ + private void saveDefaultConfiguration() { + Log.i(TAG, "saveDefaultConfiguration()-Entered"); + + SharedPreferences fmConfigPreferences = getSharedPreferences( + "fmConfigPreferences", MODE_PRIVATE); + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + editor.putInt(BAND, sBand); + editor.putBoolean(MUTE, mToggleMute); + editor.putFloat(FREQUENCY, lastTunedFrequency); + if (DBG) + Log.d(TAG, " save default band " + sBand + "default volume" + mVolume + + "last fre" + lastTunedFrequency+"mToggleMute"+mToggleMute); + /* Write the stations stored to text file */ + saveObject(); + editor.commit(); + } + + /* Read the Stations from the text file in file system */ + void readObject() { + Log.i(TAG, "readObject "); + + db.open(); + Cursor c = db.getAllStations(); + int count = c.getCount(); + + Log.i(TAG, "readObject cursor count " + count); + int iCount = 0; + if (c.moveToFirst()) { + do { + + HashMap<String, String> stations1 = new HashMap<String, String>(); + + stations1.put(ITEM_KEY, c.getString(1)); + stations1.put(ITEM_VALUE, c.getString(2)); + stations1.put(ITEM_NAME, c.getString(3)); + stations.set(iCount, stations1); + iCount++; + + } while (c.moveToNext()); + + } else + Toast.makeText(this, "No station found", Toast.LENGTH_LONG).show(); + c.close(); + db.close(); + + } + + /* Write the Stations to the text file in file system */ + void writeObject() { + Log.i(TAG, "writeObject "); + + db.open(); + long id; + id = db.insertStation("1", "", ""); + id = db.insertStation("2", "", " "); + id = db.insertStation("3", "", ""); + id = db.insertStation("4", "", " "); + id = db.insertStation("5", "", " "); + id = db.insertStation("6", "", " "); + db.close(); + + } + + void saveObject() { + + Log.i(TAG, "enter saveObject"); + db.open(); + Iterator iterator = stations.iterator(); + + while (iterator.hasNext()) { + HashMap<String, String> item = (HashMap<String, String>) iterator.next(); + Object v = item.get(ITEM_VALUE); + Object n = item.get(ITEM_NAME); + Object i = item.get(ITEM_KEY); + + try { + mIndex = Integer.parseInt(i.toString()); + updateSetStation((mIndex - 1), v.toString(), n.toString()); + db.updateStation(mIndex, i.toString(), v.toString(), n.toString()); + } catch (Exception e) { + Log.e(TAG, "Exception"); + e.printStackTrace(); + } + + } + + db.close(); + + } + /* Initialise all the widgets */ + private void initControls() { + /** + * Start FM RX + */ + Log.i(TAG, "enter initControls"); + + imgFmPower = (ImageView) findViewById(R.id.imgPower); + imgFmPower.setOnClickListener(this); + + imgFmMode = (ImageView) findViewById(R.id.imgMode); + if (mMode == 0) { + Log.i(TAG, " setting stereo icon" +mMode); + imgFmMode.setImageResource(R.drawable.fm_stereo); + } else { + Log.i(TAG, " setting mono icon" +mMode); + imgFmMode.setImageResource(R.drawable.fm_mono); + } + + imgFmVolume = (ImageView) findViewById(R.id.imgMute); + imgFmVolume.setOnClickListener(this); + + if (mToggleMute == true) { + imgFmVolume.setImageResource(R.drawable.fm_volume_mute); + Log.i(TAG, " initControls mute" +mToggleMute); + } else { + imgFmVolume.setImageResource(R.drawable.fm_volume); + Log.i(TAG, " initControls mute" +mToggleMute); + } + + + imgFmSeekUp = (ImageButton) findViewById(R.id.imgseekup); + imgFmSeekUp.setOnClickListener(this); + + imgFmSeekDown = (ImageButton) findViewById(R.id.imgseekdown); + imgFmSeekDown.setOnClickListener(this); + + txtFmRxTunedFreq = (TextView) findViewById(R.id.txtRxFreq); + txtFmRxTunedFreq.setText(lastTunedFrequency.toString()); + + txtStatusMsg = (TextView) findViewById(R.id.txtStatusMsg); + txtRadioText = (TextView) findViewById(R.id.txtRadioText); + txtPsText = (TextView) findViewById(R.id.txtPsText); + + txtStationName = (TextView) findViewById(R.id.txtStationName); + txtStationName.setText(null); + + btnStation1 = (Button) findViewById(R.id.station1); + btnStation1.setOnClickListener(this); + btnStation1.setEnabled(false); + + btnStation2 = (Button) findViewById(R.id.station2); + btnStation2.setOnClickListener(this); + btnStation2.setEnabled(false); + + btnStation3 = (Button) findViewById(R.id.station3); + btnStation3.setOnClickListener(this); + btnStation3.setEnabled(false); + + btnStation4 = (Button) findViewById(R.id.station4); + btnStation4.setOnClickListener(this); + btnStation4.setEnabled(false); + + btnStation5 = (Button) findViewById(R.id.station5); + btnStation5.setOnClickListener(this); + btnStation5.setEnabled(false); + + btnStation6 = (Button) findViewById(R.id.station6); + btnStation6.setOnClickListener(this); + btnStation6.setEnabled(false); + + // Get the notification manager service. + mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + + } + + /** Adds Delay of 3 seconds */ + private void insertDelayThread() { + + new Thread() { + public void run() { + try { + // Add some delay to make sure all configuration has been + // completed. + sleep(3000); + } catch (Exception e) { + Log.e(TAG, "InsertDelayThread()-- Exception !!"); + } + // Dismiss the Dialog + configPd.dismiss(); + } + }.start(); + + } + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + Log.i(TAG, "onActivityResult"); + switch (requestCode) { + case (ACTIVITY_PRESET): { + if (resultCode == Activity.RESULT_OK) { + Log.i(TAG, "Prests saved"); + saveObject(); + + } + } + break; + case (ACTIVITY_TUNE): { + if (resultCode == Activity.RESULT_OK && data != null) { + + Bundle extras = data.getExtras(); + if (extras != null) { + + lastTunedFrequency = (float) extras.getFloat(FREQ_VALUE, 0); + txtFmRxTunedFreq.setText(lastTunedFrequency.toString()); + mStatus = sFmRadio.rxTune_nb((int)(lastTunedFrequency.floatValue()*1000)); + if (mStatus == false) { + showAlert(this, "FmRadio", "Not able to tune!!!!"); + } + } + } + } + break; + + case (ACTIVITY_CONFIG): { + if (resultCode == Activity.RESULT_OK) { + Log.i(TAG, "ActivityFmRdsConfig configurationState " + + configurationState); + if(configurationState == CONFIGURATION_STATE_IDLE) + { + + + setRdsConfig(); + configPd = ProgressDialog.show(this, "Please wait..", + "Applying new Configuration", true, false); + // The delay is inserted to make sure all the configurations + // have been completed. + insertDelayThread(); + } + } + + } + break; + + } + } + + public boolean onKeyDown(int keyCode, KeyEvent event) { + + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_DOWN: + + return true; + case KeyEvent.KEYCODE_DPAD_UP: + + return true; + case KeyEvent.KEYCODE_BACK: + + saveDefaultConfiguration(); + finish(); + return true; + /* Keys A to L are mapped to different get APIs for Testing */ + case KeyEvent.KEYCODE_A: + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getVolume() returned volume = " + + sFmRadio.rxGetVolume()); + + } else { + // Code for non blocking call + Log.i(TAG, "Testing getVolume_nb() returned volume = " + + sFmRadio.rxGetVolume_nb()); + + } + + + return true; + + case KeyEvent.KEYCODE_B: + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getTunedFrequency() returned Tuned Freq = " + + sFmRadio.rxGetTunedFrequency()); + + } else { + // Code for non blocking call + Log.i(TAG, "Testing getTunedFrequency_nb() returned Tuned Freq = " + + sFmRadio.rxGetTunedFrequency_nb()); + + } + + return true; + + case KeyEvent.KEYCODE_C: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getRssiThreshold() returned RSSI thrshld = " + + sFmRadio.rxGetRssiThreshold()); + } else { + // Code for non blocking call + Log.i(TAG, "Testing getRssiThreshold_nb() returned RSSI thrshld = " + + sFmRadio.rxGetRssiThreshold_nb()); + } + + return true; + + case KeyEvent.KEYCODE_D: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getBand() returned Band = " + + sFmRadio.rxGetBand()); + } else { + // Code for non blocking call + Log.i(TAG, "Testing getBand_nb() returned Band = " + + sFmRadio.rxGetBand_nb()); + } + + return true; + + case KeyEvent.KEYCODE_E: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getDeEmphasisFilter() returned De-emp = " + + sFmRadio.rxGetDeEmphasisFilter()); + } else { + // Code for non blocking call + Log.i(TAG, "Testing getDeEmphasisFilter_nb() returned De-emp = " + + sFmRadio.rxGetDeEmphasisFilter_nb()); + } + + return true; + + case KeyEvent.KEYCODE_F: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getMonoStereoMode() returned MonoStereo = " + + sFmRadio.rxGetMonoStereoMode()); + + } else { + // Code for non blocking call + Log.i(TAG, "Testing getMonoStereoMode_nb() returned MonoStereo = " + + sFmRadio.rxGetMonoStereoMode_nb()); + + } + + return true; + + case KeyEvent.KEYCODE_G: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getMuteMode() returned MuteMode = " + + sFmRadio.rxGetMuteMode()); + } else { + // Code for non blocking call + Log.i(TAG, "Testing getMuteMode_nb() returned MuteMode = " + + sFmRadio.rxGetMuteMode_nb()); + } + + return true; + + case KeyEvent.KEYCODE_H: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, + "Testing getRdsAfSwitchMode() returned RdsAfSwitchMode = " + + sFmRadio.rxGetRdsAfSwitchMode()); + } else { + // Code for non blocking call + Log.i(TAG, + "Testing getRdsAfSwitchMode_nb() returned RdsAfSwitchMode = " + + sFmRadio.rxGetRdsAfSwitchMode_nb()); + } + + return true; + + case KeyEvent.KEYCODE_I: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getRdsGroupMask() returned RdsGrpMask = " + + sFmRadio.rxGetRdsGroupMask()); + } else { + // Code for non blocking call + Log.i(TAG, "Testing getRdsGroupMask_nb() returned RdsGrpMask = " + + sFmRadio.rxGetRdsGroupMask_nb()); + } + + return true; + + case KeyEvent.KEYCODE_J: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, "Testing getRdsSystem() returned Rds System = " + + sFmRadio.rxGetRdsSystem()); + } else { + // Code for non blocking call + Log.i(TAG, "Testing getRdsSystem_nb() returned Rds System = " + + sFmRadio.rxGetRdsSystem_nb()); + } + + return true; + + case KeyEvent.KEYCODE_K: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, + "Testing getRfDependentMuteMode() returned RfDepndtMuteMode = " + + sFmRadio.rxGetRfDependentMuteMode()); + } else { + // Code for non blocking call + Log.i(TAG, + "Testing getRfDependentMuteMode_nb() returned RfDepndtMuteMode = " + + sFmRadio.rxGetRfDependentMuteMode_nb()); + } + + return true; + + case KeyEvent.KEYCODE_L: + + if (MAKE_FM_APIS_BLOCKING == true) { + + LayoutInflater inflater = getLayoutInflater(); + View layout = inflater.inflate(R.layout.toast, + (ViewGroup) findViewById(R.id.toast_layout)); + TextView text = (TextView) layout.findViewById(R.id.text); + text.setText("The current Rssi " + sFmRadio.rxGetRssi()); + + Toast toast = new Toast(getApplicationContext()); + toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL, 0, 0); + toast.setDuration(Toast.LENGTH_LONG); + toast.setView(layout); + toast.show(); + } + else + { + Log.i(TAG, + "Testing rxGetRssi_nb() returned = " + + sFmRadio.rxGetRssi_nb()); + } + + return true; + + case KeyEvent.KEYCODE_M: + Log.i(TAG, "Testing isValidChannel() returned isValidChannel = " + + sFmRadio.rxIsValidChannel()); + + return true; + + case KeyEvent.KEYCODE_N: + Log.i(TAG, "Testing getFwVersion() returned getFwVersion = " + + sFmRadio.rxGetFwVersion()); + + return true; + + case KeyEvent.KEYCODE_O: + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, + "Testing getChannelSpacing() returned getChannelSpacing = " + + sFmRadio.rxGetChannelSpacing()); + } else { + // Code for non blocking call + Log.i(TAG, + "Testing getChannelSpacing_nb() returned getChannelSpacing = " + + sFmRadio.rxGetChannelSpacing_nb()); + } + + + return true; + + case KeyEvent.KEYCODE_P: + Log.i(TAG, "Testing completescan()"); + sFmRadio.rxCompleteScan_nb(); + return true; + + case KeyEvent.KEYCODE_Q: + + if (MAKE_FM_APIS_BLOCKING == true) { + Log.i(TAG, + "Testing getCompleteScanProgress() returned scan progress = " + + sFmRadio.rxGetCompleteScanProgress()); + } + else + { + Log.i(TAG, + "Testing getCompleteScanProgress() returned scan progress = " + + sFmRadio.rxGetCompleteScanProgress_nb()); + } + + return true; + + case KeyEvent.KEYCODE_R: + if (MAKE_FM_APIS_BLOCKING == true) { + Log.i(TAG, "Testing stopCompleteScan() returned status = " + + sFmRadio.rxStopCompleteScan()); + } + else + { + Log.i(TAG, "Testing stopCompleteScan() returned status = " + + sFmRadio.rxStopCompleteScan_nb()); + } + + return true; + + case KeyEvent.KEYCODE_S: + +if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + Log.i(TAG, + "Testing setRfDependentMuteMode() returned RfDepndtMuteMode = " + + sFmRadio.rxSetRfDependentMuteMode(1)); + } else { + // Code for non blocking call + Log.i(TAG, + "Testing setRfDependentMuteMode() returned RfDepndtMuteMode = " + + sFmRadio.rxSetRfDependentMuteMode_nb(1)); + } + + return true; + + } + + return false; + } + + /* Get the stored frequency from the arraylist and tune to that frequency */ + void tuneStationFrequency(String text) { + try { + float iFreq = Float.parseFloat(text); + if (iFreq != 0) { + lastTunedFrequency = (float) iFreq ; + if (DBG) + Log.d(TAG, "lastTunedFrequency" + lastTunedFrequency); + mStatus = sFmRadio.rxTune_nb((int)(lastTunedFrequency.floatValue()*1000)); + if (mStatus == false) { + showAlert(getParent(), "FmRadio", "Not able to tune!!!!"); + } + } else { + + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid frequency!!").setNegativeButton( + android.R.string.ok, null).show(); + + } + } catch (NumberFormatException nfe) { + Log.e(TAG, "nfe"); + } + } + + public void onClick(View v) { + int id = v.getId(); + + switch (id) { + case R.id.imgPower: + + /* + * The exit from the FM application happens here The audio will be + * disabled and when he callback for this is recived, FM will be + * disabled + */ + +// mStatus = sFmRadio.rxDisableAudioRouting(); +// Log.d(TAG, "mStatus is : " + mStatus ); + +// try{ +// if (mStatus == false) { +// showAlert(getParent(), "FmRadio", +// "Not able to disable audio!!!!"); +// } +// }catch (NumberFormatException e) { +// Log.e(TAG, "showAlert - disableAudioRouting exception (" + e.toString() + ")"); +// } + + mStatus = sFmRadio.rxDisable(); + mPreset = false; + break; + case R.id.imgMode: + break; + //case R.id.imgAudiopath: + + // TODO + //break; + case R.id.imgMute: + + + Log.d(TAG, " imgMute mToggleMute " + mToggleMute ); + int muteValue =0; + if(mToggleMute ==true) + muteValue =1 ; + else + muteValue =0; + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + mStatus = sFmRadio.rxSetMuteMode(muteValue); + } else { + // Code for non blocking call + mStatus = sFmRadio.rxSetMuteMode_nb(muteValue); + } + + if (mStatus == false) { + showAlert(this, "FmRadio", "Not able to setmute!!!!"); + } else { + + mToggleMute = !mToggleMute ; + if (mToggleMute == true) { + imgFmVolume.setImageResource(R.drawable.fm_volume_mute); + } else { + imgFmVolume.setImageResource(R.drawable.fm_volume); + } + } + + break; + + case R.id.imgseekdown: + mDirection = FM_SEEK_DOWN; + // FM seek down + + if (mSeekState == SEEK_REQ_STATE_IDLE) { + txtStationName.setText(null); // set the station name to null + mStatus = sFmRadio.rxSeek_nb(mDirection); + if (mStatus == false) { + showAlert(this, "FmRadio", "Not able to seek down!!!!"); + } else { + mSeekState = SEEK_REQ_STATE_PENDING; + txtStatusMsg.setText(R.string.seeking); + } + + } + + break; + case R.id.imgseekup: + mDirection = FM_SEEK_UP; + // FM seek up + if (mSeekState == SEEK_REQ_STATE_IDLE) { + txtStationName.setText(null); // set the station name to null + mStatus = sFmRadio.rxSeek_nb(mDirection); + if (mStatus == false) { + showAlert(this, "FmRadio", "Not able to seek up!!!!"); + + } else { + mSeekState = SEEK_REQ_STATE_PENDING; + txtStatusMsg.setText(R.string.seeking); + } + } + + break; + case R.id.station1: + mStationIndex = 0; + updateStationDisplay(mStationIndex); + + break; + case R.id.station2: + mStationIndex = 1; + updateStationDisplay(mStationIndex); + + break; + case R.id.station3: + mStationIndex = 2; + updateStationDisplay(mStationIndex); + + break; + case R.id.station4: + mStationIndex = 3; + updateStationDisplay(mStationIndex); + break; + + case R.id.station5: + mStationIndex = 4; + updateStationDisplay(mStationIndex); + + break; + case R.id.station6: + mStationIndex = 5; + updateStationDisplay(mStationIndex); + break; + } + + } + + /* Gets the stored frequency and tunes to it. */ + void updateStationDisplay(int index) { + String tunedFreq = null; + tunedFreq = GetStation(index); + tuneStationFrequency(tunedFreq); + txtFmRxTunedFreq.setText(tunedFreq.toString()); + + } + + /* Creates the menu items */ + public boolean onCreateOptionsMenu(Menu menu) { + + super.onCreateOptionsMenu(menu); + MenuItem item; + + item = menu.add(0, MENU_CONFIGURE, 0, R.string.configure); + item.setIcon(R.drawable.configure); + + item = menu.add(0, MENU_ABOUT, 0, R.string.about); + item.setIcon(R.drawable.fm_menu_help); + + item = menu.add(0, MENU_EXIT, 0, R.string.exit); + item.setIcon(R.drawable.icon); + + item = menu.add(0, MENU_PRESET, 0, R.string.preset); + item.setIcon(R.drawable.fm_menu_preferences); + + item = menu.add(0, MENU_SETFREQ, 0, R.string.setfreq); + item.setIcon(R.drawable.fm_menu_manage); + + return true; + } + + /* Handles item selections */ + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case MENU_CONFIGURE: + /* Start the configuration window */ + Intent irds = new Intent(INTENT_RDS_CONFIG); + startActivityForResult(irds, ACTIVITY_CONFIG); + break; + case MENU_PRESET: + /* Start the Presets window */ + Intent i = new Intent(INTENT_PRESET); + mPreset = true; + startActivity(i); + break; + case MENU_EXIT: + /* + * The exit from the FM application happens here The audio will be + * disabled and when he callback for this is recived, FM will be + * disabled + */ +// mStatus = sFmRadio.rxDisableAudioRouting(); +// if (mStatus == false) { +// showAlert(getParent(), "FmRadio", +// "Not able to disable audio!!!!"); +// } +// Log.d(TAG, "MENU_EXIT ------------------- 2"); + + mStatus = sFmRadio.rxDisable(); + mPreset = false; + + break; + case MENU_ABOUT: + /* Start the help window */ + Intent iTxHelp = new Intent(INTENT_RXHELP); + startActivity(iTxHelp); + break; + + case MENU_SETFREQ: + /* Start the Manual frequency input window */ + Intent iRxTune = new Intent(INTENT_RXTUNE); + startActivityForResult(iRxTune, ACTIVITY_TUNE); + break; + + } + return super.onOptionsItemSelected(item); + } + + protected void onSaveInstanceState(Bundle icicle) { + super.onSaveInstanceState(icicle); + Log.i(TAG, "onSaveInstanceState"); + /* save the fm state into bundle for the activity restart */ + mFmInterrupted = true; + Bundle fmState = new Bundle(); + fmState.putBoolean(FM_INTERRUPTED_KEY, mFmInterrupted); + + icicle.putBundle(FM_STATE_KEY, fmState); + } + + public void onStart() { + Log.i(TAG, "onStart"); + super.onStart(); + } + + public void onPause() { + super.onPause(); + Log.i(TAG, "onPause"); + + if (pd != null) + pd.dismiss(); + + saveDefaultConfiguration(); + + } + + public void onConfigurationChanged(Configuration newConfig) { + Log.i(TAG, "onConfigurationChanged"); + super.onConfigurationChanged(newConfig); + + } + + public void onResume() { + Log.i(TAG, "onResume"); + super.onResume(); + if(mFmServiceConnected == true) + startup(); + } + + public void onDestroy() { + Log.i(TAG, "onDestroy"); + super.onDestroy(); + /* + * Unregistering the receiver , so that we dont handle any FM events + * when out of the FM application screen + */ + unregisterReceiver(mReceiver); + } + + // Receives all of the FM intents and dispatches to the proper handler + + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { + + public void onReceive(Context context, Intent intent) { + + String fmAction = intent.getAction(); + + Log.i(TAG, "enter onReceive" + fmAction); + if (fmAction.equals(FmRadioIntent.FM_ENABLED_ACTION)) { + Log.i(TAG, "enter onReceive FM_ENABLED_ACTION " + fmAction); + + mHandler.sendMessage(mHandler + .obtainMessage(EVENT_FM_ENABLED, 0)); + } + if (fmAction.equals(FmRadioIntent.FM_DISABLED_ACTION)) { + Log.i(TAG, "enter onReceive FM_DISABLED_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_DISABLED, + 0)); + } + + if (fmAction.equals(FmRadioIntent.SET_MODE_MONO_STEREO_ACTION)) { + Log.i(TAG, "enter onReceive SET_MODE_MONO_STEREO_ACTION " + + fmAction); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_MONO_STEREO_CHANGE, 0)); + } + if (fmAction + .equals(FmRadioIntent.DISPLAY_MODE_MONO_STEREO_ACTION)) { + Log.i(TAG, "enter onReceive DISPLAY_MODE_MONO_STEREO_ACTION " + + fmAction); + Integer modeDisplay = intent.getIntExtra( + FmRadioIntent.MODE_MONO_STEREO, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_MONO_STEREO_DISPLAY, modeDisplay)); + } + + if (fmAction.equals(FmRadioIntent.RDS_TEXT_CHANGED_ACTION)) { + Log.i(TAG, "enter onReceive RDS_TEXT_CHANGED_ACTION " + + fmAction); + if (FM_SEND_RDS_IN_BYTEARRAY == true) { + Bundle extras = intent.getExtras(); + + byte[] rdsText = extras.getByteArray(FmRadioIntent.RDS); + int status = extras.getInt(FmRadioIntent.STATUS, 0); + + mHandler.sendMessage(mHandler.obtainMessage(EVENT_RDS_TEXT, + status, 0, rdsText)); + } else { + String rdstext = intent + .getStringExtra(FmRadioIntent.RADIOTEXT_CONVERTED); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_RDS_TEXT, + rdstext)); + } + } + if (fmAction.equals(FmRadioIntent.PI_CODE_CHANGED_ACTION)) { + Log + .i(TAG, "enter onReceive PI_CODE_CHANGED_ACTION " + + fmAction); + + Integer pi = intent.getIntExtra(FmRadioIntent.PI, 0); + + mHandler.sendMessage(mHandler.obtainMessage(EVENT_PI_CODE, pi + .toString())); + } + + if (fmAction.equals(FmRadioIntent.TUNE_COMPLETE_ACTION)) { + Log.i(TAG, "enter onReceive TUNE_COMPLETE_ACTION " + fmAction); + + int tuneFreq = intent.getIntExtra( + FmRadioIntent.TUNED_FREQUENCY, 0); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_TUNE_COMPLETE, tuneFreq)); + + } + + if (fmAction.equals(FmRadioIntent.COMPLETE_SCAN_PROGRESS_ACTION)) { + Log.i(TAG, "enter onReceive COMPLETE_SCAN_PROGRESS_ACTION " + fmAction); + + int progress = intent.getIntExtra( + FmRadioIntent.SCAN_PROGRESS, 0); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_COMPLETE_SCAN_PROGRESS, progress)); + + } + + + if (fmAction.equals(FmRadioIntent.VOLUME_CHANGED_ACTION)) { + Log.i(TAG, "enter onReceive VOLUME_CHANGED_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_VOLUME_CHANGE, 0)); + } + + if (fmAction.equals(FmRadioIntent.MUTE_CHANGE_ACTION)) { + Log.i(TAG, "enter onReceive MUTE_CHANGE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_MUTE_CHANGE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.SEEK_STOP_ACTION)) { + Log.i(TAG, "enter onReceive SEEK_STOP_ACTION " + fmAction); + + int freq = intent.getIntExtra(FmRadioIntent.SEEK_FREQUENCY, + 0); + + mHandler.sendMessage(mHandler.obtainMessage(EVENT_SEEK_STOPPED, + freq)); + } + + if (fmAction.equals(FmRadioIntent.SEEK_ACTION)) { + Log.i(TAG, "enter onReceive SEEK_ACTION " + fmAction); + + int freq = intent.getIntExtra(FmRadioIntent.SEEK_FREQUENCY, + 0); + + mHandler.sendMessage(mHandler.obtainMessage(EVENT_SEEK_STARTED, + freq)); + } + + if (fmAction.equals(FmRadioIntent.BAND_CHANGE_ACTION)) { + Log.i(TAG, "enter onReceive BAND_CHANGE_ACTION " + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage(EVENT_BAND_CHANGE, + 0)); + } + + + if (fmAction.equals(FmRadioIntent.GET_CHANNEL_SPACE_ACTION)) { + Log.i(TAG, "enter onReceive GET_CHANNEL_SPACE_ACTION " + fmAction); + + Long chSpace = intent.getLongExtra( + FmRadioIntent.GET_CHANNEL_SPACE, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_CHANNEL_SPACE_CHANGE, chSpace)); + } + + + if (fmAction.equals(FmRadioIntent.SET_CHANNEL_SPACE_ACTION)) { + Log.i(TAG, "enter onReceive SET_CHANNEL_SPACE_ACTION " + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_SET_CHANNELSPACE, 0)); + } + + + + if (fmAction.equals(FmRadioIntent.GET_RDS_AF_SWITCH_MODE_ACTION)) { + Log.i(TAG, "enter onReceive GET_RDS_AF_SWITCH_MODE_ACTION " + fmAction); + + Long switchMode = intent.getLongExtra( + FmRadioIntent.GET_RDS_AF_SWITCHMODE, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_RDS_AF_SWITCHMODE, switchMode)); + } + + + if (fmAction.equals(FmRadioIntent.GET_VOLUME_ACTION)) { + Log.i(TAG, "enter onReceive GET_VOLUME_ACTION " + fmAction); + + Long gVolume = intent.getLongExtra( + FmRadioIntent.GET_VOLUME, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_VOLUME, gVolume)); + } + + + if (fmAction.equals(FmRadioIntent.GET_MONO_STEREO_MODE_ACTION)) { + Log.i(TAG, "enter onReceive GET_MONO_STEREO_MODE_ACTION " + fmAction); + + Long gMode = intent.getLongExtra( + FmRadioIntent.GET_MODE, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_MODE, gMode)); + } + + + + if (fmAction.equals(FmRadioIntent.GET_MUTE_MODE_ACTION)) { + Log.i(TAG, "enter onReceive GET_MUTE_MODE_ACTION " + fmAction); + + Long gMuteMode = intent.getLongExtra( + FmRadioIntent.GET_MUTE_MODE, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_MUTE_MODE, gMuteMode)); + } + + + + + if (fmAction.equals(FmRadioIntent.GET_BAND_ACTION)) { + Log.i(TAG, "enter onReceive GET_BAND_ACTION " + fmAction); + + Long gBand = intent.getLongExtra( + FmRadioIntent.GET_BAND, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_BAND, gBand)); + } + + + if (fmAction.equals(FmRadioIntent.GET_FREQUENCY_ACTION)) { + Log.i(TAG, "enter onReceive GET_FREQUENCY_ACTION " + fmAction); + + int gFreq = intent.getIntExtra( + FmRadioIntent.TUNED_FREQUENCY, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_FREQUENCY, gFreq)); + } + + + if (fmAction.equals(FmRadioIntent.GET_RF_MUTE_MODE_ACTION)) { + Log.i(TAG, "enter onReceive GET_RF_MUTE_MODE_ACTION " + fmAction); + + Long gRfMuteMode = intent.getLongExtra( + FmRadioIntent.GET_RF_MUTE_MODE, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_RF_MUTE_MODE, gRfMuteMode)); + } + + + + if (fmAction.equals(FmRadioIntent.GET_RSSI_THRESHHOLD_ACTION)) { + Log.i(TAG, "enter onReceive GET_RSSI_THRESHHOLD_ACTION " + fmAction); + + Long gRssiThreshhold = intent.getLongExtra( + FmRadioIntent.GET_RSSI_THRESHHOLD, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_RSSI_THRESHHOLD, gRssiThreshhold)); + } + + + if (fmAction.equals(FmRadioIntent.GET_DEEMPHASIS_FILTER_ACTION)) { + Log.i(TAG, "enter onReceive GET_DEEMPHASIS_FILTER_ACTION " + fmAction); + + Long gFilter = intent.getLongExtra( + FmRadioIntent.GET_DEEMPHASIS_FILTER, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_DEEMPHASIS_FILTER, gFilter)); + } + + + if (fmAction.equals(FmRadioIntent.GET_RSSI_ACTION)) { + Log.i(TAG, "enter onReceive GET_RSSI_ACTION " + fmAction); + + int gRssi = intent.getIntExtra( + FmRadioIntent.GET_RSSI, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_RSSI, gRssi)); + } + + + if (fmAction.equals(FmRadioIntent.GET_RDS_SYSTEM_ACTION)) { + Log.i(TAG, "enter onReceive GET_RDS_SYSTEM_ACTION " + fmAction); + + Long gRdsSystem = intent.getLongExtra( + FmRadioIntent.GET_RDS_SYSTEM, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_RDS_SYSTEM, gRdsSystem)); + } + + + if (fmAction.equals(FmRadioIntent.GET_RDS_GROUPMASK_ACTION)) { + Log.i(TAG, "enter onReceive GET_RDS_GROUPMASK_ACTION " + fmAction); + + Long gRdsMask = intent.getLongExtra( + FmRadioIntent.GET_RDS_GROUPMASK, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_GET_RDS_GROUPMASK, gRdsMask)); + } + + + + if (fmAction.equals(FmRadioIntent.ENABLE_RDS_ACTION)) { + Log.i(TAG, "enter onReceive ENABLE_RDS_ACTION " + fmAction); + + mHandler.sendMessage(mHandler + .obtainMessage(EVENT_ENABLE_RDS, 0)); + } + + if (fmAction.equals(FmRadioIntent.DISABLE_RDS_ACTION)) { + Log.i(TAG, "enter onReceive DISABLE_RDS_ACTION " + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage(EVENT_DISABLE_RDS, + 0)); + } + + if (fmAction.equals(FmRadioIntent.SET_RDS_AF_ACTION)) { + Log.i(TAG, "enter onReceive SET_RDS_AF_ACTION " + fmAction); + + mHandler.sendMessage(mHandler + .obtainMessage(EVENT_SET_RDS_AF, 0)); + } + + if (fmAction.equals(FmRadioIntent.SET_RDS_SYSTEM_ACTION)) { + Log.i(TAG, "enter onReceive SET_RDS_SYSTEM_ACTION " + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_SET_RDS_SYSTEM, 0)); + } + + if (fmAction.equals(FmRadioIntent.SET_DEEMP_FILTER_ACTION)) { + Log.i(TAG, "enter onReceive SET_DEEMP_FILTER_ACTION " + + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_SET_DEEMP_FILTER, 0)); + } + + if (fmAction.equals(FmRadioIntent.PS_CHANGED_ACTION)) { + Log.i(TAG, "enter onReceive PS_CHANGED_ACTION " + fmAction); + + if (FM_SEND_RDS_IN_BYTEARRAY == true) { + Bundle extras = intent.getExtras(); + byte[] psName = extras.getByteArray(FmRadioIntent.PS); + int status = extras.getInt(FmRadioIntent.STATUS, 0); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_PS_CHANGED, status, 0, psName)); + } else { + + String name = intent + .getStringExtra(FmRadioIntent.PS_CONVERTED); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_PS_CHANGED, name)); + } + } + + if (fmAction.equals(FmRadioIntent.SET_RSSI_THRESHHOLD_ACTION)) { + Log.i(TAG, "enter onReceive SET_RSSI_THRESHHOLD_ACTION " + + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_SET_RSSI_THRESHHOLD, 0)); + } + + if (fmAction.equals(FmRadioIntent.SET_RF_DEPENDENT_MUTE_ACTION)) { + Log.i(TAG, "enter onReceive SET_RF_DEPENDENT_MUTE_ACTION " + + fmAction); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_SET_RF_DEPENDENT_MUTE, 0)); + } + + if (fmAction.equals(FmRadioIntent.COMPLETE_SCAN_DONE_ACTION)) { + Log.i(TAG, "enter onReceive COMPLETE_SCAN_DONE_ACTION " + + fmAction); + + Bundle extras = intent.getExtras(); + + int[] channelList = extras + .getIntArray(FmRadioIntent.SCAN_LIST); + + int noOfChannels = extras.getInt( + FmRadioIntent.SCAN_LIST_COUNT, 0); + + int status = extras.getInt(FmRadioIntent.STATUS, 0); + + Log.i(TAG, "noOfChannels" + noOfChannels); + + for (int i = 0; i < noOfChannels; i++) + + Log.i(TAG, "channelList" + channelList[i]); + + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_COMPLETE_SCAN_DONE, status, noOfChannels, + channelList)); + } + + if (fmAction.equals(FmRadioIntent.COMPLETE_SCAN_STOP_ACTION)) { + Log.i(TAG, "enter onReceive COMPLETE_SCAN_STOP_ACTION " + + fmAction); + Bundle extras = intent.getExtras(); + int status = extras.getInt(FmRadioIntent.STATUS, 0); + int channelValue = extras.getInt( + FmRadioIntent.LAST_SCAN_CHANNEL, 0); + Log.i(TAG, "Last Scanned Channel Frequency before calling Stop Scan" + channelValue); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_COMPLETE_SCAN_STOP, status , channelValue)); + } + + if (fmAction.equals(FmRadioIntent.MASTER_VOLUME_CHANGED_ACTION)) { + Log.i(TAG, "enter onReceive MASTER_VOLUME_CHANGED_ACTION " + + fmAction); + mVolume = intent.getIntExtra(FmRadioIntent.MASTER_VOLUME, 0); + mHandler.sendMessage(mHandler.obtainMessage( + EVENT_MASTER_VOLUME_CHANGED, mVolume)); + } + + } + }; + + /* Get the volume */ + void getNewGain(int volume) { + Log.d(TAG, "getNewGain" + volume); + if (volume <= GAIN_STEP) { + mVolume = MIN_VOLUME; + } + + else if (volume >= MAX_VOLUME) { + mVolume = MAX_VOLUME; + } else { + mVolume = volume; + } + } + +} diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxAppConstants.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxAppConstants.java new file mode 100644 index 0000000..3429e29 --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxAppConstants.java @@ -0,0 +1,154 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + +public interface FmRxAppConstants { + /******************************************** + * Message Code + ********************************************/ + public static final int EVENT_FM_ENABLED = 1; + public static final int EVENT_FM_DISABLED = 2; + public static final int EVENT_MONO_STEREO_CHANGE = 3; + public static final int EVENT_SEEK_STARTED = 4; + public static final int EVENT_VOLUME_CHANGE = 5; + public static final int EVENT_TUNE_COMPLETE = 6; + public static final int EVENT_MUTE_CHANGE = 7; + public static final int EVENT_SEEK_STOPPED = 8; + public static final int EVENT_RDS_TEXT = 9; + public static final int EVENT_BAND_CHANGE = 10; + public static final int EVENT_MONO_STEREO_DISPLAY = 11; + public static final int EVENT_ENABLE_RDS = 12; + public static final int EVENT_SET_RDS_SYSTEM = 13; + public static final int EVENT_SET_RDS_AF = 14; + public static final int EVENT_DISABLE_RDS = 15; + public static final int EVENT_SET_DEEMP_FILTER = 16; + public static final int EVENT_PS_CHANGED = 17; + public static final int EVENT_SET_RSSI_THRESHHOLD = 18; + public static final int EVENT_SET_RF_DEPENDENT_MUTE = 19; + public static final int EVENT_MASTER_VOLUME_CHANGED = 20; + public static final int EVENT_SET_CHANNELSPACE = 21; + public static final int EVENT_COMPLETE_SCAN_DONE = 22; + public static final int EVENT_COMPLETE_SCAN_STOP = 23; + public static final int EVENT_GET_CHANNEL_SPACE_CHANGE = 24; + public static final int EVENT_PI_CODE = 25; + public static final int EVENT_GET_RDS_AF_SWITCHMODE = 26; + public static final int EVENT_GET_BAND = 27; + public static final int EVENT_GET_VOLUME = 28; + public static final int EVENT_GET_MODE = 29; + public static final int EVENT_GET_MUTE_MODE = 30; + public static final int EVENT_GET_RF_MUTE_MODE =31 ; + public static final int EVENT_GET_RSSI_THRESHHOLD =32 ; + public static final int EVENT_GET_DEEMPHASIS_FILTER = 33; + public static final int EVENT_GET_RSSI =34 ; + public static final int EVENT_GET_RDS_SYSTEM =35 ; + public static final int EVENT_GET_RDS_GROUPMASK = 36; + public static final int EVENT_GET_FREQUENCY = 37; + public static final int EVENT_COMPLETE_SCAN_PROGRESS = 38; + + + /* Volume range */ + + public static final int MIN_VOLUME = 0; + public static final int MAX_VOLUME =16383; //32767,//65535; + public static final int GAIN_STEP = 234; //468, //935; + + /* default values */ + public static final int DEF_VOLUME = 10; + public static final float DEFAULT_FREQ_EUROPE = (float) 87500 / 1000; + public static final float DEFAULT_FREQ_JAPAN = (float) 76000 / 1000; + public static final int DEFAULT_BAND = 0; // EuropeUS + public static final int DEFAULT_MODE = 0; // Stereo + public static final boolean DEFAULT_RDS = false; + public static final int DEFAULT_DEEMP = 0; + public static final int DEFAULT_RDS_SYSTEM = 0; + public static final boolean DEFAULT_RDS_AF = false; + public static final int DEFAULT_RSSI = 7; + public static final int DEFAULT_CHANNELSPACE = 2; + + /* Actvity result index */ + + public static final int ACTIVITY_TUNE = 1; + public static final int ACTIVITY_CONFIG = 2; + public static final int ACTIVITY_PRESET = 3; + + public static final String FREQ_VALUE = "FREQUENCY"; + + /* Rssi range */ + + public static final int RSSI_MIN = 1; + public static final int RSSI_MAX = 127; + + /* Preset list display items */ + + public static final String ITEM_KEY = "key"; + public static final String ITEM_VALUE = "value"; + public static final String ITEM_NAME = "name"; + + /* seek states */ + public static final boolean SEEK_REQ_STATE_IDLE = true; + public static final boolean SEEK_REQ_STATE_PENDING = false; + + /* Preference save keys */ + + public static final String BAND = "BAND"; + public static final String VOLUME = "VOLUME"; + public static final String FREQUENCY = "FREQUENCY"; + public static final String MODE = "MODE"; + public static final String RDS = "RDS"; + public static final String RDSSYSTEM = "RDSSYSTEM"; + public static final String DEEMP = "DEEMP"; + public static final String RDSAF = "RDSAF"; + public static final String RSSI = "RSSI"; + public static final String RSSI_STRING = "RSSI_STRING"; + public static final String DEF_RSSI_STRING = "7"; + public static final String CHANNELSPACE = "CHANNELSPACE"; + public static final String MUTE = "MUTE"; + + /* Configuration states */ + + public static final int CONFIGURATION_STATE_IDLE = 1; + public static final int CONFIGURATION_STATE_PENDING = 2; + + /* Initial values */ + public static final int INITIAL_VAL = 5; + public static final int INITIAL_RSSI = 0; + + /* Seek constants */ + + public static final int FM_SEEK_UP = 1; + public static final int FM_SEEK_DOWN = 0; + + + /* Activity Intenets */ + public static final String INTENT_RDS_CONFIG = "android.intent.action.RDS_CONFIG"; + public static final String INTENT_PRESET = "android.intent.action.PRESET"; + public static final String INTENT_RXHELP = "android.intent.action.START_RXHELP"; + public static final String INTENT_RXTUNE = "android.intent.action.START_RXFREQ"; + + +/* Europe / US band limits */ +public static final float APP_FM_FIRST_FREQ_US_EUROPE_KHZ = (float)87.5; + +public static final float APP_FM_LAST_FREQ_US_EUROPE_KHZ = (float)108.0; + +/* Japan band limits */ +public static final float APP_FM_FIRST_FREQ_JAPAN_KHZ = (float)76.0; + +public static final float APP_FM_LAST_FREQ_JAPAN_KHZ = (float)90.0; + +} diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxFreqInput.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxFreqInput.java new file mode 100644 index 0000000..c87ed8f --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxFreqInput.java @@ -0,0 +1,153 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.View.OnKeyListener; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import com.ti.fm.IFmConstants; + +/** + * FmRxFreqInput asks the user to enter a valid frequency for tuning the radio. + * It is an activity that appears as a dialog. + */ + +public class FmRxFreqInput extends Activity implements OnKeyListener, + View.OnClickListener, IFmConstants, FmRxAppConstants { + + public static final String TAG = "ManualFreqInput"; + private EditText mUserText; + private TextView mBandRange; + private Button btnCancel, btnOk; + + /** Called when the activity is first created. */ + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fmrxfreq); + initControls(); + } + + private void initControls() { + /* listening to key click or a key input into the exit text box */ + mUserText = (EditText) findViewById(R.id.txtFrequency); + /* wait for key inputs or mouse clicks in the edit box */ + mUserText.setOnKeyListener(this); + btnCancel = (Button) findViewById(R.id.btnCancel); + btnOk = (Button) findViewById(R.id.btnOk); + btnOk.setOnClickListener(this); + btnCancel.setOnClickListener(this); + mBandRange = (TextView) findViewById(R.id.freqRange); + if (FmRxApp.sBand == FM_BAND_EUROPE_US) { + mBandRange.setText(getText(R.string.freqRangeEurope)); + } else { + mBandRange.setText(getText(R.string.freqRangeJapan)); + + } + + } + + private void writeFrequency() { + // get the text entered in edit box + String text = mUserText.getText().toString(); + try { + float iFreq = Float.parseFloat(text); + Float validFreq = UpdateFrequency(iFreq); + if (validFreq != 0) { + // reset the text in edit box for the next entry + mUserText.setText(null); + + Bundle bundle = new Bundle(); + bundle.putFloat(FREQ_VALUE, validFreq); + Intent result = new Intent(); + result.putExtras(bundle); + setResult(RESULT_OK, result); + finish(); + + } else { + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid frequency!!").setNegativeButton( + android.R.string.ok, null).show(); + mUserText.setText(null); + } + } catch (NumberFormatException nfe) { + Log.d(TAG, "NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid number!!").setNegativeButton( + android.R.string.ok, null).show(); + mUserText.setText(null); + } + + } + + /* This is a method implementation of OnKeyListener */ + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_DOWN) { + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_CENTER: + case KeyEvent.KEYCODE_ENTER: + writeFrequency(); + return true; + } + } + return false; + } + + public void onClick(View v) { + int id = v.getId(); + switch (id) { + case R.id.btnOk: + writeFrequency(); + break; + case R.id.btnCancel: + finish(); + break; + + } + } + + static float BaseFreq() { + return FmRxApp.sBand == FM_BAND_JAPAN ? APP_FM_FIRST_FREQ_JAPAN_KHZ + : APP_FM_FIRST_FREQ_US_EUROPE_KHZ; + } + + static float LastFreq() { + return FmRxApp.sBand == FM_BAND_JAPAN ? APP_FM_LAST_FREQ_JAPAN_KHZ + : APP_FM_LAST_FREQ_US_EUROPE_KHZ; + } + + // Update the Frequency label with the given value + float UpdateFrequency(float freq) { + Log.d(TAG, "FM App: UpdateFrequency %d." + freq); + if (freq < BaseFreq() || freq > LastFreq()) { + freq = 0; + } + return (float) freq; + } + +} diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxHelp.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxHelp.java new file mode 100644 index 0000000..a92a2da --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxHelp.java @@ -0,0 +1,57 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + +import android.app.Activity; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.widget.Button; + +public class FmRxHelp extends Activity implements View.OnKeyListener, + View.OnClickListener { + public static final String TAG = "FmTxHelp"; + + /** Called when the activity is first created. */ + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fmrxhelp); + initControls(); + + } + + private void initControls() { + Button btnBack = (Button) findViewById(R.id.btnBack); + btnBack.setOnClickListener(this); + + } + + public boolean onKey(View arg0, int arg1, KeyEvent arg2) { + return false; + } + + public void onClick(View v) { + int id = v.getId(); + switch (id) { + case R.id.btnBack: + finish(); + break; + } + } +} diff --git a/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxRdsConfig.java b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxRdsConfig.java new file mode 100644 index 0000000..252d101 --- /dev/null +++ b/tools/FM/FmRxApp/src/com/ti/fmrxapp/FmRxRdsConfig.java @@ -0,0 +1,472 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmrxapp; + +import java.util.ArrayList; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.AdapterView.OnItemSelectedListener; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.Context; +import android.widget.CompoundButton; + +public class FmRxRdsConfig extends Activity implements View.OnKeyListener, + View.OnClickListener, CompoundButton.OnCheckedChangeListener, + FmRxAppConstants { + + public static final String TAG = "FmRxRdsConfig"; + + /******************************************** + * Widgets + ********************************************/ + private Button btnCancel, btnOk; + private Spinner spnBand, spnDeEmp, spnRdsSystem, spnMode, + spnChannelSpacing;; + private EditText textRssi; + private CheckBox chbRdsMode; + private CheckBox chbSetRdsAf; + private ArrayAdapter<String> bandAdapter; + private ArrayAdapter<String> channelSpaceAdapter; + private ArrayAdapter<String> deEmpAdapter; + private ArrayAdapter<String> rdsSystemAdapter; + private ArrayAdapter<String> modeAdapter; + private ArrayAdapter<String> emptyAdapter; + private ArrayList<String> channelSpaceString = new ArrayList<String>(); + + private ArrayList<String> bandString = new ArrayList<String>(); + private ArrayList<String> deEmpStrings = new ArrayList<String>(); + private ArrayList<String> rdsSystemStrings = new ArrayList<String>(); + private ArrayList<String> emptyStrings = new ArrayList<String>(); + private ArrayList<String> modeStrings = new ArrayList<String>(); + + /******************************************** + * private variables + ********************************************/ + private Context mContext; + + /******************************************** + * public variables + ********************************************/ + public SharedPreferences fmConfigPreferences; + + /** Called when the activity is first created. */ + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fmrxrdsconfig); + initControl(); + setSpinners(); + setRdsSystemSpinner(); + + } + + /** Initialise the Widget controls of the Activity */ + private void initControl() { + btnCancel = (Button) findViewById(R.id.btnCancel); + btnCancel.setOnKeyListener(this); + btnCancel.setOnClickListener(this); + + btnOk = (Button) findViewById(R.id.btnOk); + btnOk.setOnKeyListener(this); + btnOk.setOnClickListener(this); + + spnRdsSystem = (Spinner) findViewById(R.id.spnRdsSystem); + spnBand = (Spinner) findViewById(R.id.spnBand); + //spnDeEmp = (Spinner) findViewById(R.id.spnEmp); + spnMode = (Spinner) findViewById(R.id.spnMode); + + spnChannelSpacing = (Spinner) findViewById(R.id.spnChannelSpace); + + textRssi = (EditText) findViewById(R.id.Rssi); + + chbRdsMode = (CheckBox) findViewById(R.id.chbRdsmode); + chbRdsMode.setOnCheckedChangeListener(this); + + chbSetRdsAf = (CheckBox) findViewById(R.id.chbSetRdsAf); + chbSetRdsAf.setOnCheckedChangeListener(this); + } + + /** + * sets the Band , De-Emp Filter and Mode option selections Spinner for the + * User + */ + private void setSpinners() { + // BAnd Spinner + bandAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, bandString); + + bandAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnBand.setAdapter(bandAdapter); + bandAdapter.add("European"); + bandAdapter.add("Japanese"); + spnBand.setOnItemSelectedListener(gItemSelectedHandler); + + // ChannelSpace Spinner + channelSpaceAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, channelSpaceString); + + channelSpaceAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnChannelSpacing.setAdapter(channelSpaceAdapter); + channelSpaceAdapter.add("50 KHZ"); + channelSpaceAdapter.add("100 KHZ"); + channelSpaceAdapter.add("200 KHZ"); + spnChannelSpacing.setOnItemSelectedListener(gItemSelectedHandler); + + // De-Emp Spinner + /*deEmpAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, deEmpStrings); + + deEmpAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnDeEmp.setAdapter(deEmpAdapter); + deEmpAdapter.add("0 sec"); + deEmpAdapter.add("50 sec"); + deEmpAdapter.add("75 sec"); + spnDeEmp.setOnItemSelectedListener(gItemSelectedHandler); +*/ + // Mode(Mono/Stereo) Spinner + modeAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, modeStrings); + + modeAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnMode.setAdapter(modeAdapter); + modeAdapter.add("STEREO"); + modeAdapter.add("MONO"); + spnMode.setOnItemSelectedListener(gItemSelectedHandler); + + } + + /** spinner to select Rds System option */ + private void setRdsSystemSpinner() { + + rdsSystemAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, rdsSystemStrings); + + rdsSystemAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnRdsSystem.setAdapter(rdsSystemAdapter); + rdsSystemAdapter.clear(); + rdsSystemAdapter.add("RDB"); + //rdsSystemAdapter.add("RBDS"); + spnRdsSystem.setOnItemSelectedListener(gItemSelectedHandler); + + } + + /** Spinner with no options */ + private void setEmptySpinner() { + emptyAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, emptyStrings); + + emptyAdapter + .setDropDownViewResource(android.R.layout.select_dialog_item); + spnRdsSystem.setAdapter(emptyAdapter); + emptyAdapter.clear(); + emptyAdapter.add(" RDS is Disabled "); + spnRdsSystem.setOnItemSelectedListener(gItemSelectedHandler); + + } + + public OnItemSelectedListener gItemSelectedHandler = new OnItemSelectedListener() { + public void onItemSelected(AdapterView<?> arg0, View view, int arg2, + long arg3) { + + } + + public void onNothingSelected(AdapterView<?> arg0) { + } + + }; + + /** Pops up the alert Dialog */ + public void showAlert(Context context, String title, String msg) { + + new AlertDialog.Builder(context).setTitle(title).setIcon( + android.R.drawable.ic_dialog_alert).setMessage(msg) + .setNegativeButton(android.R.string.ok, null).show(); + + } + + public void onClick(View view) { + Log.i(TAG, "onClick()"); + int id = view.getId(); + switch (id) { + case R.id.btnCancel: + finish(); + break; + case R.id.btnOk: + savePrefernces(); + break; + + default: + break; + } + } + + /** Send the Intent to Parent Activity */ + private void sendRdsIntent() { + + Intent rdsIntent = new Intent(); + setResult(RESULT_OK, rdsIntent); + finish(); + + } + + public void onCheckedChanged(CompoundButton view, boolean isChecked) { + Log.i(TAG, "onCheckedChanged()"); + int id = view.getId(); + switch (id) { + case R.id.chbSetRdsAf: + break; + + case R.id.chbRdsmode: + + if (isChecked) { + chbSetRdsAf.setEnabled(true); + setRdsSystemSpinner(); + } else { + chbSetRdsAf.setChecked(false); + chbSetRdsAf.setEnabled(false); + setEmptySpinner(); + } + break; + + default: + break; + } + + } + + public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { + int action = keyEvent.getAction(); + + if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT) { + Log.v(TAG, "KEYCODE_SOFT_RIGHT "); + finish(); + return true; + } + + if (keyCode == KeyEvent.KEYCODE_SOFT_LEFT) { + Log.v(TAG, "KEYCODE_SOFT_LEFT "); + savePrefernces(); + // finish(); + return true; + } + + if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER + && keyCode != KeyEvent.KEYCODE_DPAD_UP + && keyCode != KeyEvent.KEYCODE_DPAD_DOWN + && keyCode != KeyEvent.KEYCODE_ENTER) { + return false; + } + + if (action == KeyEvent.ACTION_UP) { + switch (keyCode) { + case KeyEvent.KEYCODE_ENTER: + case KeyEvent.KEYCODE_DPAD_CENTER: + + break; + + case KeyEvent.KEYCODE_DPAD_UP: + + break; + + case KeyEvent.KEYCODE_DPAD_DOWN: + + break; + } + } + return true; + } + + public void onResume() { + super.onResume(); + Log.i(TAG, "onResume()-Entered"); + updateUiFromPreference(); + } + + public void onPause() { + super.onPause(); + Log.i(TAG, "onPause()-Entered"); + + } + + public void onStop() { + Log.i(TAG, "onStop()-Entered"); + super.onStop(); + } + + public void onRestart() { + Log.i(TAG, "onRestart()-Entered"); + super.onRestart(); + + } + + /** Updates the UI with Default/last saved values */ + private void updateUiFromPreference() { + fmConfigPreferences = getSharedPreferences("fmConfigPreferences", + MODE_PRIVATE); + Log.i(TAG, "updateUiFromPreference()"); + + chbRdsMode.setChecked(fmConfigPreferences.getBoolean(RDS, DEFAULT_RDS)); + boolean rdsON = fmConfigPreferences.getBoolean(RDS, DEFAULT_RDS); + + if (!rdsON) // Rds is Disabled + { + chbSetRdsAf.setChecked(false); // When the RDS is Disabled uncheck + // Rds Af checkbox + chbSetRdsAf.setEnabled(false); // When the RDS is Disabled disable + // Rds Af checkbox + setEmptySpinner(); // When the RDS is Disabled, disable RDS System + // spinner + } else// Rds Is Enable + { + chbSetRdsAf.setChecked(fmConfigPreferences.getBoolean(RDSAF, + DEFAULT_RDS_AF)); + spnRdsSystem.setSelection(fmConfigPreferences.getInt(RDSSYSTEM, + DEFAULT_RDS_SYSTEM)); + } + + textRssi.setText(fmConfigPreferences.getString(RSSI_STRING, + DEF_RSSI_STRING)); + + spnBand.setSelection(fmConfigPreferences.getInt(BAND, DEFAULT_BAND)); + //spnDeEmp.setSelection(fmConfigPreferences.getInt(DEEMP, DEFAULT_DEEMP)); + spnMode.setSelection(fmConfigPreferences.getInt(MODE, DEFAULT_MODE)); + + int pos = 1; + switch (fmConfigPreferences.getInt(CHANNELSPACE, DEFAULT_CHANNELSPACE)) { + + case 1: + pos = 0; + break; + + case 2: + pos = 1; + break; + + case 4: + pos = 2; + break; + + } + spnChannelSpacing.setSelection(pos); + + } + + /** Saves Configuration settings in the Shared Preference */ + private void savePrefernces() { + Log.i(TAG, "savePrefernces()"); + + int mChannelSpacePos = 2; + + fmConfigPreferences = getSharedPreferences("fmConfigPreferences", + MODE_PRIVATE); + + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + + if (chbRdsMode.isChecked()) { + editor.putBoolean(RDSAF, chbSetRdsAf.isChecked()); + editor.putBoolean(RDS, chbRdsMode.isChecked()); + editor.putInt(RDSSYSTEM, spnRdsSystem.getSelectedItemPosition()); + } else { + editor.putBoolean(RDSAF, DEFAULT_RDS_AF); + editor.putBoolean(RDS, DEFAULT_RDS); + editor.putInt(RDSSYSTEM, DEFAULT_RDS_SYSTEM); + } + + editor.putInt(BAND, spnBand.getSelectedItemPosition()); + + //editor.putInt(DEEMP, spnDeEmp.getSelectedItemPosition()); + + editor.putInt(MODE, spnMode.getSelectedItemPosition()); + + switch (spnChannelSpacing.getSelectedItemPosition()) { + case 0: + mChannelSpacePos = 1; + break; + + case 1: + mChannelSpacePos = 2; + break; + + case 2: + mChannelSpacePos = 4; + break; + } + + editor.putInt(CHANNELSPACE, mChannelSpacePos); + + try { + int rssiValue = Integer.parseInt(textRssi.getText().toString()); + boolean valid = rssiValid(rssiValue); + if (valid || (textRssi.getText().toString() == null)) { + editor.putString(RSSI_STRING, textRssi.getText().toString()); + if (textRssi.getText().toString() == null) + editor.putInt(RSSI, DEFAULT_RSSI); + else { + editor.putInt(RSSI, rssiValue); + } + editor.commit(); + sendRdsIntent(); + } else { + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid RSSI value in range 1-127!!") + .setNegativeButton(android.R.string.ok, null).show(); + textRssi.setText(null); + } + } catch (NumberFormatException nfe) { + Log.d(TAG, "NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid RSSI value in range 1-127!!") + .setNegativeButton(android.R.string.ok, null).show(); + textRssi.setText(null); + } + + } + + /** Checks the RSSI value for validity */ + private boolean rssiValid(int value) { + //Log.d(TAG, "rssiValid " + value); + if (value < RSSI_MIN || value > RSSI_MAX) { + Log.d(TAG, "TAG,rssiValid %d." + value); + + return false; + } else + return true; + + } + +} diff --git a/tools/FM/FmTxApp/Android.mk b/tools/FM/FmTxApp/Android.mk new file mode 100644 index 0000000..3098c3c --- /dev/null +++ b/tools/FM/FmTxApp/Android.mk @@ -0,0 +1,36 @@ + +# +# +# Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ +# +# 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. +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := FmTxApp +LOCAL_CERTIFICATE := shared +LOCAL_JAVA_LIBRARIES := fmradioif + +include $(BUILD_PACKAGE) +# Use the folloing include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) + + + + + diff --git a/tools/FM/FmTxApp/AndroidManifest.xml b/tools/FM/FmTxApp/AndroidManifest.xml new file mode 100644 index 0000000..84a755b --- /dev/null +++ b/tools/FM/FmTxApp/AndroidManifest.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.ti.fmtxapp" + android:versionCode="1" + android:versionName="1.0.0"> + <uses-permission android:name="ti.permission.FMRX" /> + <uses-permission android:name="ti.permission.FMRX_ADMIN" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + + <application android:icon="@drawable/txradio_ics" android:label="@string/app_name"> +<uses-library android:name="fmradioif" /> + <activity android:name=".FmTx" + android:label="@string/Fm_Tx"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + <intent-filter> + <action android:name="android.intent.action.FMTXRELAUNCH" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <activity android:name=".FmTxConfig" android:label="@string/rdsConfigApp"> + <intent-filter> + <action android:name="android.intent.action.RDSPARAM_CONFIG" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <!-- <activity android:name=".FmTxParamConfig" android:label="@string/rdsConfigApp"> + <intent-filter> + <action android:name="android.intent.action.TXPARAM_CONFIG" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> --> + + + <activity android:name=".FmTxHelp" android:label="@string/app_tx"> + <intent-filter> + <action android:name="android.intent.action.START_TXABOUT" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + </application> + <uses-sdk android:minSdkVersion="2" /> +</manifest> diff --git a/tools/FM/FmTxApp/MODULE_LICENSE_APACHE2 b/tools/FM/FmTxApp/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/FM/FmTxApp/MODULE_LICENSE_APACHE2 diff --git a/tools/FM/FmTxApp/NOTICE b/tools/FM/FmTxApp/NOTICE new file mode 100644 index 0000000..b86e267 --- /dev/null +++ b/tools/FM/FmTxApp/NOTICE @@ -0,0 +1,192 @@ + + Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + + 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. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/tools/FM/FmTxApp/res/drawable/background.png b/tools/FM/FmTxApp/res/drawable/background.png Binary files differnew file mode 100644 index 0000000..5efab8f --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/background.png diff --git a/tools/FM/FmTxApp/res/drawable/background1.png b/tools/FM/FmTxApp/res/drawable/background1.png Binary files differnew file mode 100644 index 0000000..3294905 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/background1.png diff --git a/tools/FM/FmTxApp/res/drawable/btn_bgd_default.png b/tools/FM/FmTxApp/res/drawable/btn_bgd_default.png Binary files differnew file mode 100644 index 0000000..f7eb14d --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/btn_bgd_default.png diff --git a/tools/FM/FmTxApp/res/drawable/btn_bgd_pressed.png b/tools/FM/FmTxApp/res/drawable/btn_bgd_pressed.png Binary files differnew file mode 100644 index 0000000..c502db4 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/btn_bgd_pressed.png diff --git a/tools/FM/FmTxApp/res/drawable/configure.png b/tools/FM/FmTxApp/res/drawable/configure.png Binary files differnew file mode 100644 index 0000000..a2f1038 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/configure.png diff --git a/tools/FM/FmTxApp/res/drawable/icon.png b/tools/FM/FmTxApp/res/drawable/icon.png Binary files differnew file mode 100644 index 0000000..7502484 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/icon.png diff --git a/tools/FM/FmTxApp/res/drawable/radio.png b/tools/FM/FmTxApp/res/drawable/radio.png Binary files differnew file mode 100644 index 0000000..9de7e9a --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/radio.png diff --git a/tools/FM/FmTxApp/res/drawable/robot.png b/tools/FM/FmTxApp/res/drawable/robot.png Binary files differnew file mode 100644 index 0000000..8a9e698 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/robot.png diff --git a/tools/FM/FmTxApp/res/drawable/txradio.png b/tools/FM/FmTxApp/res/drawable/txradio.png Binary files differnew file mode 100644 index 0000000..6e74968 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/txradio.png diff --git a/tools/FM/FmTxApp/res/drawable/txradio_ics.png b/tools/FM/FmTxApp/res/drawable/txradio_ics.png Binary files differnew file mode 100644 index 0000000..9f72599 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/txradio_ics.png diff --git a/tools/FM/FmTxApp/res/drawable/wallpaper11.png b/tools/FM/FmTxApp/res/drawable/wallpaper11.png Binary files differnew file mode 100644 index 0000000..92d2a00 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/wallpaper11.png diff --git a/tools/FM/FmTxApp/res/drawable/wallpaper22.png b/tools/FM/FmTxApp/res/drawable/wallpaper22.png Binary files differnew file mode 100644 index 0000000..d04a788 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/wallpaper22.png diff --git a/tools/FM/FmTxApp/res/drawable/wallpaper33.png b/tools/FM/FmTxApp/res/drawable/wallpaper33.png Binary files differnew file mode 100644 index 0000000..126c7a3 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/wallpaper33.png diff --git a/tools/FM/FmTxApp/res/drawable/wallpaper4.png b/tools/FM/FmTxApp/res/drawable/wallpaper4.png Binary files differnew file mode 100644 index 0000000..ea83620 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/wallpaper4.png diff --git a/tools/FM/FmTxApp/res/drawable/wallpaper_fmtx.png b/tools/FM/FmTxApp/res/drawable/wallpaper_fmtx.png Binary files differnew file mode 100644 index 0000000..25d0cd5 --- /dev/null +++ b/tools/FM/FmTxApp/res/drawable/wallpaper_fmtx.png diff --git a/tools/FM/FmTxApp/res/layout/fmtxhelp.xml b/tools/FM/FmTxApp/res/layout/fmtxhelp.xml new file mode 100644 index 0000000..377e44d --- /dev/null +++ b/tools/FM/FmTxApp/res/layout/fmtxhelp.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" + android:orientation="vertical" android:background="@drawable/wallpaper_fmtx"> + + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + + <LinearLayout android:id="@+id/widget224" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="fill_parent"> + <LinearLayout android:id="@+id/widget224" + android:layout_alignParentTop="true" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_height="120dip"> + <ImageView android:id="@+id/imgFTP" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginLeft="30dip" android:src="@drawable/txradio_ics"> + </ImageView> + <TextView android:id="@+id/lblFmRx" android:layout_width="fill_parent" + android:layout_height="30dip" android:layout_marginTop="15dip" + android:text="@string/app_tx" android:textSize="24sp" + android:textStyle="bold" android:layout_marginLeft="20dip" + android:layout_gravity="center" android:textColor="@android:color/white"> + </TextView> + </LinearLayout> + <LinearLayout android:id="@+id/widget233" + android:layout_below="@+id/widget224" android:layout_width="fill_parent" + android:layout_alignParentLeft="false" android:layout_height="100dip"> + <TextView android:id="@+id/lblFmApp" android:layout_width="wrap_content" + android:text="@string/app_tx" android:textSize="24sp" + android:textStyle="bold" android:layout_height="50dip" + android:layout_marginTop="20dip" android:paddingLeft="50dip" + android:textColor="@android:color/white"> + </TextView> + <TextView android:id="@+id/txtplatform" + android:layout_width="wrap_content" android:text="@string/txtplatform" + android:paddingLeft="10dip" android:textSize="24sp" + android:layout_height="50dip" android:layout_marginTop="20dip" + android:textStyle="bold" android:textColor="@android:color/white"> + </TextView> + </LinearLayout> + <LinearLayout android:id="@+id/widget243" + android:layout_below="@+id/widget233" android:layout_width="fill_parent" + android:layout_alignParentLeft="false" android:layout_height="50dip"> + <TextView android:id="@+id/lblversion" + android:layout_width="wrap_content" android:text="@string/lblversion" + android:layout_height="40dip" android:textSize="24sp" + android:layout_marginLeft="30dip" android:paddingLeft="50dip" + android:textColor="@android:color/white"> + </TextView> + <TextView android:id="@+id/txtversion" + android:layout_width="wrap_content" android:text="@string/txtversion" + android:paddingLeft="30dip" android:layout_height="40dip" + android:textSize="24sp" android:textColor="@android:color/white"> + </TextView> + </LinearLayout> + + </LinearLayout> +</ScrollView> + + <LinearLayout android:id="@+id/widget244" + android:layout_below="@+id/widget224" + android:layout_alignParentBottom="true" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:gravity="right"> + + <Button android:id="@+id/btnBack" android:layout_width="150dip" + android:layout_height="50dip" android:text="@string/btnCancel" + android:layout_alignParentRight="true" android:layout_gravity="center"> + </Button> + </LinearLayout> + </LinearLayout> + + + diff --git a/tools/FM/FmTxApp/res/layout/fmtxparamconfig.xml b/tools/FM/FmTxApp/res/layout/fmtxparamconfig.xml new file mode 100644 index 0000000..8a4b02a --- /dev/null +++ b/tools/FM/FmTxApp/res/layout/fmtxparamconfig.xml @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper33"> + + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + <LinearLayout android:id="@+id/widget224" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="fill_parent"> + <LinearLayout android:id="@+id/widget28" + android:layout_width="fill_parent" android:layout_below="@+id/widget0" + android:layout_alignParentLeft="true" + android:layout_height="50dip" android:layout_marginTop="10dip"> + <TextView android:id="@+id/txtEmpFilter" android:text="@string/empFilter" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginLeft="15dip" + android:textSize="18sp" android:textStyle="normal" + android:textColor="@android:color/white"> + </TextView> + <Spinner android:id="@+id/spnEmpFilter" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginRight="15dip"> + </Spinner> + + </LinearLayout> + <LinearLayout android:id="@+id/widget63" + android:layout_width="fill_parent" android:layout_below="@+id/widget28" + android:layout_alignParentLeft="true" android:layout_height="50dip"> + + <TextView android:id="@+id/txtMusicSpeech" android:text="@string/MusicSpeech" + android:textSize="18sp" android:layout_height="fill_parent" + android:layout_width="fill_parent" android:layout_weight="1" + android:layout_marginLeft="15dip" + android:textStyle="normal" android:textColor="@android:color/white"> + </TextView> + <Spinner android:id="@+id/spnMusicSpeech" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginRight="15dip"> + </Spinner> + + </LinearLayout> + <LinearLayout android:id="@+id/widget130" + android:layout_width="fill_parent" android:layout_below="@+id/widget63" + android:layout_alignParentLeft="true" android:layout_height="50dip"> + + <TextView android:id="@+id/txtPty" android:text="@string/ptyCode" + android:textSize="18sp" android:layout_height="fill_parent" + android:layout_width="fill_parent" android:layout_weight="1" + android:layout_marginLeft="15dip" android:textColor="@android:color/white"> + </TextView> + <EditText android:id="@+id/EdtPty" + android:textSize="18sp" android:gravity="left" + android:layout_width="fill_parent" + android:editable="true" android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginRight="15dip"> + </EditText> + + </LinearLayout> + <LinearLayout android:id="@+id/widget140" + android:layout_width="fill_parent" android:layout_below="@+id/widget130" + android:layout_alignParentLeft="true" android:layout_height="60dip"> + <TextView android:id="@+id/txtgroupmask" android:text="@string/txgroupmask" + android:layout_height="50dip" android:textSize="18sp" + android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip" android:layout_width="100dip"> + </TextView> + <RadioButton android:id="@+id/rbtnPs" android:text="@string/PS" + android:layout_height="50dip" android:layout_weight="1" android:layout_width="wrap_content"> + </RadioButton> + <RadioButton android:id="@+id/rbtnRt" android:text="@string/RT" + android:layout_height="50dip" android:layout_weight="1" android:layout_width="wrap_content"> + </RadioButton> + + <RadioButton android:id="@+id/rbtnEcc" android:text="@string/ecc" + android:layout_height="50dip" android:layout_weight="1" android:layout_width="wrap_content"> + </RadioButton> + </LinearLayout> + + <LinearLayout android:id="@+id/widget131" + android:layout_width="fill_parent" android:layout_below="@+id/widget140" + android:layout_alignParentLeft="true" android:layout_height="50dip"> + <TextView android:id="@+id/txtEcc" android:text="@string/ecc" + android:textSize="18sp" + android:gravity="center_vertical" + android:textColor="@android:color/white" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/EdtEcc" + android:textSize="18sp" + + android:editable="true" android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginRight="15dip"> + </EditText> + </LinearLayout> + + <LinearLayout android:id="@+id/widget231" + android:layout_width="fill_parent" android:layout_height="50dip"> + <TextView android:id="@+id/txtRadioText" + android:textSize="18sp" android:text="@string/radioText" + android:textColor="@android:color/white" android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/EdtRadioText" + android:textSize="18sp" + android:editable="true" android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_marginRight="15dip"> + </EditText> + </LinearLayout> + </LinearLayout> + </ScrollView> + <LinearLayout android:id="@+id/widget173" + android:layout_below="@+id/widget231" android:layout_width="fill_parent" + android:layout_height="50dip"> + <Button android:id="@+id/btnOk" android:text="@string/btnOk" + android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_weight="1"> + </Button> + <Button android:id="@+id/btnCancel" android:text="@string/btnCancel" + + android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_weight="1"> + </Button> + </LinearLayout> +</LinearLayout> + diff --git a/tools/FM/FmTxApp/res/layout/fmtxrdsconfig.xml b/tools/FM/FmTxApp/res/layout/fmtxrdsconfig.xml new file mode 100644 index 0000000..0bedf64 --- /dev/null +++ b/tools/FM/FmTxApp/res/layout/fmtxrdsconfig.xml @@ -0,0 +1,209 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper_fmtx"> + + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + <TableLayout android:layout_width="fill_parent" + android:id="@+id/widget0" android:orientation="vertical" + android:layout_height="fill_parent" android:background="@drawable/wallpaper_fmtx"> + <!-- <TableRow android:id="@+id/widget28" android:layout_width="fill_parent" + android:layout_below="@+id/widget0" android:layout_alignParentLeft="true" + android:layout_height="50dip" android:layout_marginTop="10dip"> + <TextView android:id="@+id/txtDisplayMode" android:text="@string/dispalyMode" + android:layout_width="120dip" android:textSize="18sp" + android:textColor="@android:color/white" android:layout_weight="1" + android:layout_marginLeft="15dip" android:layout_marginTop="10dip" + android:layout_height="30dip"> + </TextView> + <Spinner android:id="@+id/spnDisplayMode" + android:layout_height="45dip" android:layout_width="120dip" + android:layout_weight="1" android:layout_marginRight="15dip"> + </Spinner> + </TableRow> + <TableRow android:id="@+id/widget63" android:layout_width="fill_parent" + android:layout_below="@+id/widget28" android:layout_alignParentLeft="true" + android:layout_height="50dip"> + <TextView android:id="@+id/txtTxMode" android:text="@string/transmissionMode" + android:gravity="center_vertical" android:layout_width="120dip" + android:textSize="18sp" android:layout_height="45dip" + android:textColor="@android:color/white" android:layout_weight="1" + android:layout_marginLeft="15dip"> + </TextView> + <Spinner android:id="@+id/spnTxMode" android:layout_width="120dip" + android:layout_height="45dip" android:layout_weight="1" + android:layout_marginRight="15dip"> + </Spinner> + </TableRow>--> + + <TableRow android:id="@+id/widget133" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_below="@+id/widget165" android:layout_height="60dip"> + + <TextView android:id="@+id/txtTXConfig" + android:textSize="18sp" android:text="@string/txtTXConfig" + android:layout_width="80dip" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip" android:gravity="center_horizontal" android:layout_height="45dip" android:paddingTop="10dip" android:textStyle="bold"> + </TextView> + </TableRow> + + <TableRow android:id="@+id/widget165" android:layout_width="fill_parent" + android:layout_below="@+id/widget148" + android:layout_alignParentLeft="true" android:layout_height="50dip"> + <TextView android:id="@+id/txtMonoStereo" android:text="@string/monoStereo" + android:textSize="18sp" android:layout_width="80dip" + android:textColor="@android:color/white" android:layout_weight="1" + android:layout_marginLeft="15dip" android:layout_height="30dip"> + </TextView> + <Spinner android:id="@+id/spnMonoStereo" + android:layout_weight="1" + android:layout_width="80dip" android:layout_marginRight="15dip" android:layout_height="40dip"> + </Spinner> + </TableRow> + <TableRow android:id="@+id/widget186" android:layout_width="fill_parent" + android:layout_below="@+id/widget130" android:layout_height="55dip"> + + <TextView android:id="@+id/powerLev" android:layout_height="45dip" + android:textSize="18sp" android:text="@string/powerLevel" + android:layout_width="80dip" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/powLevel" android:textSize="18sp" android:gravity="left" + android:layout_width="80dip" android:layout_weight="1" + android:layout_marginRight="15dip" android:layout_height="40dip"> + </EditText> + </TableRow> + + <TableRow android:id="@+id/widget130" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_height="50dip" + android:layout_below="@+id/widget186"> + + <TextView android:id="@+id/txtRdsConfig" + android:textSize="18sp" android:text="@string/txtRdsConfig" + android:layout_width="80dip" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip" android:gravity="center_horizontal" android:layout_height="45dip" android:paddingTop="10dip" android:textStyle="bold"> + </TextView> + </TableRow> + + <TableRow android:id="@+id/widget140" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_below="@+id/widget130" + android:layout_height="50dip"> + <TextView android:id="@+id/txtAfCode" android:textSize="18sp" + android:layout_width="80dip" android:layout_height="45dip" + android:text="@string/afCode" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/afCode" android:textSize="18sp" + android:layout_width="80dip" android:editable="true" + android:layout_height="45dip" android:layout_weight="1" + android:layout_marginRight="15dip"> + </EditText> + </TableRow> + + <TableRow android:id="@+id/widget145" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_below="@+id/widget140" + android:layout_height="50dip"> + <TextView android:id="@+id/txtPiCode" android:textSize="18sp" + android:layout_width="80dip" android:text="@string/picode" + android:layout_height="45dip" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/piCode" android:textSize="18sp" + android:layout_width="80dip" android:editable="true" + android:layout_height="45dip" android:layout_weight="1" + android:layout_marginRight="15dip"> + </EditText> + </TableRow> + + <TableRow android:id="@+id/widget140" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_below="@+id/widget141" android:layout_height="55dip"> + + <TextView android:id="@+id/txtPty" android:text="@string/ptyCode" + android:textSize="18sp" android:layout_width="80dip" + android:textColor="@android:color/white" android:layout_weight="1" + android:layout_marginLeft="15dip" android:layout_marginTop="10dip" + android:layout_height="30dip"> + </TextView> + <EditText android:id="@+id/EdtPty" android:textSize="18sp" android:gravity="left" + android:layout_width="80dip" android:layout_weight="1" + android:layout_marginRight="15dip" android:editable="true" android:layout_height="40dip"> + </EditText> + </TableRow> + + <TableRow android:id="@+id/widget141" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_below="@+id/widget231" android:layout_height="55dip"> + + <TextView android:id="@+id/txtgroupmask" android:text="@string/txgroupmask" + android:gravity="center_vertical" android:textSize="18sp" android:layout_height="45dip" + android:textColor="@android:color/white" android:layout_weight="1" + android:layout_marginLeft="15dip" android:layout_width="wrap_content"> + </TextView> + <CheckBox android:id="@+id/rbtnPs" android:text="@string/PS" + android:layout_height="50dip" android:layout_weight="1" android:layout_width="wrap_content" android:paddingLeft="50dip" android:checked="false"> + </CheckBox> + <CheckBox android:id="@+id/rbtnRt" android:text="@string/RT" + android:layout_height="50dip" android:layout_weight="1" android:layout_width="wrap_content" android:paddingLeft="50dip" android:checked="false"> + </CheckBox> + </TableRow> + + <!-- <TableRow android:id="@+id/widget130" android:layout_width="fill_parent" + android:layout_alignParentLeft="true" android:layout_height="50dip" + android:layout_below="@+id/widget186"> + <TextView android:id="@+id/txtRepertoire" android:text="@string/Repertoire" + android:gravity="center_vertical" android:layout_width="80dip" + android:textSize="18sp" android:layout_height="45dip" + android:textColor="@android:color/white" android:layout_weight="1" + android:layout_marginLeft="15dip"> + </TextView> + <Spinner android:id="@+id/spnRepetoire" + android:layout_height="45dip" android:layout_weight="1" + android:layout_width="80dip" android:layout_marginRight="15dip"> + </Spinner> + </TableRow>--> + + + + <TableRow android:id="@+id/widget231" android:layout_width="fill_parent" android:layout_height="55dip"> + <TextView android:id="@+id/txtPsData" + android:layout_height="45dip" android:textSize="18sp" android:text="@string/psString" + android:layout_width="80dip" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/EdtPSString" + android:textSize="18sp" + android:layout_width="80dip" android:editable="true" + android:layout_weight="1" android:layout_marginRight="15dip" android:layout_height="40dip"> + </EditText> + </TableRow> + + <TableRow android:id="@+id/widget232" android:layout_width="fill_parent" android:layout_height="55dip"> + <TextView android:id="@+id/txtRadioText" + android:layout_height="45dip" android:textSize="18sp" android:text="@string/radioText" + android:layout_width="80dip" android:textColor="@android:color/white" + android:layout_weight="1" android:layout_marginLeft="15dip"> + </TextView> + <EditText android:id="@+id/EdtRadioText" + android:textSize="18sp" + android:layout_width="80dip" android:editable="true" + android:layout_weight="1" android:layout_marginRight="15dip" android:layout_height="40dip"> + </EditText> + </TableRow> + + </TableLayout> + </ScrollView> + <LinearLayout android:id="@+id/widget173" + android:layout_below="@+id/widget231" android:layout_width="fill_parent" + android:layout_height="50dip"> + <Button android:id="@+id/btnOk" android:text="@string/btnOk" + android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_weight="1"> + </Button> + <Button android:id="@+id/btnCancel" android:text="@string/btnCancel" + android:layout_alignTop="@+id/ok_button" android:layout_width="wrap_content" + android:layout_height="fill_parent" android:layout_weight="1"> + </Button> + </LinearLayout> + + </LinearLayout> diff --git a/tools/FM/FmTxApp/res/layout/main.xml b/tools/FM/FmTxApp/res/layout/main.xml new file mode 100644 index 0000000..4c67435 --- /dev/null +++ b/tools/FM/FmTxApp/res/layout/main.xml @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:id="@+id/ParentLayout" android:orientation="vertical" + android:background="@drawable/wallpaper_fmtx"> + + <ScrollView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/scrollview1" + android:layout_weight="1"> + <LinearLayout android:id="@+id/widget0" + android:orientation="vertical" android:layout_height="fill_parent" + android:layout_width="fill_parent"> + <LinearLayout android:id="@+id/widget224" + android:layout_alignParentTop="false" android:layout_alignParentLeft="true" + android:layout_marginTop="15dip" + android:layout_width="fill_parent" android:layout_height="70dip"> + <ImageView android:id="@+id/imgFTP" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginLeft="30dip" android:src="@drawable/txradio_ics"> + </ImageView> + <TextView android:id="@+id/lblFmRx" android:layout_width="fill_parent" + android:layout_height="70dip" android:layout_marginTop="15dip" + android:text="@string/app_name" android:textSize="30sp" + android:textStyle="bold" android:layout_marginLeft="20dip" + android:layout_gravity="center"> + </TextView> + </LinearLayout> + <LinearLayout android:id="@+id/widget38" + android:orientation="vertical" android:layout_below="@+id/widget0" + android:layout_alignParentLeft="true" android:layout_width="fill_parent" + android:layout_marginTop="30dip" android:layout_height="100dip"> + + <CheckBox android:id="@+id/ChbTx" android:text="@string/startTx" + android:clickable="true" android:layout_height="60dip" + android:layout_gravity="center_horizontal" android:layout_width="180dip" + android:textSize="25sp"> + </CheckBox> + </LinearLayout> + <LinearLayout android:id="@+id/widget49" + android:layout_width="fill_parent" android:layout_below="@+id/widget38" + android:layout_alignParentLeft="true" android:layout_height="100dip"> + <TextView android:id="@+id/txtFreq" android:text="@string/freq" + android:layout_height="60dip" android:textSize="25sp" + android:layout_width="wrap_content" android:layout_marginLeft="10dip" + android:textColor="@android:color/white"> + </TextView> + <EditText android:id="@+id/edtTxFreq" + android:layout_height="60dip" android:inputType="numberDecimal" + android:text="@string/empty" android:textSize="22sp" + android:layout_width="wrap_content" android:layout_weight="1" android:layout_marginLeft="20dip" android:layout_marginRight="20dip"> + </EditText> + <TextView android:id="@+id/widget102" android:text="@string/KHz" + android:layout_height="60dip" android:textSize="22sp" android:textStyle="bold" + android:layout_width="wrap_content" android:textColor="@android:color/white" android:layout_marginRight="30dip"> + </TextView> + </LinearLayout> + + <!-- + <LinearLayout android:id="@+id/widget100" + android:layout_width="fill_parent" android:orientation="horizontal" + android:layout_marginBottom="10dip" android:layout_height="50dip"> + + <SeekBar android:id="@+id/FreqBar" android:max="70" + android:progress="5" android:secondaryProgress="10" + android:scrollbarAlwaysDrawVerticalTrack="false" + android:layout_height="30dip" android:layout_gravity="center" + android:layout_marginLeft="30dip" android:layout_width="250dip"/> + </LinearLayout> + --> + <LinearLayout android:id="@+id/widget175" + android:layout_alignParentTop="true" android:layout_alignParentLeft="true" + android:layout_width="fill_parent" android:layout_height="70dip"> + + + <CheckBox android:id="@+id/chbEnableRds" android:text="@string/EnableRds" + android:clickable="true" android:layout_height="60dip" + android:layout_gravity="center_horizontal" + android:layout_centerInParent="false" android:layout_marginLeft="25dip" + android:layout_width="200dip" android:textSize="25sp"> + </CheckBox> + <CheckBox android:id="@+id/chbMute" android:text="@string/Mute" + android:clickable="true" android:layout_height="60dip" + android:layout_gravity="center_horizontal" + android:layout_centerInParent="false" android:layout_marginLeft="35dip" + android:layout_width="150dip" android:textSize="25sp"> + </CheckBox> + </LinearLayout> + </LinearLayout> + </ScrollView> + <LinearLayout android:id="@+id/widget173" + + android:layout_width="fill_parent" + android:layout_height="50dip" android:gravity="right"> + + <Button android:id="@+id/btnOk" android:text="@string/btnOk" + android:layout_height="fill_parent" + android:layout_width="120dip"> + </Button> + </LinearLayout> + +</LinearLayout> diff --git a/tools/FM/FmTxApp/res/values/color.xml b/tools/FM/FmTxApp/res/values/color.xml new file mode 100644 index 0000000..db85511 --- /dev/null +++ b/tools/FM/FmTxApp/res/values/color.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> + +<resources> + <drawable name="red">#7f00</drawable> + <drawable name="blue">#770000ff</drawable> + <drawable name="green">#7700ff00</drawable> + <drawable name="yellow">#77ffff00</drawable> + + <drawable name="screen_background_black">#ff000000</drawable> + <drawable name="translucent_background">#e0000000</drawable> + <drawable name="transparent_background">#00000000</drawable> + + <color name="solid_red">#f00</color> + <color name="solid_blue">#0000ff</color> + <color name="solid_green">#f0f0</color> + <color name="solid_yellow">#ffffff00</color> + + <color name="black">#000</color> + <color name="magic_flame">#00ff2222</color> + <color name="button_text">#ffffffff</color> + +</resources> + + + + + diff --git a/tools/FM/FmTxApp/res/values/strings.xml b/tools/FM/FmTxApp/res/values/strings.xml new file mode 100644 index 0000000..5b39485 --- /dev/null +++ b/tools/FM/FmTxApp/res/values/strings.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> +<string name="app_tx">FM Transmitter Application</string> +<string name="txtplatform"> TI\'s V4L2 based FM solution for Android</string> +<string name="lblversion">Version:</string> +<string name="txtversion">0.1</string> +<string name="app_txhelp">Help</string> + <string name="Fm_Tx">FM Transmitter</string> + <string name="app_name">TI\'s FM Radio Transmitter</string> + <string name="btnOptions">Options</string> + <string name="btnExit">Exit</string> + <string name="on">ON</string> + <string name="off">OFF</string> + <string name="KHz">MHz</string> + <string name="freq">Frequency</string> + <string name="configure">configure</string> + <string name="exit">Exit</string> + <string name="about">About</string> + <string name="btnOk">OK</string> +<string name="btnCancel">Cancel</string> +<string name="btnBack">Back</string> +<string name="japaneseBand">Japanese Band</string> +<string name="preEmphasis">Pre Emphasis Filter(Usec):</string> +<string name="radioData">Radio data(RDS)</string> +<string name="advanced">Advanced</string> +<string name="rdsTransmit">RDS Transmit:</string> +<string name="sec50">50</string> +<string name="sec75">75</string> +<string name="none">None</string> +<string name="PS">PS</string> +<string name="PS:">PS:</string> +<string name="RT">RT</string> +<string name="RT:">RT:</string> +<string name="TP">TP</string> +<string name="TP:">TP:</string> +<string name="stereo">Stereo</string> +<string name="rdsAf">RDS AF</string> +<string name="app_rds">FM TX Config</string> +<string name="freqRangeEurope"> 87.50MHz - 108.00MHz </string> +<string name="freqRangeJapan"> 76MHz - 90MHz </string> +<string name="label"> MHz </string> +<string name="labelhz">MHz</string> +<string name="rx_freq_val">104.00</string> +<string name="Manual">Manual</string> +<string name="Configure">Configure</string> +<string name="Help">Help</string> +<string name="enterFreq_Dialog">Enter Frequency</string> +<string name="Stereo">Stereo</string> +<string name="empty"></string> +<string name="pty">Dynamic PTY</string> +<string name="comp">Compression</string> +<string name="picode">PI Code:</string> +<string name="speed">Speed:</string> +<string name="size">Size:</string> +<string name="rdsmode">RDS Raw Mode</string> +<string name="ptycode">PTY Code:</string> +<string name="dicode">Dicodes:</string> +<string name="deemphasis">De-Emp Filter :</string> +<string name="rdssystem">RDS System :</string> +<string name="number">Enter valid number</string> +<string name="seeking">Seeking ....</string> +<string name="playing">Playing ....</string> +<string name="pstxt">PS String</string> +<string name="index">Index</string> +<string name="rdsConfigApp">RDS Config</string> +<string name="mode">Mode</string> +<string name="enableRds">Enable RDS</string> +<string name="powerLevel">Power</string> +<string name="monoStereo">Audio Mode</string> +<string name="preEmp">Pre-Emp Filter</string> +<string name="Settings">Advanced Settings Filter</string> +<string name="dispalyMode">Display Mode</string> +<string name="MusicSpeech">Music/ Speech</string> +<string name="transmissionMode">Tx Mode</string> +<string name="Repertoire">Repertoire</string> +<string name="TrafficCodes">Traffic Codes</string> +<string name="tp">TP</string> +<string name="ta">TA</string> +<string name="ecc">ECC</string> +<string name="wrireRAWdata">Wrire RAW data</string> +<string name="startTx">Start Transmitting</string> +<string name="afcode">Af Code</string> +<string name="advancedConfig">Advanced Congif</string> +<string name="psString">PS String</string> +<string name="Mute">Mute</string> +<string name="EnableRds">Enable Rds</string> +<string name="RdsSetting">RdsSetting</string> +<string name="txgroupmask">Group Mask</string> +<string name="empFilter">Emp.Filter</string> +<string name="scrollSpeed">Scroll Speed</string> +<string name="ptyCode">PTY Code</string> +<string name="radioText">RadioText</string> +<string name="afCode">Alternate Frequency</string> +<string name="txtRdsConfig">RDS Configuration:</string> +<string name="txtTXConfig">TX Configuration:</string> + +</resources> diff --git a/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTx.java b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTx.java new file mode 100644 index 0000000..20e81b6 --- /dev/null +++ b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTx.java @@ -0,0 +1,1459 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmtxapp; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.util.Log; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; +import android.app.AlertDialog; +import android.view.KeyEvent; +import android.view.View.OnKeyListener; +import android.widget.Toast; +import android.app.ProgressDialog; +import android.content.BroadcastReceiver; +import android.os.Handler; +import android.os.Message; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.SharedPreferences; +import android.content.DialogInterface; + +/*************** For calling lower layer********************/ +import com.ti.fm.FmRadio; +import com.ti.fm.FmRadioIntent; +import com.ti.fm.IFmConstants; +import android.server.*; +/**************************************************************/ + +public class FmTx extends Activity implements View.OnClickListener, +OnCheckedChangeListener,OnKeyListener,FmTxAppConstants,FmRadio.ServiceListener{ + /** Called when the activity is first created. */ + public static final String TAG = "FmTxApp"; + + /******************************************** + * Menu Constants + ********************************************/ + public static final int MENU_CONFIGURE = Menu.FIRST + 1; +// public static final int MENU_ADVANCED = Menu.FIRST + 2; + public static final int MENU_EXIT = Menu.FIRST + 2; + public static final int MENU_ABOUT = Menu.FIRST + 3; + + + /******************************************** + * Initail values + ********************************************/ + private int mTxMode = INITIAL_VAL; + private int mPiCode = INITIAL_VAL; + private int mAfCode = INITIAL_VAL; + private int mTuneFreq = INITIAL_VAL; + private int mDeEmpFilter = INITIAL_VAL; + private int mPowerLevel = INITIAL_VAL; + private int mRepertoire = INITIAL_VAL; + private int mMonoStereo = INITIAL_VAL; + private int mDisplayMode = INITIAL_VAL; + private int mEcc = INITIAL_VAL; + private int mTxMusicSpeech = INITIAL_VAL; + private int mTxEmpFilter = INITIAL_VAL; + private int mTxPtyCode = INITIAL_VAL; + private Float mFreq = (float)INITIAL_VAL; + //private int mMute = INITIAL_VAL; + /*Flag to check if service is connected*/ + boolean mFmServiceConnected = false; + + + public SharedPreferences fmTxPreferences; + private int mAppState = STATE_DEFAULT; + + public static Float freqValue = (float)0; + private ProgressDialog pd = null,configPd; + + public static FmRadio sFmRadio; + private CheckBox startTxBtn,enableRdsBtn,chbMute; + private EditText textFreq; + private boolean mStatus; + private Button btnOk; + private boolean isFmEnabled = false; + + /* Actvity result index */ + public static final int ACTIVITY_CONFIG = 1; + + + private NotificationManager mNotificationManager; + + + Context mContext; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.d(TAG, "onCreate enter"); + mContext = this; + + + // Register for FM TX intent broadcasts. + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(FmRadioIntent.FM_TX_ENABLED_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_TUNE_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_DISABLED_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_START_TRANSMISSION_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_STOP_TRANSMISSION_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_DESTROY_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_ENABLE_RSD_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_DISABLE_RSD_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_PS_DISPLAY_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_TRANSMISSION_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_POWER_LEVEL_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_RDS_TEXT_PS_MSG_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_MONO_STEREO_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_MUTE_MODE_ACTION); + intentFilter.addAction(FmRadioIntent.FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION); + registerReceiver(mReceiver, intentFilter); + + + sFmRadio = new FmRadio(this, this); + + setContentView(R.layout.main); + initControls(); + loadlastSaveddata(); + + + } + + @Override + public void onPause() { + super.onPause(); + Log.d(TAG, "onPause enter"); + saveLastData(); +} +/****************************************** +* +* enableTx() +* +*******************************************/ + private void enableTx() + { + + Log.i(TAG,"enableTx()"); + + switch (sFmRadio.txGetFMState()){ + + case STATE_DISABLED: + case STATE_DEFAULT: + mStatus = sFmRadio.txEnable(); + if (mStatus == false) { + Log.i(TAG, "Fm Tx --> Cannot enable TX !!"); + + CharSequence text = "Sorry!! Cannot enable TX"; + int duration = Toast.LENGTH_SHORT; + + Toast toast = Toast.makeText(mContext, text, duration); + toast.setGravity(android.view.Gravity.CENTER_VERTICAL, 0, 0); + toast.show(); + + finish(); + + } + else{ + Log.i(TAG, "Fm Tx --> Enabling TX !!"); + pd = ProgressDialog.show(this, "Please wait..", "Enabling FM TX", true, false); + } + + + break; + + case STATE_ENABLED: + loadlastSaveddata(); + Log.i(TAG, "Fm Tx is already Enabled."); + break; + + } + + + } + + +public void onServiceConnected() { + Log.i(TAG, "onServiceConnected"); + mFmServiceConnected =true; + enableTx(); +} + +public void onServiceDisconnected() { + Log.d(TAG, "Lost connection to service"); + mFmServiceConnected =false; + sFmRadio = null; +} + + +/****************************************** +* +* onCreateOptionsMenu() +* +*******************************************/ + public boolean onCreateOptionsMenu(Menu menu) { + + super.onCreateOptionsMenu(menu); + MenuItem item; + + item = menu.add(0, MENU_CONFIGURE, 0, R.string.configure); + item.setIcon(R.drawable.configure); + + + /*item = menu.add(0, MENU_ADVANCED, 0, R.string.advanced); + item.setIcon(R.drawable.configure);*/ + + item = menu.add(0, MENU_ABOUT, 0, R.string.about); + item.setIcon(R.drawable.icon); + + item = menu.add(0, MENU_EXIT, 0, R.string.exit); + item.setIcon(R.drawable.icon); + + return true; + } + +/****************************************** +* +* onOptionsItemSelected() +*Handles item selections +* +*******************************************/ + + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case MENU_CONFIGURE: + + /* Start the configuration window */ + Intent irds = new Intent("android.intent.action.RDSPARAM_CONFIG"); + startActivityForResult(irds, ACTIVITY_CONFIG); + + break; + + /* case MENU_ADVANCED: + Intent iAdvanced = new Intent("android.intent.action.TXPARAM_CONFIG"); + startActivityForResult(iAdvanced, ACTIVITY_ADVANCED); + + + break;*/ + + case MENU_EXIT: + saveLastData(); + /* + * The exit from the FM application happens here The audio will be + * disabled and when he callback for this is recived, FM will be + * disabled + */ + mStatus = sFmRadio.txDisable(); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Cannot Disable TX !!"); + + } + else{ + Log.i(TAG, "Fm Tx--> Disabling TX !!"); + } + break; + + case MENU_ABOUT: + /* Start the help window */ + Intent iTxHelp = new Intent("android.intent.action.START_TXABOUT"); + startActivity(iTxHelp); + break; + + + } + return super.onOptionsItemSelected(item); + } + + + /** Adds Delay of 2 seconds */ + private void insertDelayThread() { + + new Thread() { + public void run() { + try { + // Add some delay to make sure all configuration has been + // completed. + sleep(2000); + } catch (Exception e) { + Log.e(TAG, "InsertDelayThread()-- Exception !!"); + } + // Dismiss the Dialog + configPd.dismiss(); + } + }.start(); + + } + + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + Log.i(TAG, "onActivityResult"); + switch (requestCode) { + +/* case (ACTIVITY_ADVANCED):{ + if (resultCode == Activity.RESULT_OK) { + setAdvancedConfig(); + configPd = ProgressDialog.show(this, "Please wait..", + "Applying Advanced Configuration", true, false); + // The delay is inserted to make sure all the configurations + // have been completed. + insertDelayThread(); + + } + } + break; + +*/ + + case (ACTIVITY_CONFIG): { + if (resultCode == Activity.RESULT_OK) { + //Log.i(TAG, "ActivityFmRdsConfig configurationState "+ configurationState); + + setRdsConfig(); + setAdvancedConfig(); + configPd = ProgressDialog.show(this, "Please wait..", + "Applying new Configuration", true, false); + // The delay is inserted to make sure all the configurations + // have been completed. + insertDelayThread(); + + } + } + break; + + } + } + + + + +/************************************* + +setAdvancedConfig() + +*************************************/ +private void setAdvancedConfig() +{ + Log.i(TAG, "setAdvancedConfig"); + SharedPreferences fmTxParamConfigPreferences = getSharedPreferences( "fmConfigPreferences", MODE_PRIVATE); + + + //Set Music-Speech Flag +/* int txMusicSpeech = fmTxParamConfigPreferences.getInt(MUSIC_SPEECH, DEFAULT_MUSICSPEECH); + Log.i(TAG,"setAdvancedConfig-- >txMusicSpeech = "+txMusicSpeech); + if (mTxMusicSpeech != txMusicSpeech) { + mTxMusicSpeech = txMusicSpeech; + mStatus = sFmRadio.txSetRdsMusicSpeechFlag(txMusicSpeech); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsMusicSpeechFlag TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsMusicSpeechFlag is SUCCESSFUll !!"); + } + } +*/ + //Set Pre-Emp Filter +/* int txEmpFilter = fmTxParamConfigPreferences.getInt(EMP_FILTER, DEFAULT_EMPFILTER); + Log.i(TAG,"setAdvancedConfig-- >txEmpFilter = "+txMusicSpeech); + if (mTxEmpFilter != txEmpFilter) { + mTxEmpFilter = txEmpFilter; + mStatus = sFmRadio.txSetPreEmphasisFilter(txEmpFilter); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetPreEmphasisFilter TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetPreEmphasisFilter is SUCCESSFUll !!"); + } + } +*/ + + // Before Setting RT String , set the Tx group Mask + + Log.i(TAG, "txSetRdsTransmittedGroupsMask(RT)"); + mStatus = sFmRadio.txSetRdsTransmittedGroupsMask(RDS_RADIO_TRANSMITTED_GRP_RT_MASK | RDS_RADIO_TRANSMITTED_GRP_PS_MASK); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsTransmittedGroupsMask TX failed !!"); + }else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsTransmittedGroupsMask is SUCCESSFUll !!"); + } + + //Set Radio Text Code + + String txRTCode = fmTxParamConfigPreferences.getString(RT_STRING, DEF_RT_STRING); + boolean rtMask= fmTxParamConfigPreferences.getBoolean(RTENABLED,false); + int rds_mode = 2; + + Log.i(TAG,"setAdvancedConfig-- >txRT = "+txRTCode); + if (rtMask) { + mStatus = sFmRadio.txSetRdsTextRtMsg(rds_mode, txRTCode, txRTCode.length()); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsRadioText TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsRadioText is SUCCESSFUll !!"); + } + }else { + txRTCode = ""; + mStatus = sFmRadio.txSetRdsTextRtMsg(rds_mode, txRTCode, txRTCode.length()); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsRadioText TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsRadioText is Emty!!"); + } + } + + //Set PS Name + String txPSName = fmTxParamConfigPreferences.getString(PS_STRING, DEF_PS_STRING); + boolean psMask= fmTxParamConfigPreferences.getBoolean(PSENABLED,false); + + Log.i(TAG,"setAdvancedConfig-- >txPSName = "+txPSName); + if (psMask) { + mStatus = sFmRadio.txSetRdsTextPsMsg(txPSName); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsPSName TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsPSName is SUCCESSFUll !!"); + } + }else { + txPSName = ""; + mStatus = sFmRadio.txSetRdsTextPsMsg(txPSName); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsPSName TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsPSName is Empty !!"); + } + } + + //Set Pty Code + int txPtyCode = fmTxParamConfigPreferences.getInt(PTY,DEFAULT_PTY); + Log.i(TAG,"setAdvancedConfig-- >txPtyCode = "+txPtyCode); + if (mTxPtyCode != txPtyCode) { + mTxPtyCode = txPtyCode; + mStatus = sFmRadio.txSetRdsPtyCode(txPtyCode); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsPtyCode TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsPtyCode is SUCCESSFUll !!"); + } + } + +/* + int ecc = fmTxParamConfigPreferences.getInt(ECC, DEFAULT_ECC); + Log.i(TAG,"setAdvancedConfig-- >ecc ="+ecc); + if (mEcc != ecc) { + mEcc = ecc; + mStatus = sFmRadio.txSetRdsECC(ecc); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsECC TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsECC is SUCCESSFUll !!"); + } + } +*/ + + +} + + + +/************************************* + +setRdsConfig() + +*************************************/ +private void setRdsConfig() +{ + Log.i(TAG, "setRdsConfig"); + SharedPreferences fmConfigPreferences = getSharedPreferences( + "fmConfigPreferences", MODE_PRIVATE); + + String psStr = fmConfigPreferences.getString(PS_STRING,DEF_PS_STRING); + Log.i(TAG, "setRdsConfig()--- psStr= " + psStr.toString()); + + + String rtstr = fmConfigPreferences.getString(RT_STRING,DEF_RT_STRING); + Log.i(TAG, "setRdsConfig()--- RtStr= " + rtstr.toString()); + + // Set TxMode + int txMode = fmConfigPreferences.getInt(TX_MODE, DEFAULT_TXMODE); + Log.i(TAG,"setRdsConfig-- >txMode = "+txMode); + + mStatus = sFmRadio.txSetRdsTransmissionMode(txMode); + /*if (mTxMode != txMode) { + mTxMode = txMode; + mStatus = sFmRadio.txSetRdsTransmissionMode(txMode); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsTransmissionMode TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsTransmissionMode is SUCCESSFUll !!"); + } + }*/ + + // Set Ps DispalyMode + /*int psDisplayMode = fmConfigPreferences.getInt(DISPLAY_MODE, DEFAULT_DISPLAYMODE); + Log.i(TAG,"setRdsConfig-- >psDisplayMode = "+psDisplayMode); + if (mDisplayMode != psDisplayMode) { + mDisplayMode = txMode; + mStatus = sFmRadio.txSetRdsPsDisplayMode(psDisplayMode); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsPsDisplayMode TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsPsDisplayMode is SUCCESSFUll !!"); + } + }*/ + + + + // Set Mono/Stereo Flag + int monoStereo = fmConfigPreferences.getInt(MONO_STEREO, DEFAULT_MONOSTEREO); + Log.i(TAG,"setRdsConfig-- >monoStereo = "+monoStereo); + if (mMonoStereo != monoStereo) { + mMonoStereo = monoStereo; + mStatus = sFmRadio.txSetMonoStereoMode(monoStereo); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetMonoStereoMode TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetMonoStereoMode is SUCCESSFUll !!"); + } + } + + + // Set Repetoire + /*int repetoire = fmConfigPreferences.getInt(REPERTOIRE, DEFAULT_REPERTOIRE); + Log.i(TAG,"setRdsConfig-- >repetoire = "+repetoire); + if (mMonoStereo != repetoire) { + mMonoStereo = repetoire; + mStatus = sFmRadio.txSetRdsTextRepertoire(repetoire); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsTextRepertoire TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsTextRepertoire is SUCCESSFUll !!"); + } + }*/ + + + // Before Setting Ps String , set the Tx group Mask + boolean rtMask= fmConfigPreferences.getBoolean(RTENABLED,false); + boolean psMask= fmConfigPreferences.getBoolean(PSENABLED,false); + int rdsMask=(int) RDS_RADIO_TRANSMITTED_GRP_RT_MASK; + if(rtMask) + rdsMask = (int) (rdsMask |RDS_RADIO_TRANSMITTED_GRP_RT_MASK) ; + if(psMask) + rdsMask = (int) (rdsMask | RDS_RADIO_TRANSMITTED_GRP_PS_MASK); + + Log.i(TAG, "txSetRdsTransmittedGroupsMask(rdsMask )" +rdsMask ); + mStatus = sFmRadio.txSetRdsTransmittedGroupsMask(RDS_RADIO_TRANSMITTED_GRP_PS_MASK); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsTransmittedGroupsMask TX failed !!"); + }else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsTransmittedGroupsMask is SUCCESSFUll !!"); + } + + + + + // Set Power Level + int powerLevel = fmConfigPreferences.getInt(POWER,DEFAULT_POWER); + Log.i(TAG,"setRdsConfig-- >powerLevel ="+powerLevel); + if (mPowerLevel != powerLevel) { + mPowerLevel = powerLevel; + mStatus = sFmRadio.txSetPowerLevel(powerLevel); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetPowerLevel TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetPowerLevel is SUCCESSFUll !!"); + } + } + + + + // Set Pi Code + int piCode = fmConfigPreferences.getInt(PI_CODE,DEFAULT_PICODE); + Log.i(TAG,"setRdsConfig-- >piCode =" + piCode ); + + if (mPiCode != piCode) { + mPiCode = piCode; + mStatus = sFmRadio.txSetRdsPiCode(piCode); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsPiCode TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsPiCode is SUCCESSFUll !!"); + } + } + + + // Set Af Code + int afCode = fmConfigPreferences.getInt(AF_CODE,DEFAULT_AFCODE); + Log.i(TAG,"setRdsConfig-- >afCode = "+afCode); + if (mAfCode != afCode) { + mAfCode = afCode; + mStatus = sFmRadio.txSetRdsAfCode(afCode); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsAfCode TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsAfCode is SUCCESSFUll !!"); + } + } + + + +} +/************************************************************************************ +* +* initControls() +* Initialize all the UI controls +* +*************************************************************************************/ + public void initControls() + { + startTxBtn = (CheckBox)findViewById(R.id.ChbTx); + startTxBtn.setOnCheckedChangeListener(this); + + enableRdsBtn = (CheckBox)findViewById(R.id.chbEnableRds); + enableRdsBtn.setOnCheckedChangeListener(this); + + chbMute = (CheckBox)findViewById(R.id.chbMute); + chbMute.setOnCheckedChangeListener(this); + + textFreq = (EditText)findViewById(R.id.edtTxFreq); + + btnOk = (Button) findViewById(R.id.btnOk); + btnOk.setOnKeyListener(this); + btnOk.setOnClickListener(this); + + // Get the notification manager service. + mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); + + + } + + +/************************************************************************************ +* +* onCheckedChanged() +* +*************************************************************************************/ + + public void onCheckedChanged(CompoundButton btn, boolean checkedState) { + // TODO Auto-generated method stub + /*if (checkedState ){ + startTxBtn.setText("Uncheck to stop Tx"); + } + else{ + + //sFmRadio.txStopTransmission(); + startTxBtn.setText("Check to start Tx"); + + }*/ + + int id = btn.getId(); + switch (id) { + case R.id.ChbTx: + if (checkedState ){ + startTxBtn.setText("Uncheck to stop Tx"); + }else{ + startTxBtn.setText("Check to start Tx"); + } + break; + + case R.id.chbEnableRds: + if (checkedState ){ + enableRdsBtn.setText("Uncheck to Disable Rds"); + }else{ + enableRdsBtn.setText("Check to Enable Rds"); + } + break; + + default: + break; + } + } + +/************************************************************************************ +* +* BaseFreq() +* +*************************************************************************************/ + static float BaseFreq() { + return APP_FM_FIRST_FREQ_US_EUROPE_KHZ; + } + + +/************************************************************************************ +* +*LastFreq() +* +*************************************************************************************/ + static float LastFreq() { + return APP_FM_LAST_FREQ_US_EUROPE_KHZ; + } + + +/************************************************************************************ +* Update the Frequency label with the given value +* +*************************************************************************************/ + + + float UpdateFrequency(float freq) { + Log.d(TAG, "FM App: UpdateFrequency %d." + freq); + if (freq < BaseFreq() || freq > LastFreq()) { + freq = 0; + } + Log.d(TAG, "FM App: returned %d." + freq); + return (float) freq; + } + +/************************************************************************************ +* writeFrequency() +* +*************************************************************************************/ + private void writeFrequency() { + // get the text entered in edit box + String text = textFreq.getText().toString(); + Log.d("writeFrequency()","--> text ="+text); + try { + + float iFreq = Float.parseFloat(text); + Log.d("writeFrequency()","--> iFreq ="+iFreq); + Float validFreq = UpdateFrequency(iFreq); + if (validFreq != 0) { + freqValue = validFreq; + + } + else { + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid frequency!!").setNegativeButton( + android.R.string.ok, null).show(); + textFreq.setText(null); + } + } catch (NumberFormatException nfe) { + Log.d(TAG, "NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this).setIcon( + android.R.drawable.ic_dialog_alert).setMessage( + "Enter valid number!!").setNegativeButton( + android.R.string.ok, null).show(); + textFreq.setText(null); + freqValue = (float) 0; + } + + } + +/************************************************************************* +* +* This is a method implementation of OnKeyListener +* +*************************************************************************/ + public boolean onKey(View v, int keyCode, KeyEvent event) { + Log.i(TAG,"onKey()"); + if (event.getAction() == KeyEvent.ACTION_DOWN) { + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_CENTER: + case KeyEvent.KEYCODE_ENTER: + writeFrequency(); + if (startTxBtn.isChecked()){ + // Tune TX + Log.i(TAG, "Fm Tx--> TX Tune is (long)(freqValue.floatValue()*1000) !!"+(long)(freqValue.floatValue()*1000)); + + mStatus = sFmRadio.txTune((long)(freqValue.floatValue()*1000)); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Tune TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX Tune is SUCCESSFUll !!"); + } + } + return true; + } + } + return false; + } + + +/************************************************************************* +* +* This is a method implementation of onKeyDown +* +*************************************************************************/ + public boolean onKeyDown(int keyCode, KeyEvent event) { + Log.i(TAG,"onKeyDown()"); + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_CENTER: + writeFrequency(); + if (startTxBtn.isChecked()){ + /* Tune TX */ + mStatus = sFmRadio.txTune((long)(freqValue.floatValue()*1000)); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Tune TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX Tune is SUCCESSFUll !!"); + } + + } + return true; + + case KeyEvent.KEYCODE_DPAD_UP: + return true; + + case KeyEvent.KEYCODE_BACK: + Log.i("onKeyDown()","KEYCODE_BACK"); + finish(); + return true; + + case KeyEvent.KEYCODE_HOME: + Log.i("onKeyDown()","KEYCODE_HOME"); + //this.showNotification(R.drawable.radio, R.string.app_name,textFreq.getText(), false); + //moved the notification to TX + //finish(); + return true; + + + + /* Keys A to L are mapped to different get APIs for Testing */ + case KeyEvent.KEYCODE_A: + Log.i("onKeyDown()","KEYCODE_A"); + Log.i(TAG, "Testing txSetRdsTextPsMsg(psStr) returned = " + + sFmRadio.txSetRdsTextPsMsg("psStr")); + return true; + + case KeyEvent.KEYCODE_B: + Log.i("onKeyDown()","KEYCODE_B"); + Log.i(TAG, "Testing txWriteRdsRawData(RawData) returned= " + + sFmRadio.txWriteRdsRawData("RdsRawData")); + return true; + + case KeyEvent.KEYCODE_C: + Log.i("onKeyDown()","KEYCODE_C"); + sFmRadio.txSetRdsTransmissionMode(1); + + return true; + + case KeyEvent.KEYCODE_D: + Log.i("onKeyDown()","KEYCODE_D"); + Log.i(TAG, "Testing txSetMonoStereoMode(0) returned= " + + sFmRadio.txSetMonoStereoMode(0)); + return true; + + case KeyEvent.KEYCODE_E: + Log.i("onKeyDown()","KEYCODE_E"); + Log.i(TAG, "Testing txSetPreEmphasisFilter(1) returned = " + + sFmRadio.txSetPreEmphasisFilter(1)); + return true; + + case KeyEvent.KEYCODE_F: + Log.i("onKeyDown()","KEYCODE_F"); + Log.i(TAG, "Testing txSetMuteMode(0) returned = " + + sFmRadio.txSetMuteMode(0)); + return true; + + case KeyEvent.KEYCODE_G: + Log.i("onKeyDown()","KEYCODE_G"); + Log.i(TAG, "Testing txSetRdsAfCode(224) returned = " + + sFmRadio.txSetRdsAfCode(224)); + return true; + + case KeyEvent.KEYCODE_H: + Log.i("onKeyDown()","KEYCODE_H"); + Log.i(TAG,"Testing txSetRdsPiCode(5) returned = " + + sFmRadio.txSetRdsPiCode(5)); + return true; + + case KeyEvent.KEYCODE_I: + Log.i("onKeyDown()","KEYCODE_I"); + Log.i(TAG, "Testing txSetRdsPtyCode(0) returned = " + + sFmRadio.txSetRdsPtyCode(0)); + return true; + + case KeyEvent.KEYCODE_J: + Log.i("onKeyDown()","KEYCODE_J"); + Log.i(TAG, "Testing txSetRdsTextRepertoire(0) returned = " + + sFmRadio.txSetRdsTextRepertoire(0)); + return true; + + case KeyEvent.KEYCODE_K: + Log.i("onKeyDown()","KEYCODE_K"); + Log.i(TAG,"Testing txSetRdsPsDisplayMode(0) returned = " + + sFmRadio.txSetRdsPsDisplayMode(0)); + return true; + + case KeyEvent.KEYCODE_L: + Log.i("onKeyDown()","KEYCODE_L"); + Log.i(TAG, "Testing txChangeDigitalSourceConfiguration(1) returned = " + + sFmRadio.txChangeDigitalSourceConfiguration(1)); + + return true; + + case KeyEvent.KEYCODE_M: + Log.i("onKeyDown()","KEYCODE_M"); + Log.i(TAG, "Testing txSetRdsPsScrollSpeed(3) returned = " + + sFmRadio.txSetRdsPsScrollSpeed(3)); + return true; + + case KeyEvent.KEYCODE_N: + Log.i("onKeyDown()","KEYCODE_N"); + Log.i(TAG, "Testing txSetRdsTextRtMsg(2,RtMsg,5) returned = " + + sFmRadio.txSetRdsTextRtMsg(2,"RtMsg",5)); + return true; + + case KeyEvent.KEYCODE_O: + Log.i("onKeyDown()","KEYCODE_O"); + Log.i(TAG, + "Testing txSetRdsTransmittedGroupsMask(1) returned = " + + sFmRadio.txSetRdsTransmittedGroupsMask(7)); + return true; + + case KeyEvent.KEYCODE_P: + Log.i("onKeyDown()","KEYCODE_P"); + Log.i(TAG, + "Testing txSetRdsTrafficCodes(0,0) returned = " + + sFmRadio.txSetRdsTrafficCodes(0,0)); + + return true; + + case KeyEvent.KEYCODE_Q: + Log.i("onKeyDown()","KEYCODE_Q"); + Log.i(TAG, + "Testing txSetRdsMusicSpeechFlag(1) returned = " + + sFmRadio.txSetRdsMusicSpeechFlag(1)); + + return true; + + case KeyEvent.KEYCODE_R: + Log.i("onKeyDown()","KEYCODE_R"); + Log.i(TAG, "Testing txSetRdsECC(0) returned = " + + sFmRadio.txSetRdsECC(0)); + + return true; + + case KeyEvent.KEYCODE_S: + Log.i("onKeyDown()","KEYCODE_S"); + Log.i(TAG, + "Testing txChangeAudioSource(0,0) returned = " + + sFmRadio.txChangeAudioSource(0,0)); + return true; + + case KeyEvent.KEYCODE_T: + Log.i("onKeyDown()","KEYCODE_T"); + Log.i(TAG, + "Testing txEnableRds() returned = " + + sFmRadio.txEnableRds()); + return true; + + case KeyEvent.KEYCODE_U: + Log.i("onKeyDown()","KEYCODE_U"); + Log.i(TAG, + "Testing txDisableRds() returned = " + + sFmRadio.txDisableRds()); + return true; + + case KeyEvent.KEYCODE_V: + Log.i("onKeyDown()","KEYCODE_V"); + Log.i(TAG, + "Testing txStartTransmission() returned = " + + sFmRadio.txStartTransmission()); + return true; + + case KeyEvent.KEYCODE_W: + Log.i("onKeyDown()","KEYCODE_W"); + Log.i(TAG, + "Testing txStopTransmission() returned = " + + sFmRadio.txStopTransmission()); + return true; + + case KeyEvent.KEYCODE_X: + Log.i("onKeyDown()","KEYCODE_X"); + Log.i(TAG, + "Testing txSetPowerLevel() returned = " + + sFmRadio.txSetPowerLevel(0)); + return true; + + case KeyEvent.KEYCODE_Y: + Log.i("onKeyDown()","KEYCODE_Y"); + Log.i(TAG, + "Testing txTune() returned = " + + sFmRadio.txTune(104000)); + return true; + + } + return false; + } + + + +private void setMuteMode() +{ + + Log.i(TAG,"setMuteMode()"); + // Mute + if(chbMute.isChecked()== true){ + mStatus = sFmRadio.txSetMuteMode(0); + }else{ + mStatus = sFmRadio.txSetMuteMode(1); + } + + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Cannot Mute TX !!"); + }else{ + Log.i(TAG, "Fm Tx--> Muting TX !!"); + } + +} + + +/************************************************************************* +* +* This is a method implementation of onClick +* +*************************************************************************/ + public void onClick(View view) { + Log.i(TAG, "onClick()"); + int id = view.getId(); + switch (id) { + case R.id.btnOk: + setMuteMode(); + writeFrequency(); + fmTxPreferences = getSharedPreferences("fmTxPreferences", MODE_PRIVATE); + + if (startTxBtn.isChecked() && freqValue != 0 ){ + Log.i(TAG, " FM-------> mFreq:" + mFreq); + Log.i(TAG, " FM-------> freqValue" + freqValue); + if(((mFreq-freqValue) < -.00001) ||((mFreq-freqValue) > .00001)) { + /* Tune TX */ + mFreq = freqValue; + Log.i(TAG, " FM-------> mFreq:" + mFreq); + mStatus = sFmRadio.txTune((long)(freqValue.floatValue()*1000)); + Log.i(TAG, "Fm Tx--> Tune TX freqValue !!" +(long)(freqValue.floatValue()*1000)); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Tune TX failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX Tune is SUCCESSFUll !!"); + } + } else { + /* Already Tuned */ + mStatus = sFmRadio.txStartTransmission(); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Stop Tx failed !!"); + }else { + Log.i(TAG, "Fm Tx--> Stop Transmission is SUCCESSFUll !!"); + } + } + }else{ + mStatus = sFmRadio.txStopTransmission(); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> Stop Tx failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> Stop Transmission is SUCCESSFUll !!"); + } + + } + + if(enableRdsBtn.isChecked()){ + sFmRadio.txEnableRds(); + }else{ + sFmRadio.txDisableRds(); + } + + + + break; + + default: + break; + } + } + + + +/************************************************************************* +* +* +* +*************************************************************************/ + private Handler mHandler = new Handler() { + + public void handleMessage(Message msg) { + + switch (msg.what) { + + + case EVENT_FM_TX_ENABLED: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_ENABLED"); + isFmEnabled = true; + mAppState = STATE_ENABLED; + if (pd != null){ + pd.dismiss(); + } + pd =null; + break; + + case EVENT_FM_TX_DISABLED: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_DISABLED"); + isFmEnabled = false; + mAppState = STATE_DISABLED; + startTxBtn.setChecked(false); + finish(); //Close the Activity + break; + + + case EVENT_FM_TX_STARTTRANSMISSION: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_STARTTRANSMISSION"); + break; + + case EVENT_FM_TX_STOPTRANSMISSION: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_STOPTRANSMISSION"); + break; + + case EVENT_FM_TX_TUNE: + mStatus = sFmRadio.txStartTransmission(); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> TX txStartTransmission failed !!"); + } + else{ + Log.i(TAG, "Fm Tx--> TX is Transmitting.."); + } + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_TUNE"); + break; + + + case EVENT_FM_TX_ENABLE_RDS: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_ENABLE_RDS"); + break; + + + case EVENT_FM_TX_DISABLE_RDS: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_DISABLE_RDS"); + break; + + case EVENT_FM_TX_SET_TRANSMISSION_MODE: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_TRANSMISSION_MODE"); + break; + + case EVENT_FM_TX_SET_PS_DISPLAY_MODE: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_PS_DISPLAY_MODE"); + break; + + case EVENT_FM_TX_SET_RDS_MUSIC_SPEECH_FLAG: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_RDS_MUSIC_SPEECH_FLAG"); + break; + + case EVENT_FM_TX_SET_MONO_STEREO_MODE: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_MONO_STEREO_MODE"); + break; + + case EVENT_FM_TX_SET_POWER_LEVEL: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_POWER_LEVEL"); + break; + + case EVENT_FM_TX_SET_MUTE_MODE: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_MUTE_MODE"); + break; + + case EVENT_FM_TX_SET_RDS_TEXT_PS_MSG: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_RDS_TEXT_PS_MSG"); + break; + + case EVENT_FM_TX_SET_RDS_TX_GRP_MASK_PS: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_RDS_TX_GRP_MASK_PS"); + + SharedPreferences fmConfigPreferences = getSharedPreferences( + "fmConfigPreferences", MODE_PRIVATE); + + String psStr = fmConfigPreferences.getString(PS_STRING,DEF_PS_STRING); + Log.i(TAG, "txSetRdsTextPsMsg()--- psStr= " + psStr.toString()); + mStatus = sFmRadio.txSetRdsTextPsMsg(psStr); + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsTextPsMsg TX failed !!"); + }else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsTextPsMsg is SUCCESSFUll !!"); + } + break; + + case EVENT_FM_TX_SET_RDS_TX_GRP_MASK_RT: + Log.i(TAG, "enter handleMessage ----EVENT_FM_TX_SET_RDS_TX_GRP_MASK_RT"); + + SharedPreferences fmTxParamConfigPreferences = getSharedPreferences( + "fmTxParamConfigPreferences", MODE_PRIVATE); + + String rtStr = fmTxParamConfigPreferences.getString(RT_STRING,DEF_RT_STRING); + Log.i(TAG, "txSetRdsTextRtMsg()--- rtStr= " + rtStr.toString()); + mStatus = sFmRadio.txSetRdsTextRtMsg(RDS_TEXT_TYPE_RT_B,rtStr,rtStr.length()); //msgType =4 + if (mStatus == false) { + Log.i(TAG, "Fm Tx--> txSetRdsTextRtMsg TX failed !!"); + }else{ + Log.i(TAG, "Fm Tx--> TX txSetRdsTextRtMsg is SUCCESSFUll !!"); + } + break; + + + }}}; + + +/************************************************************************* +* +* +* +*************************************************************************/ + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { + public void onReceive(Context context, Intent intent) { + String fmAction = intent.getAction(); + Log.i(TAG, "enter onReceive" + fmAction); + if (fmAction.equals(FmRadioIntent.FM_TX_ENABLED_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_ENABLED_ACTION " + fmAction); + mHandler.sendMessage(mHandler + .obtainMessage(EVENT_FM_TX_ENABLED, 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_DISABLED_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_DISABLED_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_DISABLED, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_TUNE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_TUNE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_TUNE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_START_TRANSMISSION_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_START_TRANSMISSION_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_STARTTRANSMISSION, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_STOP_TRANSMISSION_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_STOP_TRANSMISSION_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_STOPTRANSMISSION, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_DESTROY_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_DESTROY_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_DESTROY, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_ENABLE_RSD_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_ENABLE_RSD_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_ENABLE_RDS, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_DISABLE_RSD_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_DISABLE_RSD_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_DISABLE_RDS, + 0)); + } + + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_TRANSMISSION_MODE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_TRANSMISSION_MODE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_TRANSMISSION_MODE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_PS_DISPLAY_MODE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_PS_DISPLAY_MODE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_PS_DISPLAY_MODE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_RDS_MUSIC_SPEECH_FLAG, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_RDS_TEXT_REPERTOIRE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_TRANSMISSION_MODE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_TRANSMISSION_MODE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_TRANSMISSION_MODE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_POWER_LEVEL_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_POWER_LEVEL_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_POWER_LEVEL, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_RDS_TEXT_PS_MSG_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_RDS_TEXT_PS_MSG_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_RDS_TEXT_PS_MSG, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_MONO_STEREO_MODE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_MONO_STEREO_MODE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_MONO_STEREO_MODE, + 0)); + } + + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_MUTE_MODE_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_MUTE_MODE_ACTION " + fmAction); + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_MUTE_MODE, + 0)); + } + + if (fmAction.equals(FmRadioIntent.FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION)) { + Log.i(TAG, "enter onReceive FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION " + fmAction); + + Long grpMask = intent.getLongExtra( + FmRadioIntent.RDS_GRP_MASK, 0); + /* + if(grpMask == RDS_RADIO_TRANSMITTED_GRP_PS_MASK){ + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_RDS_TX_GRP_MASK_PS, + 0)); + }else if(grpMask == RDS_RADIO_TRANSMITTED_GRP_RT_MASK){ + mHandler.sendMessage(mHandler.obtainMessage(EVENT_FM_TX_SET_RDS_TX_GRP_MASK_RT, + 0)); + } + */ + + } + + + + } + }; + + + + + /* Save the values to the preference when the application exits */ + private void saveLastData() { + Log.i(TAG, "saveLastData()---Entered"); + fmTxPreferences = getSharedPreferences("fmTxPreferences", MODE_PRIVATE); + SharedPreferences.Editor editor = fmTxPreferences.edit(); + + editor.putBoolean(FMENABLED, startTxBtn.isChecked()); + editor.putBoolean(RDSENABLED, enableRdsBtn.isChecked()); + editor.putBoolean(MUTE, chbMute.isChecked()); + + editor.putString(FREQUENCY_STRING, textFreq.getText().toString()); + editor.putString(FREQUENCY, DEFAULT_FREQ); + + Log.d(TAG, " save FMENABLED " +isFmEnabled + "FREQUENCY_STRING"+freqValue); + editor.commit(); + Log.i(TAG, "saveLastData()---Exit"); + } + + /* Load the last saved values from the preference when the application starts */ + private void loadlastSaveddata() { + + Log.i(TAG, "loadlastSaveddata()-entered"); + fmTxPreferences = getSharedPreferences("fmTxPreferences", MODE_PRIVATE); + + isFmEnabled = fmTxPreferences.getBoolean(FMENABLED,false); + if(isFmEnabled == true) + { + startTxBtn.setChecked(true); + startTxBtn.setEnabled(true); + + }else{ + startTxBtn.setChecked(false); + startTxBtn.setEnabled(true); + } + + enableRdsBtn.setChecked(fmTxPreferences.getBoolean(RDSENABLED,false)); + enableRdsBtn.setEnabled(true); + + chbMute.setChecked(fmTxPreferences.getBoolean(MUTE,false)); + chbMute.setEnabled(true); + + textFreq.setText(fmTxPreferences.getString(FREQUENCY_STRING,null)); + + Log.d(TAG, " Load FMENABLED " +isFmEnabled + "FREQUENCY_STRING"+freqValue); + + Log.i(TAG, "loadlastSaveddata()-exit"); + } + + + + + public void onStart() { + Log.i(TAG, "onStart"); + super.onStart(); + } + + + public void onResume() { + Log.i(TAG, "onResume"); + super.onResume(); + if(mFmServiceConnected == true) + enableTx(); + + + } + + public void onDestroy() { + Log.i(TAG, "onDestroy"); + super.onDestroy(); + /* + * Unregistering the receiver , so that we dont handle any FM events + * when out of the FM application screen + */ + + unregisterReceiver(mReceiver); + } + + public int getFmTxAppState() { + Log.d(TAG, "getFmTxAppState()"); + return mAppState; + + } + + +} diff --git a/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxAppConstants.java b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxAppConstants.java new file mode 100644 index 0000000..8c96abe --- /dev/null +++ b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxAppConstants.java @@ -0,0 +1,150 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmtxapp; + +public interface FmTxAppConstants { + + /******************************************** + * Message Code + ********************************************/ + public static final int EVENT_FM_TX_ENABLED = 1; + public static final int EVENT_FM_TX_DISABLED = 2; + public static final int EVENT_FM_TX_TUNE = 3; + public static final int EVENT_FM_TX_STARTTRANSMISSION = 4; + public static final int EVENT_FM_TX_STOPTRANSMISSION = 5; + public static final int EVENT_FM_TX_DESTROY = 6; + public static final int EVENT_FM_TX_ENABLE_RDS = 7; + public static final int EVENT_FM_TX_DISABLE_RDS = 8; + public static final int EVENT_FM_TX_SET_PS_DISPLAY_MODE = 9 ; + public static final int EVENT_FM_TX_SET_RDS_MUSIC_SPEECH_FLAG = 10; + public static final int EVENT_FM_TX_SET_TRANSMISSION_MODE = 11; + public static final int EVENT_FM_TX_SET_RDS_TEXT_REPERTOIRE = 12; + public static final int EVENT_FM_TX_SET_MONO_STEREO_MODE = 13; + public static final int EVENT_FM_TX_SET_POWER_LEVEL = 14; + public static final int EVENT_FM_TX_SET_RDS_TEXT_PS_MSG = 15; + public static final int EVENT_FM_TX_SET_MUTE_MODE = 16; + public static final int EVENT_FM_TX_SET_RDS_TX_GRP_MASK_RT = 17; + public static final int EVENT_FM_TX_SET_RDS_TX_GRP_MASK_PS = 18; + /******************************************** + *Fm Radio State + ********************************************/ + public static final int STATE_ENABLED = 0; + public static final int STATE_DISABLED = 1; + public static final int STATE_ENABLING = 2; + public static final int STATE_DISABLING = 3; + public static final int STATE_PAUSE = 4; + public static final int STATE_RESUME = 5; + public static final int STATE_DEFAULT = 6; + + + /******************************************** + *Main Screen Preference save keys + ********************************************/ + public static final String FMENABLED = "FMENABLED"; + public static final String RDSENABLED = "RDSENABLED"; + public static final String FREQUENCY_STRING = "FREQUENCY_STRING"; + public static final String DEFAULT_FREQ = "90000"; + public static final String FMTXSTATE = "FMTXSTATE"; + + + + /* Actvity result index */ + public static final int ACTIVITY_CONFIG = 1; + public static final int ACTIVITY_ADVANCED = 2; + + /* Power range */ + public static final int POWER_MIN = 0; + public static final int POWER_MAX = 31; + public static final int PICODE_MIN = 0; + public static final int PICODE_MAX = 65535; + public static final int AFCODE_MIN = 75000; + public static final int AFCODE_MAX = 108000; + public static final int PTY_MIN = 0; + public static final int PTY_MAX = 31; + public static final int ECC_MIN = 0; + public static final int ECC_MAX = 65535; + + public static final long RDS_RADIO_TRANSMITTED_GRP_PS_MASK = 1; + public static final long RDS_RADIO_TRANSMITTED_GRP_RT_MASK = 2; + + public static final int RDS_TEXT_TYPE_RT_AUTO = 2; + public static final int RDS_TEXT_TYPE_RT_A = 3; + public static final int RDS_TEXT_TYPE_RT_B = 4; + + + /* Config Preference save keys */ + public static final String DISPLAY_MODE = "DISPLAY_MODE"; + public static final String TX_MODE = "TX_MODE"; + public static final String FREQUENCY = "FREQUENCY"; + public static final String REPERTOIRE = "REPERTOIRE"; + public static final String MUSIC_SPEECH = "MUSIC_SPEECH"; + public static final String ECC = "ECC"; + public static final String ECC_STRING = "ECC_STRING"; + public static final String PS_STRING = "PS_STRING"; + public static final String RT_STRING = "RT_STRING"; + public static final String PTY_STRING = "PTY_STRING"; + public static final String PTY = "PTY"; + public static final String POWER = "POWER"; + public static final String POWER_STRING = "POWER_STRING"; + public static final String DEF_POWER_STRING = "4"; + public static final String MONO_STEREO = "MONO_STEREO"; + public static final String AFCODE_STRING = "AFCODE_STRING"; + public static final String PICODE_STRING = "PICODE_STRING"; + public static final String AF_CODE = "AF_CODE"; + public static final String PI_CODE = "PI_CODE"; + public static final String EMP_FILTER = "EMP_FILTER"; + public static final String MUTE = "MUTE"; + + public static final String PSENABLED = "PSENABLED"; + public static final String RTENABLED = "RTENABLED"; + public static final String ECCENABLED = "ECCENABLED"; + + + /* Default Preference values */ + public static final int INITIAL_VAL = -1; + public static final int DEFAULT_POWER = 4; + public static final int DEFAULT_PTY = 0; + public static final int DEFAULT_TXMODE = 1; + public static final int DEFAULT_MUSICSPEECH = 0; + public static final int DEFAULT_ECC = 0; + public static final int DEFAULT_REPERTOIRE = 0; + public static final int DEFAULT_DISPLAYMODE = 0; + public static final int DEFAULT_MONOSTEREO = 1; + public static final String DEF_PS_STRING = "TI Radio PS"; + public static final String DEF_RT_STRING = "TI Radio RT"; + public static final String DEF_PTY_STRING = "0"; + public static final String DEF_ECC_STRING = "0"; + public static final int DEFAULT_AFCODE = 108000; + public static final int DEFAULT_PICODE = 0; + public static final int DEFAULT_EMPFILTER = 0; + public static final String DEFAULT_AFCODE_STRING = "108000"; + public static final String DEFAULT_PICODE_STRING = "0"; + public static final int DEF_FREQ = 90000; + public static final int EVENT_GET_FREQUENCY = 40; + + + /* Activity Intenets */ + public static final String INTENT_RDS_CONFIG = "android.intent.action.RDS_CONFIG"; + public static final String INTENT_PRESET = "android.intent.action.PRESET"; + public static final String INTENT_RXHELP = "android.intent.action.START_RXHELP"; + public static final String INTENT_RXTUNE = "android.intent.action.START_RXFREQ"; + + + public static final float APP_FM_FIRST_FREQ_US_EUROPE_KHZ = (float)87.5; + public static final float APP_FM_LAST_FREQ_US_EUROPE_KHZ = (float)108.0; +} diff --git a/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxConfig.java b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxConfig.java new file mode 100644 index 0000000..bab0574 --- /dev/null +++ b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxConfig.java @@ -0,0 +1,700 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmtxapp; + +import java.util.ArrayList; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.Spinner; +import android.widget.Toast; +import android.widget.AdapterView.OnItemSelectedListener; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.Context; +import android.widget.CompoundButton; + +public class FmTxConfig extends Activity implements View.OnKeyListener, +View.OnClickListener,CompoundButton.OnCheckedChangeListener,FmTxAppConstants +{ + + public static final String TAG = "FmRxRdsConfig"; + + /******************************************** + * Widgets + ********************************************/ + private Button btnCancel,btnOk; + private Spinner spnMonoStereo/*spnEcc,spnRepetoire,spnTxMode,spnDisplayMode*/; + private EditText txtPsStr,textPower,edtPiCode,edtAfCode; + private EditText edtRadioText,edtPty; + private CheckBox rbtnPs,rbtnRt; +/* private CheckBox chbRdsMode; + private CheckBox chbSetRdsAf;*/ + //private RadioButton rbtnTp,rbtnTa; + private ArrayAdapter<String> monoStereoAdapter; +// private ArrayAdapter<String> eccAdapter; + /*private ArrayAdapter<String> repertoireAdapter; + private ArrayAdapter<String> txModeAdapter; + private ArrayAdapter<String> emptyAdapter; + + private ArrayAdapter<String> displayAdapter; */ + private ArrayList<String> monoStereoStrings = new ArrayList<String>(); + private ArrayList<String> eccStrings = new ArrayList<String>(); + /*private ArrayList<String> repertoireStrings = new ArrayList<String>(); + private ArrayList<String> emptyStrings = new ArrayList<String>(); + private ArrayList<String> txModeStrings = new ArrayList<String>(); + private ArrayList<String> displayStrings = new ArrayList<String>(); */ + + + /******************************************** + * private variables + ********************************************/ + private Context mContext; + + /******************************************** + * public variables + ********************************************/ + public SharedPreferences fmConfigPreferences; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fmtxrdsconfig); + initControl(); + setSpinners(); + + + } + + /** Initialise the Widget controls of the Activity*/ + private void initControl() + { + btnCancel = (Button) findViewById(R.id.btnCancel); + btnCancel.setOnKeyListener(this); + btnCancel.setOnClickListener(this); + + btnOk = (Button) findViewById(R.id.btnOk); + btnOk.setOnKeyListener(this); + btnOk.setOnClickListener(this); + + /* spnDisplayMode = (Spinner)findViewById(R.id.spnDisplayMode); + spnTxMode = (Spinner)findViewById(R.id.spnTxMode); + spnRepetoire = (Spinner)findViewById(R.id.spnRepetoire);*/ + spnMonoStereo= (Spinner)findViewById(R.id.spnMonoStereo); + // spnEcc= (Spinner)findViewById(R.id.spnEcc); + + txtPsStr = (EditText)findViewById(R.id.EdtPSString); + textPower = (EditText)findViewById(R.id.powLevel); + + edtPiCode = (EditText)findViewById(R.id.piCode); + edtAfCode = (EditText)findViewById(R.id.afCode); + //rbtnTp=(RadioButton)findViewById(R.id.rbtnTp); + //rbtnTp.setOnCheckedChangeListener(this); + + //rbtnTa=(RadioButton)findViewById(R.id.rbtnTa); + //rbtnTa.setOnCheckedChangeListener(this); + + + //Edit Box + edtRadioText = (EditText)findViewById(R.id.EdtRadioText); + edtPty = (EditText)findViewById(R.id.EdtPty); + + rbtnPs = (CheckBox)findViewById(R.id.rbtnPs); + rbtnRt = (CheckBox)findViewById(R.id.rbtnRt); + + rbtnPs.setOnCheckedChangeListener(this); + rbtnRt.setOnCheckedChangeListener(this); + + } + + + /** sets the Band , De-Emp Filter and Mode option selections Spinner for the User*/ + private void setSpinners() + { + // Tx Mode Spinner + /* txModeAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, txModeStrings); + + txModeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnTxMode.setAdapter(txModeAdapter); + txModeAdapter.add("Manual"); + txModeAdapter.add("Automatic"); + spnTxMode.setOnItemSelectedListener(gItemSelectedHandler);*/ + + + // Mono/Stereo Spinner + monoStereoAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, monoStereoStrings); + + monoStereoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnMonoStereo.setAdapter(monoStereoAdapter); + //monoStereoAdapter.add("Mono"); + monoStereoAdapter.add("Stereo"); + spnMonoStereo.setOnItemSelectedListener(gItemSelectedHandler); + + + // Ecc Spinner + //eccAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, eccStrings); + + //eccAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + //spnEcc.setAdapter(eccAdapter); + //eccAdapter.add("0"); + //spnEcc.setOnItemSelectedListener(gItemSelectedHandler); + + + // Repetoire Spinner + /* repertoireAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, repertoireStrings); + + repertoireAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnRepetoire.setAdapter(repertoireAdapter); + repertoireAdapter.add("G0"); + repertoireAdapter.add("G1"); + repertoireAdapter.add("G2"); + spnRepetoire.setOnItemSelectedListener(gItemSelectedHandler);*/ + + + + // Display Mode + /* displayAdapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, displayStrings); + + displayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spnDisplayMode.setAdapter(displayAdapter); + displayAdapter.add("Static"); + displayAdapter.add("Scroll"); + spnDisplayMode.setOnItemSelectedListener(gItemSelectedHandler);*/ + + + } + + + + public OnItemSelectedListener gItemSelectedHandler = new OnItemSelectedListener() + { +// @Override + public void onItemSelected(AdapterView<?> arg0, View view, int arg2,long arg3) { + Log.d(TAG,"mono selected"+arg0.getSelectedItemPosition() ); + + + + // TODO Auto-generated method stub + + } + +// @Override + public void onNothingSelected(AdapterView<?> arg0) { + // TODO Auto-generated method stub + } + + }; + + /** Pops up the alert Dialog */ + public void showAlert(Context context,String title,String msg) + { + + new AlertDialog.Builder(context) + .setTitle(title) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage(msg) + .setNegativeButton(android.R.string.ok, null) + .show(); + + } + + //@Override + public void onClick(View view) + { + Log.i(TAG,"onClick()"); + int id = view.getId(); + switch (id) + { + + + case R.id.btnCancel: + finish(); + break; + case R.id.btnOk: + savePrefernces(); + break; + + default: + break; + } + } + + + /** Send the Intent to Parent Activity */ + private void sendAdvanceConfigIntent(){ + + Intent rdsIntent = new Intent(); + setResult(RESULT_OK, rdsIntent); + finish(); + + } + + + + /** Send the Intent to Parent Activity */ + private void sendRdsIntent(){ + + Intent rdsIntent = new Intent(); + setResult(RESULT_OK, rdsIntent); + finish(); + + } + + + + public void onCheckedChanged(CompoundButton view, boolean isChecked) + { + Log.i(TAG,"onCheckedChanged()"); + int id = view.getId(); + switch(id) + { + case R.id.rbtnRt: + + Log.i(TAG,"onCheckedChanged() rbtnRt isChecked " +isChecked); + + break; + case R.id.rbtnPs: + + Log.i(TAG,"onCheckedChanged() rbtnPs isChecked" +isChecked); + } + + } + + //@Override + public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { + int action = keyEvent.getAction(); + + if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT) { + Log.v(TAG, "KEYCODE_SOFT_RIGHT " ); + finish(); + return true; + } + + if (keyCode == KeyEvent.KEYCODE_SOFT_LEFT) { + Log.v(TAG, "KEYCODE_SOFT_LEFT " ); + savePrefernces(); + //finish(); + return true; + } + + + if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && + keyCode != KeyEvent.KEYCODE_DPAD_UP && + keyCode != KeyEvent.KEYCODE_DPAD_DOWN && + keyCode != KeyEvent.KEYCODE_ENTER) { + return false; + } + + if (action == KeyEvent.ACTION_UP) { + switch (keyCode) { + case KeyEvent.KEYCODE_ENTER: + case KeyEvent.KEYCODE_DPAD_CENTER: + + break; + + case KeyEvent.KEYCODE_DPAD_UP: + + break; + + case KeyEvent.KEYCODE_DPAD_DOWN: + + break; + } + } + return true; + } + + public void onResume(){ + super.onResume(); + Log.i(TAG,"onResume()-Entered"); + updateUiFromPreference(); + } + + public void onPause(){ + super.onPause(); + Log.i(TAG,"onPause()-Entered"); + + } + + public void onStop(){ + Log.i(TAG,"onStop()-Entered"); + super.onStop(); + } + + public void onRestart(){ + Log.i(TAG,"onRestart()-Entered"); + super.onRestart(); + + } + + + /** Updates the UI with Default/last saved values */ + private void updateUiFromPreference() { + fmConfigPreferences = getSharedPreferences("fmConfigPreferences", + MODE_PRIVATE); + Log.i(TAG, "updateUiFromPreference()"); + + edtRadioText.setText(fmConfigPreferences.getString(RT_STRING,DEF_RT_STRING)); + edtPty.setText(fmConfigPreferences.getString(PTY_STRING,DEF_PTY_STRING)); + edtPiCode.setText(fmConfigPreferences.getString(PICODE_STRING,DEFAULT_PICODE_STRING)); + + rbtnPs.setChecked(fmConfigPreferences.getBoolean(PSENABLED,false)); + rbtnRt.setChecked(fmConfigPreferences.getBoolean(RTENABLED,false)); + + Log.i(TAG,"updateUiFromPreference() --> PSENABLED = "+fmConfigPreferences.getBoolean(PSENABLED,false)); + Log.i(TAG,"updateUiFromPreference() --> RTENABLED = "+fmConfigPreferences.getBoolean(RTENABLED,false)); + + textPower.setText(fmConfigPreferences.getString(POWER_STRING,DEF_POWER_STRING)); + txtPsStr.setText(fmConfigPreferences.getString(PS_STRING,DEF_PS_STRING)); + Log.i(TAG,"updateUiFromPreference() --> PS_STRING = "+txtPsStr.getText().toString()); + edtAfCode.setText(fmConfigPreferences.getString(AFCODE_STRING,DEFAULT_AFCODE_STRING)); + + /*spnDisplayMode.setSelection(fmConfigPreferences.getInt(DISPLAY_MODE, DEFAULT_DISPLAYMODE)); + spnTxMode.setSelection(fmConfigPreferences.getInt(TX_MODE, DEFAULT_TXMODE)); + spnRepetoire.setSelection(fmConfigPreferences.getInt(REPERTOIRE, DEFAULT_REPERTOIRE));*/ + spnMonoStereo.setSelection(fmConfigPreferences.getInt(MONO_STEREO, DEFAULT_MONOSTEREO)); + //spnEcc.setSelection(fmConfigPreferences.getInt(ECC, DEFAULT_ECC)); + + /*if(spnTxMode.getSelectedItemPosition() == 0) // If Tx Mode is MANUAL, Disable AF Code & PS Strg + { + edtAfCode.setEnabled(false); + txtPsStr.setEnabled(false); + }else{ + edtAfCode.setEnabled(true); + txtPsStr.setEnabled(true); + + }*/ + + } + + + /** Saves Configuration settings in the Shared Preference */ + private void savePrefernces(){ + Log.i(TAG,"savePrefernces()"); + + fmConfigPreferences = getSharedPreferences("fmConfigPreferences",MODE_PRIVATE); + + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + + + /*editor.putInt(DISPLAY_MODE, spnDisplayMode.getSelectedItemPosition()); + editor.putInt(TX_MODE, spnTxMode.getSelectedItemPosition()); + editor.putInt(REPERTOIRE, spnRepetoire.getSelectedItemPosition());*/ + editor.putInt(MONO_STEREO, spnMonoStereo.getSelectedItemPosition()); + //editor.putInt(ECC, spnEcc.getSelectedItemPosition()); + + editor.putString(PS_STRING, txtPsStr.getText().toString()); + editor.putString(RT_STRING, edtRadioText.getText().toString()); + editor.putString(PTY_STRING, edtPty.getText().toString()); + editor.putString(PICODE_STRING, edtPiCode.getText().toString()); + editor.putBoolean(PSENABLED,rbtnPs.isChecked()); + editor.putBoolean(RTENABLED,rbtnRt.isChecked()); + + editor.commit(); + Log.i(TAG,"savePrefernces() --> PS_STRING = "+txtPsStr.getText().toString()); + Log.i(TAG,"savePrefernces() --> RT_STRING = "+ edtRadioText.getText().toString()); + + savePowerLevel(); + savePtyCode(); + sendAdvanceConfigIntent(); + savePiCode(); + saveAfCode(); + } + + /** Checks the Power value for validity */ + private boolean ptyValid(int value){ + Log.d(TAG,"ptyValid %d." +value ); + if (value < PTY_MIN || value > PTY_MAX) + { + Log.d(TAG,"TAG,ptyValid %d." +value ); + + return false; + } + else + return true; + + } + +/********************************************************************* + + savePtyCode() + +*********************************************************************/ + private void savePtyCode() + { + fmConfigPreferences = getSharedPreferences("fmConfigPreferences",MODE_PRIVATE); + + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + + try{ + int ptyValue = Integer.parseInt(edtPty.getText().toString()); + boolean valid = ptyValid(ptyValue); + if(valid || (edtPty.getText().toString()== null)) + { + editor.putString(PTY_STRING, edtPty.getText().toString()); + if(edtPty.getText().toString()== null) + editor.putInt(PTY, DEFAULT_PTY); + else + { + editor.putInt(PTY, ptyValue); + } + editor.commit(); + //sendAdvanceConfigIntent(); + } + else + { + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("Enter valid Pty value in range 0-31!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + edtPty.setText(null); + } + } + catch(NumberFormatException nfe) + { + Log.d(TAG,"--> NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("--> Enter valid pty value in range 0-31!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + edtPty.setText(null); + } + + } + + +/********************************************************************* + + savePowerLevel() + +*********************************************************************/ + private void savePowerLevel() + { + fmConfigPreferences = getSharedPreferences("fmConfigPreferences",MODE_PRIVATE); + + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + + try{ + int powerValue = Integer.parseInt(textPower.getText().toString()); + boolean valid = powerValid(powerValue); + if(valid || (textPower.getText().toString()== null)) + { + editor.putString(POWER_STRING, textPower.getText().toString()); + if(textPower.getText().toString()== null) + editor.putInt(POWER, DEFAULT_POWER); + else + { + editor.putInt(POWER, powerValue); + } + editor.commit(); + //sendRdsIntent(); + } + else + { + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("Enter valid Power value in range 0-31!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + textPower.setText(null); + } + } + catch(NumberFormatException nfe) + { + Log.d(TAG,"--> NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("--> Enter valid power value in range 0-31!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + textPower.setText(null); + } + + } + + + +/********************************************************************* + + saveAfCode() + +*********************************************************************/ + private void saveAfCode() + { + + fmConfigPreferences = getSharedPreferences("fmConfigPreferences",MODE_PRIVATE); + + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + + Log.i(TAG,"saveAfCode()"); + try{ + int afCodeValue = Integer.parseInt(edtAfCode.getText().toString()); + boolean valid = afCodeValid(afCodeValue); + if(valid || (edtAfCode.getText().toString()== null)) + { + editor.putString(AFCODE_STRING, edtAfCode.getText().toString()); + if(edtAfCode.getText().toString()== null) + editor.putInt(AF_CODE, DEFAULT_AFCODE); + else + { + editor.putInt(AF_CODE, afCodeValue); + } + editor.commit(); + //sendRdsIntent(); + } + else + { + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("Enter valid AfCode value in range 1 - 204!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + edtAfCode.setText(null); + } + } + catch(NumberFormatException nfe) + { + Log.d(TAG,"--> NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("--> Enter valid AfCode value in range 1 - 204 !!") + .setNegativeButton(android.R.string.ok, null) + .show(); + edtAfCode.setText(null); + } + + } + +/********************************************************************* + + savePiCode() + +*********************************************************************/ + private void savePiCode() + { + + fmConfigPreferences = getSharedPreferences("fmConfigPreferences",MODE_PRIVATE); + + SharedPreferences.Editor editor = fmConfigPreferences.edit(); + + Log.i(TAG,"savePiCode()"); + + try{ + int piCodeValue = Integer.parseInt(edtPiCode.getText().toString()); + boolean valid = piCodeValid(piCodeValue); + if(valid || (edtPiCode.getText().toString()== null)) + { + editor.putString(PICODE_STRING, edtPiCode.getText().toString()); + if(edtPiCode.getText().toString()== null) + editor.putInt(PI_CODE, DEFAULT_PICODE); + else + { + editor.putInt(PI_CODE, piCodeValue); + } + editor.commit(); + sendRdsIntent(); + } + else + { + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("Enter valid Pi Code value in range 0-65535!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + edtPiCode.setText(null); + } + } + catch(NumberFormatException nfe) + { + Log.d(TAG,"--> NumberFormatException:" + nfe.getMessage()); + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("--> Enter valid Pi Code value in range 0-65535!!") + .setNegativeButton(android.R.string.ok, null) + .show(); + edtPiCode.setText(null); + } + + } + + + /** Checks the Power value for validity */ + private boolean powerValid(int value){ + Log.d(TAG,"powerValid %d." +value ); + if (value < POWER_MIN || value > POWER_MAX) + { + Log.d(TAG,"TAG,powerValid %d." +value ); + + return false; + } + else + return true; + + } + + /** Checks the AF code value for validity */ + private boolean afCodeValid(int value){ + Log.d(TAG,"afCodeValid %d." +value ); + if ((value < AFCODE_MIN || value > AFCODE_MAX)) + { + if(value != DEFAULT_AFCODE){ + Log.d(TAG,"TAG,afCodeValid %d." +value ); + return false; + }else{ + return true; + } + //return false; + } + else + return true; + + } + + /** Checks the pi Code value for validity */ + private boolean piCodeValid(int value){ + Log.d(TAG,"piCodeValid %d." +value ); + if (value < PICODE_MIN || value > PICODE_MAX) + { + Log.d(TAG,"TAG,piCodeValid %d." +value ); + + return false; + } + else + return true; + + } +} diff --git a/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxHelp.java b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxHelp.java new file mode 100644 index 0000000..f007c0b --- /dev/null +++ b/tools/FM/FmTxApp/src/com/ti/fmtxapp/FmTxHelp.java @@ -0,0 +1,59 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.fmtxapp; + +import android.app.Activity; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.widget.Button; + +public class FmTxHelp extends Activity implements View.OnKeyListener, + View.OnClickListener { + public static final String TAG = "FmTxHelp"; + + /** Called when the activity is first created. */ + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fmtxhelp); + initControls(); + + } + + private void initControls() { + Button btnBack = (Button) findViewById(R.id.btnBack); + btnBack.setOnClickListener(this); + + } + + + public boolean onKey(View arg0, int arg1, KeyEvent arg2) { + return false; + } + + + public void onClick(View v) { + int id = v.getId(); + switch (id) { + case R.id.btnBack: + finish(); + break; + } + } +} diff --git a/tools/FM/LICENSE.TXT b/tools/FM/LICENSE.TXT new file mode 100644 index 0000000..aa4c6e1 --- /dev/null +++ b/tools/FM/LICENSE.TXT @@ -0,0 +1,224 @@ + + + Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + + 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. + + + Texas Instruments' FM Radio Solution + + +All code provided herein are under the following license: + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/tools/FM/presets.db b/tools/FM/presets.db Binary files differnew file mode 100644 index 0000000..f66720f --- /dev/null +++ b/tools/FM/presets.db diff --git a/tools/FM/service/Android.mk b/tools/FM/service/Android.mk new file mode 100644 index 0000000..2525470 --- /dev/null +++ b/tools/FM/service/Android.mk @@ -0,0 +1,10 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE_TAGS := optional +LOCAL_PACKAGE_NAME := FmService +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_JAVA_LIBRARIES := fmradioif +LOCAL_CERTIFICATE := platform +include $(BUILD_PACKAGE) +include $(call all-makefiles-under,$(LOCAL_PATH)) + diff --git a/tools/FM/service/AndroidManifest.xml b/tools/FM/service/AndroidManifest.xml new file mode 100644 index 0000000..a43bd68 --- /dev/null +++ b/tools/FM/service/AndroidManifest.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.ti.server" + android:versionCode="1" + android:versionName="1.0.0"> + +<!---Android FM Permissions defined --> + <permission android:name="ti.permission.FMRX" + android:label="@string/permlab_FmRx" + android:description="@string/permdesc_FmRxAdmin" + android:permissionGroup="android.permission-group.HARDWARE_CONTROLS" + android:protectionLevel="dangerous" /> + <permission android:name="ti.permission.FMRX_ADMIN" + android:label="@string/permlab_FmRxAdmin" + android:description="@string/permdesc_FmRxAdmin" + android:permissionGroup="android.permission-group.HARDWARE_CONTROLS" + android:protectionLevel="dangerous" /> +<!---Android FM Permissions defined --> + + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> + <uses-permission android:name="ti.permission.FMRX" /> + <uses-permission android:name="ti.permission.FMRX_ADMIN" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + <uses-permission android:name="android.permission.RECEIVE_SMS" /> + + <application + android:label="FmService"> + + <uses-library android:name="fmradioif" /> + <service android:name=".FmService" + android:exported="true" + android:enabled="true"> + <intent-filter> + <action android:name="com.ti.server.FmService" /> + </intent-filter> + </service> + <receiver android:name=".BootReceiver"> + <intent-filter> + <action android:name ="android.intent.action.BOOT_COMPLETED" /> + </intent-filter> + </receiver> + </application> + <uses-sdk android:minSdkVersion="4" /> +</manifest> + diff --git a/tools/FM/service/res/drawable/rxradio.png b/tools/FM/service/res/drawable/rxradio.png Binary files differnew file mode 100644 index 0000000..9de7e9a --- /dev/null +++ b/tools/FM/service/res/drawable/rxradio.png diff --git a/tools/FM/service/res/drawable/txradio.png b/tools/FM/service/res/drawable/txradio.png Binary files differnew file mode 100644 index 0000000..6e74968 --- /dev/null +++ b/tools/FM/service/res/drawable/txradio.png diff --git a/tools/FM/service/res/raw/ding.mp3 b/tools/FM/service/res/raw/ding.mp3 Binary files differnew file mode 100644 index 0000000..caf4187 --- /dev/null +++ b/tools/FM/service/res/raw/ding.mp3 diff --git a/tools/FM/service/res/values/strings.xml b/tools/FM/service/res/values/strings.xml new file mode 100644 index 0000000..863ad14 --- /dev/null +++ b/tools/FM/service/res/values/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!---Android FM Permissions description --> +<resources> + <string name="permlab_FmRx">FM Radio</string> + <string name="permdesc_FmRx">FM Radio</string> + <string name="permlab_FmRxAdmin">FM Radio</string> + <string name="permdesc_FmRxAdmin">FM Radio</string> +</resources> diff --git a/tools/FM/service/src/java/com/ti/server/BootReceiver.java b/tools/FM/service/src/java/com/ti/server/BootReceiver.java new file mode 100644 index 0000000..e5bfc3d --- /dev/null +++ b/tools/FM/service/src/java/com/ti/server/BootReceiver.java @@ -0,0 +1,36 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.server; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +/** + * Broadcast receiver that will handle the boot completed intent and start the + * AccessoryService. + * + */ +public class BootReceiver extends BroadcastReceiver { + public void onReceive(final Context context, final Intent bootintent) { + Log.i("BootReceiver", "Starting FM service"); + // Starting service at boot to speed up enable/disable of FM radio + context.startService(new Intent("com.ti.server.FmService")); + } +} diff --git a/tools/FM/service/src/java/com/ti/server/FmService.java b/tools/FM/service/src/java/com/ti/server/FmService.java new file mode 100644 index 0000000..28a4b1b --- /dev/null +++ b/tools/FM/service/src/java/com/ti/server/FmService.java @@ -0,0 +1,74 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.server; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; +import android.os.RemoteException; +import android.util.Log; +import com.ti.fm.IFmRadio; +import com.ti.server.StubFmService; +import android.content.Context; + +public final class FmService extends Service { + + /** TAG for log. */ + private static final String TAG = "FmService"; + + /** + * IBinder of this service. + */ + private final IFmRadio.Stub mBinder = new StubFmService(); + + /** + * Called by the system when the service is first created. Do not call this + * method directly. + */ + @Override + public void onCreate() { + Log.i(TAG, "onCreate called"); + super.onCreate(); + ((StubFmService) mBinder).init(this); + } + + /** + * Called by the system to notify a Service that it is no longer used and is + * being removed. The service should clean up an resources it holds (threads + * registered receivers, etc) at this point. Upon return, there will be no + * more calls in to this Service object and it is effectively dead. + */ + @Override + public void onDestroy() { + Log.i(TAG, "onDestroy called"); + super.onDestroy(); + } + + /** + * If this service is binded, this method is called. + * + * @param arg + * Intent used when service is called. + * @return IBinder. + */ + @Override + public IBinder onBind(final Intent arg) { + Log.i(TAG, "onBind called"); + return mBinder; + } +} diff --git a/tools/FM/service/src/java/com/ti/server/StubFmService.java b/tools/FM/service/src/java/com/ti/server/StubFmService.java new file mode 100644 index 0000000..1c806a5 --- /dev/null +++ b/tools/FM/service/src/java/com/ti/server/StubFmService.java @@ -0,0 +1,7228 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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.ti.server; + +import com.ti.fm.FmRadio; +import com.ti.fm.IFmRadio; +import com.ti.fm.FmRadioIntent; +import com.ti.fm.IFmConstants; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.RemoteException; +import android.os.Handler; +import android.media.AudioManager; +import android.os.IBinder; +import android.os.Message; +import android.os.PowerManager; +import android.provider.Settings; +import android.util.Log; +import android.os.Bundle; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; /* (additional packages required) */ +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import android.telephony.PhoneStateListener; +import android.telephony.TelephonyManager; + +import android.os.ServiceManager; +import android.os.SystemClock; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; /*need wakelock for delayed poweroff */ +import android.os.PowerManager; +import android.os.PowerManager.WakeLock; + +import android.media.MediaPlayer; +import android.media.MediaPlayer.OnCompletionListener; +import android.media.MediaPlayer.OnErrorListener; +import android.view.KeyEvent; +import java.io.IOException; +import android.content.res.Resources; +import android.content.ComponentName; +import com.ti.jfm.core.*; +import com.ti.server.R.*; + + +/************************************************************************************************* + * Provides FM Radio functionality as a service in the Android Framework. + * There is a single instance of this class that is created during system + * startup as part of the system server. The class exposes its services via + * IFmRadio.aidl. + * + * @hide + *************************************************************************************************/ + +public class StubFmService extends IFmRadio.Stub implements + JFmRx.ICallback,JFmTx.ICallback, IFmConstants { + + private static final String TAG = "StubFmService"; + private static final boolean DBG = false; + private static final String FMRX_ADMIN_PERM = "ti.permission.FMRX_ADMIN"; + private static final String FMRX_PERM = "ti.permission.FMRX"; + public static final String FM_SERVICE = "StubFmService"; + private static final String AUDIO_RX_ENABLE = "audio_rx_enable"; + private static final String AUDIO_TX_ENABLE = "audio_tx_enable"; + + /*FM specific commands*/ + public static final String FM_PAUSE_CMD = "com.ti.server.fmpausecmd"; + public static final String FM_RESUME_CMD = "com.ti.server.fmresumecmd"; + private static final String FM_RESTORE_VALUES = "com.ti.server.fmrestorecmd"; + public static final String FM_MUTE_CMD = "com.ti.server.fmmutecmd"; + public static final String FM_UNMUTE_CMD = "com.ti.server.fmunmutecmd"; + + + /*As the Alarm intents are not published in teh framework, using the string explicitly */ + // TODO: Publish these intents + // This is a public action used in the manifest for receiving Alarm broadcasts + // from the alarm manager. + public static final String ALARM_ALERT_ACTION = "com.android.deskclock.ALARM_ALERT"; + + // A public action sent by AlarmKlaxon when the alarm has stopped sounding + // for any reason (e.g. because it has been dismissed from AlarmAlertFullScreen, + // or killed due to an incoming phone call, etc). + public static final String ALARM_DONE_ACTION = "com.android.deskclock.ALARM_DONE"; + + public static final String MUSIC_PAUSE_ACTION ="com.android.music.musicservicecommand"; + public static final String CMDPAUSE = "pause"; + + private static final String ACTION_FMRx_PLUG = "ti.android.intent.action.FMRx_PLUG"; + private static final String ACTION_FMTx_PLUG = "ti.android.intent.action.FMTx_PLUG"; + private boolean mIsFmTxOn = false; + + private AudioManager mAudioManager = null; + TelephonyManager tmgr; + private Context mContext = null; + + private ComponentName mRemoteControlResponder; + + /*FM TX and RX notification Ids*/ + // TODO: When FM Service is made as an App Service, these will have to be moved there. + private int FM_RX_NOTIFICATION_ID; + private int FM_TX_NOTIFICATION_ID; + + /* + * variable to make sure that the next volume change happens after the + * current volume request has been completed. + */ + private boolean mVolState = VOL_REQ_STATE_IDLE; + + /* Varibale to check whether to resume FM after call.*/ + + private boolean mResumeAfterCall = false; + + private boolean mIsFmMuted = false; + + private Object mVolumeSynchronizationLock = new Object(); + + + /* ***********Constants *********************** */ + private Handler mDelayedDisableHandler; + private DelayedDisable mDelayedDisable; + private DelayedPauseDisable mDelayedPauseDisable; + private static final int FM_DISABLE_DELAY = 50; + private WakeLock mWakeLock = null; + private JFmRx mJFmRx; + private JFmTx mJFmTx; + + private int mRxState = FmRadio.STATE_DEFAULT; // State of the FM Rx Service + private int mTxState = STATE_DEFAULT; // State of the FM Tx Service + + private int mVolume = DEF_VOL; // to store the App Volume value + /* + * Variable to store the volume , so that when the value is changed intimate + * to the application + */ + private int mLastVolume = DEF_VOL; + + /* Variable to store the current Band */ + private static int mCurrentBand = FM_BAND_EUROPE_US; + + /* Variable to store the current tuned frequency */ + private static int mCurrentFrequency = FM_FIRST_FREQ_US_EUROPE_KHZ; + + /* Variable to store the current mute mode */ + private static int mCurrentMuteMode = FM_NOT_MUTE; + /* Variable to store the current RDS state */ + private static boolean mCurrentRdsState = false; + /* + * Variable to store the Mode , so that when the value is changed ,intimate + * to the application + */ + private JFmRx.JFmRxMonoStereoMode mMode = JFmRx.JFmRxMonoStereoMode.FM_RX_STEREO; + /* + * Variable to store the PiCode , so that when the value is changed + * ,intimate to the application + */ + static int last_msg_printed = 255; + + /* + * To identify the pause/resume of the FM and reload the values + * accordingly(band,volume,freq) + */ + private int mFmPauseResume =STATE_DISABLED; + private IntentFilter mIntentFilter; + + /* Variables to store the return value of the FM APIs */ + private static int getBandValue = FM_BAND_EUROPE_US; + private static int getMonoStereoModeValue = 0; + private static int getMuteModeValue = FM_NOT_MUTE; + private static int getRfDependentMuteModeValue = FM_RF_DEP_MUTE_OFF; + private static int getRssiThresholdValue = FM_RSSI_THRESHHOLD; + private static int getDeEmphasisFilterValue = 0; + private static int getVolumeValue = FM_MAX_VOLUME / 2; + private static int getChannelSpaceValue = FM_CHANNEL_SPACE; + private static int getTunedFrequencyValue = FM_UNDEFINED_FREQ; + private static int getRssiValue = 0; + private static int getRdsSystemValue = 0; + private static long getRdsGroupMaskValue = FM_UNDEFINED_FREQ; + private static int getRdsAfSwitchModeValue = 0; + private static double getFwVersion = 0.0; + private static int getScanProgress = 0; + private static boolean mIsValidChannel = false; + private static int mStopCompleteScanStatus = 0; + + /*Variable to protect the FM APIS when Seek,Tune,CompleteScan is in progress*/ + private static boolean mIsCompleteScanInProgress = false; + private static boolean mIsSeekInProgress = false; + private static boolean mIsTuneInProgress = false; + + + /* Varibale for fm TX zoom2 audio deafult */ + private static final int fmTxDeafultCalResource=0; /*CAL_RESOURCE_I2SH*/ + private static final int fmTxDeafultSampleFrequency=7; /*CAL_SAMPLE_FREQ_44100*/ + + /* + * Listener for Incoming call. Disable the FM and let the call proceed. + */ + + private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + + public void onCallStateChanged(int state, String incomingNumber) { + if (state == TelephonyManager.CALL_STATE_RINGING) { + /* Don't handle pause/resume if FM radio is off */ + if (!rxIsEnabled()) { + return; + } + Log.d(TAG,"onCallStateChanged:CALL_STATE_RINGING.Pause FM Radio "); + pauseFm(); + /* Turn off speakerphone before call and save state */ + if (!mResumeAfterCall) { + /* only turn off speaker if not already paused */ + mAudioManager.setSpeakerphoneOn(false); + } + mResumeAfterCall = true; + + } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) { + /* pause the music while a conversation is in progress. + Don't handle pause/resume if FM radio is off */ + if (!rxIsEnabled()) { + return; + } + Log.d(TAG,"onCallStateChanged:CALL_STATE_OFFHOOK Pause FM Radio "); + pauseFm(); + /* Turn off speakerphone before call and save state */ + if (!mResumeAfterCall) { + /* only turn off speaker if not already paused */ + mAudioManager.setSpeakerphoneOn(false); + } + mResumeAfterCall = true; + + } else if (state == TelephonyManager.CALL_STATE_IDLE) { + // start playing again + if (DBG) + Log.d(TAG, "onCallStateChanged:CALL_STATE_IDLE) "); + + if (mResumeAfterCall) { + /* resume playback only if FM was playing + when the call was answered */ + if (!rxIsFMPaused() ) { + return; + } + resumeFm(); + mResumeAfterCall = false; + } + + } + } + }; + + /************************************************************************************************* + * Constructor + *************************************************************************************************/ + + public StubFmService() { + + super(); + //Log.d(TAG, "StubFmService: null constructor called"); + } + + private void initialise(Context context) { + //Log.d(TAG, "StubFmService: initialise called"); + // Save the context to be used later + mContext = context; + mRxState = STATE_DEFAULT; + mFmPauseResume =STATE_DEFAULT; + + mDelayedDisable = new DelayedDisable(); + mDelayedPauseDisable = new DelayedPauseDisable(); + mDelayedDisableHandler = new Handler(); + mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); + tmgr = (TelephonyManager) mContext + .getSystemService(Context.TELEPHONY_SERVICE); + tmgr.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); + + PowerManager powerManager = (PowerManager)context. + getSystemService(Context.POWER_SERVICE); + if (powerManager != null) { + mWakeLock = powerManager. + newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); + } + else { + Log.e(TAG, "Failed to get Power Manager."); + mWakeLock = null; + } + + if (mWakeLock != null) { + mWakeLock.setReferenceCounted(false); + } + else { + Log.e(TAG, "Failed to create WakeLock."); + } + + mRemoteControlResponder = new ComponentName(mContext.getPackageName(), + MediaButtonBroadcastReceiver.class.getName()); + + } + + /************************************************************************************************* + * Must be called after construction, and before any other method. + *************************************************************************************************/ + public synchronized void init(Context context) { + + initialise(context); + // create a single new JFmRx instance + mJFmRx = new JFmRx(); + // create a single new JFmTx instance + mJFmTx = new JFmTx(); + + } + + /************************************************************************************************* + * Must be called when the service is no longer needed.But is the service + * really going down? + *************************************************************************************************/ + public synchronized void close() { + JFmRxStatus status; + //Log.d(TAG, "StubFmService: close "); + try { + tmgr.listen(mPhoneStateListener, 0); + // destroy the underlying FMRX & FMTX + destroyJFmRx(); + destroyJFmTx(); + } catch (Exception e) { + Log.e(TAG, "close: Exception thrown during close (" + e.toString() + + ")"); + return; + } + + } + /* + * L27 Specific + */ + + public void enableRx(int state) { + Intent fm_intent = new Intent(ACTION_FMRx_PLUG); + fm_intent.putExtra("state", state); + mContext.sendBroadcast(fm_intent); + } + + public void enableTx(int state) { + Intent fm_intent = new Intent(ACTION_FMTx_PLUG); + fm_intent.putExtra("state", state); + mContext.sendBroadcast(fm_intent); + if (state == 1) + mIsFmTxOn = true; + else + mIsFmTxOn = false; + } + + public boolean isTransmissionOn() { + return mIsFmTxOn; + } + /************************************************************************************************* + * Must be called after construction, and before any other method. + *************************************************************************************************/ + + public boolean rxIsEnabled() { + //Log.d(TAG, "StubFmService: rxIsEnabled "); + mContext.enforceCallingOrSelfPermission(FMRX_PERM, + "Need FMRX_PERM permission"); + return (mRxState == STATE_ENABLED); + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public int rxGetFMState() { + mContext.enforceCallingOrSelfPermission(FMRX_PERM, + "Need FMRX_PERM permission"); + Log.i(TAG, "rxGetFMState mRxState" +mRxState ); + return mRxState; + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + public boolean rxIsFMPaused() { + mContext.enforceCallingOrSelfPermission(FMRX_PERM, + "Need FMRX_PERM permission"); + Log.i(TAG, "rxIsFMPaused mFmPauseResume" + mFmPauseResume); + return (mFmPauseResume == STATE_PAUSE); + } + + /************************************************************************************************* + * Implementation of conversion from Unsigned to nSigned Integer + *************************************************************************************************/ + private int convertUnsignedToSignedInt(long a) { + + int nReturnVal; + + if ((a > 65535) || (a < 0)) { + Log.d(TAG,"convertUnsignedToSignedInt: Error in conversion from Unsigned to nSigned Integer"); + nReturnVal = 0; + return nReturnVal; + } + + if (a > 32767) + nReturnVal = (int) (a - 65536); + else + nReturnVal = (int) a; + + return nReturnVal; + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public synchronized boolean rxEnable() { + Log.i(TAG, "StubFmService: rxEnable "); + + if(IsFmTxEnabled()==true){ + Log.e(TAG, "StubFmService rxEnable: FM TX is enabled could not Enable fm RX"); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + mDelayedDisableHandler.removeCallbacks(mDelayedDisable); + mDelayedDisableHandler.removeCallbacks(mDelayedPauseDisable); + JFmRxStatus status; + try { + /* Tell the music playback service to pause*/ + // TODO: these constants need to be published somewhere in the + //framework + Intent i = new Intent("com.android.music.musicservicecommand"); + i.putExtra("command", "pause"); + mContext.sendBroadcast(i); + + /* + * register for the master Volume control Intent and music/video + * playback + */ + mIntentFilter = new IntentFilter(); + mIntentFilter.addAction(AudioManager.VOLUME_CHANGED_ACTION); + mIntentFilter.addAction(FM_PAUSE_CMD); + mIntentFilter.addAction(FM_RESUME_CMD); + /*This is for the SMS and other notifications*/ + mIntentFilter.addAction(FM_MUTE_CMD); + mIntentFilter.addAction(FM_UNMUTE_CMD); + mIntentFilter.addAction(FM_RESTORE_VALUES); + /*This is for the Alarm notifications*/ + mIntentFilter.addAction(ALARM_ALERT_ACTION); + mIntentFilter.addAction(ALARM_DONE_ACTION); + mIntentFilter.addAction(MUSIC_PAUSE_ACTION); + mContext.registerReceiver(mFmRxIntentReceiver, mIntentFilter); + + /*Seperate Receiver for Headset*/ + IntentFilter inf = new IntentFilter(); + inf.addAction(Intent.ACTION_HEADSET_PLUG); + mContext.registerReceiver(mHeadsetPlugReceiver, inf); + + /*Seperate Receiver for MediaButton*/ + mAudioManager.registerMediaButtonEventReceiver( + mRemoteControlResponder); + + if((mRxState!= STATE_DEFAULT)&&(mRxState!= STATE_DISABLED)) + switch (mRxState) { + case STATE_ENABLED: + return true; + default: + return false; + } + + // try communicating for 5 seconds (by trying to create a valid FmRX context) + boolean fmRxCreated = false; + for (int count = 0; count< 10; count++) { + //Log.i(TAG, "FmRxEnable: FmRx create try #" + count); + //Log.i(TAG, "FmRxEnable: mJFmRx is:"+ mJFmRx); + status = mJFmRx.create(this); + //Log.i(TAG, "FmRxEnable: FmRx create returned " + status.toString()); + if (status == JFmRxStatus.SUCCESS) { + fmRxCreated = true; + break; + } + SystemClock.sleep(500); + } + + if (fmRxCreated == false) { + Log.e(TAG, "FmRxEnable: FmRx create failed. Aborting"); + return false; + } + + status = mJFmRx.enable(); + Log.i(TAG, "mJFmRx.enable returned status " + status.toString()); + + /* If the Operation Fail, Send false to the user and reset the MCP Monitor */ + if (status != JFmRxStatus.PENDING && status != JFmRxStatus.SUCCESS){ + Log.e(TAG, "mJFmRx.enable returned status "+ status.toString()); + return false; + } + + } catch (Exception e) { + Log.e(TAG, "enable: Exception thrown during enable (" + + e.toString() + ")"); + return false; + } + mRxState = STATE_ENABLING; + mFmPauseResume =STATE_DEFAULT; + + // if its already on, call the event + if (status == JFmRxStatus.SUCCESS) + { + updateEnableConfiguration(); + enableIntent(JFmRxStatus.SUCCESS); + } + else { + // set a delayed timeout message + } + return true; + + } + private void destroyJFmRx() { + //Log.i(TAG, "StubFmService: destroyJFmRx "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + try { + if(mContext!= null) + mContext.unregisterReceiver(mFmRxIntentReceiver); + mContext.unregisterReceiver(mHeadsetPlugReceiver); + mAudioManager.unregisterMediaButtonEventReceiver( + mRemoteControlResponder); + + if (mJFmRx != null) { + mJFmRx.destroy(); + } + + } catch (Exception e) { + Log.e(TAG, "destroyJFmRx: Exception thrown during destroy (" + + e.toString() + ")"); + } + + mRxState = STATE_DEFAULT; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + public synchronized boolean rxDisable() { + Log.i(TAG, "StubFmRxService: rxDisable "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "disable error: fm not enabled " + mRxState); + return false; + } + + mDelayedDisableHandler.postDelayed(mDelayedDisable, FM_DISABLE_DELAY); + + return true; + + } + + /************************************************************************************************* + * Implementation DelayedDisable runnable class + *************************************************************************************************/ + private class DelayedDisable implements Runnable { + + public final void run() { + if ((mWakeLock != null) && (mWakeLock.isHeld())) { + mWakeLock.release(); + } + if (mRxState == STATE_ENABLED) { + boolean success = true; + try { + JFmRxStatus status = mJFmRx.disable(); + if (DBG) + Log.d(TAG, "mJFmRx.disable returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + success = false; + Log.e(TAG, "mJFmRx.disable returned status " + + status.toString()); + } + } catch (Exception e) { + success = false; + Log.e(TAG, "disable: Exception thrown during disable (" + + e.toString() + ")"); + } + if (success) { + mRxState = STATE_DISABLING; + mFmPauseResume = STATE_DEFAULT; + } + } else { + Log.e(TAG, "disable error: fm not enabled " + mRxState); + } + } + } + + private class DelayedPauseDisable implements Runnable { + public final void run() { + if ((mWakeLock != null) && (mWakeLock.isHeld())) { + mWakeLock.release(); + } + // if its already off, call the completion function + if (mRxState == STATE_ENABLED) { + boolean success = true; + try { + JFmRxStatus status = mJFmRx.disable(); + if (DBG) + Log.d(TAG, "mJFmRx.disable returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + success = false; + Log.e(TAG, "mJFmRx.disable returned status " + + status.toString()); + } + } catch (Exception e) { + success = false; + Log.e(TAG, "disable: Exception thrown during disable (" + + e.toString() + ")"); + } + if (success) { + mRxState = STATE_PAUSE; + mFmPauseResume = STATE_PAUSE; + } + } else { + Log.e(TAG, "disable error: fm not enabled " + mRxState); + } + } + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* separate queue for each set call synchronization */ + private BlockingQueue<String> mSetBandSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public boolean rxSetBand(int band) { + Log.i(TAG, "StubFmService:rxSetBand band " + band); + mCurrentBand = band; + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetBand: failed, fm not enabled state " + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRx.JFmRxBand lBand = JFmUtils.getEnumConst(JFmRx.JFmRxBand.class, + band); + if (lBand == null) { + Log.e(TAG, "StubFmService:rxSetBand invalid lBand " + lBand); + return false; + } + + JFmRxStatus status = mJFmRx.setBand(lBand); + Log.i(TAG, "mJFmRx.setBand returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setBand returned status " + status.toString()); + return false; + } + + /*implementation to make the set API Synchronous */ + try { + String syncString = mSetBandSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setBand-- Wait() s Exception!!!"); + } + +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxSetBand():--------- Exiting... "); + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + public boolean rxSetBand_nb(int band) { + Log.i(TAG, "StubFmService:rxSetBand_nb band " + band); + mCurrentBand = band; + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetBand_nb: failed, fm not enabled state " + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxBand lBand = JFmUtils.getEnumConst(JFmRx.JFmRxBand.class, + band); + if (lBand == null) { + Log.e(TAG, "StubFmService:rxSetBand_nb invalid lBand " + lBand); + return false; + } + + JFmRxStatus status = mJFmRx.setBand(lBand); + Log.i(TAG, "mJFmRx.setBand returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setBand returned status " + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mBandSyncQueue = new LinkedBlockingQueue<String>( + 5); + public synchronized int rxGetBand() { + + Log.i(TAG, "StubFmService:rxGetBand "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetBand: failed, fm not enabled state " + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRxStatus status = mJFmRx.getBand(); + Log.i(TAG, "mJFmRx.getBand returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getBand returned status " + + status.toString()); + return 0; + } + + /* implementation to make the FM API Synchronous */ + try { + String syncString = mBandSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getBand-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetBand():--------- Exiting... "); + return getBandValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetBand_nb() { + + Log.i(TAG, "StubFmService:rxGetBand_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetBand_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getBand(); + Log.i(TAG, "mJFmRx.getBand returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getBand returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetMonoStereoModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public boolean rxSetMonoStereoMode(int mode) { + Log.i(TAG, "StubFmService:rxSetMonoStereoMode mode " + mode); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetMonoStereoMode: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRx.JFmRxMonoStereoMode lMode = JFmUtils.getEnumConst( + JFmRx.JFmRxMonoStereoMode.class, mode); + if (lMode == null) { + Log.e(TAG, "StubFmService:rxSetMonoStereoMode invalid lBand " + lMode); + return false; + } + JFmRxStatus status = mJFmRx.setMonoStereoMode(lMode); + Log.i(TAG, "mJFmRx.setMonoStereoMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setMonoStereoMode returned status " + + status.toString()); + return false; + } + + /*implementation to make the set API Synchronous */ + try { + String syncString = mSetMonoStereoModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setMonoStereoMode-- Wait() s Exception!!!"); + } + +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxSetMonoStereoMode exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetMonoStereoMode_nb(int mode) { + Log.i(TAG, "StubFmService:rxSetMonoStereoMode_nb mode " + mode); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetMonoStereoMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxMonoStereoMode lMode = JFmUtils.getEnumConst( + JFmRx.JFmRxMonoStereoMode.class, mode); + if (lMode == null) { + Log.e(TAG, "StubFmService:rxSetMonoStereoMode_nb invalid lBand " + + lMode); + return false; + } + JFmRxStatus status = mJFmRx.setMonoStereoMode(lMode); + Log.i(TAG, "mJFmRx.setMonoStereoMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setMonoStereoMode returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mMonoStereoModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetMonoStereoMode() { + Log.i(TAG, "StubFmService:rxGetMonoStereoMode "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetMonoStereoMode: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getMonoStereoMode(); + Log.i(TAG, "mJFmRx.getMonoStereoMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getMonoStereoMode returned status " + + status.toString()); + return 0; + } + + /*implementation to make the FM API Synchronous */ + + try { + String syncString = mMonoStereoModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getMonoStereoMode-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + + Log.i(TAG, "StubFmService:rxGetMonoStereoMode(): -------- Exiting "); + + return getMonoStereoModeValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetMonoStereoMode_nb() { + Log.i(TAG, "StubFmService:rxGetMonoStereoMode_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetMonoStereoMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getMonoStereoMode(); + Log.i(TAG, "mJFmRx.getMonoStereoMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getMonoStereoMode returned status " + + status.toString()); + return false; + } + + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetMuteModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public boolean rxSetMuteMode(int muteMode) { + Log.i(TAG, "StubFmService:rxSetMuteMode muteMode" + muteMode); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetMuteMode: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxMuteMode lMode = JFmUtils.getEnumConst( + JFmRx.JFmRxMuteMode.class, muteMode); + if (lMode == null) { + Log.e(TAG, "StubFmService:rxSetMuteMode invalid lMode " + lMode); + return false; + } + JFmRxStatus status = mJFmRx.setMuteMode(lMode); + Log.i(TAG, "mJFmRx.SetMuteMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.SetMuteMode returned status " + + status.toString()); + return false; + } + + /* + * (When muting turn off audio paths to lower power consumption and + * reduce noise) + */ + if (lMode == JFmRx.JFmRxMuteMode.FMC_MUTE) { + + /* L25 Specific */ + //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=false"); + //Log.i(TAG, "MUTE- On"); + /* L27 Specific */ + enableRx(0); + + } else { + /* L25 Specific */ + //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=true"); + //Log.i(TAG, "MUTE- OFF"); + /* L27 Specific */ + enableRx(1); + } + + + /* implementation to make the set API Synchronous */ + + try { + String syncString = mSetMuteModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setMuteMode-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + mCurrentMuteMode = muteMode; + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetMuteMode_nb(int muteMode) { + JFmRx.JFmRxMuteMode lMode; + Log.i(TAG, "StubFmService:rxSetMuteMode_nb muteode" + muteMode); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetMuteMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + lMode = JFmUtils.getEnumConst( + JFmRx.JFmRxMuteMode.class, muteMode); + if (lMode == null) { + Log.e(TAG, "StubFmService:rxSetMuteMode_nb invalid lBand " + lMode); + return false; + } + JFmRxStatus status = mJFmRx.setMuteMode(lMode); + Log.i(TAG, "mJFmRx.SetMuteMode returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.SetMuteMode returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + /* + * (When muting turn off audio paths to lower power consumption and + * reduce noise) + * L25 Specific + */ + if (lMode == JFmRx.JFmRxMuteMode.FMC_MUTE) { + //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=false"); + + } else { + //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=true"); + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mMuteModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetMuteMode() { + Log.i(TAG, "StubFmService:rxGetMuteMode "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetMuteMode: failed, fm not enabled state " + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getMuteMode(); + Log.i(TAG, "mJFmRx.getMuteMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getMuteMode returned status " + + status.toString()); + return 0; + } + + /* implementation to make the FM API Synchronous */ + + try { + String syncString = mMuteModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getMuteMode-- Wait() s Exception!!!"); + } + + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetMuteMode(): -------- Exiting... "); + return getMuteModeValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetMuteMode_nb() { + Log.i(TAG, "StubFmService:rxGetMuteMode_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetMuteMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getMuteMode(); + Log.i(TAG, "mJFmRx.getMuteMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getMuteMode returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetRfDependentMuteModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public boolean rxSetRfDependentMuteMode(int rfMuteMode) { + Log.i(TAG, "StubFmService:rxSetRfDependentMuteMode " + rfMuteMode); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRfDependentMuteMode: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRx.JFmRxRfDependentMuteMode lrfMute = JFmUtils.getEnumConst( + JFmRx.JFmRxRfDependentMuteMode.class, rfMuteMode); + if (lrfMute == null) { + Log.e(TAG, "StubFmService:rxSetRfDependentMuteMode invalid lrfMute " + + lrfMute); + return false; + } + + JFmRxStatus status = mJFmRx.setRfDependentMuteMode(lrfMute); + Log.i(TAG, "mJFmRx.setRfDependentMuteMode returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRfDependentMuteMode returned status " + + status.toString()); + return false; + } + + /* implementation to make the set API Synchronous */ + + try { + String syncString = mSetRfDependentMuteModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setRfDependentMuteMode-- Wait() s Exception!!!"); + } + +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxSetRfDependentMuteMode exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetRfDependentMuteMode_nb(int rfMuteMode) { + Log.i(TAG, "StubFmService:rxSetRfDependentMuteMode_nb " + rfMuteMode); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, + "rxSetRfDependentMuteMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxRfDependentMuteMode lrfMute = JFmUtils.getEnumConst( + JFmRx.JFmRxRfDependentMuteMode.class, rfMuteMode); + if (lrfMute == null) { + Log.e(TAG, + "StubFmService:rxSetRfDependentMuteMode_nb invalid lrfMute " + + lrfMute); + return false; + } + + JFmRxStatus status = mJFmRx.setRfDependentMuteMode(lrfMute); + Log.i(TAG, "mJFmRx.setRfDependentMuteMode returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRfDependentMuteMode returned status " + + status.toString()); + return false; + } + + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mRfDependentMuteModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetRfDependentMuteMode() { + Log.i(TAG, "StubFmService:rxGetRfDependentMuteMode "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRfDependentMuteMode: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) ||(mIsTuneInProgress == false)) { + JFmRxStatus status = mJFmRx.getRfDependentMute(); + Log.i(TAG, "mJFmRx.getRfDependentMuteMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getRfDependentMuteMode returned status " + + status.toString()); + + return 0; + } + /* implementation to make the FM API Synchronous */ + + try { + String syncString = mRfDependentMuteModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log + .e(TAG, + "mJFmRx.getRfDependentMuteMode-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, + "StubFmService:rxGetRfDependentMuteMode(): --------- Exiting... "); + return getRfDependentMuteModeValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetRfDependentMuteMode_nb() { + Log.i(TAG, "StubFmService:rxGetRfDependentMuteMode_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRfDependentMuteMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRfDependentMute(); + Log.i(TAG, "mJFmRx.getRfDependentMuteMode returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getRfDependentMuteMode returned status " + + status.toString()); + + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetRssiThresholdSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public boolean rxSetRssiThreshold(int threshhold) { + Log.i(TAG, "StubFmService:rxSetRssiThreshold " + threshhold); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRssiThreshold: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRx.JFmRxRssi lrssiThreshhold = new JFmRx.JFmRxRssi(threshhold); + if (lrssiThreshhold == null) { + Log.e(TAG, "StubFmService:rxSetRssiThreshold invalid rssi " + + lrssiThreshhold); + return false; + } + Log.d(TAG, "StubFmService:rxSetRssiThreshold " + lrssiThreshhold); + JFmRxStatus status = mJFmRx.setRssiThreshold(lrssiThreshhold); + Log.i(TAG, "mJFmRx.setRssiThreshold returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRssiThreshold returned status " + + status.toString()); + return false; + } + + /*implementation to make the set API Synchronous */ + + try { + String syncString = mSetRssiThresholdSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setRssiThreshold-- Wait() s Exception!!!"); + } + +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxSetRssiThreshold exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetRssiThreshold_nb(int threshhold) { + Log.i(TAG, "StubFmService:rxSetRssiThreshold_nb " + threshhold); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRssiThreshold_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxRssi lrssiThreshhold = new JFmRx.JFmRxRssi(threshhold); + if (lrssiThreshhold == null) { + Log.e(TAG, "StubFmService:setRssiThreshold_nb invalid rssi " + + lrssiThreshhold); + return false; + } + Log.d(TAG, "StubFmService:setRssiThreshold_nb " + lrssiThreshhold); + JFmRxStatus status = mJFmRx.setRssiThreshold(lrssiThreshhold); + if (DBG) + Log.i(TAG, "mJFmRx.setRssiThreshold returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRssiThreshold returned status " + + status.toString()); + return false; + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mRssiThresholdSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public synchronized int rxGetRssiThreshold() { + + Log.i(TAG, "StubFmService:rxGetRssiThreshold --Entry "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRssiThreshold: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRssiThreshold(); + Log.i(TAG, "mJFmRx.getRssiThreshold returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getRssiThreshold returned status " + + status.toString()); + return 0; + } + + /*implementation to make the FM API Synchronous */ + + try { + String syncString = mRssiThresholdSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getRssiThreshold-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetRssiThreshold(): ---------- Exiting "); + return getRssiThresholdValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetRssiThreshold_nb() { + + Log.i(TAG, "StubFmService:rxGetRssiThreshold_nb --Entry "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRssiThreshold_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRssiThreshold(); + Log.i(TAG, "mJFmRx.getRssiThreshold returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getRssiThreshold returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetDeEmphasisFilterSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public boolean rxSetDeEmphasisFilter(int filter) { + Log.i(TAG, "StubFmService:rxSetDeEmphasisFilter filter " + filter); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetDeEmphasisFilter: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxEmphasisFilter lFilter = JFmUtils.getEnumConst( + JFmRx.JFmRxEmphasisFilter.class, filter); + if (lFilter == null) { + Log.e(TAG, "StubFmService:rxSetDeEmphasisFilter invalid lBand " + + lFilter); + return false; + } + JFmRxStatus status = mJFmRx.SetDeEmphasisFilter(lFilter); + Log.i(TAG, "mJFmRx.setDeEmphasisFilter returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setDeEmphasisFilter returned status " + + status.toString()); + return false; + } + + /*implementation to make the set API Synchronous */ + + try { + String syncString = mSetDeEmphasisFilterSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setDeEmphasisFilter-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxSetDeEmphasisFilter exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetDeEmphasisFilter_nb(int filter) { + Log.i(TAG, "StubFmService:rxSetDeEmphasisFilter_nb filter " + filter); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetDeEmphasisFilter_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxEmphasisFilter lFilter = JFmUtils.getEnumConst( + JFmRx.JFmRxEmphasisFilter.class, filter); + if (lFilter == null) { + Log.e(TAG, "StubFmService:rxSetDeEmphasisFilter_nb invalid lBand " + + lFilter); + return false; + } + JFmRxStatus status = mJFmRx.SetDeEmphasisFilter(lFilter); + Log.i(TAG, "mJFmRx.setDeEmphasisFilter returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setDeEmphasisFilter returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mDeEmphasisFilterSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public synchronized int rxGetDeEmphasisFilter() { + Log.i(TAG, "StubFmService:rxGetDeEmphasisFilter "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetDeEmphasisFilter: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.GetDeEmphasisFilter(); + Log.i(TAG, "mJFmRx.getDeEmphasisFilter returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getDeEmphasisFilter returned status " + + status.toString()); + return 0; + } + /* :implementation to make the FM API Synchronous */ + + try { + String syncString = mDeEmphasisFilterSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log + .e(TAG, + "mJFmRx.getDeEmphasisFilter-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetDeEmphasisFilter(): -------- Exiting "); + return getDeEmphasisFilterValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetDeEmphasisFilter_nb() { + Log.i(TAG, "StubFmService:rxGetDeEmphasisFilter_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetDeEmphasisFilter_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.GetDeEmphasisFilter(); + Log.i(TAG, "mJFmRx.getDeEmphasisFilter returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getDeEmphasisFilter returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetVolume(int volume) { + Log.i(TAG, "StubFmService:rxSetVolume " + volume); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetVolume: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + mVolState = VOL_REQ_STATE_PENDING; + JFmRx.JFmRxVolume lVolume = new JFmRx.JFmRxVolume(volume); + if (lVolume == null) { + Log.e(TAG, "StubFmService:rxSetVolume invalid lVolume " + lVolume); + return false; + } + + synchronized (mVolumeSynchronizationLock) { + + JFmRxStatus status = mJFmRx.setVolume(lVolume); + Log.i(TAG, "mJFmRx.setVolume returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setVolume returned status " + + status.toString()); + return false; + } + +// mVolState = VOL_REQ_STATE_PENDING; + } + + return true; + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetChannelSpacing_nb(int channelSpace) { + + Log.i(TAG, "StubFmService:rxSetChannelSpacing_nb " + channelSpace); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetChannelSpacing_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxChannelSpacing lChannelSpace = JFmUtils.getEnumConst( + JFmRx.JFmRxChannelSpacing.class, channelSpace); + + if (lChannelSpace == null) { + Log.e(TAG, "StubFmService:rxSetChannelSpacing_nb invalid lChannelSpace " + + lChannelSpace); + return false; + } + JFmRxStatus status = mJFmRx.setChannelSpacing(lChannelSpace); + Log.i(TAG, "mJFmRx.setChannelSpacing returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setChannelSpacing returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetChannelSpacingSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public boolean rxSetChannelSpacing(int channelSpace) { + + Log.i(TAG, "StubFmService:rxSetChannelSpacing " + channelSpace); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetChannelSpacing: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxChannelSpacing lChannelSpace = JFmUtils.getEnumConst( + JFmRx.JFmRxChannelSpacing.class, channelSpace); + + if (lChannelSpace == null) { + Log.e(TAG, + "StubFmService:rxSetChannelSpacing invalid lChannelSpace " + + lChannelSpace); + return false; + } + JFmRxStatus status = mJFmRx.setChannelSpacing(lChannelSpace); + Log.i(TAG, "mJFmRx.setChannelSpacing returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.setChannelSpacing returned status " + + status.toString()); + return false; + } + + /* implementation to make the FM API Synchronous */ + try { + Log + .i(TAG, + "StubFmService:rxSetChannelSpacing(): -------- Waiting... "); + String syncString = mSetChannelSpacingSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string receieved: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setChannelSpacing-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxSetChannelSpacing exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mVolumeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetVolume() { + Log.i(TAG, "StubFmService:rxGetVolume "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetVolume: failed, fm not enabled state " + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRxStatus status = mJFmRx.getVolume(); + Log.i(TAG, "mJFmRx.getVolume returned status " + status.toString()); + + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getVolume returned status " + + status.toString()); + return 0; + } + + /*implementation to make the FM API Synchronous */ + + try { + String syncString = mVolumeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getVolume-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetVolume(): -------- Exiting... "); + return getVolumeValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetVolume_nb() { + Log.i(TAG, "StubFmService:rxGetVolume_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetVolume_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getVolume(); + Log.i(TAG, "mJFmRx.rxGetVolume returned status " + status.toString()); + + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.rxGetVolume returned status " + + status.toString()); + return false; + } + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mChannelSpacingSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetChannelSpacing() { + Log.i(TAG, "StubFmService:rxGetChannelSpacing "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetChannelSpacing: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRxStatus status = mJFmRx.getChannelSpacing(); + Log.i(TAG, "mJFmRx.rxGetChannelSpacing returned status " + + status.toString()); + + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.rxGetChannelSpacing returned status " + + status.toString()); + return 0; + } + + /* implementation to make the FM API Synchronous */ + + try { + String syncString = mChannelSpacingSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getChannelSpacing-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetChannelSpacing() --Exiting "); + return getChannelSpaceValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetChannelSpacing_nb() { + Log.i(TAG, "StubFmService:rxGetChannelSpacing_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetChannelSpacing_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getChannelSpacing(); + Log.i(TAG, "mJFmRx.getChannelSpacing returned status " + + status.toString()); + + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getChannelSpacing returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + return false; + + } + + static int BaseFreq() { + return mCurrentBand == FM_BAND_JAPAN ? FM_FIRST_FREQ_JAPAN_KHZ + : FM_FIRST_FREQ_US_EUROPE_KHZ; + } + + static int LastFreq() { + return mCurrentBand == FM_BAND_JAPAN ? FM_LAST_FREQ_JAPAN_KHZ + : FM_LAST_FREQ_US_EUROPE_KHZ; + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxTune_nb(int freq) { + Log.i(TAG, "StubFmService: rxTune_nb " + freq); + + mCurrentFrequency = freq; + if (mRxState != STATE_ENABLED) { + Log.e(TAG, " rxTune_nb: failed, fm not enabled state " + mRxState); + return false; + } + if (freq < BaseFreq() || freq > LastFreq()) { + Log.e(TAG, "StubFmService: rxTune_nb invalid frequency not in range " + + freq); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmRx.JFmRxFreq lFreq = new JFmRx.JFmRxFreq(freq); + if (lFreq == null) { + Log.e(TAG, "StubFmService:tune invalid frequency " + lFreq); + return false; + } + mIsTuneInProgress = true; + Log.d(TAG, "StubFmService: rxTune_nb " + lFreq); + JFmRxStatus status = mJFmRx.tune(lFreq); + Log.i(TAG, "mJFmRx.tune returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.tune returned status " + status.toString()); + return false; + } +// mIsTuneInProgress = true; + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mTunedFrequencySyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetTunedFrequency() { + Log.i(TAG, "StubFmService:rxGetTunedFrequency "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetTunedFrequency: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRxStatus status = mJFmRx.getTunedFrequency(); + Log.i(TAG, "mJFmRx.getTunedFrequency returned status " + + status.toString()); + + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getTunedFrequency returned status " + + status.toString()); + return 0; + } + /* implementation to make the FM API Synchronous */ + try { + String syncString = mTunedFrequencySyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getTunedFrequency-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetTunedFrequency(): ------- Exiting "); + return getTunedFrequencyValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetTunedFrequency_nb() { + Log.i(TAG, "StubFmService:rxGetTunedFrequency_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetTunedFrequency_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRxStatus status = mJFmRx.getTunedFrequency(); + Log.i(TAG, "mJFmRx.getTunedFrequency returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getTunedFrequency returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSeek_nb(int direction) { + Log.i(TAG, "StubFmService:rxSeek_nb " + direction); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSeek_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmRx.JFmRxSeekDirection lDir = JFmUtils.getEnumConst( + JFmRx.JFmRxSeekDirection.class, direction); + if (lDir == null) { + Log.e(TAG, "StubFmService:rxSeek_nb invalid lDir " + lDir); + return false; + } + mIsSeekInProgress = true; + JFmRxStatus status = mJFmRx.seek(lDir); + Log.i(TAG, "mJFmRx.seek returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.seek returned status " + status.toString()); + return false; + } + +// mIsSeekInProgress = true; + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxStopSeek_nb() { + Log.i(TAG, "StubFmService:rxStopSeek_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxStopSeek_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRxStatus status = mJFmRx.stopSeek(); + Log.i(TAG, "mJFmRx.stopSeek returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.stopSeek returned status " + status.toString()); + return false; + } + + +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mStopSeekSyncQueue = new LinkedBlockingQueue<String>( + 5); + public boolean rxStopSeek() { + Log.i(TAG, "StubFmService:rxStopSeek "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxStopSeek: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRxStatus status = mJFmRx.stopSeek(); + Log.i(TAG, "mJFmRx.stopSeek returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.stopSeek returned status " + + status.toString()); + return false; + } + + try { + Log.i(TAG, "StubFmService:stopSeek(): -------- Waiting... "); + String syncString = mStopSeekSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string receieved: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.stopSeek-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "tune is in progress.cannot call the API"); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetRssi_nb() { + Log.i(TAG, "StubFmService:rxGetRssi_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRssi_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRxStatus status = mJFmRx.getRssi(); + Log.i(TAG, "mJFmRx.getRssi returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRssi returned status " + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mRssiSyncQueue = new LinkedBlockingQueue<String>( + 5); + public synchronized int rxGetRssi() { + + Log.i(TAG, "StubFmService:rxGetRssi "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRssi: failed, fm not enabled state " + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRssi(); + Log.i(TAG, "mJFmRx.getRssi returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRssi returned status " + + status.toString()); + return 0; + } + /* implementation to make the FM API Synchronous */ + try { + String syncString = mRssiSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getRssi-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetRssi(): ---------- Exiting "); + return getRssiValue; + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mRdsSystemSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetRdsSystem() { + Log.i(TAG, "StubFmService:rxGetRdsSystem "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRdsSystem: failed, fm not enabled state " + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRdsSystem(); + Log.i(TAG, "mJFmRx.getRdsSystem returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRdsSystem returned status " + + status.toString()); + return 0; + } + /* implementation to make the FM API Synchronous */ + + + try { + String syncString = mRdsSystemSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getRdsSystem-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetRdsSystem(): ----------- Exiting "); + return getRdsSystemValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetRdsSystem_nb() { + Log.i(TAG, "StubFmService:rxGetRdsSystem_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRdsSystem_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRdsSystem(); + Log.i(TAG, "mJFmRx.getRdsSystem returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRdsSystem returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetRdsSystem_nb(int system) { + + Log.i(TAG, "StubFmService:rxSetRdsSystem_nb " + system); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRdsSystem_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxRdsSystem lSystem = JFmUtils.getEnumConst( + JFmRx.JFmRxRdsSystem.class, system); + if (lSystem == null) { + Log.e(TAG, "StubFmService:rxSetRdsSystem_nb invalid lSystem " + lSystem); + return false; + } + Log.d(TAG, "StubFmService:setRdsSystem lSystem " + lSystem); + JFmRxStatus status = mJFmRx.setRdsSystem(lSystem); + Log.i(TAG, "mJFmRx.setRdsSystem returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRdsSystem returned status " + + status.toString()); + return false; + } + + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetRdsSystemSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public boolean rxSetRdsSystem(int system) { + + Log.i(TAG, "StubFmService:rxSetRdsSystem " + system); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRdsSystem: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxRdsSystem lSystem = JFmUtils.getEnumConst( + JFmRx.JFmRxRdsSystem.class, system); + if (lSystem == null) { + Log.e(TAG, "StubFmService:rxSetRdsSystem invalid lSystem " + + lSystem); + return false; + } + Log.d(TAG, "StubFmService:rxSetRdsSystem lSystem " + lSystem); + JFmRxStatus status = mJFmRx.setRdsSystem(lSystem); + Log.i(TAG, "mJFmRx.setRdsSystem returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.rxSetRdsSystem returned status " + + status.toString()); + return false; + } + /* (separate queue for each get call synchronization) */ + try { + Log.i(TAG, "StubFmService:rxSetRdsSystem(): -------- Waiting... "); + String syncString = mSetRdsSystemSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string received: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setRdsSystem-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mEnableRdsSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public boolean rxEnableRds() { + Log.i(TAG, "StubFmService:rxEnableRds "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxEnableRds: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRxStatus status = mJFmRx.enableRDS(); + Log.i(TAG, "mJFmRx.enableRds returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.enableRds returned status " + status.toString()); + return false; + } + mCurrentRdsState = true; + Log.e(TAG, "rxEnableRds mCurrentRdsState"+mCurrentRdsState); + /* implementation to make the set API Synchronous */ + try { + String syncString = mEnableRdsSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.enableRds-- Wait() s Exception!!!"); + } +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxEnableRds exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxEnableRds_nb() { + Log.i(TAG, "StubFmService:rxEnableRds_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxEnableRds_nb: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRxStatus status = mJFmRx.enableRDS(); + Log.i(TAG, "mJFmRx.enableRds returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.enableRds returned status " + status.toString()); + return false; + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + mCurrentRdsState = true; + Log.e(TAG, "rxEnableRds_nb mCurrentRdsState"+mCurrentRdsState); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mDisableRdsSyncQueue = new LinkedBlockingQueue<String>( + 5); + + + public boolean rxDisableRds() { + Log.i(TAG, "StubFmService:rxDisableRds "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxDisableRds: failed, fm not enabled state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + + JFmRxStatus status = mJFmRx.DisableRDS(); + Log.i(TAG, "mJFmRx.disableRds returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log + .e(TAG, "mJFmRx.disableRds returned status " + + status.toString()); + return false; + } + mCurrentRdsState = false; + Log.e(TAG, "rxDisableRds mCurrentRdsState"+mCurrentRdsState); + /* implementation to make the set API Synchronous */ + + try { + String syncString = mDisableRdsSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.disableRds-- Wait() s Exception!!!"); + } +} else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxDisableRds exiting"); + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxDisableRds_nb() { + Log.i(TAG, "StubFmService:rxDisableRds_nb "); + if (mRxState != STATE_ENABLED) { + Log + .e(TAG, "disableRds_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRxStatus status = mJFmRx.DisableRDS(); + Log.i(TAG, "mJFmRx.disableRds returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log + .e(TAG, "mJFmRx.disableRds returned status " + + status.toString()); + return false; + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + mCurrentRdsState = false; + Log.e(TAG, "rxDisableRds_nb mCurrentRdsState"+mCurrentRdsState); + return true; + + } + +/************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* separate queue for each set call synchronization */ + private BlockingQueue<String> mSetRdsGroupMaskSyncQueue = new LinkedBlockingQueue<String>( + 5); + public boolean rxSetRdsGroupMask(int mask) { + Log.i(TAG, "StubFmService:rxSetRdsGroupMask " + mask); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRdsGroupMask: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxRdsGroupTypeMask lMask = JFmUtils.getEnumConst( + JFmRx.JFmRxRdsGroupTypeMask.class, (long) mask); + JFmRxStatus status = mJFmRx.setRdsGroupMask(lMask); + Log.i(TAG, "mJFmRx.setRdsGroupMask returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRdsGroupMask returned status " + + status.toString()); + return false; + } + /* implementation to make the set API Synchronous */ + + try { + Log.i(TAG, + "StubFmService:rxSetRdsGroupMask(): -------- Waiting... "); + String syncString = mSetRdsGroupMaskSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string received: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setRdsGroupMask-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetRdsGroupMask_nb(int mask) { + Log.i(TAG, "StubFmService:rxSetRdsGroupMask_nb " + mask); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, " rxSetRdsGroupMask_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxRdsGroupTypeMask lMask = JFmUtils.getEnumConst( + JFmRx.JFmRxRdsGroupTypeMask.class, (long) mask); + JFmRxStatus status = mJFmRx.setRdsGroupMask(lMask); + Log.i(TAG, "mJFmRx.setRdsSystem returned status " + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRdsSystem returned status " + + status.toString()); + return false; + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mRdsGroupMaskSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized long rxGetRdsGroupMask() { + Log.i(TAG, "StubFmService:rxGetRdsGroupMask "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRdsGroupMask: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRdsGroupMask(); + Log.i(TAG, "mJFmRx.getRdsGroupMask returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRdsGroupMask returned status " + + status.toString()); + return 0; + } + /* implementation to make the set API Synchronous */ + + try { + String syncString = mRdsGroupMaskSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getRdsGroupMask-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetRdsGroupMask(): ---------- Exiting "); + return getRdsGroupMaskValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetRdsGroupMask_nb() { + Log.i(TAG, "StubFmService:rxGetRdsGroupMask_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRdsGroupMask_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRdsGroupMask(); + Log.i(TAG, "mJFmRx.getRdsGroupMask returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRdsGroupMask returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxSetRdsAfSwitchMode_nb(int mode) { + Log.i(TAG, "StubFmService:rxSetRdsAfSwitchMode_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRdsAfSwitchMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + JFmRx.JFmRxRdsAfSwitchMode lMode = JFmUtils.getEnumConst( + JFmRx.JFmRxRdsAfSwitchMode.class, mode); + if (lMode == null) { + Log + .e(TAG, "StubFmService:rxSetRdsAfSwitchMode_nb invalid lMode " + + lMode); + return false; + } + JFmRxStatus status = mJFmRx.setRdsAfSwitchMode(lMode); + Log.i(TAG, "mJFmRx.setRdsAfSwitchMode returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRdsAfSwitchMode returned status " + + status.toString()); + + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each set call synchronization) */ + private BlockingQueue<String> mSetRdsAfSwitchModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + public boolean rxSetRdsAfSwitchMode(int mode) { + Log.i(TAG, "StubFmService:rxSetRdsAfSwitchMode "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxSetRdsAfSwitchMode: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRx.JFmRxRdsAfSwitchMode lMode = JFmUtils.getEnumConst( + JFmRx.JFmRxRdsAfSwitchMode.class, mode); + if (lMode == null) { + Log.e(TAG, "StubFmService:rxSetRdsAfSwitchMode invalid lMode " + + lMode); + return false; + } + JFmRxStatus status = mJFmRx.setRdsAfSwitchMode(lMode); + Log.i(TAG, "mJFmRx.setRdsAfSwitchMode returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.setRdsAfSwitchMode returned status " + + status.toString()); + + return false; + } + + try { + Log + .i(TAG, + "StubFmService:rxSetRdsAfSwitchMode(): -------- Waiting... "); + String syncString = mSetRdsAfSwitchModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string received: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.setRdsAfSwitchMode-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mRdsAfSwitchModeSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetRdsAfSwitchMode() { + + Log.i(TAG, "rxGetRdsAfSwitchMode "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRdsAfSwitchMode: failed, fm not enabled state " + + mRxState); + return 0; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRdsAfSwitchMode(); + Log.i(TAG, "mJFmRx.getRdsAfSwitchMode returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRdsAfSwitchMode returned status " + + status.toString()); + + return 0; + } + /* implementation to make the set API Synchronous */ + + try { + String syncString = mRdsAfSwitchModeSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getRdsAfSwitchMode-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetRdsAfSwitchMode(): ---------- Exiting... "); + return getRdsAfSwitchModeValue; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetRdsAfSwitchMode_nb() { + + Log.i(TAG, "rxGetRdsAfSwitchMode_nb "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxGetRdsAfSwitchMode_nb: failed, fm not enabled state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getRdsAfSwitchMode(); + Log.i(TAG, "mJFmRx.getRdsAfSwitchMode returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.getRdsAfSwitchMode returned status " + + status.toString()); + + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.Cannot call the API"); + return false; + } + + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxChangeAudioTarget(int mask, int digitalConfig) { + Log.i(TAG, "StubFmService:rxChangeAudioTarget "); + + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxChangeAudioTarget: failed, already in state " + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmRx.JFmRxEcalSampleFrequency lconfig = JFmUtils.getEnumConst( + JFmRx.JFmRxEcalSampleFrequency.class, digitalConfig); + JFmRx.JFmRxAudioTargetMask lMask = JFmUtils.getEnumConst( + JFmRx.JFmRxAudioTargetMask.class, mask); + if (lMask == null || lconfig == null) { + Log.e(TAG, "StubFmService:rxChangeAudioTarget invalid lMask , lconfig" + + lMask + "" + lconfig); + return false; + } + + JFmRxStatus status = mJFmRx.changeAudioTarget(lMask, lconfig); + Log.i(TAG, "mJFmRx.changeAudioTarget returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.changeAudioTarget returned status " + + status.toString()); + return false; + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxChangeDigitalTargetConfiguration(int digitalConfig) { + Log.i(TAG, "StubFmService:rxChangeDigitalTargetConfiguration "); + + if (mRxState != STATE_ENABLED) { + Log.e(TAG, + "rxChangeDigitalTargetConfiguration: failed, already in state " + + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmRx.JFmRxEcalSampleFrequency lconfig = JFmUtils.getEnumConst( + JFmRx.JFmRxEcalSampleFrequency.class, digitalConfig); + if (lconfig == null) { + Log.e(TAG, + "StubFmService:rxChangeDigitalTargetConfiguration invalid lconfig" + + lconfig); + return false; + } + + JFmRxStatus status = mJFmRx.changeDigitalTargetConfiguration(lconfig); + Log.i(TAG, "mJFmRx.changeDigitalTargetConfiguration returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, + "mJFmRx.changeDigitalTargetConfiguration returned status " + + status.toString()); + + return false; + } + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxEnableAudioRouting() { + Log.i(TAG, "StubFmService:rxEnableAudioRouting "); + if (mRxState != STATE_ENABLED) { + Log + .e(TAG, "rxEnableAudioRouting: failed, already in state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmRxStatus status = mJFmRx.enableAudioRouting(); + Log.i(TAG, "mJFmRx.enableAudioRouting returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.enableAudioRouting returned status " + + status.toString()); + + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxDisableAudioRouting() { + Log.i(TAG, "StubFmService:rxDisableAudioRouting "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxDisableAudioRouting: failed, already in state " + + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmRxStatus status = mJFmRx.disableAudioRouting(); + if (DBG) + Log.i(TAG, "mJFmRx.disableAudioRouting returned status " + + status.toString()); + if (status != JFmRxStatus.PENDING) { + Log.e(TAG, "mJFmRx.disableAudioRouting returned status " + + status.toString()); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /*When Asynchronous Events like Call, Music PLayback,VideoPlayback is happning, FM will be put into pause state + by disabling the audio.*/ + public boolean pauseFm() { + if (rxIsEnabled() == true) { + Log.i(TAG, "StubFmService:pauseFm "); + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "pauseFm: failed, already in state " + mRxState); + return false; + } + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + /* L25 Specific */ + //mAudioManager.setParameters(AUDIO_RX_ENABLE+"=false"); + int off = 0; + /* L27 Specific */ + enableRx(off); + + if (mWakeLock != null) { + mWakeLock.acquire(); + } + + try { + JFmRxStatus status = mJFmRx.disableAudioRouting(); + Log.i(TAG, "mJFmRx.disableAudioRouting returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.disableAudioRouting returned status " + + status.toString()); + return false; + } + } catch (Exception e) { + Log.e(TAG, "disableAudioRouting: Exception thrown during disableAudioRouting (" + + e.toString() + ")"); + return false; + } + + mDelayedDisableHandler.postDelayed(mDelayedPauseDisable, + FM_DISABLE_DELAY); + return true; + } else + return false; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /*This API will be called when teh user wants to resume FM after it has been paused. + With this API you resume the FM playback by restoring the values before pause.*/ + public boolean resumeFm() { + + Log.i(TAG, "StubFmService: resumeFm "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + mDelayedDisableHandler.removeCallbacks(mDelayedPauseDisable); + mDelayedDisableHandler.removeCallbacks(mDelayedDisable); + + // Tell the music playback service to pause + // TODO: these constants need to be published somewhere in the + // framework. + Intent i = new Intent("com.android.music.musicservicecommand"); + i.putExtra("command", "pause"); + mContext.sendBroadcast(i); + + if ((mWakeLock != null) && (mWakeLock.isHeld())) { + mWakeLock.release(); + } + /* L25 Specific */ + //mAudioManager.setParameters(AUDIO_RX_ENABLE+"=true"); + int On=1; + /* L27 Specific */ + enableRx(On); + + mRxState = STATE_RESUME; + mFmPauseResume =STATE_RESUME; + + Log.d(TAG, "Sending restore values intent"); + Intent restoreValuesIntent = new Intent(FM_RESTORE_VALUES); + mContext.sendBroadcast(restoreValuesIntent); + + + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + public boolean rxCompleteScan_nb() { + Log.i(TAG, "StubFmService:rxCompleteScan_nb"); + + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxCompleteScan_nb: failed, fm not enabled state " + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmRxStatus status = mJFmRx.completeScan(); + Log.i(TAG, "mJFmRx.completeScan returned status " + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.completeScan returned status " + + status.toString()); + return false; + } + + mIsCompleteScanInProgress = true; + + return true; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + public boolean rxStopCompleteScan_nb() { + Log.i(TAG, "StubFmService:rxStopCompleteScan_nb"); + + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxStopCompleteScan_nb: failed, fm not enabled state " + + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) { + JFmRxStatus status = mJFmRx.stopCompleteScan(); + Log.i(TAG, "mJFmRx.stopCompleteScan returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.stopCompleteScan returned status " + + status.toString()); + return false; + } + + return true; + } else { + Log.e(TAG, "Seek/tune is in progress.cannot call the API"); + return false; + } + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* separate queue for each set call synchronization */ + private BlockingQueue<String> mStopCompleteScanSyncQueue = new LinkedBlockingQueue<String>( + 5); + public int rxStopCompleteScan() { + Log.i(TAG, "StubFmService:rxStopCompleteScan"); + + if (mRxState != STATE_ENABLED) { + Log.e(TAG, "rxStopCompleteScan: failed, fm not enabled state " + + mRxState); + return 0; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) { + JFmRxStatus status = mJFmRx.stopCompleteScan(); + Log.i(TAG, "mJFmRx.stopCompleteScan returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.stopCompleteScan returned status " + + status.toString()); + if (JFmRxStatus.COMPLETE_SCAN_IS_NOT_IN_PROGRESS == status) { + return status.getValue(); + } else + return 0; + } + + /* implementation to make the set API Synchronous */ + + try { + Log.i(TAG, + "StubFmService:rxStopCompleteScan(): -------- Waiting... "); + String syncString = mStopCompleteScanSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string received: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.stopCompleteScan-- Wait() s Exception!!!"); + } + + } else { + Log.e(TAG, "Seek/tune is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + + Log.i(TAG, "StubFmService:stopCompleteScan(): ---------- Exiting... "); + return mStopCompleteScanStatus; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mValidChannelSyncQueue = new LinkedBlockingQueue<String>( + 5); + public synchronized boolean rxIsValidChannel() { + Log.i(TAG, "StubFmService:rxIsValidChannel"); + + if (mRxState != STATE_ENABLED) { + Log + .e(TAG, "rxIsValidChannel: failed, fm not enabled state " + + mRxState); + return false; + } + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.isValidChannel(); + Log.i(TAG, "mJFmRx.isValidChannel returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.isValidChannel returned status " + + status.toString()); + return false; + } + + /* implementation to make the FM API Synchronous */ + + try { + String syncString = mValidChannelSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.isValidChannel-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log.i(TAG, "StubFmService:rxIsValidChannel(): ---------- Exiting... "); + return mIsValidChannel; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mFwVersionSyncQueue = new LinkedBlockingQueue<String>( + 5); + public synchronized double rxGetFwVersion() { + Log.i(TAG, "StubFmService:rxGetFwVersion"); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false) + && (mIsCompleteScanInProgress == false)) { + + JFmRxStatus status = mJFmRx.getFwVersion(); + Log.i(TAG, "mJFmRx.getFwVersion returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getFwVersion returned status " + + status.toString()); + return 0; + } + + /* implementation to make the FM API Synchronous */ + + try { + String syncString = mFwVersionSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log.e(TAG, "mJFmRx.getFwVersion-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + Log.i(TAG, "StubFmService:rxGetFwVersion(): ---------- Exiting... "); + return getFwVersion; + + } + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + /* (separate queue for each get call synchronization) */ + private BlockingQueue<String> mCompleteScanProgressSyncQueue = new LinkedBlockingQueue<String>( + 5); + + public synchronized int rxGetCompleteScanProgress() { + Log.i(TAG, "StubFmService:rxGetCompleteScanProgress"); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) { + JFmRxStatus status = mJFmRx.getCompleteScanProgress(); + if (DBG) + Log.i(TAG, "mJFmRx.getCompleteScanProgress returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getCompleteScanProgress returned status " + + status.toString()); + if (JFmRxStatus.COMPLETE_SCAN_IS_NOT_IN_PROGRESS == status) { + return status.getValue(); + } else + return 0; + } + /* implementation to make the FM API Synchronous */ + + try { + String syncString = mCompleteScanProgressSyncQueue.take(); + if (!syncString.equals("*")) { + Log.e(TAG, "wrong sync string reseived: " + syncString); + } + } catch (InterruptedException e) { + Log + .e(TAG, + "mJFmRx.getCompleteScanProgress-- Wait() s Exception!!!"); + } + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return FM_SEEK_IN_PROGRESS; + } + if (DBG) + Log + .i(TAG, + "StubFmService:rxGetCompleteScanProgress(): ---------- Exiting... "); + return getScanProgress; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public boolean rxGetCompleteScanProgress_nb() { + Log.i(TAG, "StubFmService:rxGetCompleteScanProgress_nb"); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) { + JFmRxStatus status = mJFmRx.getCompleteScanProgress(); + Log.i(TAG, "mJFmRx.rxGetCompleteScanProgress_nb returned status " + + status.toString()); + if (JFmRxStatus.PENDING != status) { + Log.e(TAG, "mJFmRx.getCompleteScanProgress returned status " + + status.toString()); + return false; + } + + } else { + Log.e(TAG, "Seek is in progress.cannot call the API"); + return false; + } + Log + .i(TAG, + "StubFmService:rxGetCompleteScanProgress(): ---------- Exiting... "); + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txEnable() { + /* If Rx is NOT ENABLED then only Enable TX*/ + if(rxIsEnabled()==true){ + Log.e(TAG, "Fm TX Enable: FM RX is enabled could not Enable fm TX"); + return false; + } + + Log.i(TAG, "StubFmService: txEnable "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmTxStatus status; + + /* Creating the Fm Tx Context*/ + + // try communicating for 5 seconds (by trying to create a valid FmRX context) + boolean fmTxCreated = false; + for (int count = 0; count< 10; count++) { + Log.i(TAG, "FmTxEnable: FmRx create try #" + count); + Log.i(TAG, "FmTxEnable: mJFmTx is:"+ mJFmTx); + status = mJFmTx.txCreate(this); + Log.i(TAG, "FmTxEnable: FmRx create returned " + status.toString()); + if (status == JFmTxStatus.SUCCESS) { + fmTxCreated = true; + break; + } + SystemClock.sleep(500); + } + + if (fmTxCreated == false) { + Log.e(TAG, "fmTxCreated: FmRx create failed. Aborting"); + return false; + } + + +/* Enabling the Fm Tx module */ + try { + // TODO: these constants need to be published somewhere in the framework. + status = mJFmTx.txEnable(); + Log.i(TAG, "mJFmTx.txEnable returned status " + status.toString()); + + /* If the Operation Fail, Send false to the user and reset the MCP Monitor */ + if (status != JFmTxStatus.PENDING && status != JFmTxStatus.SUCCESS) { + Log.e(TAG, "mJFmTx.txEnable returned status " + status.toString()); + return false; + } + } catch (Exception e) { + Log.e(TAG, "enable: Exception thrown during enable ("+ e.toString() + ")"); + return false; + } + + if (status == JFmTxStatus.SUCCESS) + { + Intent intentTxEnable = new Intent(FmRadioIntent.FM_TX_ENABLED_ACTION); + intentTxEnable.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxEnable, FMRX_PERM); + + }else { + // set a delayed timeout message + } + + return true; + } + + + + public boolean IsFmTxEnabled() { + Log.i(TAG, "StubFmService: IsFmTxEnabled "); + mContext.enforceCallingOrSelfPermission(FMRX_PERM, + "Need FMRX_PERM permission"); + return (mTxState == STATE_ENABLED); + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + public boolean txDisable() { + JFmTxStatus status; + Log.i(TAG, "StubFmService: disableTx "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + try { + status = mJFmTx.txDisable(); + Log.i(TAG, "mJFmTx.txDisable returned status " + status.toString()); + if (status != JFmTxStatus.PENDING && status != JFmTxStatus.SUCCESS){ + destroyJFmTx(); /* destroy all connection with deamon on radioOff */ + return false; + } + } catch (Exception e) { + Log.e(TAG, "txDisable: Exception thrown during disable ("+ e.toString() + ")"); + return false; + } + + mTxState = STATE_DEFAULT; + + if (status == JFmTxStatus.SUCCESS) + { + //TODO - Need to see what to send here if the operation is synchronic + + } + else { + // set a delayed timeout message + } + + return true; + } + + + /* Destroy Tx Context */ + private void destroyJFmTx() { + JFmTxStatus status; + Log.i(TAG, "StubFmService: destroyJFmTx "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,"Need FMRX_ADMIN_PERM permission"); + + try { + if (mJFmTx != null) { + status = mJFmTx.txDestroy(); + Log.i(TAG, "mJFmTx.destroyJFmTx returned status " + status.toString()); + } + } catch (Exception e) { + Log.e(TAG, "destroyJFmTx: Exception thrown during destroy ("+ e.toString() + ")"); + } + + mTxState = STATE_DEFAULT; + + } + + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + public boolean txStartTransmission() { + Log.i(TAG, "StubFmService: txStartTransmission "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + try { + + JFmTxStatus status = mJFmTx.txStartTransmission(); + Log.i(TAG, "mJFmTx.txStartTransmission returned status " + status.toString()); + if (JFmTxStatus.PENDING != status) { + Log.e(TAG, "mJFmTx.txStartTransmission returned status " + + status.toString()); + return false; + } + + } catch (Exception e) { + Log.e(TAG, "txStartTransmission: Exception thrown during disable (" + + e.toString() + ")"); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + public boolean txStopTransmission() { + Log.i(TAG, "StubFmService: txStopTransmission "); + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + try { + + JFmTxStatus status = mJFmTx.txStopTransmission(); + Log.i(TAG, "mJFmTx.txStopTransmission returned status " + status.toString()); + if (JFmTxStatus.PENDING != status) { + Log.e(TAG, "mJFmTx.txStopTransmission returned status " + + status.toString()); + return false; + } + } catch (Exception e) { + Log.e(TAG, "txStopTransmission: Exception thrown during disable (" + + e.toString() + ")"); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txTune(long freq) { + Log.i(TAG, "StubFmService:txTune " + freq); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmTx.JFmTxFreq lFreq = new JFmTx.JFmTxFreq(freq); + if (lFreq == null) { + Log.e(TAG, "StubFmService:txTune invalid frequency " + lFreq); + return false; + } + Log.d(TAG, "StubFmService:txTune " + lFreq); + JFmTxStatus status = mJFmTx.txTune(lFreq); + Log.i(TAG, "mJFmRx.tune returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txTune returned status " + status.toString()); + return false; + } + return true; + + } + + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txGetTunedFrequency( ) { + Log.i(TAG, "StubFmService:txGetTunedFrequency "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetTunedFrequency(); + + Log.i(TAG, "mJFmTx.txGetTunedFrequency returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetTunedFrequency returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txSetPowerLevel(int powerLevel) { + Log.i(TAG, "StubFmService:txSetPowerLevel " + powerLevel); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + JFmTx.JFmTxPowerLevel lPowerLevel = new JFmTx.JFmTxPowerLevel(powerLevel); + if (lPowerLevel == null) { + Log.e(TAG, "StubFmService:txSetPowerLevel invalid PowerLevel " + lPowerLevel); + return false; + } + Log.d(TAG, "StubFmService:txSetPowerLevel " + lPowerLevel); + JFmTxStatus status = mJFmTx.txSetPowerLevel(lPowerLevel); + Log.i(TAG, "mJFmTx.txSetPowerLevel returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetPowerLevel returned status " + status.toString()); + return false; + } + return true; + + } + + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txGetPowerLevel() { + Log.i(TAG, "StubFmService:txGetPowerLevel "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetPowerLevel(); + Log.i(TAG, "mJFmTx.txGetPowerLevel returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetPowerLevel returned status " + status.toString()); + return false; + } + return true; + + } + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txEnableRds() { + Log.i(TAG, "StubFmService:txEnableRds "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txEnableRds(); + + Log.i(TAG, "mJFmTx.txEnableRds returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txEnableRds returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txDisableRds() { + Log.i(TAG, "StubFmService:txDisableRds "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txDisableRds(); + + Log.i(TAG, "mJFmTx.txDisableRds returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txDisableRds returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txSetRdsTransmissionMode(int mode) { + Log.i(TAG, "StubFmService:txSetRdsTransmissionMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmTxRdsTransmissionMode lMode = JFmUtils.getEnumConst(JFmTx.JFmTxRdsTransmissionMode.class, + mode); + if (lMode == null) { + Log.e(TAG, "StubFmService:txSetRdsTransmissionMode invalid lMode " + lMode); + return false; + } + + JFmTxStatus status = mJFmTx.txSetRdsTransmissionMode(lMode); + + Log.i(TAG, "mJFmTx.txSetRdsTransmissionMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsTransmissionMode returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txGetRdsTransmissionMode( ) { + Log.i(TAG, "StubFmService:txGetRdsTransmissionMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsTransmissionMode(); + + Log.i(TAG, "mJFmTx.txGetRdsTransmissionMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsTransmissionMode returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txSetRdsTextPsMsg(String psStr) { + Log.i(TAG, "StubFmService:txSetRdsTextPsMsg --> psString = "+psStr); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + int strLength = psStr.length(); + //byte[] psString = psStr.getBytes();// converting String to Byte Array + + JFmTxStatus status = mJFmTx.txSetRdsTextPsMsg(psStr,strLength); + + Log.i(TAG, "mJFmTx.txSetRdsTextPsMsg returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsTextPsMsg returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txGetRdsTextPsMsg( ) { + Log.i(TAG, "StubFmService:txGetRdsTextPsMsg --> psString = "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsTextPsMsg(); + + Log.i(TAG, "mJFmTx.txGetRdsTextPsMsg returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsTextPsMsg returned status " + status.toString()); + return false; + } + return true; + + } + + + + /************************************************************************************************* + * Implementation of IFMReciever IPC interface + *************************************************************************************************/ + + public boolean txWriteRdsRawData(String msg) { + Log.i(TAG, "StubFmService:txWriteRdsRawData "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + int strLength = msg.length(); + //byte[] rawData = msg.getBytes();// converting String to Byte Array + + JFmTxStatus status = mJFmTx.txWriteRdsRawData(msg,strLength); + + Log.i(TAG, "mJFmTx.txWriteRdsRawData returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txWriteRdsRawData returned status " + status.toString()); + return false; + } + return true; + + } + + public boolean txChangeDigitalSourceConfiguration(int ecalSampleFreq){ + Log.i(TAG, "StubFmService:txChangeDigitalSourceConfiguration "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txChangeDigitalSourceConfiguration(ecalSampleFreq); + + Log.i(TAG, "mJFmTx.txChangeDigitalSourceConfiguration returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txChangeDigitalSourceConfiguration returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txChangeAudioSource(int audioSrc,int ecalSampleFreq){ + Log.i(TAG, "StubFmService:txChangeAudioSource "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmTxEcalResource lAudioSrc = JFmUtils.getEnumConst( + JFmTx.JFmTxEcalResource.class, audioSrc); + if (lAudioSrc == null) { + Log.e(TAG, "StubFmService:txChangeAudioSource invalid lAudioSrc " + lAudioSrc); + return false; + } + + JFmTx.JFmTxEcalSampleFrequency lEcalSampleFreq = JFmUtils.getEnumConst( + JFmTx.JFmTxEcalSampleFrequency.class, ecalSampleFreq); + if (lAudioSrc == null) { + Log.e(TAG, "StubFmService:txChangeAudioSource invalid lEcalSampleFreq " + lEcalSampleFreq); + return false; + } + + + JFmTxStatus status = mJFmTx.txChangeAudioSource(lAudioSrc,lEcalSampleFreq); + + Log.i(TAG, "mJFmTx.txChangeAudioSource returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txChangeAudioSource returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txSetRdsECC(int ecc){ + Log.i(TAG, "StubFmService:txSetRdsECC "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txSetRdsECC(ecc); + + Log.i(TAG, "mJFmTx.txSetRdsECC returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsECC returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetRdsECC( ){ + Log.i(TAG, "StubFmService:txGetRdsECC "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetRdsECC(); + + Log.i(TAG, "mJFmTx.txGetRdsECC returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsECC returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetMonoStereoMode(int mode){ + Log.i(TAG, "StubFmService:txSetMonoStereoMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTx.JFmTxMonoStereoMode lMode = JFmUtils.getEnumConst( + JFmTx.JFmTxMonoStereoMode.class, mode); + if (lMode == null) { + Log.e(TAG, "StubFmService:txSetPreEmphasisFilter invalid lMode " + lMode); + return false; + } + + JFmTxStatus status = mJFmTx.txSetMonoStereoMode(lMode); + + Log.i(TAG, "mJFmTx.txSetMonoStereoMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetMonoStereoMode returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetMonoStereoMode(){ + Log.i(TAG, "StubFmService:txGetMonoStereoMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetMonoStereoMode(); + + Log.i(TAG, "mJFmTx.txGetMonoStereoMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetMonoStereoMode returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txSetPreEmphasisFilter(int preEmpFilter) { + Log.i(TAG, "StubFmService:txSetPreEmphasisFilter "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTx.JFmTxEmphasisFilter lPreEmpFilter = JFmUtils.getEnumConst( + JFmTx.JFmTxEmphasisFilter.class, preEmpFilter); + if (lPreEmpFilter == null) { + Log.e(TAG, "StubFmService:txSetPreEmphasisFilter invalid lPreEmpFilter " + lPreEmpFilter); + return false; + } + + JFmTxStatus status = mJFmTx.txSetPreEmphasisFilter(lPreEmpFilter); + + Log.i(TAG, "mJFmTx.txSetPreEmphasisFilter returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetPreEmphasisFilter returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetPreEmphasisFilter( ) { + Log.i(TAG, "StubFmService:txGetPreEmphasisFilter "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetPreEmphasisFilter(); + + Log.i(TAG, "mJFmTx.txGetPreEmphasisFilter returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetPreEmphasisFilter returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetMuteMode(int muteMode){ + Log.i(TAG, "StubFmService:txSetMuteMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTx.JFmTxMuteMode lMuteMode = JFmUtils.getEnumConst( + JFmTx.JFmTxMuteMode.class, muteMode); + if (lMuteMode == null) { + Log.e(TAG, "StubFmService:txSetMuteMode invalid lMuteMode " + lMuteMode); + return false; + } + JFmTxStatus status = mJFmTx.txSetMuteMode(lMuteMode); + + Log.i(TAG, "mJFmTx.txSetMuteMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetMuteMode returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetMuteMode( ){ + Log.i(TAG, "StubFmService:txGetMuteMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetMuteMode(); + + Log.i(TAG, "mJFmTx.txGetMuteMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetMuteMode returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetRdsAfCode(int afCode) { + Log.i(TAG, "StubFmService:txSetRdsAfCode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txSetRdsAfCode(afCode); + + Log.i(TAG, "mJFmTx.txSetRdsAfCode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsAfCode returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetRdsAfCode( ) { + Log.i(TAG, "StubFmService:txGetRdsAfCode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetRdsAfCode(); + + Log.i(TAG, "mJFmTx.txGetRdsAfCode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsAfCode returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetRdsPiCode(int piCode){ + Log.i(TAG, "StubFmService:txSetRdsPiCode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmTxRdsPiCode lPiCode = new JFmTx.JFmTxRdsPiCode(piCode); + if (lPiCode == null) { + Log.e(TAG, "StubFmService:txSetRdsPiCode invalid lPiCode " + lPiCode); + return false; + } + + JFmTxStatus status = mJFmTx.txSetRdsPiCode(lPiCode); + + Log.i(TAG, "mJFmTx.txSetRdsPiCode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsPiCode returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetRdsPiCode( ){ + Log.i(TAG, "StubFmService:txGetRdsPiCode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsPiCode(); + + Log.i(TAG, "mJFmTx.txGetRdsPiCode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsPiCode returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetRdsPtyCode(int ptyCode) { + Log.i(TAG, "StubFmService:txSetRdsPtyCode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTx.JFmTxRdsPtyCode lPtyCode = new JFmTx.JFmTxRdsPtyCode(ptyCode); + if (lPtyCode == null) { + Log.e(TAG, "StubFmService:txSetRdsPtyCode invalid ptyCode " + lPtyCode); + return false; + } + + JFmTxStatus status = mJFmTx.txSetRdsPtyCode(lPtyCode); + + Log.i(TAG, "mJFmTx.txSetRdsPtyCode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsPtyCode returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetRdsPtyCode( ) { + Log.i(TAG, "StubFmService:txGetRdsPtyCode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsPtyCode(); + + Log.i(TAG, "mJFmTx.txGetRdsPtyCode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsPtyCode returned status " + status.toString()); + return false; + } + return true; + + } + + + + + public boolean txSetRdsTextRepertoire(int repertoire){ + Log.i(TAG, "StubFmService:txSetRdsTextRepertoire "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmTxRepertoire lRepertoire = JFmUtils.getEnumConst( + JFmTx.JFmTxRepertoire.class, repertoire); + if (lRepertoire == null) { + Log.e(TAG, "StubFmService:txSetRdsTextRepertoire invalid lRepertoire " + lRepertoire); + return false; + } + + + JFmTxStatus status = mJFmTx.txSetRdsTextRepertoire(lRepertoire); + + Log.i(TAG, "mJFmTx.txSetRdsTextRepertoire returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsTextRepertoire returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txGetRdsTextRepertoire( ){ + Log.i(TAG, "StubFmService:txGetRdsTextRepertoire "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsTextRepertoire(); + + Log.i(TAG, "mJFmTx.txGetRdsTextRepertoire returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsTextRepertoire returned status " + status.toString()); + return false; + } + return true; + + } + + + + + public boolean txSetRdsPsDisplayMode(int dispalyMode) { + Log.i(TAG, "StubFmService:txSetRdsPsDisplayMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmRdsPsDisplayMode lPsDisplayMode = JFmUtils.getEnumConst( + JFmTx.JFmRdsPsDisplayMode.class, dispalyMode); + if (lPsDisplayMode == null) { + Log.e(TAG, "StubFmService:txSetRdsPsDisplayMode invalid lPsDisplayMode " + lPsDisplayMode); + return false; + } + + JFmTxStatus status = mJFmTx.txSetRdsPsDisplayMode(lPsDisplayMode); + + Log.i(TAG, "mJFmTx.txSetRdsPsDisplayMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsPsDisplayMode returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txGetRdsPsDisplayMode( ) { + Log.i(TAG, "StubFmService:txGetRdsPsDisplayMode "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsPsDisplayMode(); + + Log.i(TAG, "mJFmTx.txGetRdsPsDisplayMode returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsPsDisplayMode returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetRdsPsScrollSpeed(int scrollSpeed) { + Log.i(TAG, "StubFmService:txSetRdsPsScrollSpeed "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txSetRdsPsScrollSpeed(scrollSpeed); + + Log.i(TAG, "mJFmTx.txSetRdsPsScrollSpeed returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsPsScrollSpeed returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txGetRdsPsScrollSpeed( ) { + Log.i(TAG, "StubFmService:txGetRdsPsScrollSpeed "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetRdsPsScrollSpeed(); + + Log.i(TAG, "mJFmTx.txGetRdsPsScrollSpeed returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsPsScrollSpeed returned status " + status.toString()); + return false; + } + return true; + + } + + public boolean txSetRdsTextRtMsg(int msgType, String msg, int msgLength){ + Log.i(TAG, "StubFmService:txSetRdsTextRtMsg "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmRdsRtMsgType lMsgType = JFmUtils.getEnumConst( + JFmTx.JFmRdsRtMsgType.class, msgType); + if (lMsgType == null) { + Log.e(TAG, "StubFmService:txSetRdsTextRtMsg invalid lMsgType " + lMsgType); + return false; + } + JFmTxStatus status = mJFmTx.txSetRdsTextRtMsg(lMsgType,msg,msgLength); + + Log.i(TAG, "mJFmTx.txSetRdsTextRtMsg returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsTextRtMsg returned status " + status.toString()); + return false; + } + return true; + + } + + + public boolean txGetRdsTextRtMsg(){ + Log.i(TAG, "StubFmService:txGetRdsTextRtMsg "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsTextRtMsg(); + + Log.i(TAG, "mJFmTx.txGetRdsTextRtMsg returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsTextRtMsg returned status " + status.toString()); + return false; + } + return true; + + } + + + + + public boolean txSetRdsTransmittedGroupsMask(long rdsTrasmittedGrpMask){ + Log.i(TAG, "StubFmService:txSetRdsTransmittedGroupsMask "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txSetRdsTransmittedGroupsMask(rdsTrasmittedGrpMask); + + Log.i(TAG, "mJFmTx.txSetRdsTransmittedGroupsMask returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsTransmittedGroupsMask returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txGetRdsTransmittedGroupsMask(){ + Log.i(TAG, "StubFmService:txGetRdsTransmittedGroupsMask "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetRdsTransmittedGroupsMask(); + + Log.i(TAG, "mJFmTx.txGetRdsTransmittedGroupsMask returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsTransmittedGroupsMask returned status " + status.toString()); + return false; + } + return true; + + } + + + + + public boolean txSetRdsTrafficCodes(int taCode, int tpCode){ + Log.i(TAG, "StubFmService:txSetRdsTrafficCodes "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTx.JFmTaCode lTaCode = JFmUtils.getEnumConst( + JFmTx.JFmTaCode.class, taCode); + if (lTaCode == null) { + Log.e(TAG, "StubFmService:txChangeAudioSource invalid lTaCode " + lTaCode); + return false; + } + + JFmTx.JFmTpCode lTpCode = JFmUtils.getEnumConst( + JFmTx.JFmTpCode.class, tpCode); + if (lTaCode == null) { + Log.e(TAG, "StubFmService:txChangeAudioSource invalid lTpCode " + lTpCode); + return false; + } + + JFmTxStatus status = mJFmTx.txSetRdsTrafficCodes(lTaCode,lTpCode); + + Log.i(TAG, "mJFmTx.txSetRdsTrafficCodes returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsTrafficCodes returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txGetRdsTrafficCodes(){ + Log.i(TAG, "StubFmService:txGetRdsTrafficCodes "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + + JFmTxStatus status = mJFmTx.txGetRdsTrafficCodes(); + + Log.i(TAG, "mJFmTx.txGetRdsTrafficCodes returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsTrafficCodes returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txSetRdsMusicSpeechFlag(int musicSpeechFlag) { + Log.i(TAG, "StubFmService:txSetRdsMusicSpeechFlag "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTx.JFmMusicSpeechFlag lMusicSpeechFlag = JFmUtils.getEnumConst( + JFmTx.JFmMusicSpeechFlag.class, musicSpeechFlag); + if (lMusicSpeechFlag == null) { + Log.e(TAG, "StubFmService:txChangeAudioSource invalid lMusicSpeechFlag " + lMusicSpeechFlag); + return false; + } + + JFmTxStatus status = mJFmTx.txSetRdsMusicSpeechFlag(lMusicSpeechFlag); + + Log.i(TAG, "mJFmTx.txSetRdsMusicSpeechFlag returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txSetRdsMusicSpeechFlag returned status " + status.toString()); + return false; + } + return true; + + } + + + + public boolean txGetRdsMusicSpeechFlag( ) { + Log.i(TAG, "StubFmService:txGetRdsMusicSpeechFlag "); + + mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM, + "Need FMRX_ADMIN_PERM permission"); + + JFmTxStatus status = mJFmTx.txGetRdsMusicSpeechFlag(); + + Log.i(TAG, "mJFmTx.txGetRdsMusicSpeechFlag returned status " + status.toString()); + if (status != JFmTxStatus.PENDING) { + Log.e(TAG, "mJFmTx.txGetRdsMusicSpeechFlag returned status " + status.toString()); + return false; + } + return true; + + } + + + /************************************************************************************************* + * Implementation of IFmRadio IPC interface + *************************************************************************************************/ + + public int txGetFMState() { + mContext.enforceCallingOrSelfPermission(FMRX_PERM, + "Need FMRX_PERM permission"); + return mTxState; + } + + + + /************************************************************************************************* + * JFmRxlback interface for receiving its events and for broadcasting them + * as intents + *************************************************************************************************/ + + public void fmRxRawRDS(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsGroupTypeMask bitInMaskValue, byte[] groupData) + + { + Log.i(TAG, "StubFmService:fmRxRawRDS "); + Log.d(TAG, "StubFmService:fmRxRawRDS status = " + status.toString()); + Log.d(TAG, "StubFmService:fmRxRawRDS bitInMaskValue = " + + bitInMaskValue.getValue()); + + } + + public void fmRxRadioText(JFmRx context, JFmRxStatus status, + boolean resetDisplay, byte[] msg1, int len, int startIndex, + JFmRx.JFmRxRepertoire repertoire) { + Log.i(TAG, "StubFmService:fmRxRadioText "); + Log.d(TAG, + "StubFmService:fmRxRadioText status = , msg1 = ,len = , startIndex = " + + status.toString() + " " +" " + len + + " " + startIndex); + Log.d(TAG, "StubFmService:sending intent RDS_TEXT_CHANGED_ACTION"); + + Intent intentRds = new Intent(FmRadioIntent.RDS_TEXT_CHANGED_ACTION); + if (FM_SEND_RDS_IN_BYTEARRAY == true) { + Bundle b = new Bundle(); + b.putByteArray(FmRadioIntent.RDS, msg1);// Send Byte Array to App + intentRds.putExtras(b); + } else { + /* + *Convert the received Byte Array to + * appropriate String + */ + String radioTextString = findFromLookupTable(msg1, repertoire); + intentRds.putExtra(FmRadioIntent.RADIOTEXT_CONVERTED, + radioTextString);// converted String + } + + intentRds.putExtra(FmRadioIntent.STATUS, status.getValue());// Status + + mContext.sendBroadcast(intentRds, FMRX_PERM); + } + + public void fmRxPiCodeChanged(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsPiCode pi) { + + Log.i(TAG, "StubFmService:fmRxPiCodeChanged "); + Log.d(TAG, "StubFmService:fmRxPiCodeChanged status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxPiCodeChanged pi = " + pi.getValue()); + + if (status == JFmRxStatus.SUCCESS) { + /* simple mechanism to prevent displaying repetitious messages */ + if (pi.getValue() != last_msg_printed) { + last_msg_printed = pi.getValue(); + Log.d(TAG, "StubFmService:sending intent PI_CODE_CHANGED_ACTION"); + Intent intentPi = new Intent( + FmRadioIntent.PI_CODE_CHANGED_ACTION); + intentPi.putExtra(FmRadioIntent.PI, pi.getValue()); + intentPi.putExtra(FmRadioIntent.STATUS, status.getValue()); + mContext.sendBroadcast(intentPi, FMRX_PERM); + } + } + } + + public void fmRxPtyCodeChanged(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsPtyCode pty) { + + Log.i(TAG, "StubFmService:fmRxPtyCodeChanged "); + Log.d(TAG, "StubFmService:fmRxPtyCodeChanged status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxPtyCodeChanged pty = " + pty.getValue()); + + } + + public void fmRxPsChanged(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxFreq frequency, byte[] name, + JFmRx.JFmRxRepertoire repertoire) { + Log.i(TAG, "StubFmService:fmRxPsChanged "); + Log.d(TAG, "StubFmService:fmRxPsChanged status = " + status.toString()); + Log.d(TAG, "StubFmService:fmRxPsChanged frequency = " + + frequency.getValue()); + + Log.d(TAG, "StubFmService:fmRxPsChanged repertoire = " + + repertoire.getValue()); + Log.d(TAG, "StubFmService:sending intent PS_CHANGED_ACTION"); + + + Intent intentPs = new Intent(FmRadioIntent.PS_CHANGED_ACTION); + if (FM_SEND_RDS_IN_BYTEARRAY == true) { + Bundle b = new Bundle(); + b.putByteArray(FmRadioIntent.PS, name);// Send Byte Array to App + intentPs.putExtras(b); + } else { + /* + * Convert the received Byte Array to + * appropriate String Broadcast the PS data Byte Array, Converted + * string to App + */ + + String psString = findFromLookupTable(name, repertoire); + Log.i(TAG, "fmRxPsChanged--> psString = " + psString); + intentPs.putExtra(FmRadioIntent.PS_CONVERTED, psString);// converted + // PS + // String + } + + intentPs.putExtra(FmRadioIntent.REPERTOIRE, repertoire.getValue());// repertoire + intentPs.putExtra(FmRadioIntent.STATUS, status.getValue());// status + + mContext.sendBroadcast(intentPs, FMRX_PERM); + + } + + public void fmRxMonoStereoModeChanged(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxMonoStereoMode mode) { + Log.e(TAG, "StubFmService:fmRxMonoStereoModeChanged status = " + + status.toString()); + + Log.i(TAG, "StubFmService:fmRxMonoStereoModeChanged "); + Log.d(TAG, "StubFmService:fmRxMonoStereoModeChanged status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxMonoStereoModeChanged mode = " + + mode.getValue()); + + /* simple mechanism to prevent displaying repetitious messages */ + if (mode == mMode) + return; + + mMode = mode; + switch (mMode) { + case FM_RX_MONO: + Log.e(TAG, "Mono Mode"); + break; + case FM_RX_STEREO: + Log.e(TAG, "Stereo Mode"); + break; + default: + Log.e(TAG, "Illegal stereo mode received from stack: " + mode); + break; + } + Log + .d(TAG, + "StubFmService:sending intent DISPLAY_MODE_MONO_STEREO_ACTION"); + Intent intentMode = new Intent( + FmRadioIntent.DISPLAY_MODE_MONO_STEREO_ACTION); + intentMode.putExtra(FmRadioIntent.MODE_MONO_STEREO, mode.getValue()); + intentMode.putExtra(FmRadioIntent.STATUS, status.getValue()); + mContext.sendBroadcast(intentMode, FMRX_PERM); + } + + public void fmRxAudioPathChanged(JFmRx context, JFmRxStatus status) { + + Log.i(TAG, "StubFmService:fmRxAudioPathChanged "); + Log.d(TAG, "StubFmService:fmRxAudioPathChanged status = " + + status.toString()); + Log.d(TAG, "StubFmService:sending intent AUDIO_PATH_CHANGED_ACTION"); + + Intent intentPath = new Intent( + FmRadioIntent.AUDIO_PATH_CHANGED_ACTION); + intentPath.putExtra(FmRadioIntent.STATUS, status.getValue()); + mContext.sendBroadcast(intentPath, FMRX_PERM); + } + + public void fmRxAfSwitchFreqFailed(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsPiCode pi, JFmRx.JFmRxFreq tunedFreq, + JFmRx.JFmRxAfFreq afFreq) { + + Log.i(TAG, "StubFmService:fmRxAfSwitchFreqFailed "); + Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed pi = " + pi.getValue()); + Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed tunedFreq = " + + tunedFreq.getValue()); + Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed afFreq = " + + afFreq.getAfFreq()); + + } + + public void fmRxAfSwitchStart(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsPiCode pi, JFmRx.JFmRxFreq tunedFreq, + JFmRx.JFmRxAfFreq afFreq) { + + Log.i(TAG, "StubFmService:fmRxAfSwitchStart "); + Log.d(TAG, "StubFmService:fmRxAfSwitchStart status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxAfSwitchStart pi = " + pi.getValue()); + Log.d(TAG, "StubFmService:fmRxAfSwitchStart tunedFreq = " + + tunedFreq.getValue()); + Log.d(TAG, "StubFmService:fmRxAfSwitchStart afFreq = " + + afFreq.getAfFreq()); + + } + + public void fmRxAfSwitchComplete(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsPiCode pi, JFmRx.JFmRxFreq tunedFreq, + JFmRx.JFmRxAfFreq afFreq) { + + Log.i(TAG, "StubFmService:fmRxAfSwitchComplete "); + Log.d(TAG, "StubFmService:fmRxAfSwitchComplete status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxAfSwitchComplete pi = " + pi.getValue()); + Log.d(TAG, "StubFmService:fmRxAfSwitchComplete tunedFreq = " + + tunedFreq.getValue()); + Log.d(TAG, "StubFmService:fmRxAfSwitchComplete afFreq = " + + afFreq.getAfFreq()); + + } + + public void fmRxAfListChanged(JFmRx context, JFmRxStatus status, + JFmRx.JFmRxRdsPiCode pi, int[] afList, + JFmRx.JFmRxAfListSize afListSize) { + + Log.i(TAG, "StubFmService:fmRxAfListChanged "); + Log.d(TAG, "StubFmService:fmRxAfListChanged status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxAfListChanged pi = " + pi.getValue()); + Log.d(TAG, "StubFmService:fmRxAfListChanged afListSize = " + + afListSize.getValue()); + + } + + public void fmRxCompleteScanDone(JFmRx context, JFmRxStatus status, + int numOfChannels, int[] channelsData) { + + mIsCompleteScanInProgress = false; + + Log.i(TAG, "StubFmService:fmRxCompleteScanDone "); + Log.d(TAG, "StubFmService:fmRxCompleteScanDone status = " + + status.toString()); + Log.d(TAG, "StubFmService:fmRxCompleteScanDone numOfChannels = " + + numOfChannels); + for (int i = 0; i < numOfChannels; i++) + Log.d(TAG, "StubFmService:fmRxCompleteScanDone channelsData = " + i + + " " + +channelsData[i]); + + Log.i(TAG, "StubFmService:COMPLETE_SCAN_DONE_ACTION "); + Intent intentscan = new Intent( + FmRadioIntent.COMPLETE_SCAN_DONE_ACTION); + Bundle b = new Bundle(); + b.putIntArray(FmRadioIntent.SCAN_LIST, channelsData); + b.putInt(FmRadioIntent.STATUS, status.getValue()); + b.putInt(FmRadioIntent.SCAN_LIST_COUNT, numOfChannels); + intentscan.putExtras(b); + mContext.sendBroadcast(intentscan, FMRX_PERM); + } + + public void fmRxCmdEnable(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdEnable "); + Log.d(TAG, " fmRxCmdEnable ( command: , status: , value: )" + command + + "" + status + "" + value); + + if (status == JFmRxStatus.SUCCESS) { + updateEnableConfiguration(); + } + + else { + + Log.e(TAG, " fmRxCmdEnable fail (status: " + status + ", value: " + + value); + mRxState = STATE_DEFAULT; + } + int RXicon = R.drawable.rxradio; + sendNotificationRX(); + Log.d(TAG, "Sending restore values intent"); + Intent restoreValuesIntent = new Intent(FM_RESTORE_VALUES); + mContext.sendBroadcast(restoreValuesIntent); + enableIntent(status); + } + + public synchronized void fmRxCmdDisable(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdDisable "); + Log.d(TAG, " fmRxCmdDisable ( command: , status: , value: )" + command + + "" + status + "" + value); + + if (status != JFmRxStatus.SUCCESS) { + Log.e(TAG, "StubFmService:fmRxCmdDisable failed "); + return ; + } + destroyJFmRx(); + mRxState = STATE_DISABLED; + int off =0; + /* L27 Specific */ + enableRx(off); + /* Release the wake lock + * so that device can go into + * OFF mode + */ + if ((mWakeLock != null) && (mWakeLock.isHeld())) + mWakeLock.release(); + Log.d(TAG, "FM RX powered on mRxState " + mRxState); + Log.d(TAG, "StubFmService:sending intent FM_DISABLED_ACTION"); + + cancelNotification(FM_RX_NOTIFICATION_ID); + + if (mFmPauseResume == STATE_PAUSE) { + ; + } else { + if (DBG) + Log + .d(TAG, + "StubFmRxService:sending intent FM_DISABLED_ACTION"); + Intent intentDisable = new Intent(FmRadioIntent.FM_DISABLED_ACTION); + intentDisable.putExtra(FmRadioIntent.STATUS, status.getValue()); + mContext.sendBroadcast(intentDisable, FMRX_PERM); + } + + } + + public void fmRxCmdDestroy(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdDestroy "); + Log.d(TAG, " fmRxCmdDestroy ( command: , status: , value: )" + command + + "" + status + "" + value); + } + + public void fmRxCmdDisableAudio(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdDisableAudio "); + Log.d(TAG, " fmRxCmdDisableAudio ( command: , status: , value: )" + + command + "" + status + "" + value); + } + + public void fmRxCmdGetRdsAfSwitchMode(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetRdsAfSwitchMode "); + Log.d(TAG, + " fmRxCmdGetRdsAfSwitchMode ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + getRdsAfSwitchModeValue = (int) value; + + /* implementation to make the FM API Synchronous */ + try { + mRdsAfSwitchModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, + " fmRxCmdGetRdsAfSwitchMode ( getRdsAfSwitchModeValue: )" + + getRdsAfSwitchModeValue); + + } else { + // Code for non blocking call + Log.d(TAG, + "StubFmService:sending intent GET_RDS_AF_SWITCH_MODE_ACTION"); + + Intent getRdsAf = new Intent( + FmRadioIntent.GET_RDS_AF_SWITCH_MODE_ACTION); + getRdsAf.putExtra(FmRadioIntent.GET_RDS_AF_SWITCHMODE, value); + getRdsAf.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getRdsAf, FMRX_PERM); + + } + + + + } + + public void fmRxCmdSetRdsAfSwitchMode(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetRdsAfSwitchMode "); + Log.d(TAG, + " fmRxCmdSetRdsAfSwitchMode ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /* implementation to make the FM API Synchronous */ + try { + mSetRdsAfSwitchModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + } + else + { + + Log.d(TAG, "StubFmService:sending intent SET_RDS_AF_ACTION"); + Intent intent = new Intent(FmRadioIntent.SET_RDS_AF_ACTION); + intent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intent, FMRX_PERM); + } + } + + public void fmRxCmdSetRdsSystem(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetRdsSystem "); + Log.d(TAG, " fmRxCmdSetRdsSystem ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + getRdsSystemValue = (int) value; + /* implementation to make the FM API Synchronous */ + try { + mRdsSystemSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, " fmRxCmdGetRdsSystem ( getRdsSystemValue: )" + + getRdsSystemValue); + } + else + { + Log.d(TAG, "StubFmService:sending intent SET_RDS_SYSTEM_ACTION"); + Intent intent = new Intent(FmRadioIntent.SET_RDS_SYSTEM_ACTION); + intent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intent, FMRX_PERM); + } + + } + + public void fmRxCmdGetRdsSystem(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetRdsSystem "); + Log.d(TAG, " fmRxCmdGetRdsSystem ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + getRdsSystemValue = (int) value; + + /* implementation to make the FM API Synchronous */ + try { + mRdsSystemSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetRdsSystem ( getRdsSystemValue: )" + + getRdsSystemValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_RDS_SYSTEM_ACTION"); + + Intent getRdsSystem = new Intent( + FmRadioIntent.GET_RDS_SYSTEM_ACTION); + getRdsSystem.putExtra(FmRadioIntent.GET_RDS_SYSTEM, value); + getRdsSystem.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getRdsSystem, FMRX_PERM); + } + + } + + public void fmRxCmdDisableRds(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdDisableRds "); + Log.d(TAG, " fmRxCmdDisableRds ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /* implementation to make the FM API Synchronous */ + + try { + mDisableRdsSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + } else { + // Code for non blocking call + + Log.d(TAG, "StubFmService:sending intent DISABLE_RDS_ACTION"); + Intent intent = new Intent(FmRadioIntent.DISABLE_RDS_ACTION); + intent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intent, FMRX_PERM); + } + + } + + public void fmRxCmdEnableRds(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdEnableRds "); + Log.d(TAG, " fmRxCmdEnableRds ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /*implementation to make the set API Synchronous */ + + try { + mEnableRdsSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent ENABLE_RDS_ACTION"); + Intent intentRdsOn = new Intent(FmRadioIntent.ENABLE_RDS_ACTION); + intentRdsOn.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentRdsOn, FMRX_PERM); + } + + } + + public void fmRxCmdGetRdsGroupMask(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetRdsGroupMask "); + Log.d(TAG, " fmRxCmdGetRdsGroupMask ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + getRdsGroupMaskValue = value; + + /* implementation to make the FM API Synchronous */ + try { + mRdsGroupMaskSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetRdsGroupMask ( getRdsGroupMaskValue: )" + + getRdsGroupMaskValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_RDS_GROUPMASK_ACTION"); + + Intent getRdsGroup = new Intent( + FmRadioIntent.GET_RDS_GROUPMASK_ACTION); + getRdsGroup.putExtra(FmRadioIntent.GET_RDS_GROUPMASK, value); + getRdsGroup.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getRdsGroup, FMRX_PERM); + } + + } + + public void fmRxCmdSetRdsGroupMask(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetRdsGroupMask "); + Log.d(TAG, " fmRxCmdSetRdsGroupMask ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /* implementation to make the FM API Synchronous */ + try { + mSetRdsGroupMaskSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + } + else + { + Intent intent = new Intent(FmRadioIntent.SET_RDS_GROUP_MASK_ACTION); + intent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intent, FMRX_PERM); + } + + } + + public void fmRxCmdGetRssi(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetRssi "); + Log.d(TAG, " fmRxCmdGetRssi ( command: , status: , value: )" + command + + "" + status + "" + value); + // The RSSI value is 8 bit signed number in 2's complement format + + getRssiValue = convertUnsignedToSignedInt(value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + /*implementation to make the FM API Synchronous */ + try { + mRssiSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetRssi ( getRssiValue: )" + getRssiValue); + } + else + { + Log.d(TAG, "StubFmService:sending intent GET_RSSI_ACTION"); + Intent intent = new Intent(FmRadioIntent.GET_RSSI_ACTION); + intent.putExtra(FmRadioIntent.GET_RSSI, getRssiValue); + intent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intent, FMRX_PERM); + } + } + + public void fmRxCmdStopSeek(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdStopSeek "); + Log.d(TAG, " fmRxCmdStopSeek ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + try { + mStopSeekSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + }else + { + Log.d(TAG, "StubFmService:sending intent SEEK_STOP_ACTION"); + Intent intentstop = new Intent(FmRadioIntent.SEEK_STOP_ACTION); + intentstop.putExtra(FmRadioIntent.SEEK_FREQUENCY, value); + intentstop.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentstop, FMRX_PERM); + } + } + + public void fmRxCmdSeek(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSeek "); + Log.d(TAG, " fmRxCmdSeek ( command: , status: , value: )" + command + + "" + status + "" + value); + Log.d(TAG, "StubFmService:sending intent SEEK_ACTION"); + mIsSeekInProgress = false; + mCurrentFrequency = (int) value; + + Log.d(TAG, "StubFmService:sending intent SEEK_ACTION"); + Intent intentstart = new Intent(FmRadioIntent.SEEK_ACTION); + intentstart.putExtra(FmRadioIntent.SEEK_FREQUENCY, mCurrentFrequency); + intentstart.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentstart, FMRX_PERM); + } + + public void fmRxCmdGetTunedFrequency(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetTunedFrequency "); + Log.d(TAG, " fmRxCmdGetTunedFrequency ( command: , status: , value: )" + + command + "" + status + "" + value); + getTunedFrequencyValue = (int) value; + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + getTunedFrequencyValue = (int) value; + + /* implementation to make the FM API Synchronous */ + + try { + mTunedFrequencySyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetTunedFrequency ( getTunedFrequencyValue: )" + + getTunedFrequencyValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_FREQUENCY_ACTION"); + Intent freqIntent = new Intent( + FmRadioIntent.GET_FREQUENCY_ACTION); + freqIntent.putExtra(FmRadioIntent.TUNED_FREQUENCY, getTunedFrequencyValue); + freqIntent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(freqIntent, FMRX_PERM); + } + } + + public void fmRxCmdTune(JFmRx context, JFmRxStatus status, int command, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdTune "); + Log.d(TAG, " fmRxCmdTune ( command: , status: , value: )" + command + + "" + status + "" + value); + mIsTuneInProgress = false; + mCurrentFrequency = (int) value; + Log.d(TAG, "StubFmService:sending intent TUNE_COMPLETE_ACTION"); + /* Now FM resume has been completed.Set it to default. */ + if (mFmPauseResume ==STATE_RESUME) { + +// mFmPauseResume =STATE_DEFAULT; + } else { + Intent intentTune = new Intent( + FmRadioIntent.TUNE_COMPLETE_ACTION); + intentTune.putExtra(FmRadioIntent.TUNED_FREQUENCY, mCurrentFrequency); + intentTune.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTune, FMRX_PERM); + } + + } + + public void fmRxCmdGetVolume(JFmRx context, JFmRxStatus status, + int command, long value) { + Log.i(TAG, "StubFmService:fmRxCmdGetVolume "); + Log.d(TAG, " fmRxCmdGetVolume ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + getVolumeValue = (int) value; + + /*implementation to make the FM API Synchronous */ + try { + mVolumeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetVolume ( getVolumeValue: )" + + getVolumeValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_VOLUME_ACTION"); + Intent getVolume = new Intent(FmRadioIntent.GET_VOLUME_ACTION); + getVolume.putExtra(FmRadioIntent.GET_VOLUME, value); + getVolume.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getVolume, FMRX_PERM); + + } + } + + public void fmRxCmdSetVolume(JFmRx context, JFmRxStatus status, + int command, long value) { + + /* + * volume change will be completed here. So set the state to idle, so + * that user can set other volume. + */ + synchronized (mVolumeSynchronizationLock) { + mVolState = VOL_REQ_STATE_IDLE; + } + + Log.d(TAG, "StubFmService:fmRxCmdDone JFmRxCommand.CMD_SET_VOLUME"); + Log.d(TAG, " fmRxCmdSetVolume ( command: , status: , value: )" + + command + "" + status + "" + value); + Log.d(TAG, "StubFmService:sending intent VOLUME_CHANGED_ACTION"); + /* If the FM is resumed, then load the current band. */ + if (mFmPauseResume ==STATE_RESUME) { + Log.d(TAG, "StubFmService:FM resuming . Dont do anything"); + } + /* + * If the FM is enabled, then send the intent to App to load the band.. + */ + else { + Intent intentVolume = new Intent( + FmRadioIntent.VOLUME_CHANGED_ACTION); + intentVolume.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentVolume, FMRX_PERM); + } + + } + + public void fmRxCmdGetDeemphasisFilter(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetDeemphasisFilter "); + Log.d(TAG, + " fmRxCmdGetDeemphasisFilter ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + getDeEmphasisFilterValue = (int) value; + + /*implementation to make the FM API Synchronous */ + + try { + mDeEmphasisFilterSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, + " fmRxCmdGetDeemphasisFilter ( getDeEmphasisFilterValue: )" + + getDeEmphasisFilterValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_DEEMPHASIS_FILTER_ACTION"); + Intent getDeEmpFilter = new Intent( + FmRadioIntent.GET_DEEMPHASIS_FILTER_ACTION); + getDeEmpFilter.putExtra(FmRadioIntent.GET_DEEMPHASIS_FILTER, value); + getDeEmpFilter.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getDeEmpFilter, FMRX_PERM); + + } + } + + public void fmRxCmdSetDeemphasisFilter(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetDeemphasisFilter "); + Log.d(TAG, + " fmRxCmdSetDeemphasisFilter ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /*implementation to make the set API Synchronous */ + try { + mSetDeEmphasisFilterSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent SET_DEEMP_FILTER_ACTION"); + Intent intent = new Intent(FmRadioIntent.SET_DEEMP_FILTER_ACTION); + intent.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intent, FMRX_PERM); + } + + } + + public void fmRxCmdGetRssiThreshhold(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetRssiThreshhold "); + Log.d(TAG, " fmRxCmdGetRssiThreshhold ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + getRssiThresholdValue = (int) value; + + /*implementation to make the FM API Synchronous */ + try { + mRssiThresholdSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetRssiThreshhold ( getRssiThresholdValue: )" + + getRssiThresholdValue); + + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_RSSI_THRESHHOLD_ACTION"); + Intent getRssiThreshHold = new Intent( + FmRadioIntent.GET_RSSI_THRESHHOLD_ACTION); + getRssiThreshHold.putExtra(FmRadioIntent.GET_RSSI_THRESHHOLD, + value); + getRssiThreshHold.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getRssiThreshHold, FMRX_PERM); + } + } + + public void fmRxCmdSetRssiThreshhold(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetRssiThreshhold "); + Log.d(TAG, " fmRxCmdSetRssiThreshhold ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /* implementation to make the FM API Synchronous */ + + try { + mSetRssiThresholdSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent SET_RSSI_THRESHHOLD_ACTION"); + Intent intentRssi = new Intent( + FmRadioIntent.SET_RSSI_THRESHHOLD_ACTION); + intentRssi.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentRssi, FMRX_PERM); + } + + } + + public void fmRxCmdGetRfDependentMuteMode(JFmRx context, + JFmRxStatus status, int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetRfDependentMuteMode "); + Log.d(TAG, + " fmRxCmdGetRfDependentMuteMode ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + getRfDependentMuteModeValue = (int) value; + + /*implementation to make the FM API Synchronous */ + + try { + mRfDependentMuteModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, + " fmRxCmdGetRfDependentMuteMode ( getRfDependentMuteModeValue: )" + + getRfDependentMuteModeValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_RF_MUTE_MODE_ACTION"); + + Intent getRfMuteMode = new Intent( + FmRadioIntent.GET_RF_MUTE_MODE_ACTION); + getRfMuteMode.putExtra(FmRadioIntent.GET_RF_MUTE_MODE, value); + getRfMuteMode.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getRfMuteMode, FMRX_PERM); + + } + } + + public void fmRxCmdSetRfDependentMuteMode(JFmRx context, + JFmRxStatus status, int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetRfDependentMuteMode "); + Log.d(TAG, + " fmRxCmdSetRfDependentMuteMode ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /*implementation to make the set API Synchronous */ + + try { + mSetRfDependentMuteModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + } else { + // Code for non blocking call + Log.d(TAG, + "StubFmService:sending intent SET_RF_DEPENDENT_MUTE_ACTION"); + Intent intentRfMute = new Intent( + FmRadioIntent.SET_RF_DEPENDENT_MUTE_ACTION); + intentRfMute.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentRfMute, FMRX_PERM); + } + + } + + public void fmRxCmdSetMuteMode(JFmRx context, JFmRxStatus status, + int command, long value) { + Log.i(TAG, "StubFmService:fmRxCmdSetMuteMode "); + Log.d(TAG, " fmRxCmdSetMuteMode ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + /* implementation to make the FM API Synchronous */ + + try { + mSetMuteModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + } else { + // Code for non blocking call + + if(mIsFmMuted == false) + { + Log.d(TAG, "StubFmService:sending intent MUTE_CHANGE_ACTION"); + Intent intentMute = new Intent(FmRadioIntent.MUTE_CHANGE_ACTION); + intentMute.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentMute, FMRX_PERM); + } + } + + } + + public void fmRxCmdGetMuteMode(JFmRx context, JFmRxStatus status, + int command, long value) { + Log.i(TAG, "StubFmService:fmRxCmdGetMuteMode "); + Log.d(TAG, " fmRxCmdGetMuteMode ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + getMuteModeValue = (int) value; + + /* implementation to make the FM API Synchronous */ + try { + mMuteModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, " fmRxCmdGetMuteMode ( getMuteModeValue: )" + + getMuteModeValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_MUTE_MODE_ACTION"); + + Intent getMuteMode = new Intent( + FmRadioIntent.GET_MUTE_MODE_ACTION); + getMuteMode.putExtra(FmRadioIntent.GET_MUTE_MODE, value); + getMuteMode.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getMuteMode, FMRX_PERM); + + } + } + + public void fmRxCmdGetMonoStereoMode(JFmRx context, JFmRxStatus status, + int command, long value) { + Log.i(TAG, "StubFmService:fmRxCmdGetMonoStereoMode "); + Log.d(TAG, " fmRxCmdGetMonoStereoMode ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + getMonoStereoModeValue = (int) value; + + /* implementation to make the FM API Synchronous */ + + try { + mMonoStereoModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, " fmRxCmdGetMonoStereoMode ( getMonoStereoModeValue: )" + + getMonoStereoModeValue); + + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_MONO_STEREO_MODE_ACTION"); + Intent getMode = new Intent( + FmRadioIntent.GET_MONO_STEREO_MODE_ACTION); + getMode.putExtra(FmRadioIntent.GET_MODE, value); + getMode.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getMode, FMRX_PERM); + } + } + + public void fmRxCmdSetMonoStereoMode(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetMonoStereoMode "); + Log.d(TAG, " fmRxCmdSetMonoStereoMode ( command: , status: , value: )" + + command + "" + status + "" + value); + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /* implementation to make the set API Synchronous */ + + try { + mSetMonoStereoModeSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + } else { + // Code for non blocking call + Log + .d(TAG, + "StubFmService:sending intent SET_MODE_MONO_STEREO_ACTION"); + Intent intentMode = new Intent( + FmRadioIntent.SET_MODE_MONO_STEREO_ACTION); + intentMode.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentMode, FMRX_PERM); + } + + } + + public void fmRxCmdGetBand(JFmRx context, JFmRxStatus status, int command, + long value) { + Log.i(TAG, "StubFmService:fmRxCmdGetBand "); + Log.d(TAG, " fmRxCmdGetBand ( command: , status: , value: )" + command + + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + + getBandValue = (int) value; + + /* implementation to make the FM API Synchronous */ + + try { + mBandSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + Log.d(TAG, " fmRxCmdGetBand ( getBandValue: )" + getBandValue); + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:sending intent GET_BAND_ACTION"); + Intent getBand = new Intent(FmRadioIntent.GET_BAND_ACTION); + getBand.putExtra(FmRadioIntent.GET_BAND, value); + getBand.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getBand, FMRX_PERM); + + } + } + + public void fmRxCmdSetBand(JFmRx context, JFmRxStatus status, int command, + long value) { + Log.i(TAG, "StubFmService:fmRxCmdSetBand "); + Log.d(TAG, " fmRxCmdSetBand ( command: , status: , value: )" + command + + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + /*implementation to make the Set API Synchronous */ + + try { + mSetBandSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + + } else { + // Code for non blocking call + Log.d(TAG, "StubFmService:FM resuming . mFmPauseResume" + + mFmPauseResume); + /* If the FM is resumed, then load the previously tuned frequency. */ + if (mFmPauseResume ==STATE_RESUME) { + Log.d(TAG, "StubFmService:FM resuming . Dont do anything"); + } + /* + * If the FM is enabled, then send the intent to App to load the + * freq.. + */ + else { + Log.d(TAG, "StubFmService:sending intent BAND_CHANGE_ACTION"); + Intent intentBand = new Intent(FmRadioIntent.BAND_CHANGE_ACTION); + intentBand.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentBand, FMRX_PERM); + } + + } + + } + + public void fmRxCmdChangeAudioTarget(JFmRx context, JFmRxStatus status, + int command, long AudioCmd) { + Log.i(TAG, "StubFmService:fmRxCmdChangeAudioTarget "); + Log.d(TAG, + " fmRxCmdChangeAudioTarget ( command: , status: , AudioCmd: )" + + command + "" + status + "" + AudioCmd); + } + + public void fmRxCmdEnableAudio(JFmRx context, JFmRxStatus status, + int command, long AudioCmd) { + Log.i(TAG, "StubFmService:fmRxCmdEnableAudio "); + Log.d(TAG, + " fmRxCmdEnableAudio ( command: , status: , AudioCmd: )" + + command + "" + status + "" + AudioCmd); + } + + public void fmRxCmdChangeDigitalAudioConfiguration(JFmRx context, + JFmRxStatus status, int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdChangeDigitalAudioConfiguration "); + Log.d(TAG, + " fmRxCmdChangeDigitalAudioConfiguration ( command: , status: , value: )" + + command + "" + status + "" + value); + } + + public void fmRxCmdGetChannelSpacing(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetChannelSpacing "); + Log.d(TAG, " fmRxCmdGetChannelSpacing ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + // Code for blocking call + getChannelSpaceValue = (int) value; + /* implementation to make the FM API Synchronous */ + + try { + mChannelSpacingSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, " fmRxCmdGetChannelSpacing ( getChannelSpaceValue: )" + + getChannelSpaceValue); + + } else { + // Code for non blocking call + + Log.d(TAG, "StubFmService:sending intent GET_CHANNEL_SPACE_ACTION"); + Intent getChSpace = new Intent( + FmRadioIntent.GET_CHANNEL_SPACE_ACTION); + getChSpace.putExtra(FmRadioIntent.GET_CHANNEL_SPACE, value); + getChSpace.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(getChSpace, FMRX_PERM); + + } + } + + public void fmRxCmdSetChannelSpacing(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdSetChannelSpacing "); + Log.d(TAG, " fmRxCmdSetChannelSpacing ( command: , status: , value: )" + + command + "" + status + "" + value); + + if (MAKE_FM_APIS_BLOCKING == true) { + /* implementation to make the FM API Synchronous */ + try { + mSetChannelSpacingSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + } + else + { + + Log.d(TAG, "StubFmService:sending intent CHANNEL_SPACING_CHANGED_ACTION"); + Intent intentChannelSpace = new Intent( + FmRadioIntent.CHANNEL_SPACING_CHANGED_ACTION); + intentChannelSpace.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentChannelSpace, FMRX_PERM); + } + } + + public void fmRxCmdIsValidChannel(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdIsValidChannel "); + Log.d(TAG, " fmRxCmdIsValidChannel ( command: , status: , value: )" + + command + "" + status + "" + value); + if (value > 0) + mIsValidChannel = true; + else + mIsValidChannel = false; + + /*implementation to make the FM API Synchronous */ + + try { + mValidChannelSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + + Log.d(TAG, " fmRxCmdIsValidChannel ( isValidChannel: )" + + mIsValidChannel); + + } + + public void fmRxCmdGetFwVersion(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetFwVersion "); + Log.d(TAG, " fmRxCmdGetFwVersion ( command: , status: , value: )" + + command + "" + status + "" + value); + + getFwVersion = ((double) value / 1000); + + /* implementation to make the FM API Synchronous */ + try { + mFwVersionSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdGetFwVersion ( getFwVersion: )" + getFwVersion); + + } + + public void fmRxCmdGetCompleteScanProgress(JFmRx context, + JFmRxStatus status, int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdGetCompleteScanProgress "); + Log.d(TAG, + " fmRxCmdGetCompleteScanProgress ( command: , status: , value: )" + + command + "" + status + "" + value); + + getScanProgress = (int) value; + + if (MAKE_FM_APIS_BLOCKING == true) { + + + /* implementation to make the FM API Synchronous */ + + try { + mCompleteScanProgressSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + + + Log.d(TAG, " fmRxCmdGetCompleteScanProgress ( getFwVersion: )" + + getScanProgress); + } + else + { + + Log.d(TAG, "StubFmService:sending intent COMPLETE_SCAN_PROGRESS_ACTION"); + Intent intent = new Intent( + FmRadioIntent.COMPLETE_SCAN_PROGRESS_ACTION); + intent.putExtra(FmRadioIntent.STATUS, status); + intent.putExtra(FmRadioIntent.SCAN_PROGRESS, getScanProgress); + mContext.sendBroadcast(intent, FMRX_PERM); + + } + + } + + public void fmRxCmdStopCompleteScan(JFmRx context, JFmRxStatus status, + int command, long value) { + + Log.i(TAG, "StubFmService:fmRxCmdStopCompleteScan "); + Log.d(TAG, " fmRxCmdStopCompleteScan ( command: , status: , value: )" + + command + "" + status + "" + value); + mIsCompleteScanInProgress = false; + + if (MAKE_FM_APIS_BLOCKING == true) { + + mStopCompleteScanStatus = status.getValue(); + + /* implementation to make the FM API Synchronous */ + + try { + mStopCompleteScanSyncQueue.put("*"); + } catch (InterruptedException e) { + Log.e(TAG, "InterruptedException on queue wakeup!"); + } + ; + Log.d(TAG, " fmRxCmdStopCompleteScan ( mStopCompleteScanStatus: )" + + mStopCompleteScanStatus); + } + else + { + + Log.d(TAG, "StubFmService:sending intent COMPLETE_SCAN_STOP_ACTION "); + + Intent intentStopScan = new Intent( + FmRadioIntent.COMPLETE_SCAN_STOP_ACTION); + + Bundle b = new Bundle(); + b.putInt(FmRadioIntent.STATUS, status.getValue()); + b.putInt(FmRadioIntent.LAST_SCAN_CHANNEL, (int)value); + intentStopScan.putExtras(b); + mContext.sendBroadcast(intentStopScan, FMRX_PERM); + } + + } + + + + + + +/***** FM TX ******/ + + public void fmTxCmdEnable(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdEnable "); + Log.d(TAG, " fmTxCmdEnable ( status: " + status + " )"); + + Intent intentTxEnable = new Intent(FmRadioIntent.FM_TX_ENABLED_ACTION); + intentTxEnable.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxEnable, FMRX_PERM); + mTxState = STATE_ENABLED; + + + sendNotificationTX(); + /* Ne need to call again, let it take from default */ + + //if(status ==JFmTxStatus.SUCCESS ) + // { + // /*Enable the Audio deafult platfrom values */ + // JFmTx.JFmTxEcalResource fmTxDeafultSourceConfig = + // JFmUtils.getEnumConst( JFmTx.JFmTxEcalResource.class,fmTxDeafultCalResource); + + // JFmTx.JFmTxEcalSampleFrequency fmTxDeafultFreqConfig = JFmUtils.getEnumConst( + // JFmTx.JFmTxEcalSampleFrequency.class,fmTxDeafultSampleFrequency); + + // mJFmTx.txChangeAudioSource(fmTxDeafultSourceConfig,fmTxDeafultFreqConfig); + /* Notify to APM */ + + // } + } + + public void fmTxCmdDisable(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdDisable "); + Log.d(TAG, " fmTxCmdDisable ( status: " + status + " )"); + /* Notify to APM */ + + if (isTransmissionOn()) { + Log.i(TAG, "StubFmService:Sending ACTION_FMTx_PLUG "); + enableTx(0); + Log.i(TAG, "StubFmService:Sent! ACTION_FMTx_PLUG "); + } + + mIsFmTxOn = false; + + cancelNotification(FM_TX_NOTIFICATION_ID); + + destroyJFmTx(); + + Intent intentTxDisable = new Intent(FmRadioIntent.FM_TX_DISABLED_ACTION); + intentTxDisable.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxDisable, FMRX_PERM); + mTxState = STATE_DISABLED; + + } + + + public void fmTxCmdDestroy(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdDestroy "); + Log.d(TAG, " fmRxCmdDestroy (status: " + status + " )"); + + Intent intentTxDestroy = new Intent(FmRadioIntent.FM_TX_DESTROY_ACTION); + intentTxDestroy.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxDestroy, FMRX_PERM); + + } + + public void fmTxCmdStartTransmission(JFmTx context, JFmTxStatus status/*, + JFmCcmVacUnavailResourceList ccmVacUnavailResourceList*/) { + + Log.i(TAG, "StubFmService:fmTxCmdStartTransmission "); + Log.d(TAG, " fmTxCmdStartTransmission (status: " + status + " )"); + Intent intentStartTransmission = new Intent(FmRadioIntent.FM_TX_START_TRANSMISSION_ACTION); + intentStartTransmission.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentStartTransmission, FMRX_PERM); + + if(status ==JFmTxStatus.SUCCESS ) { + //mAudioManager.setParameters(AUDIO_TX_ENABLE+"=true"); + Log.i(TAG, "StubFmService:Sending ACTION_FMTx_PLUG "); + enableTx(1); + Log.i(TAG, "StubFmService:Sent! ACTION_FMTx_PLUG "); + } + + } + + + public void fmTxCmdStopTransmission(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdStopTransmission "); + Log.d(TAG, " fmTxCmdStopTransmission ( status: " + status + " )"); + + Intent intentStopTransmission = new Intent(FmRadioIntent.FM_TX_STOP_TRANSMISSION_ACTION); + intentStopTransmission.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentStopTransmission, FMRX_PERM); + + if(status ==JFmTxStatus.SUCCESS ) { + //mAudioManager.setParameters(AUDIO_TX_ENABLE+"=false"); + Log.i(TAG, "StubFmService:Sending ACTION_FMTx_PLUG "); + enableTx(0); + Log.i(TAG, "StubFmService:Sent! ACTION_FMTx_PLUG "); + } + + } + + public void fmTxCmdSetPowerLevel(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetPowerLevel "); + Log.d(TAG, " fmTxCmdSetPowerLevel ( status: " + status + " )"); + } + + + + public void fmTxCmdEnableRds(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdEnableRds "); + Log.d(TAG, " fmTxCmdEnableRds ( status: " + status + " )"); + + + Intent intentTxEnableRds = new Intent(FmRadioIntent.FM_TX_ENABLE_RSD_ACTION); + intentTxEnableRds.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxEnableRds, FMRX_PERM); + + } + + + public void fmTxCmdDisableRds(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdDisableRds "); + Log.d(TAG, " fmTxCmdDisableRds (status: " + status + " )"); + + Intent intentTxDisableRds = new Intent(FmRadioIntent.FM_TX_DISABLE_RSD_ACTION); + intentTxDisableRds.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxDisableRds, FMRX_PERM); + + } + + public void fmTxCmdTune(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmRxCmdTune "); + Log.d(TAG, " fmRxCmdTune (status: " + status + " )"); + + Intent intentTxTune = new Intent( + FmRadioIntent.FM_TX_TUNE_ACTION); + intentTxTune.putExtra(FmRadioIntent.TUNED_FREQUENCY, value); + intentTxTune.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentTxTune, FMRX_PERM); + + } + + + public void fmTxCmdGetTunedFrequency(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetTunedFrequency "); + Log.d(TAG, " fmTxCmdGetTunedFrequency ( status: " + status + " )"); + + } + + + + public void fmTxCmdSetRdsTransmissionMode(JFmTx context,JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsTransmissionMode "); + Log.d(TAG, " fmTxCmdSetRdsTransmissionMode ( status: " + status + " )"); + + + Intent txMode = new Intent( + FmRadioIntent.FM_TX_SET_TRANSMISSION_MODE_ACTION); + txMode.putExtra(FmRadioIntent.TX_MODE, value); + txMode.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(txMode, FMRX_PERM); + + + } + + + public void fmTxCmdGetRdsTransmissionMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTransmissionMode "); + Log.d(TAG, " fmTxCmdGetRdsTransmissionMode ( status: " + status + " ) value: " + value + ")"); + + } + + + public void fmTxCmdSetMonoStereoMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetMonoStereoMode "); + Log.d(TAG, " fmTxCmdSetMonoStereoMode ( status: " + status + " )"); + + Intent txModeMonoStereo = new Intent( + FmRadioIntent.FM_TX_SET_MONO_STEREO_MODE_ACTION); + txModeMonoStereo.putExtra(FmRadioIntent.MODE_MONO_STEREO, value); + txModeMonoStereo.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(txModeMonoStereo, FMRX_PERM); + + + } + + public void fmTxCmdGetMonoStereoMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetMonoStereoMode "); + Log.d(TAG, " fmTxCmdGetMonoStereoMode ( status: " + status + " ) value: " + value + ")"); + } + + public void fmTxCmdSetPreEmphasisFilter(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetPreEmphasisFilter "); + Log.d(TAG, " fmTxCmdSetPreEmphasisFilter ( status: " + status + " )"); + + Log.i(TAG, "StubFmService:Calling txGetPreEmphasisFilter().. "); + + } + + public void fmTxCmdGetPreEmphasisFilter(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetPreEmphasisFilter "); + Log.d(TAG, " fmTxCmdGetPreEmphasisFilter ( status: " + status + " ) value: " + value + ")"); + } + + + public void fmTxCmdSetMuteMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetMuteMode "); + Log.d(TAG, " fmTxCmdSetMuteMode ( status: " + status + " )"); + Intent intentMute = new Intent(FmRadioIntent.FM_TX_SET_MUTE_MODE_ACTION); + intentMute.putExtra(FmRadioIntent.TX_REPERTOIRE, value); + intentMute.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentMute, FMRX_PERM); + + } + + + public void fmTxCmdGetMuteMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetMuteMode "); + Log.d(TAG, " fmTxCmdGetMuteMode ( status: " + status + " ) value: " + value + ")"); + + } + + + + public void fmTxCmdSetRdsAfCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsAfCode "); + Log.d(TAG, " fmTxCmdSetRdsAfCode ( status: " + status + " )"); + } + + + public void fmTxCmdGetRdsAfCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsAfCode "); + Log.d(TAG, " fmTxCmdGetRdsAfCode ( status: " + status + " ) value: " + value + ")"); + + } + + + + public void fmTxCmdSetRdsPiCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsPiCode "); + Log.d(TAG, " fmTxCmdSetRdsPiCode (status: " + status + " )"); + + } + + + + public void fmTxCmdGetRdsPiCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsPiCode "); + Log.d(TAG, " fmTxCmdGetRdsPiCode ( status: " + status + " ) value: " + value + ")"); + + } + + + + + public void fmTxCmdSetRdsPtyCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsPtyCode "); + Log.d(TAG, " fmTxCmdSetRdsPtyCode ( status: " + status + " )"); + + } + + + public void fmTxCmdGetRdsPtyCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsPtyCode "); + Log.d(TAG, " fmTxCmdGetRdsPtyCode ( status: " + status + " ) value: " + value + ")"); + + } + + + + public void fmTxCmdSetRdsTextRepertoire(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsTextRepertoire "); + Log.d(TAG, " fmTxCmdSetRdsTextRepertoire ( status: " + status + " )"); + Intent intentRepertoire = new Intent(FmRadioIntent. FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION); + intentRepertoire.putExtra(FmRadioIntent.TX_REPERTOIRE, value); + intentRepertoire.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentRepertoire, FMRX_PERM); + + } + + + public void fmTxCmdGetRdsTextRepertoire(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTextRepertoire "); + Log.d(TAG, " fmTxCmdGetRdsTextRepertoire ( status: " + status + " ) value: " + value + ")"); + + } + + + public void fmTxCmdSetRdsPsDisplayMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsDisplayMode "); + Log.d(TAG, " fmTxCmdSetRdsPsDisplayMode ( status: " + status + " )"); + Intent intentRdsPsDisplayMode = new Intent( + FmRadioIntent.FM_TX_PS_DISPLAY_MODE_ACTION); + intentRdsPsDisplayMode.putExtra(FmRadioIntent.DISPLAY_MODE, value); + intentRdsPsDisplayMode.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentRdsPsDisplayMode, FMRX_PERM); + + } + + + + public void fmTxCmdGetRdsPsDisplayMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsDisplayMode "); + Log.d(TAG, " fmTxCmdGetRdsPsDisplayMode ( status: " + status + " ) value: " + value + ")"); + + } + + + public void fmTxCmdSetRdsPsScrollSpeed(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsScrollSpeed "); + Log.d(TAG, " fmTxCmdSetRdsPsScrollSpeed ( status: " + status + " )"); + + } + + + public void fmTxCmdGetRdsPsScrollSpeed(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsScrollSpeed "); + Log.d(TAG, " fmTxCmdGetRdsPsScrollSpeed ( status: " + status + " ) value: " + value + ")"); + + } + + + + public void fmTxCmdSetRdsTextRtMsg(JFmTx context, JFmTxStatus status, + int msgType,int msgLen,byte[]msg) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsTextRtMsg "); + Log.d(TAG, " fmTxCmdSetRdsTextRtMsg ( status: " + status + " )"); + } + + + + public void fmTxCmdGetRdsTextRtMsg(JFmTx context, JFmTxStatus status, + int msgType,int msgLen,byte[]msg) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTextRtMsg "); + Log.d(TAG, " fmTxCmdgetRdsTextRtMsg ( status: " + status + "msgType: " + msgType + + "msgLen: " + msgLen + ")"); + } + + + + public void fmTxCmdSetRdsTextPsMsg(JFmTx context, JFmTxStatus status, + int msgLen,byte[] msg) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsTextPsMsg "); + Log.d(TAG, " fmTxCmdSetRdsTextPsMsg ( status: " + status + " )"); + Intent intentPsMsg = new Intent( + FmRadioIntent.FM_TX_SET_RDS_TEXT_PS_MSG_ACTION); + + String psString = new String(msg); + intentPsMsg.putExtra(FmRadioIntent.PS_MSG, psString); + intentPsMsg.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentPsMsg, FMRX_PERM); + + } + + + + public void fmTxCmdGetRdsTextPsMsg(JFmTx context, JFmTxStatus status, + int msgLen,byte[] msg) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTextPsMsg "); + Log.d(TAG, " fmTxCmdGetRdsTextPsMsg ( status: " + status + + "msgLen: " + msgLen + ")"); + } + + + +/* + public void fmTxCmdGetRdsTransmittedGroupsMask(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTransmittedGroupsMask "); + Log.d(TAG, " fmTxCmdGetRdsTransmittedGroupsMask ( status: " + status + " ) value: " + value + ")"); + + + } +*/ + + public void fmTxCmdSetRdsTrafficCodes(JFmTx context, JFmTxStatus status, + int tacode,int tpCode) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsTrafficCodes "); + Log.d(TAG, " fmTxCmdSetRdsTrafficCodes ( status: " + status + " )"); + + } + + + public void fmTxCmdGetRdsTrafficCodes(JFmTx context, JFmTxStatus status, + int tacode,int tpCode) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTrafficCodes "); + Log.d(TAG, " fmTxCmdGetRdsTrafficCodes ( status: " + status + " ) tpCode: " +tpCode+ " tacode: " + tacode ); + } + + + public void fmTxCmdSetRdsMusicSpeechFlag(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsMusicSpeechFlag "); + Log.d(TAG, " fmTxCmdSetRdsMusicSpeechFlag ( status: " + status + " )"); + + + Intent intentMusicSpeechFlag = new Intent( + FmRadioIntent.FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION); + intentMusicSpeechFlag.putExtra(FmRadioIntent.MUSIC_SPEECH_FLAG, value); + intentMusicSpeechFlag.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentMusicSpeechFlag, FMRX_PERM); + + } + + + + public void fmTxCmdGetRdsMusicSpeechFlag(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsMusicSpeechFlag "); + Log.d(TAG, " fmTxCmdGetRdsMusicSpeechFlag ( status: " + status + " ) value: " + value + ")"); + + } + + + + + public void fmTxCmdChangeAudioSource(JFmTx context, JFmTxStatus status, + JFmCcmVacUnavailResourceList ccmVacUnavailResourceList) { + + Log.i(TAG, "StubFmService:fmTxCmdChangeAudioSource "); + Log.d(TAG, " fmTxCmdChangeAudioSource ( status: " + status + " )"); + } + /* + public void fmTxCmdChangeDigitalAudioConfiguration(JFmTx context, JFmTxStatus status, + JFmCcmVacUnavailResourceList ccmVacUnavailResourceList) { + + Log.i(TAG, "StubFmService:fmTxCmdChangeDigitalAudioConfiguration "); + Log.d(TAG, " fmTxCmdChangeDigitalAudioConfiguration ( command: , status: )" + command + ); + } +*/ + + + + public void fmTxCmdSetInterruptMask(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetInterruptMask "); + Log.d(TAG, " fmTxCmdSetInterruptMask ( status: " + status + " )"); + } + + + public void fmTxCmdGetInterruptMask(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetInterruptMask "); + Log.d(TAG, " fmTxCmdGetInterruptMask ( status: " + status + " ) value: " + value + ")"); + } + + + public void fmTxCmdSetRdsPsDisplaySpeed(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsDisplaySpeed "); + Log.d(TAG, " fmTxCmdSetRdsPsDisplaySpeed ( status: " + status + " )"); + + } + + + + public void fmTxCmdGetRdsPsDisplaySpeed(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsDisplaySpeed "); + Log.d(TAG, " fmTxCmdGetRdsPsDisplaySpeed ( status: " + status + " ) value: " + value + ")"); + } + + + public void fmTxCmdReadRdsRawData(JFmTx context, JFmTxStatus status, + int len,byte[] msg) { + + Log.i(TAG, "StubFmService:fmTxCmdReadRdsRawData "); + Log.d(TAG, " fmTxCmdReadRdsRawData ( status: " + status + " ) len: " + len + ")"); + } + + + + + public void fmTxCmdSetRdsTransmittedMask(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsTransmittedMask "); + Log.d(TAG, " fmTxCmdSetRdsTransmittedMask ( status: " + status + " ) value: " + value + ")"); + + + Intent intentRdsTxGrpMask = new Intent( + FmRadioIntent.FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION); + + intentRdsTxGrpMask.putExtra(FmRadioIntent.RDS_GRP_MASK, value); + intentRdsTxGrpMask.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentRdsTxGrpMask, FMRX_PERM); + + + } + + + + public void fmTxCmdGetRdsTransmittedMask(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsTransmittedMask "); + Log.d(TAG, " fmTxCmdGetRdsTransmittedMask ( status: " + status + " )"); + } + + + + public void fmTxCmdChangeDigitalAudioConfiguration(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdChangeDigitalAudioConfiguration "); + Log.d(TAG, " fmTxCmdChangeDigitalAudioConfiguration ( status: " + status + " )"); + } + + + + public void fmTxCmdSetRdsExtendedCountryCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsExtendedCountryCode "); + Log.d(TAG, " fmTxCmdSetRdsExtendedCountryCode ( status: " + status + " )"); + + } + + + + public void fmTxCmdGetRdsExtendedCountryCode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsExtendedCountryCode "); + Log.d(TAG, " fmTxCmdGetRdsExtendedCountryCode ( status: " + status + " ) value: " + value + ")"); + } + + + public void fmTxCmdWriteRdsRawData(JFmTx context, JFmTxStatus status, + int len, byte[] msg) { + + Log.i(TAG, "StubFmService:fmTxCmdWriteRdsRawData "); + Log.d(TAG, " fmTxCmdWriteRdsRawData ( status: " + status + " )"); + } + + + + public void fmTxCmdSetRdsPsDispalyMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsDispalyMode "); + Log.d(TAG, " fmTxCmdSetRdsPsDispalyMode ( status: " + status + " )"); + } + + + + public void fmTxCmdGetRdsPsDispalyMode(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsDispalyMode "); + Log.d(TAG, " fmTxCmdGetRdsPsDispalyMode ( status: " + status + " ) value: " + value + ")"); + } + + + public void fmTxCmdGetPowerLevel(JFmTx context, JFmTxStatus status, + long value) { + + Log.i(TAG, "StubFmService:fmTxCmdGetPowerLevel "); + Log.d(TAG, " fmTxCmdGetPowerLevel ( status: " + status + " ) value: " + value + ")"); + } + + /*Play Mp3 file*/ + private void musicPlay(Context context) + { + MediaPlayer mp = MediaPlayer.create(context, + R.raw.ding); + mp.start(); + // react on the end of the music-file: + mp.setOnCompletionListener(new OnCompletionListener(){ + + public void onCompletion(MediaPlayer mp) { + // File has ended !!! + cleanupPlayer(mp); + } + }); + } + + + private void cleanupPlayer(MediaPlayer mp) { + if (mp != null) { + try { + mp.stop(); + mp.release(); + } catch (IllegalStateException ex) { + Log.w(TAG, "MediaPlayer IllegalStateException: "+ex); + } + } + } + + /* Broadcast receiver for the HEDASET_PLUG broadcast intent.*/ + private final BroadcastReceiver mHeadsetPlugReceiver = new BroadcastReceiver() { + + public void onReceive(Context context, Intent intent) { + + Log.i(TAG, " mHeadsetPlugReceiver--->onReceive"); + int state = intent.getIntExtra("state", 0); + if (mRxState == STATE_ENABLED ){ + int on =1; + if (state == 1) { + Log.i(TAG, " mHeadsetPlugReceiver--->Headset plugged"); + /* L25 Specific */ + /* HEADSET IS OR HAS BEEN CONNECTED */ + /*Play a ding mp3 file to force the new routing to take effect, + as FM analog playback is not associated with any PCM stream to trigger + the routing change based on headset detection*/ + //musicPlay(context); + } else { + Log.i(TAG, " mHeadsetPlugReceiver--->Headset unplugged"); + } + /* L27 Specific */ + + enableRx(on-1); + enableRx(on); + } + + } + }; + + + /* Broadcast receiver for the ACTION_MEDIA_BUTTON broadcast intent.*/ + + private class MediaButtonBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + Log.i(TAG, " MediaButtonBroadcastReceiver--->onReceive"); + String intentAction = intent.getAction(); + if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) + { + KeyEvent event = (KeyEvent) + intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); + + if (event == null) { + return; + } + + int keycode = event.getKeyCode(); + int action = event.getAction(); + + boolean volState; + + synchronized (mVolumeSynchronizationLock) { + volState = mVolState; + } + + int mVolume = mAudioManager + .getStreamVolume(AudioManager.STREAM_MUSIC); + // Convert the stream volume to the FM specific volume. + mVolume = (mVolume * FM_MAX_VOLUME)/ (mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)); + Log.i(TAG, " Audio Manager mVolume " + mVolume); + + switch (keycode) { + case KeyEvent.KEYCODE_VOLUME_UP: + mVolume ++; + break; + + case KeyEvent.KEYCODE_VOLUME_DOWN: + mVolume --; + break; + } + + if (action == KeyEvent.ACTION_DOWN) { + if (mVolState) { + + if (!rxSetVolume(mVolume)) { + Log.i(TAG, "Not able, to set volume "); + } + Log.i(TAG, "send intent for UI updation "); + /* Send Intent to App for UI updation */ + Intent intentMasterVolume = new Intent( + FmRadioIntent.MASTER_VOLUME_CHANGED_ACTION); + intentMasterVolume.putExtra(FmRadioIntent.MASTER_VOLUME,mVolume); + mContext.sendBroadcast(intentMasterVolume, FMRX_PERM); + + } // mVolState + else { + Log.i(TAG, "previous volume set not complete "); + } + } + + if (isOrderedBroadcast()) { + abortBroadcast(); + } + + } + + } + + } + + + private class SmsBroadcastReceiver extends BroadcastReceiver { + public void onReceive(Context context, Intent intent) { + Log.i(TAG, " SmsBroadcastReceiver--->onReceive"); + rxSetMuteMode(FM_MUTE); + + } + } + + + // Receiver of the Intent Broadcasted by AudioService + private final BroadcastReceiver mFmRxIntentReceiver = new BroadcastReceiver() { + + public void onReceive(Context context, Intent intent) { + + String fmRxAction = intent.getAction(); + boolean setVolume = false; + Log.d(TAG, " mFmRxIntentReceiver--->fmRxAction" + fmRxAction); + int volType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, AudioManager.STREAM_MUSIC); + + + + + /* + * Intent received when the volume has been changed from the master + * volume control keys. Convert it to the FM specific volume and set + * the volume. + */ + if (fmRxAction.equals(AudioManager.VOLUME_CHANGED_ACTION)) { + Log.i(TAG, " AUDIOMANGER_VOLUME_CHANGED_ACTION "); + if ((mRxState == STATE_ENABLED)&& + (volType == AudioManager.STREAM_MUSIC) ){ + Log.i(TAG, " AUDIOMANGER_VOLUME_CHANGED_ACTION "); + setVolume = true; + } // mRxState & volType + + else { + Log.i(TAG,"VOLUME_CHANGED_ACTION Intent is Ignored, as FM is not yet Enabled"); + + } + } // volume _change + + /* + * Intent recived if the video or Music playback has started. + * Disable the FM and let the music/video playback proceed. + */ + if (fmRxAction.equals(FM_PAUSE_CMD) ) { + Log.i(TAG, FM_PAUSE_CMD); + if (rxIsEnabled() == true) { + pauseFm(); + } + } + + /* + * Intent recived if the video or Music playback has started. + * Disable the FM and let the music/video playback proceed. + */ + if (fmRxAction.equals(FM_RESUME_CMD)) { + Log.i(TAG, FM_RESUME_CMD); + // resume playback only if FM was playing + // when the call was answered + resumeFm(); + + } + /* + * Intent recived if the Notification sound playback has started. + * Mute the FM and let the notification sound playback proceed. + */ + if (fmRxAction.equals(FM_MUTE_CMD) ) { + Log.i(TAG, FM_MUTE_CMD); + if (rxIsEnabled() == true) + { + mIsFmMuted = true; + if (MAKE_FM_APIS_BLOCKING == true) { + Log.i(TAG, " Blocking version"); + rxSetMuteMode(FM_MUTE); + } else { + Log.i(TAG, " Non blocking version"); + rxSetMuteMode_nb(FM_MUTE); + } + } + + } + + /* + * Intent recived if the Notification sound playback has stopped. + * UnMute the FM and let the notification sound playback proceed. + */ + if (fmRxAction.equals(FM_UNMUTE_CMD) ) { + Log.i(TAG, FM_UNMUTE_CMD); + if (rxIsEnabled() == true) + { + mIsFmMuted = false ; + if (MAKE_FM_APIS_BLOCKING == true) { + Log.i(TAG, " Blocking version"); + rxSetMuteMode(FM_NOT_MUTE); + } else { + Log.i(TAG, " Non blocking version"); + rxSetMuteMode_nb(FM_NOT_MUTE); + } + } + + } + + /* + * Intent recived if the Alarm alert is recieved sound playback has stopped. + * UnMute the FM and let the Alarm sound playback proceed. + */ + + if (fmRxAction.equals(ALARM_ALERT_ACTION)) { + Log.i(TAG, ALARM_ALERT_ACTION); + if (rxIsEnabled() == true) + { + mIsFmMuted = true; + if (MAKE_FM_APIS_BLOCKING == true) { + Log.i(TAG, " Blocking version"); + rxSetMuteMode(FM_MUTE); + } else { + Log.i(TAG, " Non blocking version"); + rxSetMuteMode_nb(FM_MUTE); + enableRx(0); + } + + } + } + + if (fmRxAction.equals(MUSIC_PAUSE_ACTION)) { + Log.i(TAG, MUSIC_PAUSE_ACTION); + String cmd = intent.getStringExtra("command"); + if (CMDPAUSE.equals(cmd)) { + if (rxIsEnabled() == true) { + pauseFm(); + Log.i(TAG, "FM app exit"); + } + } + } + /* + * Intent recived if the Alarm alert has stopped sounding for any reason + * UnMute the FM and let the Alarm sound playback proceed. + */ + + if (fmRxAction.equals(ALARM_DONE_ACTION) ) { + Log.i(TAG, ALARM_DONE_ACTION ); + if (rxIsEnabled() == true) + { + mIsFmMuted = false ; + if (MAKE_FM_APIS_BLOCKING == true) { + Log.i(TAG, " Blocking version"); + rxSetMuteMode(FM_NOT_MUTE); + } else { + Log.i(TAG, " Non blocking version"); + rxSetMuteMode_nb(FM_NOT_MUTE); + enableRx(1); + } + + } + } + + + if (fmRxAction.equals(FM_RESTORE_VALUES)) { + Log.e(TAG, "FM_RESTORE_VALUES intent received"); + + setVolume = true; + + if (mFmPauseResume == STATE_RESUME) { + + if (MAKE_FM_APIS_BLOCKING == true) { + Log.d(TAG, " Blocking version"); + rxSetBand(mCurrentBand); + rxSetMuteMode(mCurrentMuteMode); + if(mCurrentRdsState) + { + Log.d(TAG, " restore mCurrentRdsState"); + rxEnableRds(); + } + + } else { + + Log.d(TAG, " Non blocking version"); + rxSetBand_nb(mCurrentBand); + rxSetMuteMode_nb(mCurrentMuteMode); + if(mCurrentRdsState) + { + Log.d(TAG, " restore mCurrentRdsState"); + rxEnableRds_nb(); + } + } + rxTune_nb(mCurrentFrequency); + //rxEnableAudioRouting(); + mFmPauseResume = STATE_DEFAULT; + + } + } + + if (setVolume) { + boolean volState; + + synchronized (mVolumeSynchronizationLock) { + volState = mVolState; + } + if (mVolState) { + int mVolume = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0); + if (mVolume == 0) { + Log.i(TAG, "no volume setting in intent"); + // read the current volume + mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + } + + Log.i(TAG, " Audio Manager mVolume " + mVolume); + // Convert the stream volume to the FM specific volume. + mVolume = (mVolume * FM_MAX_VOLUME)/ (mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)); + + Log.i(TAG, " mVolume " + mVolume); + if (!rxSetVolume(mVolume)) { + Log.i(TAG, "Not able, to set volume "); + } + Log.i(TAG, "send intent for UI updation "); + /* Send Intent to App for UI updation */ + Intent intentMasterVolume = new Intent( + FmRadioIntent.MASTER_VOLUME_CHANGED_ACTION); + intentMasterVolume.putExtra(FmRadioIntent.MASTER_VOLUME,mVolume); + mContext.sendBroadcast(intentMasterVolume, FMRX_PERM); + + } // mVolState + else { + Log.i(TAG, "previous volume set not complete "); + } + } + + } + }; + + private void updateEnableConfiguration() { + + mRxState = STATE_ENABLED; + Log.d(TAG, "FM RX powered on mRxState " + mRxState); + Log.d(TAG, "StubFmService:sending intent FM_ENABLED_ACTION"); + + /* + * Tell the Audio Hardware interface that FM is enabled, so that routing + * happens appropriately + */ + int on = 1; + enableRx(on); + /* + * Previously when FM playback use to happen the wake lock was present in kernel + * which used to prevent device into suspend. And FM playback used to work + * Now, the wake lock has been removed and the FM service will not control + * by acquiring wake lock and releasing once FM is off + */ + if (mWakeLock != null) { + if (!mWakeLock.isHeld()) { + mWakeLock.acquire(); + } else + Log.e(TAG," Wake lock is already held"); + } + } + + private void enableIntent(JFmRxStatus status) { + Intent intentEnable = new Intent(FmRadioIntent.FM_ENABLED_ACTION); + intentEnable.putExtra(FmRadioIntent.STATUS, status); + mContext.sendBroadcast(intentEnable, FMRX_PERM); + } + + /*************************************************************** + * findAndPrintFromLookup(): + * + ****************************************************************/ + public String findFromLookupTable(byte[] indexArray, + JFmRx.JFmRxRepertoire repertoire) { + StringBuilder sb = new StringBuilder(""); + + Log.i(TAG, "findFromLookupTable"); + Log.i(TAG, "Repertoire= " + repertoire); + + switch (repertoire) { + case FMC_RDS_REPERTOIRE_G0_CODE_TABLE: + Log.i(TAG, "FMC_RDS_REPERTOIRE_G0_CODE_TABLE"); + + for (int i = 0; i < indexArray.length; i++) { + int msb = (indexArray[i] & 0xF0) >> 4; + int lsb = (indexArray[i] & 0x0F); + sb.append(lookUpTable_G0[msb][lsb]); + } + break; + + case FMC_RDS_REPERTOIRE_G1_CODE_TABLE: + Log.i(TAG, "FMC_RDS_REPERTOIRE_G1_CODE_TABLE"); + for (int i = 0; i < indexArray.length; i++) { + int msb = (indexArray[i] & 0xF0) >> 4; + int lsb = (indexArray[i] & 0x0F); + sb.append(lookUpTable_G1[msb][lsb]); + } + break; + + case FMC_RDS_REPERTOIRE_G2_CODE_TABLE: + Log.i(TAG, "FMC_RDS_REPERTOIRE_G2_CODE_TABLE"); + + for (int i = 0; i < indexArray.length; i++) { + int msb = (indexArray[i] & 0xF0) >> 4; + int lsb = (indexArray[i] & 0x0F); + sb.append(lookUpTable_G2[msb][lsb]); + } + break; + + default: + Log.i(TAG, "Incorrect Repertoire received..."); + String convertedPsString = "???????????"; + break; + } + + String convertedString = sb.toString(); + return convertedString; + + } + + + + + private final void sendNotificationRX() { + Log.i(TAG, "Sending FM running notification"); + + // Pack up the values and broadcast them to everyone + Intent FMplaybackIntent = new Intent( + "android.intent.action.FM_PLAYBACK"); + NotificationManager mNotificationMgr = (NotificationManager) mContext + .getSystemService(Context.NOTIFICATION_SERVICE); + CharSequence title = "FM Radio RX"; + Long lcurrentfreq; + lcurrentfreq = new Long(mCurrentFrequency); + CharSequence details = lcurrentfreq.toString(); + + PendingIntent intent = PendingIntent.getActivity(mContext, 0, + FMplaybackIntent, 0); + Notification notification = new Notification(); + + /* Currently making use of the icon in the service. when FM is made application Service + we would use the APP icon */ + notification.icon = R.drawable.rxradio; + + notification.setLatestEventInfo(mContext, title, details, intent); + mNotificationMgr.notify(FM_RX_NOTIFICATION_ID, notification); + + } + + + private final void sendNotificationTX() { + Log.i(TAG, "Sending FM running notification"); + + // Pack up the values and broadcast them to everyone + Intent FMplaybackIntent = new Intent( + "android.intent.action.FMTXRELAUNCH"); + NotificationManager mNotificationMgr = (NotificationManager) mContext + .getSystemService(Context.NOTIFICATION_SERVICE); + CharSequence title = "FM Radio TX"; + + PendingIntent intent = PendingIntent.getActivity(mContext, 0, + FMplaybackIntent, 0); + Notification notification = new Notification(); + /* Currently making use of the icon in the service. when FM is made application Service + we would use the APP icon */ + notification.icon = R.drawable.txradio; + CharSequence emptychr = ""; + notification.setLatestEventInfo(mContext, title, emptychr, intent); + mNotificationMgr.notify(FM_TX_NOTIFICATION_ID, notification); + + } + + private final void cancelNotification(int id) { + Log.i(TAG, "Canceling FM notification"); + NotificationManager mNotificationMgr = (NotificationManager) mContext + .getSystemService(Context.NOTIFICATION_SERVICE); + // cancel notification since memory has been freed + mNotificationMgr.cancel(id); + + } + +} diff --git a/tools/FM/service/src/jni/Android.mk b/tools/FM/service/src/jni/Android.mk new file mode 100644 index 0000000..f8a701a --- /dev/null +++ b/tools/FM/service/src/jni/Android.mk @@ -0,0 +1,51 @@ +# +# +# Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ +# +# 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. +# + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +ALSA_PATH := external/alsa-lib/ + +include $(CLEAR_VARS) + + +LOCAL_C_INCLUDES :=\ + $(JNI_H_INCLUDE) \ + external/bluetooth/bluez/include \ + external/tinyalsa/include/tinyalsa + + +LOCAL_CFLAGS:= -g -c -W -Wall -O2 -D_POSIX_SOURCE + +LOCAL_SRC_FILES += JFmRxNative.cpp \ + JFmTxNative.cpp + +LOCAL_SHARED_LIBRARIES := \ + libnativehelper \ + libcutils \ + libutils \ + liblog + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libfmradio +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) + diff --git a/tools/FM/service/src/jni/JFmRxNative.cpp b/tools/FM/service/src/jni/JFmRxNative.cpp new file mode 100644 index 0000000..5febe05 --- /dev/null +++ b/tools/FM/service/src/jni/JFmRxNative.cpp @@ -0,0 +1,2258 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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. + */ + +#include "android_runtime/AndroidRuntime.h" +#include "jni.h" +#include "JNIHelp.h" +#include "v4l2_JbtlLog.h" + + +#define LOG_TAG "JFmRxNative" +#include <cutils/properties.h> + +using namespace android; + +extern "C" { +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <asoundlib.h> +#include <linux/videodev.h> +#include <math.h> +#include <pthread.h> +#include <errno.h> +#include <string.h> +#include <poll.h> + +#include "JFmRxNative.h" + +/*Callback for FM commands*/ +void nativeJFmRx_Callback(long context, int status, + int command, long value); + + /*Callback for FM PS*/ + + + void nativeJFmRx_PS_Callback(long context,int status, int freq, + int len,unsigned char * name, + int repertoire) ; + +/*Callback for FM Radio Text*/ + +void nativeJFmRx_RadioText_Callback(int status, bool resetDisplay, + unsigned char * msg, int len, int startIndex, + int repertoire) ; +} //extern "C" + +static JavaVM *g_jVM = NULL; +static jclass _sJClass; + +typedef pthread_t THREAD_HANDLE; +THREAD_HANDLE p_threadHandle; /* Thread Handle for RDS data */ +static bool isThreadCreated = false; +static int radio_fd; +//snd_ctl_t *fm_snd_ctrl; +long jContext; +volatile bool g_stopCommListener = false; + +static int chanl_spacing=200000; + +/* Complete parsing of the RDS data has not been implemented yet +Commented the FM RX RDS callbacks functionality start*/ + +#if 0 +static jmethodID _sMethodId_nativeCb_fmRxRawRDS; +static jmethodID _sMethodId_nativeCb_fmRxPiCodeChanged; +static jmethodID _sMethodId_nativeCb_fmRxPtyCodeChanged; +static jmethodID _sMethodId_nativeCb_fmRxMonoStereoModeChanged; +static jmethodID _sMethodId_nativeCb_fmRxAudioPathChanged; +static jmethodID _sMethodId_nativeCb_fmRxAfSwitchFreqFailed; +static jmethodID _sMethodId_nativeCb_fmRxAfSwitchStart; +static jmethodID _sMethodId_nativeCb_fmRxAfSwitchComplete; +static jmethodID _sMethodId_nativeCb_fmRxAfListChanged; +static jmethodID _sMethodId_nativeCb_fmRxCompleteScanDone; +#endif + +/*Commented the FM RX RDS callbacks functionality end*/ + + +static jmethodID _sMethodId_nativeCb_fmRxPsChanged; +static jmethodID _sMethodId_nativeCb_fmRxRadioText; +static jmethodID _sMethodId_nativeCb_fmRxCmdEnable; +static jmethodID _sMethodId_nativeCb_fmRxCmdDisable; + +static jmethodID _sMethodId_nativeCb_fmRxCmdEnableAudio; +static jmethodID _sMethodId_nativeCb_fmRxCmdChangeAudioTarget; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetBand; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetBand; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetMonoStereoMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetMonoStereoMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetMuteMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetMuteMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetRssiThreshhold; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetRssiThreshhold; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetVolume; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetVolume; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetChannelSpacing; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetChannelSpacing; +static jmethodID _sMethodId_nativeCb_fmRxCmdTune; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetTunedFrequency; +static jmethodID _sMethodId_nativeCb_fmRxCmdSeek; +static jmethodID _sMethodId_nativeCb_fmRxCmdStopSeek; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetRssi; +static jmethodID _sMethodId_nativeCb_fmRxCmdEnableRds; +static jmethodID _sMethodId_nativeCb_fmRxCmdDisableRds; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetRdsSystem; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetRdsSystem; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetRdsGroupMask; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetRdsGroupMask; +static jmethodID _sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode; +static jmethodID _sMethodId_nativeCb_fmRxCmdDisableAudio; +static jmethodID _sMethodId_nativeCb_fmRxCmdDestroy; +static jmethodID _sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetFwVersion; +static jmethodID _sMethodId_nativeCb_fmRxCmdIsValidChannel; +static jmethodID _sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress; +static jmethodID _sMethodId_nativeCb_fmRxCmdStopCompleteScan; + + + + + +int rdsParseFunc_updateRepertoire(int byte1,int byte2) +{ + + int repertoire1,repertoire2; + int repertoire3,repertoire4; + int repertoire; + + /*replace to nibble high/low*/ + repertoire1 = (FMC_U8)(byte1&RDS_BIT_0_TO_BIT_3); + repertoire2 = (FMC_U8)((byte1&RDS_BIT_4_TO_BIT_7)>>4); + repertoire3 = (FMC_U8)(byte2&RDS_BIT_0_TO_BIT_3); + repertoire4 = (FMC_U8)((byte2&RDS_BIT_4_TO_BIT_7)>>4); + + if((repertoire2==0)&&(repertoire1==15)&&(repertoire4==0)&&(repertoire3==15)) + { + repertoire = FMC_RDS_REPERTOIRE_G0_CODE_TABLE; + + } + else if((repertoire2==0)&&(repertoire1==14)&&(repertoire4==0)&&(repertoire3==14)) + { + repertoire = FMC_RDS_REPERTOIRE_G1_CODE_TABLE; + + } + else if ((repertoire2==1)&&(repertoire1==11)&&(repertoire4==6)&&(repertoire3==14)) + { + repertoire = FMC_RDS_REPERTOIRE_G2_CODE_TABLE; + + } + +V4L2_JBTL_LOGD(" rdsParseFunc_updateRepertoire repertoire%d\n",repertoire); + return repertoire; +} + + +void rds_decode(int blkno, int byte1, int byte2) +{ + static unsigned char rds_psn[9]; + static unsigned char rds_txt[65]; + static int rds_pty,ms_code; + static int group,spare,blkc_byte1,blkc_byte2; + int len; + bool resetDisplay =false; + int status = 0,startIndex=0,repertoire,freq; + + switch (blkno) { + case 0: /* Block A */ + V4L2_JBTL_LOGD("block A - id=%d\n",(byte1 << 8) | byte2); + break; + case 1: /* Block B */ + V4L2_JBTL_LOGD("block B - group=%d%c tp=%d pty=%d spare=%d\n", + (byte1 >> 4) & 0x0f, + ((byte1 >> 3) & 0x01) + 'A', + (byte1 >> 2) & 0x01, + ((byte1 << 3) & 0x18) | ((byte2 >> 5) & 0x07), + byte2 & 0x1f); + group = (byte1 >> 3) & 0x1f; + spare = byte2 & 0x1f; + rds_pty = ((byte1 << 3) & 0x18) | ((byte2 >> 5) & 0x07); + ms_code = (byte2 >> 3)& 0x1; + + break; + case 2: /* Block C */ + V4L2_JBTL_LOGD("block C - 0x%02x 0x%02x\n",byte1,byte2); + blkc_byte1 = byte1; + blkc_byte2 = byte2; + break; + case 3 : /* Block D */ + V4L2_JBTL_LOGD("block D - 0x%02x 0x%02x\n",byte1,byte2); + switch (group) { + case 0: /* Group 0A */ + rds_psn[2*(spare & 0x03)+0] = byte1; + rds_psn[2*(spare & 0x03)+1] = byte2; + if ((spare & 0x03) == 0x03) + { + V4L2_JBTL_LOGD("PSN: %s, PTY: %d, MS: %s\n",rds_psn, + rds_pty,ms_code?"Music":"Speech"); + + len = strlen((const char *)rds_psn); + V4L2_JBTL_LOGD("PS len %d",len); + nativeJFmRx_PS_Callback(jContext,status,freq,len,rds_psn,repertoire); + } + + break; + case 4: /* Group 2A */ + + repertoire = rdsParseFunc_updateRepertoire(byte1,byte2); + + repertoire =0; + + V4L2_JBTL_LOGD("Radio repertoire: %d\n",repertoire); + rds_txt[4*(spare & 0x0f)+0] = blkc_byte1; + rds_txt[4*(spare & 0x0f)+1] = blkc_byte2; + rds_txt[4*(spare & 0x0f)+2] = byte1; + rds_txt[4*(spare & 0x0f)+3] = byte2; + /* Display radio text once we get 16 characters */ + if (spare > 16) + { + len =strlen((const char *)rds_txt); + + V4L2_JBTL_LOGD("RDS len %d",len); + V4L2_JBTL_LOGD("Radio Text: %s\n",rds_txt); + + nativeJFmRx_RadioText_Callback(status, resetDisplay, + rds_txt, len, startIndex,repertoire) ; + } + break; + } + V4L2_JBTL_LOGD("----------------------------------------\n"); + break; + default: + V4L2_JBTL_LOGD("unknown block [%d]\n",blkno); + } +} + +/** + * Function: entryFunctionForRdsThread + * Brief: Creates a thread for waiting on responses from RDS . + * Description: + */ + +void *entryFunctionForRdsThread(void *data) +{ + unsigned char buf[600]; + int radio_fd; + int ret,index; + struct pollfd pfd; + + radio_fd = (int)data; + + V4L2_JBTL_LOGD(" entryFunctionForRdsThread: Entering.g_stopCommListener %d \n",g_stopCommListener); + + while(!g_stopCommListener) + { + + V4L2_JBTL_LOGD("RDS thread running..\n"); + + while(1){ + memset(&pfd, 0, sizeof(pfd)); + pfd.fd = radio_fd; + pfd.events = POLLIN; + ret = poll(&pfd, 1, 10); + if (ret == 0){ + /* Break the poll after RDS data available */ + break; + } + } + + ret = read(radio_fd,buf,500); + if(ret < 0) + { V4L2_JBTL_LOGD("NO RDS data to read..\n"); + return NULL; + } + + else if( ret > 0) + { + + V4L2_JBTL_LOGD(" RDS data to read is available..\n"); + for(index=0;index<ret;index+=3) + rds_decode(buf[index+2] & 0x7,buf[index+1],buf[index]); + } + } + + V4L2_JBTL_LOGD("RDS thread exiting..\n"); + return NULL; +} + +int fm_read_tuner_capabilities(int radio_fd) +{ + struct v4l2_capability cap; + int res; + + res = ioctl(radio_fd,VIDIOC_QUERYCAP,&cap); + if(res < 0) + { + V4L2_JBTL_LOGD("Failed to read %s capabilities\n",DEFAULT_RADIO_DEVICE); + return FM_FAILED; + } + if((cap.capabilities & V4L2_CAP_RADIO) == 0) + { + V4L2_JBTL_LOGD("%s is not radio devcie",DEFAULT_RADIO_DEVICE); + return FM_FAILED; + } + V4L2_JBTL_LOGD("\n***%s Info ****\n",DEFAULT_RADIO_DEVICE); + V4L2_JBTL_LOGD("Driver : %s\n",cap.driver); + V4L2_JBTL_LOGD("Card : %s\n",cap.card); + V4L2_JBTL_LOGD("Bus : %s\n",cap.bus_info); + V4L2_JBTL_LOGD("Capabilities : 0x%x\n",cap.capabilities); + + return FM_SUCCESS; +} + + +static int nativeJFmRx_Create(JNIEnv *env,jobject obj,jobject jContextValue) +{ + + int fmStatus ; + + V4L2_JBTL_LOGD("Java_JFmRx_nativeJFmRx_Create(): Entered"); + + radio_fd = open(DEFAULT_RADIO_DEVICE, O_RDWR); + if(radio_fd < 0) + { + V4L2_JBTL_LOGD("Unable to open %s ..\n",DEFAULT_RADIO_DEVICE); + jniThrowIOException(env, errno); + return FM_FAILED; + } + + fmStatus = fm_read_tuner_capabilities(radio_fd); + if(fmStatus< 0) + { + close(radio_fd); + return fmStatus; + } + + V4L2_JBTL_LOGD("nativeJFmRx_create:Exiting Successfully"); + + return fmStatus; +} + + + +static int nativeJFmRx_Destroy(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + V4L2_JBTL_LOGD("nativeJFmRx_destroy(): Entered"); + + V4L2_JBTL_LOGD("nativeJFmRx_destroy(): Exit"); + return FM_SUCCESS; +} + + + +static int nativeJFmRx_Enable(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + int status ; + struct v4l2_tuner vtun; + + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Entered"); + + jContext = jContextValue; + + vtun.index = 0; + vtun.audmode = V4L2_TUNER_MODE_STEREO; + vtun.rxsubchans = V4L2_TUNER_SUB_RDS; + + status = ioctl(radio_fd, VIDIOC_S_TUNER, &vtun); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to Enable FM\n"); + return status; + } + + V4L2_JBTL_LOGD("nativeJFmRx_enable: FM_RX_Enable() returned %d",(int)status); + nativeJFmRx_Callback(jContext,status,FM_RX_CMD_ENABLE,status); + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Exit"); + return status; +} + + + +static int nativeJFmRx_Disable(JNIEnv *env, jobject obj, jlong jContextValue) +{ + V4L2_JBTL_LOGD("nativeJFmRx_disable(): Entered"); + + // Terminate RDS thread + g_stopCommListener = true; + isThreadCreated = false; + + close(radio_fd); + nativeJFmRx_Callback(jContext,0,FM_RX_CMD_DISABLE,0); + + V4L2_JBTL_LOGD("nativeJFmRx_disable(): Exit");; + return FM_SUCCESS; +} + + + +static int nativeJFmRx_SetBand(JNIEnv *env, jobject obj,jlong jContextValue, jint jFmBand) +{ + int status=0; + static unsigned char last_band = FM_BAND_EUROPE_US; + char curr_band; + int fd, res; + + switch(jFmBand) { + case 1: + curr_band = '1'; + break; + case 0: + default: + curr_band = '0'; + break; + } + + V4L2_JBTL_LOGD("nativeJFmRx_setBand(): EnteredjFmBand %d",jFmBand); + V4L2_JBTL_LOGD("nativeJFmRx_setBand(): curr_band %d last_band %d",curr_band,last_band); + + fd = open(FM_BAND_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + V4L2_JBTL_LOGD("Can't open %s", FM_BAND_SYSFS_ENTRY); + return FM_FAILED; + } + + res = write(fd, &curr_band, sizeof(char)); + if(res <= 0){ + V4L2_JBTL_LOGD("Failed to set FM Band\n"); + return FM_FAILED; + } + + nativeJFmRx_Callback(jContext,status,FM_RX_CMD_SET_BAND,status); + + V4L2_JBTL_LOGD("nativeJFmRx_setBand(): Exit"); + return FM_PENDING; +} + + +static int nativeJFmRx_GetBand(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status = 0; + unsigned char curr_band; + +nativeJFmRx_Callback(jContext,status,FM_RX_CMD_GET_BAND,curr_band); + + V4L2_JBTL_LOGD("nativeJFmRx_getBand(): Exit"); + + return FM_PENDING; +} + + +static int nativeJFmRx_Tune(JNIEnv *env, jobject obj,jlong jContextValue,jint user_freq) +{ + struct v4l2_frequency vf; + struct v4l2_tuner vt; + int status, div; + + V4L2_JBTL_LOGD("nativeJFmRx_tune(): Entered"); + + vt.index = 0; + status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to get tuner capabilities\n"); + return FM_FAILED; + } + + vf.tuner = 0; + vf.frequency = rint(user_freq * 16 + 0.5); + + div = (vt.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; + if (div == 1) + vf.frequency /=1000; + + status = ioctl(radio_fd, VIDIOC_S_FREQUENCY, &vf); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to tune to frequency %d\n",user_freq); + return FM_FAILED; + } + V4L2_JBTL_LOGD("Tuned to frequency %2.1f MHz\n",user_freq); + +nativeJFmRx_Callback(jContext,status,FM_RX_CMD_TUNE,user_freq); + + V4L2_JBTL_LOGD("nativeJFmRx_Tune(): Exit"); + return FM_PENDING; + + + +} + + +static int nativeJFmRx_GetTunedFrequency(JNIEnv *env, jobject obj,jlong jContextValue) +{ + struct v4l2_frequency vf; + int status; + V4L2_JBTL_LOGD("nativeJFmRx_getTunedFrequency(): Entered"); + + status = ioctl(radio_fd, VIDIOC_G_FREQUENCY,&vf); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to read current frequency\n"); + return FM_FAILED; + } + + V4L2_JBTL_LOGD("Tuned to frequency %2.1f MHz \n",(float)vf.frequency/1000); +nativeJFmRx_Callback(jContext,status,FM_RX_CMD_GET_TUNED_FREQUENCY,vf.frequency); + + V4L2_JBTL_LOGD("nativeJFmRx_getTunedFrequency(): Exit"); + return FM_PENDING; + +} + + + +static int nativeJFmRx_SetMonoStereoMode(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmMode) +{ + + struct v4l2_tuner vt; + int status; + V4L2_JBTL_LOGD("nativeJFmRx_SetMonoStereoMode(): Entered"); + + vt.index = 0; + vt.audmode = jFmMode; + + status = ioctl(radio_fd, VIDIOC_S_TUNER, &vt); + if (status < 0){ + V4L2_JBTL_LOGD("Failed to set stereo/mono mode\n"); + return FM_FAILED; + } + + V4L2_JBTL_LOGD("Set to %d Mode\n",jFmMode); + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_MONO_STEREO_MODE,status); + + V4L2_JBTL_LOGD("nativeJFmRx_SetMonoStereoMode(): Exit"); + return FM_PENDING; +} + + + +static int nativeJFmRx_GetMonoStereoMode(JNIEnv *env, jobject obj,jlong jContextValue) +{ + struct v4l2_tuner vt; + int status; + unsigned char mode; + + V4L2_JBTL_LOGD("nativeJFmRx_GetMonoStereoMode(): Entered"); + + vt.index = 0; + status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); + if (status < 0){ + V4L2_JBTL_LOGD("Failed to get stereo/mono mode\n"); + return FM_FAILED; + } + mode = vt.audmode; + + V4L2_JBTL_LOGD("%d mode\n",mode); +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_MONO_STEREO_MODE,mode); + + V4L2_JBTL_LOGD("nativeJFmRx_GetMonoStereoMode(): Exit"); + return FM_PENDING ; +} + + + +static int nativeJFmRx_SetMuteMode(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmMuteMode) +{ + + struct v4l2_control vctrl; + int status; + + V4L2_JBTL_LOGD("nativeJFmRx_setMuteMode(): Entered"); + + vctrl.id = V4L2_CID_AUDIO_MUTE; + vctrl.value = !jFmMuteMode; /* To Do:: Mapping in future for V4L2*/ + status = ioctl(radio_fd,VIDIOC_S_CTRL,&vctrl); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to set mute mode\n"); + return FM_FAILED; + } + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_MUTE_MODE,status); + V4L2_JBTL_LOGD("nativeJFmRx_setMuteMode(): Exit"); + return FM_PENDING; + + +} + + +static int nativeJFmRx_GetMuteMode(JNIEnv *env, jobject obj,jlong jContextValue) +{ + struct v4l2_control vctrl; + int status; + V4L2_JBTL_LOGD("nativeJFmRx_getMuteMode(): Entered"); + vctrl.id = V4L2_CID_AUDIO_MUTE; + status = ioctl(radio_fd,VIDIOC_G_CTRL,&vctrl); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to get mute mode\n"); + return FM_FAILED; + } + + V4L2_JBTL_LOGD("%d\n",vctrl.value); +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_MUTE_MODE,vctrl.value); + + V4L2_JBTL_LOGD("nativeJFmRx_getMuteMode(): Exit"); + return FM_PENDING; +} + + +static int nativeJFmRx_SetRssiThreshold(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmRssi) +{ + + int status; + char rssi_lvl[10]; + int fd, res; + + V4L2_JBTL_LOGD("nativeJFmRx_setRssiThreshold(): Entered"); + + sprintf(rssi_lvl,"%d",jFmRssi); + + V4L2_JBTL_LOGD("nativeJFmRx_setRssiThreshold(): val = %s", rssi_lvl); + ; + fd = open(FM_RSSI_LVL_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + V4L2_JBTL_LOGD("Can't open %s", FM_RSSI_LVL_SYSFS_ENTRY); + return FM_FAILED; + } + + res = write(fd, &rssi_lvl, sizeof(char)); + if(res <= 0){ + V4L2_JBTL_LOGD("Failed to set FM RSSI level\n"); + return FM_FAILED; + } + + V4L2_JBTL_LOGD("Setting rssi to %d\n",jFmRssi); + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RSSI_THRESHOLD,status); + V4L2_JBTL_LOGD("nativeJFmRx_setRssiThreshold(): Exit"); + + return FM_PENDING; +} + +static int nativeJFmRx_GetRssiThreshold(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + short rssi_threshold; + int status; + V4L2_JBTL_LOGD("nativeJFmRx_getRssiThreshold(): Entered"); + + status = 0; + + V4L2_JBTL_LOGD("RSSI threshold set to %d\n",rssi_threshold); +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RSSI_THRESHOLD,rssi_threshold); + V4L2_JBTL_LOGD("nativeJFmRx_getRssiThreshold(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_GetRssi(JNIEnv *env, jobject obj,jlong jContextValue) +{ + int status; + short curr_rssi_lvl; + + V4L2_JBTL_LOGD("nativeJFmRx_getRssi(): Entered"); + + status = 0; + + V4L2_JBTL_LOGD("RSSI level is %d\n",curr_rssi_lvl); + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RSSI,curr_rssi_lvl); + V4L2_JBTL_LOGD("nativeJFmRx_getRssi(): Exit"); + return FM_PENDING;; + +} + +static int nativeJFmRx_SetVolume(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmVolume) +{ + struct v4l2_control vctrl; + int status; + + V4L2_JBTL_LOGD("nativeJFmRx_SetVolume(): Entered"); + + vctrl.id = V4L2_CID_AUDIO_VOLUME; + vctrl.value = jFmVolume; + + status = ioctl(radio_fd,VIDIOC_S_CTRL,&vctrl); + if(status < 0) + { + V4L2_JBTL_LOGD("nativeJFmRx_SetVolume():Failed to set volume\n"); + return status; + } + V4L2_JBTL_LOGD("nativeJFmRx_SetVolume():Setting volume to %d \n",jFmVolume); + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_VOLUME,status); + + V4L2_JBTL_LOGD("nativeJFmRx_SetVolume(): Exit"); + return FM_PENDING; + + +} + +static int nativeJFmRx_GetVolume(JNIEnv *env, jobject obj,jlong jContextValue) +{ + struct v4l2_control vctrl; + int status; + + V4L2_JBTL_LOGD("nativeJFmRx_getVolume(): Entered"); + + + vctrl.id = V4L2_CID_AUDIO_VOLUME; + status = ioctl(radio_fd,VIDIOC_G_CTRL,&vctrl); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to get volume\n"); + return status; + } + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_VOLUME,vctrl.value); + V4L2_JBTL_LOGD("nativeJFmRx_getVolume(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_SetChannelSpacing(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmChannelSpacing) +{ + + int status = 0; + LOGD("nativeJFmRx_SetChannelSpacing(): Entered"); + + chanl_spacing = jFmChannelSpacing * 50000; + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_CHANNEL_SPACING,status); + + LOGD("nativeJFmRx_SetChannelSpacing(): Exit"); + return FM_PENDING; + +} + +static int nativeJFmRx_GetChannelSpacing(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status =0; + LOGD("nativeJFmRx_GetChannelSpacing(): Entered"); + + LOGD("nativeJFmRx_GetChannelSpacing(): Exit"); + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_CHANNEL_SPACING,status); + return FM_PENDING; +} + +static jint nativeJFmRx_SetDeEmphasisFilter(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmEmphasisFilter) +{ + + int status; + V4L2_JBTL_LOGD("nativeJFmRx_SetDeEmphasisFilter(): Entered"); + + V4L2_JBTL_LOGD("1. nativeJFmRx_EnableRDS\n"); + status = 0; + + V4L2_JBTL_LOGD("Set to De-emphasis %d mode\n",jFmEmphasisFilter); +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_DEEMPHASIS_FILTER,status); + V4L2_JBTL_LOGD("nativeJFmRx_SetDeEmphasisFilter(): Exit"); + V4L2_JBTL_LOGD("2. nativeJFmRx_EnableRDS\n"); + return FM_PENDING; +} + + +static int nativeJFmRx_GetDeEmphasisFilter(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status; + unsigned char mode; + + V4L2_JBTL_LOGD("nativeJFmRx_GetDeEmphasisFilter(): Entered"); + + V4L2_JBTL_LOGD("1. nativeJFmRx_EnableRDS\n"); + mode = 0; + + V4L2_JBTL_LOGD("De-emphasis filter %d\n",mode); +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_DEEMPHASIS_FILTER,mode); + + V4L2_JBTL_LOGD("nativeJFmRx_GetDeEmphasisFilter(): Exit"); + V4L2_JBTL_LOGD("2. nativeJFmRx_EnableRDS\n"); + return FM_PENDING; +} + + + +static int nativeJFmRx_Seek(JNIEnv *env, jobject obj,jlong jContextValue,jint jdirection) +{ + + struct ti_v4l2_hw_freq_seek frq_seek; + struct v4l2_frequency vf; + struct v4l2_tuner vt; + int status, div; + + V4L2_JBTL_LOGD("nativeJFmRx_Seek(): Entered"); + V4L2_JBTL_LOGD("Seeking %s.. and channel spacing is %d\n",jdirection?"up":"down", chanl_spacing); + frq_seek.seek_upward = jdirection; + frq_seek.type = (v4l2_tuner_type)1; + frq_seek.spacing = chanl_spacing; + frq_seek.wrap_around = 0; + + errno = 0; + status = ioctl(radio_fd,VIDIOC_S_HW_FREQ_SEEK,&frq_seek); + if(errno == EAGAIN) + { + V4L2_JBTL_LOGD("Band limit reached\n"); + } + else if(status <0) + { + V4L2_JBTL_LOGD("Seek operation failed\n"); + return status; + } + + V4L2_JBTL_LOGD("nativeJFmRx_tune(): Entered"); + + vt.index = 0; + status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to get tuner capabilities\n"); + return FM_FAILED; + } + + div = (vt.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; + + status = ioctl(radio_fd, VIDIOC_G_FREQUENCY,&vf); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to read current frequency\n"); + return status; + } + + V4L2_JBTL_LOGD("Tuned to frequency %3.2f MHz \n",vf.frequency / (16.0 * div)); + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SEEK,vf.frequency * 1000 / (16 * div)); + + V4L2_JBTL_LOGD("nativeJFmRx_Seek(): Exit"); + return FM_PENDING; + +} + + +static int nativeJFmRx_StopSeek(JNIEnv *env, jobject obj,jlong jContextValue) +{ +int status =0; + V4L2_JBTL_LOGD("nativeJFmRx_StopSeek(): Entered"); + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_STOP_SEEK,status); + V4L2_JBTL_LOGD("nativeJFmRx_StopSeek(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_EnableRDS(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status; + unsigned char rds_mode = FM_RDS_ENABLE; + struct v4l2_tuner vt; + + V4L2_JBTL_LOGD("nativeJFmRx_enableRDS(): Entered"); + + V4L2_JBTL_LOGD("1. nativeJFmRx_EnableRDS\n"); + vt.index = 0; + status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to get tuner attributes\n"); + return status; + } + + V4L2_JBTL_LOGD("2. nativeJFmRx_EnableRDS\n"); + + if ((vt.rxsubchans & V4L2_TUNER_SUB_RDS) != 1) + vt.rxsubchans |= V4L2_TUNER_SUB_RDS; + + status = ioctl(radio_fd, VIDIOC_S_TUNER, &vt); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to set RDS on/off status\n"); + return status; + } + + V4L2_JBTL_LOGD("3. nativeJFmRx_EnableRDS\n"); + if(isThreadCreated == false) + { + + V4L2_JBTL_LOGD(" nativeJFmRx_EnableRDS: creating thread !!! \n"); + g_stopCommListener = false; + /* Create rds receive thread once */ + status = pthread_create(&p_threadHandle, /* Thread Handle. */ + NULL, /* Default Atributes. */ + entryFunctionForRdsThread, /* Entry Function. */ + (void *)radio_fd); /* Parameters. */ + if (status < 0) + { + V4L2_JBTL_LOGD(" nativeJFmRx_EnableRDS: Thread Creation FAILED !!! \n"); + return FM_ERR_THREAD_CREATION_FAILED; + } + + isThreadCreated = true; + } + else + V4L2_JBTL_LOGD("RDS thread already created\n"); + + V4L2_JBTL_LOGD("4. nativeJFmRx_EnableRDS\n"); + V4L2_JBTL_LOGD("RDS %d\n",rds_mode); + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_ENABLE_RDS,status); + V4L2_JBTL_LOGD("nativeJFmRx_enableRDS(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_DisableRDS(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status; + unsigned char rds_mode = FM_RDS_DISABLE; + struct v4l2_tuner vt; + + V4L2_JBTL_LOGD("1. nativeJFmRx_DisableRDS\n"); + vt.index = 0; + status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to get tuner attributes\n"); + return status; + } + + if(vt.rxsubchans & V4L2_TUNER_SUB_RDS) + vt.rxsubchans &= ~V4L2_TUNER_SUB_RDS; + + V4L2_JBTL_LOGD("2. nativeJFmRx_DisableRDS and vt.rxsubchans = %d\n", vt.rxsubchans); + + status = ioctl(radio_fd, VIDIOC_S_TUNER, &vt); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to set RDS on/off status\n"); + return status; + } + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_DISABLE_RDS,status); + + V4L2_JBTL_LOGD("nativeJFmRx_DisableRDS(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_EnableAudioRouting(JNIEnv *env, jobject obj,jlong jContextValue) +{ + int status = 0 ; + V4L2_JBTL_LOGD("nativeJFmRx_enableAudioRouting(): Entered"); + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_ENABLE_AUDIO,status); + + V4L2_JBTL_LOGD("nativeJFmRx_enableAudioRouting(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_DisableAudioRouting(JNIEnv *env, jobject obj,jlong jContextValue) +{ + int status = 0 ; + V4L2_JBTL_LOGD("nativeJFmRx_disableAudioRouting(): Entered"); + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_ENABLE_AUDIO,status); + + V4L2_JBTL_LOGD("nativeJFmRx_disableAudioRouting(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_SetRdsAfSwitchMode(JNIEnv *env, jobject obj,jlong jContextValue,jint jRdsAfSwitchMode) +{ + + int status; + char af_switch; + int fd, res; + + V4L2_JBTL_LOGD("nativeJFmRx_setRdsAfSwitchMode(): Entered"); + + switch(jRdsAfSwitchMode) { + case 1: + af_switch = '1'; + break; + case 0: + default: + af_switch = '0'; + break; + } + + fd = open(FM_RDS_AF_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + V4L2_JBTL_LOGD("Can't open %s", FM_RDS_AF_SYSFS_ENTRY); + return FM_FAILED; + } + + res = write(fd, &af_switch, sizeof(char)); + if(res <= 0){ + V4L2_JBTL_LOGD("Failed to set FM AF Switch\n"); + return FM_FAILED; + } + + + V4L2_JBTL_LOGD("AF Switch %d ",jRdsAfSwitchMode); + + nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RDS_AF_SWITCH_MODE,status); + V4L2_JBTL_LOGD("nativeJFmRx_setRdsAfSwitchMode(): Exit"); + return FM_PENDING; + +} + +static int nativeJFmRx_GetRdsAfSwitchMode(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status; + unsigned char af_mode; + + + V4L2_JBTL_LOGD("nativeJFmRx_getRdsAfSwitchMode(): Entered"); + + status = 0; + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RDS_AF_SWITCH_MODE,af_mode); + V4L2_JBTL_LOGD("nativeJFmRx_getRdsAfSwitchMode(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_ChangeAudioTarget (JNIEnv *env, jobject obj,jlong jContextValue, jint jFmRxAudioTargetMask, jint digitalConfig) +{ + + V4L2_JBTL_LOGD("nativeJFmRx_ChangeAudioTarget(): Entered"); +//nativeJFmRx_Callback(jContext,status, FM_RX_CMD_CHANGE_AUDIO_TARGET,status); + V4L2_JBTL_LOGD("nativeJFmRx_ChangeAudioTarget(): Exit"); + return FM_PENDING; + +} + + +static int nativeJFmRx_ChangeDigitalTargetConfiguration(JNIEnv *env, jobject obj,jlong jContextValue,jint digitalConfig) +{ + + V4L2_JBTL_LOGD("nativeJFmRx_ChangeDigitalTargetConfiguration(): Entered"); + + //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION,status); + + V4L2_JBTL_LOGD("nativeJFmRx_ChangeDigitalTargetConfiguration(): Exit"); + return FM_PENDING; + +} + + +static int nativeJFmRx_SetRfDependentMuteMode(JNIEnv *env, jobject obj,jlong jContextValue, jint rf_mute) +{ + + int status; + V4L2_JBTL_LOGD("nativeJFmRx_SetRfDependentMuteMode(): Entered"); + + status = 0; + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RF_DEPENDENT_MUTE_MODE,status); + V4L2_JBTL_LOGD("nativeJFmRx_SetRfDependentMuteMode(): Exit"); + return FM_PENDING; + + + +} + + +static int nativeJFmRx_GetRfDependentMute(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status; + unsigned char rf_mute; + V4L2_JBTL_LOGD(" nativeJFmRx_GetRfDependentMute(): Entered"); + + status = 0; + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RF_DEPENDENT_MUTE_MODE,rf_mute); + V4L2_JBTL_LOGD(" nativeJFmRx_GetRfDependentMute(): Exit"); + return FM_PENDING; + +} + + +static int nativeJFmRx_SetRdsSystem(JNIEnv *env, jobject obj,jlong jContextValue, jint rdsSystem) +{ + int status; + + V4L2_JBTL_LOGD(" nativeJFmRx_SetRdsSystem(): Entered"); + + V4L2_JBTL_LOGD("entered to ELSE\n"); + status = 0; + + V4L2_JBTL_LOGD("Set to %d\n",rdsSystem); + nativeJFmRx_Callback(jContext,status,FM_RX_CMD_SET_RDS_SYSTEM,status); + V4L2_JBTL_LOGD(" nativeJFmRx_SetRdsSystem(): Exit"); + return FM_PENDING; + + + +} + + +static int nativeJFmRx_GetRdsSystem(JNIEnv *env, jobject obj,jlong jContextValue) +{ + + int status; + unsigned char mode; + + V4L2_JBTL_LOGD("nativeJFmRx_GetRdsSystem(): Entered"); + + status = 0; + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RDS_SYSTEM,mode); + V4L2_JBTL_LOGD(" nativeJFmRx_GetRdsSystem(): Exit"); + return FM_PENDING; + +} + + +static int nativeJFmRx_SetRdsGroupMask(JNIEnv *env, jobject obj,jlong jContextValue, jlong groupMask) +{ +int status =0; + V4L2_JBTL_LOGD("nativeJFmRx_SetRdsGroupMask(): Entered"); + + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RDS_GROUP_MASK,status); + V4L2_JBTL_LOGD(" nativeJFmRx_SetRdsGroupMask(): Exit"); + return FM_PENDING; + +} + +static int nativeJFmRx_GetRdsGroupMask(JNIEnv *env, jobject obj,jlong jContextValue) +{ +int status =0; + V4L2_JBTL_LOGD("nativeJFmRx_GetRdsGroupMask(): Entered"); + + +nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RDS_GROUP_MASK,status); + V4L2_JBTL_LOGD(" nativeJFmRx_GetRdsGroupMask(): Exit"); + return FM_PENDING; + +} + +static int nativeJFmRx_CompleteScan(JNIEnv *env, jobject obj, jlong jContextValue) +{ + +int status =0; + LOGD("nativeJFmRx_CompleteScan(): Entered"); + + //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_COMPLETE_SCAN,status); + LOGD("nativeJFmRx_CompleteScan(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_GetCompleteScanProgress(JNIEnv *env, jobject obj, jlong jContextValue) +{ +int status =0; + LOGD("nativeJFmRx_GetCompleteScanProgress(): Entered"); + //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_COMPLETE_SCAN_PROGRESS,status); + + LOGD("nativeJFmRx_GetCompleteScanProgress(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_StopCompleteScan(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + LOGD("nativeJFmRx_StopCompleteScan(): Entered"); + + //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_STOP_COMPLETE_SCAN,status); + LOGD("nativeJFmRx_StopCompleteScan(): Exit"); + return FM_PENDING; +} + +static int nativeJFmRx_IsValidChannel(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + + LOGD("nativeJFmRx_IsValidChannel(): Entered"); +//nativeJFmRx_Callback(jContext,status, FM_RX_CMD_IS_CHANNEL_VALID ,status); + LOGD("nativeJFmRx_IsValidChannel(): Exit"); + return FM_PENDING; +} + + +static int nativeJFmRx_GetFwVersion(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + LOGD("nativeJFmRx_GetFwVersion(): Entered"); +//nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_FW_VERSION,status); + LOGD("nativeJFmRx_GetFwVersion(): Exit"); + return FM_PENDING; +} + + +//################################################################################ + +// SIGNALS + +//############################################################################### + +extern "C" +{ + +void nativeJFmRx_RadioText_Callback(int status, bool resetDisplay, + unsigned char * msg, int len, int startIndex, + int repertoire) +{ + LOGE("nativeJFmRx_RadioText_Callback: Entering"); + +LOGE("nativeJFmRx_RadioText_Callback: msg %s",msg); + JNIEnv* env = NULL; + bool attachedThread = false; + int jRet ; + jbyteArray jRadioTxtMsg = NULL; + + /* check whether the current thread is attached to a virtual machine instance, + if no only then try to attach to the current thread. */ + jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); + + if(jRet < 0) + { + LOGE("failed to get JNI env,assuming native thread"); + jRet = g_jVM->AttachCurrentThread((&env), NULL); + + if(jRet != JNI_OK) + { + LOGE("failed to atatch to current thread %d",jRet); + return ; + } + + attachedThread = true; + } + + + + + if(env == NULL) { + LOGI("%s: Entered, env is null", __func__); + } else { + LOGD("%s: jEnv %p", __func__, (void *)env); + } + + +V4L2_JBTL_LOGD("nativeJFmRx_Callback():EVENT --------------->FM_RX_EVENT_RADIO_TEXT"); + jRadioTxtMsg = env->NewByteArray(len); + if (jRadioTxtMsg == NULL) { + LOGE("%s: Failed converting elements", __func__); + goto CLEANUP; + } + + env->SetByteArrayRegion(jRadioTxtMsg, + 0, + len, + (jbyte*)msg); + + if (env->ExceptionOccurred()) { + LOGE("%s: Calling nativeCb_fmRxRadioText failed", + __func__); + goto CLEANUP; + } + + env->CallStaticVoidMethod(_sJClass, + _sMethodId_nativeCb_fmRxRadioText,(jlong)jContext, + (jint)status, + (jboolean)resetDisplay, + jRadioTxtMsg, + (jint)len, + (jint)startIndex, + (jint)repertoire); + + if (env->ExceptionOccurred()) { + LOGE("nativeJFmRx_RadioText_Callback: ExceptionOccurred"); + goto CLEANUP; + } + +if(jRadioTxtMsg!= NULL) + env->DeleteLocalRef(jRadioTxtMsg); + + if(attachedThread == true) + g_jVM->DetachCurrentThread(); + +return ; + + CLEANUP: +LOGE("nativeJFmRx_RadioText_Callback: Exiting due to failure"); + +if(jRadioTxtMsg!= NULL) + env->DeleteLocalRef(jRadioTxtMsg); + if (env->ExceptionOccurred()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + + if(attachedThread == true) + g_jVM->DetachCurrentThread(); +return ; +} + + + + + + void nativeJFmRx_PS_Callback(long context,int status, int freq, + int len,unsigned char * name, + int repertoire) + + { + LOGE("nativeJFmRx_PS_Callback: Exiting due to failure"); + JNIEnv* env = NULL; + bool attachedThread = false; + int jRet ; + jbyteArray jNameString = NULL; + int frequency =0; + + /* check whether the current thread is attached to a virtual machine instance, + if no only then try to attach to the current thread. */ + jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); + + if(jRet < 0) + { + LOGE("failed to get JNI env,assuming native thread"); + jRet = g_jVM->AttachCurrentThread((&env), NULL); + + if(jRet != JNI_OK) + { + LOGE("failed to atatch to current thread %d",jRet); + return ; + } + + attachedThread = true; + } + + + + + if(env == NULL) { + LOGI("%s: Entered, env is null", __func__); + } else { + LOGD("%s: jEnv %p", __func__, (void *)env); + } + + V4L2_JBTL_LOGD("nativeJFmRx_PS_Callback():EVENT --------------->FM_RX_EVENT_PS_CHANGED len %d",len); + + + jNameString = env->NewByteArray(len); + + if (jNameString == NULL) + { + V4L2_JBTL_LOGD("nativeJFmRx_PS_Callback: Failed converting elements"); + goto CLEANUP; + } + + env->SetByteArrayRegion(jNameString,0,len,(jbyte*)name); + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGD("nativeJFmRx_PS_Callback: Calling Java nativeCb_fmRxRadioText failed"); + goto CLEANUP; + } + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxPsChanged,(jlong)context, + (jint)status, + (jint)frequency, + jNameString, + (jint)repertoire); + + + if (env->ExceptionOccurred()) { + LOGE("nativeJFmRx_PS_Callback: ExceptionOccurred"); + goto CLEANUP; + } + + if(jNameString!= NULL) + env->DeleteLocalRef(jNameString); + + if(attachedThread == true) + g_jVM->DetachCurrentThread(); + + return ; + + CLEANUP: + LOGE("nativeJFmRx_PS_Callback: Exiting due to failure"); + + if(jNameString!= NULL) + env->DeleteLocalRef(jNameString); + if (env->ExceptionOccurred()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + + if(attachedThread == true) + g_jVM->DetachCurrentThread(); + return ; + } + + + void nativeJFmRx_Callback(long context, int status, + int command, long value) + { + + V4L2_JBTL_LOGI("nativeJFmRx_Callback: Entered, "); + + JNIEnv* env = NULL; + bool attachedThread = false; + int jRet ; + +/* check whether the current thread is attached to a virtual machine instance, +if no only then try to attach to the current thread. */ + + jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); + + if(jRet < 0) + { + V4L2_JBTL_LOGI("failed to get JNI env,assuming native thread"); + jRet = g_jVM->AttachCurrentThread((&env), NULL); + + if(jRet != JNI_OK) + { + V4L2_JBTL_LOGI("failed to atatch to current thread %d",jRet); + return ; + } + + attachedThread = true; + } + + if(env == NULL) + { + V4L2_JBTL_LOGD("nativeJFmRx_Callback: Entered, env is null"); + } + + + switch (command) + { + + case FM_RX_CMD_ENABLE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdEnable,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_DISABLE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdDisable,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_BAND: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetBand,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_BAND: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetBand,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_MONO_STEREO_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetMonoStereoMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_MONO_STEREO_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetMonoStereoMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_MUTE_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetMuteMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_MUTE_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetMuteMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_RF_DEPENDENT_MUTE_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_RF_DEPENDENT_MUTE_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_RSSI_THRESHOLD: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRssiThreshhold,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_RSSI_THRESHOLD: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRssiThreshhold,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_DEEMPHASIS_FILTER: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_DEEMPHASIS_FILTER: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_VOLUME: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetVolume,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_VOLUME: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetVolume,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_TUNE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdTune,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_TUNED_FREQUENCY: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetTunedFrequency,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SEEK: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSeek,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_STOP_SEEK: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdStopSeek,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_RSSI: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRssi,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_ENABLE_RDS: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdEnableRds,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_DISABLE_RDS: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdDisableRds,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_RDS_SYSTEM: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRdsSystem,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_RDS_SYSTEM: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRdsSystem,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_RDS_GROUP_MASK: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRdsGroupMask,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_RDS_GROUP_MASK: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRdsGroupMask,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_RDS_AF_SWITCH_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_RDS_AF_SWITCH_MODE: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_ENABLE_AUDIO: + V4L2_JBTL_LOGD("nativeJFmRx_Callback: at FM_RX_CMD_ENABLE_AUDIO step 1"); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdEnableAudio,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + V4L2_JBTL_LOGD("nativeJFmRx_Callback: at FM_RX_CMD_ENABLE_AUDIO step 2"); + break; + + case FM_RX_CMD_DISABLE_AUDIO: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdDisableAudio, (jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_CHANGE_AUDIO_TARGET: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdChangeAudioTarget,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_SET_CHANNEL_SPACING: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetChannelSpacing,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_CHANNEL_SPACING: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetChannelSpacing,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_GET_FW_VERSION: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetFwVersion,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_IS_CHANNEL_VALID: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdIsValidChannel,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_COMPLETE_SCAN_PROGRESS: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + case FM_RX_CMD_STOP_COMPLETE_SCAN: + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdStopCompleteScan,(jlong)context, + (jint)status, + (jint)command, + (jlong)value); + break; + + default: + V4L2_JBTL_LOGD("nativeJFmRx_Callback:FM_RX_EVENT_CMD_DONE,unhendeld event"); + break; + } + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGD("nativeJFmRx_Callback: ExceptionOccurred"); + goto EXCEPTION; + } + + V4L2_JBTL_LOGD("nativeJFmRx_Callback: Exiting, Calling DetachCurrentThread at the END"); + if(attachedThread == true) + g_jVM->DetachCurrentThread(); + + return; + +EXCEPTION: + + /*Delete Jni Local refrencece */ + V4L2_JBTL_LOGD("nativeJFmRx_Callback: Exiting due to failure"); + if (env->ExceptionOccurred()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + if(attachedThread == true) + g_jVM->DetachCurrentThread(); + + return; + + } + + +} //extern c + + +/********************************************************************** +* Callback registration + +***********************************************************************/ +#define VERIFY_METHOD_ID(methodId) \ + if (!_VerifyMethodId(methodId, #methodId)) { \ + V4L2_JBTL_LOGD("Error obtaining method id for %s", #methodId); \ + return; \ + } + +static bool _VerifyMethodId(jmethodID methodId, const char *name) +{ + bool result = true; + + if (methodId == NULL) + { + V4L2_JBTL_LOGD("_VerifyMethodId: Failed getting method id of %s", name); + result = false; + } + + return result; +} + + + +void nativeJFmRx_ClassInitNative(JNIEnv* env, jclass clazz){ + V4L2_JBTL_LOGD("nativeJFmRx_ClassInitNative: Entered"); + + if (NULL == env) + { + V4L2_JBTL_LOGD("nativeJFmRx_ClassInitNative: NULL == env"); + } + + env->GetJavaVM(&g_jVM); + + + + /* Save class information in global reference in order to prevent class unloading */ + _sJClass = (jclass)env->NewGlobalRef(clazz); + + + V4L2_JBTL_LOGI("nativeJFmRx_ClassInitNative: Obtaining method IDs"); + + _sMethodId_nativeCb_fmRxRadioText = env->GetStaticMethodID(clazz, + "nativeCb_fmRxRadioText", + "(JIZ[BIII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxRadioText); + + + _sMethodId_nativeCb_fmRxPsChanged = env->GetStaticMethodID(clazz, + "nativeCb_fmRxPsChanged", + "(JII[BI)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxPsChanged); + + /* Complete parsing of the RDS data has not been implemented yet + Commented the FM RX RDS callbacks functionality start*/ + + #if 0 + _sMethodId_nativeCb_fmRxRawRDS = env->GetStaticMethodID(clazz, + "nativeCb_fmRxRawRDS", + "(JII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxRawRDS); + + + _sMethodId_nativeCb_fmRxPiCodeChanged = env->GetStaticMethodID(clazz, + "nativeCb_fmRxPiCodeChanged", + "(JII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxPiCodeChanged); + + + _sMethodId_nativeCb_fmRxPtyCodeChanged = env->GetStaticMethodID(clazz, + "nativeCb_fmRxPtyCodeChanged", + "(JII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxPtyCodeChanged); + + + + + _sMethodId_nativeCb_fmRxMonoStereoModeChanged = env->GetStaticMethodID(clazz, + "nativeCb_fmRxMonoStereoModeChanged", + "(JII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxMonoStereoModeChanged); + + + _sMethodId_nativeCb_fmRxAudioPathChanged = env->GetStaticMethodID(clazz, + "nativeCb_fmRxAudioPathChanged", + "(JI)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAudioPathChanged); + + + _sMethodId_nativeCb_fmRxAfSwitchFreqFailed = env->GetStaticMethodID(clazz, + "nativeCb_fmRxAfSwitchFreqFailed", + "(JIIII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfSwitchFreqFailed); + + + _sMethodId_nativeCb_fmRxAfSwitchStart = env->GetStaticMethodID(clazz, + "nativeCb_fmRxAfSwitchStart", + "(JIIII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfSwitchStart); + + + _sMethodId_nativeCb_fmRxAfSwitchComplete = env->GetStaticMethodID(clazz, + "nativeCb_fmRxAfSwitchComplete", + "(JIIII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfSwitchComplete); + + + _sMethodId_nativeCb_fmRxAfListChanged = env->GetStaticMethodID(clazz, + "nativeCb_fmRxAfListChanged", + "(JII[BI)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfListChanged); + +#endif + /*Commented the FM RX RDS callbacks functionality end*/ + + + _sMethodId_nativeCb_fmRxCmdEnable = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdEnable", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdEnable); + + + _sMethodId_nativeCb_fmRxCmdDisable = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdDisable", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDisable); + + _sMethodId_nativeCb_fmRxCmdEnableAudio = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdEnableAudio", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdEnableAudio); + + + + _sMethodId_nativeCb_fmRxCmdChangeAudioTarget = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdChangeAudioTarget", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdChangeAudioTarget); + + + _sMethodId_nativeCb_fmRxCmdSetBand = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetBand", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetBand); + + _sMethodId_nativeCb_fmRxCmdGetBand = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetBand", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetBand); + + + + _sMethodId_nativeCb_fmRxCmdSetMonoStereoMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetMonoStereoMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetMonoStereoMode); + + + + _sMethodId_nativeCb_fmRxCmdGetMonoStereoMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetMonoStereoMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetMonoStereoMode); + + + + _sMethodId_nativeCb_fmRxCmdGetMuteMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetMuteMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetMuteMode); + + + + _sMethodId_nativeCb_fmRxCmdSetMuteMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetMuteMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetMuteMode); + + + + _sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetRfDependentMuteMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode); + + + + _sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetRfDependentMuteMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode); + + + + _sMethodId_nativeCb_fmRxCmdSetRssiThreshhold = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetRssiThreshhold", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRssiThreshhold); + + + + _sMethodId_nativeCb_fmRxCmdGetRssiThreshhold = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetRssiThreshhold", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRssiThreshhold); + + + + _sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetDeemphasisFilter", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter); + + + _sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetDeemphasisFilter", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter); + + + + _sMethodId_nativeCb_fmRxCmdSetVolume = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetVolume", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetVolume); + + + + _sMethodId_nativeCb_fmRxCmdGetVolume = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetVolume", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetVolume); + + _sMethodId_nativeCb_fmRxCmdSetChannelSpacing = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetChannelSpacing", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetChannelSpacing); + + + + _sMethodId_nativeCb_fmRxCmdGetChannelSpacing = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetChannelSpacing", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetChannelSpacing); + + + + _sMethodId_nativeCb_fmRxCmdTune = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdTune", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdTune); + + + _sMethodId_nativeCb_fmRxCmdGetTunedFrequency = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetTunedFrequency", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetTunedFrequency); + + + _sMethodId_nativeCb_fmRxCmdSeek = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSeek", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSeek); + + + + _sMethodId_nativeCb_fmRxCmdStopSeek = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdStopSeek", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdStopSeek); + + + _sMethodId_nativeCb_fmRxCmdGetRssi = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetRssi", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRssi); + + + _sMethodId_nativeCb_fmRxCmdEnableRds = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdEnableRds", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdEnableRds); + + + _sMethodId_nativeCb_fmRxCmdDisableRds = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdDisableRds", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDisableRds); + + + _sMethodId_nativeCb_fmRxCmdGetRdsSystem = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetRdsSystem", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRdsSystem); + + + + _sMethodId_nativeCb_fmRxCmdSetRdsSystem = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetRdsSystem", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRdsSystem); + + + _sMethodId_nativeCb_fmRxCmdSetRdsGroupMask = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetRdsGroupMask", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRdsGroupMask); + + + _sMethodId_nativeCb_fmRxCmdGetRdsGroupMask = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetRdsGroupMask", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRdsGroupMask); + + + _sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdSetRdsAfSwitchMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode); + + + _sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetRdsAfSwitchMode", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode); + + + _sMethodId_nativeCb_fmRxCmdDisableAudio = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdDisableAudio", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDisableAudio); + + _sMethodId_nativeCb_fmRxCmdDestroy = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdDestroy", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDestroy); + + + _sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration= env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdChangeDigitalAudioConfiguration", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration); + + /* Complete scan in V4l2 FM driver is not implemented yet + Commented the FM RX Completescan functionality start*/ + + /*_sMethodId_nativeCb_fmRxCompleteScanDone = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCompleteScanDone", + "(JII[I)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCompleteScanDone);*/ + + /*Commented the FM RX Completescan functionality end*/ + + + _sMethodId_nativeCb_fmRxCmdGetFwVersion = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetFwVersion", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetFwVersion); + + _sMethodId_nativeCb_fmRxCmdIsValidChannel = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdIsValidChannel", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdIsValidChannel); + + + _sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdGetCompleteScanProgress", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress); + + _sMethodId_nativeCb_fmRxCmdStopCompleteScan = env->GetStaticMethodID(clazz, + "nativeCb_fmRxCmdStopCompleteScan", + "(JIIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdStopCompleteScan); + + V4L2_JBTL_LOGD("nativeJFmRx_ClassInitNative:Exiting"); +} + +static JNINativeMethod JFmRxNative_sMethods[] = { + /* name, signature, funcPtr */ + {"nativeJFmRx_ClassInitNative", "()V", (void*)nativeJFmRx_ClassInitNative}, + {"nativeJFmRx_Create", "(Lcom/ti/jfm/core/JFmContext;)I", (void*)nativeJFmRx_Create}, + {"nativeJFmRx_Destroy", "(J)I", (void*)nativeJFmRx_Destroy}, + {"nativeJFmRx_Enable", "(J)I", (void*)nativeJFmRx_Enable}, + {"nativeJFmRx_Disable", "(J)I", (void*)nativeJFmRx_Disable}, + {"nativeJFmRx_SetBand","(JI)I", (void*)nativeJFmRx_SetBand}, + {"nativeJFmRx_GetBand","(J)I", (void*)nativeJFmRx_GetBand}, + {"nativeJFmRx_Tune","(JI)I", (void*)nativeJFmRx_Tune}, + {"nativeJFmRx_GetTunedFrequency","(J)I", (void*)nativeJFmRx_GetTunedFrequency}, + {"nativeJFmRx_SetMonoStereoMode","(JI)I", (void*)nativeJFmRx_SetMonoStereoMode}, + {"nativeJFmRx_GetMonoStereoMode","(J)I", (void*)nativeJFmRx_GetMonoStereoMode}, + {"nativeJFmRx_SetMuteMode","(JI)I", (void*)nativeJFmRx_SetMuteMode}, + {"nativeJFmRx_GetMuteMode","(J)I", (void*)nativeJFmRx_GetMuteMode}, + {"nativeJFmRx_SetRssiThreshold","(JI)I", (void*)nativeJFmRx_SetRssiThreshold}, + {"nativeJFmRx_GetRssiThreshold","(J)I", (void*)nativeJFmRx_GetRssiThreshold}, + {"nativeJFmRx_GetRssi","(J)I", (void*)nativeJFmRx_GetRssi}, + {"nativeJFmRx_SetVolume","(JI)I", (void*)nativeJFmRx_SetVolume}, + {"nativeJFmRx_GetVolume","(J)I", (void*)nativeJFmRx_GetVolume}, + {"nativeJFmRx_SetChannelSpacing","(JI)I", (void*)nativeJFmRx_SetChannelSpacing}, + {"nativeJFmRx_GetChannelSpacing","(J)I", (void*)nativeJFmRx_GetChannelSpacing}, + {"nativeJFmRx_SetDeEmphasisFilter","(JI)I", (void*)nativeJFmRx_SetDeEmphasisFilter}, + {"nativeJFmRx_GetDeEmphasisFilter","(J)I", (void*)nativeJFmRx_GetDeEmphasisFilter}, + {"nativeJFmRx_Seek","(JI)I", (void*)nativeJFmRx_Seek}, + {"nativeJFmRx_StopSeek","(J)I", (void*)nativeJFmRx_StopSeek}, + {"nativeJFmRx_EnableRDS","(J)I", (void*)nativeJFmRx_EnableRDS}, + {"nativeJFmRx_DisableRDS","(J)I", (void*)nativeJFmRx_DisableRDS}, + {"nativeJFmRx_EnableAudioRouting","(J)I", (void*)nativeJFmRx_EnableAudioRouting}, + {"nativeJFmRx_DisableAudioRouting","(J)I", (void*)nativeJFmRx_DisableAudioRouting}, + {"nativeJFmRx_SetRdsAfSwitchMode","(JI)I", (void*)nativeJFmRx_SetRdsAfSwitchMode}, + {"nativeJFmRx_GetRdsAfSwitchMode","(J)I", (void*)nativeJFmRx_GetRdsAfSwitchMode}, + {"nativeJFmRx_ChangeAudioTarget","(JII)I",(void*)nativeJFmRx_ChangeAudioTarget}, + {"nativeJFmRx_ChangeDigitalTargetConfiguration","(JI)I",(void*)nativeJFmRx_ChangeDigitalTargetConfiguration}, + {"nativeJFmRx_SetRfDependentMuteMode","(JI)I",(void*)nativeJFmRx_SetRfDependentMuteMode}, + {"nativeJFmRx_GetRfDependentMute","(J)I",(void*)nativeJFmRx_GetRfDependentMute}, + {"nativeJFmRx_SetRdsSystem","(JI)I",(void*)nativeJFmRx_SetRdsSystem}, + {"nativeJFmRx_GetRdsSystem","(J)I",(void*)nativeJFmRx_GetRdsSystem}, + {"nativeJFmRx_SetRdsGroupMask","(JJ)I",(void*)nativeJFmRx_SetRdsGroupMask}, + {"nativeJFmRx_GetRdsGroupMask","(J)I",(void*)nativeJFmRx_GetRdsGroupMask}, + {"nativeJFmRx_CompleteScan","(J)I",(void*)nativeJFmRx_CompleteScan}, + {"nativeJFmRx_IsValidChannel","(J)I",(void*)nativeJFmRx_IsValidChannel}, + {"nativeJFmRx_GetFwVersion","(J)I",(void*)nativeJFmRx_GetFwVersion}, + {"nativeJFmRx_GetCompleteScanProgress","(J)I",(void*)nativeJFmRx_GetCompleteScanProgress}, + {"nativeJFmRx_StopCompleteScan","(J)I",(void*)nativeJFmRx_StopCompleteScan}, + +}; + +/**********************************/ + + +/* + * Register several native methods for one class. + */ +static int registerNatives(JNIEnv* env, const char* className, + JNINativeMethod* gMethods, int numMethods) +{ + jclass clazz; + + clazz = env->FindClass(className); + if (clazz == NULL) { + V4L2_JBTL_LOGD("Can not find class %s\n", className); + return JNI_FALSE; + } + + if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) { + V4L2_JBTL_LOGD("Can not RegisterNatives\n"); + return JNI_FALSE; + } + + return JNI_TRUE; +} + +/*Commented the FM TX functionality start*/ + +extern JNINativeMethod JFmTxNative_sMethods[]; +extern int getTxNativeSize(); + +/*Commented the FM TX functionality end*/ + +jint JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + V4L2_JBTL_LOGD("OnLoad"); + + if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) { + goto bail; + } + + if (!registerNatives(env, + "com/ti/jfm/core/JFmRx", + JFmRxNative_sMethods, + NELEM(JFmRxNative_sMethods))) { + goto bail; + } + + + if (!registerNatives(env, + "com/ti/jfm/core/JFmTx", + JFmTxNative_sMethods, + getTxNativeSize())) { + goto bail; + } + + + env->GetJavaVM(&g_jVM); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + +bail: + return result; +} + + diff --git a/tools/FM/service/src/jni/JFmRxNative.h b/tools/FM/service/src/jni/JFmRxNative.h new file mode 100644 index 0000000..66d4467 --- /dev/null +++ b/tools/FM/service/src/jni/JFmRxNative.h @@ -0,0 +1,172 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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. + */ + +#ifndef JFMRXNATIVE_H_ +#define JFMRXNATIVE_H_ + +extern "C" { +#include "jni.h" +} + + + +#define FM_SUCCESS 0 +#define FM_FAILED 1 +#define FM_PENDING 2 +#define FM_ERR_THREAD_CREATION_FAILED 4 + + +#define DEFAULT_RADIO_DEVICE "/dev/radio0" +#define DEFAULT_FM_ALSA_CARD "hw:CARD=0" +#define FM_BAND_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmrx_band" +#define FM_RDS_AF_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmrx_rds_af" +#define FM_RSSI_LVL_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmrx_rssi_lvl" + +#define CTL_INDEX_0 0 + +#define FM_MODE_SWITCH_CTL_NAME "Mode Switch" +#define FM_MODE_OFF 0 +#define FM_MODE_TX 1 +#define FM_MODE_RX 2 + +#define FM_BAND_SWITCH_CTL_NAME "Region Switch" +#define FM_BAND_EUROPE_US 0 +#define FM_BAND_JAPAN 1 + + +#define FM_RF_DEPENDENT_MUTE_CTL_NAME "RF Dependent Mute" +#define FM_RX_GET_RSSI_LVL_CTL_NAME "RSSI Level" +#define FM_RX_RSSI_THRESHOLD_LVL_CTL_NAME "RSSI Threshold" +#define FM_STEREO_MONO_CTL_NAME "Stereo/Mono" +#define FM_RX_DEEMPHASIS_CTL_NAME "De-emphasis Filter" +#define FM_RDS_SWITCH_CTL_NAME "RDS Switch" +#define FM_RDS_DISABLE 0 +#define FM_RDS_ENABLE 1 +#define FM_RX_RDS_OPMODE_CTL_NAME "RDS Operation Mode" +#define FM_RX_AF_SWITCH_CTL_NAME "AF Switch" + + + +typedef unsigned long FMC_U32; +typedef unsigned int FMC_UINT; +typedef unsigned char FMC_U8; + +/*------------------------------------------------------------------------------- + * FmcRdsRepertoire Type + * + * RDS Repertoire used for text data encoding and decoding + */ +typedef FMC_UINT FmcRdsRepertoire; + +#define FMC_RDS_REPERTOIRE_G0_CODE_TABLE ((FmcRdsRepertoire)0) +#define FMC_RDS_REPERTOIRE_G1_CODE_TABLE ((FmcRdsRepertoire)1) +#define FMC_RDS_REPERTOIRE_G2_CODE_TABLE ((FmcRdsRepertoire)2) + + +#define RDS_BIT_0_TO_BIT_3 0x0f +#define RDS_BIT_4_TO_BIT_7 0xf0 + + +/******************************************************************************** + * + * Events sent to the application + * + *******************************************************************************/ + +/*------------------------------------------------------------------------------- + * FmRxEventType structure + * + */ +typedef FMC_UINT FmRxEventType; +typedef FMC_UINT FmRxStatus; + + +/*------------------------------------------------------------------------------- + * FmRxCmdType structure + * + */ +typedef FMC_UINT FmRxCmdType; + +#define FM_RX_CMD_ENABLE ((FmRxCmdType)0) /* Enable command */ +#define FM_RX_CMD_DISABLE ((FmRxCmdType)1) /* Disable command */ +#define FM_RX_CMD_SET_BAND ((FmRxCmdType)2) /* Set Band command */ +#define FM_RX_CMD_GET_BAND ((FmRxCmdType)3) /* Get Band command */ +#define FM_RX_CMD_SET_MONO_STEREO_MODE ((FmRxCmdType)4) /* Set Mono/Stereo command */ +#define FM_RX_CMD_GET_MONO_STEREO_MODE ((FmRxCmdType)5) /* Get Mono/Stereo command */ +#define FM_RX_CMD_SET_MUTE_MODE ((FmRxCmdType)6) /* Set Mute mode command */ +#define FM_RX_CMD_GET_MUTE_MODE ((FmRxCmdType)7) /* Get Mute mode command */ +#define FM_RX_CMD_SET_RF_DEPENDENT_MUTE_MODE ((FmRxCmdType)8) /* Set RF-Dependent Mute Mode command */ +#define FM_RX_CMD_GET_RF_DEPENDENT_MUTE_MODE ((FmRxCmdType)9) /* Get RF-Dependent Mute Mode command */ +#define FM_RX_CMD_SET_RSSI_THRESHOLD ((FmRxCmdType)10) /* Set RSSI Threshold command */ +#define FM_RX_CMD_GET_RSSI_THRESHOLD ((FmRxCmdType)11) /* Get RSSI Threshold command */ +#define FM_RX_CMD_SET_DEEMPHASIS_FILTER ((FmRxCmdType)12) /* Set De-Emphassi Filter command */ +#define FM_RX_CMD_GET_DEEMPHASIS_FILTER ((FmRxCmdType)13) /* Get De-Emphassi Filter command */ +#define FM_RX_CMD_SET_VOLUME ((FmRxCmdType)14) /* Set Volume command */ +#define FM_RX_CMD_GET_VOLUME ((FmRxCmdType)15) /* Get Volume command */ +#define FM_RX_CMD_TUNE ((FmRxCmdType)16) /* Tune command */ +#define FM_RX_CMD_GET_TUNED_FREQUENCY ((FmRxCmdType)17) /* Get Tuned Frequency command */ +#define FM_RX_CMD_SEEK ((FmRxCmdType)18) /* Seek command */ +#define FM_RX_CMD_STOP_SEEK ((FmRxCmdType)19) /* Stop Seek command */ +#define FM_RX_CMD_GET_RSSI ((FmRxCmdType)20) /* Get RSSI command */ +#define FM_RX_CMD_ENABLE_RDS ((FmRxCmdType)21) /* Enable RDS command */ +#define FM_RX_CMD_DISABLE_RDS ((FmRxCmdType)22) /* Disable RDS command */ +#define FM_RX_CMD_SET_RDS_SYSTEM ((FmRxCmdType)23) /* Set RDS System command */ +#define FM_RX_CMD_GET_RDS_SYSTEM ((FmRxCmdType)24) /* Get RDS System command */ +#define FM_RX_CMD_SET_RDS_GROUP_MASK ((FmRxCmdType)25) /* Set RDS groups to be recieved */ +#define FM_RX_CMD_GET_RDS_GROUP_MASK ((FmRxCmdType)26) /* Get RDS groups to be recieved*/ +#define FM_RX_CMD_SET_RDS_AF_SWITCH_MODE ((FmRxCmdType)27) /* Set AF Switch Mode command */ +#define FM_RX_CMD_GET_RDS_AF_SWITCH_MODE ((FmRxCmdType)28) /* Get AF Switch Mode command */ +#define FM_RX_CMD_ENABLE_AUDIO ((FmRxCmdType)29) /* Set Audio Routing command */ +#define FM_RX_CMD_DISABLE_AUDIO ((FmRxCmdType)30) /* Get Audio Routing command */ +#define FM_RX_CMD_DESTROY ((FmRxCmdType)31) /* Destroy command */ +#define FM_RX_CMD_CHANGE_AUDIO_TARGET ((FmRxCmdType)32) /* Change the audio target*/ +#define FM_RX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION ((FmRxCmdType)33) /* Change the digital target configuration*/ +#define FM_RX_INIT_ASYNC ((FmRxCmdType)34) /* */ +#define FM_RX_CMD_INIT ((FmRxCmdType)35) /* */ +#define FM_RX_CMD_DEINIT ((FmRxCmdType)36) /* */ +#define FM_RX_CMD_SET_CHANNEL_SPACING ((FmRxCmdType)37) /* */ +#define FM_RX_CMD_GET_CHANNEL_SPACING ((FmRxCmdType)38) /* */ +#define FM_RX_CMD_GET_FW_VERSION ((FmRxCmdType)39) /*Gets the FW version */ +#define FM_RX_CMD_IS_CHANNEL_VALID ((FmRxCmdType)40) /*Verify that the tuned channel is valid*/ +#define FM_RX_CMD_COMPLETE_SCAN ((FmRxCmdType)41) /*Perfrom Complete Scan on the selected Band*/ +#define FM_RX_CMD_COMPLETE_SCAN_PROGRESS ((FmRxCmdType)42) +#define FM_RX_CMD_STOP_COMPLETE_SCAN ((FmRxCmdType)43) +#define FM_RX_LAST_API_CMD (FM_RX_CMD_STOP_COMPLETE_SCAN) +#define FM_RX_CMD_NONE 0xFFFFFFFF + + +namespace android { + +extern JNIEnv *getJBtlEnv(); +extern void setJBtlEnv(JNIEnv *env); + +} + +/* Presently android videodev2.h is from k2.6.35 so remove below struct when + * android header files moves to k3.0+ kernel header + * */ +struct ti_v4l2_hw_freq_seek { + __u32 tuner; + enum v4l2_tuner_type type; + __u32 seek_upward; + __u32 wrap_around; + __u32 spacing; + __u32 reserved[7]; +}; + +#define V4L2_TUNER_SUB_RDS 0x0010 +#endif /* JFMRXNATIVE_H_ */ diff --git a/tools/FM/service/src/jni/JFmTxNative.cpp b/tools/FM/service/src/jni/JFmTxNative.cpp new file mode 100644 index 0000000..e56d269 --- /dev/null +++ b/tools/FM/service/src/jni/JFmTxNative.cpp @@ -0,0 +1,1804 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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. + */ + +#include "android_runtime/AndroidRuntime.h" +#include "jni.h" +#include "JNIHelp.h" +#include "v4l2_JbtlLog.h" +#include "JFmTxNative.h" + +#include <stdlib.h> + +#define LOG_TAG "JFmTxNative" +#include <cutils/properties.h> + +using namespace android; +static int radio_fd; +extern long jContext; + +#undef VIDIOC_S_MODULATOR +#define VIDIOC_S_MODULATOR 1078220343 + +extern "C" { +#include <stdio.h> +#include <fcntl.h> +#include <asoundlib.h> +#include <linux/videodev.h> +#include <math.h> +#include <pthread.h> +#include <errno.h> +#include <string.h> + +void nativeJFmTx_Callback(long context, int status, + int command, long value); +extern void MCP_HAL_LOG_EnableLogToAndroid(const char *app_name); + +} //extern "C" + +static jclass _sJClass; +static JavaVM *g_jVM = NULL; + +static jmethodID _sMethodId_nativeCb_fmTxCmdEnable; +static jmethodID _sMethodId_nativeCb_fmTxCmdDisable; +static jmethodID _sMethodId_nativeCb_fmTxCmdDestroy; +static jmethodID _sMethodId_nativeCb_fmTxCmdTune; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetTunedFrequency; +static jmethodID _sMethodId_nativeCb_fmTxCmdStartTransmission; +static jmethodID _sMethodId_nativeCb_fmTxCmdStopTransmission; +static jmethodID _sMethodId_nativeCb_fmTxCmdEnableRds; +static jmethodID _sMethodId_nativeCb_fmTxCmdDisableRds; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsTextRtMsg; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsTextPsMsg; +/* +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsTransmissionMode; +// static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsTransmissionMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsTrafficCodes; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsTrafficCodes; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsTextPsMsg; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsTextRtMsg; +static jmethodID _sMethodId_nativeCb_fmTxCmdWriteRdsRawData; +static jmethodID _sMethodId_nativeCb_fmTxCmdReadRdsRawData; +static jmethodID _sMethodId_nativeCb_fmTxCmdChangeAudioSource; +*/ +static jmethodID _sMethodId_nativeCb_fmTxCmdSetInterruptMask; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetMonoStereoMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetMonoStereoMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetPowerLevel; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetPowerLevel; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetMuteMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetMuteMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsAfCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsAfCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsPiCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsPiCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsPtyCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsPtyCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsTextRepertoire; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsTextRepertoire; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsPsDispalyMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsPsDispalyMode; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsPsDisplaySpeed; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsPsDisplaySpeed; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsTransmittedMask; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsTransmittedMask; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsMusicSpeechFlag ; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsMusicSpeechFlag ; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetPreEmphasisFilter; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetPreEmphasisFilter; +static jmethodID _sMethodId_nativeCb_fmTxCmdSetRdsExtendedCountryCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdGetRdsExtendedCountryCode; +static jmethodID _sMethodId_nativeCb_fmTxCmdChangeDigitalAudioConfiguration; + + + +int fm_read_transmitter_capabilities(int radio_fd) +{ + struct v4l2_capability cap; + int res; + + res = ioctl(radio_fd,VIDIOC_QUERYCAP,&cap); + if(res < 0) + { + V4L2_JBTL_LOGD("Failed to read %s capabilities\n",DEFAULT_RADIO_DEVICE); + return FM_FAILED; + } + if((cap.capabilities & V4L2_CAP_RADIO) == 0) + { + V4L2_JBTL_LOGD("%s is not radio devcie",DEFAULT_RADIO_DEVICE); + return FM_FAILED; + } + V4L2_JBTL_LOGD("\n***%s Info ****\n",DEFAULT_RADIO_DEVICE); + V4L2_JBTL_LOGD("Driver : %s\n",cap.driver); + V4L2_JBTL_LOGD("Card : %s\n",cap.card); + V4L2_JBTL_LOGD("Bus : %s\n",cap.bus_info); + V4L2_JBTL_LOGD("Capabilities : 0x%x\n",cap.capabilities); + + return FM_SUCCESS; +} + +static int nativeJFmTx_Create(JNIEnv *env,jobject obj,jobject jContextValue) +{ + int fmStatus ; + + V4L2_JBTL_LOGD("Java_JFmRx_nativeJFmRx_Create(): Entered"); + + radio_fd = open(DEFAULT_RADIO_DEVICE, O_RDWR); + if(radio_fd < 0) + { + V4L2_JBTL_LOGD("Unable to open %s ..\n",DEFAULT_RADIO_DEVICE); + jniThrowIOException(env, errno); + return FM_FAILED; + } + + fmStatus = fm_read_transmitter_capabilities(radio_fd); + if(fmStatus< 0) + { + close(radio_fd); + return fmStatus; + } + + V4L2_JBTL_LOGD("nativeJFmRx_create:Exiting Successfully"); + + return fmStatus; +return 0; +} + +static jint nativeJFmTx_Destroy(JNIEnv *env, jobject obj,jlong jContextValue) +{ + +return 0; + +} + + + +static int nativeJFmTx_Enable(JNIEnv *env, jobject obj, jlong jContextValue) +{ + int status ; + struct v4l2_modulator vm; + + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Entered"); + + jContext = jContextValue; + vm.index = 0; + + status = ioctl(radio_fd, VIDIOC_S_MODULATOR, &vm); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to Enable FM\n"); + return status; + } + + V4L2_JBTL_LOGD("nativeJFmRx_enable: FM_RX_Enable() returned %d",(int)status); + nativeJFmTx_Callback(jContext,status,FM_TX_CMD_ENABLE,status); + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Exit"); + + return status; +} + + +static int nativeJFmTx_Disable(JNIEnv *env, jobject obj, jlong jContextValue) +{ + V4L2_JBTL_LOGD("nativeJFmTx_disable(): Entered"); + + jContext = jContextValue; + close(radio_fd); + nativeJFmTx_Callback(jContext,0,FM_TX_CMD_DISABLE,0); + + V4L2_JBTL_LOGD("nativeJFmTx_disable(): Exit");; + + return FM_SUCCESS; +} + + +static int nativeJFmTx_Tune(JNIEnv *env, jobject obj,jlong jContextValue,jlong user_freq) +{ + struct v4l2_frequency vf; + struct v4l2_tuner vt; + int status, div; + + V4L2_JBTL_LOGD("nativeJFmRx_tune(): Entered"); + + vf.tuner = 0; + vf.frequency = rint(user_freq * 16 + 0.5); + + status = ioctl(radio_fd, VIDIOC_S_FREQUENCY, &vf); + if(status < 0) + { + V4L2_JBTL_LOGD("Failed to tune to frequency %d\n",user_freq); + return FM_FAILED; + } + V4L2_JBTL_LOGD("Tuned to frequency %2.1f MHz\n",user_freq); + + jContext = jContextValue; +nativeJFmTx_Callback(jContext,status,FM_TX_CMD_TUNE,user_freq); + + V4L2_JBTL_LOGD("nativeJFmRx_Tune(): Exit"); + return FM_PENDING; + +} + +static int nativeJFmTx_GetTunedFrequency(JNIEnv *env, jobject obj,jlong jContextValue) +{ +return 0; + +} +static int nativeJFmTx_StartTransmission(JNIEnv *env, jobject obj, jlong jContextValue) +{ + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Init"); + jContext = jContextValue; + nativeJFmTx_Callback(jContext,0,FM_TX_CMD_START_TRANSMISSION,0); + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Exit"); + +return 0; + +} + +static int nativeJFmTx_StopTransmission(JNIEnv *env, jobject obj, jlong jContextValue) +{ + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Init"); + jContext = jContextValue; + nativeJFmTx_Callback(jContext,0,FM_TX_CMD_STOP_TRANSMISSION,0); + V4L2_JBTL_LOGD("nativeJFmRx_enable(): Exit"); +return 0; + +} + + +static int nativeJFmTx_EnableRds(JNIEnv *env, jobject obj, jlong jContextValue) +{ + struct v4l2_modulator vmod; + int ret; + + V4L2_JBTL_LOGD("nativeJFmTx_EnableRds(): Init"); + vmod.index = 0; + ret = ioctl(radio_fd, VIDIOC_G_MODULATOR, &vmod); + if(ret < 0) + { + printf("Failed to get TX mode\n"); + return -1; + } + vmod.txsubchans = vmod.txsubchans | V4L2_TUNER_SUB_RDS; + + ret = ioctl(radio_fd, VIDIOC_S_MODULATOR, &vmod); + if(ret < 0) + { + printf("Failed to set TX mode\n"); + return -1; + } + + jContext = jContextValue; + nativeJFmTx_Callback(jContext,0,FM_TX_CMD_ENABLE_RDS,0); + + V4L2_JBTL_LOGD("nativeJFmTx_EnableRds(): Exit");; + +return 0; + +} + + +static int nativeJFmTx_DisableRds(JNIEnv *env, jobject obj, jlong jContextValue) +{ + struct v4l2_modulator vmod; + int ret; + + V4L2_JBTL_LOGD("nativeJFmTx_DisableRds(): Init"); + vmod.index = 0; + ret = ioctl(radio_fd, VIDIOC_G_MODULATOR, &vmod); + if(ret < 0) + { + printf("Failed to get TX mode\n"); + return -1; + } + vmod.txsubchans = vmod.txsubchans & ~V4L2_TUNER_SUB_RDS; + + ret = ioctl(radio_fd, VIDIOC_S_MODULATOR, &vmod); + if(ret < 0) + { + printf("Failed to set TX mode\n"); + return -1; + } + + jContext = jContextValue; + nativeJFmTx_Callback(jContext,0,FM_TX_CMD_DISABLE_RDS,0); + + V4L2_JBTL_LOGD("nativeJFmTx_DisableRds(): Exit");; + +return 0; +} + +static int nativeJFmTx_SetRdsTransmissionMode(JNIEnv *env, jobject obj, jlong jContextValue,jint mode) +{ + +/* FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_SetRdsTransmissionMode(): Entered"); + + FmTxStatus status =FM_TX_SetRdsTransmissionMode(fmTxContext,(FmTxRdsTransmissionMode)mode); + LOGD("nativeJFmTx_SetRdsTransmissionMode: FM_TX_SetRdsTransmissionMode() returned %d",(int)status); +*/ + LOGD("nativeJFmTx_SetRdsTransmissionMode(): Exit"); + return 0; +} + +/* +static int nativeJFmTx_GetRdsTransmissionMode(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsTransmissionMode(): Entered"); + + FmTxStatus status =FM_TX_GetRdsTransmissionMode(fmTxContext); + LOGD("nativeJFmTx_GetRdsTransmissionMode: FM_TX_GetRdsTransmissionMode() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsTransmissionMode(): Exit"); + return status; +} + +*/ +static int nativeJFmTx_SetRdsTextPsMsg(JNIEnv *env, jobject obj, jlong jContextValue,jstring psString,jint length) +{ + +/* FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + const char *psStr = (char*) env->GetStringUTFChars(psString, &iscopy); + + LOGD("nativeJFmTx_SetRdsTextPsMsg(): Entered"); + LOGD("nativeJFmTx_SetRdsTextPsMsg():--> psStr= %s",psStr); + + FmTxStatus status =FM_TX_SetRdsTextPsMsg(fmTxContext,(const FMC_U8 *)psStr,(FMC_UINT)length); + LOGD("nativeJFmTx_SetRdsTextPsMsg: FM_TX_SetRdsTextPsMsg() returned %d",(int)status); +*/ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + jboolean iscopy; + int res; + char rds_text[100]; + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_PS_NAME; + vctrls.string = (char*) env->GetStringUTFChars(psString, &iscopy); + vctrls.size = strlen(rds_text) + 1; + vec.controls = &vctrls; + + LOGE("Entered RDS PS Name is - %s\n",vctrls.string); + res = ioctl(radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + LOGE("Failed to set FM Tx RDS Radio PS Name\n"); + return res; + } + + LOGD("nativeJFmTx_SetRdsTextPsMsg(): Exit"); + + return res; +} +/* +static int nativeJFmTx_GetRdsTextPsMsg(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsTextPsMsg(): Entered"); + + FmTxStatus status =FM_TX_GetRdsTextPsMsg(fmTxContext); + LOGD("nativeJFmTx_GetRdsTextPsMsg: FM_TX_GetRdsTextPsMsg() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsTextPsMsg(): Exit"); + + return status; +} + +static int nativeJFmTx_WriteRdsRawData(JNIEnv *env, jobject obj, jlong jContextValue,jstring msg,jint length) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_WriteRdsRawData(): Entered"); + + jboolean iscopy; + const char *rawData = (char*) env->GetStringUTFChars(msg, &iscopy); + + + FmTxStatus status =FM_TX_WriteRdsRawData(fmTxContext,(const FMC_U8 *)rawData,(FMC_UINT)length); + LOGD("nativeJFmTx_WriteRdsRawData: FM_TX_WriteRdsRawData() returned %d",(int)status); + + LOGD("nativeJFmTx_WriteRdsRawData(): Exit"); + return status; +} + + +static int nativeJFmTx_ReadRdsRawData(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_ReadRdsRawData(): Entered"); + + FmTxStatus status =FM_TX_ReadRdsRawData(fmTxContext); + LOGD("nativeJFmTx_ReadRdsRawData: FM_TX_ReadRdsRawData() returned %d",(int)status); + + LOGD("nativeJFmTx_ReadRdsRawData(): Exit"); + return status; +} +*/ +static int nativeJFmTx_SetMuteMode(JNIEnv *env, jobject obj, jlong jContextValue,jint mode) +{ + + struct v4l2_control vt; + int status; + + LOGD("nativeJFmTx_SetMuteMode(): Entered"); + vt.id = V4L2_CID_AUDIO_MUTE; + + if (mode == 0) + vt.value = FM_MUTE_OFF; + else + vt.value = FM_MUTE_ON; + + status = ioctl(radio_fd,VIDIOC_S_CTRL,&vt); + if(status < 0) + { + LOGD("nativeJFmTx_SetMuteMode(): Faile returned %d\n", status); + return status; + } + + LOGD("nativeJFmTx_SetMuteMode(): Exit"); + return status; +} + +static int nativeJFmTx_GetMuteMode(JNIEnv *env, jobject obj, jlong jContextValue) +{ + LOGD("nativeJFmTx_GetMuteMode(): Entered"); + + LOGD("nativeJFmTx_GetMuteMode(): Exit"); + return 0; +} +/* +static int nativeJFmTx_SetRdsPsDisplayMode(JNIEnv *env, jobject obj, jlong jContextValue, jint displayMode) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_SetRdsPsDisplayMode(): Entered"); + + FmTxStatus status =FM_TX_SetRdsPsDisplayMode(fmTxContext,(FmcRdsPsDisplayMode)displayMode); + LOGD("nativeJFmTx_SetRdsPsDisplayMode: FM_TX_SetRdsPsDisplayMode() returned %d",(int)status); + + LOGD("nativeJFmTx_SetRdsPsDisplayMode(): Exit"); + return status; +} + + +static int nativeJFmTx_GetRdsPsDisplayMode(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsPsDisplayMode(): Entered"); + + FmTxStatus status =FM_TX_GetRdsPsDisplayMode(fmTxContext); + LOGD("nativeJFmTx_GetRdsPsDisplayMode: FM_TX_GetRdsPsDisplayMode() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsPsDisplayMode(): Exit"); + return status; +} + +*/ +static int nativeJFmTx_SetRdsTextRtMsg(JNIEnv *env, jobject obj, jlong jContextValue, jint msgType,jstring msg,jint length) +{ + + // FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + + jboolean iscopy; + const char *rtMsg = (char*) env->GetStringUTFChars(msg, &iscopy); + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int res; + char rds_text[100]; + + LOGD("nativeJFmTx_SetRdsTextRtMsg(): Entered"); + + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_RADIO_TEXT; + vctrls.string = (char*) env->GetStringUTFChars(msg, &iscopy); + vctrls.size = strlen(rtMsg) + 1; + vec.controls = &vctrls; + + LOGD("nativeJFmTx_SetRdsTextRtMsg():--> RTMsg = %s",vctrls.string); + res = ioctl(radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + LOGE("Failed to set FM Tx RDS Radio text"); + return res; + } + + // FmTxStatus status =FM_TX_SetRdsTextRtMsg(fmTxContext,(FmcRdsRtMsgType)msgType,(const FMC_U8 *)rtMsg,(FMC_UINT)length); + // LOGD("nativeJFmTx_SetRdsTextRtMsg: FM_TX_SetRdsTextRtMsg() returned %d",(int)status); + + LOGD("nativeJFmTx_SetRdsTextRtMsg(): Exit"); + return 0; +} + +/* +static int nativeJFmTx_GetRdsTextRtMsg(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsTextRtMsg(): Entered"); + FmTxStatus status =FM_TX_GetRdsTextRtMsg(fmTxContext); + LOGD("nativeJFmTx_GetRdsTextRtMsg: FM_TX_SetRdsTextRtMsg() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsTextRtMsg(): Exit"); + return status; +} + +*/ +static int nativeJFmTx_SetRdsTransmittedGroupsMask(JNIEnv *env, jobject obj, jlong jContextValue, jlong fieldMask) +{ + +/* FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_SetRdsTransmittedGroupsMask(): Entered"); + + FmTxStatus status =FM_TX_SetRdsTransmittedGroupsMask(fmTxContext,(FmTxRdsTransmittedGroupsMask)fieldMask); + LOGD("nativeJFmTx_SetRdsTransmittedGroupsMask: FM_TX_SetRdsTransmittedGroupsMask() returned %d",(int)status); +*/ + LOGD("nativeJFmTx_SetRdsTransmittedGroupsMask(): Exit"); + return 0; +} + +/* +static int nativeJFmTx_GetRdsTransmittedGroupsMask(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsTransmittedGroupsMask(): Entered"); + + FmTxStatus status =FM_TX_GetRdsTransmittedGroupsMask(fmTxContext); + LOGD("nativeJFmTx_GetRdsTransmittedGroupsMask: FM_TX_GetRdsTransmittedGroupsMask() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsTransmittedGroupsMask(): Exit"); + return status; +} + +static int nativeJFmTx_SetRdsTrafficCodes(JNIEnv *env, jobject obj, jlong jContextValue, jint taCode,jint tpCode) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_SetRdsTrafficCodes(): Entered"); + + FmTxStatus status =FM_TX_SetRdsTrafficCodes(fmTxContext,(FmcRdsTaCode)taCode,(FmcRdsTpCode)tpCode); + LOGD("nativeJFmTx_SetRdsTrafficCodes: FM_TX_SetRdsTrafficCodes() returned %d",(int)status); + + LOGD("nativeJFmTx_SetRdsTrafficCodes(): Exit"); + return status; +} + +static int nativeJFmTx_GetRdsTrafficCodes(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsTrafficCodes(): Entered"); + + FmTxStatus status =FM_TX_GetRdsTrafficCodes(fmTxContext); + LOGD("nativeJFmTx_GetRdsTrafficCodes: FM_TX_GetRdsTrafficCodes() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsTrafficCodes(): Exit"); + return status; +} + +static int nativeJFmTx_SetRdsMusicSpeechFlag(JNIEnv *env, jobject obj, jlong jContextValue, jint musicSpeechFlag) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_SetRdsMusicSpeechFlag(): Entered"); + + FmTxStatus status =FM_TX_SetRdsMusicSpeechFlag(fmTxContext,(FmcRdsMusicSpeechFlag)musicSpeechFlag); + LOGD("nativeJFmTx_SetRdsMusicSpeechFlag: FM_TX_SetRdsMusicSpeechFlag() returned %d",(int)status); + + LOGD("nativeJFmTx_SetRdsMusicSpeechFlag(): Exit"); + return status; +} + + +static int nativeJFmTx_GetRdsMusicSpeechFlag(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsMusicSpeechFlag(): Entered"); + + FmTxStatus status =FM_TX_GetRdsMusicSpeechFlag(fmTxContext); + LOGD("nativeJFmTx_GetRdsMusicSpeechFlag: FM_TX_GetRdsMusicSpeechFlag() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsMusicSpeechFlag(): Exit"); + return status; +} + +static int nativeJFmTx_SetRdsExtendedCountryCode(JNIEnv *env, jobject obj, jlong jContextValue, jint ecc) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_SetRdsExtendedCountryCode(): Entered"); + + FmTxStatus status =FM_TX_SetRdsECC(fmTxContext,(FmcRdsExtendedCountryCode)ecc); + LOGD("nativeJFmTx_SetRdsExtendedCountryCode: FM_TX_SetRdsECC() returned %d",(int)status); + + LOGD("nativeJFmTx_SetRdsExtendedCountryCode(): Exit"); + return status; +} + +static int nativeJFmTx_GetRdsExtendedCountryCode(JNIEnv *env, jobject obj, jlong jContextValue) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_GetRdsExtendedCountryCode(): Entered"); + + FmTxStatus status =FM_TX_GetRdsECC(fmTxContext); + LOGD("nativeJFmTx_GetRdsExtendedCountryCode: FM_TX_GetRdsECC() returned %d",(int)status); + + LOGD("nativeJFmTx_GetRdsExtendedCountryCode(): Exit"); + return status; +} + +static int nativeJFmTx_ChangeAudioSource(JNIEnv *env, jobject obj, jlong jContextValue,jint txSource,jint eSampleFreq) +{ + + FmTxContext * fmTxContext = (FmTxContext *)jContextValue; + LOGD("nativeJFmTx_ChangeAudioSource(): Entered"); + + LOGD(" txSource = %d , Sampling frequency = %d ",(int) txSource, (int) eSampleFreq); + FmTxStatus status =FM_TX_ChangeAudioSource(fmTxContext,(FmTxAudioSource)txSource,(ECAL_SampleFrequency)eSampleFreq); + LOGD("nativeJFmTx_ChangeAudioSource: FM_TX_ChangeAudioSource() returned %d",(int)status); + + LOGD("nativeJFmTx_ChangeAudioSource(): Exit"); + return status; +} +*/ + +static int nativeJFmTx_ChangeDigitalSourceConfiguration(JNIEnv *env, jobject obj, jlong jContextValue,jint eSampleFreq) +{ +return 0; + +} + + +static int nativeJFmTx_SetRdsTextRepertoire(JNIEnv *env, jobject obj, jlong jContextValue,jint repertoire) +{ +return 0; + +} + + +static int nativeJFmTx_GetRdsTextRepertoire(JNIEnv *env, jobject obj, jlong jContextValue,jint repertoire) +{ +return 0; +} + +static int nativeJFmTx_SetRdsPtyCode(JNIEnv *env, jobject obj, jlong jContextValue,jint ptyCode) +{ + int user_val; + int res; + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + + LOGE("nativeJFmTx_SetRdsPtyCode(): Entered"); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_PTY; + vctrls.value = ptyCode; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + LOGE("Failed to set FM Tx RDS PTY\n"); + return res; + } + + LOGE("nativeJFmTx_SetRdsPtyCode(): Exit"); + + return res; +} + +static int nativeJFmTx_GetRdsPtyCode(JNIEnv *env, jobject obj, jlong jContextValue,jint ptyCode) +{ + return 0; +} + +static int nativeJFmTx_SetRdsPiCode(JNIEnv *env, jobject obj, jlong jContextValue,jint piCode) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int res; + + LOGD("nativeJFmTx_SetRdsPiCode(): Enter"); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_PI; + vctrls.value = piCode; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + LOGE("Failed to set FM Tx RDS PI Code\n"); + return res; + } + + LOGD("Setting FM Tx RDS PI Code is Succesful\n"); + + return res; +} + +static int nativeJFmTx_GetRdsPiCode(JNIEnv *env, jobject obj, jlong jContextValue) +{ +return 0; +} +static int nativeJFmTx_SetRdsAfCode(JNIEnv *env, jobject obj, jlong jContextValue,jint afCode) +{ + int fd, res; + char str[10]; + + sprintf(str, "%d", afCode); + + LOGD("nativeJFmTx_SetRdsAfCode(): Enter"); + + fd = open(FMTX_RDS_AF_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + LOGD("Can't open %s", FMTX_RDS_AF_SYSFS_ENTRY); + return -1; + } + + /* Need max 6 cahrs to set AF between 75000 KHz to 108000 KHz */ + res = write(fd, str, 6); + if(res <= 0) { + LOGD("Failed to set FM TX RDS AF Frequency\n"); + goto exit; + } + + LOGD("FM RDS Alternate Frequency Set is succesfull\n"); +exit: + close(fd); + return res; +} + +static int nativeJFmTx_GetRdsAfCode(JNIEnv *env, jobject obj, jlong jContextValue) +{ + return 0; +} + +static int nativeJFmTx_SetMonoStereoMode(JNIEnv *env, jobject obj, jlong jContextValue,jint monoStereoMode) +{ +return 0; +} + +static int nativeJFmTx_GetMonoStereoMode(JNIEnv *env, jobject obj, jlong jContextValue) +{ +return 0; + +} + +static int nativeJFmTx_SetPowerLevel(JNIEnv *env, jobject obj, jlong jContextValue,jint powerLevel) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int res; + + LOGD("nativeJFmTx_SetPowerLevel(): Enter and power level = %d\n",powerLevel); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_TUNE_POWER_LEVEL; + vctrls.value = 122 - powerLevel; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + LOGE("Failed to set FM Tx power level\n"); + return res; + } + + LOGE("Setting FM Tx Power level to ---> %d\n", 122 - vctrls.value); + + return res; +} + +static int nativeJFmTx_GetPowerLevel(JNIEnv *env, jobject obj, jlong jContextValue) +{ +return 0; + +} + +static int nativeJFmTx_SetPreEmphasisFilter(JNIEnv *env, jobject obj, jlong jContextValue,jint preEmpFilter) +{ +return 0; +} + + +static int nativeJFmTx_GetPreEmphasisFilter(JNIEnv *env, jobject obj, jlong jContextValue) +{ +return 0; + +} + +static int nativeJFmTx_SetRdsPsScrollSpeed(JNIEnv *env, jobject obj, jlong jContextValue,jint scrollSpeed) +{ +return 0; + +} + +static int nativeJFmTx_GetRdsPsScrollSpeed(JNIEnv *env, jobject obj, jlong jContextValue) +{ +return 0; + +} +//################################################################################ + +// SIGNALS + +//############################################################################### + + void nativeJFmTx_Callback(long context, int status, + int command, long value) + { + + V4L2_JBTL_LOGI("nativeJFmTx_Callback: Entered, "); + + JNIEnv* env = NULL; + bool attachedThread = false; + int jRet ; + + jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); + + + if(jRet < 0) + { + V4L2_JBTL_LOGI("failed to get JNI env,assuming native thread"); + jRet = g_jVM->AttachCurrentThread((&env), NULL); + + if(jRet != JNI_OK) + { + V4L2_JBTL_LOGI("failed to atatch to current thread %d",jRet); + return ; + } + + attachedThread = true; + } + + if(env == NULL) + { + V4L2_JBTL_LOGD("nativeJFmRx_Callback: Entered, env is null"); + } + + + switch (command) { + + case FM_TX_CMD_ENABLE: + V4L2_JBTL_LOGI("FM_TX_CMD_ENABLE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdEnable, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_DISABLE: + V4L2_JBTL_LOGI("FM_TX_CMD_DISABLE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdDisable, + (jlong)context, + (jint)status, + (jint)value); + break; +/* + case FM_TX_CMD_SET_INTERRUPT_MASK: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_INTERRUPT_MASK:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetInterruptMask, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_INTERRUPT_STATUS: + V4L2_JBTL_LOGI("FM_TX_CMD_DISABLE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetInterruptMask, + (jlong)context, + (jint)status, + (jint)value); + break; + + */ + case FM_TX_CMD_START_TRANSMISSION: + V4L2_JBTL_LOGI("FM_TX_CMD_START_TRANSMISSION:Status: %d ",status); +// lptUnavailResources = (jclass *)event->p.cmdDone.v.audioOperation.ptUnavailResources; + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdStartTransmission, + (jlong)context, + (jint)status); + break; + + case FM_TX_CMD_STOP_TRANSMISSION: + V4L2_JBTL_LOGI("FM_TX_CMD_STOP_TRANSMISSION:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdStopTransmission, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_TUNE: + V4L2_JBTL_LOGI("FM_TX_CMD_TUNE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdTune, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_TUNED_FREQUENCY: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_TUNED_FREQUENCY:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetTunedFrequency, + (jlong)context, + (jint)status, + (jint)value); + break; + + + case FM_TX_CMD_SET_MONO_STEREO_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_MONO_STEREO_MODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetMonoStereoMode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_MONO_STEREO_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_MONO_STEREO_MODE:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetMonoStereoMode, + (jlong)context, + (jint)status, + (jint)value); + break; + +/* + case FM_TX_CMD_SET_POWER_LEVEL: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_POWER_LEVEL:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetPowerLevel, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_POWER_LEVEL: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_POWER_LEVEL:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetPowerLevel, + (jlong)context, + (jint)status, + (jint)value); + break; +*/ + case FM_TX_CMD_SET_MUTE_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_MUTE_MODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetMuteMode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_MUTE_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_MUTE_MODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetMuteMode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_ENABLE_RDS: + V4L2_JBTL_LOGI("FM_TX_CMD_ENABLE_RDS:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdEnableRds, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_DISABLE_RDS: + V4L2_JBTL_LOGI("FM_TX_CMD_DISABLE_RDS:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdDisableRds, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_TEXT_RT_MSG: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_TEXT_RT_MSG:Status: %d ",status); + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsTextRtMsg, + (jlong)context, + (jint)status, + (jint)value); + + break; + + case FM_TX_CMD_SET_RDS_TEXT_PS_MSG: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_TEXT_PS_MSG:Status: %d ",status); + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsTextPsMsg, + (jlong)context, + (jint)status, + (jint)value); + + break; + + case FM_TX_CMD_SET_RDS_PTY_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_PI_CODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsPtyCode, + (jlong)context, + (jint)status, + (jint)value); + break; + +/* + case FM_TX_CMD_SET_RDS_TRANSMISSION_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_TRANSMISSION_MODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsTransmissionMode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_TRANSMISSION_MODE + V4L2_JBTL_LOGI("FM_TX_CMD_GET_POWER_LEVEL:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsTransmissionMode, + (jlong)context, + (jint)status, + (jint)value); + break; +*/ + case FM_TX_CMD_SET_RDS_AF_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_AF_CODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsAfCode, + (jlong)context, + (jint)status, + (jint)value); + break; +/* + case FM_TX_CMD_GET_RDS_AF_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_POWER_LEVEL:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsAfCode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_PI_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_PI_CODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsPiCode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_PI_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_PI_CODE:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsPiCode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_PTY_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_PTY_CODE:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsPtyCode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_TEXT_REPERTOIRE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_TEXT_REPERTOIRE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsTextRepertoire, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_TEXT_REPERTOIRE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_TEXT_REPERTOIRE:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsTextRepertoire, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_PS_DISPLAY_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_PS_DISPLAY_MODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsPsDispalyMode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_PS_DISPLAY_MODE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_PS_DISPLAY_MODE:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsPsDispalyMode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_PS_DISPLAY_SPEED: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_PS_DISPLAY_SPEED:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsPsDisplaySpeed, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_PS_DISPLAY_SPEED: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_PS_DISPLAY_SPEED:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsPsDisplaySpeed, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_TEXT_PS_MSG: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_TEXT_PS_MSG:Status: %d ",status); + + jRadioTextMsg = env->NewByteArray(event->p.cmdDone.v.psMsg.len); + + if (jRadioTextMsg == NULL) + { + V4L2_JBTL_LOGE("FM_TX_CMD_GET_RDS_TEXT_PS_MSG: Failed converting elements"); + goto EXCEPTION; + } + + env->SetByteArrayRegion(jRadioTextMsg,0,event->p.cmdDone.v.psMsg.len,(jbyte*)event->p.cmdDone.v.psMsg.msg); + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGE("FM_TX_CMD_GET_RDS_TEXT_PS_MSG: env->SetByteArrayRegion failed"); + goto EXCEPTION; + } + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsTextPsMsg, + (jlong)context, + (jint)status, + (jint)event->p.cmdDone.v.psMsg.len, + jRadioTextMsg); + break; + + case FM_TX_CMD_GET_RDS_TEXT_RT_MSG: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_TEXT_RT_MSG:Status: %d ",status); + + jRadioTextMsg = env->NewByteArray(event->p.cmdDone.v.rtMsg.len); + + if (jRadioTextMsg == NULL) + { + V4L2_JBTL_LOGE("FM_TX_CMD_GET_RDS_TEXT_RT_MSG: Failed converting elements"); + goto EXCEPTION; + } + + env->SetByteArrayRegion(jRadioTextMsg,0,event->p.cmdDone.v.rtMsg.len,(jbyte*)event->p.cmdDone.v.rtMsg.msg); + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGE("FM_TX_CMD_GET_RDS_TEXT_RT_MSG: env->SetByteArrayRegion failed"); + goto EXCEPTION; + } + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsTextRtMsg, + (jlong)context, + (jint)status, + (jint)event->p.cmdDone.v.rtMsg.rtMsgType, + (jint)event->p.cmdDone.v.rtMsg.len, + jRadioTextMsg); + break; + + case FM_TX_CMD_SET_RDS_TRANSMITTED_MASK: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_TRANSMITTED_MASK:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsTransmittedMask, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_TRANSMITTED_MASK: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_TRANSMITTED_MASK:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsTransmittedMask, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_TRAFFIC_CODES: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_TRAFFIC_CODES:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsTrafficCodes, + (jlong)context, + (jint)status, + (jint)event->p.cmdDone.v.trafficCodes.taCode, + (jint)event->p.cmdDone.v.trafficCodes.tpCode); + break; + + case FM_TX_CMD_GET_RDS_TRAFFIC_CODES: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_TRAFFIC_CODES:Status: %d , taCode: %d ,tpCode: %d ",status,event->p.cmdDone.v.trafficCodes.taCode,event->p.cmdDone.v.trafficCodes.tpCode); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsTrafficCodes, + (jlong)context, + (jint)status, + (jint)event->p.cmdDone.v.trafficCodes.taCode, + (jint)event->p.cmdDone.v.trafficCodes.tpCode); + break; + + case FM_TX_CMD_SET_RDS_MUSIC_SPEECH_FLAG: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_MUSIC_SPEECH_FLAG:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsMusicSpeechFlag, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_MUSIC_SPEECH_FLAG: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_RDS_MUSIC_SPEECH_FLAG:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsMusicSpeechFlag, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_PRE_EMPHASIS_FILTER: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_PRE_EMPHASIS_FILTER:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetPreEmphasisFilter, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_PRE_EMPHASIS_FILTER: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_PRE_EMPHASIS_FILTER:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetPreEmphasisFilter, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_SET_RDS_EXTENDED_COUNTRY_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_SET_RDS_EXTENDED_COUNTRY_CODE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdSetRdsExtendedCountryCode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_GET_RDS_EXTENDED_COUNTRY_CODE: + V4L2_JBTL_LOGI("FM_TX_CMD_GET_PRE_EMPHASIS_FILTER:Status: %d,Value: %d ",status,value); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdGetRdsExtendedCountryCode, + (jlong)context, + (jint)status, + (jint)value); + break; + + case FM_TX_CMD_WRITE_RDS_RAW_DATA: + V4L2_JBTL_LOGI("FM_TX_CMD_WRITE_RDS_RAW_DATA:Status: %d ",status); + jRadioTextMsg = env->NewByteArray(event->p.cmdDone.v.rawRds.len); + + if (jRadioTextMsg == NULL) + { + V4L2_JBTL_LOGE("FM_TX_CMD_WRITE_RDS_RAW_DATA: Failed converting elements"); + goto EXCEPTION; + } + + env->SetByteArrayRegion(jRadioTextMsg,0,event->p.cmdDone.v.rawRds.len,(jbyte*)event->p.cmdDone.v.rawRds.data); + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGE("FM_TX_CMD_WRITE_RDS_RAW_DATA: env->SetByteArrayRegion failed"); + goto EXCEPTION; + } + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdWriteRdsRawData, + (jlong)context, + (jint)status, + (jint)event->p.cmdDone.v.rawRds.len, + jRadioTextMsg); + break; + + case FM_TX_CMD_READ_RDS_RAW_DATA: + V4L2_JBTL_LOGI("FM_TX_CMD_READ_RDS_RAW_DATA:Status: %d ",status); + jRadioTextMsg = env->NewByteArray(event->p.cmdDone.v.rawRds.len); + + if (jRadioTextMsg == NULL) + { + V4L2_JBTL_LOGE("FM_TX_CMD_READ_RDS_RAW_DATA: Failed converting elements"); + goto EXCEPTION; + } + + env->SetByteArrayRegion(jRadioTextMsg,0,event->p.cmdDone.v.rawRds.len,(jbyte*)event->p.cmdDone.v.rawRds.data); + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGE("FM_TX_CMD_READ_RDS_RAW_DATA: env->SetByteArrayRegion failed"); + goto EXCEPTION; + } + + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdReadRdsRawData, + (jlong)context, + (jint)status, + (jint)event->p.cmdDone.v.rawRds.len, + jRadioTextMsg); + break; + + case FM_TX_CMD_CHANGE_AUDIO_SOURCE: + V4L2_JBTL_LOGI("FM_TX_CMD_CHANGE_AUDIO_SOURCE:Status: %d ",status); + lptUnavailResources = (jclass *)event->p.cmdDone.v.audioOperation.ptUnavailResources; + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdChangeAudioSource, + (jlong)context, + (jint)status, + (jclass)lptUnavailResources); + break; +*/ + case FM_TX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION: + V4L2_JBTL_LOGI("FM_TX_CMD_CHANGE_AUDIO_SOURCE:Status: %d ",status); + env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmTxCmdChangeDigitalAudioConfiguration, + (jlong)context, + (jint)status, + (jint)value); + break; + + default: + V4L2_JBTL_LOGE("nativeJFmTx_Callback():EVENT cmdType-------------->default"); +// V4L2_JBTL_LOGE("unhandled fm cmdType %d", event->p.cmdDone.cmdType); + break; + } //end switch + + if (env->ExceptionOccurred()) { + V4L2_JBTL_LOGE("nativeJFmTx_Callback: ExceptionOccurred"); + goto EXCEPTION; + } + +/*Delete the local references + if (jRadioTextMsg!= NULL) + env->DeleteLocalRef(jRadioTextMsg); +*/ + V4L2_JBTL_LOGD("nativeJFmTx_Callback: Exiting, Calling DetachCurrentThread at the END"); + +// g_jVM->DetachCurrentThread(); + + return; + +EXCEPTION: + V4L2_JBTL_LOGE("nativeJFmTx_Callback: Exiting due to failure"); +/* if (jRadioTextMsg!= NULL) + env->DeleteLocalRef(jRadioTextMsg); +*/ + if (env->ExceptionOccurred()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + + g_jVM->DetachCurrentThread(); + + return; + + } + +/********************************************************************** +* Callback registration + +***********************************************************************/ +#define VERIFY_METHOD_ID(methodId) \ + if (!_VerifyMethodId(methodId, #methodId)) { \ + V4L2_JBTL_LOGE("Error obtaining method id for %s", #methodId); \ + return; \ + } + +static bool _VerifyMethodId(jmethodID methodId, const char *name) +{ + bool result = true; + + if (methodId == NULL) + { + V4L2_JBTL_LOGE("_VerifyMethodId: Failed getting method id of %s", name); + result = false; + } + + return result; +} + + + +void nativeJFmTx_ClassInitNative(JNIEnv* env, jclass clazz){ + V4L2_JBTL_LOGD("nativeJFmTx_ClassInitNative: Entered"); + + + if (NULL == env) + { + V4L2_JBTL_LOGE("nativeJFmRx_ClassInitNative: NULL == env"); + } + + env->GetJavaVM(&g_jVM); + + /* Save class information in global reference in order to prevent class unloading */ + _sJClass = (jclass)env->NewGlobalRef(clazz); + + /* Initialize structure of RBTL callbacks */ + V4L2_JBTL_LOGD("nativeJFmTx_ClassInitNative: Initializing FMTX callback structure"); + + + V4L2_JBTL_LOGD("nativeJFmTx_ClassInitNative: Obtaining method IDs"); + + + _sMethodId_nativeCb_fmTxCmdEnable = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdEnable", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdEnable); + + + _sMethodId_nativeCb_fmTxCmdDisable = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdDisable", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdDisable); + + _sMethodId_nativeCb_fmTxCmdDestroy = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdDestroy", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdDestroy); + + + _sMethodId_nativeCb_fmTxCmdTune = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdTune", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdTune); + + + _sMethodId_nativeCb_fmTxCmdGetTunedFrequency= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetTunedFrequency", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetTunedFrequency); + + + + _sMethodId_nativeCb_fmTxCmdStartTransmission = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdStartTransmission", + "(JI)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdStartTransmission); + + + _sMethodId_nativeCb_fmTxCmdStopTransmission = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdStopTransmission", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdStopTransmission); + + + _sMethodId_nativeCb_fmTxCmdEnableRds = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdEnableRds", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdEnableRds); + + + _sMethodId_nativeCb_fmTxCmdDisableRds = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdDisableRds", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdDisableRds); + + _sMethodId_nativeCb_fmTxCmdSetRdsTextRtMsg= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsTextRtMsg", + "(JIII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsTextRtMsg); + + +/* + _sMethodId_nativeCb_fmTxCmdSetRdsTransmissionMode = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsTransmissionMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsTransmissionMode); + _sMethodId_nativeCb_fmTxCmdGetRdsTransmissionMode = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsTransmissionMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsTransmissionMode); + + _sMethodId_nativeCb_fmTxCmdGetRdsTrafficCodes= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsTrafficCodes", + "(JIII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsTrafficCodes); + + + _sMethodId_nativeCb_fmTxCmdSetRdsTrafficCodes= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsTrafficCodes", + "(JIII)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsTrafficCodes); + + +*/ + _sMethodId_nativeCb_fmTxCmdSetRdsTextPsMsg= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsTextPsMsg", + "(JII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsTextPsMsg); + +/* + _sMethodId_nativeCb_fmTxCmdGetRdsTextPsMsg= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsTextPsMsg", + "(JII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsTextPsMsg); + + + _sMethodId_nativeCb_fmTxCmdGetRdsTextRtMsg= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsTextRtMsg", + "(JIII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsTextRtMsg); + + + _sMethodId_nativeCb_fmTxCmdWriteRdsRawData= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdWriteRdsRawData", + "(JII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdWriteRdsRawData); + + + _sMethodId_nativeCb_fmTxCmdReadRdsRawData= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdReadRdsRawData", + "(JII[B)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdReadRdsRawData); + + */ + + _sMethodId_nativeCb_fmTxCmdSetInterruptMask= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetInterruptMask", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetInterruptMask); + + /* + _sMethodId_nativeCb_fmTxCmdGetInterruptMask= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetInterruptMask", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetInterruptMask); + */ + + + _sMethodId_nativeCb_fmTxCmdSetMonoStereoMode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetMonoStereoMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetMonoStereoMode); + + + _sMethodId_nativeCb_fmTxCmdGetMonoStereoMode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetMonoStereoMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetMonoStereoMode); + + + + _sMethodId_nativeCb_fmTxCmdSetPowerLevel= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetPowerLevel", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetPowerLevel); + + + + _sMethodId_nativeCb_fmTxCmdGetPowerLevel= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetPowerLevel", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetPowerLevel); + + + _sMethodId_nativeCb_fmTxCmdSetMuteMode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetMuteMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetMuteMode); + + + _sMethodId_nativeCb_fmTxCmdGetMuteMode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetMuteMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetMuteMode); + + + _sMethodId_nativeCb_fmTxCmdSetRdsAfCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsAfCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsAfCode); + + + + _sMethodId_nativeCb_fmTxCmdGetRdsAfCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsAfCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsAfCode); + + + + _sMethodId_nativeCb_fmTxCmdSetRdsPiCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsPiCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsPiCode); + + + _sMethodId_nativeCb_fmTxCmdGetRdsPiCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsPiCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsPiCode); + + + _sMethodId_nativeCb_fmTxCmdSetRdsPtyCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsPtyCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsPtyCode); + + + _sMethodId_nativeCb_fmTxCmdGetRdsPtyCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsPtyCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsPtyCode); + + + + _sMethodId_nativeCb_fmTxCmdSetRdsPsDispalyMode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsPsDispalyMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsPsDispalyMode); + + + + _sMethodId_nativeCb_fmTxCmdGetRdsPsDispalyMode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsPsDispalyMode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsPsDispalyMode); + + + + _sMethodId_nativeCb_fmTxCmdSetRdsPsDisplaySpeed= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsPsDisplaySpeed", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsPsDisplaySpeed); + + + _sMethodId_nativeCb_fmTxCmdGetRdsPsDisplaySpeed= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsPsDisplaySpeed", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsPsDisplaySpeed); + + + _sMethodId_nativeCb_fmTxCmdSetRdsTransmittedMask= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsTransmittedMask", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsTransmittedMask); + + + _sMethodId_nativeCb_fmTxCmdGetRdsTransmittedMask= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsTransmittedMask", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsTransmittedMask); + + + _sMethodId_nativeCb_fmTxCmdSetRdsMusicSpeechFlag = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsMusicSpeechFlag", + "(JIJ)V") ; + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsMusicSpeechFlag); + + + _sMethodId_nativeCb_fmTxCmdGetRdsMusicSpeechFlag = env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsMusicSpeechFlag", + "(JIJ)V") ; + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsMusicSpeechFlag); + + + _sMethodId_nativeCb_fmTxCmdSetPreEmphasisFilter= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetPreEmphasisFilter", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetPreEmphasisFilter); + + + _sMethodId_nativeCb_fmTxCmdGetPreEmphasisFilter= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetPreEmphasisFilter", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetPreEmphasisFilter); + + + + _sMethodId_nativeCb_fmTxCmdSetRdsExtendedCountryCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsExtendedCountryCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsExtendedCountryCode); + + + _sMethodId_nativeCb_fmTxCmdGetRdsExtendedCountryCode= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsExtendedCountryCode", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsExtendedCountryCode); + + + _sMethodId_nativeCb_fmTxCmdChangeDigitalAudioConfiguration= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdChangeDigitalAudioConfiguration", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdChangeDigitalAudioConfiguration); + +/* + _sMethodId_nativeCb_fmTxCmdChangeAudioSource= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdChangeAudioSource", + "(JILcom/ti/jfm/core/JFmCcmVacUnavailResourceList;)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdChangeAudioSource); +*/ + _sMethodId_nativeCb_fmTxCmdSetRdsTextRepertoire= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdSetRdsTextRepertoire", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdSetRdsTextRepertoire); + + + _sMethodId_nativeCb_fmTxCmdGetRdsTextRepertoire= env->GetStaticMethodID(clazz, + "nativeCb_fmTxCmdGetRdsTextRepertoire", + "(JIJ)V"); + VERIFY_METHOD_ID(_sMethodId_nativeCb_fmTxCmdGetRdsTextRepertoire); + + V4L2_JBTL_LOGD("nativeJFmTx_ClassInitNative:Exiting"); +} + + JNINativeMethod JFmTxNative_sMethods[] = { + /* name, signature, funcPtr */ + {"nativeJFmTx_ClassInitNative", "()V", (void*)nativeJFmTx_ClassInitNative}, + {"nativeJFmTx_Create","(Lcom/ti/jfm/core/JFmContext;)I", (void*)nativeJFmTx_Create}, + {"nativeJFmTx_Destroy","(J)I", (void*)nativeJFmTx_Destroy}, + {"nativeJFmTx_Enable","(J)I", (void*)nativeJFmTx_Enable}, + {"nativeJFmTx_Disable","(J)I", (void*)nativeJFmTx_Disable}, + {"nativeJFmTx_Tune","(JJ)I", (void*)nativeJFmTx_Tune}, + {"nativeJFmTx_StopTransmission","(J)I", (void*)nativeJFmTx_StopTransmission}, + {"nativeJFmTx_StartTransmission","(J)I", (void*)nativeJFmTx_StartTransmission}, + {"nativeJFmTx_EnableRds","(J)I", (void*)nativeJFmTx_EnableRds}, + {"nativeJFmTx_DisableRds","(J)I", (void*)nativeJFmTx_DisableRds}, + {"nativeJFmTx_SetRdsTransmissionMode","(JI)I", (void*)nativeJFmTx_SetRdsTransmissionMode}, + {"nativeJFmTx_SetRdsTextPsMsg","(JLjava/lang/String;I)I", (void*)nativeJFmTx_SetRdsTextPsMsg}, +/* + {"nativeJFmTx_GetRdsTextPsMsg","(J)I", (void*)nativeJFmTx_GetRdsTextPsMsg}, + {"nativeJFmTx_WriteRdsRawData","(JLjava/lang/String;I)I", (void*)nativeJFmTx_WriteRdsRawData}, +*/ + {"nativeJFmTx_SetMuteMode","(JI)I", (void*)nativeJFmTx_SetMuteMode}, + {"nativeJFmTx_GetMuteMode","(J)I", (void*)nativeJFmTx_GetMuteMode}, + {"nativeJFmTx_SetRdsTextRtMsg","(JILjava/lang/String;I)I", (void*)nativeJFmTx_SetRdsTextRtMsg}, + {"nativeJFmTx_SetRdsTransmittedGroupsMask","(JJ)I", (void*)nativeJFmTx_SetRdsTransmittedGroupsMask}, +/* + {"nativeJFmTx_SetRdsPsDisplayMode","(JI)I", (void*)nativeJFmTx_SetRdsPsDisplayMode}, + {"nativeJFmTx_GetRdsPsDisplayMode","(J)I", (void*)nativeJFmTx_GetRdsPsDisplayMode}, + {"nativeJFmTx_GetRdsTextRtMsg","(J)I", (void*)nativeJFmTx_GetRdsTextRtMsg}, + {"nativeJFmTx_GetRdsTransmittedGroupsMask","(J)I", (void*)nativeJFmTx_GetRdsTransmittedGroupsMask}, + {"nativeJFmTx_SetRdsTrafficCodes","(JII)I", (void*)nativeJFmTx_SetRdsTrafficCodes}, + {"nativeJFmTx_GetRdsTrafficCodes","(J)I", (void*)nativeJFmTx_GetRdsTrafficCodes}, + {"nativeJFmTx_SetRdsMusicSpeechFlag","(JI)I", (void*)nativeJFmTx_SetRdsMusicSpeechFlag}, + {"nativeJFmTx_GetRdsMusicSpeechFlag","(J)I", (void*)nativeJFmTx_GetRdsMusicSpeechFlag}, + {"nativeJFmTx_SetRdsExtendedCountryCode","(JI)I", (void*)nativeJFmTx_SetRdsExtendedCountryCode}, + {"nativeJFmTx_GetRdsExtendedCountryCode","(J)I", (void*)nativeJFmTx_GetRdsExtendedCountryCode}, + {"nativeJFmTx_ReadRdsRawData","(J)I", (void*)nativeJFmTx_ReadRdsRawData}, + {"nativeJFmTx_ChangeAudioSource","(JII)I", (void*)nativeJFmTx_ChangeAudioSource}, +*/ + {"nativeJFmTx_ChangeDigitalSourceConfiguration","(JI)I", (void*)nativeJFmTx_ChangeDigitalSourceConfiguration}, + {"nativeJFmTx_SetRdsTextRepertoire","(JI)I", (void*)nativeJFmTx_SetRdsTextRepertoire}, + {"nativeJFmTx_GetRdsTextRepertoire","(J)I", (void*)nativeJFmTx_GetRdsTextRepertoire}, + {"nativeJFmTx_SetRdsPtyCode","(JI)I", (void*)nativeJFmTx_SetRdsPtyCode}, + {"nativeJFmTx_GetRdsPtyCode","(J)I", (void*)nativeJFmTx_GetRdsPtyCode}, + {"nativeJFmTx_SetRdsPiCode","(JI)I", (void*)nativeJFmTx_SetRdsPiCode}, + {"nativeJFmTx_GetRdsPiCode","(J)I", (void*)nativeJFmTx_GetRdsPiCode}, + {"nativeJFmTx_SetRdsAfCode","(JI)I", (void*)nativeJFmTx_SetRdsAfCode}, + {"nativeJFmTx_GetRdsAfCode","(J)I", (void*)nativeJFmTx_GetRdsAfCode}, + {"nativeJFmTx_SetMonoStereoMode","(JI)I", (void*)nativeJFmTx_SetMonoStereoMode}, + {"nativeJFmTx_GetMonoStereoMode","(J)I", (void*)nativeJFmTx_GetMonoStereoMode}, + {"nativeJFmTx_SetPowerLevel","(JI)I", (void*)nativeJFmTx_SetPowerLevel}, + {"nativeJFmTx_GetPowerLevel","(J)I", (void*)nativeJFmTx_GetPowerLevel}, + {"nativeJFmTx_SetPreEmphasisFilter","(JI)I", (void*)nativeJFmTx_SetPreEmphasisFilter}, + {"nativeJFmTx_GetPreEmphasisFilter","(J)I", (void*)nativeJFmTx_GetPreEmphasisFilter}, + {"nativeJFmTx_SetRdsPsScrollSpeed","(JI)I", (void*)nativeJFmTx_SetRdsPsScrollSpeed}, + {"nativeJFmTx_GetRdsPsScrollSpeed","(J)I", (void*)nativeJFmTx_GetRdsPsScrollSpeed} + +}; + +/* + * Register several native methods for one class. + */ + +int getTxNativeSize() +{ + return NELEM(JFmTxNative_sMethods); +} + diff --git a/tools/FM/service/src/jni/JFmTxNative.h b/tools/FM/service/src/jni/JFmTxNative.h new file mode 100644 index 0000000..24bc455 --- /dev/null +++ b/tools/FM/service/src/jni/JFmTxNative.h @@ -0,0 +1,220 @@ + /* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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. + */ + + +#ifndef JFMTXNATIVE_H_ +#define JFMTXNATIVE_H_ + +extern "C" { +#include "jni.h" +} + + + +#define FM_SUCCESS 0 +#define FM_FAILED 1 +#define FM_PENDING 2 +#define FM_ERR_THREAD_CREATION_FAILED 4 + + +#define DEFAULT_RADIO_DEVICE "/dev/radio0" + +#define FMTX_RDS_AF_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmtx_rds_af" + +#define DEFAULT_FM_ALSA_CARD "hw:CARD=0" + +#define CTL_INDEX_0 0 + +#define FM_MODE_SWITCH_CTL_NAME "Mode Switch" +#define FM_MODE_OFF 0 +#define FM_MODE_TX 1 +#define FM_MODE_TX 2 + +#define FM_BAND_SWITCH_CTL_NAME "Region Switch" +#define FM_BAND_EUROPE_US 0 +#define FM_BAND_JAPAN 1 + +#define FM_MUTE_ON 0 +#define FM_MUTE_OFF 1 +#define FM_MUTE_ATTENUATE 2 + +#define FM_RF_DEPENDENT_MUTE_CTL_NAME "RF Dependent Mute" +#define FM_TX_GET_RSSI_LVL_CTL_NAME "RSSI Level" +#define FM_TX_RSSI_THRESHOLD_LVL_CTL_NAME "RSSI Threshold" +#define FM_STEREO_MONO_CTL_NAME "Stereo/Mono" +#define FM_TX_DEEMPHASIS_CTL_NAME "De-emphasis Filter" +#define FM_RDS_SWITCH_CTL_NAME "RDS Switch" +#define FM_RDS_DISABLE 0 +#define FM_RDS_ENABLE 1 +#define FM_TX_RDS_OPMODE_CTL_NAME "RDS Operation Mode" +#define FM_TX_AF_SWITCH_CTL_NAME "AF Switch" + + + +typedef unsigned long FMC_U32; +typedef unsigned int FMC_UINT; +typedef unsigned char FMC_U8; + +/*------------------------------------------------------------------------------- + * FmcRdsRepertoire Type + * + * RDS Repertoire used for text data encoding and decoding + */ +typedef FMC_UINT FmcRdsRepertoire; + +#define FMC_RDS_REPERTOIRE_G0_CODE_TABLE ((FmcRdsRepertoire)0) +#define FMC_RDS_REPERTOIRE_G1_CODE_TABLE ((FmcRdsRepertoire)1) +#define FMC_RDS_REPERTOIRE_G2_CODE_TABLE ((FmcRdsRepertoire)2) + + +#define RDS_BIT_0_TO_BIT_3 0x0f +#define RDS_BIT_4_TO_BIT_7 0xf0 + + +/******************************************************************************** + * + * Events sent to the application + * + *******************************************************************************/ + +/*------------------------------------------------------------------------------- + * FmTxEventType structure + * + */ +typedef FMC_UINT FmTxEventType; +typedef FMC_UINT FmTxStatus; + + +/*------------------------------------------------------------------------------- + * FmTxCmdType structure + * + */ +typedef FMC_UINT FmTxCmdType; + +#define FM_TX_CMD_ENABLE ((FmTxCmdType)0) /* Enable command */ +#define FM_TX_CMD_DISABLE ((FmTxCmdType)1) /* Disable command */ +#define FM_TX_CMD_SET_BAND ((FmTxCmdType)2) /* Set Band command */ +#define FM_TX_CMD_GET_BAND ((FmTxCmdType)3) /* Get Band command */ +#define FM_TX_CMD_SET_MONO_STEREO_MODE ((FmTxCmdType)4) /* Set Mono/Stereo command */ +#define FM_TX_CMD_GET_MONO_STEREO_MODE ((FmTxCmdType)5) /* Get Mono/Stereo command */ +#define FM_TX_CMD_SET_MUTE_MODE ((FmTxCmdType)6) /* Set Mute mode command */ +#define FM_TX_CMD_GET_MUTE_MODE ((FmTxCmdType)7) /* Get Mute mode command */ +#define FM_TX_CMD_SET_RF_DEPENDENT_MUTE_MODE ((FmTxCmdType)8) /* Set RF-Dependent Mute Mode command */ +#define FM_TX_CMD_GET_RF_DEPENDENT_MUTE_MODE ((FmTxCmdType)9) /* Get RF-Dependent Mute Mode command */ +#define FM_TX_CMD_SET_RSSI_THRESHOLD ((FmTxCmdType)10) /* Set RSSI Threshold command */ +#define FM_TX_CMD_GET_RSSI_THRESHOLD ((FmTxCmdType)11) /* Get RSSI Threshold command */ +#define FM_TX_CMD_SET_DEEMPHASIS_FILTER ((FmTxCmdType)12) /* Set De-Emphassi Filter command */ +#define FM_TX_CMD_GET_DEEMPHASIS_FILTER ((FmTxCmdType)13) /* Get De-Emphassi Filter command */ +#define FM_TX_CMD_SET_VOLUME ((FmTxCmdType)14) /* Set Volume command */ +#define FM_TX_CMD_GET_VOLUME ((FmTxCmdType)15) /* Get Volume command */ +#define FM_TX_CMD_TUNE ((FmTxCmdType)16) /* Tune command */ +#define FM_TX_CMD_GET_TUNED_FREQUENCY ((FmTxCmdType)17) /* Get Tuned Frequency command */ +#define FM_TX_CMD_SEEK ((FmTxCmdType)18) /* Seek command */ +#define FM_TX_CMD_STOP_SEEK ((FmTxCmdType)19) /* Stop Seek command */ +#define FM_TX_CMD_GET_RSSI ((FmTxCmdType)20) /* Get RSSI command */ +#define FM_TX_CMD_ENABLE_RDS ((FmTxCmdType)21) /* Enable RDS command */ +#define FM_TX_CMD_DISABLE_RDS ((FmTxCmdType)22) /* Disable RDS command */ +#define FM_TX_CMD_SET_RDS_SYSTEM ((FmTxCmdType)23) /* Set RDS System command */ +#define FM_TX_CMD_GET_RDS_SYSTEM ((FmTxCmdType)24) /* Get RDS System command */ +#define FM_TX_CMD_SET_RDS_GROUP_MASK ((FmTxCmdType)25) /* Set RDS groups to be recieved */ +#define FM_TX_CMD_GET_RDS_GROUP_MASK ((FmTxCmdType)26) /* Get RDS groups to be recieved*/ +#define FM_TX_CMD_SET_RDS_AF_SWITCH_MODE ((FmTxCmdType)27) /* Set AF Switch Mode command */ +#define FM_TX_CMD_GET_RDS_AF_SWITCH_MODE ((FmTxCmdType)28) /* Get AF Switch Mode command */ +#define FM_TX_CMD_ENABLE_AUDIO ((FmTxCmdType)29) /* Set Audio Routing command */ +#define FM_TX_CMD_DISABLE_AUDIO ((FmTxCmdType)30) /* Get Audio Routing command */ +#define FM_TX_CMD_DESTROY ((FmTxCmdType)31) /* Destroy command */ +#define FM_TX_CMD_CHANGE_AUDIO_TARGET ((FmTxCmdType)32) /* Change the audio target*/ +#define FM_TX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION ((FmTxCmdType)33) /* Change the digital target configuration*/ +#define FM_TX_INIT_ASYNC ((FmTxCmdType)34) /* */ +#define FM_TX_CMD_INIT ((FmTxCmdType)35) /* */ +#define FM_TX_CMD_DEINIT ((FmTxCmdType)36) /* */ +#define FM_TX_CMD_SET_CHANNEL_SPACING ((FmTxCmdType)37) /* */ +#define FM_TX_CMD_GET_CHANNEL_SPACING ((FmTxCmdType)38) /* */ +#define FM_TX_CMD_GET_FW_VERSION ((FmTxCmdType)39) /*Gets the FW version */ +#define FM_TX_CMD_IS_CHANNEL_VALID ((FmTxCmdType)40) /*Verify that the tuned channel is valid*/ +#define FM_TX_CMD_COMPLETE_SCAN ((FmTxCmdType)41) /*Perfrom Complete Scan on the selected Band*/ +#define FM_TX_CMD_COMPLETE_SCAN_PROGRESS ((FmTxCmdType)42) +#define FM_TX_CMD_STOP_COMPLETE_SCAN ((FmTxCmdType)43) +#define FM_TX_CMD_START_TRANSMISSION ((FmTxCmdType)44) +#define FM_TX_CMD_STOP_TRANSMISSION ((FmTxCmdType)45) +#define FM_TX_CMD_SET_RDS_TEXT_RT_MSG ((FmTxCmdType)46) +#define FM_TX_CMD_SET_RDS_TEXT_PS_MSG ((FmTxCmdType)47) +#define FM_TX_CMD_SET_RDS_PTY_CODE ((FmTxCmdType)48) +#define FM_TX_CMD_GET_RDS_PTY_CODE ((FmTxCmdType)49) +#define FM_TX_CMD_SET_RDS_AF_CODE ((FmTxCmdType)50) + +#define FM_TX_LAST_API_CMD (FM_TX_CMD_SET_RDS_AF_CODE) +#define FM_TX_CMD_NONE 0xFFFFFFFF + + +namespace android { + +extern JNIEnv *getJBtlEnv(); +extern void setJBtlEnv(JNIEnv *env); + +} + +/* Following macros and structs are re-declared since android + file system has old videodev2.h but kfmapp needs new K35 videodev2.h + declarations, So need to remove these definitions once android headers + move to K35 plus */ + +#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */ +/* FM Modulator class control IDs */ +#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) +#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1) + +#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112) +enum v4l2_preemphasis { + V4L2_PREEMPHASIS_DISABLED = 0, + V4L2_PREEMPHASIS_50_uS = 1, + V4L2_PREEMPHASIS_75_uS = 2, +}; + +#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1) +#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2) +#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3) +#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5) +#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6) + +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114) +#define V4L2_TUNER_SUB_RDS 0x0010 + + +#undef VIDIOC_S_MODULATOR +#define VIDIOC_S_MODULATOR 1078220343 + +struct v4l2_ext_control_kfmapp { + __u32 id; + __u32 size; + __u32 reserved2[1]; + union { + __s32 value; + __s64 value64; + char *string; + }; +} __attribute__ ((packed)); + +struct v4l2_ext_controls_kfmapp { + __u32 ctrl_class; + __u32 count; + __u32 error_idx; + __u32 reserved[2]; + struct v4l2_ext_control_kfmapp *controls; +}; +#endif /* JFMTXNATIVE_H_ */ diff --git a/tools/FM/service/src/jni/v4l2_JbtlLog.h b/tools/FM/service/src/jni/v4l2_JbtlLog.h new file mode 100644 index 0000000..907bf95 --- /dev/null +++ b/tools/FM/service/src/jni/v4l2_JbtlLog.h @@ -0,0 +1,69 @@ +/* + * + * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ + * + * 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. + */ + +#ifndef _V4L2_JBTL_LOG__H +#define _V4L2_JBTL_LOG__H + +#include "utils/Log.h" + + +/* + * Log a verbose log mesage. + */ +#define V4L2_JBTL_LOGV(...) LOGV( __VA_ARGS__) +#define V4L2_JBTL_LOGV_IF(cond, ...) LOGV_IF(cond, __VA_ARGS__) + +/* + * Log a debug log mesage. + */ +#define V4L2_JBTL_LOGD(...) LOGD( __VA_ARGS__) +#define V4L2_JBTL_LOGD_IF(cond, ...) LOGD_IF(cond, __VA_ARGS__) + +/* + * Log a informational log mesage. + */ +#define V4L2_JBTL_LOGI(...) LOGI( __VA_ARGS__) +#define V4L2_JBTL_LOGI_IF(cond, ...) LOGI_IF(cond, __VA_ARGS__) + +/* + * Log a warning log mesage. + */ +#define V4L2_JBTL_LOGW(...) LOGW( __VA_ARGS__) +#define V4L2_JBTL_LOGW_IF(cond, ...) LOGW_IF(cond, __VA_ARGS__) + +/* + * Log a error log mesage. + */ +#define V4L2_JBTL_LOGE(...) LOGW( __VA_ARGS__) +#define V4L2_JBTL_LOGE_IF(cond, ...) LOGE_IF(cond, __VA_ARGS__) + + +/* + * Log a fatal log message. + */ +#define V4L2_JBTL_LOG_FATAL(...) LOG_FATAL(__VA_ARGS__) +#define V4L2_JBTL_LOG_FATAL_IF(cond, ...) LOG_FATAL_IF(cond, __VA_ARGS__) + + +/* + * Assertion + */ +#define V4L2_JBTL_LOG_ASSERT(cond, ...) LOG_ASSERT(cond, __VA_ARGS__) + + +#endif // _V4L2_JBTL_LOG__H + diff --git a/tools/kfmapp/Android.mk b/tools/kfmapp/Android.mk new file mode 100644 index 0000000..164452f --- /dev/null +++ b/tools/kfmapp/Android.mk @@ -0,0 +1,36 @@ +LOCAL_PATH := $(call my-dir) +TINYALSA_PATH := external/tinyalsa/ + +include $(CLEAR_VARS) + +BUILD_FM_RADIO = true + +ifeq ($(BUILD_FM_RADIO), true) + +# +## Kerenl FM Driver Test Application +# +# +LOCAL_C_INCLUDES:= $(TINYALSA_PATH)/include/ + + +LOCAL_CFLAGS:= -g -c -W -Wall -O2 -D_POSIX_SOURCE + +LOCAL_SRC_FILES:= \ + kfmapp.c + + +LOCAL_SHARED_LIBRARIES := \ + libtinyalsa + +LOCAL_STATIC_LIBRARIES := + +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) +LOCAL_MODULE_TAGS := eng + +LOCAL_MODULE:=kfmapp + +include $(BUILD_EXECUTABLE) + +endif # BUILD_FMAPP_ + diff --git a/tools/kfmapp/kfmapp.c b/tools/kfmapp/kfmapp.c new file mode 100644 index 0000000..d35a64f --- /dev/null +++ b/tools/kfmapp/kfmapp.c @@ -0,0 +1,1588 @@ +/* + * TI FM kernel driver's sample application. + * + * Copyright (C) 2010 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <stdio.h> +#include <fcntl.h> +#include <linux/videodev2.h> +#include <math.h> +#include <pthread.h> +#include <errno.h> +#include <signal.h> +#include <string.h> +#include <stdlib.h> +#include <tinyalsa/asoundlib.h> +#include <poll.h> + +#include "kfmapp.h" + +static unsigned int pdevice = 0; /* playback device */ +static unsigned int cdevice = 1; /* capture device */ +static int fm_aud_enable; +struct pcm *pcm_p = NULL; +struct pcm *pcm_c = NULL; +struct mixer *mixer; + +/* #define V4L2_TUNER_SUB_RDS 0x10 */ + +static char *g_mutemodes[]={"Mute ON","Mute OFF","Attenuate Voice"}; +/* +static char *g_bands[]={"Europe/US","Japan"}; +static char *g_sm_modes[]={"Stereo","Mono"}; +static char *g_rx_deemphasis_modes[]={"50 usec","75 usec"}; +static char *g_rds_opmodes[]={"RDS","RBDS"}; +static char *g_af_switch_mode[]={"Off","On"}; +*/ +static char *g_rds_modes[]={"Off","On"}; +static int g_vol_to_set; +static pthread_t g_rds_thread_ptr; +volatile char g_rds_thread_terminate,g_rds_thread_running; + +static int g_radio_fd; + +/* Program Type */ +static char *pty_str[]= {"None", "News", "Current Affairs", + "Information","Sport", "Education", + "Drama", "Culture","Science", + "Varied Speech", "Pop Music", + "Rock Music","Easy Listening", + "Light Classic Music", "Serious Classics", + "other Music","Weather", "Finance", + "Childrens Progs","Social Affairs", + "Religion", "Phone In", "Travel", + "Leisure & Hobby","Jazz", "Country", + "National Music","Oldies","Folk", + "Documentary", "Alarm Test", "Alarm"}; + +void fmapp_display_tx_menu(void) +{ + printf("Available FM TX Commands:\n"); + printf("f <freq> tune to freq(in MHz)\n"); + printf("gf get frequency(MHz)\n"); + printf("e <val> set pre-emphasis filter value" + "(0 = OFF, 1 = 50 usec and 2 = 75 usec)\n"); +/* printf("ge get pre-emphasis filter\n");*/ + printf("p <val> set FM TX powerlevel (91 - 122)\n"); +/* printf("gp get deemphasis filter\n"); + printf("i <val> set FM TX antenna impedance value (0 = 50, 1 = 200 and 2 = 500)\n"); + printf("gi get FM TX antenna impedance value\n");*/ + printf("1 to set RDS Radio Text\n"); + printf("2 to set RDS Radio PS Name\n"); + printf("3 <value> to set RDS Radio PI code\n"); + printf("4 <value> to set RDS Radio PTY\n"); + printf("5 <AF Freq in KHz> to set RDS Radio Alternate Frequency\n"); +} +void fmapp_display_rx_menu(void) +{ + printf("Available FM RX Commands:\n"); +/* printf("p power on/off\n"); */ + printf("f <freq> tune to freq(in MHz)\n"); + printf("gf get frequency(MHz)\n"); + printf("gr get rssi level\n"); + printf("t turns RDS on/off\n"); + printf("gt get RDS on/off\n"); + printf("+ increases the volume\n"); + printf("- decreases the volume\n"); + printf("v <0-65535> sets the volume\n"); + printf("gv get volume\n"); + printf("b<value> switches Japan / Eur-Us (0=US/Eur & 1=Japan)\n"); + printf("gb get band\n"); + printf("s switches stereo / mono\n"); + printf("gs get stereo/mono mode\n"); + printf("m changes mute mode\n"); + printf("gm get mute mode\n"); +/* printf("e set deemphasis filter\n"); + printf("ge get deemphasis filter\n"); + printf("d set rf dependent mute\n"); + printf("gd get rf dependent mute\n"); + printf("z set rds system\n"); + printf("gz get rds system\n"); */ + printf("c<value> set rds af switch(0-OFF & 1=ON)\n"); + printf("gc get rds af switch\n"); + printf("< seek down\n"); + printf("> seek up\n"); + printf("? <(0)-(127)> set RSSI threshold\n"); + printf("g? get rssi threshold\n"); + printf("ga get tuner attributes\n"); +/* printf("gn auto scan\n"); */ + printf("A Start FM RX Audio Routing\n"); + printf("q quit rx menu\n"); +} +int fmapp_get_tx_ant_imp(void) +{ + struct v4l2_control vctrl; + int res; + + vctrl.id = V4L2_CID_TUNE_ANTENNA_CAPACITOR; + + res = ioctl(g_radio_fd,VIDIOC_G_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to get FM Tx antenna impedence value\n"); + return res; + } + + printf("FM Tx antenna impedence value is --> %d\n",vctrl.value); + return 0; +} + +int fmapp_get_tx_power_level(void) +{ + struct v4l2_control vctrl; + int res; + + vctrl.id = V4L2_CID_TUNE_POWER_LEVEL; + + res = ioctl(g_radio_fd,VIDIOC_G_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to get FM Tx power level\n"); + return res; + } + + printf("FM Tx Power level is --> %d\n",vctrl.value); + return 0; +} +int fmapp_get_premphasis_filter_mode(void) +{ + struct v4l2_control vctrl; + int res; + + vctrl.id = V4L2_CID_TUNE_PREEMPHASIS; + + res = ioctl(g_radio_fd,VIDIOC_G_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to get preemphasis filter val\n"); + return res; + } + + printf("Preemphasis filter val is --> %d\n",vctrl.value); + return 0; +} +int fmapp_get_tx_frequency(void) +{ + struct v4l2_frequency vf; + struct v4l2_modulator vm; + int res, div; + + vm.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_MODULATOR, &vm); + if(res < 0) + { + printf("Failed to get modulator capabilities\n"); + return res; + } + + res = ioctl(g_radio_fd, VIDIOC_G_FREQUENCY,&vf); + if(res < 0) + { + printf("Failed to read current frequency\n"); + return res; + } + + div = (vm.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; + + printf("Transmitting at Frequency %3.2f MHz\n",vf.frequency / + ( 16000.0 * div)); + return 0; +} +int fmapp_get_rx_frequency(void) +{ + struct v4l2_frequency vf; + struct v4l2_tuner vt; + int res, div; + + vt.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vt); + if(res < 0) + { + printf("Failed to get tuner capabilities\n"); + return res; + } + + res = ioctl(g_radio_fd, VIDIOC_G_FREQUENCY,&vf); + if(res < 0) + { + printf("Failed to read current frequency\n"); + return res; + } + + div = (vt.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; + + printf("Tuned to frequency %3.2f MHz \n",vf.frequency / ( 16.0 * div)); + return 0; +} + +int fmapp_set_tx_rds_radio_text(void) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int res; + char rds_text[100]; + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_RADIO_TEXT; + printf("Enter RDS text to transmit\n"); + scanf("%s", rds_text); + vctrls.string = rds_text; + vctrls.size = strlen(rds_text) + 1; + vec.controls = &vctrls; + + printf("Entered RDS text is - %s and strlen = %d\n",vctrls.string, vctrls.size); + res = ioctl(g_radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + printf("Failed to set FM Tx RDS Radio text\n"); + return res; + } + + printf("FM Modulator RDS Radio text is set and transmitted\n"); + + return res; +} + +int fmapp_set_tx_rds_radio_ps_name(void) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int res; + char rds_text[100]; + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_PS_NAME; + printf("Enter RDS PS Name to transmit\n"); + scanf("%s", rds_text); + vctrls.string = rds_text; + vctrls.size = strlen(rds_text) + 1; + vec.controls = &vctrls; + + printf("Entered RDS text is - %s\n",vctrls.string); + res = ioctl(g_radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + printf("Failed to set FM Tx RDS Radio PS Name\n"); + return res; + } + + printf("FM Modulator RDS Radio PS Name set and transmitted\n"); + + return res; +} + +int fmapp_set_tx_rds_radio_pi_code(char *cmd) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int user_val; + int res; + + sscanf(cmd, "%d", &user_val); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_PI; + vctrls.value = user_val; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(g_radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + printf("Failed to set FM Tx RDS PI Code\n"); + return res; + } + + printf("Setting FM Tx RDS PI Code is Succesful\n"); + + return res; + +} + +int fmapp_set_tx_rds_radio_af(char *cmd) +{ + int fd, res, af_freq; + + fd = open(FMTX_RDS_AF_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + printf("Can't open %s", FMTX_RDS_AF_SYSFS_ENTRY); + return -1; + } + + res = write(fd, cmd, FMAPP_AF_MAX_FREQ_RANGE); + if(res <= 0){ + printf("Failed to set FM TX RDS Alternate Frequency\n"); + goto exit; + } + + printf("FM RDS Alternate Frequency is to %s Succesfully\n", cmd); +exit: + close(fd); + return res; + +} +int fmapp_set_tx_rds_radio_pty(char *cmd) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int user_val; + int res; + + sscanf(cmd, "%d", &user_val); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_RDS_TX_PTY; + vctrls.value = user_val; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(g_radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + printf("Failed to set FM Tx RDS PTY\n"); + return res; + } + + printf("Setting FM Tx RDS PTY is Succesful\n"); + + return res; + +} +int fmapp_set_tx_ant_imp(char *cmd) +{ + int user_val; + struct v4l2_control vctrl; + int res; + + sscanf(cmd, "%d", &user_val); + + vctrl.id = V4L2_CID_TUNE_ANTENNA_CAPACITOR; + vctrl.value = user_val; + res = ioctl(g_radio_fd,VIDIOC_S_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to set FM Tx antenna impedence value\n"); + return res; + } + + printf("Setting FM Tx antenna impedence value to ---> %d\n",vctrl.value); + return 0; +} + +int fmapp_set_tx_power_level(char *cmd) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int user_val; + int res; + + sscanf(cmd, "%d", &user_val); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_TUNE_POWER_LEVEL; + vctrls.value = user_val; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(g_radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + printf("Failed to set FM Tx power level\n"); + return res; + } + + printf("Setting FM Tx Power level to ---> %d\n", vctrls.value); + + return res; + +} +int fmapp_set_premphasis_filter_mode(char *cmd) +{ + struct v4l2_ext_controls_kfmapp vec; + struct v4l2_ext_control_kfmapp vctrls; + int user_val; + int res; + + sscanf(cmd, "%d", &user_val); + + vec.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + vec.count = 1; + vctrls.id = V4L2_CID_TUNE_PREEMPHASIS; + vctrls.value = user_val; + vctrls.size = 0; + vec.controls = &vctrls; + + res = ioctl(g_radio_fd, VIDIOC_S_EXT_CTRLS, &vec); + if(res < 0) + { + printf("Failed to set preemphasis filter val\n"); + return res; + } + + printf("Setting preemphasis filter val success\n"); + + return res; + +} + +int fmapp_set_tx_frequency(char *cmd) +{ + float user_freq; + struct v4l2_frequency vf; + struct v4l2_modulator vm; + int res, div; + + sscanf(cmd, "%f", &user_freq); + + vm.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_MODULATOR, &vm); + if(res < 0) + { + printf("Failed to get modulator capabilities\n"); + return res; + } + + vf.tuner = 0; + vf.frequency = rint(user_freq * 16000 + 0.5); + + div = (vm.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; + if (div == 1) + vf.frequency /= 1000; + + res = ioctl(g_radio_fd, VIDIOC_S_FREQUENCY, &vf); + if(res < 0) + { + printf("Failed to set frequency %f\n",user_freq); + return res; + } + printf("Started Transmitting at %3.2f MHz Frequency\n", vf.frequency / + (16.0 * div)); + + return res; +} +int fmapp_set_rx_frequency(char *cmd) +{ + float user_freq; + struct v4l2_frequency vf; + struct v4l2_tuner vt; + int res, div; + + sscanf(cmd, "%f", &user_freq); + + vf.tuner = 0; + /* As per V4L2 specifications VIDIOC_S_FREQUENCY ioctl expects tuning + * frequency in units of 62.5 KHz, or if the struct v4l2_tuner or struct + * v4l2_modulator capabilities flag V4L2_TUNER_CAP_LOW is set, in units + * of 62.5 Hz. But FM ST v4l2 driver presently handling the frequency in + * units of 1 KHz + */ + vf.frequency = rint(user_freq * 16000 + 0.5); + + vt.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vt); + if(res < 0) + { + printf("Failed to get tuner capabilities\n"); + return res; + } + + div = (vt.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; + if (div == 1) + vf.frequency /= 1000; + + if(vf.frequency < vt.rangelow || vf.frequency > vt.rangehigh){ + printf("Failed to set frequency: Frequency is not in range" + "(%3.2f MHz to %3.2f MHz)\n", (vt.rangelow/(16.0 * div)), + (vt.rangehigh/(16.0 * div))); + return -EINVAL; + } + + res = ioctl(g_radio_fd, VIDIOC_S_FREQUENCY, &vf); + if(res < 0) + { + printf("Failed to set frequency %f\n",user_freq); + return res; + } + printf("Tuned to frequency %3.2f MHz\n", vf.frequency / (16.0 * div)); + return 0; +} + +inline void display_volume_bar(void) +{ + int index; + printf("\nVolume: "); + for(index=1; index<g_vol_to_set; index = index*1000) + printf("#"); + + printf("\nVolume is : %d\n",g_vol_to_set); + +} +int fmapp_set_rx_volume(char *cmd,int interactive,int vol_to_set) +{ + struct v4l2_control vctrl; + int res; + + if(interactive == FMAPP_INTERACTIVE) + sscanf(cmd, "%d", &g_vol_to_set); + else + g_vol_to_set = vol_to_set; + + vctrl.id = V4L2_CID_AUDIO_VOLUME; + vctrl.value = g_vol_to_set; + res = ioctl(g_radio_fd,VIDIOC_S_CTRL,&vctrl); + if(res < 0) + { + g_vol_to_set = 0; + printf("Failed to set volume\n"); + return res; + } + printf("Setting volume to %d \n",g_vol_to_set); + return 0; +} + +int fmapp_get_rx_volume(void) +{ + struct v4l2_control vctrl; + int res; + + vctrl.id = V4L2_CID_AUDIO_VOLUME; + res = ioctl(g_radio_fd,VIDIOC_G_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to get volume\n"); + return res; + } + g_vol_to_set = vctrl.value; + + printf("Radio Volume is set to %d\n",g_vol_to_set); +// display_volume_bar(); + return 0; +} + +int fmapp_rx_increase_volume(void) +{ + int ret; + + g_vol_to_set +=1; + if(g_vol_to_set > 70) + g_vol_to_set = 70; + + ret = fmapp_set_rx_volume(NULL,FMAPP_BATCH,g_vol_to_set); + if(ret < 0) + return ret; + + display_volume_bar(); + return 0; +} +int fmapp_rx_decrease_volume(void) +{ + int ret; + g_vol_to_set -=1; + if(g_vol_to_set < 0) + g_vol_to_set = 0; + + ret = fmapp_set_rx_volume(NULL,FMAPP_BATCH,g_vol_to_set); + if(ret < 0) + return ret; + + display_volume_bar(); + return 0; +} +int fmapp_set_rx_mute_mode(void) +{ + struct v4l2_control vctrl; + static short int mute_mode = FM_MUTE_OFF; + int res; + + vctrl.value = 0; + printf("Mutemode = %d\n",mute_mode); + switch (mute_mode) + { + case FM_MUTE_OFF: + mute_mode = FM_MUTE_ON; + break; + + case FM_MUTE_ON: + mute_mode = FM_MUTE_OFF; + break; + } + + vctrl.id = V4L2_CID_AUDIO_MUTE; + vctrl.value = mute_mode; + res = ioctl(g_radio_fd,VIDIOC_S_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to set mute mode\n"); + return res; + } + + printf("Setting to \"%s\" \n",g_mutemodes[mute_mode]); + return 0; +} +int fmapp_get_rx_mute_mode(void) +{ + struct v4l2_control vctrl; + int res; + + vctrl.id = V4L2_CID_AUDIO_MUTE; + res = ioctl(g_radio_fd,VIDIOC_G_CTRL,&vctrl); + if(res < 0) + { + printf("Failed to get mute mode\n"); + return res; + } + + printf("%s\n",g_mutemodes[vctrl.value]); + return 0; +} +int fmapp_rx_seek(int seek_direction) +{ + struct ti_v4l2_hw_freq_seek frq_seek; + int res; + + printf("Seeking %s..\n",seek_direction?"up":"down"); + frq_seek.type = 1; + frq_seek.seek_upward = seek_direction; + frq_seek.spacing = 200000; + frq_seek.wrap_around = 0; + errno = 0; + res = ioctl(g_radio_fd,VIDIOC_S_HW_FREQ_SEEK,&frq_seek); + if(errno == EAGAIN) + { + printf("Band limit reached\n"); + } + else if(res <0) + { + printf("Seek operation failed\n"); + return res; + } + /* Display seeked freq */ + fmapp_get_rx_frequency(); + return 0; +} + +int fmapp_set_rx_af_switch(char *cmd) +{ + int fd, res; + + fd = open(FMRX_RDS_AF_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + printf("Can't open %s", FMRX_RDS_AF_SYSFS_ENTRY); + return -1; + } + + res = write(fd, cmd, sizeof(char)); + if(res <= 0){ + printf("Failed to set FM RDS AF Switch\n"); + goto exit; + } + + printf("FM RDS Alternate Frequency is %s\n", + atoi(cmd) == 0 ? "OFF":"ON"); +exit: + close(fd); + return res; +} + +int fmapp_get_rx_af_switch(void) +{ + unsigned char fm_rds_af; + int fd, res; + + fd = open(FMRX_RDS_AF_SYSFS_ENTRY, O_RDONLY); + if (fd < 0) { + printf("Can't open %s", FMRX_RDS_AF_SYSFS_ENTRY); + return -1; + } + + res = read(fd, &fm_rds_af, 1); + if(res < 0){ + printf("reading %s failed %s\n", + FMRX_RDS_AF_SYSFS_ENTRY,strerror(res)); + goto exit; + } + + printf("FM RDS Alternate Frequency is %s \n", + (atoi((char *) &fm_rds_af)) == 0?"OFF":"ON"); +exit: + close(fd); + return 0; +} + +int fmapp_get_rx_rssi_threshold(void) +{ + unsigned char fm_rssi_threshhold; + int fd, res; + + fd = open(FMRX_RSSI_LVL_SYSFS_ENTRY, O_RDONLY); + if (fd < 0) { + printf("Can't open %s", FMRX_RSSI_LVL_SYSFS_ENTRY); + return -1; + } + + res = read(fd, &fm_rssi_threshhold, 3); + if(res < 0){ + printf("reading %s failed %s\n", + FMRX_RSSI_LVL_SYSFS_ENTRY,strerror(res)); + goto exit; + } + + printf("Current FM RSSI threshold level is %d \n", + atoi((char *) &fm_rssi_threshhold)); + +exit: + close(fd); + return res; +} + +int fmapp_set_rx_rssi_threshold(char *cmd) +{ + int fd, res; + + fd = open(FMRX_RSSI_LVL_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + printf("Can't open %s", FMRX_RSSI_LVL_SYSFS_ENTRY); + return -1; + } + + res = write(fd, cmd, sizeof(char) * 3); + if(res <= 0){ + printf("Failed to set FM RSSI threshold level\n"); + goto exit; + } + + printf("FM RSSI threshold level is set to %d\n", atoi(cmd)); + +exit: + close(fd); + return res; +} + +int fmapp_set_band(char *cmd) +{ + int fd, res; + + fd = open(FMRX_BAND_SYSFS_ENTRY, O_RDWR); + if (fd < 0) { + printf("Can't open %s", FMRX_BAND_SYSFS_ENTRY); + return -1; + } + + res = write(fd, cmd, sizeof(char)); + if(res <= 0){ + printf("Failed to set FM Band\n"); + goto exit; + } + + printf("FM Band is set to %s\n", atoi(cmd) == 0?"US/EUROPE":"JAPAN"); +exit: + close(fd); + return res; +} + +int fmapp_get_band(void) +{ + unsigned char fm_band; + int fd, res; + + fd = open(FMRX_BAND_SYSFS_ENTRY, O_RDONLY); + if (fd < 0) { + printf("Can't open %s", FMRX_BAND_SYSFS_ENTRY); + return -1; + } + + res = read(fd, &fm_band, 1); + if(res < 0){ + printf("reading %s failed %s\n",FMRX_BAND_SYSFS_ENTRY,strerror(res)); + goto exit; + } + + printf("Present FM Band is %s \n", + (atoi((char *) &fm_band)) == 0?"US/EUROPE":"JAPAN"); +exit: + close(fd); + return res; +} +static void tinymix_set_value(struct mixer *mixer, unsigned int id, + int value) +{ + struct mixer_ctl *ctl; + enum mixer_ctl_type type; + unsigned int i, num_values; + + ctl = mixer_get_ctl(mixer, id); + type = mixer_ctl_get_type(ctl); + num_values = mixer_ctl_get_num_values(ctl); + + for(i=0; i<num_values; i++) { + if (mixer_ctl_set_value(ctl, i, value)) { + fprintf(stderr, "Error: invalid value\n"); + return; + } + } +} + +int fmapp_start_audio() +{ + struct pcm_config config; + + mixer = mixer_open(0); + if (!mixer) { + fprintf(stderr, "Failed to open mixer\n"); + return EXIT_FAILURE; + } + + config.channels = 2; + config.rate = 48000; + config.period_size = 1024; + config.period_count = 4; + config.format = PCM_FORMAT_S16_LE; + config.silence_threshold = 0; + config.stop_threshold = -1; + + if (fm_aud_enable == 0){ + /* Set Tinymix controles */ + tinymix_set_value(mixer, 77, 2); + tinymix_set_value(mixer, 76, 2); + tinymix_set_value(mixer, 64, 1); + tinymix_set_value(mixer, 65, 4); + tinymix_set_value(mixer, 55, 12); + tinymix_set_value(mixer, 54, 11); + tinymix_set_value(mixer, 51, 1); + tinymix_set_value(mixer, 9, 120); + tinymix_set_value(mixer, 72, 1); + tinymix_set_value(mixer, 73, 1); + tinymix_set_value(mixer, 34, 1); + tinymix_set_value(mixer, 50, 1); + + pcm_p = pcm_open(0, pdevice, PCM_OUT, &config); + if (!pcm_p || !pcm_is_ready(pcm_p)) { + fprintf(stderr, "Unable to open PCM device (%s)\n", + pcm_get_error(pcm_p)); + return 0; + } + printf("Playback device opened successfully"); + pcm_c = pcm_open(0, cdevice, PCM_IN, &config); + if (!pcm_c || !pcm_is_ready(pcm_c)) { + fprintf(stderr, "Unable to open PCM device (%s)\n", + pcm_get_error(pcm_c)); + return 0; + } + printf("Capture device opened successfully"); + pcm_start(pcm_c); + pcm_start(pcm_p); + printf(" Trigered the loopback"); + fm_aud_enable = 1; + } + else { + /* Set Tinymix controls to Normal*/ + tinymix_set_value(mixer, 77, 0); + tinymix_set_value(mixer, 76, 0); + tinymix_set_value(mixer, 64, 0); + tinymix_set_value(mixer, 65, 0); + tinymix_set_value(mixer, 55, 0); + tinymix_set_value(mixer, 54, 0); + tinymix_set_value(mixer, 51, 0); + tinymix_set_value(mixer, 9, 0); + tinymix_set_value(mixer, 72, 0); + tinymix_set_value(mixer, 73, 0); + tinymix_set_value(mixer, 34, 0); + tinymix_set_value(mixer, 50, 0); + + /* close the device */ + pcm_stop(pcm_p); + pcm_stop(pcm_c); + pcm_close(pcm_p); + pcm_close(pcm_c); + fm_aud_enable = 0; + } + printf("FM RX Audio Routing Done\n"); + return 0; +} + +int fmapp_get_rx_rssi_lvl(void) +{ + struct v4l2_tuner vtun; + float rssi_lvl; + int res; + + vtun.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); + if(res < 0) + { + printf("Failed to get tunner attributes\n"); + return res; + } + rssi_lvl = ((float)vtun.signal / 0xFFFF) * 100; + printf("Signal Strength: %d%%\n",(unsigned int)rssi_lvl); + + return 0; +} +int fmapp_set_stereo_mono_mode(void) +{ + struct v4l2_tuner vtun; + int res = 0; + + vtun.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); + if(res < 0) + { + printf("Failed to set stereo-mono mode\n"); + return res; + } + + if(V4L2_TUNER_MODE_STEREO == vtun.audmode) + vtun.audmode = V4L2_TUNER_MODE_MONO; + else + vtun.audmode = V4L2_TUNER_MODE_STEREO; + + res = ioctl(g_radio_fd, VIDIOC_S_TUNER, &vtun); + if(res < 0) + { + printf("Failed to set stereo-mono mode\n"); + return res; + } + printf("Audio Mode set to: %s\n",(vtun.audmode == V4L2_TUNER_MODE_STEREO) ? "STEREO":"MONO"); + + return 0; +} +int fmapp_get_stereo_mono_mode(void) +{ + struct v4l2_tuner vtun; + int res; + + vtun.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); + if(res < 0) + { + printf("Failed to get tunner attributes\n"); + return res; + } + printf("Audio Mode: %s\n",(vtun.audmode == V4L2_TUNER_MODE_STEREO) ? "STEREO":"MONO"); + + return 0; +} +int fmapp_get_rx_tunner_attributes(void) +{ + struct v4l2_tuner vtun; + float sigstrength_percentage; + int res; + + vtun.index = 0; + res = ioctl(g_radio_fd,VIDIOC_G_TUNER,&vtun); + if(res < 0) + { + printf("Failed to get tunner attributes\n"); + return res; + } + printf("-----------------------\n"); + printf("Tuner Name: %s\n",vtun.name); + /* TODO: FM driver is not setting V4L2_TUNER_CAP_LOW flag , but its returning vtun.rangelow + * and vtun.rangehigh ranges in HZ . This needs to be corrected in FM driver */ + printf(" Low Freq: %d KHz\n", + (unsigned int )((float)vtun.rangelow * 0.0625)); + printf(" High Freq: %d KHz\n", + (unsigned int) ((float)vtun.rangehigh * 0.0625)); + printf("Audio Mode: %s\n",(vtun.audmode == V4L2_TUNER_MODE_STEREO) ? "STEREO":"MONO"); + sigstrength_percentage = ((float)vtun.signal /0xFFFF) * 100; + printf("Signal Strength: %d%%\n",(unsigned int)sigstrength_percentage); + printf("-----------------------\n"); + return 0; +} + +int fmapp_get_scan_valid_frequencies(void) +{ + int ret; + struct v4l2_tuner vtun; + struct v4l2_frequency vf; + struct v4l2_control vctrl; + float freq_multiplicator,start_frq,end_frq, + freq,perc,threshold,divide_by; + long totsig; + unsigned char index; + + vtun.index = 0; + ret = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); /* get frequency range */ + if (ret < 0) { + printf("Failed to get frequency range"); + return ret; + } + freq_multiplicator = (62.5 * ((vtun.capability & V4L2_TUNER_CAP_LOW) + ? 1 : 1000)); + + divide_by = (vtun.capability & V4L2_TUNER_CAP_LOW) ? 1000000 : 1000; + start_frq = ((float)vtun.rangelow * freq_multiplicator)/divide_by; + end_frq = ((float)vtun.rangehigh * freq_multiplicator)/divide_by; + + threshold = FMAPP_ASCAN_SIGNAL_THRESHOLD_PER; + + /* Enable Mute */ + vctrl.id = V4L2_CID_AUDIO_MUTE; + vctrl.value = FM_MUTE_ON; + ret = ioctl(g_radio_fd,VIDIOC_S_CTRL,&vctrl); + if(ret < 0) + { + printf("Failed to set mute mode\n"); + return ret; + } + printf("Auto Scanning..\n"); + for(freq=start_frq;freq<=end_frq;freq+=0.1) + { + vf.tuner = 0; + vf.frequency = rint(freq*1000); + ret = ioctl(g_radio_fd, VIDIOC_S_FREQUENCY, &vf); /* tune */ + if (ret < 0) { + printf("failed to set freq"); + return ret; + } + totsig = 0; + for(index=0;index<FMAPP_ASCAN_NO_OF_SIGNAL_SAMPLE;index++) + { + vtun.index = 0; + ret = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); /* get info */ + if (ret < 0) { + printf("Failed to get frequency range"); + return ret; + } + totsig += vtun.signal; + perc = (totsig / (65535.0 * index)); + usleep(1); + } + perc = (totsig / (65535.0 * FMAPP_ASCAN_NO_OF_SIGNAL_SAMPLE)); + if ((perc*100.0) > threshold) + printf("%2.1f MHz(%d%%)\n",freq,((unsigned short)(perc * 100.0))); + } + /* Disable Mute */ + vctrl.id = V4L2_CID_AUDIO_MUTE; + vctrl.value = FM_MUTE_OFF; + ret = ioctl(g_radio_fd,VIDIOC_S_CTRL,&vctrl); + if(ret < 0) + { + printf("Failed to set mute mode\n"); + return ret; + } + printf("Scan Completed\n"); + return 0; +} +int fmapp_get_rds_onoff(void) +{ + struct v4l2_tuner vtun; + int res = 0; + + vtun.index = 0; + res = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); + if(res < 0) + { + printf("Failed to read RDS state\n"); + return res; + } + printf("RDS is: %s\n",(vtun.rxsubchans & V4L2_TUNER_SUB_RDS) ? "ON":"OFF"); + + return 0; +} +void fmapp_rds_decode(int blkno, int byte1, int byte2) +{ + static char rds_psn[9]; + static char rds_txt[65]; + static int rds_pty,ms_code; + static int group,spare,blkc_byte1,blkc_byte2; + + switch (blkno) { + case 0: /* Block A */ + printf("----------------------------------------\n"); + printf("block A - id=%d\n",(byte1 << 8) | byte2); + break; + case 1: /* Block B */ + printf("block B - group=%d%c tp=%d pty=%d spare=%d\n", + (byte1 >> 4) & 0x0f, + ((byte1 >> 3) & 0x01) + 'A', + (byte1 >> 2) & 0x01, + ((byte1 << 3) & 0x18) | ((byte2 >> 5) & 0x07), + byte2 & 0x1f); + group = (byte1 >> 3) & 0x1f; + spare = byte2 & 0x1f; + rds_pty = ((byte1 << 3) & 0x18) | ((byte2 >> 5) & 0x07); + ms_code = (byte2 >> 3)& 0x1; + break; + case 2: /* Block C */ + printf("block C - 0x%02x 0x%02x\n",byte1,byte2); + blkc_byte1 = byte1; + blkc_byte2 = byte2; + break; + case 3 : /* Block D */ + printf("block D - 0x%02x 0x%02x\n",byte1,byte2); + switch (group) { + case 0: /* Group 0A */ + rds_psn[2*(spare & 0x03)+0] = byte1; + rds_psn[2*(spare & 0x03)+1] = byte2; + if ((spare & 0x03) == 0x03) + printf("PSN: %s, PTY: %s, MS: %s\n",rds_psn, + pty_str[rds_pty],ms_code?"Music":"Speech"); + break; + case 4: /* Group 2A */ + rds_txt[4*(spare & 0x0f)+0] = blkc_byte1; + rds_txt[4*(spare & 0x0f)+1] = blkc_byte2; + rds_txt[4*(spare & 0x0f)+2] = byte1; + rds_txt[4*(spare & 0x0f)+3] = byte2; + /* Display radio text once we get 16 characters */ +// if ((spare & 0x0f) == 0x0f) + if (spare > 16) + { + printf("Radio Text: %s\n",rds_txt); +// memset(&rds_txt,0,sizeof(rds_txt)); + } + break; + } + printf("----------------------------------------\n"); + break; + default: + printf("unknown block [%d]\n",blkno); + } +} +void *rds_thread(void *data) +{ + unsigned char buf[600]; + int radio_fd; + int ret,index; + struct pollfd pfd; + + radio_fd = (int)data; + + while(!g_rds_thread_terminate) + { + while(1){ + memset(&pfd, 0, sizeof(pfd)); + pfd.fd = radio_fd; + pfd.events = POLLIN; + ret = poll(&pfd, 1, 10); + if (ret == 0){ + /* Break the poll after RDS data available */ + break; + } + } + + ret = read(radio_fd,buf,500); + if(ret < 0) { + + break; + } + else if( ret > 0) + { + for(index=0;index<ret;index+=3) + fmapp_rds_decode(buf[index+2] & 0x7,buf[index+1],buf[index]); + } + } +/* TODO: Need to conform thread termination. + * below msg is not coming ,have a doubt on thread termination. + * Fix this later. */ + printf("RDS thread exiting..\n"); + return NULL; +} +int fmapp_set_rds_onoff(unsigned char fmapp_mode) +{ + struct v4l2_tuner vtun; + int ret; + static unsigned char rds_mode = FM_RDS_DISABLE; + + vtun.index = 0; + ret = ioctl(g_radio_fd, VIDIOC_G_TUNER, &vtun); + if(ret < 0) + { + printf("Failed to get tuner capabilities\n"); + return ret; + } + if(rds_mode == FM_RDS_DISABLE) { + vtun.rxsubchans |= V4L2_TUNER_SUB_RDS; + rds_mode = FM_RDS_ENABLE; + } else { + vtun.rxsubchans &= ~V4L2_TUNER_SUB_RDS; + rds_mode = FM_RDS_DISABLE; + } + + ret = ioctl(g_radio_fd, VIDIOC_S_TUNER, &vtun); + if(ret < 0) + { + printf("Failed to set rds on/off status\n"); + return ret; + } + /* Create rds receive thread once */ + if(fmapp_mode == FM_MODE_RX && rds_mode == FM_RDS_ENABLE && + g_rds_thread_running == 0) + { + g_rds_thread_running = 1; + pthread_create(&g_rds_thread_ptr,NULL,rds_thread,(void *)g_radio_fd); + } + + printf("RDS %s\n",g_rds_modes[rds_mode]); + return 0; +} + +void fmapp_execute_tx_get_command(char *cmd) +{ + switch(cmd[0]) + { + case 'f': + fmapp_get_tx_frequency(); + break; + case 'e': + fmapp_get_premphasis_filter_mode(); + break; + case 'p': + fmapp_get_tx_power_level(); + break; + case 'i': + fmapp_get_tx_ant_imp(); + break; + default: + printf("unknown command; type 'h' for help\n"); + } + +} +void fmapp_execute_rx_get_command(char *cmd) +{ + switch(cmd[0]) + { + case 'f': + fmapp_get_rx_frequency(); + break; + case 'r': + fmapp_get_rx_rssi_lvl(); + break; + case 't': + fmapp_get_rds_onoff(); + break; + case 'v': + fmapp_get_rx_volume(); + break; + case 'm': + fmapp_get_rx_mute_mode(); + break; + case 'b': + fmapp_get_band(); + break; + case 'c': + fmapp_get_rx_af_switch(); + break; + case '?': + fmapp_get_rx_rssi_threshold(); + break; +#if 0 + case 'd': + fmapp_get_rfmute(fm_snd_ctrl); + break; + case 'z': + fmapp_get_rds_operation_mode(fm_snd_ctrl); + break; +#endif + case 's': + fmapp_get_stereo_mono_mode(); + break; +#if 0 + case 'e': + fmapp_get_rx_deemphasis_filter_mode(fm_snd_ctrl); + break; +#endif + case 'a': + fmapp_get_rx_tunner_attributes(); + break; +#if 0 + case 'n': + fmapp_get_scan_valid_frequencies(); + break; +#endif + default: + printf("unknown command; type 'h' for help\n"); + } +} +void fmapp_execute_rx_other_command(char *cmd) +{ + switch(cmd[0]) + { +#if 0 + case 'p': + fmapp_change_rx_power_mode(fm_snd_ctrl); + break; +#endif + case 'f': + fmapp_set_rx_frequency(cmd+1); + break; + case 't': + fmapp_set_rds_onoff(FM_MODE_RX); + break; + case '+': + fmapp_rx_increase_volume(); + break; + case '-': + fmapp_rx_decrease_volume(); + break; + case 'v': + fmapp_set_rx_volume(cmd+1,FMAPP_INTERACTIVE,0); + break; + case 'm': + fmapp_set_rx_mute_mode(); + break; + case '<': + fmapp_rx_seek(FM_SEARCH_DIRECTION_DOWN); + break; + case '>': + fmapp_rx_seek(FM_SEARCH_DIRECTION_UP); + break; + case 'b': + fmapp_set_band(cmd+1); + break; + case 'h': + fmapp_display_rx_menu(); + break; + case 'c': + fmapp_set_rx_af_switch(cmd+1); + break; + case '?': + fmapp_set_rx_rssi_threshold(cmd+1); + break; +#if 0 + case 'd': + fmapp_set_rfmute(fm_snd_ctrl); + break; + case 'z': + fmapp_set_rds_operation_mode(fm_snd_ctrl); + break; +#endif + case 's': + fmapp_set_stereo_mono_mode(); + break; +#if 0 + case 'e': + fmapp_set_rx_deemphasis_filter_mode(fm_snd_ctrl); + break; +#endif + case 'A': + fmapp_start_audio(); + break; + } +} + +void fmapp_execute_tx_other_command(char *cmd) +{ + switch(cmd[0]) + { + case 'f': + fmapp_set_tx_frequency(cmd+1); + break; + case 'e': + fmapp_set_premphasis_filter_mode(cmd+1); + break; + case 'p': + fmapp_set_tx_power_level(cmd+1); + break; + case 'i': + fmapp_set_tx_ant_imp(cmd+1); + break; + case '1': + fmapp_set_tx_rds_radio_text(); + break; + case '2': + fmapp_set_tx_rds_radio_ps_name(); + break; + case '3': + fmapp_set_tx_rds_radio_pi_code(cmd+1); + break; + case '4': + fmapp_set_tx_rds_radio_pty(cmd+1); + break; + case '5': + fmapp_set_tx_rds_radio_af(cmd+1); + break; + case 'h': + fmapp_display_tx_menu(); + break; + } +} +/* Switch to RX mode before accepting user commands for RX */ +void fmapp_execute_rx_command(void) +{ + char cmd[100]; + struct v4l2_tuner vtun; + int ret; + + vtun.index = 0; + vtun.audmode = V4L2_TUNER_MODE_STEREO; + vtun.rxsubchans = V4L2_TUNER_SUB_RDS; + ret = ioctl(g_radio_fd, VIDIOC_S_TUNER, &vtun); + if(ret < 0) + { + printf("Failed to set RX mode\n"); + return; + } + + printf("Switched to RX menu\n"); + printf("type 'h' for help\n"); + + while(1) + { + fgets(cmd, sizeof(cmd), stdin); + switch(cmd[0]) { + case 'g': + fmapp_execute_rx_get_command(cmd+1); + break; + case 'q': + printf("quiting RX menu\n"); + if (pcm_p != NULL && pcm_c != NULL) + fmapp_start_audio(); + return; + default: + fmapp_execute_rx_other_command(cmd); + break; + } + } +} +void fmapp_execute_tx_command(void) +{ + char cmd[100]; + struct v4l2_modulator vmod; + int ret; + + vmod.index = 0; + vmod.txsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_RDS; + + ret = ioctl(g_radio_fd, VIDIOC_S_MODULATOR, &vmod); + if(ret < 0) + { + printf("Failed to set TX mode\n"); + return; + } + + printf("Switched to TX menu\n"); + printf("type 'h' for help\n"); + + while(1) + { + fgets(cmd, sizeof(cmd), stdin); + switch(cmd[0]) { + case 'g': + fmapp_execute_tx_get_command(cmd+1); + break; + case 'q': + printf("quiting TX menu\n"); + return; + default: + fmapp_execute_tx_other_command(cmd); + break; + } + } +} + +int fmapp_read_anddisplay_capabilities(void) +{ + struct v4l2_capability cap; + int res; + + res = ioctl(g_radio_fd,VIDIOC_QUERYCAP,&cap); + if(res < 0) + { + printf("Failed to read %s capabilities\n",DEFAULT_RADIO_DEVICE); + return res; + } + if((cap.capabilities & V4L2_CAP_RADIO) == 0) + { + printf("%s is not radio devcie",DEFAULT_RADIO_DEVICE); + return -1; + } + printf("\n***%s Info ****\n",DEFAULT_RADIO_DEVICE); + printf("Driver : %s\n",cap.driver); + printf("Card : %s\n",cap.card); + printf("Bus : %s\n",cap.bus_info); + printf("Capabilities : 0x%x\n",cap.capabilities); + + return 0; +} + +static void sig_handler() +{ + if(g_rds_thread_running) + g_rds_thread_terminate = 1; + + close(g_radio_fd); + printf("Terminating..\n\n"); + exit(1); +} +int main() +{ + char choice[100]; + char exit_flag; + int ret; + struct sigaction sa; + + printf("** TI Kernel Space FM Driver Test Application **\n"); + + printf("Opening device '%s'\n",DEFAULT_RADIO_DEVICE); + g_radio_fd = open(DEFAULT_RADIO_DEVICE, O_RDWR); + if(g_radio_fd < 0) + { + printf("Unable to open %s \nTerminating..\n",DEFAULT_RADIO_DEVICE); + return 0; + } + ret = fmapp_read_anddisplay_capabilities(); + if(ret< 0) + { + close(g_radio_fd); + return ret; + } + /* to handle ctrl + c and kill signals */ + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = sig_handler; + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + + exit_flag = 1; + while(exit_flag) + { + printf("1 FM RX\n"); + printf("2 FM TX\n"); + printf("3 Exit\n"); + fgets(choice, sizeof(choice), stdin); + + switch(atoi(choice)) + { + case 1: /* FM RX */ + fmapp_execute_rx_command(); + break; + case 2: /* FM TX */ + fmapp_execute_tx_command(); + break; + case 3: + printf("Terminating..\n\n"); + exit_flag = 0; + break; + default: + printf("Invalid choice , try again\n"); + continue; + } + } + if(g_rds_thread_running) + g_rds_thread_terminate = 1; // Terminate RDS thread + + close(g_radio_fd); + return 0; +} + + diff --git a/tools/kfmapp/kfmapp.h b/tools/kfmapp/kfmapp.h new file mode 100644 index 0000000..1282498 --- /dev/null +++ b/tools/kfmapp/kfmapp.h @@ -0,0 +1,154 @@ +/* + * TI FM kernel driver's sample application. + * + * Copyright (C) 2010 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _KFMAPP_H +#define _KFMAPP_H + +#define DEFAULT_RADIO_DEVICE "/dev/radio0" + +#define FMRX_BAND_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmrx_band" +#define FMRX_RDS_AF_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmrx_rds_af" +#define FMRX_RSSI_LVL_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmrx_rssi_lvl" + +#define FMTX_RDS_AF_SYSFS_ENTRY "/sys/class/video4linux/radio0/fmtx_rds_af" + +#define CTL_INDEX_0 0 +#define CTL_INDEX_1 1 + +#define FMAPP_BATCH 0 +#define FMAPP_INTERACTIVE 1 + +#define FM_MUTE_OFF 0 +#define FM_MUTE_ON 1 + +#define FM_SEARCH_DIRECTION_DOWN 0 +#define FM_SEARCH_DIRECTION_UP 1 + +#define FM_MODE_SWITCH_CTL_NAME "Mode Switch" +#define FM_MODE_OFF 0 +#define FM_MODE_TX 1 +#define FM_MODE_RX 2 + +#define FM_BAND_SWITCH_CTL_NAME "Region Switch" +#define FM_BAND_EUROPE_US 0 +#define FM_BAND_JAPAN 1 + +#define FM_RF_DEPENDENT_MUTE_CTL_NAME "RF Dependent Mute" +#define FM_RX_RF_DEPENDENT_MUTE_ON 1 +#define FM_RX_RF_DEPENDENT_MUTE_OFF 0 + +#define FM_RX_GET_RSSI_LVL_CTL_NAME "RSSI Level" +#define FM_RX_RSSI_THRESHOLD_LVL_CTL_NAME "RSSI Threshold" + +#define FM_STEREO_MONO_CTL_NAME "Stereo/Mono" +#define FM_STEREO_MODE 0 +#define FM_MONO_MODE 1 + +#define FM_RX_DEEMPHASIS_CTL_NAME "De-emphasis Filter" +#define FM_RX_EMPHASIS_FILTER_50_USEC 0 +#define FM_RX_EMPHASIS_FILTER_75_USEC 1 + +#define FM_RDS_SWITCH_CTL_NAME "RDS Switch" +#define FM_RDS_DISABLE 0 +#define FM_RDS_ENABLE 1 + +#define FM_RX_RDS_OPMODE_CTL_NAME "RDS Operation Mode" +#define FM_RDS_SYSTEM_RDS 0 +#define FM_RDS_SYSTEM_RBDS 1 + +#define FM_RX_AF_SWITCH_CTL_NAME "AF Switch" +#define FM_RX_RDS_AF_SWITCH_MODE_ON 1 +#define FM_RX_RDS_AF_SWITCH_MODE_OFF 0 + +/* Auto scan info */ +#define FMAPP_ASCAN_SIGNAL_THRESHOLD_PER 50 /* 50 % */ +#define FMAPP_ASCAN_NO_OF_SIGNAL_SAMPLE 3 /* 3 Samples */ + +#define FMAPP_AF_MAX_FREQ_RANGE 6 + +#define V4L2_CID_CHANNEL_SPACING (V4L2_CID_PRIVATE_BASE + 0) + +struct tx_rds { + unsigned char text_type; + unsigned char text[25]; + unsigned int af_freq; +}; +#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */ +/* FM Modulator class control IDs */ +#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) +#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1) + +#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112) +enum v4l2_preemphasis { + V4L2_PREEMPHASIS_DISABLED = 0, + V4L2_PREEMPHASIS_50_uS = 1, + V4L2_PREEMPHASIS_75_uS = 2, +}; + +#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1) +#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2) +#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3) +#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5) +#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6) + +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113) +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114) +#define V4L2_TUNER_SUB_RDS 0x0010 + +/* Following macros and structs are re-declared since android +file system has old videodev2.h but kfmapp needs new K35 videodev2.h +declarations, So need to remove these definitions once android headers +move to K35 plus */ +#undef VIDIOC_S_MODULATOR +#define VIDIOC_S_MODULATOR 1078220343 + +struct v4l2_ext_control_kfmapp { + __u32 id; + __u32 size; + __u32 reserved2[1]; + union { + __s32 value; + __s64 value64; + char *string; + }; +} __attribute__ ((packed)); + +struct v4l2_ext_controls_kfmapp { + __u32 ctrl_class; + __u32 count; + __u32 error_idx; + __u32 reserved[2]; + struct v4l2_ext_control_kfmapp *controls; +}; + +/* Presently android videodev2.h is from k2.6.35 so remove below struct when + * android header files moves to k3.0+ kernel header + * */ +struct ti_v4l2_hw_freq_seek { + __u32 tuner; + enum v4l2_tuner_type type; + __u32 seek_upward; + __u32 wrap_around; + __u32 spacing; + __u32 reserved[7]; +}; + +#endif + |