Display Info
Provides display-related metrics such as physical screen size, app window size, status bar, and navigation bar sizes.
물리 화면 크기, 앱 윈도우 크기, 상태 바, 내비게이션 바 크기 등 디스플레이 정보를 제공합니다.
Why this class exists / 이 클래스가 필요한 이유:
Android's display APIs changed significantly in API 30 (R), requiring different approaches for older and newer versions.
System bar sizes vary across devices, orientations, and UI modes (gesture navigation vs. button navigation).
Multi-window mode requires separate handling of physical screen size vs app window size.
Accessing display metrics requires repetitive null checks, try-catch blocks, and resource lookups.
This class provides a unified, safe API for retrieving display information across all Android versions.
Android의 디스플레이 API는 API 30(R)에서 크게 변경되어 이전/이후 버전에 대해 다른 접근 방식이 필요합니다.
시스템 바 크기는 기기, 화면 방향, UI 모드(제스처 네비게이션 vs 버튼 네비게이션)에 따라 다릅니다.
멀티윈도우 모드에서는 물리 화면 크기와 앱 윈도우 크기를 별도로 처리해야 합니다.
디스플레이 정보 접근 시 반복적인 null 체크, try-catch 블록, 리소스 조회가 필요합니다.
이 클래스는 모든 Android 버전에서 디스플레이 정보를 안전하게 가져올 수 있는 통합 API를 제공합니다.
Design decisions / 설계 결정 이유:
SDK version branching: Uses
checkSdkVersionto handle API 30+ WindowMetrics vs legacy DisplayMetrics APIs.Return semantics:
nullmeans measurement is unavailable (e.g., missing Activity on pre-R, Insets not ready, resource lookup failure), while zero-size results (DisplayInfoSize(0, 0)/ zero-thickness insets) mean measurement succeeded but no reserved system-bar area exists.tryCatchSystemManager pattern: Inherits from BaseSystemService to provide consistent error handling and logging.
Resource name constants: Hardcoded Android system resource names are extracted to companion object for maintainability.
DisplayInfoBarInsets semantics:
DisplayInfoBarInsets(top, bottom, left, right)represents system bar insets. Status bar only usestop(others are 0), while navigation bar uses the direction where it appears (bottom/left/right depending on orientation and device).SDK 버전 분기: API 30+ WindowMetrics와 레거시 DisplayMetrics API를 처리하기 위해
checkSdkVersion을 사용합니다.반환 의미 구분:
null은 측정 불가(예: pre-R에서 Activity 없음, Insets 미수신, 리소스 조회 실패)를 의미하고, 0 크기 결과(DisplayInfoSize(0, 0)/ 두께 0 insets)는 측정 성공 + 시스템 바 점유 영역 없음(예: 제스처 모드)을 의미합니다.tryCatchSystemManager 패턴: BaseSystemService를 상속하여 일관된 에러 처리 및 로깅을 제공합니다.
리소스 이름 상수화: 하드코딩된 Android 시스템 리소스 이름을 companion object로 추출하여 유지보수성을 높였습니다.
DisplayInfoBarInsets 의미:
DisplayInfoBarInsets(top, bottom, left, right)는 시스템 바 insets를 나타냅니다. Status bar는top만 사용(나머지는 0)하며, Navigation bar는 나타나는 방향(화면 방향 및 기기에 따라 bottom/left/right)을 사용합니다.
Usage / 사용법:
val displayInfo = context.getDisplayInfo()
// Get physical and app window screen sizes
val physicalSize = displayInfo.getPhysicalScreenSize() // DisplayInfoSize
val appWindowSize = displayInfo.getAppWindowSize(activity?) // DisplayInfoSize?
// Get system bar sizes (nullable)
val statusBarSize = displayInfo.getStatusBarSize() // DisplayInfoSize?
val navBarSize = displayInfo.getNavigationBarSize() // DisplayInfoSize?
// Check orientation and multi-window mode
val isPortrait = displayInfo.isPortrait() // Boolean
val isLandscape = displayInfo.isLandscape() // Boolean
val isMultiWindow = displayInfo.isInMultiWindowMode(activity) // Boolean
```<br><br>Functions
Returns the app window size in pixels (supports multi-window mode).
앱 윈도우 크기(픽셀)를 반환합니다 (멀티윈도우 모드 지원).
Returns the navigation bar size as DisplayInfoSize(width, height), or null if unavailable.
Returns the navigation bar stable insets.
내비게이션 바의 stable insets를 반환합니다.
Gets information about required permissions and their status.
필요한 권한과 그 상태에 대한 정보를 가져옵니다.
Returns the physical screen size in pixels (ignores multi-window mode).
물리 화면 크기(픽셀)를 반환합니다 (멀티윈도우 모드 무시).
Returns the status bar size based on physical screen dimensions as DisplayInfoSize(width, height), or null if unavailable.
Returns the status bar stable insets.
상태 바의 stable insets를 반환합니다.
Returns true if the app is in multi-window mode.
앱이 멀티윈도우 모드인 경우 true를 반환합니다.
Returns true if the screen is in landscape orientation.
화면이 가로 방향인 경우 true를 반환합니다.
Checks if a specific permission is granted.
특정 권한이 부여되었는지 확인합니다.
Returns true if the screen is in portrait orientation.
화면이 세로 방향인 경우 true를 반환합니다.
Refreshes the permission status. Call this after requesting permissions.
권한 상태를 새로고침합니다. 권한 요청 후 이를 호출하세요.