summaryrefslogtreecommitdiff
path: root/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2015-12-16 12:50:23 -0800
committerYohei Yukawa <yukawa@google.com>2016-01-07 06:37:13 +0000
commitb823e12d6c7d2fd1f07321ffc2c07dddaf32c3a5 (patch)
tree3b6bf7b7fe2321a6a83e04251f1759866e3112a4 /java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
parent91965ce45c2bc18ff4e390384bbdba81f2159696 (diff)
Hide settings-key until the device is unlocked.
Starting in N, we are going to have new APIs to officially support the situation where apps need to run before the user has unlocked their device for the first time. For IME developers those APIs would be important not only because IMEs developers may want to support other apps that support that feature but also because IMEs developers have already needed to pay attention to the same situation where the IME is running so that the user can enter the initial password (e.g. for an encrypted device). Bug 11270326 is a perfect example of this scenario. Now we can disable settings-key until the device is unlocked by using the new API when running in Android N devices. Bug: 11270326 Change-Id: Ie1c6efa63b60b91430f1a78dde624d0f3dff3c69
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index 47013fe9e..26ff051bb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -32,6 +32,7 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
+import com.android.inputmethod.compat.UserManagerCompatUtils;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.UniqueKeysCache;
@@ -275,6 +276,16 @@ public final class KeyboardLayoutSet {
params.mIsPasswordField = InputTypeUtils.isPasswordInputType(editorInfo.inputType);
params.mNoSettingsKey = InputAttributes.inPrivateImeOptions(
mPackageName, NO_SETTINGS_KEY, editorInfo);
+
+ // When the device is still unlocked, features like showing the IME setting app need to
+ // be locked down.
+ // TODO: Switch to {@code UserManagerCompat.isUserUnlocked()} in the support-v4 library
+ // when it becomes publicly available.
+ @UserManagerCompatUtils.LockState
+ final int lockState = UserManagerCompatUtils.getUserLockState(context);
+ if (lockState == UserManagerCompatUtils.LOCK_STATE_LOCKED) {
+ params.mNoSettingsKey = true;
+ }
}
public Builder setKeyboardGeometry(final int keyboardWidth, final int keyboardHeight) {