1 /* 2 * Copyright (C) 2022 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 android.car.oem; 17 18 import android.annotation.NonNull; 19 import android.annotation.SystemApi; 20 import android.media.AudioFocusInfo; 21 22 import java.util.List; 23 24 /* 25 * OemCarAudioFocusServiceInterface would expose all the method from IOemCarAudioFocusService. It 26 * should always be in sync with IOemCarAudioFocusService. Oem will implement 27 * OemCarAudioFocusServiceInterface which would be used by OemCarAudioFocusService. 28 */ 29 /** 30 * Interface for Audio focus for OEM Service. 31 * 32 * @hide 33 */ 34 @SystemApi 35 public interface OemCarAudioFocusService extends OemCarServiceComponent { 36 /** 37 * Notifies of audio focus changes in car focus stack. It is one way call for OEM Service. 38 */ notifyAudioFocusChange(@onNull List<AudioFocusInfo> currentFocusHolders, @NonNull List<AudioFocusInfo> currentFocusLosers, int zoneId)39 void notifyAudioFocusChange(@NonNull List<AudioFocusInfo> currentFocusHolders, 40 @NonNull List<AudioFocusInfo> currentFocusLosers, int zoneId); 41 42 /** 43 * Call to evaluate a focus request, the request contains the information to make a decision. 44 * 45 * @param request current request containing the focus entry that triggered the current focus 46 * evaluation, the current focus holders, and current focus losers (focus requests that have 47 * transiently lost focus but can gain it again). 48 * 49 * @return the result of the focus request 50 * The result can be granted, delayed, or failed. In the case of granted the car audio stack 51 * will be changed according to the entries returned in newly loss and newly blocked. 52 * For delayed results the entry will be added as the current delayed request and it will be 53 * re-evaluated when any of the current focus holders abandons focus. For failed request, 54 * the car audio focus stack will not change and the current request will not gain focus. 55 * 56 * <p>Note: For the new focus losers and new blocked focus entries the focus loss can be 57 * permanent or transient. In the case of permanent loss the entry will receive permanent 58 * focus loss and it will be removed from the car audio focus stack. For transient losses, 59 * the new current request will become a blocker but will only receive transient focus loss. 60 * Everytime there is focus change the blocked entries will be re-evaluated to determine 61 * which can regain, lose, or continue with block focus. 62 **/ 63 @NonNull evaluateAudioFocusRequest( @onNull OemCarAudioFocusEvaluationRequest request)64 OemCarAudioFocusResult evaluateAudioFocusRequest( 65 @NonNull OemCarAudioFocusEvaluationRequest request); 66 } 67