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.car.systeminterface; 18 19 import android.car.builtin.view.DisplayHelper; 20 import android.view.Display; 21 22 /** 23 * An interface to wrap {@link DisplayHelper} methods. 24 * 25 * This allows faking the implementation for tests. 26 */ 27 public interface DisplayHelperInterface { 28 /** 29 * @return the physical port number of the display, or {@code INVALID_PORT} if the display isn't 30 * the physical one. 31 */ getPhysicalPort(Display display)32 int getPhysicalPort(Display display); 33 34 /** 35 * @return the uniqueId of the given display. 36 */ getUniqueId(Display display)37 String getUniqueId(Display display); 38 39 /** 40 * Gets the display type. 41 */ getType(Display display)42 int getType(Display display); 43 44 /** 45 * A real implementation. 46 */ 47 final class DefaultImpl implements DisplayHelperInterface { 48 @Override getPhysicalPort(Display display)49 public int getPhysicalPort(Display display) { 50 return DisplayHelper.getPhysicalPort(display); 51 } 52 53 @Override getUniqueId(Display display)54 public String getUniqueId(Display display) { 55 return DisplayHelper.getUniqueId(display); 56 } 57 58 @Override getType(Display display)59 public int getType(Display display) { 60 return DisplayHelper.getType(display); 61 } 62 } 63 } 64