2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
입력 방식 편집기(IME) 지원
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이러한 디스플레이 관련 영역에 적용된 업데이트는 아래와 같습니다.
Android 10은 기본이 아닌 디스플레이에서 실행되는 앱을 위한 소프트웨어 키보드를 지원합니다.
기본이 아닌 디스플레이에서 실행 중인 앱
입력 방식 편집기(IME)의 소프트웨어 키보드는 서로 다른 모드로 디스플레이에 표시됩니다. 소프트웨어 키보드가 표시되는 위치는 다음과 같습니다.
- 포커스가 맞춰진 앱이 표시되는 동일한 디스플레이
- 포커스가 맞춰진 앱이 기본이 아닌 디스플레이에서 실행되는 동안의 기본 디스플레이
- 표시되는 디스플레이 없음
시스템은 포커스가 맞춰진 앱이 표시되는 디스플레이의 설정에 따라 어떤 모드를 사용할지 결정합니다. 자세한 내용은 다음을 참고하세요.
WindowManager#setDisplayImePolicy()
WindowManager#getDisplayImePolicy()

그림 1. 보조 디스플레이에 표시되는 IME 소프트웨어 키보드(타겟 앱 포함)
시스템에서는 단일 IME를 사용하지만 디스플레이 간에 전환하여 사용자 포커스를 따를 수 있습니다. Android 10에서는 모든 퍼스트 파티 및 서드 파티 IME가 새 디스플레이 크기에 따라 레이아웃을 수정하고 크기를 조절할 것을 자동으로 기대합니다.
A 디스플레이에 연결이 활성화된 경우 입력란은 B 디스플레이에 관한 입력 포커스를 요청하며, 이어서 다음과 같은 흐름이 발생합니다.
- 새 입력 연결은 B 디스플레이의 입력란에서 발생합니다.
InputMethodManagerService
는 연결이 승인되어야 하는지 확인합니다.
- IME에 대해 디스플레이 A가 선택됩니다. B 디스플레이에서 IME 표시 기능을 지원하고 이러한 기능이 허용된 경우에는 B가 사용됩니다. 그렇지 않으면 기본 기기 디스플레이가 선택됩니다.
- 선택한 디스플레이가 A 디스플레이에서 오는 것이 아닌 경우 연결이 다시 설정됩니다.
InputMethodService
가 소멸되었다가 다시 생성됩니다.
보안 제한사항
시스템은 시스템 소유가 아닌 가상 디스플레이에 IME를 표시하지 않습니다. 이는 악성 앱이 시스템 장식 지원이 사용 설정된 가상 디스플레이를 생성하여 노출 영역에서 사용자의 민감한 정보를 읽을 수도 있다는 보안 우려 때문입니다(예: 입력 예측 및 맞춤 백그라운드).
구현
Android 9 이하에서는 화면상의 입력 방법에 설명된 것처럼 기본 화면에서만 IME를 사용할 수 있었습니다. Android 10 이상에서는 사용자가 포커스를 전환하여 여러 디스플레이의 여러 입력 텍스트 필드 간에 전환할 수 있으며, IME 창이 보조 디스플레이로 이동합니다.
WindowManager
의 구현은 입력 방법 창(소프트 키보드가 그려진 IME 창)과 입력 방법 타겟(IME 입력이 적용되는 창)을 추적하여 IME 상태를 관리합니다.
InputMethodManagerService
(IMMS)의 경우 포커스를 다른 디스플레이로 이동할 때 다른 어떠한 기본 메커니즘도 디스플레이 변경을 InputMethodService
(IMS)에 전파하거나 런타임 시에 키보드 레이아웃을 재구성할 수 없습니다.
디스플레이 간의 IME 창 전환을 위해 Android 10은 다음을 구현합니다.
- IME 및 입력 타겟 창은 이제
DisplayContent#mInputMethodWindow
및 DisplayContent#mInputMethodTarget
에서 디스플레이별로 추적됩니다. 이는 WindowManager(WM)가 각 디스플레이와 상관없이 IME 포커스 상태를 관리할 수 있도록 하기 위함입니다.
- IMMS 측에서는 외부 디스플레이에서 발생한 앱 클라이언트의 포커스 요청이
ViewRootImpl#handleWindowFocusChanged ->
InputMethodManager#onPostWindowFocus ->
IMMS#startInputOrWindowGainedFocus
를 통해 수신되는 경우 먼저 현재의 입력 방법 서비스를 바인딩 해제한 다음 서비스를 다시 바인딩하여 onServiceConnected()
의 외부 디스플레이에 새 IME 창 토큰을 다시 연결합니다.
- IMS 측에서는
IMS#attachToken
이 수신된 후에 다음과 같은 흐름이 발생합니다.ContextImpl#updateDisplay
가 호출되어 InputMethodService#attachToken()
의 서비스 컨텍스트 디스플레이를 업데이트합니다. 그러면 ViewGroup#addView()
가 호출되어 키보드의 레이아웃을 수정하고 현재 컨텍스트를 확인 중인 타겟 디스플레이에 맞게 조정됩니다.
DisplayContent#setInputMethodWindowLocked()
가 호출되면 구현은 WindowProcessController
를 사용하여 프로세스 수준의 디스플레이 구성 변경사항을 IME 프로세스로 전송하고 리소스와 디스플레이 측정항목을 재정의합니다.
InputMethodService
클라이언트는 입력 보기를 다시 초기화하기 위한 onConfigurationChanged()
및 ViewGroup#addView()
호출 이후에 올바른 디스플레이 측정항목이 포함된 올바른 구성을 가져옵니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2024-05-01(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-05-01(UTC)"],[],[],null,["# Input method editor support\n\nUpdates made to these display-specific areas are provided below:\n\n- [Apps running on a non-default display](/docs/core/display/multi_display/ime-support#non-default)\n- [Multi-session input method editor support](/docs/core/display/multi_display/ime-support#ime-multi)\n\nAndroid 10 supports\n[software keyboard](https://developer.android.com/guide/topics/text/creating-input-method)\nfor apps running on a non-default display.\n\nApps running on a non-default display\n-------------------------------------\n\nIn terms of which display shows the software keyboard of the Input Method Editor\n(IME), there are different modes. The software keyboard is shown on the:\n\n- *Same* display on which the focused app appears.\n- *Default* display while the focused app is running on a non-default display.\n- *No* display at all.\n\nThe system determines which mode to use based on the settings of the display\non which the focused app appears. For more details, see:\n\n- `WindowManager#setDisplayImePolicy()`\n- `WindowManager#getDisplayImePolicy()`\n\n**Figure 1.** IME software keyboard as it appears on secondary display,\nincluding target app\n\nThe system uses a single IME, but can shift between displays to follow\nuser focus. Android 10 automatically expects all first- and third-party IMEs to\nrevise the layout and resize according to the new display size when created.\n\nIf there's an active connection on display A, and an input field requests\ninput focus on display B, then the following flow occurs:\n\n1. A new input connection comes from the input field on display B.\n2. `InputMethodManagerService` checks if the connection should be approved.\n3. A display is selected for the IME. If display B supports showing the IME and is allowed to show it, then B is used. Otherwise, the primary device display is selected.\n4. If the selected display is not from display A, then the connection is re-established. `InputMethodService` is destroyed and then created again.\n\n### Security restriction\n\nThe system won't show an IME on virtual displays that aren't owned by the\nsystem. This is due to a security concern that a malicious app could create a\nvirtual display with enabled\n[system decorations support](/docs/core/display/multi_display/system-decorations)\nand read user-sensitive information from the surface, such as typing predictions\nand custom backgrounds.\n\n### Implementation\n\nIn Android 9 (and lower), the IME was only available on the default screen, as\ndescribed in [On-Screen\nInput methods](https://android-developers.googleblog.com/2009/04/updating-applications-for-on-screen.html). In Android 10 (and higher), a user can switch\nbetween different input text fields on different displays by switching focus,\nand the IME window moves to the secondary displays.\n\nThe implementation in `WindowManager` tracks the input method\nwindow (the IME window where the soft keyboard is drawn) and the input method\ntarget (the window where the IME input goes) to manage the IME state.\n\nFor `InputMethodManagerService` (IMMS), no other built-in mechanism can\npropagate the display change to `InputMethodService` (IMS) and\nreconfigure the keyboard layout at runtime when moving focus to another display.\n\nTo achieve the IME window switch between displays, Android\n10 implements the following:\n\n- The IME and input target window are now tracked per display in `DisplayContent#mInputMethodWindow` and `DisplayContent#mInputMethodTarget`, so that the WindowManager (WM) can manage the IME focus state independently of each display.\n- On the IMMS side, when an app client's focus request from the external display is received through `ViewRootImpl#handleWindowFocusChanged -\u003e\n InputMethodManager#onPostWindowFocus -\u003e\n IMMS#startInputOrWindowGainedFocus`, it first unbinds the current input method service and then rebinds the service to reattach the new IME window token for the external display in `onServiceConnected()`.\n- On the IMS side, after the `IMS#attachToken` is received, the following flow occurs:\n - `ContextImpl#updateDisplay` is called to update the service context's display in `InputMethodService#attachToken()`. This calls `ViewGroup#addView()` to revise the layout of the keyboard and adapt to the target display checking the current context.\n - After `DisplayContent#setInputMethodWindowLocked()` is called, the implementation sends process-level display configuration changes using the `WindowProcessController` to IME process to override resources and display metrics.\n - The `InputMethodService` client gets the correct configuration with the correct display metrics after `onConfigurationChanged()` and the `ViewGroup#addView()` call to reinitialize the input view."]]