merge in oc-release history after reset to master
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a6d066b..791be09 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2490,6 +2490,18 @@
android:value="com.android.settings.applications.PictureInPictureSettings" />
</activity>
+ <activity android:name="Settings$AppPictureInPictureSettingsActivity"
+ android:label="@string/picture_in_picture_title"
+ android:taskAffinity="">
+ <intent-filter>
+ <action android:name="android.settings.PICTURE_IN_PICTURE_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="package" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.PictureInPictureDetails" />
+ </activity>
+
<activity android:name="Settings$ZenAccessSettingsActivity"
android:label="@string/manage_zen_access_title"
android:taskAffinity="">
diff --git a/res/layout/app_details.xml b/res/layout/app_details.xml
index 15cb38a..00d4cca 100644
--- a/res/layout/app_details.xml
+++ b/res/layout/app_details.xml
@@ -18,7 +18,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/app_snippet"
- style="@style/AppInfoHeader"
+ style="@style/EntityHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
@@ -79,7 +79,7 @@
<TextView
android:id="@+id/app_detail_title"
- style="@style/TextAppearance.AppInfoTitle"
+ style="@style/TextAppearance.EntityHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false"
@@ -89,22 +89,24 @@
<TextView
android:id="@+id/install_type"
- style="@style/TextAppearance.AppInfoSummary"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
- android:ellipsize="marquee"/>
+ android:ellipsize="marquee"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondary"/>
<TextView
android:id="@+id/app_detail_summary"
- style="@style/TextAppearance.AppInfoSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
- android:ellipsize="marquee"/>
+ android:ellipsize="marquee"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
diff --git a/res/layout/preference_widget_seekbar_settings.xml b/res/layout/preference_widget_seekbar_settings.xml
index 77c27a4..87fea99 100644
--- a/res/layout/preference_widget_seekbar_settings.xml
+++ b/res/layout/preference_widget_seekbar_settings.xml
@@ -15,81 +15,49 @@
-->
<!-- Layout used by SeekBarPreference for the seekbar widget style. -->
-<!-- Same as frameworks/base/core/res/res/layout/preference_widget_seekbar_material.xml with
- reserved icon space -->
-<LinearLayout
+<RelativeLayout
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:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingBottom="6dp"
+ android:paddingTop="6dp">
- <LinearLayout
- android:id="@+id/icon_container"
+ <TextView
+ android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:minWidth="60dp"
- android:gravity="start|center_vertical"
- android:orientation="horizontal"
- android:paddingEnd="12dp"
- android:paddingTop="4dp"
- android:paddingBottom="4dp">
- <com.android.internal.widget.PreferenceImageView
- android:id="@android:id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxWidth="48dp"
- android:maxHeight="48dp"/>
- </LinearLayout>
+ android:layout_marginStart="60dp"
+ android:layout_marginEnd="8dp"
+ android:singleLine="true"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textColor="?android:attr/textColorPrimary"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
- <RelativeLayout
+ <TextView
+ android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginEnd="8dip"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
- android:layout_weight="1">
+ android:layout_marginStart="60dp"
+ android:layout_marginEnd="8dp"
+ android:layout_below="@android:id/title"
+ android:layout_alignStart="@android:id/title"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="4" />
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textColor="?android:attr/textColorPrimary"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal"/>
+ <com.android.settings.widget.DefaultIndicatorSeekBar
+ android:id="@*android:id/seekbar"
+ style="@android:style/Widget.Material.SeekBar.Discrete"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:layout_alignParentEnd="true"
+ android:layout_below="@android:id/summary"
+ android:layout_marginEnd="8dp"
+ android:layout_marginStart="44dp" />
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@android:id/title"
- android:layout_alignStart="@android:id/title"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
- android:maxLines="4"/>
-
- <!-- Preference should place its actual preference widget here. -->
- <LinearLayout
- android:id="@android:id/widget_frame"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_below="@android:id/summary"
- android:layout_alignStart="@android:id/title"
- android:gravity="center"
- android:orientation="vertical"/>
-
- <SeekBar
- android:id="@*android:id/seekbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@android:id/summary"
- android:layout_toEndOf="@android:id/widget_frame"
- android:layout_alignParentEnd="true"/>
-
- </RelativeLayout>
-
-</LinearLayout>
+</RelativeLayout>
diff --git a/res/layout/storage_item.xml b/res/layout/storage_item.xml
index de73543..520f5ce 100644
--- a/res/layout/storage_item.xml
+++ b/res/layout/storage_item.xml
@@ -31,25 +31,25 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
- <TextView
- android:id="@android:id/title"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textAlignment="viewStart"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAlignment="viewStart"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondaryNoDisable"
- android:maxLines="10" />
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondaryNoDisable"
+ android:maxLines="10" />
</LinearLayout>
diff --git a/res/layout/storage_item_alternate.xml b/res/layout/storage_item_alternate.xml
deleted file mode 100644
index b41c82b..0000000
--- a/res/layout/storage_item_alternate.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:minHeight="?android:attr/listPreferredItemHeightSmall"
- android:gravity="center_vertical"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="16dip"
- android:paddingBottom="16dip"
- android:background="?android:attr/selectableItemBackground">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textAlignment="viewStart"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondaryNoDisable"
- android:maxLines="10" />
-
- </LinearLayout>
-
-</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ddb1bf1..2520722 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1306,6 +1306,9 @@
<!-- Title of preference to manage device admins -->
<string name="manage_device_admin">Device admin apps</string>
+ <!-- Summary of preference to manage device administrators, informing the user that currently no device administrator apps are installed and active -->
+ <string name="number_of_device_admins_none">No active apps</string>
+
<!-- Summary of preference to manage device administrators, informing the user how many device administrator apps are installed and active -->
<plurals name="number_of_device_admins">
<item quantity="one"><xliff:g id="count">%d</xliff:g> active app</item>
@@ -2230,6 +2233,8 @@
<string name="night_display_start_time_title">Start time</string>
<!-- Night display screen, setting option name to configure time to automatically turn off night display. [CHAR LIMIT=30] -->
<string name="night_display_end_time_title">End time</string>
+ <!-- Night display screen, setting the color temperature of the display. [CHAR LIMIT=30] -->
+ <string name="night_display_temperature_title">Intensity</string>
<!-- Display settings screen, summary format of night display when off. [CHAR LIMIT=NONE] -->
<string name="night_display_summary_off">Off. <xliff:g name="auto_mode_summary" example="Never turn on automatically">%1$s</xliff:g></string>
<!-- Display settings screen, summary of night display when off and will *never* turn on automatically. [CHAR LIMIT=NONE] -->
@@ -3362,20 +3367,25 @@
<string name="install_applications">Unknown sources</string>
<!-- Applications settings screen, setting check box title. If checked, the system allows installation of applications that are downloaded from random places, such as web sites. [CHAR LIMIT=30] -->
<string name="install_applications_title">Allow all app sources</string>
- <!-- Applications settings screen, setting check box summary. This is the summary for "Unknown sources" checkbox [CHAR LIMIT=65] -->
- <string name="install_unknown_applications_title">Lets you install apps from sources other than Google Play</string>
- <!-- Applications settings screen, setting check box summary. This is the summary for "Unknown sources" checkbox -->
- <string name="install_unknown_applications">Allow installation of apps from unknown sources</string>
- <!-- Applications settings screen, message text of alert that appears if user selects the "Unknown sources" check box -->
- <string name="install_all_warning" product="tablet">Your tablet and personal data are more vulnerable to attack by apps
- from unknown sources. You agree that you are solely responsible for any
- damage to your tablet or loss of data that may result from using
- these apps.</string>
- <!-- Applications settings screen, message text of alert that appears if user selects the "Unknown sources" check box -->
- <string name="install_all_warning" product="default">Your phone and personal data are more vulnerable to attack by apps
- from unknown sources. You agree that you are solely responsible for any
- damage to your phone or loss of data that may result from using
- these apps.</string>
+
+ <!-- Warning that appears below the unknown sources switch in settings -->
+ <string name="install_all_warning" product="tablet">
+ Your tablet and personal data are more vulnerable
+ to attack by unknown apps. By installing apps from
+ this source, you agree that you are responsible for
+ any damage to your tablet or loss of data that may
+ result from their use.
+ </string>
+
+ <!-- Warning that appears below the unknown sources switch in settings -->
+ <string name="install_all_warning" product="default">
+ Your phone and personal data are more vulnerable
+ to attack by unknown apps. By installing apps from
+ this source, you agree that you are responsible for
+ any damage to your phone or loss of data that may
+ result from their use.
+ </string>
+
<!-- Applications settings screen, setting check box title. If checked, applications show more settings options. -->
<string name="advanced_settings">Advanced settings</string>
<!-- Applications settings screen, setting check box summary. This is the summary for "Advanced settings" checkbox -->
@@ -3807,7 +3817,7 @@
<!-- Title for the 'keyboard and input methods' preference category. [CHAR LIMIT=45] -->
<string name="keyboard_and_input_methods_category">Keyboard and input methods</string>
<!-- Title for the 'virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
- <string name="virtual_keyboard_category">Virtual keyboard</string>
+ <string name="virtual_keyboard_category">Virtual keyboards</string>
<!-- Title for the 'available virtual keyboard' preference sub-screen. [CHAR LIMIT=35] -->
<string name="available_virtual_keyboard_category">Available virtual keyboard</string>
<!-- Title for the button to trigger the 'Manage keyboards' preference sub-screen, where the user can turn on/off installed virtual keyboards.[CHAR LIMIT=35] -->
@@ -6459,8 +6469,17 @@
<!-- Apps > App Details > Advanced section string title. [CHAR LIMIT=NONE] -->
<string name="picture_in_picture_app_detail_title">Picture-in-picture</string>
- <!-- Apps > App Details > Advanced section string description. [CHAR LIMIT=NONE] -->
- <string name="picture_in_picture_app_detail_summary">Permit entering picture-in-picture when leaving app</string>
+ <!-- Apps > App Details > Picture-in-picture > Switch title. [CHAR LIMIT=NONE] -->
+ <string name="picture_in_picture_app_detail_switch">Allow picture-in-picture</string>
+
+ <!-- Apps > App Details > Picture-in-picture > Description. [CHAR LIMIT=NONE] -->
+ <string name="picture_in_picture_app_detail_summary">Allow this app to create a picture-in-picture window while the app is open or after you leave it (for example, to continue watching a video). This window displays on top of other apps you're using.</string>
+
+ <!-- Summary of app allowed to enter picture-in-picture. [CHAR LIMIT=60] -->
+ <string name="picture_in_picture_on">Yes</string>
+
+ <!-- Summary of app not allowed to enter picture-in-picture. [CHAR LIMIT=60] -->
+ <string name="picture_in_picture_off">No</string>
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
<string name="manage_zen_access_title">Do Not Disturb access</string>
@@ -7383,9 +7402,9 @@
<string name="system_alert_window_off">No</string>
<!-- Title for settings screen for controlling apps that can install other apps on device [CHAR LIMIT=50] -->
- <string name="install_other_apps">Install other apps</string>
+ <string name="install_other_apps">Install unknown apps</string>
<!-- Keywords for setting screen for controlling apps that can install other apps on device -->
- <string name="keywords_install_other_apps">install apps external unknown sources</string>
+ <string name="keywords_install_other_apps">install apps unknown sources</string>
<!-- Write Settings settings -->
<!-- Settings title in main settings screen for WRITE_SETTINGS [CHAR LIMIT=30] -->
@@ -7418,7 +7437,7 @@
<!-- Summary of app not trusted to install apps [CHAR LIMIT=45] -->
<string name="external_source_untrusted">No</string>
<!-- Title of switch preference that controls whether an external app source is trusted or not [CHAR LIMIT=50] -->
- <string name="external_source_switch_title">Trust apps from this source</string>
+ <string name="external_source_switch_title">Allow app installs</string>
<!-- Title of setting that controls gesture to open camera [CHAR LIMIT=40] -->
<string name="camera_gesture_title">Double twist for camera</string>
@@ -8168,7 +8187,7 @@
<!-- Enterprise Privacy --> <skip />
<!-- Title of setting on security settings screen. This will take the user to a screen with information about admin powers and their impact on the user's privacy on a managed device. Shown on enterprise-managed devices only. Note: "Device" is singular and refers to the device (e.g. phone or tablet) that the user is holding in their hand. -->
- <string name="enterprise_privacy_settings">Managed device details</string>
+ <string name="enterprise_privacy_settings">Managed device info</string>
<!-- Summary for Enterprise Privacy settings, explaining what the user can expect to find under it [CHAR LIMIT=NONE]-->
<string name="enterprise_privacy_settings_summary_generic">Changes & settings managed by your organization</string>
<!-- Summary for Enterprise Privacy settings, explaining what the user can expect to find under it [CHAR LIMIT=NONE]-->
@@ -8229,13 +8248,13 @@
<string name="enterprise_privacy_global_http_proxy">Global HTTP proxy set</string>
<!-- Label explaining that the admin installed trusted CA certificates for the current user. [CHAR LIMIT=NONE] -->
<plurals name="enterprise_privacy_ca_certs_user">
- <item quantity="one">Trusted CA Certificate installed</item>
- <item quantity="other">Trusted CA Certificates installed</item>
+ <item quantity="one">Trusted CA certificate installed</item>
+ <item quantity="other">Trusted CA certificates installed</item>
</plurals>
<!-- Label explaining that the admin installed trusted CA certificates for the personal profile. [CHAR LIMIT=NONE] -->
<plurals name="enterprise_privacy_ca_certs_personal">
- <item quantity="one">Trusted CA Certificate installed in your personal profile</item>
- <item quantity="other">Trusted CA Certificates installed in your personal profile</item>
+ <item quantity="one">Trusted CA certificate installed in your personal profile</item>
+ <item quantity="other">Trusted CA certificates installed in your personal profile</item>
</plurals>
<!-- Summary indicating the number of trusted CA certificates installed by the admin. [CHAR LIMIT=NONE] -->
<plurals name="enterprise_privacy_number_ca_certs">
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 95efaec..fa40932 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -428,19 +428,6 @@
<item name="android:textSize">24sp</item>
</style>
- <style name="AppInfoHeader" parent="EntityHeader">
- <item name="android:background">?android:attr/colorAccent</item>
- </style>
-
- <style name="TextAppearance.AppInfoTitle" parent="TextAppearance.EntityHeaderTitle">
- <item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
- </style>
-
- <style name="TextAppearance.AppInfoSummary"
- parent="@android:style/TextAppearance.Material.Body1">
- <item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
- </style>
-
<style name="AppActionPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
<style name="LockPatternStyle">
diff --git a/res/xml/night_display_settings.xml b/res/xml/night_display_settings.xml
index c0b91ae..f78a769 100644
--- a/res/xml/night_display_settings.xml
+++ b/res/xml/night_display_settings.xml
@@ -16,7 +16,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/night_display_title">
<PreferenceCategory
@@ -44,6 +43,10 @@
android:key="night_display_activated"
android:title="@string/night_display_title" />
+ <com.android.settings.SeekBarPreference
+ android:key="night_display_temperature"
+ android:title="@string/night_display_temperature_title"/>
+
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index 8bf5c56..6eaede9 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -79,6 +79,7 @@
android:title="@string/picture_in_picture_title"
android:fragment="com.android.settings.applications.PictureInPictureSettings"
settings:keywords="@string/picture_in_picture_keywords" />
+
<Preference
android:key="premium_sms"
android:title="@string/premium_sms_access"
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index bf8483f..64a2aba 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -30,28 +30,28 @@
android:order="1"
settings:allowDividerAbove="true"
settings:allowDividerBelow="true"/>
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_photos_videos"
android:title="@string/storage_photos_videos"
- android:order="2"
- settings:allowDividerAbove="true" />
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ settings:allowDividerAbove="true"
+ android:order="2" />
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_music_audio"
android:title="@string/storage_music_audio"
android:order="3" />
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_games"
android:title="@string/storage_games"
android:order="4" />
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_other_apps"
android:title="@string/storage_other_apps"
android:order="5" />
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_files"
android:title="@string/storage_files"
android:order="6" />
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_system"
android:title="@string/storage_detail_system"
android:order="100" />
diff --git a/res/xml/storage_profile_fragment.xml b/res/xml/storage_profile_fragment.xml
index d0c5c3a..c675744 100644
--- a/res/xml/storage_profile_fragment.xml
+++ b/res/xml/storage_profile_fragment.xml
@@ -18,24 +18,24 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/storage_settings">
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_photos_videos"
android:title="@string/storage_photos_videos">
- </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ </com.android.settings.deviceinfo.StorageItemPreference>
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_music_audio"
android:title="@string/storage_music_audio">
- </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ </com.android.settings.deviceinfo.StorageItemPreference>
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_games"
android:title="@string/storage_games">
- </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ </com.android.settings.deviceinfo.StorageItemPreference>
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_other_apps"
android:title="@string/storage_other_apps">
- </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
- <com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
+ </com.android.settings.deviceinfo.StorageItemPreference>
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_files"
android:title="@string/storage_files">
- </com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
+ </com.android.settings.deviceinfo.StorageItemPreference>
</PreferenceScreen>
diff --git a/src/com/android/settings/SeekBarPreference.java b/src/com/android/settings/SeekBarPreference.java
index 26b69db..a8d5fbf 100644
--- a/src/com/android/settings/SeekBarPreference.java
+++ b/src/com/android/settings/SeekBarPreference.java
@@ -21,7 +21,6 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.content.res.TypedArrayUtils;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.KeyEvent;
@@ -29,6 +28,7 @@
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
+import com.android.settings.widget.DefaultIndicatorSeekBar;
import com.android.settingslib.RestrictedPreference;
/**
@@ -41,6 +41,11 @@
private int mMax;
private boolean mTrackingTouch;
+ private boolean mContinuousUpdates;
+ private int mDefaultProgress = -1;
+
+ private SeekBar mSeekBar;
+
public SeekBarPreference(
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
@@ -78,12 +83,15 @@
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
view.itemView.setOnKeyListener(this);
- SeekBar seekBar = (SeekBar) view.findViewById(
+ mSeekBar = (SeekBar) view.findViewById(
com.android.internal.R.id.seekbar);
- seekBar.setOnSeekBarChangeListener(this);
- seekBar.setMax(mMax);
- seekBar.setProgress(mProgress);
- seekBar.setEnabled(isEnabled());
+ mSeekBar.setOnSeekBarChangeListener(this);
+ mSeekBar.setMax(mMax);
+ mSeekBar.setProgress(mProgress);
+ mSeekBar.setEnabled(isEnabled());
+ if (mSeekBar instanceof DefaultIndicatorSeekBar) {
+ ((DefaultIndicatorSeekBar) mSeekBar).setDefaultProgress(mDefaultProgress);
+ }
}
@Override
@@ -126,6 +134,27 @@
setProgress(progress, true);
}
+ /**
+ * Sets the progress point to draw a single tick mark representing a default value.
+ */
+ public void setDefaultProgress(int defaultProgress) {
+ if (mDefaultProgress != defaultProgress) {
+ mDefaultProgress = defaultProgress;
+ if (mSeekBar instanceof DefaultIndicatorSeekBar) {
+ ((DefaultIndicatorSeekBar) mSeekBar).setDefaultProgress(mDefaultProgress);
+ }
+ }
+ }
+
+ /**
+ * When {@code continuousUpdates} is true, update the persisted setting immediately as the thumb
+ * is dragged along the SeekBar. Otherwise, only update the value of the setting when the thumb
+ * is dropped.
+ */
+ public void setContinuousUpdates(boolean continuousUpdates) {
+ mContinuousUpdates = continuousUpdates;
+ }
+
private void setProgress(int progress, boolean notifyChanged) {
if (progress > mMax) {
progress = mMax;
@@ -164,7 +193,7 @@
@Override
public void onProgressChanged(
SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser && !mTrackingTouch) {
+ if (fromUser && (mContinuousUpdates || !mTrackingTouch)) {
syncProgress(seekBar);
}
}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index f2d6452..8f645f8 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -95,6 +95,7 @@
public static class NotificationAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class VrListenersSettingsActivity extends SettingsActivity { /* empty */ }
public static class PictureInPictureSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AppPictureInPictureSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class ConditionProviderSettingsActivity extends SettingsActivity { /* empty */ }
public static class UsbSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/applications/AppCounter.java b/src/com/android/settings/applications/AppCounter.java
index 9464531..09a10e2 100644
--- a/src/com/android/settings/applications/AppCounter.java
+++ b/src/com/android/settings/applications/AppCounter.java
@@ -57,6 +57,10 @@
onCountComplete(count);
}
+ void executeInForeground() {
+ onPostExecute(doInBackground());
+ }
+
protected abstract void onCountComplete(int num);
protected abstract List<UserInfo> getUsersToCount();
protected abstract boolean includeInCount(ApplicationInfo info);
diff --git a/src/com/android/settings/applications/AppStateInstallAppsBridge.java b/src/com/android/settings/applications/AppStateInstallAppsBridge.java
index 39a31e6..cc7fb62 100644
--- a/src/com/android/settings/applications/AppStateInstallAppsBridge.java
+++ b/src/com/android/settings/applications/AppStateInstallAppsBridge.java
@@ -43,12 +43,10 @@
private final IPackageManager mIpm;
private final AppOpsManager mAppOpsManager;
- private final Context mContext;
public AppStateInstallAppsBridge(Context context, ApplicationsState appState,
Callback callback) {
super(appState, callback);
- mContext = context;
mIpm = AppGlobals.getPackageManager();
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
}
diff --git a/src/com/android/settings/applications/ApplicationFeatureProvider.java b/src/com/android/settings/applications/ApplicationFeatureProvider.java
index fccbbd3..7dce793 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProvider.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProvider.java
@@ -35,15 +35,17 @@
public static final int IGNORE_INSTALL_REASON = -1;
/**
- * Asynchronously calculates the total number of apps installed on the device, across all users
- * and managed profiles.
+ * Calculates the total number of apps installed on the device, across all users and managed
+ * profiles.
*
* @param installReason Only consider apps with this install reason; may be any install reason
* defined in {@link android.content.pm.PackageManager} or
* {@link #IGNORE_INSTALL_REASON} to count all apps, irrespective of install reason.
+ * @param async Whether to count asynchronously in a background thread
* @param callback The callback to invoke with the result
*/
- void calculateNumberOfInstalledApps(int installReason, NumberOfAppsCallback callback);
+ void calculateNumberOfInstalledApps(int installReason, boolean async,
+ NumberOfAppsCallback callback);
/**
* Asynchronously calculates the total number of apps installed on the device, across all users
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index 31d26ed..5ba228f 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -56,8 +56,15 @@
}
@Override
- public void calculateNumberOfInstalledApps(int installReason, NumberOfAppsCallback callback) {
- new AllUserInstalledAppCounter(mContext, installReason, mPm, callback).execute();
+ public void calculateNumberOfInstalledApps(int installReason, boolean async,
+ NumberOfAppsCallback callback) {
+ final AllUserInstalledAppCounter counter = new AllUserInstalledAppCounter(mContext,
+ installReason, mPm, callback);
+ if (async) {
+ counter.execute();
+ } else {
+ counter.executeInForeground();
+ }
}
@Override
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 08be7f7..e00ba92 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -52,7 +52,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
-import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceCategory;
@@ -1041,17 +1040,16 @@
category.addPreference(pref);
}
if (hasPictureInPictureActivities) {
- final SwitchPreference pref = new SwitchPreference(getPrefContext());
- pref.setPersistent(false);
+ Preference pref = new Preference(getPrefContext());
pref.setTitle(R.string.picture_in_picture_app_detail_title);
- pref.setSummary(R.string.picture_in_picture_app_detail_summary);
- pref.setChecked(PictureInPictureSettings.getEnterPipOnHideStateForPackage(
- getContext(), mPackageInfo.applicationInfo.uid, mPackageName));
- pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ pref.setKey("picture_in_picture");
+ pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- PictureInPictureSettings.setEnterPipOnHideStateForPackage(getContext(),
- mPackageInfo.applicationInfo.uid, mPackageName, (Boolean) newValue);
+ public boolean onPreferenceClick(Preference preference) {
+ AppInfoBase.startAppInfoFragment(PictureInPictureDetails.class,
+ R.string.picture_in_picture_app_detail_title, mPackageName,
+ mPackageInfo.applicationInfo.uid, InstalledAppDetails.this,
+ -1, getMetricsCategory());
return true;
}
});
@@ -1164,6 +1162,11 @@
if (pref != null) {
pref.setSummary(DrawOverlayDetails.getSummary(getContext(), mAppEntry));
}
+ pref = findPreference("picture_in_picture");
+ if (pref != null) {
+ pref.setSummary(PictureInPictureDetails.getPreferenceSummary(getContext(),
+ mPackageInfo.applicationInfo.uid, mPackageName));
+ }
pref = findPreference("write_settings_apps");
if (pref != null) {
pref.setSummary(WriteSettingsDetails.getSummary(getContext(), mAppEntry));
diff --git a/src/com/android/settings/applications/PictureInPictureDetails.java b/src/com/android/settings/applications/PictureInPictureDetails.java
new file mode 100644
index 0000000..41f006a
--- /dev/null
+++ b/src/com/android/settings/applications/PictureInPictureDetails.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.applications;
+
+import static android.app.AppOpsManager.MODE_ALLOWED;
+import static android.app.AppOpsManager.MODE_ERRORED;
+import static android.app.AppOpsManager.OP_PICTURE_IN_PICTURE;
+
+import android.app.AlertDialog;
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.Preference.OnPreferenceChangeListener;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
+
+public class PictureInPictureDetails extends AppInfoWithHeader
+ implements OnPreferenceChangeListener {
+
+ private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
+ private static final String KEY_APP_OPS_SETTINGS_PREFS = "app_ops_settings_preference";
+ private static final String KEY_APP_OPS_SETTINGS_DESC = "app_ops_settings_description";
+ private static final String LOG_TAG = "PictureInPictureDetails";
+
+ private SwitchPreference mSwitchPref;
+ private Preference mOverlayDesc;
+ private Intent mSettingsIntent;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // find preferences
+ addPreferencesFromResource(R.xml.app_ops_permissions_details);
+ mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
+ mOverlayDesc = findPreference(KEY_APP_OPS_SETTINGS_DESC);
+ getPreferenceScreen().removePreference(findPreference(KEY_APP_OPS_SETTINGS_PREFS));
+
+ // set title/summary for all of them
+ getPreferenceScreen().setTitle(R.string.picture_in_picture_app_detail_title);
+ mSwitchPref.setTitle(R.string.picture_in_picture_app_detail_switch);
+ mOverlayDesc.setSummary(R.string.picture_in_picture_app_detail_summary);
+
+ // install event listeners
+ mSwitchPref.setOnPreferenceChangeListener(this);
+
+ mSettingsIntent = new Intent(Intent.ACTION_MAIN)
+ .setAction(Settings.ACTION_PICTURE_IN_PICTURE_SETTINGS);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mSwitchPref) {
+ logSpecialPermissionChange((Boolean) newValue, mPackageName);
+ setEnterPipStateForPackage(getActivity(), mPackageInfo.applicationInfo.uid, mPackageName,
+ (Boolean) newValue);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean refreshUi() {
+ boolean isAllowed = getEnterPipStateForPackage(getActivity(),
+ mPackageInfo.applicationInfo.uid, mPackageName);
+ mSwitchPref.setChecked(isAllowed);
+ return true;
+ }
+
+ @Override
+ protected AlertDialog createDialog(int id, int errorCode) {
+ return null;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.SETTINGS_MANAGE_PICTURE_IN_PICTURE;
+ }
+
+ /**
+ * Sets whether the app associated with the given {@param packageName} is allowed to enter
+ * picture-in-picture.
+ */
+ static void setEnterPipStateForPackage(Context context, int uid, String packageName,
+ boolean value) {
+ final AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
+ final int newMode = value ? MODE_ALLOWED : MODE_ERRORED;
+ appOps.setMode(OP_PICTURE_IN_PICTURE, uid, packageName, newMode);
+ }
+
+ /**
+ * @return whether the app associated with the given {@param packageName} is allowed to enter
+ * picture-in-picture.
+ */
+ static boolean getEnterPipStateForPackage(Context context, int uid, String packageName) {
+ final AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
+ return appOps.checkOpNoThrow(OP_PICTURE_IN_PICTURE, uid, packageName) == MODE_ALLOWED;
+ }
+
+ /**
+ * @return the summary for the current state of whether the app associated with the given
+ * {@param packageName} is allowed to enter picture-in-picture.
+ */
+ static int getPreferenceSummary(Context context, int uid, String packageName) {
+ final boolean enabled = PictureInPictureDetails.getEnterPipStateForPackage(context, uid,
+ packageName);
+ return enabled ? R.string.picture_in_picture_on : R.string.picture_in_picture_off;
+ }
+
+ @VisibleForTesting
+ void logSpecialPermissionChange(boolean newState, String packageName) {
+ int logCategory = newState
+ ? MetricsEvent.APP_PICTURE_IN_PICTURE_ALLOW
+ : MetricsEvent.APP_PICTURE_IN_PICTURE_DENY;
+ FeatureFactory.getFactory(getContext())
+ .getMetricsFeatureProvider().action(getContext(), logCategory, packageName);
+ }
+}
diff --git a/src/com/android/settings/applications/PictureInPictureSettings.java b/src/com/android/settings/applications/PictureInPictureSettings.java
index df73572..b1c544a 100644
--- a/src/com/android/settings/applications/PictureInPictureSettings.java
+++ b/src/com/android/settings/applications/PictureInPictureSettings.java
@@ -15,13 +15,9 @@
*/
package com.android.settings.applications;
-import static android.app.AppOpsManager.MODE_ALLOWED;
-import static android.app.AppOpsManager.MODE_ERRORED;
-import static android.app.AppOpsManager.OP_ENTER_PICTURE_IN_PICTURE_ON_HIDE;
import static android.content.pm.PackageManager.GET_ACTIVITIES;
import android.annotation.Nullable;
-import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
@@ -30,8 +26,8 @@
import android.content.pm.PackageManager;
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.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceScreen;
import android.util.ArrayMap;
import android.view.View;
@@ -40,7 +36,6 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.notification.EmptyTextSettings;
-import com.android.settings.overlay.FeatureFactory;
import java.util.ArrayList;
import java.util.Collections;
@@ -98,28 +93,6 @@
return false;
}
- /**
- * Sets whether the app associated with the given {@param packageName} is allowed to enter
- * picture-in-picture when it is hidden.
- */
- static void setEnterPipOnHideStateForPackage(Context context, int uid, String packageName,
- boolean value) {
- final AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
- final int newMode = value ? MODE_ALLOWED : MODE_ERRORED;
- appOps.setMode(OP_ENTER_PICTURE_IN_PICTURE_ON_HIDE,
- uid, packageName, newMode);
- }
-
- /**
- * @return whether the app associated with the given {@param packageName} is allowed to enter
- * picture-in-picture when it is hidden.
- */
- static boolean getEnterPipOnHideStateForPackage(Context context, int uid, String packageName) {
- final AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
- return appOps.checkOpNoThrow(OP_ENTER_PICTURE_IN_PICTURE_ON_HIDE,
- uid, packageName) == MODE_ALLOWED;
- }
-
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -147,8 +120,8 @@
if (checkPackageHasPictureInPictureActivities(packageInfo.packageName,
packageInfo.activities)) {
final String packageName = packageInfo.applicationInfo.packageName;
- final boolean state = getEnterPipOnHideStateForPackage(mContext,
- packageInfo.applicationInfo.uid, packageName);
+ final boolean state = PictureInPictureDetails.getEnterPipStateForPackage(
+ mContext, packageInfo.applicationInfo.uid, packageName);
pipApps.add(packageInfo.applicationInfo);
packageToState.put(packageName, state);
}
@@ -160,17 +133,18 @@
for (final ApplicationInfo appInfo : pipApps) {
final String packageName = appInfo.packageName;
final CharSequence label = appInfo.loadLabel(mPackageManager);
- final SwitchPreference pref = new SwitchPreference(prefContext);
- pref.setPersistent(false);
+
+ final Preference pref = new Preference(prefContext);
pref.setIcon(appInfo.loadIcon(mPackageManager));
pref.setTitle(label);
- pref.setChecked(packageToState.get(packageName));
- pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ pref.setSummary(PictureInPictureDetails.getPreferenceSummary(prefContext,
+ appInfo.uid, packageName));
+ pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- logSpecialPermissionChange((Boolean) newValue, packageName);
- setEnterPipOnHideStateForPackage(mContext, appInfo.uid, packageName,
- (Boolean) newValue);
+ public boolean onPreferenceClick(Preference preference) {
+ AppInfoBase.startAppInfoFragment(PictureInPictureDetails.class,
+ R.string.picture_in_picture_app_detail_title, packageName, appInfo.uid,
+ PictureInPictureSettings.this, -1, getMetricsCategory());
return true;
}
});
@@ -188,13 +162,4 @@
public int getMetricsCategory() {
return MetricsEvent.SETTINGS_MANAGE_PICTURE_IN_PICTURE;
}
-
- @VisibleForTesting
- void logSpecialPermissionChange(boolean newState, String packageName) {
- int logCategory = newState
- ? MetricsEvent.APP_PICTURE_IN_PICTURE_ON_HIDE_ALLOW
- : MetricsEvent.APP_PICTURE_IN_PICTURE_ON_HIDE_DENY;
- FeatureFactory.getFactory(getContext())
- .getMetricsFeatureProvider().action(getContext(), logCategory, packageName);
- }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
index a24a3f0..5dfd283 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingService.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -80,6 +80,7 @@
Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" + mDevice.getName() + "), Cancelled.");
}
stopForeground(true);
+ stopSelf();
}
};
@@ -89,6 +90,12 @@
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
+ if (intent == null) {
+ Log.e(TAG, "Can't start: null intent!");
+ stopSelf();
+ return START_NOT_STICKY;
+ }
+
Resources res = getResources();
Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
@@ -99,6 +106,12 @@
mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (mDevice.getBondState() != BluetoothDevice.BOND_BONDING) {
+ Log.w(TAG, "Device " + mDevice + " not bonding: " + mDevice.getBondState());
+ stopSelf();
+ return START_NOT_STICKY;
+ }
+
String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
if (TextUtils.isEmpty(name)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
@@ -119,7 +132,7 @@
registerReceiver(mCancelReceiver, filter);
startForeground(NOTIFICATION_ID, builder.getNotification());
- return START_STICKY;
+ return START_REDELIVER_INTENT;
}
@Override
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index fb2c9ce..467b848 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -52,6 +52,7 @@
import com.android.settings.applications.ManageApplications;
import com.android.settings.applications.ManageDomainUrls;
import com.android.settings.applications.NotificationApps;
+import com.android.settings.applications.PictureInPictureDetails;
import com.android.settings.applications.PictureInPictureSettings;
import com.android.settings.applications.ProcessStatsSummary;
import com.android.settings.applications.ProcessStatsUi;
@@ -218,6 +219,7 @@
WallpaperTypeSettings.class.getName(),
VrListenerSettings.class.getName(),
PictureInPictureSettings.class.getName(),
+ PictureInPictureDetails.class.getName(),
ManagedProfileSettings.class.getName(),
ChooseAccountActivity.class.getName(),
IccLockSettings.class.getName(),
diff --git a/src/com/android/settings/development/DevelopmentSettings.java b/src/com/android/settings/development/DevelopmentSettings.java
index 2a4a231..0a3351a 100644
--- a/src/com/android/settings/development/DevelopmentSettings.java
+++ b/src/com/android/settings/development/DevelopmentSettings.java
@@ -23,7 +23,6 @@
import android.app.AppOpsManager;
import android.app.AppOpsManager.PackageOps;
import android.app.Dialog;
-import android.app.admin.DevicePolicyManager;
import android.app.backup.IBackupManager;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
@@ -246,17 +245,15 @@
private IWindowManager mWindowManager;
private IBackupManager mBackupManager;
private IWebViewUpdateService mWebViewUpdateService;
- private DevicePolicyManager mDpm;
private UserManager mUm;
private WifiManager mWifiManager;
private PersistentDataBlockManager mOemUnlockManager;
private TelephonyManager mTelephonyManager;
private SwitchBar mSwitchBar;
- private boolean mLastEnabledState;
+
private boolean mHaveDebugSettings;
private boolean mDontPokeProperties;
-
private SwitchPreference mEnableAdb;
private Preference mClearAdbKeys;
private SwitchPreference mEnableTerminal;
@@ -350,6 +347,7 @@
private boolean mLogpersistCleared;
private Dialog mLogpersistClearDialog;
private DashboardFeatureProvider mDashboardFeatureProvider;
+ private DevelopmentSettingsEnabler mSettingsEnabler;
private BugReportPreferenceController mBugReportController;
private BugReportInPowerPreferenceController mBugReportInPowerController;
private TelephonyMonitorPreferenceController mTelephonyMonitorController;
@@ -366,6 +364,7 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
+ mSettingsEnabler = new DevelopmentSettingsEnabler(context, getLifecycle());
mDashboardFeatureProvider = FeatureFactory.getFactory(context)
.getDashboardFeatureProvider(context);
}
@@ -382,7 +381,6 @@
.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- mDpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
@@ -671,22 +669,18 @@
mDisabledPrefs.add(mKeepScreenOn);
}
- final ContentResolver cr = getActivity().getContentResolver();
- mLastEnabledState = Settings.Global.getInt(cr,
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
- mSwitchBar.setChecked(mLastEnabledState);
- setPrefsEnabledState(mLastEnabledState);
+ final boolean lastEnabledState = mSettingsEnabler.getLastEnabledState();
+ mSwitchBar.setChecked(lastEnabledState);
+ setPrefsEnabledState(lastEnabledState);
- if (mHaveDebugSettings && !mLastEnabledState) {
+ if (mHaveDebugSettings && !lastEnabledState) {
// Overall debugging is disabled, but there are some debug
// settings that are enabled. This is an invalid state. Switch
// to debug settings being enabled, so the user knows there is
// stuff enabled and can turn it all off if they want.
- Settings.Global.putInt(getActivity().getContentResolver(),
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
- mLastEnabledState = true;
- mSwitchBar.setChecked(mLastEnabledState);
- setPrefsEnabledState(mLastEnabledState);
+ mSettingsEnabler.enableDevelopmentSettings();
+ mSwitchBar.setChecked(lastEnabledState);
+ setPrefsEnabledState(lastEnabledState);
}
mSwitchBar.show();
@@ -1560,7 +1554,7 @@
|| currentValue.equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE)) {
writeLogpersistOption(null, true);
mLogpersist.setEnabled(false);
- } else if (mLastEnabledState) {
+ } else if (mSettingsEnabler.getLastEnabledState()) {
mLogpersist.setEnabled(true);
}
}
@@ -1848,8 +1842,9 @@
}
}
}
- if (codecConfig == null)
+ if (codecConfig == null) {
return;
+ }
try {
resources = getResources();
@@ -2329,7 +2324,8 @@
if (switchView != mSwitchBar.getSwitch()) {
return;
}
- if (isChecked != mLastEnabledState) {
+ final boolean lastEnabledState = mSettingsEnabler.getLastEnabledState();
+ if (isChecked != lastEnabledState) {
if (isChecked) {
mDialogClicked = false;
if (mEnableDialog != null) dismissDialogs();
@@ -2343,10 +2339,8 @@
mEnableDialog.setOnDismissListener(this);
} else {
resetDangerousOptions();
- Settings.Global.putInt(getActivity().getContentResolver(),
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
- mLastEnabledState = isChecked;
- setPrefsEnabledState(mLastEnabledState);
+ mSettingsEnabler.disableDevelopmentSettings();
+ setPrefsEnabledState(false);
}
}
}
@@ -2629,10 +2623,8 @@
} else if (dialog == mEnableDialog) {
if (which == DialogInterface.BUTTON_POSITIVE) {
mDialogClicked = true;
- Settings.Global.putInt(getActivity().getContentResolver(),
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
- mLastEnabledState = true;
- setPrefsEnabledState(mLastEnabledState);
+ mSettingsEnabler.enableDevelopmentSettings();
+ setPrefsEnabledState(true);
} else {
// Reset the toggle
mSwitchBar.setChecked(false);
diff --git a/src/com/android/settings/development/DevelopmentSettingsEnabler.java b/src/com/android/settings/development/DevelopmentSettingsEnabler.java
new file mode 100644
index 0000000..e97997e
--- /dev/null
+++ b/src/com/android/settings/development/DevelopmentSettingsEnabler.java
@@ -0,0 +1,72 @@
+/*
+ * 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.content.Context;
+import android.content.SharedPreferences;
+import android.provider.Settings;
+
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnResume;
+
+public class DevelopmentSettingsEnabler implements LifecycleObserver, OnResume {
+
+ private final Context mContext;
+ private final SharedPreferences mDevelopmentPreferences;
+ private boolean mLastEnabledState;
+
+ public DevelopmentSettingsEnabler(Context context, Lifecycle lifecycle) {
+ mContext = context;
+ mDevelopmentPreferences = context.getSharedPreferences(DevelopmentSettings.PREF_FILE,
+ Context.MODE_PRIVATE);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ mLastEnabledState = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
+ }
+
+ public static boolean enableDevelopmentSettings(Context context, SharedPreferences prefs) {
+ prefs.edit()
+ .putBoolean(DevelopmentSettings.PREF_SHOW, true)
+ .commit();
+ return Settings.Global.putInt(context.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
+ }
+
+ public boolean getLastEnabledState() {
+ return mLastEnabledState;
+ }
+
+ public void enableDevelopmentSettings() {
+ mLastEnabledState = enableDevelopmentSettings(mContext, mDevelopmentPreferences);
+ }
+
+ public void disableDevelopmentSettings() {
+ mDevelopmentPreferences.edit()
+ .putBoolean(DevelopmentSettings.PREF_SHOW, false)
+ .commit();
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+ mLastEnabledState = false;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
index 4062be8..f174e10 100644
--- a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -39,8 +39,8 @@
import com.android.settings.core.lifecycle.LifecycleObserver;
import com.android.settings.core.lifecycle.events.OnResume;
import com.android.settings.development.DevelopmentSettings;
+import com.android.settings.development.DevelopmentSettingsEnabler;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.search2.SearchFeatureProvider;
import com.android.settingslib.RestrictedLockUtils;
public class BuildNumberPreferenceController extends PreferenceController
@@ -210,10 +210,9 @@
private void enableDevelopmentSettings() {
mDevHitCountdown = 0;
mProcessingLastDevHit = false;
- mContext.getSharedPreferences(DevelopmentSettings.PREF_FILE,
- Context.MODE_PRIVATE).edit()
- .putBoolean(DevelopmentSettings.PREF_SHOW, true)
- .apply();
+ DevelopmentSettingsEnabler.enableDevelopmentSettings(mContext,
+ mContext.getSharedPreferences(DevelopmentSettings.PREF_FILE,
+ Context.MODE_PRIVATE));
if (mDevHitToast != null) {
mDevHitToast.cancel();
}
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index 133c56c..18393ac 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -114,6 +114,16 @@
mSummaryController.updateBytes(usedBytes, totalSize);
mPreferenceController.setVolume(mVolume);
mPreferenceController.setSystemSize(systemSize);
+
+ mPreferenceController.setTotalSize(totalSize);
+ for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
+ PreferenceController controller = mSecondaryUsers.get(i);
+ if (controller instanceof SecondaryUserController) {
+ SecondaryUserController userController = (SecondaryUserController) controller;
+ userController.setTotalSize(totalSize);
+
+ }
+ }
}
@Override
diff --git a/src/com/android/settings/deviceinfo/StorageItemPreference.java b/src/com/android/settings/deviceinfo/StorageItemPreference.java
index b15794e..763b6d4 100644
--- a/src/com/android/settings/deviceinfo/StorageItemPreference.java
+++ b/src/com/android/settings/deviceinfo/StorageItemPreference.java
@@ -20,6 +20,7 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.format.Formatter;
+import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
@@ -28,13 +29,18 @@
public class StorageItemPreference extends Preference {
public int userHandle;
- private ProgressBar progressBar;
+ private ProgressBar mProgressBar;
private static final int PROGRESS_MAX = 100;
- private int progress = -1;
+ private int mProgressPercent = -1;
public StorageItemPreference(Context context) {
- super(context);
+ this(context, null);
+ }
+
+ public StorageItemPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
setLayoutResource(R.layout.storage_item);
+ setSummary(R.string.memory_calculating_size);
}
public void setStorageSize(long size, long total) {
@@ -42,30 +48,30 @@
? String.valueOf(0)
: Formatter.formatFileSize(getContext(), size));
if (total == 0) {
- progress = 0;
+ mProgressPercent = 0;
} else {
- progress = (int)(size * PROGRESS_MAX / total);
+ mProgressPercent = (int)(size * PROGRESS_MAX / total);
}
updateProgressBar();
}
protected void updateProgressBar() {
- if (progressBar == null)
+ if (mProgressBar == null)
return;
- if (progress == -1) {
- progressBar.setVisibility(View.GONE);
+ if (mProgressPercent == -1) {
+ mProgressBar.setVisibility(View.GONE);
return;
}
- progressBar.setVisibility(View.VISIBLE);
- progressBar.setMax(PROGRESS_MAX);
- progressBar.setProgress(progress);
+ mProgressBar.setVisibility(View.VISIBLE);
+ mProgressBar.setMax(PROGRESS_MAX);
+ mProgressBar.setProgress(mProgressPercent);
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
- progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
+ mProgressBar = (ProgressBar) view.findViewById(android.R.id.progress);
updateProgressBar();
super.onBindViewHolder(view);
}
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index 4fd9e52..eb589ca 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -28,6 +28,7 @@
import com.android.settings.Utils;
import com.android.settings.applications.UserManagerWrapper;
import com.android.settings.core.PreferenceController;
+import com.android.settings.deviceinfo.StorageItemPreference;
import java.util.ArrayList;
import java.util.List;
@@ -46,8 +47,9 @@
private static final int SIZE_NOT_SET = -1;
private @NonNull UserInfo mUser;
- private @Nullable StorageItemPreferenceAlternate mStoragePreference;
+ private @Nullable StorageItemPreference mStoragePreference;
private long mSize;
+ private long mTotalSizeBytes;
/**
* Adds the appropriate controllers to a controller list for handling all secondary users on
@@ -98,14 +100,14 @@
@Override
public void displayPreference(PreferenceScreen screen) {
if (mStoragePreference == null) {
- mStoragePreference = new StorageItemPreferenceAlternate(screen.getContext());
+ mStoragePreference = new StorageItemPreference(screen.getContext());
PreferenceGroup group =
(PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
mStoragePreference.setTitle(mUser.name);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
if (mSize != SIZE_NOT_SET) {
- mStoragePreference.setStorageSize(mSize);
+ mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
group.setVisible(true);
group.addPreference(mStoragePreference);
@@ -137,10 +139,18 @@
public void setSize(long size) {
mSize = size;
if (mStoragePreference != null) {
- mStoragePreference.setStorageSize(mSize);
+ mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
}
+ /**
+ * Sets the total size for the preference for the progress bar.
+ * @param totalSizeBytes Total size in bytes.
+ */
+ public void setTotalSize(long totalSizeBytes) {
+ mTotalSizeBytes = totalSizeBytes;
+ }
+
public void handleResult(SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
int userId = getUser().id;
StorageAsyncLoader.AppsStorageResult result = stats.get(userId);
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceAlternate.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceAlternate.java
deleted file mode 100644
index d5a36b9..0000000
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceAlternate.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.deviceinfo.storage;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.text.format.Formatter;
-import android.util.AttributeSet;
-
-import com.android.settings.R;
-
-public class StorageItemPreferenceAlternate extends Preference {
- public StorageItemPreferenceAlternate(Context context) {
- this(context, null);
- }
-
- public StorageItemPreferenceAlternate(Context context, AttributeSet attrs) {
- super(context, attrs);
- setLayoutResource(R.layout.storage_item_alternate);
- setSummary(R.string.memory_calculating_size);
- }
-
- public void setStorageSize(long size) {
- setSummary(size == 0
- ? String.valueOf(0)
- : Formatter.formatFileSize(getContext(), size));
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 36cf73e..eec9487 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -35,6 +35,7 @@
import com.android.settings.applications.ManageApplications;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
+import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.deviceinfo.StorageMeasurement;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -71,13 +72,14 @@
private VolumeInfo mVolume;
private int mUserId;
private long mSystemSize;
+ private long mTotalSize;
- private StorageItemPreferenceAlternate mPhotoPreference;
- private StorageItemPreferenceAlternate mAudioPreference;
- private StorageItemPreferenceAlternate mGamePreference;
- private StorageItemPreferenceAlternate mAppPreference;
- private StorageItemPreferenceAlternate mFilePreference;
- private StorageItemPreferenceAlternate mSystemPreference;
+ private StorageItemPreference mPhotoPreference;
+ private StorageItemPreference mAudioPreference;
+ private StorageItemPreference mGamePreference;
+ private StorageItemPreference mAppPreference;
+ private StorageItemPreference mFilePreference;
+ private StorageItemPreference mSystemPreference;
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
@@ -164,37 +166,38 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mPhotoPreference = (StorageItemPreferenceAlternate) screen.findPreference(PHOTO_KEY);
- mAudioPreference = (StorageItemPreferenceAlternate) screen.findPreference(AUDIO_KEY);
- mGamePreference = (StorageItemPreferenceAlternate) screen.findPreference(GAME_KEY);
- mAppPreference = (StorageItemPreferenceAlternate) screen.findPreference(OTHER_APPS_KEY);
- mSystemPreference = (StorageItemPreferenceAlternate) screen.findPreference(SYSTEM_KEY);
- mFilePreference = (StorageItemPreferenceAlternate) screen.findPreference(FILES_KEY);
+ mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
+ mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
+ mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
+ mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
+ mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
+ mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
}
public void onLoadFinished(StorageAsyncLoader.AppsStorageResult data) {
// TODO(b/35927909): Figure out how to split out apps which are only installed for work
// profiles in order to attribute those app's code bytes only to that profile.
mPhotoPreference.setStorageSize(
- data.externalStats.imageBytes + data.externalStats.videoBytes);
- mAudioPreference.setStorageSize(data.musicAppsSize + data.externalStats.audioBytes);
- mGamePreference.setStorageSize(data.gamesSize);
- mAppPreference.setStorageSize(data.otherAppsSize);
+ data.externalStats.imageBytes + data.externalStats.videoBytes, mTotalSize);
+ mAudioPreference.setStorageSize(
+ data.musicAppsSize + data.externalStats.audioBytes, mTotalSize);
+ mGamePreference.setStorageSize(data.gamesSize, mTotalSize);
+ mAppPreference.setStorageSize(data.otherAppsSize, mTotalSize);
if (mSystemPreference != null) {
- mSystemPreference.setStorageSize(mSystemSize + data.systemSize);
+ mSystemPreference.setStorageSize(mSystemSize + data.systemSize, mTotalSize);
}
long unattributedBytes = data.externalStats.totalBytes - data.externalStats.audioBytes
- data.externalStats.videoBytes - data.externalStats.imageBytes;
- mFilePreference.setStorageSize(unattributedBytes);
+ mFilePreference.setStorageSize(unattributedBytes, mTotalSize);
}
- /**
- * Sets the system size for the system size preference.
- * @param systemSize the size of the system in bytes
- */
- public void setSystemSize(long systemSize) {
- mSystemSize = systemSize;
+ public void setSystemSize(long systemSizeBytes) {
+ mSystemSize = systemSizeBytes;
+ }
+
+ public void setTotalSize(long totalSizeBytes) {
+ mTotalSize = totalSizeBytes;
}
/**
diff --git a/src/com/android/settings/deviceinfo/storage/UserProfileController.java b/src/com/android/settings/deviceinfo/storage/UserProfileController.java
index 963784d..ef8b21e 100644
--- a/src/com/android/settings/deviceinfo/storage/UserProfileController.java
+++ b/src/com/android/settings/deviceinfo/storage/UserProfileController.java
@@ -29,6 +29,7 @@
import com.android.internal.util.Preconditions;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
+import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.deviceinfo.StorageProfileFragment;
import com.android.settingslib.drawer.SettingsDrawerActivity;
@@ -38,8 +39,9 @@
public class UserProfileController extends PreferenceController implements
StorageAsyncLoader.ResultHandler {
private static final String PREFERENCE_KEY_BASE = "pref_profile_";
- private StorageItemPreferenceAlternate mStoragePreference;
+ private StorageItemPreference mStoragePreference;
private UserInfo mUser;
+ private long mTotalSizeBytes;
private final int mPreferenceOrder;
public UserProfileController(Context context, UserInfo info, int preferenceOrder) {
@@ -60,7 +62,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mStoragePreference = new StorageItemPreferenceAlternate(screen.getContext());
+ mStoragePreference = new StorageItemPreference(screen.getContext());
mStoragePreference.setOrder(mPreferenceOrder);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
mStoragePreference.setTitle(mUser.name);
@@ -91,16 +93,20 @@
int userId = mUser.id;
StorageAsyncLoader.AppsStorageResult result = stats.get(userId);
if (result != null) {
- setSize(result.externalStats.totalBytes);
+ setSize(result.externalStats.totalBytes, mTotalSizeBytes);
}
}
/**
* Sets the size for the preference using a byte count.
*/
- public void setSize(long size) {
+ public void setSize(long size, long totalSize) {
if (mStoragePreference != null) {
- mStoragePreference.setStorageSize(size);
+ mStoragePreference.setStorageSize(size, totalSize);
}
}
+
+ public void setTotalSize(long totalSize) {
+ mTotalSizeBytes = totalSize;
+ }
}
diff --git a/src/com/android/settings/display/NightDisplaySettings.java b/src/com/android/settings/display/NightDisplaySettings.java
index 619c0d4..bc90eb9 100644
--- a/src/com/android/settings/display/NightDisplaySettings.java
+++ b/src/com/android/settings/display/NightDisplaySettings.java
@@ -28,6 +28,7 @@
import com.android.internal.app.NightDisplayController;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
+import com.android.settings.SeekBarPreference;
import com.android.settings.SettingsPreferenceFragment;
import java.text.DateFormat;
@@ -44,6 +45,7 @@
private static final String KEY_NIGHT_DISPLAY_START_TIME = "night_display_start_time";
private static final String KEY_NIGHT_DISPLAY_END_TIME = "night_display_end_time";
private static final String KEY_NIGHT_DISPLAY_ACTIVATED = "night_display_activated";
+ private static final String KEY_NIGHT_DISPLAY_TEMPERATURE = "night_display_temperature";
private static final int DIALOG_START_TIME = 0;
private static final int DIALOG_END_TIME = 1;
@@ -55,6 +57,7 @@
private Preference mStartTimePreference;
private Preference mEndTimePreference;
private TwoStatePreference mActivatedPreference;
+ private SeekBarPreference mTemperaturePreference;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -65,6 +68,11 @@
mTimeFormatter = android.text.format.DateFormat.getTimeFormat(context);
mTimeFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ mTemperaturePreference.setMax(convertTemperature(mController.getMinimumColorTemperature()));
+ mTemperaturePreference.setDefaultProgress(convertTemperature(
+ mController.getDefaultColorTemperature()));
+ mTemperaturePreference.setContinuousUpdates(true);
}
@Override
@@ -78,6 +86,7 @@
mStartTimePreference = findPreference(KEY_NIGHT_DISPLAY_START_TIME);
mEndTimePreference = findPreference(KEY_NIGHT_DISPLAY_END_TIME);
mActivatedPreference = (TwoStatePreference) findPreference(KEY_NIGHT_DISPLAY_ACTIVATED);
+ mTemperaturePreference = (SeekBarPreference) findPreference(KEY_NIGHT_DISPLAY_TEMPERATURE);
mAutoModePreference.setEntries(new CharSequence[] {
getString(R.string.night_display_auto_mode_never),
@@ -91,6 +100,7 @@
});
mAutoModePreference.setOnPreferenceChangeListener(this);
mActivatedPreference.setOnPreferenceChangeListener(this);
+ mTemperaturePreference.setOnPreferenceChangeListener(this);
}
@Override
@@ -105,6 +115,7 @@
onAutoModeChanged(mController.getAutoMode());
onCustomStartTimeChanged(mController.getCustomStartTime());
onCustomEndTimeChanged(mController.getCustomEndTime());
+ onColorTemperatureChanged(mController.getColorTemperature());
}
@Override
@@ -166,9 +177,11 @@
return 0;
}
}
+
@Override
public void onActivated(boolean activated) {
mActivatedPreference.setChecked(activated);
+ mTemperaturePreference.setEnabled(activated);
}
@Override
@@ -180,6 +193,11 @@
mEndTimePreference.setVisible(showCustomSchedule);
}
+ @Override
+ public void onColorTemperatureChanged(int colorTemperature) {
+ mTemperaturePreference.setProgress(convertTemperature(colorTemperature));
+ }
+
private String getFormattedTimeString(NightDisplayController.LocalTime localTime) {
final Calendar c = Calendar.getInstance();
c.setTimeZone(mTimeFormatter.getTimeZone());
@@ -190,6 +208,15 @@
return mTimeFormatter.format(c.getTime());
}
+ /**
+ * Inverts and range-adjusts a raw value from the SeekBar (i.e. [0, maxTemp-minTemp]), or
+ * converts an inverted and range-adjusted value to the raw SeekBar value, depending on the
+ * adjustment status of the input.
+ */
+ private int convertTemperature(int temperature) {
+ return mController.getMaximumColorTemperature() - temperature;
+ }
+
@Override
public void onCustomStartTimeChanged(NightDisplayController.LocalTime startTime) {
mStartTimePreference.setSummary(getFormattedTimeString(startTime));
@@ -206,6 +233,8 @@
return mController.setAutoMode(Integer.parseInt((String) newValue));
} else if (preference == mActivatedPreference) {
return mController.setActivated((Boolean) newValue);
+ } else if (preference == mTemperaturePreference) {
+ return mController.setColorTemperature(convertTemperature((Integer) newValue));
}
return false;
}
diff --git a/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java b/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java
index 35648c8..8394262 100644
--- a/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java
+++ b/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceController.java
@@ -24,7 +24,7 @@
= "enterprise_privacy_number_camera_access_packages";
public AdminGrantedCameraPermissionPreferenceController(Context context) {
- super(context, new String[] {Manifest.permission.CAMERA});
+ super(context, new String[] {Manifest.permission.CAMERA}, Manifest.permission_group.CAMERA);
}
@Override
diff --git a/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java b/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java
index f570558..4dfc4be 100644
--- a/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java
+++ b/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceController.java
@@ -25,7 +25,7 @@
public AdminGrantedLocationPermissionsPreferenceController(Context context) {
super(context, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION});
+ Manifest.permission.ACCESS_FINE_LOCATION}, Manifest.permission_group.LOCATION);
}
@Override
diff --git a/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java b/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java
index 842235d..e2ab555 100644
--- a/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java
+++ b/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceController.java
@@ -24,7 +24,8 @@
= "enterprise_privacy_number_microphone_access_packages";
public AdminGrantedMicrophonePermissionPreferenceController(Context context) {
- super(context, new String[] {Manifest.permission.RECORD_AUDIO});
+ super(context, new String[] {Manifest.permission.RECORD_AUDIO},
+ Manifest.permission_group.MICROPHONE);
}
@Override
diff --git a/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java b/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
index 2b972a5..5263817 100644
--- a/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
+++ b/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
@@ -15,7 +15,7 @@
package com.android.settings.enterprise;
import android.content.Context;
-import android.content.res.Resources;
+import android.content.Intent;
import android.support.v7.preference.Preference;
import com.android.settings.R;
@@ -26,11 +26,15 @@
public abstract class AdminGrantedPermissionsPreferenceControllerBase extends PreferenceController {
private final String[] mPermissions;
+ private final String mPermissionGroup;
private final ApplicationFeatureProvider mFeatureProvider;
- public AdminGrantedPermissionsPreferenceControllerBase(Context context, String[] permissions) {
+ public AdminGrantedPermissionsPreferenceControllerBase(Context context,
+ String[] permissions,
+ String permissionGroup) {
super(context);
mPermissions = permissions;
+ mPermissionGroup = permissionGroup;
mFeatureProvider = FeatureFactory.getFactory(context)
.getApplicationFeatureProvider(context);
}
@@ -44,7 +48,7 @@
} else {
preference.setVisible(true);
preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_packages, num, num));
+ R.plurals.enterprise_privacy_number_packages_actionable, num, num));
}
});
}
@@ -53,4 +57,15 @@
public boolean isAvailable() {
return true;
}
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!getPreferenceKey().equals(preference.getKey())) {
+ return false;
+ }
+ final Intent intent = new Intent(Intent.ACTION_MANAGE_PERMISSION_APPS)
+ .putExtra(Intent.EXTRA_PERMISSION_NAME, mPermissionGroup);
+ mContext.startActivity(intent);
+ return true;
+ }
}
diff --git a/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java b/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
index 9b4be3a..93c1909 100644
--- a/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
+++ b/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
@@ -20,25 +20,30 @@
import com.android.settings.R;
import com.android.settings.applications.ApplicationFeatureProvider;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class EnterpriseInstalledPackagesPreferenceController extends PreferenceController {
+public class EnterpriseInstalledPackagesPreferenceController
+ extends DynamicAvailabilityPreferenceController {
private static final String KEY_NUMBER_ENTERPRISE_INSTALLED_PACKAGES
= "number_enterprise_installed_packages";
private final ApplicationFeatureProvider mFeatureProvider;
+ private final boolean mAsync;
- public EnterpriseInstalledPackagesPreferenceController(Context context) {
- super(context);
+ public EnterpriseInstalledPackagesPreferenceController(Context context, Lifecycle lifecycle,
+ boolean async) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getApplicationFeatureProvider(context);
+ mAsync = async;
}
@Override
public void updateState(Preference preference) {
mFeatureProvider.calculateNumberOfInstalledApps(
- PackageManager.INSTALL_REASON_POLICY,
+ PackageManager.INSTALL_REASON_POLICY, true /* async */,
(num) -> {
if (num == 0) {
preference.setVisible(false);
@@ -52,7 +57,20 @@
@Override
public boolean isAvailable() {
- return true;
+ if (mAsync) {
+ // When called on the main UI thread, we must not block. Since calculating the number of
+ // enterprise-installed apps takes a bit of time, we always return true here and
+ // determine the pref's actual visibility asynchronously in updateState().
+ return true;
+ }
+
+ // When called by the search indexer, we are on a background thread that we can block. Also,
+ // changes to the pref's visibility made in updateState() would not be seen by the indexer.
+ // We block and return synchronously whether there are enterprise-installed apps or not.
+ final Boolean[] haveEnterpriseInstalledPackages = { null };
+ mFeatureProvider.calculateNumberOfInstalledApps(PackageManager.INSTALL_REASON_POLICY,
+ false /* async */, (num) -> haveEnterpriseInstalledPackages[0] = num > 0);
+ return haveEnterpriseInstalledPackages[0];
}
@Override
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index 3f66f02..0fb341a 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -22,6 +22,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -51,16 +52,22 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle(), true /* async */);
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle, boolean async) {
final List controllers = new ArrayList<PreferenceController>();
controllers.add(new InstalledPackagesPreferenceController(context));
controllers.add(new NetworkLogsPreferenceController(context));
controllers.add(new BugReportsPreferenceController(context));
controllers.add(new SecurityLogsPreferenceController(context));
- controllers.add(new EnterpriseInstalledPackagesPreferenceController(context));
+ controllers.add(new EnterpriseInstalledPackagesPreferenceController(context, lifecycle,
+ async));
controllers.add(new AdminGrantedLocationPermissionsPreferenceController(context));
controllers.add(new AdminGrantedMicrophonePermissionPreferenceController(context));
controllers.add(new AdminGrantedCameraPermissionPreferenceController(context));
- controllers.add(new EnterpriseSetDefaultAppsPreferenceController(context));
+ controllers.add(new EnterpriseSetDefaultAppsPreferenceController(context, lifecycle));
controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context));
controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context));
controllers.add(new GlobalHttpProxyPreferenceController(context));
@@ -91,6 +98,11 @@
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.enterprise_privacy_settings;
return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */, false /* async */);
}
};
}
diff --git a/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceController.java b/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceController.java
index 08a72e3..ae76d63 100644
--- a/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceController.java
+++ b/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceController.java
@@ -22,22 +22,40 @@
import com.android.settings.R;
import com.android.settings.applications.ApplicationFeatureProvider;
-import com.android.settings.core.PreferenceController;
+import com.android.settings.core.DynamicAvailabilityPreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.overlay.FeatureFactory;
-public class EnterpriseSetDefaultAppsPreferenceController extends PreferenceController {
+public class EnterpriseSetDefaultAppsPreferenceController
+ extends DynamicAvailabilityPreferenceController {
private static final String KEY_DEFAULT_APPS = "number_enterprise_set_default_apps";
private final ApplicationFeatureProvider mFeatureProvider;
- public EnterpriseSetDefaultAppsPreferenceController(Context context) {
- super(context);
+ public EnterpriseSetDefaultAppsPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, lifecycle);
mFeatureProvider = FeatureFactory.getFactory(context)
.getApplicationFeatureProvider(context);
}
@Override
public void updateState(Preference preference) {
+ final int num = getNumberOfEnterpriseSetDefaultApps();
+ preference.setSummary(mContext.getResources().getQuantityString(
+ R.plurals.enterprise_privacy_number_packages, num, num));
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return getNumberOfEnterpriseSetDefaultApps() > 0;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_DEFAULT_APPS;
+ }
+
+ private int getNumberOfEnterpriseSetDefaultApps() {
// Browser
int num = mFeatureProvider.findPersistentPreferredActivities(new Intent[] {
buildIntent(Intent.ACTION_VIEW, Intent.CATEGORY_BROWSABLE, "http:", null)}).size();
@@ -64,23 +82,7 @@
num += mFeatureProvider.findPersistentPreferredActivities(new Intent[] {
new Intent(Intent.ACTION_DIAL), new Intent(Intent.ACTION_CALL)}).size();
- if (num == 0) {
- preference.setVisible(false);
- } else {
- preference.setVisible(true);
- preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_packages, num, num));
- }
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_DEFAULT_APPS;
+ return num;
}
private static Intent buildIntent(String action, String category, String protocol,
diff --git a/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java b/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java
index 4252429..43436b1 100644
--- a/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java
+++ b/src/com/android/settings/enterprise/InstalledPackagesPreferenceController.java
@@ -36,7 +36,7 @@
@Override
public void updateState(Preference preference) {
mFeatureProvider.calculateNumberOfInstalledApps(
- ApplicationFeatureProvider.IGNORE_INSTALL_REASON,
+ ApplicationFeatureProvider.IGNORE_INSTALL_REASON, true /* async */,
(num) -> {
if (num == 0) {
preference.setSummary("");
diff --git a/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java b/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java
index 55937ec..6317afe 100644
--- a/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java
+++ b/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java
@@ -36,8 +36,10 @@
public void updateState(Preference preference) {
final int activeAdmins
= mFeatureProvider.getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile();
- preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.number_of_device_admins, activeAdmins, activeAdmins));
+ preference.setSummary(activeAdmins == 0
+ ? mContext.getResources().getString(R.string.number_of_device_admins_none)
+ : mContext.getResources().getQuantityString(R.plurals.number_of_device_admins,
+ activeAdmins, activeAdmins));
}
@Override
diff --git a/src/com/android/settings/widget/DefaultIndicatorSeekBar.java b/src/com/android/settings/widget/DefaultIndicatorSeekBar.java
new file mode 100644
index 0000000..d8edf03
--- /dev/null
+++ b/src/com/android/settings/widget/DefaultIndicatorSeekBar.java
@@ -0,0 +1,89 @@
+/*
+ * 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.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.widget.SeekBar;
+
+public class DefaultIndicatorSeekBar extends SeekBar {
+
+ private int mDefaultProgress = -1;
+
+ public DefaultIndicatorSeekBar(Context context) {
+ super(context);
+ }
+
+ public DefaultIndicatorSeekBar(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public DefaultIndicatorSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public DefaultIndicatorSeekBar(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ /**
+ * N.B. Only draws the default indicator tick mark, NOT equally spaced tick marks.
+ */
+ @Override
+ protected void drawTickMarks(Canvas canvas) {
+ if (isEnabled() && mDefaultProgress <= getMax() && mDefaultProgress >= getMin()) {
+ final Drawable defaultIndicator = getTickMark();
+
+ // Adjust the drawable's bounds to center it at the point where it's drawn.
+ final int w = defaultIndicator.getIntrinsicWidth();
+ final int h = defaultIndicator.getIntrinsicHeight();
+ final int halfW = w >= 0 ? w / 2 : 1;
+ final int halfH = h >= 0 ? h / 2 : 1;
+ defaultIndicator.setBounds(-halfW, -halfH, halfW, halfH);
+
+ // This mimics the computation of the thumb position, to get the true "default."
+ final int availableWidth = getWidth() - mPaddingLeft - mPaddingRight;
+ final int range = getMax() - getMin();
+ final float scale = range > 0f ? mDefaultProgress / (float) range : 0f;
+ final int offset = (int) ((scale * availableWidth) + 0.5f);
+ final int indicatorPosition = isLayoutRtl() && getMirrorForRtl()
+ ? availableWidth - offset + mPaddingRight : offset + mPaddingLeft;
+
+ final int saveCount = canvas.save();
+ canvas.translate(indicatorPosition, getHeight() / 2);
+ defaultIndicator.draw(canvas);
+ canvas.restoreToCount(saveCount);
+ }
+ }
+
+ /**
+ * N.B. This sets the default *unadjusted* progress, i.e. in the SeekBar's [0 - max] terms.
+ */
+ public void setDefaultProgress(int defaultProgress) {
+ if (mDefaultProgress != defaultProgress) {
+ mDefaultProgress = defaultProgress;
+ invalidate();
+ }
+ }
+
+ public int getDefaultProgress() {
+ return mDefaultProgress;
+ }
+}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index dd17a64..f6e4022 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -629,71 +629,11 @@
switch (wifiState) {
case WifiManager.WIFI_STATE_ENABLED:
- // AccessPoints are sorted by the WifiTracker
- final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
-
- boolean hasAvailableAccessPoints = false;
- mAccessPointsPreferenceCategory.removePreference(mStatusMessagePreference);
- cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
-
- int index = configureConnectedAccessPointPreferenceCategory(accessPoints) ? 1 : 0;
- boolean fewerNetworksThanLimit =
- accessPoints.size() <= index + NETWORKS_TO_INITIALLY_SHOW;
- int numAccessPointsToShow = mSeeAllNetworks || fewerNetworksThanLimit
- ? accessPoints.size() : index + NETWORKS_TO_INITIALLY_SHOW;
-
- for (; index < numAccessPointsToShow; index++) {
- AccessPoint accessPoint = accessPoints.get(index);
- // Ignore access points that are out of range.
- if (accessPoint.isReachable()) {
- String key = accessPoint.getBssid();
- if (TextUtils.isEmpty(key)) {
- key = accessPoint.getSsidStr();
- }
- hasAvailableAccessPoints = true;
- LongPressAccessPointPreference pref = (LongPressAccessPointPreference)
- getCachedPreference(key);
- if (pref != null) {
- pref.setOrder(index);
- continue;
- }
- LongPressAccessPointPreference
- preference = createLongPressActionPointPreference(accessPoint);
- preference.setKey(key);
- preference.setOrder(index);
- if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr())
- && !accessPoint.isSaved()
- && accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
- onPreferenceTreeClick(preference);
- mOpenSsid = null;
- }
- mAccessPointsPreferenceCategory.addPreference(preference);
- accessPoint.setListener(this);
- preference.refresh();
- }
- }
- removeCachedPrefs(mAccessPointsPreferenceCategory);
- if (!hasAvailableAccessPoints) {
- setProgressBarVisible(true);
- Preference pref = new Preference(getPrefContext());
- pref.setSelectable(false);
- pref.setSummary(R.string.wifi_empty_list_wifi_on);
- pref.setOrder(index++);
- pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
- mAccessPointsPreferenceCategory.addPreference(pref);
- } else {
- setProgressBarVisible(false);
- }
- if (mSeeAllNetworks || fewerNetworksThanLimit) {
- mAccessPointsPreferenceCategory.removePreference(mSeeAllNetworksPreference);
- mAddPreference.setOrder(index);
- mAccessPointsPreferenceCategory.addPreference(mAddPreference);
- } else {
- mAccessPointsPreferenceCategory.removePreference(mAddPreference);
- mSeeAllNetworksPreference.setOrder(index);
- mAccessPointsPreferenceCategory.addPreference(mSeeAllNetworksPreference);
- }
- setConfigureWifiSettingsVisibility();
+ setProgressBarVisible(true);
+ // Have the progress bar displayed before starting to modify APs
+ getView().postDelayed(() -> {
+ updateAccessPointPreferences();
+ }, 300 /* delay milliseconds */);
break;
case WifiManager.WIFI_STATE_ENABLING:
@@ -715,6 +655,79 @@
}
}
+ private void updateAccessPointPreferences() {
+ // AccessPoints are sorted by the WifiTracker
+ final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
+
+ boolean hasAvailableAccessPoints = false;
+ mAccessPointsPreferenceCategory.removePreference(mStatusMessagePreference);
+ cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
+
+ int index =
+ configureConnectedAccessPointPreferenceCategory(accessPoints) ? 1 : 0;
+ boolean fewerNetworksThanLimit =
+ accessPoints.size() <= index + NETWORKS_TO_INITIALLY_SHOW;
+ int numAccessPointsToShow = mSeeAllNetworks || fewerNetworksThanLimit
+ ? accessPoints.size() : index + NETWORKS_TO_INITIALLY_SHOW;
+
+ for (; index < numAccessPointsToShow; index++) {
+ AccessPoint accessPoint = accessPoints.get(index);
+ // Ignore access points that are out of range.
+ if (accessPoint.isReachable()) {
+ String key = accessPoint.getBssid();
+ if (TextUtils.isEmpty(key)) {
+ key = accessPoint.getSsidStr();
+ }
+ hasAvailableAccessPoints = true;
+ LongPressAccessPointPreference pref =
+ (LongPressAccessPointPreference) getCachedPreference(key);
+ if (pref != null) {
+ pref.setOrder(index);
+ continue;
+ }
+ LongPressAccessPointPreference preference =
+ createLongPressActionPointPreference(accessPoint);
+ preference.setKey(key);
+ preference.setOrder(index);
+ if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr())
+ && !accessPoint.isSaved()
+ && accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
+ onPreferenceTreeClick(preference);
+ mOpenSsid = null;
+ }
+ mAccessPointsPreferenceCategory.addPreference(preference);
+ accessPoint.setListener(WifiSettings.this);
+ preference.refresh();
+ }
+ }
+ removeCachedPrefs(mAccessPointsPreferenceCategory);
+ if (mSeeAllNetworks || fewerNetworksThanLimit) {
+ mAccessPointsPreferenceCategory.removePreference(mSeeAllNetworksPreference);
+ mAddPreference.setOrder(index);
+ mAccessPointsPreferenceCategory.addPreference(mAddPreference);
+ } else {
+ mAccessPointsPreferenceCategory.removePreference(mAddPreference);
+ mSeeAllNetworksPreference.setOrder(index);
+ mAccessPointsPreferenceCategory.addPreference(mSeeAllNetworksPreference);
+ }
+ setConfigureWifiSettingsVisibility();
+
+ if (!hasAvailableAccessPoints) {
+ setProgressBarVisible(true);
+ Preference pref = new Preference(getPrefContext());
+ pref.setSelectable(false);
+ pref.setSummary(R.string.wifi_empty_list_wifi_on);
+ pref.setOrder(index++);
+ pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
+ mAccessPointsPreferenceCategory.addPreference(pref);
+ } else {
+ // Continuing showing progress bar for an additional delay to overlap with animation
+ getView().postDelayed(() -> {
+ setProgressBarVisible(false);
+ }, 1700 /* delay millis */);
+ }
+ }
+
@NonNull
private LongPressAccessPointPreference createLongPressActionPointPreference(
AccessPoint accessPoint) {
@@ -844,7 +857,8 @@
protected void setProgressBarVisible(boolean visible) {
if (mProgressHeader != null) {
- mProgressHeader.setVisibility(visible && !isUiRestricted() ? View.VISIBLE : View.GONE);
+ mProgressHeader.setVisibility(
+ visible && !isUiRestricted() ? View.VISIBLE : View.INVISIBLE);
}
}
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index d7ea14c..0f65f89 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -91,3 +91,4 @@
com.android.settings.qstile.DevelopmentTileConfigActivity$DevelopmentTileConfigFragment
com.android.settings.applications.ExternalSourcesDetails
com.android.settings.applications.PictureInPictureSettings
+com.android.settings.applications.PictureInPictureDetails
diff --git a/tests/robotests/src/com/android/settings/TestUtils.java b/tests/robotests/src/com/android/settings/TestUtils.java
new file mode 100644
index 0000000..16d35f3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/TestUtils.java
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+/**
+ * Convenience methods and constants for testing.
+ */
+public class TestUtils {
+ public static final long KILOBYTE = 1024L; // TODO: Change to 1000 in O Robolectric.
+ public static final long MEGABYTE = KILOBYTE * KILOBYTE;
+ public static final long GIGABYTE = KILOBYTE * MEGABYTE;
+}
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index 2f344dc..3c8d933 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -88,8 +88,7 @@
mPackageManagerService, mDevicePolicyManager);
}
- @Test
- public void testCalculateNumberOfInstalledApps() {
+ private void testCalculateNumberOfInstalledApps(boolean async) {
setUpUsersAndInstalledApps();
when(mPackageManager.getInstallReason(APP_1, new UserHandle(MAIN_USER_ID)))
@@ -100,23 +99,33 @@
// Count all installed apps.
mAppCount = -1;
mProvider.calculateNumberOfInstalledApps(ApplicationFeatureProvider.IGNORE_INSTALL_REASON,
- (num) -> {
- mAppCount = num;
- });
- ShadowApplication.runBackgroundTasks();
+ async, (num) -> mAppCount = num);
+ if (async) {
+ ShadowApplication.runBackgroundTasks();
+ }
assertThat(mAppCount).isEqualTo(2);
// Count apps with specific install reason only.
mAppCount = -1;
- mProvider.calculateNumberOfInstalledApps(PackageManager.INSTALL_REASON_POLICY,
- (num) -> {
- mAppCount = num;
- });
- ShadowApplication.runBackgroundTasks();
+ mProvider.calculateNumberOfInstalledApps(PackageManager.INSTALL_REASON_POLICY, async,
+ (num) -> mAppCount = num);
+ if (async) {
+ ShadowApplication.runBackgroundTasks();
+ }
assertThat(mAppCount).isEqualTo(1);
}
@Test
+ public void testCalculateNumberOfInstalledAppsSync() {
+ testCalculateNumberOfInstalledApps(false /* async */);
+ }
+
+ @Test
+ public void testCalculateNumberOfInstalledAppsAsync() {
+ testCalculateNumberOfInstalledApps(true /* async */);
+ }
+
+ @Test
public void testCalculateNumberOfAppsWithAdminGrantedPermissions() throws Exception {
setUpUsersAndInstalledApps();
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
index 458959c..8b1c9c9 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppCounterTest.java
@@ -97,8 +97,7 @@
: new ArrayList<ResolveInfo>());
}
- @Test
- public void testCountInstalledAppsAcrossAllUsers() {
+ private void testCountInstalledAppsAcrossAllUsers(boolean async) {
// There are two users.
mUsersToCount = Arrays.asList(
new UserInfo(MAIN_USER_ID, "main", UserInfo.FLAG_ADMIN),
@@ -156,12 +155,8 @@
when(mPackageManager.getInstallReason(APP_6, managedProfileUser))
.thenReturn(PackageManager.INSTALL_REASON_UNKNOWN);
- // Count the number of all apps installed, irrespective of install reason. Wait for the
- // background task to finish.
- (new InstalledAppCounterTestable(ApplicationFeatureProvider.IGNORE_INSTALL_REASON))
- .execute();
- ShadowApplication.runBackgroundTasks();
-
+ // Count the number of all apps installed, irrespective of install reason.
+ count(ApplicationFeatureProvider.IGNORE_INSTALL_REASON, async);
assertThat(mInstalledAppCount).isEqualTo(5);
// Verify that installed packages were retrieved for the users returned by
@@ -173,15 +168,34 @@
anyInt());
verifyNoMoreInteractions(mPackageManager);
- // Count once more, considering apps installed by enterprise policy only. Wait for the
- // background task to finish.
- mInstalledAppCount = -1;
- (new InstalledAppCounterTestable(PackageManager.INSTALL_REASON_POLICY)).execute();
- ShadowApplication.runBackgroundTasks();
-
+ // Count once more, considering apps installed by enterprise policy only.
+ count(PackageManager.INSTALL_REASON_POLICY, async);
assertThat(mInstalledAppCount).isEqualTo(3);
}
+ @Test
+ public void testCountInstalledAppsAcrossAllUsersSync() {
+ testCountInstalledAppsAcrossAllUsers(false /* async */);
+ }
+
+ @Test
+ public void testCountInstalledAppsAcrossAllUsersAsync() {
+ testCountInstalledAppsAcrossAllUsers(true /* async */);
+ }
+
+ private void count(int installReason, boolean async) {
+ mInstalledAppCount = -1;
+ final InstalledAppCounterTestable counter = new InstalledAppCounterTestable(installReason);
+ if (async) {
+ counter.execute();
+ // Wait for the background task to finish.
+ ShadowApplication.runBackgroundTasks();
+ } else {
+ counter.executeInForeground();
+ }
+ }
+
+
private class InstalledAppCounterTestable extends InstalledAppCounter {
public InstalledAppCounterTestable(int installReason) {
super(mContext, installReason, mPackageManager);
diff --git a/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java b/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
similarity index 86%
rename from tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
rename to tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
index 262c9e0..96a10f1 100644
--- a/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
@@ -17,8 +17,6 @@
package com.android.settings.applications;
import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsRobolectricTestRunner;
@@ -34,40 +32,32 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
-import java.lang.reflect.Field;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class PictureInPictureSettingsTest {
+public class PictureInPictureDetailsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
private FakeFeatureFactory mFeatureFactory;
- private PictureInPictureSettings mFragment;
+ private PictureInPictureDetails mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mFragment = new PictureInPictureSettings();
+ mFragment = new PictureInPictureDetails();
}
@Test
public void testIgnoredApp() {
- for (String ignoredPackage : mFragment.IGNORE_PACKAGE_LIST) {
+ for (String ignoredPackage : PictureInPictureSettings.IGNORE_PACKAGE_LIST) {
assertThat(checkPackageHasPictureInPictureActivities(ignoredPackage, true))
.isFalse();
}
@@ -94,11 +84,11 @@
public void logSpecialPermissionChange() {
mFragment.logSpecialPermissionChange(true, "app");
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
- eq(MetricsProto.MetricsEvent.APP_PICTURE_IN_PICTURE_ON_HIDE_ALLOW), eq("app"));
+ eq(MetricsProto.MetricsEvent.APP_PICTURE_IN_PICTURE_ALLOW), eq("app"));
mFragment.logSpecialPermissionChange(false, "app");
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
- eq(MetricsProto.MetricsEvent.APP_PICTURE_IN_PICTURE_ON_HIDE_DENY), eq("app"));
+ eq(MetricsProto.MetricsEvent.APP_PICTURE_IN_PICTURE_DENY), eq("app"));
}
private boolean checkPackageHasPictureInPictureActivities(String packageName,
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsEnablerTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsEnablerTest.java
new file mode 100644
index 0000000..87905aa
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsEnablerTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.content.Context;
+import android.content.SharedPreferences;
+import android.provider.Settings;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DevelopmentSettingsEnablerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private SharedPreferences mDevelopmentPreferences;
+ private Context mContext;
+ private DevelopmentSettingsEnabler mEnabler;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mEnabler = new DevelopmentSettingsEnabler(mContext, null);
+ ReflectionHelpers.setField(mEnabler, "mDevelopmentPreferences", mDevelopmentPreferences);
+ }
+
+ @Test
+ public void onResume_shouldReadStateFromSettingProvider() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
+
+ mEnabler.onResume();
+
+ assertThat(mEnabler.getLastEnabledState()).isTrue();
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+
+ mEnabler.onResume();
+
+ assertThat(mEnabler.getLastEnabledState()).isFalse();
+ }
+
+ @Test
+ public void disable_shouldChangeSettingProviderValue() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
+
+ mEnabler.disableDevelopmentSettings();
+
+ assertThat(mEnabler.getLastEnabledState()).isFalse();
+ assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1)).isEqualTo(0);
+ }
+
+ @Test
+ public void enable_shouldChangeSettingProviderValue() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+
+ mEnabler.enableDevelopmentSettings();
+
+ assertThat(mEnabler.getLastEnabledState()).isTrue();
+ assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0)).isEqualTo(1);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
new file mode 100644
index 0000000..f9d26c7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.deviceinfo;
+
+import static com.android.settings.TestUtils.KILOBYTE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.LayoutInflater;
+import android.widget.ProgressBar;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class StorageItemPreferenceTest {
+ private Context mContext;
+ private StorageItemPreference mPreference;
+
+ @Before
+ public void setUp() throws Exception {
+ mContext = RuntimeEnvironment.application;
+ mPreference = new StorageItemPreference(mContext);
+ }
+
+ @Test
+ public void testBeforeLoad() {
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.memory_calculating_size));
+ }
+
+ @Test
+ public void testAfterLoad() {
+ mPreference.setStorageSize(KILOBYTE, KILOBYTE * 10);
+ assertThat(((String) mPreference.getSummary())).isEqualTo("1.00KB");
+ }
+
+ @Test
+ public void testProgressBarPercentageSet() {
+ final PreferenceViewHolder holder = new PreferenceViewHolder(
+ LayoutInflater.from(mContext).inflate(R.layout.storage_item, null));
+ final ProgressBar progressBar =
+ (ProgressBar) holder.itemView.findViewById(android.R.id.progress);
+
+ mPreference.onBindViewHolder(holder);
+ mPreference.setStorageSize(KILOBYTE, KILOBYTE * 10);
+
+ assertThat(progressBar.getProgress()).isEqualTo(10);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceAlternateTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceAlternateTest.java
deleted file mode 100644
index d2fc504..0000000
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceAlternateTest.java
+++ /dev/null
@@ -1,56 +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.deviceinfo.storage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import com.android.settings.R;
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class StorageItemPreferenceAlternateTest {
- private Context mContext;
-
- @Before
- public void setUp() throws Exception {
- mContext = RuntimeEnvironment.application;
- }
-
- @Test
- public void testBeforeLoad() {
- StorageItemPreferenceAlternate pref = new StorageItemPreferenceAlternate(mContext);
- assertThat(((String) pref.getSummary())).isEqualTo(
- mContext.getString(R.string.memory_calculating_size));
- }
-
- @Test
- public void testAfterLoad() {
- StorageItemPreferenceAlternate pref = new StorageItemPreferenceAlternate(mContext);
- pref.setStorageSize(1024L);
- assertThat(((String) pref.getSummary())).isEqualTo("1.00KB");
- }
-}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 961a6c7..387bc43 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -15,6 +15,8 @@
*/
package com.android.settings.deviceinfo.storage;
+import static com.android.settings.TestUtils.KILOBYTE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
@@ -43,6 +45,7 @@
import com.android.settings.TestConfig;
import com.android.settings.applications.ManageApplications;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
+import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -60,11 +63,6 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class StorageItemPreferenceControllerTest {
- /**
- * In O, this will change to 1000 instead of 1024 due to the formatter properly defining a
- * kilobyte.
- */
- private static long KILOBYTE = 1024L;
private Context mContext;
private VolumeInfo mVolume;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -72,7 +70,7 @@
@Mock
private StorageVolumeProvider mSvp;
private StorageItemPreferenceController mController;
- private StorageItemPreferenceAlternate mPreference;
+ private StorageItemPreference mPreference;
private FakeFeatureFactory mFakeFeatureFactory;
private MetricsFeatureProvider mMetricsFeatureProvider;
@@ -87,7 +85,7 @@
// Note: null is passed as the Lifecycle because we are handling it outside of the normal
// Settings fragment lifecycle for test purposes.
mController = new StorageItemPreferenceController(mContext, mFragment, mVolume, mSvp);
- mPreference = new StorageItemPreferenceAlternate(mContext);
+ mPreference = new StorageItemPreference(mContext);
// Inflate the preference and the widget.
LayoutInflater inflater = LayoutInflater.from(mContext);
@@ -190,12 +188,12 @@
@Test
public void testMeasurementCompletedUpdatesPreferences() {
- StorageItemPreferenceAlternate audio = new StorageItemPreferenceAlternate(mContext);
- StorageItemPreferenceAlternate image = new StorageItemPreferenceAlternate(mContext);
- StorageItemPreferenceAlternate games = new StorageItemPreferenceAlternate(mContext);
- StorageItemPreferenceAlternate apps = new StorageItemPreferenceAlternate(mContext);
- StorageItemPreferenceAlternate system = new StorageItemPreferenceAlternate(mContext);
- StorageItemPreferenceAlternate files = new StorageItemPreferenceAlternate(mContext);
+ StorageItemPreference audio = new StorageItemPreference(mContext);
+ StorageItemPreference image = new StorageItemPreference(mContext);
+ StorageItemPreference games = new StorageItemPreference(mContext);
+ StorageItemPreference apps = new StorageItemPreference(mContext);
+ StorageItemPreference system = new StorageItemPreference(mContext);
+ StorageItemPreference files = new StorageItemPreference(mContext);
PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(
eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
index 2c091f2..444a0d1 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
@@ -52,12 +52,13 @@
import java.io.File;
+import static com.android.settings.TestUtils.KILOBYTE;
+import static com.android.settings.TestUtils.MEGABYTE;
+import static com.android.settings.TestUtils.GIGABYTE;
+
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class StorageSummaryDonutPreferenceControllerTest {
- private static final long KILOBYTE = 1024; // Note: When O comes around, this value changes!
- private static final long MEGABYTE = KILOBYTE * KILOBYTE;
- private static final long GIGABYTE = KILOBYTE * MEGABYTE;
private Context mContext;
private StorageSummaryDonutPreferenceController mController;
private StorageSummaryDonutPreference mPreference;
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
index 6efccfc..a998fb5 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedCameraPermissionPreferenceControllerTest.java
@@ -20,6 +20,7 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
@@ -33,7 +34,8 @@
public AdminGrantedCameraPermissionPreferenceControllerTest() {
super("enterprise_privacy_number_camera_access_packages",
- new String[] {Manifest.permission.CAMERA});
+ new String[] {Manifest.permission.CAMERA},
+ Manifest.permission_group.CAMERA);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
index a23ad8b..e7aa358 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedLocationPermissionsPreferenceControllerTest.java
@@ -20,6 +20,7 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
@@ -34,7 +35,8 @@
public AdminGrantedLocationPermissionsPreferenceControllerTest() {
super("enterprise_privacy_number_location_access_packages",
new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION});
+ Manifest.permission.ACCESS_FINE_LOCATION},
+ Manifest.permission_group.LOCATION);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
index 39a715f..8c84af2 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedMicrophonePermissionPreferenceControllerTest.java
@@ -20,6 +20,7 @@
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
@@ -33,7 +34,8 @@
public AdminGrantedMicrophonePermissionPreferenceControllerTest() {
super("enterprise_privacy_number_microphone_access_packages",
- new String[] {Manifest.permission.RECORD_AUDIO});
+ new String[] {Manifest.permission.RECORD_AUDIO},
+ Manifest.permission_group.MICROPHONE);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
index 1f52b0e..0d53fb6 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBaseTest.java
@@ -16,8 +16,14 @@
package com.android.settings.enterprise;
+import android.Manifest;
+import android.content.Intent;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
@@ -30,7 +36,7 @@
AdminGrantedPermissionsPreferenceControllerTestBase {
public AdminGrantedPermissionsPreferenceControllerBaseTest() {
- super(null, new String[] {"some.permission"});
+ super("some.key", new String[] {"some.permission"}, "some.permission");
}
@Override
@@ -43,12 +49,14 @@
AdminGrantedPermissionsPreferenceControllerBase {
AdminGrantedPermissionsPreferenceControllerBaseTestable() {
- super(AdminGrantedPermissionsPreferenceControllerBaseTest.this.mContext, mPermissions);
+ super(AdminGrantedPermissionsPreferenceControllerBaseTest.this.mContext, mPermissions,
+ mPermissionGroup);
}
@Override
public String getPreferenceKey() {
- return null;
+ return "some.key";
}
}
}
+
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
index 821fb34..5a70b7a 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
@@ -17,6 +17,7 @@
package com.android.settings.enterprise;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
import android.support.v7.preference.Preference;
@@ -27,6 +28,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Answers;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
@@ -36,6 +38,7 @@
import static org.mockito.Mockito.anyObject;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
@@ -45,6 +48,7 @@
protected final String mKey;
protected final String[] mPermissions;
+ protected final String mPermissionGroup;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
protected Context mContext;
@@ -52,9 +56,11 @@
protected AdminGrantedPermissionsPreferenceControllerBase mController;
- public AdminGrantedPermissionsPreferenceControllerTestBase(String key, String[] permissions) {
+ public AdminGrantedPermissionsPreferenceControllerTestBase(String key, String[] permissions,
+ String permissionGroup) {
mKey = key;
mPermissions = permissions;
+ mPermissionGroup = permissionGroup;
}
@Before
@@ -81,8 +87,9 @@
preference.setVisible(false);
setNumberOfPackagesWithAdminGrantedPermissions(20);
- when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
- 20, 20)).thenReturn("20 packages");
+ when(mContext.getResources().getQuantityString(
+ R.plurals.enterprise_privacy_number_packages_actionable,20, 20))
+ .thenReturn("20 packages");
mController.updateState(preference);
assertThat(preference.getSummary()).isEqualTo("20 packages");
assertThat(preference.isVisible()).isTrue();
@@ -99,8 +106,19 @@
@Test
public void testHandlePreferenceTreeClick() {
- assertThat(mController.handlePreferenceTreeClick(new Preference(mContext, null, 0, 0)))
- .isFalse();
+ final Preference preference = new Preference(mContext, null, 0, 0);
+ preference.setKey(mKey);
+
+ assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
+
+ final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).startActivity(argumentCaptor.capture());
+
+ final Intent intent = argumentCaptor.getValue();
+
+ assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MANAGE_PERMISSION_APPS);
+ assertThat(intent.getStringExtra(Intent.EXTRA_PERMISSION_NAME)).
+ isEqualTo(mPermissionGroup);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index 46c29b2..6ff1703 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -62,18 +62,19 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new EnterpriseInstalledPackagesPreferenceController(mContext);
+ mController = new EnterpriseInstalledPackagesPreferenceController(mContext,
+ null /* lifecycle */, true /* async */);
}
- private void setNumberOfEnterpriseInstalledPackages(int number) {
+ private void setNumberOfEnterpriseInstalledPackages(int number, boolean async) {
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
((ApplicationFeatureProvider.NumberOfAppsCallback)
- invocation.getArguments()[1]).onNumberOfAppsResult(number);
+ invocation.getArguments()[2]).onNumberOfAppsResult(number);
return null;
}}).when(mFeatureFactory.applicationFeatureProvider)
.calculateNumberOfInstalledApps(eq(PackageManager.INSTALL_REASON_POLICY),
- anyObject());
+ eq(async), anyObject());
}
@Test
@@ -81,11 +82,11 @@
final Preference preference = new Preference(mContext, null, 0, 0);
preference.setVisible(true);
- setNumberOfEnterpriseInstalledPackages(0);
+ setNumberOfEnterpriseInstalledPackages(0, true /* async */);
mController.updateState(preference);
assertThat(preference.isVisible()).isFalse();
- setNumberOfEnterpriseInstalledPackages(20);
+ setNumberOfEnterpriseInstalledPackages(20, true /* async */);
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
20, 20)).thenReturn("20 packages");
mController.updateState(preference);
@@ -94,7 +95,24 @@
}
@Test
- public void testIsAvailable() {
+ public void testIsAvailableSync() {
+ EnterpriseInstalledPackagesPreferenceController controller
+ = new EnterpriseInstalledPackagesPreferenceController(mContext,
+ null /* lifecycle */, false /* async */);
+
+ setNumberOfEnterpriseInstalledPackages(0, false /* async */);
+ assertThat(controller.isAvailable()).isFalse();
+
+ setNumberOfEnterpriseInstalledPackages(20, false /* async */);
+ assertThat(controller.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testIsAvailableAsync() {
+ setNumberOfEnterpriseInstalledPackages(0, true /* async */);
+ assertThat(mController.isAvailable()).isTrue();
+
+ setNumberOfEnterpriseInstalledPackages(20, true /* async */);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 29ca4cd..46d6b6c 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -104,6 +104,18 @@
public void getPreferenceControllers() {
final List<PreferenceController> controllers = mSettings.getPreferenceControllers(
ShadowApplication.getInstance().getApplicationContext());
+ verifyPreferenceControllers(controllers);
+ }
+
+ @Test
+ public void getSearchIndexProviderPreferenceControllers() {
+ final List<PreferenceController> controllers
+ = EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER.getPreferenceControllers(
+ ShadowApplication.getInstance().getApplicationContext());
+ verifyPreferenceControllers(controllers);
+ }
+
+ private void verifyPreferenceControllers(List<PreferenceController> controllers) {
assertThat(controllers).isNotNull();
assertThat(controllers.size()).isEqualTo(17);
assertThat(controllers.get(0)).isInstanceOf(InstalledPackagesPreferenceController.class);
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
index 093ce20..3455e80 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
@@ -65,7 +65,8 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mController = new EnterpriseSetDefaultAppsPreferenceController(mContext);
+ mController = new EnterpriseSetDefaultAppsPreferenceController(mContext,
+ null /* lifecycle */);
}
private static Intent buildIntent(String action, String category, String protocol,
@@ -95,15 +96,6 @@
@Test
public void testUpdateState() {
- final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
-
- when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(
- anyObject())).thenReturn(
- new ArraySet<ApplicationFeatureProvider.PersistentPreferredActivityInfo>());
- mController.updateState(preference);
- assertThat(preference.isVisible()).isFalse();
-
setEnterpriseSetDefaultApps(new Intent[] {buildIntent(Intent.ACTION_VIEW,
Intent.CATEGORY_BROWSABLE, "http:", null)}, 1);
setEnterpriseSetDefaultApps(new Intent[] {new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
@@ -120,13 +112,21 @@
new Intent(Intent.ACTION_CALL)}, 64);
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
127, 127)).thenReturn("127 apps");
+
+ final Preference preference = new Preference(mContext, null, 0, 0);
mController.updateState(preference);
assertThat(preference.getSummary()).isEqualTo("127 apps");
- assertThat(preference.isVisible()).isTrue();
}
@Test
public void testIsAvailable() {
+ when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(
+ anyObject())).thenReturn(
+ new ArraySet<ApplicationFeatureProvider.PersistentPreferredActivityInfo>());
+ assertThat(mController.isAvailable()).isFalse();
+
+ setEnterpriseSetDefaultApps(new Intent[] {buildIntent(Intent.ACTION_VIEW,
+ Intent.CATEGORY_BROWSABLE, "http:", null)}, 1);
assertThat(mController.isAvailable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java
index 60ceed6..4a5a183 100644
--- a/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/InstalledPackagesPreferenceControllerTest.java
@@ -68,11 +68,10 @@
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
((ApplicationFeatureProvider.NumberOfAppsCallback)
- invocation.getArguments()[1]).onNumberOfAppsResult(number);
+ invocation.getArguments()[2]).onNumberOfAppsResult(number);
return null;
- }}).when(mFeatureFactory.applicationFeatureProvider)
- .calculateNumberOfInstalledApps(
- eq(ApplicationFeatureProvider.IGNORE_INSTALL_REASON), anyObject());
+ }}).when(mFeatureFactory.applicationFeatureProvider).calculateNumberOfInstalledApps(
+ eq(ApplicationFeatureProvider.IGNORE_INSTALL_REASON), eq(true), anyObject());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
index 5cb6377..d3f5e97 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
@@ -62,6 +62,13 @@
final Preference preference = new Preference(mContext, null, 0, 0);
when(mFeatureFactory.enterprisePrivacyFeatureProvider
+ .getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile()).thenReturn(0);
+ when(mContext.getResources().getString(R.string.number_of_device_admins_none))
+ .thenReturn("no apps");
+ mController.updateState(preference);
+ assertThat(preference.getSummary()).isEqualTo("no apps");
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider
.getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile()).thenReturn(5);
when(mContext.getResources().getQuantityString(R.plurals.number_of_device_admins, 5, 5))
.thenReturn("5 active apps");
diff --git a/tests/robotests/src/com/android/settings/widget/DefaultIndicatorSeekBarTest.java b/tests/robotests/src/com/android/settings/widget/DefaultIndicatorSeekBarTest.java
new file mode 100644
index 0000000..cf4be56
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/DefaultIndicatorSeekBarTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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 com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static junit.framework.Assert.assertEquals;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DefaultIndicatorSeekBarTest {
+
+ private DefaultIndicatorSeekBar mDefaultIndicatorSeekBar;
+
+ @Before
+ public void setUp() {
+ mDefaultIndicatorSeekBar = new DefaultIndicatorSeekBar(RuntimeEnvironment.application);
+ mDefaultIndicatorSeekBar.setMax(100);
+ }
+
+ @After
+ public void tearDown() {
+ mDefaultIndicatorSeekBar = null;
+ }
+
+ @Test
+ public void defaultProgress_setSucceeds() {
+ mDefaultIndicatorSeekBar.setDefaultProgress(40);
+ assertEquals(40, mDefaultIndicatorSeekBar.getDefaultProgress());
+ }
+
+}