blob: fb72ac282e8d19e44dbaab29fb11813120cedd27 [file] [log] [blame]
Aurimas Liutikas88c7ff12023-08-10 12:42:26 -07001/*
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.audio;
18
19import android.annotation.NonNull;
20
21public interface PlayerFocusEnforcer {
22
23 /**
24 * Ducks the players associated with the "loser" focus owner (i.e. same UID). Returns true if
25 * at least one active player was found and ducked, false otherwise.
26 * @param winner
27 * @param loser
28 * @return
29 */
30 boolean duckPlayers(@NonNull FocusRequester winner, @NonNull FocusRequester loser,
31 boolean forceDuck);
32
33 /**
34 * Restore the initial state of any players that had had a volume ramp applied as the result
35 * of a duck or fade out through {@link #duckPlayers(FocusRequester, FocusRequester, boolean)}
36 * or {@link #fadeOutPlayers(FocusRequester, FocusRequester)}
37 * @param winner
38 */
39 void restoreVShapedPlayers(@NonNull FocusRequester winner);
40
41 /**
42 * Mute players at the beginning of a call
43 * @param usagesToMute array of {@link android.media.AudioAttributes} usages to mute
44 */
45 void mutePlayersForCall(int[] usagesToMute);
46
47 /**
48 * Unmute players at the end of a call
49 */
50 void unmutePlayersForCall();
51
52 /**
53 * Fade out whatever is still playing after the non-transient focus change
54 * @param winner the new non-transient focus owner
55 * @param loser the previous focus owner
56 * @return true if there were any active players for the loser that qualified for being
57 * faded out (because of audio attributes, or player types), and as such were faded
58 * out.
59 */
60 boolean fadeOutPlayers(@NonNull FocusRequester winner, @NonNull FocusRequester loser);
61
62 /**
63 * Mark this UID as no longer playing a role in focus enforcement
64 * @param uid
65 */
66 void forgetUid(int uid);
67}