1 /* 2 * Copyright (C) 2024 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.graphics.Rect; 21 import android.view.SurfaceControl; 22 23 /** 24 * Abstraction for different Letterbox state implementations. 25 */ 26 interface AppCompatLetterboxPolicyState { 27 28 /** 29 * Checks if a relayout is necessary for the letterbox implementations. 30 * @param w The {@link WindowState} to use for defining Letterbox sizes. 31 */ layoutLetterboxIfNeeded(@onNull WindowState w)32 void layoutLetterboxIfNeeded(@NonNull WindowState w); 33 34 /** 35 * @return {@code true} if the policy is running and so if the current activity is 36 * letterboxed. 37 */ isRunning()38 boolean isRunning(); 39 40 /** 41 * Called when the activity is moved to a new display. 42 * @param displayId Id for the new display 43 */ onMovedToDisplay(int displayId)44 void onMovedToDisplay(int displayId); 45 46 /** Cleans up {@link Letterbox} if it exists.*/ stop()47 void stop(); 48 49 /** Hides the letterbox surfaces implementation. */ hide()50 void hide(); 51 52 /** Gets the letterbox insets. The insets will be empty if there is no letterbox. */ 53 @NonNull getLetterboxInsets()54 Rect getLetterboxInsets(); 55 56 /** Gets the inner bounds of letterbox. The bounds will be empty with no letterbox. */ getLetterboxInnerBounds(@onNull Rect outBounds)57 void getLetterboxInnerBounds(@NonNull Rect outBounds); 58 59 /** Gets the outer bounds of letterbox. The bounds will be empty with no letterbox. */ getLetterboxOuterBounds(@onNull Rect outBounds)60 void getLetterboxOuterBounds(@NonNull Rect outBounds); 61 62 /** 63 * Updates the letterbox surfaces in case this is needed. 64 * 65 * @param winHint The WindowState for the letterboxed Activity. 66 * @param t The current Transaction. 67 * @param inputT The pending transaction used for the input surface. 68 */ updateLetterboxSurfaceIfNeeded(@onNull WindowState winHint, @NonNull SurfaceControl.Transaction t, @NonNull SurfaceControl.Transaction inputT)69 void updateLetterboxSurfaceIfNeeded(@NonNull WindowState winHint, 70 @NonNull SurfaceControl.Transaction t, 71 @NonNull SurfaceControl.Transaction inputT); 72 73 /** 74 * @return {@code true} if bar shown within a given rectangle is allowed to be fully 75 * transparent when the current activity is displayed. 76 */ isFullyTransparentBarAllowed(@onNull Rect rect)77 boolean isFullyTransparentBarAllowed(@NonNull Rect rect); 78 79 } 80