Snap for 7364021 from 15d75cf59a to sc-release
Change-Id: Ib893cc110405228715024a8310717eb5aa78d9d2
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:padding="7dp"
|
||||
android:contentDescription="@android:string/fingerprint_icon_content_description"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/fingerprint_enroll_finish" />
|
||||
</com.google.android.setupdesign.view.FillContentLayout>
|
||||
|
||||
|
||||
@@ -495,12 +495,6 @@
|
||||
<!-- Authority of advanced device battery prediction -->
|
||||
<string name="config_battery_prediction_authority" translatable="false"></string>
|
||||
|
||||
<!-- Packages for overriding tile positions on the homepage -->
|
||||
<string-array name="config_homepage_tile_packages" translatable="false"/>
|
||||
|
||||
<!-- Orders for overriding tile positions on the homepage -->
|
||||
<integer-array name="config_homepage_tile_orders"/>
|
||||
|
||||
<!-- Whether to handle slot change events -->
|
||||
<bool name="config_handle_sim_slot_change">false</bool>
|
||||
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
<!-- Sim Card Name length -->
|
||||
<integer name="sim_name_length">32</integer>
|
||||
|
||||
<!-- Height of a user icon view -->
|
||||
<dimen name="user_icon_view_height">56dp</dimen>
|
||||
|
||||
<!-- CheckBoxPreference -->
|
||||
<dimen name="checkbox_widget_min_width">58dip</dimen>
|
||||
<dimen name="checkbox_layout_padding">16dip</dimen>
|
||||
|
||||
@@ -916,11 +916,11 @@
|
||||
<!-- Button text to cancel enrollment [CHAR LIMIT=30] -->
|
||||
<string name="security_settings_fingerprint_enroll_introduction_no_thanks">No thanks</string>
|
||||
<!-- Button text to skip enrollment [CHAR LIMIT=30] -->
|
||||
<string name="security_settings_fingerprint_enroll_introduction_skip">Skip</string>
|
||||
<string name="security_settings_fingerprint_enroll_introduction_skip">No thanks</string>
|
||||
<!-- Button text to continue to the next screen from the introduction [CHAR LIMIT=22] -->
|
||||
<string name="security_settings_fingerprint_enroll_introduction_continue">Continue</string>
|
||||
<!-- Button text to agree the consent and continue to the next screen from the introduction [CHAR LIMIT=22] -->
|
||||
<string name="security_settings_fingerprint_enroll_introduction_agree">Agree</string>
|
||||
<string name="security_settings_fingerprint_enroll_introduction_agree">I agree</string>
|
||||
<!-- Button text to cancel enrollment from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
|
||||
<string name="security_settings_fingerprint_enroll_introduction_cancel_setup">Skip</string>
|
||||
<!-- Button text to continue to the next screen from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
|
||||
@@ -1017,7 +1017,9 @@
|
||||
<!-- Message shown in fingerprint enrollment dialog to locate the sensor -->
|
||||
<string name="security_settings_fingerprint_enroll_find_sensor_message">It\u2019s on the back of your phone. Use your index finger.</string>
|
||||
<!-- Message shown in fingerprint enrollment dialog to locate the sensor [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_udfps_enroll_find_sensor_message">The fingerprint sensor is on your screen. Move your finger across the screen to find it.</string>
|
||||
<string name="security_settings_udfps_enroll_find_sensor_message">The fingerprint sensor is on your screen</string>
|
||||
<!-- Message announced to a11y users during fingerprint enrollment to help them locate the sensor. [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_udfps_enroll_find_sensor_a11y">The fingerprint sensor is on your screen. Move your finger across the screen to find the sensor.</string>
|
||||
<!-- Content description of graphic that shows where the fingerprint of the device is [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_fingerprint_enroll_find_sensor_content_description">Illustration with device and fingerprint sensor location</string>
|
||||
<!-- Label text shown in fingerprint dialog for renaming a fingerprint template [CHAR LIMIT=22] -->
|
||||
@@ -1031,21 +1033,21 @@
|
||||
<!-- Message shown in fingerprint enrollment dialog to begin enrollment [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_fingerprint_enroll_start_message">Put your finger on the sensor and lift after you feel a vibration</string>
|
||||
<!-- Message shown in fingerprint enrollment dialog to begin enrollment [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_udfps_enroll_start_message">Each time you touch, keep your finger on the icon until you feel a vibration</string>
|
||||
<string name="security_settings_udfps_enroll_start_message">Keep your finger on the icon until you feel a vibration</string>
|
||||
<!-- Title shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_fingerprint_enroll_repeat_title">Lift, then touch again</string>
|
||||
<!-- Title shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_udfps_enroll_title_one_more_time">One more time</string>
|
||||
<!-- Title shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=60] -->
|
||||
<string name="security_settings_udfps_enroll_repeat_title_touch_icon">Touch the fingerprint icon as it moves</string>
|
||||
<string name="security_settings_udfps_enroll_repeat_title_touch_icon">Follow the fingerprint icon</string>
|
||||
<!-- Message shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_fingerprint_enroll_repeat_message">Keep lifting your finger to add the different parts of your fingerprint</string>
|
||||
<!-- Message shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_udfps_enroll_repeat_message">This helps capture your full fingerprint</string>
|
||||
<string name="security_settings_udfps_enroll_repeat_message">Touch & hold each time the icon moves. This helps capture your full fingerprint.</string>
|
||||
<!-- Title shown in fingerprint enrollment dialog once enrollment is completed [CHAR LIMIT=29] -->
|
||||
<string name="security_settings_fingerprint_enroll_finish_title">Fingerprint added</string>
|
||||
<!-- Message shown in fingerprint enrollment dialog once enrollment is completed -->
|
||||
<string name="security_settings_fingerprint_enroll_finish_message">When you see this icon, use your fingerprint for identification or to approve purchases</string>
|
||||
<string name="security_settings_fingerprint_enroll_finish_message">Now you can use your fingerprint to unlock your phone or for authentication, like when you sign in to apps</string>
|
||||
<!-- Button text to skip enrollment of fingerprint [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_fingerprint_enroll_enrolling_skip">Do it later</string>
|
||||
<!-- Title of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=40] -->
|
||||
@@ -1505,7 +1507,7 @@
|
||||
<string name="unlock_disable_frp_warning_content_unknown_face_fingerprint">"Device protection features will not work without your screen lock.<xliff:g id="empty_line">\n\n</xliff:g>This deletes the fingerprint model stored on your device. Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face or fingerprint for authentication in apps."</string>
|
||||
|
||||
<!-- Affirmative action of the dialog shown when the user removes the device lock [CHAR LIMIT=25] -->
|
||||
<string name="unlock_disable_frp_warning_ok">Yes, remove</string>
|
||||
<string name="unlock_disable_frp_warning_ok">Delete</string>
|
||||
|
||||
<!-- Title shown on security settings to allow the user to change their lockscreen pattern [CHAR LIMIT=22] -->
|
||||
<string name="unlock_change_lock_pattern_title">Change unlock pattern</string>
|
||||
|
||||
@@ -145,7 +145,6 @@
|
||||
<item name="android:layout_marginStart">4dip</item>
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
<item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
|
||||
<item name="android:textColorHint">?android:attr/textColorSecondary</item>
|
||||
<item name="android:minHeight">@dimen/min_tap_target_size</item>
|
||||
</style>
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:datePickerDialogTheme">@style/PickerDialogTheme.Settings</item>
|
||||
<item name="android:progressBarStyleHorizontal">@style/HorizontalProgressBarStyle</item>
|
||||
<item name="android:textColorHint">?android:attr/textColorSecondary</item>
|
||||
|
||||
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
|
||||
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
|
||||
|
||||
@@ -45,11 +45,6 @@
|
||||
</com.android.settings.widget.GearPreference>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="accounts_category"
|
||||
android:order="100"
|
||||
android:title="@string/account_settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
@@ -73,6 +68,5 @@
|
||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="204"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -46,11 +46,6 @@
|
||||
</com.android.settings.widget.GearPreference>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="accounts_category"
|
||||
android:order="100"
|
||||
android:title="@string/account_settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
@@ -67,6 +62,5 @@
|
||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="210"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<com.android.settings.widget.WorkOnlyCategory
|
||||
android:key="autofill_work_app_defaults"
|
||||
android:order="30"
|
||||
android:title="@string/default_for_work">
|
||||
android:title="@string/autofill_app">
|
||||
|
||||
<com.android.settings.widget.GearPreference
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
|
||||
@@ -46,11 +46,6 @@
|
||||
</com.android.settings.widget.GearPreference>
|
||||
</com.android.settings.widget.WorkOnlyCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="accounts_category"
|
||||
android:order="100"
|
||||
android:title="@string/account_settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
@@ -67,6 +62,5 @@
|
||||
android:title="@string/account_settings_menu_auto_sync_work"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="210"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
android:key="action_buttons"
|
||||
settings:allowDividerBelow="true"/>
|
||||
|
||||
<!-- Add SpacePreference to draw divider -->
|
||||
<com.android.settings.applications.SpacePreference
|
||||
android:layout_height="0dp"
|
||||
settings:allowDividerAbove="true" />
|
||||
|
||||
<com.android.settings.slices.SlicePreference
|
||||
android:key="bt_device_slice"
|
||||
settings:controller="com.android.settings.slices.BlockingSlicePrefController"
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
<com.android.settings.bluetooth.BluetoothProgressCategory
|
||||
android:key="bt_device_list"
|
||||
android:orderingFromXml="false" />
|
||||
android:orderingFromXml="false"
|
||||
android:title="@string/bluetooth_preference_found_media_devices" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
android:key="gesture_navigation_settings_footer"
|
||||
android:title="@string/back_sensitivity_dialog_message"
|
||||
android:selectable="false"
|
||||
settings:searchable="false"
|
||||
settings:allowDividerAbove="true"/>
|
||||
settings:searchable="false"/>
|
||||
</PreferenceScreen>
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
android:key="open_by_default_supported_links"
|
||||
android:title="@string/app_launch_open_domain_urls_title"/>
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="open_by_default_top_intro"
|
||||
android:title="@string/app_launch_top_intro_message"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
android:key="open_by_default_main_category"
|
||||
|
||||
@@ -21,140 +21,157 @@
|
||||
android:key="top_level_settings">
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.network.NetworkDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_wireless"
|
||||
android:key="top_level_network"
|
||||
android:order="-150"
|
||||
android:title="@string/network_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_network"
|
||||
android:order="-120"
|
||||
android:fragment="com.android.settings.network.NetworkDashboardFragment"
|
||||
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
|
||||
android:icon="@drawable/ic_devices_other"
|
||||
android:key="top_level_connected_devices"
|
||||
android:order="-140"
|
||||
android:title="@string/connected_devices_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_connected_device"
|
||||
android:order="-110"
|
||||
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
|
||||
settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_apps_and_notifs"
|
||||
android:title="@string/app_and_notification_dashboard_title"
|
||||
android:summary="@string/app_and_notification_dashboard_summary"
|
||||
android:icon="@drawable/ic_homepage_apps"
|
||||
android:order="-100"
|
||||
android:fragment="com.android.settings.applications.AppAndNotificationDashboardFragment"/>
|
||||
android:fragment="com.android.settings.applications.AppDashboardFragment"
|
||||
android:icon="@drawable/ic_apps"
|
||||
android:key="top_level_apps"
|
||||
android:order="-130"
|
||||
android:title="@string/apps_dashboard_title"
|
||||
android:summary="@string/app_and_notification_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
|
||||
android:icon="@drawable/ic_notifications"
|
||||
android:key="top_level_notification"
|
||||
android:order="-120"
|
||||
android:title="@string/configure_notification_settings"
|
||||
android:summary="@string/notification_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
|
||||
android:icon="@drawable/ic_settings_battery_white"
|
||||
android:key="top_level_battery"
|
||||
android:order="-110"
|
||||
android:title="@string/power_usage_summary_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_battery"
|
||||
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
|
||||
android:order="-90"
|
||||
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_display"
|
||||
android:title="@string/display_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_display"
|
||||
android:order="-80"
|
||||
android:fragment="com.android.settings.DisplaySettings"
|
||||
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_sound"
|
||||
android:title="@string/sound_settings"
|
||||
android:summary="@string/sound_dashboard_summary"
|
||||
android:icon="@drawable/ic_homepage_sound"
|
||||
android:order="-70"
|
||||
android:fragment="com.android.settings.notification.SoundSettings"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
|
||||
android:icon="@drawable/ic_storage_white"
|
||||
android:key="top_level_storage"
|
||||
android:order="-100"
|
||||
android:title="@string/storage_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_storage"
|
||||
android:order="-60"
|
||||
android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
|
||||
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_privacy"
|
||||
android:title="@string/privacy_dashboard_title"
|
||||
android:summary="@string/privacy_dashboard_summary"
|
||||
android:icon="@drawable/ic_homepage_privacy"
|
||||
android:order="-55"
|
||||
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"/>
|
||||
android:fragment="com.android.settings.notification.SoundSettings"
|
||||
android:icon="@drawable/ic_volume_up_24dp"
|
||||
android:key="top_level_sound"
|
||||
android:order="-90"
|
||||
android:title="@string/sound_settings"
|
||||
android:summary="@string/sound_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_location"
|
||||
android:title="@string/location_settings_title"
|
||||
android:summary="@string/location_settings_loading_app_permission_stats"
|
||||
android:icon="@drawable/ic_homepage_location"
|
||||
android:order="-50"
|
||||
android:fragment="com.android.settings.location.LocationSettings"
|
||||
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
|
||||
android:fragment="com.android.settings.DisplaySettings"
|
||||
android:icon="@drawable/ic_settings_display_white"
|
||||
android:key="top_level_display"
|
||||
android:order="-80"
|
||||
android:title="@string/display_settings"
|
||||
android:summary="@string/display_dashboard_summary"
|
||||
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedTopLevelPreference
|
||||
android:icon="@drawable/ic_settings_wallpaper_white"
|
||||
android:key="top_level_wallpaper"
|
||||
android:order="-70"
|
||||
android:title="@string/wallpaper_settings_title"
|
||||
android:summary="@string/wallpaper_dashboard_summary"
|
||||
settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
|
||||
android:icon="@drawable/ic_settings_accessibility"
|
||||
android:key="top_level_accessibility"
|
||||
android:order="-60"
|
||||
android:title="@string/accessibility_settings"
|
||||
android:summary="@string/accessibility_settings_summary"
|
||||
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_security"
|
||||
android:title="@string/security_settings_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_security"
|
||||
android:order="-40"
|
||||
android:fragment="com.android.settings.security.SecuritySettings"
|
||||
android:icon="@drawable/ic_settings_security_white"
|
||||
android:key="top_level_security"
|
||||
android:order="-50"
|
||||
android:title="@string/security_settings_title"
|
||||
android:summary="@string/security_dashboard_summary"
|
||||
settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_accounts"
|
||||
android:title="@string/account_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_accounts"
|
||||
android:order="-30"
|
||||
android:fragment="com.android.settings.accounts.AccountDashboardFragment"
|
||||
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
|
||||
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_privacy"
|
||||
android:key="top_level_privacy"
|
||||
android:order="-40"
|
||||
android:title="@string/privacy_dashboard_title"
|
||||
android:summary="@string/privacy_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_accessibility"
|
||||
android:title="@string/accessibility_settings"
|
||||
android:summary="@string/accessibility_settings_summary"
|
||||
android:icon="@drawable/ic_homepage_accessibility"
|
||||
android:order="-20"
|
||||
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
|
||||
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
|
||||
android:fragment="com.android.settings.location.LocationSettings"
|
||||
android:icon="@drawable/ic_settings_location"
|
||||
android:key="top_level_location"
|
||||
android:order="-30"
|
||||
android:title="@string/location_settings_title"
|
||||
android:summary="@string/location_settings_loading_app_permission_stats"
|
||||
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_emergency"
|
||||
android:title="@string/emergency_settings_preference_title"
|
||||
android:icon="@drawable/ic_homepage_emergency"
|
||||
android:order="-10"
|
||||
android:summary="@string/emergency_dashboard_summary"
|
||||
android:icon="@drawable/ic_settings_emergency"
|
||||
android:order="-20"
|
||||
android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_system"
|
||||
android:title="@string/header_category_system"
|
||||
android:summary="@string/system_dashboard_summary"
|
||||
android:icon="@drawable/ic_homepage_system_dashboard"
|
||||
android:order="10"
|
||||
android:fragment="com.android.settings.system.SystemDashboardFragment"/>
|
||||
android:fragment="com.android.settings.accounts.AccountDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_accounts"
|
||||
android:key="top_level_accounts"
|
||||
android:order="-10"
|
||||
android:title="@string/account_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.system.SystemDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_system_dashboard_white"
|
||||
android:key="top_level_system"
|
||||
android:order="10"
|
||||
android:title="@string/header_category_system"
|
||||
android:summary="@string/system_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
|
||||
android:icon="@drawable/ic_phone_info"
|
||||
android:key="top_level_about_device"
|
||||
android:order="20"
|
||||
android:title="@string/about_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_about"
|
||||
android:order="20"
|
||||
android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
|
||||
settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_help"
|
||||
android:key="top_level_support"
|
||||
android:summary="@string/support_summary"
|
||||
android:title="@string/page_tab_title_support"
|
||||
android:icon="@drawable/ic_homepage_support"
|
||||
android:order="100"
|
||||
android:title="@string/page_tab_title_support"
|
||||
android:summary="@string/support_summary"
|
||||
settings:controller="com.android.settings.support.SupportPreferenceController"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="top_level_settings_grouped">
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.network.NetworkDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_wireless"
|
||||
android:key="top_level_network"
|
||||
android:order="-150"
|
||||
android:title="@string/network_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
|
||||
android:icon="@drawable/ic_devices_other"
|
||||
android:key="top_level_connected_devices"
|
||||
android:order="-140"
|
||||
android:title="@string/connected_devices_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.applications.AppDashboardFragment"
|
||||
android:icon="@drawable/ic_apps"
|
||||
android:key="top_level_apps"
|
||||
android:order="-130"
|
||||
android:title="@string/apps_dashboard_title"
|
||||
android:summary="@string/app_and_notification_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
|
||||
android:icon="@drawable/ic_notifications"
|
||||
android:key="top_level_notification"
|
||||
android:order="-120"
|
||||
android:title="@string/configure_notification_settings"
|
||||
android:summary="@string/notification_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
|
||||
android:icon="@drawable/ic_settings_battery_white"
|
||||
android:key="top_level_battery"
|
||||
android:order="-110"
|
||||
android:title="@string/power_usage_summary_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
|
||||
android:icon="@drawable/ic_storage_white"
|
||||
android:key="top_level_storage"
|
||||
android:order="-100"
|
||||
android:title="@string/storage_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.notification.SoundSettings"
|
||||
android:icon="@drawable/ic_volume_up_24dp"
|
||||
android:key="top_level_sound"
|
||||
android:order="-90"
|
||||
android:title="@string/sound_settings"
|
||||
android:summary="@string/sound_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.DisplaySettings"
|
||||
android:icon="@drawable/ic_settings_display_white"
|
||||
android:key="top_level_display"
|
||||
android:order="-80"
|
||||
android:title="@string/display_settings"
|
||||
android:summary="@string/display_dashboard_summary"
|
||||
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedTopLevelPreference
|
||||
android:icon="@drawable/ic_settings_wallpaper_white"
|
||||
android:key="top_level_wallpaper"
|
||||
android:order="-70"
|
||||
android:title="@string/wallpaper_settings_title"
|
||||
android:summary="@string/wallpaper_dashboard_summary"
|
||||
settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
|
||||
android:icon="@drawable/ic_settings_accessibility"
|
||||
android:key="top_level_accessibility"
|
||||
android:order="-60"
|
||||
android:title="@string/accessibility_settings"
|
||||
android:summary="@string/accessibility_settings_summary"
|
||||
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.security.SecuritySettings"
|
||||
android:icon="@drawable/ic_settings_security_white"
|
||||
android:key="top_level_security"
|
||||
android:order="-50"
|
||||
android:title="@string/security_settings_title"
|
||||
android:summary="@string/security_dashboard_summary"
|
||||
settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_privacy"
|
||||
android:key="top_level_privacy"
|
||||
android:order="-40"
|
||||
android:title="@string/privacy_dashboard_title"
|
||||
android:summary="@string/privacy_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.location.LocationSettings"
|
||||
android:icon="@drawable/ic_settings_location"
|
||||
android:key="top_level_location"
|
||||
android:order="-30"
|
||||
android:title="@string/location_settings_title"
|
||||
android:summary="@string/location_settings_loading_app_permission_stats"
|
||||
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_emergency"
|
||||
android:title="@string/emergency_settings_preference_title"
|
||||
android:summary="@string/emergency_dashboard_summary"
|
||||
android:icon="@drawable/ic_settings_emergency"
|
||||
android:order="-20"
|
||||
android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accounts.AccountDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_accounts"
|
||||
android:key="top_level_accounts"
|
||||
android:order="-10"
|
||||
android:title="@string/account_dashboard_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.system.SystemDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_system_dashboard_white"
|
||||
android:key="top_level_system"
|
||||
android:order="10"
|
||||
android:title="@string/header_category_system"
|
||||
android:summary="@string/system_dashboard_summary"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
|
||||
android:icon="@drawable/ic_phone_info"
|
||||
android:key="top_level_about_device"
|
||||
android:order="20"
|
||||
android:title="@string/about_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_help"
|
||||
android:key="top_level_support"
|
||||
android:order="100"
|
||||
android:title="@string/page_tab_title_support"
|
||||
android:summary="@string/support_summary"
|
||||
settings:controller="com.android.settings.support.SupportPreferenceController"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -80,7 +80,6 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
||||
private static final int ORDER_NEXT_TO_LAST = 1001;
|
||||
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
|
||||
|
||||
private static final String PREF_KEY_ACCOUNTS = "accounts_category";
|
||||
private static final String PREF_KEY_ADD_ACCOUNT = "add_account";
|
||||
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
|
||||
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
|
||||
@@ -324,6 +323,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
||||
mHelper.createAccessiblePreferenceCategory(
|
||||
mFragment.getPreferenceManager().getContext());
|
||||
preferenceGroup.setOrder(mAccountProfileOrder++);
|
||||
preferenceGroup.setTitle(R.string.account_settings); // default title; may be modified below
|
||||
if (isSingleProfile()) {
|
||||
final String title = context.getString(R.string.account_for_section_header,
|
||||
BidiFormatter.getInstance().unicodeWrap(userInfo.name));
|
||||
@@ -349,10 +349,8 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
||||
}
|
||||
}
|
||||
final PreferenceScreen screen = mFragment.getPreferenceScreen();
|
||||
final PreferenceGroup accounts =
|
||||
screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
|
||||
if (accounts != null) {
|
||||
accounts.addPreference(preferenceGroup);
|
||||
if (screen != null) {
|
||||
screen.addPreference(preferenceGroup);
|
||||
}
|
||||
profileData.preferenceGroup = preferenceGroup;
|
||||
if (userInfo.isEnabled()) {
|
||||
|
||||
@@ -158,6 +158,10 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context, AppEntry entry) {
|
||||
if (entry == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
OverlayState state;
|
||||
if (entry.extraInfo instanceof OverlayState) {
|
||||
state = (OverlayState) entry.extraInfo;
|
||||
|
||||
@@ -191,12 +191,13 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
return;
|
||||
}
|
||||
final Activity activity = getActivity();
|
||||
final String summary = activity.getString(R.string.app_launch_top_intro_message);
|
||||
final Preference pref = EntityHeaderController
|
||||
.newInstance(activity, this, null /* header */)
|
||||
.setRecyclerView(getListView(), getSettingsLifecycle())
|
||||
.setIcon(Utils.getBadgedIcon(mContext, mPackageInfo.applicationInfo))
|
||||
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
|
||||
.setSummary("" /* summary */) // no version number
|
||||
.setSummary(summary) // add intro text
|
||||
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
|
||||
.setPackageName(mPackageName)
|
||||
.setUid(mPackageInfo.applicationInfo.uid)
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||
import com.google.android.setupcompat.template.FooterButton;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -109,6 +110,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
@Nullable private AnimatedVectorDrawable mIconBackgroundBlinksDrawable;
|
||||
private boolean mRestoring;
|
||||
private Vibrator mVibrator;
|
||||
private boolean mIsSetupWizard;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -131,7 +133,12 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
setDescriptionText(R.string.security_settings_fingerprint_enroll_start_message);
|
||||
}
|
||||
|
||||
mIsSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
|
||||
if (mCanAssumeUdfps && !mIsSetupWizard) {
|
||||
setHeaderText(R.string.security_settings_udfps_enroll_find_sensor_title);
|
||||
} else {
|
||||
setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
|
||||
}
|
||||
|
||||
mErrorText = findViewById(R.id.error_text);
|
||||
mProgressBar = findViewById(R.id.fingerprint_progress_bar);
|
||||
@@ -280,7 +287,11 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
setDescriptionText(R.string.security_settings_fingerprint_enroll_start_message);
|
||||
}
|
||||
} else if (mCanAssumeUdfps && !isCenterEnrollmentComplete()) {
|
||||
if (mIsSetupWizard) {
|
||||
setHeaderText(R.string.security_settings_udfps_enroll_title_one_more_time);
|
||||
} else {
|
||||
setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
|
||||
}
|
||||
setDescriptionText(R.string.security_settings_udfps_enroll_start_message);
|
||||
} else {
|
||||
if (mCanAssumeUdfps) {
|
||||
|
||||
@@ -72,6 +72,8 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase implements
|
||||
if (mCanAssumeUdfps) {
|
||||
setHeaderText(R.string.security_settings_udfps_enroll_find_sensor_title);
|
||||
setDescriptionText(R.string.security_settings_udfps_enroll_find_sensor_message);
|
||||
final CharSequence description = getString(R.string.security_settings_udfps_enroll_find_sensor_a11y);
|
||||
getLayout().getDescriptionTextView().setContentDescription(description);
|
||||
} else {
|
||||
setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title);
|
||||
setDescriptionText(R.string.security_settings_fingerprint_enroll_find_sensor_message);
|
||||
|
||||
@@ -274,11 +274,14 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
||||
showBatteryPredictionIfNecessary(linearLayout, deviceId, batteryLevel);
|
||||
}
|
||||
final TextView batterySummaryView = linearLayout.findViewById(R.id.bt_battery_summary);
|
||||
if (isUntetheredHeadset(bluetoothDevice)) {
|
||||
if (batteryLevel != BluetoothUtils.META_INT_ERROR) {
|
||||
linearLayout.setVisibility(View.VISIBLE);
|
||||
batterySummaryView.setText(com.android.settings.Utils.formatPercentage(batteryLevel));
|
||||
batterySummaryView.setText(
|
||||
com.android.settings.Utils.formatPercentage(batteryLevel));
|
||||
batterySummaryView.setVisibility(View.VISIBLE);
|
||||
int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, lowBatteryMetaKey);
|
||||
int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice,
|
||||
lowBatteryMetaKey);
|
||||
if (lowBatteryLevel == BluetoothUtils.META_INT_ERROR) {
|
||||
if (batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY) {
|
||||
lowBatteryLevel = CASE_LOW_BATTERY_LEVEL;
|
||||
@@ -294,7 +297,8 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
||||
int level = bluetoothDevice.getBatteryLevel();
|
||||
if (level != BluetoothDevice.BATTERY_LEVEL_UNKNOWN
|
||||
&& level != BluetoothDevice.BATTERY_LEVEL_BLUETOOTH_OFF) {
|
||||
batterySummaryView.setText(com.android.settings.Utils.formatPercentage(level));
|
||||
batterySummaryView.setText(
|
||||
com.android.settings.Utils.formatPercentage(level));
|
||||
batterySummaryView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
batterySummaryView.setVisibility(View.GONE);
|
||||
@@ -304,7 +308,9 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
||||
linearLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
batterySummaryView.setVisibility(View.GONE);
|
||||
}
|
||||
final TextView textView = linearLayout.findViewById(R.id.header_title);
|
||||
if (deviceId == MAIN_DEVICE_ID) {
|
||||
textView.setVisibility(View.GONE);
|
||||
@@ -314,6 +320,14 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isUntetheredHeadset(BluetoothDevice bluetoothDevice) {
|
||||
return BluetoothUtils.getBooleanMetaData(bluetoothDevice,
|
||||
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)
|
||||
|| TextUtils.equals(BluetoothUtils.getStringMetaData(bluetoothDevice,
|
||||
BluetoothDevice.METADATA_DEVICE_TYPE),
|
||||
BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET);
|
||||
}
|
||||
|
||||
private void showBatteryPredictionIfNecessary(LinearLayout linearLayout, int batteryId,
|
||||
int batteryLevel) {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
|
||||
@@ -37,9 +37,9 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
|
||||
if (action == null || !action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PowerManager powerManager = context.getSystemService(PowerManager.class);
|
||||
BluetoothDevice device =
|
||||
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
|
||||
BluetoothDevice.ERROR);
|
||||
String deviceAddress = device != null ? device.getAddress() : null;
|
||||
@@ -62,6 +62,7 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
|
||||
} else {
|
||||
// Put up a notification that leads to the dialog
|
||||
intent.setClass(context, BluetoothPairingService.class);
|
||||
intent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
|
||||
context.startServiceAsUser(intent, UserHandle.CURRENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ import android.os.IBinder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
@@ -39,10 +42,14 @@ import com.android.settings.R;
|
||||
*/
|
||||
public final class BluetoothPairingService extends Service {
|
||||
|
||||
private static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
|
||||
|
||||
private static final String ACTION_DISMISS_PAIRING =
|
||||
@VisibleForTesting
|
||||
static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
|
||||
@VisibleForTesting
|
||||
static final String ACTION_DISMISS_PAIRING =
|
||||
"com.android.settings.bluetooth.ACTION_DISMISS_PAIRING";
|
||||
@VisibleForTesting
|
||||
static final String ACTION_PAIRING_DIALOG =
|
||||
"com.android.settings.bluetooth.ACTION_PAIRING_DIALOG";
|
||||
|
||||
private static final String BLUETOOTH_NOTIFICATION_CHANNEL =
|
||||
"bluetooth_notification_channel";
|
||||
@@ -51,6 +58,9 @@ public final class BluetoothPairingService extends Service {
|
||||
|
||||
private BluetoothDevice mDevice;
|
||||
|
||||
@VisibleForTesting
|
||||
NotificationManager mNm;
|
||||
|
||||
public static Intent getPairingDialogIntent(Context context, Intent intent, int initiator) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
|
||||
@@ -80,33 +90,35 @@ public final class BluetoothPairingService extends Service {
|
||||
if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
|
||||
int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
|
||||
BluetoothDevice.ERROR);
|
||||
Log.d(TAG, "onReceive() Bond state change : " + bondState + ", device name : "
|
||||
+ mDevice.getName());
|
||||
if ((bondState != BluetoothDevice.BOND_NONE) && (bondState != BluetoothDevice.BOND_BONDED)) {
|
||||
return;
|
||||
}
|
||||
} else if (action.equals(ACTION_DISMISS_PAIRING)) {
|
||||
Log.d(TAG, "Notification cancel " + mDevice.getAddress() + " (" +
|
||||
Log.d(TAG, "Notification cancel " + " (" +
|
||||
mDevice.getName() + ")");
|
||||
mDevice.cancelPairing();
|
||||
} else {
|
||||
int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
|
||||
BluetoothDevice.ERROR);
|
||||
Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" +
|
||||
Log.d(TAG, "Dismiss pairing for " + " (" +
|
||||
mDevice.getName() + "), BondState: " + bondState);
|
||||
}
|
||||
stopForeground(true);
|
||||
|
||||
mNm.cancel(NOTIFICATION_ID);
|
||||
stopSelf();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
NotificationManager mgr = (NotificationManager)this
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNm = getSystemService(NotificationManager.class);
|
||||
NotificationChannel notificationChannel = new NotificationChannel(
|
||||
BLUETOOTH_NOTIFICATION_CHANNEL,
|
||||
this.getString(R.string.bluetooth),
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
mgr.createNotificationChannel(notificationChannel);
|
||||
mNm.createNotificationChannel(notificationChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,23 +128,8 @@ public final class BluetoothPairingService extends Service {
|
||||
stopSelf();
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
Resources res = getResources();
|
||||
Notification.Builder builder = new Notification.Builder(this,
|
||||
BLUETOOTH_NOTIFICATION_CHANNEL)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
|
||||
.setTicker(res.getString(R.string.bluetooth_notif_ticker))
|
||||
.setLocalOnly(true);
|
||||
|
||||
PendingIntent pairIntent = PendingIntent.getActivity(this, 0,
|
||||
getPairingDialogIntent(this, intent,
|
||||
BluetoothDevice.EXTRA_PAIRING_INITIATOR_BACKGROUND),
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT
|
||||
| PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
PendingIntent dismissIntent = PendingIntent.getBroadcast(this, 0,
|
||||
new Intent(ACTION_DISMISS_PAIRING), PendingIntent.FLAG_ONE_SHOT
|
||||
| PendingIntent.FLAG_IMMUTABLE);
|
||||
String action = intent.getAction();
|
||||
Log.d(TAG, "onStartCommand() action : " + action);
|
||||
|
||||
mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
|
||||
@@ -142,26 +139,16 @@ public final class BluetoothPairingService extends Service {
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
name = device != null ? device.getAlias() : res.getString(android.R.string.unknownName);
|
||||
}
|
||||
|
||||
Log.d(TAG, "Show pairing notification for " + mDevice.getAddress() + " (" + name + ")");
|
||||
|
||||
Notification.Action pairAction = new Notification.Action.Builder(0,
|
||||
res.getString(R.string.bluetooth_device_context_pair_connect), pairIntent).build();
|
||||
Notification.Action dismissAction = new Notification.Action.Builder(0,
|
||||
res.getString(android.R.string.cancel), dismissIntent).build();
|
||||
|
||||
builder.setContentTitle(res.getString(R.string.bluetooth_notif_title))
|
||||
.setContentText(res.getString(R.string.bluetooth_notif_message, name))
|
||||
.setContentIntent(pairIntent)
|
||||
.setDefaults(Notification.DEFAULT_SOUND)
|
||||
.setColor(getColor(com.android.internal.R.color.system_notification_accent_color))
|
||||
.addAction(pairAction)
|
||||
.addAction(dismissAction);
|
||||
if (TextUtils.equals(action, BluetoothDevice.ACTION_PAIRING_REQUEST)) {
|
||||
createPairingNotification(intent);
|
||||
} else if (TextUtils.equals(action, ACTION_DISMISS_PAIRING)) {
|
||||
Log.d(TAG, "Notification cancel " + " (" + mDevice.getName() + ")");
|
||||
mDevice.cancelPairing();
|
||||
mNm.cancel(NOTIFICATION_ID);
|
||||
stopSelf();
|
||||
} else if (TextUtils.equals(action, ACTION_PAIRING_DIALOG)) {
|
||||
Intent pairingDialogIntent = getPairingDialogIntent(this, intent,
|
||||
BluetoothDevice.EXTRA_PAIRING_INITIATOR_BACKGROUND);
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
|
||||
@@ -170,8 +157,58 @@ public final class BluetoothPairingService extends Service {
|
||||
registerReceiver(mCancelReceiver, filter);
|
||||
mRegistered = true;
|
||||
|
||||
startForeground(NOTIFICATION_ID, builder.getNotification());
|
||||
return START_REDELIVER_INTENT;
|
||||
startActivity(pairingDialogIntent);
|
||||
}
|
||||
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void createPairingNotification(Intent intent) {
|
||||
Resources res = getResources();
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,
|
||||
BLUETOOTH_NOTIFICATION_CHANNEL)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
|
||||
.setTicker(res.getString(R.string.bluetooth_notif_ticker))
|
||||
.setLocalOnly(true);
|
||||
|
||||
int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
|
||||
BluetoothDevice.ERROR);
|
||||
Intent pairingDialogIntent = new Intent(ACTION_PAIRING_DIALOG);
|
||||
pairingDialogIntent.setClass(this, BluetoothPairingService.class);
|
||||
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
|
||||
PendingIntent pairIntent = PendingIntent.getService(this, 0, pairingDialogIntent,
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
Intent serviceIntent = new Intent(ACTION_DISMISS_PAIRING);
|
||||
serviceIntent.setClass(this, BluetoothPairingService.class);
|
||||
serviceIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||
PendingIntent dismissIntent = PendingIntent.getService(this, 0,
|
||||
serviceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
name = device != null ? device.getAlias() : res.getString(android.R.string.unknownName);
|
||||
}
|
||||
|
||||
Log.d(TAG, "Show pairing notification for " + " (" + name + ")");
|
||||
|
||||
NotificationCompat.Action pairAction = new NotificationCompat.Action.Builder(0,
|
||||
res.getString(R.string.bluetooth_device_context_pair_connect), pairIntent).build();
|
||||
NotificationCompat.Action dismissAction = new NotificationCompat.Action.Builder(0,
|
||||
res.getString(android.R.string.cancel), dismissIntent).build();
|
||||
|
||||
builder.setContentTitle(res.getString(R.string.bluetooth_notif_title))
|
||||
.setContentText(res.getString(R.string.bluetooth_notif_message, name))
|
||||
.setContentIntent(pairIntent)
|
||||
.setDefaults(Notification.DEFAULT_SOUND)
|
||||
.setOngoing(true)
|
||||
.setColor(getColor(com.android.internal.R.color.system_notification_accent_color))
|
||||
.addAction(pairAction)
|
||||
.addAction(dismissAction);
|
||||
|
||||
mNm.notify(NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +217,6 @@ public final class BluetoothPairingService extends Service {
|
||||
unregisterReceiver(mCancelReceiver);
|
||||
mRegistered = false;
|
||||
}
|
||||
stopForeground(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,6 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.widget.Toast;
|
||||
@@ -60,7 +59,6 @@ import androidx.preference.SwitchPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.PrimarySwitchPreference;
|
||||
@@ -185,9 +183,6 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
pref.setOrder(order + baseOrder);
|
||||
}
|
||||
}
|
||||
|
||||
overrideTilePosition(tile, pref);
|
||||
|
||||
return outObservers.isEmpty() ? null : outObservers;
|
||||
}
|
||||
|
||||
@@ -402,8 +397,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
private void setPreferenceIcon(Preference preference, Tile tile, boolean forceRoundedIcon,
|
||||
String iconPackage, Icon icon) {
|
||||
Drawable iconDrawable = icon.loadDrawable(preference.getContext());
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
|
||||
&& TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
|
||||
if (TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
|
||||
iconDrawable.setTint(Utils.getHomepageIconColor(preference.getContext()));
|
||||
} else if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {
|
||||
iconDrawable = new AdaptiveIcon(mContext, iconDrawable,
|
||||
@@ -457,25 +451,4 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
}
|
||||
return eligibleUsers;
|
||||
}
|
||||
|
||||
private void overrideTilePosition(Tile tile, Preference pref) {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
|
||||
&& TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
|
||||
final String[] homepageTilePackages = mContext.getResources().getStringArray(
|
||||
R.array.config_homepage_tile_packages);
|
||||
final int[] homepageTileOrders = mContext.getResources().getIntArray(
|
||||
R.array.config_homepage_tile_orders);
|
||||
if (homepageTilePackages.length == 0
|
||||
|| homepageTilePackages.length != homepageTileOrders.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < homepageTilePackages.length; i++) {
|
||||
if (TextUtils.equals(tile.getPackageName(), homepageTilePackages[i])) {
|
||||
pref.setOrder(homepageTileOrders[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.android.settings.display;
|
||||
import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
|
||||
import static android.provider.Settings.Secure.CAMERA_AUTOROTATE;
|
||||
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -32,7 +35,9 @@ import android.provider.Settings;
|
||||
import android.service.rotationresolver.RotationResolverService;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@@ -41,14 +46,12 @@ import com.android.internal.view.RotationPolicy;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
/**
|
||||
* SmartAutoRotateController controls whether auto rotation is enabled
|
||||
*/
|
||||
public class SmartAutoRotateController extends TogglePreferenceController implements
|
||||
Preference.OnPreferenceChangeListener, LifecycleObserver, OnStart, OnStop {
|
||||
Preference.OnPreferenceChangeListener, LifecycleObserver {
|
||||
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final SensorPrivacyManager mPrivacyManager;
|
||||
@@ -60,6 +63,7 @@ public class SmartAutoRotateController extends TogglePreferenceController implem
|
||||
}
|
||||
};
|
||||
private Preference mPreference;
|
||||
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
|
||||
|
||||
public SmartAutoRotateController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
@@ -70,6 +74,10 @@ public class SmartAutoRotateController extends TogglePreferenceController implem
|
||||
mPowerManager = context.getSystemService(PowerManager.class);
|
||||
}
|
||||
|
||||
public void init(Lifecycle lifecycle) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!isRotationResolverServiceAvailable(mContext)) {
|
||||
@@ -101,21 +109,35 @@ public class SmartAutoRotateController extends TogglePreferenceController implem
|
||||
return mPowerManager.isPowerSaveMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnLifecycleEvent(ON_START)
|
||||
public void onStart() {
|
||||
mContext.registerReceiver(mReceiver,
|
||||
new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
|
||||
if (mRotationPolicyListener == null) {
|
||||
mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() {
|
||||
@Override
|
||||
public void onChange() {
|
||||
updateState(mPreference);
|
||||
}
|
||||
};
|
||||
}
|
||||
RotationPolicy.registerRotationPolicyListener(mContext, mRotationPolicyListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnLifecycleEvent(ON_STOP)
|
||||
public void onStop() {
|
||||
mContext.unregisterReceiver(mReceiver);
|
||||
if (mRotationPolicyListener != null) {
|
||||
RotationPolicy.unregisterRotationPolicyListener(mContext, mRotationPolicyListener);
|
||||
mRotationPolicyListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return hasSufficientPermission(mContext) && !isCameraLocked() && !isPowerSaveMode()
|
||||
&& Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
return !RotationPolicy.isRotationLocked(mContext) && hasSufficientPermission(mContext)
|
||||
&& !isCameraLocked() && !isPowerSaveMode() && Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
CAMERA_AUTOROTATE, 0) == 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.android.settings.display.SmartAutoRotateController.hasSufficientPermission;
|
||||
import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.hardware.SensorPrivacyManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -49,16 +47,19 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
||||
private static final String TAG = "SmartAutoRotatePreferenceFragment";
|
||||
|
||||
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
|
||||
private SensorPrivacyManager mPrivacyManager;
|
||||
private AutoRotateSwitchBarController mSwitchBarController;
|
||||
private PowerManager mPowerManager;
|
||||
private static final String FACE_SWITCH_PREFERENCE_ID = "face_based_rotate";
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.auto_rotate_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
use(SmartAutoRotateController.class).init(getLifecycle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -70,8 +71,6 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
||||
switchBar.show();
|
||||
mSwitchBarController = new AutoRotateSwitchBarController(activity, switchBar,
|
||||
getSettingsLifecycle());
|
||||
mPrivacyManager = SensorPrivacyManager.getInstance(activity);
|
||||
mPowerManager = getSystemService(PowerManager.class);
|
||||
final Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
|
||||
if (footerPreference != null) {
|
||||
footerPreference.setTitle(Html.fromHtml(getString(R.string.smart_rotate_text_headline),
|
||||
@@ -89,14 +88,6 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
||||
@Override
|
||||
public void onChange() {
|
||||
mSwitchBarController.onChange();
|
||||
final boolean isLocked = RotationPolicy.isRotationLocked(getContext());
|
||||
final boolean isCameraLocked = mPrivacyManager.isSensorPrivacyEnabled(
|
||||
SensorPrivacyManager.Sensors.CAMERA);
|
||||
final boolean isBatterySaver = mPowerManager.isPowerSaveMode();
|
||||
final Preference preference = findPreference(FACE_SWITCH_PREFERENCE_ID);
|
||||
if (preference != null && hasSufficientPermission(getContext())) {
|
||||
preference.setEnabled(!isLocked && !isCameraLocked && !isBatterySaver);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -59,8 +59,10 @@ public class StartNowPreferenceController extends SettingsMainSwitchPreferenceCo
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
if (isChecked) {
|
||||
if (mSwitchPreference != null) {
|
||||
mMetricsFeatureProvider.logClickedPreference(mSwitchPreference,
|
||||
mSwitchPreference.getExtras().getInt(DashboardFragment.CATEGORY));
|
||||
}
|
||||
mBackend.startDreaming();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -35,7 +36,9 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnCreate;
|
||||
@@ -88,9 +91,10 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
private final String mPreferenceKey;
|
||||
private final SettingsActivity mActivity;
|
||||
private final InstrumentedPreferenceFragment mFragment;
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private final CharSequence[] mNotAllowShowSummaryPackages;
|
||||
private final CharSequence[] mNotAllowShowEntryPackages;
|
||||
private final CharSequence[] mNotAllowShowSummaryPackages;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
// Preference cache to avoid create new instance each time.
|
||||
@VisibleForTesting
|
||||
@@ -110,6 +114,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
.getTextArray(R.array.allowlist_hide_summary_in_battery_usage);
|
||||
mNotAllowShowEntryPackages = context.getResources()
|
||||
.getTextArray(R.array.allowlist_hide_entry_in_battery_usage);
|
||||
mMetricsFeatureProvider =
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
@@ -126,6 +132,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
savedInstanceState.getBoolean(KEY_EXPAND_SYSTEM_INFO, mIsExpanded);
|
||||
Log.d(TAG, String.format("onCreate() slotIndex=%d isExpanded=%b",
|
||||
mTrapezoidIndex, mIsExpanded));
|
||||
mMetricsFeatureProvider.action(mPrefContext, SettingsEnums.OPEN_BATTERY_USAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,15 +197,22 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
final BatteryDiffEntry diffEntry = powerPref.getBatteryDiffEntry();
|
||||
final BatteryHistEntry histEntry = diffEntry.mBatteryHistEntry;
|
||||
final String packageName = histEntry.mPackageName;
|
||||
final boolean isAppEntry = histEntry.isAppEntry();
|
||||
// Checks whether the package is installed or not.
|
||||
boolean isValidPackage = true;
|
||||
if (histEntry.isAppEntry()) {
|
||||
if (isAppEntry) {
|
||||
if (mBatteryUtils == null) {
|
||||
mBatteryUtils = BatteryUtils.getInstance(mPrefContext);
|
||||
}
|
||||
isValidPackage = mBatteryUtils.getPackageUid(packageName)
|
||||
!= BatteryUtils.UID_NULL;
|
||||
}
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
isAppEntry
|
||||
? SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM
|
||||
: SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM,
|
||||
packageName);
|
||||
Log.d(TAG, String.format("handleClick() label=%s key=%s isValid:%b\n%s",
|
||||
diffEntry.getAppLabel(), histEntry.getKey(), isValidPackage, histEntry));
|
||||
if (isValidPackage) {
|
||||
@@ -214,11 +228,20 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
public void onSelect(int trapezoidIndex) {
|
||||
Log.d(TAG, "onChartSelect:" + trapezoidIndex);
|
||||
refreshUi(trapezoidIndex, /*isForce=*/ false);
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
trapezoidIndex == BatteryChartView.SELECTED_INDEX_ALL
|
||||
? SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL
|
||||
: SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpand(boolean isExpanded) {
|
||||
mIsExpanded = isExpanded;
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
SettingsEnums.ACTION_BATTERY_USAGE_EXPAND_ITEM,
|
||||
isExpanded);
|
||||
refreshExpandUi();
|
||||
}
|
||||
|
||||
@@ -236,16 +259,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mBatteryHistoryLevels = null;
|
||||
return;
|
||||
}
|
||||
// Generates battery history timestamp slots.
|
||||
final List<Long> batteryHistoryKeyList =
|
||||
new ArrayList<>(batteryHistoryMap.keySet());
|
||||
Collections.sort(batteryHistoryKeyList);
|
||||
mBatteryHistoryKeys = new long[CHART_KEY_ARRAY_SIZE];
|
||||
for (int index = 0; index < CHART_KEY_ARRAY_SIZE; index++) {
|
||||
mBatteryHistoryKeys[index] = batteryHistoryKeyList.get(index);
|
||||
}
|
||||
|
||||
// Generates the battery history levels for chart graph.
|
||||
mBatteryHistoryKeys = getBatteryHistoryKeys(batteryHistoryMap);
|
||||
mBatteryHistoryLevels = new int[CHART_LEVEL_ARRAY_SIZE];
|
||||
for (int index = 0; index < CHART_LEVEL_ARRAY_SIZE; index++) {
|
||||
final long timestamp = mBatteryHistoryKeys[index * 2];
|
||||
@@ -273,7 +287,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
|
||||
Log.d(TAG, String.format(
|
||||
"setBatteryHistoryMap() size=%d\nkeys=%s\nlevels=%s",
|
||||
batteryHistoryKeyList.size(),
|
||||
batteryHistoryMap.size(),
|
||||
utcToLocalTime(mBatteryHistoryKeys),
|
||||
Arrays.toString(mBatteryHistoryLevels)));
|
||||
}
|
||||
@@ -599,4 +613,37 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static List<BatteryDiffEntry> getBatteryLast24HrUsageData(Context context) {
|
||||
final long start = System.currentTimeMillis();
|
||||
final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.getBatteryHistory(context);
|
||||
if (batteryHistoryMap == null || batteryHistoryMap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Log.d(TAG, String.format("getBatteryLast24HrData() size=%d time=&d/ms",
|
||||
batteryHistoryMap.size(), (System.currentTimeMillis() - start)));
|
||||
final Map<Integer, List<BatteryDiffEntry>> batteryIndexedMap =
|
||||
ConvertUtils.getIndexedUsageMap(
|
||||
context,
|
||||
/*timeSlotSize=*/ CHART_LEVEL_ARRAY_SIZE - 1,
|
||||
getBatteryHistoryKeys(batteryHistoryMap),
|
||||
batteryHistoryMap,
|
||||
/*purgeLowPercentageAndFakeData=*/ true);
|
||||
return batteryIndexedMap.get(BatteryChartView.SELECTED_INDEX_ALL);
|
||||
}
|
||||
|
||||
private static long[] getBatteryHistoryKeys(
|
||||
final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
|
||||
final List<Long> batteryHistoryKeyList =
|
||||
new ArrayList<>(batteryHistoryMap.keySet());
|
||||
Collections.sort(batteryHistoryKeyList);
|
||||
final long[] batteryHistoryKeys = new long[CHART_KEY_ARRAY_SIZE];
|
||||
for (int index = 0; index < CHART_KEY_ARRAY_SIZE; index++) {
|
||||
batteryHistoryKeys[index] = batteryHistoryKeyList.get(index);
|
||||
}
|
||||
return batteryHistoryKeys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.graphics.CornerPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
@@ -44,7 +45,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/** A widget component to draw chart graph. */
|
||||
public class BatteryChartView extends AppCompatImageView implements View.OnClickListener {
|
||||
public class BatteryChartView extends AppCompatImageView implements View.OnClickListener,
|
||||
AccessibilityManager.AccessibilityStateChangeListener {
|
||||
private static final String TAG = "BatteryChartView";
|
||||
private static final List<String> ACCESSIBILITY_SERVICE_NAMES =
|
||||
Arrays.asList("SwitchAccessService", "TalkBackService", "JustSpeakService");
|
||||
@@ -52,6 +54,8 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
private static final String[] PERCENTAGES = new String[] {"100%", "50%", "0%"};
|
||||
private static final int DEFAULT_TRAPEZOID_COUNT = 12;
|
||||
private static final int DEFAULT_TIMESTAMP_COUNT = 4;
|
||||
private static final int DIVIDER_COLOR = Color.parseColor("#CDCCC5");
|
||||
private static final long UPDATE_STATE_DELAYED_TIME = 500L;
|
||||
|
||||
/** Selects all trapezoid shapes. */
|
||||
public static final int SELECTED_INDEX_ALL = -1;
|
||||
@@ -74,7 +78,6 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
// Colors for drawing the trapezoid shape and dividers.
|
||||
private int mTrapezoidColor;
|
||||
private int mTrapezoidSolidColor;
|
||||
private final int mDividerColor = Color.parseColor("#CDCCC5");
|
||||
// For drawing the percentage information.
|
||||
private int mTextPadding;
|
||||
private final Rect mIndent = new Rect();
|
||||
@@ -85,11 +88,17 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
private final Rect[] mTimestampsBounds =
|
||||
new Rect[] {new Rect(), new Rect(), new Rect(), new Rect()};
|
||||
|
||||
@VisibleForTesting
|
||||
Handler mHandler = new Handler();
|
||||
@VisibleForTesting
|
||||
final Runnable mUpdateClickableStateRun = () -> updateClickableState();
|
||||
|
||||
private int[] mLevels;
|
||||
private Paint mTextPaint;
|
||||
private Paint mDividerPaint;
|
||||
private Paint mTrapezoidPaint;
|
||||
private Paint mTrapezoidCurvePaint = null;
|
||||
@VisibleForTesting
|
||||
Paint mTrapezoidCurvePaint = null;
|
||||
private TrapezoidSlot[] mTrapezoidSlots;
|
||||
// Records the location to calculate selected index.
|
||||
private MotionEvent mTouchUpEvent;
|
||||
@@ -257,6 +266,26 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
updateClickableState();
|
||||
mContext.getSystemService(AccessibilityManager.class)
|
||||
.addAccessibilityStateChangeListener(/*listener=*/ this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mContext.getSystemService(AccessibilityManager.class)
|
||||
.removeAccessibilityStateChangeListener(/*listener=*/ this);
|
||||
mHandler.removeCallbacks(mUpdateClickableStateRun);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccessibilityStateChanged(boolean enabled) {
|
||||
Log.d(TAG, "onAccessibilityStateChanged:" + enabled);
|
||||
mHandler.removeCallbacks(mUpdateClickableStateRun);
|
||||
// We should delay it a while since accessibility manager will spend
|
||||
// some times to bind with new enabled accessibility services.
|
||||
mHandler.postDelayed(
|
||||
mUpdateClickableStateRun, UPDATE_STATE_DELAYED_TIME);
|
||||
}
|
||||
|
||||
private void updateClickableState() {
|
||||
@@ -275,6 +304,10 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
mTrapezoidCurvePaint.setColor(mTrapezoidSolidColor);
|
||||
mTrapezoidCurvePaint.setStyle(Paint.Style.STROKE);
|
||||
mTrapezoidCurvePaint.setStrokeWidth(mDividerWidth * 2);
|
||||
} else if (mIsSlotsClickabled) {
|
||||
mTrapezoidCurvePaint = null;
|
||||
// Sets levels again to force update the click state.
|
||||
setLevels(mLevels);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
@@ -299,7 +332,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
mDividerHeight = resources.getDimensionPixelSize(R.dimen.chartview_divider_height);
|
||||
mDividerPaint = new Paint();
|
||||
mDividerPaint.setAntiAlias(true);
|
||||
mDividerPaint.setColor(mDividerColor);
|
||||
mDividerPaint.setColor(DIVIDER_COLOR);
|
||||
mDividerPaint.setStyle(Paint.Style.STROKE);
|
||||
mDividerPaint.setStrokeWidth(mDividerWidth);
|
||||
Log.i(TAG, "mDividerWidth:" + mDividerWidth);
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -29,6 +31,8 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TopLevelBatteryPreferenceController extends BasePreferenceController implements
|
||||
LifecycleObserver, OnStart, OnStop, BatteryPreferenceController {
|
||||
|
||||
@@ -37,9 +41,13 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
|
||||
private Preference mPreference;
|
||||
private BatteryInfo mBatteryInfo;
|
||||
private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
|
||||
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
|
||||
private String mBatteryStatusLabel;
|
||||
|
||||
@VisibleForTesting
|
||||
protected static HashMap<String, ComponentName> sReplacingActivityMap = new HashMap<>();
|
||||
|
||||
public TopLevelBatteryPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(mContext);
|
||||
@@ -53,6 +61,8 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
}, true /* shortString */);
|
||||
});
|
||||
|
||||
mBatterySettingsFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getBatterySettingsFeatureProvider(context);
|
||||
mBatteryStatusFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getBatteryStatusFeatureProvider(context);
|
||||
}
|
||||
@@ -69,6 +79,37 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
String prefFrag = preference.getFragment();
|
||||
if (prefFrag == null || prefFrag.isEmpty()) {
|
||||
// Not a redirect, so use the default.
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
ComponentName currentFragmentName = convertClassPathToComponentName(prefFrag);
|
||||
if (currentFragmentName == null) {
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
ComponentName replacingActivity;
|
||||
if (sReplacingActivityMap.containsKey(prefFrag)) {
|
||||
replacingActivity = sReplacingActivityMap.get(prefFrag);
|
||||
} else {
|
||||
replacingActivity = mBatterySettingsFeatureProvider.getReplacingActivity(
|
||||
currentFragmentName);
|
||||
sReplacingActivityMap.put(prefFrag, replacingActivity);
|
||||
}
|
||||
|
||||
if (replacingActivity == null || currentFragmentName.compareTo(replacingActivity) == 0) {
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(currentFragmentName);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mBatteryBroadcastReceiver.register();
|
||||
@@ -133,4 +174,19 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected static ComponentName convertClassPathToComponentName(String classPath) {
|
||||
if (classPath == null || classPath.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String[] split = classPath.split("\\.");
|
||||
int classNameIndex = split.length - 1;
|
||||
if (classNameIndex < 0) {
|
||||
return null;
|
||||
}
|
||||
int lastPkgIndex = classPath.length() - split[classNameIndex].length() - 1;
|
||||
String pkgName = lastPkgIndex > 0 ? classPath.substring(0, lastPkgIndex) : "";
|
||||
return new ComponentName(pkgName, split[classNameIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,12 +96,7 @@ public class SettingsHomepageActivity extends FragmentActivity {
|
||||
getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
|
||||
}
|
||||
|
||||
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME)) {
|
||||
showSuggestionFragment();
|
||||
} else {
|
||||
findViewById(R.id.homepage_title).setVisibility(View.GONE);
|
||||
avatarView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
|
||||
showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
@@ -33,7 +31,6 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
@@ -41,9 +38,6 @@ import com.android.settings.support.SupportPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable(forTarget = MOBILE)
|
||||
public class TopLevelSettings extends DashboardFragment implements
|
||||
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
|
||||
@@ -59,9 +53,6 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
||||
return R.xml.top_level_settings_grouped;
|
||||
}
|
||||
return R.xml.top_level_settings;
|
||||
}
|
||||
|
||||
@@ -108,9 +99,6 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
||||
return;
|
||||
}
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen == null) {
|
||||
return;
|
||||
@@ -137,16 +125,7 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME)
|
||||
? R.xml.top_level_settings_grouped : R.xml.top_level_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
new BaseSearchIndexProvider(R.xml.top_level_settings) {
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
|
||||
@@ -306,12 +306,6 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigateUp() {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
private @ColorInt int obtainThemeColor(@AttrRes int attrRes) {
|
||||
Resources.Theme theme = new ContextThemeWrapper(this,
|
||||
android.R.style.Theme_DeviceDefault_DayNight).getTheme();
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.android.settings.biometrics.fingerprint.FingerprintStatusPreferenceCo
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
|
||||
import com.android.settings.enterprise.FinancedPrivacyPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
|
||||
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
|
||||
@@ -152,5 +153,11 @@ public class SecuritySettings extends DashboardFragment {
|
||||
return buildPreferenceControllers(context, null /* lifecycle */,
|
||||
null /* host*/);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return !FeatureFactory.getFactory(context).getSecuritySettingsFeatureProvider()
|
||||
.hasAlternativeSecuritySettingsFragment();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -100,14 +100,4 @@
|
||||
|
||||
<!-- Uri to query non-public Slice Uris. -->
|
||||
<string name="config_non_public_slice_query_uri" translatable="false">content://com.android.settings.slices/test</string>
|
||||
|
||||
<!-- Packages for overriding tile positions on the homepage -->
|
||||
<string-array name="config_homepage_tile_packages" translatable="false">
|
||||
<item>com.android.settings</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Orders for overriding tile positions on the homepage -->
|
||||
<integer-array name="config_homepage_tile_orders">
|
||||
<item>100</item>
|
||||
</integer-array>
|
||||
</resources>
|
||||
|
||||
@@ -39,7 +39,6 @@ import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -73,13 +72,9 @@ import java.util.List;
|
||||
ShadowSettingsLibUtils.class})
|
||||
public class AccountPreferenceControllerTest {
|
||||
|
||||
private static final String PREF_KEY_ACCOUNTS = "accounts_category";
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private PreferenceCategory mAccountsCategory;
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private UserManager mUserManager;
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private SettingsPreferenceFragment mFragment;
|
||||
@@ -100,9 +95,6 @@ public class AccountPreferenceControllerTest {
|
||||
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
|
||||
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
||||
// This is a bit ugly, but hard to avoid because of how the mocks are used in these tests.
|
||||
// TODO: Refactor these tests to not use RETURNS_DEEP_STUBS.
|
||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
||||
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
||||
.thenReturn(new AuthenticatorDescription[0]);
|
||||
@@ -174,7 +166,6 @@ public class AccountPreferenceControllerTest {
|
||||
// First time resume will build the UI
|
||||
mController.onResume();
|
||||
reset(mScreen);
|
||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
||||
|
||||
mController.onResume();
|
||||
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
|
||||
@@ -193,7 +184,6 @@ public class AccountPreferenceControllerTest {
|
||||
// add a new profile
|
||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
reset(mScreen);
|
||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
||||
|
||||
mController.onResume();
|
||||
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.bluetooth;
|
||||
|
||||
import static com.android.settings.bluetooth.BluetoothPairingService.ACTION_DISMISS_PAIRING;
|
||||
import static com.android.settings.bluetooth.BluetoothPairingService.ACTION_PAIRING_DIALOG;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.NotificationManager;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BluetoothPairingServiceTest {
|
||||
|
||||
private final String mFakeTicker = "fake_ticker";
|
||||
|
||||
@Mock
|
||||
private NotificationManager mNm;
|
||||
@Mock
|
||||
private BluetoothDevice mDevice;
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private Resources mResources;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private DisplayMetrics mDisplayMetrics;
|
||||
|
||||
private BluetoothPairingService mBluetoothPairingService;
|
||||
private Application mApplication;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mBluetoothPairingService = new BluetoothPairingService();
|
||||
mBluetoothPairingService.mNm = mNm;
|
||||
mApplication = RuntimeEnvironment.application;
|
||||
|
||||
ReflectionHelpers.setField(mBluetoothPairingService, "mBase", mContext);
|
||||
when(mContext.getResources()).thenReturn(mResources);
|
||||
when(mResources.getString(R.string.bluetooth_notif_ticker)).thenReturn(mFakeTicker);
|
||||
when(mContext.getApplicationInfo()).thenReturn(new ApplicationInfo());
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
when(mResources.getDisplayMetrics()).thenReturn(mDisplayMetrics);
|
||||
mDisplayMetrics.density = 1.5f;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receivePairingRequestAction_notificationShown() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_NAME, "fake_name");
|
||||
when(mDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDING);
|
||||
|
||||
mBluetoothPairingService.onStartCommand(intent, /* flags */ 0, /* startId */ 0);
|
||||
|
||||
verify(mNm).notify(eq(mBluetoothPairingService.NOTIFICATION_ID), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiveDismissPairingAction_cancelPairing() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_DISMISS_PAIRING);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_NAME, "fake_name");
|
||||
when(mDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDING);
|
||||
|
||||
mBluetoothPairingService.onStartCommand(intent, /* flags */ 0, /* startId */ 0);
|
||||
|
||||
verify(mDevice).cancelPairing();
|
||||
verify(mNm).cancel(mBluetoothPairingService.NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receivePairingDialogAction_startActivity() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_PAIRING_DIALOG);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||
intent.putExtra(BluetoothDevice.EXTRA_NAME, "fake_name");
|
||||
when(mDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDING);
|
||||
|
||||
mBluetoothPairingService.onStartCommand(intent, /* flags */ 0, /* startId */ 0);
|
||||
|
||||
verify(mContext).startActivity(any());
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class ConnectedDeviceDashboardFragmentTest {
|
||||
private static final String KEY_NEARBY_DEVICES = "bt_nearby_slice";
|
||||
private static final String KEY_DISCOVERABLE_FOOTER = "discoverable_footer";
|
||||
private static final String KEY_SEE_ALL = "previously_connected_devices_see_all";
|
||||
private static final String KEY_ADD_BT_DEVICES = "add_bt_devices";
|
||||
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@@ -83,7 +84,7 @@ public class ConnectedDeviceDashboardFragmentTest {
|
||||
.getNonIndexableKeys(mContext);
|
||||
|
||||
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
|
||||
KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER, KEY_SEE_ALL);
|
||||
KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER, KEY_SEE_ALL, KEY_ADD_BT_DEVICES);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -672,18 +672,4 @@ public class DashboardFeatureProviderImplTest {
|
||||
assertThat(argument.getValue().getIdentifier()).isEqualTo(0);
|
||||
verify(mActivity, never()).getSupportFragmentManager();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void bindPreference_specificHomepageTile_shouldOverridePosition() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true);
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
|
||||
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon,
|
||||
MetricsEvent.VIEW_UNKNOWN, preference, tile, null /*key */,
|
||||
Preference.DEFAULT_ORDER);
|
||||
|
||||
assertThat(preference.getOrder()).isEqualTo(100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ 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 android.content.ContentValues;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -43,6 +44,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -82,12 +84,16 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
@Mock private Resources mResources;
|
||||
|
||||
private Context mContext;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private BatteryDiffEntry mBatteryDiffEntry;
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private BatteryChartPreferenceController mBatteryChartPreferenceController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mBatteryChartPreferenceController = createController();
|
||||
mBatteryChartPreferenceController.mPrefContext = mContext;
|
||||
@@ -331,9 +337,14 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_notPowerGaugePreference_returnFalse() {
|
||||
public void testHandlePreferenceTreeiClick_notPowerGaugePreference_returnFalse() {
|
||||
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(mAppListGroup))
|
||||
.isFalse();
|
||||
|
||||
verify(mMetricsFeatureProvider, never())
|
||||
.action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM);
|
||||
verify(mMetricsFeatureProvider, never())
|
||||
.action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -343,6 +354,11 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
|
||||
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(
|
||||
mPowerGaugePreference)).isTrue();
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM,
|
||||
mBatteryHistEntry.mPackageName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -355,6 +371,11 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
|
||||
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(
|
||||
mPowerGaugePreference)).isFalse();
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM,
|
||||
mBatteryHistEntry.mPackageName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -474,6 +495,11 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
verify(mAppListGroup).addPreference(captor.capture());
|
||||
// Verifies the added preference.
|
||||
assertThat(captor.getValue().getKey()).isEqualTo(PREF_KEY);
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_BATTERY_USAGE_EXPAND_ITEM,
|
||||
true /*isExpanded*/);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -489,6 +515,28 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
verify(mAppListGroup).findPreference(PREF_KEY);
|
||||
verify(mAppListGroup).removePreference(mPowerGaugePreference);
|
||||
assertThat(mBatteryChartPreferenceController.mPreferenceCache).hasSize(1);
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(
|
||||
mContext,
|
||||
SettingsEnums.ACTION_BATTERY_USAGE_EXPAND_ITEM,
|
||||
false /*isExpanded*/);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnSelect_selectSpecificTimeSlot_logMetric() {
|
||||
mBatteryChartPreferenceController.onSelect(1 /*slot index*/);
|
||||
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnSelect_selectAll_logMetric() {
|
||||
mBatteryChartPreferenceController.onSelect(
|
||||
BatteryChartView.SELECTED_INDEX_ALL /*slot index*/);
|
||||
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -610,6 +658,8 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
assertThat(mBatteryChartPreferenceController.mTrapezoidIndex)
|
||||
.isEqualTo(expectedIndex);
|
||||
assertThat(mBatteryChartPreferenceController.mIsExpanded).isTrue();
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(mContext, SettingsEnums.OPEN_BATTERY_USAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -130,6 +130,7 @@ public final class BatteryChartViewTest {
|
||||
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
assertThat(mBatteryChartView.isClickable()).isFalse();
|
||||
assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,6 +142,7 @@ public final class BatteryChartViewTest {
|
||||
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
assertThat(mBatteryChartView.isClickable()).isTrue();
|
||||
assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,6 +157,7 @@ public final class BatteryChartViewTest {
|
||||
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
assertThat(mBatteryChartView.isClickable()).isTrue();
|
||||
assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,5 +169,62 @@ public final class BatteryChartViewTest {
|
||||
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
assertThat(mBatteryChartView.isClickable()).isFalse();
|
||||
assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClickable_restoreFromNonClickableState() {
|
||||
final int[] levels = new int[13];
|
||||
for (int index = 0; index < levels.length; index++) {
|
||||
levels[index] = index + 1;
|
||||
}
|
||||
mBatteryChartView.setTrapezoidCount(12);
|
||||
mBatteryChartView.setLevels(levels);
|
||||
mBatteryChartView.setClickableForce(true);
|
||||
when(mPowerUsageFeatureProvider.isChartGraphSlotsEnabled(mContext))
|
||||
.thenReturn(true);
|
||||
doReturn(true).when(mockAccessibilityManager).isEnabled();
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
// Ensures the testing environment is correct.
|
||||
assertThat(mBatteryChartView.isClickable()).isFalse();
|
||||
// Turns off accessibility service.
|
||||
doReturn(false).when(mockAccessibilityManager).isEnabled();
|
||||
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
|
||||
assertThat(mBatteryChartView.isClickable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnAttachedToWindow_addAccessibilityStateChangeListener() {
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
verify(mockAccessibilityManager)
|
||||
.addAccessibilityStateChangeListener(mBatteryChartView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnDetachedFromWindow_removeAccessibilityStateChangeListener() {
|
||||
mBatteryChartView.onAttachedToWindow();
|
||||
mBatteryChartView.mHandler.postDelayed(
|
||||
mBatteryChartView.mUpdateClickableStateRun, 1000);
|
||||
|
||||
mBatteryChartView.onDetachedFromWindow();
|
||||
|
||||
verify(mockAccessibilityManager)
|
||||
.removeAccessibilityStateChangeListener(mBatteryChartView);
|
||||
assertThat(mBatteryChartView.mHandler.hasCallbacks(
|
||||
mBatteryChartView.mUpdateClickableStateRun))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnAccessibilityStateChanged_postUpdateStateRunnable() {
|
||||
mBatteryChartView.mHandler = spy(mBatteryChartView.mHandler);
|
||||
mBatteryChartView.onAccessibilityStateChanged(/*enabled=*/ true);
|
||||
|
||||
verify(mBatteryChartView.mHandler)
|
||||
.removeCallbacks(mBatteryChartView.mUpdateClickableStateRun);
|
||||
verify(mBatteryChartView.mHandler)
|
||||
.postDelayed(mBatteryChartView.mUpdateClickableStateRun, 500L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.os.BatteryManager;
|
||||
import android.os.BatteryUsageStats;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -45,15 +47,18 @@ import java.util.TimeZone;
|
||||
public final class ConvertUtilsTest {
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private BatteryUsageStats mBatteryUsageStats;
|
||||
@Mock
|
||||
private BatteryEntry mockBatteryEntry;
|
||||
@Mock private BatteryUsageStats mBatteryUsageStats;
|
||||
@Mock private BatteryEntry mockBatteryEntry;
|
||||
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -250,6 +255,21 @@ public final class ConvertUtilsTest {
|
||||
// Verifies the fake data is cleared out.
|
||||
assertThat(entryList.get(0).getPackageName())
|
||||
.isNotEqualTo(ConvertUtils.FAKE_PACKAGE_NAME);
|
||||
|
||||
// Adds lacked data into the battery history map.
|
||||
final int remainingSize = 25 - batteryHistoryKeys.length;
|
||||
for (int index = 0; index < remainingSize; index++) {
|
||||
batteryHistoryMap.put(105L + index + 1, new HashMap<>());
|
||||
}
|
||||
when(mPowerUsageFeatureProvider.getBatteryHistory(mContext))
|
||||
.thenReturn(batteryHistoryMap);
|
||||
|
||||
final List<BatteryDiffEntry> batteryDiffEntryList =
|
||||
BatteryChartPreferenceController.getBatteryLast24HrUsageData(mContext);
|
||||
|
||||
assertThat(batteryDiffEntryList).isNotEmpty();
|
||||
final BatteryDiffEntry resultEntry = batteryDiffEntryList.get(0);
|
||||
assertThat(resultEntry.getPackageName()).isEqualTo("package2");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,26 +21,55 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
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.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TopLevelBatteryPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private TopLevelBatteryPreferenceController mController;
|
||||
private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mContext = spy(Robolectric.setupActivity(Activity.class));
|
||||
mController = new TopLevelBatteryPreferenceController(mContext, "test_key");
|
||||
mBatterySettingsFeatureProvider =
|
||||
mFeatureFactory.batterySettingsFeatureProvider;
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false);
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
TopLevelBatteryPreferenceController.sReplacingActivityMap.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,6 +83,80 @@ public class TopLevelBatteryPreferenceControllerTest {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_noFragment_noCustomActivityCalled() {
|
||||
Preference preference = new Preference(mContext);
|
||||
|
||||
assertThat(mController.handlePreferenceTreeClick(preference)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_sameActivityReturned_noCustomActivityCalled() {
|
||||
String fragmentPath = "my.fragment.ClassName";
|
||||
Preference preference = mock(Preference.class);
|
||||
when(preference.getFragment()).thenReturn(fragmentPath);
|
||||
ComponentName pathName = mController.convertClassPathToComponentName(fragmentPath);
|
||||
when(mBatterySettingsFeatureProvider.getReplacingActivity(any())).thenReturn(pathName);
|
||||
|
||||
assertThat(mController.handlePreferenceTreeClick(preference)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_newActivityReturned_newActivityRedirected() {
|
||||
String fragmentPath = "my.fragment.ClassName";
|
||||
Preference preference = mock(Preference.class);
|
||||
when(preference.getFragment()).thenReturn(fragmentPath);
|
||||
String newFragmentPath = "my.fragment.NewClassName";
|
||||
ComponentName newPathName = mController.convertClassPathToComponentName(newFragmentPath);
|
||||
when(mBatterySettingsFeatureProvider.getReplacingActivity(any())).thenReturn(
|
||||
newPathName);
|
||||
doNothing().when(mContext).startActivity(any());
|
||||
|
||||
assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_calledMultipleTimes_fetchedFromCache() {
|
||||
String fragmentPath = "my.fragment.ClassName";
|
||||
Preference preference = mock(Preference.class);
|
||||
when(preference.getFragment()).thenReturn(fragmentPath);
|
||||
String newFragmentPath = "my.fragment.NewClassName";
|
||||
ComponentName newPathName = mController.convertClassPathToComponentName(newFragmentPath);
|
||||
when(mBatterySettingsFeatureProvider.getReplacingActivity(any())).thenReturn(
|
||||
newPathName);
|
||||
doNothing().when(mContext).startActivity(any());
|
||||
|
||||
assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
|
||||
assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
|
||||
verify(mBatterySettingsFeatureProvider, times(1)).getReplacingActivity(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertClassPathToComponentName_nullInput_returnsNull() {
|
||||
assertThat(mController.convertClassPathToComponentName(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertClassPathToComponentName_emptyStringInput_returnsNull() {
|
||||
assertThat(mController.convertClassPathToComponentName("")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertClassPathToComponentName_singleClassName_returnsCorrectComponentName() {
|
||||
ComponentName output = mController.convertClassPathToComponentName("ClassName");
|
||||
|
||||
assertThat(output.getPackageName()).isEqualTo("");
|
||||
assertThat(output.getClassName()).isEqualTo("ClassName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertClassPathToComponentName_validAddress_returnsCorrectComponentName() {
|
||||
ComponentName output = mController.convertClassPathToComponentName("my.fragment.ClassName");
|
||||
|
||||
assertThat(output.getPackageName()).isEqualTo("my.fragment");
|
||||
assertThat(output.getClassName()).isEqualTo("ClassName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDashboardLabel_returnsCorrectLabel() {
|
||||
BatteryInfo info = new BatteryInfo();
|
||||
|
||||
@@ -28,13 +28,11 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -65,19 +63,6 @@ public class TopLevelSettingsTest {
|
||||
assertThat(mSettings.shouldForceRoundedIcon()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_silkyHomeDisabled_defaultSettings() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false);
|
||||
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.top_level_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_silkyHomeEnabled_groupedSettings() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true);
|
||||
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.top_level_settings_grouped);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCreatePreferences_shouldTintPreferenceIcon() {
|
||||
final Preference preference = new Preference(mContext);
|
||||
|
||||
@@ -1048,8 +1048,7 @@ public class WifiDetailPreferenceController2Test {
|
||||
}
|
||||
|
||||
private NetworkCapabilities makeNetworkCapabilities() {
|
||||
final NetworkCapabilities nc = new NetworkCapabilities.Builder()
|
||||
.clearAll()
|
||||
final NetworkCapabilities nc = NetworkCapabilities.Builder.withoutDefaultCapabilities()
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
.build();
|
||||
return nc;
|
||||
|
||||
@@ -144,8 +144,7 @@ public class ContextualWifiSliceTest {
|
||||
}
|
||||
|
||||
private NetworkCapabilities makeValidatedNetworkCapabilities() {
|
||||
final NetworkCapabilities nc = new NetworkCapabilities.Builder()
|
||||
.clearAll()
|
||||
final NetworkCapabilities nc = NetworkCapabilities.Builder.withoutDefaultCapabilities()
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
||||
.build();
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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.security;
|
||||
|
||||
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
|
||||
import static com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag.FLAG_INCLUDE_PREF_SCREEN;
|
||||
import static com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag.FLAG_NEED_KEY;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.annotation.XmlRes;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.security.trustagent.TrustAgentManager;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class SecuritySettingsTest {
|
||||
|
||||
private Context mContext;
|
||||
private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider;
|
||||
|
||||
@Mock
|
||||
private TrustAgentManager mTrustAgentManager;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
|
||||
SecurityFeatureProvider mSecurityFeatureProvider =
|
||||
mFeatureFactory.getSecurityFeatureProvider();
|
||||
|
||||
when(mSecurityFeatureProvider.getTrustAgentManager()).thenReturn(mTrustAgentManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noAlternativeFragmentAvailable_pageIndexIncluded() throws Exception {
|
||||
when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
|
||||
.thenReturn(false);
|
||||
BaseSearchIndexProvider indexProvider = SecuritySettings.SEARCH_INDEX_DATA_PROVIDER;
|
||||
|
||||
List<String> allXmlKeys = getAllXmlKeys(indexProvider);
|
||||
List<String> nonIndexableKeys = indexProvider.getNonIndexableKeys(mContext);
|
||||
allXmlKeys.removeAll(nonIndexableKeys);
|
||||
|
||||
assertThat(allXmlKeys).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alternativeFragmentAvailable_pageIndexExcluded() throws Exception {
|
||||
when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
|
||||
.thenReturn(true);
|
||||
BaseSearchIndexProvider indexProvider = SecuritySettings.SEARCH_INDEX_DATA_PROVIDER;
|
||||
|
||||
List<String> allXmlKeys = getAllXmlKeys(indexProvider);
|
||||
List<String> nonIndexableKeys = indexProvider.getNonIndexableKeys(mContext);
|
||||
allXmlKeys.removeAll(nonIndexableKeys);
|
||||
|
||||
assertThat(allXmlKeys).isEmpty();
|
||||
}
|
||||
|
||||
private List<String> getAllXmlKeys(BaseSearchIndexProvider indexProvider) throws Exception {
|
||||
final List<SearchIndexableResource> resources = indexProvider.getXmlResourcesToIndex(
|
||||
mContext, true /* not used*/);
|
||||
if (resources == null || resources.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
final List<String> keys = new ArrayList<>();
|
||||
for (SearchIndexableResource res : resources) {
|
||||
keys.addAll(getKeysFromXml(res.xmlResId));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
private List<String> getKeysFromXml(@XmlRes int xmlResId) throws Exception {
|
||||
final List<String> keys = new ArrayList<>();
|
||||
final List<Bundle> metadata = PreferenceXmlParserUtils
|
||||
.extractMetadata(mContext, xmlResId, FLAG_NEED_KEY | FLAG_INCLUDE_PREF_SCREEN);
|
||||
for (Bundle bundle : metadata) {
|
||||
keys.add(bundle.getString(METADATA_KEY));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user