• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.server.wm;
18 
19 import android.annotation.NonNull;
20 import android.os.Message;
21 import android.view.Surface;
22 import android.window.DisplayAreaInfo;
23 
24 /**
25  * Interface for a helper class that manages updates of DisplayInfo coming from DisplayManager
26  */
27 interface DisplayUpdater {
28     /**
29      * Reads the latest display parameters from the display manager and returns them in a callback.
30      * If there are pending display updates, it will wait for them to finish first and only then it
31      * will call the callback with the latest display parameters.
32      *
33      * @param callback is called when all pending display updates are finished
34      */
updateDisplayInfo(@onNull Runnable callback)35     void updateDisplayInfo(@NonNull Runnable callback);
36 
37     /**
38      * Called when physical display has changed and before DisplayContent has applied new display
39      * properties
40      */
onDisplayContentDisplayPropertiesPreChanged(int displayId, int initialDisplayWidth, int initialDisplayHeight, int newWidth, int newHeight)41     default void onDisplayContentDisplayPropertiesPreChanged(int displayId, int initialDisplayWidth,
42             int initialDisplayHeight, int newWidth, int newHeight) {
43     }
44 
45     /**
46      * Called after physical display has changed and after DisplayContent applied new display
47      * properties
48      */
onDisplayContentDisplayPropertiesPostChanged( @urface.Rotation int previousRotation, @Surface.Rotation int newRotation, @NonNull DisplayAreaInfo newDisplayAreaInfo)49     default void onDisplayContentDisplayPropertiesPostChanged(
50             @Surface.Rotation int previousRotation, @Surface.Rotation int newRotation,
51             @NonNull DisplayAreaInfo newDisplayAreaInfo) {
52     }
53 
54     /**
55      * Called with {@code true} when physical display is going to switch. And {@code false} when
56      * the display is turned on or the device goes to sleep.
57      */
onDisplaySwitching(boolean switching)58     default void onDisplaySwitching(boolean switching) {
59     }
60 
61     /** Returns {@code true} if the transition will control when to turn on the screen. */
waitForTransition(@onNull Message screenUnBlocker)62     default boolean waitForTransition(@NonNull Message screenUnBlocker) {
63         return false;
64     }
65 }
66