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.display; 18 19 import android.util.ArrayMap; 20 import android.util.Slog; 21 22 /** 23 * Provides {@link HighBrightnessModeMetadata}s for {@link DisplayDevice}s. This class should only 24 * be accessed from the display thread. 25 */ 26 class HighBrightnessModeMetadataMapper { 27 28 private static final String TAG = "HighBrightnessModeMetadataMapper"; 29 30 /** 31 * Map of every internal primary display device {@link HighBrightnessModeMetadata}s indexed by 32 * {@link DisplayDevice#mUniqueId}. 33 */ 34 private final ArrayMap<String, HighBrightnessModeMetadata> mHighBrightnessModeMetadataMap = 35 new ArrayMap<>(); 36 getHighBrightnessModeMetadataLocked(LogicalDisplay display)37 HighBrightnessModeMetadata getHighBrightnessModeMetadataLocked(LogicalDisplay display) { 38 final DisplayDevice device = display.getPrimaryDisplayDeviceLocked(); 39 if (device == null) { 40 Slog.wtf(TAG, "Display Device is null in DisplayPowerController for display: " 41 + display.getDisplayIdLocked()); 42 return null; 43 } 44 if (device.getDisplayDeviceConfig().getHighBrightnessModeData() == null) { 45 return null; 46 } 47 48 final String uniqueId = device.getUniqueId(); 49 50 if (mHighBrightnessModeMetadataMap.containsKey(uniqueId)) { 51 return mHighBrightnessModeMetadataMap.get(uniqueId); 52 } 53 54 // HBM Time info not present. Create a new one for this physical display. 55 HighBrightnessModeMetadata hbmInfo = new HighBrightnessModeMetadata(); 56 mHighBrightnessModeMetadataMap.put(uniqueId, hbmInfo); 57 return hbmInfo; 58 } 59 } 60