Merge "Add number of enterprise-installed apps to Privacy Settings page"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b04182f2..ed511ef 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -277,6 +277,27 @@
android:value="true" />
</activity>
+ <activity android:name="Settings$ConfigureWifiSettingsActivity"
+ android:taskAffinity="com.android.settings"
+ android:label="@string/wifi_configure_titlebar"
+ android:icon="@drawable/ic_settings_wireless"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:parentActivityName="Settings$WifiSettingsActivity">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.CONFIGURE_WIFI_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.VOICE_LAUNCH" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.wifi.ConfigureWifiSettings" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
<activity android:name="Settings$AdvancedWifiSettingsActivity"
android:taskAffinity="com.android.settings"
android:label="@string/wifi_advanced_settings_label"
@@ -3032,7 +3053,7 @@
<activity android:name=".Settings$ConnectedDeviceDashboardActivity"
android:label="@string/connected_devices_dashboard_title"
- android:icon="@drawable/ic_bt_laptop">
+ android:icon="@drawable/ic_devices_other">
<intent-filter android:priority="10">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3044,7 +3065,7 @@
<activity android:name=".Settings$AppAndNotificationDashboardActivity"
android:label="@string/app_and_notification_dashboard_title"
- android:icon="@drawable/ic_settings_applications">
+ android:icon="@drawable/ic_apps">
<intent-filter android:priority="9">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3100,7 +3121,7 @@
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.homepage" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.deviceinfo.StorageDashboardFragment" />
+ android:value="com.android.settings.deviceinfo.StorageSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
@@ -3170,7 +3191,7 @@
<activity android:name=".Settings$SupportDashboardActivity"
android:label="@string/page_tab_title_support"
- android:icon="@drawable/ic_support_24dp">
+ android:icon="@drawable/ic_help">
<intent-filter android:priority="0">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3338,7 +3359,8 @@
</activity-alias>
<activity-alias android:name="AppNotificationDashboardAlias"
- android:targetActivity="Settings$NotificationAppListActivity">
+ android:targetActivity="Settings$NotificationAppListActivity"
+ android:icon="@drawable/ic_notifications">
<intent-filter android:priority="150">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3346,6 +3368,7 @@
android:value="com.android.settings.category.ia.apps"/>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.NotificationApps"/>
+
</activity-alias>
<activity-alias android:name="ConfigureNotificationDashboardAlias"
@@ -3375,7 +3398,7 @@
<activity-alias android:name="AppDefaultDashboardAlias"
android:targetActivity="Settings$AdvancedAppsActivity"
android:label="@string/app_default_dashboard_title"
- android:icon="@drawable/ic_settings_applications">
+ android:icon="@drawable/ic_adb">
<intent-filter android:priority="130">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
diff --git a/res/drawable/ic_adb.xml b/res/drawable/ic_adb.xml
new file mode 100644
index 0000000..af28aa1
--- /dev/null
+++ b/res/drawable/ic_adb.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M5,16c0,3.87 3.13,7 7,7s7,-3.13 7,-7v-4L5,12v4zM16.12,4.37l2.1,-2.1 -0.82,-0.83 -2.3,2.31C14.16,3.28 13.12,3 12,3s-2.16,0.28 -3.09,0.75L6.6,1.44l-0.82,0.83 2.1,2.1C6.14,5.64 5,7.68 5,10v1h14v-1c0,-2.32 -1.14,-4.36 -2.88,-5.63zM9,9c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM15,9c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_airplanemode_active.xml b/res/drawable/ic_airplanemode_active.xml
new file mode 100644
index 0000000..5759341
--- /dev/null
+++ b/res/drawable/ic_airplanemode_active.xml
@@ -0,0 +1,28 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M10.18,9"
+ android:fillColor="#FFFFFFFF"/>
+ <path
+ android:pathData="M21,16v-2l-8,-5V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5V9l-8,5v2l8,-2.5V19l-2,1.5V22l3.5,-1 3.5,1v-1.5L13,19v-5.5l8,2.5z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_android.xml b/res/drawable/ic_android.xml
new file mode 100644
index 0000000..b9b4075
--- /dev/null
+++ b/res/drawable/ic_android.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_devices_other.xml b/res/drawable/ic_devices_other.xml
new file mode 100644
index 0000000..20639a3
--- /dev/null
+++ b/res/drawable/ic_devices_other.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M3,6h18L21,4L3,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h4v-2L3,18L3,6zM13,12L9,12v1.78c-0.61,0.55 -1,1.33 -1,2.22s0.39,1.67 1,2.22L9,20h4v-1.78c0.61,-0.55 1,-1.34 1,-2.22s-0.39,-1.67 -1,-2.22L13,12zM11,17.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM22,8h-6c-0.5,0 -1,0.5 -1,1v10c0,0.5 0.5,1 1,1h6c0.5,0 1,-0.5 1,-1L23,9c0,-0.5 -0.5,-1 -1,-1zM21,18h-4v-8h4v8z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_help.xml b/res/drawable/ic_help.xml
new file mode 100644
index 0000000..7a225e5
--- /dev/null
+++ b/res/drawable/ic_help.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_network_cell.xml b/res/drawable/ic_network_cell.xml
new file mode 100644
index 0000000..cc3c633
--- /dev/null
+++ b/res/drawable/ic_network_cell.xml
@@ -0,0 +1,29 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M2,22h20V2z"
+ android:fillAlpha=".3"
+ android:fillColor="#FFFFFFFF"/>
+ <path
+ android:pathData="M17,7L2,22h15z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_nfc.xml b/res/drawable/ic_nfc.xml
new file mode 100644
index 0000000..d9321ac
--- /dev/null
+++ b/res/drawable/ic_nfc.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,20L4,20L4,4h16v16zM18,6h-5c-1.1,0 -2,0.9 -2,2v2.28c-0.6,0.35 -1,0.98 -1,1.72 0,1.1 0.9,2 2,2s2,-0.9 2,-2c0,-0.74 -0.4,-1.38 -1,-1.72L13,8h3v8L8,16L8,8h2L10,6L6,6v12h12L18,6z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_notifications.xml b/res/drawable/ic_notifications.xml
new file mode 100644
index 0000000..ec2422d
--- /dev/null
+++ b/res/drawable/ic_notifications.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_settings_backup_restore.xml b/res/drawable/ic_settings_backup_restore.xml
new file mode 100644
index 0000000..245b0fc
--- /dev/null
+++ b/res/drawable/ic_settings_backup_restore.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M14,12c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2 0.9,2 2,2 2,-0.9 2,-2zM12,3c-4.97,0 -9,4.03 -9,9L0,12l4,4 4,-4L5,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.51,0 -2.91,-0.49 -4.06,-1.3l-1.42,1.44C8.04,20.3 9.94,21 12,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_usb.xml b/res/drawable/ic_usb.xml
new file mode 100644
index 0000000..8b9f759
--- /dev/null
+++ b/res/drawable/ic_usb.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M15,7v4h1v2h-3V5h2l-3,-4 -3,4h2v8H8v-2.07c0.7,-0.37 1.2,-1.08 1.2,-1.93 0,-1.21 -0.99,-2.2 -2.2,-2.2 -1.21,0 -2.2,0.99 -2.2,2.2 0,0.85 0.5,1.56 1.2,1.93V13c0,1.11 0.89,2 2,2h3v3.05c-0.71,0.37 -1.2,1.1 -1.2,1.95 0,1.22 0.99,2.2 2.2,2.2 1.21,0 2.2,-0.98 2.2,-2.2 0,-0.85 -0.49,-1.58 -1.2,-1.95V15h3c1.11,0 2,-0.89 2,-2v-2h1V7h-4z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_vpn_key.xml b/res/drawable/ic_vpn_key.xml
new file mode 100644
index 0000000..aad1096
--- /dev/null
+++ b/res/drawable/ic_vpn_key.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/drawable/ic_wifi_tethering.xml b/res/drawable/ic_wifi_tethering.xml
new file mode 100644
index 0000000..359da5f
--- /dev/null
+++ b/res/drawable/ic_wifi_tethering.xml
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M12,11c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,13c0,-3.31 -2.69,-6 -6,-6s-6,2.69 -6,6c0,2.22 1.21,4.15 3,5.19l1,-1.74c-1.19,-0.7 -2,-1.97 -2,-3.45 0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,1.48 -0.81,2.75 -2,3.45l1,1.74c1.79,-1.04 3,-2.97 3,-5.19zM12,3C6.48,3 2,7.48 2,13c0,3.7 2.01,6.92 4.99,8.65l1,-1.73C5.61,18.53 4,15.96 4,13c0,-4.42 3.58,-8 8,-8s8,3.58 8,8c0,2.96 -1.61,5.53 -4,6.92l1,1.73c2.99,-1.73 5,-4.95 5,-8.65 0,-5.52 -4.48,-10 -10,-10z"
+ android:fillColor="#FFFFFFFF"/>
+</vector>
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index d9ead9c..eadb6e5 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -15,60 +15,73 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:background="?android:attr/selectableItemBackground">
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/selectableItemBackground"
+ android:gravity="center_vertical"
+ android:orientation="horizontal" >
- <LinearLayout android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:minHeight="?android:attr/listPreferredItemHeightSmall"
- android:gravity="center_vertical"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
- android:paddingEnd="@dimen/storage_summary_padding_end"
- android:paddingTop="16dip"
- android:paddingBottom="16dip"
- android:enabled="false">
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:enabled="false"
+ android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:orientation="vertical"
+ android:paddingStart="@dimen/preference_no_icon_padding_start"
+ android:paddingEnd="@dimen/storage_summary_padding_end"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp" >
<TextView
android:id="@android:id/title"
- android:layout_width="wrap_content"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAlignment="viewStart"
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
android:textColor="?android:attr/colorAccent"
- android:textSize="36sp"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
+ android:textSize="36sp" />
<TextView
android:id="@android:id/summary"
- android:layout_marginStart="4dp"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginStart="4dp"
+ android:layout_marginEnd="4dp"
+ android:maxLines="10"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:maxLines="10" />
+ android:textAppearance="@android:style/TextAppearance.Material.Body1" />
+
+ <TextView
+ android:id="@+id/storage_manager_indicator"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="4dp"
+ android:layout_marginEnd="4dp"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"/>
<Button
android:id="@+id/deletion_helper_button"
- android:theme="@style/FreeUpStorageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/summary"
- android:text="@string/storage_menu_free"/>
+ android:text="@string/storage_menu_free"
+ style="@android:style/@Widget.Material.Button.Colored" />
</LinearLayout>
<com.android.settings.widget.DonutView
android:id="@+id/donut"
android:layout_width="100dp"
android:layout_height="100dp"
+ android:layout_marginEnd="48dp"
+ android:gravity="end|center_vertical"
+ android:minWidth="58dp"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:minWidth="58dip"
- android:gravity="end|center_vertical"/>
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" />
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cae4351..5038177 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1582,9 +1582,13 @@
<!-- Toast message when Wi-Fi or bluetooth is disallowed in airplane mode -->
<string name="wifi_in_airplane_mode">In Airplane mode</string>
<!-- Checkbox title for option to notify user when open networks are nearby -->
- <string name="wifi_notify_open_networks">Network notification</string>
+ <string name="wifi_notify_open_networks">Open network notification</string>
<!-- Checkbox summary for option to notify user when open networks are nearby [CHAR LIMIT=60]-->
- <string name="wifi_notify_open_networks_summary">Notify whenever a public network is available</string>
+ <string name="wifi_notify_open_networks_summary">Notify whenever a high quality open network is available</string>
+ <!-- Checkbox title for option to enable Wi-Fi when saved networks are nearby -->
+ <string name="wifi_wakeup">Turn Wi\u2011Fi back on</string>
+ <!-- Checkbox summary for option to enable Wi-Fi when saved networks are nearby [CHAR LIMIT=60]-->
+ <string name="wifi_wakeup_summary">Automatically turn on Wi\u2011Fi near saved networks</string>
<!-- Checkbox title for option to toggle poor network detection -->
<string name="wifi_poor_network_detection">Avoid poor connections</string>
<!-- Checkbox summary for option to toggle poor network detection -->
@@ -8042,4 +8046,13 @@
<!-- The percent of storage used by a storage volume. Exposed inside of a donut graph. [CHAR LIMIT=4]-->
<string name="storage_percent_used"><xliff:g id="percent" example="50%">%1$s</xliff:g>%%</string>
+ <!-- Indicates if the automatic storage manager is enabled or not. [CHAR_LIMIT=40] -->
+ <string name="storage_manager_indicator">Storage Manager: <xliff:g id="status" example="on">^1</xliff:g></string>
+
+ <!-- Off status for the automatic storage manager. [CHAR_LIMIT=10] -->
+ <string name="storage_manager_indicator_off">Off</string>
+
+ <!-- On status for the automatic storage manager. [CHAR_LIMIT=10] -->
+ <string name="storage_manager_indicator_on">On</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a4a679b..29cb390 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -438,9 +438,4 @@
<style name="AppActionPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
- <style name="FreeUpStorageButton">
- <item name="android:buttonStyle">@android:style/Widget.Material.Button</item>
- <item name="android:colorButtonNormal">#fff</item>
- </style>
-
</resources>
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index 188fd86..abf493f 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -21,6 +21,7 @@
<SwitchPreference
android:key="toggle_nfc"
android:title="@string/nfc_quick_toggle_title"
+ android:icon="@drawable/ic_nfc"
android:summary="@string/nfc_quick_toggle_summary"
android:order="-5"/>
@@ -28,11 +29,13 @@
android:fragment="com.android.settings.nfc.AndroidBeam"
android:key="android_beam_settings"
android:title="@string/android_beam_settings_title"
+ android:icon="@drawable/ic_android"
android:order="-4"/>
<Preference
android:key="usb_mode"
android:title="@string/usb_pref"
+ android:icon="@drawable/ic_usb"
android:order="-3">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
diff --git a/res/xml/location_mode.xml b/res/xml/location_mode.xml
index b1b05bb..e6dc067 100644
--- a/res/xml/location_mode.xml
+++ b/res/xml/location_mode.xml
@@ -17,15 +17,15 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/location_mode_screen_title">
- <com.android.settings.location.RadioButtonPreference
+ <com.android.settings.widget.RadioButtonPreference
android:key="high_accuracy"
android:title="@string/location_mode_high_accuracy_title"
android:summary="@string/location_mode_high_accuracy_description" />
- <com.android.settings.location.RadioButtonPreference
+ <com.android.settings.widget.RadioButtonPreference
android:key="battery_saving"
android:title="@string/location_mode_battery_saving_title"
android:summary="@string/location_mode_battery_saving_description" />
- <com.android.settings.location.RadioButtonPreference
+ <com.android.settings.widget.RadioButtonPreference
android:key="sensors_only"
android:title="@string/location_mode_sensors_only_title"
android:summary="@string/location_mode_sensors_only_description" />
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index 2dfb1cc..dc2efd8 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -22,12 +22,14 @@
<SwitchPreference
android:key="toggle_airplane"
android:title="@string/airplane_mode"
+ android:icon="@drawable/ic_airplanemode_active"
android:disableDependentsState="true"
android:order="-30"/>
<com.android.settingslib.RestrictedPreference
android:key="mobile_network_settings"
android:title="@string/network_settings_title"
+ android:icon="@drawable/ic_network_cell"
android:dependency="toggle_airplane"
android:order="-15"
settings:keywords="@string/keywords_more_mobile_networks"
@@ -43,6 +45,7 @@
android:fragment="com.android.settings.TetherSettings"
android:key="tether_settings"
android:title="@string/tether_settings_title_all"
+ android:icon="@drawable/ic_wifi_tethering"
android:order="-5"
settings:userRestriction="no_config_tethering"
settings:useAdminDisabledSummary="true"/>
@@ -51,6 +54,7 @@
android:fragment="com.android.settings.vpn2.VpnSettings"
android:key="vpn_settings"
android:title="@string/vpn_settings_title"
+ android:icon="@drawable/ic_vpn_key"
android:order="0"
settings:userRestriction="no_config_vpn"
settings:useAdminDisabledSummary="true"/>
@@ -77,6 +81,7 @@
<com.android.settingslib.RestrictedPreference
android:key="network_reset"
android:title="@string/reset_network_title"
+ android:icon="@drawable/ic_settings_backup_restore"
settings:keywords="@string/keywords_network_reset"
android:fragment="com.android.settings.ResetNetwork"
settings:userRestriction="no_network_reset"
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 50287c3..f6d6310 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -36,11 +36,11 @@
android:title="@string/storage_other_apps">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
- android:key="pref_system"
- android:title="@string/storage_detail_system">
- </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
android:key="pref_files"
android:title="@string/storage_files">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
+ <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ android:key="pref_system"
+ android:title="@string/storage_detail_system">
+ </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 91df2fe..a43ea87 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -23,11 +23,6 @@
android:fragment="com.android.settings.wifi.SavedAccessPointsWifiSettings" />
<!-- android:dependency="enable_wifi" -->
- <SwitchPreference
- android:key="notify_open_networks"
- android:title="@string/wifi_notify_open_networks"
- android:summary="@string/wifi_notify_open_networks_summary" />
-
<ListPreference
android:key="sleep_policy"
android:title="@string/wifi_setting_sleep_policy_title"
@@ -40,6 +35,16 @@
android:summary="@string/networking_allow_recommendations_summary"/>
<SwitchPreference
+ android:key="notify_open_networks"
+ android:title="@string/wifi_notify_open_networks"
+ android:summary="@string/wifi_notify_open_networks_summary" />
+
+ <SwitchPreference
+ android:key="enable_wifi_wakeup"
+ android:title="@string/wifi_wakeup"
+ android:summary="@string/wifi_wakeup_summary" />
+
+ <SwitchPreference
android:key="wifi_cellular_data_fallback"
android:title="@string/wifi_cellular_data_fallback_title"
android:summary="@string/wifi_cellular_data_fallback_summary"/>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index d779f3e..97e53e5 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -94,6 +94,7 @@
public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
+ public static class ConfigureWifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class AdvancedWifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class SavedAccessPointsSettingsActivity extends SettingsActivity { /* empty */ }
public static class TextToSpeechSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 02610b7..38f6b1a 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -63,7 +63,6 @@
import static android.content.Intent.EXTRA_USER;
import static android.os.UserManager.DISALLOW_MODIFY_ACCOUNTS;
import static android.os.UserManager.DISALLOW_REMOVE_MANAGED_PROFILE;
-import static android.os.UserManager.DISALLOW_REMOVE_USER;
import static android.provider.Settings.EXTRA_AUTHORITIES;
public class AccountPreferenceController extends PreferenceController
@@ -405,7 +404,8 @@
}
private void updateAccountTypes(ProfileData profileData) {
- if (mParent.getPreferenceManager() == null) {
+ if (mParent.getPreferenceManager() == null
+ || profileData.preferenceGroup.getPreferenceManager() == null) {
// This could happen if activity is finishing
return;
}
diff --git a/src/com/android/settings/core/PreferenceController.java b/src/com/android/settings/core/PreferenceController.java
index 01c998a..002240d 100644
--- a/src/com/android/settings/core/PreferenceController.java
+++ b/src/com/android/settings/core/PreferenceController.java
@@ -16,56 +16,20 @@
package com.android.settings.core;
import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.search2.ResultPayload;
+import com.android.settingslib.core.AbstractPreferenceController;
import java.util.List;
/**
* A controller that manages event for preference.
*/
-public abstract class PreferenceController {
-
- protected final Context mContext;
+public abstract class PreferenceController extends AbstractPreferenceController {
public PreferenceController(Context context) {
- mContext = context;
- }
-
- /**
- * Displays preference in this controller.
- */
- public void displayPreference(PreferenceScreen screen) {
- if (isAvailable()) {
- if (this instanceof Preference.OnPreferenceChangeListener) {
- final Preference preference = screen.findPreference(getPreferenceKey());
- preference.setOnPreferenceChangeListener(
- (Preference.OnPreferenceChangeListener) this);
- }
- } else {
- removePreference(screen, getPreferenceKey());
- }
- }
-
- /**
- * Updates the current status of preference (summary, switch state, etc)
- */
- public void updateState(Preference preference) {
-
- }
-
- /**
- * Updates non-indexable keys for search provider.
- *
- * Called by SearchIndexProvider#getNonIndexableKeys
- */
- public void updateNonIndexableKeys(List<String> keys) {
- if (!isAvailable()) {
- keys.add(getPreferenceKey());
- }
+ super(context);
}
/**
@@ -77,36 +41,6 @@
}
/**
- * Returns true if preference is available (should be displayed)
- */
- public abstract boolean isAvailable();
-
- /**
- * Handles preference tree click
- *
- * @param preference the preference being clicked
- * @return true if click is handled
- */
- public boolean handlePreferenceTreeClick(Preference preference) {
- return false;
- }
-
- /**
- * Returns the key for this preference.
- */
- public abstract String getPreferenceKey();
-
- /**
- * Removes preference from screen.
- */
- protected final void removePreference(PreferenceScreen screen, String key) {
- Preference pref = screen.findPreference(key);
- if (pref != null) {
- screen.removePreference(pref);
- }
- }
-
- /**
* @return the {@link ResultPayload} corresponding to the search result type for the preference.
*/
public ResultPayload getResultPayload() {
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 637fcd5..682fa36 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -121,6 +121,7 @@
import com.android.settings.vpn2.VpnSettings;
import com.android.settings.wfd.WifiDisplaySettings;
import com.android.settings.wifi.AdvancedWifiSettings;
+import com.android.settings.wifi.ConfigureWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiAPITest;
import com.android.settings.wifi.WifiInfo;
@@ -136,6 +137,7 @@
public static final String[] ENTRY_FRAGMENTS = {
WirelessSettings.class.getName(),
WifiSettings.class.getName(),
+ ConfigureWifiSettings.class.getName(),
AdvancedWifiSettings.class.getName(),
SavedAccessPointsWifiSettings.class.getName(),
BluetoothSettings.class.getName(),
diff --git a/src/com/android/settings/datetime/AutoTimeZonePreferenceController.java b/src/com/android/settings/datetime/AutoTimeZonePreferenceController.java
index c70289b..b48e535 100644
--- a/src/com/android/settings/datetime/AutoTimeZonePreferenceController.java
+++ b/src/com/android/settings/datetime/AutoTimeZonePreferenceController.java
@@ -67,7 +67,7 @@
}
public boolean isEnabled() {
- return Settings.Global.getInt(mContext.getContentResolver(),
+ return isAvailable() && Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AUTO_TIME_ZONE, 0) > 0;
}
}
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index c9572b3..d05d088 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -62,7 +62,8 @@
// Initialize the storage sizes that we can quickly calc.
StorageManager sm = context.getSystemService(StorageManager.class);
- mVolume = sm.findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL);
+ String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
+ mVolume = sm.findVolumeById(volumeId);
if (!isVolumeValid()) {
getActivity().finish();
return;
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 5ee3983..53d4c85 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -235,9 +235,8 @@
// Only showing primary internal storage, so just shortcut
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
- PrivateVolumeSettings.setVolumeSize(args, sTotalInternalStorage);
Intent intent = Utils.onBuildStartFragmentIntent(getActivity(),
- PrivateVolumeSettings.class.getName(), args, null, R.string.apps_storage, null,
+ StorageDashboardFragment.class.getName(), args, null, R.string.apps_storage, null,
false);
intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
getActivity().startActivity(intent);
@@ -280,9 +279,7 @@
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
- PrivateVolumeSettings.setVolumeSize(args, PrivateStorageInfo.getTotalSize(vol,
- sTotalInternalStorage));
- startFragment(this, PrivateVolumeSettings.class.getCanonicalName(),
+ startFragment(this, StorageDashboardFragment.class.getCanonicalName(),
-1, 0, args);
return true;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
index 9e39034..12e76b2 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
@@ -18,17 +18,27 @@
import android.content.Context;
import android.content.Intent;
+import android.graphics.Typeface;
import android.os.storage.StorageManager;
+import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.TextPaint;
+import android.text.TextUtils;
+import android.text.style.StyleSpan;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.view.View;
import android.widget.Button;
+import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.widget.DonutView;
+import java.util.Locale;
+
/**
* StorageSummaryDonutPreference is a preference which summarizes the used and remaining storage left
* on a given storage volume. It is visualized with a donut graphing the % used.
@@ -68,6 +78,23 @@
if (deletionHelperButton != null) {
deletionHelperButton.setOnClickListener(this);
}
+
+ final TextView storageManagerText =
+ (TextView) view.findViewById(R.id.storage_manager_indicator);
+ if (storageManagerText != null) {
+ Context context = getContext();
+ final SpannableString templateSs = new SpannableString(
+ context.getString(R.string.storage_manager_indicator));
+ boolean isStorageManagerEnabled = Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
+ String value = isStorageManagerEnabled ?
+ context.getString(R.string.storage_manager_indicator_on) :
+ context.getString(R.string.storage_manager_indicator_off);
+ Locale locale = storageManagerText.getTextLocale();
+ final SpannableString ss = new SpannableString(value.toUpperCase(locale));
+ ss.setSpan(new BoldLinkSpan(), 0, value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ storageManagerText.setText(TextUtils.expandTemplate(templateSs, ss));
+ }
}
@Override
@@ -77,4 +104,16 @@
getContext().startActivity(intent);
}
}
+
+ private static class BoldLinkSpan extends StyleSpan {
+ public BoldLinkSpan() {
+ super(Typeface.BOLD);
+ }
+
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setColor(ds.linkColor);
+ }
+ }
}
diff --git a/src/com/android/settings/location/LocationMode.java b/src/com/android/settings/location/LocationMode.java
index e50a0d9..4ca098d 100644
--- a/src/com/android/settings/location/LocationMode.java
+++ b/src/com/android/settings/location/LocationMode.java
@@ -21,6 +21,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPreference;
/**
* A page with 3 radio buttons to choose the location mode.
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index 28861ca..95cdd94 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -57,6 +57,7 @@
import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.users.UserSettings;
import com.android.settings.wifi.AdvancedWifiSettings;
+import com.android.settings.wifi.ConfigureWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;
@@ -104,6 +105,7 @@
static {
// Wi-Fi
sRankMap.put(WifiSettings.class.getName(), RANK_WIFI);
+ sRankMap.put(ConfigureWifiSettings.class.getName(), RANK_WIFI);
sRankMap.put(AdvancedWifiSettings.class.getName(), RANK_WIFI);
sRankMap.put(SavedAccessPointsWifiSettings.class.getName(), RANK_WIFI);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 831244b..8a158cd 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -73,6 +73,7 @@
import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.users.UserSettings;
import com.android.settings.wifi.AdvancedWifiSettings;
+import com.android.settings.wifi.ConfigureWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;
@@ -97,10 +98,10 @@
static {
addIndex(WifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
addIndex(NetworkDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
- addIndex(AdvancedWifiSettings.class,
- R.xml.wifi_advanced_settings, R.drawable.ic_settings_wireless);
- addIndex(SavedAccessPointsWifiSettings.class,
- R.xml.wifi_display_saved_access_points, R.drawable.ic_settings_wireless);
+ addIndex(AdvancedWifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
+ addIndex(ConfigureWifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
+ addIndex(SavedAccessPointsWifiSettings.class, NO_DATA_RES_ID,
+ R.drawable.ic_settings_wireless);
addIndex(BluetoothSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_bluetooth);
addIndex(SimSettings.class, NO_DATA_RES_ID, R.drawable.ic_sim_sd);
addIndex(DataUsageSummary.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage);
diff --git a/src/com/android/settings/search2/InlineSwitchViewHolder.java b/src/com/android/settings/search2/InlineSwitchViewHolder.java
index 54d3523..ad99af8 100644
--- a/src/com/android/settings/search2/InlineSwitchViewHolder.java
+++ b/src/com/android/settings/search2/InlineSwitchViewHolder.java
@@ -17,14 +17,11 @@
package com.android.settings.search2;
-import android.app.Fragment;
-import android.util.Log;
+import android.content.Context;
import android.view.View;
-import android.view.ViewParent;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
-import android.content.Context;
import com.android.internal.widget.PreferenceImageView;
import com.android.settings.R;
@@ -52,7 +49,7 @@
}
@Override
- public void onBind(Fragment fragment, SearchResult result) {
+ public void onBind(SearchFragment fragment, SearchResult result) {
if (mContext == null) {
return;
}
@@ -62,6 +59,7 @@
switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ fragment.onSearchResultClicked();
payload.setSwitchValue(mContext, isChecked);
}
});
diff --git a/src/com/android/settings/search2/IntentSearchViewHolder.java b/src/com/android/settings/search2/IntentSearchViewHolder.java
index da3f724..c9952fa 100644
--- a/src/com/android/settings/search2/IntentSearchViewHolder.java
+++ b/src/com/android/settings/search2/IntentSearchViewHolder.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.search2;
-import android.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -40,7 +39,7 @@
}
@Override
- public void onBind(final Fragment fragment, final SearchResult result) {
+ public void onBind(final SearchFragment fragment, final SearchResult result) {
titleView.setText(result.title);
summaryView.setText(result.summary);
iconView.setImageDrawable(result.icon);
@@ -50,6 +49,7 @@
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ fragment.onSearchResultClicked();
fragment.startActivity(((IntentPayload) result.payload).intent);
}
});
diff --git a/src/com/android/settings/search2/SearchFragment.java b/src/com/android/settings/search2/SearchFragment.java
index 1a4e6dc..757a0e2 100644
--- a/src/com/android/settings/search2/SearchFragment.java
+++ b/src/com/android/settings/search2/SearchFragment.java
@@ -35,23 +35,33 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import java.util.List;
public class SearchFragment extends InstrumentedFragment implements
SearchView.OnQueryTextListener, LoaderManager.LoaderCallbacks<List<SearchResult>> {
+ private static final String TAG = "SearchFragment";
// State values
- static final String STATE_QUERY = "query";
+ private static final String STATE_QUERY = "state_query";
+ private static final String STATE_NEVER_ENTERED_QUERY = "state_never_entered_query";
+ private static final String STATE_RESULT_CLICK_COUNT = "state_result_click_count";
// Loader IDs
private static final int LOADER_ID_DATABASE = 0;
private static final int LOADER_ID_INSTALLED_APPS = 1;
- @VisibleForTesting
- String mQuery;
+ // Logging
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ static final String RESULT_CLICK_COUNT = "settings_search_result_click_count";
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ String mQuery;
+ private boolean mNeverEnteredQuery = true;
+ private int mResultClickCount;
+ private MetricsFeatureProvider mMetricsFeatureProvider;
private SearchFeatureProvider mSearchFeatureProvider;
private SearchResultsAdapter mSearchAdapter;
@@ -65,8 +75,8 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- mSearchFeatureProvider = FeatureFactory.getFactory(context)
- .getSearchFeatureProvider();
+ mSearchFeatureProvider = FeatureFactory.getFactory(context).getSearchFeatureProvider();
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
@@ -76,6 +86,8 @@
mSearchAdapter = new SearchResultsAdapter(this);
if (savedInstanceState != null) {
mQuery = savedInstanceState.getString(STATE_QUERY);
+ mNeverEnteredQuery = savedInstanceState.getBoolean(STATE_NEVER_ENTERED_QUERY);
+ mResultClickCount = savedInstanceState.getInt(STATE_RESULT_CLICK_COUNT);
final LoaderManager loaderManager = getLoaderManager();
loaderManager.initLoader(LOADER_ID_DATABASE, null, this);
loaderManager.initLoader(LOADER_ID_INSTALLED_APPS, null, this);
@@ -97,9 +109,24 @@
}
@Override
+ public void onStop() {
+ super.onStop();
+ final Activity activity = getActivity();
+ if (activity != null && activity.isFinishing()) {
+ mMetricsFeatureProvider.histogram(activity, RESULT_CLICK_COUNT, mResultClickCount);
+ if (mNeverEnteredQuery) {
+ mMetricsFeatureProvider.action(activity,
+ MetricsProto.MetricsEvent.ACTION_LEAVE_SEARCH_RESULT_WITHOUT_QUERY);
+ }
+ }
+ }
+
+ @Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(STATE_QUERY, mQuery);
+ outState.putBoolean(STATE_NEVER_ENTERED_QUERY, mNeverEnteredQuery);
+ outState.putInt(STATE_RESULT_CLICK_COUNT, mResultClickCount);
}
@Override
@@ -107,6 +134,8 @@
if (TextUtils.equals(query, mQuery)) {
return true;
}
+ mResultClickCount = 0;
+ mNeverEnteredQuery = false;
mQuery = query;
mSearchAdapter.clearResults();
@@ -147,6 +176,10 @@
public void onLoaderReset(Loader<List<SearchResult>> loader) {
}
+ public void onSearchResultClicked() {
+ mResultClickCount++;
+ }
+
private void restartLoaders() {
final LoaderManager loaderManager = getLoaderManager();
loaderManager.restartLoader(LOADER_ID_DATABASE, null /* args */, this /* callback */);
diff --git a/src/com/android/settings/search2/SearchViewHolder.java b/src/com/android/settings/search2/SearchViewHolder.java
index 45ceb38..315ec65 100644
--- a/src/com/android/settings/search2/SearchViewHolder.java
+++ b/src/com/android/settings/search2/SearchViewHolder.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.search2;
-import android.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@@ -30,5 +29,5 @@
super(view);
}
- public abstract void onBind(Fragment fragment, SearchResult result);
+ public abstract void onBind(SearchFragment fragment, SearchResult result);
}
\ No newline at end of file
diff --git a/src/com/android/settings/location/RadioButtonPreference.java b/src/com/android/settings/widget/RadioButtonPreference.java
similarity index 83%
rename from src/com/android/settings/location/RadioButtonPreference.java
rename to src/com/android/settings/widget/RadioButtonPreference.java
index 9135266..cf5921e 100644
--- a/src/com/android/settings/location/RadioButtonPreference.java
+++ b/src/com/android/settings/widget/RadioButtonPreference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Android Open Source Project
+ * 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.
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package com.android.settings.location;
+package com.android.settings.widget;
import android.content.Context;
+import android.support.v4.content.res.TypedArrayUtils;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
@@ -36,7 +37,7 @@
*/
public class RadioButtonPreference extends CheckBoxPreference {
public interface OnClickListener {
- public abstract void onRadioButtonClicked(RadioButtonPreference emiter);
+ void onRadioButtonClicked(RadioButtonPreference emiter);
}
private OnClickListener mListener = null;
@@ -47,14 +48,16 @@
}
public RadioButtonPreference(Context context, AttributeSet attrs) {
- this(context, attrs, com.android.internal.R.attr.checkBoxPreferenceStyle);
+ this(context, attrs, TypedArrayUtils.getAttr(context,
+ android.support.v7.preference.R.attr.preferenceStyle,
+ android.R.attr.preferenceStyle));
}
public RadioButtonPreference(Context context) {
this(context, null);
}
- void setOnClickListener(OnClickListener listener) {
+ public void setOnClickListener(OnClickListener listener) {
mListener = listener;
}
diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java
index 4727428..07c7ce3 100644
--- a/src/com/android/settings/wifi/AdvancedWifiSettings.java
+++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java
@@ -26,6 +26,7 @@
import android.net.wifi.WpsInfo;
import android.os.Bundle;
import android.os.UserManager;
+import android.provider.SearchIndexableResource;
import android.security.Credentials;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
@@ -35,7 +36,11 @@
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settingslib.RestrictedLockUtils;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+
+import java.util.Arrays;
+import java.util.List;
public class AdvancedWifiSettings extends RestrictedSettingsFragment {
private static final String TAG = "AdvancedWifiSettings";
@@ -166,4 +171,14 @@
}
}
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.wifi_advanced_settings;
+ return Arrays.asList(sir);
+ }
+ };
}
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index 98f68ee..6cbdb29 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -15,19 +15,23 @@
*/
package com.android.settings.wifi;
+import static android.content.Context.WIFI_SERVICE;
+
import android.content.Context;
import android.net.wifi.WifiManager;
+import android.provider.SearchIndexableResource;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-import static android.content.Context.WIFI_SERVICE;
-
public class ConfigureWifiSettings extends DashboardFragment {
private static final String TAG = "ConfigureWifiSettings";
@@ -61,10 +65,22 @@
final List<PreferenceController> controllers = new ArrayList<>();
controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), mWifiManager));
controllers.add(new SavedNetworkPreferenceController(context, mWifiManager));
- controllers.add(new NotifyOpenNetworksPreferenceController(context, mWifiManager));
controllers.add(new CellularFallbackPreferenceController(context));
controllers.add(new AllowRecommendationPreferenceController(context));
+ controllers.add(new NotifyOpenNetworksPreferenceController(context, getLifecycle()));
+ controllers.add(new WifiWakeupPreferenceController(context, getLifecycle()));
controllers.add(new WifiSleepPolicyPreferenceController(context));
return controllers;
}
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.wifi_configure_settings;
+ return Arrays.asList(sir);
+ }
+ };
}
diff --git a/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java b/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java
index df3aa26..8771da4 100644
--- a/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java
+++ b/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java
@@ -16,27 +16,56 @@
package com.android.settings.wifi;
+import android.content.ContentResolver;
import android.content.Context;
-import android.net.wifi.WifiManager;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnPause;
+import com.android.settings.core.lifecycle.events.OnResume;
/**
* {@link PreferenceController} that controls whether we should notify user when open network is
* available.
*/
-public class NotifyOpenNetworksPreferenceController extends PreferenceController {
+public class NotifyOpenNetworksPreferenceController extends PreferenceController implements
+ LifecycleObserver, OnResume, OnPause {
private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks";
- private final WifiManager mWifiManager;
+ private SettingObserver mSettingObserver;
- public NotifyOpenNetworksPreferenceController(Context context, WifiManager wifiManager) {
+ public NotifyOpenNetworksPreferenceController(Context context, Lifecycle lifecycle) {
super(context);
- mWifiManager = wifiManager;
+ lifecycle.addObserver(this);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mSettingObserver = new SettingObserver(screen.findPreference(KEY_NOTIFY_OPEN_NETWORKS));
+ }
+
+ @Override
+ public void onResume() {
+ if (mSettingObserver != null) {
+ mSettingObserver.register(mContext.getContentResolver(), true /* register */);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (mSettingObserver != null) {
+ mSettingObserver.register(mContext.getContentResolver(), false /* register */);
+ }
}
@Override
@@ -71,6 +100,35 @@
final SwitchPreference notifyOpenNetworks = (SwitchPreference) preference;
notifyOpenNetworks.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
- notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
+ notifyOpenNetworks.setEnabled(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1);
+ }
+
+ class SettingObserver extends ContentObserver {
+ private final Uri NETWORK_RECOMMENDATIONS_ENABLED_URI =
+ Settings.Global.getUriFor(Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED);
+
+ private final Preference mPreference;
+
+ public SettingObserver(Preference preference) {
+ super(new Handler());
+ mPreference = preference;
+ }
+
+ public void register(ContentResolver cr, boolean register) {
+ if (register) {
+ cr.registerContentObserver(NETWORK_RECOMMENDATIONS_ENABLED_URI, false, this);
+ } else {
+ cr.unregisterContentObserver(this);
+ }
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (NETWORK_RECOMMENDATIONS_ENABLED_URI.equals(uri)) {
+ updateState(mPreference);
+ }
+ }
}
}
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index a830dc0..1ec4380 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -21,6 +21,7 @@
import android.content.res.Resources;
import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.provider.SearchIndexableResource;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
@@ -37,6 +38,7 @@
import com.android.settingslib.wifi.WifiTracker;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -206,6 +208,14 @@
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.wifi_display_saved_access_points;
+ return Arrays.asList(sir);
+ }
+
+ @Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
final Resources res = context.getResources();
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
new file mode 100644
index 0000000..122e524
--- /dev/null
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -0,0 +1,133 @@
+/*
+ * 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.wifi;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnPause;
+import com.android.settings.core.lifecycle.events.OnResume;
+
+/**
+ * {@link PreferenceController} that controls whether the Wi-Fi Wakeup feature should be enabled.
+ */
+public class WifiWakeupPreferenceController extends PreferenceController implements
+ LifecycleObserver, OnResume, OnPause {
+
+ private static final String KEY_ENABLE_WIFI_WAKEUP = "enable_wifi_wakeup";
+ private SettingObserver mSettingObserver;
+
+ public WifiWakeupPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context);
+ lifecycle.addObserver(this);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mSettingObserver = new SettingObserver(screen.findPreference(KEY_ENABLE_WIFI_WAKEUP));
+ }
+
+ @Override
+ public void onResume() {
+ if (mSettingObserver != null) {
+ mSettingObserver.register(mContext.getContentResolver(), true /* register */);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (mSettingObserver != null) {
+ mSettingObserver.register(mContext.getContentResolver(), false /* register */);
+ }
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), KEY_ENABLE_WIFI_WAKEUP)) {
+ return false;
+ }
+ if (!(preference instanceof SwitchPreference)) {
+ return false;
+ }
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_WAKEUP_ENABLED,
+ ((SwitchPreference) preference).isChecked() ? 1 : 0);
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_ENABLE_WIFI_WAKEUP;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (!(preference instanceof SwitchPreference)) {
+ return;
+ }
+ final SwitchPreference enableWifiWakeup = (SwitchPreference) preference;
+ enableWifiWakeup.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1);
+ enableWifiWakeup.setEnabled(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1);
+ }
+
+ class SettingObserver extends ContentObserver {
+ private final Uri NETWORK_RECOMMENDATIONS_ENABLED_URI =
+ Settings.Global.getUriFor(Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED);
+
+ private final Preference mPreference;
+
+ public SettingObserver(Preference preference) {
+ super(new Handler());
+ mPreference = preference;
+ }
+
+ public void register(ContentResolver cr, boolean register) {
+ if (register) {
+ cr.registerContentObserver(NETWORK_RECOMMENDATIONS_ENABLED_URI, false, this);
+ } else {
+ cr.unregisterContentObserver(this);
+ }
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (NETWORK_RECOMMENDATIONS_ENABLED_URI.equals(uri)) {
+ updateState(mPreference);
+ }
+ }
+ }
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index ffaf615..05cd93b 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -2,5 +2,4 @@
com.android.settings.language.LanguageAndRegionSettings
com.android.settings.notification.ZenModePrioritySettings
com.android.settings.inputmethod.InputAndGestureSettings
-com.android.settings.accounts.AccountDetailDashboardFragment
-com.android.settings.wifi.ConfigureWifiSettings
\ No newline at end of file
+com.android.settings.accounts.AccountDetailDashboardFragment
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index 78d6698..87be756 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -25,6 +25,7 @@
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
+import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.AccessiblePreferenceCategory;
@@ -324,6 +325,7 @@
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(authDescs);
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
+ when(preferenceGroup.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn(
preferenceGroup);
diff --git a/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java
index e49b8b8..bf1fbb8 100644
--- a/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2016 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.os.Looper;
diff --git a/tests/robotests/src/com/android/settings/core/PreferenceControllerTest.java b/tests/robotests/src/com/android/settings/core/PreferenceControllerTest.java
deleted file mode 100644
index aaab183..0000000
--- a/tests/robotests/src/com/android/settings/core/PreferenceControllerTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2016 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.core;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-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.annotation.Config;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class PreferenceControllerTest {
-
- @Mock
- private Context mContext;
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private Preference mPreference;
-
- private TestPrefController mTestPrefController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mTestPrefController = new TestPrefController(mContext);
- }
-
- @Test
- public void removeExistingPref_shouldBeRemoved() {
- when(mScreen.findPreference(TestPrefController.KEY_PREF)).thenReturn(mPreference);
-
- mTestPrefController.removePreference(mScreen, TestPrefController.KEY_PREF);
-
- verify(mScreen).removePreference(mPreference);
- }
-
- @Test
- public void removeNonExistingPref_shouldNotRemoveAnything() {
- mTestPrefController.removePreference(mScreen, TestPrefController.KEY_PREF);
-
- verify(mScreen, never()).removePreference(any(Preference.class));
- }
-
- @Test
- public void displayPref_ifAvailable() {
- mTestPrefController.isAvailable = true;
-
- mTestPrefController.displayPreference(mScreen);
-
- verify(mScreen, never()).removePreference(any(Preference.class));
- }
-
- @Test
- public void doNotDisplayPref_ifNotAvailable() {
- when(mScreen.findPreference(TestPrefController.KEY_PREF)).thenReturn(mPreference);
- mTestPrefController.isAvailable = false;
-
- mTestPrefController.displayPreference(mScreen);
-
- verify(mScreen).removePreference(any(Preference.class));
- }
-
- private class TestPrefController extends PreferenceController {
- private static final String KEY_PREF = "test_pref";
- public boolean isAvailable;
-
- public TestPrefController(Context context) {
- super(context);
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- return false;
- }
-
- @Override
- public boolean isAvailable() {
- return isAvailable;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_PREF;
- }
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java
index cc8d84a..0ac0251 100644
--- a/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java
@@ -55,6 +55,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ ShadowApplication.getInstance().setSystemService(Context.CONNECTIVITY_SERVICE, mCm);
mContext = ShadowApplication.getInstance().getApplicationContext();
mPreference = new Preference(mContext);
when(mMockContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mCm);
@@ -88,6 +89,24 @@
}
@Test
+ public void isFromSUW_notEnable() {
+ mController = new AutoTimeZonePreferenceController(
+ mMockContext, null /* callback */, true /* isFromSUW */);
+
+ assertThat(mController.isEnabled()).isFalse();
+ }
+
+ @Test
+ public void isWifiOnly_notEnable() {
+ when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
+
+ mController = new AutoTimeZonePreferenceController(
+ mMockContext, null /* callback */, false /* isFromSUW */);
+
+ assertThat(mController.isEnabled()).isFalse();
+ }
+
+ @Test
public void testIsEnabled_shouldReadFromSettingsProvider() {
mController = new AutoTimeZonePreferenceController(
mContext, null /* callback */, false /* isFromSUW */);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
index 848616a..fa0851e 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
@@ -22,9 +22,14 @@
import android.content.Context;
import android.os.storage.VolumeInfo;
+import android.provider.Settings;
+import android.support.v7.preference.PreferenceViewHolder;
import android.view.LayoutInflater;
+import android.view.View;
import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -41,11 +46,10 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class StorageSummaryDonutPreferenceControllerTest {
- private static String KEY = "pref";
-
private Context mContext;
private StorageSummaryDonutPreferenceController mController;
private StorageSummaryDonutPreference mPreference;
+ private PreferenceViewHolder mHolder;
@Before
public void setUp() throws Exception {
@@ -54,7 +58,11 @@
mPreference = new StorageSummaryDonutPreference(mContext);
LayoutInflater inflater = LayoutInflater.from(mContext);
- inflater.inflate(mPreference.getLayoutResource(), new LinearLayout(mContext), false);
+ final View view =
+ inflater.inflate(
+ mPreference.getLayoutResource(), new LinearLayout(mContext), false);
+
+ mHolder = new PreferenceViewHolder(view);
}
@Test
@@ -91,4 +99,22 @@
assertThat(mPreference.getTitle().toString()).isEqualTo("9.00KB used");
assertThat(mPreference.getSummary().toString()).isEqualTo("1.00KB free");
}
+
+ @Test
+ public void testAutomaticStorageManagerLabelOff() throws Exception {
+ mPreference.onBindViewHolder(mHolder);
+ TextView asmTextView = (TextView) mHolder.findViewById(R.id.storage_manager_indicator);
+ assertThat(asmTextView.getText().toString()).isEqualTo("Storage Manager: OFF");
+ }
+
+ @Test
+ public void testAutomaticStorageManagerLabelOn() throws Exception {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 1);
+
+ mPreference.onBindViewHolder(mHolder);
+
+ TextView asmTextView = (TextView) mHolder.findViewById(R.id.storage_manager_indicator);
+ assertThat(asmTextView.getText().toString()).isEqualTo("Storage Manager: ON");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
index efbad2f..b8fe3fc 100644
--- a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
@@ -17,7 +17,6 @@
package com.android.settings.search;
-import android.app.Fragment;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
@@ -28,7 +27,7 @@
import com.android.settings.TestConfig;
import com.android.settings.search2.InlineSwitchPayload;
import com.android.settings.search2.InlineSwitchViewHolder;
-import com.android.settings.search2.IntentPayload;
+import com.android.settings.search2.SearchFragment;
import com.android.settings.search2.SearchResult;
import org.junit.Before;
@@ -53,7 +52,7 @@
private static final String SUMMARY = "summary";
@Mock
- private Fragment mFragment;
+ private SearchFragment mFragment;
@Mock
private InlineSwitchPayload mPayload;
@@ -97,7 +96,7 @@
.addSummary(SUMMARY)
.addRank(1)
.addPayload(new InlineSwitchPayload("", 0, null))
- .addBreadcrumbs(new ArrayList<String>())
+ .addBreadcrumbs(new ArrayList<>())
.addIcon(mIcon)
.addPayload(mPayload);
diff --git a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
index ed503d8..3874479 100644
--- a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
@@ -17,7 +17,6 @@
package com.android.settings.search;
-import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -29,6 +28,7 @@
import com.android.settings.TestConfig;
import com.android.settings.search2.IntentPayload;
import com.android.settings.search2.IntentSearchViewHolder;
+import com.android.settings.search2.SearchFragment;
import com.android.settings.search2.SearchResult;
import com.android.settings.search2.SearchResult.Builder;
@@ -54,7 +54,7 @@
private static final String SUMMARY = "summary";
@Mock
- private Fragment mFragment;
+ private SearchFragment mFragment;
private IntentSearchViewHolder mHolder;
private Drawable mIcon;
@@ -84,6 +84,8 @@
assertThat(mHolder.titleView.getText()).isEqualTo(TITLE);
assertThat(mHolder.summaryView.getText()).isEqualTo(SUMMARY);
assertThat(mHolder.iconView.getDrawable()).isEqualTo(mIcon);
+
+ verify(mFragment).onSearchResultClicked();
verify(mFragment).startActivity(any(Intent.class));
}
@@ -93,7 +95,7 @@
.addSummary(SUMMARY)
.addRank(1)
.addPayload(new IntentPayload(null))
- .addBreadcrumbs(new ArrayList<String>())
+ .addBreadcrumbs(new ArrayList<>())
.addIcon(mIcon);
return builder.build();
diff --git a/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java b/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java
index 40d1ae5..64d602e 100644
--- a/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.os.Bundle;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -36,6 +37,8 @@
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -97,7 +100,14 @@
.findFragmentById(R.id.main_content);
fragment.onQueryTextChange(testQuery);
+ activityController.get().onBackPressed();
+ activityController.pause().stop().destroy();
+ verify(mFeatureFactory.metricsFeatureProvider, never()).action(
+ any(Context.class),
+ eq(MetricsProto.MetricsEvent.ACTION_LEAVE_SEARCH_RESULT_WITHOUT_QUERY));
+ verify(mFeatureFactory.metricsFeatureProvider).histogram(
+ any(Context.class), eq(SearchFragment.RESULT_CLICK_COUNT), eq(0));
verify(mFeatureFactory.searchFeatureProvider)
.getDatabaseSearchLoader(any(Context.class), anyString());
verify(mFeatureFactory.searchFeatureProvider)
diff --git a/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
index aa12787..3afa7fb 100644
--- a/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
@@ -16,31 +16,34 @@
package com.android.settings.wifi;
+import static android.provider.Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED;
+import static android.provider.Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
import android.content.Context;
-import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.core.lifecycle.Lifecycle;
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 static com.google.common.truth.Truth.assertThat;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class NotifyOpenNetworkPreferenceControllerTest {
- @Mock
- private WifiManager mWifiManager;
private Context mContext;
private NotifyOpenNetworksPreferenceController mController;
@@ -48,7 +51,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mController = new NotifyOpenNetworksPreferenceController(mContext, mWifiManager);
+ mController = new NotifyOpenNetworksPreferenceController(mContext, mock(Lifecycle.class));
}
@Test
@@ -71,7 +74,6 @@
assertThat(mController.handlePreferenceTreeClick(pref)).isFalse();
}
-
@Test
public void handlePreferenceTreeClick_matchingKeyAndType_shouldUpdateSetting() {
final SwitchPreference pref = new SwitchPreference(mContext);
@@ -80,8 +82,33 @@
assertThat(mController.handlePreferenceTreeClick(pref)).isTrue();
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0))
+ WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0))
.isEqualTo(1);
}
+ @Test
+ public void updateState_preferenceSetCheckedAndSetEnabledWhenSettingsAreEnabled() {
+ final SwitchPreference preference = mock(SwitchPreference.class);
+ Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 1);
+ Settings.System.putInt(mContext.getContentResolver(),
+ WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1);
+
+ mController.updateState(preference);
+
+ verify(preference).setChecked(true);
+ verify(preference).setEnabled(true);
+ }
+
+ @Test
+ public void updateState_preferenceSetCheckedAndSetEnabledWhenSettingsAreDisabled() {
+ final SwitchPreference preference = mock(SwitchPreference.class);
+ Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 0);
+ Settings.System.putInt(mContext.getContentResolver(),
+ WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0);
+
+ mController.updateState(preference);
+
+ verify(preference).setChecked(false);
+ verify(preference).setEnabled(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
new file mode 100644
index 0000000..d6243ac
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.wifi;
+
+import static android.provider.Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED;
+import static android.provider.Settings.Global.WIFI_WAKEUP_ENABLED;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class WifiWakeupPreferenceControllerTest {
+
+ private Context mContext;
+ private WifiWakeupPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new WifiWakeupPreferenceController(mContext, mock(Lifecycle.class));
+ }
+
+ @Test
+ public void testIsAvailable_shouldAlwaysReturnTrue() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_nonMatchingKey_shouldDoNothing() {
+ final SwitchPreference pref = new SwitchPreference(mContext);
+
+ assertThat(mController.handlePreferenceTreeClick(pref)).isFalse();
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_nonMatchingType_shouldDoNothing() {
+ final Preference pref = new Preference(mContext);
+ pref.setKey(mController.getPreferenceKey());
+
+ assertThat(mController.handlePreferenceTreeClick(pref)).isFalse();
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_matchingKeyAndType_shouldUpdateSetting() {
+ final SwitchPreference pref = new SwitchPreference(mContext);
+ pref.setChecked(true);
+ pref.setKey(mController.getPreferenceKey());
+
+ assertThat(mController.handlePreferenceTreeClick(pref)).isTrue();
+ assertThat(Settings.Global.getInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0))
+ .isEqualTo(1);
+ }
+
+ @Test
+ public void updateState_preferenceSetCheckedAndSetEnabledWhenSettingsAreEnabled() {
+ final SwitchPreference preference = mock(SwitchPreference.class);
+ Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 1);
+ Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+
+ mController.updateState(preference);
+
+ verify(preference).setChecked(true);
+ verify(preference).setEnabled(true);
+ }
+
+ @Test
+ public void updateState_preferenceSetCheckedAndSetEnabledWhenSettingsAreDisabled() {
+ final SwitchPreference preference = mock(SwitchPreference.class);
+ Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 0);
+ Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+
+ mController.updateState(preference);
+
+ verify(preference).setChecked(false);
+ verify(preference).setEnabled(false);
+ }
+}