Loading core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -6018,6 +6018,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 ':'. Loading core/java/com/android/internal/app/AssistUtils.java +40 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } } core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2502,6 +2502,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> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2675,6 +2675,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" /> Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading
core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -6018,6 +6018,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 ':'. Loading
core/java/com/android/internal/app/AssistUtils.java +40 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } }
core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2502,6 +2502,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> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2675,6 +2675,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" /> Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading