blob: 3520f37880c5fac707df998badc1eff32a12e178 [file] [log] [blame]
Tomasz Wasilczykf58305d2017-12-28 14:03:15 -08001/**
2 * Copyright (C) 2017 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
17package com.android.server.broadcastradio.hal2;
18
19enum FrequencyBand {
20 UNKNOWN,
21 FM,
22 AM_LW,
23 AM_MW,
24 AM_SW,
25};
26
27class Utils {
28 private static final String TAG = "BcRadio2Srv.utils";
29
30 static FrequencyBand getBand(int freq) {
31 // keep in sync with hardware/interfaces/broadcastradio/common/utils2x/Utils.cpp
32 if (freq < 30) return FrequencyBand.UNKNOWN;
33 if (freq < 500) return FrequencyBand.AM_LW;
34 if (freq < 1705) return FrequencyBand.AM_MW;
35 if (freq < 30000) return FrequencyBand.AM_SW;
36 if (freq < 60000) return FrequencyBand.UNKNOWN;
37 if (freq < 110000) return FrequencyBand.FM;
38 return FrequencyBand.UNKNOWN;
39 }
40}