Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77c1f608 authored by Steve Elliott's avatar Steve Elliott
Browse files

DO NOT MERGE: Add configurable default setting for assistant componentname

By requiring an explicit default setting, it eliminates all ambiguous
states where a disambiguation would normally be shown. With this
change in place, at no point should a disambiguation be shown.

Test: manual
Bug: 111603898
Change-Id: Ib32dafbd3c6fcbe11186dc8ecab6b09c9b734067
Merged-In: Id39fdf700ed4ef08ebbc333b5452223430ac2e48
parent ab80221a
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Log;

import com.android.internal.R;

import java.util.ArrayList;
import java.util.Set;

/**
 * Utility method for dealing with the assistant aspects of
 * {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}.
@@ -40,6 +45,14 @@ public class AssistUtils {

    private static final String TAG = "AssistUtils";

    /**
     * Sentinel value for "no default assistant specified."
     *
     * Empty string is already used to represent an explicit setting of No Assistant. null cannot
     * be used because we can't represent a null value in XML.
     */
    private static final String UNSET = "#+UNSET";

    private final Context mContext;
    private final IVoiceInteractionManagerService mVoiceInteractionManagerService;

@@ -152,13 +165,27 @@ public class AssistUtils {
            return ComponentName.unflattenFromString(setting);
        }

        final String defaultSetting = mContext.getResources().getString(
                R.string.config_defaultAssistantComponentName);
        if (defaultSetting != null && !defaultSetting.equals(UNSET)) {
            return ComponentName.unflattenFromString(defaultSetting);
        }

        // Fallback to keep backward compatible behavior when there is no user setting.
        if (activeServiceSupportsAssistGesture()) {
            return getActiveServiceComponentName();
        }

        Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
                .getAssistIntent(false);
        if (UNSET.equals(defaultSetting)) {
            return null;
        }

        final SearchManager searchManager =
                (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
        if (searchManager == null) {
            return null;
        }
        final Intent intent = searchManager.getAssistIntent(false);
        PackageManager pm = mContext.getPackageManager();
        ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY,
                userId);
+4 −0
Original line number Diff line number Diff line
@@ -2913,4 +2913,8 @@

    <!-- An array of packages that need to be treated as type service in battery settings -->
    <string-array translatable="false" name="config_batteryPackageTypeService"/>

    <!-- Component name for default assistant on this device -->
    <string name="config_defaultAssistantComponentName">#+UNSET</string>

</resources>
+1 −0
Original line number Diff line number Diff line
@@ -3028,4 +3028,5 @@
  <java-symbol type="array" name="config_batteryPackageTypeSystem" />
  <java-symbol type="array" name="config_batteryPackageTypeService" />

  <java-symbol type="string" name="config_defaultAssistantComponentName" />
</resources>