Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e597ce15 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Add background scan routines and callbacks to broadcast radio API.

Bug: b/34054813
Test: it builds.
Change-Id: I4483d1034f28af05d869cada672e9c0988bd4b65
parent 48a153e5
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -196,6 +196,19 @@ public class RadioManager {
            return mIsCaptureSupported;
        }

        /**
         * {@code true} if the module supports background scanning. At the given time it may not
         * be available though, see {@link RadioTuner#startBackgroundScan()}.
         *
         * @return {@code true} if background scanning is supported (not necessary available
         * at a given time), {@code false} otherwise.
         *
         * @hide FutureFeature
         */
        public boolean isBackgroundScanningSupported() {
            return false;
        }

        /** List of descriptors for all bands supported by this module.
         * @return an array of {@link BandDescriptor}.
         */
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class RadioModule extends RadioTuner {

    public native int getProgramInformation(RadioManager.ProgramInfo[] info);

    public native boolean startBackgroundScan();

    public native @NonNull List<RadioManager.ProgramInfo> getProgramList(@Nullable String filter);

    public native boolean isAntennaConnected();
+45 −1
Original line number Diff line number Diff line
@@ -211,6 +211,23 @@ public abstract class RadioTuner {
     */
    public abstract int getProgramInformation(RadioManager.ProgramInfo[] info);

    /**
     * Initiates a background scan to update internally cached program list.
     *
     * It may not be necessary to initiate the scan explicitly - the scan MAY be performed on boot.
     *
     * The operation is asynchronous and {@link Callback} backgroundScanComplete or onError will
     * be called if the return value of this call was {@code true}. As result of this call
     * programListChanged may be triggered (if the scanned list differs).
     *
     * @return {@code true} if the scan was properly scheduled, {@code false} if the scan feature
     * is unavailable; ie. temporarily due to ongoing foreground playback in single-tuner device
     * or permanently if the feature is not supported
     * (see ModuleProperties#isBackgroundScanningSupported()).
     * @hide FutureFeature
     */
    public abstract boolean startBackgroundScan();

    /**
     * Get the list of discovered radio stations.
     *
@@ -219,7 +236,8 @@ public abstract class RadioTuner {
     *
     * @param filter vendor-specific selector for radio stations.
     * @return a list of radio stations.
     * @throws IllegalStateException if the scan is in progress or has not been started.
     * @throws IllegalStateException if the scan is in progress or has not been started,
     *         startBackgroundScan() call may fix it.
     * @throws IllegalArgumentException if the filter argument is not valid.
     * @hide FutureFeature
     */
@@ -317,6 +335,32 @@ public abstract class RadioTuner {
         * with control set to {@code true}.
         */
        public void onControlChanged(boolean control) {}

        /**
         * onBackgroundScanAvailabilityChange() is called when background scan
         * feature becomes available or not.
         *
         * @param isAvailable true, if the tuner turned temporarily background-
         *                    capable, false in the other case.
         * @hide FutureFeature
         */
        public void onBackgroundScanAvailabilityChange(boolean isAvailable) {}

        /**
         * Called when a background scan completes successfully.
         *
         * @hide FutureFeature
         */
        public void onBackgroundScanComplete() {}

        /**
         * Called when available program list changed.
         *
         * Use getProgramList() to get the actual list.
         *
         * @hide FutureFeature
         */
        public void onProgramListChanged() {}
    }

}