From 3204251a4a77789d3ed64cd09fed173aca7be4bc Mon Sep 17 00:00:00 2001 From: Anna Galusza Date: Mon, 29 Feb 2016 15:39:08 -0800 Subject: [PATCH] Throw exception from SoftKeyboardController if connection is dead and declare SHOW_MODE_AUTO and SHOW_MODE_HIDDEN in AccessibilityService class. Bug: 27364143 Change-Id: I02c23fbfab1eae8b2a155b1d9c3857e4eb6addb1 --- api/current.txt | 2 + api/system-current.txt | 2 + api/test-current.txt | 2 + .../AccessibilityService.java | 38 ++++++++----------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/api/current.txt b/api/current.txt index d4f9d73124afb..2b6bdd428dd56 100644 --- a/api/current.txt +++ b/api/current.txt @@ -2668,6 +2668,8 @@ package android.accessibilityservice { field public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // 0x7 field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService"; field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice"; + field public static final int SHOW_MODE_AUTO = 0; // 0x0 + field public static final int SHOW_MODE_HIDDEN = 1; // 0x1 } public static abstract class AccessibilityService.GestureResultCallback { diff --git a/api/system-current.txt b/api/system-current.txt index db90b8903d965..745dd7354e618 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -2770,6 +2770,8 @@ package android.accessibilityservice { field public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // 0x7 field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService"; field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice"; + field public static final int SHOW_MODE_AUTO = 0; // 0x0 + field public static final int SHOW_MODE_HIDDEN = 1; // 0x1 } public static abstract class AccessibilityService.GestureResultCallback { diff --git a/api/test-current.txt b/api/test-current.txt index ad3a5e64463f6..619b2bb955b31 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2668,6 +2668,8 @@ package android.accessibilityservice { field public static final int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // 0x7 field public static final java.lang.String SERVICE_INTERFACE = "android.accessibilityservice.AccessibilityService"; field public static final java.lang.String SERVICE_META_DATA = "android.accessibilityservice"; + field public static final int SHOW_MODE_AUTO = 0; // 0x0 + field public static final int SHOW_MODE_HIDDEN = 1; // 0x1 } public static abstract class AccessibilityService.GestureResultCallback { diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index fb5f5b9e1efca..ac3b8e360b2e9 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -383,13 +383,7 @@ public abstract class AccessibilityService extends Service { @Retention(RetentionPolicy.SOURCE) @IntDef({SHOW_MODE_AUTO, SHOW_MODE_HIDDEN}) public @interface SoftKeyboardShowMode {}; - /** - * @hide - */ public static final int SHOW_MODE_AUTO = 0; - /** - * @hide - */ public static final int SHOW_MODE_HIDDEN = 1; private int mConnectionId; @@ -1137,7 +1131,7 @@ public abstract class AccessibilityService extends Service { } /** - * Removes all instances of the specified change listener from teh list of magnification + * Removes all instances of the specified change listener from the list of magnification * change listeners. * * @param listener the listener to remove, must be non-null @@ -1216,14 +1210,11 @@ public abstract class AccessibilityService extends Service { /** * Returns the show mode of the soft keyboard. The default show mode is - * {@code Settings.Secure.SHOW_MODE_AUTO}, where the soft keyboard is shown when a text - * input field is focused. An AccessibilityService can also request the show mode - * {@code Settings.Secure.SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. + * {@code SHOW_MODE_AUTO}, where the soft keyboard is shown when a text input field is + * focused. An AccessibilityService can also request the show mode + * {@code SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. * * @return the current soft keyboard show mode - * - * @see Settings#Secure#SHOW_MODE_AUTO - * @see Settings#Secure#SHOW_MODE_HIDDEN */ @SoftKeyboardShowMode public int getShowMode() { @@ -1239,9 +1230,9 @@ public abstract class AccessibilityService extends Service { /** * Sets the soft keyboard show mode. The default show mode is - * {@code Settings.Secure.SHOW_MODE_AUTO}, where the soft keyboard is shown when a text - * input field is focused. An AccessibilityService can also request the show mode - * {@code Settings.Secure.SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. The + * {@code SHOW_MODE_AUTO}, where the soft keyboard is shown when a text input field is + * focused. An AccessibilityService can also request the show mode + * {@code SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. The * The lastto this method will be honored, regardless of any previous calls (including those * made by other AccessibilityServices). *

@@ -1251,9 +1242,6 @@ public abstract class AccessibilityService extends Service { * * @param showMode the new show mode for the soft keyboard * @return {@code true} on success - * - * @see Settings#Secure#SHOW_MODE_AUTO - * @see Settings#Secure#SHOW_MODE_HIDDEN */ public boolean setShowMode(@SoftKeyboardShowMode int showMode) { final IAccessibilityServiceConnection connection = @@ -1263,9 +1251,13 @@ public abstract class AccessibilityService extends Service { try { return connection.setSoftKeyboardShowMode(showMode); } catch (RemoteException re) { - Log.w(LOG_TAG, "Falied to set soft keyboard behavior", re); + Log.w(LOG_TAG, "Failed to set soft keyboard behavior", re); + re.rethrowFromSystemServer(); } + } else { + throw new RuntimeException("AccessibilityServiceConnection is null"); } + return false; } @@ -1275,9 +1267,9 @@ public abstract class AccessibilityService extends Service { public interface OnShowModeChangedListener { /** * Called when the soft keyboard behavior changes. The default show mode is - * {@code Settings.Secure.SHOW_MODE_AUTO}, where the soft keyboard is shown when a text - * input field is focused. An AccessibilityService can also request the show mode - * {@code Settings.Secure.SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. + * {@code SHOW_MODE_AUTO}, where the soft keyboard is shown when a text input field is + * focused. An AccessibilityService can also request the show mode + * {@code SHOW_MODE_HIDDEN}, where the soft keyboard is never shown. * * @param controller the soft keyboard controller * @param showMode the current soft keyboard show mode