Merge "Fixed a bug were secure Wi-Fi connections would show unsecured." into lmp-dev
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 bfa43a1..b71c344 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] -->
@@ -4761,6 +4755,11 @@
<!-- UI debug setting: force use of NuPlayer summary [CHAR LIMIT=50] -->
<string name="use_nuplayer_summary">Use NuPlayer instead of AwesomePlayer</string>
+ <!-- UI debug setting: disable USB audio routing title [CHAR LIMIT=25] -->
+ <string name="usb_audio_disable_routing">Disable USB audio routing</string>
+ <!-- UI debug setting: disable USB audio routing summary [CHAR LIMIT=50] -->
+ <string name="usb_audio_disable_routing_summary">Disable automatic routing to USB audio peripherals</string>
+
<!-- UI debug setting: show layout bounds information [CHAR LIMIT=25] -->
<string name="debug_layout">Show layout bounds</string>
<!-- UI debug setting: show layout bounds information summary [CHAR LIMIT=50] -->
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/development_prefs.xml b/res/xml/development_prefs.xml
index 854aa97..2a1a5bb 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -251,6 +251,11 @@
android:title="@string/use_nuplayer"
android:summary="@string/use_nuplayer_summary"/>
+ <CheckBoxPreference
+ android:key="usb_audio"
+ android:title="@string/usb_audio_disable_routing"
+ android:summary="@string/usb_audio_disable_routing_summary" />
+
</PreferenceCategory>
<PreferenceCategory android:key="debug_monitoring_category"
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/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index ba8e2f1..7b12e6f 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -117,6 +117,7 @@
private static final String DISABLE_OVERLAYS_KEY = "disable_overlays";
private static final String SIMULATE_COLOR_SPACE = "simulate_color_space";
private static final String USE_NUPLAYER_KEY = "use_nuplayer";
+ private static final String USB_AUDIO_KEY = "usb_audio";
private static final String USE_AWESOMEPLAYER_PROPERTY = "persist.sys.media.use-awesome";
private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
@@ -222,6 +223,7 @@
private ListPreference mSimulateColorSpace;
private CheckBoxPreference mUseNuplayer;
+ private CheckBoxPreference mUSBAudio;
private CheckBoxPreference mImmediatelyDestroyActivities;
private ListPreference mAppProcessLimit;
@@ -343,6 +345,7 @@
mOpenGLTraces = addListPreference(OPENGL_TRACES_KEY);
mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
mUseNuplayer = findAndInitCheckboxPref(USE_NUPLAYER_KEY);
+ mUSBAudio = findAndInitCheckboxPref(USB_AUDIO_KEY);
mImmediatelyDestroyActivities = (CheckBoxPreference) findPreference(
IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
@@ -549,6 +552,7 @@
updateWifiAllowScansWithTrafficOptions();
updateSimulateColorSpace();
updateUseNuplayerOptions();
+ updateUSBAudioOptions();
}
private void resetDangerousOptions() {
@@ -1013,6 +1017,17 @@
pokeSystemProperties();
}
+ private void updateUSBAudioOptions() {
+ updateCheckBox(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
+ }
+
+ private void writeUSBAudioOptions() {
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED,
+ mUSBAudio.isChecked() ? 1 : 0);
+ }
+
private void updateForceRtlOptions() {
updateCheckBox(mForceRtlLayout, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL, 0) != 0);
@@ -1417,6 +1432,8 @@
writeWifiAllowScansWithTrafficOptions();
} else if (preference == mUseNuplayer) {
writeUseNuplayerOptions();
+ } else if (preference == mUSBAudio) {
+ writeUSBAudioOptions();
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index 0bd548f..ed95500 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -32,7 +32,10 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.os.Bundle;
@@ -103,6 +106,7 @@
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mAppOps = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE);
+ PackageManager packageManager = getPackageManager();
if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
Log.w(TAG, "Cannot start ADD_DEVICE_ADMIN as a new task");
@@ -120,6 +124,8 @@
}
if (action != null && action.equals(DevicePolicyManager.ACTION_SET_PROFILE_OWNER)) {
+ setResult(RESULT_CANCELED);
+ setFinishOnTouchOutside(true);
mAddingProfileOwner = true;
mProfileOwnerName =
getIntent().getStringExtra(DevicePolicyManager.EXTRA_PROFILE_OWNER_NAME);
@@ -129,11 +135,23 @@
finish();
return;
}
+ try {
+ PackageInfo packageInfo = packageManager.getPackageInfo(callingPackage, 0);
+ if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
+ Log.e(TAG, "Cannot set a non-system app as a profile owner");
+ finish();
+ return;
+ }
+ } catch (NameNotFoundException nnfe) {
+ Log.e(TAG, "Cannot find the package " + callingPackage);
+ finish();
+ return;
+ }
}
ActivityInfo ai;
try {
- ai = getPackageManager().getReceiverInfo(who, PackageManager.GET_META_DATA);
+ ai = packageManager.getReceiverInfo(who, PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Unable to retrieve device policy " + who, e);
finish();
@@ -144,7 +162,7 @@
// No need to check this when deactivating, because it is safe to deactivate an active
// invalid device admin.
if (!mDPM.isAdminActive(who)) {
- List<ResolveInfo> avail = getPackageManager().queryBroadcastReceivers(
+ List<ResolveInfo> avail = packageManager.queryBroadcastReceivers(
new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED),
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
int count = avail == null ? 0 : avail.size();
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/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index a8e28df..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;
@@ -238,7 +237,6 @@
AdvancedWifiSettings.class.getName(),
SavedAccessPointsWifiSettings.class.getName(),
BluetoothSettings.class.getName(),
- MessageAccessSettings.class.getName(),
SimSettings.class.getName(),
TetherSettings.class.getName(),
WifiP2pSettings.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/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index 92eaade..4ff4dfd 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -16,15 +16,20 @@
package com.android.settings.fuelgauge;
+import android.app.AppGlobals;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
import android.os.BatteryStats;
import android.os.Handler;
+import android.os.RemoteException;
+import android.os.UserHandle;
import android.os.UserManager;
+import android.util.Log;
import com.android.internal.os.BatterySipper;
import com.android.settings.R;
@@ -256,9 +261,17 @@
System.arraycopy(sipper.mPackages, 0, packageLabels, 0, sipper.mPackages.length);
// Convert package names to user-facing labels where possible
+ IPackageManager ipm = AppGlobals.getPackageManager();
+ final int userId = UserHandle.getUserId(uid);
for (int i = 0; i < packageLabels.length; i++) {
try {
- ApplicationInfo ai = pm.getApplicationInfo(packageLabels[i], 0);
+ final ApplicationInfo ai = ipm.getApplicationInfo(packageLabels[i],
+ 0 /* no flags */, userId);
+ if (ai == null) {
+ Log.d(PowerUsageSummary.TAG, "Retrieving null app info for package "
+ + packageLabels[i] + ", user " + userId);
+ continue;
+ }
CharSequence label = ai.loadLabel(pm);
if (label != null) {
packageLabels[i] = label.toString();
@@ -268,10 +281,14 @@
icon = ai.loadIcon(pm);
break;
}
- } catch (PackageManager.NameNotFoundException e) {
+ } catch (RemoteException e) {
+ Log.d(PowerUsageSummary.TAG, "Error while retrieving app info for package "
+ + packageLabels[i] + ", user " + userId, e);
}
}
- if (icon == null) icon = defaultActivityIcon;
+ if (icon == null) {
+ icon = defaultActivityIcon;
+ }
if (packageLabels.length == 1) {
name = packageLabels[0];
@@ -279,7 +296,12 @@
// Look for an official name for this UID.
for (String pkgName : sipper.mPackages) {
try {
- final PackageInfo pi = pm.getPackageInfo(pkgName, 0);
+ final PackageInfo pi = ipm.getPackageInfo(pkgName, 0 /* no flags */, userId);
+ if (pi == null) {
+ Log.d(PowerUsageSummary.TAG, "Retrieving null package info for package "
+ + pkgName + ", user " + userId);
+ continue;
+ }
if (pi.sharedUserLabel != 0) {
final CharSequence nm = pm.getText(pkgName,
pi.sharedUserLabel, pi.applicationInfo);
@@ -292,7 +314,9 @@
break;
}
}
- } catch (PackageManager.NameNotFoundException e) {
+ } catch (RemoteException e) {
+ Log.d(PowerUsageSummary.TAG, "Error while retrieving package info for package "
+ + pkgName + ", user " + userId, e);
}
}
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index ad8afa5..b26ba65 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -54,7 +54,7 @@
private static final boolean DEBUG = false;
- private static final String TAG = "PowerUsageSummary";
+ static final String TAG = "PowerUsageSummary";
private static final String KEY_APP_LIST = "app_list";
@@ -293,7 +293,7 @@
}
final UserHandle userHandle = new UserHandle(UserHandle.getUserId(sipper.getUid()));
final BatteryEntry entry = new BatteryEntry(getActivity(), mHandler, mUm, sipper);
- final Drawable badgedIcon = mUm.getBadgedDrawableForUser(entry.getIcon(),
+ final Drawable badgedIcon = mUm.getBadgedIconForUser(entry.getIcon(),
userHandle);
final CharSequence contentDescription = mUm.getBadgedLabelForUser(entry.getLabel(),
userHandle);
@@ -337,7 +337,7 @@
if (pgp != null) {
final int userId = UserHandle.getUserId(entry.sipper.getUid());
final UserHandle userHandle = new UserHandle(userId);
- pgp.setIcon(mUm.getBadgedDrawableForUser(entry.getIcon(), userHandle));
+ pgp.setIcon(mUm.getBadgedIconForUser(entry.getIcon(), userHandle));
pgp.setTitle(entry.name);
}
break;
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index c8b86ae..3528c56 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -807,33 +807,6 @@
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 input
diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java
index 13d282d..7c59927 100644
--- a/src/com/android/settings/location/RecentLocationApps.java
+++ b/src/com/android/settings/location/RecentLocationApps.java
@@ -203,6 +203,11 @@
IPackageManager ipm = AppGlobals.getPackageManager();
ApplicationInfo appInfo =
ipm.getApplicationInfo(packageName, PackageManager.GET_META_DATA, userId);
+ if (appInfo == null) {
+ Log.w(TAG, "Null application info retrieved for package " + packageName
+ + ", userId " + userId);
+ return null;
+ }
Resources res = mActivity.getResources();
final UserHandle userHandle = new UserHandle(userId);
@@ -214,7 +219,8 @@
appLabel, highBattery, badgedAppLabel,
new PackageEntryClickedListener(packageName));
} catch (RemoteException e) {
- Log.w(TAG, "Error while retrieving application info", e);
+ Log.w(TAG, "Error while retrieving application info for package " + packageName
+ + ", userId " + userId, e);
}
return preference;
diff --git a/src/com/android/settings/net/UidDetailProvider.java b/src/com/android/settings/net/UidDetailProvider.java
index b933025..4b54137 100644
--- a/src/com/android/settings/net/UidDetailProvider.java
+++ b/src/com/android/settings/net/UidDetailProvider.java
@@ -16,8 +16,10 @@
package com.android.settings.net;
+import android.app.AppGlobals;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -28,7 +30,9 @@
import android.net.TrafficStats;
import android.os.UserManager;
import android.os.UserHandle;
+import android.os.RemoteException;
import android.text.TextUtils;
+import android.util.Log;
import android.util.SparseArray;
import com.android.settings.R;
@@ -39,6 +43,7 @@
* {@link TrafficStats#UID_TETHERING} and {@link UserInfo}.
*/
public class UidDetailProvider {
+ private static final String TAG = "DataUsage";
private final Context mContext;
private final SparseArray<UidDetail> mUidDetailCache;
@@ -148,31 +153,43 @@
final String[] packageNames = pm.getPackagesForUid(uid);
final int length = packageNames != null ? packageNames.length : 0;
try {
- final UserHandle userHandle = new UserHandle(UserHandle.getUserId(uid));
+ final int userId = UserHandle.getUserId(uid);
+ UserHandle userHandle = new UserHandle(userId);
+ IPackageManager ipm = AppGlobals.getPackageManager();
if (length == 1) {
- final ApplicationInfo info = pm.getApplicationInfo(packageNames[0], 0);
- detail.label = info.loadLabel(pm).toString();
- detail.icon = um.getBadgedDrawableForUser(info.loadIcon(pm), userHandle);
+ final ApplicationInfo info = ipm.getApplicationInfo(packageNames[0],
+ 0 /* no flags */, userId);
+ if (info != null) {
+ detail.label = info.loadLabel(pm).toString();
+ detail.icon = um.getBadgedIconForUser(info.loadIcon(pm),
+ new UserHandle(userId));
+ }
} else if (length > 1) {
detail.detailLabels = new CharSequence[length];
detail.detailContentDescriptions = new CharSequence[length];
for (int i = 0; i < length; i++) {
final String packageName = packageNames[i];
final PackageInfo packageInfo = pm.getPackageInfo(packageName, 0);
- final ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0);
+ final ApplicationInfo appInfo = ipm.getApplicationInfo(packageName,
+ 0 /* no flags */, userId);
- detail.detailLabels[i] = appInfo.loadLabel(pm).toString();
- detail.detailContentDescriptions[i] = um.getBadgedLabelForUser(
- detail.detailLabels[i], userHandle);
- if (packageInfo.sharedUserLabel != 0) {
- detail.label = pm.getText(packageName, packageInfo.sharedUserLabel,
- packageInfo.applicationInfo).toString();
- detail.icon = um.getBadgedDrawableForUser(appInfo.loadIcon(pm), userHandle);
+ if (appInfo != null) {
+ detail.detailLabels[i] = appInfo.loadLabel(pm).toString();
+ detail.detailContentDescriptions[i] = um.getBadgedLabelForUser(
+ detail.detailLabels[i], userHandle);
+ if (packageInfo.sharedUserLabel != 0) {
+ detail.label = pm.getText(packageName, packageInfo.sharedUserLabel,
+ packageInfo.applicationInfo).toString();
+ detail.icon = um.getBadgedIconForUser(appInfo.loadIcon(pm), userHandle);
+ }
}
}
}
detail.contentDescription = um.getBadgedLabelForUser(detail.label, userHandle);
} catch (NameNotFoundException e) {
+ Log.w(TAG, "Error while building UI detail for uid "+uid, e);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error while building UI detail for uid "+uid, e);
}
if (TextUtils.isEmpty(detail.label)) {
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index 1a08aa2..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;
@@ -94,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);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 31dac7b..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;
@@ -97,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()),
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/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 5be9046..c707b447 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -16,13 +16,11 @@
package com.android.settings.vpn2;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
@@ -31,13 +29,10 @@
import android.os.Message;
import android.os.ServiceManager;
import android.os.SystemProperties;
-import android.os.UserHandle;
import android.os.UserManager;
-import android.os.Process;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
-import android.provider.Settings;
import android.security.Credentials;
import android.security.KeyStore;
import android.text.TextUtils;
@@ -49,14 +44,11 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.Spinner;
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
@@ -64,9 +56,6 @@
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.UserSpinnerAdapter;
-import com.android.settings.UserSpinnerAdapter.UserDetails;
-import com.android.settings.Utils;
import com.google.android.collect.Lists;
@@ -76,12 +65,11 @@
public class VpnSettings extends SettingsPreferenceFragment implements
Handler.Callback, Preference.OnPreferenceClickListener,
- DialogInterface.OnClickListener, DialogInterface.OnDismissListener, OnItemSelectedListener {
+ DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String TAG = "VpnSettings";
private static final String TAG_LOCKDOWN = "lockdown";
- private static final String ACTION_VPN_SETTINGS = "android.net.vpn.SETTINGS";
private static final String EXTRA_PICK_LOCKDOWN = "android.net.vpn.PICK_LOCKDOWN";
// TODO: migrate to using DialogFragment when editing
@@ -102,7 +90,6 @@
private String mSelectedKey;
private boolean mUnavailable;
- private UserSpinnerAdapter mProfileSpinnerAdapter;
@Override
public void onCreate(Bundle savedState) {
@@ -130,39 +117,6 @@
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- Context context = getActivity();
- mProfileSpinnerAdapter = Utils.createUserSpinnerAdapter(mUm, getActivity());
- if (mProfileSpinnerAdapter != null) {
- Spinner spinner = (Spinner) getActivity().getLayoutInflater().inflate(
- R.layout.spinner_view, null);
-
- spinner.setAdapter(mProfileSpinnerAdapter);
- spinner.setOnItemSelectedListener(this);
- setPinnedHeaderView(spinner);
- }
- }
-
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- UserHandle selectedUser = mProfileSpinnerAdapter.getUserHandle(position);
- if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
- Intent intent = new Intent(ACTION_VPN_SETTINGS);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- Activity activity = getActivity();
- activity.startActivityAsUser(intent, selectedUser);
- activity.finish();
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- // Nothing to do
- }
-
- @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.vpn, menu);