Loading core/java/android/view/inputmethod/InputMethodManager.java +17 −2 Original line number Diff line number Diff line Loading @@ -1427,17 +1427,32 @@ public final class InputMethodManager { * @see #startStylusHandwriting(View) */ public boolean isStylusHandwritingAvailable() { return isStylusHandwritingAvailableAsUser(UserHandle.myUserId()); } /** * Returns {@code true} if currently selected IME supports Stylus handwriting & is enabled for * the given userId. * If the method returns {@code false}, {@link #startStylusHandwriting(View)} shouldn't be * called and Stylus touch should continue as normal touch input. * @see #startStylusHandwriting(View) * @param userId user ID to query. * @hide */ public boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) { final Context fallbackContext = ActivityThread.currentApplication(); if (fallbackContext == null) { return false; } if (Settings.Global.getInt(fallbackContext.getContentResolver(), Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 0) { if (DEBUG) { Log.d(TAG, "Stylus handwriting is not enabled in settings."); } return false; } try { return mService.isStylusHandwritingAvailable(); return mService.isStylusHandwritingAvailableAsUser(userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/com/android/internal/view/IInputMethodManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -91,5 +91,5 @@ interface IInputMethodManager { /** Start Stylus handwriting session **/ void startStylusHandwriting(in IInputMethodClient client); /** Returns {@code true} if currently selected IME supports Stylus handwriting. */ boolean isStylusHandwritingAvailable(); boolean isStylusHandwritingAvailableAsUser(int userId); } services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +17 −2 Original line number Diff line number Diff line Loading @@ -2108,10 +2108,25 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } @Override public boolean isStylusHandwritingAvailable() { public boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) { if (UserHandle.getCallingUserId() != userId) { mContext.enforceCallingPermission( Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); } synchronized (ImfLock.class) { if (userId == mSettings.getCurrentUserId()) { return mBindingController.supportsStylusHandwriting(); } //TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList. //TODO(b/210039666): use cache. final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting(); } } @GuardedBy("ImfLock.class") Loading Loading
core/java/android/view/inputmethod/InputMethodManager.java +17 −2 Original line number Diff line number Diff line Loading @@ -1427,17 +1427,32 @@ public final class InputMethodManager { * @see #startStylusHandwriting(View) */ public boolean isStylusHandwritingAvailable() { return isStylusHandwritingAvailableAsUser(UserHandle.myUserId()); } /** * Returns {@code true} if currently selected IME supports Stylus handwriting & is enabled for * the given userId. * If the method returns {@code false}, {@link #startStylusHandwriting(View)} shouldn't be * called and Stylus touch should continue as normal touch input. * @see #startStylusHandwriting(View) * @param userId user ID to query. * @hide */ public boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) { final Context fallbackContext = ActivityThread.currentApplication(); if (fallbackContext == null) { return false; } if (Settings.Global.getInt(fallbackContext.getContentResolver(), Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 0) { if (DEBUG) { Log.d(TAG, "Stylus handwriting is not enabled in settings."); } return false; } try { return mService.isStylusHandwritingAvailable(); return mService.isStylusHandwritingAvailableAsUser(userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/com/android/internal/view/IInputMethodManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -91,5 +91,5 @@ interface IInputMethodManager { /** Start Stylus handwriting session **/ void startStylusHandwriting(in IInputMethodClient client); /** Returns {@code true} if currently selected IME supports Stylus handwriting. */ boolean isStylusHandwritingAvailable(); boolean isStylusHandwritingAvailableAsUser(int userId); }
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +17 −2 Original line number Diff line number Diff line Loading @@ -2108,10 +2108,25 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } @Override public boolean isStylusHandwritingAvailable() { public boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) { if (UserHandle.getCallingUserId() != userId) { mContext.enforceCallingPermission( Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); } synchronized (ImfLock.class) { if (userId == mSettings.getCurrentUserId()) { return mBindingController.supportsStylusHandwriting(); } //TODO(b/197848765): This can be optimized by caching multi-user methodMaps/methodList. //TODO(b/210039666): use cache. final ArrayMap<String, InputMethodInfo> methodMap = queryMethodMapForUser(userId); final InputMethodSettings settings = new InputMethodSettings(mContext.getResources(), mContext.getContentResolver(), methodMap, userId, true); final InputMethodInfo imi = methodMap.get(settings.getSelectedInputMethod()); return imi != null && imi.supportsStylusHandwriting(); } } @GuardedBy("ImfLock.class") Loading