Merge "Make scribe setting default_on and secure" into udc-dev am: b679e3eeba am: b858ff707e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21618239

Change-Id: Idfb82297e43b995c5ab9ca82c56f1e2b7c3354b9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Taran Singh
2023-03-29 08:10:36 +00:00
committed by Automerger Merge Worker
7 changed files with 66 additions and 40 deletions

View File

@@ -2616,7 +2616,6 @@ package android.provider {
field @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
field public static final String SHOW_FIRST_CRASH_DIALOG = "show_first_crash_dialog";
field public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
field public static final String USER_DISABLED_HDR_FORMATS = "user_disabled_hdr_formats";
field public static final String USER_PREFERRED_REFRESH_RATE = "user_preferred_refresh_rate";
field public static final String USER_PREFERRED_RESOLUTION_HEIGHT = "user_preferred_resolution_height";
@@ -2648,6 +2647,8 @@ package android.provider {
field public static final String SHOW_FIRST_CRASH_DIALOG_DEV_OPTION = "show_first_crash_dialog_dev_option";
field public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
field public static final String STYLUS_BUTTONS_ENABLED = "stylus_buttons_enabled";
field public static final int STYLUS_HANDWRITING_DEFAULT_VALUE = 1; // 0x1
field public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
}

View File

@@ -7141,6 +7141,28 @@ public final class Settings {
public static final String INPUT_METHOD_SELECTOR_VISIBILITY =
"input_method_selector_visibility";
/**
* Toggle for enabling stylus handwriting. When enabled, current Input method receives
* stylus {@link MotionEvent}s if an {@link Editor} is focused.
*
* @see #STYLUS_HANDWRITING_DEFAULT_VALUE
* @hide
*/
@TestApi
@Readable
@SuppressLint("NoSettingsProvider")
public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
/**
* Default value for {@link #STYLUS_HANDWRITING_ENABLED}.
*
* @hide
*/
@TestApi
@Readable
@SuppressLint("NoSettingsProvider")
public static final int STYLUS_HANDWRITING_DEFAULT_VALUE = 1;
/**
* The currently selected voice interaction service flattened ComponentName.
* @hide
@@ -16510,17 +16532,6 @@ public final class Settings {
@Readable
public static final String AUTOFILL_MAX_VISIBLE_DATASETS = "autofill_max_visible_datasets";
/**
* Toggle for enabling stylus handwriting. When enabled, current Input method receives
* stylus {@link MotionEvent}s if an {@link Editor} is focused.
*
* @hide
*/
@TestApi
@Readable
@SuppressLint("NoSettingsProvider")
public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
/**
* Indicates whether a stylus has ever been used on the device.
*

View File

@@ -508,6 +508,7 @@ final class IInputMethodManagerGlobalInvoker {
@AnyThread
static void prepareStylusHandwritingDelegation(
@NonNull IInputMethodClient client,
@UserIdInt int userId,
@NonNull String delegatePackageName,
@NonNull String delegatorPackageName) {
final IInputMethodManager service = getService();
@@ -516,7 +517,7 @@ final class IInputMethodManagerGlobalInvoker {
}
try {
service.prepareStylusHandwritingDelegation(
client, delegatePackageName, delegatorPackageName);
client, userId, delegatePackageName, delegatorPackageName);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -525,6 +526,7 @@ final class IInputMethodManagerGlobalInvoker {
@AnyThread
static boolean acceptStylusHandwritingDelegation(
@NonNull IInputMethodClient client,
@UserIdInt int userId,
@NonNull String delegatePackageName,
@NonNull String delegatorPackageName) {
final IInputMethodManager service = getService();
@@ -533,7 +535,7 @@ final class IInputMethodManagerGlobalInvoker {
}
try {
return service.acceptStylusHandwritingDelegation(
client, delegatePackageName, delegatorPackageName);
client, userId, delegatePackageName, delegatorPackageName);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

View File

@@ -1553,9 +1553,7 @@ public final class InputMethodManager {
if (fallbackContext == null) {
return false;
}
if (!isStylusHandwritingEnabled(fallbackContext)) {
return false;
}
return IInputMethodManagerGlobalInvoker.isStylusHandwritingAvailableAsUser(userId);
}
@@ -2244,11 +2242,6 @@ public final class InputMethodManager {
}
boolean useDelegation = !TextUtils.isEmpty(delegatorPackageName);
if (!isStylusHandwritingEnabled(view.getContext())) {
Log.w(TAG, "Stylus handwriting pref is disabled. "
+ "Ignoring calls to start stylus handwriting.");
return false;
}
checkFocus();
synchronized (mH) {
@@ -2264,7 +2257,8 @@ public final class InputMethodManager {
}
if (useDelegation) {
return IInputMethodManagerGlobalInvoker.acceptStylusHandwritingDelegation(
mClient, view.getContext().getOpPackageName(), delegatorPackageName);
mClient, UserHandle.myUserId(), view.getContext().getOpPackageName(),
delegatorPackageName);
} else {
IInputMethodManagerGlobalInvoker.startStylusHandwriting(mClient);
}
@@ -2272,15 +2266,6 @@ public final class InputMethodManager {
}
}
private boolean isStylusHandwritingEnabled(@NonNull Context context) {
if (Settings.Global.getInt(context.getContentResolver(),
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 0) {
Log.d(TAG, "Stylus handwriting pref is disabled.");
return false;
}
return true;
}
/**
* Prepares delegation of starting stylus handwriting session to a different editor in same
* or different window than the view on which initial handwriting stroke was detected.
@@ -2344,13 +2329,9 @@ public final class InputMethodManager {
fallbackImm.prepareStylusHandwritingDelegation(delegatorView, delegatePackageName);
}
if (!isStylusHandwritingEnabled(delegatorView.getContext())) {
Log.w(TAG, "Stylus handwriting pref is disabled. "
+ "Ignoring prepareStylusHandwritingDelegation().");
return;
}
IInputMethodManagerGlobalInvoker.prepareStylusHandwritingDelegation(
mClient,
UserHandle.myUserId(),
delegatePackageName,
delegatorView.getContext().getOpPackageName());
}

View File

@@ -150,12 +150,13 @@ interface IInputMethodManager {
/** Prepares delegation of starting stylus handwriting session to a different editor **/
void prepareStylusHandwritingDelegation(in IInputMethodClient client,
in int userId,
in String delegatePackageName,
in String delegatorPackageName);
/** Accepts and starts a stylus handwriting session for the delegate view **/
boolean acceptStylusHandwritingDelegation(in IInputMethodClient client,
in String delegatePackageName, in String delegatorPackageName);
in int userId, in String delegatePackageName, in String delegatorPackageName);
/** Returns {@code true} if currently selected IME supports Stylus handwriting. */
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "

View File

@@ -274,7 +274,6 @@ public class SettingsBackupTest {
Settings.Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD,
Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS,
Settings.Global.SMART_SUGGESTIONS_IN_NOTIFICATIONS_FLAGS,
Settings.Global.STYLUS_HANDWRITING_ENABLED,
Settings.Global.STYLUS_EVER_USED,
Settings.Global.ENABLE_ADB_INCREMENTAL_INSTALL_DEFAULT,
Settings.Global.ENABLE_MULTI_SLOT_TIMEOUT_MILLIS,
@@ -787,6 +786,7 @@ public class SettingsBackupTest {
Settings.Secure.SMS_DEFAULT_APPLICATION,
Settings.Secure.SPELL_CHECKER_ENABLED, // Intentionally removed in Q
Settings.Secure.STYLUS_BUTTONS_ENABLED,
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
Settings.Secure.TRUST_AGENTS_INITIALIZED,
Settings.Secure.KNOWN_TRUST_AGENTS_INITIALIZED,
Settings.Secure.TV_APP_USES_NON_SYSTEM_INPUTS,

View File

@@ -20,6 +20,8 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.IServiceManager.DUMP_FLAG_PROTO;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.provider.Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE;
import static android.provider.Settings.Secure.STYLUS_HANDWRITING_ENABLED;
import static android.server.inputmethod.InputMethodManagerServiceProto.BACK_DISPOSITION;
import static android.server.inputmethod.InputMethodManagerServiceProto.BOUND_TO_METHOD;
import static android.server.inputmethod.InputMethodManagerServiceProto.CUR_ATTRIBUTE;
@@ -2067,10 +2069,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
synchronized (ImfLock.class) {
if (!isStylusHandwritingEnabled(mContext, userId)) {
return false;
}
// Check if selected IME of current user supports handwriting.
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);
@@ -2081,6 +2087,18 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
}
}
private boolean isStylusHandwritingEnabled(
@NonNull Context context, @UserIdInt int userId) {
// If user is a profile, use preference of it`s parent profile.
final int profileParentUserId = mUserManagerInternal.getProfileParentId(userId);
if (Settings.Secure.getIntForUser(context.getContentResolver(),
STYLUS_HANDWRITING_ENABLED, STYLUS_HANDWRITING_DEFAULT_VALUE,
profileParentUserId) == 0) {
return false;
}
return true;
}
@GuardedBy("ImfLock.class")
private List<InputMethodInfo> getInputMethodListLocked(@UserIdInt int userId,
@DirectBootAwareness int directBootAwareness, int callingUid) {
@@ -3418,8 +3436,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@Override
public void prepareStylusHandwritingDelegation(
@NonNull IInputMethodClient client,
@UserIdInt int userId,
@NonNull String delegatePackageName,
@NonNull String delegatorPackageName) {
if (!isStylusHandwritingEnabled(mContext, userId)) {
Slog.w(TAG, "Can not prepare stylus handwriting delegation. Stylus handwriting"
+ " pref is disabled for user: " + userId);
return;
}
if (!verifyClientAndPackageMatch(client, delegatorPackageName)) {
Slog.w(TAG, "prepareStylusHandwritingDelegation() fail");
throw new IllegalArgumentException("Delegator doesn't match Uid");
@@ -3430,8 +3454,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@Override
public boolean acceptStylusHandwritingDelegation(
@NonNull IInputMethodClient client,
@UserIdInt int userId,
@NonNull String delegatePackageName,
@NonNull String delegatorPackageName) {
if (!isStylusHandwritingEnabled(mContext, userId)) {
Slog.w(TAG, "Can not accept stylus handwriting delegation. Stylus handwriting"
+ " pref is disabled for user: " + userId);
return false;
}
if (!verifyDelegator(client, delegatePackageName, delegatorPackageName)) {
return false;
}