Snap for 7419753 from ef963fe079 to sc-release

Change-Id: Ife659a87b970934b2e756725076a2af94ec431fc
This commit is contained in:
android-build-team Robot
2021-06-03 01:09:30 +00:00
51 changed files with 1265 additions and 745 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2021 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="412dp"
android:height="300dp"
android:viewportWidth="412"
android:viewportHeight="300">
<group>
<clip-path
android:pathData="M206,255.65A67.68,67.68 0,1 0,138.32 188,67.68 67.68,0 0,0 206,255.65Z"/>
<path
android:pathData="M237.58,172.63a4.51,4.51 0,1 1,-4.51 -4.51A4.51,4.51 0,0 1,237.58 172.63Z"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:fillType="evenOdd"/>
<path
android:pathData="M178.93,177.14a4.51,4.51 0,1 1,4.51 -4.51A4.51,4.51 0,0 1,178.93 177.14Z"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:fillType="evenOdd"/>
<path
android:pathData="M212.41,215.89a9.93,9.93 0,0 1,-16.34 -7.57v0l-3.6,0s0,0 0,0.06A13.53,13.53 0,0 0,206 221.85a12.81,12.81 0,0 0,1.39 -0.07,13.38 13.38,0 0,0 7.35,-3.13Z"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:fillType="evenOdd"/>
<path
android:pathData="M207.35,181.66v11.73h-7.22V197H211V181.66Z"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:fillType="evenOdd"/>
</group>
<path
android:pathData="M206,45.75a38,38 0,0 0,-14.87 3h0A38.16,38.16 0,0 0,167.79 84v19.21h7V84A31.17,31.17 0,0 1,193.86 55.2h0a31.24,31.24 0,0 1,38.43 11.93l5.88,-3.78A38.08,38.08 0,0 0,206 45.75Z"
android:fillColor="@color/biometric_enroll_intro_color_bar"/>
<path
android:pathData="M238.18,63.35l-5.89,3.78A31.11,31.11 0,0 1,237.21 84v42.55h7V84A38.11,38.11 0,0 0,238.18 63.35Z"
android:fillColor="@color/biometric_enroll_intro_color_bar"/>
<path
android:pathData="M271.77,254.25H140.23a14,14 0,0 1,-14 -14V138.51a14,14 0,0 1,14 -14H271.77a14,14 0,0 1,14 14V240.25A14,14 0,0 1,271.77 254.25ZM140.23,128.51a10,10 0,0 0,-10 10V240.25a10,10 0,0 0,10 10H271.77a10,10 0,0 0,10 -10V138.51a10,10 0,0 0,-10 -10Z"
android:fillColor="@color/biometric_enroll_intro_color_outline"/>
</vector>

View File

@@ -21,33 +21,33 @@
android:viewportHeight="210.0"
android:viewportWidth="210.0">
<path
android:fillColor="#34A853"
android:fillColor="@color/biometric_enroll_intro_color_bar"
android:pathData="M73.79,58.17h-7V38.96c0,-15.39 9.16,-29.21 23.34,-35.21l2.73,6.45c-11.58,4.9 -19.06,16.19 -19.06,28.76V58.17z" />
<path
android:fillColor="#34A853"
android:fillColor="@color/biometric_enroll_intro_color_bar"
android:pathData="M131.29,22.13C125.51,13.12 115.68,7.75 105,7.75c-4.21,0 -8.3,0.82 -12.15,2.45l-2.73,-6.45c4.71,-1.99 9.72,-3 14.87,-3c13.08,0 25.11,6.58 32.18,17.6L131.29,22.13z" />
<path
android:fillColor="#34A853"
android:fillColor="@color/biometric_enroll_intro_color_bar"
android:pathData="M143.21,62.11h-7V38.96c0,-5.99 -1.7,-11.81 -4.92,-16.83l5.89,-3.78c3.94,6.15 6.03,13.27 6.03,20.6V62.11z" />
<path
android:fillColor="#34A853"
android:fillColor="@color/biometric_enroll_intro_color_bar"
android:pathData="M136.21,62.11h7v19.4h-7z" />
<path
android:fillColor="#3E82F1"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:pathData="M125.03,118.78c-0.28,0 -0.55,-0.07 -0.79,-0.2c-6.61,-3.37 -12.33,-4.79 -19.19,-4.79c-6.82,0 -13.3,1.6 -19.19,4.79c-0.83,0.44 -1.86,0.14 -2.34,-0.68c-0.45,-0.82 -0.14,-1.87 0.69,-2.31c6.41,-3.43 13.44,-5.2 20.84,-5.2c7.34,0 13.75,1.6 20.77,5.17c0.86,0.44 1.17,1.46 0.72,2.28C126.24,118.44 125.65,118.78 125.03,118.78z" />
<path
android:fillColor="#3E82F1"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:pathData="M75.73,136.63c-0.34,0 -0.69,-0.1 -1,-0.31c-0.79,-0.54 -0.96,-1.6 -0.41,-2.38c3.41,-4.76 7.75,-8.5 12.92,-11.12c10.82,-5.51 24.67,-5.54 35.52,-0.03c5.17,2.62 9.51,6.32 12.92,11.05c0.55,0.75 0.38,1.84 -0.41,2.38c-0.79,0.54 -1.86,0.37 -2.41,-0.41c-3.1,-4.28 -7.03,-7.65 -11.68,-10c-9.89,-5 -22.53,-5 -32.38,0.03c-4.69,2.38 -8.61,5.78 -11.71,10.06C76.8,136.39 76.28,136.63 75.73,136.63z" />
<path
android:fillColor="#3E82F1"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:pathData="M97.27,177.67c-0.45,0 -0.9,-0.17 -1.21,-0.51c-3,-2.96 -4.62,-4.86 -6.92,-8.98c-2.38,-4.18 -3.62,-9.28 -3.62,-14.76c0,-10.1 8.75,-18.33 19.5,-18.33s19.5,8.23 19.5,18.33c0,0.95 -0.76,1.7 -1.72,1.7s-1.72,-0.75 -1.72,-1.7c0,-8.23 -7.2,-14.93 -16.05,-14.93s-16.05,6.7 -16.05,14.93c0,4.9 1.1,9.42 3.2,13.09c2.2,3.91 3.72,5.58 6.37,8.23c0.65,0.68 0.65,1.73 0,2.41C98.16,177.5 97.71,177.67 97.27,177.67z" />
<path
android:fillColor="#3E82F1"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:pathData="M121.97,171.38c-4.1,0 -7.72,-1.02 -10.68,-3.03c-5.13,-3.43 -8.2,-9.01 -8.2,-14.93c0,-0.95 0.76,-1.7 1.72,-1.7s1.72,0.75 1.72,1.7c0,4.79 2.48,9.32 6.68,12.1c2.45,1.63 5.31,2.41 8.75,2.41c0.83,0 2.2,-0.1 3.58,-0.34c0.93,-0.17 1.83,0.44 2,1.39c0.17,0.92 -0.45,1.8 -1.41,1.97C124.17,171.34 122.45,171.38 121.97,171.38z" />
<path
android:fillColor="#3E82F1"
android:fillColor="@color/biometric_enroll_intro_color_icon"
android:pathData="M115.04,178.38c-0.14,0 -0.31,-0.03 -0.45,-0.07c-5.48,-1.5 -9.06,-3.5 -12.82,-7.14c-4.82,-4.73 -7.48,-11.02 -7.48,-17.75c0,-5.51 4.75,-10 10.61,-10c5.86,0 10.61,4.49 10.61,10c0,3.64 3.2,6.6 7.17,6.6s7.17,-2.96 7.17,-6.6c0,-12.82 -11.2,-23.22 -24.98,-23.22c-9.78,0 -18.74,5.37 -22.77,13.7c-1.34,2.75 -2.03,5.98 -2.03,9.52c0,2.65 0.24,6.83 2.31,12.27c0.34,0.88 -0.1,1.87 -1,2.18c-0.9,0.34 -1.89,-0.14 -2.2,-0.99c-1.69,-4.45 -2.51,-8.87 -2.51,-13.46c0,-4.08 0.79,-7.79 2.34,-11.02c4.58,-9.49 14.75,-15.64 25.87,-15.64c15.68,0 28.42,11.93 28.42,26.62c0,5.51 -4.75,10 -10.61,10c-5.86,0 -10.61,-4.49 -10.61,-10c0,-3.64 -3.2,-6.6 -7.17,-6.6s-7.17,2.96 -7.17,6.6c0,5.81 2.27,11.25 6.44,15.33c3.27,3.2 6.41,4.96 11.27,6.29c0.93,0.24 1.45,1.19 1.21,2.07C116.49,177.87 115.77,178.38 115.04,178.38z" />
<path
android:fillColor="#DADCE0"
android:fillColor="@color/biometric_enroll_intro_color_outline"
android:pathData="M170.77,209.25H39.23c-7.72,0 -14,-6.28 -14,-14V93.51c0,-7.72 6.28,-14 14,-14h131.54c7.72,0 14,6.28 14,14v101.74C184.77,202.97 178.49,209.25 170.77,209.25zM39.23,83.51c-5.51,0 -10,4.49 -10,10v101.74c0,5.51 4.49,10 10,10h131.54c5.51,0 10,-4.49 10,-10V93.51c0,-5.51 -4.49,-10 -10,-10H39.23z" />
</vector>

View File

@@ -27,7 +27,7 @@
<LinearLayout
style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
@@ -42,24 +42,23 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp">
android:layout_marginTop="-24dp"
android:layout_marginBottom="4dp">
<com.google.android.setupdesign.view.IllustrationVideoView
android:id="@+id/illustration_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
style="@style/SudContentIllustration"
app:sudVideo="@raw/face_settings"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:src="@drawable/face_enroll_intro_illustration"/>
</FrameLayout>
<!-- Contains the buttons and extra information text at the bottom -->
<!-- Contains the extra information text at the bottom -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal|bottom"
android:paddingTop="12dp">
android:orientation="vertical">
<TextView
android:layout_width="match_parent"

View File

@@ -64,7 +64,8 @@
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:paddingTop="12dp"
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_title_2" />
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_title_2"
android:textColor="?android:attr/textColorPrimary"/>
<LinearLayout
android:layout_width="match_parent"
@@ -84,7 +85,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_2" />
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_2"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
<LinearLayout
@@ -105,7 +107,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_3" />
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_3"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
<!-- You're in control -->
@@ -115,7 +118,8 @@
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:paddingTop="12dp"
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1" />
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1"
android:textColor="?android:attr/textColorPrimary"/>
<LinearLayout
android:layout_width="match_parent"
@@ -135,7 +139,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_4" />
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_4"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
</LinearLayout>
@@ -147,7 +152,8 @@
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:paddingTop="12dp"
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2" />
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2"
android:textColor="?android:attr/textColorPrimary"/>
<LinearLayout
android:layout_width="match_parent"
@@ -167,7 +173,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_5" />
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_5"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
<LinearLayout
@@ -188,7 +195,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more" />
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
</LinearLayout>

View File

@@ -56,7 +56,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layoutDirection="ltr"
android:paddingTop="8dp">
<ImageView

View File

@@ -24,6 +24,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:importantForAccessibility="yes"
style="@style/ContextualCardStyle">
<LinearLayout
android:layout_width="match_parent"
@@ -46,16 +47,16 @@
android:layout_marginTop="12dp"
android:layout_marginBottom="16dp"
android:text="@string/battery_missing_message"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
android:textAppearance="?android:attr/textAppearanceListItem" />
<TextView android:id="@+id/link_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/battery_missing_link_message"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@*android:color/material_red_A700" />
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="@*android:color/material_red_A700"
android:contentDescription="@string/battery_missing_link_a11y_message" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>

View File

@@ -41,5 +41,10 @@
<color name="color_surface_header">@*android:color/surface_header_dark</color>
<!-- Dialog error color. -->
<color name="settings_dialog_colorError">#f28b82</color> <!-- Red 300 -->
<!-- Face and fingerprint enrollment -->
<color name="biometric_enroll_intro_color_bar">#5bb974</color>
<color name="biometric_enroll_intro_color_icon">#669df6</color>
<color name="biometric_enroll_intro_color_outline">#5e5e5e</color>
</resources>

View File

@@ -126,6 +126,11 @@
<color name="face_anim_particle_color_4">#fffdd835</color> <!-- Material Yellow 600 -->
<color name="face_anim_particle_error">#ff9e9e9e</color> <!-- Material Gray 500 -->
<!-- Face and fingerprint enrollment -->
<color name="biometric_enroll_intro_color_bar">#1e8e3e</color>
<color name="biometric_enroll_intro_color_icon">#1a73e8</color>
<color name="biometric_enroll_intro_color_outline">#e3e3e3</color>
<!-- notification settings -->
<color name="notification_block_color">#ffff0000</color>
<color name="notification_silence_color">#FF32c1de</color>

View File

@@ -103,7 +103,7 @@
<!-- Disclaimer for camera based rotate [CHAR_LIMIT=NONE] -->
<string name="smart_rotate_text_headline">
Face Detection uses the front-facing camera to improve Auto-rotate accuracy. Images are never stored or sent to Google.&lt;br>&lt;br>
&lt;a href="<xliff:g example="http://www.google.com" id="url">http://support.google.com/mobile?p=telephony_rtt</xliff:g>">Learn more&lt;/a>
&lt;a href="<xliff:g example="http://www.google.com" id="url">http://support.google.com/mobile?p=telephony_rtt</xliff:g>">Learn more about Auto-rotate screen&lt;/a>
</string>
<string name="font_size_preview_text_headline">Sample text</string>
<string name="font_size_preview_text_title"
@@ -695,9 +695,8 @@
emergency responders when you call or text an emergency number.
</string>
<!-- Location settings footer link to support page [CHAR LIMIT=NONE] -->
<string name="location_settings_footer_learn_more">
&lt;a href="<xliff:g example="http://www.google.com"
id="url"> https://support.google.com/android/answer/3467281</xliff:g>">Learn more&lt;/a>
<string name="location_settings_footer_learn_more_link" translatable="false">
https://support.google.com/android/answer/3467281
</string>
<!-- Location settings footer link content description [CHAR LIMIT=NONE] -->
<string name="location_settings_footer_learn_more_content_description">
@@ -5335,8 +5334,8 @@
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold.</string>
<!-- Summary for software shortcut in accessibility edit shortcut dialog when user had enabled the accessibility floating button mode (Floating over other apps). [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_summary_software_floating"><annotation id="link">Customize accessibility button</annotation></string>
<!-- Summary for footer to show help link. [CHAR LIMIT=NONE] -->
<string name="footer_learn_more"><annotation id="link">Learn more</annotation></string>
<!-- Footer to show help link content description. [CHAR LIMIT=NONE] -->
<string name="footer_learn_more_content_description">Learn more about <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<!-- Title for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
<!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
@@ -6052,7 +6051,7 @@
<!-- Activity title for battery usage history details [CHAR LIMIT=60] -->
<string name="history_details_title">History details</string>
<!-- Preference title for advanced battery usage [CHAR LIMIT=40] -->
<string name="advanced_battery_preference_title">View battery usage</string>
<string name="advanced_battery_preference_title">Battery Usage</string>
<!-- Preference summary for advanced battery usage, for past 24 hours [CHAR LIMIT=40] -->
<string name="advanced_battery_preference_summary_with_hours">View usage for past 24 hours</string>
<!-- Preference summary for advanced battery usage, from last full charge [CHAR LIMIT=40] -->
@@ -6100,7 +6099,7 @@
<!-- Title for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_title">Charging temporarily limited</string>
<!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_summary">Battery limited temporarily. Learn more.</string>
<string name="battery_tip_limited_temporarily_summary">To preserve your battery. Learn more.</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
@@ -6201,9 +6200,11 @@
<string name="battery_header_title_alternate"><xliff:g id="number" example="88">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="%">%</xliff:g></font></small></string>
<!-- Summary for top level battery tile if battery is not present. [CHAR LIMIT=NONE] -->
<string name="battery_missing_message">Cant update battery info</string>
<string name="battery_missing_message">Problem reading the battery meter.</string>
<!-- Help text if battery is not present. [CHAR LIMIT=NONE] -->
<string name="battery_missing_link_message"></string>
<!-- Accessibility description for battery missing link. [CHAR LIMIT=NONE] -->
<string name="battery_missing_link_a11y_message">Tap to learn more about this error</string>
<!-- Title for force stop dialog [CHAR LIMIT=30] -->
<string name="dialog_stop_title">Stop app?</string>
@@ -10473,13 +10474,13 @@
Allowing <xliff:g id="app_name" example="Settings">%1$s</xliff:g> to always run in the background may reduce battery life.
\n\nYou can change this later from Settings > Apps &amp; notifications.</string>
<!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->
<string name="battery_summary"><xliff:g id="percentage" example="2">%1$s</xliff:g> use since last full charge</string>
<string name="battery_summary"><xliff:g id="percentage" example="2">%1$s</xliff:g> use for past 24 hours</string>
<!-- Title of a group of settings that let you manage settings that affect battery life [CHAR LIMIT=60] -->
<string name="battery_power_management">Power management</string>
<!-- Summary for app with no battery usage [CHAR LIMIT=NONE] -->
<string name="no_battery_summary">No battery use since last full charge</string>
<string name="no_battery_summary">No battery use for past 24 hours</string>
<!-- Link to an apps notification settings [CHAR LIMIT=50] -->
<string name="app_notification_preferences">App settings</string>

View File

@@ -27,10 +27,11 @@
settings:preview="@drawable/aab_brightness"
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<com.android.settingslib.widget.MainSwitchPreference
<com.android.settings.widget.SettingsMainSwitchPreference
android:key="auto_brightness"
android:title="@string/adaptive_brightness_main_switch_title"
settings:keywords="@string/keywords_display_auto_brightness"
settings:userRestriction="no_config_brightness"
settings:controller="com.android.settings.display.AutoBrightnessDetailPreferenceController"/>
<com.android.settingslib.widget.FooterPreference

View File

@@ -71,7 +71,6 @@
<com.android.settingslib.widget.FooterPreference
android:title="@string/location_settings_footer_general"
android:key="location_footer"
android:selectable="false"
settings:searchable="false"
settings:controller="com.android.settings.location.LocationSettingsFooterPreferenceController"/>
</PreferenceScreen>

View File

@@ -21,13 +21,11 @@
android:key="privacy_dashboard_page"
android:title="@string/privacy_dashboard_title">
<!-- Work Policy info -->
<Preference
android:key="work_policy_info"
android:title="@string/work_policy_privacy_settings"
android:summary="@string/work_policy_privacy_settings_summary"
settings:allowDividerAbove="true"
settings:controller="com.android.settings.privacy.WorkPolicyInfoPreferenceController"/>
<!-- Connected work and personal apps -->
@@ -42,7 +40,6 @@
<Preference
android:key="privacy_accessibility_usage"
android:title="@string/accessibility_usage_title"
settings:allowDividerAbove="true"
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
<intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
</Preference>
@@ -52,7 +49,6 @@
android:key="privacy_permissions_usage"
android:title="@string/permissions_usage_title"
android:summary="@string/permissions_usage_summary"
settings:allowDividerAbove="true"
settings:searchable="false"
settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController">
<intent android:action="android.intent.action.REVIEW_PERMISSION_USAGE"/>

View File

@@ -70,21 +70,17 @@
settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" />
</PreferenceCategory>
<PreferenceCategory
android:key="security_settings_face_button_category"
android:title="@string/security_settings_face_preference_title">
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_delete_faces_container"
android:title="@string/security_settings_face_settings_remove_face_model"
android:selectable="false"
android:layout="@layout/face_remove_button"/>
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_delete_faces_container"
android:title="@string/security_settings_face_settings_remove_face_model"
android:selectable="false"
android:layout="@layout/face_remove_button"/>
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_enroll_faces_container"
android:title="@string/security_settings_face_settings_enroll"
android:selectable="false"
android:layout="@layout/face_enroll_button"/>
</PreferenceCategory>
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_enroll_faces_container"
android:title="@string/security_settings_face_settings_enroll"
android:selectable="false"
android:layout="@layout/face_enroll_button"/>
<com.android.settingslib.widget.FooterPreference
android:key="security_face_footer"

View File

@@ -111,9 +111,9 @@ public class SettingsDumpService extends Service {
for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) {
telephonyManager = telephonyManager
.createForSubscriptionId(info.getSubscriptionId());
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
NetworkTemplate carrier = NetworkTemplate.buildTemplateCarrierMetered(
telephonyManager.getSubscriberId());
final JSONObject usage = dumpDataUsage(mobileAll, controller);
final JSONObject usage = dumpDataUsage(carrier, controller);
usage.put("subId", info.getSubscriptionId());
array.put(usage);
}

View File

@@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -43,11 +42,8 @@ import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
import com.android.settings.widget.LoadingViewController;
@@ -129,11 +125,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// TODO(b/176883483): Remove both search and help menu if this feature rolled out
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
SearchMenuController.init(this /* host */);
HelpMenuController.init(this /* host */);
}
if (icicle != null) {
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);

View File

@@ -110,7 +110,6 @@ import androidx.preference.PreferenceGroup;
import com.android.internal.app.UnlaunchableAppActivity;
import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
@@ -1228,10 +1227,7 @@ public final class Utils extends com.android.settingslib.Utils {
}
public static boolean isPageTransitionEnabled(Context context) {
final boolean isSilkyHome = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME);
final boolean isTransitionEnabled = Settings.Global.getInt(context.getContentResolver(),
return Settings.Global.getInt(context.getContentResolver(),
SETTINGS_SHARED_AXIS_ENABLED, 0) == 1;
return isSilkyHome && isTransitionEnabled;
}
}

View File

@@ -17,29 +17,19 @@
package com.android.settings.accessibility;
import android.content.Context;
import android.content.Intent;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.widget.FooterPreference;
/**
* A custom preference acting as footer of a page. It has a field for icon and text. It is added
* to screen as the last preference and groups of icon and text content in accessibility-focusable
* {@link android.view.accessibility.AccessibilityNodeInfo} for TalkBack to use.
* A custom preference acting as footer of a page. Disables the movement method by default.
*/
public final class AccessibilityFooterPreference extends FooterPreference {
private CharSequence mIconContentDescription;
private boolean mLinkEnabled;
public AccessibilityFooterPreference(Context context, AttributeSet attrs) {
@@ -65,33 +55,6 @@ public final class AccessibilityFooterPreference extends FooterPreference {
} else {
title.setMovementMethod(/* movement= */ null);
}
final LinearLayout infoFrame = holder.itemView.findViewById(R.id.icon_frame);
if (!TextUtils.isEmpty(mIconContentDescription)) {
// Groups related content.
infoFrame.setContentDescription(mIconContentDescription);
title.setFocusable(false);
} else {
infoFrame.setContentDescription(null);
title.setFocusable(true);
}
}
/**
* Sets the content description of the icon.
*/
public void setIconContentDescription(CharSequence iconContentDescription) {
if (!TextUtils.equals(iconContentDescription, mIconContentDescription)) {
mIconContentDescription = iconContentDescription;
notifyChanged();
}
}
/**
* Gets the content description of the icon.
*/
public CharSequence getIconContentDescription() {
return mIconContentDescription;
}
/**
@@ -110,23 +73,4 @@ public final class AccessibilityFooterPreference extends FooterPreference {
public boolean isLinkEnabled() {
return mLinkEnabled;
}
/**
* Appends {@link AnnotationSpan} with learn more link apart from the other text.
*
* @param helpLinkRes The Help Uri Resource key
*/
public void appendHelpLink(int helpLinkRes) {
final SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append(getTitle()).append("\n\n").append(getLearnMoreLink(getContext(), helpLinkRes));
setTitle(sb);
}
private CharSequence getLearnMoreLink(Context context, int helpLinkRes) {
final Intent helpIntent = HelpUtils.getHelpIntent(
context, context.getString(helpLinkRes), context.getClass().getName());
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
context, AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, helpIntent);
return AnnotationSpan.linkify(context.getText(R.string.footer_learn_more), linkInfo);
}
}

View File

@@ -17,11 +17,13 @@
package com.android.settings.accessibility;
import android.content.Context;
import android.content.Intent;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.HelpUtils;
/**
* Base class for accessibility preference footer.
@@ -59,13 +61,24 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
protected abstract String getLabelName();
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
final String iconContentDescription = mContext.getString(
R.string.accessibility_introduction_title, getLabelName());
footerPreference.setIconContentDescription(iconContentDescription);
final StringBuffer sb = new StringBuffer();
sb.append(mContext.getString(
R.string.accessibility_introduction_title, getLabelName()))
.append("\n\n")
.append(footerPreference.getTitle());
footerPreference.setContentDescription(sb);
if (getHelpResource() != 0) {
footerPreference.appendHelpLink(getHelpResource());
footerPreference.setLinkEnabled(true);
footerPreference.setLearnMoreAction(view -> {
final Intent helpIntent = HelpUtils.getHelpIntent(
mContext, mContext.getString(getHelpResource()),
mContext.getClass().getName());
view.startActivityForResult(helpIntent, 0);
});
final String learnMoreContentDescription = mContext.getString(
R.string.footer_learn_more_content_description, getLabelName());
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
}
}
}

View File

@@ -55,6 +55,7 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.utils.LocaleUtils;
import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
@@ -520,14 +521,25 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
new AccessibilityFooterPreference(screen.getContext());
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
htmlFooterPreference.setSummary(htmlDescription);
htmlFooterPreference.setContentDescription(
generateFooterContentDescription(htmlDescription));
// Only framework tools support help link
if (getHelpResource() != 0) {
htmlFooterPreference.appendHelpLink(getHelpResource());
htmlFooterPreference.setLearnMoreAction(view -> {
final Intent helpIntent = HelpUtils.getHelpIntent(
getContext(), getContext().getString(getHelpResource()),
getContext().getClass().getName());
view.startActivityForResult(helpIntent, 0);
});
final String learnMoreContentDescription = getPrefContext().getString(
R.string.footer_learn_more_content_description, mPackageName);
htmlFooterPreference.setLearnMoreContentDescription(learnMoreContentDescription);
htmlFooterPreference.setLinkEnabled(true);
} else {
htmlFooterPreference.setLinkEnabled(false);
}
htmlFooterPreference.setIconContentDescription(iconContentDescription);
screen.addPreference(htmlFooterPreference);
}
@@ -559,14 +571,33 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
final AccessibilityFooterPreference footerPreference =
new AccessibilityFooterPreference(screen.getContext());
footerPreference.setSummary(summary);
footerPreference.setIconContentDescription(iconContentDescription);
footerPreference.setContentDescription(
generateFooterContentDescription(summary));
// Only framework tools support help link
if (getHelpResource() != 0) {
footerPreference.appendHelpLink(getHelpResource());
footerPreference.setLinkEnabled(true);
footerPreference.setLearnMoreAction(view -> {
final Intent helpIntent = HelpUtils.getHelpIntent(
getContext(), getContext().getString(getHelpResource()),
getContext().getClass().getName());
view.startActivityForResult(helpIntent, 0);
});
final String learnMoreContentDescription = getPrefContext().getString(
R.string.footer_learn_more_content_description, mPackageName);
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
}
screen.addPreference(footerPreference);
}
private CharSequence generateFooterContentDescription(CharSequence footerContent) {
final StringBuffer sb = new StringBuffer();
sb.append(getPrefContext().getString(
R.string.accessibility_introduction_title, mPackageName))
.append("\n\n")
.append(footerContent);
return sb;
}
@VisibleForTesting
void setupEditShortcutDialog(Dialog dialog) {
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);

View File

@@ -36,7 +36,12 @@ public interface ExtraAppInfoFeatureProvider {
void setPackageName(String packageName);
/**
* gets the summary name
* Checks if enabled
*/
boolean isEnabled(Context context);
/**
* Gets the summary name
*/
String getSummary(Context context);
}

View File

@@ -38,6 +38,11 @@ public class ExtraAppInfoFeatureProviderImpl implements
return;
}
@Override
public boolean isEnabled(Context context) {
return false;
}
@Override
public String getSummary(Context context) {
return "";

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.text.TextUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.overlay.FeatureFactory;
@@ -55,6 +56,16 @@ public class ExtraAppInfoPreferenceController extends BasePreferenceController {
return mExtraAppInfoFeatureProvider.getSummary(mContext);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (mExtraAppInfoFeatureProvider != null) {
final Preference preference = screen.findPreference(getPreferenceKey());
preference.setEnabled(mExtraAppInfoFeatureProvider.isEnabled(preference.getContext()));
}
}
/**
* Set the local package name
*/

View File

@@ -123,7 +123,6 @@ import com.android.settings.notification.app.AppNotificationSettings;
import com.android.settings.widget.LoadingViewController;
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
import com.android.settings.wifi.ChangeWifiStateDetails;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
@@ -661,10 +660,6 @@ public class ManageApplications extends InstrumentedFragment
if (activity == null) {
return;
}
// TODO(b/176883483): Remove the help menu if this feature rolled out
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
HelpUtils.prepareHelpMenuItem(activity, menu, getHelpResource(), getClass().getName());
}
mOptionsMenu = menu;
inflater.inflate(R.menu.manage_apps, menu);

View File

@@ -266,10 +266,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
faceManager.getSensorPropertiesInternal();
// This would need to be updated for devices with multiple sensors of the same modality
mIsFaceEnrollable = faceManager.getEnrolledFaces(mUserId).size()
< faceProperties.get(0).maxEnrollmentsPerUser;
mIsFingerprintEnrollable = fingerprintManager.getEnrolledFingerprints(mUserId).size()
< fpProperties.get(0).maxEnrollmentsPerUser;
mIsFaceEnrollable = !faceProperties.isEmpty() &&
faceManager.getEnrolledFaces(mUserId).size()
< faceProperties.get(0).maxEnrollmentsPerUser;
mIsFingerprintEnrollable = !fpProperties.isEmpty() &&
fingerprintManager.getEnrolledFingerprints(mUserId).size()
< fpProperties.get(0).maxEnrollmentsPerUser;
if (!mConfirmingCredentials) {
mConfirmingCredentials = true;

View File

@@ -18,6 +18,8 @@ package com.android.settings.biometrics;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.os.Bundle;
@@ -25,14 +27,17 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;
@@ -182,6 +187,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
}
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
final LinearLayout buttonContainer = mFooterBarMixin.getButtonContainer();
if (buttonContainer != null) {
buttonContainer.setBackgroundColor(getBackgroundColor());
}
}
@Override
protected void onResume() {
super.onResume();
@@ -199,6 +213,12 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
getWindow().setStatusBarColor(getBackgroundColor());
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -335,4 +355,10 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
return mIconColorFilter;
}
@ColorInt
private int getBackgroundColor() {
final ColorStateList stateList = Utils.getColorAttr(this, android.R.attr.windowBackground);
return stateList != null ? stateList.getDefaultColor() : Color.TRANSPARENT;
}
}

View File

@@ -67,7 +67,7 @@ public class SettingsBaseActivity extends FragmentActivity {
/**
* What type of page transition should be apply.
*/
public static final String EXTRA_PAGE_TRANSITION_TYPE = "extra_page_transition_type";
public static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
protected static final boolean DEBUG_TIMING = false;
private static final String TAG = "SettingsBaseActivity";

View File

@@ -17,22 +17,17 @@
package com.android.settings.core;
import android.annotation.StringRes;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
import android.widget.Toolbar;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SubSettings;
import com.android.settings.Utils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
@@ -199,14 +194,6 @@ public class SubSettingLauncher {
@VisibleForTesting
void launchForResult(Fragment listener, Intent intent, int requestCode) {
if (Utils.isPageTransitionEnabled(mContext)) {
final Activity activity = listener.getActivity();
final Toolbar toolbar = activity.findViewById(R.id.action_bar);
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity, toolbar,
"shared_element_view").toBundle();
listener.startActivityForResult(intent, requestCode, bundle);
return;
}
listener.startActivityForResult(intent, requestCode);
}

View File

@@ -73,7 +73,7 @@ public class DataUsageLib {
private static NetworkTemplate getMobileTemplateForSubId(
TelephonyManager telephonyManager, int subId) {
return NetworkTemplate.buildTemplateMobileAll(
return NetworkTemplate.buildTemplateCarrierMetered(
telephonyManager.getSubscriberId(subId));
}
}

View File

@@ -21,7 +21,7 @@ import android.widget.Switch;
import androidx.preference.PreferenceScreen;
import com.android.settingslib.widget.MainSwitchPreference;
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
/**
@@ -51,7 +51,7 @@ public class AutoBrightnessDetailPreferenceController extends
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
MainSwitchPreference pref = (MainSwitchPreference) screen.findPreference(
SettingsMainSwitchPreference pref = (SettingsMainSwitchPreference) screen.findPreference(
getPreferenceKey());
pref.addOnSwitchChangeListener(this);
pref.updateStatus(isChecked());

View File

@@ -46,30 +46,25 @@ import java.util.Objects;
/**
* Helper class for {@link ActionDisabledByAdminDialog} which sets up the dialog.
*/
public class ActionDisabledByAdminDialogHelper {
public final class ActionDisabledByAdminDialogHelper {
private static final String TAG = ActionDisabledByAdminDialogHelper.class.getName();
@VisibleForTesting EnforcedAdmin mEnforcedAdmin;
private ViewGroup mDialogView;
private String mRestriction = null;
private final Activity mActivity;
private String mRestriction;
private final ActionDisabledByAdminController mActionDisabledByAdminController;
private final Activity mActivity;
public ActionDisabledByAdminDialogHelper(Activity activity) {
mActivity = activity;
mActionDisabledByAdminController =
ActionDisabledByAdminControllerFactory.createInstance(
mActivity.getSystemService(DevicePolicyManager.class),
new ActionDisabledLearnMoreButtonLauncherImpl(),
new DeviceAdminStringProviderImpl(mActivity));
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
R.layout.admin_support_details_dialog, null);
mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
.createInstance(mActivity, new DeviceAdminStringProviderImpl(mActivity));
}
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
if (admin.user == null) {
return UserHandle.USER_NULL;
} else {
return admin.user.getIdentifier();
}
return admin.user == null ? UserHandle.USER_NULL : admin.user.getIdentifier();
}
private @UserIdInt int getEnforcementAdminUserId() {
@@ -78,21 +73,24 @@ public class ActionDisabledByAdminDialogHelper {
public AlertDialog.Builder prepareDialogBuilder(String restriction,
EnforcedAdmin enforcedAdmin) {
mEnforcedAdmin = enforcedAdmin;
mRestriction = restriction;
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
R.layout.admin_support_details_dialog, null);
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
mRestriction, mActionDisabledByAdminController);
builder.setPositiveButton(R.string.okay, null).setView(mDialogView);
maybeSetLearnMoreButton(builder);
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
.setPositiveButton(R.string.okay, null)
.setView(mDialogView);
prepareDialogBuilder(builder, restriction, enforcedAdmin);
return builder;
}
@VisibleForTesting
void maybeSetLearnMoreButton(AlertDialog.Builder builder) {
mActionDisabledByAdminController.setupLearnMoreButton(mActivity, builder);
void prepareDialogBuilder(AlertDialog.Builder builder, String restriction,
EnforcedAdmin enforcedAdmin) {
mActionDisabledByAdminController.initialize(
new ActionDisabledLearnMoreButtonLauncherImpl(mActivity, builder));
mEnforcedAdmin = enforcedAdmin;
mRestriction = restriction;
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
mRestriction);
mActionDisabledByAdminController.setupLearnMoreButton(mActivity);
}
public void updateDialog(String restriction, EnforcedAdmin admin) {
@@ -102,17 +100,17 @@ public class ActionDisabledByAdminDialogHelper {
mEnforcedAdmin = admin;
mRestriction = restriction;
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
mRestriction, mActionDisabledByAdminController);
mRestriction);
}
private void initializeDialogViews(View root, EnforcedAdmin enforcedAdmin, int userId,
String restriction, ActionDisabledByAdminController controller) {
String restriction) {
ComponentName admin = enforcedAdmin.component;
if (admin == null) {
return;
}
controller.updateEnforcedAdmin(enforcedAdmin, userId);
mActionDisabledByAdminController.updateEnforcedAdmin(enforcedAdmin, userId);
setAdminSupportIcon(root, admin, userId);
if (isNotCurrentUserOrProfile(admin, userId)) {
@@ -151,8 +149,7 @@ public class ActionDisabledByAdminDialogHelper {
if (titleView == null) {
return;
}
titleView.setText(
mActionDisabledByAdminController.getAdminSupportTitle(restriction));
titleView.setText(mActionDisabledByAdminController.getAdminSupportTitle(restriction));
}
@VisibleForTesting

View File

@@ -20,104 +20,67 @@ import static java.util.Objects.requireNonNull;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.enterprise.ActionDisabledLearnMoreButtonLauncher;
import java.util.function.BiConsumer;
/**
* Helper class to set up the "Learn more" button in the action disabled dialog.
*/
public class ActionDisabledLearnMoreButtonLauncherImpl
implements ActionDisabledLearnMoreButtonLauncher {
public final class ActionDisabledLearnMoreButtonLauncherImpl
extends ActionDisabledLearnMoreButtonLauncher {
static final BiConsumer<Activity, EnforcedAdmin> SHOW_ADMIN_POLICIES =
(activity, enforcedAdmin) -> {
showAdminPolicies(enforcedAdmin, activity);
activity.finish();
};
private final Activity mActivity;
private final AlertDialog.Builder mBuilder;
static final BiConsumer<Activity, String> LAUNCH_HELP_PAGE = (activity, url) -> {
launchLearnMoreHelpPage(activity, url);
activity.finish();
};
@Override
public void setupLearnMoreButtonToShowAdminPolicies(
Context context,
Object alertDialogBuilder,
int enforcementAdminUserId,
EnforcedAdmin enforcedAdmin) {
requireNonNull(context);
requireNonNull(alertDialogBuilder);
requireNonNull(enforcedAdmin);
// The "Learn more" button appears only if the restriction is enforced by an admin in the
// same profile group. Otherwise the admin package and its policies are not accessible to
// the current user.
final UserManager um = UserManager.get(context);
if (um.isSameProfileGroup(enforcementAdminUserId, um.getUserHandle())) {
setupLearnMoreButton((AlertDialog.Builder) alertDialogBuilder, () ->
SHOW_ADMIN_POLICIES.accept((Activity) context, enforcedAdmin));
}
ActionDisabledLearnMoreButtonLauncherImpl(Activity activity, AlertDialog.Builder builder) {
mActivity = requireNonNull(activity, "activity cannot be null");
mBuilder = requireNonNull(builder, "builder cannot be null");
}
@Override
public void setupLearnMoreButtonToLaunchHelpPage(
Context context,
Object alertDialogBuilder,
String url) {
requireNonNull(context);
requireNonNull(alertDialogBuilder);
requireNonNull(url);
setupLearnMoreButton((AlertDialog.Builder) alertDialogBuilder,
() -> LAUNCH_HELP_PAGE.accept((Activity) context, url));
public void setLearnMoreButton(Runnable action) {
requireNonNull(action, "action cannot be null");
mBuilder.setNeutralButton(R.string.learn_more, (dialog, which) -> action.run());
}
private void setupLearnMoreButton(AlertDialog.Builder builder, Runnable runnable) {
builder.setNeutralButton(R.string.learn_more, (dialog, which) -> {
runnable.run();
});
@Override
protected void launchShowAdminPolicies(Context context, UserHandle user, ComponentName admin) {
requireNonNull(context, "context cannot be null");
requireNonNull(user, "user cannot be null");
requireNonNull(admin, "admin cannot be null");
Intent intent = new Intent()
.setClass(mActivity, DeviceAdminAdd.class)
.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, admin)
.putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true);
// DeviceAdminAdd class may need to run as managed profile.
mActivity.startActivityAsUser(intent, user);
}
private static void launchLearnMoreHelpPage(Activity activity, String url) {
activity.startActivityAsUser(createLearnMoreIntent(url), UserHandle.SYSTEM);
@Override
protected void launchShowAdminSettings(Context context) {
requireNonNull(context, "context cannot be null");
Intent intent = new Intent()
.setClass(mActivity, Settings.DeviceAdminSettingsActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Activity merges both managed profile and parent users
// admins so show as same user as this activity.
mActivity.startActivity(intent);
}
private static Intent createLearnMoreIntent(String url) {
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
return intent;
}
private static void showAdminPolicies(
EnforcedAdmin enforcedAdmin,
Activity activity) {
final Intent intent = new Intent();
if (enforcedAdmin.component != null) {
intent.setClass(activity, DeviceAdminAdd.class);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
enforcedAdmin.component);
intent.putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true);
// DeviceAdminAdd class may need to run as managed profile.
activity.startActivityAsUser(intent, enforcedAdmin.user);
} else {
intent.setClass(activity, Settings.DeviceAdminSettingsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Activity merges both managed profile and parent users
// admins so show as same user as this activity.
activity.startActivity(intent);
}
@Override
protected void finishSelf() {
mActivity.finish();
}
}

View File

@@ -30,18 +30,14 @@ import android.content.om.OverlayInfo;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.utils.CandidateInfoExtra;
import com.android.settings.widget.RadioButtonPickerFragment;
@@ -76,11 +72,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
@Override
public void onAttach(Context context) {
super.onAttach(context);
// TODO(b/176883483): Remove both search and help menu if this feature rolled out
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
SearchMenuController.init(this /* host */);
HelpMenuController.init(this /* host */);
}
SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
.getSuggestionFeatureProvider(context);

View File

@@ -26,7 +26,6 @@ import android.database.Cursor;
import android.os.Bundle;
import android.provider.UserDictionary;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -45,7 +44,6 @@ import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.Instrumentable;
@@ -106,10 +104,7 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO(b/176883483): Remove the title after material component updated
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
getActivity().setTitle(R.string.user_dict_settings_title);
}
getActivity().setTitle(R.string.user_dict_settings_title);
// Show the language as a subtitle of the action bar
final ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {

View File

@@ -31,6 +31,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.widget.FooterPreference;
import java.util.ArrayList;
@@ -104,15 +105,22 @@ public class LocationSettingsFooterPreferenceController extends LocationBasePref
+ footerString;
}
if (mFooterPreference != null) {
mFooterPreference.setTitle(Html.fromHtml(footerString
+ PARAGRAPH_SEPARATOR
+ mContext.getString(
R.string.location_settings_footer_learn_more)));
mFooterPreference.setContentDescription(Html.fromHtml(footerString + mContext.getString(
R.string.location_settings_footer_learn_more_content_description)));
mFooterPreference.setTitle(Html.fromHtml(footerString));
mFooterPreference.setLearnMoreAction(v -> openLocationLearnMoreLink());
mFooterPreference.setLearnMoreContentDescription(mContext.getString(
R.string.location_settings_footer_learn_more_content_description));
}
}
private void openLocationLearnMoreLink() {
mFragment.startActivityForResult(
HelpUtils.getHelpIntent(
mContext,
mContext.getString(R.string.location_settings_footer_learn_more_link),
/*backupContext=*/""),
/*requestCode=*/ 0);
}
/**
* Location footer preference group should always be displayed.
*/

View File

@@ -18,6 +18,8 @@ package com.android.settings.security;
import android.content.Context;
import android.os.UserManager;
import android.security.keystore.KeyProperties;
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
import androidx.preference.PreferenceScreen;
@@ -35,6 +37,7 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr
private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
private final KeyStore mKeyStore;
private final KeyStore mWifiKeyStore;
private RestrictedPreference mPreference;
@@ -45,8 +48,19 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr
keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
} catch (Exception e) {
keyStore = null;
}
mKeyStore = keyStore;
keyStore = null;
if (context.getUser().isSystem()) {
try {
keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(new AndroidKeyStoreLoadStoreParameter(KeyProperties.NAMESPACE_WIFI));
} catch (Exception e) {
keyStore = null;
}
}
mWifiKeyStore = keyStore;
if (lifecycle != null) {
lifecycle.addObserver(this);
}
@@ -68,9 +82,11 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr
if (mPreference != null && !mPreference.isDisabledByAdmin()) {
boolean isEnabled = false;
try {
if (mKeyStore != null) {
isEnabled = mKeyStore.aliases().hasMoreElements();
}
isEnabled = (mKeyStore != null
&& mKeyStore.aliases().hasMoreElements())
|| (mWifiKeyStore != null
&& mWifiKeyStore.aliases().hasMoreElements());
} catch (KeyStoreException e) {
// If access to keystore fails, treat as disabled.
}

View File

@@ -33,6 +33,7 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.security.SecurityFeatureProvider;
@@ -44,6 +45,7 @@ import com.android.settingslib.core.lifecycle.events.OnCreate;
import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.transition.SettingsTransitionHelper;
import java.util.ArrayList;
import java.util.List;
@@ -128,6 +130,8 @@ public class TrustAgentListPreferenceController extends AbstractPreferenceContro
.show();
mTrustAgentClickIntent = preference.getIntent();
mTrustAgentClickIntent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
if (!confirmationLaunched && mTrustAgentClickIntent != null) {
// If this returns false, it means no password confirmation is required.

View File

@@ -16,6 +16,8 @@
package com.android.settings.widget;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.util.AttributeSet;
@@ -47,7 +49,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
}
private ImageView mRestrictedIcon;
private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
private EnforcedAdmin mEnforcedAdmin;
private boolean mDisabledByAdmin;
private final MetricsFeatureProvider mMetricsFeatureProvider;
@@ -87,7 +89,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
* If admin is not null, disables the text and switch but keeps the view clickable (unless the
* switch is disabled for other reasons). Otherwise, calls setEnabled.
*/
public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
public void setDisabledByAdmin(EnforcedAdmin admin) {
mEnforcedAdmin = admin;
if (admin != null) {
super.setEnabled(true);

View File

@@ -16,10 +16,13 @@
package com.android.settings.widget;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.Switch;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.PreferenceViewHolder;
@@ -27,7 +30,7 @@ import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.widget.SettingsMainSwitchBar.OnBeforeCheckedChangeListener;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreferenceHelper;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
import java.util.ArrayList;
@@ -38,7 +41,9 @@ import java.util.List;
* This component is used as the main switch of the page
* to enable or disable the prefereces on the page.
*/
public class SettingsMainSwitchPreference extends TwoStatePreference {
public class SettingsMainSwitchPreference extends TwoStatePreference implements
OnMainSwitchChangeListener {
private final List<OnBeforeCheckedChangeListener> mBeforeCheckedChangeListeners =
new ArrayList<>();
private final List<OnMainSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
@@ -46,8 +51,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
private SettingsMainSwitchBar mMainSwitchBar;
private CharSequence mTitle;
private boolean mIsVisible;
private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
private EnforcedAdmin mEnforcedAdmin;
private RestrictedPreferenceHelper mRestrictedHelper;
public SettingsMainSwitchPreference(Context context) {
super(context);
@@ -78,8 +83,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
holder.setDividerAllowedBelow(false);
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
mMainSwitchBar.show();
mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
updateStatus(isChecked());
registerListenerToSwitchBar();
@@ -90,6 +95,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
private void init(Context context, AttributeSet attrs) {
setLayoutResource(R.layout.preference_widget_main_switch);
mSwitchChangeListeners.add(this);
mIsVisible = true;
if (attrs != null) {
@@ -103,6 +109,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
setTitle(title.toString());
}
a.recycle();
mRestrictedHelper = new RestrictedPreferenceHelper(context, this, attrs);
}
}
@@ -129,13 +137,17 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
}
}
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
super.setChecked(isChecked);
}
/**
* Update the switch status of preference
*/
public void updateStatus(boolean checked) {
setChecked(checked);
if (mMainSwitchBar != null) {
mMainSwitchBar.setChecked(checked);
mMainSwitchBar.setTitle(mTitle);
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
mMainSwitchBar.show();
@@ -230,7 +242,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
* Otherwise, calls setEnabled which will enables the entire view including
* the text and switch.
*/
public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
public void setDisabledByAdmin(EnforcedAdmin admin) {
mEnforcedAdmin = admin;
if (mMainSwitchBar != null) {
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);

View File

@@ -22,7 +22,6 @@ import android.os.Bundle;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -35,12 +34,10 @@ import androidx.fragment.app.FragmentPagerAdapter;
import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.RtlCompatibleViewPager;
import com.android.settings.widget.SlidingTabLayout;
@@ -121,12 +118,6 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// TODO(b/176883483): Remove the option menu if collapsing toolbar feature rolled out
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
setHasOptionsMenu(true);
SearchMenuController.init(this /* host */);
HelpMenuController.init(this /* host */);
}
// TODO: besides in onCreate, we should also update subList when SIM / Sub status
// changes.

View File

@@ -1,67 +0,0 @@
/*
* Copyright (C) 2021 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 android.content.Context;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */
@RunWith(RobolectricTestRunner.class)
public class AccessibilityButtonFooterPreferenceControllerTest {
private static final String TEST_KEY = "test_key";
private static final String TEST_TITLE = "test_title";
private final Context mContext = ApplicationProvider.getApplicationContext();
private PreferenceScreen mScreen;
private AccessibilityButtonFooterPreferenceController mController;
@Before
public void setUp() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
final AccessibilityFooterPreference footerPreference =
new AccessibilityFooterPreference(mContext);
footerPreference.setKey(TEST_KEY);
footerPreference.setTitle(TEST_TITLE);
mScreen.addPreference(footerPreference);
mController = new AccessibilityButtonFooterPreferenceController(mContext, TEST_KEY);
}
@Test
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
mController.displayPreference(mScreen);
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
final String packageName = mContext.getString(R.string.accessibility_button_title);
final String iconContentDescription = mContext.getString(
R.string.accessibility_introduction_title,
packageName);
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
}
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright (C) 2021 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 android.content.Context;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link AccessibilityControlTimeoutFooterPreferenceController}. */
@RunWith(RobolectricTestRunner.class)
public class AccessibilityControlTimeoutFooterPreferenceControllerTest {
private static final String TEST_KEY = "test_key";
private static final String TEST_TITLE = "test_title";
private final Context mContext = ApplicationProvider.getApplicationContext();
private PreferenceScreen mScreen;
private AccessibilityControlTimeoutFooterPreferenceController mController;
@Before
public void setUp() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
final AccessibilityFooterPreference footerPreference =
new AccessibilityFooterPreference(mContext);
footerPreference.setKey(TEST_KEY);
footerPreference.setTitle(TEST_TITLE);
mScreen.addPreference(footerPreference);
mController = new AccessibilityControlTimeoutFooterPreferenceController(mContext, TEST_KEY);
}
@Test
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
mController.displayPreference(mScreen);
final AccessibilityFooterPreference footerPreference =
mScreen.findPreference(TEST_KEY);
final String packageName =
mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
final String iconContentDescription = mContext.getString(
R.string.accessibility_introduction_title,
packageName);
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
}
}

View File

@@ -19,13 +19,12 @@ package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.text.method.MovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.preference.PreferenceViewHolder;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
@@ -39,10 +38,6 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public final class AccessibilityFooterPreferenceTest {
private static final String DEFAULT_SUMMARY = "default summary";
private static final String DEFAULT_DESCRIPTION = "default description";
private Context mContext = ApplicationProvider.getApplicationContext();
private AccessibilityFooterPreference mAccessibilityFooterPreference;
private PreferenceViewHolder mPreferenceViewHolder;
@@ -58,41 +53,22 @@ public final class AccessibilityFooterPreferenceTest {
}
@Test
public void onBindViewHolder_initTextConfig_parseTextAndFocusable() {
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
public void onBindViewHolder_LinkDisabledByDefault_notReturnLinkMovement() {
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
android.R.id.title);
assertThat(summaryView.getMovementMethod()).isNull();
}
@Test
public void onBindViewHolder_setLinkEnabled_returnLinkMovement() {
mAccessibilityFooterPreference.setLinkEnabled(true);
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
android.R.id.title);
assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
assertThat(summaryView.isFocusable()).isEqualTo(true);
}
@Test
public void onBindViewHolder_initTextConfigAndAccessibleIcon_groupContentForAccessible() {
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
mAccessibilityFooterPreference.setIconContentDescription(DEFAULT_DESCRIPTION);
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
android.R.id.title);
assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
assertThat(summaryView.isFocusable()).isEqualTo(false);
final LinearLayout infoFrame = (LinearLayout) mPreferenceViewHolder.findViewById(
R.id.icon_frame);
assertThat(infoFrame.getContentDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(infoFrame.isFocusable()).isEqualTo(false);
}
@Test
public void appendHelpLink_timeoutHelpUri_updateSummary() {
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
mAccessibilityFooterPreference.appendHelpLink(R.string.help_url_timeout);
final String title = mAccessibilityFooterPreference.getTitle().toString();
assertThat(title.contains(mContext.getString(R.string.footer_learn_more))).isTrue();
assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class);
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright (C) 2021 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 android.content.Context;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link CaptionFooterPreferenceController}. */
@RunWith(RobolectricTestRunner.class)
public class CaptionFooterPreferenceControllerTest {
private static final String TEST_KEY = "test_key";
private static final String TEST_TITLE = "test_title";
private final Context mContext = ApplicationProvider.getApplicationContext();
private PreferenceScreen mScreen;
private CaptionFooterPreferenceController mController;
@Before
public void setUp() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
final AccessibilityFooterPreference footerPreference =
new AccessibilityFooterPreference(mContext);
footerPreference.setKey(TEST_KEY);
footerPreference.setTitle(TEST_TITLE);
mScreen.addPreference(footerPreference);
mController = new CaptionFooterPreferenceController(mContext, TEST_KEY);
}
@Test
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
mController.displayPreference(mScreen);
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
final String packageName = mContext.getString(R.string.accessibility_captioning_title);
final String iconContentDescription = mContext.getString(
R.string.accessibility_introduction_title,
packageName);
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
}
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (C) 2021 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 android.content.Context;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link ToggleAutoclickFooterPreferenceController}. */
@RunWith(RobolectricTestRunner.class)
public class ToggleAutoclickFooterPreferenceControllerTest {
private static final String TEST_KEY = "test_key";
private static final String TEST_TITLE = "test_title";
private final Context mContext = ApplicationProvider.getApplicationContext();
private PreferenceScreen mScreen;
private ToggleAutoclickFooterPreferenceController mController;
@Before
public void setUp() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
final AccessibilityFooterPreference footerPreference =
new AccessibilityFooterPreference(mContext);
footerPreference.setKey(TEST_KEY);
footerPreference.setTitle(TEST_TITLE);
mScreen.addPreference(footerPreference);
mController = new ToggleAutoclickFooterPreferenceController(mContext, TEST_KEY);
}
@Test
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
mController.displayPreference(mScreen);
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
final String packageName = mContext.getString(
R.string.accessibility_autoclick_preference_title);
final String iconContentDescription = mContext.getString(
R.string.accessibility_introduction_title,
packageName);
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
}
}

View File

@@ -215,8 +215,6 @@ public class ToggleFeaturePreferenceFragmentTest {
(AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference(
mFragment.getPreferenceScreen().getPreferenceCount() - 1);
assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY);
assertThat(accessibilityFooterPreference.getIconContentDescription()).isEqualTo(
DEFAULT_DESCRIPTION);
assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true);
assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1);
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.applications.appinfo;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class ExtraAppInfoFeatureProviderImplTest {
private Context mContext;
private ExtraAppInfoFeatureProviderImpl mController;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mController = new ExtraAppInfoFeatureProviderImpl();
}
@Test
public void isSupported_notSupportedByDefault() {
assertThat(mController.isSupported(mContext)).isEqualTo(false);
}
@Test
public void isEnabled_notEnabledByDefault() {
assertThat(mController.isEnabled(mContext)).isEqualTo(false);
}
@Test
public void getSummary_emptyByDefault() {
assertThat(mController.getSummary(mContext)).isEqualTo("");
}
}

View File

@@ -50,7 +50,6 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowUtils.class)
public class SubSettingLauncherTest {
@Mock
@@ -117,7 +116,6 @@ public class SubSettingLauncherTest {
@Test
public void launch_hasRequestListener_shouldStartActivityForResult() {
ShadowUtils.setIsPageTransitionEnabled(true);
final int requestCode = 123123;
when(mFragment.getActivity()).thenReturn(mActivity);

View File

@@ -200,24 +200,21 @@ public class ActionDisabledByAdminDialogHelperTest {
@Test
public void testMaybeSetLearnMoreButton() {
final UserManager userManager = RuntimeEnvironment.application.getSystemService(
UserManager.class);
final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
mHelper.prepareDialogBuilder(
/* restriction= */ null, ENFORCED_ADMIN);
UserManager userManager = RuntimeEnvironment.application
.getSystemService(UserManager.class);
ShadowUserManager userManagerShadow = Shadow.extract(userManager);
// Set up for shadow call.
userManagerShadow.getSameProfileGroupIds().put(USER_ID, 0);
// Test that the button is shown when user IDs are in the same profile group
AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
mHelper.maybeSetLearnMoreButton(builder);
mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN);
verify(builder).setNeutralButton(anyInt(), any());
// Test that the button is not shown when user IDs are not in the same profile group
userManagerShadow.getSameProfileGroupIds().clear();
builder = mock(AlertDialog.Builder.class);
mHelper.maybeSetLearnMoreButton(builder);
mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN);
verify(builder, never()).setNeutralButton(anyInt(), any());
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.widget;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class SettingsMainSwitchPreferenceTest {
@Mock
private EnforcedAdmin mEnforcedAdmin;
private SettingsMainSwitchPreference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final Context context = RuntimeEnvironment.application;
final SettingsMainSwitchBar switchBar = new SettingsMainSwitchBar(context);
mPreference = new SettingsMainSwitchPreference(context);
ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
}
@Test
public void updateStatus_isRestricted_restrictIconShouldDisplay() {
mPreference.updateStatus(true);
final SettingsMainSwitchBar switchBar = mPreference.getSwitchBar();
final ImageView restrictedIcon = switchBar.findViewById(
com.android.settingslib.widget.R.id.restricted_icon);
assertThat(restrictedIcon.getVisibility() == View.VISIBLE).isTrue();
}
}

View File

@@ -24,86 +24,104 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
import androidx.appcompat.app.AlertDialog;
import androidx.test.runner.AndroidJUnit4;
import com.android.settings.Settings;
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@RunWith(AndroidJUnit4.class)
public class ActionDisabledLearnMoreButtonLauncherImplTest {
private static final int ENFORCED_ADMIN_USER_ID = 123;
private static final UserHandle ENFORCED_ADMIN_USER = UserHandle.of(ENFORCED_ADMIN_USER_ID);
private static final int CONTEXT_USER_ID = -ENFORCED_ADMIN_USER_ID;
private static final UserHandle CONTEXT_USER = UserHandle.of(CONTEXT_USER_ID);
private static final ComponentName ADMIN_COMPONENT =
new ComponentName("some.package.name", "some.package.name.SomeClass");
private static final String URL = "https://testexample.com";
private static final Uri URI = Uri.parse(URL);
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Mock
private Activity mActivity;
@Captor
private ArgumentCaptor<Intent> mIntentCaptor;
@Mock
private AlertDialog.Builder mBuilder;
private ActionDisabledLearnMoreButtonLauncherImpl mImpl;
@Mock
private UserManager mUserManager;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
// Can't mock getSystemService(Class) directly because it's final
when(mActivity.getSystemServiceName(UserManager.class)).thenReturn(Context.USER_SERVICE);
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
when(mActivity.getUserId()).thenReturn(CONTEXT_USER_ID);
when(mUserManager.getUserHandle()).thenReturn(CONTEXT_USER_ID);
mImpl = new ActionDisabledLearnMoreButtonLauncherImpl(mActivity, mBuilder);
}
@Test
public void showAdminPolicies_noComponent_works() {
final EnforcedAdmin enforcedAdmin = createEnforcedAdmin(/* component= */ null);
public void launchShowAdminSettings_works() {
mImpl.launchShowAdminSettings(mActivity);
ActionDisabledLearnMoreButtonLauncherImpl.SHOW_ADMIN_POLICIES
.accept(mActivity, enforcedAdmin);
verify(mActivity).startActivity(mIntentCaptor.capture());
assertDeviceAdminSettingsActivity(mIntentCaptor.getValue());
}
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(mActivity).startActivity(captor.capture());
assertThat(captor.getValue().getComponent().getClassName())
@Test
public void launchShowAdminPolicies_works() {
mImpl.launchShowAdminPolicies(mActivity, ENFORCED_ADMIN_USER, ADMIN_COMPONENT);
verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(ENFORCED_ADMIN_USER));
assertDeviceAdminAddIntent(mIntentCaptor.getValue());
}
@Test
public void showHelpPage_works() {
mImpl.showHelpPage(mActivity, URL);
verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(CONTEXT_USER));
assertActionViewIntent(mIntentCaptor.getValue());
}
private void assertDeviceAdminSettingsActivity(Intent intent) {
assertThat(intent.getComponent().getClassName())
.isEqualTo(Settings.DeviceAdminSettingsActivity.class.getName());
}
@Test
public void showAdminPolicies_withComponent_works() {
final EnforcedAdmin enforcedAdmin = createEnforcedAdmin(ADMIN_COMPONENT);
ActionDisabledLearnMoreButtonLauncherImpl.SHOW_ADMIN_POLICIES
.accept(mActivity, enforcedAdmin);
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(mActivity).startActivityAsUser(
captor.capture(),
eq(UserHandle.of(ENFORCED_ADMIN_USER_ID)));
assertDeviceAdminAddIntent(captor.getValue());
}
@Test
public void launchHelpPage_works() {
ActionDisabledLearnMoreButtonLauncherImpl.LAUNCH_HELP_PAGE.accept(mActivity, URL);
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(mActivity).startActivityAsUser(captor.capture(), eq(UserHandle.SYSTEM));
assertActionViewIntent(captor.getValue());
}
private EnforcedAdmin createEnforcedAdmin(ComponentName component) {
return new RestrictedLockUtils.EnforcedAdmin(
component, UserHandle.of(ENFORCED_ADMIN_USER_ID));
}
private void assertDeviceAdminAddIntent(Intent intent) {
assertThat(intent.getComponent().getClassName())
.isEqualTo(DeviceAdminAdd.class.getName());