Merge "Add setting to disable automatic USB audio routing" into lmp-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2d2f9b4..63cb07c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -469,6 +469,21 @@
android:value="true" />
</activity>
+ <activity android:name="Settings$VoiceInputSettingsActivity"
+ android:label="@string/voice_input_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings$InputMethodAndLanguageSettingsActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.settings.VOICE_INPUT_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.voice.VoiceInputSettings" />
+ <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
+ android:resource="@id/language_settings" />
+ </activity>
+
<activity android:name="Settings$KeyboardLayoutPickerActivity"
android:label="@string/keyboard_layout_picker_title"
android:clearTaskOnLaunch="true">
@@ -984,6 +999,21 @@
</intent-filter>
</activity>
+ <activity android:name="Settings$UsageAccessSettingsActivity"
+ android:label="@string/usage_access_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings$SecuritySettingsActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.UsageAccessSettings" />
+ <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
+ android:resource="@id/security_settings" />
+ </activity>
+
<activity-alias android:name="SetProfileOwner"
android:label="@string/profile_owner_add_title"
android:targetActivity="DeviceAdminAdd">
diff --git a/res/layout/advanced_security_settings.xml b/res/layout/advanced_security_settings.xml
deleted file mode 100644
index 98ff43d..0000000
--- a/res/layout/advanced_security_settings.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2014 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingStart="@dimen/settings_side_margin"
- android:paddingEnd="@dimen/settings_side_margin">
-
- <ListView android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:drawSelectorOnTop="false"
- android:fastScrollEnabled="true" />
-
- <TextView android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/no_trust_agents"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
-</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bb86d6c..f410357 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -314,8 +314,6 @@
<string name="bluetooth_notif_message">Touch to pair with <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Bluetooth settings screen, menu to show the list of received files [CHAR LIMIT=30] -->
<string name="bluetooth_show_received_files">Show received files</string>
- <!-- Bluetooth settings screen, menu to show the list of email accounts to pull messages from [CHAR LIMIT=30] -->
- <string name="bluetooth_show_message_access">Message access</string>
<!-- Strings for BluetoothDevicePicker -->
<string name="device_picker">Bluetooth device chooser</string>
@@ -326,8 +324,6 @@
<!-- Strings for asking to the user whether to allow an app to enable bluetooth -->
<string name="bluetooth_ask_enablement">An app wants to turn on Bluetooth.</string>
- <!-- String for informing the user that bluetooth devices must be granted permission. [CHAR LIMIT=100] -->
- <string name="bluetooth_message_access_notice">Bluetooth devices must ask for permission before accessing available accounts.</string>
<!-- Strings for asking to the user whether to allow an app to enable discovery mode -->
<string name="bluetooth_ask_discovery" product="tablet">An app wants to make your tablet visible to other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>
<!-- Strings for asking to the user whether to allow an app to enable discovery mode -->
@@ -1207,8 +1203,6 @@
<string name="bluetooth_pairing_dialog_paring_request"><xliff:g id="device_name">%1$s</xliff:g> wants to pair with Bluetooth. When connected, it will have access to your contacts and call history.</string>
<!-- Bluetooth settings: The sub heading for devices which have already been paired with this device. [CHAR LIMIT=40] -->
<string name="bluetooth_preference_paired_devices">Paired devices</string>
- <!-- Bluetooth settings: The sub heading for messaging accesses. [CHAR LIMIT=50] -->
- <string name="bluetooth_message_access">Paired devices can view messages from</string>
<!-- Bluetooth settings: The sub heading for available devices during and after scanning. [CHAR LIMIT=40] -->
<string name="bluetooth_preference_found_devices">Available devices</string>
<!-- Bluetooth settings: The message displayed if no Bluetooth devices were found. [CHAR LIMIT=40] -->
diff --git a/res/xml/bluetooth_message_access.xml b/res/xml/bluetooth_message_access.xml
deleted file mode 100644
index d1da132..0000000
--- a/res/xml/bluetooth_message_access.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/bluetooth_show_message_access">
-
- <PreferenceCategory
- android:key="accounts"
- android:title="@string/bluetooth_message_access" />
-
- <Preference
- android:key="notice"
- android:title=""
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/colorForegroundInverse"
- android:selectable="false"
- android:summary="@string/bluetooth_message_access_notice" />
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index a0e81b2..1f280a9 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -107,7 +107,7 @@
android:title="@string/manage_trust_agents"
android:summary="@string/manage_trust_agents_summary"
android:persistent="false"
- android:fragment="com.android.settings.AdvancedSecuritySettings"/>
+ android:fragment="com.android.settings.TrustAgentSettings"/>
<PreferenceScreen
android:key="screen_pinning_settings"
diff --git a/res/xml/trust_agent_settings.xml b/res/xml/trust_agent_settings.xml
new file mode 100644
index 0000000..e9374f3
--- /dev/null
+++ b/res/xml/trust_agent_settings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="trust_agents"
+ android:title="@string/manage_trust_agents" />
diff --git a/src/com/android/settings/AdvancedSecuritySettings.java b/src/com/android/settings/AdvancedSecuritySettings.java
deleted file mode 100644
index 3ddbf96..0000000
--- a/src/com/android/settings/AdvancedSecuritySettings.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings;
-
-import com.android.internal.widget.LockPatternUtils;
-
-import android.app.ListFragment;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.os.Bundle;
-import android.service.trust.TrustAgentService;
-import android.util.ArrayMap;
-import android.util.ArraySet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.CheckBox;
-import android.widget.TextView;
-
-import java.util.List;
-
-public class AdvancedSecuritySettings extends ListFragment implements View.OnClickListener {
- static final String TAG = "AdvancedSecuritySettings";
-
- private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE;
-
- private final ArraySet<ComponentName> mActiveAgents = new ArraySet<ComponentName>();
- private final ArrayMap<ComponentName, AgentInfo> mAvailableAgents
- = new ArrayMap<ComponentName, AgentInfo>();
-
- private LockPatternUtils mLockPatternUtils;
-
- public static final class AgentInfo {
- CharSequence label;
- ComponentName component; // service that implements ITrustAgent
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof AgentInfo) {
- return component.equals(((AgentInfo)other).component);
- }
- return true;
- }
-
- public int compareTo(AgentInfo other) {
- return component.compareTo(other.component);
- }
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- if (mLockPatternUtils == null) {
- mLockPatternUtils = new LockPatternUtils(
- container.getContext().getApplicationContext());
- }
- setListAdapter(new AgentListAdapter());
- return inflater.inflate(R.layout.advanced_security_settings, container, false);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- updateList();
- }
-
- void updateList() {
- Context context = getActivity();
- if (context == null) {
- return;
- }
-
- loadActiveAgents();
-
- PackageManager pm = getActivity().getPackageManager();
- Intent trustAgentIntent = new Intent(SERVICE_INTERFACE);
- List<ResolveInfo> resolveInfos = pm.queryIntentServices(trustAgentIntent,
- PackageManager.GET_META_DATA);
-
- mAvailableAgents.clear();
- mAvailableAgents.ensureCapacity(resolveInfos.size());
-
- for (ResolveInfo resolveInfo : resolveInfos) {
- if (resolveInfo.serviceInfo == null) continue;
- if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue;
- ComponentName name = TrustAgentUtils.getComponentName(resolveInfo);
- if (!mAvailableAgents.containsKey(name)) {
- AgentInfo agentInfo = new AgentInfo();
- agentInfo.label = resolveInfo.loadLabel(pm);
- agentInfo.component = name;
- mAvailableAgents.put(name, agentInfo);
- }
- }
- ((BaseAdapter) getListAdapter()).notifyDataSetChanged();
- }
-
- @Override
- public void onClick(View view) {
- ViewHolder h = (ViewHolder) view.getTag();
-
- if (view.getId() == R.id.clickable) {
- boolean wasActive = mActiveAgents.contains(h.agentInfo.component);
- loadActiveAgents();
- if (!wasActive) {
- mActiveAgents.add(h.agentInfo.component);
- } else {
- mActiveAgents.remove(h.agentInfo.component);
- }
- saveActiveAgents();
- ((BaseAdapter) getListAdapter()).notifyDataSetChanged();
- }
- }
-
- private void loadActiveAgents() {
- mActiveAgents.clear();
- List<ComponentName> activeTrustAgents = mLockPatternUtils.getEnabledTrustAgents();
- if (activeTrustAgents != null) {
- mActiveAgents.addAll(activeTrustAgents);
- }
- }
-
- private void saveActiveAgents() {
- mLockPatternUtils.setEnabledTrustAgents(mActiveAgents);
- }
-
- static class ViewHolder {
- TextView name;
- CheckBox checkbox;
- TextView description;
- AgentInfo agentInfo;
- View clickable;
- }
-
- class AgentListAdapter extends BaseAdapter {
- final LayoutInflater mInflater;
-
- AgentListAdapter() {
- mInflater = (LayoutInflater)
- getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
-
- public boolean hasStableIds() {
- return false;
- }
-
- public int getCount() {
- return mAvailableAgents.size();
- }
-
- public Object getItem(int position) {
- return mAvailableAgents.valueAt(position);
- }
-
- public long getItemId(int position) {
- return position;
- }
-
- public boolean areAllItemsEnabled() {
- return false;
- }
-
- public boolean isEnabled(int position) {
- return true;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- View v;
- if (convertView == null) {
- v = newView(parent);
- } else {
- v = convertView;
- }
- bindView(v, position);
- return v;
- }
-
- public View newView(ViewGroup parent) {
- View v = mInflater.inflate(R.layout.trust_agent_item, parent, false);
- ViewHolder h = new ViewHolder();
- h.name = (TextView)v.findViewById(R.id.name);
- h.checkbox = (CheckBox)v.findViewById(R.id.checkbox);
- h.clickable = v.findViewById(R.id.clickable);
- h.clickable.setOnClickListener(AdvancedSecuritySettings.this);
- h.description = (TextView)v.findViewById(R.id.description);
- v.setTag(h);
- h.clickable.setTag(h);
- return v;
- }
-
- public void bindView(View view, int position) {
- ViewHolder vh = (ViewHolder) view.getTag();
- AgentInfo item = mAvailableAgents.valueAt(position);
- vh.name.setText(item.label);
- vh.checkbox.setChecked(mActiveAgents.contains(item.component));
- vh.agentInfo = item;
- }
- }
-}
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 129b201..c2295e6 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -170,6 +170,11 @@
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
// Factory reset the device.
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
+ } else if (failedAttempts == -1) {
+ // Right password, but decryption failed. Tell user bad news ...
+ setContentView(R.layout.crypt_keeper_progress);
+ showFactoryReset(true);
+ return;
} else {
// Wrong entry. Handle pattern case.
if (mLockPatternView != null) {
@@ -392,7 +397,7 @@
private void setupUi() {
if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
setContentView(R.layout.crypt_keeper_progress);
- showFactoryReset();
+ showFactoryReset(false);
return;
}
@@ -508,7 +513,13 @@
updateProgress();
}
- private void showFactoryReset() {
+ /**
+ * Show factory reset screen allowing the user to reset their phone when
+ * there is nothing else we can do
+ * @param corrupt true if userdata is corrupt, false if encryption failed
+ * partway through
+ */
+ private void showFactoryReset(boolean corrupt) {
// Hide the encryption-bot to make room for the "factory reset" button
findViewById(R.id.encroid).setVisibility(View.GONE);
@@ -524,8 +535,13 @@
});
// Alert the user of the failure.
- ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_failed_title);
- ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_failed_summary);
+ if (corrupt) {
+ ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_data_corrupt_title);
+ ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_data_corrupt_summary);
+ } else {
+ ((TextView) findViewById(R.id.title)).setText(R.string.crypt_keeper_failed_title);
+ ((TextView) findViewById(R.id.status)).setText(R.string.crypt_keeper_failed_summary);
+ }
final View view = findViewById(R.id.bottom_divider);
// TODO(viki): Why would the bottom divider be missing in certain layouts? Investigate.
@@ -538,7 +554,7 @@
final String state = SystemProperties.get("vold.encrypt_progress");
if ("error_partially_encrypted".equals(state)) {
- showFactoryReset();
+ showFactoryReset(false);
return;
}
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 7f51599..1b9f44c 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -296,14 +296,10 @@
root.findPreference(KEY_SIM_LOCK).setEnabled(false);
}
}
- try {
- if (Settings.System.getInt(getContentResolver(), Settings.System.LOCK_TO_APP_ENABLED)
- != 0) {
- root.findPreference(KEY_SCREEN_PINNING).setSummary(
- getResources().getString(R.string.switch_on_text));
- }
- } catch (SettingNotFoundException e) {
- Log.w(TAG, "No Lock-to-app enabled setting", e);
+ if (Settings.System.getInt(getContentResolver(),
+ Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) {
+ root.findPreference(KEY_SCREEN_PINNING).setSummary(
+ getResources().getString(R.string.switch_on_text));
}
// Show password
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 123d4fe..3a69125 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -38,6 +38,7 @@
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
+ public static class VoiceInputSettingsActivity extends SettingsActivity { /* empty */ }
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
public static class UserDictionarySettingsActivity extends SettingsActivity { /* empty */ }
@@ -63,6 +64,7 @@
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
public static class SecuritySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class UsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
public static class RunningServicesActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index bf0d9a1..e0ab5bc 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -72,7 +72,6 @@
import com.android.settings.applications.ManageApplications;
import com.android.settings.applications.ProcessStatsUi;
import com.android.settings.bluetooth.BluetoothSettings;
-import com.android.settings.bluetooth.MessageAccessSettings;
import com.android.settings.dashboard.DashboardCategory;
import com.android.settings.dashboard.DashboardSummary;
import com.android.settings.dashboard.DashboardTile;
@@ -105,6 +104,7 @@
import com.android.settings.sim.SimSettings;
import com.android.settings.tts.TextToSpeechSettings;
import com.android.settings.users.UserSettings;
+import com.android.settings.voice.VoiceInputSettings;
import com.android.settings.vpn2.VpnSettings;
import com.android.settings.wfd.WifiDisplaySettings;
import com.android.settings.widget.SwitchBar;
@@ -237,7 +237,6 @@
AdvancedWifiSettings.class.getName(),
SavedAccessPointsWifiSettings.class.getName(),
BluetoothSettings.class.getName(),
- MessageAccessSettings.class.getName(),
SimSettings.class.getName(),
TetherSettings.class.getName(),
WifiP2pSettings.class.getName(),
@@ -245,6 +244,7 @@
DateTimeSettings.class.getName(),
LocalePicker.class.getName(),
InputMethodAndLanguageSettings.class.getName(),
+ VoiceInputSettings.class.getName(),
SpellCheckersSettings.class.getName(),
UserDictionaryList.class.getName(),
UserDictionarySettings.class.getName(),
@@ -256,6 +256,7 @@
NotificationStation.class.getName(),
LocationSettings.class.getName(),
SecuritySettings.class.getName(),
+ UsageAccessSettings.class.getName(),
PrivacySettings.class.getName(),
DeviceAdminSettings.class.getName(),
AccessibilitySettings.class.getName(),
diff --git a/src/com/android/settings/TrustAgentSettings.java b/src/com/android/settings/TrustAgentSettings.java
new file mode 100644
index 0000000..54fef36
--- /dev/null
+++ b/src/com/android/settings/TrustAgentSettings.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import java.util.List;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceGroup;
+import android.preference.SwitchPreference;
+import android.service.trust.TrustAgentService;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+
+import com.android.internal.widget.LockPatternUtils;
+
+public class TrustAgentSettings extends SettingsPreferenceFragment implements
+ Preference.OnPreferenceChangeListener {
+ private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE;
+ private ArrayMap<ComponentName, AgentInfo> mAvailableAgents;
+ private final ArraySet<ComponentName> mActiveAgents = new ArraySet<ComponentName>();
+ private LockPatternUtils mLockPatternUtils;
+
+ public static final class AgentInfo {
+ CharSequence label;
+ ComponentName component; // service that implements ITrustAgent
+ SwitchPreference preference;
+ public Drawable icon;
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof AgentInfo) {
+ return component.equals(((AgentInfo)other).component);
+ }
+ return true;
+ }
+
+ public int compareTo(AgentInfo other) {
+ return component.compareTo(other.component);
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ addPreferencesFromResource(R.xml.trust_agent_settings);
+ }
+
+ public void onResume() {
+ super.onResume();
+ updateAgents();
+ };
+
+ private void updateAgents() {
+ final Context context = getActivity();
+ if (mAvailableAgents == null) {
+ mAvailableAgents = findAvailableTrustAgents();
+ }
+ if (mLockPatternUtils == null) {
+ mLockPatternUtils = new LockPatternUtils(getActivity());
+ }
+ loadActiveAgents();
+ PreferenceGroup category =
+ (PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
+ category.removeAll();
+ final int count = mAvailableAgents.size();
+ for (int i = 0; i < count; i++) {
+ AgentInfo agent = mAvailableAgents.valueAt(i);
+ final SwitchPreference preference = new SwitchPreference(context);
+ agent.preference = preference;
+ preference.setPersistent(false);
+ preference.setTitle(agent.label);
+ preference.setIcon(agent.icon);
+ preference.setPersistent(false);
+ preference.setOnPreferenceChangeListener(this);
+ preference.setChecked(mActiveAgents.contains(agent.component));
+ category.addPreference(agent.preference);
+ }
+ }
+
+ private void loadActiveAgents() {
+ List<ComponentName> activeTrustAgents = mLockPatternUtils.getEnabledTrustAgents();
+ if (activeTrustAgents != null) {
+ mActiveAgents.addAll(activeTrustAgents);
+ }
+ }
+
+ private void saveActiveAgents() {
+ mLockPatternUtils.setEnabledTrustAgents(mActiveAgents);
+ }
+
+ ArrayMap<ComponentName, AgentInfo> findAvailableTrustAgents() {
+ PackageManager pm = getActivity().getPackageManager();
+ Intent trustAgentIntent = new Intent(SERVICE_INTERFACE);
+ List<ResolveInfo> resolveInfos = pm.queryIntentServices(trustAgentIntent,
+ PackageManager.GET_META_DATA);
+
+ ArrayMap<ComponentName, AgentInfo> agents = new ArrayMap<ComponentName, AgentInfo>();
+ final int count = resolveInfos.size();
+ agents.ensureCapacity(count);
+ for (int i = 0; i < count; i++ ) {
+ ResolveInfo resolveInfo = resolveInfos.get(i);
+ if (resolveInfo.serviceInfo == null) continue;
+ if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue;
+ ComponentName name = TrustAgentUtils.getComponentName(resolveInfo);
+ AgentInfo agentInfo = new AgentInfo();
+ agentInfo.label = resolveInfo.loadLabel(pm);
+ agentInfo.icon = resolveInfo.loadIcon(pm);
+ agentInfo.component = name;
+ agents.put(name, agentInfo);
+ }
+ return agents;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference instanceof SwitchPreference) {
+ final int count = mAvailableAgents.size();
+ for (int i = 0; i < count; i++) {
+ AgentInfo agent = mAvailableAgents.valueAt(i);
+ if (agent.preference == preference) {
+ if ((Boolean) newValue) {
+ if (!mActiveAgents.contains(agent.component)) {
+ mActiveAgents.add(agent.component);
+ }
+ } else {
+ mActiveAgents.remove(agent.component);
+ }
+ saveActiveAgents();
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index bbd86a1..3c62ba9 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -69,7 +69,6 @@
private static final int MENU_ID_SCAN = Menu.FIRST;
private static final int MENU_ID_RENAME_DEVICE = Menu.FIRST + 1;
private static final int MENU_ID_SHOW_RECEIVED = Menu.FIRST + 2;
- private static final int MENU_ID_MESSAGE_ACCESS = Menu.FIRST + 3;
/* Private intent to show the list of received files */
private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
@@ -205,12 +204,6 @@
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(Menu.NONE, MENU_ID_SHOW_RECEIVED, 0, R.string.bluetooth_show_received_files)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- // Message Access API is still not finished, once completed we undo this check.
- // Bug 16232864
- if (android.os.SystemProperties.get("show_bluetooth_message_access").equals("true")){
- menu.add(Menu.NONE, MENU_ID_MESSAGE_ACCESS, 0, R.string.bluetooth_show_message_access)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- }
super.onCreateOptionsMenu(menu, inflater);
}
@@ -232,14 +225,6 @@
Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
getActivity().sendBroadcast(intent);
return true;
-
- case MENU_ID_MESSAGE_ACCESS:
- if (getActivity() instanceof SettingsActivity) {
- ((SettingsActivity) getActivity()).startPreferencePanel(
- MessageAccessSettings.class.getCanonicalName(), null,
- R.string.bluetooth_show_message_access, null, this, 0);
- }
- return true;
}
return super.onOptionsItemSelected(item);
}
@@ -377,7 +362,6 @@
}
}
- @Override
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
setDeviceListGroup(getPreferenceScreen());
removeAllDevices();
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index a7104df..3b64ade 100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -539,7 +539,7 @@
if (bondState == BluetoothDevice.BOND_NONE) {
mProfiles.clear();
mConnectAfterPairing = false; // cancel auto-connect
- setPhonebookPermissionChoice(ACCESS_ALLOWED);
+ setPhonebookPermissionChoice(ACCESS_UNKNOWN);
setMessagePermissionChoice(ACCESS_UNKNOWN);
mPhonebookRejectedTimes = 0;
savePhonebookRejectTimes();
diff --git a/src/com/android/settings/bluetooth/MessageAccessSettings.java b/src/com/android/settings/bluetooth/MessageAccessSettings.java
deleted file mode 100644
index 913357c..0000000
--- a/src/com/android/settings/bluetooth/MessageAccessSettings.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.bluetooth;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.app.ActivityManagerNative;
-import android.content.Context;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.preference.SwitchPreference;
-import android.preference.Preference;
-import android.preference.PreferenceGroup;
-import android.preference.PreferenceScreen;
-import android.provider.SearchIndexableResource;
-import android.util.Log;
-
-import com.android.settings.accounts.AuthenticatorHelper;
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class MessageAccessSettings extends SettingsPreferenceFragment
- implements AuthenticatorHelper.OnAccountsUpdateListener, Indexable {
- private static final String TAG = "MessageAccessSettings";
- private static final String GMAIL_PACKAGE_NAME = "com.google.android.gm";
- private static final String EMAIL_PACKAGE_NAME = "com.google.android.email";
-
- private Account[] mAccounts;
- private UserHandle mUserHandle;
- private PreferenceGroup mAvailableAccounts;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // TODO: Define behavior for managed profile. See: http://b/16287773
- mUserHandle = new UserHandle(UserHandle.myUserId());
-
- addPreferencesFromResource(R.xml.bluetooth_message_access);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- initPreferences();
- }
-
- @Override
- public void onAccountsUpdate(final UserHandle userHandle) {
- mAccounts = AccountManager.get(getActivity()).getAccountsAsUser(
- mUserHandle.getIdentifier());
-
- final int mAccountsSize = mAccounts.length;
- for (int i = 0; i < mAccountsSize; ++i){
- Log.d(TAG, String.format("account.type = %s\n", mAccounts[i].type));
- }
- }
-
- /**
- * Retrieves the email icon for a given account's email preference
- *
- * @param accountPref The user's account to retrieve the icon from.
- *
- * @return The drawable representing the icon of the user's email preference
- **/
- private Drawable getIcon(AccountPreference accountPref){
- Drawable icon = null;
-
- // Currently only two types of icons are allowed.
- final String packageName = accountPref.account.type.equals("com.google")
- ? GMAIL_PACKAGE_NAME : EMAIL_PACKAGE_NAME;
-
- try{
- icon = getPackageManager().getApplicationIcon(packageName);
- }catch(NameNotFoundException nnfe){
- icon = null;
- }
-
- return icon;
- }
-
- private void initPreferences() {
- final PreferenceScreen preferenceScreen = getPreferenceScreen();
- mAvailableAccounts = (PreferenceGroup)preferenceScreen.findPreference("accounts");
- mAccounts = AccountManager.get(getActivity()).getAccountsAsUser(
- mUserHandle.getIdentifier());
-
- final int mAccountsSize = mAccounts.length;
- for (int i = 0; i < mAccountsSize; ++i){
- AccountPreference accountPref = new AccountPreference(getActivity(), mAccounts[i]);
- Drawable icon = getIcon(accountPref);
- if (icon != null){
- accountPref.setIcon(icon);
- }
- mAvailableAccounts.addPreference(accountPref);
- }
- }
-
- private class AccountPreference extends SwitchPreference
- implements Preference.OnPreferenceChangeListener{
- private Account account;
-
- AccountPreference(Context context, Account account){
- super(context);
- this.account = account;
- setTitle(account.type);
- setSummary(account.name);
-
- setOnPreferenceChangeListener(this);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object val) {
- if (preference instanceof AccountPreference){
- final AccountPreference accountPref = (AccountPreference) preference;
-
- if (((Boolean)val).booleanValue()){
- // Enable paired deviced to connect, fill in once API is available
- Log.w(TAG, String.format(
- "User has turned on '%s' for Bluetooth message access.",
- accountPref.account.name));
- } else {
- // Disable paired deviced to connect, fill in once API is available
- Log.w(TAG, String.format(
- "User has turned off '%s' for Bluetooth message access.",
- accountPref.account.name));
- }
- }
- return true;
- }
- }
-
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- List<SearchIndexableResource> indexables = new ArrayList<SearchIndexableResource>();
- SearchIndexableResource indexable = new SearchIndexableResource(context);
- indexable.xmlResId = R.xml.bluetooth_message_access;
- indexables.add(indexable);
- return indexables;
- }
- };
-}
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index b8ae493..3528c56 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -673,8 +673,8 @@
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
List<SearchIndexableRaw> indexables = new ArrayList<>();
- Resources resources = context.getResources();
- String screenTitle = context.getString(R.string.language_keyboard_settings_title);
+ final Resources resources = context.getResources();
+ final String screenTitle = context.getString(R.string.language_keyboard_settings_title);
// Locale picker.
if (context.getAssets().getLocales().length > 1) {
@@ -807,73 +807,14 @@
R.string.builtin_keyboard_settings_title);
indexable.screenTitle = screenTitle;
indexables.add(indexable);
-
- // Auto replace.
- indexable = new SearchIndexableRaw(context);
- indexable.key = "auto_replace";
- indexable.title = context.getString(R.string.auto_replace);
- indexable.summaryOn = context.getString(R.string.auto_replace_summary);
- indexable.summaryOff = context.getString(R.string.auto_replace_summary);
- indexable.screenTitle = screenTitle;
- indexables.add(indexable);
-
- // Auto caps.
- indexable = new SearchIndexableRaw(context);
- indexable.key = "auto_caps";
- indexable.title = context.getString(R.string.auto_caps);
- indexable.summaryOn = context.getString(R.string.auto_caps_summary);
- indexable.summaryOff = context.getString(R.string.auto_caps_summary);
- indexable.screenTitle = screenTitle;
- indexables.add(indexable);
-
- // Auto punctuate.
- indexable = new SearchIndexableRaw(context);
- indexable.key = "auto_punctuate";
- indexable.title = context.getString(R.string.auto_punctuate);
- indexable.summaryOn = context.getString(R.string.auto_punctuate_summary);
- indexable.summaryOff = context.getString(R.string.auto_punctuate_summary);
- indexable.screenTitle = screenTitle;
- indexables.add(indexable);
}
- // Voice recognizers.
- List<ResolveInfo> recognizers = context.getPackageManager()
- .queryIntentServices(new Intent(RecognitionService.SERVICE_INTERFACE),
- PackageManager.GET_META_DATA);
-
- final int recognizerCount = recognizers.size();
-
- // Recognizer settings.
- if (recognizerCount > 0) {
- indexable = new SearchIndexableRaw(context);
- indexable.key = "recognizer_settings";
- indexable.title = context.getString(R.string.recognizer_settings_title);
- indexable.screenTitle = screenTitle;
- indexables.add(indexable);
- }
-
- if (recognizerCount > 1) {
- // Recognizer chooser.
- indexable = new SearchIndexableRaw(context);
- indexable.key = "recognizer_title";
- indexable.title = context.getString(R.string.recognizer_title);
- indexable.screenTitle = screenTitle;
- indexables.add(indexable);
- }
-
- for (int i = 0; i < recognizerCount; i++) {
- ResolveInfo recognizer = recognizers.get(i);
-
- ServiceInfo serviceInfo = recognizer.serviceInfo;
- ComponentName componentName = new ComponentName(serviceInfo.packageName,
- serviceInfo.name);
-
- indexable = new SearchIndexableRaw(context);
- indexable.key = componentName.flattenToString();
- indexable.title = recognizer.loadLabel(context.getPackageManager()).toString();
- indexable.screenTitle = screenTitle;
- indexables.add(indexable);
- }
+ // Voice input
+ indexable = new SearchIndexableRaw(context);
+ indexable.key = "voice_input_settings";
+ indexable.title = context.getString(R.string.voice_input_settings);
+ indexable.screenTitle = screenTitle;
+ indexables.add(indexable);
// Text-to-speech.
TtsEngines ttsEngines = new TtsEngines(context);
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index 44717c1..2c76002 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -30,7 +30,6 @@
import com.android.settings.WirelessSettings;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.bluetooth.BluetoothSettings;
-import com.android.settings.bluetooth.MessageAccessSettings;
import com.android.settings.deviceinfo.Memory;
import com.android.settings.fuelgauge.BatterySaverSettings;
import com.android.settings.fuelgauge.PowerUsageSummary;
@@ -43,6 +42,7 @@
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.sim.SimSettings;
import com.android.settings.users.UserSettings;
+import com.android.settings.voice.VoiceInputSettings;
import com.android.settings.wifi.AdvancedWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;
@@ -93,7 +93,6 @@
// BT
sRankMap.put(BluetoothSettings.class.getName(), RANK_BT);
- sRankMap.put(MessageAccessSettings.class.getName(), RANK_BT);
// SIM Cards
sRankMap.put(SimSettings.class.getName(), RANK_SIM);
@@ -139,6 +138,7 @@
// IMEs
sRankMap.put(InputMethodAndLanguageSettings.class.getName(), RANK_IME);
+ sRankMap.put(VoiceInputSettings.class.getName(), RANK_IME);
// Privacy
sRankMap.put(PrivacySettings.class.getName(), RANK_PRIVACY);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index e0e09a8..5108da3 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -33,7 +33,6 @@
import com.android.settings.WirelessSettings;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.bluetooth.BluetoothSettings;
-import com.android.settings.bluetooth.MessageAccessSettings;
import com.android.settings.deviceinfo.Memory;
import com.android.settings.fuelgauge.BatterySaverSettings;
import com.android.settings.fuelgauge.PowerUsageSummary;
@@ -46,6 +45,7 @@
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.sim.SimSettings;
import com.android.settings.users.UserSettings;
+import com.android.settings.voice.VoiceInputSettings;
import com.android.settings.wifi.AdvancedWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;
@@ -96,13 +96,6 @@
SimSettings.class.getName(),
R.drawable.ic_sim_sd));
- sResMap.put(MessageAccessSettings.class.getName(),
- new SearchIndexableResource(
- Ranking.getRankForClassName(MessageAccessSettings.class.getName()),
- NO_DATA_RES_ID,
- MessageAccessSettings.class.getName(),
- R.drawable.ic_settings_bluetooth2));
-
sResMap.put(DataUsageSummary.class.getName(),
new SearchIndexableResource(
Ranking.getRankForClassName(DataUsageSummary.class.getName()),
@@ -230,6 +223,13 @@
InputMethodAndLanguageSettings.class.getName(),
R.drawable.ic_settings_language));
+ sResMap.put(VoiceInputSettings.class.getName(),
+ new SearchIndexableResource(
+ Ranking.getRankForClassName(VoiceInputSettings.class.getName()),
+ NO_DATA_RES_ID,
+ VoiceInputSettings.class.getName(),
+ R.drawable.ic_settings_language));
+
sResMap.put(PrivacySettings.class.getName(),
new SearchIndexableResource(
Ranking.getRankForClassName(PrivacySettings.class.getName()),
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 93f9b0f..9ad34a9 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -790,6 +790,8 @@
} else {
setPhotoId(pref, user);
}
+ } else {
+ pref.setIcon(getEncircledDefaultAvatar());
}
}
@@ -833,7 +835,7 @@
if (missingIcons.size() > 0) {
loadIconsAsync(missingIcons);
}
- boolean moreUsers = mUserManager.getMaxSupportedUsers() > users.size();
+ boolean moreUsers = mUserManager.canAddMoreUsers();
mAddUser.setEnabled(moreUsers);
}
@@ -849,6 +851,9 @@
protected Void doInBackground(List<Integer>... values) {
for (int userId : values[0]) {
Bitmap bitmap = mUserManager.getUserIcon(userId);
+ if (bitmap == null) {
+ bitmap = createBitmapFromDrawable(R.drawable.ic_avatar_default_1);
+ }
mUserIcons.append(userId, bitmap);
}
return null;
diff --git a/src/com/android/settings/voice/VoiceInputSettings.java b/src/com/android/settings/voice/VoiceInputSettings.java
index 309c6e9..aa85024 100644
--- a/src/com/android/settings/voice/VoiceInputSettings.java
+++ b/src/com/android/settings/voice/VoiceInputSettings.java
@@ -16,18 +16,33 @@
package com.android.settings.voice;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
import android.preference.Preference;
import android.provider.Settings;
+import android.service.voice.VoiceInteractionService;
+import android.service.voice.VoiceInteractionServiceInfo;
+import android.speech.RecognitionService;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.voice.VoiceInputPreference.RadioButtonGroupState;
import android.os.Bundle;
import android.preference.PreferenceCategory;
import android.widget.Checkable;
+import java.util.ArrayList;
+import java.util.List;
+
public class VoiceInputSettings extends SettingsPreferenceFragment implements
- Preference.OnPreferenceClickListener, RadioButtonGroupState {
+ Preference.OnPreferenceClickListener, RadioButtonGroupState, Indexable {
private static final String TAG = "VoiceInputSettings";
private static final boolean DBG = false;
@@ -160,4 +175,68 @@
}
return true;
}
+
+ // For Search
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ @Override
+ public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+ boolean enabled) {
+
+ List<SearchIndexableRaw> indexables = new ArrayList<>();
+
+ final String screenTitle = context.getString(R.string.voice_input_settings_title);
+
+ SearchIndexableRaw indexable = new SearchIndexableRaw(context);
+ indexable.key = "voice_service_preference_section_title";
+ indexable.title = context.getString(R.string.voice_service_preference_section_title);
+ indexable.screenTitle = screenTitle;
+ indexables.add(indexable);
+
+ final List<ResolveInfo> voiceInteractions =
+ context.getPackageManager().queryIntentServices(
+ new Intent(VoiceInteractionService.SERVICE_INTERFACE),
+ PackageManager.GET_META_DATA);
+
+ final int countInteractions = voiceInteractions.size();
+ for (int i = 0; i < countInteractions; i++) {
+ ResolveInfo info = voiceInteractions.get(i);
+ VoiceInteractionServiceInfo visInfo = new VoiceInteractionServiceInfo(
+ context.getPackageManager(), info.serviceInfo);
+ if (visInfo.getParseError() != null) {
+ continue;
+ }
+ indexables.add(getSearchIndexableRaw(context, info, screenTitle));
+ }
+
+ final List<ResolveInfo> recognitions =
+ context.getPackageManager().queryIntentServices(
+ new Intent(RecognitionService.SERVICE_INTERFACE),
+ PackageManager.GET_META_DATA);
+
+ final int countRecognitions = recognitions.size();
+ for (int i = 0; i < countRecognitions; i++) {
+ ResolveInfo info = recognitions.get(i);
+ indexables.add(getSearchIndexableRaw(context, info, screenTitle));
+ }
+
+ return indexables;
+ }
+
+ private SearchIndexableRaw getSearchIndexableRaw(Context context,
+ ResolveInfo info, String screenTitle) {
+
+ ServiceInfo serviceInfo = info.serviceInfo;
+ ComponentName componentName = new ComponentName(serviceInfo.packageName,
+ serviceInfo.name);
+
+ SearchIndexableRaw indexable = new SearchIndexableRaw(context);
+ indexable.key = componentName.flattenToString();
+ indexable.title = info.loadLabel(context.getPackageManager()).toString();
+ indexable.screenTitle = screenTitle;
+
+ return indexable;
+ }
+ };
}