1 /*
2  * Copyright (C) 2015 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 android.hardware.radio;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 import android.graphics.Bitmap;
23 import android.os.Handler;
24 
25 import java.util.List;
26 import java.util.Map;
27 
28 /**
29  * RadioTuner interface provides methods to control a radio tuner on the device: selecting and
30  * configuring the active band, muting/unmuting, scanning and tuning, etc...
31  *
32  * Obtain a RadioTuner interface by calling {@link RadioManager#openTuner(int,
33  * RadioManager.BandConfig, boolean, RadioTuner.Callback, Handler)}.
34  * @hide
35  */
36 @SystemApi
37 public abstract class RadioTuner {
38 
39     /** Scanning direction UP for {@link #step(int, boolean)}, {@link #scan(int, boolean)} */
40     public static final int DIRECTION_UP      = 0;
41 
42     /** Scanning directions DOWN for {@link #step(int, boolean)}, {@link #scan(int, boolean)} */
43     public static final int DIRECTION_DOWN    = 1;
44 
45     /**
46      * Close the tuner interface. The {@link Callback} callback will not be called
47      * anymore and associated resources will be released.
48      * Must be called when the tuner is not needed to make hardware resources available to others.
49      * */
close()50     public abstract void close();
51 
52     /**
53      * Set the active band configuration for this module.
54      * Must be a valid configuration obtained via buildConfig() from a valid BandDescriptor listed
55      * in the ModuleProperties of the module with the specified ID.
56      * @param config The desired band configuration (FmBandConfig or AmBandConfig).
57      * @return
58      * <ul>
59      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
60      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
61      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
62      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
63      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
64      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
65      *  service fails, </li>
66      * </ul>
67      * @deprecated Only applicable for HAL 1.x.
68      */
69     @Deprecated
setConfiguration(RadioManager.BandConfig config)70     public abstract int setConfiguration(RadioManager.BandConfig config);
71 
72     /**
73      * Get current configuration.
74      * @param config a BandConfig array of lengh 1 where the configuration is returned.
75      * @return
76      * <ul>
77      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
78      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
79      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
80      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
81      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
82      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
83      *  service fails, </li>
84      * </ul>
85      *
86      * @deprecated Only applicable for HAL 1.x.
87      */
88     @Deprecated
getConfiguration(RadioManager.BandConfig[] config)89     public abstract int getConfiguration(RadioManager.BandConfig[] config);
90 
91 
92     /**
93      * Set mute state. When muted, the radio tuner audio source is not available for playback on
94      * any audio device. when unmuted, the radio tuner audio source is output as a media source
95      * and renderd over the audio device selected for media use case.
96      * The radio tuner audio source is muted by default when the tuner is first attached.
97      * Only effective if the tuner is attached with audio enabled.
98      *
99      * @param mute the requested mute state.
100      * @return
101      * <ul>
102      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
103      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
104      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
105      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
106      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
107      *  service fails, </li>
108      * </ul>
109      */
setMute(boolean mute)110     public abstract int setMute(boolean mute);
111 
112     /**
113      * Get mute state.
114      *
115      * @return {@code true} if the radio tuner audio source is muted or a problem occured
116      * retrieving the mute state, {@code false} otherwise.
117      */
getMute()118     public abstract boolean getMute();
119 
120     /**
121      * Step up or down by one channel spacing.
122      * The operation is asynchronous and {@link Callback}
123      * onProgramInfoChanged() will be called when step completes or
124      * onError() when cancelled or timeout.
125      * @param direction {@link #DIRECTION_UP} or {@link #DIRECTION_DOWN}.
126      * @param skipSubChannel indicates to skip sub channels when the configuration currently
127      * selected supports sub channel (e.g HD Radio). N/A otherwise.
128      * @return
129      * <ul>
130      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
131      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
132      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
133      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
134      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
135      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
136      *  service fails, </li>
137      * </ul>
138      */
step(int direction, boolean skipSubChannel)139     public abstract int step(int direction, boolean skipSubChannel);
140 
141     /**
142      * Scan up or down to next valid station.
143      * The operation is asynchronous and {@link Callback}
144      * onProgramInfoChanged() will be called when scan completes or
145      * onError() when cancelled or timeout.
146      * @param direction {@link #DIRECTION_UP} or {@link #DIRECTION_DOWN}.
147      * @param skipSubChannel indicates to skip sub channels when the configuration currently
148      * selected supports sub channel (e.g HD Radio). N/A otherwise.
149      * @return
150      * <ul>
151      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
152      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
153      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
154      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
155      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
156      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
157      *  service fails, </li>
158      * </ul>
159      */
scan(int direction, boolean skipSubChannel)160     public abstract int scan(int direction, boolean skipSubChannel);
161 
162     /**
163      * Tune to a specific frequency.
164      * The operation is asynchronous and {@link Callback}
165      * onProgramInfoChanged() will be called when tune completes or
166      * onError() when cancelled or timeout.
167      * @param channel the specific channel or frequency to tune to.
168      * @param subChannel the specific sub-channel to tune to. N/A if the selected configuration
169      * does not support cub channels.
170      * @return
171      * <ul>
172      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
173      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
174      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
175      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
176      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
177      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
178      *  service fails, </li>
179      * </ul>
180      * @deprecated Use {@link tune(ProgramSelector)} instead.
181      */
182     @Deprecated
tune(int channel, int subChannel)183     public abstract int tune(int channel, int subChannel);
184 
185     /**
186      * Tune to a program.
187      *
188      * The operation is asynchronous and {@link Callback} onProgramInfoChanged() will be called
189      * when tune completes or onError() when cancelled or on timeout.
190      *
191      * @throws IllegalArgumentException if the provided selector is invalid
192      */
tune(@onNull ProgramSelector selector)193     public abstract void tune(@NonNull ProgramSelector selector);
194 
195     /**
196      * Cancel a pending scan or tune operation.
197      * If an operation is pending, {@link Callback} onError() will be called with
198      * {@link #ERROR_CANCELLED}.
199      * @return
200      * <ul>
201      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
202      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
203      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
204      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
205      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
206      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
207      *  service fails, </li>
208      * </ul>
209      */
cancel()210     public abstract int cancel();
211 
212     /**
213      * Cancels traffic or emergency announcement.
214      *
215      * If there was no announcement to cancel, no action is taken.
216      *
217      * There is a race condition between calling cancelAnnouncement and the actual announcement
218      * being finished, so onTrafficAnnouncement / onEmergencyAnnouncement callback should be
219      * tracked with proper locking.
220      */
cancelAnnouncement()221     public abstract void cancelAnnouncement();
222 
223     /**
224      * Get current station information.
225      * @param info a ProgramInfo array of lengh 1 where the information is returned.
226      * @return
227      * <ul>
228      *  <li>{@link RadioManager#STATUS_OK} in case of success, </li>
229      *  <li>{@link RadioManager#STATUS_ERROR} in case of unspecified error, </li>
230      *  <li>{@link RadioManager#STATUS_NO_INIT} if the native service cannot be reached, </li>
231      *  <li>{@link RadioManager#STATUS_BAD_VALUE} if parameters are invalid, </li>
232      *  <li>{@link RadioManager#STATUS_INVALID_OPERATION} if the call is out of sequence, </li>
233      *  <li>{@link RadioManager#STATUS_DEAD_OBJECT} if the binder transaction to the native
234      *  service fails, </li>
235      * </ul>
236      * @deprecated Use {@link onProgramInfoChanged} callback instead.
237      */
238     @Deprecated
getProgramInformation(RadioManager.ProgramInfo[] info)239     public abstract int getProgramInformation(RadioManager.ProgramInfo[] info);
240 
241     /**
242      * Retrieves a {@link Bitmap} for the given image ID or null,
243      * if the image was missing from the tuner.
244      *
245      * This involves doing a call to the tuner, so the bitmap should be cached
246      * on the application side.
247      *
248      * If the method returns null for non-zero ID, it means the image was
249      * updated on the tuner side. There is a race conditon between fetching
250      * image for an old ID and tuner updating the image (and cleaning up the
251      * old image). In such case, a new ProgramInfo with updated image id will
252      * be sent with a {@link onProgramInfoChanged} callback.
253      *
254      * @param id The image identifier, retrieved with
255      *           {@link RadioMetadata#getBitmapId(String)}.
256      * @return A {@link Bitmap} or null.
257      * @throws IllegalArgumentException if id==0
258      * @hide This API is not thoroughly elaborated yet
259      */
getMetadataImage(int id)260     public abstract @Nullable Bitmap getMetadataImage(int id);
261 
262     /**
263      * Initiates a background scan to update internally cached program list.
264      *
265      * It may not be necessary to initiate the scan explicitly - the scan MAY be performed on boot.
266      *
267      * The operation is asynchronous and {@link Callback} backgroundScanComplete or onError will
268      * be called if the return value of this call was {@code true}. As result of this call
269      * programListChanged may be triggered (if the scanned list differs).
270      *
271      * @return {@code true} if the scan was properly scheduled, {@code false} if the scan feature
272      * is unavailable; ie. temporarily due to ongoing foreground playback in single-tuner device
273      * or permanently if the feature is not supported
274      * (see ModuleProperties#isBackgroundScanningSupported()).
275      */
startBackgroundScan()276     public abstract boolean startBackgroundScan();
277 
278     /**
279      * Get the list of discovered radio stations.
280      *
281      * To get the full list, set filter to null or empty map.
282      * Keys must be prefixed with unique vendor Java-style namespace,
283      * eg. 'com.somecompany.parameter1'.
284      *
285      * @param vendorFilter vendor-specific selector for radio stations.
286      * @return a list of radio stations.
287      * @throws IllegalStateException if the scan is in progress or has not been started,
288      *         startBackgroundScan() call may fix it.
289      * @throws IllegalArgumentException if the vendorFilter argument is not valid.
290      * @deprecated Use {@link getDynamicProgramList} instead.
291      */
292     @Deprecated
293     public abstract @NonNull List<RadioManager.ProgramInfo>
getProgramList(@ullable Map<String, String> vendorFilter)294             getProgramList(@Nullable Map<String, String> vendorFilter);
295 
296     /**
297      * Get the dynamic list of discovered radio stations.
298      *
299      * The list object is updated asynchronously; to get the updates register
300      * with {@link ProgramList#addListCallback}.
301      *
302      * When the returned object is no longer used, it must be closed.
303      *
304      * @param filter filter for the list, or null to get the full list.
305      * @return the dynamic program list object, close it after use
306      *         or {@code null} if program list is not supported by the tuner
307      */
getDynamicProgramList(@ullable ProgramList.Filter filter)308     public @Nullable ProgramList getDynamicProgramList(@Nullable ProgramList.Filter filter) {
309         return null;
310     }
311 
312     /**
313      * Checks, if the analog playback is forced, see setAnalogForced.
314      *
315      * @throws IllegalStateException if the switch is not supported at current
316      *         configuration.
317      * @return {@code true} if analog is forced, {@code false} otherwise.
318      * @deprecated Use {@link isConfigFlagSet(int)} instead.
319      */
320     @Deprecated
isAnalogForced()321     public abstract boolean isAnalogForced();
322 
323     /**
324      * Forces the analog playback for the supporting radio technology.
325      *
326      * User may disable digital playback for FM HD Radio or hybrid FM/DAB with
327      * this option. This is purely user choice, ie. does not reflect digital-
328      * analog handover managed from the HAL implementation side.
329      *
330      * Some radio technologies may not support this, ie. DAB.
331      *
332      * @param isForced {@code true} to force analog, {@code false} for a default behaviour.
333      * @throws IllegalStateException if the switch is not supported at current
334      *         configuration.
335      * @deprecated Use {@link setConfigFlag(int, boolean)} instead.
336      */
337     @Deprecated
setAnalogForced(boolean isForced)338     public abstract void setAnalogForced(boolean isForced);
339 
340     /**
341      * Checks, if a given config flag is supported
342      *
343      * @param flag Flag to check.
344      * @return True, if the flag is supported.
345      */
isConfigFlagSupported(@adioManager.ConfigFlag int flag)346     public boolean isConfigFlagSupported(@RadioManager.ConfigFlag int flag) {
347         return false;
348     }
349 
350     /**
351      * Fetches the current setting of a given config flag.
352      *
353      * The success/failure result is consistent with isConfigFlagSupported.
354      *
355      * @param flag Flag to fetch.
356      * @return The current value of the flag.
357      * @throws IllegalStateException if the flag is not applicable right now.
358      * @throws UnsupportedOperationException if the flag is not supported at all.
359      */
isConfigFlagSet(@adioManager.ConfigFlag int flag)360     public boolean isConfigFlagSet(@RadioManager.ConfigFlag int flag) {
361         throw new UnsupportedOperationException();
362     }
363 
364     /**
365      * Sets the config flag.
366      *
367      * The success/failure result is consistent with isConfigFlagSupported.
368      *
369      * @param flag Flag to set.
370      * @param value The new value of a given flag.
371      * @throws IllegalStateException if the flag is not applicable right now.
372      * @throws UnsupportedOperationException if the flag is not supported at all.
373      */
setConfigFlag(@adioManager.ConfigFlag int flag, boolean value)374     public void setConfigFlag(@RadioManager.ConfigFlag int flag, boolean value) {
375         throw new UnsupportedOperationException();
376     }
377 
378     /**
379      * Generic method for setting vendor-specific parameter values.
380      * The framework does not interpret the parameters, they are passed
381      * in an opaque manner between a vendor application and HAL.
382      *
383      * Framework does not make any assumptions on the keys or values, other than
384      * ones stated in VendorKeyValue documentation (a requirement of key
385      * prefixes).
386      * See VendorKeyValue at hardware/interfaces/broadcastradio/2.0/types.hal.
387      *
388      * For each pair in the result map, the key will be one of the keys
389      * contained in the input (possibly with wildcards expanded), and the value
390      * will be a vendor-specific result status (such as "OK" or an error code).
391      * The implementation may choose to return an empty map, or only return
392      * a status for a subset of the provided inputs, at its discretion.
393      *
394      * Application and HAL must not use keys with unknown prefix. In particular,
395      * it must not place a key-value pair in results vector for unknown key from
396      * parameters vector - instead, an unknown key should simply be ignored.
397      * In other words, results vector may contain a subset of parameter keys
398      * (however, the framework doesn't enforce a strict subset - the only
399      * formal requirement is vendor domain prefix for keys).
400      *
401      * @param parameters Vendor-specific key-value pairs.
402      * @return Operation completion status for parameters being set.
403      */
404     public @NonNull Map<String, String>
setParameters(@onNull Map<String, String> parameters)405             setParameters(@NonNull Map<String, String> parameters) {
406         throw new UnsupportedOperationException();
407     }
408 
409     /**
410      * Generic method for retrieving vendor-specific parameter values.
411      * The framework does not interpret the parameters, they are passed
412      * in an opaque manner between a vendor application and HAL.
413      *
414      * Framework does not cache set/get requests, so it's possible for
415      * getParameter to return a different value than previous setParameter call.
416      *
417      * The syntax and semantics of keys are up to the vendor (as long as prefix
418      * rules are obeyed). For instance, vendors may include some form of
419      * wildcard support. In such case, result vector may be of different size
420      * than requested keys vector. However, wildcards are not recognized by
421      * framework and they are passed as-is to the HAL implementation.
422      *
423      * Unknown keys must be ignored and not placed into results vector.
424      *
425      * @param keys Parameter keys to fetch.
426      * @return Vendor-specific key-value pairs.
427      */
428     public @NonNull Map<String, String>
getParameters(@onNull List<String> keys)429             getParameters(@NonNull List<String> keys) {
430         throw new UnsupportedOperationException();
431     }
432 
433     /**
434      * Get current antenna connection state for current configuration.
435      * Only valid if a configuration has been applied.
436      * @return {@code true} if the antenna is connected, {@code false} otherwise.
437      *
438      * @deprecated Use {@link onAntennaState} callback instead
439      */
440     @Deprecated
isAntennaConnected()441     public abstract boolean isAntennaConnected();
442 
443     /**
444      * Indicates if this client actually controls the tuner.
445      * Control is always granted after
446      * {@link RadioManager#openTuner(int,
447      * RadioManager.BandConfig, boolean, Callback, Handler)}
448      * returns a non null tuner interface.
449      * Control is lost when another client opens an interface on the same tuner.
450      * When this happens, {@link Callback#onControlChanged(boolean)} is received.
451      * The client can either wait for control to be returned (which is indicated by the same
452      * callback) or close and reopen the tuner interface.
453      * @return {@code true} if this interface controls the tuner,
454      * {@code false} otherwise or if a problem occured retrieving the state.
455      */
hasControl()456     public abstract boolean hasControl();
457 
458     /** Indicates a failure of radio IC or driver.
459      * The application must close and re open the tuner
460      * @deprecated See {@link onError} callback.
461      */
462     @Deprecated
463     public static final int ERROR_HARDWARE_FAILURE = 0;
464     /** Indicates a failure of the radio service.
465      * The application must close and re open the tuner
466      * @deprecated See {@link onError} callback.
467      */
468     @Deprecated
469     public static final  int ERROR_SERVER_DIED = 1;
470     /** A pending seek or tune operation was cancelled
471      * @deprecated See {@link onError} callback.
472      */
473     @Deprecated
474     public static final  int ERROR_CANCELLED = 2;
475     /** A pending seek or tune operation timed out
476      * @deprecated See {@link onError} callback.
477      */
478     @Deprecated
479     public static final  int ERROR_SCAN_TIMEOUT = 3;
480     /** The requested configuration could not be applied
481      * @deprecated See {@link onError} callback.
482      */
483     @Deprecated
484     public static final  int ERROR_CONFIG = 4;
485     /** Background scan was interrupted due to hardware becoming temporarily unavailable.
486      * @deprecated See {@link onError} callback.
487      */
488     @Deprecated
489     public static final int ERROR_BACKGROUND_SCAN_UNAVAILABLE = 5;
490     /** Background scan failed due to other error, ie. HW failure.
491      * @deprecated See {@link onError} callback.
492      */
493     @Deprecated
494     public static final int ERROR_BACKGROUND_SCAN_FAILED = 6;
495 
496     /**
497      * Callback provided by the client application when opening a {@link RadioTuner}
498      * to receive asynchronous operation results, updates and error notifications.
499      */
500     public static abstract class Callback {
501         /**
502          * onError() is called when an error occured while performing an asynchronous
503          * operation of when the hardware or system service experiences a problem.
504          * status is one of {@link #ERROR_HARDWARE_FAILURE}, {@link #ERROR_SERVER_DIED},
505          * {@link #ERROR_CANCELLED}, {@link #ERROR_SCAN_TIMEOUT},
506          * {@link #ERROR_CONFIG}
507          *
508          * @deprecated Use {@link onTuneFailed} for tune, scan and step;
509          *             other use cases (configuration, background scan) are already deprecated.
510          */
onError(int status)511         public void onError(int status) {}
512 
513         /**
514          * Called when tune, scan or step operation fails.
515          *
516          * @param result cause of the failure
517          * @param selector ProgramSelector argument of tune that failed;
518          *                 null for scan and step.
519          */
onTuneFailed(int result, @Nullable ProgramSelector selector)520         public void onTuneFailed(int result, @Nullable ProgramSelector selector) {}
521 
522         /**
523          * onConfigurationChanged() is called upon successful completion of
524          * {@link RadioManager#openTuner(int, RadioManager.BandConfig, boolean, Callback, Handler)}
525          * or {@link RadioTuner#setConfiguration(RadioManager.BandConfig)}
526          *
527          * @deprecated Only applicable for HAL 1.x.
528          */
529         @Deprecated
onConfigurationChanged(RadioManager.BandConfig config)530         public void onConfigurationChanged(RadioManager.BandConfig config) {}
531 
532         /**
533          * Called when program info (including metadata) for the current program has changed.
534          *
535          * It happens either upon successful completion of {@link RadioTuner#step(int, boolean)},
536          * {@link RadioTuner#scan(int, boolean)}, {@link RadioTuner#tune(int, int)}; when
537          * a switching to alternate frequency occurs; or when metadata is updated.
538          */
onProgramInfoChanged(RadioManager.ProgramInfo info)539         public void onProgramInfoChanged(RadioManager.ProgramInfo info) {}
540 
541         /**
542          * Called when metadata is updated for the current program.
543          *
544          * @deprecated Use {@link #onProgramInfoChanged(RadioManager.ProgramInfo)} instead.
545          */
546         @Deprecated
onMetadataChanged(RadioMetadata metadata)547         public void onMetadataChanged(RadioMetadata metadata) {}
548 
549         /**
550          * onTrafficAnnouncement() is called when a traffic announcement starts and stops.
551          */
onTrafficAnnouncement(boolean active)552         public void onTrafficAnnouncement(boolean active) {}
553         /**
554          * onEmergencyAnnouncement() is called when an emergency annoucement starts and stops.
555          */
onEmergencyAnnouncement(boolean active)556         public void onEmergencyAnnouncement(boolean active) {}
557         /**
558          * onAntennaState() is called when the antenna is connected or disconnected.
559          */
onAntennaState(boolean connected)560         public void onAntennaState(boolean connected) {}
561         /**
562          * onControlChanged() is called when the client loses or gains control of the radio tuner.
563          * The control is always granted after a successful call to
564          * {@link RadioManager#openTuner(int, RadioManager.BandConfig, boolean, Callback, Handler)}.
565          * If another client opens the same tuner, onControlChanged() will be called with
566          * control set to {@code false} to indicate loss of control.
567          * At this point, RadioTuner APIs other than getters will return
568          * {@link RadioManager#STATUS_INVALID_OPERATION}.
569          * When the other client releases the tuner, onControlChanged() will be called
570          * with control set to {@code true}.
571          */
onControlChanged(boolean control)572         public void onControlChanged(boolean control) {}
573 
574         /**
575          * onBackgroundScanAvailabilityChange() is called when background scan
576          * feature becomes available or not.
577          *
578          * @param isAvailable true, if the tuner turned temporarily background-
579          *                    capable, false in the other case.
580          */
onBackgroundScanAvailabilityChange(boolean isAvailable)581         public void onBackgroundScanAvailabilityChange(boolean isAvailable) {}
582 
583         /**
584          * Called when a background scan completes successfully.
585          */
onBackgroundScanComplete()586         public void onBackgroundScanComplete() {}
587 
588         /**
589          * Called when available program list changed.
590          *
591          * Use {@link RadioTuner#getProgramList(String)} to get an actual list.
592          */
onProgramListChanged()593         public void onProgramListChanged() {}
594 
595         /**
596          * Generic callback for passing updates to vendor-specific parameter values.
597          * The framework does not interpret the parameters, they are passed
598          * in an opaque manner between a vendor application and HAL.
599          *
600          * It's up to the HAL implementation if and how to implement this callback,
601          * as long as it obeys the prefix rule. In particular, only selected keys
602          * may be notified this way. However, setParameters must not trigger
603          * this callback, while an internal event can change parameters
604          * asynchronously.
605          *
606          * @param parameters Vendor-specific key-value pairs.
607          */
onParametersUpdated(@onNull Map<String, String> parameters)608         public void onParametersUpdated(@NonNull Map<String, String> parameters) {}
609     }
610 
611 }
612 
613