Input Method Editor Support | Android Open Source Project

文章推薦指數: 80 %
投票人數:10人

In Android 9 (and lower), the IME was only available on the default screen, as described in On-Screen Input methods. In Android 10 (and higher), ... Docs GettingStarted About Start Download Build Create Contribute Security Overview Bulletins Features Testing BestPractices CoreTopics Architecture Audio Camera Connectivity Data Display Graphics Interaction Media Performance Permissions Power Runtime Settings Storage Tests Updates Compatibility CompatibilityDefinitionDocument(CDD) CompatibilityTestSuite(CTS) AndroidDevices Automotive Enterprise TV Reference HIDL HAL TradeFederation GOTOCODE➚ Language English BahasaIndonesia Deutsch Español–AméricaLatina Français Italiano Polski Português–Brasil TiếngViệt Türkçe Русский עברית' العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文–简体 中文–繁體 日本語 한국어 Signin Documentation GettingStarted Security CoreTopics Compatibility AndroidDevices Reference Docs More GettingStarted Security CoreTopics Compatibility AndroidDevices Reference GOTOCODE➚ Overview ArchitectureOverview ModularSystemComponentsOverviewadbdARTCellBroadcastConscryptDeviceSchedulingDNSResolverDocumentsUIExtServicesIPsec/IKEv2LibraryMediaModuleMetadataNetworkingNNAPIRuntimePermissionControllerSDKExtensionsStatsdTetheringTimeZoneDataWi-Fi HardwareAbstractionLayer(HAL)LegacyHALsHALTypesFrameworkTestingDynamicLifecycle KernelOverview StableReleases&UpdatesOverviewLinux-stableMergesAndroidCommonKernelsGenericKernelImageGKIVersioningKernelABIMonitoring ModularKernelsOverviewLoadableKernelModulesKernelModuleSupportMountingPartitionsEarlyDTOSupportCoreKernelRequirementsFutureAndroidVersionsIncrementalFileSystemInterfaceRequirementsExtendingthekernelwitheBPFIONABIChangesModularIONHeapsforGKIDMA-BUFHeapsConfigurationAndroidLiveLocKDaemonKernelHardeningSquashFSLLDBDebuggingNetworkTests HIDL(General)OverviewInterfaces&PackagesInterfaceHashingServices&DataTransferFastMessageQueueUsingBinderIPCUsingMemoryBlockNetworkStackConfigurationToolsThreadingModelsConvertingModulesDataTypesSafeUnionVersioningCodeStyleGuide HIDL(C++)OverviewPackagesInterfacesDataTypesFunctions HIDL(Java)OverviewDataTypesInterfaceErrors&MethodsExportingConstants ConfigurationOverviewMMEvents-HistoricalMemoryStatisticsSystemPropertiesAPIsAddSystemPropertiesConfigFileSchemaAPI ConfigStoreHALOverviewCreatingtheHALInterfaceImplementingtheServiceClient-SideUsageAddingClasses&ItemsSystemSuspendService DeviceTreeOverlaysOverviewImplementingDTODTOSyntaxCompiling&VerifyingUsingMultipleDTsDTB/DTBOPartitionFormatOptimizingDTO VendorNDKOverviewEnablingtheVNDKVNDKBuildSystemSupportVNDKExtensionsVNDKDefinitionToolVNDKSnapshotDesignGeneratingVNDKSnapshotsGeneratingVendorSnapshotsLinkerNamespaceDirectories,Rules,andsepolicyRenderscriptABIStabilityPrebuiltABIUsageChecker VendorInterfaceObjectOverviewManifestsCompatibilityMatricesFCMLifecycleDMDevelopmentMatchingRulesResources AIDLOverviewAIDLBackendsStableAIDLAIDLforHALsDynamicAIDLAnnotationsinAIDLFMQwithAIDL BootloaderOverviewBootReasonBootImageHeaderBootImageProfilesImplementingBootconfig PartitionsOverviewPartitionLayoutVendorBootPartitionsVendor/ODMDLKMPartitionSharedSystemImageRamdiskPartitionsGenericBootPartitionODMPartitionsProductPartitionsEnforcingProductPartitionInterfacesTrustyOS(TOS)PartitionsImagesRecoveryImagesDTBImagesSupportingOTAUpdatesLockingandUnlockingtheBootloaderFastbootinUserspaceSoftRestartsJavaSDKLibraryRuntimeResourceOverlays(RROs)ImplementingCustomFontFallback AudioOverviewTerminology ImplementationAudioHALPolicyConfigurationSharedLibraryPre-processingEffectsDataFormatsAttributesAudioEffectsHigh-ResolutionAudioDeviceTypeLimitAAudioandMMAPWarmup LatencyOverviewContributorsDesignMeasureLightTestingCircuitAudioLoopbackDongleMeasurementsApplicationsPriorityInversionSampleRateConversionDebugging MIDIOverviewMIDIArchitectureMIDITestProcedureUSBDigitalAudioTVAudioConcurrentCaptureSoundTriggerCombinedAudioDeviceRouting CameraOverviewArchitectureCamera3HALSubsystemCoreConcepts3AModesandStateErrorsandStreamsMetadataandControlsOutputandCroppingRequestCreationStreamConfigurationsPerformanceCameraHAL3BufferManagementAPIsSessionParametersSingleProducer,MultipleConsumerCameraFeaturesCameraBokehConcurrentCameraStreamingExternalUSBCamerasHEIFImagingMonochromeCamerasMotionTrackingMulti-CameraSupportSystemCamerasCameraXCameraXVendorExtensionsVersioningVersionSupport ConnectivityOverview BluetoothandNFCOverviewBluetoothServicesBluetoothLowEnergyHearingAidsoverBLEBLEAdvertisingVerifyingandDebuggingBluetoothBluetoothHCIRequirementsNFCHostCardEmulationofFeliCaNFCOff-HostPaymentSynchronizationSecureNFCQuickAccessWallet CallingandMessaging5GNon-Standalone(NSA)BlockPhoneNumbersCallNotificationsEmergencyAffordanceEmergencyNumberDatabaseEmergencyNumbersandEmergencyCallingIPMultimediaSubsystem(IMS)IMSServiceEntitlementIMSSingleRegistrationPhoneAccountSuggestionReal-TimeText(RTT)Third-PartyCallingAppsVisualVoicemail CarrierOverview5GNetworkSlicingAPNandCarrierConfigCarrierIdentificationDataPlansDeviceidentifiers eSIMImplementingeSIMModemRequirementseUICCAPIsHandlingeUICCAPIErrorsDownloadableTestProfilesMulti-OperatorNetworkSupportOut-of-BalanceUsersRadioInterfaceLayer(RIL)SmallCellSupportUICC TimeTimeOverviewLocationTimeZoneDetectionTelephonyTimeZoneDetectionGNSSTimeDetectionExternalTimeDetectionTimeSourcePriorityTimeZoneRules Wi-FiOverviewWi-FiHALWi-FiInfrastructureFeaturesTesting,Debugging,andTuningWi-FiCarrierWi-FiMACRandomizationBehaviorImplementingMACRandomizationPasspoint(Hotspot2.0)STA/APConcurrencySTA/STAConcurrencyWi-FiAwareWi-Fi/CellularCoexChannelAvoidanceWi-FiDirectWi-FiEasyConnectWi-FiHotspot(SoftAP)SupportforTetheringWi-FiAP/APConcurrencyWi-FiLowLatencyModeWi-FiNetworkSelectionWi-FiPreferredNetworkOffloadScanningWi-FiRoundTripTime(RTT)WPA3andWi-FiEnhancedOpen ACTSTestsOverviewACTSAdvancedGuideConfiguringACTSTestsUserParameters5GTestingCompanionDeviceProfilesConnectivityDiagnosticsAPIConnectivityUserInterfaceNetworkSelectionSignalStrengthReporting DataOverviewDataUsageTagsExplainedDataSaverModeeBPFTrafficMonitoringExcludeNetworkTypesfromUsageNetworkInterfaceStatisticsOverviewTetheringDataTetheringOffloadUsageCycleResetDatesKernelOverviewKernelChanges DisplayOverview AppsAdaptiveIconsAppShortcutsCircularIconsConversationNotificationsandWidgetsWindowBlursWidgets&ShortcutsSynchronizedAppTransitions ColorColorManagementDisplayCutoutsDoNotDisturbHDRVideoNightLight Multi-WindowOverviewSplit-ScreenInteractionsPicture-in-PictureWindowMagnifier Multi-DisplayOverviewRecommendedPracticesTestingandDevelopmentEnvironmentFrequentlyAskedQuestionsMulti-ResumeActivityLaunchPolicyDisplaySupportSystemDecorationsSupportLockScreenInputMethodEditorSupportInputRoutingMulti-ZoneAudioNotificationHistoryRetailDemoModeRotateSuggestionsTextClassification GraphicsOverviewArchitectureBufferQueueandGrallocDMABUFandGPUMemoryAccounting SurfaceandSurfaceHolderOverviewSurfaceViewSurfaceTextureTextureView SurfaceFlingerandWindowManagerOverviewTracingWindowTransitions HardwareComposerHALOverviewImplementingtheHWCHotplughandlinginComposerHALLayersandDisplaysVSYNCFramePacingMultipleRefreshRate OpenGLESOverviewImplementingOpenGLESOpenGLRendererConfiguration VulkanOverviewImplementingVulkanSynchronizationFramework TestingImplementationTestsIntegratingwithAndroidCTSdeqpTesting InteractionOverviewInputOverviewKeyLayoutFilesKeyCharacterMapFilesInputDeviceConfigurationFilesMigrationGuideKeyboardDevicesTouchDevicesGeteventValidateKeymapsHapticsOverviewImplementingHapticsUXFoundationforHapticFrameworkHapticsUXDesignNeuralNetworksOverviewBurstExecutionsandFastMessageQueuesCompilationCachingControlFlowDeviceDiscoveryandAssignmentMemoryPoolsNNAPIDriverImplementationBestPracticesQualityofServiceVendorExtensionsPeripheralsOverview AudioAccessoriesOverview 3.5mmHeadsetHeadsetSpecDeviceSpec USBHeadsetHeadsetSpecAdapterSpecDeviceSpecExpectedBehaviorTesting CustomAccessoriesOverview AOAOverviewAOA2.0AOA1.0DisablingDataSignalingOverUSBStylusSensorsOverviewSensorStackSensorTypesInteraction PowerBatchingPowerConsumption ModesReportingModesSuspendModeSensorsOff SensorsHALSensorsMulti-HALSensorsHAL2SensorsHAL1VersionDeprecationContextHubRuntimeEnvironmentOverview MediaOverviewMediaModulesMediaProviderCustomizingMediaComponentsLowLatencyDecodinginMediaCodecFrameworkHardeningSoCDependenciesOEMDependenciesDRMCompatibleMediaTranscoding PerformanceOverviewAPKCachingCachedAppsFreezerBootTimes HealthOverviewImplementingHealth2.0ImplementingHealth2.1Deprecatinghealth@1.0CgroupAbstractionLayerLowMemoryKillerDaemon(LMKD)LowRAMProfileGuidedOptimization(PGO)TaskSnapshotsWrite-AheadLoggingAppHibernation PermissionsOverviewAmbientCapabilitiesBackgroundLocationAccessReminderContactsAffinitiesAccessDiscretionaryAccessControlImmutableDeviceIDsLibraryNamespacesPrivilegedPermissionAllowlistPreinstalledSystemPackagesPrivacyIndicatorsRestrictOpportunisticLocationsRestrictedScreenReadingRuntimePermissionsTristateLocationPermissionsUSBHAL PowerOverviewPowerManagementThermalMitigationPowerStatsHALAppManagementPlatformManagementPerformanceManagementBatterylessDevicesComponentPowerDevicePowerPowerValuesRoutineBatterySaverTVStandby RuntimeOverviewDexpreoptandChecksImprovementsBytecodeFormatDexFormatInstructionFormatsConstraintsConfigurationARTTISignedConfigGarbageCollectionJITCompilation SettingsOverviewDesignGuidelinesPatternsandComponentsInformationArchitecturePersonalizedSettingsUniversalSearch StorageOverviewTraditionalStorageAdoptableStorageScopedStorageFUSEPassthroughDeviceConfigurationConfigurationExamplesFasterStatisticsSDCardFSDeprecation TestsOverviewTestDevelopmentWorkflowOverviewSimpleConfigurationComplexConfiguration InstrumentationTestsOverviewSelf-InstrumentingTestsTargetinganApplication NativeTestsOverviewAddingaNewNativeTestNativeMetricTestsJARHostTestsMappingTestsRunningTests(Atest) AndroidTestStationUserGuideVirtualDevicesTestingUserBuildsRunningCTSVerifierAPIReleaseNotesFAQVendorTestSuite(VTS)11OverviewParameterizedgtestforHALTestingTestSetupVendorTestSuite(VTS)10OverviewVideoTutorialsSystemsTestingwithVTS TestFrameworkDeviceShellCommandsTestTemplatesServiceNameAwareHALTestingHALTestabilityCheckMulti-DeviceTestingVTSwithdebugramdisk VTSDashboardSetupDatabaseUserInterface LabInfrastructureAutomatedTestingInfrastructureHostControllerArchitecturePerformanceTestingTradeFederation(TF)TestHarness GettingStartedOverviewStartBuildorDownloadTradefedWorkingwithDevicesConsoleTestLifecycleOptionHandlingEnd-to-EndExample TestingwithTFOverview ThroughTradefedOverviewNewTestRunnerShardableIRemoteTestHost-DrivenTestHost-sideDevicelessTestReportMetricsAutomaticTestRetryRetryIsolationAutomatedLogCollectionDryRunningConfigurationInstrumentationsTestsfromAPKWriteashelltestGlobalfilters ThroughSuiteOverviewSetupSuitePassOptionsandFiltersCheckSystemStatusStructureAndroidTest.xmlConfigureShardingModuleControllersSuiteRetry DevelopingTFOverviewGuidelinesSetupEclipseIncludeUnitandFunctionalTestsRunErrorProneBugCheckerContributeNon-CoreCode ArchitectureOverview XMLConfigurationStructureTemplatesandIncludesConfigurationObject GlobalConfigurationFileOptionsHostOptions AdvancedConceptsKeystoreSecretsCommandSchedulerTestRunnerTestShardingMultipleDevicesScriptingLayerProtocolsandGlobalConfig DeviceManagerDeviceStateDeviceAllocationDeviceDetection BuildBuildProviderBuildInfo DevicesetupTargetPreparerMulti-TargetPreparer ResultsResultReporterReporterLogsReporterSummary MetricsMetricsCollectorDevice-SideMetricsPackageIndexDebuggingOverviewReadingBugReportsUnderstandingLoggingScopedVendorLoggingDiagnosingNativeCrashes EvaluatingPerformanceOverviewUnderstandingsystraceUsingftraceIdentifyingCapacityJankIdentifyingJitterJank FeatureImplementationTestHarnessModeUsingDebuggersNativeMemoryUseNetworkConnectivityTestsRescuePartyStoragedStrace UpdatesOverviewAPEXFileFormatBuildingOTAPackagesSigningBuildsforReleaseReducingOTASize A/BSystemUpdatesOverviewImplementingA/BUpdatesFrequentlyAskedQuestions Non-A/BSystemUpdatesOverviewBlock-BasedOTAInsideOTAPackagesDevice-SpecificCode DynamicPartitionsOverviewImplementingDynamicPartitionsOTAforA/BDevicesOTAforLegacyA/BDevicesOTAfornon-A/BDevices VirtualA/BOverviewImplementingVirtualA/BImplementingVirtualA/B-patchesTimeZoneRulesUserDataCheckpointDynamicSystemUpdatesResumeonReboot GettingStarted About Start Download Build Create Contribute Security Overview Bulletins Features Testing BestPractices CoreTopics Architecture Audio Camera Connectivity Data Display Graphics Interaction Media Performance Permissions Power Runtime Settings Storage Tests Updates Compatibility CompatibilityDefinitionDocument(CDD) CompatibilityTestSuite(CTS) AndroidDevices Automotive Enterprise TV Reference HIDL HAL TradeFederation AOSP Docs CoreTopics Sendfeedback InputMethodEditorSupport Updatesmadetothesedisplay-specificareasareprovidedbelow: Appsrunningonanon-defaultdisplay Multi-sessionInputMethodEditorsupport Android10supports softwarekeyboard forappsrunningonanon-defaultdisplay. Appsrunningonanon-defaultdisplay IntermsofwhichdisplayshowsthesoftwarekeyboardoftheInputMethodEditor (IME),therearetwodifferentmodes.Thesoftwarekeyboardisshownonthe: Samedisplayonwhichthefocusedappappears. Defaultdisplaywhilethefocusedappisrunningonanon-defaultdisplay. Thesystemdetermineswhichmodetousebasedonthesettingsofthedisplay onwhichthefocusedappappears.Formoredetails,see: DisplayWindowSettings#shouldShowImeLocked() DisplayWindowSettings#setShouldShowImeLocked() Figure1.IMEsoftwarekeyboardasitappearsonsecondarydisplay, includingtargetapp ThesystemusesasingleIME,butcanshiftbetweendisplaystofollow userfocus.Android10automaticallyexpectsallfirst-andthird-partyIMEsto revisethelayoutandresizeaccordingtothenewdisplaysizewhencreated. Ifthere'sanactiveconnectionondisplayA,andaninputfieldrequests inputfocusondisplayB,thenthefollowingflowoccurs: AnewinputconnectioncomesfromtheinputfieldondisplayB. InputMethodManagerServicechecksiftheconnectionshouldbe approved. AdisplayisselectedfortheIME.IfdisplayBsupportsshowingtheIMEand isallowedtoshowit,thenBisused.Otherwise,theprimarydevicedisplayis selected. IftheselecteddisplayisnotfromdisplayA,thentheconnectionis re-established.InputMethodServiceisdestroyedandthencreatedagain. Securityrestriction Thesystemwon'tshowanIMEonvirtualdisplaysthataren'townedbythe system.Thisisduetoasecurityconcernthatamaliciousappcouldcreatea virtualdisplaywithenabled SystemDecorationsSupport andreaduser-sensitiveinformationfromthesurface,suchastypingpredictions andcustombackgrounds. Implementation InAndroid9(andlower),theIMEwasonlyavailableonthedefaultscreen,as describedinOn-Screen Inputmethods.InAndroid10(andhigher),ausercanswitch betweendifferentinputtextfieldsondifferentdisplaysbyswitchingfocus, andtheIMEwindowmovestothesecondarydisplays. TheimplementationinWindowManagertrackstheinputmethod window(theIMEwindowwherethesoftkeyboardisdrawn)andtheinputmethod target(thewindowwheretheIMEinputgoes)tomanagetheIMEstate. ForInputMethodManagerService(IMMS),nootherbuilt-inmechanismcan propagatethedisplaychangetoInputMethodService(IMS)and reconfigurethekeyboardlayoutatruntimewhenmovingfocustoanotherdisplay. ToachievetheIMEwindowswitchbetweendisplays,Android 10implementsthefollowing: TheIMEandinputtargetwindowarenowtrackedperdisplayin DisplayContent#mInputMethodWindowand DisplayContent#mInputMethodTarget,sothattheWindowManager(WM)canmanagethe IMEfocusstateindependentlyofeachdisplay. OntheIMMSside,whenanappclient'sfocusrequestfromtheexternaldisplay isreceivedthroughViewRootImpl#handleWindowFocusChanged-> InputMethodManager#onPostWindowFocus-> IMMS#startInputOrWindowGainedFocus,itfirstunbindsthecurrentinput methodserviceandthenrebindstheservicetoreattachthenewIMEwindowtoken fortheexternaldisplayinonServiceConnected(). OntheIMSside,aftertheIMS#attachTokenisreceived,the followingflowoccurs: ContextImpl#updateDisplayiscalledtoupdatetheservice context'sdisplayinInputMethodService#attachToken().Thiscalls ViewGroup#addView()torevisethelayoutofthekeyboardandadapt tothetargetdisplaycheckingthecurrentcontext. AfterDisplayContent#setInputMethodWindowLocked()iscalled, theimplementationsendsprocess-leveldisplayconfigurationchangesusingthe WindowProcessControllertoIMEprocesstooverrideresourcesand displaymetrics. TheInputMethodServiceclientgetsthecorrectconfiguration withthecorrectdisplaymetricsafteronConfigurationChanged()and theViewGroup#addView()calltoreinitializetheinputview. Multi-sessionInputMethodEditorsupport Deviceimplementationswithmultipledisplaysexpectedtobesimultaneously usedbymultipleuserstoprovideappropriateinputsourcescanbeconfigured tosimultaneouslydisplaymultipleinputmethodeditors(IME),atmostoneper display.Thefollowingtwofiguresshowasamplemulti-sessionIMEontwodisplays: Figure2.Samplemulti-sessionIME Figure3.Samplemulti-sessionIME Supportfor Per-displayfocus isaprerequisiteforthisfeature.Ifnot,thisfeaturecan'tbeenabled. Duetosecurityrestrictions,theper-displayfocuslimitationrestricted thisfeaturetoasmallsubsetofdevices. InAndroid10,supportformulti-sessionIMEs isimplementedwithseparatesystemserviceswithadifferentsetofAPIsand reducedfunctionality.Multi-sessionIMEisn'tcompatiblewithexistingIMEs. Eithermulti-sessionorsingle-sessionservicecanbeused,butnotboth. Itisn'tpossibletouseexistingAndroidIMEsbuiltontopofthe InputMethodServiceclassbecausetheassumptionthatasingleIME clientcanbefocusedatthesametimewasmadebeforeAndroidIMEAPIswere introducedinAndroid1.5andmanypublicAPIsin InputMethodServicehavealreadyreliedheavilyonthatassumption. However,updatingtheInputMethodServiceclasstosupporta multi-clientscenarioischallengingbecause: Doingsowouldintroduceanunacceptableamountofcomplexityinto InputMethodService,whichisalreadyhardtomaintain. IMEdevelopersstillneedtoupdatetheirimplementationtobeableto supportparallelrequestsfrommultiplefocusedIMEclients,whichmayrequirea nontrivialredesignontheirside(suchasinputdecoderandtypinghistory database). Actualusecasesformulti-IMEclientsareexpectedtoevolverapidly,so thenewprotocolisn'tstableandisn'treadytobeexposedaspublicAPIs. Aswithsingle-session(regular)IME,controlovershowingIMEonindividual displaysisperformedusingDisplayWindowSettings. Thereisasamplemulti-sessionIMElocatedat development/samples/MultiClientInputMethod. Totestmulti-sessionIME: Setconfig_perDisplayFocusEnabledtotrue. Runthesecommands: $make-jMultiClientInputMethod $adbinstall-r $OUT/system/priv-app/MultiClientInputMethod/MultiClientInputMethod.apk $adbroot $adbshellsetproppersist.debug.multi_client_ime\ com.example.android.multiclientinputmethod/.MultiClientInputMethod $adbreboot Trymultipletextinputscenarios. Implementation SeeMultiClientInputMethodManagerServiceforimplementation details. Sendfeedback ContentandcodesamplesonthispagearesubjecttothelicensesdescribedintheContentLicense.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2021-10-05UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] Needtotellusmore? Build Androidrepository Requirements Downloading Previewbinaries Factoryimages Driverbinaries GitHub Connect @AndroidonTwitter @AndroidDevonTwitter AndroidBlog GoogleSecurityBlog PlatformonGoogleGroups BuildingonGoogleGroups PortingonGoogleGroups Gethelp AndroidHelpCenter PixelHelpCenter www.android.com GoogleMobileServices StackOverflow IssueTracker AboutAndroid Community Legal License Privacy Sitefeedback Language English BahasaIndonesia Deutsch Español–AméricaLatina Français Italiano Polski Português–Brasil TiếngViệt Türkçe Русский עברית' العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文–简体 中文–繁體 日本語 한국어



請為這篇文章評分?