1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.fmradio; 18 19 /** 20 * This class define FM native interface, will description FM native interface 21 */ 22 public class FmNative { 23 static { 24 System.loadLibrary("fmjni"); 25 } 26 27 /** 28 * Open FM device, call before power up 29 * 30 * @return (true,success; false, failed) 31 */ openDev()32 static native boolean openDev(); 33 34 /** 35 * Close FM device, call after power down 36 * 37 * @return (true, success; false, failed) 38 */ closeDev()39 static native boolean closeDev(); 40 41 /** 42 * power up FM with frequency use long antenna 43 * 44 * @param frequency frequency(50KHZ, 87.55; 100KHZ, 87.5) 45 * 46 * @return (true, success; false, failed) 47 */ powerUp(float frequency)48 static native boolean powerUp(float frequency); 49 50 /** 51 * Power down FM 52 * 53 * @param type (0, FMRadio; 1, FMTransimitter) 54 * 55 * @return (true, success; false, failed) 56 */ powerDown(int type)57 static native boolean powerDown(int type); 58 59 /** 60 * tune to frequency 61 * 62 * @param frequency frequency(50KHZ, 87.55; 100KHZ, 87.5) 63 * 64 * @return (true, success; false, failed) 65 */ tune(float frequency)66 static native boolean tune(float frequency); 67 68 /** 69 * seek with frequency in direction 70 * 71 * @param frequency frequency(50KHZ, 87.55; 100KHZ, 87.5) 72 * @param isUp (true, next station; false previous station) 73 * 74 * @return frequency(float) 75 */ seek(float frequency, boolean isUp)76 static native float seek(float frequency, boolean isUp); 77 78 /** 79 * Auto scan(from 87.50-108.00) 80 * 81 * @return The scan station array(short) 82 */ autoScan()83 static native short[] autoScan(); 84 85 /** 86 * Stop scan, also can stop seek, other native when scan should call stop 87 * scan first, else will execute wait auto scan finish 88 * 89 * @return (true, can stop scan process; false, can't stop scan process) 90 */ stopScan()91 static native boolean stopScan(); 92 93 /** 94 * Open or close rds fuction 95 * 96 * @param rdson The rdson (true, open; false, close) 97 * 98 * @return rdsset 99 */ setRds(boolean rdson)100 static native int setRds(boolean rdson); 101 102 /** 103 * Read rds events 104 * 105 * @return rds event type 106 */ readRds()107 static native short readRds(); 108 109 /** 110 * Get program service(program name) 111 * 112 * @return The program name 113 */ getPs()114 static native byte[] getPs(); 115 116 /** 117 * Get radio text, RDS standard does not support Chinese character 118 * 119 * @return The LRT (Last Radio Text) bytes 120 */ getLrText()121 static native byte[] getLrText(); 122 123 /** 124 * Active alternative frequencies 125 * 126 * @return The frequency(float) 127 */ activeAf()128 static native short activeAf(); 129 130 /** 131 * Mute or unmute FM voice 132 * 133 * @param mute (true, mute; false, unmute) 134 * 135 * @return (true, success; false, failed) 136 */ setMute(boolean mute)137 static native int setMute(boolean mute); 138 139 /** 140 * Inquiry if RDS is support in driver 141 * 142 * @return (1, support; 0, NOT support; -1, error) 143 */ isRdsSupport()144 static native int isRdsSupport(); 145 146 /** 147 * Switch antenna 148 * 149 * @param antenna antenna (0, long antenna, 1 short antenna) 150 * 151 * @return (0, success; 1 failed; 2 not support) 152 */ switchAntenna(int antenna)153 static native int switchAntenna(int antenna); 154 } 155