TunerAdapter.java revision 347192e0da1f39347e7ab7b58b002f166b4afaa7
1/**
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 android.hardware.radio;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.os.RemoteException;
22import android.util.Log;
23
24import java.util.ArrayList;
25import java.util.List;
26
27/**
28 * Implements the RadioTuner interface by forwarding calls to radio service.
29 */
30class TunerAdapter extends RadioTuner {
31    private static final String TAG = "radio.TunerAdapter";
32
33    @NonNull private final ITuner mTuner;
34
35    TunerAdapter(ITuner tuner) {
36        if (tuner == null) {
37            throw new NullPointerException();
38        }
39        mTuner = tuner;
40    }
41
42    @Override
43    public void close() {
44        // TODO(b/36863239): forward to mTuner
45        Log.w(TAG, "Close call not implemented");
46    }
47
48    @Override
49    public int setConfiguration(RadioManager.BandConfig config) {
50        // TODO(b/36863239): forward to mTuner
51        throw new RuntimeException("Not implemented");
52    }
53
54    @Override
55    public int getConfiguration(RadioManager.BandConfig[] config) {
56        // TODO(b/36863239): forward to mTuner
57        throw new RuntimeException("Not implemented");
58    }
59
60    @Override
61    public int setMute(boolean mute) {
62        // TODO(b/36863239): forward to mTuner
63        throw new RuntimeException("Not implemented");
64    }
65
66    @Override
67    public boolean getMute() {
68        // TODO(b/36863239): forward to mTuner
69        throw new RuntimeException("Not implemented");
70    }
71
72    @Override
73    public int step(int direction, boolean skipSubChannel) {
74        // TODO(b/36863239): forward to mTuner
75        throw new RuntimeException("Not implemented");
76    }
77
78    @Override
79    public int scan(int direction, boolean skipSubChannel) {
80        // TODO(b/36863239): forward to mTuner
81        throw new RuntimeException("Not implemented");
82    }
83
84    @Override
85    public int tune(int channel, int subChannel) {
86        // TODO(b/36863239): forward to mTuner
87        throw new RuntimeException("Not implemented");
88    }
89
90    @Override
91    public int cancel() {
92        // TODO(b/36863239): forward to mTuner
93        throw new RuntimeException("Not implemented");
94    }
95
96    @Override
97    public int getProgramInformation(RadioManager.ProgramInfo[] info) {
98        if (info == null || info.length != 1) {
99            throw new IllegalArgumentException("The argument must be an array of length 1");
100        }
101        try {
102            return mTuner.getProgramInformation(info);
103        } catch (RemoteException e) {
104            throw e.rethrowFromSystemServer();
105        }
106    }
107
108    @Override
109    public boolean startBackgroundScan() {
110        // TODO(b/36863239): forward to mTuner
111        throw new RuntimeException("Not implemented");
112    }
113
114    @Override
115    public @NonNull List<RadioManager.ProgramInfo> getProgramList(@Nullable String filter) {
116        // TODO(b/36863239): forward to mTuner
117        throw new RuntimeException("Not implemented");
118    }
119
120    @Override
121    public boolean isAnalogForced() {
122        // TODO(b/36863239): forward to mTuner
123        throw new RuntimeException("Not implemented");
124    }
125
126    @Override
127    public void setAnalogForced(boolean isForced) {
128        // TODO(b/36863239): forward to mTuner
129        throw new RuntimeException("Not implemented");
130    }
131
132    @Override
133    public boolean isAntennaConnected() {
134        // TODO(b/36863239): forward to mTuner
135        throw new RuntimeException("Not implemented");
136    }
137
138    @Override
139    public boolean hasControl() {
140        // TODO(b/36863239): forward to mTuner
141        throw new RuntimeException("Not implemented");
142    }
143}
144