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.statusbar; 18 19 import static android.view.WindowInsets.Type.systemBars; 20 21 import android.annotation.Nullable; 22 import android.graphics.Insets; 23 import android.util.Pair; 24 import android.view.DisplayCutout; 25 import android.view.WindowInsets; 26 27 import com.android.systemui.dagger.SysUISingleton; 28 29 import javax.inject.Inject; 30 31 /** 32 * Default implementation of NotificationsInsetsController. 33 */ 34 @SysUISingleton 35 public class NotificationInsetsImpl extends NotificationInsetsController { 36 37 @Inject NotificationInsetsImpl()38 public NotificationInsetsImpl() { 39 40 } 41 42 @Override getinsets(@ullable WindowInsets windowInsets, @Nullable DisplayCutout displayCutout)43 public Pair<Integer, Integer> getinsets(@Nullable WindowInsets windowInsets, 44 @Nullable DisplayCutout displayCutout) { 45 final Insets insets = windowInsets.getInsetsIgnoringVisibility(systemBars()); 46 int leftInset = 0; 47 int rightInset = 0; 48 49 if (displayCutout != null) { 50 leftInset = displayCutout.getSafeInsetLeft(); 51 rightInset = displayCutout.getSafeInsetRight(); 52 } 53 leftInset = Math.max(insets.left, leftInset); 54 rightInset = Math.max(insets.right, rightInset); 55 56 return new Pair(leftInset, rightInset); 57 } 58 } 59