Merge "Display network name in status bar"
diff --git a/res/drawable/ic_bt_laptop.xml b/res/drawable/ic_bt_laptop.xml
deleted file mode 100644
index 029e4d9..0000000
--- a/res/drawable/ic_bt_laptop.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="#FF000000"
- android:pathData="M20,18c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2H4c-1.1,0
- -2,0.9 -2,2v10c0,1.1 0.9,2 2,2H0v2h24v-2h-4zM4,6h16v10H4V6z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_settings_bluetooth.xml b/res/drawable/ic_settings_bluetooth.xml
deleted file mode 100644
index 6e32e1a..0000000
--- a/res/drawable/ic_settings_bluetooth.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="#FFFFFFFF"
- android:pathData="M13.5,12l3.8,-3.7c0.4,-0.4 0.4,-1.1 0,-1.5l-4.5,-4.5c-0.4,-0.4 -1.1,-0.4 -1.5,0.1C11.1,2.5 11,2.8 11,3v6.4L6.9,5.4C6.5,5 5.9,5 5.5,5.4s-0.4,1.1 0,1.5l5.1,5.1l-5.1,5.1c-0.4,0.4 -0.4,1.1 0,1.5s1.1,0.4 1.5,0l4.1,-4V21c0,0.6 0.5,1 1,1c0.3,0 0.5,-0.1 0.7,-0.3l0.1,0l4.5,-4.5c0.4,-0.4 0.4,-1.1 0,-1.5L13.5,12zM13,9.7V5.4l2.1,2.2L13,9.7zM13,18.6v-4.3l2.1,2.2L13,18.6z"/>
-</vector>
diff --git a/res/drawable/ic_settings_print.xml b/res/drawable/ic_settings_print.xml
deleted file mode 100644
index 0eab402..0000000
--- a/res/drawable/ic_settings_print.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="#FFFFFFFF"
- android:pathData="M19,8H5c-1.66,0-3,1.34-3,3v5c0,0.55,0.45,1,1,1h3v3c0,0.55,0.45,1,1,1h10c0.55,0,1-0.45,1-1v-3h3c0.55,0,1-0.45,1-1v-5
-C22,9.34,20.66,8,19,8z M16,19H8v-5h8V19z
-M19,12c-0.55,0-1-0.45-1-1s0.45-1,1-1s1,0.45,1,1S19.55,12,19,12z M17,3H7
-C6.45,3,6,3.45,6,4v3h12V4C18,3.45,17.55,3,17,3z"/>
-</vector>
diff --git a/res/layout/app_header.xml b/res/layout/app_header.xml
deleted file mode 100644
index 2d8a099..0000000
--- a/res/layout/app_header.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
- android:background="@drawable/switchbar_background"
- android:gravity="center_vertical"
- android:theme="?attr/switchBarTheme" >
-
- <ImageView android:id="@+id/app_icon"
- android:layout_width="@dimen/switchbar_subsettings_margin_start"
- android:layout_height="40dp"
- android:gravity="end"
- android:layout_centerVertical="true" />
-
- <TextView
- android:id="@+id/app_name"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:layout_toStartOf="@+id/app_settings"
- android:layout_marginStart="@dimen/switchbar_subsettings_margin_start"
- android:layout_alignWithParentIfMissing="true"
- android:layout_centerVertical="true"
- android:textAppearance="@style/TextAppearance.Switch"
- android:textColor="@android:color/white"
- android:textAlignment="viewStart" />
-
- <ImageView
- android:id="@id/app_settings"
- android:layout_width="56dp"
- android:layout_height="56dp"
- android:layout_alignParentEnd="true"
- android:layout_marginEnd="@dimen/switchbar_subsettings_margin_end"
- android:layout_centerVertical="true"
- android:minHeight="0dp"
- android:minWidth="0dp"
- android:contentDescription="@string/notification_app_settings_button"
- android:scaleType="center"
- android:src="@drawable/ic_settings_24dp"
- android:visibility="gone"
- style="?android:attr/borderlessButtonStyle" />
-
-</RelativeLayout>
-
diff --git a/res/layout/app_item.xml b/res/layout/app_item.xml
deleted file mode 100644
index d53afc9..0000000
--- a/res/layout/app_item.xml
+++ /dev/null
@@ -1,81 +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.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="72dp"
- android:paddingTop="12dp"
- android:paddingBottom="12dp"
- android:gravity="top"
- android:columnCount="3"
- android:duplicateParentState="true">
-
- <ImageView
- android:id="@android:id/icon"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:layout_gravity="center"
- android:scaleType="fitXY"
- android:layout_marginEnd="16dip"
- android:contentDescription="@null"
- android:duplicateParentState="true" />
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toEndOf="@android:id/icon"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textColor="?android:attr/textColorPrimary"
- android:textAlignment="viewStart"
- android:duplicateParentState="true" />
-
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toEndOf="@android:id/title"
- android:layout_alignParentEnd="true"
- android:layout_marginStart="6dip"
- android:gravity="end"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textColor="?android:attr/textColorSecondary"
- android:duplicateParentState="true" />
-
- <Switch
- android:id="@android:id/switch_widget"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:background="@null"
- android:visibility="gone"/>
-
- <FrameLayout
- android:id="@android:id/widget_frame"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toEndOf="@android:id/icon"
- android:layout_below="@android:id/title"
- android:layout_alignParentEnd="true"
- android:layout_gravity="fill_horizontal|top"
- android:duplicateParentState="true" />
-
-</RelativeLayout>
diff --git a/res/layout/data_usage_item.xml b/res/layout/data_usage_item.xml
deleted file mode 100644
index 5e931f9..0000000
--- a/res/layout/data_usage_item.xml
+++ /dev/null
@@ -1,25 +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.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
-
- <include layout="@layout/app_item" />
-
-</FrameLayout>
diff --git a/res/layout/device_admin_item.xml b/res/layout/device_admin_item.xml
index 0420bb5..875c734 100644
--- a/res/layout/device_admin_item.xml
+++ b/res/layout/device_admin_item.xml
@@ -29,13 +29,17 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="center"
- android:orientation="horizontal">
+ android:gravity="start|center_vertical"
+ android:minWidth="60dp"
+ android:orientation="horizontal"
+ android:paddingEnd="12dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp">
<ImageView
android:id="@+id/icon"
- android:layout_width="@android:dimen/app_icon_size"
- android:layout_height="@android:dimen/app_icon_size"
+ android:layout_width="@dimen/secondary_app_icon_size"
+ android:layout_height="@dimen/secondary_app_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="8dip"
android:contentDescription="@null" />
@@ -70,7 +74,7 @@
</RelativeLayout>
- <CheckBox
+ <Switch
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/location_list_no_item.xml b/res/layout/location_list_no_item.xml
deleted file mode 100644
index c0465cf..0000000
--- a/res/layout/location_list_no_item.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<!-- text that appears when the recent app list is empty -->
-<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:paddingEnd="?android:attr/scrollbarSize"
- android:background="?android:attr/selectableItemBackground" >
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="15dip"
- android:layout_marginEnd="6dip"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
- android:layout_weight="1">
-
- <TextView android:id="@android:id/title"
- android:gravity="center"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary" />
-
- </RelativeLayout>
-
-</LinearLayout>
-
diff --git a/res/layout/preference_app.xml b/res/layout/preference_app.xml
index 526d5af..8cbb6f2 100644
--- a/res/layout/preference_app.xml
+++ b/res/layout/preference_app.xml
@@ -13,13 +13,87 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:background="?android:attr/selectableItemBackground"
+ android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
- <include layout="@layout/app_item" />
+ <LinearLayout
+ android:id="@+id/icon_frame"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="start|center_vertical"
+ android:minWidth="60dp"
+ android:orientation="horizontal"
+ android:paddingEnd="12dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp">
+ <android.support.v7.internal.widget.PreferenceImageView
+ android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ settings:maxWidth="@dimen/secondary_app_icon_size"
+ settings:maxHeight="@dimen/secondary_app_icon_size" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical"
+ 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="@style/TextAppearance.TileTitle"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <LinearLayout
+ android:id="@+id/summary_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone">
+ <TextView android:id="@android:id/summary"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textAppearance="@style/TextAppearance.Small"
+ android:textColor="?android:attr/textColorSecondary" />
+
+ <TextView android:id="@+id/appendix"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/TextAppearance.Small"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="1"
+ android:ellipsize="end" />
+ </LinearLayout>
+ <ProgressBar
+ android:id="@android:id/progress"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="4dp"
+ android:max="100"
+ android:visibility="gone" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@android:id/widget_frame"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="end|center_vertical"
+ android:paddingStart="16dp"
+ android:orientation="vertical" />
</LinearLayout>
diff --git a/res/layout/widget_progress_bar.xml b/res/layout/widget_progress_bar.xml
deleted file mode 100644
index a2a5154..0000000
--- a/res/layout/widget_progress_bar.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/progress"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="4dp"
- android:max="100"
- style="?android:attr/progressBarStyleHorizontal" />
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index c0d92c1..2ba7919 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -133,11 +133,6 @@
<attr name="forWork" format="boolean" />
</declare-styleable>
- <declare-styleable name="DividerPreference">
- <attr name="allowDividerAbove" format="boolean" />
- <attr name="allowDividerBelow" format="boolean" />
- </declare-styleable>
-
<declare-styleable name="VideoPreference">
<attr name="animation" format="reference" />
<attr name="preview" format="reference" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index fdb9c32..0d4289a 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -22,6 +22,7 @@
<dimen name="action_bar_switch_padding">16dip</dimen>
<dimen name="app_icon_size">40dip</dimen>
+ <dimen name="secondary_app_icon_size">24dp</dimen>
<dimen name="min_tap_target_size">48dp</dimen>
<dimen name="screen_margin_sides">64dip</dimen>
<dimen name="screen_margin_top">72dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 66f1569..f0721fc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8658,27 +8658,6 @@
<!-- Estimated wait time range for real time supports -->
<string name="support_estimated_wait_time">~<xliff:g id="ESTIMATE" example="2 minutes">%1$s</xliff:g> wait</string>
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_computer">Computer</string>
-
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_headset">Headset</string>
-
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_phone">Phone</string>
-
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_imaging">Imaging</string>
-
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_headphone">Headphone</string>
-
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_input_peripheral">Input Peripheral</string>
-
- <!-- Message for telling the user the kind of BT device being displayed in list. -->
- <string name="bluetooth_talkback_bluetooth">Bluetooth</string>
-
<!-- Used as title on the automatic storage manager settings. [CHAR LIMIT=60] -->
<string name="automatic_storage_manager_settings">Manage storage</string>
@@ -8801,7 +8780,8 @@
<string name="oem_unlock_enable_disabled_summary_connectivity_or_locked">Connect to the Internet or contact your carrier</string>
<!-- setting enable OEM unlock Checkbox's summary to explain this Checkbox is disabled because this setting is unavailable on sim-locked devices. [CHAR_LIMIT=60] -->
<string name="oem_unlock_enable_disabled_summary_sim_locked_device">Unavailable on carrier-locked devices</string>
-
+ <!-- Information displayed after user locks OEM lock [Char Limit=None]-->
+ <string name="oem_lock_info_message">Please restart the device to enable device protection feature.</string>
<string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
<!-- Title text for enabling web actions. [CHAR_LIMIT=60] -->
diff --git a/res/xml/app_default_settings.xml b/res/xml/app_default_settings.xml
index 3a8c997..0204c64 100644
--- a/res/xml/app_default_settings.xml
+++ b/res/xml/app_default_settings.xml
@@ -21,56 +21,56 @@
android:key="app_default_settings_screen"
android:title="@string/app_default_dashboard_title">
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="assist_and_voice_input"
android:title="@string/assist_and_voice_input_title"
android:fragment="com.android.settings.applications.assist.ManageAssist" />
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_browser"
android:title="@string/default_browser_title"
android:fragment="com.android.settings.applications.defaultapps.DefaultBrowserPicker">
<extra android:name="for_work" android:value="false" />
- </Preference>
+ </com.android.settings.widget.AppPreference>
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_home"
android:title="@string/home_app"
android:fragment="com.android.settings.applications.defaultapps.DefaultHomePicker"
settings:keywords="@string/keywords_home" />
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_phone_app"
android:title="@string/default_phone_title"
android:fragment="com.android.settings.applications.defaultapps.DefaultPhonePicker"
settings:keywords="@string/keywords_default_phone_app" />
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_sms_app"
android:title="@string/sms_application_title"
android:fragment="com.android.settings.applications.defaultapps.DefaultSmsPicker"
settings:keywords="@string/keywords_more_default_sms_app" />
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_payment_app"
android:title="@string/nfc_payment_settings_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.nfc.PaymentSettings" />
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_emergency_app"
android:title="@string/default_emergency_app"
settings:keywords="@string/keywords_emergency_app" />
<!--
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="default_notification_asst_app"
android:title="@string/default_notification_assistant"
android:fragment="com.android.settings.applications.defaultapps.DefaultNotificationAssistantPicker"
/>
-->
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="domain_urls"
android:title="@string/domain_urls_title"
android:fragment="com.android.settings.applications.ManageDomainUrls" />
@@ -79,20 +79,20 @@
android:key="work_app_defaults"
android:title="@string/default_for_work">
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="work_default_browser"
android:title="@string/default_browser_title"
android:fragment="com.android.settings.applications.defaultapps.DefaultBrowserPicker">
<extra android:name="for_work" android:value="true" />
- </Preference>
+ </com.android.settings.widget.AppPreference>
- <Preference
+ <com.android.settings.widget.AppPreference
android:key="work_default_phone_app"
android:title="@string/default_phone_title"
android:fragment="com.android.settings.applications.defaultapps.DefaultPhonePicker"
settings:keywords="@string/keywords_default_phone_app">
<extra android:name="for_work" android:value="true" />
- </Preference>
+ </com.android.settings.widget.AppPreference>
</com.android.settings.widget.WorkOnlyCategory>
diff --git a/res/xml/data_usage.xml b/res/xml/data_usage.xml
index 5bc8087..958459c 100644
--- a/res/xml/data_usage.xml
+++ b/res/xml/data_usage.xml
@@ -28,7 +28,7 @@
android:key="status_header"
android:selectable="false" />
- <com.android.settings.DividerPreference
+ <Preference
android:key="limit_summary"
android:selectable="false"
settings:allowDividerBelow="true" />
diff --git a/src/com/android/settings/AppProgressPreference.java b/src/com/android/settings/AppProgressPreference.java
deleted file mode 100644
index 5822d8d..0000000
--- a/src/com/android/settings/AppProgressPreference.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-import android.widget.ProgressBar;
-
-public class AppProgressPreference extends Preference {
-
- private int mProgress;
-
- public AppProgressPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- setLayoutResource(R.layout.preference_app);
- setWidgetLayoutResource(R.layout.widget_progress_bar);
- }
-
- public void setProgress(int amount) {
- mProgress = amount;
- notifyChanged();
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder view) {
- super.onBindViewHolder(view);
-
- final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
- progress.setProgress(mProgress);
- }
-}
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index 00f4d9c..350d731 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -43,9 +43,9 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.Switch;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
@@ -205,7 +205,7 @@
static class ViewHolder {
ImageView icon;
TextView name;
- CheckBox checkbox;
+ Switch checkbox;
TextView description;
}
@@ -291,10 +291,10 @@
private View newDeviceAdminView(ViewGroup parent) {
View v = mInflater.inflate(R.layout.device_admin_item, parent, false);
ViewHolder h = new ViewHolder();
- h.icon = (ImageView) v.findViewById(R.id.icon);
- h.name = (TextView) v.findViewById(R.id.name);
- h.checkbox = (CheckBox) v.findViewById(R.id.checkbox);
- h.description = (TextView) v.findViewById(R.id.description);
+ h.icon = v.findViewById(R.id.icon);
+ h.name = v.findViewById(R.id.name);
+ h.checkbox = v.findViewById(R.id.checkbox);
+ h.description = v.findViewById(R.id.description);
v.setTag(h);
return v;
}
diff --git a/src/com/android/settings/DividerPreference.java b/src/com/android/settings/DividerPreference.java
deleted file mode 100644
index aec7d44..0000000
--- a/src/com/android/settings/DividerPreference.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.settings;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-
-@Deprecated
-public class DividerPreference extends Preference {
-
- private Boolean mAllowAbove;
- private Boolean mAllowBelow;
-
- public DividerPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DividerPreference, 0, 0);
- if (a.hasValue(R.styleable.DividerPreference_allowDividerAbove)) {
- mAllowAbove = a.getBoolean(R.styleable.DividerPreference_allowDividerAbove, false);
- }
- if (a.hasValue(R.styleable.DividerPreference_allowDividerBelow)) {
- mAllowBelow = a.getBoolean(R.styleable.DividerPreference_allowDividerBelow, false);
- }
- a.recycle();
- }
-
- public DividerPreference(Context context) {
- this(context, null /* attrs */);
- }
-
- public void setDividerAllowedAbove(boolean allowed) {
- mAllowAbove = allowed;
- notifyChanged();
- }
-
- public void setDividerAllowedBelow(boolean allowed) {
- mAllowBelow = allowed;
- notifyChanged();
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
- super.onBindViewHolder(holder);
- if (mAllowAbove != null) {
- holder.setDividerAllowedAbove(mAllowAbove);
- }
- if (mAllowBelow != null) {
- holder.setDividerAllowedBelow(mAllowBelow);
- }
- }
-}
diff --git a/src/com/android/settings/accounts/AccountTypePreference.java b/src/com/android/settings/accounts/AccountTypePreference.java
index 3e869fe..1d39473 100644
--- a/src/com/android/settings/accounts/AccountTypePreference.java
+++ b/src/com/android/settings/accounts/AccountTypePreference.java
@@ -16,6 +16,8 @@
package com.android.settings.accounts;
+import static android.content.Intent.EXTRA_USER;
+
import android.accounts.Account;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -25,12 +27,10 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
-import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.widget.AppPreference;
-import static android.content.Intent.EXTRA_USER;
-
-public class AccountTypePreference extends Preference implements OnPreferenceClickListener {
+public class AccountTypePreference extends AppPreference implements OnPreferenceClickListener {
/**
* Title of the tile that is shown to the user.
* @attr ref android.R.styleable#PreferenceHeader_title
diff --git a/src/com/android/settings/accounts/ProviderPreference.java b/src/com/android/settings/accounts/ProviderPreference.java
index 817c3b6..81e0221 100644
--- a/src/com/android/settings/accounts/ProviderPreference.java
+++ b/src/com/android/settings/accounts/ProviderPreference.java
@@ -16,15 +16,14 @@
package com.android.settings.accounts;
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.support.v7.preference.Preference;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreference;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
/**
* ProviderPreference is used to display an image to the left of a provider name.
* The preference ultimately calls AccountManager.addAccount() for the account type.
@@ -35,6 +34,7 @@
public ProviderPreference(
Context context, String accountType, Drawable icon, CharSequence providerName) {
super(context);
+ setUseSmallIcon(true);
mAccountType = accountType;
setIcon(icon);
setPersistent(false);
diff --git a/src/com/android/settings/applications/PictureInPictureSettings.java b/src/com/android/settings/applications/PictureInPictureSettings.java
index 9b8a897..3dc8ab3 100644
--- a/src/com/android/settings/applications/PictureInPictureSettings.java
+++ b/src/com/android/settings/applications/PictureInPictureSettings.java
@@ -38,6 +38,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.notification.EmptyTextSettings;
+import com.android.settings.widget.AppPreference;
import com.android.settings.wrapper.ActivityInfoWrapper;
import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -176,7 +177,7 @@
final String packageName = appInfo.packageName;
final CharSequence label = appInfo.loadLabel(pm);
- final Preference pref = new Preference(prefContext);
+ final Preference pref = new AppPreference(prefContext);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, userId));
pref.setTitle(pm.getUserBadgedLabel(label, user));
pref.setSummary(PictureInPictureDetails.getPreferenceSummary(prefContext,
diff --git a/src/com/android/settings/applications/PremiumSmsAccess.java b/src/com/android/settings/applications/PremiumSmsAccess.java
index 94945a9..b6613f2 100644
--- a/src/com/android/settings/applications/PremiumSmsAccess.java
+++ b/src/com/android/settings/applications/PremiumSmsAccess.java
@@ -28,7 +28,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.telephony.SmsUsageMonitor;
-import com.android.settings.DividerPreference;
import com.android.settings.R;
import com.android.settings.applications.AppStateBaseBridge.Callback;
import com.android.settings.applications.AppStateSmsPremBridge.SmsState;
@@ -38,6 +37,7 @@
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.Callbacks;
import com.android.settingslib.applications.ApplicationsState.Session;
+import com.android.settingslib.widget.FooterPreference;
import java.util.ArrayList;
@@ -141,11 +141,9 @@
screen.addPreference(smsPreference);
}
if (apps.size() != 0) {
- DividerPreference summary = new DividerPreference(getPrefContext());
- summary.setSelectable(false);
- summary.setSummary(R.string.premium_sms_warning);
- summary.setDividerAllowedAbove(true);
- screen.addPreference(summary);
+ FooterPreference footer = new FooterPreference(getPrefContext());
+ footer.setTitle(R.string.premium_sms_warning);
+ screen.addPreference(footer);
}
if (!usePreferenceScreenTitle()) {
diff --git a/src/com/android/settings/applications/ProcessStatsPreference.java b/src/com/android/settings/applications/ProcessStatsPreference.java
index 4ee0a04..034a68d 100644
--- a/src/com/android/settings/applications/ProcessStatsPreference.java
+++ b/src/com/android/settings/applications/ProcessStatsPreference.java
@@ -18,14 +18,13 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.graphics.drawable.ColorDrawable;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.Log;
-import com.android.settings.AppProgressPreference;
+import com.android.settings.widget.AppPreference;
-public class ProcessStatsPreference extends AppProgressPreference {
+public class ProcessStatsPreference extends AppPreference {
static final String TAG = "ProcessStatsPreference";
private ProcStatsPackageEntry mEntry;
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index b6ae1ee..090a5a7 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -40,6 +40,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.widget.AppPreference;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -230,7 +231,7 @@
boolean rebindPref = true;
Preference pref = appPreferences.remove(pkgName);
if (pref == null) {
- pref = new Preference(prefContext);
+ pref = new AppPreference(prefContext);
rebindPref = false;
}
pref.setKey(pkgName);
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
index 6eb1ad8..7b27516 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
@@ -84,6 +84,11 @@
}
}
+ @Override
+ protected int getRadioButtonPreferenceCustomLayoutResId() {
+ return R.layout.preference_app;
+ }
+
protected ConfirmationDialogFragment newConfirmationDialogFragment(String selectedKey,
CharSequence confirmationMessage) {
final ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
index 91143b1..d016567 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
@@ -29,6 +29,7 @@
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.widget.GearPreference;
+import com.android.settingslib.TwoTargetPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -53,6 +54,12 @@
public void updateState(Preference preference) {
final DefaultAppInfo app = getDefaultAppInfo();
CharSequence defaultAppLabel = getDefaultAppLabel();
+ if (preference instanceof TwoTargetPreference) {
+ // For use small icon because we are displaying an app preference.
+ // We only need to do this for TwoTargetPreference because the other prefs are
+ // already using AppPreference so their icon is already normalized.
+ ((TwoTargetPreference) preference).setUseSmallIcon(true);
+ }
if (!TextUtils.isEmpty(defaultAppLabel)) {
preference.setSummary(defaultAppLabel);
Utils.setSafeIcon(preference, getDefaultAppIcon());
diff --git a/src/com/android/settings/applications/manageapplications/ApplicationViewHolder.java b/src/com/android/settings/applications/manageapplications/ApplicationViewHolder.java
index 9ac2167..e968b1c 100644
--- a/src/com/android/settings/applications/manageapplications/ApplicationViewHolder.java
+++ b/src/com/android/settings/applications/manageapplications/ApplicationViewHolder.java
@@ -22,6 +22,7 @@
import android.support.annotation.StringRes;
import android.support.annotation.VisibleForTesting;
import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -38,33 +39,39 @@
private final TextView mAppName;
private final ImageView mAppIcon;
+ private final boolean mKeepStableHeight;
+
+ @VisibleForTesting
+ View mSummaryContainer;
@VisibleForTesting
final TextView mSummary;
@VisibleForTesting
final TextView mDisabled;
- ApplicationViewHolder(View itemView) {
+
+ ApplicationViewHolder(View itemView, boolean keepStableHeight) {
super(itemView);
mAppName = itemView.findViewById(android.R.id.title);
mAppIcon = itemView.findViewById(android.R.id.icon);
- mSummary = itemView.findViewById(R.id.widget_text1);
- mDisabled = itemView.findViewById(R.id.widget_text2);
+ mSummaryContainer = itemView.findViewById(R.id.summary_container);
+ mSummary = itemView.findViewById(android.R.id.summary);
+ mDisabled = itemView.findViewById(R.id.appendix);
+ mKeepStableHeight = keepStableHeight;
}
- static View newView(LayoutInflater inflater, ViewGroup parent) {
- final View root = LayoutInflater.from(parent.getContext())
+ static View newView(ViewGroup parent) {
+ return LayoutInflater.from(parent.getContext())
.inflate(R.layout.preference_app, parent, false);
- inflater.inflate(R.layout.widget_text_views,
- root.findViewById(android.R.id.widget_frame));
- return root;
}
void setSummary(CharSequence summary) {
mSummary.setText(summary);
+ updateSummaryContainer();
}
void setSummary(@StringRes int summary) {
mSummary.setText(summary);
+ updateSummaryContainer();
}
void setEnabled(boolean isEnabled) {
@@ -78,6 +85,10 @@
mAppName.setText(title);
}
+ void setIcon(int drawableRes) {
+ mAppIcon.setImageResource(drawableRes);
+ }
+
void setIcon(Drawable icon) {
if (icon == null) {
return;
@@ -96,6 +107,17 @@
} else {
mDisabled.setVisibility(View.GONE);
}
+ updateSummaryContainer();
+ }
+
+ void updateSummaryContainer() {
+ if (mKeepStableHeight) {
+ mSummaryContainer.setVisibility(View.VISIBLE);
+ return;
+ }
+ final boolean hasContent =
+ !TextUtils.isEmpty(mDisabled.getText()) || !TextUtils.isEmpty(mSummary.getText());
+ mSummaryContainer.setVisibility(hasContent ? View.VISIBLE : View.GONE);
}
void updateSizeText(AppEntry entry, CharSequence invalidSizeStr, int whichSize) {
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 33762e4..7dc8951 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -412,20 +412,6 @@
return null;
}
- private boolean isFastScrollEnabled() {
- switch (mListType) {
- case LIST_TYPE_MAIN:
- case LIST_TYPE_NOTIFICATION:
- case LIST_TYPE_STORAGE:
- case LIST_TYPE_GAMES:
- case LIST_TYPE_MOVIES:
- case LIST_TYPE_PHOTOGRAPHY:
- return mSortOrder == R.id.sort_order_alpha;
- default:
- return false;
- }
- }
-
@Override
public int getMetricsCategory() {
switch (mListType) {
@@ -924,9 +910,9 @@
@Override
public ApplicationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- final View view = ApplicationViewHolder.newView(
- LayoutInflater.from(parent.getContext()), parent);
- return new ApplicationViewHolder(view);
+ final View view = ApplicationViewHolder.newView(parent);
+ return new ApplicationViewHolder(view,
+ shouldUseStableItemHeight(mManageApplications.mListType));
}
@Override
@@ -994,7 +980,21 @@
});
}
- static private boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
+ @VisibleForTesting
+ static boolean shouldUseStableItemHeight(int listType) {
+ switch (listType) {
+ case LIST_TYPE_NOTIFICATION:
+ // Most entries in notification type has no summary. Don't use stable height
+ // so height is short for most entries.
+ return false;
+ default:
+ // Other types have non-empty summary, so keep the height as we expect summary
+ // to fill in.
+ return true;
+ }
+ }
+
+ private static boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
if (info1 == null || info2 == null) {
return false;
}
diff --git a/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java b/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java
index 2a2ac3b..14d08aa 100644
--- a/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java
+++ b/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java
@@ -19,7 +19,6 @@
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
-import android.graphics.drawable.InsetDrawable;
import android.os.UserHandle;
import android.provider.DocumentsContract;
import android.support.annotation.WorkerThread;
@@ -39,7 +38,6 @@
private static final String TAG = "MusicViewHolderCtrl";
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
- private static final int INSET_SIZE = 24; // dp
private Context mContext;
private StorageStatsSource mSource;
@@ -73,8 +71,7 @@
@Override
public void setupView(ApplicationViewHolder holder) {
- holder.setIcon(
- new InsetDrawable(mContext.getDrawable(R.drawable.ic_headset_24dp), INSET_SIZE));
+ holder.setIcon(R.drawable.ic_headset_24dp);
holder.setTitle(mContext.getText(R.string.audio_files_title));
holder.setSummary(Formatter.formatFileSize(mContext, mMusicSize));
}
diff --git a/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java b/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java
index fafa875..73330e9 100644
--- a/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java
+++ b/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java
@@ -19,7 +19,6 @@
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
-import android.graphics.drawable.InsetDrawable;
import android.os.UserHandle;
import android.support.annotation.WorkerThread;
import android.text.format.Formatter;
@@ -36,7 +35,6 @@
private static final String TAG = "PhotosViewHolderCtrl";
private static final String IMAGE_MIME_TYPE = "image/*";
- private static final int INSET_SIZE = 24; // dp
private Context mContext;
private StorageStatsSource mSource;
@@ -72,8 +70,7 @@
@Override
public void setupView(ApplicationViewHolder holder) {
- holder.setIcon(
- new InsetDrawable(mContext.getDrawable(R.drawable.ic_photo_library), INSET_SIZE));
+ holder.setIcon(R.drawable.ic_photo_library);
holder.setTitle(mContext.getText(R.string.storage_detail_images));
holder.setSummary(Formatter.formatFileSize(mContext, mFilesSize));
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index 04e9f5a..df7b601 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -51,8 +51,8 @@
}
protected void setHeaderProperties() {
- final Pair<Drawable, String> pair = Utils.getBtClassDrawableWithDescription(
- mContext, mCachedDevice,
+ final Pair<Drawable, String> pair = com.android.settingslib.bluetooth.Utils
+ .getBtClassDrawableWithDescription(mContext, mCachedDevice,
mContext.getResources().getFraction(R.fraction.bt_battery_scale_fraction, 1, 1));
String summaryText = mCachedDevice.getConnectionSummary();
mHeaderController.setLabel(mCachedDevice.getName());
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 94ba478..043cb95 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -122,8 +122,8 @@
// Null check is done at the framework
setSummary(mCachedDevice.getConnectionSummary());
- final Pair<Drawable, String> pair = Utils.getBtClassDrawableWithDescription(getContext(),
- mCachedDevice);
+ final Pair<Drawable, String> pair = com.android.settingslib.bluetooth.Utils
+ .getBtClassDrawableWithDescription(getContext(), mCachedDevice);
if (pair.first != null) {
setIcon(pair.first);
contentDescription = pair.second;
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index 0ecf62d..d5d4e50 100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -17,31 +17,19 @@
package com.android.settings.bluetooth;
import android.app.AlertDialog;
-import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.support.annotation.DrawableRes;
-import android.support.annotation.IdRes;
import android.support.annotation.VisibleForTesting;
-import android.util.Pair;
import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.HidProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothManager.BluetoothManagerCallback;
-import com.android.settingslib.bluetooth.LocalBluetoothProfile;
import com.android.settingslib.bluetooth.Utils.ErrorListener;
-import com.android.settingslib.graph.BluetoothDeviceLayerDrawable;
-
-import java.util.List;
/**
* Utils is a helper class that contains constants for various
@@ -57,16 +45,16 @@
public static int getConnectionStateSummary(int connectionState) {
switch (connectionState) {
- case BluetoothProfile.STATE_CONNECTED:
- return R.string.bluetooth_connected;
- case BluetoothProfile.STATE_CONNECTING:
- return R.string.bluetooth_connecting;
- case BluetoothProfile.STATE_DISCONNECTED:
- return R.string.bluetooth_disconnected;
- case BluetoothProfile.STATE_DISCONNECTING:
- return R.string.bluetooth_disconnecting;
- default:
- return 0;
+ case BluetoothProfile.STATE_CONNECTED:
+ return R.string.bluetooth_connected;
+ case BluetoothProfile.STATE_CONNECTING:
+ return R.string.bluetooth_connecting;
+ case BluetoothProfile.STATE_DISCONNECTED:
+ return R.string.bluetooth_disconnected;
+ case BluetoothProfile.STATE_DISCONNECTING:
+ return R.string.bluetooth_disconnecting;
+ default:
+ return 0;
}
}
@@ -154,81 +142,4 @@
}
};
- static Pair<Drawable, String> getBtClassDrawableWithDescription(Context context,
- CachedBluetoothDevice cachedDevice) {
- return getBtClassDrawableWithDescription(context, cachedDevice, 1 /* iconScale */);
- }
-
- static Pair<Drawable, String> getBtClassDrawableWithDescription(Context context,
- CachedBluetoothDevice cachedDevice, float iconScale) {
- BluetoothClass btClass = cachedDevice.getBtClass();
- final int level = cachedDevice.getBatteryLevel();
- if (btClass != null) {
- switch (btClass.getMajorDeviceClass()) {
- case BluetoothClass.Device.Major.COMPUTER:
- return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_bt_laptop, level,
- iconScale),
- context.getString(R.string.bluetooth_talkback_computer));
-
- case BluetoothClass.Device.Major.PHONE:
- return new Pair<>(
- getBluetoothDrawable(context, R.drawable.ic_bt_cellphone, level,
- iconScale),
- context.getString(R.string.bluetooth_talkback_phone));
-
- case BluetoothClass.Device.Major.PERIPHERAL:
- return new Pair<>(
- getBluetoothDrawable(context, HidProfile.getHidClassDrawable(btClass),
- level, iconScale),
- context.getString(R.string.bluetooth_talkback_input_peripheral));
-
- case BluetoothClass.Device.Major.IMAGING:
- return new Pair<>(
- getBluetoothDrawable(context, R.drawable.ic_settings_print, level,
- iconScale),
- context.getString(R.string.bluetooth_talkback_imaging));
-
- default:
- // unrecognized device class; continue
- }
- }
-
- List<LocalBluetoothProfile> profiles = cachedDevice.getProfiles();
- for (LocalBluetoothProfile profile : profiles) {
- int resId = profile.getDrawableResource(btClass);
- if (resId != 0) {
- return new Pair<>(getBluetoothDrawable(context, resId, level, iconScale), null);
- }
- }
- if (btClass != null) {
- if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
- return new Pair<>(
- getBluetoothDrawable(context, R.drawable.ic_bt_headset_hfp, level,
- iconScale),
- context.getString(R.string.bluetooth_talkback_headset));
- }
- if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
- return new Pair<>(
- getBluetoothDrawable(context, R.drawable.ic_bt_headphones_a2dp, level,
- iconScale),
- context.getString(R.string.bluetooth_talkback_headphone));
- }
- }
- return new Pair<>(
- getBluetoothDrawable(context, R.drawable.ic_settings_bluetooth, level, iconScale),
- context.getString(R.string.bluetooth_talkback_bluetooth));
- }
-
- @VisibleForTesting
- static Drawable getBluetoothDrawable(Context context, @DrawableRes int resId,
- int batteryLevel, float iconScale) {
- if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
- return BluetoothDeviceLayerDrawable.createLayerDrawable(context, resId, batteryLevel,
- iconScale);
- } else if (resId != 0) {
- return context.getDrawable(resId);
- } else {
- return null;
- }
- }
}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index 783987d..1be31b4 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -92,7 +92,7 @@
}
private static boolean isV2Enabled() {
- return FeatureFlagUtils.isEnabled(FEATURE_FLAG_SUGGESTIONS_V2);
+ return FeatureFlagUtils.isEnabled(FEATURE_FLAG_SUGGESTIONS_V2) || true;
}
@Override
diff --git a/src/com/android/settings/datausage/AppDataUsagePreference.java b/src/com/android/settings/datausage/AppDataUsagePreference.java
index 35f1fe2..f0fd755 100644
--- a/src/com/android/settings/datausage/AppDataUsagePreference.java
+++ b/src/com/android/settings/datausage/AppDataUsagePreference.java
@@ -15,19 +15,18 @@
package com.android.settings.datausage;
import android.content.Context;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.format.Formatter;
import android.view.View;
import android.widget.ProgressBar;
-import com.android.settings.R;
+import com.android.settings.widget.AppPreference;
import com.android.settingslib.AppItem;
import com.android.settingslib.net.UidDetail;
import com.android.settingslib.net.UidDetailProvider;
import com.android.settingslib.utils.ThreadUtils;
-public class AppDataUsagePreference extends Preference {
+public class AppDataUsagePreference extends AppPreference {
private final AppItem mItem;
private final int mPercent;
@@ -38,8 +37,6 @@
super(context);
mItem = item;
mPercent = percent;
- setLayoutResource(R.layout.data_usage_item);
- setWidgetLayoutResource(R.layout.widget_progress_bar);
if (item.restricted && item.total <= 0) {
setSummary(com.android.settings.R.string.data_usage_app_restricted);
@@ -60,7 +57,6 @@
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
-
final ProgressBar progress = (ProgressBar) holder.findViewById(
android.R.id.progress);
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccess.java b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
index 8fad986..6771abc 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccess.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.os.Bundle;
import android.os.UserHandle;
-import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.view.Menu;
@@ -34,6 +33,7 @@
import com.android.settings.applications.InstalledAppDetails;
import com.android.settings.datausage.AppStateDataUsageBridge.DataUsageState;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.AppSwitchPreference;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
@@ -59,11 +59,7 @@
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setAnimationAllowed(true);
- if (usePreferenceScreenTitle()) {
- addPreferencesFromResource(R.xml.unrestricted_data_access_settings);
- } else {
- setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getContext()));
- }
+ addPreferencesFromResource(R.xml.unrestricted_data_access_settings);
mApplicationsState = ApplicationsState.getInstance(
(Application) getContext().getApplicationContext());
mDataSaverBackend = new DataSaverBackend(getContext());
@@ -239,7 +235,8 @@
return app != null && UserHandle.isApp(app.info.uid);
}
- private class AccessPreference extends SwitchPreference implements DataSaverBackend.Listener {
+ private class AccessPreference extends AppSwitchPreference
+ implements DataSaverBackend.Listener {
private final AppEntry mEntry;
private final DataUsageState mState;
diff --git a/src/com/android/settings/development/AppViewHolder.java b/src/com/android/settings/development/AppViewHolder.java
index 7a90bcf..1082efe 100644
--- a/src/com/android/settings/development/AppViewHolder.java
+++ b/src/com/android/settings/development/AppViewHolder.java
@@ -18,7 +18,6 @@
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -37,23 +36,21 @@
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.preference_app, null);
- inflater.inflate(R.layout.widget_text_views,
- (ViewGroup) convertView.findViewById(android.R.id.widget_frame));
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
AppViewHolder holder = new AppViewHolder();
holder.rootView = convertView;
- holder.appName = (TextView) convertView.findViewById(android.R.id.title);
- holder.appIcon = (ImageView) convertView.findViewById(android.R.id.icon);
- holder.summary = (TextView) convertView.findViewById(R.id.widget_text1);
- holder.disabled = (TextView) convertView.findViewById(R.id.widget_text2);
+ holder.appName = convertView.findViewById(android.R.id.title);
+ holder.appIcon = convertView.findViewById(android.R.id.icon);
+ holder.summary = convertView.findViewById(android.R.id.summary);
+ holder.disabled = convertView.findViewById(R.id.appendix);
convertView.setTag(holder);
return holder;
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
- return (AppViewHolder)convertView.getTag();
+ return (AppViewHolder) convertView.getTag();
}
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/development/OemLockInfoDialog.java b/src/com/android/settings/development/OemLockInfoDialog.java
new file mode 100644
index 0000000..6d75812
--- /dev/null
+++ b/src/com/android/settings/development/OemLockInfoDialog.java
@@ -0,0 +1,53 @@
+/*
+ * 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.development;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.os.Bundle;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+
+public class OemLockInfoDialog extends InstrumentedDialogFragment {
+
+ private static final String TAG = "OemLockInfoDialog";
+
+ public static void show(Fragment host) {
+ final FragmentManager manager = host.getChildFragmentManager();
+ if (manager.findFragmentByTag(TAG) == null) {
+ final OemLockInfoDialog dialog = new OemLockInfoDialog();
+ dialog.show(manager, TAG);
+ }
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.DIALOG_OEM_LOCK_INFO;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+ .setMessage(R.string.oem_lock_info_message);
+
+ return builder.create();
+ }
+}
diff --git a/src/com/android/settings/development/OemUnlockPreferenceController.java b/src/com/android/settings/development/OemUnlockPreferenceController.java
index 91994c2..f486b3d 100644
--- a/src/com/android/settings/development/OemUnlockPreferenceController.java
+++ b/src/com/android/settings/development/OemUnlockPreferenceController.java
@@ -90,6 +90,7 @@
}
} else {
mOemLockManager.setOemUnlockAllowedByUser(false);
+ OemLockInfoDialog.show(mFragment);
}
return true;
}
diff --git a/src/com/android/settings/enterprise/ApplicationListPreferenceController.java b/src/com/android/settings/enterprise/ApplicationListPreferenceController.java
index dce6f57..8be7944 100644
--- a/src/com/android/settings/enterprise/ApplicationListPreferenceController.java
+++ b/src/com/android/settings/enterprise/ApplicationListPreferenceController.java
@@ -22,11 +22,11 @@
import android.support.v7.preference.PreferenceScreen;
import android.util.IconDrawableFactory;
-import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.applications.UserAppInfo;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.widget.AppPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.List;
@@ -68,8 +68,7 @@
final Context prefContext = mParent.getPreferenceManager().getContext();
for (int position = 0; position < result.size(); position++) {
final UserAppInfo item = result.get(position);
- final Preference preference = new Preference(prefContext);
- preference.setLayoutResource(R.layout.preference_app);
+ final Preference preference = new AppPreference(prefContext);
preference.setTitle(item.appInfo.loadLabel(mPm));
preference.setIcon(iconDrawableFactory.getBadgedIcon(item.appInfo));
preference.setOrder(position);
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index d96db68..819846a 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -45,6 +45,7 @@
import com.android.settings.Utils;
import com.android.settings.applications.LayoutPreference;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment;
@@ -360,6 +361,9 @@
@Override
public void onLoadFinished(Loader<List<Anomaly>> loader, List<Anomaly> data) {
+ final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(getContext());
+ anomalyUtils.logAnomalies(mMetricsFeatureProvider, data,
+ MetricsEvent.FUELGAUGE_POWER_USAGE_DETAIL);
mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(data);
}
diff --git a/src/com/android/settings/fuelgauge/PowerGaugePreference.java b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
index 05dad27..93e33cc 100644
--- a/src/com/android/settings/fuelgauge/PowerGaugePreference.java
+++ b/src/com/android/settings/fuelgauge/PowerGaugePreference.java
@@ -19,15 +19,13 @@
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.widget.AppPreference;
/**
* Custom preference for displaying battery usage info as a bar and an icon on
@@ -36,8 +34,7 @@
* The battery usage info could be usage percentage or usage time. The preference
* won't show any icon if it is null.
*/
-public class PowerGaugePreference extends Preference {
- private final int mIconSize;
+public class PowerGaugePreference extends AppPreference {
private BatteryEntry mInfo;
private CharSequence mContentDescription;
@@ -64,7 +61,6 @@
setWidgetLayoutResource(R.layout.preference_widget_summary);
mInfo = info;
mContentDescription = contentDescription;
- mIconSize = context.getResources().getDimensionPixelSize(R.dimen.app_icon_size);
mShowAnomalyIcon = false;
}
@@ -107,8 +103,6 @@
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
- ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
- icon.setLayoutParams(new LinearLayout.LayoutParams(mIconSize, mIconSize));
final TextView subtitle = (TextView) view.findViewById(R.id.widget_summary);
subtitle.setText(mProgress);
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index adadb78..6ed92a7 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -18,6 +18,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Bundle;
@@ -250,7 +251,7 @@
boolean shouldHideCategory(PowerUsageData powerUsageData) {
return powerUsageData.usageType == UsageType.UNACCOUNTED
|| powerUsageData.usageType == UsageType.OVERCOUNTED
- || (powerUsageData.usageType == UsageType.USER && mUserManager.getUserCount() == 1)
+ || (powerUsageData.usageType == UsageType.USER && isSingleNormalUser())
|| (powerUsageData.usageType == UsageType.CELL
&& !DataUsageUtils.hasMobileData(getContext()));
}
@@ -373,6 +374,18 @@
mBatteryUtils = batteryUtils;
}
+ @VisibleForTesting
+ boolean isSingleNormalUser() {
+ int count = 0;
+ for (UserInfo userInfo : mUserManager.getUsers()) {
+ if (userInfo.isEnabled() && !userInfo.isManagedProfile()) {
+ count++;
+ }
+ }
+
+ return count == 1;
+ }
+
/**
* Class that contains data used in {@link PowerGaugePreference}.
*/
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java b/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java
index bf4c2af..0d73511 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java
@@ -125,8 +125,7 @@
@Override
public int getMetricsCategory() {
- //TODO(b/37681923): add correct metrics category
- return 0;
+ return MetricsProto.MetricsEvent.FUELGAUGE_ANOMALY_DETAIL;
}
void refreshUi() {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index ac50e66..dd8c169 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -67,6 +67,7 @@
import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment.AnomalyDialogListener;
import com.android.settings.fuelgauge.anomaly.AnomalyLoader;
import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
+import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -148,6 +149,10 @@
@Override
public void onLoadFinished(Loader<List<Anomaly>> loader, List<Anomaly> data) {
+ final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(getContext());
+ anomalyUtils.logAnomalies(mMetricsFeatureProvider, data,
+ MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY);
+
// show high usage preference if possible
mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(data);
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java
index 69d03b9..538f5b1 100644
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java
@@ -23,6 +23,7 @@
import android.os.Bundle;
import android.support.annotation.VisibleForTesting;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
@@ -79,8 +80,7 @@
@Override
public int getMetricsCategory() {
- // TODO(b/37681923): add anomaly metric id
- return 0;
+ return MetricsProto.MetricsEvent.DIALOG_HANDLE_ANOMALY;
}
@Override
@@ -100,9 +100,13 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle bundle = getArguments();
- mAnomaly = bundle.getParcelable(ARG_ANOMALY);
-
final Context context = getContext();
+ final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(context);
+
+ mAnomaly = bundle.getParcelable(ARG_ANOMALY);
+ anomalyUtils.logAnomaly(mMetricsFeatureProvider, mAnomaly,
+ MetricsProto.MetricsEvent.DIALOG_HANDLE_ANOMALY);
+
final AnomalyAction anomalyAction = mAnomalyUtils.getAnomalyAction(mAnomaly);
switch (anomalyAction.getActionType()) {
case Anomaly.AnomalyActionType.FORCE_STOP:
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
index 491a3b4..39d51dc0 100644
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
+++ b/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
@@ -19,8 +19,12 @@
import android.content.Context;
import android.os.Build;
import android.support.annotation.VisibleForTesting;
+import android.util.Pair;
+import android.util.SparseIntArray;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.os.BatteryStatsHelper;
+import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
import com.android.settings.fuelgauge.anomaly.action.ForceStopAction;
import com.android.settings.fuelgauge.anomaly.action.LocationCheckAction;
@@ -40,6 +44,17 @@
private Context mContext;
private static AnomalyUtils sInstance;
+ private static final SparseIntArray mMetricArray;
+ static {
+ mMetricArray = new SparseIntArray();
+ mMetricArray.append(Anomaly.AnomalyType.WAKE_LOCK,
+ MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKELOCK);
+ mMetricArray.append(Anomaly.AnomalyType.WAKEUP_ALARM,
+ MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKEUP_ALARM);
+ mMetricArray.append(Anomaly.AnomalyType.BLUETOOTH_SCAN,
+ MetricsProto.MetricsEvent.ANOMALY_TYPE_UNOPTIMIZED_BT);
+ }
+
@VisibleForTesting
AnomalyUtils(Context context) {
mContext = context.getApplicationContext();
@@ -118,4 +133,39 @@
return anomalies;
}
+ /**
+ * Log the list of {@link Anomaly} using {@link MetricsFeatureProvider}, which contains
+ * anomaly type, package name, field_context, field_action_type
+ *
+ * @param provider provider to do the logging
+ * @param anomalies contains the data to log
+ * @param contextId which page invoke this logging
+ * @see #logAnomaly(MetricsFeatureProvider, Anomaly, int)
+ */
+ public void logAnomalies(MetricsFeatureProvider provider, List<Anomaly> anomalies,
+ int contextId) {
+ for (int i = 0, size = anomalies.size(); i < size; i++) {
+ logAnomaly(provider, anomalies.get(i), contextId);
+ }
+ }
+
+ /**
+ * Log the {@link Anomaly} using {@link MetricsFeatureProvider}, which contains
+ * anomaly type, package name, field_context, field_action_type
+ *
+ * @param provider provider to do the logging
+ * @param anomaly contains the data to log
+ * @param contextId which page invoke this logging
+ * @see #logAnomalies(MetricsFeatureProvider, List, int)
+ */
+ public void logAnomaly(MetricsFeatureProvider provider, Anomaly anomaly, int contextId) {
+ provider.action(
+ mContext,
+ mMetricArray.get(anomaly.type, MetricsProto.MetricsEvent.VIEW_UNKNOWN),
+ anomaly.packageName,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, contextId),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
+ getAnomalyAction(anomaly).getActionType()));
+ }
+
}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java b/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java
index 87212e7..3ee89d1 100644
--- a/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java
+++ b/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java
@@ -58,5 +58,6 @@
*/
public abstract boolean isActionActive(Anomaly anomaly);
+ @Anomaly.AnomalyActionType
public abstract int getActionType();
}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java b/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java
index dba221a..2c799ee 100644
--- a/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java
+++ b/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.support.annotation.VisibleForTesting;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.fuelgauge.anomaly.Anomaly;
/**
@@ -34,6 +35,7 @@
public StopAndBackgroundCheckAction(Context context) {
this(context, new ForceStopAction(context), new BackgroundCheckAction(context));
+ mActionMetricKey = MetricsProto.MetricsEvent.ACTION_APP_STOP_AND_BACKGROUND_CHECK;
}
@VisibleForTesting
@@ -46,6 +48,7 @@
@Override
public void handlePositiveAction(Anomaly anomaly, int metricsKey) {
+ super.handlePositiveAction(anomaly, metricsKey);
mForceStopAction.handlePositiveAction(anomaly, metricsKey);
mBackgroundCheckAction.handlePositiveAction(anomaly, metricsKey);
}
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 39d5f6d..7d61f7f 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -43,9 +43,9 @@
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
+import com.android.settings.widget.AppPreference;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.location.RecentLocationApps;
@@ -211,21 +211,19 @@
List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
for (final RecentLocationApps.Request request : recentLocationRequests) {
- RestrictedPreference pref = new RestrictedPreference(getPrefContext());
+ final AppPreference pref = new AppPreference(getPrefContext());
pref.setSummary(request.contentDescription);
pref.setIcon(request.icon);
pref.setTitle(request.label);
pref.setOnPreferenceClickListener(
new PackageEntryClickedListener(request.packageName, request.userHandle));
recentLocationPrefs.add(pref);
-
}
if (recentLocationRequests.size() > 0) {
addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
} else {
// If there's no item to display, add a "No recent apps" item.
- Preference banner = new Preference(getPrefContext());
- banner.setLayoutResource(R.layout.location_list_no_item);
+ Preference banner = new AppPreference(getPrefContext());
banner.setTitle(R.string.location_no_recent_apps);
banner.setSelectable(false);
mCategoryRecentLocationRequests.addPreference(banner);
diff --git a/src/com/android/settings/location/SettingsInjector.java b/src/com/android/settings/location/SettingsInjector.java
index 428745b..c6d1f37 100644
--- a/src/com/android/settings/location/SettingsInjector.java
+++ b/src/com/android/settings/location/SettingsInjector.java
@@ -40,6 +40,8 @@
import android.util.Log;
import android.util.Xml;
+import com.android.settings.widget.AppPreference;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -268,7 +270,7 @@
PackageManager pm = mContext.getPackageManager();
Drawable appIcon = pm.getDrawable(info.packageName, info.iconId, null);
Drawable icon = pm.getUserBadgedIcon(appIcon, info.mUserHandle);
- Preference pref = new Preference(prefContext);
+ Preference pref = new AppPreference(prefContext);
pref.setTitle(info.title);
pref.setSummary(null);
pref.setIcon(icon);
diff --git a/src/com/android/settings/notification/ZenAccessSettings.java b/src/com/android/settings/notification/ZenAccessSettings.java
index 44052b1..0a4915a 100644
--- a/src/com/android/settings/notification/ZenAccessSettings.java
+++ b/src/com/android/settings/notification/ZenAccessSettings.java
@@ -51,6 +51,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.AppSwitchPreference;
import java.util.ArrayList;
import java.util.Collections;
@@ -138,7 +139,7 @@
for (ApplicationInfo app : apps) {
final String pkg = app.packageName;
final CharSequence label = app.loadLabel(mPkgMan);
- final SwitchPreference pref = new SwitchPreference(getPrefContext());
+ final SwitchPreference pref = new AppSwitchPreference(getPrefContext());
pref.setPersistent(false);
pref.setIcon(app.loadIcon(mPkgMan));
pref.setTitle(label);
diff --git a/src/com/android/settings/utils/ManagedServiceSettings.java b/src/com/android/settings/utils/ManagedServiceSettings.java
index 7a888db..d488dfe 100644
--- a/src/com/android/settings/utils/ManagedServiceSettings.java
+++ b/src/com/android/settings/utils/ManagedServiceSettings.java
@@ -21,7 +21,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
-import android.app.Notification;
import android.app.NotificationManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -46,6 +45,7 @@
import com.android.settings.Utils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.notification.EmptyTextSettings;
+import com.android.settings.widget.AppSwitchPreference;
import java.util.Collections;
import java.util.List;
@@ -127,7 +127,7 @@
Log.e(TAG, "can't find package name", e);
}
final String summary = service.loadLabel(mPm).toString();
- final SwitchPreference pref = new SwitchPreference(getPrefContext());
+ final SwitchPreference pref = new AppSwitchPreference(getPrefContext());
pref.setPersistent(false);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo,
UserHandle.getUserId(service.applicationInfo.uid)));
diff --git a/src/com/android/settings/vpn2/LegacyVpnPreference.java b/src/com/android/settings/vpn2/LegacyVpnPreference.java
index 4ef2808..8fa9680 100644
--- a/src/com/android/settings/vpn2/LegacyVpnPreference.java
+++ b/src/com/android/settings/vpn2/LegacyVpnPreference.java
@@ -16,6 +16,8 @@
package com.android.settings.vpn2;
+import static com.android.internal.net.LegacyVpnInfo.STATE_CONNECTED;
+
import android.content.Context;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
@@ -23,7 +25,6 @@
import com.android.internal.net.VpnProfile;
import com.android.settings.R;
-import static com.android.internal.net.LegacyVpnInfo.STATE_CONNECTED;
/**
* {@link android.support.v7.preference.Preference} tracks the underlying legacy vpn profile and
@@ -35,6 +36,7 @@
LegacyVpnPreference(Context context) {
super(context, null /* attrs */);
setIcon(R.drawable.ic_vpn_key);
+ setUseSmallIcon(true);
}
public VpnProfile getProfile() {
diff --git a/src/com/android/settings/widget/AppPreference.java b/src/com/android/settings/widget/AppPreference.java
new file mode 100644
index 0000000..8a0e6a1
--- /dev/null
+++ b/src/com/android/settings/widget/AppPreference.java
@@ -0,0 +1,63 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.ProgressBar;
+
+import com.android.settings.R;
+
+public class AppPreference extends Preference {
+
+ private int mProgress;
+ private boolean mProgressVisible;
+
+ public AppPreference(Context context) {
+ super(context);
+ setLayoutResource(R.layout.preference_app);
+ }
+
+ public AppPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setLayoutResource(R.layout.preference_app);
+ }
+
+ public void setProgress(int amount) {
+ mProgress = amount;
+ mProgressVisible = true;
+ notifyChanged();
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder view) {
+ super.onBindViewHolder(view);
+
+ view.findViewById(R.id.summary_container)
+ .setVisibility(TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
+ final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
+ if (mProgressVisible) {
+ progress.setProgress(mProgress);
+ progress.setVisibility(View.VISIBLE);
+ } else {
+ progress.setVisibility(View.GONE);
+ }
+ }
+}
diff --git a/src/com/android/settings/widget/AppSwitchPreference.java b/src/com/android/settings/widget/AppSwitchPreference.java
new file mode 100644
index 0000000..d67e895
--- /dev/null
+++ b/src/com/android/settings/widget/AppSwitchPreference.java
@@ -0,0 +1,41 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.text.TextUtils;
+import android.view.View;
+
+import com.android.settings.R;
+
+public class AppSwitchPreference extends SwitchPreference {
+
+ public AppSwitchPreference(Context context) {
+ super(context);
+ setLayoutResource(R.layout.preference_app);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder view) {
+ super.onBindViewHolder(view);
+
+ view.findViewById(R.id.summary_container)
+ .setVisibility(TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
+ }
+}
diff --git a/src/com/android/settings/widget/RadioButtonPickerFragment.java b/src/com/android/settings/widget/RadioButtonPickerFragment.java
index e446340..7489a77 100644
--- a/src/com/android/settings/widget/RadioButtonPickerFragment.java
+++ b/src/com/android/settings/widget/RadioButtonPickerFragment.java
@@ -21,6 +21,7 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
+import android.support.annotation.LayoutRes;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
@@ -133,8 +134,13 @@
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
+
+ final int customLayoutResId = getRadioButtonPreferenceCustomLayoutResId();
if (shouldShowItemNone()) {
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
+ if (customLayoutResId > 0) {
+ nonePref.setLayoutResource(customLayoutResId);
+ }
nonePref.setIcon(R.drawable.ic_remove_circle);
nonePref.setTitle(R.string.app_list_preference_none);
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
@@ -144,6 +150,9 @@
if (candidateList != null) {
for (CandidateInfo info : candidateList) {
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
+ if (customLayoutResId > 0) {
+ pref.setLayoutResource(customLayoutResId);
+ }
bindPreference(pref, info.getKey(), info, defaultKey);
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
screen.addPreference(pref);
@@ -206,6 +215,14 @@
return null;
}
+ /**
+ * Provides a custom layout for each candidate row.
+ */
+ @LayoutRes
+ protected int getRadioButtonPreferenceCustomLayoutResId() {
+ return 0;
+ }
+
public static abstract class CandidateInfo {
public final boolean enabled;
diff --git a/tests/robotests/src/com/android/settings/accounts/ProviderPreferenceTest.java b/tests/robotests/src/com/android/settings/accounts/ProviderPreferenceTest.java
new file mode 100644
index 0000000..4e4bb4f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accounts/ProviderPreferenceTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.accounts;
+
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+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.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class ProviderPreferenceTest {
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ public void shouldUseSmallIcon() {
+ final ProviderPreference providerPreference = new ProviderPreference(
+ mContext, "account_type", null /* icon */, "provider_name");
+ final boolean useSmallIcon =
+ ReflectionHelpers.getField(providerPreference, "mUseSmallIcon");
+ assertThat(useSmallIcon).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
index 66ec80a..3621edd 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
@@ -17,6 +17,14 @@
package com.android.settings.applications.defaultapps;
+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.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Activity;
import android.content.Context;
import android.os.UserManager;
@@ -24,9 +32,10 @@
import android.util.Pair;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.RadioButtonPreference;
import org.junit.Before;
@@ -41,13 +50,6 @@
import java.util.ArrayList;
import java.util.List;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-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 DefaultAppPickerFragmentTest {
@@ -97,6 +99,12 @@
any(Pair.class));
}
+ @Test
+ public void shouldHaveAppPreferenceLayout() {
+ assertThat(mFragment.getRadioButtonPreferenceCustomLayoutResId())
+ .isEqualTo(R.layout.preference_app);
+ }
+
public static class TestFragment extends DefaultAppPickerFragment {
boolean setDefaultAppKeyCalled;
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 120f3ae..a02a2de 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
@@ -26,8 +26,9 @@
import android.support.v7.preference.Preference;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.TwoTargetPreference;
import org.junit.Before;
import org.junit.Test;
@@ -79,6 +80,16 @@
verify(mPreference).setSummary(R.string.app_list_preference_none);
}
+ @Test
+ public void updateState_twoTargetPref_shouldUseSmallIcon() {
+ final TwoTargetPreference pref = mock(TwoTargetPreference.class);
+ mController = new TestPreferenceController(mContext);
+
+ mController.updateState(pref);
+
+ verify(pref).setUseSmallIcon(true);
+ }
+
private static class TestPreferenceController extends DefaultAppPreferenceController {
private DefaultAppInfo mAppInfo;
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java
index cf2403b..c32b262 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ApplicationViewHolderTest.java
@@ -22,7 +22,6 @@
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
-import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
@@ -48,9 +47,8 @@
@Before
public void seUp() {
mContext = RuntimeEnvironment.application;
- mView = ApplicationViewHolder.newView(LayoutInflater.from(mContext),
- new FrameLayout(mContext));
- mHolder = new ApplicationViewHolder(mView);
+ mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
+ mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
}
@Test
@@ -71,6 +69,10 @@
mHolder.setSummary(R.string.disabled);
assertThat(mHolder.mSummary.getText()).isEqualTo(mContext.getText(R.string.disabled));
+ assertThat(mHolder.mSummaryContainer.getVisibility()).isEqualTo(View.VISIBLE);
+
+ mHolder.setSummary(null);
+ assertThat(mHolder.mSummaryContainer.getVisibility()).isEqualTo(View.GONE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 9eb36ef..a0b0146 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -18,6 +18,10 @@
import static com.android.settings.applications.manageapplications.AppFilterRegistry
.FILTER_APPS_ALL;
+import static com.android.settings.applications.manageapplications.ManageApplications
+ .LIST_TYPE_MAIN;
+import static com.android.settings.applications.manageapplications.ManageApplications
+ .LIST_TYPE_NOTIFICATION;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
@@ -102,7 +106,7 @@
@Test
public void updateMenu_mainListType_showAppReset() {
setUpOptionMenus();
- ReflectionHelpers.setField(mFragment, "mListType", ManageApplications.LIST_TYPE_MAIN);
+ ReflectionHelpers.setField(mFragment, "mListType", LIST_TYPE_MAIN);
ReflectionHelpers.setField(mFragment, "mOptionsMenu", mMenu);
mFragment.updateOptionsMenu();
@@ -183,6 +187,21 @@
}
@Test
+ public void shouldUseStableItemHeight_mainType_yes() {
+ assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
+ LIST_TYPE_MAIN))
+ .isTrue();
+ assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
+ LIST_TYPE_NOTIFICATION))
+ .isFalse();
+ }
+
+ @Test
+ public void shouldUseStableItemHeight_notificationType_no() {
+
+ }
+
+ @Test
public void onRebuildComplete_shouldHideLoadingView() {
final Context context = RuntimeEnvironment.application;
final ManageApplications fragment = mock(ManageApplications.class);
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
index 28ac9d9..fc761cc 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
@@ -27,7 +27,6 @@
import android.os.UserHandle;
import android.os.storage.VolumeInfo;
import android.provider.DocumentsContract;
-import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
@@ -68,9 +67,8 @@
mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid,
new UserHandle(0));
- LayoutInflater inflater = LayoutInflater.from(mContext);
- mView = ApplicationViewHolder.newView(inflater, new FrameLayout(mContext));
- mHolder = new ApplicationViewHolder(mView);
+ mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
+ mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
index 2a26e31..0a147ac 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
@@ -26,7 +26,6 @@
import android.content.Intent;
import android.os.UserHandle;
import android.os.storage.VolumeInfo;
-import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
@@ -67,9 +66,8 @@
new PhotosViewHolderController(
mContext, mSource, mVolume.fsUuid, new UserHandle(0));
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- mView = ApplicationViewHolder.newView(inflater, new FrameLayout(mContext));
- mHolder = new ApplicationViewHolder(mView);
+ mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
+ mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
index 220d829..e0d4638 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
@@ -15,21 +15,15 @@
*/
package com.android.settings.bluetooth;
-import static com.google.common.truth.Truth.assertThat;
-
-import android.bluetooth.BluetoothDevice;
import android.content.Context;
-import android.graphics.drawable.Drawable;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.graph.BluetoothDeviceLayerDrawable;
import org.junit.Before;
import org.junit.Test;
@@ -37,7 +31,6 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.mockito.Matchers.anyInt;
@@ -76,20 +69,4 @@
verify(mMetricsFeatureProvider).visible(eq(mContext), anyInt(),
eq(MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT_ERROR));
}
-
- @Test
- public void testGetBluetoothDrawable_noBatteryLevel_returnSimpleDrawable() {
- final Drawable drawable = Utils.getBluetoothDrawable(RuntimeEnvironment.application,
- R.drawable.ic_bt_laptop, BluetoothDevice.BATTERY_LEVEL_UNKNOWN, 1 /* iconScale */);
-
- assertThat(drawable).isNotInstanceOf(BluetoothDeviceLayerDrawable.class);
- }
-
- @Test
- public void testGetBluetoothDrawable_hasBatteryLevel_returnLayerDrawable() {
- final Drawable drawable = Utils.getBluetoothDrawable(RuntimeEnvironment.application,
- R.drawable.ic_bt_laptop, 10 /* batteryLevel */, 1 /* iconScale */);
-
- assertThat(drawable).isInstanceOf(BluetoothDeviceLayerDrawable.class);
- }
}
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 5e56714..8feef92 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
@@ -133,13 +133,6 @@
}
@Test
- public void isSuggestionEnabled_isNotLowMemoryDevice_shouldReturnTrue() {
- when(mActivityManager.isLowRamDevice()).thenReturn(false);
-
- assertThat(mProvider.isSuggestionEnabled(mContext)).isTrue();
- }
-
- @Test
public void isSuggestionV2Enabled_isNotLowMemoryDevice_sysPropOn_shouldReturnTrue() {
when(mActivityManager.isLowRamDevice()).thenReturn(false);
SettingsShadowSystemProperties.set(
@@ -148,14 +141,6 @@
}
@Test
- public void isSuggestionV2Enabled_isNotLowMemoryDevice_sysPropOff_shouldReturnTrue() {
- when(mActivityManager.isLowRamDevice()).thenReturn(false);
- SettingsShadowSystemProperties.set(
- FeatureFlagUtils.FFLAG_PREFIX + mProvider.FEATURE_FLAG_SUGGESTIONS_V2, "false");
- assertThat(mProvider.isSuggestionV2Enabled(mContext)).isFalse();
- }
-
- @Test
public void dismissSuggestion_noParserOrSuggestion_noop() {
mProvider.dismissSuggestion(mContext, null, (Tile) null);
mProvider.dismissSuggestion(mContext, mSuggestionParser, null);
diff --git a/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java
index 1367870..f59c29f 100644
--- a/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/OemUnlockPreferenceControllerTest.java
@@ -18,18 +18,17 @@
import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes
.REQUEST_CODE_ENABLE_OEM_UNLOCK;
-
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.doNothing;
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;
import android.app.Activity;
+import android.app.FragmentManager;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.UserManager;
import android.service.oemlock.OemLockManager;
@@ -43,6 +42,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;
@@ -81,6 +81,8 @@
mController = new OemUnlockPreferenceController(mContext, mActivity, mFragment);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
mPreference);
+ when(mFragment.getChildFragmentManager()).thenReturn(
+ mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS));
mController.displayPreference(mPreferenceScreen);
}
@@ -114,8 +116,8 @@
@Test
public void onPreferenceChanged_turnOffUnlock() {
mController.onPreferenceChange(null, false);
-
verify(mOemLockManager).setOemUnlockAllowedByUser(false);
+ verify(mFragment).getChildFragmentManager();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
index b737d1f..7d47fc2 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
@@ -32,6 +32,7 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
@@ -41,6 +42,8 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
import com.android.settings.widget.MasterSwitchPreference;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -83,6 +86,10 @@
mContext, mMetricsFeature, mFragmentManager);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
+ @After
+ public void tearDown() {
+ SettingsShadowSystemProperties.clear();
+ }
@Test
public void isAvailable_shouldReturnTrue_forHighRamDevice() {
@@ -146,6 +153,9 @@
public void togglingOnShouldTriggerWarningFragment() {
FragmentTransaction transaction = mock(FragmentTransaction.class);
when (mFragmentManager.beginTransaction()).thenReturn(transaction);
+ SettingsShadowSystemProperties.set(
+ AutomaticStorageManagementSwitchPreferenceController
+ .STORAGE_MANAGER_ENABLED_BY_DEFAULT_PROPERTY, "false");
mController.onSwitchToggled(true);
diff --git a/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java
index 0d22d2e..81223a5 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ApplicationListPreferenceControllerTest.java
@@ -16,6 +16,16 @@
package com.android.settings.enterprise;
+import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
@@ -23,10 +33,10 @@
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.applications.UserAppInfo;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -43,16 +53,6 @@
import java.util.List;
import java.util.Set;
-import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Answers.RETURNS_DEEP_STUBS;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.times;
-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 ApplicationListPreferenceControllerTest {
@@ -120,7 +120,7 @@
implements ApplicationListPreferenceController.ApplicationListBuilder {
@Override
public void buildApplicationList(Context context,
- ApplicationFeatureProvider.ListOfAppsCallback callback) {
+ ApplicationFeatureProvider.ListOfAppsCallback callback) {
final List<UserAppInfo> apps = new ArrayList<>();
final UserInfo user = new UserInfo(MAIN_USER_ID, "main", UserInfo.FLAG_ADMIN);
apps.add(new UserAppInfo(user, buildInfo(MAIN_USER_APP_UID, APP_1, 0, 0)));
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java
index 1259670..32f6a96 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerGaugePreferenceTest.java
@@ -15,6 +15,8 @@
*/
package com.android.settings.fuelgauge;
+import static com.google.common.truth.Truth.assertThat;
+
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
@@ -35,8 +37,6 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static com.google.common.truth.Truth.assertThat;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class PowerGaugePreferenceTest {
@@ -53,7 +53,7 @@
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mRootView = LayoutInflater.from(mContext).inflate(R.layout.preference,
+ mRootView = LayoutInflater.from(mContext).inflate(R.layout.preference_app,
null);
mWidgetView = LayoutInflater.from(mContext).inflate(R.layout.preference_widget_summary,
null);
@@ -61,6 +61,7 @@
mPreferenceViewHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
mPowerGaugePreference = new PowerGaugePreference(mContext);
+ assertThat(mPowerGaugePreference.getLayoutResource()).isEqualTo(R.layout.preference_app);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index 8030463..2b5e704 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -31,6 +31,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
import android.net.ConnectivityManager;
import android.os.UserManager;
import android.support.v7.preference.PreferenceCategory;
@@ -93,6 +94,10 @@
private PreferenceGroup mUsageListGroup;
@Mock
private ConnectivityManager mConnectivityManager;
+ @Mock
+ private UserInfo mNormalUserInfo;
+ @Mock
+ private UserInfo mManagedUserInfo;
private PowerUsageAdvanced mPowerUsageAdvanced;
private PowerUsageData mPowerUsageData;
private Context mShadowContext;
@@ -136,6 +141,11 @@
mMaxBatterySipper.totalPowerMah = TYPE_BLUETOOTH_USAGE;
mMaxBatterySipper.drainType = DrainType.BLUETOOTH;
mNormalBatterySipper.drainType = DrainType.SCREEN;
+
+ doReturn(true).when(mNormalUserInfo).isEnabled();
+ doReturn(false).when(mNormalUserInfo).isManagedProfile();
+ doReturn(true).when(mManagedUserInfo).isEnabled();
+ doReturn(true).when(mManagedUserInfo).isManagedProfile();
}
@Test
@@ -293,9 +303,12 @@
}
@Test
- public void testShouldHideCategory_typeUserAndOnlyOne_returnTrue() {
+ public void testShouldHideCategory_typeUserAndOnlyOneNormalUser_returnTrue() {
mPowerUsageData.usageType = UsageType.USER;
- doReturn(1).when(mUserManager).getUserCount();
+ List<UserInfo> userInfos = new ArrayList<>();
+ userInfos.add(mNormalUserInfo);
+ userInfos.add(mManagedUserInfo);
+ doReturn(userInfos).when(mUserManager).getUsers();
assertThat(mPowerUsageAdvanced.shouldHideCategory(mPowerUsageData)).isTrue();
}
@@ -321,7 +334,10 @@
@Test
public void testShouldHideCategory_typeUserAndMoreThanOne_returnFalse() {
mPowerUsageData.usageType = UsageType.USER;
- doReturn(2).when(mUserManager).getUserCount();
+ List<UserInfo> userInfos = new ArrayList<>();
+ userInfos.add(mNormalUserInfo);
+ userInfos.add(mNormalUserInfo);
+ doReturn(userInfos).when(mUserManager).getUsers();
assertThat(mPowerUsageAdvanced.shouldHideCategory(mPowerUsageData)).isFalse();
}
@@ -423,4 +439,5 @@
mPowerUsageAdvanced.refreshUi();
verify(mHistPref, atLeastOnce()).setBottomSummary(any());
}
+
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
index 8cd5a06..38391c9 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
@@ -18,8 +18,13 @@
import static com.google.common.truth.Truth.assertThat;
-import android.os.Build;
+import static org.mockito.Mockito.verify;
+import android.os.Build;
+import android.util.Pair;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.fuelgauge.anomaly.action.StopAndBackgroundCheckAction;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -31,18 +36,42 @@
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;
+
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
ShadowKeyValueListParserWrapperImpl.class})
public class AnomalyUtilsTest {
+ private static final String PACKAGE_NAME_WAKEUP = "com.android.app1";
+ private static final String PACKAGE_NAME_WAKELOCK = "com.android.app2";
+ private static final int CONTEXT_ID = 55;
+
+ @Mock
+ private MetricsFeatureProvider mMetricsFeatureProvider;
private AnomalyUtils mAnomalyUtils;
+ private Anomaly mWakeupAnomaly;
+ private Anomaly mWakeLockAnomaly;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
mAnomalyUtils = new AnomalyUtils(RuntimeEnvironment.application);
+
+ mWakeLockAnomaly = new Anomaly.Builder()
+ .setType(Anomaly.AnomalyType.WAKE_LOCK)
+ .setPackageName(PACKAGE_NAME_WAKELOCK)
+ .build();
+ mWakeupAnomaly = new Anomaly.Builder()
+ .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
+ .setPackageName(PACKAGE_NAME_WAKEUP)
+ .build();
}
@Test
@@ -97,4 +126,47 @@
assertThat(mAnomalyUtils.getAnomalyDetector(Anomaly.AnomalyType.WAKEUP_ALARM)).isInstanceOf(
WakeupAlarmAnomalyDetector.class);
}
+
+ @Test
+ public void testLogAnomaly() {
+ mAnomalyUtils.logAnomaly(mMetricsFeatureProvider, mWakeLockAnomaly, CONTEXT_ID);
+
+ verify(mMetricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKELOCK,
+ PACKAGE_NAME_WAKELOCK,
+ Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT,
+ CONTEXT_ID),
+ Pair.create(
+ MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
+ Anomaly.AnomalyActionType.FORCE_STOP));
+ }
+
+ @Test
+ public void testLogAnomalies() {
+ final List<Anomaly> anomalies = new ArrayList<>();
+ anomalies.add(mWakeLockAnomaly);
+ anomalies.add(mWakeupAnomaly);
+
+ mAnomalyUtils.logAnomalies(mMetricsFeatureProvider, anomalies, CONTEXT_ID);
+
+ verify(mMetricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKELOCK,
+ PACKAGE_NAME_WAKELOCK,
+ Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT,
+ CONTEXT_ID),
+ Pair.create(
+ MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
+ Anomaly.AnomalyActionType.FORCE_STOP));
+ verify(mMetricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKEUP_ALARM,
+ PACKAGE_NAME_WAKEUP,
+ Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT,
+ CONTEXT_ID),
+ Pair.create(
+ MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
+ Anomaly.AnomalyActionType.STOP_AND_BACKGROUND_CHECK));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/widget/AppPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppPreferenceTest.java
new file mode 100644
index 0000000..d489094
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/AppPreferenceTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AppPreferenceTest {
+
+ private Context mContext;
+ private View mRootView;
+ private AppPreference mPref;
+ private PreferenceViewHolder mHolder;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
+ mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
+ mPref = new AppPreference(mContext);
+ }
+
+ @Test
+ public void setProgress_showProgress() {
+ mPref.setProgress(1);
+ mPref.onBindViewHolder(mHolder);
+
+ assertThat(mHolder.findViewById(android.R.id.progress).getVisibility())
+ .isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void setSummary_showSummaryContainer() {
+ mPref.setSummary("test");
+ mPref.onBindViewHolder(mHolder);
+
+ assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
+ .isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void noSummary_hideSummaryContainer() {
+ mPref.setSummary(null);
+ mPref.onBindViewHolder(mHolder);
+
+ assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
+ .isEqualTo(View.GONE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
new file mode 100644
index 0000000..a7c8d7c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AppSwitchPreferenceTest {
+
+ private Context mContext;
+ private View mRootView;
+ private AppSwitchPreference mPref;
+ private PreferenceViewHolder mHolder;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
+ mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
+ mPref = new AppSwitchPreference(mContext);
+ }
+
+ @Test
+ public void setSummary_showSummaryContainer() {
+ mPref.setSummary("test");
+ mPref.onBindViewHolder(mHolder);
+
+ assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
+ .isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void noSummary_hideSummaryContainer() {
+ mPref.setSummary(null);
+ mPref.onBindViewHolder(mHolder);
+
+ assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
+ .isEqualTo(View.GONE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java b/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java
index e314ef3..40d73eb 100644
--- a/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java
@@ -16,15 +16,21 @@
package com.android.settings.widget;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Activity;
import android.content.Context;
import android.os.UserManager;
import android.support.v7.preference.PreferenceScreen;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.applications.defaultapps.DefaultAppInfo;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -38,12 +44,6 @@
import java.util.ArrayList;
import java.util.List;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-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 RadioButtonPickerFragmentTest {
@@ -99,6 +99,11 @@
assertThat(mFragment.setDefaultKeyCalled).isTrue();
}
+ @Test
+ public void shouldHaveNoCustomPreferenceLayout() {
+ assertThat(mFragment.getRadioButtonPreferenceCustomLayoutResId()).isEqualTo(0);
+ }
+
public static class TestFragment extends RadioButtonPickerFragment {
boolean setDefaultKeyCalled;