Merge "No input instead of disabling password/pin entry" into mnc-dev
diff --git a/res/layout/manage_assist_footer.xml b/res/layout/manage_assist_footer.xml
new file mode 100644
index 0000000..8e10d62
--- /dev/null
+++ b/res/layout/manage_assist_footer.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@android:style/TextAppearance.Material.Body1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="?android:attr/textColorSecondary"
+ android:paddingTop="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingBottom="16dp"
+ android:selectable="false"
+ android:clickable="false"
+ android:text="@string/assist_footer">
+</TextView>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e4e9255..646c385 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -207,7 +207,9 @@
<integer name="bluetooth_name_length">32</integer>
<dimen name="bluetooth_pairing_padding">20dp</dimen>
+ <!-- WiFi Preferences -->
<dimen name="wifi_divider_height">1px</dimen>
+ <dimen name="wifi_preference_badge_padding">8dip</dimen>
<!-- Color picker -->
<dimen name="color_swatch_size">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3bea360..feb10a7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1552,7 +1552,7 @@
<!-- Label for the check box to show password -->
<string name="wifi_show_password">Show password</string>
<!-- Label for the RadioGroup to choose wifi ap band -->
- <string name="wifi_ap_band_config">Config AP Band</string>
+ <string name="wifi_ap_band_config">Select AP Band</string>
<!-- Label for the radio button to choose wifi ap 2.4 GHz band -->
<string name="wifi_ap_choose_2G">2.4 GHz Band</string>
<!-- Label for the radio button to choose wifi ap 5GHz band -->
@@ -4595,6 +4595,8 @@
<string name="backup_erase_dialog_message">Stop backing up your Wi\u2011Fi passwords, bookmarks, other settings, and app data, plus erase all copies on Google servers?</string>
<!-- Dialog title for confirmation to erase full backup data from server -->
<string name="fullbackup_erase_dialog_message">Stop backing up device data (such as Wi-Fi passwords and call history) and app data (such as settings and files stored by apps), plus erase all copies on Google Drive?</string>
+ <!-- Summary for explanation of what full app data backup means. Manufacturers may wish to overlay this resource with their own text -->
+ <string name="fullbackup_data_summary">Automatically back up device data (such as Wi-Fi passwords and call history) and app data (such as settings and files stored by apps) remotely.\n\nWhen you turn on automatic backup, device and app data is periodically saved remotely. App data can be any data that an app has saved (based on developer settings), including potentially sensitive data such as contacts, messages, and photos.</string>
<!-- Device admin settings screen --><skip />
<!-- Device admin settings activity title -->
<string name="device_admin_settings_title">Device administration settings</string>
@@ -6508,6 +6510,12 @@
<!-- Title for Default Apps settings [CHAR LIMIT=30] -->
<string name="default_apps_title">Default Apps</string>
+ <!-- Title for Default Assist settings [CHAR LIMIT=30] -->
+ <string name="default_assist_title">Assist</string>
+
+ <!-- Summary for No Default Assist settings [CHAR LIMIT=45] -->
+ <string name="default_assist_none">No default Assist</string>
+
<!-- Title for Default Browser settings [CHAR LIMIT=30] -->
<string name="default_browser_title">Browser app</string>
@@ -6635,4 +6643,12 @@
<!-- Settings item summary for active app [CHAR LIMIT=100] -->
<string name="inactive_app_active_summary">Active. Touch to toggle.</string>
+ <!-- Title for the "context" preference to determine whether assist can access the data currently displayed on-screen [CHAR LIMIT=40] -->
+ <string name="assist_access_context_title">Use current context</string>
+
+ <!-- Summary for the "context" preference to determine whether assist can access the data currently displayed on-screen [CHAR LIMIT=NONE] -->
+ <string name="assist_access_context_summary">When you open the assist app, let it see what you\'ve been doing on your screen</string>
+
+ <!-- Footer text in the manage assist screen. [CHAR LIMIT=NONE] -->
+ <string name="assist_footer">Assist apps help you identify and act on useful information without having to ask. Some apps support both launcher and voice input services to give you integrated assistance.</string>
</resources>
diff --git a/res/xml/default_apps.xml b/res/xml/default_apps.xml
index 7fc32fd..ab65ac8 100644
--- a/res/xml/default_apps.xml
+++ b/res/xml/default_apps.xml
@@ -19,6 +19,12 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:key="default_apps">
+ <Preference
+ android:key="default_assist"
+ android:fragment="com.android.settings.applications.ManageAssist"
+ android:title="@string/default_assist_title"
+ />
+
<com.android.settings.applications.DefaultBrowserPreference
android:key="default_browser"
android:title="@string/default_browser_title"
diff --git a/res/xml/manage_assist.xml b/res/xml/manage_assist.xml
new file mode 100644
index 0000000..00e86ad
--- /dev/null
+++ b/res/xml/manage_assist.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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="manage_assist">
+
+ <SwitchPreference
+ android:key="context"
+ android:title="@string/assist_access_context_title"
+ android:summary="@string/assist_access_context_summary"
+ android:persistent="false" />
+</PreferenceScreen>
diff --git a/res/xml/privacy_settings.xml b/res/xml/privacy_settings.xml
index 4607254..f9b4fbe 100644
--- a/res/xml/privacy_settings.xml
+++ b/res/xml/privacy_settings.xml
@@ -19,11 +19,11 @@
android:title="@string/privacy_settings_title">
<!-- Backup settings -->
- <SwitchPreference
+ <PreferenceScreen
android:key="backup_data"
android:title="@string/backup_data_title"
- android:summary="@string/backup_data_summary"
- android:persistent="false" />
+ android:persistent="false"
+ android:fragment="com.android.settings.backup.ToggleBackupSettingFragment"/>
<PreferenceScreen
android:key="configure_account"
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index 6eb22fb..7c911cb 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -16,12 +16,9 @@
package com.android.settings;
-import android.app.AlertDialog;
-import android.app.Dialog;
import android.app.backup.IBackupManager;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Process;
@@ -49,8 +46,7 @@
/**
* Gesture lock pattern settings.
*/
-public class PrivacySettings extends SettingsPreferenceFragment implements
- DialogInterface.OnClickListener, Indexable {
+public class PrivacySettings extends SettingsPreferenceFragment implements Indexable {
// Vendor specific
private static final String GSETTINGS_PROVIDER = "com.google.settings";
@@ -61,15 +57,11 @@
private static final String FACTORY_RESET = "factory_reset";
private static final String TAG = "PrivacySettings";
private IBackupManager mBackupManager;
- private SwitchPreference mBackup;
+ private PreferenceScreen mBackup;
private SwitchPreference mAutoRestore;
- private Dialog mConfirmDialog;
private PreferenceScreen mConfigure;
private boolean mEnabled;
- private static final int DIALOG_ERASE_BACKUP = 2;
- private int mDialogType;
-
@Override
protected int getMetricsCategory() {
return MetricsLogger.PRIVACY;
@@ -89,8 +81,7 @@
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
- mBackup = (SwitchPreference) screen.findPreference(BACKUP_DATA);
- mBackup.setOnPreferenceChangeListener(preferenceChangeListener);
+ mBackup = (PreferenceScreen) screen.findPreference(BACKUP_DATA);
mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
@@ -120,16 +111,6 @@
}
}
- @Override
- public void onStop() {
- if (mConfirmDialog != null && mConfirmDialog.isShowing()) {
- mConfirmDialog.dismiss();
- }
- mConfirmDialog = null;
- mDialogType = 0;
- super.onStop();
- }
-
private OnPreferenceChangeListener preferenceChangeListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -138,16 +119,7 @@
}
boolean nextValue = (Boolean) newValue;
boolean result = false;
- if (preference == mBackup) {
- if (nextValue == false) {
- // Don't change Switch status until user makes choice in dialog
- // so return false here.
- showEraseBackupDialog();
- } else {
- setBackupEnabled(true);
- result = true;
- }
- } else if (preference == mAutoRestore) {
+ if (preference == mAutoRestore) {
try {
mBackupManager.setAutoRestore(nextValue);
result = true;
@@ -159,19 +131,9 @@
}
};
- private void showEraseBackupDialog() {
- mDialogType = DIALOG_ERASE_BACKUP;
- CharSequence msg = getResources().getText(R.string.backup_erase_dialog_message);
- // TODO: DialogFragment?
- mConfirmDialog = new AlertDialog.Builder(getActivity()).setMessage(msg)
- .setTitle(R.string.backup_erase_dialog_title)
- .setPositiveButton(android.R.string.ok, this)
- .setNegativeButton(android.R.string.cancel, this)
- .show();
- }
/*
- * Creates toggles for each available location provider
+ * Creates toggles for each backup/reset preference.
*/
private void updateToggles() {
ContentResolver res = getContentResolver();
@@ -184,11 +146,14 @@
String transport = mBackupManager.getCurrentTransport();
configIntent = mBackupManager.getConfigurationIntent(transport);
configSummary = mBackupManager.getDestinationString(transport);
+
+ mBackup.setSummary(backupEnabled
+ ? R.string.accessibility_feature_state_on
+ : R.string.accessibility_feature_state_off);
} catch (RemoteException e) {
// leave it 'false' and disable the UI; there's no backup manager
mBackup.setEnabled(false);
}
- mBackup.setChecked(backupEnabled);
mAutoRestore.setChecked(Settings.Secure.getInt(res,
Settings.Secure.BACKUP_AUTO_RESTORE, 1) == 1);
@@ -208,54 +173,6 @@
}
}
- private void updateConfigureSummary() {
- try {
- String transport = mBackupManager.getCurrentTransport();
- String summary = mBackupManager.getDestinationString(transport);
- setConfigureSummary(summary);
- } catch (RemoteException e) {
- // Not much we can do here
- }
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Dialog is triggered before Switch status change, that means marking the Switch to
- // true in showEraseBackupDialog() method will be override by following status change.
- // So we do manual switching here due to users' response.
- if (mDialogType == DIALOG_ERASE_BACKUP) {
- // Accept turning off backup
- if (which == DialogInterface.BUTTON_POSITIVE) {
- setBackupEnabled(false);
- } else if (which == DialogInterface.BUTTON_NEGATIVE) {
- // Reject turning off backup
- setBackupEnabled(true);
- }
- updateConfigureSummary();
- }
- mDialogType = 0;
- }
-
- /**
- * Informs the BackupManager of a change in backup state - if backup is disabled,
- * the data on the server will be erased.
- * @param enable whether to enable backup
- */
- private void setBackupEnabled(boolean enable) {
- if (mBackupManager != null) {
- try {
- mBackupManager.setBackupEnabled(enable);
- } catch (RemoteException e) {
- mBackup.setChecked(!enable);
- mAutoRestore.setEnabled(!enable);
- return;
- }
- }
- mBackup.setChecked(enable);
- mAutoRestore.setEnabled(enable);
- mConfigure.setEnabled(enable);
- }
-
@Override
protected int getHelpResource() {
return R.string.help_url_backup_reset;
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 7ce581f..c256f5c 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -1272,8 +1272,7 @@
((UserManager) getSystemService(Context.USER_SERVICE))
.getUserCount() > 1;
if (!UserHandle.MU_ENABLED
- || (!UserManager.supportsMultipleUsers()
- && !hasMultipleUsers)
+ || !UserManager.supportsMultipleUsers()
|| Utils.isMonkeyRunning()) {
removeTile = true;
}
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 16234ba..124f9da 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -237,6 +237,8 @@
getActivity().getActionBar().setTitle(R.string.usage_access_title);
} else if (className.equals(HighPowerApplicationsActivity.class.getName())) {
mListType = LIST_TYPE_HIGH_POWER;
+ // Default to showing system.
+ mShowSystem = true;
} else {
mListType = LIST_TYPE_MAIN;
}
diff --git a/src/com/android/settings/applications/ManageAssist.java b/src/com/android/settings/applications/ManageAssist.java
new file mode 100644
index 0000000..e222e1c
--- /dev/null
+++ b/src/com/android/settings/applications/ManageAssist.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 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.applications;
+
+import android.annotation.Nullable;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.SwitchPreference;
+import android.provider.Settings;
+import android.text.method.LinkMovementMethod;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.settings.InstrumentedFragment;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+/**
+ * Settings screen to manage everything about assist.
+ */
+public class ManageAssist extends SettingsPreferenceFragment
+ implements Preference.OnPreferenceChangeListener {
+
+ private static final String KEY_CONTEXT = "context";
+
+ private SwitchPreference mContextPref;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ addPreferencesFromResource(R.xml.manage_assist);
+ mContextPref = (SwitchPreference) findPreference(KEY_CONTEXT);
+ mContextPref.setChecked(Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1) != 0);
+ mContextPref.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ TextView v = (TextView) LayoutInflater.from(view.getContext()).inflate(
+ R.layout.manage_assist_footer, null);
+ getListView().addFooterView(v);
+ }
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsLogger.APPLICATIONS_MANAGE_ASSIST;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mContextPref) {
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED,
+ (boolean) newValue ? 1 : 0);
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/backup/ToggleBackupSettingFragment.java b/src/com/android/settings/backup/ToggleBackupSettingFragment.java
new file mode 100644
index 0000000..e30266f
--- /dev/null
+++ b/src/com/android/settings/backup/ToggleBackupSettingFragment.java
@@ -0,0 +1,174 @@
+package com.android.settings.backup;
+
+import android.app.AlertDialog;
+import android.app.backup.IBackupManager;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.preference.Preference;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.widget.SwitchBar;
+import com.android.settings.widget.ToggleSwitch;
+
+/**
+ * Fragment to display a bunch of text about backup and restore, and allow the user to enable/
+ * disable it.
+ */
+public class ToggleBackupSettingFragment extends SettingsPreferenceFragment
+ implements DialogInterface.OnClickListener {
+ private static final String TAG = "ToggleBackupSettingFragment";
+
+ private static final String BACKUP_TOGGLE = "toggle_backup";
+
+ private IBackupManager mBackupManager;
+
+ protected SwitchBar mSwitchBar;
+ protected ToggleSwitch mToggleSwitch;
+
+ private Preference mSummaryPreference;
+
+ private Dialog mConfirmDialog;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mBackupManager = IBackupManager.Stub.asInterface(
+ ServiceManager.getService(Context.BACKUP_SERVICE));
+
+ PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
+ getActivity());
+ setPreferenceScreen(preferenceScreen);
+ mSummaryPreference = new Preference(getActivity()) {
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ final TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
+ summaryView.setText(getSummary());
+ }
+ };
+ mSummaryPreference.setPersistent(false);
+ mSummaryPreference.setLayoutResource(R.layout.text_description_preference);
+ preferenceScreen.addPreference(mSummaryPreference);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ SettingsActivity activity = (SettingsActivity) getActivity();
+ mSwitchBar = activity.getSwitchBar();
+ mToggleSwitch = mSwitchBar.getSwitch();
+
+ // Set up UI.
+ mSummaryPreference.setSummary(R.string.fullbackup_data_summary);
+ try {
+ boolean backupEnabled = mBackupManager == null ?
+ false : mBackupManager.isBackupEnabled();
+ mSwitchBar.setCheckedInternal(backupEnabled);
+ } catch (RemoteException e) {
+ // The world is aflame, turn it off.
+ mSwitchBar.setEnabled(false);
+ }
+ getActivity().setTitle(R.string.backup_data_title);
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+
+ mToggleSwitch.setOnBeforeCheckedChangeListener(null);
+ mSwitchBar.hide();
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // Set up toggle listener. We need this b/c we have to intercept the toggle event in order
+ // to pop up the dialogue.
+ mToggleSwitch.setOnBeforeCheckedChangeListener(
+ new ToggleSwitch.OnBeforeCheckedChangeListener() {
+ @Override
+ public boolean onBeforeCheckedChanged(
+ ToggleSwitch toggleSwitch, boolean checked) {
+ if (!checked) {
+ // Don't change Switch status until user makes choice in dialog
+ // so return false here.
+ showEraseBackupDialog();
+ return false;
+ } else {
+ setBackupEnabled(true);
+ mSwitchBar.setCheckedInternal(true);
+ return true;
+ }
+ }
+ });
+ mSwitchBar.show();
+ }
+
+ /** Get rid of the dialog if it's still showing. */
+ @Override
+ public void onStop() {
+ if (mConfirmDialog != null && mConfirmDialog.isShowing()) {
+ mConfirmDialog.dismiss();
+ }
+ mConfirmDialog = null;
+ super.onStop();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Accept turning off backup
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ setBackupEnabled(false);
+ mSwitchBar.setCheckedInternal(false);
+ } else if (which == DialogInterface.BUTTON_NEGATIVE) {
+ // Reject turning off backup
+ setBackupEnabled(true);
+ mSwitchBar.setCheckedInternal(true);
+ }
+ }
+
+ private void showEraseBackupDialog() {
+ CharSequence msg = getResources().getText(R.string.fullbackup_erase_dialog_message);
+ // TODO: DialogFragment?
+ mConfirmDialog = new AlertDialog.Builder(getActivity()).setMessage(msg)
+ .setTitle(R.string.backup_erase_dialog_title)
+ .setPositiveButton(android.R.string.ok, this)
+ .setNegativeButton(android.R.string.cancel, this)
+ .show();
+ }
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsLogger.PRIVACY;
+ }
+
+ /**
+ * Informs the BackupManager of a change in backup state - if backup is disabled,
+ * the data on the server will be erased.
+ * @param enable whether to enable backup
+ */
+ private void setBackupEnabled(boolean enable) {
+ if (mBackupManager != null) {
+ try {
+ mBackupManager.setBackupEnabled(enable);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error communicating with BackupManager", e);
+ return;
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java b/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
index 76b2fd1..e0369d6 100644
--- a/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
+++ b/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
@@ -18,12 +18,14 @@
import android.annotation.Nullable;
import android.app.Activity;
+import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.util.Log;
+
import com.android.settings.R;
/**
@@ -46,7 +48,9 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- setCurrentFunction(which);
+ if (!ActivityManager.isUserAMonkey()) {
+ setCurrentFunction(which);
+ }
dialog.dismiss();
UsbModeChooserActivity.this.finish();
}
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index d0dde32..2628c7f 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -33,7 +33,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Switch;
-
import com.android.internal.logging.MetricsLogger;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -45,7 +44,29 @@
import java.util.List;
/**
- * Location access settings.
+ * System location settings (Settings > Location). The screen has three parts:
+ * <ul>
+ * <li>Platform location controls</li>
+ * <ul>
+ * <li>In switch bar: location master switch. Used to toggle
+ * {@link android.provider.Settings.Secure#LOCATION_MODE} between
+ * {@link android.provider.Settings.Secure#LOCATION_MODE_OFF} and another location mode.
+ * </li>
+ * <li>Mode preference: only available if the master switch is on, selects between
+ * {@link android.provider.Settings.Secure#LOCATION_MODE} of
+ * {@link android.provider.Settings.Secure#LOCATION_MODE_HIGH_ACCURACY},
+ * {@link android.provider.Settings.Secure#LOCATION_MODE_BATTERY_SAVING}, or
+ * {@link android.provider.Settings.Secure#LOCATION_MODE_SENSORS_ONLY}.</li>
+ * </ul>
+ * <li>Recent location requests: automatically populated by {@link RecentLocationApps}</li>
+ * <li>Location services: multi-app settings provided from outside the Android framework. Each
+ * is injected by a system-partition app via the {@link SettingInjectorService} API.</li>
+ * </ul>
+ * <p>
+ * Note that as of KitKat, the {@link SettingInjectorService} is the preferred method for OEMs to
+ * add their own settings to this page, rather than directly modifying the framework code. Among
+ * other things, this simplifies integration with future changes to the default (AOSP)
+ * implementation.
*/
public class LocationSettings extends LocationSettingsBase
implements SwitchBar.OnSwitchChangeListener {
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index cef0833..d61032b 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -200,7 +200,7 @@
final Context context = getActivity();
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
boolean hasMultipleUsers = mUserManager.getUserCount() > 1;
- if ((!UserManager.supportsMultipleUsers() && !hasMultipleUsers)
+ if ((!UserManager.supportsMultipleUsers())
|| Utils.isMonkeyRunning()) {
mEnabled = false;
return;
diff --git a/src/com/android/settings/vpn2/AppDialog.java b/src/com/android/settings/vpn2/AppDialog.java
index cd6a16c..c06de14 100644
--- a/src/com/android/settings/vpn2/AppDialog.java
+++ b/src/com/android/settings/vpn2/AppDialog.java
@@ -41,28 +41,25 @@
*/
class AppDialog extends AlertDialog implements DialogInterface.OnClickListener {
private final Listener mListener;
- private final PackageInfo mPkgInfo;
+ private final PackageInfo mPackageInfo;
private final String mLabel;
- private final boolean mConnected;
- AppDialog(Context context, Listener listener, PackageInfo pkgInfo, String label,
- boolean connected) {
+ AppDialog(Context context, Listener listener, PackageInfo pkgInfo, String label) {
super(context);
mListener = listener;
- mPkgInfo = pkgInfo;
+ mPackageInfo = pkgInfo;
mLabel = label;
- mConnected = connected;
}
public final PackageInfo getPackageInfo() {
- return mPkgInfo;
+ return mPackageInfo;
}
@Override
protected void onCreate(Bundle savedState) {
setTitle(mLabel);
- setMessage(getContext().getString(R.string.vpn_version, mPkgInfo.versionName));
+ setMessage(getContext().getString(R.string.vpn_version, mPackageInfo.versionName));
createButtons();
super.onCreate(savedState);
@@ -71,11 +68,9 @@
protected void createButtons() {
Context context = getContext();
- if (mConnected) {
- // Forget the network
- setButton(DialogInterface.BUTTON_NEGATIVE,
- context.getString(R.string.vpn_forget), this);
- }
+ // Forget the network
+ setButton(DialogInterface.BUTTON_NEGATIVE,
+ context.getString(R.string.vpn_forget), this);
// Dismiss
setButton(DialogInterface.BUTTON_POSITIVE,
diff --git a/src/com/android/settings/vpn2/AppDialogFragment.java b/src/com/android/settings/vpn2/AppDialogFragment.java
index 6ac4fb5..906f896 100644
--- a/src/com/android/settings/vpn2/AppDialogFragment.java
+++ b/src/com/android/settings/vpn2/AppDialogFragment.java
@@ -27,6 +27,7 @@
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.util.Log;
import com.android.internal.net.VpnConfig;
@@ -41,18 +42,20 @@
private static final String ARG_MANAGING = "managing";
private static final String ARG_LABEL = "label";
- private static final String ARG_PACKAGE = "package";
private static final String ARG_CONNECTED = "connected";
+ private static final String ARG_PACKAGE = "package";
+
+ private PackageInfo mPackageInfo;
private final IConnectivityManager mService = IConnectivityManager.Stub.asInterface(
ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
- public static void show(VpnSettings parent, PackageInfo pkgInfo, String label, boolean managing,
- boolean connected) {
+ public static void show(VpnSettings parent, PackageInfo packageInfo, String label,
+ boolean managing, boolean connected) {
if (!parent.isAdded()) return;
Bundle args = new Bundle();
- args.putParcelable(ARG_PACKAGE, pkgInfo);
+ args.putParcelable(ARG_PACKAGE, packageInfo);
args.putString(ARG_LABEL, label);
args.putBoolean(ARG_MANAGING, managing);
args.putBoolean(ARG_CONNECTED, connected);
@@ -66,13 +69,13 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle args = getArguments();
- PackageInfo pkgInfo = (PackageInfo) args.getParcelable(ARG_PACKAGE);
- String label = args.getString(ARG_LABEL);
+ final String label = args.getString(ARG_LABEL);
boolean managing = args.getBoolean(ARG_MANAGING);
boolean connected = args.getBoolean(ARG_CONNECTED);
+ mPackageInfo = (PackageInfo) args.getParcelable(ARG_PACKAGE);
if (managing) {
- return new AppDialog(getActivity(), this, pkgInfo, label, connected);
+ return new AppDialog(getActivity(), this, mPackageInfo, label);
} else {
// Build an AlertDialog with an option to disconnect.
AlertDialog.Builder dlog = new AlertDialog.Builder(getActivity())
@@ -94,12 +97,6 @@
}
@Override
- public void dismiss() {
- ((VpnSettings) getTargetFragment()).update();
- super.dismiss();
- }
-
- @Override
public void onCancel(DialogInterface dialog) {
dismiss();
super.onCancel(dialog);
@@ -107,25 +104,29 @@
@Override
public void onForget(final DialogInterface dialog) {
- PackageInfo pkgInfo = (PackageInfo) getArguments().getParcelable(ARG_PACKAGE);
- final String pkg = pkgInfo.packageName;
+ final int userId = UserHandle.getUserId(mPackageInfo.applicationInfo.uid);
try {
- VpnConfig vpnConfig = mService.getVpnConfig();
- if (vpnConfig != null && pkg.equals(vpnConfig.user) && !vpnConfig.legacy) {
- mService.setVpnPackageAuthorization(false);
- onDisconnect(dialog);
- }
+ mService.setVpnPackageAuthorization(mPackageInfo.packageName, userId, false);
+ onDisconnect(dialog);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to forget authorization for " + pkg, e);
+ Log.e(TAG, "Failed to forget authorization of " + mPackageInfo.packageName +
+ " for user " + userId, e);
}
}
private void onDisconnect(final DialogInterface dialog) {
- PackageInfo pkgInfo = (PackageInfo) getArguments().getParcelable(ARG_PACKAGE);
+ final int userId = UserHandle.getUserId(mPackageInfo.applicationInfo.uid);
try {
- mService.prepareVpn(pkgInfo.packageName, VpnConfig.LEGACY_VPN);
+ final VpnConfig vpnConfig = mService.getVpnConfig(userId);
+ if (vpnConfig == null || vpnConfig.legacy) {
+ return;
+ }
+ if (mPackageInfo.packageName.equals(vpnConfig.user)) {
+ mService.prepareVpn(mPackageInfo.packageName, VpnConfig.LEGACY_VPN, userId);
+ }
} catch (RemoteException e) {
- Log.e(TAG, "Failed to disconnect package " + pkgInfo.packageName, e);
+ Log.e(TAG, "Failed to disconnect package " + mPackageInfo.packageName +
+ " for user " + userId, e);
}
}
}
diff --git a/src/com/android/settings/vpn2/ConfigDialogFragment.java b/src/com/android/settings/vpn2/ConfigDialogFragment.java
index 42e1614..26b7982 100644
--- a/src/com/android/settings/vpn2/ConfigDialogFragment.java
+++ b/src/com/android/settings/vpn2/ConfigDialogFragment.java
@@ -24,6 +24,7 @@
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.security.Credentials;
import android.security.KeyStore;
import android.util.Log;
@@ -128,12 +129,6 @@
}
@Override
- public void dismiss() {
- ((VpnSettings) getTargetFragment()).update();
- super.dismiss();
- }
-
- @Override
public void onCancel(DialogInterface dialog) {
dismiss();
super.onCancel(dialog);
@@ -151,7 +146,8 @@
try {
LegacyVpnInfo connected = mService.getLegacyVpnInfo();
if (connected != null && profile.key.equals(connected.key)) {
- mService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN);
+ mService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN,
+ UserHandle.myUserId());
}
} catch (RemoteException e) {
Log.e(TAG, "Failed to disconnect", e);
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index e60a262..a82585d 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -71,6 +71,9 @@
Handler.Callback, Preference.OnPreferenceClickListener {
private static final String LOG_TAG = "VpnSettings";
+ private static final int RESCAN_MESSAGE = 0;
+ private static final int RESCAN_INTERVAL_MS = 1000;
+
private static final String EXTRA_PICK_LOCKDOWN = "android.net.vpn.PICK_LOCKDOWN";
private static final NetworkRequest VPN_REQUEST = new NetworkRequest.Builder()
.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
@@ -90,7 +93,6 @@
private Handler mUpdater;
private LegacyVpnInfo mConnectedLegacyVpn;
- private HashSet<String> mConnectedVpns = new HashSet<>();
private boolean mUnavailable;
@@ -111,7 +113,6 @@
}
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- mConnectivityManager.registerNetworkCallback(VPN_REQUEST, mNetworkCallback);
setHasOptionsMenu(true);
addPreferencesFromResource(R.xml.vpn_settings2);
@@ -179,10 +180,32 @@
LockdownConfigFragment.show(this);
}
- update();
+ // Start monitoring
+ mConnectivityManager.registerNetworkCallback(VPN_REQUEST, mNetworkCallback);
+
+ // Trigger a refresh
+ if (mUpdater == null) {
+ mUpdater = new Handler(this);
+ }
+ mUpdater.sendEmptyMessage(RESCAN_MESSAGE);
}
- public void update() {
+ @Override
+ public void onPause() {
+ // Pause monitoring
+ mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
+
+ if (mUpdater != null) {
+ mUpdater.removeCallbacksAndMessages(null);
+ }
+
+ super.onPause();
+ }
+
+ @Override
+ public boolean handleMessage(Message message) {
+ mUpdater.removeMessages(RESCAN_MESSAGE);
+
// Pref group within which to list VPNs
PreferenceGroup vpnGroup = getPreferenceScreen();
vpnGroup.removeAll();
@@ -200,18 +223,43 @@
// 3rd-party VPN apps can change elsewhere. Reload them every time.
for (AppOpsManager.PackageOps pkg : getVpnApps()) {
+ String key = getVpnIdentifier(UserHandle.getUserId(pkg.getUid()), pkg.getPackageName());
final AppPreference pref = new AppPreference(getActivity(), mManageListener,
pkg.getPackageName(), pkg.getUid());
pref.setOnPreferenceClickListener(this);
- mAppPreferences.put(pkg.getPackageName(), pref);
+ mAppPreferences.put(key, pref);
vpnGroup.addPreference(pref);
}
- // Start monitoring.
- if (mUpdater == null) {
- mUpdater = new Handler(this);
+ // Mark out connections with a subtitle
+ try {
+ // Legacy VPNs
+ LegacyVpnInfo info = mConnectivityService.getLegacyVpnInfo();
+ if (info != null) {
+ ConfigPreference preference = mConfigPreferences.get(info.key);
+ if (preference != null) {
+ preference.setState(info.state);
+ mConnectedLegacyVpn = info;
+ }
+ }
+
+ // Third-party VPNs
+ for (UserHandle profile : mUserManager.getUserProfiles()) {
+ VpnConfig cfg = mConnectivityService.getVpnConfig(profile.getIdentifier());
+ if (cfg != null) {
+ final String key = getVpnIdentifier(profile.getIdentifier(), cfg.user);
+ final AppPreference preference = mAppPreferences.get(key);
+ if (preference != null) {
+ preference.setState(AppPreference.STATE_CONNECTED);
+ }
+ }
+ }
+ } catch (RemoteException e) {
+ // ignore
}
- mUpdater.sendEmptyMessage(0);
+
+ mUpdater.sendEmptyMessageDelayed(RESCAN_MESSAGE, RESCAN_INTERVAL_MS);
+ return true;
}
@Override
@@ -275,68 +323,22 @@
}
};
- @Override
- public boolean handleMessage(Message message) {
- mUpdater.removeMessages(0);
-
- if (isResumed()) {
- try {
- // Legacy VPNs
- LegacyVpnInfo info = mConnectivityService.getLegacyVpnInfo();
- if (mConnectedLegacyVpn != null) {
- ConfigPreference preference = mConfigPreferences.get(mConnectedLegacyVpn.key);
- if (preference != null) {
- preference.setState(-1);
- }
- mConnectedLegacyVpn = null;
- }
- if (info != null) {
- ConfigPreference preference = mConfigPreferences.get(info.key);
- if (preference != null) {
- preference.setState(info.state);
- mConnectedLegacyVpn = info;
- }
- }
-
- // VPN apps
- for (String key : mConnectedVpns) {
- AppPreference preference = mAppPreferences.get(key);
- if (preference != null) {
- preference.setState(AppPreference.STATE_DISCONNECTED);
- }
- }
- mConnectedVpns.clear();
- // TODO: also query VPN services in user profiles STOPSHIP
- VpnConfig cfg = mConnectivityService.getVpnConfig();
- if (cfg != null) {
- mConnectedVpns.add(cfg.user);
- }
- for (String key : mConnectedVpns) {
- AppPreference preference = mAppPreferences.get(key);
- if (preference != null) {
- preference.setState(AppPreference.STATE_CONNECTED);
- }
- }
- } catch (RemoteException e) {
- // ignore
- }
- mUpdater.sendEmptyMessageDelayed(0, 1000);
- }
- return true;
+ private static String getVpnIdentifier(int userId, String packageName) {
+ return Integer.toString(userId)+ "_" + packageName;
}
private NetworkCallback mNetworkCallback = new NetworkCallback() {
@Override
public void onAvailable(Network network) {
if (mUpdater != null) {
- mUpdater.sendEmptyMessage(0);
+ mUpdater.sendEmptyMessage(RESCAN_MESSAGE);
}
}
@Override
public void onLost(Network network) {
if (mUpdater != null) {
- mUpdater.sendEmptyMessage(0);
+ mUpdater.sendEmptyMessage(RESCAN_MESSAGE);
}
}
};
diff --git a/src/com/android/settings/wifi/AccessPointPreference.java b/src/com/android/settings/wifi/AccessPointPreference.java
index 511d88d..55d575e 100644
--- a/src/com/android/settings/wifi/AccessPointPreference.java
+++ b/src/com/android/settings/wifi/AccessPointPreference.java
@@ -18,9 +18,12 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
+import android.net.wifi.WifiConfiguration;
+import android.os.UserHandle;
import android.preference.Preference;
import android.view.View;
import android.widget.TextView;
+
import com.android.settings.R;
import com.android.settingslib.wifi.AccessPoint;
@@ -33,6 +36,7 @@
private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
+ private TextView mTitleView;
private TextView mSummaryView;
private boolean showSummary = true;
private boolean mForSavedNetworks = false;
@@ -56,9 +60,12 @@
super.onBindView(view);
updateIcon(mAccessPoint.getLevel(), getContext());
+ mTitleView = (TextView) view.findViewById(com.android.internal.R.id.title);
+
mSummaryView = (TextView) view.findViewById(com.android.internal.R.id.summary);
mSummaryView.setVisibility(showSummary ? View.VISIBLE : View.GONE);
+ updateBadge(getContext());
notifyChanged();
}
@@ -94,6 +101,27 @@
}
}
+ protected void updateBadge(Context context) {
+ if (mTitleView != null) {
+ WifiConfiguration config = mAccessPoint.getConfig();
+ if (config == null) {
+ return;
+ }
+ // Fetch badge (may be null)
+ UserHandle creatorUser = new UserHandle(UserHandle.getUserId(config.creatorUid));
+ Drawable badge =
+ context.getPackageManager().getUserBadgeForDensity(creatorUser, 0 /* dpi */);
+
+ // Distance from the end of the title at which this AP's user badge should sit.
+ final int badgePadding = context.getResources()
+ .getDimensionPixelSize(R.dimen.wifi_preference_badge_padding);
+
+ // Attach to the end of the title view
+ mTitleView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, badge, null);
+ mTitleView.setCompoundDrawablePadding(badgePadding);
+ }
+ }
+
/**
* Shows or Hides the Summary of an AccessPoint.
*
@@ -117,6 +145,7 @@
final Context context = getContext();
updateIcon(mAccessPoint.getLevel(), context);
+ updateBadge(context);
// Force new summary
setSummary(null);
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 72dca9e..81815ae 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -194,6 +194,19 @@
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
if (mWifiP2pManager != null) {
+ String name = mDeviceNameText.getText().toString();
+ if (name != null) {
+ for (int i = 0; i < name.length(); i++) {
+ char cur = name.charAt(i);
+ if(!Character.isDigit(cur) && !Character.isLetter(cur)
+ && cur != '-' && cur != '_' && cur != ' ') {
+ Toast.makeText(getActivity(),
+ R.string.wifi_p2p_failed_rename_message,
+ Toast.LENGTH_LONG).show();
+ return;
+ }
+ }
+ }
mWifiP2pManager.setDeviceName(mChannel,
mDeviceNameText.getText().toString(),
new WifiP2pManager.ActionListener() {
diff --git a/tests/src/com/android/settings/vpn2/VpnTests.java b/tests/src/com/android/settings/vpn2/VpnTests.java
index 8300534..26cfc9b 100644
--- a/tests/src/com/android/settings/vpn2/VpnTests.java
+++ b/tests/src/com/android/settings/vpn2/VpnTests.java
@@ -22,6 +22,7 @@
import android.os.Environment;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.security.Credentials;
import android.security.KeyStore;
import android.security.NetworkSecurityPolicy;
@@ -214,7 +215,7 @@
*/
private void disconnect() throws Exception {
try {
- mService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN);
+ mService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN, UserHandle.myUserId());
} catch (RemoteException e) {
Log.e(TAG, String.format("disconnect VPN exception: %s", e.toString()));
}