DO NOT MERGE ANYWHERE: resolve merge conflicts of 77c1f60801 to oc-dr1-dev

Bug: 111603898
Test: manual
Change-Id: I5933f27f2fbd90a6de447fbf7f17063f6b7f1fb8
This commit is contained in:
Steve Elliott
2018-10-26 15:29:12 -04:00
committed by Myles Watson
3 changed files with 35 additions and 2 deletions

View File

@@ -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);

View File

@@ -2981,4 +2981,8 @@
<!-- Allow SystemUI to show the shutdown dialog -->
<bool name="config_showSysuiShutdown">true</bool>
<!-- Component name for default assistant on this device -->
<string name="config_defaultAssistantComponentName">#+UNSET</string>
</resources>

View File

@@ -3061,4 +3061,6 @@
<java-symbol type="layout" name="shutdown_dialog" />
<java-symbol type="dimen" name="chooser_service_spacing" />
<java-symbol type="bool" name="config_showSysuiShutdown" />
<java-symbol type="string" name="config_defaultAssistantComponentName" />
</resources>