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: Id39fdf700ed4ef08ebbc333b5452223430ac2e48 Merged-In: Id39fdf700ed4ef08ebbc333b5452223430ac2e48
This commit is contained in:
@@ -32,6 +32,11 @@ import android.os.ServiceManager;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
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
|
* Utility method for dealing with the assistant aspects of
|
||||||
* {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}.
|
* {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}.
|
||||||
@@ -40,6 +45,14 @@ public class AssistUtils {
|
|||||||
|
|
||||||
private static final String TAG = "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 Context mContext;
|
||||||
private final IVoiceInteractionManagerService mVoiceInteractionManagerService;
|
private final IVoiceInteractionManagerService mVoiceInteractionManagerService;
|
||||||
|
|
||||||
@@ -152,13 +165,27 @@ public class AssistUtils {
|
|||||||
return ComponentName.unflattenFromString(setting);
|
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.
|
// Fallback to keep backward compatible behavior when there is no user setting.
|
||||||
if (activeServiceSupportsAssistGesture()) {
|
if (activeServiceSupportsAssistGesture()) {
|
||||||
return getActiveServiceComponentName();
|
return getActiveServiceComponentName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
|
if (UNSET.equals(defaultSetting)) {
|
||||||
.getAssistIntent(false);
|
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();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY,
|
ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY,
|
||||||
userId);
|
userId);
|
||||||
|
|||||||
@@ -3087,4 +3087,8 @@
|
|||||||
booted. -->
|
booted. -->
|
||||||
<integer name="config_stableDeviceDisplayWidth">-1</integer>
|
<integer name="config_stableDeviceDisplayWidth">-1</integer>
|
||||||
<integer name="config_stableDeviceDisplayHeight">-1</integer>
|
<integer name="config_stableDeviceDisplayHeight">-1</integer>
|
||||||
|
|
||||||
|
<!-- Component name for default assistant on this device -->
|
||||||
|
<string name="config_defaultAssistantComponentName">#+UNSET</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -3078,4 +3078,6 @@
|
|||||||
|
|
||||||
<java-symbol type="integer" name="config_stableDeviceDisplayWidth" />
|
<java-symbol type="integer" name="config_stableDeviceDisplayWidth" />
|
||||||
<java-symbol type="integer" name="config_stableDeviceDisplayHeight" />
|
<java-symbol type="integer" name="config_stableDeviceDisplayHeight" />
|
||||||
|
|
||||||
|
<java-symbol type="string" name="config_defaultAssistantComponentName" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user