1 /* 2 * Copyright (C) 2019 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 package com.android.server.broadcastradio.hal2; 17 18 import android.hardware.broadcastradio.V2_0.ProgramInfo; 19 import android.hardware.radio.ProgramSelector; 20 import android.hardware.radio.RadioManager; 21 import android.hardware.radio.RadioMetadata; 22 23 import java.util.HashMap; 24 25 final class TestUtils { makeProgramInfo(int programType, ProgramSelector.Identifier identifier, int signalQuality)26 static RadioManager.ProgramInfo makeProgramInfo(int programType, 27 ProgramSelector.Identifier identifier, int signalQuality) { 28 // Note: If you set new fields, check if programInfoToHal() needs to be updated as well. 29 return new RadioManager.ProgramInfo(new ProgramSelector(programType, identifier, null, 30 null), null, null, null, 0, signalQuality, new RadioMetadata.Builder().build(), 31 new HashMap<String, String>()); 32 } 33 programInfoToHal(RadioManager.ProgramInfo info)34 static ProgramInfo programInfoToHal(RadioManager.ProgramInfo info) { 35 // Note that because Convert does not by design provide functions for all conversions, this 36 // function only copies fields that are set by makeProgramInfo(). 37 ProgramInfo hwInfo = new ProgramInfo(); 38 hwInfo.selector = Convert.programSelectorToHal(info.getSelector()); 39 hwInfo.signalQuality = info.getSignalStrength(); 40 return hwInfo; 41 } 42 } 43