Snap for 11847214 from 3072209e7d to 24Q3-release
Change-Id: I6a2e0382f3594ede9b955b9b29e7f3a078e5b529
This commit is contained in:
@@ -3,6 +3,13 @@ container: "system_ext"
|
|||||||
|
|
||||||
# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.
|
# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.
|
||||||
|
|
||||||
|
flag {
|
||||||
|
name: "add_brightness_settings_in_suw"
|
||||||
|
namespace: "accessibility"
|
||||||
|
description: "Whether to add brightness preference in SUW Vision Settings"
|
||||||
|
bug: "332974327"
|
||||||
|
}
|
||||||
|
|
||||||
flag {
|
flag {
|
||||||
name: "edit_shortcuts_in_full_screen"
|
name: "edit_shortcuts_in_full_screen"
|
||||||
namespace: "accessibility"
|
namespace: "accessibility"
|
||||||
|
|||||||
9
aconfig/settings_device_diagnostics_declarations.aconfig
Normal file
9
aconfig/settings_device_diagnostics_declarations.aconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package: "com.android.settings.flags"
|
||||||
|
container: "system_ext"
|
||||||
|
|
||||||
|
flag {
|
||||||
|
name: "enable_device_diagnostics_in_settings"
|
||||||
|
namespace: "phoenix"
|
||||||
|
description: "Enable the Device Diagnostics app in Settings"
|
||||||
|
bug: "309886423"
|
||||||
|
}
|
||||||
@@ -1,6 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<issues format="4">
|
<issues format="4">
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="LintError"
|
||||||
|
severity="Error"
|
||||||
|
message="No `.class` files were found in project ".", so none of the classfile based checks could be run. Does the project need to be built first?"
|
||||||
|
category="Lint"
|
||||||
|
priority="10"
|
||||||
|
summary="Lint Failure"
|
||||||
|
explanation="This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.
These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.">
|
||||||
|
<location
|
||||||
|
file="."/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
<issue
|
<issue
|
||||||
id="HardCodedColor"
|
id="HardCodedColor"
|
||||||
severity="Error"
|
severity="Error"
|
||||||
@@ -4561,6 +4573,38 @@
|
|||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="HardCodedColor"
|
||||||
|
severity="Error"
|
||||||
|
message="Avoid using hardcoded color"
|
||||||
|
category="Correctness"
|
||||||
|
priority="4"
|
||||||
|
summary="Using hardcoded color"
|
||||||
|
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||||
|
errorLine1=" android:color="@color/accessibility_feature_background"/>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="res/drawable/ic_suw_brightness_auto.xml"
|
||||||
|
line="22"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="HardCodedColor"
|
||||||
|
severity="Error"
|
||||||
|
message="Avoid using hardcoded color"
|
||||||
|
category="Correctness"
|
||||||
|
priority="4"
|
||||||
|
summary="Using hardcoded color"
|
||||||
|
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||||
|
errorLine1=" android:color="@color/accessibility_feature_background"/>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="res/drawable/ic_suw_brightness_level.xml"
|
||||||
|
line="22"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
<issue
|
<issue
|
||||||
id="HardCodedColor"
|
id="HardCodedColor"
|
||||||
severity="Error"
|
severity="Error"
|
||||||
|
|||||||
25
res/drawable/ic_brightness_auto.xml
Normal file
25
res/drawable/ic_brightness_auto.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2024 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="@dimen/accessibility_icon_foreground_size"
|
||||||
|
android:height="@dimen/accessibility_icon_foreground_size"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M312,640L376,640L408,548L554,548L586,640L648,640L512,280L448,280L312,640ZM426,496L478,346L482,346L534,496L426,496ZM480,932L346,800L160,800L160,614L28,480L160,346L160,160L346,160L480,28L614,160L800,160L800,346L932,480L800,614L800,800L614,800L480,932ZM480,820L580,720L720,720L720,580L820,480L720,380L720,240L580,240L480,140L380,240L240,240L240,380L140,480L240,580L240,720L380,720L480,820ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||||
|
</vector>
|
||||||
25
res/drawable/ic_brightness_medium.xml
Normal file
25
res/drawable/ic_brightness_medium.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2024 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="@dimen/accessibility_icon_foreground_size"
|
||||||
|
android:height="@dimen/accessibility_icon_foreground_size"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M480,932L346,800L160,800L160,614L28,480L160,346L160,160L346,160L480,28L614,160L800,160L800,346L932,480L800,614L800,800L614,800L480,932ZM480,680Q563,680 621.5,621.5Q680,563 680,480Q680,397 621.5,338.5Q563,280 480,280L480,680ZM480,820L580,720L720,720L720,580L820,480L720,380L720,240L580,240L480,140L380,240L240,240L240,380L140,480L240,580L240,720L380,720L480,820ZM480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480Z"/>
|
||||||
|
</vector>
|
||||||
10
res/drawable/ic_device_diagnostics.xml
Normal file
10
res/drawable/ic_device_diagnostics.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?android:attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:pathData="M320,760h320v-80L320,680v80ZM320,640h320v-80L320,560v80ZM480,492q66,-60 113,-106.5t47,-97.5q0,-36 -26,-62t-62,-26q-21,0 -40.5,8.5T480,232q-12,-15 -31.5,-23.5T408,200q-36,0 -62,26t-26,62q0,51 45.5,96T480,492ZM720,880L240,880q-33,0 -56.5,-23.5T160,800v-640q0,-33 23.5,-56.5T240,80h480q33,0 56.5,23.5T800,160v640q0,33 -23.5,56.5T720,880ZM240,800h480v-640L240,160v640ZM240,800v-640,640Z"
|
||||||
|
android:fillColor="#FFFFFFFF"/>
|
||||||
|
</vector>
|
||||||
26
res/drawable/ic_suw_brightness_auto.xml
Normal file
26
res/drawable/ic_suw_brightness_auto.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2024 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.
|
||||||
|
-->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<com.android.settingslib.widget.AdaptiveIconShapeDrawable
|
||||||
|
android:width="@dimen/accessibility_icon_size"
|
||||||
|
android:height="@dimen/accessibility_icon_size"
|
||||||
|
android:color="@color/accessibility_feature_background"/>
|
||||||
|
</item>
|
||||||
|
<item android:gravity="center"
|
||||||
|
android:drawable="@drawable/ic_brightness_auto"/>
|
||||||
|
</layer-list>
|
||||||
26
res/drawable/ic_suw_brightness_level.xml
Normal file
26
res/drawable/ic_suw_brightness_level.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2024 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.
|
||||||
|
-->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<com.android.settingslib.widget.AdaptiveIconShapeDrawable
|
||||||
|
android:width="@dimen/accessibility_icon_size"
|
||||||
|
android:height="@dimen/accessibility_icon_size"
|
||||||
|
android:color="@color/accessibility_feature_background"/>
|
||||||
|
</item>
|
||||||
|
<item android:gravity="center"
|
||||||
|
android:drawable="@drawable/ic_brightness_medium"/>
|
||||||
|
</layer-list>
|
||||||
@@ -836,4 +836,7 @@
|
|||||||
|
|
||||||
<!-- The Activity intent to trigger to launch time-related feedback. -->
|
<!-- The Activity intent to trigger to launch time-related feedback. -->
|
||||||
<string name="config_time_feedback_intent_uri" translatable="false" />
|
<string name="config_time_feedback_intent_uri" translatable="false" />
|
||||||
|
|
||||||
|
<!-- Package name for diagnostics app. -->
|
||||||
|
<string name="config_device_diagnostics_package_name" translatable="false">com.android.devicediagnostics</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1257,8 +1257,8 @@
|
|||||||
<string name="private_space_auto_lock_page_summary">You can lock your private space automatically if you haven\’t used your device for a period of time</string>
|
<string name="private_space_auto_lock_page_summary">You can lock your private space automatically if you haven\’t used your device for a period of time</string>
|
||||||
<!-- Configure auto lock: Value for auto lock configuration to lock private space every time device locks. [CHAR LIMIT=40] -->
|
<!-- Configure auto lock: Value for auto lock configuration to lock private space every time device locks. [CHAR LIMIT=40] -->
|
||||||
<string name="private_space_auto_lock_every_time">Every time device locks</string>
|
<string name="private_space_auto_lock_every_time">Every time device locks</string>
|
||||||
<!-- Configure auto lock: Value for auto lock configuration to lock private space after 5 minutes of inactivity. [CHAR LIMIT=40] -->
|
<!-- Configure auto lock: Value for auto lock configuration to lock private space after 5 minutes of inactivity post screen timeout. [CHAR LIMIT=40] -->
|
||||||
<string name="private_space_auto_lock_after_inactivity">After 5 minutes of inactivity</string>
|
<string name="private_space_auto_lock_after_inactivity">5 minutes after screen timeout</string>
|
||||||
<!-- Configure auto lock: Value for auto lock configuration to lock private space only after device restarts. [CHAR LIMIT=40] -->
|
<!-- Configure auto lock: Value for auto lock configuration to lock private space only after device restarts. [CHAR LIMIT=40] -->
|
||||||
<string name="private_space_auto_lock_after_device_restart">Only after device restarts</string>
|
<string name="private_space_auto_lock_after_device_restart">Only after device restarts</string>
|
||||||
<!-- Title for the settings page for hiding private space. [CHAR LIMIT=45] -->
|
<!-- Title for the settings page for hiding private space. [CHAR LIMIT=45] -->
|
||||||
@@ -2732,6 +2732,10 @@
|
|||||||
<!-- Display settings screen, Color mode option for "Adaptive color" [CHAR LIMIT=45] -->
|
<!-- Display settings screen, Color mode option for "Adaptive color" [CHAR LIMIT=45] -->
|
||||||
<string name="color_mode_option_automatic">Adaptive</string>
|
<string name="color_mode_option_automatic">Adaptive</string>
|
||||||
|
|
||||||
|
<!-- Key for the brightness level preference -->
|
||||||
|
<string name="preference_key_brightness_level" translatable="false">brightness</string>
|
||||||
|
<!-- Key for the auto brightness preference -->
|
||||||
|
<string name="preference_key_auto_brightness" translatable="false">auto_brightness_entry</string>
|
||||||
<!-- Sound & display settings screen, setting option name to change brightness level -->
|
<!-- Sound & display settings screen, setting option name to change brightness level -->
|
||||||
<string name="brightness">Brightness level</string>
|
<string name="brightness">Brightness level</string>
|
||||||
<!-- Sound & display settings screen, setting option name to enable adaptive brightness [CHAR LIMIT=30] -->
|
<!-- Sound & display settings screen, setting option name to enable adaptive brightness [CHAR LIMIT=30] -->
|
||||||
@@ -7889,6 +7893,9 @@
|
|||||||
<!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=50]-->
|
<!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=50]-->
|
||||||
<string name="zen_mode_settings_title">Do Not Disturb</string>
|
<string name="zen_mode_settings_title">Do Not Disturb</string>
|
||||||
|
|
||||||
|
<!-- Sound: Title for the Modes option and associated settings page. [CHAR LIMIT=50]-->
|
||||||
|
<string name="zen_modes_list_title">Priority Modes</string>
|
||||||
|
|
||||||
<!-- Sound: Summary for the Do not Disturb option and associated settings page. [CHAR LIMIT=240]-->
|
<!-- Sound: Summary for the Do not Disturb option and associated settings page. [CHAR LIMIT=240]-->
|
||||||
<string name="zen_mode_settings_summary">Only get notified by important people and apps</string>
|
<string name="zen_mode_settings_summary">Only get notified by important people and apps</string>
|
||||||
|
|
||||||
@@ -12947,17 +12954,17 @@
|
|||||||
<string name="bluetooth_details_permissions_sync_summary">Give your watch the same app permissions that you’ve allowed on this phone</string>
|
<string name="bluetooth_details_permissions_sync_summary">Give your watch the same app permissions that you’ve allowed on this phone</string>
|
||||||
|
|
||||||
<!-- The title of the bluetooth audio device type selection [CHAR LIMIT=none] -->
|
<!-- The title of the bluetooth audio device type selection [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_types_title">Audio Device Type</string>
|
<string name="bluetooth_details_audio_device_types_title">Audio device type</string>
|
||||||
<!-- The audio device type corresponding to unknown device type [CHAR LIMIT=none] -->
|
<!-- The audio device type corresponding to a not set device type [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_type_unknown">Unknown</string>
|
<string name="bluetooth_details_audio_device_type_unknown">Not set</string>
|
||||||
<!-- The audio device type corresponding to speakers [CHAR LIMIT=none] -->
|
<!-- The audio device type corresponding to speakers [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_type_speaker">Speaker</string>
|
<string name="bluetooth_details_audio_device_type_speaker">Speaker</string>
|
||||||
<!-- The audio device type corresponding to headphones [CHAR LIMIT=none] -->
|
<!-- The audio device type corresponding to headphones [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_type_headphones">Headphones</string>
|
<string name="bluetooth_details_audio_device_type_headphones">Headphones</string>
|
||||||
<!-- The audio device type corresponding to hearing aid [CHAR LIMIT=none] -->
|
<!-- The audio device type corresponding to hearing device [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_type_hearing_aid">Hearing Aid</string>
|
<string name="bluetooth_details_audio_device_type_hearing_aid">Hearing device</string>
|
||||||
<!-- The audio device type corresponding to car kit [CHAR LIMIT=none] -->
|
<!-- The audio device type corresponding to car kit [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_type_carkit">Car Kit</string>
|
<string name="bluetooth_details_audio_device_type_carkit">Car</string>
|
||||||
<!-- The audio device type corresponding to other device type [CHAR LIMIT=none] -->
|
<!-- The audio device type corresponding to other device type [CHAR LIMIT=none] -->
|
||||||
<string name="bluetooth_details_audio_device_type_other">Other</string>
|
<string name="bluetooth_details_audio_device_type_other">Other</string>
|
||||||
|
|
||||||
@@ -13258,4 +13265,9 @@
|
|||||||
|
|
||||||
<!--Title for Sync Across Devices category-->
|
<!--Title for Sync Across Devices category-->
|
||||||
<string name="sync_across_devices_title">Sync across devices</string>
|
<string name="sync_across_devices_title">Sync across devices</string>
|
||||||
|
|
||||||
|
<!-- Device Diagnostics -->
|
||||||
|
|
||||||
|
<!-- Title for System dashboard fragment -->
|
||||||
|
<string name="device_diagnostics_title">Device diagnostics</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -29,6 +29,22 @@
|
|||||||
settings:keywords="text_reading_options"
|
settings:keywords="text_reading_options"
|
||||||
settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/>
|
settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/>
|
||||||
|
|
||||||
|
<com.android.settingslib.RestrictedPreference
|
||||||
|
android:key="@string/preference_key_brightness_level"
|
||||||
|
android:icon="@drawable/ic_suw_brightness_level"
|
||||||
|
android:title="@string/brightness"
|
||||||
|
settings:keywords="@string/keywords_display_brightness_level"
|
||||||
|
settings:useAdminDisabledSummary="true"
|
||||||
|
settings:userRestriction="no_config_brightness"/>
|
||||||
|
|
||||||
|
<com.android.settingslib.PrimarySwitchPreference
|
||||||
|
android:key="@string/preference_key_auto_brightness"
|
||||||
|
android:icon="@drawable/ic_suw_brightness_auto"
|
||||||
|
android:title="@string/auto_brightness_title"
|
||||||
|
android:fragment="com.android.settings.accessibility.AutoBrightnessPreferenceFragmentForSetupWizard"
|
||||||
|
settings:useAdminDisabledSummary="true"
|
||||||
|
settings:userRestriction="no_config_brightness"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
|
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
|
||||||
android:key="screen_magnification_preference"
|
android:key="screen_magnification_preference"
|
||||||
|
|||||||
@@ -26,14 +26,14 @@
|
|||||||
android:order="-200">
|
android:order="-200">
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="brightness"
|
android:key="@string/preference_key_brightness_level"
|
||||||
android:title="@string/brightness"
|
android:title="@string/brightness"
|
||||||
settings:keywords="@string/keywords_display_brightness_level"
|
settings:keywords="@string/keywords_display_brightness_level"
|
||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
settings:userRestriction="no_config_brightness"/>
|
settings:userRestriction="no_config_brightness"/>
|
||||||
|
|
||||||
<com.android.settingslib.PrimarySwitchPreference
|
<com.android.settingslib.PrimarySwitchPreference
|
||||||
android:key="auto_brightness_entry"
|
android:key="@string/preference_key_auto_brightness"
|
||||||
android:title="@string/auto_brightness_title"
|
android:title="@string/auto_brightness_title"
|
||||||
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
|
|||||||
28
res/xml/modes_list_settings.xml
Normal file
28
res/xml/modes_list_settings.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2024 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"
|
||||||
|
android:title="@string/zen_modes_list_title" >
|
||||||
|
|
||||||
|
<!-- TODO: b/333682392 - add strings for summary as appropriate -->
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="zen_modes_list">
|
||||||
|
<!-- Preferences leading to rules are added in this PreferenceCategory. -->
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
25
res/xml/modes_rule_settings.xml
Normal file
25
res/xml/modes_rule_settings.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2024 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"
|
||||||
|
android:title="@string/zen_modes_list_title" >
|
||||||
|
|
||||||
|
<!-- TODO: b/308819292 - implement page, delete this test preference -->
|
||||||
|
<Preference
|
||||||
|
android:key="zen_mode_test" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -97,6 +97,13 @@
|
|||||||
android:order="-40"
|
android:order="-40"
|
||||||
settings:controller="com.android.settings.system.DeveloperOptionsController"/>
|
settings:controller="com.android.settings.system.DeveloperOptionsController"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="device_diagnostics"
|
||||||
|
android:title="@string/device_diagnostics_title"
|
||||||
|
android:order="-35"
|
||||||
|
android:icon="@drawable/ic_device_diagnostics"
|
||||||
|
settings:controller="com.android.settings.system.DeviceDiagnosticsPreferenceController"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="reset_dashboard"
|
android:key="reset_dashboard"
|
||||||
android:title="@string/reset_dashboard_title"
|
android:title="@string/reset_dashboard_title"
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import com.android.internal.content.PackageMonitor;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
|
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.development.Enable16kUtils;
|
||||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
@@ -98,6 +99,8 @@ public class AccessibilitySettings extends DashboardFragment implements
|
|||||||
static final String EXTRA_TIME_FOR_LOGGING = "start_time_to_log_a11y_tool";
|
static final String EXTRA_TIME_FOR_LOGGING = "start_time_to_log_a11y_tool";
|
||||||
static final String EXTRA_METRICS_CATEGORY = "metrics_category";
|
static final String EXTRA_METRICS_CATEGORY = "metrics_category";
|
||||||
|
|
||||||
|
public static final String VOICE_ACCESS_SERVICE = "android.apps.accessibility.voiceaccess";
|
||||||
|
|
||||||
// Timeout before we update the services if packages are added/removed
|
// Timeout before we update the services if packages are added/removed
|
||||||
// since the AccessibilityManagerService has to do that processing first
|
// since the AccessibilityManagerService has to do that processing first
|
||||||
// to generate the AccessibilityServiceInfo we need for proper
|
// to generate the AccessibilityServiceInfo we need for proper
|
||||||
@@ -488,6 +491,11 @@ public class AccessibilitySettings extends DashboardFragment implements
|
|||||||
String[] services = getResources().getStringArray(key);
|
String[] services = getResources().getStringArray(key);
|
||||||
PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
|
PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
|
||||||
for (int i = 0; i < services.length; i++) {
|
for (int i = 0; i < services.length; i++) {
|
||||||
|
// TODO(b/335443194) Voice access is not available in 16kB mode.
|
||||||
|
if (services[i].contains(VOICE_ACCESS_SERVICE)
|
||||||
|
&& Enable16kUtils.isPageAgnosticModeOn(getContext())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ComponentName component = ComponentName.unflattenFromString(services[i]);
|
ComponentName component = ComponentName.unflattenFromString(services[i]);
|
||||||
mPreBundledServiceComponentToCategoryMap.put(component, category);
|
mPreBundledServiceComponentToCategoryMap.put(component, category);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_MEDIU
|
|||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -40,11 +41,15 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.display.AutoBrightnessPreferenceController;
|
||||||
|
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||||
import com.google.android.setupdesign.GlifPreferenceLayout;
|
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,6 +166,21 @@ public class AccessibilitySettingsForSetupWizard extends DashboardFragment
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
|
BrightnessLevelPreferenceController brightnessLevelPreferenceController =
|
||||||
|
new BrightnessLevelPreferenceController(context, getSettingsLifecycle());
|
||||||
|
brightnessLevelPreferenceController.setInSetupWizard(true);
|
||||||
|
controllers.add(brightnessLevelPreferenceController);
|
||||||
|
String autoBrightnessKey = context.getString(R.string.preference_key_auto_brightness);
|
||||||
|
AutoBrightnessPreferenceController autoBrightnessPreferenceController =
|
||||||
|
new AutoBrightnessPreferenceController(context, autoBrightnessKey);
|
||||||
|
autoBrightnessPreferenceController.setInSetupWizard(true);
|
||||||
|
controllers.add(autoBrightnessPreferenceController);
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns accessibility service info by given package name and service name.
|
* Returns accessibility service info by given package name and service name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.accessibility;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_CANCELED;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.display.AutoBrightnessSettings;
|
||||||
|
import com.android.settingslib.Utils;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||||
|
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fragment for adaptive brightness settings in the SetupWizard.
|
||||||
|
*/
|
||||||
|
public class AutoBrightnessPreferenceFragmentForSetupWizard extends AutoBrightnessSettings {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
if (view instanceof GlifPreferenceLayout) {
|
||||||
|
final GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
|
||||||
|
final String title = getContext().getString(
|
||||||
|
R.string.auto_brightness_title);
|
||||||
|
final Drawable icon = getContext().getDrawable(R.drawable.ic_accessibility_visibility);
|
||||||
|
icon.setTintList(Utils.getColorAttr(getContext(), android.R.attr.colorPrimary));
|
||||||
|
AccessibilitySetupWizardUtils.updateGlifPreferenceLayout(getContext(), layout, title,
|
||||||
|
/* description= */ null, icon);
|
||||||
|
|
||||||
|
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
|
||||||
|
AccessibilitySetupWizardUtils.setPrimaryButton(getContext(), mixin, R.string.done,
|
||||||
|
() -> {
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView onCreateRecyclerView(@NonNull LayoutInflater inflater,
|
||||||
|
@NonNull ViewGroup parent, @Nullable Bundle savedInstanceState) {
|
||||||
|
if (parent instanceof GlifPreferenceLayout) {
|
||||||
|
final GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
|
||||||
|
return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
|
||||||
|
}
|
||||||
|
return super.onCreateRecyclerView(inflater, parent, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.SUW_ACCESSIBILITY_AUTO_BRIGHTNESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import static com.android.settings.accessibility.AccessibilitySettings.VOICE_ACCESS_SERVICE;
|
||||||
import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_MEDIUM;
|
import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_MEDIUM;
|
||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
@@ -37,6 +38,7 @@ import androidx.core.content.ContextCompat;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.development.Enable16kUtils;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||||
@@ -89,6 +91,11 @@ public class RestrictedPreferenceHelper {
|
|||||||
final AccessibilityServiceInfo info = installedServices.get(i);
|
final AccessibilityServiceInfo info = installedServices.get(i);
|
||||||
final ResolveInfo resolveInfo = info.getResolveInfo();
|
final ResolveInfo resolveInfo = info.getResolveInfo();
|
||||||
final String packageName = resolveInfo.serviceInfo.packageName;
|
final String packageName = resolveInfo.serviceInfo.packageName;
|
||||||
|
// TODO(b/335443194) Voice access is not available in 16kB mode.
|
||||||
|
if (packageName.contains(VOICE_ACCESS_SERVICE)
|
||||||
|
&& Enable16kUtils.isPageAgnosticModeOn(mContext)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final ComponentName componentName = new ComponentName(packageName,
|
final ComponentName componentName = new ComponentName(packageName,
|
||||||
resolveInfo.serviceInfo.name);
|
resolveInfo.serviceInfo.name);
|
||||||
|
|
||||||
|
|||||||
@@ -20,16 +20,20 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.credentials.CredentialManager;
|
import android.credentials.CredentialManager;
|
||||||
import android.credentials.CredentialProviderInfo;
|
import android.credentials.CredentialProviderInfo;
|
||||||
|
import android.credentials.SetEnabledProvidersException;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.OutcomeReceiver;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.autofill.AutofillService;
|
import android.service.autofill.AutofillService;
|
||||||
import android.service.autofill.AutofillServiceInfo;
|
import android.service.autofill.AutofillServiceInfo;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.autofill.AutofillManager;
|
import android.view.autofill.AutofillManager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
@@ -41,6 +45,7 @@ import com.android.settingslib.widget.TwoTargetPreference;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
public class DefaultCombinedPreferenceController extends DefaultAppPreferenceController {
|
public class DefaultCombinedPreferenceController extends DefaultAppPreferenceController {
|
||||||
|
|
||||||
@@ -49,10 +54,12 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon
|
|||||||
|
|
||||||
private final AutofillManager mAutofillManager;
|
private final AutofillManager mAutofillManager;
|
||||||
private final CredentialManager mCredentialManager;
|
private final CredentialManager mCredentialManager;
|
||||||
|
private final Executor mExecutor;
|
||||||
|
|
||||||
public DefaultCombinedPreferenceController(Context context) {
|
public DefaultCombinedPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
|
mExecutor = ContextCompat.getMainExecutor(context);
|
||||||
mAutofillManager = mContext.getSystemService(AutofillManager.class);
|
mAutofillManager = mContext.getSystemService(AutofillManager.class);
|
||||||
|
|
||||||
if (CredentialManager.isServiceEnabled(context)) {
|
if (CredentialManager.isServiceEnabled(context)) {
|
||||||
@@ -158,6 +165,9 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon
|
|||||||
// Apply device admin restrictions to top provider.
|
// Apply device admin restrictions to top provider.
|
||||||
if (topProvider != null
|
if (topProvider != null
|
||||||
&& topProvider.getDeviceAdminRestrictions(mContext, userId) != null) {
|
&& topProvider.getDeviceAdminRestrictions(mContext, userId) != null) {
|
||||||
|
// This case means, the provider is blocked by device admin, but settings' storage has
|
||||||
|
// not be cleared correctly. So clean the storage here.
|
||||||
|
removePrimaryProvider();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,4 +219,28 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon
|
|||||||
mContext.createContextAsUser(UserHandle.of(getUser()), /* flags= */ 0);
|
mContext.createContextAsUser(UserHandle.of(getUser()), /* flags= */ 0);
|
||||||
return new Intent(context, CredentialsPickerActivity.class);
|
return new Intent(context, CredentialsPickerActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removePrimaryProvider() {
|
||||||
|
// Commit using the CredMan API.
|
||||||
|
if (mCredentialManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCredentialManager.setEnabledProviders(
|
||||||
|
List.of(), // empty primary provider.
|
||||||
|
List.of(), // empty enabled providers.
|
||||||
|
getUser(),
|
||||||
|
mExecutor,
|
||||||
|
new OutcomeReceiver<Void, SetEnabledProvidersException>() {
|
||||||
|
@Override
|
||||||
|
public void onResult(Void result) {
|
||||||
|
Log.i(TAG, "setEnabledProviders success");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(SetEnabledProvidersException e) {
|
||||||
|
Log.e(TAG, "setEnabledProviders error: " + e.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.android.settings.accessibility.AccessibilityDetailsSettingsFragment;
|
|||||||
import com.android.settings.accessibility.AccessibilityHearingAidsFragment;
|
import com.android.settings.accessibility.AccessibilityHearingAidsFragment;
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
||||||
|
import com.android.settings.accessibility.AutoBrightnessPreferenceFragmentForSetupWizard;
|
||||||
import com.android.settings.accessibility.CaptioningPropertiesFragment;
|
import com.android.settings.accessibility.CaptioningPropertiesFragment;
|
||||||
import com.android.settings.accessibility.ColorAndMotionFragment;
|
import com.android.settings.accessibility.ColorAndMotionFragment;
|
||||||
import com.android.settings.accessibility.HearingDevicePairingFragment;
|
import com.android.settings.accessibility.HearingDevicePairingFragment;
|
||||||
@@ -258,6 +259,7 @@ public class SettingsGateway {
|
|||||||
EditShortcutsPreferenceFragment.class.getName(),
|
EditShortcutsPreferenceFragment.class.getName(),
|
||||||
TextReadingPreferenceFragment.class.getName(),
|
TextReadingPreferenceFragment.class.getName(),
|
||||||
TextReadingPreferenceFragmentForSetupWizard.class.getName(),
|
TextReadingPreferenceFragmentForSetupWizard.class.getName(),
|
||||||
|
AutoBrightnessPreferenceFragmentForSetupWizard.class.getName(),
|
||||||
CaptioningPropertiesFragment.class.getName(),
|
CaptioningPropertiesFragment.class.getName(),
|
||||||
ToggleDaltonizerPreferenceFragment.class.getName(),
|
ToggleDaltonizerPreferenceFragment.class.getName(),
|
||||||
ToggleColorInversionPreferenceFragment.class.getName(),
|
ToggleColorInversionPreferenceFragment.class.getName(),
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.provider.Settings;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.accessibility.Flags;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
import com.android.settingslib.PrimarySwitchPreference;
|
import com.android.settingslib.PrimarySwitchPreference;
|
||||||
|
|
||||||
@@ -33,10 +34,16 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
|||||||
private final String SYSTEM_KEY = SCREEN_BRIGHTNESS_MODE;
|
private final String SYSTEM_KEY = SCREEN_BRIGHTNESS_MODE;
|
||||||
private final int DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL;
|
private final int DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||||
|
|
||||||
|
private boolean mInSetupWizard;
|
||||||
|
|
||||||
public AutoBrightnessPreferenceController(Context context, String key) {
|
public AutoBrightnessPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInSetupWizard(boolean inSetupWizard) {
|
||||||
|
mInSetupWizard = inSetupWizard;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return Settings.System.getInt(mContext.getContentResolver(),
|
return Settings.System.getInt(mContext.getContentResolver(),
|
||||||
@@ -53,10 +60,14 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
|||||||
@Override
|
@Override
|
||||||
@AvailabilityStatus
|
@AvailabilityStatus
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return mContext.getResources().getBoolean(
|
if (!mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_automatic_brightness_available)
|
com.android.internal.R.bool.config_automatic_brightness_available)) {
|
||||||
? AVAILABLE_UNSEARCHABLE
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
}
|
||||||
|
if (mInSetupWizard && !Flags.addBrightnessSettingsInSuw()) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
return AVAILABLE_UNSEARCHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static com.android.settingslib.display.BrightnessUtils.GAMMA_SPACE_MAX;
|
|||||||
import static com.android.settingslib.display.BrightnessUtils.GAMMA_SPACE_MIN;
|
import static com.android.settingslib.display.BrightnessUtils.GAMMA_SPACE_MIN;
|
||||||
import static com.android.settingslib.display.BrightnessUtils.convertLinearToGammaFloat;
|
import static com.android.settingslib.display.BrightnessUtils.convertLinearToGammaFloat;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -39,10 +40,12 @@ import android.text.TextUtils;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.accessibility.Flags;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settings.core.SettingsBaseActivity;
|
import com.android.settings.core.SettingsBaseActivity;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
@@ -51,17 +54,18 @@ import com.android.settingslib.transition.SettingsTransitionHelper;
|
|||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
public class BrightnessLevelPreferenceController extends AbstractPreferenceController implements
|
public class BrightnessLevelPreferenceController extends BasePreferenceController implements
|
||||||
PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop {
|
PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop {
|
||||||
|
|
||||||
private static final String TAG = "BrightnessPrefCtrl";
|
private static final String TAG = "BrightnessPrefCtrl";
|
||||||
private static final String KEY_BRIGHTNESS = "brightness";
|
|
||||||
private static final Uri BRIGHTNESS_ADJ_URI;
|
private static final Uri BRIGHTNESS_ADJ_URI;
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||||
private final DisplayManager mDisplayManager;
|
private final DisplayManager mDisplayManager;
|
||||||
|
@Nullable
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
private boolean mInSetupWizard;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BRIGHTNESS_ADJ_URI = System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ);
|
BRIGHTNESS_ADJ_URI = System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ);
|
||||||
@@ -90,9 +94,12 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle) {
|
public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle) {
|
||||||
super(context);
|
this(context, context.getString(R.string.preference_key_brightness_level), lifecycle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BrightnessLevelPreferenceController(Context context, String key, Lifecycle lifecycle) {
|
||||||
|
super(context, key);
|
||||||
mDisplayManager = context.getSystemService(DisplayManager.class);
|
mDisplayManager = context.getSystemService(DisplayManager.class);
|
||||||
|
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
@@ -101,20 +108,22 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
|
|||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setInSetupWizard(boolean inSetupWizard) {
|
||||||
public boolean isAvailable() {
|
mInSetupWizard = inSetupWizard;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public int getAvailabilityStatus() {
|
||||||
return KEY_BRIGHTNESS;
|
if (mInSetupWizard && !Flags.addBrightnessSettingsInSuw()) {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mPreference = screen.findPreference(KEY_BRIGHTNESS);
|
mPreference = screen.findPreference(getPreferenceKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -61,9 +61,8 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
|
mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
|
||||||
// Set up loading text first to prevent layout flaky before info loaded.
|
// Set up empty space text first to prevent layout flaky before info loaded.
|
||||||
mBatteryUsageProgressBarPref.setBottomSummary(
|
mBatteryUsageProgressBarPref.setBottomSummary(" ");
|
||||||
mContext.getString(R.string.settings_license_activity_loading));
|
|
||||||
|
|
||||||
if (com.android.settings.Utils.isBatteryPresent(mContext)) {
|
if (com.android.settings.Utils.isBatteryPresent(mContext)) {
|
||||||
quickUpdateHeaderPreference();
|
quickUpdateHeaderPreference();
|
||||||
@@ -86,13 +85,14 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||||||
return mContext.getString(
|
return mContext.getString(
|
||||||
com.android.settingslib.R.string.battery_info_status_charging_on_hold);
|
com.android.settingslib.R.string.battery_info_status_charging_on_hold);
|
||||||
}
|
}
|
||||||
|
if (info.remainingLabel != null
|
||||||
|
&& mBatterySettingsFeatureProvider.isChargingOptimizationMode(mContext)) {
|
||||||
|
return info.remainingLabel;
|
||||||
|
}
|
||||||
if (info.remainingLabel == null
|
if (info.remainingLabel == null
|
||||||
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
||||||
return info.statusLabel;
|
return info.statusLabel;
|
||||||
}
|
}
|
||||||
if (mBatterySettingsFeatureProvider.isChargingOptimizationMode(mContext)) {
|
|
||||||
return info.remainingLabel;
|
|
||||||
}
|
|
||||||
if (info.pluggedStatus == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
|
if (info.pluggedStatus == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
|
||||||
final CharSequence wirelessChargingLabel =
|
final CharSequence wirelessChargingLabel =
|
||||||
mBatterySettingsFeatureProvider.getWirelessChargingLabel(mContext, info);
|
mBatterySettingsFeatureProvider.getWirelessChargingLabel(mContext, info);
|
||||||
|
|||||||
@@ -390,12 +390,37 @@ public class BatteryInfo {
|
|||||||
info.remainingLabel = null;
|
info.remainingLabel = null;
|
||||||
int chargingLimitedResId = R.string.power_charging_limited;
|
int chargingLimitedResId = R.string.power_charging_limited;
|
||||||
info.chargeLabel = context.getString(chargingLimitedResId, info.batteryPercentString);
|
info.chargeLabel = context.getString(chargingLimitedResId, info.batteryPercentString);
|
||||||
} else if ((chargeTimeMs > 0
|
return;
|
||||||
|
}
|
||||||
|
final BatterySettingsFeatureProvider featureProvider =
|
||||||
|
FeatureFactory.getFeatureFactory().getBatterySettingsFeatureProvider();
|
||||||
|
if (featureProvider.isChargingOptimizationMode(context)) {
|
||||||
|
final CharSequence chargeLabel =
|
||||||
|
featureProvider.getChargingOptimizationChargeLabel(
|
||||||
|
context,
|
||||||
|
info.batteryLevel,
|
||||||
|
info.batteryPercentString,
|
||||||
|
chargeTimeMs,
|
||||||
|
currentTimeMs);
|
||||||
|
if (chargeLabel != null) {
|
||||||
|
final CharSequence remainingLabel =
|
||||||
|
featureProvider.getChargingOptimizationRemainingLabel(
|
||||||
|
context,
|
||||||
|
info.batteryLevel,
|
||||||
|
info.pluggedStatus,
|
||||||
|
chargeTimeMs,
|
||||||
|
currentTimeMs);
|
||||||
|
if (remainingLabel != null) {
|
||||||
|
info.chargeLabel = chargeLabel;
|
||||||
|
info.remainingLabel = remainingLabel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((chargeTimeMs > 0
|
||||||
&& status != BatteryManager.BATTERY_STATUS_FULL
|
&& status != BatteryManager.BATTERY_STATUS_FULL
|
||||||
&& dockDefenderMode == BatteryUtils.DockDefenderMode.DISABLED)
|
&& dockDefenderMode == BatteryUtils.DockDefenderMode.DISABLED)
|
||||||
|| dockDefenderMode == BatteryUtils.DockDefenderMode.TEMPORARILY_BYPASSED) {
|
|| dockDefenderMode == BatteryUtils.DockDefenderMode.TEMPORARILY_BYPASSED) {
|
||||||
final BatterySettingsFeatureProvider featureProvider =
|
|
||||||
FeatureFactory.getFeatureFactory().getBatterySettingsFeatureProvider();
|
|
||||||
// Battery is charging to full
|
// Battery is charging to full
|
||||||
info.remainingTimeUs = PowerUtil.convertMsToUs(chargeTimeMs);
|
info.remainingTimeUs = PowerUtil.convertMsToUs(chargeTimeMs);
|
||||||
int resId = getChargingDurationResId(info.isFastCharging);
|
int resId = getChargingDurationResId(info.isFastCharging);
|
||||||
@@ -419,8 +444,7 @@ public class BatteryInfo {
|
|||||||
info.batteryPercentString,
|
info.batteryPercentString,
|
||||||
chargeTimeMs,
|
chargeTimeMs,
|
||||||
info.isFastCharging,
|
info.isFastCharging,
|
||||||
currentTimeMs,
|
currentTimeMs);
|
||||||
featureProvider);
|
|
||||||
} else if (dockDefenderMode == BatteryUtils.DockDefenderMode.FUTURE_BYPASS) {
|
} else if (dockDefenderMode == BatteryUtils.DockDefenderMode.FUTURE_BYPASS) {
|
||||||
// Dock defender will be triggered in the future, charging will be optimized.
|
// Dock defender will be triggered in the future, charging will be optimized.
|
||||||
info.chargeLabel =
|
info.chargeLabel =
|
||||||
@@ -447,14 +471,6 @@ public class BatteryInfo {
|
|||||||
int pluggedStatus,
|
int pluggedStatus,
|
||||||
long currentTimeMs,
|
long currentTimeMs,
|
||||||
BatterySettingsFeatureProvider featureProvider) {
|
BatterySettingsFeatureProvider featureProvider) {
|
||||||
if (featureProvider.isChargingOptimizationMode(context)) {
|
|
||||||
final CharSequence chargingOptimizationRemainingLabel =
|
|
||||||
featureProvider.getChargingOptimizationRemainingLabel(
|
|
||||||
context, chargeRemainingTimeMs, currentTimeMs);
|
|
||||||
if (chargingOptimizationRemainingLabel != null) {
|
|
||||||
return chargingOptimizationRemainingLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pluggedStatus == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
|
if (pluggedStatus == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
|
||||||
final CharSequence wirelessChargingRemainingLabel =
|
final CharSequence wirelessChargingRemainingLabel =
|
||||||
featureProvider.getWirelessChargingRemainingLabel(
|
featureProvider.getWirelessChargingRemainingLabel(
|
||||||
@@ -488,16 +504,7 @@ public class BatteryInfo {
|
|||||||
String batteryPercentString,
|
String batteryPercentString,
|
||||||
long chargeTimeMs,
|
long chargeTimeMs,
|
||||||
boolean isFastCharging,
|
boolean isFastCharging,
|
||||||
long currentTimeMs,
|
long currentTimeMs) {
|
||||||
BatterySettingsFeatureProvider featureProvider) {
|
|
||||||
if (featureProvider.isChargingOptimizationMode(context)) {
|
|
||||||
final CharSequence chargingOptimizationChargeLabel =
|
|
||||||
featureProvider.getChargingOptimizationChargeLabel(
|
|
||||||
context, batteryPercentString, chargeTimeMs, currentTimeMs);
|
|
||||||
if (chargingOptimizationChargeLabel != null) {
|
|
||||||
return chargingOptimizationChargeLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (com.android.settingslib.fuelgauge.BatteryUtils.isChargingStringV2Enabled()) {
|
if (com.android.settingslib.fuelgauge.BatteryUtils.isChargingStringV2Enabled()) {
|
||||||
var timeString =
|
var timeString =
|
||||||
PowerUtil.getTargetTimeShortString(context, chargeTimeMs, currentTimeMs);
|
PowerUtil.getTargetTimeShortString(context, chargeTimeMs, currentTimeMs);
|
||||||
|
|||||||
@@ -60,13 +60,18 @@ public interface BatterySettingsFeatureProvider {
|
|||||||
/** Return a charging remaining time label for charging optimization mode. */
|
/** Return a charging remaining time label for charging optimization mode. */
|
||||||
@Nullable
|
@Nullable
|
||||||
CharSequence getChargingOptimizationRemainingLabel(
|
CharSequence getChargingOptimizationRemainingLabel(
|
||||||
@NonNull Context context, long chargeRemainingTimeMs, long currentTimeMs);
|
@NonNull Context context,
|
||||||
|
int batteryLevel,
|
||||||
|
int pluggedStatus,
|
||||||
|
long chargeRemainingTimeMs,
|
||||||
|
long currentTimeMs);
|
||||||
|
|
||||||
/** Return a charge label for charging optimization mode. */
|
/** Return a charge label for charging optimization mode. */
|
||||||
@Nullable
|
@Nullable
|
||||||
CharSequence getChargingOptimizationChargeLabel(
|
CharSequence getChargingOptimizationChargeLabel(
|
||||||
@NonNull Context context,
|
@NonNull Context context,
|
||||||
@NonNull String batteryPercentageString,
|
int batteryLevel,
|
||||||
|
String batteryPercentageString,
|
||||||
long chargeRemainingTimeMs,
|
long chargeRemainingTimeMs,
|
||||||
long currentTimeMs);
|
long currentTimeMs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,11 @@ public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatur
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getChargingOptimizationRemainingLabel(
|
public CharSequence getChargingOptimizationRemainingLabel(
|
||||||
@NonNull Context context, long chargeRemainingTimeMs, long currentTimeMs) {
|
@NonNull Context context,
|
||||||
|
int batteryLevel,
|
||||||
|
int pluggedStatus,
|
||||||
|
long chargeRemainingTimeMs,
|
||||||
|
long currentTimeMs) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +88,8 @@ public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatur
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getChargingOptimizationChargeLabel(
|
public CharSequence getChargingOptimizationChargeLabel(
|
||||||
@NonNull Context context,
|
@NonNull Context context,
|
||||||
@NonNull String batteryPercentageString,
|
int batteryLevel,
|
||||||
|
String batteryPercentageString,
|
||||||
long chargeRemainingTimeMs,
|
long chargeRemainingTimeMs,
|
||||||
long currentTimeMs) {
|
long currentTimeMs) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -159,6 +159,11 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
|||||||
com.android.settingslib.R.string.power_charging_on_hold_settings_home_page,
|
com.android.settingslib.R.string.power_charging_on_hold_settings_home_page,
|
||||||
info.batteryPercentString);
|
info.batteryPercentString);
|
||||||
}
|
}
|
||||||
|
final BatterySettingsFeatureProvider featureProvider =
|
||||||
|
FeatureFactory.getFeatureFactory().getBatterySettingsFeatureProvider();
|
||||||
|
if (info.chargeLabel != null && featureProvider.isChargingOptimizationMode(mContext)) {
|
||||||
|
return info.chargeLabel;
|
||||||
|
}
|
||||||
if (info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
if (info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
||||||
// Present status only if no remaining time or status anomalous
|
// Present status only if no remaining time or status anomalous
|
||||||
return info.statusLabel;
|
return info.statusLabel;
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public class CallsDefaultSubscriptionController extends DefaultSubscriptionContr
|
|||||||
super(context, preferenceKey, lifecycle, lifecycleOwner);
|
super(context, preferenceKey, lifecycle, lifecycleOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CallsDefaultSubscriptionController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDefaultSubscriptionId() {
|
protected int getDefaultSubscriptionId() {
|
||||||
int defaultCallSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
|
int defaultCallSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
|
||||||
|
|||||||
@@ -68,15 +68,19 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo
|
|||||||
|
|
||||||
public ConvertToEsimPreferenceController(Context context, String key, Lifecycle lifecycle,
|
public ConvertToEsimPreferenceController(Context context, String key, Lifecycle lifecycle,
|
||||||
LifecycleOwner lifecycleOwner, int subId) {
|
LifecycleOwner lifecycleOwner, int subId) {
|
||||||
super(context, key);
|
this(context, key);
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
|
||||||
mLifecycleOwner = lifecycleOwner;
|
mLifecycleOwner = lifecycleOwner;
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConvertToEsimPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||||
|
}
|
||||||
|
|
||||||
public void init(int subId, SubscriptionInfoEntity subInfoEntity) {
|
public void init(int subId, SubscriptionInfoEntity subInfoEntity) {
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
mSubscriptionInfoEntity = subInfoEntity;
|
mSubscriptionInfoEntity = subInfoEntity;
|
||||||
|
|||||||
@@ -64,16 +64,20 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
|
|||||||
|
|
||||||
public DefaultSubscriptionController(Context context, String preferenceKey, Lifecycle lifecycle,
|
public DefaultSubscriptionController(Context context, String preferenceKey, Lifecycle lifecycle,
|
||||||
LifecycleOwner lifecycleOwner) {
|
LifecycleOwner lifecycleOwner) {
|
||||||
|
this(context, preferenceKey);
|
||||||
|
mLifecycleOwner = lifecycleOwner;
|
||||||
|
if (lifecycle != null) {
|
||||||
|
lifecycle.addObserver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultSubscriptionController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mManager = context.getSystemService(SubscriptionManager.class);
|
mManager = context.getSystemService(SubscriptionManager.class);
|
||||||
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
|
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
|
||||||
== View.LAYOUT_DIRECTION_RTL;
|
== View.LAYOUT_DIRECTION_RTL;
|
||||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||||
mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
|
mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
|
||||||
mLifecycleOwner = lifecycleOwner;
|
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the id of the default subscription for the service, or
|
/** @return the id of the default subscription for the service, or
|
||||||
|
|||||||
@@ -73,16 +73,20 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
|
|
||||||
public MobileDataPreferenceController(Context context, String key, Lifecycle lifecycle,
|
public MobileDataPreferenceController(Context context, String key, Lifecycle lifecycle,
|
||||||
LifecycleOwner lifecycleOwner, int subId) {
|
LifecycleOwner lifecycleOwner, int subId) {
|
||||||
super(context, key);
|
this(context, key);
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
|
||||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
|
||||||
mLifecycleOwner = lifecycleOwner;
|
mLifecycleOwner = lifecycleOwner;
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MobileDataPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||||
|
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus(int subId) {
|
public int getAvailabilityStatus(int subId) {
|
||||||
if (Flags.isDualSimOnboardingEnabled()) {
|
if (Flags.isDualSimOnboardingEnabled()) {
|
||||||
|
|||||||
@@ -709,12 +709,13 @@ public class MobileNetworkUtils {
|
|||||||
return tm.getNetworkOperatorName();
|
return tm.getNetworkOperatorName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] getActiveSubscriptionIdList(Context context) {
|
@VisibleForTesting
|
||||||
|
static int[] getActiveSubscriptionIdList(Context context) {
|
||||||
final SubscriptionManager subscriptionManager = context.getSystemService(
|
final SubscriptionManager subscriptionManager = context.getSystemService(
|
||||||
SubscriptionManager.class).createForAllUserProfiles();
|
SubscriptionManager.class).createForAllUserProfiles();
|
||||||
final List<SubscriptionInfo> subInfoList =
|
final List<SubscriptionInfo> subInfoList =
|
||||||
subscriptionManager.getActiveSubscriptionInfoList();
|
SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
|
||||||
if (subInfoList == null) {
|
if (subInfoList == null || subInfoList.isEmpty()) {
|
||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
int[] activeSubIds = new int[subInfoList.size()];
|
int[] activeSubIds = new int[subInfoList.size()];
|
||||||
|
|||||||
@@ -63,16 +63,20 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
|
|||||||
|
|
||||||
public RoamingPreferenceController(Context context, String key, Lifecycle lifecycle,
|
public RoamingPreferenceController(Context context, String key, Lifecycle lifecycle,
|
||||||
LifecycleOwner lifecycleOwner, int subId) {
|
LifecycleOwner lifecycleOwner, int subId) {
|
||||||
super(context, key);
|
this(context, key);
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
|
||||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
|
||||||
mLifecycleOwner = lifecycleOwner;
|
mLifecycleOwner = lifecycleOwner;
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RoamingPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||||
|
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public class SmsDefaultSubscriptionController extends DefaultSubscriptionControl
|
|||||||
.getBoolean(com.android.internal.R.bool.config_sms_ask_every_time_support);
|
.getBoolean(com.android.internal.R.bool.config_sms_ask_every_time_support);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SmsDefaultSubscriptionController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
mIsAskEverytimeSupported = mContext.getResources()
|
||||||
|
.getBoolean(com.android.internal.R.bool.config_sms_ask_every_time_support);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDefaultSubscriptionId() {
|
protected int getDefaultSubscriptionId() {
|
||||||
int defaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId();
|
int defaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.modes;
|
||||||
|
|
||||||
|
import android.app.AutomaticZenRule;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ZenModeFragment extends ZenModeFragmentBase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.modes_rule_settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
|
// TODO: fill in with all the elements of this page. Each should be an instance of
|
||||||
|
// {@link AbstractZenModePreferenceController}.
|
||||||
|
List<AbstractPreferenceController> prefControllers = new ArrayList<>();
|
||||||
|
return prefControllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
// Set title for the entire screen
|
||||||
|
ZenMode mode = getMode();
|
||||||
|
AutomaticZenRule azr = getAZR();
|
||||||
|
if (mode == null || azr == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getActivity().setTitle(azr.getName());
|
||||||
|
|
||||||
|
// TODO: b/308819292 - implement the real screen!
|
||||||
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
if (screen == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preference tmpPref = screen.findPreference("zen_mode_test");
|
||||||
|
if (tmpPref == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tmpPref.setTitle(azr.getTriggerDescription());
|
||||||
|
tmpPref.setSummary("active?: " + mode.isActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
// TODO: b/332937635 - make this the correct metrics category
|
||||||
|
return SettingsEnums.NOTIFICATION_ZEN_MODE_AUTOMATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.modes;
|
||||||
|
|
||||||
|
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
|
import com.android.settings.notification.zen.ZenModeSettings;
|
||||||
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference representing a single mode item on the modes aggregator page. Clicking on this
|
||||||
|
* preference leads to an individual mode's configuration page.
|
||||||
|
*/
|
||||||
|
public class ZenModeListPreference extends RestrictedPreference {
|
||||||
|
final Context mContext;
|
||||||
|
ZenMode mZenMode;
|
||||||
|
|
||||||
|
ZenModeListPreference(Context context, ZenMode zenMode) {
|
||||||
|
super(context);
|
||||||
|
mContext = context;
|
||||||
|
mZenMode = zenMode;
|
||||||
|
setTitle(mZenMode.getRule().getName());
|
||||||
|
setSummary((mZenMode.isActive() ? "ACTIVE" : "inactive") + ": "
|
||||||
|
+ mZenMode.getRule().getTriggerDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick() {
|
||||||
|
// TODO: b/322373473 - This implementation is a hack that just leads to the old DND page
|
||||||
|
// for manual only; remove this in favor of the real implementation.
|
||||||
|
if (mZenMode.isManualDnd()) {
|
||||||
|
new SubSettingLauncher(mContext)
|
||||||
|
.setDestination(ZenModeSettings.class.getName())
|
||||||
|
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_ZEN_MODE)
|
||||||
|
.launch();
|
||||||
|
} else {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(MODE_ID, mZenMode.getId());
|
||||||
|
new SubSettingLauncher(mContext)
|
||||||
|
.setDestination(ZenModeFragment.class.getName())
|
||||||
|
.setArguments(bundle)
|
||||||
|
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_ZEN_MODE_AUTOMATION)
|
||||||
|
.launch();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.modes;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.service.notification.ConditionProviderService;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settings.utils.ManagedServiceSettings;
|
||||||
|
import com.android.settings.utils.ZenServiceListing;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SearchIndexable
|
||||||
|
public class ZenModesListFragment extends ZenModesFragmentBase {
|
||||||
|
protected final ManagedServiceSettings.Config CONFIG = getConditionProviderConfig();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
|
ZenServiceListing serviceListing = new ZenServiceListing(getContext(), CONFIG);
|
||||||
|
serviceListing.reloadApprovedServices();
|
||||||
|
return buildPreferenceControllers(context, this, serviceListing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||||
|
@Nullable Fragment parent, @Nullable ZenServiceListing serviceListing) {
|
||||||
|
// We need to redefine ZenModesBackend here even though mBackend exists so that this method
|
||||||
|
// can be static; it must be static to be able to be used in SEARCH_INDEX_DATA_PROVIDER.
|
||||||
|
ZenModesBackend backend = ZenModesBackend.getInstance(context);
|
||||||
|
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
|
controllers.add(new ZenModesListPreferenceController(
|
||||||
|
context, parent, backend));
|
||||||
|
|
||||||
|
// TODO: b/326442408 - Add controller for "Add Mode" preference/flow, which is what uses
|
||||||
|
// the ZenServiceListing.
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateZenModeState() {
|
||||||
|
// TODO: b/322373473 -- update any overall description of modes state here if necessary.
|
||||||
|
// Note the preferences linking to individual rules do not need to be updated, as
|
||||||
|
// updateState() is called on all preference controllers whenever the page is resumed.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.modes_list_settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
// TODO: b/332937635 - add new & set metrics categories correctly
|
||||||
|
return SettingsEnums.NOTIFICATION_ZEN_MODE_AUTOMATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static ManagedServiceSettings.Config getConditionProviderConfig() {
|
||||||
|
return new ManagedServiceSettings.Config.Builder()
|
||||||
|
.setTag(TAG)
|
||||||
|
.setIntentAction(ConditionProviderService.SERVICE_INTERFACE)
|
||||||
|
.setConfigurationIntentAction(NotificationManager.ACTION_AUTOMATIC_ZEN_RULE)
|
||||||
|
.setPermission(android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE)
|
||||||
|
.setNoun("condition provider")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: b/322373473 - Add 3-dot options menu with capability to delete modes.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For Search.
|
||||||
|
*/
|
||||||
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider(R.xml.modes_list_settings) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
|
final List<String> keys = super.getNonIndexableKeys(context);
|
||||||
|
// TODO: b/332937523 - determine if this should be removed once the preference
|
||||||
|
// controller adds dynamic data to index
|
||||||
|
keys.add(ZenModesListPreferenceController.KEY);
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||||
|
Context context) {
|
||||||
|
return buildPreferenceControllers(context, null, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.modes;
|
||||||
|
|
||||||
|
import android.app.Flags;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
|
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for the PreferenceCategory on the modes aggregator page ({@link ZenModesListFragment})
|
||||||
|
* containing links to each individual mode. This is a central controller that populates and updates
|
||||||
|
* all the preferences that then lead to a mode configuration page.
|
||||||
|
*/
|
||||||
|
public class ZenModesListPreferenceController extends AbstractPreferenceController {
|
||||||
|
protected static final String KEY = "zen_modes_list";
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected Fragment mParent;
|
||||||
|
protected ZenModesBackend mBackend;
|
||||||
|
|
||||||
|
public ZenModesListPreferenceController(Context context, @Nullable Fragment parent,
|
||||||
|
@NonNull ZenModesBackend backend) {
|
||||||
|
super(context);
|
||||||
|
mParent = parent;
|
||||||
|
mBackend = backend;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return Flags.modesUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
if (mBackend == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The preference given us is a PreferenceCategory; create one preference inside the
|
||||||
|
// category for each rule that exists.
|
||||||
|
PreferenceCategory category = (PreferenceCategory) preference;
|
||||||
|
|
||||||
|
// TODO: b/322373473 - This is not the right way to replace these preferences; we should
|
||||||
|
// follow something similar to what
|
||||||
|
// ZenModeAutomaticRulesPreferenceController does to change rules
|
||||||
|
// only as necessary and update them.
|
||||||
|
category.removeAll();
|
||||||
|
|
||||||
|
for (ZenMode mode : mBackend.getModes()) {
|
||||||
|
Preference pref = new ZenModeListPreference(mContext, mode);
|
||||||
|
category.addPreference(pref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification.zen;
|
package com.android.settings.notification.zen;
|
||||||
|
|
||||||
|
import android.app.Flags;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@@ -27,7 +28,9 @@ import android.provider.Settings;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.notification.modes.ZenModesListFragment;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
@@ -46,7 +49,9 @@ public class ZenModePreferenceController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mSettingObserver = new SettingObserver(screen.findPreference(getPreferenceKey()));
|
Preference preference = screen.findPreference(getPreferenceKey());
|
||||||
|
mSettingObserver = new SettingObserver(preference);
|
||||||
|
maybeSetTitleAndDestination(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -71,11 +76,22 @@ public class ZenModePreferenceController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
|
maybeSetTitleAndDestination(preference);
|
||||||
if (preference.isEnabled()) {
|
if (preference.isEnabled()) {
|
||||||
preference.setSummary(mSummaryBuilder.getSoundSummary());
|
preference.setSummary(mSummaryBuilder.getSoundSummary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only when modes_ui is active: change title & target fragment.
|
||||||
|
private void maybeSetTitleAndDestination(Preference preference) {
|
||||||
|
if (!Flags.modesUi()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
preference.setTitle(R.string.zen_modes_list_title);
|
||||||
|
preference.setFragment(ZenModesListFragment.class.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
class SettingObserver extends ContentObserver {
|
class SettingObserver extends ContentObserver {
|
||||||
private final Uri ZEN_MODE_URI = Settings.Global.getUriFor(Settings.Global.ZEN_MODE);
|
private final Uri ZEN_MODE_URI = Settings.Global.getUriFor(Settings.Global.ZEN_MODE);
|
||||||
private final Uri ZEN_MODE_CONFIG_ETAG_URI = Settings.Global.getUriFor(
|
private final Uri ZEN_MODE_CONFIG_ETAG_URI = Settings.Global.getUriFor(
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package com.android.settings.privatespace;
|
|||||||
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
|
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
|
||||||
import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
|
import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
|
||||||
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
|
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
|
||||||
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_AFTER_DEVICE_RESTART;
|
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK;
|
||||||
import static android.provider.Settings.Secure.SKIP_FIRST_USE_HINTS;
|
import static android.provider.Settings.Secure.SKIP_FIRST_USE_HINTS;
|
||||||
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class PrivateSpaceMaintainer {
|
|||||||
/** Default value for private space auto lock settings. */
|
/** Default value for private space auto lock settings. */
|
||||||
@Settings.Secure.PrivateSpaceAutoLockOption
|
@Settings.Secure.PrivateSpaceAutoLockOption
|
||||||
public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL =
|
public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL =
|
||||||
PRIVATE_SPACE_AUTO_LOCK_AFTER_DEVICE_RESTART;
|
PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK;
|
||||||
/** Default value for the hide private space sensitive notifications on lockscreen. */
|
/** Default value for the hide private space sensitive notifications on lockscreen. */
|
||||||
public static final int HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL = 0;
|
public static final int HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.system
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.ResolveInfo
|
||||||
|
|
||||||
|
import androidx.preference.Preference
|
||||||
|
|
||||||
|
import com.android.settings.R
|
||||||
|
import com.android.settings.core.BasePreferenceController
|
||||||
|
import com.android.settings.flags.Flags
|
||||||
|
|
||||||
|
class DeviceDiagnosticsPreferenceController(context: Context, preferenceKey: String) :
|
||||||
|
BasePreferenceController(context, preferenceKey) {
|
||||||
|
|
||||||
|
override fun getAvailabilityStatus(): Int {
|
||||||
|
if (!Flags.enableDeviceDiagnosticsInSettings()) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE
|
||||||
|
}
|
||||||
|
if (getIntent() == null) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE
|
||||||
|
}
|
||||||
|
return AVAILABLE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
|
||||||
|
if (preferenceKey != preference.key) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
val intent = getIntent()
|
||||||
|
if (intent == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
preference.getContext().startActivity(intent)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getIntent(): Intent? {
|
||||||
|
val intent = Intent(Intent.ACTION_MAIN)
|
||||||
|
|
||||||
|
val packageName = mContext.getResources().getString(
|
||||||
|
R.string.config_device_diagnostics_package_name)
|
||||||
|
intent.setPackage(packageName)
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
return intent
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,8 +63,7 @@ public class MultiUserSwitchBarController implements SwitchWidgetController.OnSw
|
|||||||
.checkIfRestrictionEnforced(mContext, UserManager.DISALLOW_ADD_USER,
|
.checkIfRestrictionEnforced(mContext, UserManager.DISALLOW_ADD_USER,
|
||||||
UserHandle.myUserId()));
|
UserHandle.myUserId()));
|
||||||
} else {
|
} else {
|
||||||
mSwitchBar.setEnabled(!mUserCapabilities.mDisallowSwitchUser
|
mSwitchBar.setEnabled(mUserCapabilities.mIsMain);
|
||||||
&& !mUserCapabilities.mIsGuest && mUserCapabilities.isAdmin());
|
|
||||||
}
|
}
|
||||||
mSwitchBar.setListener(this);
|
mSwitchBar.setListener(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class UserCapabilities {
|
|||||||
boolean mEnabled = true;
|
boolean mEnabled = true;
|
||||||
boolean mCanAddUser = true;
|
boolean mCanAddUser = true;
|
||||||
boolean mCanAddRestrictedProfile;
|
boolean mCanAddRestrictedProfile;
|
||||||
|
boolean mIsMain;
|
||||||
boolean mIsAdmin;
|
boolean mIsAdmin;
|
||||||
boolean mIsGuest;
|
boolean mIsGuest;
|
||||||
boolean mIsEphemeral;
|
boolean mIsEphemeral;
|
||||||
@@ -57,6 +58,7 @@ public class UserCapabilities {
|
|||||||
final UserInfo myUserInfo = userManager.getUserInfo(UserHandle.myUserId());
|
final UserInfo myUserInfo = userManager.getUserInfo(UserHandle.myUserId());
|
||||||
caps.mIsGuest = myUserInfo.isGuest();
|
caps.mIsGuest = myUserInfo.isGuest();
|
||||||
caps.mIsAdmin = myUserInfo.isAdmin();
|
caps.mIsAdmin = myUserInfo.isAdmin();
|
||||||
|
caps.mIsMain = myUserInfo.isMain();
|
||||||
caps.mIsEphemeral = myUserInfo.isEphemeral();
|
caps.mIsEphemeral = myUserInfo.isEphemeral();
|
||||||
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
|
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
|
||||||
Context.DEVICE_POLICY_SERVICE);
|
Context.DEVICE_POLICY_SERVICE);
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||||
final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
|
final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
|
||||||
switchBar.setTitle(getContext().getString(R.string.multiple_users_main_switch_title));
|
switchBar.setTitle(getContext().getString(R.string.multiple_users_main_switch_title));
|
||||||
if (isCurrentUserAdmin()) {
|
if (!mUserCaps.mIsGuest) {
|
||||||
switchBar.show();
|
switchBar.show();
|
||||||
} else {
|
} else {
|
||||||
switchBar.hide();
|
switchBar.hide();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import static com.android.settings.accessibility.AccessibilitySettingsForSetupWi
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -45,7 +46,10 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.display.AutoBrightnessPreferenceController;
|
||||||
|
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||||
import com.google.android.setupdesign.GlifPreferenceLayout;
|
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||||
@@ -88,7 +92,7 @@ public class AccessibilitySettingsForSetupWizardTest {
|
|||||||
private GlifPreferenceLayout mGlifLayoutView;
|
private GlifPreferenceLayout mGlifLayoutView;
|
||||||
@Mock
|
@Mock
|
||||||
private FooterBarMixin mFooterBarMixin;
|
private FooterBarMixin mFooterBarMixin;
|
||||||
private AccessibilitySettingsForSetupWizard mFragment;
|
private TestAccessibilitySettingsForSetupWizard mFragment;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -141,6 +145,19 @@ public class AccessibilitySettingsForSetupWizardTest {
|
|||||||
assertThat(mFragment.mSelectToSpeakPreference.getKey()).isNull();
|
assertThat(mFragment.mSelectToSpeakPreference.getKey()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createPreferenceControllers_brightnessPreferencesControllersAreCreated() {
|
||||||
|
mFragment.onAttach(mContext);
|
||||||
|
|
||||||
|
List<AbstractPreferenceController> controllers =
|
||||||
|
mFragment.createPreferenceControllers(mContext);
|
||||||
|
|
||||||
|
assertTrue(controllers.stream().anyMatch(
|
||||||
|
controller -> controller instanceof BrightnessLevelPreferenceController));
|
||||||
|
assertTrue(controllers.stream().anyMatch(
|
||||||
|
controller -> controller instanceof AutoBrightnessPreferenceController));
|
||||||
|
}
|
||||||
|
|
||||||
private void addEnabledServiceInfo(ComponentName componentName, boolean isAccessibilityTool) {
|
private void addEnabledServiceInfo(ComponentName componentName, boolean isAccessibilityTool) {
|
||||||
final AccessibilityServiceInfo a11yServiceInfo = mock(AccessibilityServiceInfo.class);
|
final AccessibilityServiceInfo a11yServiceInfo = mock(AccessibilityServiceInfo.class);
|
||||||
when(a11yServiceInfo.getComponentName()).thenReturn(componentName);
|
when(a11yServiceInfo.getComponentName()).thenReturn(componentName);
|
||||||
@@ -170,12 +187,14 @@ public class AccessibilitySettingsForSetupWizardTest {
|
|||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final PreferenceManager mPreferenceManager;
|
private final PreferenceManager mPreferenceManager;
|
||||||
|
final PreferenceScreen mPreferenceScreen;
|
||||||
|
|
||||||
TestAccessibilitySettingsForSetupWizard(Context context) {
|
TestAccessibilitySettingsForSetupWizard(Context context) {
|
||||||
super();
|
super();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPreferenceManager = new PreferenceManager(context);
|
mPreferenceManager = new PreferenceManager(context);
|
||||||
mPreferenceManager.setPreferences(mPreferenceManager.createPreferenceScreen(context));
|
mPreferenceScreen = spy(mPreferenceManager.createPreferenceScreen(context));
|
||||||
|
mPreferenceManager.setPreferences(mPreferenceScreen);
|
||||||
mDisplayMagnificationPreference = new Preference(context);
|
mDisplayMagnificationPreference = new Preference(context);
|
||||||
mScreenReaderPreference = new RestrictedPreference(context);
|
mScreenReaderPreference = new RestrictedPreference(context);
|
||||||
mSelectToSpeakPreference = new RestrictedPreference(context);
|
mSelectToSpeakPreference = new RestrictedPreference(context);
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.accessibility;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
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.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||||
|
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Spy;
|
||||||
|
import org.mockito.junit.MockitoJUnit;
|
||||||
|
import org.mockito.junit.MockitoRule;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
/** Tests for {@link AutoBrightnessPreferenceFragmentForSetupWizard}. */
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class AutoBrightnessPreferenceFragmentForSetupWizardTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final MockitoRule mMockito = MockitoJUnit.rule();
|
||||||
|
|
||||||
|
@Spy
|
||||||
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
@Mock
|
||||||
|
private GlifPreferenceLayout mGlifLayoutView;
|
||||||
|
@Mock
|
||||||
|
private FooterBarMixin mFooterBarMixin;
|
||||||
|
private AutoBrightnessPreferenceFragmentForSetupWizard mFragment;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mFragment = spy(new AutoBrightnessPreferenceFragmentForSetupWizard());
|
||||||
|
doReturn(mock(LifecycleOwner.class)).when(mFragment).getViewLifecycleOwner();
|
||||||
|
doReturn(mContext).when(mFragment).getContext();
|
||||||
|
when(mGlifLayoutView.getMixin(eq(FooterBarMixin.class))).thenReturn(mFooterBarMixin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setHeaderText_onViewCreated_verifyAction() {
|
||||||
|
final String title = "title";
|
||||||
|
doReturn(title).when(mContext).getString(R.string.auto_brightness_title);
|
||||||
|
|
||||||
|
mFragment.onViewCreated(mGlifLayoutView, null);
|
||||||
|
|
||||||
|
verify(mGlifLayoutView).setHeaderText(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMetricsCategory_returnsCorrectCategory() {
|
||||||
|
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||||
|
SettingsEnums.SUW_ACCESSIBILITY_AUTO_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onViewCreated_verifyAction() {
|
||||||
|
mFragment.onViewCreated(mGlifLayoutView, null);
|
||||||
|
|
||||||
|
verify(mFooterBarMixin).setPrimaryButton(any());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,18 +21,24 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
|
|||||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.accessibility.Flags;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@@ -44,6 +50,9 @@ import org.robolectric.annotation.Config;
|
|||||||
@Config(shadows = {SettingsShadowResources.class})
|
@Config(shadows = {SettingsShadowResources.class})
|
||||||
public class AutoBrightnessPreferenceControllerTest {
|
public class AutoBrightnessPreferenceControllerTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
private static final String PREFERENCE_KEY = "auto_brightness";
|
private static final String PREFERENCE_KEY = "auto_brightness";
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -121,13 +130,34 @@ public class AutoBrightnessPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailableUnsearchable() {
|
public void getAvailabilityStatusNotInSUW_configTrueSet_shouldReturnAvailableUnsearchable() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
com.android.internal.R.bool.config_automatic_brightness_available, true);
|
com.android.internal.R.bool.config_automatic_brightness_available, true);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_ADD_BRIGHTNESS_SETTINGS_IN_SUW)
|
||||||
|
public void getAvailabilityStatusInSUW_configTrueAndFlagOn_shouldReturnAvailableUnsearchable() {
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
com.android.internal.R.bool.config_automatic_brightness_available, true);
|
||||||
|
mController.setInSetupWizard(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_ADD_BRIGHTNESS_SETTINGS_IN_SUW)
|
||||||
|
public void
|
||||||
|
getAvailabilityStatusInSUW_configTrueAndFlagOff_shouldReturnConditionallyUnavailable() {
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
com.android.internal.R.bool.config_automatic_brightness_available, true);
|
||||||
|
mController.setInSetupWizard(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
|
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
|
|||||||
@@ -33,16 +33,22 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.display.BrightnessInfo;
|
import android.hardware.display.BrightnessInfo;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings.System;
|
import android.provider.Settings.System;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.accessibility.Flags;
|
||||||
import com.android.settings.core.SettingsBaseActivity;
|
import com.android.settings.core.SettingsBaseActivity;
|
||||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -58,6 +64,9 @@ import org.robolectric.shadows.ShadowContentResolver;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class BrightnessLevelPreferenceControllerTest {
|
public class BrightnessLevelPreferenceControllerTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PowerManager mPowerManager;
|
private PowerManager mPowerManager;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -90,10 +99,24 @@ public class BrightnessLevelPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_shouldAlwaysReturnTrue() {
|
public void isAvailable_shouldAlwaysReturnTrueWhenNotInSetupWizard() {
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_ADD_BRIGHTNESS_SETTINGS_IN_SUW)
|
||||||
|
public void isAvailable_inSetupWizardAndFlagOn_shouldReturnTrue() {
|
||||||
|
mController.setInSetupWizard(true);
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_ADD_BRIGHTNESS_SETTINGS_IN_SUW)
|
||||||
|
public void isAvailable_inSetupWizardAndFlagOff_shouldReturnFalse() {
|
||||||
|
mController.setInSetupWizard(true);
|
||||||
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onStart_shouldRegisterObserver() {
|
public void onStart_shouldRegisterObserver() {
|
||||||
BrightnessLevelPreferenceController controller =
|
BrightnessLevelPreferenceController controller =
|
||||||
@@ -169,13 +192,14 @@ public class BrightnessLevelPreferenceControllerTest {
|
|||||||
final BrightnessLevelPreferenceController controller =
|
final BrightnessLevelPreferenceController controller =
|
||||||
new BrightnessLevelPreferenceController(activity, null);
|
new BrightnessLevelPreferenceController(activity, null);
|
||||||
final ShadowActivity shadowActivity = shadowOf(activity);
|
final ShadowActivity shadowActivity = shadowOf(activity);
|
||||||
when(mPreference.getKey()).thenReturn("brightness");
|
|
||||||
|
String preferenceKey = mContext.getString(R.string.preference_key_brightness_level);
|
||||||
|
when(mPreference.getKey()).thenReturn(preferenceKey);
|
||||||
|
|
||||||
controller.handlePreferenceTreeClick(mPreference);
|
controller.handlePreferenceTreeClick(mPreference);
|
||||||
|
|
||||||
final Intent intent = shadowActivity.getNextStartedActivity();
|
final Intent intent = shadowActivity.getNextStartedActivity();
|
||||||
assertThat(intent.getIntExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE, 0))
|
assertThat(intent.getIntExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE, 0))
|
||||||
.isEqualTo(SettingsTransitionHelper.TransitionType.TRANSITION_NONE);
|
.isEqualTo(SettingsTransitionHelper.TransitionType.TRANSITION_NONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import android.os.SystemProperties;
|
|||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
||||||
@@ -286,8 +285,9 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
/* isFastCharging= */ true,
|
/* isFastCharging= */ true,
|
||||||
/* isChargingStringV2= */ true);
|
/* isChargingStringV2= */ true);
|
||||||
batteryInfo.pluggedStatus = BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
batteryInfo.pluggedStatus = BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||||
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingLabel(eq(mContext),
|
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingLabel(
|
||||||
any(BatteryInfo.class))).thenReturn(label);
|
eq(mContext), any(BatteryInfo.class)))
|
||||||
|
.thenReturn(label);
|
||||||
|
|
||||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
@@ -326,14 +326,64 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateBatteryStatus_chargingOptimizationMode_remainingLabel() {
|
||||||
|
var batteryInfo =
|
||||||
|
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
|
/* remainingLabel= */ "Expected remaining label",
|
||||||
|
/* statusLabel= */ "Fast Charging",
|
||||||
|
/* isFastCharging= */ true,
|
||||||
|
/* isChargingStringV2= */ true);
|
||||||
|
var expectedChargingString = batteryInfo.remainingLabel;
|
||||||
|
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateBatteryStatus_chargingOptimizationModeNoRemainingLabel_statusLabel() {
|
||||||
|
var batteryInfo =
|
||||||
|
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
|
/* remainingLabel= */ null,
|
||||||
|
/* statusLabel= */ "Fast Charging",
|
||||||
|
/* isFastCharging= */ true,
|
||||||
|
/* isChargingStringV2= */ true);
|
||||||
|
var expectedChargingString = batteryInfo.statusLabel;
|
||||||
|
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateBatteryStatus_notChargingOptimizationMode_statusWithRemainingLabel() {
|
||||||
|
var batteryInfo =
|
||||||
|
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
|
/* remainingLabel= */ "Full by 1:30 PM",
|
||||||
|
/* statusLabel= */ "Fast Charging",
|
||||||
|
/* isFastCharging= */ true,
|
||||||
|
/* isChargingStringV2= */ true);
|
||||||
|
var expectedChargingString = batteryInfo.statusLabel + " • " + batteryInfo.remainingLabel;
|
||||||
|
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||||
|
}
|
||||||
|
|
||||||
private BatteryInfo arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
private BatteryInfo arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
String remainingLabel,
|
String remainingLabel,
|
||||||
String statusLabel,
|
String statusLabel,
|
||||||
boolean isFastCharging,
|
boolean isFastCharging,
|
||||||
boolean isChargingStringV2) {
|
boolean isChargingStringV2) {
|
||||||
SystemProperties.set(
|
SystemProperties.set(
|
||||||
BatteryUtils.PROPERTY_CHARGING_STRING_V2_KEY,
|
BatteryUtils.PROPERTY_CHARGING_STRING_V2_KEY, String.valueOf(isChargingStringV2));
|
||||||
String.valueOf(isChargingStringV2));
|
|
||||||
mBatteryInfo.isBatteryDefender = false;
|
mBatteryInfo.isBatteryDefender = false;
|
||||||
mBatteryInfo.remainingLabel = remainingLabel;
|
mBatteryInfo.remainingLabel = remainingLabel;
|
||||||
mBatteryInfo.statusLabel = statusLabel;
|
mBatteryInfo.statusLabel = statusLabel;
|
||||||
@@ -389,8 +439,11 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateHeaderPreference(mBatteryInfo);
|
mController.updateHeaderPreference(mBatteryInfo);
|
||||||
|
|
||||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(mContext.getString(
|
verify(mBatteryUsageProgressBarPref)
|
||||||
com.android.settingslib.R.string.battery_info_status_charging_on_hold));
|
.setBottomSummary(
|
||||||
|
mContext.getString(
|
||||||
|
com.android.settingslib.R.string
|
||||||
|
.battery_info_status_charging_on_hold));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -429,11 +482,10 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_init_showLoading() {
|
public void displayPreference_init_showEmptySpace() {
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
|
|
||||||
verify(mBatteryUsageProgressBarPref)
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(" ");
|
||||||
.setBottomSummary(mContext.getString(R.string.settings_license_activity_loading));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence formatBatteryPercentageText() {
|
private CharSequence formatBatteryPercentageText() {
|
||||||
|
|||||||
@@ -724,15 +724,15 @@ public class BatteryInfoTest {
|
|||||||
Intent batteryIntent =
|
Intent batteryIntent =
|
||||||
createIntentForGetBatteryInfoTest(
|
createIntentForGetBatteryInfoTest(
|
||||||
ChargingType.WIRED, ChargingSpeed.REGULAR, /* batteryLevel= */ 65);
|
ChargingType.WIRED, ChargingSpeed.REGULAR, /* batteryLevel= */ 65);
|
||||||
var expectedRemainingLabel = "Done charging by";
|
var expectedRemainingLabel = "Expected remaining label";
|
||||||
var expectedChargeLabel = "65% - " + expectedRemainingLabel;
|
var expectedChargeLabel = "65% - " + expectedRemainingLabel;
|
||||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationRemainingLabel(
|
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationRemainingLabel(
|
||||||
eq(mContext), anyLong(), anyLong()))
|
eq(mContext), anyInt(), anyInt(), anyLong(), anyLong()))
|
||||||
.thenReturn(expectedRemainingLabel);
|
.thenReturn(expectedRemainingLabel);
|
||||||
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationChargeLabel(
|
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationChargeLabel(
|
||||||
eq(mContext), anyString(), anyLong(), anyLong()))
|
eq(mContext), anyInt(), anyString(), anyLong(), anyLong()))
|
||||||
.thenReturn(expectedChargeLabel);
|
.thenReturn(expectedChargeLabel);
|
||||||
var expectedStatusLabel = "Charging";
|
var expectedStatusLabel = "Charging";
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.settings.fuelgauge;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.BatteryManager;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
@@ -87,12 +88,15 @@ public class BatterySettingsFeatureProviderImplTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getChargingOptimizationRemainingLabel_default_returnNull() {
|
public void getChargingOptimizationRemainingLabel_default_returnNull() {
|
||||||
assertThat(mImpl.getChargingOptimizationRemainingLabel(mContext, 1000L, 1000L)).isNull();
|
assertThat(
|
||||||
|
mImpl.getChargingOptimizationRemainingLabel(
|
||||||
|
mContext, 75, BatteryManager.BATTERY_PLUGGED_AC, 1000L, 1000L))
|
||||||
|
.isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getChargingOptimizationChargeLabel_default_returnNull() {
|
public void getChargingOptimizationChargeLabel_default_returnNull() {
|
||||||
assertThat(mImpl.getChargingOptimizationChargeLabel(mContext, "70%", 1000L, 1000L))
|
assertThat(mImpl.getChargingOptimizationChargeLabel(mContext, 70, "70%", 1000L, 1000L))
|
||||||
.isNull();
|
.isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,13 @@
|
|||||||
|
|
||||||
package com.android.settings.notification.zen;
|
package com.android.settings.notification.zen;
|
||||||
|
|
||||||
|
import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT;
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -27,13 +30,20 @@ import static org.mockito.Mockito.spy;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.Flags;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.NotificationManager.Policy;
|
import android.app.NotificationManager.Policy;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.notification.modes.ZenModesListFragment;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -46,6 +56,9 @@ import org.robolectric.util.ReflectionHelpers;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class ZenModePreferenceControllerTest {
|
public class ZenModePreferenceControllerTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(DEVICE_DEFAULT);
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -96,4 +109,20 @@ public class ZenModePreferenceControllerTest {
|
|||||||
|
|
||||||
verify(mPreference, never()).setSummary(anyString());
|
verify(mPreference, never()).setSummary(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_MODES_UI)
|
||||||
|
public void updateState_modesUi_resetsTitleAndFragment() {
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
verify(mPreference).setTitle(anyInt()); // Resource IDs are ints
|
||||||
|
verify(mPreference).setFragment(ZenModesListFragment.class.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_MODES_UI)
|
||||||
|
public void updateState_noModesUi_doesNotSetTitleAndFragment() {
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
verify(mPreference, never()).setTitle(anyInt());
|
||||||
|
verify(mPreference, never()).setFragment(anyString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ public class BatteryTestUtils {
|
|||||||
|
|
||||||
/** Create a power anomaly event proto of adaptive brightness. */
|
/** Create a power anomaly event proto of adaptive brightness. */
|
||||||
public static PowerAnomalyEvent createAdaptiveBrightnessAnomalyEvent(boolean changeSettings) {
|
public static PowerAnomalyEvent createAdaptiveBrightnessAnomalyEvent(boolean changeSettings) {
|
||||||
|
// TODO: migrate "auto_brightness_entry" to use R.string.preference_key_auto_brightness
|
||||||
|
// if we can access the Context here. (b/338314718)
|
||||||
WarningBannerInfo.Builder warningBannerInfoBuilder =
|
WarningBannerInfo.Builder warningBannerInfoBuilder =
|
||||||
WarningBannerInfo.newBuilder()
|
WarningBannerInfo.newBuilder()
|
||||||
.setMainButtonDestination(DisplaySettings.class.getName())
|
.setMainButtonDestination(DisplaySettings.class.getName())
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.UserInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
@@ -79,4 +80,26 @@ public class MultiUserSwitchBarControllerTest {
|
|||||||
|
|
||||||
verify(mSwitchWidgetController, never()).setDisabledByAdmin(any());
|
verify(mSwitchWidgetController, never()).setDisabledByAdmin(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onStart_userIsNotMain_shouldNotBeEnabled() {
|
||||||
|
mUserManager.setUserRestriction(UserHandle.of(UserHandle.myUserId()),
|
||||||
|
UserManager.DISALLOW_USER_SWITCH, false);
|
||||||
|
mUserManager.addUser(10, "Test", UserInfo.FLAG_ADMIN);
|
||||||
|
mUserManager.switchUser(10);
|
||||||
|
new MultiUserSwitchBarController(mContext, mSwitchWidgetController, null);
|
||||||
|
|
||||||
|
verify(mSwitchWidgetController, never()).setDisabledByAdmin(any());
|
||||||
|
verify(mSwitchWidgetController).setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onStart_userIsMain_shouldBeEnabled() {
|
||||||
|
mUserManager.setUserRestriction(UserHandle.of(UserHandle.myUserId()),
|
||||||
|
UserManager.DISALLOW_USER_SWITCH, false);
|
||||||
|
new MultiUserSwitchBarController(mContext, mSwitchWidgetController, null);
|
||||||
|
|
||||||
|
verify(mSwitchWidgetController, never()).setDisabledByAdmin(any());
|
||||||
|
verify(mSwitchWidgetController).setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ import androidx.test.core.app.ApplicationProvider;
|
|||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@Ignore("b/340657656")
|
||||||
public class LinkifyUtilsTest {
|
public class LinkifyUtilsTest {
|
||||||
private static final String TEST_STRING = "to LINK_BEGINscanning settingsLINK_END.";
|
private static final String TEST_STRING = "to LINK_BEGINscanning settingsLINK_END.";
|
||||||
private static final String WRONG_STRING = "to scanning settingsLINK_END.";
|
private static final String WRONG_STRING = "to scanning settingsLINK_END.";
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||||||
import com.android.settingslib.net.DataUsageController.DataUsageInfo;
|
import com.android.settingslib.net.DataUsageController.DataUsageInfo;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@Ignore("b/340657656")
|
||||||
public class DataUsageInfoControllerTest {
|
public class DataUsageInfoControllerTest {
|
||||||
|
|
||||||
private static final int ZERO = 0;
|
private static final int ZERO = 0;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package com.android.settings.localepicker;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.app.GrammaticalInflectionManager;
|
import android.app.GrammaticalInflectionManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -34,7 +32,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||||||
import com.android.settings.widget.TickButtonPreference;
|
import com.android.settings.widget.TickButtonPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@@ -62,7 +59,7 @@ public class TermsOfAddressFeminineControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
if (Looper.myLooper() == null) {
|
if (Looper.myLooper() == null) {
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
@@ -93,7 +90,6 @@ public class TermsOfAddressFeminineControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("b/339543490")
|
|
||||||
public void displayPreference_setGrammaticalGenderIsFeminine_FeminineIsSelected() {
|
public void displayPreference_setGrammaticalGenderIsFeminine_FeminineIsSelected() {
|
||||||
TickButtonPreference selectedPreference =
|
TickButtonPreference selectedPreference =
|
||||||
(TickButtonPreference) mPreferenceScreen.getPreference(2);
|
(TickButtonPreference) mPreferenceScreen.getPreference(2);
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package com.android.settings.localepicker;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.app.GrammaticalInflectionManager;
|
import android.app.GrammaticalInflectionManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -34,7 +32,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||||||
import com.android.settings.widget.TickButtonPreference;
|
import com.android.settings.widget.TickButtonPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@@ -62,7 +59,7 @@ public class TermsOfAddressMasculineControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
if (Looper.myLooper() == null) {
|
if (Looper.myLooper() == null) {
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
@@ -93,7 +90,6 @@ public class TermsOfAddressMasculineControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("b/339543490")
|
|
||||||
public void displayPreference_setGrammaticalGenderIsMasculine_MasculineIsSelected() {
|
public void displayPreference_setGrammaticalGenderIsMasculine_MasculineIsSelected() {
|
||||||
TickButtonPreference selectedPreference =
|
TickButtonPreference selectedPreference =
|
||||||
(TickButtonPreference) mPreferenceScreen.getPreference(3);
|
(TickButtonPreference) mPreferenceScreen.getPreference(3);
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package com.android.settings.localepicker;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.app.GrammaticalInflectionManager;
|
import android.app.GrammaticalInflectionManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -34,7 +32,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||||||
import com.android.settings.widget.TickButtonPreference;
|
import com.android.settings.widget.TickButtonPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@@ -62,7 +59,7 @@ public class TermsOfAddressNeutralControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
if (Looper.myLooper() == null) {
|
if (Looper.myLooper() == null) {
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
@@ -93,7 +90,6 @@ public class TermsOfAddressNeutralControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("b/339543490")
|
|
||||||
public void displayPreference_setGrammaticalGenderIsNotSpecified_NeutralIsSelected() {
|
public void displayPreference_setGrammaticalGenderIsNotSpecified_NeutralIsSelected() {
|
||||||
TickButtonPreference selectedPreference =
|
TickButtonPreference selectedPreference =
|
||||||
(TickButtonPreference) mPreferenceScreen.getPreference(4);
|
(TickButtonPreference) mPreferenceScreen.getPreference(4);
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package com.android.settings.localepicker;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.app.GrammaticalInflectionManager;
|
import android.app.GrammaticalInflectionManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -34,7 +32,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||||||
import com.android.settings.widget.TickButtonPreference;
|
import com.android.settings.widget.TickButtonPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@@ -62,7 +59,7 @@ public class TermsOfAddressNotSpecifiedControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
if (Looper.myLooper() == null) {
|
if (Looper.myLooper() == null) {
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
@@ -93,7 +90,6 @@ public class TermsOfAddressNotSpecifiedControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("b/339543490")
|
|
||||||
public void displayPreference_setGrammaticalGenderIsNotSpecified_NotSpecifiedIsSelected() {
|
public void displayPreference_setGrammaticalGenderIsNotSpecified_NotSpecifiedIsSelected() {
|
||||||
TickButtonPreference selectedPreference =
|
TickButtonPreference selectedPreference =
|
||||||
(TickButtonPreference) mPreferenceScreen.getPreference(1);
|
(TickButtonPreference) mPreferenceScreen.getPreference(1);
|
||||||
|
|||||||
@@ -243,6 +243,33 @@ public class MobileNetworkUtilsTest {
|
|||||||
.isEqualTo(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
.isEqualTo(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getActiveSubscriptionIdList_nonActive_returnEmptyArray() {
|
||||||
|
int[] expectedList = new int[0];
|
||||||
|
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(new ArrayList<>());
|
||||||
|
|
||||||
|
assertThat(MobileNetworkUtils.getActiveSubscriptionIdList(mContext))
|
||||||
|
.isEqualTo(expectedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getActiveSubscriptionIdList_normalCaseTwoActiveSims_returnValidSubId() {
|
||||||
|
int[] expectedList = {SUB_ID_1, SUB_ID_2};
|
||||||
|
|
||||||
|
assertThat(MobileNetworkUtils.getActiveSubscriptionIdList(mContext))
|
||||||
|
.isEqualTo(expectedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getActiveSubscriptionIdList_TwoActiveSimsAndOneIsNtn_returnOneSubId() {
|
||||||
|
int[] expectedList = {SUB_ID_2};
|
||||||
|
when(mSubscriptionInfo1.isEmbedded()).thenReturn(true);
|
||||||
|
when(mSubscriptionInfo1.isOnlyNonTerrestrialNetwork()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(MobileNetworkUtils.getActiveSubscriptionIdList(mContext))
|
||||||
|
.isEqualTo(expectedList);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldDisplayNetworkSelectOptions_HideCarrierNetwork_returnFalse() {
|
public void shouldDisplayNetworkSelectOptions_HideCarrierNetwork_returnFalse() {
|
||||||
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class AutoLockPreferenceControllerTest {
|
|||||||
Settings.Secure.PRIVATE_SPACE_AUTO_LOCK,
|
Settings.Secure.PRIVATE_SPACE_AUTO_LOCK,
|
||||||
Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_AFTER_INACTIVITY);
|
Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_AFTER_INACTIVITY);
|
||||||
assertThat(mAutoLockPreferenceController.getSummary().toString())
|
assertThat(mAutoLockPreferenceController.getSummary().toString())
|
||||||
.isEqualTo("After 5 minutes of inactivity");
|
.isEqualTo("5 minutes after screen timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user