Merge "Add double-tap & lift gestures to display settings"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 791be09..10b91cb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -564,11 +564,11 @@
<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"/>
+ android:value="com.android.settings.category.ia.system"/>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.language.LanguageAndInputSettings"/>
+ android:value="com.android.settings.language.LanguageAndInputSettings"/>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true"/>
+ android:value="true"/>
</activity>
<activity android:name="Settings$AvailableVirtualKeyboardActivity"
@@ -943,6 +943,8 @@
android:value="com.android.settings.category.ia.system" />
<meta-data android:name="com.android.settings.title"
android:resource="@string/about_settings" />
+ <meta-data android:name="com.android.settings.summary"
+ android:resource="@string/summary_empty"/>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.DeviceInfoSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1012,6 +1014,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.development" />
+ <meta-data android:name="com.android.settings.summary"
+ android:resource="@string/summary_empty" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.ProcessStatsSummary" />
</activity>
@@ -1889,6 +1893,8 @@
</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.FRAGMENT_CLASS"
android:value="com.android.settings.development.DevelopmentSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1937,7 +1943,7 @@
android:label="@string/development_settings_title"
android:targetActivity="Settings$DevelopmentSettingsActivity">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.DevelopmentSettings" />
+ android:value="com.android.settings.development.DevelopmentSettings" />
</activity-alias>
<activity android:name=".development.AppPicker"
@@ -2388,6 +2394,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.accounts" />
+ <meta-data android:name="com.android.settings.summary"
+ android:resource="@string/summary_empty"/>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.users.UserSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2531,6 +2539,13 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
+ <intent-filter android:priority="120">
+ <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.apps"/>
+ <meta-data android:name="com.android.settings.summary"
+ android:resource="@string/summary_empty"/>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.notification.ConfigureNotificationSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2885,16 +2900,25 @@
<activity android:name="Settings$AdvancedAppsActivity"
android:taskAffinity=""
- android:exported="true">
+ android:exported="true"
+ android:label="@string/app_default_dashboard_title"
+ android:icon="@drawable/ic_adb">
<intent-filter android:priority="1">
<action android:name="android.settings.MANAGE_DEFAULT_APPS_SETTINGS" />
<action android:name="android.settings.HOME_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
+ <intent-filter android:priority="130">
+ <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.apps"/>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.AdvancedAppSettings" />
+ <meta-data android:name="com.android.settings.summary"
+ android:resource="@string/summary_empty"/>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
+ android:value="true" />
</activity>
<!-- Keep compatibility with old WebView-picker implementation -->
@@ -2933,6 +2957,8 @@
</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"
android:value="true" />
</activity>
@@ -3013,34 +3039,6 @@
android:resource="@string/support_summary"/>
</activity>
- <activity-alias android:name="ConfigureNotificationDashboardAlias"
- android:targetActivity="Settings$ConfigureNotificationSettingsActivity">
- <intent-filter android:priority="120">
- <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.apps"/>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.notification.ConfigureNotificationSettings" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- </activity-alias>
-
- <activity-alias android:name="AppDefaultDashboardAlias"
- android:targetActivity="Settings$AdvancedAppsActivity"
- android:label="@string/app_default_dashboard_title"
- android:icon="@drawable/ic_adb">
- <intent-filter android:priority="130">
- <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.apps"/>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.applications.AdvancedAppSettings" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- </activity-alias>
-
<!-- End of information architecture host activities -->
<service
diff --git a/res/drawable/ic_settings_battery.xml b/res/drawable/ic_settings_battery.xml
index c8e053d..6afc5d0 100644
--- a/res/drawable/ic_settings_battery.xml
+++ b/res/drawable/ic_settings_battery.xml
@@ -14,13 +14,12 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
+ android:width="24dp"
+ android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
- android:fillColor="#FFFFFFFF"
- android:pathData="M15.67,4.0L14.0,4.0L14.0,2.0l-4.0,0.0l0.0,2.0L8.33,4.0C7.6,4.0 7.0,4.6 7.0,5.33l0.0,15.33C7.0,21.4 7.6,22.0 8.33,22.0l7.33,0.0c0.74,0.0 1.34,-0.6 1.34,-1.33L17.0,5.33C17.0,4.6 16.4,4.0 15.67,4.0z
- M16,5l0,5.5l-8,0l0,-5.5l3,0l0,-2l2,0l0,2l3,0z"/>
+ android:fillColor="#FF000000"
+ android:pathData="M15.67,4H14V2h-4v2H8.33C7.6,4 7,4.6 7,5.33v15.33C7,21.4 7.6,22 8.33,22h7.33c0.74,0 1.34,-0.6 1.34,-1.33V5.33C17,4.6 16.4,4 15.67,4z"/>
</vector>
diff --git a/res/drawable/selectable_card.xml b/res/drawable/selectable_card.xml
deleted file mode 100644
index 3a1e8b2..0000000
--- a/res/drawable/selectable_card.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-
-<ripple
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?android:attr/colorControlHighlight">
- <item android:drawable="?android:attr/colorBackground"/>
-</ripple>
\ No newline at end of file
diff --git a/res/layout/battery_usage_graph.xml b/res/layout/battery_usage_graph.xml
index bd6e7a5..80f966b 100644
--- a/res/layout/battery_usage_graph.xml
+++ b/res/layout/battery_usage_graph.xml
@@ -18,6 +18,7 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingTop="16dp"
android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="vertical">
@@ -26,22 +27,16 @@
android:id="@+id/charge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="36sp"
android:textColor="?android:attr/colorAccent" />
- <TextView
- android:id="@+id/estimation"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="8dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="?android:attr/textColorSecondary" />
-
<com.android.settingslib.graph.UsageView
android:id="@+id/battery_usage"
android:layout_width="match_parent"
android:layout_height="141dp"
+ android:layout_marginBottom="16dp"
settings:sideLabels="@array/battery_labels"
android:colorAccent="?android:attr/colorAccent"
android:gravity="end"
diff --git a/res/layout/dashboard_tile.xml b/res/layout/dashboard_tile.xml
index 0e06d18..1ec1730 100644
--- a/res/layout/dashboard_tile.xml
+++ b/res/layout/dashboard_tile.xml
@@ -19,7 +19,7 @@
android:id="@+id/dashboard_tile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@drawable/selectable_card"
+ android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height"
android:clickable="true"
diff --git a/res/layout/preference_bluetooth.xml b/res/layout/preference_bluetooth.xml
deleted file mode 100644
index c339e67..0000000
--- a/res/layout/preference_bluetooth.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2006 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical">
-
- <!-- Details button -->
- <ImageView
- android:id="@+id/deviceDetails"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:padding="8dip"
- android:background="?android:attr/selectableItemBackground"
- android:src="@drawable/ic_settings"
- android:contentDescription="@string/bluetooth_device_details" />
-
-</LinearLayout>
diff --git a/res/layout/preference_master_switch.xml b/res/layout/preference_master_switch.xml
deleted file mode 100644
index c7dd6d6..0000000
--- a/res/layout/preference_master_switch.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!-- Based off preference_material_settings.xml except that ripple on only on the left side. -->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:gravity="center_vertical"
- android:background="@android:color/transparent"
- android:clipToPadding="false">
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
- android:gravity="start|center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart">
-
- <LinearLayout
- android:id="@+id/icon_container"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minWidth="60dp"
- android:orientation="horizontal"
- android:paddingEnd="12dp"
- android:paddingTop="4dp"
- android:paddingBottom="4dp">
- <com.android.internal.widget.PreferenceImageView
- android:id="@android:id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxWidth="48dp"
- android:maxHeight="48dp"/>
- </LinearLayout>
-
- <RelativeLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingTop="16dp"
- android:paddingBottom="16dp">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceListItem"
- android:ellipsize="marquee"/>
-
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@android:id/title"
- android:layout_alignStart="@android:id/title"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
- android:maxLines="10"/>
-
- </RelativeLayout>
-
- </LinearLayout>
-
- <!-- Preference should place its actual preference widget here. -->
- <LinearLayout
- android:id="@android:id/widget_frame"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="end|center_vertical"
- android:orientation="vertical"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
-
-</LinearLayout>
diff --git a/res/layout/preference_progress_category.xml b/res/layout/preference_progress_category.xml
index 1380698..9f5a8b4 100644
--- a/res/layout/preference_progress_category.xml
+++ b/res/layout/preference_progress_category.xml
@@ -35,7 +35,6 @@
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:tint="?android:attr/textColorPrimary"
android:maxWidth="18dp"
android:maxHeight="18dp"/>
</LinearLayout>
@@ -47,7 +46,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="start|center"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"/>
+ android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textColor="?android:attr/colorAccent"/>
<ProgressBar
android:id="@+id/scanning_progress"
diff --git a/res/layout/preference_widget_gear.xml b/res/layout/preference_widget_gear.xml
new file mode 100644
index 0000000..f533dcf
--- /dev/null
+++ b/res/layout/preference_widget_gear.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Settings button -->
+<ImageView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/settings_button"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:paddingStart="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:background="?android:attr/selectableItemBackground"
+ android:scaleType="center"
+ android:src="@drawable/ic_settings"
+ android:contentDescription="@string/settings_button" />
+
diff --git a/res/layout/preference_widget_master_switch.xml b/res/layout/preference_widget_master_switch.xml
index ee335f1..7e28be9 100644
--- a/res/layout/preference_widget_master_switch.xml
+++ b/res/layout/preference_widget_master_switch.xml
@@ -15,28 +15,12 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="start|center_vertical"
- android:orientation="horizontal"
- android:paddingEnd="20dp"
- android:paddingTop="16dp"
- android:paddingBottom="16dp">
- <View
- android:layout_width="1dp"
- android:layout_height="match_parent"
- android:background="?android:attr/dividerVertical"/>
- </LinearLayout>
-
- <Switch android:id="@+id/switchWidget"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="center_vertical"
- android:clickable="false"/>
-
-</LinearLayout>
+<Switch
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/switchWidget"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:paddingStart="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:clickable="false" />
diff --git a/res/layout/preference_widget_settings.xml b/res/layout/preference_widget_settings.xml
deleted file mode 100644
index dfeca1a..0000000
--- a/res/layout/preference_widget_settings.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:paddingEnd="?android:attr/scrollbarSize">
-
- <!-- Settings button -->
- <ImageView
- android:id="@+id/settings_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:padding="8dip"
- android:background="?android:attr/selectableItemBackground"
- android:src="@drawable/ic_settings"
- android:contentDescription="@string/settings_button" />
-
-</LinearLayout>
diff --git a/res/layout/search_panel_2.xml b/res/layout/search_panel.xml
similarity index 100%
rename from res/layout/search_panel_2.xml
rename to res/layout/search_panel.xml
diff --git a/res/layout/settings_main_dashboard.xml b/res/layout/settings_main_dashboard.xml
index 1b7506e..c10193c 100644
--- a/res/layout/settings_main_dashboard.xml
+++ b/res/layout/settings_main_dashboard.xml
@@ -21,5 +21,4 @@
android:id="@+id/main_content"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:background="@color/material_grey_300"
/>
diff --git a/res/layout/support_tile.xml b/res/layout/support_tile.xml
index e294868..c2081c7 100644
--- a/res/layout/support_tile.xml
+++ b/res/layout/support_tile.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@drawable/selectable_card"
+ android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/support_tile_min_height"
android:orientation="horizontal">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4a85b8f..790b916 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -71,7 +71,7 @@
<!-- Wifi Calling provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="wfc_provisioned_switch_string">Wifi Calling Provisioned</string>
- <!-- Cell Radio Power. Only shown in diagnostic screen, so precise translation is not needed. -->
+ <!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="radio_info_radio_power">Mobile Radio Power</string>
<!-- Phone Info screen. Menu item label. Used for diagnostic info screens, precise translation isn't needed -->
@@ -222,8 +222,6 @@
<string name="bluetooth_devices">Bluetooth devices</string>
<!-- Bluetooth settings screen, title for the current bluetooth name setting -->
<string name="bluetooth_device_name">Device name</string>
- <!-- Bluetooth settings screen, image description for device details button. This opens the screen to rename, unpair, etc. a single device. -->
- <string name="bluetooth_device_details">Device settings</string>
<!-- Bluetooth settings screen, image description for profile of a device details button. -->
<string name="bluetooth_profile_details">Profile settings</string>
<!-- Bluetooth settings screen, summary text when there isn't a name set (for the name setting) -->
@@ -629,7 +627,7 @@
<string name="calls_title">Calls</string>
<!-- check box SMS Messges title [CHAR LIMIT=30] -->
<string name="sms_messages_title">SMS messages</string>
- <!-- check box cellular data summary [CHAR LIMIT=41] -->
+ <!-- check box cellular data summary [CHAR LIMIT=85] -->
<string name="cellular_data_summary">Allow data usage over mobile network</string>
<!-- check box to allow data usage when roaming [CHAR LIMIT=41] -->
<string name="allow_data_usage_title">Allow data usage when roaming</string>
@@ -1300,9 +1298,6 @@
<!-- Toast shown when lock pattern or password successfully setup. [CHAR LIMIT=64] -->
<string name="lock_setup" msgid="5507462851158901718">Setup is complete.</string>
- <!-- In the security screen, the header title for settings related to device admins -->
- <string name="device_admin_title">Device administration</string>
-
<!-- Title of preference to manage device admins -->
<string name="manage_device_admin">Device admin apps</string>
@@ -1642,7 +1637,7 @@
<string name="wifi_switch_away_when_unvalidated">Switch to mobile data if Wi\u2011Fi loses Internet access.</string>
<!-- Preference title for option to automatically switch away from bad wifi networks [CHAR LIMIT=60]-->
<string name="wifi_cellular_data_fallback_title">Switch to mobile data automatically</string>
- <!-- Preference summary for option to automatically switch away from bad wifi networks [CHAR LIMIT=None]-->
+ <!-- Preference summary to automatically switch away from bad wifi networks [CHAR LIMIT=None]-->
<string name="wifi_cellular_data_fallback_summary">Use mobile data when Wi\u2011Fi has no Internet access. Data usage may apply.</string>
<!-- Action bar text message to manually add a wifi network [CHAR LIMIT=20]-->
<string name="wifi_add_network">Add network</string>
@@ -1809,7 +1804,8 @@
<!-- Dialog text to tell the user that the selected network has lost Internet access, and asking the user whether they want to avoid this network. -->
<string name="lost_internet_access_title">Wi\u2011Fi is not connected to the Internet</string>
- <string name="lost_internet_access_text">You can switch to the mobile network whenever Wi\u2011Fi has a bad connection. Data usage may apply.</string>
+ <string name="lost_internet_access_text">You can switch to the mobile network whenever Wi\u2011Fi has a bad connection. Data usage charges may apply.</string>
+ <!-- Button text to let user switch to mobile data -->
<string name="lost_internet_access_switch">Switch to mobile</string>
<string name="lost_internet_access_cancel">Stay on Wi\u2011Fi</string>
<string name="lost_internet_access_persist">Never show again</string>
@@ -1935,7 +1931,7 @@
<!-- Summary Used to open the ssid and security dialog for Wifi Access Point. [CHAR LIMIT=60] -->
<string name="wifi_hotspot_configure_ap_text_summary">AndroidAP WPA2 PSK hotspot</string>
<!-- Subtext on configuration preference to indicate SSID and security chosen -->
- <string name="wifi_tether_configure_subtext"><xliff:g id="network_ssid">%1$s</xliff:g> <xliff:g id="network_security">%2$s</xliff:g> portable Wi\u2011Fi hotspot</string>
+ <string name="wifi_tether_configure_subtext"><xliff:g id="network_ssid">%1$s</xliff:g> <xliff:g id="network_security">%2$s</xliff:g> hotspot</string>
<!-- Default access point SSID used for tethering -->
<string name="wifi_tether_configure_ssid_default">AndroidHotspot</string>
@@ -2078,8 +2074,10 @@
<string name="display_settings_title">Display</string>
<!-- Sound settings screen heading -->
<string name="sound_settings">Sound</string>
- <!-- Sound settings screen, setting option summary text -->
- <string name="ringtone_summary"> </string>
+ <!-- DO NOT TRANSLATE Summary placeholder -->
+ <string name="summary_placeholder" translatable="false"> </string>
+ <!-- DO NOT TRANSLATE Empty summary for dynamic preferences -->
+ <string name="summary_empty" translatable="false"></string>
<!-- Sound settings screen, volume title -->
<string name="all_volume_title">Volumes</string>
<!-- Sound settings screen, music effects title [CHAR LIMIT=30]-->
@@ -2260,6 +2258,10 @@
<string name="screen_timeout_summary">After <xliff:g id="timeout_description">%1$s</xliff:g> of inactivity</string>
<!-- Wallpaper settings title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_title">Wallpaper</string>
+ <!-- Wallpaper settings summary when default wallpaper is used [CHAR LIMIT=NONE] -->
+ <string name="wallpaper_settings_summary_default">Default</string>
+ <!-- Wallpaper settings summary when wallpaper has been updated [CHAR LIMIT=NONE] -->
+ <string name="wallpaper_settings_summary_custom">Custom</string>
<!-- Wallpaper suggestion title [CHAR LIMIT=30] -->
<string name="wallpaper_suggestion_title">Change wallpaper</string>
<!-- Wallpaper suggestion title [CHAR LIMIT=60] -->
@@ -2910,8 +2912,6 @@
<string name="reset_network_complete_toast">Network settings have been reset</string>
<!-- Master Clear -->
- <!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=30] -->
- <string name="device_reset_title">Reset device</string>
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading -->
<string name="master_clear_title">Factory data reset</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
@@ -3769,6 +3769,8 @@
<string name="language_settings">Languages & input</string>
<!-- Title of Languages & input settings screen -->
<string name="language_keyboard_settings_title">Languages & input</string>
+ <!-- Title of preference category that lists all settings about helping user input such as spell checker [CHAR LIMIT=60]-->
+ <string name="input_assistance">Input assistance</string>
<!-- On Languages & input settings screen, heading. Inside the "Languages & input settings" screen, this is the header for settings that relate to keyboard (enable/disable each keyboard, settings for each keyboard). -->
<string name="keyboard_settings_category">Keyboard & input methods</string>
<!-- On Text & language settings screen, setting option name. title of the setting to take the user to a screen to select the locale. -->
@@ -3815,7 +3817,7 @@
<string name="failed_to_open_app_settings_toast">Failed to open settings for <xliff:g id="spell_application_name">%1$s</xliff:g></string>
<!-- Title for the 'keyboard and input methods' preference category. [CHAR LIMIT=45] -->
- <string name="keyboard_and_input_methods_category">Keyboard and input methods</string>
+ <string name="keyboard_and_input_methods_category">Keyboard & inputs</string>
<!-- Title for the 'virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
<string name="virtual_keyboard_category">Virtual keyboards</string>
<!-- Title for the 'available virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
@@ -5287,7 +5289,7 @@
<!-- Checkbox label that restricts background data usage of a specific application. [CHAR LIMIT=40] -->
<string name="data_usage_app_restrict_background">Background data</string>
<!-- Summary message for checkbox that restricts background data usage of a specific application. [CHAR LIMIT=NONE] -->
- <string name="data_usage_app_restrict_background_summary">Enable usage of Mobile data in the background</string>
+ <string name="data_usage_app_restrict_background_summary">Enable usage of mobile data in the background</string>
<!-- Summary message for checkbox that restricts background data usage of a specific application when no networks have been limited. [CHAR LIMIT=84] -->
<string name="data_usage_app_restrict_background_summary_disabled">To restrict background data for this app, first set a mobile data limit.</string>
<!-- Title of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=48] -->
@@ -7536,7 +7538,7 @@
<string name="backup_disabled">Back up disabled</string>
<!-- Summary of device info page [CHAR LIMIT=NONE] -->
- <string name="about_summary">Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
+ <string name="about_summary">Updated to Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
<!-- Title for dialog displayed when user clicks on a setting locked by an admin [CHAR LIMIT=30] -->
<string name="disabled_by_policy_title">Action not allowed</string>
@@ -7594,7 +7596,7 @@
<!-- Summary of condition that battery saver is on [CHAR LIMIT=NONE] -->
<string name="condition_battery_summary">Performance is reduced. Location services and background data are turned off.</string>
- <!-- Title of condition that cellular data is off [CHAR LIMIT=30] -->
+ <!-- Title of condition that cellular data is off [CHAR LIMIT=50] -->
<string name="condition_cellular_title">Mobile data is off</string>
<!-- Summary of condition that cellular data is off [CHAR LIMIT=NONE] -->
@@ -8119,8 +8121,8 @@
<!-- Summary text for ambient display (device) [CHAR LIMIT=160]-->
<string name="ambient_display_pickup_summary" product="device">To quickly check your notifications, pick up your device.</string>
- <!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
- <string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
+ <!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=80]-->
+ <string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
<!-- Summary text for fingerprint swipe for notifications (phone) [CHAR LIMIT=160]-->
<string name="fingerprint_swipe_for_notifications_summary" product="default">To check your notifications, swipe down on the fingerprint sensor on the back of your phone.</string>
@@ -8246,10 +8248,8 @@
<string name="enterprise_privacy_always_on_vpn_work">Always-on VPN turned on in your work profile</string>
<!-- Label explaining that a global HTTP proxy was set by the admin. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_global_http_proxy">Global HTTP proxy set</string>
- <!-- Label explaining that the admin installed trusted CA certificates for the current user. [CHAR LIMIT=NONE] -->
- <string name="enterprise_privacy_ca_certs_user">Trusted credentials</string>
- <!-- Label explaining that the admin installed trusted CA certificates for the personal profile. [CHAR LIMIT=NONE] -->
- <string name="enterprise_privacy_ca_certs_personal">Trusted credentials in your personal profile</string>
+ <!-- Label explaining that the admin installed trusted CA certificates. [CHAR LIMIT=NONE] -->
+ <string name="enterprise_privacy_ca_certs">Trusted credentials</string>
<!-- Summary indicating the number of trusted CA certificates installed by the admin. [CHAR LIMIT=NONE] -->
<plurals name="enterprise_privacy_number_ca_certs">
<item quantity="one"><xliff:g id="count">%d</xliff:g> CA certificate</item>
@@ -8260,8 +8260,6 @@
<item quantity="one"><xliff:g id="count">%d</xliff:g> CA certificate. Tap to view.</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> CA certificates. Tap to view.</item>
</plurals>
- <!-- Label explaining that the admin installed trusted CA certificates for the work profile. [CHAR LIMIT=NONE] -->
- <string name="enterprise_privacy_ca_certs_work">Trusted credentials in your work profile</string>
<!-- Label explaining that the admin can lock the device and change the user's password. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_lock_device">Admin can lock the device and reset password</string>
<!-- Label explaining that the admin can wipe the device remotely. [CHAR LIMIT=NONE] -->
@@ -8322,8 +8320,8 @@
<string name="webview_disabled_for_user">(disabled for user <xliff:g id="user" example="John Doe">%s</xliff:g>)</string>
<!-- AutoFill strings -->
- <!-- Preference label for the auto-fill app. [CHAR LIMIT=60] -->
- <string name="autofill_app">Autofill app</string>
+ <!-- Preference label for choosing auto-fill service. [CHAR LIMIT=60] -->
+ <string name="autofill_app">Autofill service</string>
<!-- Keywords for the auto-fill feature. [CHAR LIMIT=NONE] -->
<string name="autofill_keywords">auto, fill, autofill</string>
<!-- Title of the warning dialog for setting the auto-fill app. [CHAR_LIMIT=NONE] -->
diff --git a/res/xml/app_default_settings.xml b/res/xml/app_default_settings.xml
index e96c070..11acb24 100644
--- a/res/xml/app_default_settings.xml
+++ b/res/xml/app_default_settings.xml
@@ -29,7 +29,6 @@
<Preference
android:key="default_browser"
android:title="@string/default_browser_title"
- android:summary="@string/default_browser_title_none"
android:fragment="com.android.settings.applications.defaultapps.DefaultBrowserPicker"
android:order="-19">
<extra android:name="for_work" android:value="false"/>
@@ -38,7 +37,6 @@
<Preference
android:key="default_home"
android:title="@string/home_app"
- android:summary="@string/no_default_home"
android:fragment="com.android.settings.applications.defaultapps.DefaultHomePicker"
settings:keywords="@string/keywords_home"
android:order="-18"/>
@@ -63,14 +61,6 @@
settings:keywords="@string/keywords_emergency_app"
android:order="-15"/>
- <com.android.settings.widget.GearPreference
- android:key="default_autofill"
- android:title="@string/autofill_app"
- android:summary="@string/app_list_preference_none"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:keywords="@string/autofill_keywords"
- android:order="-14"/>
-
<!--
<Preference
android:key="default_notification_asst_app"
@@ -91,7 +81,6 @@
<Preference
android:key="work_default_browser"
android:title="@string/default_browser_title"
- android:summary="@string/default_browser_title_none"
android:fragment="com.android.settings.applications.defaultapps.DefaultBrowserPicker">
<extra android:name="for_work" android:value="true"/>
</Preference>
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index fde1bfa..5b848e6 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -69,5 +69,4 @@
android:title="@string/app_notification_override_dnd_title"
android:summary="@string/app_notification_override_dnd_summary"
settings:useAdditionalSummary="true" />
-
</PreferenceScreen>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 8422f3e..6ed8dc9 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -214,6 +214,13 @@
android:summary="@string/bluetooth_disable_absolute_volume_summary"/>
<ListPreference
+ android:key="bluetooth_select_avrcp_version"
+ android:title="@string/bluetooth_select_avrcp_version_string"
+ android:dialogTitle="@string/bluetooth_select_avrcp_version_dialog_title"
+ android:entries="@array/bluetooth_avrcp_versions"
+ android:entryValues="@array/bluetooth_avrcp_version_values" />
+
+ <ListPreference
android:key="bluetooth_select_a2dp_codec"
android:title="@string/bluetooth_select_a2dp_codec_type"
android:dialogTitle="@string/bluetooth_select_a2dp_codec_type_dialog_title"
diff --git a/res/xml/enterprise_privacy_settings.xml b/res/xml/enterprise_privacy_settings.xml
index 1a08cda..e6246c2 100644
--- a/res/xml/enterprise_privacy_settings.xml
+++ b/res/xml/enterprise_privacy_settings.xml
@@ -90,11 +90,8 @@
android:title="@string/enterprise_privacy_global_http_proxy"
settings:multiLine="true"/>
<com.android.settings.DividerPreference
- android:key="ca_certs_current_user"
- settings:multiLine="true"/>
- <com.android.settings.DividerPreference
- android:key="ca_certs_managed_profile"
- android:title="@string/enterprise_privacy_ca_certs_work"
+ android:key="ca_certs"
+ android:title="@string/enterprise_privacy_ca_certs"
settings:multiLine="true"/>
</PreferenceCategory>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 6303fbd..79f441f 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -17,6 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/language_keyboard_settings_title" >
<Preference
@@ -34,19 +35,28 @@
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
</PreferenceCategory>
- <!-- Spell checker preference title, summary and fragment will be set programmatically. -->
- <!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
- See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
- <Preference
- android:key="spellcheckers_settings"
- android:title="@string/spellcheckers_settings_title"
- android:persistent="false"
- android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"/>
+ <PreferenceCategory
+ android:title="@string/input_assistance">
+ <!-- Spell checker preference title, summary and fragment will be set programmatically. -->
+ <!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
+ See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
+ <Preference
+ android:key="spellcheckers_settings"
+ android:title="@string/spellcheckers_settings_title"
+ android:persistent="false"
+ android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"/>
- <!-- User dictionary preference title and fragment will be set programmatically. -->
- <Preference
- android:key="key_user_dictionary_settings"
- android:title="@string/user_dict_settings_title"/>
+ <com.android.settings.widget.GearPreference
+ android:key="default_autofill"
+ android:title="@string/autofill_app"
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ settings:keywords="@string/autofill_keywords" />
+
+ <!-- User dictionary preference title and fragment will be set programmatically. -->
+ <Preference
+ android:key="key_user_dictionary_settings"
+ android:title="@string/user_dict_settings_title"/>
+ </PreferenceCategory>
<PreferenceCategory
android:key="gesture_settings_category"
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index d7a6355..7feffca 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -23,6 +23,7 @@
android:fragment="com.android.settings.wifi.WifiSettings"
android:key="toggle_wifi"
android:title="@string/wifi_settings"
+ android:summary="@string/summary_placeholder"
android:icon="@drawable/ic_settings_wireless"
android:order="-30">
<intent
@@ -30,13 +31,6 @@
android:targetClass="Settings$WifiSettingsActivity"/>
</com.android.settings.widget.MasterSwitchPreference>
- <SwitchPreference
- android:key="toggle_airplane"
- android:title="@string/airplane_mode"
- android:icon="@drawable/ic_airplanemode_active"
- android:disableDependentsState="true"
- android:order="5"/>
-
<com.android.settingslib.RestrictedPreference
android:key="mobile_network_settings"
android:title="@string/network_settings_title"
@@ -58,6 +52,7 @@
android:title="@string/tether_settings_title_all"
android:icon="@drawable/ic_wifi_tethering"
android:order="-5"
+ android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_tethering"
settings:useAdminDisabledSummary="true"/>
@@ -67,6 +62,7 @@
android:title="@string/vpn_settings_title"
android:icon="@drawable/ic_vpn_key"
android:order="0"
+ android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_vpn"
settings:useAdminDisabledSummary="true"/>
@@ -77,6 +73,13 @@
settings:userRestriction="no_config_mobile_networks"
settings:useAdminDisabledSummary="true"/>
+ <SwitchPreference
+ android:key="toggle_airplane"
+ android:title="@string/airplane_mode"
+ android:icon="@drawable/ic_airplanemode_active"
+ android:disableDependentsState="true"
+ android:order="5"/>
+
<Preference
android:fragment="com.android.settings.ProxySelector"
android:key="proxy_settings"
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index aecb6f1..a387813 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -30,9 +30,9 @@
android:title="@string/battery_power_management">
<com.android.settings.widget.MasterSwitchPreference
+ android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
android:key="battery_saver"
- android:title="@string/battery_saver"
- android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"/>
+ android:title="@string/battery_saver"/>
<SwitchPreference
android:key="battery_percentage"
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index e058b3e..943f04c 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -33,9 +33,7 @@
</PreferenceCategory>
- <PreferenceCategory android:key="device_admin_category"
- android:title="@string/device_admin_title"
- android:persistent="false">
+ <PreferenceCategory>
<Preference android:key="manage_device_admin"
android:title="@string/manage_device_admin"
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index a34d875..0aaaff1 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -67,7 +67,7 @@
android:key="ringtone"
android:title="@string/ringtone_title"
android:dialogTitle="@string/ringtone_title"
- android:summary="@string/ringtone_summary"
+ android:summary="@string/summary_placeholder"
android:ringtoneType="ringtone" />
<!-- Default notification ringtone -->
@@ -75,7 +75,7 @@
android:key="notification_ringtone"
android:title="@string/notification_ringtone_title"
android:dialogTitle="@string/notification_ringtone_title"
- android:summary="@string/ringtone_summary"
+ android:summary="@string/summary_placeholder"
android:ringtoneType="notification" />
<!-- Default alarm ringtone -->
@@ -83,7 +83,7 @@
android:key="alarm_ringtone"
android:title="@string/alarm_ringtone_title"
android:dialogTitle="@string/alarm_ringtone_title"
- android:summary="@string/ringtone_summary"
+ android:summary="@string/summary_placeholder"
android:persistent="false"
android:ringtoneType="alarm" />
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 14579c5..b03fab6 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -23,7 +23,7 @@
<Preference
android:key="system_update_settings"
android:title="@string/system_update_settings_list_item_title"
- android:summary="@string/system_update_settings_list_item_summary"
+ android:summary="@string/summary_placeholder"
android:icon="@drawable/ic_system_update"
android:order="-30">
<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS"/>
@@ -41,7 +41,7 @@
<!-- Factory reset -->
<com.android.settingslib.RestrictedPreference
android:key="factory_reset"
- android:title="@string/device_reset_title"
+ android:title="@string/master_clear_title"
android:icon="@drawable/ic_restore"
android:order="-20"
settings:keywords="@string/keywords_factory_data_reset"
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index e9d3f86..b1c9e2c 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -20,14 +20,12 @@
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
-import android.os.Build;
import android.provider.SearchIndexableResource;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
import com.android.settings.deviceinfo.BasebandVersionPreferenceController;
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
@@ -88,34 +86,6 @@
getLifecycle());
}
- private static class SummaryProvider implements SummaryLoader.SummaryProvider {
-
- private final Context mContext;
- private final SummaryLoader mSummaryLoader;
-
- public SummaryProvider(Context context, SummaryLoader summaryLoader) {
- mContext = context;
- mSummaryLoader = summaryLoader;
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- mSummaryLoader.setSummary(this, mContext.getString(R.string.about_summary,
- Build.VERSION.RELEASE));
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
-
private static List<PreferenceController> buildPreferenceControllers(Context context,
Activity activity, Fragment fragment, Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index edefaf7..1cb763b 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -102,7 +102,6 @@
private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
private static final String KEY_VISIBLE_PATTERN_PROFILE = "visiblepattern_profile";
private static final String KEY_SECURITY_CATEGORY = "security_category";
- private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
private static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
private static final String KEY_UNIFICATION = "unification";
@@ -351,10 +350,6 @@
// Credential storage
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
- // Application install
- PreferenceGroup deviceAdminCategory = (PreferenceGroup)
- root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
-
// Advanced Security features
Preference manageAgents = root.findPreference(KEY_MANAGE_TRUST_AGENTS);
if (manageAgents != null && !mLockPatternUtils.isSecure(MY_USER_ID)) {
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index 0a0eed2..61cad39 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -132,6 +132,8 @@
super.onCreate(icicle);
addPreferencesFromResource(R.xml.tether_prefs);
+ mFooterPreferenceMixin.createFooterPreference()
+ .setTitle(R.string.tethering_footer_info);
mDataSaverBackend = new DataSaverBackend(getContext());
mDataSaverEnabled = mDataSaverBackend.isDataSaverEnabled();
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 86c340d..eaadf13 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -775,8 +775,6 @@
SearchIndexableRaw indexable = new SearchIndexableRaw(context);
indexable.key = componentName.flattenToString();
indexable.title = service.getResolveInfo().loadLabel(packageManager).toString();
- indexable.summaryOn = context.getString(R.string.accessibility_feature_state_on);
- indexable.summaryOff = context.getString(R.string.accessibility_feature_state_off);
indexable.screenTitle = screenTitle;
indexables.add(indexable);
}
diff --git a/src/com/android/settings/applications/AdvancedAppSettings.java b/src/com/android/settings/applications/AdvancedAppSettings.java
index b8ebeb4..e59f94b 100644
--- a/src/com/android/settings/applications/AdvancedAppSettings.java
+++ b/src/com/android/settings/applications/AdvancedAppSettings.java
@@ -20,7 +20,6 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
-import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
import com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController;
import com.android.settings.applications.defaultapps.DefaultEmergencyPreferenceController;
import com.android.settings.applications.defaultapps.DefaultHomePreferenceController;
@@ -61,7 +60,6 @@
controllers.add(new DefaultSmsPreferenceController(context));
controllers.add(new DefaultEmergencyPreferenceController(context));
controllers.add(new DefaultHomePreferenceController(context));
- controllers.add(new DefaultAutofillPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/applications/AppHeaderController.java b/src/com/android/settings/applications/AppHeaderController.java
index 45b8960..0bc9f8f 100644
--- a/src/com/android/settings/applications/AppHeaderController.java
+++ b/src/com/android/settings/applications/AppHeaderController.java
@@ -90,7 +90,7 @@
if (appHeader != null) {
mAppHeader = appHeader;
} else {
- mAppHeader = LayoutInflater.from(mContext)
+ mAppHeader = LayoutInflater.from(fragment.getContext())
.inflate(R.layout.app_details, null /* root */);
}
}
diff --git a/src/com/android/settings/applications/ApplicationFeatureProvider.java b/src/com/android/settings/applications/ApplicationFeatureProvider.java
index 7dce793..51e79d8 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProvider.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProvider.java
@@ -54,9 +54,10 @@
*
* @param permissions Only consider apps that have been granted one or more of these permissions
* by the admin, either at run-time or install-time
+ * @param async Whether to count asynchronously in a background thread
* @param callback The callback to invoke with the result
*/
- void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions,
+ void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions, boolean async,
NumberOfAppsCallback callback);
/**
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index 5ba228f..77c9f3e 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -69,9 +69,15 @@
@Override
public void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions,
- NumberOfAppsCallback callback) {
- new AllUserAppWithAdminGrantedPermissionsCounter(mContext, permissions, mPm, mPms, mDpm,
- callback).execute();
+ boolean async, NumberOfAppsCallback callback) {
+ final AllUserAppWithAdminGrantedPermissionsCounter counter =
+ new AllUserAppWithAdminGrantedPermissionsCounter(mContext, permissions, mPm, mPms,
+ mDpm, callback);
+ if (async) {
+ counter.execute();
+ } else {
+ counter.executeInForeground();
+ }
}
@Override
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
index d8fb225..4c65fca 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
@@ -24,6 +24,7 @@
import android.text.TextUtils;
import android.util.Log;
+import com.android.settings.R;
import com.android.settings.applications.PackageManagerWrapper;
import com.android.settings.applications.PackageManagerWrapperImpl;
import com.android.settings.core.PreferenceController;
@@ -56,7 +57,7 @@
preference.setSummary(defaultAppLabel);
} else {
Log.d(TAG, "No default app");
- preference.setSummary(null);
+ preference.setSummary(R.string.app_list_preference_none);
}
mayUpdateGearIcon(app, preference);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 5bddffa..7be6dd7 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -30,14 +30,13 @@
import android.util.Log;
import android.util.Pair;
import android.util.TypedValue;
-import android.view.View;
-import android.view.View.OnClickListener;
import android.widget.ImageView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.GearPreference;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HidProfile;
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
@@ -50,15 +49,14 @@
* BluetoothDevicePreference is the preference type used to display each remote
* Bluetooth device in the Bluetooth Settings screen.
*/
-public final class BluetoothDevicePreference extends Preference implements
- CachedBluetoothDevice.Callback, OnClickListener {
- private static final String TAG = "BluetoothDevicePreference";
+public final class BluetoothDevicePreference extends GearPreference implements
+ CachedBluetoothDevice.Callback {
+ private static final String TAG = "BluetoothDevicePref";
private static int sDimAlpha = Integer.MIN_VALUE;
private final CachedBluetoothDevice mCachedDevice;
-
- private OnClickListener mOnSettingsClickListener;
+ private final UserManager mUserManager;
private AlertDialog mDisconnectDialog;
@@ -76,7 +74,8 @@
public final String BLUETOOTH = r.getString(R.string.bluetooth_talkback_bluetooth);
public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) {
- super(context);
+ super(context, null);
+ mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (sDimAlpha == Integer.MIN_VALUE) {
TypedValue outValue = new TypedValue();
@@ -85,14 +84,6 @@
}
mCachedDevice = cachedDevice;
-
- if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
- UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
- if (!um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
- setWidgetLayoutResource(R.layout.preference_bluetooth);
- }
- }
-
mCachedDevice.registerCallback(this);
onDeviceAttributesChanged();
@@ -102,12 +93,20 @@
notifyChanged();
}
- CachedBluetoothDevice getCachedDevice() {
- return mCachedDevice;
+ @Override
+ protected boolean shouldHideSecondTarget() {
+ return mCachedDevice == null
+ || mCachedDevice.getBondState() != BluetoothDevice.BOND_BONDED
+ || mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH);
}
- public void setOnSettingsClickListener(OnClickListener listener) {
- mOnSettingsClickListener = listener;
+ @Override
+ protected int getSecondTargetResId() {
+ return R.layout.preference_widget_gear;
+ }
+
+ CachedBluetoothDevice getCachedDevice() {
+ return mCachedDevice;
}
@Override
@@ -120,6 +119,10 @@
}
}
+ public CachedBluetoothDevice getBluetoothDevice() {
+ return mCachedDevice;
+ }
+
public void onDeviceAttributesChanged() {
/*
* The preference framework takes care of making sure the value has
@@ -157,11 +160,10 @@
}
if (mCachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
- ImageView deviceDetails = (ImageView) view.findViewById(R.id.deviceDetails);
+ ImageView deviceDetails = (ImageView) view.findViewById(R.id.settings_button);
if (deviceDetails != null) {
deviceDetails.setOnClickListener(this);
- deviceDetails.setTag(mCachedDevice);
}
}
final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
@@ -171,13 +173,6 @@
super.onBindViewHolder(view);
}
- public void onClick(View v) {
- // Should never be null by construction
- if (mOnSettingsClickListener != null) {
- mOnSettingsClickListener.onClick(v);
- }
- }
-
@Override
public boolean equals(Object o) {
if ((o == null) || !(o instanceof BluetoothDevicePreference)) {
@@ -207,19 +202,19 @@
int bondState = mCachedDevice.getBondState();
final MetricsFeatureProvider metricsFeatureProvider =
- FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
+ FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
if (mCachedDevice.isConnected()) {
metricsFeatureProvider.action(getContext(),
- MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
+ MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
askDisconnect();
} else if (bondState == BluetoothDevice.BOND_BONDED) {
metricsFeatureProvider.action(getContext(),
- MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
+ MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
mCachedDevice.connect(true);
} else if (bondState == BluetoothDevice.BOND_NONE) {
metricsFeatureProvider.action(getContext(),
- MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+ MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
pair();
}
}
@@ -283,10 +278,10 @@
}
}
if (btClass != null) {
- if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
return new Pair<Integer, String>(R.drawable.ic_bt_headset_hfp, HEADSET);
}
- if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
return new Pair<Integer, String>(R.drawable.ic_bt_headphones_a2dp, HEADPHONE);
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 5679f90..317a350 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -45,13 +45,14 @@
import com.android.settings.LinkifyUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.location.ScanningSettings;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.widget.FooterPreference;
+import com.android.settings.widget.GearPreference;
+import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBarController;
import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
@@ -476,24 +477,25 @@
}
}
- private final View.OnClickListener mDeviceProfilesListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // User clicked on advanced options icon for a device in the list
- if (!(v.getTag() instanceof CachedBluetoothDevice)) {
- Log.w(TAG, "onClick() called for other View: " + v);
- return;
- }
-
- final CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
- Bundle args = new Bundle();
- args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
- device.getDevice().getAddress());
- DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
- profileSettings.setArguments(args);
- profileSettings.show(getFragmentManager(),
- DeviceProfilesSettings.class.getSimpleName());
+ private final GearPreference.OnGearClickListener mDeviceProfilesListener = pref -> {
+ // User clicked on advanced options icon for a device in the list
+ if (!(pref instanceof BluetoothDevicePreference)) {
+ Log.w(TAG, "onClick() called for other View: " + pref);
+ return;
}
+ final CachedBluetoothDevice device =
+ ((BluetoothDevicePreference) pref).getBluetoothDevice();
+ if (device == null) {
+ Log.w(TAG, "No BT device attached with this pref: " + pref);
+ return;
+ }
+ final Bundle args = new Bundle();
+ args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
+ device.getDevice().getAddress());
+ final DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
+ profileSettings.setArguments(args);
+ profileSettings.show(getFragmentManager(),
+ DeviceProfilesSettings.class.getSimpleName());
};
/**
@@ -506,7 +508,7 @@
CachedBluetoothDevice cachedDevice = preference.getCachedDevice();
if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
// Only paired device have an associated advanced settings screen
- preference.setOnSettingsClickListener(mDeviceProfilesListener);
+ preference.setOnGearClickListener(mDeviceProfilesListener);
}
}
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 722f9e1..78d6122 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -28,6 +28,7 @@
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
@@ -124,7 +125,11 @@
} else {
pref.setKey(getDashboardKeyForTile(tile));
}
- pref.setSummary(tile.summary);
+ if (tile.summary != null) {
+ pref.setSummary(tile.summary);
+ } else {
+ pref.setSummary(R.string.summary_placeholder);
+ }
if (tile.icon != null) {
pref.setIcon(tile.icon.loadDrawable(activity));
}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index b82c28d..779a8aa 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -63,7 +63,7 @@
@Override
public void dismissSuggestion(Context context, SuggestionParser parser, Tile suggestion) {
- if (parser == null || suggestion == null) {
+ if (parser == null || suggestion == null || context == null) {
return;
}
mMetricsFeatureProvider.action(
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index e12f89e..de92154 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -477,7 +477,7 @@
final ConnectivityManager conn = ConnectivityManager.from(context);
final TelephonyManager tele = TelephonyManager.from(context);
- final int slotId = SubscriptionManager.getSlotId(subId);
+ final int slotId = SubscriptionManager.getSlotIndex(subId);
final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY;
boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index 41dc78f..8eb1f61 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -20,13 +20,18 @@
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.INetworkStatsSession;
+import android.net.NetworkPolicy;
+import android.net.NetworkPolicyManager;
import android.net.NetworkTemplate;
import android.net.TrafficStats;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.telephony.SubscriptionInfo;
@@ -56,6 +61,7 @@
import static android.net.ConnectivityManager.TYPE_ETHERNET;
import static android.net.ConnectivityManager.TYPE_WIFI;
+import static android.net.NetworkPolicy.LIMIT_DISABLED;
public class DataUsageSummary extends DataUsageBase implements Indexable, DataUsageEditController {
@@ -68,6 +74,7 @@
private static final String KEY_STATUS_HEADER = "status_header";
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 DataUsageController mDataUsageController;
private DataUsageInfoController mDataInfoController;
@@ -75,6 +82,10 @@
private Preference mLimitPreference;
private NetworkTemplate mDefaultTemplate;
private int mDataUsageTemplate;
+ private NetworkRestrictionsPreference mNetworkRestrcitionPreference;
+ private WifiManager mWifiManager;
+ private NetworkPolicyManager mPolicyManager;
+ private NetworkPolicyEditor mPolicyEditor;
@Override
protected int getHelpResource() {
@@ -85,16 +96,21 @@
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- boolean hasMobileData = hasMobileData(getContext());
- mDataUsageController = new DataUsageController(getContext());
+ final Context context = getContext();
+ mPolicyManager = NetworkPolicyManager.from(context);
+ mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mPolicyEditor = new NetworkPolicyEditor(mPolicyManager);
+
+ boolean hasMobileData = hasMobileData(context);
+ mDataUsageController = new DataUsageController(context);
mDataInfoController = new DataUsageInfoController();
addPreferencesFromResource(R.xml.data_usage);
- int defaultSubId = getDefaultSubscriptionId(getContext());
+ int defaultSubId = getDefaultSubscriptionId(context);
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
hasMobileData = false;
}
- mDefaultTemplate = getDefaultTemplate(getContext(), defaultSubId);
+ mDefaultTemplate = getDefaultTemplate(context, defaultSubId);
mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
if (!hasMobileData || !isAdmin()) {
@@ -115,11 +131,11 @@
removePreference(KEY_LIMIT_SUMMARY);
mSummaryPreference.setSelectable(false);
}
- boolean hasWifiRadio = hasWifiRadio(getContext());
+ boolean hasWifiRadio = hasWifiRadio(context);
if (hasWifiRadio) {
addWifiSection();
}
- if (hasEthernet(getContext())) {
+ if (hasEthernet(context)) {
addEthernetSection();
}
mDataUsageTemplate = hasMobileData ? R.string.cell_data_template
@@ -171,6 +187,8 @@
TemplatePreferenceCategory category = (TemplatePreferenceCategory)
inflatePreferences(R.xml.data_usage_wifi);
category.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(), 0, services);
+ mNetworkRestrcitionPreference =
+ (NetworkRestrictionsPreference) category.findPreference(KEY_NETWORK_RESTRICTIONS);
}
private void addEthernetSection() {
@@ -259,6 +277,8 @@
mLimitPreference.setSummary(null);
}
+ updateNetworkRestrictionSummary(mNetworkRestrcitionPreference);
+
PreferenceScreen screen = getPreferenceScreen();
for (int i = 1; i < screen.getPreferenceCount(); i++) {
((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
@@ -362,6 +382,39 @@
}
}
+ @VisibleForTesting
+ void updateNetworkRestrictionSummary(NetworkRestrictionsPreference preference) {
+ if (preference == null) {
+ return;
+ }
+ mPolicyEditor.read();
+ int count = 0;
+ for (WifiConfiguration config : mWifiManager.getConfiguredNetworks()) {
+ if (isMetered(config)) {
+ count++;
+ }
+ }
+ preference.setSummary(getResources().getQuantityString(
+ R.plurals.network_restrictions_summary, count, count));
+ }
+
+ @VisibleForTesting
+ boolean isMetered(WifiConfiguration config) {
+ if (config.SSID == null) {
+ return false;
+ }
+ final String networkId = config.isPasspoint() ? config.providerFriendlyName : config.SSID;
+ final NetworkPolicy policy =
+ mPolicyEditor.getPolicyMaybeUnquoted(NetworkTemplate.buildTemplateWifi(networkId));
+ if (policy == null) {
+ return false;
+ }
+ if (policy.limitBytes != LIMIT_DISABLED) {
+ return true;
+ }
+ return policy.metered;
+ }
+
private static class SummaryProvider
implements SummaryLoader.SummaryProvider {
diff --git a/src/com/android/settings/development/DevelopmentSettings.java b/src/com/android/settings/development/DevelopmentSettings.java
index 0a3351a..da6e800 100644
--- a/src/com/android/settings/development/DevelopmentSettings.java
+++ b/src/com/android/settings/development/DevelopmentSettings.java
@@ -203,7 +203,10 @@
"bluetooth_disable_absolute_volume";
private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
"persist.bluetooth.disableabsvol";
+ private static final String BLUETOOTH_AVRCP_VERSION_PROPERTY =
+ "persist.bluetooth.avrcpversion";
+ private static final String BLUETOOTH_SELECT_AVRCP_VERSION_KEY = "bluetooth_select_avrcp_version";
private static final String BLUETOOTH_SELECT_A2DP_CODEC_KEY = "bluetooth_select_a2dp_codec";
private static final String BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY = "bluetooth_select_a2dp_sample_rate";
private static final String BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY = "bluetooth_select_a2dp_bits_per_sample";
@@ -280,6 +283,7 @@
private BluetoothA2dp mBluetoothA2dp;
private final Object mBluetoothA2dpLock = new Object();
+ private ListPreference mBluetoothSelectAvrcpVersion;
private ListPreference mBluetoothSelectA2dpCodec;
private ListPreference mBluetoothSelectA2dpSampleRate;
private ListPreference mBluetoothSelectA2dpBitsPerSample;
@@ -494,6 +498,7 @@
mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
+ mBluetoothSelectAvrcpVersion = addListPreference(BLUETOOTH_SELECT_AVRCP_VERSION_KEY);
mBluetoothSelectA2dpCodec = addListPreference(BLUETOOTH_SELECT_A2DP_CODEC_KEY);
mBluetoothSelectA2dpSampleRate = addListPreference(BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY);
mBluetoothSelectA2dpBitsPerSample = addListPreference(BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY);
@@ -1786,6 +1791,14 @@
String[] summaries;
int index;
+ // Init the AVRCP Version - Default
+ values = getResources().getStringArray(R.array.bluetooth_avrcp_version_values);
+ summaries = getResources().getStringArray(R.array.bluetooth_avrcp_versions);
+ String value = SystemProperties.get(BLUETOOTH_AVRCP_VERSION_PROPERTY, values[0]);
+ index = mBluetoothSelectAvrcpVersion.findIndexOfValue(value);
+ mBluetoothSelectAvrcpVersion.setValue(values[index]);
+ mBluetoothSelectAvrcpVersion.setSummary(summaries[index]);
+
// Init the Codec Type - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_values);
summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries);
@@ -1822,6 +1835,15 @@
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]);
}
+ private void writeBluetoothAvrcpVersion(Object newValue) {
+ SystemProperties.set(BLUETOOTH_AVRCP_VERSION_PROPERTY, newValue.toString());
+ int index = mBluetoothSelectAvrcpVersion.findIndexOfValue(newValue.toString());
+ if (index >= 0) {
+ String[] titles = getResources().getStringArray(R.array.bluetooth_avrcp_versions);
+ mBluetoothSelectAvrcpVersion.setSummary(titles[index]);
+ }
+ }
+
private void updateBluetoothA2dpConfigurationValues() {
int index;
String[] summaries;
@@ -2528,6 +2550,9 @@
updateHdcpValues();
pokeSystemProperties();
return true;
+ } else if (preference == mBluetoothSelectAvrcpVersion) {
+ writeBluetoothAvrcpVersion(newValue);
+ return true;
} else if ((preference == mBluetoothSelectA2dpCodec) ||
(preference == mBluetoothSelectA2dpSampleRate) ||
(preference == mBluetoothSelectA2dpBitsPerSample) ||
diff --git a/src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java b/src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java
index 4fcacd8..c2e2ad8 100644
--- a/src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java
+++ b/src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.content.Intent;
+import android.os.Build;
import android.os.PersistableBundle;
import android.os.UserManager;
import android.support.v7.preference.Preference;
@@ -25,6 +26,7 @@
import android.text.TextUtils;
import android.util.Log;
+import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
@@ -78,6 +80,12 @@
return false;
}
+ @Override
+ public void updateState(Preference preference) {
+ preference.setSummary(mContext.getString(R.string.about_summary,
+ Build.VERSION.RELEASE));
+ }
+
/**
* Trigger client initiated action (send intent) on system update
*/
diff --git a/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java b/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java
index 8394262..003ed11 100644
--- a/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java
+++ b/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java
@@ -17,14 +17,18 @@
import android.Manifest;
import android.content.Context;
+import com.android.settings.core.lifecycle.Lifecycle;
+
public class AdminGrantedCameraPermissionPreferenceController extends
AdminGrantedPermissionsPreferenceControllerBase {
private static final String KEY_ENTERPRISE_PRIVACY_NUMBER_CAMERA_ACCESS_PACKAGES
= "enterprise_privacy_number_camera_access_packages";
- public AdminGrantedCameraPermissionPreferenceController(Context context) {
- super(context, new String[] {Manifest.permission.CAMERA}, Manifest.permission_group.CAMERA);
+ public AdminGrantedCameraPermissionPreferenceController(Context context, Lifecycle lifecycle,
+ boolean async) {
+ super(context, lifecycle, async, new String[] {Manifest.permission.CAMERA},
+ Manifest.permission_group.CAMERA);
}
@Override
diff --git a/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java b/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java
index 4dfc4be..5343483 100644
--- a/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java
+++ b/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java
@@ -17,14 +17,17 @@
import android.Manifest;
import android.content.Context;
+import com.android.settings.core.lifecycle.Lifecycle;
+
public class AdminGrantedLocationPermissionsPreferenceController extends
AdminGrantedPermissionsPreferenceControllerBase {
private static final String KEY_ENTERPRISE_PRIVACY_NUMBER_LOCATION_ACCESS_PACKAGES
= "enterprise_privacy_number_location_access_packages";
- public AdminGrantedLocationPermissionsPreferenceController(Context context) {
- super(context, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
+ public AdminGrantedLocationPermissionsPreferenceController(Context context, Lifecycle lifecycle,
+ boolean async) {
+ super(context, lifecycle, async, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION}, Manifest.permission_group.LOCATION);
}
diff --git a/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java b/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java
index e2ab555..64396c5 100644
--- a/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java
+++ b/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java
@@ -17,14 +17,17 @@
import android.Manifest;
import android.content.Context;
+import com.android.settings.core.lifecycle.Lifecycle;
+
public class AdminGrantedMicrophonePermissionPreferenceController extends
AdminGrantedPermissionsPreferenceControllerBase {
private static final String KEY_ENTERPRISE_PRIVACY_NUMBER_MICROPHONE_ACCESS_PACKAGES
= "enterprise_privacy_number_microphone_access_packages";
- public AdminGrantedMicrophonePermissionPreferenceController(Context context) {
- super(context, new String[] {Manifest.permission.RECORD_AUDIO},
+ public AdminGrantedMicrophonePermissionPreferenceController(Context context,
+ Lifecycle lifecycle, boolean async) {
+ super(context, lifecycle, async, new String[] {Manifest.permission.RECORD_AUDIO},
Manifest.permission_group.MICROPHONE);
}
diff --git a/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java b/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
index 5263817..c60d7e0 100644
--- a/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
+++ b/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) 2017 The Android Open Source Project
*
@@ -20,28 +21,32 @@
import com.android.settings.R;
import com.android.settings.applications.ApplicationFeatureProvider;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public abstract class AdminGrantedPermissionsPreferenceControllerBase extends PreferenceController {
+public abstract class AdminGrantedPermissionsPreferenceControllerBase
+ extends DynamicAvailabilityPreferenceController {
private final String[] mPermissions;
private final String mPermissionGroup;
private final ApplicationFeatureProvider mFeatureProvider;
+ private final boolean mAsync;
- public AdminGrantedPermissionsPreferenceControllerBase(Context context,
- String[] permissions,
- String permissionGroup) {
- super(context);
+ public AdminGrantedPermissionsPreferenceControllerBase(Context context, Lifecycle lifecycle,
+ boolean async, String[] permissions, String permissionGroup) {
+ super(context, lifecycle);
mPermissions = permissions;
mPermissionGroup = permissionGroup;
mFeatureProvider = FeatureFactory.getFactory(context)
.getApplicationFeatureProvider(context);
+ mAsync = async;
}
@Override
public void updateState(Preference preference) {
mFeatureProvider.calculateNumberOfAppsWithAdminGrantedPermissions(mPermissions,
+ true /* async */,
(num) -> {
if (num == 0) {
preference.setVisible(false);
@@ -55,7 +60,22 @@
@Override
public boolean isAvailable() {
- return true;
+ if (mAsync) {
+ // When called on the main UI thread, we must not block. Since calculating the number of
+ // apps that the admin has granted a given permissions takes a bit of time, we always
+ // return true here and determine the pref's actual visibility asynchronously in
+ // updateState().
+ return true;
+ }
+
+ // When called by the search indexer, we are on a background thread that we can block. Also,
+ // changes to the pref's visibility made in updateState() would not be seen by the indexer.
+ // We block and return synchronously whether the admin has granted the given permissions to
+ // any apps or not.
+ final Boolean[] haveAppsWithAdminGrantedPermissions = { null };
+ mFeatureProvider.calculateNumberOfAppsWithAdminGrantedPermissions(mPermissions,
+ false /* async */, (num) -> haveAppsWithAdminGrantedPermissions[0] = num > 0);
+ return haveAppsWithAdminGrantedPermissions[0];
}
@Override
diff --git a/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceController.java b/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceController.java
index 52625ec..4796b75 100644
--- a/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceController.java
+++ b/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceController.java
@@ -14,30 +14,26 @@
package com.android.settings.enterprise;
import android.content.Context;
-import android.support.v7.preference.Preference;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class AlwaysOnVpnManagedProfilePreferenceController extends PreferenceController {
+public class AlwaysOnVpnManagedProfilePreferenceController
+ extends DynamicAvailabilityPreferenceController {
private static final String KEY_ALWAYS_ON_VPN_MANAGED_PROFILE = "always_on_vpn_managed_profile";
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
- public AlwaysOnVpnManagedProfilePreferenceController(Context context) {
- super(context);
+ public AlwaysOnVpnManagedProfilePreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
@Override
- public void updateState(Preference preference) {
- preference.setVisible(mFeatureProvider.isAlwaysOnVpnSetInManagedProfile());
- }
-
- @Override
public boolean isAvailable() {
- return true;
+ return mFeatureProvider.isAlwaysOnVpnSetInManagedProfile();
}
@Override
diff --git a/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceController.java b/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceController.java
index c7ffeaf..e5823fe 100644
--- a/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceController.java
+++ b/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceController.java
@@ -17,16 +17,18 @@
import android.support.v7.preference.Preference;
import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class AlwaysOnVpnPrimaryUserPreferenceController extends PreferenceController {
+public class AlwaysOnVpnPrimaryUserPreferenceController
+ extends DynamicAvailabilityPreferenceController {
private static final String KEY_ALWAYS_ON_VPN_PRIMARY_USER = "always_on_vpn_primary_user";
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
- public AlwaysOnVpnPrimaryUserPreferenceController(Context context) {
- super(context);
+ public AlwaysOnVpnPrimaryUserPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
@@ -36,12 +38,11 @@
preference.setTitle(mFeatureProvider.isInCompMode()
? R.string.enterprise_privacy_always_on_vpn_personal
: R.string.enterprise_privacy_always_on_vpn_device);
- preference.setVisible(mFeatureProvider.isAlwaysOnVpnSetInPrimaryUser());
}
@Override
public boolean isAvailable() {
- return true;
+ return mFeatureProvider.isAlwaysOnVpnSetInPrimaryUser();
}
@Override
diff --git a/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceController.java b/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceController.java
deleted file mode 100644
index 1895e09..0000000
--- a/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceController.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.enterprise;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v7.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
-import com.android.settings.overlay.FeatureFactory;
-
-public class CaCertsCurrentUserPreferenceController extends PreferenceController {
-
- private static final String CA_CERTS_CURRENT_USER = "ca_certs_current_user";
- private final EnterprisePrivacyFeatureProvider mFeatureProvider;
-
- public CaCertsCurrentUserPreferenceController(Context context) {
- super(context);
- mFeatureProvider = FeatureFactory.getFactory(context)
- .getEnterprisePrivacyFeatureProvider(context);
- }
-
- @Override
- public void updateState(Preference preference) {
- final int certs = mFeatureProvider.getNumberOfOwnerInstalledCaCertsInCurrentUser();
- if (certs == 0) {
- preference.setVisible(false);
- return;
- }
- preference.setTitle(mFeatureProvider.isInCompMode()
- ? R.string.enterprise_privacy_ca_certs_personal
- : R.string.enterprise_privacy_ca_certs_user);
- preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_ca_certs, certs, certs));
- preference.setVisible(true);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return CA_CERTS_CURRENT_USER;
- }
-}
diff --git a/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceController.java b/src/com/android/settings/enterprise/CaCertsPreferenceController.java
similarity index 68%
rename from src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceController.java
rename to src/com/android/settings/enterprise/CaCertsPreferenceController.java
index cc0d4f6..d020676 100644
--- a/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceController.java
+++ b/src/com/android/settings/enterprise/CaCertsPreferenceController.java
@@ -19,39 +19,37 @@
import android.support.v7.preference.Preference;
import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class CaCertsManagedProfilePreferenceController extends PreferenceController {
+public class CaCertsPreferenceController extends DynamicAvailabilityPreferenceController {
- private static final String KEY_CA_CERTS_MANAGED_PROFILE = "ca_certs_managed_profile";
+ private static final String CA_CERTS = "ca_certs";
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
- public CaCertsManagedProfilePreferenceController(Context context) {
- super(context);
+ public CaCertsPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
@Override
public void updateState(Preference preference) {
- final int certs = mFeatureProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile();
- if (certs == 0) {
- preference.setVisible(false);
- return;
- }
+ final int certs =
+ mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
preference.setSummary(mContext.getResources().getQuantityString(
R.plurals.enterprise_privacy_number_ca_certs, certs, certs));
- preference.setVisible(true);
}
@Override
public boolean isAvailable() {
- return true;
+ return mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile()
+ > 0;
}
@Override
public String getPreferenceKey() {
- return KEY_CA_CERTS_MANAGED_PROFILE;
+ return CA_CERTS;
}
}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
index 2270efa..4478865 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
@@ -98,15 +98,9 @@
/**
* Returns the number of CA certificates that the Device Owner or Profile Owner installed in
- * the current user.
+ * the current user and the user's managed profile (if any).
*/
- int getNumberOfOwnerInstalledCaCertsInCurrentUser();
-
- /**
- * Returns the number of CA certificates that the Profile Owner installed in the current user's
- * managed profile (if any).
- */
- int getNumberOfOwnerInstalledCaCertsInManagedProfile();
+ int getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
/**
* Returns the number of Device Admin apps active in the current user and the user's managed
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index 6cff807..69eaa2e 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -189,19 +189,20 @@
}
@Override
- public int getNumberOfOwnerInstalledCaCertsInCurrentUser() {
- final List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(MY_USER_ID));
- return certs != null ? certs.size() : 0;
- }
-
- @Override
- public int getNumberOfOwnerInstalledCaCertsInManagedProfile() {
- final int userId = getManagedProfileUserId();
- if (userId == UserHandle.USER_NULL) {
- return 0;
+ public int getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile() {
+ int num = 0;
+ List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(MY_USER_ID));
+ if (certs != null) {
+ num += certs.size();
}
- final List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(userId));
- return certs != null ? certs.size() : 0;
+ final int userId = getManagedProfileUserId();
+ if (userId != UserHandle.USER_NULL) {
+ certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(userId));
+ if (certs != null) {
+ num += certs.size();
+ }
+ }
+ return num;
}
@Override
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index 0fb341a..55ec3ea 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -64,18 +64,21 @@
controllers.add(new SecurityLogsPreferenceController(context));
controllers.add(new EnterpriseInstalledPackagesPreferenceController(context, lifecycle,
async));
- controllers.add(new AdminGrantedLocationPermissionsPreferenceController(context));
- controllers.add(new AdminGrantedMicrophonePermissionPreferenceController(context));
- controllers.add(new AdminGrantedCameraPermissionPreferenceController(context));
+ controllers.add(new AdminGrantedLocationPermissionsPreferenceController(context, lifecycle,
+ async));
+ controllers.add(new AdminGrantedMicrophonePermissionPreferenceController(context, lifecycle,
+ async));
+ controllers.add(new AdminGrantedCameraPermissionPreferenceController(context, lifecycle,
+ async));
controllers.add(new EnterpriseSetDefaultAppsPreferenceController(context, lifecycle));
- controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context));
- controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context));
- controllers.add(new GlobalHttpProxyPreferenceController(context));
- controllers.add(new CaCertsCurrentUserPreferenceController(context));
- controllers.add(new CaCertsManagedProfilePreferenceController(context));
- controllers.add(new FailedPasswordWipePrimaryUserPreferenceController(context));
- controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
- controllers.add(new ImePreferenceController(context));
+ controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context, lifecycle));
+ controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context, lifecycle));
+ controllers.add(new GlobalHttpProxyPreferenceController(context, lifecycle));
+ controllers.add(new CaCertsPreferenceController(context, lifecycle));
+ controllers.add(new FailedPasswordWipePrimaryUserPreferenceController(context, lifecycle));
+ controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context,
+ lifecycle));
+ controllers.add(new ImePreferenceController(context, lifecycle));
return controllers;
}
diff --git a/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java b/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java
index 5a0e7c8..205d7c1 100644
--- a/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java
+++ b/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java
@@ -14,6 +14,7 @@
package com.android.settings.enterprise;
import android.content.Context;
+import com.android.settings.core.lifecycle.Lifecycle;
public class FailedPasswordWipeManagedProfilePreferenceController
extends FailedPasswordWipePreferenceControllerBase {
@@ -21,8 +22,9 @@
private static final String KEY_FAILED_PASSWORD_WIPE_MANAGED_PROFILE
= "failed_password_wipe_managed_profile";
- public FailedPasswordWipeManagedProfilePreferenceController(Context context) {
- super(context);
+ public FailedPasswordWipeManagedProfilePreferenceController(Context context,
+ Lifecycle lifecycle) {
+ super(context, lifecycle);
}
@Override
diff --git a/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java b/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java
index ee4aecf..2f35da6 100644
--- a/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java
+++ b/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java
@@ -19,15 +19,17 @@
import android.support.v7.preference.Preference;
import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public abstract class FailedPasswordWipePreferenceControllerBase extends PreferenceController {
+public abstract class FailedPasswordWipePreferenceControllerBase
+ extends DynamicAvailabilityPreferenceController {
protected final EnterprisePrivacyFeatureProvider mFeatureProvider;
- public FailedPasswordWipePreferenceControllerBase(Context context) {
- super(context);
+ public FailedPasswordWipePreferenceControllerBase(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
@@ -37,18 +39,13 @@
@Override
public void updateState(Preference preference) {
final int failedPasswordsBeforeWipe = getMaximumFailedPasswordsBeforeWipe();
- if (failedPasswordsBeforeWipe == 0) {
- preference.setVisible(false);
- } else {
- preference.setVisible(true);
- preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_failed_password_wipe,
- failedPasswordsBeforeWipe, failedPasswordsBeforeWipe));
- }
+ preference.setSummary(mContext.getResources().getQuantityString(
+ R.plurals.enterprise_privacy_number_failed_password_wipe,
+ failedPasswordsBeforeWipe, failedPasswordsBeforeWipe));
}
@Override
public boolean isAvailable() {
- return true;
+ return getMaximumFailedPasswordsBeforeWipe() > 0;
}
}
diff --git a/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java b/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java
index 44c6383..2e18f89 100644
--- a/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java
+++ b/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java
@@ -15,14 +15,16 @@
import android.content.Context;
+import com.android.settings.core.lifecycle.Lifecycle;
+
public class FailedPasswordWipePrimaryUserPreferenceController
extends FailedPasswordWipePreferenceControllerBase {
private static final String KEY_FAILED_PASSWORD_WIPE_PRIMARY_USER
= "failed_password_wipe_primary_user";
- public FailedPasswordWipePrimaryUserPreferenceController(Context context) {
- super(context);
+ public FailedPasswordWipePrimaryUserPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
}
@Override
diff --git a/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceController.java b/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceController.java
index e2f2ab9..6ee7fc4 100644
--- a/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceController.java
+++ b/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceController.java
@@ -14,30 +14,25 @@
package com.android.settings.enterprise;
import android.content.Context;
-import android.support.v7.preference.Preference;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class GlobalHttpProxyPreferenceController extends PreferenceController {
+public class GlobalHttpProxyPreferenceController extends DynamicAvailabilityPreferenceController {
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
- public GlobalHttpProxyPreferenceController(Context context) {
- super(context);
+ public GlobalHttpProxyPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
@Override
- public void updateState(Preference preference) {
- preference.setVisible(mFeatureProvider.isGlobalHttpProxySet());
- }
-
- @Override
public boolean isAvailable() {
- return true;
+ return mFeatureProvider.isGlobalHttpProxySet();
}
@Override
diff --git a/src/com/android/settings/enterprise/ImePreferenceController.java b/src/com/android/settings/enterprise/ImePreferenceController.java
index 3c0cc26..b090bed 100644
--- a/src/com/android/settings/enterprise/ImePreferenceController.java
+++ b/src/com/android/settings/enterprise/ImePreferenceController.java
@@ -19,35 +19,31 @@
import android.support.v7.preference.Preference;
import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class ImePreferenceController extends PreferenceController {
+public class ImePreferenceController extends DynamicAvailabilityPreferenceController {
private static final String KEY_INPUT_METHOD = "input_method";
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
- public ImePreferenceController(Context context) {
- super(context);
+ public ImePreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
@Override
public void updateState(Preference preference) {
- final String ownerSetIme = mFeatureProvider.getImeLabelIfOwnerSet();
- if (ownerSetIme == null) {
- preference.setVisible(false);
- return;
- }
preference.setSummary(mContext.getResources().getString(
- R.string.enterprise_privacy_input_method_name, ownerSetIme));
- preference.setVisible(true);
+ R.string.enterprise_privacy_input_method_name,
+ mFeatureProvider.getImeLabelIfOwnerSet()));
}
@Override
public boolean isAvailable() {
- return true;
+ return mFeatureProvider.getImeLabelIfOwnerSet() != null;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
index bed2dc5..1f6030e 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
@@ -36,7 +37,8 @@
*/
public class BatteryHistoryPreference extends Preference {
- private BatteryInfo mBatteryInfo;
+ @VisibleForTesting
+ BatteryInfo mBatteryInfo;
public BatteryHistoryPreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -57,11 +59,8 @@
if (mBatteryInfo == null) {
return;
}
- view.setDividerAllowedAbove(true);
+
((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
- ((TextView) view.findViewById(R.id.estimation)).setText(
- mBatteryInfo.remainingLabel != null ?
- mBatteryInfo.remainingLabel : mBatteryInfo.statusLabel);
UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
usageView.findViewById(R.id.label_group).setAlpha(.7f);
mBatteryInfo.bindHistory(usageView);
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index c3a4d90..93e7810 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -15,6 +15,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
+import android.os.BatteryStats;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.support.annotation.ColorInt;
@@ -46,6 +47,7 @@
private static final String TAG = "AdvancedBatteryUsage";
private static final String KEY_BATTERY_GRAPH = "battery_graph";
private static final String KEY_BATTERY_USAGE_LIST = "battery_usage_list";
+ private static final int STATUS_TYPE = BatteryStats.STATS_SINCE_CHARGED;
@VisibleForTesting
final int[] mUsageTypes = {
@@ -165,9 +167,10 @@
// TODO(b/35396770): add logic to extract the summary
final List<PowerUsageData> batteryDataList = new ArrayList<>(batteryDataMap.values());
+ final int dischargeAmount = statusHelper.getStats().getDischargeAmount(STATUS_TYPE);
final double totalPower = statusHelper.getTotalPower();
for (final PowerUsageData usageData : batteryDataList) {
- usageData.percentage = (usageData.totalPowerMah / totalPower) * 100;
+ usageData.percentage = (usageData.totalPowerMah / totalPower) * dischargeAmount;
}
Collections.sort(batteryDataList);
diff --git a/src/com/android/settings/inputmethod/SpellCheckerPreference.java b/src/com/android/settings/inputmethod/SpellCheckerPreference.java
index c730bcc..02a2e29 100644
--- a/src/com/android/settings/inputmethod/SpellCheckerPreference.java
+++ b/src/com/android/settings/inputmethod/SpellCheckerPreference.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.support.v7.preference.ListPreference;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.TextUtils;
import android.view.View;
@@ -46,7 +45,7 @@
public SpellCheckerPreference(final Context context, final SpellCheckerInfo[] scis) {
super(context, null);
mScis = scis;
- setWidgetLayoutResource(R.layout.preference_widget_settings);
+ setWidgetLayoutResource(R.layout.preference_widget_gear);
CharSequence[] labels = new CharSequence[scis.length];
CharSequence[] values = new CharSequence[scis.length];
for (int i = 0 ; i < scis.length; i++) {
diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java
index ef9f84b..5a2c0c7 100644
--- a/src/com/android/settings/language/LanguageAndInputSettings.java
+++ b/src/com/android/settings/language/LanguageAndInputSettings.java
@@ -16,26 +16,34 @@
package com.android.settings.language;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
+import android.provider.Settings;
import android.speech.tts.TtsEngines;
import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
+import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.gestures.AssistGesturePreferenceController;
import com.android.settings.gestures.DoubleTapPowerPreferenceController;
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
import com.android.settings.gestures.DoubleTwistPreferenceController;
import com.android.settings.gestures.PickupGesturePreferenceController;
+import com.android.settings.gestures.SwipeToNotificationPreferenceController;
import com.android.settings.inputmethod.GameControllerPreferenceController;
import com.android.settings.inputmethod.SpellCheckerPreferenceController;
-import com.android.settings.gestures.SwipeToNotificationPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import java.util.ArrayList;
@@ -96,6 +104,7 @@
context, lifecycle, mAmbientDisplayConfig, UserHandle.myUserId()));
controllers.add(new DoubleTapScreenPreferenceController(
context, lifecycle, mAmbientDisplayConfig, UserHandle.myUserId()));
+ controllers.add(new DefaultAutofillPreferenceController(context));
return controllers;
}
@@ -104,6 +113,43 @@
mAmbientDisplayConfig = ambientConfig;
}
+ private static class SummaryProvider implements SummaryLoader.SummaryProvider {
+
+ private final Context mContext;
+ private final SummaryLoader mSummaryLoader;
+
+ public SummaryProvider(Context context, SummaryLoader summaryLoader) {
+ mContext = context;
+ mSummaryLoader = summaryLoader;
+ }
+
+ @Override
+ public void setListening(boolean listening) {
+ if (listening) {
+ final String flattenComponent = Settings.Secure.getString(
+ mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
+ if (!TextUtils.isEmpty(flattenComponent)) {
+ final PackageManager packageManage = mContext.getPackageManager();
+ final String pkg = ComponentName.unflattenFromString(flattenComponent)
+ .getPackageName();
+ final InputMethodManager imm = (InputMethodManager) mContext.getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+ final List<InputMethodInfo> imis = imm.getInputMethodList();
+ for (InputMethodInfo imi : imis) {
+ if (TextUtils.equals(imi.getPackageName(), pkg)) {
+ mSummaryLoader.setSummary(this, imi.loadLabel(packageManage));
+ return;
+ }
+ }
+ }
+ mSummaryLoader.setSummary(this, "");
+ }
+ }
+ }
+
+ public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
+ = (activity, summaryLoader) -> new SummaryProvider(activity, summaryLoader);
+
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/nfc/NfcPaymentPreference.java b/src/com/android/settings/nfc/NfcPaymentPreference.java
index 4738728..072d454 100644
--- a/src/com/android/settings/nfc/NfcPaymentPreference.java
+++ b/src/com/android/settings/nfc/NfcPaymentPreference.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.nfc;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -33,7 +32,6 @@
import com.android.settings.CustomDialogPreference;
import com.android.settings.R;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
import java.util.List;
@@ -59,7 +57,7 @@
mAdapter = new NfcPaymentAdapter();
setDialogTitle(context.getString(R.string.nfc_payment_pay_with));
mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- setWidgetLayoutResource(R.layout.preference_widget_settings);
+ setWidgetLayoutResource(R.layout.preference_widget_gear);
refresh();
}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 24405b3..fec489a 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -203,7 +203,7 @@
int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
if (deletedChannelCount > 0) {
DimmableIconPreference deletedPref = new DimmableIconPreference(getPrefContext());
- deletedPref.setEnabled(false);
+ deletedPref.setSelectable(false);
deletedPref.setTitle(getResources().getQuantityString(
R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
deletedPref.setIcon(R.drawable.ic_info);
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 7f7aa08..b24e92c 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -40,6 +40,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.DimmableIconPreference;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
import com.android.settings.applications.AppHeaderController;
@@ -131,6 +132,14 @@
intentPref.setTitle(mContext.getString(R.string.app_settings_link));
getPreferenceScreen().addPreference(intentPref);
}
+
+ if (!TextUtils.isEmpty(mChannel.getDescription())) {
+ DimmableIconPreference descPref = new DimmableIconPreference(getPrefContext());
+ descPref.setSelectable(false);
+ descPref.setSummary(mChannel.getDescription());
+ descPref.setIcon(R.drawable.ic_info);
+ getPreferenceScreen().addPreference(descPref);
+ }
}
private void setupLights() {
diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java
index b0f698f..07d6931 100644
--- a/src/com/android/settings/print/PrintSettingsFragment.java
+++ b/src/com/android/settings/print/PrintSettingsFragment.java
@@ -597,8 +597,6 @@
data = new SearchIndexableRaw(context);
data.key = componentName.flattenToString();
data.title = service.getResolveInfo().loadLabel(packageManager).toString();
- data.summaryOn = context.getString(R.string.print_feature_state_on);
- data.summaryOff = context.getString(R.string.print_feature_state_off);
data.screenTitle = screenTitle;
indexables.add(data);
}
diff --git a/src/com/android/settings/search2/SearchFragment.java b/src/com/android/settings/search2/SearchFragment.java
index eb760ee..8e1e1b4 100644
--- a/src/com/android/settings/search2/SearchFragment.java
+++ b/src/com/android/settings/search2/SearchFragment.java
@@ -157,7 +157,7 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- final View view = inflater.inflate(R.layout.search_panel_2, container, false);
+ final View view = inflater.inflate(R.layout.search_panel, container, false);
mResultsRecyclerView = view.findViewById(R.id.list_results);
mResultsRecyclerView.setAdapter(mSearchAdapter);
mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
diff --git a/src/com/android/settings/widget/GearPreference.java b/src/com/android/settings/widget/GearPreference.java
index 7659f0f..9593798 100644
--- a/src/com/android/settings/widget/GearPreference.java
+++ b/src/com/android/settings/widget/GearPreference.java
@@ -33,7 +33,6 @@
public GearPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- setWidgetLayoutResource(R.layout.preference_widget_settings);
}
public void setOnGearClickListener(OnGearClickListener l) {
@@ -42,6 +41,16 @@
}
@Override
+ protected int getSecondTargetResId() {
+ return R.layout.preference_widget_gear;
+ }
+
+ @Override
+ protected boolean shouldHideSecondTarget() {
+ return mOnGearClickListener == null;
+ }
+
+ @Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final View gear = holder.findViewById(R.id.settings_button);
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index 84f1532..3a771bb 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -17,7 +17,6 @@
package com.android.settings.widget;
import android.content.Context;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.View;
@@ -27,12 +26,13 @@
import com.android.settings.R;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.TwoTargetPreference;
/**
* A custom preference that provides inline switch toggle. It has a mandatory field for title, and
* optional fields for icon and sub-text.
*/
-public class MasterSwitchPreference extends Preference {
+public class MasterSwitchPreference extends TwoTargetPreference {
private Switch mSwitch;
private boolean mChecked;
@@ -41,28 +41,29 @@
public MasterSwitchPreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- init();
}
public MasterSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- init();
}
public MasterSwitchPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- init();
}
public MasterSwitchPreference(Context context) {
super(context);
- init();
+ }
+
+ @Override
+ protected int getSecondTargetResId() {
+ return R.layout.preference_widget_master_switch;
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- final View widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
+ final View widgetView = holder.findViewById(android.R.id.widget_frame);
if (widgetView != null) {
widgetView.setOnClickListener(new OnClickListener() {
@Override
@@ -76,12 +77,12 @@
}
});
}
- mSwitch = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+ mSwitch = (Switch) holder.findViewById(R.id.switchWidget);
if (mSwitch != null) {
mSwitch.setChecked(mChecked);
}
if (mMultiLine) {
- TextView textView = (TextView)holder.findViewById(android.R.id.title);
+ TextView textView = (TextView) holder.findViewById(android.R.id.title);
if (textView != null) {
textView.setSingleLine(false);
}
@@ -99,10 +100,6 @@
}
}
- public boolean isSwitchEnabled() {
- return mSwitch != null && mSwitch.isEnabled();
- }
-
public void setSwitchEnabled(boolean enabled) {
if (mSwitch != null) {
mSwitch.setEnabled(enabled);
@@ -128,9 +125,4 @@
public Switch getSwitch() {
return mSwitch;
}
-
- private void init() {
- setLayoutResource(R.layout.preference_master_switch);
- setWidgetLayoutResource(R.layout.preference_widget_master_switch);
- }
}
diff --git a/src/com/android/settings/wifi/WifiApEnabler.java b/src/com/android/settings/wifi/WifiApEnabler.java
index 760879e..8e577a4 100644
--- a/src/com/android/settings/wifi/WifiApEnabler.java
+++ b/src/com/android/settings/wifi/WifiApEnabler.java
@@ -28,7 +28,6 @@
import com.android.settings.R;
import com.android.settings.datausage.DataSaverBackend;
-import com.android.settingslib.TetherUtil;
import java.util.ArrayList;
@@ -140,6 +139,8 @@
updateConfigSummary(wifiConfig);
} else if (wifiErrored) {
mSwitch.setSummary(R.string.wifi_error);
+ } else {
+ mSwitch.setSummary(R.string.wifi_hotspot_off_subtext);
}
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index f6e4022..ab1e04e 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.wifi;
+import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
+
import android.annotation.NonNull;
import android.app.Activity;
import android.app.Dialog;
@@ -70,12 +72,11 @@
import com.android.settingslib.wifi.AccessPoint.AccessPointListener;
import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.WifiTracker;
+import com.android.settingslib.wifi.WifiTrackerFactory;
import java.util.ArrayList;
import java.util.List;
-import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
-
/**
* Two types of UI are provided here.
*
@@ -231,8 +232,8 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- mWifiTracker =
- new WifiTracker(getActivity(), this, mBgThread.getLooper(), true, true, false);
+ mWifiTracker = WifiTrackerFactory.create(
+ getActivity(), this, mBgThread.getLooper(), true, true, false);
mWifiManager = mWifiTracker.getManager();
mConnectListener = new WifiManager.ActionListener() {
diff --git a/src/com/android/settings/wifi/WifiSummaryUpdater.java b/src/com/android/settings/wifi/WifiSummaryUpdater.java
index 533ee07..c0d4468 100644
--- a/src/com/android/settings/wifi/WifiSummaryUpdater.java
+++ b/src/com/android/settings/wifi/WifiSummaryUpdater.java
@@ -26,6 +26,8 @@
import com.android.settings.widget.SummaryUpdater;
import com.android.settingslib.wifi.WifiStatusTracker;
+import static android.net.wifi.WifiInfo.removeDoubleQuotes;
+
/**
* Helper class that listeners to wifi callback and notify client when there is update in
* wifi summary info.
@@ -78,7 +80,7 @@
if (!mWifiTracker.connected) {
return mContext.getString(R.string.disconnected);
}
- return mWifiTracker.ssid;
+ return removeDoubleQuotes(mWifiTracker.ssid);
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
index bd55fd0..79f452a 100644
--- a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.applications;
-import android.annotation.IdRes;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
@@ -25,12 +24,10 @@
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.support.v7.preference.Preference;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.ImageView;
import android.widget.TextView;
import com.android.settings.R;
@@ -44,8 +41,8 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
@@ -55,8 +52,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.EnumSet;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class AppHeaderControllerTest {
@@ -79,7 +74,8 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mShadowContext = ShadowApplication.getInstance().getApplicationContext();
+ mShadowContext = RuntimeEnvironment.application;
+ when(mFragment.getContext()).thenReturn(mShadowContext);
mLayoutInflater = LayoutInflater.from(mShadowContext);
mInfo = new PackageInfo();
mInfo.versionName = "1234";
@@ -292,4 +288,12 @@
assertThat(label.getText()).isEqualTo(
appHeader.getResources().getString(R.string.install_type_instant));
}
+
+ @Test
+ public void initAppHeaderController_appHeaderNull_useFragmentContext() {
+ mController = new AppHeaderController(mContext, mFragment, null);
+
+ // Fragment.getContext() is invoked to inflate the view
+ verify(mFragment).getContext();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index a717306..68c153c 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -83,6 +83,7 @@
PreferenceManager mManager;
PreferenceScreen mScreen;
+ Context mShadowContext;
public TestFragment() {
mPm = mock(PackageManager.class);
@@ -90,10 +91,10 @@
mScreen = mock(PreferenceScreen.class);
mPackageInfo = new PackageInfo();
mPackageInfo.applicationInfo = new ApplicationInfo();
+ mShadowContext = ShadowApplication.getInstance().getApplicationContext();
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
(InstantAppDataProvider) (info -> false));
- when(mManager.getContext())
- .thenReturn(ShadowApplication.getInstance().getApplicationContext());
+ when(mManager.getContext()).thenReturn(mShadowContext);
}
@Override
@@ -120,6 +121,11 @@
public PreferenceManager getPreferenceManager() {
return mManager;
}
+
+ @Override
+ public Context getContext() {
+ return mShadowContext;
+ }
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
index 3dd3a65..dfef3b8 100644
--- a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
@@ -89,8 +89,7 @@
MockitoAnnotations.initMocks(this);
}
- @Test
- public void testCountInstalledAppsAcrossAllUsers() throws Exception {
+ private void verifyCountInstalledAppsAcrossAllUsers(boolean async) throws Exception {
// There are two users.
mUsersToCount = Arrays.asList(
new UserInfo(MAIN_USER_ID, "main", UserInfo.FLAG_ADMIN),
@@ -181,10 +180,14 @@
.thenReturn(PackageManager.INSTALL_REASON_UNKNOWN);
// Count the number of all apps installed that were granted on or more permissions by the
- // admin. Wait for the background task to finish.
- (new AppWithAdminGrantedPermissionsCounterTestable(PERMISSIONS)).execute();
- ShadowApplication.runBackgroundTasks();
-
+ // admin.
+ if (async) {
+ (new AppWithAdminGrantedPermissionsCounterTestable(PERMISSIONS)).execute();
+ // Wait for the background task to finish.
+ ShadowApplication.runBackgroundTasks();
+ } else {
+ (new AppWithAdminGrantedPermissionsCounterTestable(PERMISSIONS)).executeInForeground();
+ }
assertThat(mAppCount).isEqualTo(3);
// Verify that installed packages were retrieved for the users returned by
@@ -194,7 +197,16 @@
eq(MANAGED_PROFILE_ID));
verify(mPackageManager, atLeast(0)).getInstallReason(anyObject(), anyObject());
verifyNoMoreInteractions(mPackageManager);
+ }
+ @Test
+ public void testCountInstalledAppsAcrossAllUsersSync() throws Exception {
+ verifyCountInstalledAppsAcrossAllUsers(false /* async */);
+ }
+
+ @Test
+ public void testCountInstalledAppsAcrossAllUsersAync() throws Exception {
+ verifyCountInstalledAppsAcrossAllUsers(true /* async */);
}
private class AppWithAdminGrantedPermissionsCounterTestable extends
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index 3c8d933..a513f71 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -88,7 +88,7 @@
mPackageManagerService, mDevicePolicyManager);
}
- private void testCalculateNumberOfInstalledApps(boolean async) {
+ private void verifyCalculateNumberOfInstalledApps(boolean async) {
setUpUsersAndInstalledApps();
when(mPackageManager.getInstallReason(APP_1, new UserHandle(MAIN_USER_ID)))
@@ -117,16 +117,16 @@
@Test
public void testCalculateNumberOfInstalledAppsSync() {
- testCalculateNumberOfInstalledApps(false /* async */);
+ verifyCalculateNumberOfInstalledApps(false /* async */);
}
@Test
public void testCalculateNumberOfInstalledAppsAsync() {
- testCalculateNumberOfInstalledApps(true /* async */);
+ verifyCalculateNumberOfInstalledApps(true /* async */);
}
- @Test
- public void testCalculateNumberOfAppsWithAdminGrantedPermissions() throws Exception {
+ private void verifyCalculateNumberOfAppsWithAdminGrantedPermissions(boolean async)
+ throws Exception {
setUpUsersAndInstalledApps();
when(mDevicePolicyManager.getPermissionGrantState(null, APP_1, PERMISSION))
@@ -143,16 +143,26 @@
.thenReturn(PackageManager.INSTALL_REASON_POLICY);
mAppCount = -1;
- mProvider.calculateNumberOfAppsWithAdminGrantedPermissions(new String[] {PERMISSION},
- (num) -> {
- mAppCount = num;
- });
- ShadowApplication.runBackgroundTasks();
+ mProvider.calculateNumberOfAppsWithAdminGrantedPermissions(new String[] {PERMISSION}, async,
+ (num) -> mAppCount = num);
+ if (async) {
+ ShadowApplication.runBackgroundTasks();
+ }
assertThat(mAppCount).isEqualTo(2);
}
@Test
+ public void testCalculateNumberOfAppsWithAdminGrantedPermissionsSync() throws Exception {
+ verifyCalculateNumberOfAppsWithAdminGrantedPermissions(false /* async */);
+ }
+
+ @Test
+ public void testCalculateNumberOfAppsWithAdminGrantedPermissionsAsync() throws Exception {
+ verifyCalculateNumberOfAppsWithAdminGrantedPermissions(true /* async */);
+ }
+
+ @Test
public void testFindPersistentPreferredActivities() throws Exception {
when(mUserManager.getUserProfiles()).thenReturn(Arrays.asList(new UserHandle(MAIN_USER_ID),
new UserHandle(MANAGED_PROFILE_ID)));
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
index 550addb..6dc2e64 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
@@ -21,6 +21,7 @@
import android.os.UserManager;
import android.support.v7.preference.Preference;
+import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -75,7 +76,7 @@
mController.updateState(mPreference);
- verify(mPreference).setSummary(null);
+ verify(mPreference).setSummary(R.string.app_list_preference_none);
}
private static class TestPreferenceController extends DefaultAppPreferenceController {
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java
index 7bcbcb0..74612e3 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java
@@ -23,6 +23,7 @@
import android.provider.Settings;
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.applications.PackageManagerWrapper;
@@ -75,7 +76,7 @@
final Preference pref = mock(Preference.class);
mController.updateState(pref);
- verify(pref).setSummary(null);
+ verify(pref).setSummary(R.string.app_list_preference_none);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java
index 644a942..ee2cd1d 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java
@@ -23,6 +23,7 @@
import android.os.UserManager;
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.applications.PackageManagerWrapper;
@@ -92,7 +93,7 @@
final Preference pref = mock(Preference.class);
mController.updateState(pref);
- verify(pref).setSummary(null);
+ verify(pref).setSummary(R.string.app_list_preference_none);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index 5915118..c4c1f8a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -17,8 +17,10 @@
import android.bluetooth.BluetoothDevice;
import android.content.Context;
+import android.os.UserManager;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
@@ -32,7 +34,10 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -66,7 +71,7 @@
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
- mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
+ mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
}
@Test
@@ -77,7 +82,7 @@
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
- mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
+ mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
}
@Test
@@ -89,6 +94,46 @@
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
- mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+ mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+ }
+
+ @Test
+ public void getSecondTargetResource_shouldBeGearIconLayout() {
+ assertThat(mPreference.getSecondTargetResId()).isEqualTo(R.layout.preference_widget_gear);
+ }
+
+ @Test
+ public void shouldHideSecondTarget_noDevice_shouldReturnTrue() {
+ ReflectionHelpers.setField(mPreference, "mCachedDevice", null);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void shouldHideSecondTarget_notBond_shouldReturnTrue() {
+ when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_NONE);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void shouldHideSecondTarget_hasUserRestriction_shouldReturnTrue() {
+ final UserManager um = mock(UserManager.class);
+ ReflectionHelpers.setField(mPreference, "mUserManager", um);
+ when(um.hasUserRestriction(UserManager.DISALLOW_CONFIG_BLUETOOTH))
+ .thenReturn(true);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void shouldHideSecondTarget_hasBoundDeviceAndNoRestriction_shouldReturnFalse() {
+ when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
+ final UserManager um = mock(UserManager.class);
+ ReflectionHelpers.setField(mPreference, "mUserManager", um);
+ when(um.hasUserRestriction(UserManager.DISALLOW_CONFIG_BLUETOOTH))
+ .thenReturn(false);
+
+ assertThat(mPreference.shouldHideSecondTarget()).isFalse();
}
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index 4eea05e..28bed3e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -28,6 +28,7 @@
import android.support.v7.preference.Preference;
import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -217,6 +218,32 @@
}
@Test
+ public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
+ final Preference preference = new Preference(RuntimeEnvironment.application);
+ final Tile tile = new Tile();
+ tile.intent = new Intent();
+ tile.intent.setComponent(new ComponentName("pkg", "class"));
+ mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ preference, tile, null /*key */, Preference.DEFAULT_ORDER);
+
+ assertThat(preference.getSummary())
+ .isEqualTo(RuntimeEnvironment.application.getString(R.string.summary_placeholder));
+ }
+
+ @Test
+ public void bindPreference_hasSummary_shouldSetSummary() {
+ final Preference preference = new Preference(RuntimeEnvironment.application);
+ final Tile tile = new Tile();
+ tile.summary = "test";
+ tile.intent = new Intent();
+ tile.intent.setComponent(new ComponentName("pkg", "class"));
+ mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ preference, tile, null /*key */, Preference.DEFAULT_ORDER);
+
+ assertThat(preference.getSummary()).isEqualTo(tile.summary);
+ }
+
+ @Test
public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile();
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
index b36aef2..3efe15a 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
@@ -120,6 +120,14 @@
verify(mContext, never()).getPackageManager();
}
+
+ @Test
+ public void dismissSuggestion_noContext_shouldDoNothing() {
+ mProvider.dismissSuggestion(null, mSuggestionParser, mSuggestion);
+
+ verifyZeroInteractions(mFactory.metricsFeatureProvider);
+ }
+
@Test
public void dismissSuggestion_hasNoMoreDismissCount_shouldDisableComponent() {
when(mSuggestionParser.dismissSuggestion(any(Tile.class), anyBoolean()))
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
index e8a2ee4..71d9ea1 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
@@ -18,8 +18,15 @@
import android.content.Context;
import android.net.ConnectivityManager;
+import android.net.NetworkPolicy;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+
+import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settingslib.NetworkPolicyEditor;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,9 +34,17 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -57,4 +72,75 @@
boolean hasMobileData = DataUsageSummary.hasMobileData(mContext);
assertThat(hasMobileData).isTrue();
}
+
+ @Test
+ public void testUpdateNetworkRestrictionSummary_shouldSetSummary() {
+ final DataUsageSummary dataUsageSummary = spy(new DataUsageSummary());
+ final NetworkRestrictionsPreference preference = mock(NetworkRestrictionsPreference.class);
+ final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
+ final WifiManager wifiManager = mock(WifiManager.class);
+ ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
+ ReflectionHelpers.setField(dataUsageSummary, "mWifiManager", wifiManager);
+ when(wifiManager.getConfiguredNetworks()).thenReturn(new ArrayList<WifiConfiguration>());
+ doReturn(mContext.getResources()).when(dataUsageSummary).getResources();
+
+ dataUsageSummary.updateNetworkRestrictionSummary(preference);
+
+ verify(preference).setSummary(mContext.getResources().getQuantityString(
+ R.plurals.network_restrictions_summary, 0, 0));
+ }
+
+ @Test
+ public void testIsMetered_noSsid_shouldReturnFalse() {
+ final DataUsageSummary dataUsageSummary = new DataUsageSummary();
+ final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
+ ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
+ WifiConfiguration config = mock(WifiConfiguration.class);
+
+ assertThat(dataUsageSummary.isMetered(config)).isFalse();
+ }
+
+ @Test
+ public void testIsMetered_noNetworkPolicy_shouldReturnFalse() {
+ final DataUsageSummary dataUsageSummary = new DataUsageSummary();
+ final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
+ ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
+ WifiConfiguration config = mock(WifiConfiguration.class);
+ config.SSID = "network1";
+ doReturn(null).when(policyEditor).getPolicyMaybeUnquoted(any());
+
+ assertThat(dataUsageSummary.isMetered(config)).isFalse();
+ }
+
+ @Test
+ public void testIsMetered_policyHasLimit_shouldReturnTrue() {
+ final DataUsageSummary dataUsageSummary = new DataUsageSummary();
+ final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
+ ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
+ WifiConfiguration config = mock(WifiConfiguration.class);
+ config.SSID = "network1";
+ NetworkPolicy policy = mock(NetworkPolicy.class);
+ policy.limitBytes = 100;
+ doReturn(policy).when(policyEditor).getPolicyMaybeUnquoted(any());
+
+ assertThat(dataUsageSummary.isMetered(config)).isTrue();
+ }
+
+ @Test
+ public void testIsMetered_noPolicyLimit_shouldReturnMeteredValue() {
+ final DataUsageSummary dataUsageSummary = new DataUsageSummary();
+ final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
+ ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
+ WifiConfiguration config = mock(WifiConfiguration.class);
+ config.SSID = "network1";
+ NetworkPolicy policy = mock(NetworkPolicy.class);
+ policy.limitBytes = NetworkPolicy.LIMIT_DISABLED;
+ doReturn(policy).when(policyEditor).getPolicyMaybeUnquoted(any());
+
+ policy.metered = true;
+ assertThat(dataUsageSummary.isMetered(config)).isTrue();
+
+ policy.metered = false;
+ assertThat(dataUsageSummary.isMetered(config)).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java
index b35c60a..30c6dc9 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java
@@ -16,21 +16,26 @@
package com.android.settings.deviceinfo;
import android.content.Context;
+import android.os.Build;
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 java.util.ArrayList;
-import java.util.List;
+
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 java.util.ArrayList;
+import java.util.List;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Matchers.any;
@@ -92,6 +97,18 @@
}
@Test
+ public void updateState_shouldSetToAndroidVersion() {
+ final Preference preference = new Preference(RuntimeEnvironment.application);
+ mController = new SystemUpdatePreferenceController(
+ RuntimeEnvironment.application, mUserManager);
+ mController.updateState(preference);
+
+ assertThat(preference.getSummary())
+ .isEqualTo(RuntimeEnvironment.application.getString(R.string.about_summary,
+ Build.VERSION.RELEASE));
+ }
+
+ @Test
public void displayPrefs_oneAvailable_shouldDisplayOne() {
final Preference preference = mock(Preference.class);
when(mScreen.getPreferenceCount()).thenReturn(1);
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
index a998fb5..0281ce5 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
@@ -39,8 +39,8 @@
}
@Override
- public void setUp() {
- super.setUp();
- mController = new AdminGrantedCameraPermissionPreferenceController(mContext);
+ protected AdminGrantedPermissionsPreferenceControllerBase createController(boolean async) {
+ return new AdminGrantedCameraPermissionPreferenceController(mContext,null /* lifecycle */,
+ async);
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
index e7aa358..d556296 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
@@ -40,8 +40,8 @@
}
@Override
- public void setUp() {
- super.setUp();
- mController = new AdminGrantedLocationPermissionsPreferenceController(mContext);
+ protected AdminGrantedPermissionsPreferenceControllerBase createController(boolean async) {
+ return new AdminGrantedLocationPermissionsPreferenceController(mContext,
+ null /* lifecycle */, async);
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
index 8c84af2..e2a45ec 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
@@ -39,8 +39,8 @@
}
@Override
- public void setUp() {
- super.setUp();
- mController = new AdminGrantedMicrophonePermissionPreferenceController(mContext);
+ protected AdminGrantedPermissionsPreferenceControllerBase createController(boolean async) {
+ return new AdminGrantedMicrophonePermissionPreferenceController(mContext,
+ null /* lifecycle */, async);
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
index 0d53fb6..4da1cd2 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
@@ -40,17 +40,16 @@
}
@Override
- public void setUp() {
- super.setUp();
- mController = new AdminGrantedPermissionsPreferenceControllerBaseTestable();
+ protected AdminGrantedPermissionsPreferenceControllerBase createController(boolean async) {
+ return new AdminGrantedPermissionsPreferenceControllerBaseTestable(async);
}
private class AdminGrantedPermissionsPreferenceControllerBaseTestable extends
AdminGrantedPermissionsPreferenceControllerBase {
- AdminGrantedPermissionsPreferenceControllerBaseTestable() {
- super(AdminGrantedPermissionsPreferenceControllerBaseTest.this.mContext, mPermissions,
- mPermissionGroup);
+ AdminGrantedPermissionsPreferenceControllerBaseTestable(boolean async) {
+ super(AdminGrantedPermissionsPreferenceControllerBaseTest.this.mContext,
+ null /* lifecycle */, async, mPermissions, mPermissionGroup);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
index 5a70b7a..69e6237 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
@@ -68,39 +68,56 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mController = createController(true /* async */);
}
- private void setNumberOfPackagesWithAdminGrantedPermissions(int number) {
+ private void setNumberOfPackagesWithAdminGrantedPermissions(int number, boolean async) {
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
((ApplicationFeatureProvider.NumberOfAppsCallback)
- invocation.getArguments()[1]).onNumberOfAppsResult(number);
+ invocation.getArguments()[2]).onNumberOfAppsResult(number);
return null;
}}).when(mFeatureFactory.applicationFeatureProvider)
.calculateNumberOfAppsWithAdminGrantedPermissions(eq(mPermissions),
- anyObject());
+ eq(async), anyObject());
}
@Test
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(false);
+ preference.setVisible(true);
- setNumberOfPackagesWithAdminGrantedPermissions(20);
+ setNumberOfPackagesWithAdminGrantedPermissions(0, true /* async */);
+ mController.updateState(preference);
+ assertThat(preference.isVisible()).isFalse();
+
+ setNumberOfPackagesWithAdminGrantedPermissions(20, true /* async */);
when(mContext.getResources().getQuantityString(
R.plurals.enterprise_privacy_number_packages_actionable,20, 20))
.thenReturn("20 packages");
mController.updateState(preference);
assertThat(preference.getSummary()).isEqualTo("20 packages");
assertThat(preference.isVisible()).isTrue();
-
- setNumberOfPackagesWithAdminGrantedPermissions(0);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
}
@Test
- public void testIsAvailable() {
+ public void testIsAvailableSync() {
+ final AdminGrantedPermissionsPreferenceControllerBase controller
+ = createController(false /* async */);
+
+ setNumberOfPackagesWithAdminGrantedPermissions(0, false /* async */);
+ assertThat(controller.isAvailable()).isFalse();
+
+ setNumberOfPackagesWithAdminGrantedPermissions(20, false /* async */);
+ assertThat(controller.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testIsAvailableAsync() {
+ setNumberOfPackagesWithAdminGrantedPermissions(0, true /* async */);
+ assertThat(mController.isAvailable()).isTrue();
+
+ setNumberOfPackagesWithAdminGrantedPermissions(20, true /* async */);
assertThat(mController.isAvailable()).isTrue();
}
@@ -125,4 +142,7 @@
public void testGetPreferenceKey() {
assertThat(mController.getPreferenceKey()).isEqualTo(mKey);
}
+
+ protected abstract AdminGrantedPermissionsPreferenceControllerBase createController(
+ boolean async);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
index a52e049..8ac10d1 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
@@ -52,27 +52,18 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new AlwaysOnVpnManagedProfilePreferenceController(mContext);
- }
-
- @Test
- public void testUpdateState() {
- final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInManagedProfile())
- .thenReturn(false);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInManagedProfile())
- .thenReturn(true);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
+ mController = new AlwaysOnVpnManagedProfilePreferenceController(mContext,
+ null /* lifecycle */);
}
@Test
public void testIsAvailable() {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInManagedProfile())
+ .thenReturn(false);
+ assertThat(mController.isAvailable()).isFalse();
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInManagedProfile())
+ .thenReturn(true);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceControllerTest.java
index d504b84..12fdb4f 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnPrimaryUserPreferenceControllerTest.java
@@ -56,7 +56,8 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new AlwaysOnVpnPrimaryUserPreferenceController(mContext);
+ mController = new AlwaysOnVpnPrimaryUserPreferenceController(mContext,
+ null /* lifecycle */);
when(mContext.getString(R.string.enterprise_privacy_always_on_vpn_device))
.thenReturn(VPN_SET_DEVICE);
when(mContext.getString(R.string.enterprise_privacy_always_on_vpn_personal))
@@ -66,37 +67,27 @@
@Test
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(false);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInPrimaryUser())
- .thenReturn(false);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInPrimaryUser())
.thenReturn(true);
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(false);
mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
assertThat(preference.getTitle()).isEqualTo(VPN_SET_DEVICE);
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInPrimaryUser())
- .thenReturn(false);
mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInPrimaryUser())
- .thenReturn(true);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
assertThat(preference.getTitle()).isEqualTo(VPN_SET_PERSONAL);
}
@Test
public void testIsAvailable() {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInPrimaryUser())
+ .thenReturn(false);
+ assertThat(mController.isAvailable()).isFalse();
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isAlwaysOnVpnSetInPrimaryUser())
+ .thenReturn(true);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
deleted file mode 100644
index c8ffa7e..0000000
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.enterprise;
-
-import android.content.Context;
-import android.content.res.Resources;
-import com.android.settings.R;
-import android.support.v7.preference.Preference;
-
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
-/**
- * Tests for {@link CaCertsCurrentUserPreferenceController}.
- */
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class CaCertsCurrentUserPreferenceControllerTest {
-
- private final String INSTALLED_CERTS_USER = "trusted credentials";
- private final String INSTALLED_CERTS_PERSONAL = "trusted credentials in personal profile";
- private final String NUMBER_INSTALLED_CERTS_1 = "1 cert";
- private final String NUMBER_INSTALLED_CERTS_10 = "10 certs";
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- private FakeFeatureFactory mFeatureFactory;
-
- private CaCertsCurrentUserPreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new CaCertsCurrentUserPreferenceController(mContext);
-
- when(mContext.getString(R.string.enterprise_privacy_ca_certs_user))
- .thenReturn(INSTALLED_CERTS_USER);
- when(mContext.getString(R.string.enterprise_privacy_ca_certs_personal))
- .thenReturn(INSTALLED_CERTS_PERSONAL);
- when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
- 1, 1)).thenReturn(NUMBER_INSTALLED_CERTS_1);
- when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
- 10, 10)).thenReturn(NUMBER_INSTALLED_CERTS_10);
- }
-
- @Test
- public void testUpdateState() {
- final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(false);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(0);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(1);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
- assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_USER);
- assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_1);
-
- preference.setVisible(false);
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(10);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
- assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_USER);
- assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_10);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(0);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(1);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
- assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_PERSONAL);
- assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_1);
-
- preference.setVisible(false);
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(10);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
- assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_PERSONAL);
- assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_10);
- }
-
- @Test
- public void testIsAvailable() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void testHandlePreferenceTreeClick() {
- assertThat(mController.handlePreferenceTreeClick(new Preference(mContext, null, 0, 0)))
- .isFalse();
- }
-
- @Test
- public void testGetPreferenceKey() {
- assertThat(mController.getPreferenceKey()).isEqualTo("ca_certs_current_user");
- }
-}
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTest.java
similarity index 65%
rename from tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java
rename to tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTest.java
index 693cfae..fef2e0f 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTest.java
@@ -37,60 +37,46 @@
import static org.mockito.Mockito.when;
/**
- * Tests for {@link CaCertsManagedProfilePreferenceController}.
+ * Tests for {@link CaCertsPreferenceController}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class CaCertsManagedProfilePreferenceControllerTest {
-
- private final String NUMBER_INSTALLED_CERTS_1 = "1 cert";
- private final String NUMBER_INSTALLED_CERTS_10 = "10 certs";
+public final class CaCertsPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
private FakeFeatureFactory mFeatureFactory;
- private CaCertsManagedProfilePreferenceController mController;
+ private CaCertsPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new CaCertsManagedProfilePreferenceController(mContext);
-
- when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
- 1, 1)).thenReturn(NUMBER_INSTALLED_CERTS_1);
- when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
- 10, 10)).thenReturn(NUMBER_INSTALLED_CERTS_10);
+ mController = new CaCertsPreferenceController(mContext, null /* lifecycle */);
}
@Test
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
+ when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
+ 10, 10)).thenReturn("10 certs");
when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInManagedProfile()).thenReturn(0);
+ .getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile()).thenReturn(10);
mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInManagedProfile()).thenReturn(1);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
- assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_1);
-
- preference.setVisible(false);
- when(mFeatureFactory.enterprisePrivacyFeatureProvider
- .getNumberOfOwnerInstalledCaCertsInManagedProfile()).thenReturn(10);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
- assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_10);
+ assertThat(preference.getSummary()).isEqualTo("10 certs");
}
@Test
public void testIsAvailable() {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider
+ .getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile()).thenReturn(0);
+ assertThat(mController.isAvailable()).isFalse();
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider
+ .getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile()).thenReturn(10);
assertThat(mController.isAvailable()).isTrue();
}
@@ -102,6 +88,6 @@
@Test
public void testGetPreferenceKey() {
- assertThat(mController.getPreferenceKey()).isEqualTo("ca_certs_managed_profile");
+ assertThat(mController.getPreferenceKey()).isEqualTo("ca_certs");
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index 6ff1703..98d0fa6 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -96,7 +96,7 @@
@Test
public void testIsAvailableSync() {
- EnterpriseInstalledPackagesPreferenceController controller
+ final EnterpriseInstalledPackagesPreferenceController controller
= new EnterpriseInstalledPackagesPreferenceController(mContext,
null /* lifecycle */, false /* async */);
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index d4eec19..2afcab9 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -268,39 +268,45 @@
}
@Test
- public void testGetNumberOfOwnerInstalledCaCertsInCurrentUser() {
+ public void testGetNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile() {
final UserHandle userHandle = new UserHandle(UserHandle.USER_SYSTEM);
-
- when(mDevicePolicyManager.getOwnerInstalledCaCerts(userHandle))
- .thenReturn(null);
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInCurrentUser()).isEqualTo(0);
- when(mDevicePolicyManager.getOwnerInstalledCaCerts(userHandle))
- .thenReturn(new ArrayList<String>());
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInCurrentUser()).isEqualTo(0);
- when(mDevicePolicyManager.getOwnerInstalledCaCerts(userHandle))
- .thenReturn(Arrays.asList(new String[] {"ca1", "ca2"}));
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInCurrentUser()).isEqualTo(2);
- }
-
- @Test
- public void testGetNumberOfOwnerInstalledCaCertsInManagedProfile() {
- final UserHandle userHandle = new UserHandle(MANAGED_PROFILE_USER_ID);
+ final UserHandle managedProfileUserHandle = new UserHandle(MANAGED_PROFILE_USER_ID);
final UserInfo managedProfile =
new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE);
- mProfiles.add(managedProfile);
+ when(mDevicePolicyManager.getOwnerInstalledCaCerts(managedProfileUserHandle))
+ .thenReturn(Arrays.asList(new String[] {"ca1", "ca2"}));
+
when(mDevicePolicyManager.getOwnerInstalledCaCerts(userHandle))
.thenReturn(null);
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile()).isEqualTo(0);
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(0);
when(mDevicePolicyManager.getOwnerInstalledCaCerts(userHandle))
.thenReturn(new ArrayList<String>());
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile()).isEqualTo(0);
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(0);
when(mDevicePolicyManager.getOwnerInstalledCaCerts(userHandle))
.thenReturn(Arrays.asList(new String[] {"ca1", "ca2"}));
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile()).isEqualTo(2);
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(2);
+
+ mProfiles.add(managedProfile);
+ when(mDevicePolicyManager.getOwnerInstalledCaCerts(managedProfileUserHandle))
+ .thenReturn(null);
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(2);
+ when(mDevicePolicyManager.getOwnerInstalledCaCerts(managedProfileUserHandle))
+ .thenReturn(new ArrayList<String>());
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(2);
+ when(mDevicePolicyManager.getOwnerInstalledCaCerts(managedProfileUserHandle))
+ .thenReturn(Arrays.asList(new String[] {"ca1", "ca2"}));
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(4);
mProfiles.remove(managedProfile);
- assertThat(mProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile()).isEqualTo(0);
+ assertThat(mProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile())
+ .isEqualTo(2);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 46d6b6c..8a11779 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -117,7 +117,7 @@
private void verifyPreferenceControllers(List<PreferenceController> controllers) {
assertThat(controllers).isNotNull();
- assertThat(controllers.size()).isEqualTo(17);
+ assertThat(controllers.size()).isEqualTo(16);
assertThat(controllers.get(0)).isInstanceOf(InstalledPackagesPreferenceController.class);
assertThat(controllers.get(1)).isInstanceOf(NetworkLogsPreferenceController.class);
assertThat(controllers.get(2)).isInstanceOf(BugReportsPreferenceController.class);
@@ -137,13 +137,11 @@
assertThat(controllers.get(10)).isInstanceOf(
AlwaysOnVpnManagedProfilePreferenceController.class);
assertThat(controllers.get(11)).isInstanceOf(GlobalHttpProxyPreferenceController.class);
- assertThat(controllers.get(12)).isInstanceOf(CaCertsCurrentUserPreferenceController.class);
+ assertThat(controllers.get(12)).isInstanceOf(CaCertsPreferenceController.class);
assertThat(controllers.get(13)).isInstanceOf(
- CaCertsManagedProfilePreferenceController.class);
- assertThat(controllers.get(14)).isInstanceOf(
FailedPasswordWipePrimaryUserPreferenceController.class);
- assertThat(controllers.get(15)).isInstanceOf(
+ assertThat(controllers.get(14)).isInstanceOf(
FailedPasswordWipeManagedProfilePreferenceController.class);
- assertThat(controllers.get(16)).isInstanceOf(ImePreferenceController.class);
+ assertThat(controllers.get(15)).isInstanceOf(ImePreferenceController.class);
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
index c9981f9..99c68f8 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
@@ -43,7 +43,8 @@
@Override
public void setUp() {
super.setUp();
- mController = new FailedPasswordWipeManagedProfilePreferenceController(mContext);
+ mController = new FailedPasswordWipeManagedProfilePreferenceController(mContext,
+ null /* lifecycle */);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
index 1c7b448..74c3de5 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
@@ -50,7 +50,8 @@
private class FailedPasswordWipePreferenceControllerBaseTestable extends
FailedPasswordWipePreferenceControllerBase {
FailedPasswordWipePreferenceControllerBaseTestable() {
- super(FailedPasswordWipePreferenceControllerBaseTest.this.mContext);
+ super(FailedPasswordWipePreferenceControllerBaseTest.this.mContext,
+ null /* lifecycle */);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
index aa189e2..c14b71e 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
@@ -61,7 +61,6 @@
@Test
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(false);
setMaximumFailedPasswordsBeforeWipe(10);
when(mContext.getResources().getQuantityString(
@@ -69,14 +68,14 @@
.thenReturn("10 attempts");
mController.updateState(preference);
assertThat(preference.getSummary()).isEqualTo("10 attempts");
-
- setMaximumFailedPasswordsBeforeWipe(0);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
}
@Test
public void testIsAvailable() {
+ setMaximumFailedPasswordsBeforeWipe(0);
+ assertThat(mController.isAvailable()).isFalse();
+
+ setMaximumFailedPasswordsBeforeWipe(10);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java
index 65c9828..d74b9b8 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java
@@ -43,7 +43,8 @@
@Override
public void setUp() {
super.setUp();
- mController = new FailedPasswordWipePrimaryUserPreferenceController(mContext);
+ mController = new FailedPasswordWipePrimaryUserPreferenceController(mContext,
+ null /* lifecycle */);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
index d505bad..a0bc9ee 100644
--- a/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
@@ -51,27 +51,17 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new GlobalHttpProxyPreferenceController(mContext);
- }
-
- @Test
- public void testUpdateState() {
- final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
- .thenReturn(false);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
- .thenReturn(true);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
+ mController = new GlobalHttpProxyPreferenceController(mContext, null /* lifecycle */);
}
@Test
public void testIsAvailable() {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
+ .thenReturn(false);
+ assertThat(mController.isAvailable()).isFalse();
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
+ .thenReturn(true);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
index 547746c..05d0535 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
@@ -57,7 +57,7 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new ImePreferenceController(mContext);
+ mController = new ImePreferenceController(mContext, null /* lifecycle */);
when(mContext.getResources().getString(R.string.enterprise_privacy_input_method_name,
DEFAULT_IME_LABEL)).thenReturn(DEFAULT_IME_TEXT);
}
@@ -65,22 +65,21 @@
@Test
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
-
- when(mFeatureFactory.enterprisePrivacyFeatureProvider.getImeLabelIfOwnerSet())
- .thenReturn(null);
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
when(mFeatureFactory.enterprisePrivacyFeatureProvider.getImeLabelIfOwnerSet())
.thenReturn(DEFAULT_IME_LABEL);
mController.updateState(preference);
- assertThat(preference.isVisible()).isTrue();
assertThat(preference.getSummary()).isEqualTo(DEFAULT_IME_TEXT);
}
@Test
public void testIsAvailable() {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.getImeLabelIfOwnerSet())
+ .thenReturn(null);
+ assertThat(mController.isAvailable()).isFalse();
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.getImeLabelIfOwnerSet())
+ .thenReturn(DEFAULT_IME_LABEL);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
new file mode 100644
index 0000000..471f9ea
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.fuelgauge;
+
+import android.content.Context;
+import android.os.PowerManager;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settingslib.BatteryInfo;
+import com.android.settingslib.graph.UsageView;
+
+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;
+
+import static org.mockito.AdditionalMatchers.not;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+
+import static org.mockito.Mockito.spy;
+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 BatteryHistoryPreferenceTest {
+ @Mock
+ private PreferenceViewHolder mViewHolder;
+ @Mock
+ private BatteryInfo mBatteryInfo;
+ @Mock
+ private TextView mTextView;
+ @Mock
+ private View mItemView;
+ @Mock
+ private UsageView mUsageView;
+ @Mock
+ private View mLabelView;
+ private BatteryHistoryPreference mBatteryHistoryPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ final View itemView = LayoutInflater.from(context).inflate(R.layout.battery_usage_graph,
+ null);
+
+ mBatteryHistoryPreference = new BatteryHistoryPreference(context, null);
+ mBatteryHistoryPreference.mBatteryInfo = mBatteryInfo;
+ mViewHolder = spy(new PreferenceViewHolder(itemView));
+ when(mViewHolder.findViewById(R.id.battery_usage)).thenReturn(mUsageView);
+ when(mViewHolder.findViewById(R.id.charge)).thenReturn(mTextView);
+ when(mUsageView.findViewById(anyInt())).thenReturn(mLabelView);
+ }
+
+ @Test
+ public void testOnBindViewHolder_updateBatteryUsage() {
+ mBatteryHistoryPreference.onBindViewHolder(mViewHolder);
+
+ verify(mViewHolder).findViewById(R.id.battery_usage);
+ verify(mTextView).setText(anyString());
+ verify(mBatteryInfo).bindHistory(mUsageView);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index 494ac67..eb96604 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -27,6 +27,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -38,6 +39,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -45,6 +47,7 @@
public class PowerUsageAdvancedTest {
private static final int FAKE_UID_1 = 50;
private static final int FAKE_UID_2 = 100;
+ private static final int DISCHARGE_AMOUNT = 60;
private static final double TYPE_APP_USAGE = 80;
private static final double TYPE_BLUETOOTH_USAGE = 50;
private static final double TYPE_WIFI_USAGE = 0;
@@ -53,7 +56,7 @@
private static final double PRECISION = 0.001;
@Mock
private BatterySipper mBatterySipper;
- @Mock
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private BatteryStatsHelper mBatteryStatsHelper;
@Mock
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
@@ -76,6 +79,8 @@
batterySippers.add(new BatterySipper(DrainType.WIFI, new FakeUid(FAKE_UID_1),
TYPE_WIFI_USAGE));
+ when(mBatteryStatsHelper.getStats().getDischargeAmount(anyInt())).thenReturn(
+ DISCHARGE_AMOUNT);
when(mBatteryStatsHelper.getUsageList()).thenReturn(batterySippers);
when(mBatteryStatsHelper.getTotalPower()).thenReturn(TOTAL_USAGE);
mPowerUsageAdvanced.setPackageManager(mPackageManager);
@@ -118,9 +123,9 @@
@Test
public void testParsePowerUsageData_PercentageCalculatedCorrectly() {
- final double percentApp = TYPE_APP_USAGE * 2 / TOTAL_USAGE * 100;
- final double percentWifi = TYPE_WIFI_USAGE / TOTAL_USAGE * 100;
- final double percentBluetooth = TYPE_BLUETOOTH_USAGE / TOTAL_USAGE * 100;
+ final double percentApp = TYPE_APP_USAGE * 2 / TOTAL_USAGE * DISCHARGE_AMOUNT;
+ final double percentWifi = TYPE_WIFI_USAGE / TOTAL_USAGE * DISCHARGE_AMOUNT;
+ final double percentBluetooth = TYPE_BLUETOOTH_USAGE / TOTAL_USAGE * DISCHARGE_AMOUNT;
List<PowerUsageData> batteryData =
mPowerUsageAdvanced.parsePowerUsageData(mBatteryStatsHelper);
diff --git a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
index f693fd3..026264e 100644
--- a/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/language/LanguageAndInputSettingsTest.java
@@ -16,8 +16,15 @@
package com.android.settings.language;
+import android.app.Activity;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.hardware.input.InputManager;
+import android.os.UserManager;
+import android.provider.Settings;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
import android.view.textservice.TextServicesManager;
import com.android.internal.hardware.AmbientDisplayConfiguration;
@@ -27,6 +34,8 @@
import com.android.settings.core.PreferenceController;
import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.testutils.shadow.ShadowSecureSettings;
import org.junit.Before;
import org.junit.Test;
@@ -36,6 +45,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@@ -51,14 +61,19 @@
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private InputMethodManager mInputMethodManager;
private TestFragment mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
when(mContext.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
- .thenReturn(mock(TextServicesManager.class));
+ .thenReturn(mock(TextServicesManager.class));
mFragment = new TestFragment(mContext);
}
@@ -87,6 +102,33 @@
assertThat(controllers.isEmpty()).isFalse();
}
+ @Test
+ @Config(shadows = {
+ ShadowSecureSettings.class,
+ })
+ public void testSummary_shouldSetToCurrentImeName() {
+ final Activity activity = mock(Activity.class);
+ final SummaryLoader loader = mock(SummaryLoader.class);
+ final ComponentName componentName = new ComponentName("pkg", "cls");
+ ShadowSecureSettings.putString(null, Settings.Secure.DEFAULT_INPUT_METHOD,
+ componentName.flattenToString());
+ when(activity.getSystemService(Context.INPUT_METHOD_SERVICE))
+ .thenReturn(mInputMethodManager);
+ when(activity.getPackageManager()).thenReturn(mPackageManager);
+ final List<InputMethodInfo> imis = new ArrayList<>();
+ imis.add(mock(InputMethodInfo.class));
+ when(imis.get(0).getPackageName()).thenReturn(componentName.getPackageName());
+ when(mInputMethodManager.getInputMethodList()).thenReturn(imis);
+
+ SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
+ .createSummaryProvider(activity, loader);
+
+ provider.setListening(true);
+
+ verify(imis.get(0)).loadLabel(mPackageManager);
+ verify(loader).setSummary(provider, null);
+ }
+
/**
* Test fragment to expose lifecycle and context so we can verify behavior for observables.
*/
diff --git a/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java
index 7d2e240..3936d14 100644
--- a/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java
@@ -17,13 +17,10 @@
package com.android.settings.widget;
import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
+import android.support.v7.preference.PreferenceViewHolder;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.Switch;
@@ -35,14 +32,11 @@
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 static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -53,23 +47,23 @@
@Before
public void setUp() {
- mContext = ShadowApplication.getInstance().getApplicationContext();
+ mContext = RuntimeEnvironment.application;
}
@Test
public void createNewPreference_shouldSetLayout() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
- assertThat(preference.getWidgetLayoutResource()).isEqualTo(
- R.layout.preference_widget_master_switch);
+ assertThat(preference.getWidgetLayoutResource())
+ .isEqualTo(R.layout.preference_widget_master_switch);
}
@Test
public void setChecked_shouldUpdateButtonCheckedState() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
final PreferenceViewHolder holder = new PreferenceViewHolder(LayoutInflater.from(mContext)
- .inflate(R.layout.preference_widget_master_switch, null));
- final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+ .inflate(R.layout.preference_widget_master_switch, null));
+ final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
preference.onBindViewHolder(holder);
preference.setChecked(true);
@@ -82,9 +76,9 @@
@Test
public void setSwitchEnabled_shouldUpdateButtonEnabledState() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
- final PreferenceViewHolder holder = new PreferenceViewHolder(
- LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_switch, null));
- final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+ final PreferenceViewHolder holder = new PreferenceViewHolder(LayoutInflater.from(mContext)
+ .inflate(R.layout.preference_widget_master_switch, null));
+ final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
preference.onBindViewHolder(holder);
preference.setSwitchEnabled(true);
@@ -99,10 +93,10 @@
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = new PreferenceViewHolder(
- inflater.inflate(R.layout.preference_master_switch, null));
+ inflater.inflate(R.layout.preference_two_target, null));
final LinearLayout widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
inflater.inflate(R.layout.preference_widget_master_switch, widgetView, true);
- final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+ final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
preference.onBindViewHolder(holder);
widgetView.performClick();
@@ -116,8 +110,8 @@
public void clickWidgetView_shouldNotifyPreferenceChanged() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
final PreferenceViewHolder holder = new PreferenceViewHolder(
- LayoutInflater.from(mContext).inflate(R.layout.preference_master_switch, null));
- final View widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
+ LayoutInflater.from(mContext).inflate(R.layout.preference_two_target, null));
+ final View widgetView = holder.findViewById(android.R.id.widget_frame);
final OnPreferenceChangeListener listener = mock(OnPreferenceChangeListener.class);
preference.setOnPreferenceChangeListener(listener);
preference.onBindViewHolder(holder);
@@ -134,9 +128,9 @@
@Test
public void setDisabledByAdmin_hasEnforcedAdmin_shouldDisableButton() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
- final PreferenceViewHolder holder = new PreferenceViewHolder(
- LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_switch, null));
- final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+ final PreferenceViewHolder holder = new PreferenceViewHolder(LayoutInflater.from(mContext)
+ .inflate(R.layout.preference_widget_master_switch, null));
+ final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
toggle.setEnabled(true);
preference.onBindViewHolder(holder);
@@ -147,9 +141,9 @@
@Test
public void setDisabledByAdmin_noEnforcedAdmin_shouldEnableButton() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
- final PreferenceViewHolder holder = new PreferenceViewHolder(
- LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_switch, null));
- final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+ final PreferenceViewHolder holder = new PreferenceViewHolder(LayoutInflater.from(mContext)
+ .inflate(R.layout.preference_widget_master_switch, null));
+ final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
toggle.setEnabled(false);
preference.onBindViewHolder(holder);
diff --git a/tests/unit/AndroidTest.xml b/tests/unit/AndroidTest.xml
new file mode 100644
index 0000000..80a5a73
--- /dev/null
+++ b/tests/unit/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Runs Settings Test Cases.">
+ <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-file-name" value="SettingsUnitTests.apk" />
+ </target_preparer>
+
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-tag" value="SettingsUnitTests" />
+ <test class="com.android.tradefed.testtype.InstrumentationTest" >
+ <option name="package" value="com.android.settings.tests.unit" />
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+ </test>
+</configuration>