Snap for 5533229 from 21dbfce634 to qt-release

Change-Id: Ic0c62fefa8b4ffcf7f37b740143e0e1811d9be81
This commit is contained in:
android-build-team Robot
2019-05-04 23:14:23 +00:00
86 changed files with 2164 additions and 1654 deletions

View File

@@ -848,6 +848,23 @@
<meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity>
<activity android:name=".wallpaper.StyleSuggestionActivity"
android:label="@string/style_suggestion_title"
android:icon="@drawable/ic_theme"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
</intent-filter>
<meta-data android:name="com.android.settings.title"
android:resource="@string/style_suggestion_title" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/style_suggestion_summary" />
<meta-data android:name="com.android.settings.dismiss"
android:value="3,7,30" />
<meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity>
<activity
android:name="Settings$ZenModeScheduleRuleSettingsActivity"
android:exported="true"
@@ -1333,22 +1350,23 @@
</activity-alias>
<activity android:name=".applications.specialaccess.deviceadmin.DeviceAdminAdd"
android:label="@string/device_admin_add_title"
android:clearTaskOnLaunch="true">
android:label="@string/device_admin_add_title"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.app.action.ADD_DEVICE_ADMIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity-alias android:name="SetProfileOwner"
android:label="@string/profile_owner_add_title"
android:targetActivity=".applications.specialaccess.deviceadmin.DeviceAdminAdd">
<activity android:name=".applications.specialaccess.deviceadmin.ProfileOwnerAdd"
android:excludeFromRecents="true"
android:theme="@style/Transparent"
android:clearTaskOnLaunch="true">
<intent-filter android:priority="1000">
<action android:name="android.app.action.SET_PROFILE_OWNER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>
</activity>
<activity
android:name="Settings$UsageAccessSettingsActivity"

2
OWNERS
View File

@@ -6,10 +6,10 @@ asapperstein@google.com
asargent@google.com
dehboxturtle@google.com
dhnishi@google.com
dling@google.com
edgarwang@google.com
emilychuang@google.com
jackqdyulei@google.com
lindatseng@google.com
mfritze@google.com
rafftsai@google.com
tmfang@google.com

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -16,8 +16,10 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/notification_importance_selection_bg" />
<stroke
android:width="2dp"
android:color="?android:attr/textColorSecondary"/>
android:width="1dp"
android:color="@color/notification_importance_button_selected"/>
<corners android:radius="@dimen/rect_button_radius" />
</shape>

View File

@@ -17,8 +17,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="2dp"
android:color="?android:attr/textColorSecondary"/>
android:width="1dp"
android:color="@color/notification_importance_button_unselected"/>
<corners android:radius="@dimen/rect_button_radius" />
</shape>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
<!-- Copyright (C) 2019 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,15 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,13h-5v5c0,0.55-0.45,1-1,1h0c-0.55,0-1-0.45-1-1v-5H6c-0.55,0-1-0.45-1-1v0c0-0.55,0.45-1,1-1h5V6c0-0.55,0.45-1,1-1h0
c0.55,0,1,0.45,1,1v5h5c0.55,0,1,0.45,1,1v0C19,12.55,18.55,13,18,13z"/>
android:fillColor="?android:attr/colorControlNormal"
android:pathData="M12,16.41l-6.71,-6.7l1.42,-1.42l5.29,5.3l5.29,-5.3l1.42,1.42z"/>
</vector>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 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
-->
<com.android.settings.widget.TintDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_add_24dp"
android:tint="?android:attr/colorControlActivated" />

View File

@@ -20,6 +20,9 @@
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM11.75,6.1c-0.5,0 -0.75,0.32 -0.75,0.72L11,13l4.64,2.78c0.34,0.2 0.78,0.1 0.98,-0.24a0.71,0.71 0,0 0,-0.25 -0.99l-3.87,-2.3L12.5,6.82c0,-0.4 -0.25,-0.72 -0.75,-0.72z"/>
android:fillColor="@android:color/white"
android:pathData="M11.99,2.0C6.47,2.0 2.0,6.48 2.0,12.0s4.47,10.0 9.99,10.0C17.52,22.0 22.0,17.52 22.0,12.0S17.52,2.0 11.99,2.0zM12.0,20.0c-4.42,0.0 -8.0,-3.58 -8.0,-8.0s3.58,-8.0 8.0,-8.0 8.0,3.58 8.0,8.0 -3.58,8.0 -8.0,8.0z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M12.5,7.0L11.0,7.0l0.0,6.0l5.25,3.1 0.75,-1.23 -4.5,-2.67z"/>
</vector>

26
res/drawable/ic_theme.xml Normal file
View File

@@ -0,0 +1,26 @@
<!--
Copyright (C) 2019 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.
-->
<!-- This draws a paintbrush like shape -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FF000000"
android:pathData="M4,2v9c0,1.65 1.35,3 3,3h2v6c0,1.1 0.9,2 2,2h2c1.1,0 2,-0.9 2,-2v-6h2c1.65,0 3,-1.35 3,-3V2C20,2 4,2 4,2zM11,20v-6h2v6H11zM18,11c0,0.55 -0.45,1 -1,1h-2H9H7c-0.55,0 -1,-0.45 -1,-1v-0.93h12V11zM18,8.07H6V4h2.81v2.15h2V4h2.38v2.15h2V4H18V8.07z"/>
</vector>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/drawable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 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:id="@+id/active_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView android:id="@+id/add_msg_simplified"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars = "vertical"
android:padding="?dialogPreferredPadding"
android:gravity="center_vertical"/>
<TextView android:id="@+id/admin_warning_simplified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding"/>
</LinearLayout>

View File

@@ -18,6 +18,6 @@
<item
android:id="@+id/vpn_create"
android:title="@string/vpn_create"
android:icon="@drawable/ic_menu_add"
android:icon="@drawable/ic_add_24dp"
android:showAsAction="always" />
</menu>

View File

@@ -26,5 +26,8 @@
<color name="search_bar_background">@*android:color/material_grey_800</color>
<!-- Dialog background color -->
<color name="dialog_background">@*android:color/material_grey_800</color>
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
<color name="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->
<color name="notification_importance_button_unselected">#5F6368</color>
</resources>

View File

@@ -126,7 +126,9 @@
<color name="notification_block_color">#ffff0000</color>
<color name="notification_silence_color">#FF32c1de</color>
<color name="notification_alert_color">#FFF87B2B</color>
<color name="notification_importance_button_unselected">#FFDADCE0</color>
<color name="notification_importance_button_unselected">#DADCE0</color>
<color name="notification_importance_button_selected">#1967D2</color> <!-- material blue 700 -->
<color name="notification_importance_selection_bg">#FFFFFF</color>
<!-- launcher icon color -->
<color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>

View File

@@ -933,26 +933,27 @@
<!-- Button text to exit face wizard after everything is done [CHAR LIMIT=15] -->
<string name="security_settings_face_enroll_done">Done</string>
<!-- Title for a category shown for the face settings page. [CHAR LIMIT=20] -->
<string name="security_settings_face_settings_use_face_category">Use your face for</string>
<string name="security_settings_face_settings_use_face_category">Use face unlock for</string>
<!-- Text shown on a toggle which allows or disallows the device to use face for unlocking the device. [CHAR LIMIT=20] -->
<string name="security_settings_face_settings_use_face_unlock_phone">Unlocking your device</string>
<string name="security_settings_face_settings_use_face_unlock_phone">Unlocking your phone</string>
<!-- Text shown on a toggle which allows or disallows the device to use face authentication for apps. This will be presented to the user together with the context of security_settings_face_settings_use_face_category. [CHAR LIMIT=30] -->
<string name="security_settings_face_settings_use_face_for_apps">App sign-in \u0026 payments</string>
<!-- Title for a category shown for the face settings page, followed by items that the user can toggle on/off to require/disable. -->
<string name="security_settings_face_settings_require_category">Require for face unlock</string>
<!-- Text shown on a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=30] -->
<string name="security_settings_face_settings_require_attention">Eyes open to unlock</string>
<string name="security_settings_face_settings_require_attention">Open eyes looking at screen</string>
<!-- Text shown on the details of a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=70] -->
<string name="security_settings_face_settings_require_attention_details">When using face authentication, your eyes must be open</string>
<string name="security_settings_face_settings_require_attention_details">To unlock the phone, always require looking at the screen with your eyes open</string>
<!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=50] -->
<string name="security_settings_face_settings_require_confirmation">Always require confirmation</string>
<string name="security_settings_face_settings_require_confirmation">Confirm button</string>
<!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=70] -->
<string name="security_settings_face_settings_require_confirmation_details">When authenticating in apps, always require confirmation</string>
<string name="security_settings_face_settings_require_confirmation_details">When authenticating for apps, always require confirmation</string>
<!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] -->
<string name="security_settings_face_settings_remove_face_data">Remove face data</string>
<string name="security_settings_face_settings_remove_face_data">Delete face data</string>
<!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
<string name="security_settings_face_settings_enroll">Set up face authentication</string>
<string name="security_settings_face_settings_enroll">Set up new face unlock</string>
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
<annotation id="url">Learn more</annotation></string>
<string name="security_settings_face_settings_footer">Use Face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, your child or an identical sibling.</string>
<!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
<string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
<!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
@@ -1052,17 +1053,17 @@
<!-- Content of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=NONE] -->
<string name="setup_fingerprint_enroll_enrolling_skip_message">You\u2019ve chosen to use your fingerprint as one way to unlock your phone. If you skip now, you\u2019ll need to set this up later. Setup takes only a minute or so.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (tablet) [CHAR LIMIT=NONE] -->
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (device) [CHAR LIMIT=NONE] -->
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (default) [CHAR LIMIT=NONE] -->
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
<string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (tablet) [CHAR LIMIT=NONE] -->
<string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
<string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (device) [CHAR LIMIT=NONE] -->
<string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
<string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (default) [CHAR LIMIT=NONE] -->
<string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
<string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Title of dialog shown when the user tries to skip setting up a PIN, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
<string name="lock_screen_pin_skip_title">Skip PIN setup?</string>
<!-- Title of dialog shown when the user tries to skip setting up a password, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
@@ -1786,6 +1787,9 @@
<!-- Bluetooth device details. The body of a confirmation dialog for unpairing a paired device. -->
<string name="bluetooth_unpair_dialog_body" product="device">Your device will no longer be paired with <xliff:g id="device_name">%1$s</xliff:g></string>
<!-- Bluetooth device details. The body of a confirmation dialog for unpairing a paired device. [CHAR LIMIT=NONE] -->
<string name="bluetooth_untethered_unpair_dialog_body"><xliff:g id="device_name" example="Jack's headphone">%1$s</xliff:g> will no longer be paired with any device linked to this account</string>
<!-- Bluetooth device details. In the confirmation dialog for unpairing a paired device, this is the label on the button that will complete the unpairing action. -->
<string name="bluetooth_unpair_dialog_forget_confirm_button">Forget device</string>
@@ -2317,8 +2321,9 @@
<item quantity="one">1 subscription</item>
<item quantity="other">%d subscriptions</item>
</plurals>
<!-- Wi-Fi settings screen, Saved networks summary. This shows below the "Saved networks" item and indicates number of whole kinds networks, if there are both normal saved networks and saved passpoint networks. The number will be at least 2. [CHAR LIMIT=60] -->
<!-- Wi-Fi settings screen, Saved networks summary. This shows below the "Saved networks" item and indicates number of whole kinds networks, if there are both normal saved networks and saved passpoint networks. The number will be at least 2, so the one case is only to prevent lint error. [CHAR LIMIT=60] -->
<plurals name="wifi_saved_all_access_points_summary">
<item quantity="one">1 network &amp; subscription</item>
<item quantity="other">%d networks &amp; subscriptions</item>
</plurals>
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. [CHAR LIMIT=30] -->
@@ -2888,6 +2893,10 @@
<string name="wallpaper_suggestion_summary">Personalize your screen</string>
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
<!-- Styles and Wallpaper settings title [CHAR_LIMIT=46] -->
<string name="style_suggestion_title">Customize your Pixel</string>
<!-- Styles and Wallpapers summary [CHAR_LIMIT=55] -->
<string name="style_suggestion_summary">Try different styles, wallpapers, clocks, and more</string>
<!-- Display settings screen, trigger for screen saver options -->
<string name="screensaver_settings_title">Screen saver</string>
<!-- Display settings screen, summary fragment for screen saver options, activated when docked or asleep and charging -->
@@ -4885,13 +4894,13 @@
<!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
<string name="accessibility_autoclick_delay_preference_title">Delay before click</string>
<!-- Title for accessibility preference screen for configuring vibrations. -->
<string name="accessibility_vibration_settings_title">Vibration</string>
<string name="accessibility_vibration_settings_title">Vibration &amp; haptic strength</string>
<!-- Title for accessibility preference for configuring notification vibrations. -->
<string name="accessibility_notification_vibration_title">Notification vibration</string>
<!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
<string name="accessibility_ring_vibration_title">Ring vibration</string>
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch vibration</string>
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
<string name="accessibility_service_master_switch_title">Use service</string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
@@ -6019,6 +6028,9 @@
<string name="device_admin_warning">Activating this admin app will allow
the app <xliff:g id="app_name">%1$s</xliff:g> to perform the
following operations:</string>
<!-- Simplified device admin warning message [CHAR LIMIT=NONE]-->
<string name="device_admin_warning_simplified">This device will be managed and monitored by
<xliff:g id="app_name" example="Example Supervisor">%1$s</xliff:g>.</string>
<!-- Device admin warning message about policies an admin can use -->
<string name="device_admin_status">This admin app is active and allows
the app <xliff:g id="app_name">%1$s</xliff:g> to perform the
@@ -6026,6 +6038,8 @@
<!-- Title for screen to set a profile owner [CHAR LIMIT=40] -->
<string name="profile_owner_add_title">Activate Profile Manager?</string>
<!-- Simplified title for dialog to set a profile owner [CHAR LIMIT=40] -->
<string name="profile_owner_add_title_simplified">Allow supervision?</string>
<!-- Warning when trying to add a profile owner admin after setup has completed. [CHAR LIMIT=none] -->
<string name="adding_profile_owner_warning">By proceeding, your user will be managed by your
admin which may also be able to store associated data, in addition to your personal
@@ -6372,6 +6386,8 @@
<!-- Option for indicating that a network being metered (expensive) should be determined automatically. [CHAR LIMIT=32] -->
<string name="data_usage_metered_auto">Automatic</string>
<!-- Title for Network usage to control whether Wifi is metered or not [CHAR LIMIT=20] -->
<string name="wifi_metered_title">Network usage</string>
<!-- Option for indicating that a network is metered (expensive). [CHAR LIMIT=32] -->
<string name="data_usage_metered_yes">Metered</string>
<!-- Option for indicating that a network is not metered (inexpensive). [CHAR LIMIT=32] -->
@@ -7856,6 +7872,33 @@
<!-- Configure notifications: value for swipe direction [CHAR LIMIT=100] -->
<string name="swipe_direction_rtl">Swipe left to dismiss, right to show menu</string>
<!-- Configure notifications: link to education/gentle notification settings [CHAR LIMIT=100] -->
<string name="gentle_notifications_title">Gentle notifications</string>
<!-- Gentle notifications settings : header for selecting where gentle notifications should appear [CHAR LIMIT=100] -->
<string name="gentle_notifications_also_display">Also display in</string>
<!-- Gentle notifications settings: display in status bar [CHAR LIMIT=100] -->
<string name="gentle_notifications_display_status">Status bar</string>
<!-- Gentle notifications settings: display in lock screen [CHAR LIMIT=100] -->
<string name="gentle_notifications_display_lock">Lock screen</string>
<!-- Gentle notifications footer: what are gentle notification [CHAR LIMIT=NONE] -->
<string name="gentle_notifications_education">Gentle notifications are always silent and always appear in the pull-down shade</string>
<!-- Gentle notifications settings: display only in shade [CHAR LIMIT=100] -->
<string name="gentle_notifications_display_summary_shade">Display in pull-down shade only</string>
<!-- Gentle notifications settings: display in shade and on the lock screen [CHAR LIMIT=100] -->
<string name="gentle_notifications_display_summary_shade_lock">Display in pull-down shade &amp; on lock screen</string>
<!-- Gentle notifications settings: display in shade and on status bar [CHAR LIMIT=100] -->
<string name="gentle_notifications_display_summary_shade_status">Display in pull-down shade &amp; status bar</string>
<!-- Gentle notifications settings: display on all surfaces [CHAR LIMIT=100] -->
<string name="gentle_notifications_display_summary_shade_status_lock">Display in pull-down shade, status bar &amp; on lock screen</string>
<!-- Configure Notifications: Title for the pulse notification light option. [CHAR LIMIT=30] -->
<string name="notification_pulse_title">Blink light</string>
@@ -11068,9 +11111,9 @@
<string name="forget_passpoint_dialog_message">You may lose access to any remaining time or data. Check with your provider before removing.</string>
<!-- Keywords for Content Capture feature [CHAR_LIMIT=none] -->
<string name="keywords_content_capture">content capture</string>
<string name="keywords_content_capture">content capture, app content</string>
<!-- Title of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=none]-->
<string name="content_capture">Content Capture</string>
<string name="content_capture">App content</string>
<!-- Description of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
<string name="content_capture_summary">Allow apps to send content to the Android system</string>

View File

@@ -28,7 +28,7 @@
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:listPreferredItemHeight">72dip</item>
<item name="homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>

View File

@@ -28,7 +28,7 @@
<com.android.settingslib.RestrictedPreference
android:key="bluetooth_screen_add_bt_devices"
android:title="@string/bluetooth_pairing_pref_title"
android:icon="@drawable/ic_menu_add"
android:icon="@drawable/ic_add_24dp"
android:summary="@string/connected_device_add_device_summary"
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
settings:allowDividerAbove="true"

View File

@@ -26,11 +26,11 @@
settings:controller="com.android.settings.widget.VideoPreferenceController"
android:persistent="false" />
<SwitchPreference
android:key="hide_silent_icons"
android:title="@string/hide_silent_icons_title"
android:summary="@string/hide_silent_icons_summary"
settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController" />
<Preference
android:key="gentle_notifications"
android:title="@string/gentle_notifications_title"
settings:controller="com.android.settings.notification.GentleNotificationsPreferenceController"
android:fragment="com.android.settings.notification.GentleNotificationSettings"/>
<PreferenceCategory
android:key="configure_notifications_smart"

View File

@@ -39,7 +39,7 @@
<com.android.settingslib.RestrictedPreference
android:key="add_bt_devices"
android:title="@string/bluetooth_pairing_pref_title"
android:icon="@drawable/ic_menu_add"
android:icon="@drawable/ic_add_24dp"
android:summary="@string/connected_device_add_device_summary"
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
settings:allowDividerAbove="true"

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/gentle_notifications_title"
android:key="gentle_notification_settings">
<com.android.settingslib.widget.LayoutPreference
android:key="gentle_notifications_drawable"
android:title="@string/summary_placeholder"
android:layout="@layout/drawable_layout"
settings:controller="com.android.settings.notification.GentleDrawablePreferenceController"
android:order="1"
settings:allowDividerBelow="true"
android:persistent="false" />
<Preference
android:key="gentle_notifications_footer"
android:title="@string/gentle_notifications_education"
android:order="2"
android:icon="@drawable/ic_info_outline_24"
style="?attr/footerPreferenceStyle"
settings:allowDividerAbove="true"
android:clickable="false"
android:selectable="false" />
<PreferenceCategory
android:key="gentle_notifications_settings"
android:title="@string/gentle_notifications_also_display"
android:order="3">
<SwitchPreference
android:key="silent_icons"
android:title="@string/gentle_notifications_display_status"
settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController" />
<SwitchPreference
android:key="lock_screen"
android:title="@string/gentle_notifications_display_lock"
settings:controller="com.android.settings.notification.SilentLockscreenPreferenceController" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -24,7 +24,7 @@
android:key="add_more"
settings:isPreferenceVisible="false"
android:title="@string/mobile_network_list_add_more"
android:icon="@drawable/ic_menu_add"
android:icon="@drawable/ic_menu_add_activated_tint"
android:order="100" >
<intent android:action="android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION">
<extra android:name="android.telephony.euicc.extra.FORCE_PROVISION"

View File

@@ -42,7 +42,8 @@
</PreferenceCategory>
<PreferenceCategory
android:key="security_settings_face_manage_category">
android:key="security_settings_face_manage_category"
android:title="@string/security_settings_face_settings_require_category">
<SwitchPreference
android:key="security_settings_face_require_attention"
android:title="@string/security_settings_face_settings_require_attention"

View File

@@ -30,7 +30,7 @@
<com.android.settingslib.RestrictedPreference
android:key="user_add"
android:title="@string/user_add_user_or_profile_menu"
android:icon="@drawable/ic_menu_add"
android:icon="@drawable/ic_add_24dp"
android:order="20"/>
<com.android.settingslib.RestrictedSwitchPreference

View File

@@ -58,7 +58,7 @@
<DropDownPreference
android:key="metered"
android:icon="@drawable/ic_attach_money_black_24dp"
android:title="@string/data_usage_metered_yes"
android:title="@string/wifi_metered_title"
android:entries="@array/wifi_metered_entries"
android:entryValues="@array/wifi_metered_values"/>

View File

@@ -27,7 +27,7 @@
<Preference
android:key="zen_mode_add_automatic_rule"
android:icon="@drawable/ic_menu_add"
android:icon="@drawable/ic_add_24dp"
android:title="@string/zen_mode_add_rule"/>
</PreferenceScreen>

View File

@@ -351,7 +351,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
RestrictedPreference preference =
new RestrictedPreference(mParent.getPreferenceManager().getContext());
preference.setTitle(R.string.add_account_label);
preference.setIcon(R.drawable.ic_menu_add);
preference.setIcon(R.drawable.ic_add_24dp);
preference.setOnPreferenceClickListener(this);
preference.setOrder(ORDER_NEXT_TO_NEXT_TO_LAST);
return preference;

View File

@@ -23,7 +23,6 @@ import android.content.res.Resources;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import androidx.preference.Preference;
@@ -35,9 +34,9 @@ import java.util.List;
public class EmergencyInfoPreferenceController extends BasePreferenceController {
public static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENCY_INFO";
private static final String PACKAGE_NAME_EMERGENCY = "com.android.emergency";
public static String getIntentAction(Context context) {
return context.getResources().getString(R.string.config_emergency_intent_action);
}
public EmergencyInfoPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -85,19 +84,7 @@ public class EmergencyInfoPreferenceController extends BasePreferenceController
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
private static String getIntentAction(Context context) {
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
return context.getResources().getString(R.string.config_emergency_intent_action);
}
return ACTION_EDIT_EMERGENCY_INFO;
}
private static String getPackageName(Context context) {
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
return context.getResources().getString(R.string.config_emergency_package_name);
}
return PACKAGE_NAME_EMERGENCY;
return context.getResources().getString(R.string.config_emergency_package_name);
}
}

View File

@@ -178,7 +178,7 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
return true;
});
preference.setTitle(R.string.print_menu_item_add_service);
preference.setIcon(R.drawable.ic_menu_add);
preference.setIcon(R.drawable.ic_add_24dp);
preference.setOrder(Integer.MAX_VALUE -1);
preference.setPersistent(false);
return preference;

View File

@@ -46,6 +46,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.text.method.ScrollingMovementMethod;
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
@@ -273,15 +274,63 @@ public class DeviceAdminAdd extends Activity {
}
}
// If we're trying to add a profile owner and user setup hasn't completed yet, no
// need to prompt for permission. Just add and finish.
if (mAddingProfileOwner && !mDPM.hasUserSetupCompleted()) {
addAndFinish();
return;
}
mAddMsgText = getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
if (mAddingProfileOwner) {
// If we're trying to add a profile owner and user setup hasn't completed yet, no
// need to prompt for permission. Just add and finish
if (!mDPM.hasUserSetupCompleted()) {
addAndFinish();
return;
}
// othewise, only the defined default supervision profile owner can be set after user
// setup.
final String supervisor = getString(
com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
if (supervisor == null) {
Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor"
+ "profile owner defined");
finish();
return;
}
final ComponentName supervisorComponent = ComponentName.unflattenFromString(
supervisor);
if (who.compareTo(supervisorComponent) != 0) {
Log.w(TAG, "Unable to set non-default profile owner post-setup " + who);
finish();
return;
}
// Build and show the simplified dialog
final Dialog dialog = new AlertDialog.Builder(this)
.setTitle(getText(R.string.profile_owner_add_title_simplified))
.setView(R.layout.profile_owner_add)
.setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
addAndFinish();
}
})
.setNeutralButton(R.string.cancel, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialogInterface) {
finish();
}
})
.create();
dialog.show();
mActionButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
mActionButton.setFilterTouchesWhenObscured(true);
mAddMsg = dialog.findViewById(R.id.add_msg_simplified);
mAddMsg.setMovementMethod(new ScrollingMovementMethod());
mAddMsg.setText(mAddMsgText);
mAdminWarning = dialog.findViewById(R.id.admin_warning_simplified);
mAdminWarning.setText(getString(R.string.device_admin_warning_simplified,
mProfileOwnerName));
return;
}
setContentView(R.layout.device_admin_add);
mAdminIcon = (ImageView)findViewById(R.id.admin_icon);
@@ -501,7 +550,9 @@ public class DeviceAdminAdd extends Activity {
protected void onResume() {
super.onResume();
mActionButton.setEnabled(true);
updateInterface();
if (!mAddingProfileOwner) {
updateInterface();
}
// As long as we are running, don't let anyone overlay stuff on top of the screen.
mAppOps.setUserRestriction(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, true, mToken);
mAppOps.setUserRestriction(AppOpsManager.OP_TOAST_WINDOW, true, mToken);
@@ -571,9 +622,6 @@ public class DeviceAdminAdd extends Activity {
} catch (Resources.NotFoundException e) {
mAdminDescription.setVisibility(View.GONE);
}
if (mAddingProfileOwner) {
mProfileOwnerWarning.setVisibility(View.VISIBLE);
}
if (mAddMsgText != null) {
mAddMsg.setText(mAddMsgText);
mAddMsg.setVisibility(View.VISIBLE);
@@ -634,11 +682,7 @@ public class DeviceAdminAdd extends Activity {
addDeviceAdminPolicies(true /* showDescription */);
mAdminWarning.setText(getString(R.string.device_admin_warning,
mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(getPackageManager())));
if (mAddingProfileOwner) {
setTitle(getText(R.string.profile_owner_add_title));
} else {
setTitle(getText(R.string.add_device_admin_msg));
}
setTitle(getText(R.string.add_device_admin_msg));
mActionButton.setText(getText(R.string.add_device_admin));
if (isAdminUninstallable()) {
mUninstallButton.setVisibility(View.VISIBLE);

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2019 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.specialaccess.deviceadmin;
import android.os.Bundle;
/**
* ProfileOwnerAdd uses the DeviceAdminAdd logic to handle SET_PROFILE_OWNER intents
*
* TODO(b/131713071): Move profile owner add logic from DeviceAdminAdd to here
*/
public class ProfileOwnerAdd extends DeviceAdminAdd {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
}
}

View File

@@ -396,7 +396,7 @@ public class FingerprintSettings extends SubSettings {
Preference addPreference = new Preference(root.getContext());
addPreference.setKey(KEY_FINGERPRINT_ADD);
addPreference.setTitle(R.string.fingerprint_add_title);
addPreference.setIcon(R.drawable.ic_menu_add);
addPreference.setIcon(R.drawable.ic_add_24dp);
root.addPreference(addPreference);
addPreference.setOnPreferenceChangeListener(this);
updateAddPreference();

View File

@@ -29,6 +29,7 @@ import android.text.Html;
import android.text.TextUtils;
import android.util.Pair;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.VisibleForTesting;
@@ -170,6 +171,8 @@ public final class BluetoothDevicePreference extends GearPreference implements
final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
if (imageView != null) {
imageView.setContentDescription(contentDescription);
// Set property to prevent Talkback from reading out.
imageView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
imageView.setElevation(
getContext().getResources().getDimension(R.dimen.bt_icon_elevation));
}

View File

@@ -76,7 +76,7 @@ public class BluetoothPairingPreferenceController extends AbstractPreferenceCont
public Preference createBluetoothPairingPreference(int order) {
mPreference = new Preference(mFragment.getPreferenceScreen().getContext());
mPreference.setKey(KEY_PAIRING);
mPreference.setIcon(R.drawable.ic_menu_add);
mPreference.setIcon(R.drawable.ic_add_24dp);
mPreference.setOrder(order);
mPreference.setTitle(R.string.bluetooth_pairing_pref_title);

View File

@@ -29,6 +29,7 @@ import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -72,13 +73,18 @@ public class ForgetDeviceDialogFragment extends InstrumentedDialogFragment {
};
Context context = getContext();
mDevice = getDevice(context);
final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(
mDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
AlertDialog dialog = new AlertDialog.Builder(context)
.setPositiveButton(R.string.bluetooth_unpair_dialog_forget_confirm_button,
onConfirm)
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.setTitle(R.string.bluetooth_unpair_dialog_title);
dialog.setMessage(context.getString(R.string.bluetooth_unpair_dialog_body,
dialog.setMessage(context.getString(untetheredHeadset
? R.string.bluetooth_untethered_unpair_dialog_body
: R.string.bluetooth_unpair_dialog_body,
mDevice.getName()));
return dialog;
}

View File

@@ -31,6 +31,7 @@ import com.android.settings.notification.ZenOnboardingActivity;
import com.android.settings.notification.ZenSuggestionActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ScreenLockSuggestionActivity;
import com.android.settings.wallpaper.StyleSuggestionActivity;
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
import com.android.settings.wifi.calling.WifiCallingSuggestionActivity;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -62,6 +63,8 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
final String className = component.getClassName();
if (className.equals(WallpaperSuggestionActivity.class.getName())) {
return WallpaperSuggestionActivity.isSuggestionComplete(context);
} else if (className.equals(StyleSuggestionActivity.class.getName())) {
return StyleSuggestionActivity.isSuggestionComplete(context);
} else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
return FingerprintSuggestionActivity.isSuggestionComplete(context);
} else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {

View File

@@ -25,7 +25,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionPlan;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.Log;
import android.util.RecurrenceRule;
@@ -247,7 +246,7 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
summaryPreference.setChartEnabled(false);
} else {
summaryPreference.setChartEnabled(true);
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
summaryPreference.setLabels(DataUsageUtils.formatDataUsage(mContext, 0 /* sizeBytes */),
DataUsageUtils.formatDataUsage(mContext, mDataBarSize));
summaryPreference.setProgress(mDataplanUse / (float) mDataBarSize);
}

View File

@@ -19,7 +19,6 @@ package com.android.settings.datausage;
import android.app.Activity;
import android.net.NetworkTemplate;
import android.telephony.SubscriptionManager;
import android.text.format.Formatter;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -28,7 +27,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.net.DataUsageController;
/**
* The controller displays a data usage chart for the specified Wi-Fi network.
* The controller displays a data usage chart for the specified Wi-Fi network.
*/
public class WifiDataUsageSummaryPreferenceController extends DataUsageSummaryPreferenceController {
final String mNetworkId;
@@ -66,7 +65,7 @@ public class WifiDataUsageSummaryPreferenceController extends DataUsageSummaryPr
// TODO(b/126142293): Passpoint Wi-Fi should have limit of data usage and time remaining
mPreference.setProgress(100);
mPreference.setLabels(Formatter.formatFileSize(mContext, /* sizeBytes */ 0),
mPreference.setLabels(DataUsageUtils.formatDataUsage(mContext, /* sizeBytes */ 0),
DataUsageUtils.formatDataUsage(mContext, info.usageLevel));
}
}

View File

@@ -100,6 +100,9 @@ public class BatterySaverScheduleSeekBarController implements
}
public void addToScreen(PreferenceScreen screen) {
// makes sure it gets added after the preferences if called due to first time battery
// saver message
mSeekBarPreference.setOrder(5);
screen.addPreference(mSeekBarPreference);
}
}

View File

@@ -17,15 +17,20 @@
package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
import android.database.ContentObserver;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -51,8 +56,18 @@ import java.util.List;
public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
public BatterySaverScheduleRadioButtonsController mRadioButtonController;
@VisibleForTesting
Context mContext;
private BatterySaverScheduleSeekBarController mSeekBarController;
@VisibleForTesting
final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange, Uri uri) {
updateCandidates();
}
};
@Override
protected int getPreferenceScreenResId() {
return R.xml.battery_saver_schedule_settings;
@@ -64,6 +79,16 @@ public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
mSeekBarController = new BatterySaverScheduleSeekBarController(context);
mRadioButtonController = new BatterySaverScheduleRadioButtonsController(
context, mSeekBarController);
mContext = context;
}
@Override
public void onResume() {
super.onResume();
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED),
false,
mSettingsObserver);
}
@Override
@@ -78,6 +103,12 @@ public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
super.onCreate(savedInstanceState);
}
@Override
public void onPause() {
mContext.getContentResolver().unregisterContentObserver(mSettingsObserver);
super.onPause();
}
@Override
protected List<? extends CandidateInfo> getCandidates() {
Context context = getContext();

View File

@@ -20,12 +20,25 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.text.Annotation;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.URLSpan;
import android.view.View;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.FooterPreference;
import java.util.Arrays;
import java.util.List;
@@ -36,10 +49,14 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class BatterySaverSettings extends DashboardFragment {
private static final String TAG = "BatterySaverSettings";
public static final String KEY_FOOTER_PREFERENCE = "footer_preference";
private SpannableStringBuilder mFooterText;
private String mHelpUri;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
public void onStart() {
super.onStart();
setupFooter();
}
@Override
@@ -75,4 +92,82 @@ public class BatterySaverSettings extends DashboardFragment {
return Arrays.asList(sir);
}
};
// Updates the footer for this page.
@VisibleForTesting
void setupFooter() {
mFooterText = new SpannableStringBuilder(getText(
com.android.internal.R.string.battery_saver_description_with_learn_more));
mHelpUri = getString(R.string.help_url_battery_saver_settings);
if (!TextUtils.isEmpty(mHelpUri)) {
addHelpLink();
}
}
// Changes the text to include a learn more link if possible.
@VisibleForTesting
void addHelpLink() {
FooterPreference pref = getPreferenceScreen().findPreference(KEY_FOOTER_PREFERENCE);
if (pref != null) {
SupportPageLearnMoreSpan.linkify(mFooterText, this, mHelpUri);
pref.setTitle(mFooterText);
}
}
/**
* A {@link URLSpan} that opens a support page when clicked
*/
public static class SupportPageLearnMoreSpan extends URLSpan {
private static final String ANNOTATION_URL = "url";
private final Fragment mFragment;
private final String mUriString;
public SupportPageLearnMoreSpan(Fragment fragment, String uriString) {
// sets the url to empty string so we can prevent any other span processing from
// from clearing things we need in this string.
super("");
mFragment = fragment;
mUriString = uriString;
}
@Override
public void onClick(View widget) {
if (mFragment != null) {
// launch the support page
mFragment.startActivityForResult(HelpUtils.getHelpIntent(mFragment.getContext(),
mUriString, ""), 0);
}
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
// remove underline
ds.setUnderlineText(false);
}
/**
* This method takes a string and turns it into a url span that will launch a support page
* @param msg The text to turn into a link
* @param fragment The fragment which contains this span
* @param uriString The URI string of the help article to open when clicked
* @return A CharSequence containing the original text content as a url
*/
public static CharSequence linkify(Spannable msg, Fragment fragment, String uriString) {
Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
for (Annotation annotation : spans) {
int start = msg.getSpanStart(annotation);
int end = msg.getSpanEnd(annotation);
if (ANNOTATION_URL.equals(annotation.getValue())) {
SupportPageLearnMoreSpan link =
new SupportPageLearnMoreSpan(fragment, uriString);
msg.removeSpan(annotation);
msg.setSpan(link, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
return msg;
}
}
}

View File

@@ -42,11 +42,6 @@ public class SystemNavigationEdgeToEdgePreferenceController extends
super(context, overlayManager, key);
}
@Override
public boolean isSliceable() {
return TextUtils.equals(PREF_KEY_EDGE_TO_EDGE, getPreferenceKey());
}
@Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);

View File

@@ -42,11 +42,6 @@ public class SystemNavigationLegacyPreferenceController extends
super(context, overlayManager, key);
}
@Override
public boolean isSliceable() {
return TextUtils.equals(PREF_KEY_LEGACY, getPreferenceKey());
}
@Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);

View File

@@ -42,11 +42,6 @@ public class SystemNavigationSwipeUpPreferenceController extends
super(context, overlayManager, key);
}
@Override
public boolean isSliceable() {
return TextUtils.equals(PREF_KEY_SWIPE_UP, getPreferenceKey());
}
@Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);

View File

@@ -16,8 +16,6 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
import static com.android.settings.accounts.EmergencyInfoPreferenceController.ACTION_EDIT_EMERGENCY_INFO;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
@@ -29,6 +27,7 @@ import androidx.slice.builders.ListBuilder;
import androidx.slice.builders.SliceAction;
import com.android.settings.R;
import com.android.settings.accounts.EmergencyInfoPreferenceController;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
@@ -62,7 +61,7 @@ public class EmergencyInfoSlice implements CustomSliceable {
@Override
public Intent getIntent() {
return new Intent(ACTION_EDIT_EMERGENCY_INFO);
return new Intent(EmergencyInfoPreferenceController.getIntentAction(mContext));
}
@Override

View File

@@ -74,10 +74,10 @@ class SliceFullCardRendererHelper {
});
// Customize slice view for Settings
cardHolder.sliceView.showTitleItems(true);
cardHolder.sliceView.setShowTitleItems(true);
if (card.isLargeCard()) {
cardHolder.sliceView.showHeaderDivider(true);
cardHolder.sliceView.showActionDividers(true);
cardHolder.sliceView.setShowHeaderDivider(true);
cardHolder.sliceView.setShowActionDividers(true);
}
}

View File

@@ -154,7 +154,7 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem actionItem =
menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
.setIcon(R.drawable.ic_menu_add);
.setIcon(R.drawable.ic_add_24dp);
actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM |
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

View File

@@ -351,7 +351,7 @@ public class ApnSettings extends RestrictedSettingsFragment
if (mAllowAddingApns) {
menu.add(0, MENU_NEW, 0,
getResources().getString(R.string.menu_new))
.setIcon(R.drawable.ic_menu_add)
.setIcon(R.drawable.ic_add_24dp)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
menu.add(0, MENU_RESTORE, 0,

View File

@@ -28,6 +28,7 @@ import android.text.format.Formatter;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.datausage.DataUsageUtils;
import com.android.settingslib.net.DataUsageController;
/**
@@ -77,7 +78,7 @@ public class DataUsagePreferenceController extends TelephonyBasePreferenceContro
if (enabled) {
preference.setSummary(mContext.getString(R.string.data_usage_template,
Formatter.formatFileSize(mContext, mDataUsageInfo.usageLevel),
DataUsageUtils.formatDataUsage(mContext, mDataUsageInfo.usageLevel),
mDataUsageInfo.period));
}
}

View File

@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -77,7 +78,6 @@ public class DeleteSimProfileConfirmationDialog extends InstrumentedDialogFragme
@Override
public int getMetricsCategory() {
// TODO(b/131519375) - use a real id here once it's been created in the metrics proto
return 0;
return SettingsEnums.DIALOG_DELETE_SIM_CONFIRMATION;
}
}

View File

@@ -20,6 +20,7 @@ import android.app.Activity;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -114,7 +115,6 @@ public class DeleteSimProfileProgressDialog extends InstrumentedDialogFragment {
@Override
public int getMetricsCategory() {
// TODO(b/131519375) - use a real id here once it's been created in the metrics proto
return 0;
return SettingsEnums.DIALOG_DELETE_SIM_PROGRESS;
}
}

View File

@@ -21,10 +21,13 @@ import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
import android.app.Activity;
import android.app.Application;
import android.app.settings.SettingsEnums;
import android.app.usage.IUsageStatsManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.text.TextUtils;
@@ -112,7 +115,9 @@ public class ConfigureNotificationSettings extends DashboardFragment implements
lifecycle.addObserver(lockScreenNotificationController);
}
controllers.add(new RecentNotifyingAppsPreferenceController(
context, new NotificationBackend(), app, host));
context, new NotificationBackend(), IUsageStatsManager.Stub.asInterface(
ServiceManager.getService(Context.USAGE_STATS_SERVICE)),
context.getSystemService(UserManager.class), app, host));
controllers.add(lockScreenNotificationController);
controllers.add(new NotificationRingtonePreferenceController(context) {
@Override

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2019 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.notification;
import android.content.Context;
import android.provider.Settings;
import android.widget.ImageView;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.LayoutPreference;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
public class GentleDrawablePreferenceController extends BasePreferenceController {
@VisibleForTesting
static final int ON = 1;
private NotificationBackend mBackend;
public GentleDrawablePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mBackend = new NotificationBackend();
}
@VisibleForTesting
void setBackend(NotificationBackend backend) {
mBackend = backend;
}
@Override
public void updateState(Preference preference) {
LayoutPreference pref = (LayoutPreference) preference;
boolean showOnLockscreen = showOnLockscreen();
boolean showOnStatusBar = showOnStatusBar();
ImageView view = pref.findViewById(R.id.drawable);
if (showOnLockscreen) {
if (showOnStatusBar) {
view.setImageResource(R.drawable.gentle_notifications_shade_status_lock);
} else {
view.setImageResource(R.drawable.gentle_notifications_shade_lock);
}
} else if (showOnStatusBar) {
view.setImageResource(R.drawable.gentle_notifications_shade_status);
} else {
view.setImageResource(R.drawable.gentle_notifications_shade);
}
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
private boolean showOnLockscreen() {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == ON;
}
private boolean showOnStatusBar() {
return !mBackend.shouldHideSilentStatusBarIcons(mContext);
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2019 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.notification;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
import java.util.Arrays;
import java.util.List;
@SearchIndexable
public class GentleNotificationSettings extends DashboardFragment {
private static final String TAG = "GentleNotiSettings";
@Override
public int getMetricsCategory() {
return SettingsEnums.GENTLE_NOTIFICATIONS_SCREEN;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.gentle_notification_settings;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(SilentStatusBarPreferenceController.class).setListener(
shown -> updatePreferenceStates());
use(SilentLockscreenPreferenceController.class).setListener(
shown -> updatePreferenceStates());
}
/**
* For Search.
*/
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.gentle_notification_settings;
return Arrays.asList(sir);
}
};
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2019 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.notification;
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import androidx.annotation.VisibleForTesting;
public class GentleNotificationsPreferenceController extends BasePreferenceController {
@VisibleForTesting
static final int ON = 1;
private NotificationBackend mBackend;
public GentleNotificationsPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mBackend = new NotificationBackend();
}
@VisibleForTesting
void setBackend(NotificationBackend backend) {
mBackend = backend;
}
@Override
public CharSequence getSummary() {
boolean showOnLockscreen = showOnLockscreen();
boolean showOnStatusBar = showOnStatusBar();
if (showOnLockscreen) {
if (showOnStatusBar) {
return mContext.getString(
R.string.gentle_notifications_display_summary_shade_status_lock);
} else {
return mContext.getString(R.string.gentle_notifications_display_summary_shade_lock);
}
} else if (showOnStatusBar) {
return mContext.getString(R.string.gentle_notifications_display_summary_shade_status);
} else {
return mContext.getString(R.string.gentle_notifications_display_summary_shade);
}
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
private boolean showOnLockscreen() {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == ON;
}
private boolean showOnStatusBar() {
return !mBackend.shouldHideSilentStatusBarIcons(mContext);
}
}

View File

@@ -312,15 +312,6 @@ public class NotificationBackend {
}
}
public List<NotifyingApp> getRecentApps() {
try {
return sINM.getRecentNotifyingAppsForUser(UserHandle.myUserId()).getList();
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return new ArrayList<>();
}
}
public int getBlockedAppCount() {
try {
return sINM.getBlockedAppCount(UserHandle.myUserId());

View File

@@ -18,11 +18,15 @@ package com.android.settings.notification;
import android.app.Application;
import android.app.settings.SettingsEnums;
import android.app.usage.IUsageStatsManager;
import android.app.usage.UsageEvents;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.notification.NotifyingApp;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -30,13 +34,8 @@ import android.util.ArraySet;
import android.util.IconDrawableFactory;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
@@ -47,11 +46,18 @@ import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.utils.StringUtil;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
/**
* This controller displays a list of recently used apps and a "See all" button. If there is
* no recently used app, "See all" will be displayed as "Notifications".
@@ -66,28 +72,35 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
@VisibleForTesting
static final String KEY_SEE_ALL = "all_notifications";
private static final int SHOW_RECENT_APP_COUNT = 5;
private static final int DAYS = 3;
private static final Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>();
private final Fragment mHost;
private final PackageManager mPm;
private final NotificationBackend mNotificationBackend;
private IUsageStatsManager mUsageStatsManager;
private final int mUserId;
private final IconDrawableFactory mIconDrawableFactory;
private List<NotifyingApp> mApps;
private Calendar mCal;
List<NotifyingApp> mApps;
private final ApplicationsState mApplicationsState;
private PreferenceCategory mCategory;
private Preference mSeeAllPref;
private Preference mDivider;
protected List<Integer> mUserIds;
public RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
IUsageStatsManager usageStatsManager, UserManager userManager,
Application app, Fragment host) {
this(context, backend, app == null ? null : ApplicationsState.getInstance(app), host);
this(context, backend, usageStatsManager, userManager,
app == null ? null : ApplicationsState.getInstance(app), host);
}
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
IUsageStatsManager usageStatsManager, UserManager userManager,
ApplicationsState appState, Fragment host) {
super(context);
mIconDrawableFactory = IconDrawableFactory.newInstance(context);
@@ -96,6 +109,13 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
mHost = host;
mApplicationsState = appState;
mNotificationBackend = backend;
mUsageStatsManager = usageStatsManager;
mUserIds = new ArrayList<>();
mUserIds.add(mContext.getUserId());
int workUserId = Utils.getManagedProfileId(userManager, mContext.getUserId());
if (workUserId != UserHandle.USER_NULL) {
mUserIds.add(workUserId);
}
}
@Override
@@ -145,7 +165,48 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
@VisibleForTesting
void reloadData() {
mApps = mNotificationBackend.getRecentApps();
mApps = new ArrayList<>();
mCal = Calendar.getInstance();
mCal.add(Calendar.DAY_OF_YEAR, -DAYS);
for (int userId : mUserIds) {
UsageEvents events = null;
try {
events = mUsageStatsManager.queryEventsForUser(mCal.getTimeInMillis(),
System.currentTimeMillis(), userId, mContext.getPackageName());
} catch (RemoteException e) {
e.printStackTrace();
}
if (events != null) {
ArrayMap<String, NotifyingApp> aggregatedStats = new ArrayMap<>();
UsageEvents.Event event = new UsageEvents.Event();
while (events.hasNextEvent()) {
events.getNextEvent(event);
if (event.getEventType() == UsageEvents.Event.NOTIFICATION_INTERRUPTION) {
NotifyingApp app =
aggregatedStats.get(getKey(userId, event.getPackageName()));
if (app == null) {
app = new NotifyingApp();
aggregatedStats.put(getKey(userId, event.getPackageName()), app);
app.setPackage(event.getPackageName());
app.setUserId(userId);
}
if (event.getTimeStamp() > app.getLastNotified()) {
app.setLastNotified(event.getTimeStamp());
}
}
}
mApps.addAll(aggregatedStats.values());
}
}
}
private static String getKey(int userId, String pkg) {
return userId + "|" + pkg;
}
private void displayOnlyAllAppsLink() {
@@ -185,7 +246,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
// Bind recent apps to existing prefs if possible, or create a new pref.
final String pkgName = app.getPackage();
final ApplicationsState.AppEntry appEntry =
mApplicationsState.getEntry(app.getPackage(), mUserId);
mApplicationsState.getEntry(app.getPackage(), app.getUserId());
if (appEntry == null) {
continue;
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2019 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.notification;
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
import com.android.settings.core.TogglePreferenceController;
import com.google.common.annotations.VisibleForTesting;
public class SilentLockscreenPreferenceController extends TogglePreferenceController {
private static final String KEY = "lock_screen";
private Listener mListener;
public SilentLockscreenPreferenceController(Context context) {
super(context, KEY);
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, isChecked ? 1 : 0);
if (mListener != null) {
mListener.onChange(isChecked);
}
return true;
}
@Override
public int getAvailabilityStatus() {
return Settings.Secure.getInt(
mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1) != 0
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
public void setListener(Listener listener) {
mListener = listener;
}
interface Listener {
void onChange(boolean shown);
}
}

View File

@@ -28,9 +28,10 @@ import com.google.common.annotations.VisibleForTesting;
public class SilentStatusBarPreferenceController extends TogglePreferenceController {
private static final String KEY = "hide_silent_icons";
private static final String KEY = "silent_icons";
private static final int MY_USER_ID = UserHandle.myUserId();
private NotificationBackend mBackend;
private Listener mListener;
public SilentStatusBarPreferenceController(Context context) {
super(context, KEY);
@@ -44,12 +45,15 @@ public class SilentStatusBarPreferenceController extends TogglePreferenceControl
@Override
public boolean isChecked() {
return mBackend.shouldHideSilentStatusBarIcons(mContext);
return !mBackend.shouldHideSilentStatusBarIcons(mContext);
}
@Override
public boolean setChecked(boolean isChecked) {
mBackend.setHideSilentStatusIcons(isChecked);
mBackend.setHideSilentStatusIcons(!isChecked);
if (mListener != null) {
mListener.onChange(isChecked);
}
return true;
}
@@ -60,6 +64,14 @@ public class SilentStatusBarPreferenceController extends TogglePreferenceControl
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
public void setListener(Listener listener) {
mListener = listener;
}
interface Listener {
void onChange(boolean shown);
}
}

View File

@@ -242,7 +242,7 @@ public class PrintSettingsFragment extends ProfileSettingsPreferenceFragment
}
Preference preference = new Preference(getPrefContext());
preference.setTitle(R.string.print_menu_item_add_service);
preference.setIcon(R.drawable.ic_menu_add);
preference.setIcon(R.drawable.ic_add_24dp);
preference.setOrder(ORDER_LAST);
preference.setIntent(addNewServiceIntent);
preference.setPersistent(false);

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2019 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.wallpaper;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
public class StyleSuggestionActivity extends StyleSuggestionActivityBase {
@VisibleForTesting
public static boolean isSuggestionComplete(Context context) {
if (!isWallpaperServiceEnabled(context)) {
return true;
}
final String currentTheme = Settings.Secure.getStringForUser(context.getContentResolver(),
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, context.getUserId());
if (TextUtils.isEmpty(currentTheme)) {
// Empty value means the user has not visited the styles tab yet
return false;
}
return true;
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2019 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.wallpaper;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.display.WallpaperPreferenceController;
import com.google.android.setupcompat.util.WizardManagerHelper;
public abstract class StyleSuggestionActivityBase extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PackageManager pm = getPackageManager();
final Intent intent = new Intent()
.setComponent(new WallpaperPreferenceController(this, "dummy key")
.getComponentName())
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
// passing the necessary extra to next page
WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
addExtras(intent);
if (pm.resolveActivity(intent, 0) != null) {
startActivity(intent);
} else {
startFallbackSuggestion();
}
finish();
}
/**
* Add any extras to the intent before launching the wallpaper activity
* @param intent
*/
protected void addExtras(Intent intent) { }
@VisibleForTesting
void startFallbackSuggestion() {
// fall back to default wallpaper picker
new SubSettingLauncher(this)
.setDestination(WallpaperTypeSettings.class.getName())
.setTitleRes(R.string.wallpaper_suggestion_title)
.setSourceMetricsCategory(SettingsEnums.DASHBOARD_SUMMARY)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.launch();
}
protected static boolean isWallpaperServiceEnabled(Context context) {
return context.getResources().getBoolean(
com.android.internal.R.bool.config_enableWallpaperService);
}
}

View File

@@ -16,63 +16,31 @@
package com.android.settings.wallpaper;
import android.app.Activity;
import android.app.WallpaperManager;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.display.WallpaperPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
import com.google.android.setupcompat.util.WizardManagerHelper;
import java.util.ArrayList;
import java.util.List;
@SearchIndexable
public class WallpaperSuggestionActivity extends Activity implements Indexable {
public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase implements Indexable {
private static final String WALLPAPER_FLAVOR_EXTRA = "com.android.launcher3.WALLPAPER_FLAVOR";
private static final String WALLPAPER_FOCUS = "focus_wallpaper";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PackageManager pm = getPackageManager();
final Intent intent = new Intent()
.setComponent(new WallpaperPreferenceController(this, "dummy key")
.getComponentName())
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
// passing the necessary extra to next page
WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
if (pm.resolveActivity(intent, 0) != null) {
startActivity(intent);
} else {
startFallbackSuggestion();
}
finish();
}
@VisibleForTesting
void startFallbackSuggestion() {
// fall back to default wallpaper picker
new SubSettingLauncher(this)
.setDestination(WallpaperTypeSettings.class.getName())
.setTitleRes(R.string.wallpaper_suggestion_title)
.setSourceMetricsCategory(SettingsEnums.DASHBOARD_SUMMARY)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.launch();
protected void addExtras(Intent intent) {
intent.putExtra(WALLPAPER_FLAVOR_EXTRA, WALLPAPER_FOCUS);
}
@VisibleForTesting
@@ -85,11 +53,6 @@ public class WallpaperSuggestionActivity extends Activity implements Indexable {
return manager.getWallpaperId(WallpaperManager.FLAG_SYSTEM) > 0;
}
private static boolean isWallpaperServiceEnabled(Context context) {
return context.getResources().getBoolean(
com.android.internal.R.bool.config_enableWallpaperService);
}
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
private static final String SUPPORT_SEARCH_INDEX_KEY = "wallpaper_type";

View File

@@ -43,7 +43,7 @@ public class AddWifiNetworkPreference extends Preference {
setLayoutResource(com.android.settingslib.R.layout.preference_access_point);
setWidgetLayoutResource(R.layout.wifi_button_preference_widget);
setIcon(R.drawable.ic_menu_add);
setIcon(R.drawable.ic_add_24dp);
setTitle(R.string.wifi_add_network);
mScanIconDrawable = getDrawable(R.drawable.ic_scan_24dp);

View File

@@ -148,7 +148,7 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
mFakeNetworkPreference.setTitle("fake network");
mAddPreference = new Preference(getPrefContext());
mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setIcon(R.drawable.ic_add_24dp);
mAddPreference.setTitle(R.string.wifi_add_network);
mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());

View File

@@ -24,6 +24,7 @@
<item>@drawable/ic_android</item>
<item>@drawable/ic_apps</item>
<item>@drawable/ic_arrow_back</item>
<item>@drawable/ic_arrow_down_24dp</item>
<item>@drawable/ic_battery_charging_full</item>
<item>@drawable/ic_battery_saver_accent_24dp</item>
<item>@drawable/ic_battery_status_bad_24dp</item>
@@ -33,6 +34,7 @@
<item>@drawable/ic_cancel</item>
<item>@drawable/ic_cast_24dp</item>
<item>@drawable/ic_cellular_off</item>
<item>@drawable/ic_chevron_right_24dp</item>
<item>@drawable/ic_content_copy_grey600_24dp</item>
<item>@drawable/ic_data_saver</item>
<item>@drawable/ic_delete</item>
@@ -48,10 +50,11 @@
<item>@drawable/ic_gray_scale_24dp</item>
<item>@drawable/ic_headset_24dp</item>
<item>@drawable/ic_help</item>
<item>@drawable/ic_help_actionbar</item>
<item>@drawable/ic_homepage_search</item>
<item>@drawable/ic_info_outline_24</item>
<item>@drawable/ic_local_movies</item>
<item>@drawable/ic_local_phone_24_lib</item>
<item>@drawable/ic_lock</item>
<item>@drawable/ic_media_stream</item>
<item>@drawable/ic_media_stream_off</item>
<item>@drawable/ic_network_cell</item>
@@ -59,8 +62,11 @@
<item>@drawable/ic_notifications_off_24dp</item>
<item>@drawable/ic_phone_info</item>
<item>@drawable/ic_photo_library</item>
<item>@drawable/ic_search_24dp</item>
<item>@drawable/ic_settings_accent</item>
<item>@drawable/ic_settings_accessibility</item>
<item>@drawable/ic_settings_accounts</item>
<item>@drawable/ic_settings_backup</item>
<item>@drawable/ic_settings_battery_white</item>
<item>@drawable/ic_settings_data_usage</item>
<item>@drawable/ic_settings_date_time</item>
@@ -77,12 +83,14 @@
<item>@drawable/ic_settings_system_dashboard_white</item>
<item>@drawable/ic_settings_wireless</item>
<item>@drawable/ic_settings_wireless_white</item>
<item>@drawable/ic_storage</item>
<item>@drawable/ic_storage_white</item>
<item>@drawable/ic_suggestion_night_display</item>
<item>@drawable/ic_sync</item>
<item>@drawable/ic_system_update</item>
<item>@drawable/ic_videogame_vd_theme_24</item>
<item>@drawable/ic_volume_ringer_vibrate</item>
<item>@drawable/ic_volume_up_24dp</item>
<item>@drawable/ic_vpn_key</item>
<item>@drawable/ic_wifi_tethering</item>
</array>
</resources>

View File

@@ -73,7 +73,7 @@ public class BluetoothPairingPreferenceControllerTest {
Preference pref = mController.createBluetoothPairingPreference(ORDER);
assertThat(pref.getKey()).isEqualTo(BluetoothPairingPreferenceController.KEY_PAIRING);
DrawableTestHelper.assertDrawableResId(pref.getIcon(), R.drawable.ic_menu_add);
DrawableTestHelper.assertDrawableResId(pref.getIcon(), R.drawable.ic_add_24dp);
assertThat(pref.getOrder()).isEqualTo(ORDER);
assertThat(pref.getTitle())
.isEqualTo(mContext.getString(R.string.bluetooth_pairing_pref_title));

View File

@@ -25,10 +25,15 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import org.junit.Before;
@@ -39,33 +44,46 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowAlertDialogCompat.class})
public class ForgetDeviceDialogFragmentTest {
private static final String DEVICE_NAME = "Nightshade";
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private CachedBluetoothDevice mCachedDevice;
@Mock
private BluetoothDevice mBluetoothDevice;
private ForgetDeviceDialogFragment mFragment;
private FragmentActivity mActivity;
private AlertDialog mDialog;
private Context mContext;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
FakeFeatureFactory.setupForTest();
String deviceAddress = "55:66:77:88:99:AA";
when(mCachedDevice.getAddress()).thenReturn(deviceAddress);
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
when(mCachedDevice.getName()).thenReturn(DEVICE_NAME);
mFragment = spy(ForgetDeviceDialogFragment.newInstance(deviceAddress));
doReturn(mCachedDevice).when(mFragment).getDevice(any());
mActivity = Robolectric.setupActivity(FragmentActivity.class);
mActivity.getSupportFragmentManager().beginTransaction().add(mFragment, null).commit();
mDialog = (AlertDialog) ShadowDialog.getLatestDialog();
}
@Test
public void cancelDialog() {
initDialog();
mDialog.getButton(AlertDialog.BUTTON_NEGATIVE).performClick();
verify(mCachedDevice, never()).unpair();
assertThat(mActivity.isFinishing()).isFalse();
@@ -73,8 +91,43 @@ public class ForgetDeviceDialogFragmentTest {
@Test
public void confirmDialog() {
initDialog();
mDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
verify(mCachedDevice).unpair();
assertThat(mActivity.isFinishing()).isTrue();
}
@Test
public void createDialog_untetheredDevice_showUntetheredMessage() {
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
FragmentController.setupFragment(mFragment, FragmentActivity.class,
0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mContext.getString(R.string.bluetooth_untethered_unpair_dialog_body, DEVICE_NAME));
}
@Test
public void createDialog_normalDevice_showNormalMessage() {
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("false".getBytes());
FragmentController.setupFragment(mFragment, FragmentActivity.class,
0 /* containerViewId */, null /* bundle */);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mContext.getString(R.string.bluetooth_unpair_dialog_body, DEVICE_NAME));
}
private void initDialog() {
mActivity.getSupportFragmentManager().beginTransaction().add(mFragment, null).commit();
mDialog = (AlertDialog) ShadowDialog.getLatestDialog();
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.settings.fuelgauge.batterysaver;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import androidx.preference.PreferenceScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class BatterySaverSettingsTest {
BatterySaverSettings mFragment;
@Mock
PreferenceScreen mScreen;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mFragment = spy(new BatterySaverSettings());
doReturn(mScreen).when(mFragment).getPreferenceScreen();
}
@Test
public void setupFooter_linkAddedWhenAppropriate() {
doReturn("").when(mFragment).getText(anyInt());
doReturn("").when(mFragment).getString(anyInt());
mFragment.setupFooter();
verify(mFragment, never()).addHelpLink();
doReturn("testString").when(mFragment).getText(anyInt());
doReturn("testString").when(mFragment).getString(anyInt());
mFragment.setupFooter();
verify(mFragment, atLeastOnce()).addHelpLink();
}
}

View File

@@ -180,8 +180,8 @@ public class SystemNavigationEdgeToEdgePreferenceControllerTest {
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
assertThat(mController.isSliceable()).isTrue();
public void isSliceable_returnsFalse() {
assertThat(mController.isSliceable()).isFalse();
}
@Test

View File

@@ -182,8 +182,8 @@ public class SystemNavigationLegacyPreferenceControllerTest {
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
assertThat(mController.isSliceable()).isTrue();
public void isSliceable_returnsFalse() {
assertThat(mController.isSliceable()).isFalse();
}
@Test

View File

@@ -180,8 +180,8 @@ public class SystemNavigationSwipeUpPreferenceControllerTest {
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
assertThat(mController.isSliceable()).isTrue();
public void isSliceable_returnsFalse() {
assertThat(mController.isSliceable()).isFalse();
}
@Test

View File

@@ -18,20 +18,15 @@ package com.android.settings.network.telephony;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.app.usage.NetworkStats;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
import android.content.Intent;
import android.net.TrafficStats;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -114,16 +109,24 @@ public class DataUsagePreferenceControllerTest {
}
@Test
public void updateState_noUsageData_shouldDisablePreference() throws Exception {
final NetworkStatsManager networkStatsManager = mock(NetworkStatsManager.class);
when(networkStatsManager.querySummaryForDevice(anyInt() /* networkType */,
anyString() /* subscriberId */, anyLong() /* startTime */, anyLong() /* endTime */))
.thenReturn(mock(NetworkStats.Bucket.class));
public void updateState_noUsageData_shouldDisablePreference() {
ReflectionHelpers.setField(
mController, "mDataUsageInfo", new DataUsageController.DataUsageInfo());
mController, "mDataUsageInfo", new DataUsageController.DataUsageInfo());
mController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isFalse();
}
@Test
public void updateState_shouldUseIECUnit() {
final DataUsageController.DataUsageInfo usageInfo = new DataUsageController.DataUsageInfo();
usageInfo.usageLevel = TrafficStats.MB_IN_BYTES;
ReflectionHelpers.setField(mController, "mDataUsageInfo", usageInfo);
mController.updateState(mPreference);
assertThat(mPreference.getSummary().toString())
.contains("1.00 MB");
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (C) 2019 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.notification;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.provider.Settings;
import android.widget.ImageView;
import com.android.settings.R;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.Preference;
@RunWith(RobolectricTestRunner.class)
public class GentleDrawablePreferenceControllerTest {
private Context mContext;
private GentleDrawablePreferenceController mController;
@Mock
private LayoutPreference mPreference;
@Mock
NotificationBackend mBackend;
@Mock
ImageView mView;
private static final String KEY = "gentle_notifications";
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new GentleDrawablePreferenceController(mContext, KEY);
mController.setBackend(mBackend);
when(mPreference.findViewById(R.id.drawable)).thenReturn(mView);
}
@Test
public void display_shouldDisplay() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void updateState_lock() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(true);
mController.updateState(mPreference);
verify(mView).setImageResource(R.drawable.gentle_notifications_shade_lock);
}
@Test
public void updateState_status() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(false);
mController.updateState(mPreference);
verify(mView).setImageResource(R.drawable.gentle_notifications_shade_status);
}
@Test
public void updateState_both() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(false);
mController.updateState(mPreference);
verify(mView).setImageResource(R.drawable.gentle_notifications_shade_status_lock);
}
@Test
public void updateState_neither() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(true);
mController.updateState(mPreference);
verify(mView).setImageResource(R.drawable.gentle_notifications_shade);
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2019 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.notification;
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
import static com.android.settings.notification.BadgingNotificationPreferenceController.OFF;
import static com.android.settings.notification.BadgingNotificationPreferenceController.ON;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.Preference;
@RunWith(RobolectricTestRunner.class)
public class GentleNotificationsPreferenceControllerTest {
private Context mContext;
@Mock
NotificationBackend mBackend;
private GentleNotificationsPreferenceController mController;
private Preference mPreference;
private static final String KEY = "gentle_notifications";
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new GentleNotificationsPreferenceController(mContext, KEY);
mController.setBackend(mBackend);
mPreference = new Preference(mContext);
}
@Test
public void display_shouldDisplay() {
assertThat(mPreference.isVisible()).isTrue();
}
@Test
public void getSummary_lock() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(true);
assertThat(mController.getSummary()).isEqualTo(
mContext.getString(R.string.gentle_notifications_display_summary_shade_lock));
}
@Test
public void getSummary_status() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(false);
assertThat(mController.getSummary()).isEqualTo(
mContext.getString(R.string.gentle_notifications_display_summary_shade_status));
}
@Test
public void getSummary_both() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(false);
assertThat(mController.getSummary()).isEqualTo(mContext.getString(
R.string.gentle_notifications_display_summary_shade_status_lock));
}
@Test
public void getSummary_neither() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
when(mBackend.shouldHideSilentStatusBarIcons(mContext)).thenReturn(true);
assertThat(mController.getSummary()).isEqualTo(
mContext.getString(R.string.gentle_notifications_display_summary_shade));
}
}

View File

@@ -20,8 +20,10 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -31,22 +33,20 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.usage.IUsageStatsManager;
import android.app.usage.UsageEvents;
import android.app.usage.UsageEvents.Event;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Parcel;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.notification.NotifyingApp;
import android.text.TextUtils;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
@@ -67,6 +67,12 @@ import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@RunWith(RobolectricTestRunner.class)
public class RecentNotifyingAppsPreferenceControllerTest {
@@ -94,6 +100,8 @@ public class RecentNotifyingAppsPreferenceControllerTest {
private Fragment mHost;
@Mock
private FragmentActivity mActivity;
@Mock
private IUsageStatsManager mIUsageStatsManager;
private Context mContext;
private RecentNotifyingAppsPreferenceController mController;
@@ -104,9 +112,10 @@ public class RecentNotifyingAppsPreferenceControllerTest {
mContext = spy(RuntimeEnvironment.application);
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
doReturn(mPackageManager).when(mContext).getPackageManager();
when(mUserManager.getProfileIdsWithDisabled(0)).thenReturn(new int[] {0});
mController = new RecentNotifyingAppsPreferenceController(
mContext, mBackend, mAppState, mHost);
mContext, mBackend, mIUsageStatsManager, mUserManager, mAppState, mHost);
when(mScreen.findPreference(anyString())).thenReturn(mCategory);
when(mScreen.findPreference(RecentNotifyingAppsPreferenceController.KEY_SEE_ALL))
@@ -135,7 +144,7 @@ public class RecentNotifyingAppsPreferenceControllerTest {
@Test
public void onDisplayAndUpdateState_shouldRefreshUi() {
mController = spy(new RecentNotifyingAppsPreferenceController(
mContext, null, (ApplicationsState) null, null));
mContext, null, mIUsageStatsManager, mUserManager, (ApplicationsState) null, null));
doNothing().when(mController).refreshUi(mContext);
@@ -158,32 +167,41 @@ public class RecentNotifyingAppsPreferenceControllerTest {
}
@Test
public void display_showRecents() {
final List<NotifyingApp> apps = new ArrayList<>();
final NotifyingApp app1 = new NotifyingApp()
.setPackage("pkg.class")
.setLastNotified(System.currentTimeMillis());
final NotifyingApp app2 = new NotifyingApp()
.setLastNotified(System.currentTimeMillis())
.setPackage("com.android.settings");
final NotifyingApp app3 = new NotifyingApp()
.setLastNotified(System.currentTimeMillis() - 1000)
.setPackage("pkg.class2");
public void display_showRecents() throws Exception {
apps.add(app1);
apps.add(app2);
apps.add(app3);
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
app.mPackage = "a";
app.mTimeStamp = System.currentTimeMillis();
events.add(app);
Event app1 = new Event();
app1.mEventType = Event.NOTIFICATION_INTERRUPTION;
app1.mPackage = "com.android.settings";
app1.mTimeStamp = System.currentTimeMillis();
events.add(app1);
Event app2 = new Event();
app2.mEventType = Event.NOTIFICATION_INTERRUPTION;
app2.mPackage = "pkg.class2";
app2.mTimeStamp = System.currentTimeMillis() - 1000;
events.add(app2);
// app1, app2 are valid apps. app3 is invalid.
when(mAppState.getEntry(app1.getPackage(), UserHandle.myUserId()))
when(mAppState.getEntry(app.getPackageName(), UserHandle.myUserId()))
.thenReturn(mAppEntry);
when(mAppState.getEntry(app2.getPackage(), UserHandle.myUserId()))
when(mAppState.getEntry(app1.getPackageName(), UserHandle.myUserId()))
.thenReturn(mAppEntry);
when(mAppState.getEntry(app3.getPackage(), UserHandle.myUserId()))
when(mAppState.getEntry(app2.getPackageName(), UserHandle.myUserId()))
.thenReturn(null);
when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
new ResolveInfo());
when(mBackend.getRecentApps()).thenReturn(apps);
UsageEvents usageEvents = getUsageEvents(
new String[] {app.getPackageName(), app1.getPackageName(), app2.getPackageName()},
events);
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString()))
.thenReturn(usageEvents);
mAppEntry.info = mApplicationInfo;
mController.displayPreference(mScreen);
@@ -198,34 +216,37 @@ public class RecentNotifyingAppsPreferenceControllerTest {
}
@Test
public void display_showRecentsWithInstantApp() {
// Regular app.
final List<NotifyingApp> apps = new ArrayList<>();
final NotifyingApp app1 = new NotifyingApp().
setLastNotified(System.currentTimeMillis())
.setPackage("com.foo.bar");
apps.add(app1);
// Instant app.
final NotifyingApp app2 = new NotifyingApp()
.setLastNotified(System.currentTimeMillis() + 200)
.setPackage("com.foo.barinstant");
apps.add(app2);
public void display_showRecentsWithInstantApp() throws Exception {
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
app.mPackage = "com.foo.bar";
app.mTimeStamp = System.currentTimeMillis();
events.add(app);
Event app1 = new Event();
app1.mEventType = Event.NOTIFICATION_INTERRUPTION;
app1.mPackage = "com.foo.barinstant";
app1.mTimeStamp = System.currentTimeMillis() + 200;
events.add(app1);
UsageEvents usageEvents = getUsageEvents(
new String[] {"com.foo.bar", "com.foo.barinstant"}, events);
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString()))
.thenReturn(usageEvents);
ApplicationsState.AppEntry app1Entry = mock(ApplicationsState.AppEntry.class);
ApplicationsState.AppEntry app2Entry = mock(ApplicationsState.AppEntry.class);
app1Entry.info = mApplicationInfo;
app2Entry.info = mApplicationInfo;
when(mAppState.getEntry(app1.getPackage(), UserHandle.myUserId())).thenReturn(app1Entry);
when(mAppState.getEntry(app2.getPackage(), UserHandle.myUserId())).thenReturn(app2Entry);
when(mAppState.getEntry(
app.getPackageName(), UserHandle.myUserId())).thenReturn(app1Entry);
when(mAppState.getEntry(
app1.getPackageName(), UserHandle.myUserId())).thenReturn(app2Entry);
// Only the regular app app1 should have its intent resolve.
when(mPackageManager.resolveActivity(argThat(intentMatcher(app1.getPackage())),
when(mPackageManager.resolveActivity(argThat(intentMatcher(app.getPackageName())),
anyInt())).thenReturn(new ResolveInfo());
when(mBackend.getRecentApps()).thenReturn(apps);
// Make sure app2 is considered an instant app.
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
(InstantAppDataProvider) (ApplicationInfo info) -> {
@@ -241,23 +262,27 @@ public class RecentNotifyingAppsPreferenceControllerTest {
ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
verify(mCategory, times(2)).addPreference(prefCaptor.capture());
List<Preference> prefs = prefCaptor.getAllValues();
assertThat(prefs.get(1).getKey()).isEqualTo(app1.getPackage());
assertThat(prefs.get(0).getKey()).isEqualTo(app2.getPackage());
assertThat(prefs.get(1).getKey()).isEqualTo(app.getPackageName());
assertThat(prefs.get(0).getKey()).isEqualTo(app1.getPackageName());
}
@Test
public void display_showRecents_formatSummary() {
final List<NotifyingApp> apps = new ArrayList<>();
final NotifyingApp app1 = new NotifyingApp()
.setLastNotified(System.currentTimeMillis())
.setPackage("pkg.class");
apps.add(app1);
public void display_showRecents_formatSummary() throws Exception {
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
app.mPackage = "pkg.class";
app.mTimeStamp = System.currentTimeMillis();
events.add(app);
UsageEvents usageEvents = getUsageEvents(new String[] {"pkg.class"}, events);
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString()))
.thenReturn(usageEvents);
when(mAppState.getEntry(app1.getPackage(), UserHandle.myUserId()))
when(mAppState.getEntry(app.getPackageName(), UserHandle.myUserId()))
.thenReturn(mAppEntry);
when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
new ResolveInfo());
when(mBackend.getRecentApps()).thenReturn(apps);
mAppEntry.info = mApplicationInfo;
mController.displayPreference(mScreen);
@@ -265,6 +290,66 @@ public class RecentNotifyingAppsPreferenceControllerTest {
verify(mCategory).addPreference(argThat(summaryMatches("Just now")));
}
@Test
public void reloadData() throws Exception {
when(mUserManager.getProfileIdsWithDisabled(0)).thenReturn(new int[] {0, 10});
mController = new RecentNotifyingAppsPreferenceController(
mContext, mBackend, mIUsageStatsManager, mUserManager, mAppState, mHost);
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
app.mPackage = "b";
app.mTimeStamp = 1;
events.add(app);
Event app1 = new Event();
app1.mEventType = Event.MAX_EVENT_TYPE;
app1.mPackage = "com.foo.bar";
app1.mTimeStamp = 10;
events.add(app1);
UsageEvents usageEvents = getUsageEvents(
new String[] {"b", "com.foo.bar"}, events);
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), eq(0), anyString()))
.thenReturn(usageEvents);
List<Event> events10 = new ArrayList<>();
Event app10 = new Event();
app10.mEventType = Event.NOTIFICATION_INTERRUPTION;
app10.mPackage = "a";
app10.mTimeStamp = 2;
events10.add(app10);
Event app10a = new Event();
app10a.mEventType = Event.NOTIFICATION_INTERRUPTION;
app10a.mPackage = "a";
app10a.mTimeStamp = 20;
events10.add(app10a);
UsageEvents usageEvents10 = getUsageEvents(
new String[] {"a"}, events10);
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), eq(10), anyString()))
.thenReturn(usageEvents10);
mController.reloadData();
assertThat(mController.mApps.size()).isEqualTo(2);
boolean foundPkg0 = false;
boolean foundPkg10 = false;
for (NotifyingApp notifyingApp : mController.mApps) {
if (notifyingApp.getLastNotified() == 20
&& notifyingApp.getPackage().equals("a")
&& notifyingApp.getUserId() == 10) {
foundPkg10 = true;
}
if (notifyingApp.getLastNotified() == 1
&& notifyingApp.getPackage().equals("b")
&& notifyingApp.getUserId() == 0) {
foundPkg0 = true;
}
}
assertThat(foundPkg0).isTrue();
assertThat(foundPkg10).isTrue();
}
private static ArgumentMatcher<Preference> summaryMatches(String expected) {
return preference -> TextUtils.equals(expected, preference.getSummary());
}
@@ -273,4 +358,13 @@ public class RecentNotifyingAppsPreferenceControllerTest {
private static ArgumentMatcher<Intent> intentMatcher(String packageName) {
return intent -> packageName.equals(intent.getPackage());
}
private UsageEvents getUsageEvents(String[] pkgs, List<Event> events) {
UsageEvents usageEvents = new UsageEvents(events, pkgs);
Parcel parcel = Parcel.obtain();
parcel.setDataPosition(0);
usageEvents.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
return UsageEvents.CREATOR.createFromParcel(parcel);
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright (C) 2019 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.notification;
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.provider.Settings;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@RunWith(RobolectricTestRunner.class)
public class SilentLockscreenPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
private Context mContext;
private SilentLockscreenPreferenceController mController;
private Preference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new SilentLockscreenPreferenceController(mContext);
mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
@Test
public void isAvailable_featureEnabled() {
Settings.Secure.putInt(
mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void isAvailable_featureDisabled() {
Settings.Secure.putInt(
mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isChecked_settingIsOff_false() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
assertThat(mController.isChecked()).isFalse();
}
@Test
public void isChecked_settingIsOn_true() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
assertThat(mController.isChecked()).isTrue();
}
@Test
public void onPreferenceChange_on() {
mController.onPreferenceChange(mPreference, true);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0)).isEqualTo(1);
}
@Test
public void onPreferenceChange_off() {
mController.onPreferenceChange(mPreference, false);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1)).isEqualTo(0);
}
@Test
public void listenerTriggered() {
SilentLockscreenPreferenceController.Listener listener = mock(
SilentLockscreenPreferenceController.Listener.class);
mController.setListener(listener);
mController.setChecked(false);
verify(listener).onChange(false);
mController.setChecked(true);
verify(listener).onChange(true);
}
}

View File

@@ -21,6 +21,7 @@ import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MOD
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -79,26 +80,39 @@ public class SilentStatusBarPreferenceControllerTest {
@Test
public void isChecked_settingIsOff_false() {
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(false);
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(true);
assertThat(mController.isChecked()).isFalse();
}
@Test
public void isChecked_settingIsOn_true() {
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(true);
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(false);
assertThat(mController.isChecked()).isTrue();
}
@Test
public void onPreferenceChange_on() {
mController.onPreferenceChange(mPreference, true);
verify(mBackend).setHideSilentStatusIcons(true);
verify(mBackend).setHideSilentStatusIcons(false);
}
@Test
public void onPreferenceChange_off() {
mController.onPreferenceChange(mPreference, false);
verify(mBackend).setHideSilentStatusIcons(false);
verify(mBackend).setHideSilentStatusIcons(true);
}
@Test
public void listenerTriggered() {
SilentStatusBarPreferenceController.Listener listener = mock(
SilentStatusBarPreferenceController.Listener.class);
mController.setListener(listener);
mController.setChecked(false);
verify(listener).onChange(false);
mController.setChecked(true);
verify(listener).onChange(true);
}
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) 2019 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.wallpaper;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings;
import com.android.settings.testutils.shadow.ShadowSecureSettings;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
public class StyleSuggestionActivityTest {
@Mock
private Context mContext;
@Mock
private Resources mResources;
@Mock
private ContentResolver mContentResolver;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getResources()).thenReturn(mResources);
when(mContext.getContentResolver()).thenReturn(mContentResolver);
}
@Test
public void wallpaperServiceEnabled_no_shouldReturnTrue() {
when(mResources.getBoolean(com.android.internal.R.bool.config_enableWallpaperService))
.thenReturn(false);
assertThat(StyleSuggestionActivity.isSuggestionComplete(mContext)).isTrue();
}
@Test
@Config(shadows = ShadowSecureSettings.class)
public void hasStyleSet_yes_shouldReturnTrue() {
when(mResources.getBoolean(com.android.internal.R.bool.config_enableWallpaperService))
.thenReturn(true);
Settings.Secure.putString(mContentResolver,
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, "test");
assertThat(StyleSuggestionActivity.isSuggestionComplete(mContext)).isTrue();
}
@Test
@Config(shadows = ShadowSecureSettings.class)
public void hasStyleSet_no_shouldReturnFalse() {
when(mResources.getBoolean(com.android.internal.R.bool.config_enableWallpaperService))
.thenReturn(true);
Settings.Secure.putString(mContentResolver,
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, null);
assertThat(StyleSuggestionActivity.isSuggestionComplete(mContext)).isFalse();
}
}

View File

@@ -50,6 +50,7 @@ import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -169,6 +170,7 @@ public class WebViewAppPickerTest {
}
@Test
@Ignore
public void testDisabledPackageShownAsDisabled() {
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mPackageManager,
createApplicationInfo(DEFAULT_PACKAGE_NAME), "disabled");
@@ -181,6 +183,7 @@ public class WebViewAppPickerTest {
}
@Test
@Ignore
public void testEnabledPackageShownAsEnabled() {
String disabledReason = "";
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mPackageManager,
@@ -194,6 +197,7 @@ public class WebViewAppPickerTest {
}
@Test
@Ignore
public void testDisabledPackageShowsDisabledReasonSummary() {
String disabledReason = "disabled";
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mPackageManager,
@@ -208,6 +212,7 @@ public class WebViewAppPickerTest {
}
@Test
@Ignore
public void testEnabledPackageShowsEmptySummary() {
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mPackageManager,
createApplicationInfo(DEFAULT_PACKAGE_NAME), null);

View File

@@ -1,277 +0,0 @@
/*
* Copyright (C) 2018 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.ui;
import android.metrics.MetricsReader;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
import android.support.test.metricshelper.MetricsAsserts;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.Direction;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
import android.system.helpers.SettingsHelper;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.Suppress;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
public class AccessibilitySettingsTests extends InstrumentationTestCase {
private static final String SETTINGS_PACKAGE = "com.android.settings";
private static final int TIMEOUT = 2000;
private UiDevice mDevice;
private MetricsReader mMetricsReader;
@Override
public void setUp() throws Exception {
super.setUp();
mDevice = UiDevice.getInstance(getInstrumentation());
try {
mDevice.setOrientationNatural();
} catch (RemoteException e) {
throw new RuntimeException("failed to freeze device orientaion", e);
}
mMetricsReader = new MetricsReader();
// Clear out old logs
mMetricsReader.checkpoint();
}
@Override
protected void tearDown() throws Exception {
// Need to finish settings activity
mDevice.pressBack();
mDevice.pressHome();
mDevice.waitForIdle();
super.tearDown();
}
@Presubmit
@MediumTest
public void testHighContrastTextOn() throws Exception {
verifyAccessibilitySettingOnOrOff("High contrast text",
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0, 1);
}
@Presubmit
@MediumTest
public void testHighContrastTextOff() throws Exception {
verifyAccessibilitySettingOnOrOff("High contrast text",
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 1, 0);
}
@Presubmit
@MediumTest
public void testPowerButtonEndsCallOn() throws Exception {
verifyAccessibilitySettingOnOrOff("Power button ends call",
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, 1, 2);
}
@Presubmit
@MediumTest
public void testPowerButtonEndsCallOff() throws Exception {
verifyAccessibilitySettingOnOrOff("Power button ends call",
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, 2, 1);
}
/* Suppressing these four tests. The settings don't play
* nice with Settings.System.putInt or Settings.Secure.putInt.
* Need further clarification. Filed bug b/27792029
*/
@Suppress
@MediumTest
public void testAutoRotateScreenOn() throws Exception {
verifyAccessibilitySettingOnOrOff("Auto-rotate screen",
Settings.System.ACCELEROMETER_ROTATION, 0, 1);
}
@Suppress
@MediumTest
public void testAutoRotateScreenOff() throws Exception {
verifyAccessibilitySettingOnOrOff("Auto-rotate screen",
Settings.System.ACCELEROMETER_ROTATION, 1, 0);
}
@Suppress
@MediumTest
public void testMonoAudioOn() throws Exception {
verifyAccessibilitySettingOnOrOff("Mono audio",
Settings.System.MASTER_MONO, 0, 1);
}
@Suppress
@MediumTest
public void testMonoAudioOff() throws Exception {
verifyAccessibilitySettingOnOrOff("Mono audio",
Settings.System.MASTER_MONO, 1, 0);
}
@Presubmit
@MediumTest
public void testLargeMousePointerOn() throws Exception {
verifyAccessibilitySettingOnOrOff("Large mouse pointer",
Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 0, 1);
}
@Presubmit
@MediumTest
public void testLargeMousePointerOff() throws Exception {
verifyAccessibilitySettingOnOrOff("Large mouse pointer",
Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 1, 0);
}
@Presubmit
@MediumTest
public void testColorCorrection() throws Exception {
verifySettingToggleAfterScreenLoad("Color correction",
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);
MetricsAsserts.assertHasVisibilityLog("Missing color correction log",
mMetricsReader, MetricsEvent.ACCESSIBILITY_TOGGLE_DALTONIZER, true);
}
// Suppressing this test, since UiAutomator + talkback don't play nice
@Suppress
@MediumTest
public void testTalkback() throws Exception {
verifySettingToggleAfterScreenLoad("TalkBack",
Settings.Secure.ACCESSIBILITY_ENABLED);
}
@Presubmit
@MediumTest
public void testCaptions() throws Exception {
verifySettingToggleAfterScreenLoad("Captions",
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED);
MetricsAsserts.assertHasVisibilityLog("Missing captions log",
mMetricsReader, MetricsEvent.ACCESSIBILITY_CAPTION_PROPERTIES, true);
}
@Presubmit
@MediumTest
public void testMagnificationGesture() throws Exception {
verifySettingToggleAfterScreenLoad("Magnification", "Magnify with triple-tap",
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
MetricsAsserts.assertHasVisibilityLog("Missing magnification log",
mMetricsReader, MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION, true);
}
@MediumTest
public void testClickAfterPointerStopsMoving() throws Exception {
verifySettingToggleAfterScreenLoad("Click after pointer stops moving",
Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED);
}
@MediumTest
public void testAccessibilitySettingsLoadLog() throws Exception {
launchAccessibilitySettings();
MetricsAsserts.assertHasVisibilityLog("Missing accessibility settings load log",
mMetricsReader, MetricsEvent.ACCESSIBILITY, true);
}
public void launchAccessibilitySettings() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(),
Settings.ACTION_ACCESSIBILITY_SETTINGS);
}
private void verifyAccessibilitySettingOnOrOff(String settingText,
String settingFlag, int initialFlagValue, int expectedFlagValue)
throws Exception {
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
settingFlag, initialFlagValue);
launchAccessibilitySettings();
UiObject2 settingsTitle = findItemOnScreen(settingText);
settingsTitle.click();
Thread.sleep(TIMEOUT);
int settingValue = Settings.Secure
.getInt(getInstrumentation().getContext().getContentResolver(), settingFlag);
assertEquals(settingText + " not correctly set after toggle",
expectedFlagValue, settingValue);
}
private void verifySettingToggleAfterScreenLoad(String settingText, String settingFlag)
throws Exception {
verifySettingToggleAfterScreenLoad(settingText, null, settingFlag);
}
private void verifySettingToggleAfterScreenLoad
(String settingText, String subSetting, String settingFlag) throws Exception {
// Load accessibility settings
launchAccessibilitySettings();
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
settingFlag, 0);
Thread.sleep(TIMEOUT);
// Tap on setting required
UiObject2 settingTitle = findItemOnScreen(settingText);
// Load screen
settingTitle.click();
Thread.sleep(TIMEOUT);
if (subSetting != null) {
UiObject2 subSettingObject = findItemOnScreen(subSetting);
subSettingObject.click();
Thread.sleep(TIMEOUT);
}
// Toggle value
UiObject2 settingToggle = mDevice.wait(Until.findObject(By.text("Off")),
TIMEOUT);
settingToggle.click();
dismissOpenDialog();
Thread.sleep(TIMEOUT);
// Assert new value
int settingValue = Settings.Secure.
getInt(getInstrumentation().getContext().getContentResolver(), settingFlag);
assertEquals(settingText + " value not set correctly", 1, settingValue);
// Toogle value
settingToggle.click();
dismissOpenDialog();
mDevice.pressBack();
Thread.sleep(TIMEOUT);
// Assert reset to old value
settingValue = Settings.Secure.
getInt(getInstrumentation().getContext().getContentResolver(), settingFlag);
assertEquals(settingText + " value not set correctly", 0, settingValue);
}
private UiObject2 findItemOnScreen(String item) throws Exception {
int count = 0;
UiObject2 settingsPanel = mDevice.wait(Until.findObject
(By.res(SETTINGS_PACKAGE, "list")), TIMEOUT);
while (settingsPanel.fling(Direction.UP) && count < 3) {
count++;
}
count = 0;
UiObject2 setting = null;
while(count < 3 && setting == null) {
setting = mDevice.wait(Until.findObject(By.text(item)), TIMEOUT);
if (setting == null) {
settingsPanel.scroll(Direction.DOWN, 1.0f);
}
count++;
}
return setting;
}
private void dismissOpenDialog() throws Exception {
UiObject2 okButton = mDevice.wait(Until.findObject
(By.res("android:id/button1")), TIMEOUT*2);
if (okButton != null) {
okButton.click();
}
}
}

View File

@@ -1,163 +0,0 @@
/*
* Copyright (C) 2018 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.ui;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.metrics.MetricsReader;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
import android.support.test.metricshelper.MetricsAsserts;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
public class BluetoothNetworkSettingsTests extends InstrumentationTestCase {
private static final String SETTINGS_PACKAGE = "com.android.settings";
private static final int TIMEOUT = 2000;
private static final int LONG_TIMEOUT = 40000;
private UiDevice mDevice;
private MetricsReader mMetricsReader;
@Override
public void setUp() throws Exception {
super.setUp();
mDevice = UiDevice.getInstance(getInstrumentation());
try {
mDevice.setOrientationNatural();
} catch (RemoteException e) {
throw new RuntimeException("failed to freeze device orientaion", e);
}
mMetricsReader = new MetricsReader();
// Clear out old logs
mMetricsReader.checkpoint();
}
@Override
protected void tearDown() throws Exception {
mDevice.pressBack();
mDevice.pressHome();
mDevice.waitForIdle();
super.tearDown();
}
@Presubmit
@MediumTest
public void testBluetoothEnabled() throws Exception {
verifyBluetoothOnOrOff(true);
MetricsAsserts.assertHasActionLog("missing bluetooth toggle log",
mMetricsReader, MetricsEvent.ACTION_BLUETOOTH_TOGGLE);
}
@Presubmit
@MediumTest
public void testBluetoothDisabled() throws Exception {
verifyBluetoothOnOrOff(false);
MetricsAsserts.assertHasActionLog("missing bluetooth toggle log",
mMetricsReader, MetricsEvent.ACTION_BLUETOOTH_TOGGLE);
}
@MediumTest
public void testRenameOption() throws Exception {
launchBluetoothSettings();
verifyUiObjectClicked(By.text("Device name"), "Rename preference");
verifyUiObjectClicked(By.text("CANCEL"), "CANCEL button");
MetricsAsserts.assertHasActionLog("missing bluetooth rename device log",
mMetricsReader, MetricsEvent.ACTION_BLUETOOTH_RENAME);
MetricsAsserts.assertHasVisibilityLog("missing bluetooth rename dialog log",
mMetricsReader, MetricsEvent.DIALOG_BLUETOOTH_RENAME, true);
}
@MediumTest
public void testReceivedFilesOption() throws Exception {
launchBluetoothSettings();
verifyUiObjectClicked(By.text("Received files"), "Received files preference");
MetricsAsserts.assertHasActionLog("missing bluetooth received files log",
mMetricsReader, MetricsEvent.ACTION_BLUETOOTH_FILES);
}
@MediumTest
public void testHelpFeedbackOverflowOption() throws Exception {
launchBluetoothSettings();
// Verify help & feedback
assertNotNull("Help & feedback item not found under Bluetooth Settings",
mDevice.wait(Until.findObject(By.desc("Help & feedback")), TIMEOUT));
}
public void launchBluetoothSettings() throws Exception {
Intent btIntent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
btIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getInstrumentation().getContext().startActivity(btIntent);
Thread.sleep(TIMEOUT * 2);
}
/**
* Find the {@link UiObject2} by {@code itemSelector} and try to click it if possible.
*
* If not find, throw assertion error
* @param itemSelector used to find the {@link UiObject2}
* @param text the description of the {@link UiObject2}
*/
private void verifyUiObjectClicked(BySelector itemSelector, String text) throws Exception {
UiObject2 uiObject2 = mDevice.wait(Until.findObject(itemSelector), TIMEOUT);
assertNotNull(text + "is not present in bluetooth settings page", uiObject2);
uiObject2.click();
}
/**
* Toggles the Bluetooth switch and verifies that the change is reflected in Settings
*
* @param verifyOn set to whether you want the setting turned On or Off
*/
private void verifyBluetoothOnOrOff(boolean verifyOn) throws Exception {
String switchText = "ON";
BluetoothAdapter bluetoothAdapter = ((BluetoothManager) getInstrumentation().getContext()
.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
if (verifyOn) {
switchText = "OFF";
bluetoothAdapter.disable();
} else {
bluetoothAdapter.enable();
}
launchBluetoothSettings();
mDevice.wait(Until
.findObject(By.res(SETTINGS_PACKAGE, "switch_widget").text(switchText)), TIMEOUT)
.click();
Thread.sleep(TIMEOUT);
String bluetoothValue =
Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
Settings.Global.BLUETOOTH_ON);
if (verifyOn) {
assertEquals("1", bluetoothValue);
} else {
assertEquals("0", bluetoothValue);
}
}
}

View File

@@ -1,268 +0,0 @@
/*
* Copyright (C) 2018 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.ui;
import android.content.ContentResolver;
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
import android.system.helpers.SettingsHelper;
import android.system.helpers.SettingsHelper.SettingsType;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.Suppress;
import java.util.regex.Pattern;
public class DisplaySettingsTest extends InstrumentationTestCase {
private static final String PAGE = Settings.ACTION_DISPLAY_SETTINGS;
private static final int TIMEOUT = 2000;
private static final FontSetting FONT_SMALL = new FontSetting("Small", 0.85f);
private static final FontSetting FONT_NORMAL = new FontSetting("Default", 1.00f);
private static final FontSetting FONT_LARGE = new FontSetting("Large", 1.15f);
private static final FontSetting FONT_HUGE = new FontSetting("Largest", 1.30f);
private UiDevice mDevice;
private ContentResolver mResolver;
private SettingsHelper mHelper;
@Override
public void setUp() throws Exception {
super.setUp();
mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.setOrientationNatural();
mResolver = getInstrumentation().getContext().getContentResolver();
mHelper = new SettingsHelper();
}
@Override
public void tearDown() throws Exception {
// reset settings we touched that may impact others
Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, 1.00f);
mDevice.waitForIdle();
super.tearDown();
}
@Presubmit
@MediumTest
public void testAdaptiveBrightness() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
Thread.sleep(1000);
assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE, "Adaptive brightness",
Settings.System.SCREEN_BRIGHTNESS_MODE));
assertTrue(mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE, "Adaptive brightness",
Settings.System.SCREEN_BRIGHTNESS_MODE));
}
// blocked on b/27487224
@MediumTest
@Suppress
public void testDaydreamToggle() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
clickMore();
Pattern p = Pattern.compile("On|Off");
mHelper.clickSetting("Screen saver");
Thread.sleep(1000);
try {
assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE, p,
Settings.Secure.SCREENSAVER_ENABLED, false));
assertTrue(mHelper.verifyToggleSetting(SettingsType.SECURE, PAGE, p,
Settings.Secure.SCREENSAVER_ENABLED, false));
} finally {
mDevice.pressBack();
}
}
@MediumTest
public void testAccelRotation() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
clickMore();
Thread.sleep(4000);
int currentAccelSetting = Settings.System.getInt(
mResolver, Settings.System.ACCELEROMETER_ROTATION);
mHelper.clickSetting("Auto-rotate screen");
int newAccelSetting = Settings.System.getInt(
mResolver, Settings.System.ACCELEROMETER_ROTATION);
assertTrue("Accelorometer setting unchanged after toggle", currentAccelSetting != newAccelSetting);
mHelper.clickSetting("Auto-rotate screen");
int revertedAccelSetting = Settings.System.getInt(
mResolver, Settings.System.ACCELEROMETER_ROTATION);
assertTrue("Accelorometer setting unchanged after toggle", revertedAccelSetting != newAccelSetting);
}
@MediumTest
public void testDaydream() throws Exception {
Settings.Secure.putInt(mResolver, Settings.Secure.SCREENSAVER_ENABLED, 1);
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
clickMore();
mHelper.scrollVert(false);
mDevice.wait(Until.findObject(By.text("Screen saver")), TIMEOUT).click();
try {
assertTrue(mHelper.verifyRadioSetting(SettingsType.SECURE, PAGE,
"Current screen saver", "Clock", Settings.Secure.SCREENSAVER_COMPONENTS,
"com.google.android.deskclock/com.android.deskclock.Screensaver"));
assertTrue(mHelper.verifyRadioSetting(SettingsType.SECURE, PAGE,
"Current screen saver", "Colors", Settings.Secure.SCREENSAVER_COMPONENTS,
"com.android.dreams.basic/com.android.dreams.basic.Colors"));
assertTrue(mHelper.verifyRadioSetting(SettingsType.SECURE, PAGE,
"Current screen saver", "Photos", Settings.Secure.SCREENSAVER_COMPONENTS,
"com.google.android.apps.photos/com.google.android.apps.photos.daydream"
+ ".PhotosDreamService"));
} finally {
mDevice.pressBack();
Thread.sleep(2000);
}
}
@Presubmit
@MediumTest
public void testSleep15Seconds() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "15 seconds", Settings.System.SCREEN_OFF_TIMEOUT, "15000"));
}
@MediumTest
public void testSleep30Seconds() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "30 seconds", Settings.System.SCREEN_OFF_TIMEOUT, "30000"));
}
@MediumTest
public void testSleep1Minute() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "1 minute", Settings.System.SCREEN_OFF_TIMEOUT, "60000"));
}
@MediumTest
public void testSleep2Minutes() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "2 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "120000"));
}
@MediumTest
public void testSleep5Minutes() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "5 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "300000"));
}
@MediumTest
public void testSleep10Minutes() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "10 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "600000"));
}
@MediumTest
public void testSleep30Minutes() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.scrollVert(true);
assertTrue(mHelper.verifyRadioSetting(SettingsType.SYSTEM, PAGE,
"Sleep", "30 minutes", Settings.System.SCREEN_OFF_TIMEOUT, "1800000"));
}
@Presubmit
@MediumTest
public void testFontSizeLarge() throws Exception {
verifyFontSizeSetting(1.00f, FONT_LARGE);
// Leaving the font size at large can make later tests fail, so reset it
Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, 1.00f);
// It takes a second for the new font size to be picked up
Thread.sleep(2000);
}
@MediumTest
public void testFontSizeDefault() throws Exception {
verifyFontSizeSetting(1.15f, FONT_NORMAL);
}
@MediumTest
public void testFontSizeLargest() throws Exception {
verifyFontSizeSetting(1.00f, FONT_HUGE);
// Leaving the font size at huge can make later tests fail, so reset it
Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, 1.00f);
// It takes a second for the new font size to be picked up
Thread.sleep(2000);
}
@MediumTest
public void testFontSizeSmall() throws Exception {
verifyFontSizeSetting(1.00f, FONT_SMALL);
}
private void verifyFontSizeSetting(float resetValue, FontSetting setting)
throws Exception {
Settings.System.putFloat(mResolver, Settings.System.FONT_SCALE, resetValue);
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
clickMore();
mHelper.clickSetting("Font size");
try {
mDevice.wait(Until.findObject(By.desc(setting.getName())), TIMEOUT).click();
Thread.sleep(1000);
float changedValue = Settings.System.getFloat(
mResolver, Settings.System.FONT_SCALE);
assertEquals(setting.getSize(), changedValue, 0.0001);
} finally {
// Make sure to back out of the font menu
mDevice.pressBack();
}
}
private void clickMore() throws InterruptedException {
UiObject2 more = mDevice.wait(Until.findObject(By.text("Advanced")), TIMEOUT);
if (more != null) {
more.click();
Thread.sleep(TIMEOUT);
}
}
private static class FontSetting {
private final String mSizeName;
private final float mSizeVal;
public FontSetting(String sizeName, float sizeVal) {
mSizeName = sizeName;
mSizeVal = sizeVal;
}
public String getName() {
return mSizeName;
}
public float getSize() {
return mSizeVal;
}
}
}