summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adrian Roos <roosa@google.com> 2016-08-11 15:42:40 -0700
committer Adrian Roos <roosa@google.com> 2016-08-12 12:04:53 -0700
commit2335bd67876e5346acef8db2fc2f58fb2adb465e (patch)
tree37f5b28dc88226ca40181c63ef4f65b88c0ef1b3
parent58635e74edd5c5424ae22d72e6326d2ac89983bd (diff)
Assist: Allow disabling the disclosure animation
Change-Id: I6e7ed00f066fda7cc268119e7aa4133010aa69c1 Fixes: 30809067
-rwxr-xr-xcore/java/android/provider/Settings.java11
-rw-r--r--core/java/com/android/internal/app/AssistUtils.java40
-rw-r--r--core/res/res/values/config.xml4
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java3
5 files changed, 58 insertions, 1 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5da55b164f54..9383a8b1f4a9 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6019,6 +6019,17 @@ public final class Settings {
public static final String ASSIST_SCREENSHOT_ENABLED = "assist_screenshot_enabled";
/**
+ * Specifies whether the screen will show an animation if screen contents are sent to the
+ * assist application (active voice interaction service).
+ *
+ * Note that the disclosure will be forced for third-party assistants or if the device
+ * does not support disabling it.
+ *
+ * @hide
+ */
+ public static final String ASSIST_DISCLOSURE_ENABLED = "assist_disclosure_enabled";
+
+ /**
* Names of the service components that the current user has explicitly allowed to
* see all of the user's notifications, separated by ':'.
*
diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java
index 56c5cc9b69ec..294007946c77 100644
--- a/core/java/com/android/internal/app/AssistUtils.java
+++ b/core/java/com/android/internal/app/AssistUtils.java
@@ -16,10 +16,13 @@
package com.android.internal.app;
+import com.android.internal.R;
+
import android.app.SearchManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
@@ -166,4 +169,41 @@ public class AssistUtils {
return null;
}
+ public static boolean isPreinstalledAssistant(Context context, ComponentName assistant) {
+ if (assistant == null) {
+ return false;
+ }
+ ApplicationInfo applicationInfo;
+ try {
+ applicationInfo = context.getPackageManager().getApplicationInfo(
+ assistant.getPackageName(), 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ return applicationInfo.isSystemApp() || applicationInfo.isUpdatedSystemApp();
+ }
+
+ private static boolean isDisclosureEnabled(Context context) {
+ return Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.ASSIST_DISCLOSURE_ENABLED, 0) != 0;
+ }
+
+ /**
+ * @return if the disclosure animation should trigger for the given assistant.
+ *
+ * Third-party assistants will always need to disclose, while the user can configure this for
+ * pre-installed assistants.
+ */
+ public static boolean shouldDisclose(Context context, ComponentName assistant) {
+ if (!allowDisablingAssistDisclosure(context)) {
+ return true;
+ }
+
+ return isDisclosureEnabled(context) || !isPreinstalledAssistant(context, assistant);
+ }
+
+ public static boolean allowDisablingAssistDisclosure(Context context) {
+ return context.getResources().getBoolean(
+ com.android.internal.R.bool.config_allowDisablingAssistDisclosure);
+ }
}
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 2835c6f5fa0a..8636bcc29681 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2500,6 +2500,10 @@
<!-- Flag indicating whether round icons should be parsed from the application manifest. -->
<bool name="config_useRoundIcon">false</bool>
+ <!-- Flag indicating whether the assist disclosure can be disabled using
+ ASSIST_DISCLOSURE_ENABLED. -->
+ <bool name="config_allowDisablingAssistDisclosure">false</bool>
+
<!-- True if the device supports system navigation keys. -->
<bool name="config_supportSystemNavigationKeys">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 2a40c0836ae5..349c8967e8b2 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2674,6 +2674,7 @@
<java-symbol type="drawable" name="ic_doc_generic" />
<java-symbol type="bool" name="config_nightDisplayAvailable" />
+ <java-symbol type="bool" name="config_allowDisablingAssistDisclosure" />
<java-symbol type="integer" name="config_defaultNightDisplayAutoMode" />
<java-symbol type="integer" name="config_defaultNightDisplayCustomStartTime" />
<java-symbol type="integer" name="config_defaultNightDisplayCustomEndTime" />
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
index b0cc2aca8981..c3075b3daa3e 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
@@ -46,6 +46,7 @@ import android.util.Slog;
import android.view.IWindowManager;
import android.view.WindowManager;
+import com.android.internal.app.AssistUtils;
import com.android.internal.app.IAssistScreenshotReceiver;
import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.internal.app.IVoiceInteractor;
@@ -301,7 +302,7 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
} else {
mScreenshot = null;
}
- if (needDisclosure) {
+ if (needDisclosure && AssistUtils.shouldDisclose(mContext, mSessionComponentName)) {
mHandler.post(mShowAssistDisclosureRunnable);
}
if (mSession != null) {