diff options
author | Tarandeep Singh <tarandeep@google.com> | 2019-07-01 14:27:25 -0700 |
---|---|---|
committer | Manjae Park <manjaepark@google.com> | 2019-12-16 12:46:39 -0800 |
commit | f7f0454eed816d59fde4d1b36c0c7e69987ead5c (patch) | |
tree | 0d378364351b16be6af6bc81efa5b7f0e9fc157e | |
parent | 15273ad9f1c5dc34e788350b559b1a3f0f46facf (diff) | |
download | base-f7f0454eed816d59fde4d1b36c0c7e69987ead5c.tar.gz |
DO NOT MERGE: Disable SpellChecker in secondary user's direct reply
For secondary users, when AOSP keyboard is used to type in
direct-reply, unknown words can be added to dictionary.
It's *not* OK for SpellCheckerService of primary user to
check unknown words typed by a secondary user.
The dialog to add these words shows up in primary user instead.
TextView uses TextView#isSuggestionsEnabled() to determine if
SpellChecker is enabled. This can be disabled by setting the flag
TYPE_TEXT_FLAG_NO_SUGGESTIONS in inputType.
Note: This doesn't affect workprofile users on P or older versions since
they use same SpellCheckerService for all workprofiles.
Bug: 123232892
Test: Manually tested using the steps mentioned in the bug.
1. Flash latest P build.
2. Install AOSP keyboard (LatinIME) and set it as default.
3. Install and open EditTextVariations
4. Initiate direct reply in primary user and type non-english
words like "ggggg hhhhh".
5. Observe that they get red underline and tapping it brings "add
to dictionary" popup.
6. Create a new secondary user and switch to it.
7. Once the setup completes, initiate a direct reply and type words
similar to step 4.
8. Verify that red underlines dont appear.
9. switch back to primary user and verify direct reply still has red
underlines.
Change-Id: I93918eb2c12e37908e03a7951a9e2c5375bc0ecc
(cherry picked from commit b52efcb9d58348d2bcb9c83d36b0f1ae1244482b)
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index 37b0de400c9e..ad78b3a01662 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.policy; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.app.ActivityManager; import android.app.Notification; import android.app.PendingIntent; import android.app.RemoteInput; @@ -27,7 +28,9 @@ import android.content.pm.ShortcutManager; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.UserHandle; import android.text.Editable; +import android.text.InputType; import android.text.TextWatcher; import android.util.AttributeSet; import android.util.Log; @@ -278,12 +281,22 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene if (mWrapper != null) { mWrapper.setRemoteInputVisible(true); } - mController.addRemoteInput(mEntry, mToken); + + // Disable suggestions on non-owner (secondary) user. + // SpellCheckerService of primary user runs on secondary as well which shows + // "Add to dictionary" dialog on the primary user. (See b/123232892) + // Note: this doesn't affect work-profile users on P or older versions. + if (UserHandle.myUserId() != ActivityManager.getCurrentUser()) { + mEditText.setInputType( + mEditText.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); + } + mEditText.setInnerFocusable(true); mEditText.mShowImeOnInputConnection = true; mEditText.setText(mEntry.remoteInputText); mEditText.setSelection(mEditText.getText().length()); mEditText.requestFocus(); + mController.addRemoteInput(mEntry, mToken); updateSendButton(); } |