• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.systemui.settings
18 
19 import android.view.Display
20 import java.util.concurrent.Executor
21 
22 /**
23  * Display tracker for SystemUI.
24  *
25  * This tracker provides async access to display information, as well as callbacks for display
26  * changes.
27  */
28 interface DisplayTracker {
29 
30     /** The id for the default display for the current SystemUI instance. */
31     val defaultDisplayId: Int
32 
33     /** All displays that should be associated with the current SystemUI instance. */
34     val allDisplays: Array<Display>
35 
36     /**
37      * Add a [Callback] to be notified of display changes, including additions, removals, and
38      * configuration changes, on a particular [Executor].
39      */
addDisplayChangeCallbacknull40     fun addDisplayChangeCallback(callback: Callback, executor: Executor)
41 
42     /**
43      * Add a [Callback] to be notified of display brightness changes, on a particular [Executor].
44      * This callback will trigger Callback#onDisplayChanged for a display brightness change.
45      */
46     fun addBrightnessChangeCallback(callback: Callback, executor: Executor)
47 
48     /** Remove a [Callback] previously added. */
49     fun removeCallback(callback: Callback)
50 
51     /** Ćallback for notifying of changes. */
52     interface Callback {
53 
54         /** Notifies that a display has been added. */
55         @JvmDefault fun onDisplayAdded(displayId: Int) {}
56 
57         /** Notifies that a display has been removed. */
58         @JvmDefault fun onDisplayRemoved(displayId: Int) {}
59 
60         /** Notifies a display has been changed */
61         @JvmDefault fun onDisplayChanged(displayId: Int) {}
62     }
63 }
64