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