/** * Copyright (C) 2017 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.FlaggedApi; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; 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.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Stream; /** * A set of identifiers necessary to tune to a given station. * *

This can hold various identifiers, like * *

  • AM/FM frequency
  • *
  • HD Radio subchannel
  • *
  • DAB channel info
  • * * *

    The primary ID uniquely identifies a station and can be used for equality * check. The secondary IDs are supplementary and can speed up tuning process, * but the primary ID is sufficient (ie. after a full band scan). * *

    Two selectors with different secondary IDs, but the same primary ID are * considered equal. In particular, secondary IDs vector may get updated for * an entry on the program list (ie. when a better frequency for a given * station is found). * *

    The primaryId of a given programType MUST be of a specific type: * *

  • AM, FM: RDS_PI if the station broadcasts RDS, AMFM_FREQUENCY otherwise;
  • *
  • AM_HD, FM_HD: HD_STATION_ID_EXT;
  • *
  • DAB: DAB_SIDECC;
  • *
  • DRMO: DRMO_SERVICE_ID;
  • *
  • SXM: SXM_SERVICE_ID;
  • *
  • VENDOR: VENDOR_PRIMARY.
  • * * @hide */ @SystemApi public final class ProgramSelector implements Parcelable { /** Invalid program type. * @deprecated use {@link IdentifierType} instead */ @Deprecated public static final int PROGRAM_TYPE_INVALID = 0; /** Analog AM radio (with or without RDS). * @deprecated use {@link IdentifierType} instead */ @Deprecated public static final int PROGRAM_TYPE_AM = 1; /** analog FM radio (with or without RDS). * @deprecated use {@link IdentifierType} instead */ @Deprecated public static final int PROGRAM_TYPE_FM = 2; /** AM HD Radio. * @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_AM_HD = 3; /** FM HD Radio. * @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_FM_HD = 4; /** Digital audio broadcasting. * @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_DAB = 5; /** Digital Radio Mondiale. * @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_DRMO = 6; /** SiriusXM Satellite Radio. * @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_SXM = 7; /** Vendor-specific, not synced across devices. * @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_VENDOR_START = 1000; /** @deprecated use {@link Identifier} instead */ @Deprecated public static final int PROGRAM_TYPE_VENDOR_END = 1999; /** * @deprecated use {@link Identifier} instead * @removed mistakenly exposed previously */ @Deprecated @IntDef(prefix = { "PROGRAM_TYPE_" }, value = { PROGRAM_TYPE_INVALID, PROGRAM_TYPE_AM, PROGRAM_TYPE_FM, PROGRAM_TYPE_AM_HD, PROGRAM_TYPE_FM_HD, PROGRAM_TYPE_DAB, PROGRAM_TYPE_DRMO, PROGRAM_TYPE_SXM, }) @IntRange(from = PROGRAM_TYPE_VENDOR_START, to = PROGRAM_TYPE_VENDOR_END) @Retention(RetentionPolicy.SOURCE) public @interface ProgramType {} /** * Bitmask for HD radio subchannel 1 * *

    There are at most 8 HD radio subchannels of 1-based om HD radio standard. It is * converted to 0-based index. 0 is the index of main program service (MPS). 1 to 7 are * indexes of additional supplemental program services (SPS). */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_1 = 1 << 0; /** * Bitmask for HD radio subchannel 2 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_2 = 1 << 1; /** * Bitmask for HD radio subchannel 3 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_3 = 1 << 2; /** * Bitmask for HD radio subchannel 4 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_4 = 1 << 3; /** * Bitmask for HD radio subchannel 5 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_5 = 1 << 4; /** * Bitmask for HD radio subchannel 6 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_6 = 1 << 5; /** * Bitmask for HD radio subchannel 7 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_7 = 1 << 6; /** * Bitmask for HD radio subchannel 8 * *

    For further reference, see {@link #SUB_CHANNEL_HD_1} */ @FlaggedApi(Flags.FLAG_HD_RADIO_IMPROVED) public static final int SUB_CHANNEL_HD_8 = 1 << 7; /** @hide */ @IntDef(prefix = { "SUB_CHANNEL_HD_" }, value = { SUB_CHANNEL_HD_1, SUB_CHANNEL_HD_2, SUB_CHANNEL_HD_3, SUB_CHANNEL_HD_4, SUB_CHANNEL_HD_5, SUB_CHANNEL_HD_6, SUB_CHANNEL_HD_7, SUB_CHANNEL_HD_8, }) @Retention(RetentionPolicy.SOURCE) public @interface HdSubChannel {} public static final int IDENTIFIER_TYPE_INVALID = 0; /** * Primary identifier for analog (without RDS) AM/FM stations: * frequency in kHz. * *

    This identifier also contains band information: *

  • *