1 /* 2 * Copyright (C) 2021 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 android.util; 18 19 import android.content.res.Resources; 20 21 import com.android.internal.R; 22 23 /** 24 * Utils for loading resources for multi-display. 25 * 26 * @hide 27 */ 28 public class DisplayUtils { 29 30 /** 31 * Gets the index of the given display unique id in {@link R.array#config_displayUniqueIdArray} 32 * which is used to get the related cutout configs for that display. 33 * 34 * For multi-display device, {@link R.array#config_displayUniqueIdArray} should be set for each 35 * display if there are different type of cutouts on each display. 36 * For single display device, {@link R.array#config_displayUniqueIdArray} should not to be set 37 * and the system will load the default configs for main built-in display. 38 */ getDisplayUniqueIdConfigIndex(Resources res, String displayUniqueId)39 public static int getDisplayUniqueIdConfigIndex(Resources res, String displayUniqueId) { 40 int index = -1; 41 if (displayUniqueId == null || displayUniqueId.isEmpty()) { 42 return index; 43 } 44 final String[] ids = res.getStringArray(R.array.config_displayUniqueIdArray); 45 final int size = ids.length; 46 for (int i = 0; i < size; i++) { 47 if (displayUniqueId.equals(ids[i])) { 48 index = i; 49 break; 50 } 51 } 52 return index; 53 } 54 } 55