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

Commit ff73b838 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ia3065eb5,I602e8bb0

* changes:
  Update ProgramInfo to match HAL 2.0 changes.
  Implement front-end APIs for announcements.
parents 5673793a eab3e550
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -178,6 +178,8 @@ java_library {
        "core/java/android/hardware/location/IContextHubClientCallback.aidl",
        "core/java/android/hardware/location/IContextHubService.aidl",
        "core/java/android/hardware/location/IContextHubTransactionCallback.aidl",
        "core/java/android/hardware/radio/IAnnouncementListener.aidl",
        "core/java/android/hardware/radio/ICloseHandle.aidl",
        "core/java/android/hardware/radio/IRadioService.aidl",
        "core/java/android/hardware/radio/ITuner.aidl",
        "core/java/android/hardware/radio/ITunerCallback.aidl",
+29 −1
Original line number Diff line number Diff line
@@ -1738,6 +1738,27 @@ package android.hardware.location {

package android.hardware.radio {

  public final class Announcement implements android.os.Parcelable {
    method public int describeContents();
    method public android.hardware.radio.ProgramSelector getSelector();
    method public int getType();
    method public java.util.Map<java.lang.String, java.lang.String> getVendorInfo();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.radio.Announcement> CREATOR;
    field public static final int TYPE_EMERGENCY = 1; // 0x1
    field public static final int TYPE_EVENT = 6; // 0x6
    field public static final int TYPE_MISC = 8; // 0x8
    field public static final int TYPE_NEWS = 5; // 0x5
    field public static final int TYPE_SPORT = 7; // 0x7
    field public static final int TYPE_TRAFFIC = 3; // 0x3
    field public static final int TYPE_WARNING = 2; // 0x2
    field public static final int TYPE_WEATHER = 4; // 0x4
  }

  public static abstract interface Announcement.OnListUpdatedListener {
    method public abstract void onListUpdated(java.util.Collection<android.hardware.radio.Announcement>);
  }

  public final class ProgramList implements java.lang.AutoCloseable {
    method public void addOnCompleteListener(java.util.concurrent.Executor, android.hardware.radio.ProgramList.OnCompleteListener);
    method public void addOnCompleteListener(android.hardware.radio.ProgramList.OnCompleteListener);
@@ -1782,6 +1803,7 @@ package android.hardware.radio {
    method public deprecated int getProgramType();
    method public android.hardware.radio.ProgramSelector.Identifier[] getSecondaryIds();
    method public deprecated long[] getVendorIds();
    method public android.hardware.radio.ProgramSelector withSecondaryPreferred(android.hardware.radio.ProgramSelector.Identifier);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.radio.ProgramSelector> CREATOR;
    field public static final int IDENTIFIER_TYPE_AMFM_FREQUENCY = 1; // 0x1
@@ -1832,8 +1854,11 @@ package android.hardware.radio {
  }

  public class RadioManager {
    method public void addAnnouncementListener(java.util.Set<java.lang.Integer>, android.hardware.radio.Announcement.OnListUpdatedListener);
    method public void addAnnouncementListener(java.util.concurrent.Executor, java.util.Set<java.lang.Integer>, android.hardware.radio.Announcement.OnListUpdatedListener);
    method public int listModules(java.util.List<android.hardware.radio.RadioManager.ModuleProperties>);
    method public android.hardware.radio.RadioTuner openTuner(int, android.hardware.radio.RadioManager.BandConfig, boolean, android.hardware.radio.RadioTuner.Callback, android.os.Handler);
    method public void removeAnnouncementListener(android.hardware.radio.Announcement.OnListUpdatedListener);
    field public static final int BAND_AM = 0; // 0x0
    field public static final int BAND_AM_HD = 3; // 0x3
    field public static final int BAND_FM = 1; // 0x1
@@ -1963,12 +1988,15 @@ package android.hardware.radio {
  public static class RadioManager.ProgramInfo implements android.os.Parcelable {
    method public int describeContents();
    method public deprecated int getChannel();
    method public android.hardware.radio.ProgramSelector.Identifier getLogicallyTunedTo();
    method public android.hardware.radio.RadioMetadata getMetadata();
    method public android.hardware.radio.ProgramSelector.Identifier getPhysicallyTunedTo();
    method public java.util.Collection<android.hardware.radio.ProgramSelector.Identifier> getRelatedContent();
    method public android.hardware.radio.ProgramSelector getSelector();
    method public int getSignalStrength();
    method public deprecated int getSubChannel();
    method public java.util.Map<java.lang.String, java.lang.String> getVendorInfo();
    method public boolean isDigital();
    method public deprecated boolean isDigital();
    method public boolean isLive();
    method public boolean isMuted();
    method public boolean isStereo();
+20 −0
Original line number Diff line number Diff line
/**
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.radio;

/** @hide */
parcelable Announcement;
+133 −0
Original line number Diff line number Diff line
/**
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.radio;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;

/**
 * @hide
 */
@SystemApi
public final class Announcement implements Parcelable {

    /** DAB alarm, RDS emergency program type (PTY 31). */
    public static final int TYPE_EMERGENCY = 1;
    /** DAB warning. */
    public static final int TYPE_WARNING = 2;
    /** DAB road traffic, RDS TA, HD Radio transportation. */
    public static final int TYPE_TRAFFIC = 3;
    /** Weather. */
    public static final int TYPE_WEATHER = 4;
    /** News. */
    public static final int TYPE_NEWS = 5;
    /** DAB event, special event. */
    public static final int TYPE_EVENT = 6;
    /** DAB sport report, RDS sports. */
    public static final int TYPE_SPORT = 7;
    /** All others. */
    public static final int TYPE_MISC = 8;
    /** @hide */
    @IntDef(prefix = { "TYPE_" }, value = {
        TYPE_EMERGENCY,
        TYPE_WARNING,
        TYPE_TRAFFIC,
        TYPE_WEATHER,
        TYPE_NEWS,
        TYPE_EVENT,
        TYPE_SPORT,
        TYPE_MISC,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Type {}

    /**
     * Listener of announcement list events.
     */
    public interface OnListUpdatedListener {
        /**
         * An event called whenever a list of active announcements change.
         *
         * The entire list is sent each time a new announcement appears or any ends broadcasting.
         *
         * @param activeAnnouncements a full list of active announcements
         */
        void onListUpdated(Collection<Announcement> activeAnnouncements);
    }

    @NonNull private final ProgramSelector mSelector;
    @Type private final int mType;
    @NonNull private final Map<String, String> mVendorInfo;

    /** @hide */
    public Announcement(@NonNull ProgramSelector selector, @Type int type,
            @NonNull Map<String, String> vendorInfo) {
        mSelector = Objects.requireNonNull(selector);
        mType = Objects.requireNonNull(type);
        mVendorInfo = Objects.requireNonNull(vendorInfo);
    }

    private Announcement(@NonNull Parcel in) {
        mSelector = in.readTypedObject(ProgramSelector.CREATOR);
        mType = in.readInt();
        mVendorInfo = Utils.readStringMap(in);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedObject(mSelector, 0);
        dest.writeInt(mType);
        Utils.writeStringMap(dest, mVendorInfo);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Parcelable.Creator<Announcement> CREATOR =
            new Parcelable.Creator<Announcement>() {
        public Announcement createFromParcel(Parcel in) {
            return new Announcement(in);
        }

        public Announcement[] newArray(int size) {
            return new Announcement[size];
        }
    };

    public @NonNull ProgramSelector getSelector() {
        return mSelector;
    }

    public @Type int getType() {
        return mType;
    }

    public @NonNull Map<String, String> getVendorInfo() {
        return mVendorInfo;
    }
}
+24 −0
Original line number Diff line number Diff line
/**
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.radio;

import android.hardware.radio.Announcement;

/** {@hide} */
oneway interface IAnnouncementListener {
    void onListUpdated(in List<Announcement> activeAnnouncements);
}
Loading