Merge "Add content description to the master switch toggle button." into oc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 59d2d79..4529891 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2933,8 +2933,6 @@
<intent-filter android:priority="60">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.system" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/summary_empty"/>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 848d2eb..e7d17cb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3933,8 +3933,6 @@
<!-- Summary text for keyboards when no layout has been selected. [CHAR LIMIT=35] -->
<string name="default_keyboard_layout">Default</string>
- <!-- On Languages & input settings screen, heading. Inside the "Languages & input settings" screen, this is the header for settings that relate to mouse and trackpad devices. [CHAR LIMIT=40] -->
- <string name="pointer_settings_category">Mouse/trackpad</string>
<!-- On Languages & input settings screen, setting summary. Setting for mouse pointer speed. [CHAR LIMIT=35] -->
<string name="pointer_speed">Pointer speed</string>
@@ -4845,8 +4843,6 @@
<string name="voice_search_settings_title">Voice search</string>
<!-- Title of keyboard settings list item within voice input/output settings -->
<string name="keyboard_settings_title">Android keyboard</string>
- <!-- Title for the 'voice input' category of voice input/output settings -->
- <string name="voice_category">Speech</string>
<!-- Voice input settings --><skip />
<!-- [CHAR_LIMIT=NONE] Name of the settings item to open the voice input settings. -->
diff --git a/res/xml/enterprise_privacy_settings.xml b/res/xml/enterprise_privacy_settings.xml
index dae3b42..45c784e 100644
--- a/res/xml/enterprise_privacy_settings.xml
+++ b/res/xml/enterprise_privacy_settings.xml
@@ -25,72 +25,68 @@
android:summary="@string/enterprise_privacy_header"
android:selectable="false"/>
- <PreferenceCategory android:title="@string/enterprise_privacy_exposure_category">
- <com.android.settings.DividerPreference
- android:layout_height="wrap_content"
- android:title="@string/enterprise_privacy_enterprise_data"/>
- <com.android.settings.DividerPreference
- android:title="@string/enterprise_privacy_installed_packages"/>
- <com.android.settings.DividerPreference
- android:title="@string/enterprise_privacy_usage_stats"/>
- <com.android.settings.DividerPreference
- android:key="network_logs"
- android:title="@string/enterprise_privacy_network_logs"/>
- <com.android.settings.DividerPreference
- android:key="bug_reports"
- android:title="@string/enterprise_privacy_bug_reports"/>
- <com.android.settings.DividerPreference
- android:key="security_logs"
- android:title="@string/enterprise_privacy_security_logs"/>
+ <PreferenceCategory android:title="@string/enterprise_privacy_exposure_category"
+ android:contentDescription="@string/enterprise_privacy_exposure_category">
+ <Preference android:layout_height="wrap_content"
+ android:title="@string/enterprise_privacy_enterprise_data"
+ android:selectable="false"/>
+ <Preference android:title="@string/enterprise_privacy_installed_packages"
+ android:selectable="false"/>
+ <Preference android:title="@string/enterprise_privacy_usage_stats"
+ android:selectable="false"/>
+ <Preference android:key="network_logs"
+ android:title="@string/enterprise_privacy_network_logs"
+ android:selectable="false"/>
+ <Preference android:key="bug_reports"
+ android:title="@string/enterprise_privacy_bug_reports"
+ android:selectable="false"/>
+ <Preference android:key="security_logs"
+ android:title="@string/enterprise_privacy_security_logs"
+ android:selectable="false"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/enterprise_privacy_exposure_changes_category">
- <com.android.settings.DividerPreference
- android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages"
- android:key="number_enterprise_installed_packages"
- android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
- <com.android.settings.DividerPreference
- android:fragment="com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionLocation"
- android:key="enterprise_privacy_number_location_access_packages"
- android:title="@string/enterprise_privacy_location_access"/>
- <com.android.settings.DividerPreference
- android:fragment="com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionMicrophone"
- android:key="enterprise_privacy_number_microphone_access_packages"
- android:title="@string/enterprise_privacy_microphone_access"/>
- <com.android.settings.DividerPreference
- android:fragment="com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionCamera"
- android:key="enterprise_privacy_number_camera_access_packages"
- android:title="@string/enterprise_privacy_camera_access"/>
- <com.android.settings.DividerPreference
- android:fragment="com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment"
- android:key="number_enterprise_set_default_apps"
- android:title="@string/enterprise_privacy_enterprise_set_default_apps"/>
- <com.android.settings.DividerPreference
- android:key="always_on_vpn_primary_user"/>
- <com.android.settings.DividerPreference
- android:key="always_on_vpn_managed_profile"
- android:title="@string/enterprise_privacy_always_on_vpn_work"/>
- <com.android.settings.DividerPreference
- android:key="input_method"
- android:title="@string/enterprise_privacy_input_method"/>
- <com.android.settings.DividerPreference
- android:key="global_http_proxy"
- android:title="@string/enterprise_privacy_global_http_proxy"/>
- <com.android.settings.DividerPreference
- android:key="ca_certs"
- android:title="@string/enterprise_privacy_ca_certs"/>
+ <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages"
+ android:key="number_enterprise_installed_packages"
+ android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
+ <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionLocation"
+ android:key="enterprise_privacy_number_location_access_packages"
+ android:title="@string/enterprise_privacy_location_access"/>
+ <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionMicrophone"
+ android:key="enterprise_privacy_number_microphone_access_packages"
+ android:title="@string/enterprise_privacy_microphone_access"/>
+ <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionCamera"
+ android:key="enterprise_privacy_number_camera_access_packages"
+ android:title="@string/enterprise_privacy_camera_access"/>
+ <Preference android:fragment="com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment"
+ android:key="number_enterprise_set_default_apps"
+ android:title="@string/enterprise_privacy_enterprise_set_default_apps"/>
+ <Preference android:key="always_on_vpn_primary_user"
+ android:selectable="false"/>
+ <Preference android:key="always_on_vpn_managed_profile"
+ android:title="@string/enterprise_privacy_always_on_vpn_work"
+ android:selectable="false"/>
+ <Preference android:key="input_method"
+ android:title="@string/enterprise_privacy_input_method"
+ android:selectable="false"/>
+ <Preference android:key="global_http_proxy"
+ android:title="@string/enterprise_privacy_global_http_proxy"
+ android:selectable="false"/>
+ <Preference android:key="ca_certs"
+ android:title="@string/enterprise_privacy_ca_certs"
+ android:selectable="false"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
- <com.android.settings.DividerPreference
- android:title="@string/enterprise_privacy_lock_device"/>
- <com.android.settings.DividerPreference
- android:title="@string/enterprise_privacy_wipe_device"/>
- <com.android.settings.DividerPreference
- android:key="failed_password_wipe_current_user"
- android:title="@string/enterprise_privacy_failed_password_wipe_device"/>
- <com.android.settings.DividerPreference
- android:key="failed_password_wipe_managed_profile"
- android:title="@string/enterprise_privacy_failed_password_wipe_work"/>
+ <Preference android:title="@string/enterprise_privacy_lock_device"
+ android:selectable="false"/>
+ <Preference android:title="@string/enterprise_privacy_wipe_device"
+ android:selectable="false"/>
+ <Preference android:key="failed_password_wipe_current_user"
+ android:title="@string/enterprise_privacy_failed_password_wipe_device"
+ android:selectable="false"/>
+ <Preference android:key="failed_password_wipe_managed_profile"
+ android:title="@string/enterprise_privacy_failed_password_wipe_work"
+ android:selectable="false"/>
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 17bd576..ca5ce45 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -97,22 +97,13 @@
</PreferenceCategory>
- <PreferenceCategory
- android:key="pointer_settings_category"
- android:title="@string/pointer_settings_category">
+ <PreferenceCategory>
<com.android.settings.PointerSpeedPreference
android:key="pointer_speed"
android:title="@string/pointer_speed"
android:dialogTitle="@string/pointer_speed"/>
- </PreferenceCategory>
-
- <!-- TTS -->
- <PreferenceCategory
- android:key="voice_category"
- android:title="@string/voice_category">
-
<Preference
android:key="tts_settings"
android:title="@string/tts_settings_title"
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 1186e78..b50d2fd 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -18,6 +18,16 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/header_category_system">
+ <!-- Backup -->
+ <Preference
+ android:key="backup_settings"
+ android:title="@string/privacy_settings_title"
+ android:summary="@string/summary_placeholder"
+ android:icon="@drawable/ic_settings_backup"
+ android:order="-60">
+ <intent android:action="android.settings.BACKUP_AND_RESET_SETTINGS" />
+ </Preference>
+
<!-- System updates -->
<Preference
android:key="system_update_settings"
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index 9018d9b..51225aa 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -25,6 +25,7 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -55,7 +56,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
- return null;
+ return buildPreferenceControllers(context);
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context) {
+ final List<PreferenceController> controllers = new ArrayList<>();
+ controllers.add(new SpecialAppAccessPreferenceController(context));
+ return controllers;
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -67,5 +74,10 @@
sir.xmlResId = R.xml.app_and_notification;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context);
+ }
};
}
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index c0d2dd8..e9b7481 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -526,6 +526,9 @@
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_UNINSTALL:
+ // Refresh option menu
+ getActivity().invalidateOptionsMenu();
+
if (mDisableAfterUninstall) {
mDisableAfterUninstall = false;
new DisableChanger(this, mAppEntry.info,
diff --git a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
new file mode 100644
index 0000000..3735c01
--- /dev/null
+++ b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 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.content.Context;
+import android.support.v7.preference.Preference;
+import com.android.settings.R;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.datausage.DataSaverBackend;
+
+public class SpecialAppAccessPreferenceController extends PreferenceController {
+
+ private static final String KEY_SPECIAL_ACCESS = "special_access";
+
+ private DataSaverBackend mDataSaverBackend;
+
+ public SpecialAppAccessPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_SPECIAL_ACCESS;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (mDataSaverBackend == null) {
+ mDataSaverBackend = new DataSaverBackend(mContext);
+ }
+ final int count = mDataSaverBackend.getWhitelistedCount();
+ preference.setSummary(mContext.getResources().getQuantityString(
+ R.plurals.special_access_summary, count, count));
+ }
+}
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
index 2e79660..5a437db 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
@@ -16,6 +16,7 @@
package com.android.settings.applications.defaultapps;
+import android.Manifest;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
@@ -30,6 +31,7 @@
import android.service.autofill.AutofillServiceInfo;
import android.text.Html;
import android.text.TextUtils;
+import android.util.Log;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -40,6 +42,8 @@
public class DefaultAutofillPicker extends DefaultAppPickerFragment {
+ private static final String TAG = "DefaultAutofillPicker";
+
static final String SETTING = Settings.Secure.AUTOFILL_SERVICE;
static final Intent AUTOFILL_PROBE = new Intent(AutofillService.SERVICE_INTERFACE);
@@ -89,8 +93,13 @@
final List<ResolveInfo> resolveInfos = mPm.getPackageManager()
.queryIntentServices(AUTOFILL_PROBE, PackageManager.GET_META_DATA);
for (ResolveInfo info : resolveInfos) {
- candidates.add(new DefaultAppInfo(mPm, mUserId, new ComponentName(
- info.serviceInfo.packageName, info.serviceInfo.name)));
+ final String permission = info.serviceInfo.permission;
+ // TODO(b/37563972): remove BIND_AUTOFILL once clients use BIND_AUTOFILL_SERVICE
+ if (Manifest.permission.BIND_AUTOFILL_SERVICE.equals(permission)
+ || Manifest.permission.BIND_AUTOFILL.equals(permission)) {
+ candidates.add(new DefaultAppInfo(mPm, mUserId, new ComponentName(
+ info.serviceInfo.packageName, info.serviceInfo.name)));
+ }
}
return candidates;
}
@@ -157,9 +166,15 @@
final String flattenKey = new ComponentName(
serviceInfo.packageName, serviceInfo.name).flattenToString();
if (TextUtils.equals(mSelectedKey, flattenKey)) {
- final String settingsActivity = new AutofillServiceInfo(
- mPackageManager, serviceInfo)
- .getSettingsActivity();
+ final String settingsActivity;
+ try {
+ settingsActivity = new AutofillServiceInfo(mPackageManager, serviceInfo)
+ .getSettingsActivity();
+ } catch (SecurityException e) {
+ // Service does not declare the proper permission, ignore it.
+ Log.w(TAG, "Error getting info for " + serviceInfo + ": " + e);
+ return null;
+ }
if (TextUtils.isEmpty(settingsActivity)) {
return null;
}
diff --git a/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java b/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
new file mode 100644
index 0000000..8e0f922
--- /dev/null
+++ b/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 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.backup;
+
+import android.app.backup.BackupManager;
+import android.content.Context;
+import android.os.Build;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.PreferenceController;
+
+public class BackupSettingsActivityPreferenceController extends PreferenceController {
+ private static final String KEY_BACKUP_SETTINGS = "backup_settings";
+ private static final String TAG = "BackupSettingActivityPC" ;
+
+ private final UserManager mUm;
+ private final BackupManager mBackupManager;
+
+ public BackupSettingsActivityPreferenceController(Context context) {
+ super(context);
+ mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ mBackupManager = new BackupManager(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mUm.isAdminUser();
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_BACKUP_SETTINGS;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final boolean backupEnabled = mBackupManager.isBackupEnabled();
+
+ preference.setSummary(backupEnabled
+ ? R.string.accessibility_feature_state_on
+ : R.string.accessibility_feature_state_off);
+ }
+}
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index aeb7efb..6a1c06c 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -96,9 +96,7 @@
keys.add(NfcPreferenceController.KEY_TOGGLE_NFC);
keys.add(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS);
}
- if (!pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
- keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
- }
+ keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
return keys;
}
};
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index 8eb1f61..16172bd 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -75,6 +75,7 @@
private static final String KEY_LIMIT_SUMMARY = "limit_summary";
private static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
private static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
+ private static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
private DataUsageController mDataUsageController;
private DataUsageInfoController mDataInfoController;
@@ -491,6 +492,7 @@
if (hasMobileData) {
keys.add(KEY_RESTRICT_BACKGROUND);
}
+ keys.add(KEY_WIFI_USAGE_TITLE);
return keys;
}
diff --git a/src/com/android/settings/language/TtsPreferenceController.java b/src/com/android/settings/language/TtsPreferenceController.java
index 9b40b6d..0d1c753 100644
--- a/src/com/android/settings/language/TtsPreferenceController.java
+++ b/src/com/android/settings/language/TtsPreferenceController.java
@@ -18,14 +18,11 @@
import android.content.Context;
import android.speech.tts.TtsEngines;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceController;
public class TtsPreferenceController extends PreferenceController {
- private static final String KEY_VOICE_CATEGORY = "voice_category";
private static final String KEY_TTS_SETTINGS = "tts_settings";
private final TtsEngines mTtsEngines;
@@ -41,14 +38,6 @@
}
@Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- if (!isAvailable()) {
- removePreference(screen, KEY_VOICE_CATEGORY);
- }
- }
-
- @Override
public String getPreferenceKey() {
return KEY_TTS_SETTINGS;
}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index a0ccf20..a28a726 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -142,5 +142,13 @@
sir.xmlResId = R.xml.network_and_internet;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ List<String> keys = new ArrayList<>();
+ // Remove master switch as a result
+ keys.add(WifiMasterSwitchPreferenceController.KEY_TOGGLE_WIFI);
+ return keys;
+ }
};
}
diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java
index 76ac4a6..4c4ed21 100644
--- a/src/com/android/settings/system/SystemDashboardFragment.java
+++ b/src/com/android/settings/system/SystemDashboardFragment.java
@@ -21,6 +21,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
+import com.android.settings.backup.BackupSettingsActivityPreferenceController;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
@@ -60,6 +61,7 @@
final List<PreferenceController> controllers = new ArrayList<>();
controllers.add(new SystemUpdatePreferenceController(context, UserManager.get(context)));
controllers.add(new AdditionalSystemUpdatePreferenceController(context));
+ controllers.add(new BackupSettingsActivityPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index fe2bbb3..5fb6500 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -403,12 +403,13 @@
&& ((mAccessPointSecurity == AccessPoint.SECURITY_WEP
&& mPasswordView.length() == 0)
|| (mAccessPointSecurity == AccessPoint.SECURITY_PSK
- && mPasswordView.length() < 8))) {
+ && (mPasswordView.length() < 8 || mPasswordView.length() > 63)))) {
passwordInvalid = true;
}
-
if ((mSsidView != null && mSsidView.length() == 0)
- || ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid)) {
+ || ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid
+ // If AccessPoint is saved (we're modifying it), allow zero length (unchanged) pw
+ || mAccessPoint.isSaved() && passwordInvalid && mPasswordView.length() > 0)) {
enabled = false;
} else {
enabled = ipAndProxyFieldsAreValid();
diff --git a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
index d72bb3e..09b3331 100644
--- a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
@@ -33,7 +33,7 @@
implements SummaryUpdater.OnSummaryChangeListener,
LifecycleObserver, OnResume, OnPause, OnStart, OnStop {
- private static final String KEY_TOGGLE_WIFI = "toggle_wifi";
+ public static final String KEY_TOGGLE_WIFI = "toggle_wifi";
private MasterSwitchPreference mWifiPreference;
private WifiEnabler mWifiEnabler;
diff --git a/tests/app/src/com/android/settings/EncryptionInterstitialTest.java b/tests/app/src/com/android/settings/EncryptionInterstitialTest.java
index f30d511..eb61b00 100644
--- a/tests/app/src/com/android/settings/EncryptionInterstitialTest.java
+++ b/tests/app/src/com/android/settings/EncryptionInterstitialTest.java
@@ -93,7 +93,7 @@
Intent mMatchedIntent = null;
@Override
- public ActivityResult onMatchIntent(Intent intent) {
+ public ActivityResult onStartActivity(Intent intent) {
if ("test.unlock.intent".equals(intent.getAction())) {
mMatchedIntent = intent;
return new ActivityResult(Activity.RESULT_OK, null);
diff --git a/tests/robotests/src/com/android/settings/SettingsRobolectricTestRunner.java b/tests/robotests/src/com/android/settings/SettingsRobolectricTestRunner.java
index e063f88..a991e7a 100644
--- a/tests/robotests/src/com/android/settings/SettingsRobolectricTestRunner.java
+++ b/tests/robotests/src/com/android/settings/SettingsRobolectricTestRunner.java
@@ -83,11 +83,11 @@
null));
paths.add(new ResourcePath(
getPackageName(),
- Fs.fileFromPath("./frameworks/opt/setupwizard/library/gingerbread/res"),
+ Fs.fileFromPath("./frameworks/opt/setupwizard/library/eclair-mr1/res"),
null));
paths.add(new ResourcePath(
getPackageName(),
- Fs.fileFromPath("./frameworks/opt/setupwizard/library/recyclerview/res"),
+ Fs.fileFromPath("./frameworks/opt/setupwizard/library/full-support/res"),
null));
paths.add(new ResourcePath(
getPackageName(),
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index 6cf4a59..17910bf 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -31,6 +31,7 @@
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -378,4 +379,13 @@
verify(mockPreferenceScreen, times(1))
.removePreference(mockAppDomainsPref);
}
+
+ @Test
+ public void onActivityResult_uninstalledUpdates_shouldInvalidateOptionsMenu() {
+ doReturn(true).when(mAppDetail).refreshUi();
+
+ mAppDetail.onActivityResult(InstalledAppDetails.REQUEST_UNINSTALL, 0, mock(Intent.class));
+
+ verify(mActivity).invalidateOptionsMenu();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
new file mode 100644
index 0000000..44ca9f7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 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 static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.datausage.DataSaverBackend;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class SpecialAppAccessPreferenceControllerTest {
+ private Context mContext;
+ @Mock
+ private DataSaverBackend mBackend;
+ @Mock
+ private Preference mPreference;
+
+ private SpecialAppAccessPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new SpecialAppAccessPreferenceController(mContext);
+ ReflectionHelpers.setField(mController, "mDataSaverBackend", mBackend);
+ }
+
+ @Test
+ public void isAvailable_shouldAlwaysReturnTrue() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void updateState_shouldSetSummary() {
+ when(mBackend.getWhitelistedCount()).thenReturn(0);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary(mContext.getResources().getQuantityString(
+ R.plurals.special_access_summary, 0, 0));
+
+ when(mBackend.getWhitelistedCount()).thenReturn(1);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary(mContext.getResources().getQuantityString(
+ R.plurals.special_access_summary, 1, 1));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
new file mode 100644
index 0000000..a58b67d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2017 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.backup;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.accounts.AccountManager;
+import android.app.backup.BackupManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.RemoteException;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+ shadows = {BackupSettingsActivityPreferenceControllerTest.ShadowBackupManager.class})
+public class BackupSettingsActivityPreferenceControllerTest {
+ private static final String KEY_BACKUP_SETTINGS = "backup_settings";
+
+ private Context mContext;
+ @Mock
+ private UserManager mUserManager;
+
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private Preference mBackupPreference;
+
+ private BackupSettingsActivityPreferenceController mController;
+
+ private static boolean mBackupEnabled;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+
+ mController = new BackupSettingsActivityPreferenceController(mContext);
+ }
+
+ @Test
+ public void updateState_backupOn() throws RemoteException {
+ mBackupEnabled = true;
+
+ mController.updateState(mBackupPreference);
+
+ verify(mBackupPreference).setSummary(R.string.accessibility_feature_state_on);
+ }
+
+ @Test
+ public void updateState_backupOff() throws RemoteException {
+ mBackupEnabled = false;
+
+ mController.updateState(mBackupPreference);
+
+ verify(mBackupPreference).setSummary(R.string.accessibility_feature_state_off);
+ }
+
+ @Test
+ public void isAvailable_systemUser() {
+ when(mUserManager.isAdminUser()).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_nonSystemUser() {
+ when(mUserManager.isAdminUser()).thenReturn(false);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void getPreferenceKey() {
+ assertThat(mController.getPreferenceKey()).isEqualTo(KEY_BACKUP_SETTINGS);
+ }
+
+ @Implements(BackupManager.class)
+ public static class ShadowBackupManager {
+
+ @Implementation
+ public boolean isBackupEnabled() {
+ return mBackupEnabled;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
index a4b5c97..e792845 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
@@ -23,6 +23,7 @@
import com.android.settings.nfc.NfcPreferenceController;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.XmlTestUtils;
import com.android.settingslib.drawer.CategoryKey;
import org.junit.Before;
@@ -30,13 +31,12 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -92,20 +92,15 @@
}
@Test
- public void testSearchIndexProvider_NoBluetooth_KeyAdded() {
- when(mManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(false);
- final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+ public void testNonIndexableKeys_existInXmlLayout() {
+ final Context context = RuntimeEnvironment.application;
+ when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(false);
+ final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(context);
+ final int xmlId = (new ConnectedDeviceDashboardFragment()).getPreferenceScreenResId();
- assertThat(keys).isNotNull();
- assertThat(keys).contains(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
- }
+ final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
- @Test
- public void testSearchIndexProvider_Bluetooth_KeyNotAdded() {
- when(mManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(true);
- final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
-
- assertThat(keys).isNotNull();
- assertThat(keys).doesNotContain(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
+ assertThat(keys).containsAllIn(niks);
}
}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
index 71d9ea1..e1572ab 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
@@ -25,6 +25,8 @@
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
+import com.android.settings.testutils.XmlTestUtils;
import com.android.settingslib.NetworkPolicyEditor;
import org.junit.Before;
@@ -32,11 +34,13 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
+import java.util.List;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
@@ -143,4 +147,17 @@
policy.metered = false;
assertThat(dataUsageSummary.isMetered(config)).isFalse();
}
+
+ @Test
+ public void testNonIndexableKeys_existInXmlLayout() {
+ final Context context = RuntimeEnvironment.application;
+ final List<String> niks = DataUsageSummary.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(context);
+ final List<String> keys = new ArrayList<>();
+
+ keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.data_usage_wifi));
+ keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.data_usage));
+
+ assertThat(keys).containsAllIn(niks);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/language/TtsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/TtsPreferenceControllerTest.java
index 31a3f07..4908b49 100644
--- a/tests/robotests/src/com/android/settings/language/TtsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/language/TtsPreferenceControllerTest.java
@@ -38,9 +38,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -94,7 +92,7 @@
mController.displayPreference(mScreen);
- // Remove both category and preference.
- verify(mScreen, times(2)).removePreference(any(Preference.class));
+ // Remove preference.
+ verify(mScreen).removePreference(any(Preference.class));
}
}
diff --git a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
index 2201c68..d1c3207 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
@@ -15,16 +15,20 @@
*/
package com.android.settings.network;
+import android.content.Context;
import android.provider.SearchIndexableResource;
import android.view.Menu;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
+import com.android.settings.testutils.XmlTestUtils;
import com.android.settingslib.drawer.CategoryKey;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
@@ -74,4 +78,15 @@
verify(resetController).buildMenuItem(any(Menu.class));
}
+ @Test
+ public void testNonIndexableKeys_existInXmlLayout() {
+ final Context context = RuntimeEnvironment.application;
+ final List<String> niks = NetworkDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(context);
+ final int xmlId = (new NetworkDashboardFragment()).getPreferenceScreenResId();
+
+ final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
+
+ assertThat(keys).containsAllIn(niks);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java b/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
index 6a34472..6175093 100644
--- a/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
+++ b/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
@@ -125,7 +125,7 @@
"key_user_dictionary_settings", "gesture_settings_category", "gesture_assist",
"gesture_swipe_down_fingerprint", "gesture_double_tap_power",
"gesture_double_twist", "gesture_double_tap_screen", "gesture_pick_up",
- "pointer_settings_category", "pointer_speed", "voice_category", "tts_settings",
+ "pointer_speed", "tts_settings",
"game_controller_settings_category", "vibrate_input_devices");
}
diff --git a/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java b/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java
index 20b3f89..f9d5439 100644
--- a/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/XmlTestUtils.java
@@ -53,5 +53,4 @@
return keys;
}
-
-}
+}
\ No newline at end of file