summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-02-24 02:13:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-02-24 02:13:27 +0000
commit4e056c8bfacc2be6d36e47305df4a85f87d02bc4 (patch)
tree0fa44f99966cae686463b0f48fa53602683cbe23
parent99dac4043796885089ba7677f8e22caa60a1b327 (diff)
parentac5cecd85db9e1bf6e358748e9c77324978ff922 (diff)
Merge "Explicitly do not support SEARCH_SERVICE on UI_MODE_TYPE_WATCH"
-rw-r--r--core/java/android/app/Activity.java16
-rw-r--r--core/java/android/app/SearchManager.java3
-rw-r--r--core/java/android/content/Context.java6
-rw-r--r--core/java/com/android/internal/policy/PhoneWindow.java4
4 files changed, 23 insertions, 6 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 3ebe89f3a487..3d04e2c64bee 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4161,9 +4161,10 @@ public class Activity extends ContextThemeWrapper
* <p>You can override this function to force global search, e.g. in response to a dedicated
* search key, or to block search entirely (by simply returning false).
*
- * <p>Note: when running in a {@link Configuration#UI_MODE_TYPE_TELEVISION}, the default
- * implementation changes to simply return false and you must supply your own custom
- * implementation if you want to support search.</p>
+ * <p>Note: when running in a {@link Configuration#UI_MODE_TYPE_TELEVISION} or
+ * {@link Configuration#UI_MODE_TYPE_WATCH}, the default implementation changes to simply
+ * return false and you must supply your own custom implementation if you want to support
+ * search.
*
* @param searchEvent The {@link SearchEvent} that signaled this search.
* @return Returns {@code true} if search launched, and {@code false} if the activity does
@@ -4183,8 +4184,10 @@ public class Activity extends ContextThemeWrapper
* @see #onSearchRequested(SearchEvent)
*/
public boolean onSearchRequested() {
- if ((getResources().getConfiguration().uiMode&Configuration.UI_MODE_TYPE_MASK)
- != Configuration.UI_MODE_TYPE_TELEVISION) {
+ final int uiMode = getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_TYPE_MASK;
+ if (uiMode != Configuration.UI_MODE_TYPE_TELEVISION
+ && uiMode != Configuration.UI_MODE_TYPE_WATCH) {
startSearch(null, false, null, false);
return true;
} else {
@@ -4213,6 +4216,9 @@ public class Activity extends ContextThemeWrapper
* is to inject specific data such as context data, it is preferred to <i>override</i>
* onSearchRequested(), so that any callers to it will benefit from the override.
*
+ * <p>Note: when running in a {@link Configuration#UI_MODE_TYPE_WATCH}, use of this API is
+ * not supported.
+ *
* @param initialQuery Any non-null non-empty string will be inserted as
* pre-entered text in the search query box.
* @param selectInitialQuery If true, the initial query will be preselected, which means that
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index ea990ad2924e..4e2cb646e714 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -48,6 +48,9 @@ import java.util.List;
* and the {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}
* {@link android.content.Intent Intent}.
*
+ * <p>
+ * {@link Configuration#UI_MODE_TYPE_WATCH} does not support this system service.
+ *
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For more information about using the search dialog and adding search
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index f184380fd36c..e1a00b146576 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3370,7 +3370,11 @@ public abstract class Context {
* Use with {@link #getSystemService(String)} to retrieve a {@link
* android.app.SearchManager} for handling searches.
*
- * @see #getSystemService(String)
+ * <p>
+ * {@link Configuration#UI_MODE_TYPE_WATCH} does not support
+ * {@link android.app.SearchManager}.
+ *
+ * @see #getSystemService
* @see android.app.SearchManager
*/
public static final String SEARCH_SERVICE = "search";
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 03a7cd26da36..50c9d6c69ac9 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -2040,6 +2040,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
if (getKeyguardManager().inKeyguardRestrictedInputMode()) {
break;
}
+ if ((getContext().getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH) {
+ break;
+ }
if (event.isTracking() && !event.isCanceled()) {
launchDefaultSearch(event);
}