Allow IME-related Settings Activity to run for managed profiles
The following Activity classes in the Settings have been marked with PRIMARY_PROFILE_CONTROLLED = true since work profile was originally implemented [1]. * Settings$AvailableVirtualKeyboardActivity * .inputmethod.InputMethodAndSubtypeEnablerActivity * UserDictionarySettingsActivity * .inputmethod.UserDictionaryAddWordActivity This means that even if they are explicitly launched for a managed profile user, they are always re-launched for the profile owner user For instance, the following command just ends up launching the system IME settings for the user 0, not user 10. adb shell am start --user 10 \ -a "android.settings.INPUT_METHOD_SETTINGS" In order to enable per-profile IME mode, we need to remove PRIMARY_PROFILE_CONTROLLED from those classes. Unfortunately, the settings is baked into ApplicationManifest.xml hence we canot simply hook it up with the runtime flag InputMethodSystemProperty.PER_PROFILE_IME_ENABLED. Thus this CL simply remove PRIMARY_PROFILE_CONTROLLED from those classes, with an assumption that users basically will not see those Activity classes running under managed profile users unless per-profile IME flag is enabled. This is because both LanguageAndInputSettingsActivity and SettingsActivity are still marked PRIMARY_PROFILE_CONTROLLED=true. This means that almost all user-visible entry points are still be running with profile owner's user ID. Note also that because of Settings redirection implemented with Settings#CLONE_TO_MANAGED_PROFILE, what are shown on those Activity classes are basically correct. What they cannot do without enabling per-profile IME is updating actual secure settings. [1]: If3ec3866778282219267481b8f419774f7f2c9de 2513851a Bug: 120748696 Test: Manually done as follows. 1. adb root 2. adb shell setprop persist.debug.per_profile_ime 1 3. adb reboot 4. Install Test DPC. 5. Enable managed profile with Test DPC. 6. Open "Files" app for the main profile. 7. Tap the search box to show AOSP Keyboard. 8. Long tap the comma key, then "Lauguage" on the "Input options" dialog. 9. Uncheck "Use system languages" then check "English (UK)". 10. Open "Files" app for the work profile. 11. Long tap the comma key, then "Lauguage" on the "Input options" dialog. 12. Make sure that "Use system languages" is checked. 13. adb shell am start --user 10 \ -a android.settings.INPUT_METHOD_SETTINGS 14. Make sure there is no Toast message "You're using this app outside of your work profile". 15. adb shell am start --user 10 \ -a android.settings.INPUT_METHOD_SUBTYPE_SETTINGS 16. Make sure there is no Toast message. 17. adb shell am start --user 10 \ -a android.settings.USER_DICTIONARY_SETTINGS 14. Make sure there is no Toast message. Change-Id: I6ee1f226a616bb5f802f8e1d3b6f1dbbe492c6e5
Loading
Please register or sign in to comment