Snap for 4545621 from 844145686c to pi-release

Change-Id: If7e85d1bf9b063b00e89501bff5d7295a0639495
This commit is contained in:
android-build-team Robot
2018-01-14 08:38:00 +00:00
163 changed files with 3058 additions and 917 deletions

View File

@@ -1006,7 +1006,7 @@
<meta-data android:name="com.android.settings.title"
android:resource="@string/about_settings" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.DeviceInfoSettings" />
android:value="com.android.settings.deviceinfo.DeviceInfoSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
@@ -1782,45 +1782,6 @@
<activity android:name=".EncryptionInterstitial"
android:theme="@style/GlifTheme.Light" />
<activity android:name=".Settings$StatusActivity"
android:label="@string/device_status_activity_title"
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings$DeviceInfoSettingsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.deviceinfo.Status" />
</activity>
<!-- Runs in the phone process since it needs access to the Phone object -->
<activity android:name=".Settings$SimStatusActivity"
android:label="@string/sim_status_title"
android:process="com.android.phone">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.deviceinfo.SimStatus" />
</activity>
<!-- Runs in the phone process since it needs access to the Phone object -->
<activity android:name=".Settings$ImeiInformationActivity"
android:label="@string/imei_information_title"
android:process="com.android.phone">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.deviceinfo.ImeiInformation" />
</activity>
<activity android:name=".Settings$StorageDashboardActivity"
android:label="@string/storage_settings"
android:icon="@drawable/ic_settings_storage"
@@ -3220,6 +3181,26 @@
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<service
android:name=".development.qstile.DevelopmentTiles$WindowTrace"
android:label="@string/window_trace_quick_settings_title"
android:icon="@drawable/tile_icon_window_trace"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:enabled="false">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<service
android:name=".development.qstile.DevelopmentTiles$LayerTrace"
android:label="@string/layer_trace_quick_settings_title"
android:icon="@drawable/tile_icon_layer_trace"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:enabled="false">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<activity android:name=".HelpTrampoline"
android:exported="true"

View File

@@ -0,0 +1,29 @@
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M11.709,11.712 L7.061,8.098 6.039,8.893l5.676,4.415 5.676,-4.415 -1.028,-0.801zM11.716,10.11 L16.357,6.496 17.392,5.695 11.716,1.281 6.039,5.695 7.067,6.496Z"
android:fillColor="#FFFFFFFF"/>
<path
android:pathData="m20.27,15.235c0,0.82 -0.671,1.491 -1.491,1.491 -0.134,0 -0.261,-0.015 -0.38,-0.052l-2.654,2.646C15.782,19.439 15.797,19.573 15.797,19.708c0,0.82 -0.671,1.491 -1.491,1.491 -0.82,0 -1.491,-0.671 -1.491,-1.491 0,-0.134 0.015,-0.268 0.052,-0.388L10.966,17.419C10.847,17.456 10.713,17.471 10.579,17.471 10.444,17.471 10.31,17.456 10.191,17.419L6.799,20.818C6.836,20.938 6.851,21.064 6.851,21.199 6.851,22.019 6.18,22.689 5.36,22.689 4.54,22.689 3.869,22.019 3.869,21.199c0,-0.82 0.671,-1.491 1.491,-1.491 0.134,0 0.261,0.015 0.38,0.052L9.14,16.368C9.103,16.249 9.088,16.114 9.088,15.98 9.088,15.16 9.759,14.489 10.579,14.489c0.82,0 1.491,0.671 1.491,1.491 0,0.134 -0.015,0.268 -0.052,0.388l1.901,1.901C14.038,18.232 14.172,18.217 14.306,18.217c0.134,0 0.268,0.015 0.388,0.052L17.34,15.615C17.303,15.496 17.288,15.369 17.288,15.235c0,-0.82 0.671,-1.491 1.491,-1.491 0.82,0 1.491,0.671 1.491,1.491z"
android:fillColor="#FFFFFFFF"/>
</vector>

View File

@@ -0,0 +1,29 @@
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M17.115,1.535L9.984,1.535C9.38,1.535 8.887,2.029 8.887,2.632L8.887,5.923L7.241,5.923C6.638,5.923 6.144,6.417 6.144,7.021l0,5.486c0,0.603 0.494,1.097 1.097,1.097l7.131,0c0.603,0 1.097,-0.494 1.097,-1.097l0,-3.291l1.646,0c0.603,0 1.097,-0.494 1.097,-1.097L18.212,2.632C18.212,2.029 17.718,1.535 17.115,1.535ZM14.372,12.506L7.241,12.506l0,-4.388l7.131,0zM17.115,8.118L15.469,8.118L15.469,7.021C15.469,6.417 14.976,5.923 14.372,5.923L9.984,5.923L9.984,3.729l7.131,0z"
android:fillColor="#FFFFFFFF"/>
<path
android:pathData="m20.27,15.235c0,0.82 -0.671,1.491 -1.491,1.491 -0.134,0 -0.261,-0.015 -0.38,-0.052l-2.654,2.646C15.782,19.439 15.797,19.573 15.797,19.708c0,0.82 -0.671,1.491 -1.491,1.491 -0.82,0 -1.491,-0.671 -1.491,-1.491 0,-0.134 0.015,-0.268 0.052,-0.388L10.966,17.419C10.847,17.456 10.713,17.471 10.579,17.471 10.444,17.471 10.31,17.456 10.191,17.419L6.799,20.818C6.836,20.938 6.851,21.064 6.851,21.199 6.851,22.019 6.18,22.689 5.36,22.689 4.54,22.689 3.869,22.019 3.869,21.199c0,-0.82 0.671,-1.491 1.491,-1.491 0.134,0 0.261,0.015 0.38,0.052L9.14,16.368C9.103,16.249 9.088,16.114 9.088,15.98 9.088,15.16 9.759,14.489 10.579,14.489c0.82,0 1.491,0.671 1.491,1.491 0,0.134 -0.015,0.268 -0.052,0.388l1.901,1.901C14.038,18.232 14.172,18.217 14.306,18.217c0.134,0 0.268,0.015 0.388,0.052L17.34,15.615C17.303,15.496 17.288,15.369 17.288,15.235c0,-0.82 0.671,-1.491 1.491,-1.491 0.82,0 1.491,0.671 1.491,1.491z"
android:fillColor="#FFFFFFFF"/>
</vector>

View File

@@ -47,7 +47,9 @@
style="@style/device_info_dialog_value"
android:id="@+id/security_patch_level_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:textColor="?android:attr/colorAccent"/>
<TextView
style="@style/device_info_dialog_label"

View File

@@ -0,0 +1,44 @@
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/tz_region_spinner_layout"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="?android:attr/colorAccent"
android:gravity="center_vertical"
android:paddingEnd="@dimen/switchbar_subsettings_margin_end"
android:orientation="horizontal">
<Spinner
android:id="@+id/tz_region_spinner"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:paddingStart="64dp"
android:layout_weight="1"
android:background="@drawable/app_filter_spinner_background"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/tz_list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View File

@@ -0,0 +1,62 @@
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView
android:id="@+id/tz_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TimeZone name"
android:textAppearance="?android:attr/textAppearanceListItem" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tz_item_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary" />
<TextView
android:id="@+id/tz_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
<TextView
android:id="@+id/tz_item_dst"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>

View File

@@ -37,7 +37,7 @@
<Button
style="@android:style/Widget.Material.Button.Colored"
android:id="@+id/signin_button"
android:text="@string/support_sign_in_button_text"
android:text="@string/wifi_sign_in_button_text"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"

View File

@@ -57,9 +57,33 @@
<!-- Whether location mode is available or not. -->
<bool name="config_location_mode_available">true</bool>
<!-- Whether location scanning is available or not. -->
<bool name="config_show_location_scanning">true</bool>
<!-- Whether high_power_apps should be shown or not. -->
<bool name="config_show_high_power_apps">true</bool>
<!-- Whether media_volume should be shown or not. -->
<bool name="config_show_media_volume">true</bool>
<!-- Whether alarm_volume should be shown or not. -->
<bool name="config_show_alarm_volume">true</bool>
<!-- Whether notification_volume should be shown or not. -->
<bool name="config_show_notification_volume">true</bool>
<!-- Whether notification_ringtone should be shown or not. -->
<bool name="config_show_notification_ringtone">true</bool>
<!-- Whether screen_locking_sounds should be shown or not. -->
<bool name="config_show_screen_locking_sounds">true</bool>
<!-- Whether charging_sounds should be shown or not. -->
<bool name="config_show_charging_sounds">true</bool>
<!-- Whether touch_sounds should be shown or not. -->
<bool name="config_show_touch_sounds">true</bool>
<!-- Whether device_administrators should be shown or not. -->
<bool name="config_show_device_administrators">true</bool>
@@ -99,6 +123,12 @@
<!-- Whether default_home should be shown or not. -->
<bool name="config_show_default_home">true</bool>
<!-- Whether color correction preference should be shown or not. -->
<bool name="config_show_color_correction_preference">true</bool>
<!-- Whether color inversion preference should be shown or not. -->
<bool name="config_show_color_inversion_preference">true</bool>
<!-- Whether accessibility shortcut preference should be shown or not. -->
<bool name="config_show_accessibility_shortcut_preference">true</bool>

View File

@@ -752,6 +752,17 @@
<string name="zone_list_menu_sort_alphabetically">Sort alphabetically</string>
<!-- Menu item on Select time zone screen -->
<string name="zone_list_menu_sort_by_timezone">Sort by time zone</string>
<!-- Label describing when a given time zone changes to DST or standard time -->
<string name="zone_change_to_from_dst"><xliff:g id="time_type" example="Pacific Summer Time">%1$s</xliff:g> starts on <xliff:g id="transition_date" example="Mar 11 2018">%2$s</xliff:g>.</string>
<!-- Describes the time type "daylight savings time" (used in zone_change_to_from_dst, when no zone specific name is available) -->
<string name="zone_time_type_dst">Daylight savings time</string>
<!-- Describes the time type "standard time" (used in zone_change_to_from_dst, when no zone specific name is available) -->
<string name="zone_time_type_standard">Standard time</string>
<!-- The menu item to switch to selecting a time zone by region (default) -->
<string name="zone_menu_by_region">Time zone by region</string>
<!-- The menu item to switch to selecting a time zone with a fixed offset (such as UTC or GMT+0200) -->
<string name="zone_menu_by_offset">Fixed offset time zones</string>
<!-- Title string shown above DatePicker, letting a user select system date
[CHAR LIMIT=20] -->
<string name="date_picker_title">Date</string>
@@ -793,6 +804,9 @@
<string name="Accounts_settings_title">Accounts</string>
<!-- Main Settings screen setting option title for the item to take you to the location screen -->
<string name="location_settings_title">Location</string>
<!-- Used in the location settings to control turning on/off the feature entirely -->
<string name="location_settings_master_switch_title">Use location</string>
<!-- Main Settings screen setting option title for the item to take you to the accounts screen [CHAR LIMIT=22] -->
<string name="account_settings_title">Accounts</string>
<!-- Main Settings screen setting option title for the item to take you to the security screen -->
@@ -1682,6 +1696,8 @@
<string name="wifi_band_24ghz">2.4 GHz</string>
<!-- Wifi Internal 5GHz as an universal itendifier for 5GHz band -->
<string name="wifi_band_5ghz">5 GHz</string>
<!-- Wifi Sign in text for button [CHAR LIMIT = 40]-->
<string name="wifi_sign_in_button_text">Sign in</string>
<!-- Link speed on Wifi Status screen -->
<string name="link_speed">%1$d Mbps</string>
@@ -1722,6 +1738,9 @@
<string name="wifi_quick_toggle_summary">Turn on Wi\u2011Fi</string>
<!-- Used in the 1st-level settings screen to go to the 2nd-level settings screen [CHAR LIMIT=20]-->
<string name="wifi_settings">Wi\u2011Fi</string>
<!-- Used in the Wi-Fi settings screen to control turning on/off Wi-Fi entirely [CHAR LIMIT=30]-->
<string name="wifi_settings_master_switch_title">Use Wi\u2011Fi</string>
<!-- Title of the Wi-fi settings screen -->
<string name="wifi_settings_category">Wi\u2011Fi settings</string>
<!-- Title of the Wi-fi settings entry in the left top level menu -->
@@ -3432,6 +3451,8 @@
<!-- Main settings screen, setting title for the user to go into the About phone screen -->
<string name="about_settings" product="default">About phone</string>
<!-- Main settings screen, setting title for the user to go into the About phone screen -->
<string name="about_settings" product="device">About device</string>
<!-- Main settings screen, setting title for the user to go into the About phone screen -->
<string name="about_settings" product="emulator">About emulated device</string>
<!-- Main settings screen, setting summary for the user to go into the About phone screen-->
<string name="about_settings_summary">View legal info, status, software version</string>
@@ -3706,6 +3727,15 @@
result from their use.
</string>
<!-- Warning that appears below the unknown sources switch in settings -->
<string name="install_all_warning" product="device">
Your device and personal data are more vulnerable
to attack by unknown apps. By installing apps from
this source, you agree that you are responsible for
any damage to your device or loss of data that may
result from their use.
</string>
<!-- Applications settings screen, setting check box title. If checked, applications show more settings options. -->
<string name="advanced_settings">Advanced settings</string>
<!-- Applications settings screen, setting check box summary. This is the summary for "Advanced settings" checkbox -->
@@ -4394,6 +4424,12 @@
<string name="accessibility_autoclick_preference_title">Click after pointer stops moving</string>
<!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
<string name="accessibility_autoclick_delay_preference_title">Delay before click</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
<string name="accessibility_service_master_switch_title">Use service</string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
<string name="accessibility_caption_master_switch_title">Use captions</string>
<!-- Preference's state when enabled. Note: UPPERCASE -->
<string name="accessibility_summary_state_enabled">ON</string>
@@ -4773,6 +4809,10 @@
<string name="battery_tip_low_battery_title">Low battery capacity</string>
<!-- Summary for the low battery tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_low_battery_summary">Battery can\'t provide good battery life</string>
<!-- Title for the smart battery tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_smart_battery_title">Turn on smart battery manager</string>
<!-- Summary for the smart battery tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_smart_battery_summary">Turn on to optimize battery usage</string>
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_high_usage_title" product="default">Phone used heavily</string>
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
@@ -5049,6 +5089,9 @@
<!-- [CHAR_LIMIT=40] Battery saver: Label for feature, title + menu item -->
<string name="battery_saver">Battery Saver</string>
<!-- Used in the Battery Saver settings screen to control turning on/off the feature entirely -->
<string name="battery_saver_master_switch_title">Use Battery Saver</string>
<!-- [CHAR_LIMIT=40] Battery saver: Title for automatic entry option -->
<string name="battery_saver_turn_on_automatically_title">Turn on automatically</string>
@@ -5600,6 +5643,8 @@
<string name="really_remove_account_message" product="tablet">Removing this account will delete all of its messages, contacts, and other data from the tablet!</string>
<!-- Remove account message in dialog [CHAR LIMIT=NONE] -->
<string name="really_remove_account_message" product="default">Removing this account will delete all of its messages, contacts, and other data from the phone!</string>
<!-- Remove account message in dialog [CHAR LIMIT=NONE] -->
<string name="really_remove_account_message" product="device">Removing this account will delete all of its messages, contacts, and other data from the device!</string>
<!-- This is shown if the autheticator for a given account fails to remove it. [CHAR LIMIT=NONE] -->
<string name="remove_account_failed">This change isn\'t allowed by your admin</string>
<!-- What to show in messaging that refers to this provider, e.g. AccountSyncSettings -->
@@ -8683,6 +8728,12 @@
<!-- [CHAR LIMIT=60] Name of dev option to enable extra quick settings tiles -->
<string name="quick_settings_developer_tiles">Quick settings developer tiles</string>
<!-- [CHAR LIMIT=25] Title of developer tile to toggle window trace -->
<string name="window_trace_quick_settings_title">Window Trace</string>
<!-- [CHAR LIMIT=25] Title of developer tile to toggle layer trace -->
<string name="layer_trace_quick_settings_title">Layer Trace</string>
<!-- [CHAR LIMIT=60] Title of work profile setting page -->
<string name="managed_profile_settings_title">Work profile settings</string>
<!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search -->
@@ -8720,6 +8771,9 @@
<!-- Preference title for the automatic storage manager toggle. [CHAR LIMIT=60]-->
<string name="automatic_storage_manager_preference_title">Storage manager</string>
<!-- Used in the storage manager settings screen to control turning on/off the feature entirely -->
<string name="automatic_storage_manager_master_switch_title">Use Storage manager</string>
<!-- Category title for the automatic settings in the storage manager settings. [CHAR LIMIT=40] -->
<string name="deletion_helper_automatic_title">Automatic</string>

View File

@@ -20,7 +20,7 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="apps_and_notification_screen"
android:title="@string/app_and_notification_dashboard_title"
settings:initialExpandedChildrenCount="4">
settings:initialExpandedChildrenCount="6">
<PreferenceCategory
android:key="recent_apps_category"
@@ -37,7 +37,6 @@
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.Settings$ManageApplicationsActivity">
<extra android:name="show_drawer_menu" android:value="true" />
</intent>
</Preference>
</PreferenceCategory>

View File

@@ -22,12 +22,14 @@
settings:keywords="@string/keywords_display"
settings:initialExpandedChildrenCount="4">
<Preference
<com.android.settingslib.RestrictedPreference
android:key="brightness"
android:title="@string/brightness"
settings:keywords="@string/keywords_display_brightness_level">
<intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
</Preference>
settings:keywords="@string/keywords_display_brightness_level"
settings:useAdminDisabledSummary="true"
settings:userRestriction="no_config_brightness">
<intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
</com.android.settingslib.RestrictedPreference>
<com.android.settings.display.NightDisplayPreference
android:key="night_display"
@@ -38,12 +40,13 @@
settings:keywords="@string/keywords_display_night_display" />
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
<SwitchPreference
<com.android.settingslib.RestrictedSwitchPreference
android:key="auto_brightness"
android:title="@string/auto_brightness_title"
settings:keywords="@string/keywords_display_auto_brightness"
android:summary="@string/auto_brightness_summary"
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
settings:useAdminDisabledSummary="true"
settings:userRestriction="no_config_brightness" />
<com.android.settingslib.RestrictedPreference
android:key="wallpaper"

View File

@@ -61,11 +61,13 @@
android:summary="@string/battery_percentage_description"/>
<!-- Cross-listed item, if you change this, also change it in display_settings.xml -->
<SwitchPreference
<com.android.settingslib.RestrictedSwitchPreference
android:key="auto_brightness_battery"
android:title="@string/auto_brightness_title"
android:summary="@string/auto_brightness_summary"
settings:keywords="@string/keywords_display_auto_brightness"/>
settings:keywords="@string/keywords_display_auto_brightness"
settings:useAdminDisabledSummary="true"
settings:userRestriction="no_config_brightness" />
<!-- Cross-listed item, if you change this, also change it in display_settings.xml -->
<com.android.settings.TimeoutListPreference

View File

@@ -16,6 +16,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="smart_battery_detail"
android:title="@string/smart_battery_manager_title">
<!-- TODO(b/71722498): Add header back, otherwise also remove smart_battery_header

View File

@@ -47,16 +47,19 @@
android:key="zen_mode_events"
android:title="@string/zen_mode_events"/>
<Preference
<!-- Messages -->
<ListPreference
android:key="zen_mode_messages"
android:title="@string/zen_mode_messages"
android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
android:entries="@array/zen_mode_contacts_entries"
android:entryValues="@array/zen_mode_contacts_values"/>
<!-- Calls -->
<Preference
<ListPreference
android:key="zen_mode_calls"
android:title="@string/zen_mode_calls"
android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
android:entries="@array/zen_mode_contacts_entries"
android:entryValues="@array/zen_mode_contacts_values"/>
<!-- Repeat callers -->
<SwitchPreference

View File

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

View File

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

View File

@@ -90,8 +90,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
// Preferences
private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
"toggle_high_text_contrast_preference";
private static final String TOGGLE_INVERSION_PREFERENCE =
"toggle_inversion_preference";
private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE =
"toggle_power_button_ends_call_preference";
private static final String TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE =
@@ -113,9 +111,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
"tts_settings_preference";
private static final String AUTOCLICK_PREFERENCE_SCREEN =
"autoclick_preference_screen";
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
"daltonizer_preference_screen";
@VisibleForTesting static final String TOGGLE_INVERSION_PREFERENCE =
"toggle_inversion_preference";
@VisibleForTesting static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
"daltonizer_preference_screen";
@VisibleForTesting static final String ACCESSIBILITY_SHORTCUT_PREFERENCE =
"accessibility_shortcut_preference";
@@ -619,6 +619,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
displayCategory.addPreference(mToggleInversionPreference);
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
}
checkColorCorrectionVisibility(mDisplayDaltonizerPreferenceScreen);
checkColorInversionVisibility(mToggleInversionPreference);
// Text contrast.
mToggleHighTextContrastPreference.setChecked(
@@ -769,6 +771,20 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
}
}
@VisibleForTesting void checkColorCorrectionVisibility(Preference preference) {
if (!getContext().getResources().getBoolean(
R.bool.config_show_color_correction_preference)) {
removePreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
}
}
@VisibleForTesting void checkColorInversionVisibility(Preference preference) {
if (!getContext().getResources().getBoolean(
R.bool.config_show_color_inversion_preference)) {
removePreference(TOGGLE_INVERSION_PREFERENCE);
}
}
@VisibleForTesting void checkAccessibilityShortcutVisibility(Preference preference) {
if (!getContext().getResources().getBoolean(
R.bool.config_show_accessibility_shortcut_preference)) {

View File

@@ -158,6 +158,8 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
final boolean enabled = mCaptioningManager.isEnabled();
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
mSwitchBar.setSwitchBarText(R.string.accessibility_caption_master_switch_title,
R.string.accessibility_caption_master_switch_title);
mSwitchBar.setCheckedInternal(enabled);
mToggleSwitch = mSwitchBar.getSwitch();

View File

@@ -93,6 +93,12 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
mSwitchBar.removeOnSwitchChangeListener(this);
}
@Override
protected void updateSwitchBarText(SwitchBar switchBar) {
switchBar.setSwitchBarText(R.string.accessibility_daltonizer_master_switch_title,
R.string.accessibility_daltonizer_master_switch_title);
}
private void initPreferences() {
final String value = Integer.toString(
Settings.Secure.getInt(getContentResolver(), TYPE, DEFAULT_TYPE));

View File

@@ -23,6 +23,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.View;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.widget.SwitchBar;
@@ -55,6 +56,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
updateSwitchBarText(mSwitchBar);
mToggleSwitch = mSwitchBar.getSwitch();
onProcessArguments(getArguments());
@@ -83,6 +85,12 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
removeActionBarToggleSwitch();
}
protected void updateSwitchBarText(SwitchBar switchBar) {
// Implement this to provide meaningful text in switch bar
switchBar.setSwitchBarText(R.string.accessibility_service_master_switch_title,
R.string.accessibility_service_master_switch_title);
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
protected void onInstallSwitchBarToggleSwitch() {

View File

@@ -129,7 +129,7 @@ public class ManagedProfileSettings extends SettingsPreferenceFragment
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mWorkModePreference) {
boolean quietModeEnabled = !(boolean) newValue;
mUserManager.trySetQuietModeEnabled(quietModeEnabled, mManagedUser);
mUserManager.requestQuietModeEnabled(quietModeEnabled, mManagedUser);
return true;
}
if (preference == mContactPrefrence) {

View File

@@ -232,7 +232,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
Intent intent = activity.getIntent();
Bundle args = getArguments();
int screenTitle = intent.getIntExtra(
SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.notifications_label);
SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.application_info_label);
String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
if (className == null) {
className = intent.getComponent().getClassName();

View File

@@ -26,4 +26,5 @@ public class FeatureFlags {
public static final String BATTERY_SETTINGS_V2 = "settings_battery_v2";
public static final String BATTERY_DISPLAY_APP_LIST = "settings_battery_display_app_list";
public static final String SECURITY_SETTINGS_V2 = "settings_security_settings_v2";
public static final String ZONE_PICKER_V2 = "settings_zone_picker_v2";
}

View File

@@ -20,7 +20,6 @@ import com.android.settings.ApnEditor;
import com.android.settings.ApnSettings;
import com.android.settings.DateTimeSettings;
import com.android.settings.DeviceAdminSettings;
import com.android.settings.DeviceInfoSettings;
import com.android.settings.DisplaySettings;
import com.android.settings.IccLockSettings;
import com.android.settings.MasterClear;
@@ -64,6 +63,7 @@ import com.android.settings.datausage.DataUsageList;
import com.android.settings.datausage.DataUsageSummary;
import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
import com.android.settings.development.DevelopmentSettingsDashboardFragment;
import com.android.settings.deviceinfo.DeviceInfoSettings;
import com.android.settings.deviceinfo.PrivateVolumeForget;
import com.android.settings.deviceinfo.PrivateVolumeSettings;
import com.android.settings.deviceinfo.PublicVolumeSettings;

View File

@@ -91,7 +91,7 @@ public class WorkModeCondition extends Condition {
public void onActionClick(int index) {
if (index == 0) {
if (mUserHandle != null) {
mUm.trySetQuietModeEnabled(false, mUserHandle);
mUm.requestQuietModeEnabled(false, mUserHandle);
}
setActive(false);
} else {

View File

@@ -20,7 +20,10 @@ import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.util.FeatureFlagUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.datetime.timezone.ZonePicker;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.datetime.ZoneGetter;
@@ -33,11 +36,13 @@ public class TimeZonePreferenceController extends AbstractPreferenceController
private static final String KEY_TIMEZONE = "timezone";
private final AutoTimeZonePreferenceController mAutoTimeZonePreferenceController;
private final boolean mZonePickerV2;
public TimeZonePreferenceController(Context context,
AutoTimeZonePreferenceController autoTimeZonePreferenceController) {
super(context);
mAutoTimeZonePreferenceController = autoTimeZonePreferenceController;
mZonePickerV2 = FeatureFlagUtils.isEnabled(mContext, FeatureFlags.ZONE_PICKER_V2);
}
@Override
@@ -45,6 +50,9 @@ public class TimeZonePreferenceController extends AbstractPreferenceController
if (!(preference instanceof RestrictedPreference)) {
return;
}
if (mZonePickerV2) {
preference.setFragment(ZonePicker.class.getName());
}
preference.setSummary(getTimeZoneOffsetAndName());
if( !((RestrictedPreference) preference).isDisabledByAdmin()) {
preference.setEnabled(!mAutoTimeZonePreferenceController.isEnabled());

View File

@@ -0,0 +1,205 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import android.graphics.Paint;
import android.icu.text.Collator;
import android.icu.text.LocaleDisplayNames;
import android.icu.text.TimeZoneFormat;
import android.icu.text.TimeZoneNames;
import android.icu.text.TimeZoneNames.NameType;
import android.icu.util.Region;
import android.icu.util.Region.RegionType;
import android.icu.util.TimeZone;
import android.icu.util.TimeZone.SystemTimeZoneType;
import com.android.settingslib.datetime.ZoneGetter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
/**
* Provides data for manual selection of time zones based associated to regions. This class makes no
* attempt to avoid IO and processing intensive actions. This means it should not be called from the
* UI thread.
*/
public class DataLoader {
private static final int MIN_HOURS_OFFSET = -14;
private static final int MAX_HOURS_OFFSET = +12;
private final Locale mLocale;
private final Collator mCollator;
private final LocaleDisplayNames mLocaleDisplayNames;
private final TimeZoneFormat mTimeZoneFormat;
private final Paint mPaint;
private final AtomicLong nextItemId = new AtomicLong(1);
private final long mNow = System.currentTimeMillis();
public DataLoader(Locale locale) {
mLocale = locale;
mCollator = Collator.getInstance(locale);
mLocaleDisplayNames = LocaleDisplayNames.getInstance(locale);
mTimeZoneFormat = TimeZoneFormat.getInstance(locale);
mPaint = new Paint();
}
/**
* Returns a {@link RegionInfo} object for each region that has selectable time zones. The
* returned list will be sorted properly for display in the locale.
*/
public List<RegionInfo> loadRegionInfos() {
final Set<Region> regions = Region.getAvailable(RegionType.TERRITORY);
final TreeSet<RegionInfo> regionInfos = new TreeSet<>(new RegionInfoComparator());
for (final Region region : regions) {
final String regionId = region.toString();
final Set<String> timeZoneIds = getTimeZoneIds(regionId);
if (timeZoneIds.isEmpty()) {
continue;
}
final String name = mLocaleDisplayNames.regionDisplayName(regionId);
final String regionalIndicator = createRegionalIndicator(regionId);
regionInfos.add(new RegionInfo(regionId, name, regionalIndicator, timeZoneIds));
}
return Collections.unmodifiableList(new ArrayList<>(regionInfos));
}
/**
* Returns a list of {@link TimeZoneInfo} objects. The returned list will be sorted properly for
* display in the locale.It may be smaller than the input collection, if equivalent IDs are
* passed in.
*
* @param timeZoneIds a list of Olson IDs.
*/
public List<TimeZoneInfo> loadTimeZoneInfos(Collection<String> timeZoneIds) {
final TreeSet<TimeZoneInfo> timeZoneInfos = new TreeSet<>(new TimeZoneInfoComparator());
outer:
for (final String timeZoneId : timeZoneIds) {
final TimeZone timeZone = TimeZone.getFrozenTimeZone(timeZoneId);
for (final TimeZoneInfo other : timeZoneInfos) {
if (other.getTimeZone().hasSameRules(timeZone)) {
continue outer;
}
}
timeZoneInfos.add(createTimeZoneInfo(timeZone));
}
return Collections.unmodifiableList(new ArrayList<>(timeZoneInfos));
}
/**
* Returns a {@link TimeZoneInfo} for each fixed offset time zone, such as UTC or GMT+4. The
* returned list will be sorted in a reasonable way for display.
*/
public List<TimeZoneInfo> loadFixedOffsets() {
final List<TimeZoneInfo> timeZoneInfos = new ArrayList<>();
timeZoneInfos.add(createTimeZoneInfo(TimeZone.getFrozenTimeZone("Etc/UTC")));
for (int hoursOffset = MAX_HOURS_OFFSET; hoursOffset >= MIN_HOURS_OFFSET; --hoursOffset) {
if (hoursOffset == 0) {
// UTC is handled above, so don't add GMT +/-0 again.
continue;
}
final String id = String.format("Etc/GMT%+d", hoursOffset);
timeZoneInfos.add(createTimeZoneInfo(TimeZone.getFrozenTimeZone(id)));
}
return Collections.unmodifiableList(timeZoneInfos);
}
/**
* Gets the set of ids for relevant TimeZones in the given region.
*/
private Set<String> getTimeZoneIds(String regionId) {
return TimeZone.getAvailableIDs(
SystemTimeZoneType.CANONICAL_LOCATION, regionId, /* rawOffset */ null);
}
private TimeZoneInfo createTimeZoneInfo(TimeZone timeZone) {
// Every timezone we handle must be an OlsonTimeZone.
final String id = timeZone.getID();
final TimeZoneNames timeZoneNames = mTimeZoneFormat.getTimeZoneNames();
final java.util.TimeZone javaTimeZone = android.icu.impl.TimeZoneAdapter.wrap(timeZone);
final CharSequence gmtOffset = ZoneGetter.getGmtOffsetText(mTimeZoneFormat, mLocale,
javaTimeZone, new Date(mNow));
return new TimeZoneInfo.Builder(timeZone)
.setGenericName(timeZoneNames.getDisplayName(id, NameType.LONG_GENERIC, mNow))
.setStandardName(timeZoneNames.getDisplayName(id, NameType.LONG_STANDARD, mNow))
.setDaylightName(timeZoneNames.getDisplayName(id, NameType.LONG_DAYLIGHT, mNow))
.setExemplarLocation(timeZoneNames.getExemplarLocationName(id))
.setGmtOffset(gmtOffset)
.setItemId(nextItemId.getAndIncrement())
.build();
}
/**
* Create a Unicode Region Indicator Symbol for a given region id (a.k.a flag emoji). If the
* system can't render a flag for this region or the input is not a region id, this returns
* {@code null}.
*
* @param id the two-character region id.
* @return a String representing the flag of the region or {@code null}.
*/
private String createRegionalIndicator(String id) {
if (id.length() != 2) {
return null;
}
final char c1 = id.charAt(0);
final char c2 = id.charAt(1);
if ('A' > c1 || c1 > 'Z' || 'A' > c2 || c2 > 'Z') {
return null;
}
// Regional Indicator A is U+1F1E6 which is 0xD83C 0xDDE6 in UTF-16.
final String regionalIndicator = new String(
new char[]{0xd83c, (char) (0xdde6 - 'A' + c1), 0xd83c, (char) (0xdde6 - 'A' + c2)});
if (!mPaint.hasGlyph(regionalIndicator)) {
return null;
}
return regionalIndicator;
}
private class TimeZoneInfoComparator implements Comparator<TimeZoneInfo> {
@Override
public int compare(TimeZoneInfo tzi1, TimeZoneInfo tzi2) {
int result =
Integer
.compare(tzi1.getTimeZone().getRawOffset(), tzi2.getTimeZone().getRawOffset());
if (result == 0) {
result = mCollator.compare(tzi1.getExemplarLocation(), tzi2.getExemplarLocation());
}
if (result == 0 && tzi1.getGenericName() != null && tzi2.getGenericName() != null) {
result = mCollator.compare(tzi1.getGenericName(), tzi2.getGenericName());
}
return result;
}
}
private class RegionInfoComparator implements Comparator<RegionInfo> {
@Override
public int compare(RegionInfo r1, RegionInfo r2) {
return mCollator.compare(r1.getName(), r2.getName());
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Data object describing a geographical region.
*
* Regions are roughly equivalent to countries, but not every region is a country (for example "U.S.
* overseas territories" is treated as a country).
*/
public class RegionInfo {
private final String mId;
private final String mName;
private final String mRegionalIndicator;
private final Collection<String> mTimeZoneIds;
public RegionInfo(String id, String name, String regionalIndicator,
Collection<String> timeZoneIds) {
mId = id;
mName = name;
mRegionalIndicator = regionalIndicator;
mTimeZoneIds = Collections.unmodifiableList(new ArrayList<>(timeZoneIds));
}
public String getId() {
return mId;
}
public String getName() {
return mName;
}
public Collection<String> getTimeZoneIds() {
return mTimeZoneIds;
}
@Override
public String toString() {
return mRegionalIndicator != null ? mRegionalIndicator + " " + mName : mName;
}
}

View File

@@ -0,0 +1,208 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import android.content.Context;
import android.graphics.Typeface;
import android.icu.impl.OlsonTimeZone;
import android.icu.text.DateFormat;
import android.icu.text.DisplayContext;
import android.icu.text.SimpleDateFormat;
import android.icu.util.Calendar;
import android.icu.util.TimeZone;
import android.icu.util.TimeZoneTransition;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.settings.R;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* Adapter for showing {@link TimeZoneInfo} objects in a recycler view.
*/
class TimeZoneAdapter extends RecyclerView.Adapter {
static final int VIEW_TYPE_NORMAL = 1;
static final int VIEW_TYPE_SELECTED = 2;
private final DateFormat mTimeFormat;
private final DateFormat mDateFormat;
private final View.OnClickListener mOnClickListener;
private final Context mContext;
private final String mCurrentTimeZone;
private List<TimeZoneInfo> mTimeZoneInfos;
TimeZoneAdapter(View.OnClickListener onClickListener, Context context) {
mOnClickListener = onClickListener;
mContext = context;
mTimeFormat = DateFormat.getTimeInstance(SimpleDateFormat.SHORT);
mDateFormat = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);
mDateFormat.setContext(DisplayContext.CAPITALIZATION_NONE);
mCurrentTimeZone = TimeZone.getDefault().getID();
setHasStableIds(true);
}
@Override
public long getItemId(int position) {
return getItem(position).getItemId();
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.time_zone_list_item, parent, false);
view.setOnClickListener(mOnClickListener);
final ViewHolder viewHolder = new ViewHolder(view);
if (viewType == VIEW_TYPE_SELECTED) {
viewHolder.mNameView.setTypeface(
viewHolder.mNameView.getTypeface(), Typeface.BOLD);
}
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
final TimeZoneInfo item = getItem(position);
final ViewHolder tzHolder = (ViewHolder) holder;
tzHolder.mNameView.setText(formatName(item));
tzHolder.mDetailsView.setText(formatDetails(item));
tzHolder.mTimeView.setText(formatTime(item));
String dstText = formatDstText(item);
tzHolder.mDstView.setText(dstText);
// Hide DST TextView when it has no content.
tzHolder.mDstView.setVisibility(dstText != null ? View.VISIBLE : View.GONE);
}
@Override
public int getItemCount() {
return getTimeZones().size();
}
@Override
public int getItemViewType(int position) {
final TimeZoneInfo tz = getItem(position);
if (tz.getId().equals(mCurrentTimeZone)) {
return VIEW_TYPE_SELECTED;
} else {
return VIEW_TYPE_NORMAL;
}
}
public TimeZoneInfo getItem(int position) {
return getTimeZones().get(position);
}
private CharSequence formatName(TimeZoneInfo item) {
CharSequence name = item.getExemplarLocation();
if (name == null) {
name = item.getGenericName();
}
if (name == null && item.getTimeZone().inDaylightTime(new Date())) {
name = item.getDaylightName();
}
if (name == null) {
name = item.getStandardName();
}
if (name == null) {
name = item.getGmtOffset();
}
return name;
}
private CharSequence formatDetails(TimeZoneInfo item) {
String name = item.getGenericName();
if (name == null) {
if (item.getTimeZone().inDaylightTime(new Date())) {
name = item.getDaylightName();
} else {
name = item.getStandardName();
}
}
if (name == null) {
return item.getGmtOffset();
} else {
return TextUtils.concat(item.getGmtOffset(), " ", name);
}
}
private String formatDstText(TimeZoneInfo item) {
final TimeZone timeZone = item.getTimeZone();
if (!timeZone.observesDaylightTime()) {
return null;
}
final TimeZoneTransition nextDstTransition = findNextDstTransition(timeZone);
if (nextDstTransition == null) {
return null;
}
final boolean toDst = nextDstTransition.getTo().getDSTSavings() != 0;
String timeType = toDst ? item.getDaylightName() : item.getStandardName();
if (timeType == null) {
// Fall back to generic "summer time" and "standard time" if the time zone has no
// specific names.
timeType = toDst ?
mContext.getString(R.string.zone_time_type_dst) :
mContext.getString(R.string.zone_time_type_standard);
}
final Calendar transitionTime = Calendar.getInstance(timeZone);
transitionTime.setTimeInMillis(nextDstTransition.getTime());
final String date = mDateFormat.format(transitionTime);
return mContext.getString(R.string.zone_change_to_from_dst, timeType, date);
}
private TimeZoneTransition findNextDstTransition(TimeZone timeZone) {
if (!(timeZone instanceof OlsonTimeZone)) {
return null;
}
final OlsonTimeZone olsonTimeZone = (OlsonTimeZone) timeZone;
TimeZoneTransition transition = olsonTimeZone.getNextTransition(
System.currentTimeMillis(), /* inclusive */ false);
do {
if (transition.getTo().getDSTSavings() != transition.getFrom().getDSTSavings()) {
break;
}
transition = olsonTimeZone.getNextTransition(
transition.getTime(), /*inclusive */ false);
} while (transition != null);
return transition;
}
private String formatTime(TimeZoneInfo item) {
return mTimeFormat.format(Calendar.getInstance(item.getTimeZone()));
}
private List<TimeZoneInfo> getTimeZones() {
if (mTimeZoneInfos == null) {
return Collections.emptyList();
}
return mTimeZoneInfos;
}
void setTimeZoneInfos(List<TimeZoneInfo> timeZoneInfos) {
mTimeZoneInfos = timeZoneInfos;
notifyDataSetChanged();
}
}

View File

@@ -0,0 +1,136 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import android.icu.util.TimeZone;
import android.text.TextUtils;
/**
* Data object containing information for displaying a time zone for the user to select.
*/
public class TimeZoneInfo {
private final String mId;
private final TimeZone mTimeZone;
private final String mGenericName;
private final String mStandardName;
private final String mDaylightName;
private final String mExemplarLocation;
private final CharSequence mGmtOffset;
// Arbitrary id that's unique within all TimeZoneInfo objects created by a given DataLoader instance.
private final long mItemId;
public TimeZoneInfo(Builder builder) {
mTimeZone = builder.mTimeZone;
mId = mTimeZone.getID();
mGenericName = builder.mGenericName;
mStandardName = builder.mStandardName;
mDaylightName = builder.mDaylightName;
mExemplarLocation = builder.mExemplarLocation;
mGmtOffset = builder.mGmtOffset;
mItemId = builder.mItemId;
}
public String getId() {
return mId;
}
public TimeZone getTimeZone() {
return mTimeZone;
}
public String getExemplarLocation() {
return mExemplarLocation;
}
public String getGenericName() {
return mGenericName;
}
public String getStandardName() {
return mStandardName;
}
public String getDaylightName() {
return mDaylightName;
}
public CharSequence getGmtOffset() {
return mGmtOffset;
}
public long getItemId() {
return mItemId;
}
public static class Builder {
private final TimeZone mTimeZone;
private String mGenericName;
private String mStandardName;
private String mDaylightName;
private String mExemplarLocation;
private CharSequence mGmtOffset;
private long mItemId = -1;
public Builder(TimeZone timeZone) {
if (timeZone == null) {
throw new IllegalArgumentException("TimeZone must not be null!");
}
mTimeZone = timeZone;
}
public Builder setGenericName(String genericName) {
this.mGenericName = genericName;
return this;
}
public Builder setStandardName(String standardName) {
this.mStandardName = standardName;
return this;
}
public Builder setDaylightName(String daylightName) {
mDaylightName = daylightName;
return this;
}
public Builder setExemplarLocation(String exemplarLocation) {
mExemplarLocation = exemplarLocation;
return this;
}
public Builder setGmtOffset(CharSequence gmtOffset) {
mGmtOffset = gmtOffset;
return this;
}
public Builder setItemId(long itemId) {
mItemId = itemId;
return this;
}
public TimeZoneInfo build() {
if (TextUtils.isEmpty(mGmtOffset)) {
throw new IllegalStateException("gmtOffset must not be empty!");
}
if (mItemId == -1) {
throw new IllegalStateException("ItemId not set!");
}
return new TimeZoneInfo(this);
}
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.android.settings.R;
/**
* View holder for a time zone list item.
*/
class ViewHolder extends RecyclerView.ViewHolder {
final TextView mNameView;
final TextView mDstView;
final TextView mDetailsView;
final TextView mTimeView;
public ViewHolder(View itemView) {
super(itemView);
mNameView = itemView.findViewById(R.id.tz_item_name);
mDstView = itemView.findViewById(R.id.tz_item_dst);
mDetailsView = itemView.findViewById(R.id.tz_item_details);
mTimeView = itemView.findViewById(R.id.tz_item_time);
}
}

View File

@@ -0,0 +1,224 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import android.app.Activity;
import android.app.AlarmManager;
import android.content.Context;
import android.icu.util.TimeZone;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
* The class displaying a region list and a list of time zones for the selected region.
* Choosing an item from the list will set the time zone. Pressing Back without choosing from the
* list will not result in a change in the time zone setting.
*/
public class ZonePicker extends InstrumentedFragment
implements AdapterView.OnItemSelectedListener, View.OnClickListener {
private static final int MENU_BY_REGION = Menu.FIRST;
private static final int MENU_BY_OFFSET = Menu.FIRST + 1;
private Locale mLocale;
private List<RegionInfo> mRegions;
private Map<String, List<TimeZoneInfo>> mZoneInfos;
private List<TimeZoneInfo> mFixedOffsetTimeZones;
private TimeZoneAdapter mTimeZoneAdapter;
private String mSelectedTimeZone;
private boolean mSelectByRegion;
private DataLoader mDataLoader;
private RecyclerView mRecyclerView;
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.ZONE_PICKER;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.time_zone_list, container, false);
mLocale = getContext().getResources().getConfiguration().locale;
mDataLoader = new DataLoader(mLocale);
// TOOD: move this off the UI thread.
mRegions = mDataLoader.loadRegionInfos();
mZoneInfos = new HashMap<>();
mSelectByRegion = true;
mSelectedTimeZone = TimeZone.getDefault().getID();
mTimeZoneAdapter = new TimeZoneAdapter(this, getContext());
mRecyclerView = view.findViewById(R.id.tz_list);
mRecyclerView.setAdapter(mTimeZoneAdapter);
mRecyclerView.setLayoutManager(
new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, /* reverseLayout */ false));
final ArrayAdapter<RegionInfo> regionAdapter = new ArrayAdapter<>(getContext(),
R.layout.filter_spinner_item, mRegions);
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
final Spinner spinner = view.findViewById(R.id.tz_region_spinner);
spinner.setAdapter(regionAdapter);
spinner.setOnItemSelectedListener(this);
setupForCurrentTimeZone(spinner);
setHasOptionsMenu(true);
return view;
}
private void setupForCurrentTimeZone(Spinner spinner) {
final String localeRegionId = mLocale.getCountry().toUpperCase(Locale.ROOT);
final String currentTimeZone = TimeZone.getDefault().getID();
boolean fixedOffset = currentTimeZone.startsWith("Etc/GMT") ||
currentTimeZone.equals("Etc/UTC");
for (int regionIndex = 0; regionIndex < mRegions.size(); regionIndex++) {
final RegionInfo region = mRegions.get(regionIndex);
if (localeRegionId.equals(region.getId())) {
spinner.setSelection(regionIndex);
}
if (!fixedOffset) {
for (String timeZoneId: region.getTimeZoneIds()) {
if (TextUtils.equals(timeZoneId, mSelectedTimeZone)) {
spinner.setSelection(regionIndex);
return;
}
}
}
}
if (fixedOffset) {
setSelectByRegion(false);
}
}
@Override
public void onClick(View view) {
// Ignore extra clicks
if (!isResumed()) {
return;
}
final int position = mRecyclerView.getChildAdapterPosition(view);
if (position == RecyclerView.NO_POSITION) {
return;
}
final TimeZoneInfo timeZoneInfo = mTimeZoneAdapter.getItem(position);
// Update the system timezone value
final Activity activity = getActivity();
final AlarmManager alarm = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(timeZoneInfo.getId());
activity.onBackPressed();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(0, MENU_BY_REGION, 0, R.string.zone_menu_by_region);
menu.add(0, MENU_BY_OFFSET, 0, R.string.zone_menu_by_offset);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
if (mSelectByRegion) {
menu.findItem(MENU_BY_REGION).setVisible(false);
menu.findItem(MENU_BY_OFFSET).setVisible(true);
} else {
menu.findItem(MENU_BY_REGION).setVisible(true);
menu.findItem(MENU_BY_OFFSET).setVisible(false);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_BY_REGION:
setSelectByRegion(true);
return true;
case MENU_BY_OFFSET:
setSelectByRegion(false);
return true;
default:
return false;
}
}
private void setSelectByRegion(boolean selectByRegion) {
mSelectByRegion = selectByRegion;
getView().findViewById(R.id.tz_region_spinner_layout).setVisibility(
mSelectByRegion ? View.VISIBLE : View.GONE);
List<TimeZoneInfo> tzInfos;
if (selectByRegion) {
Spinner regionSpinner = getView().findViewById(R.id.tz_region_spinner);
int selectedRegion = regionSpinner.getSelectedItemPosition();
if (selectedRegion == -1) {
// Arbitrarily pick the first item if no region was selected above.
selectedRegion = 0;
regionSpinner.setSelection(selectedRegion);
}
tzInfos = getTimeZoneInfos(mRegions.get(selectedRegion));
} else {
if (mFixedOffsetTimeZones == null) {
mFixedOffsetTimeZones = mDataLoader.loadFixedOffsets();
}
tzInfos = mFixedOffsetTimeZones;
}
mTimeZoneAdapter.setTimeZoneInfos(tzInfos);
}
private List<TimeZoneInfo> getTimeZoneInfos(RegionInfo regionInfo) {
List<TimeZoneInfo> tzInfos = mZoneInfos.get(regionInfo.getId());
if (tzInfos == null) {
// TODO: move this off the UI thread.
Collection<String> tzIds = regionInfo.getTimeZoneIds();
tzInfos = mDataLoader.loadTimeZoneInfos(tzIds);
mZoneInfos.put(regionInfo.getId(), tzInfos);
}
return tzInfos;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mTimeZoneAdapter.setTimeZoneInfos(getTimeZoneInfos(mRegions.get(position)));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
mTimeZoneAdapter.setTimeZoneInfos(null);
}
}

View File

@@ -81,6 +81,8 @@ public class AutomaticStorageManagerSettings extends DashboardFragment
private void initializeSwitchBar() {
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
mSwitchBar.setSwitchBarText(R.string.automatic_storage_manager_master_switch_title,
R.string.automatic_storage_manager_master_switch_title);
mSwitchBar.show();
mSwitchController =
new AutomaticStorageManagerSwitchBarController(

View File

@@ -16,20 +16,27 @@
package com.android.settings.development.qstile;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.view.IWindowManager;
import android.view.ThreadedRenderer;
import android.view.View;
import android.view.WindowManagerGlobal;
import com.android.internal.app.LocalePicker;
import com.android.settings.wrapper.IWindowManagerWrapper;
import com.android.settingslib.development.SystemPropPoker;
public abstract class DevelopmentTiles extends TileService {
private static final String TAG = "DevelopmentTiles";
protected abstract boolean isEnabled();
@@ -131,4 +138,106 @@ public abstract class DevelopmentTiles extends TileService {
} catch (RemoteException e) { }
}
}
/**
* Tile to toggle Window Trace.
*/
public static class WindowTrace extends DevelopmentTiles {
@VisibleForTesting
IWindowManagerWrapper mWindowManager;
@Override
public void onCreate() {
super.onCreate();
mWindowManager = new IWindowManagerWrapper(WindowManagerGlobal
.getWindowManagerService());
}
@Override
protected boolean isEnabled() {
try {
return mWindowManager.isWindowTraceEnabled();
} catch (RemoteException e) {
Log.e(TAG,
"Could not get window trace status, defaulting to false." + e.toString());
}
return false;
}
@Override
protected void setIsEnabled(boolean isEnabled) {
try {
if (isEnabled) {
mWindowManager.startWindowTrace();
} else {
mWindowManager.stopWindowTrace();
}
} catch (RemoteException e) {
Log.e(TAG, "Could not set window trace status." + e.toString());
}
}
}
/**
* Tile to toggle Layer Trace.
*/
public static class LayerTrace extends DevelopmentTiles {
@VisibleForTesting
static final int SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE = 1025;
@VisibleForTesting
static final int SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE = 1026;
@VisibleForTesting
IBinder mSurfaceFlinger;
@Override
public void onCreate() {
super.onCreate();
mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger");
}
@Override
protected boolean isEnabled() {
boolean surfaceTraceEnabled = false;
Parcel reply = null;
Parcel data = null;
try {
if (mSurfaceFlinger != null) {
reply = Parcel.obtain();
data = Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE,
data, reply, 0 /* flags */ );
surfaceTraceEnabled = reply.readBoolean();
}
} catch (RemoteException e) {
Log.e(TAG, "Could not get layer trace status, defaulting to false." + e.toString());
} finally {
if (data != null) {
data.recycle();
reply.recycle();
}
}
return surfaceTraceEnabled;
}
@Override
protected void setIsEnabled(boolean isEnabled) {
Parcel data = null;
try {
if (mSurfaceFlinger != null) {
data = Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(isEnabled ? 1 : 0);
mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE,
data, null, 0 /* flags */);
}
} catch (RemoteException e) {
Log.e(TAG, "Could not set layer tracing." + e.toString());
} finally {
if (data != null) {
data.recycle();
}
}
}
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.settings;
package com.android.settings.deviceinfo;
import android.app.Activity;
import android.app.Fragment;
@@ -26,23 +26,13 @@ import android.support.annotation.VisibleForTesting;
import android.telephony.TelephonyManager;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.deviceinfo.BluetoothAddressPreferenceController;
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
import com.android.settings.deviceinfo.DeviceModelPreferenceController;
import com.android.settings.deviceinfo.FccEquipmentIdPreferenceController;
import com.android.settings.deviceinfo.FeedbackPreferenceController;
import com.android.settings.deviceinfo.ImsStatusPreferenceController;
import com.android.settings.deviceinfo.IpAddressPreferenceController;
import com.android.settings.deviceinfo.ManualPreferenceController;
import com.android.settings.deviceinfo.PhoneNumberPreferenceController;
import com.android.settings.deviceinfo.RegulatoryInfoPreferenceController;
import com.android.settings.deviceinfo.SafetyInfoPreferenceController;
import com.android.settings.deviceinfo.WifiMacAddressPreferenceController;
import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceControllerV2;
import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceControllerV2;
import com.android.settings.deviceinfo.simstatus.SimStatusPreferenceControllerV2;
import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceController;
import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceController;
import com.android.settings.deviceinfo.simstatus.SimStatusPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -84,8 +74,8 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|| !arguments.containsKey(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)) {
// Increase the number of children when the device contains more than 1 sim.
final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
Context.TELEPHONY_SERVICE);
final TelephonyManager telephonyManager = (TelephonyManager) getContext()
.getSystemService(Context.TELEPHONY_SERVICE);
final int numberOfChildren = Math.max(SIM_PREFERENCES_COUNT,
SIM_PREFERENCES_COUNT * telephonyManager.getPhoneCount())
+ NON_SIM_PREFERENCES_COUNT;
@@ -110,7 +100,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
@Override
protected int getPreferenceScreenResId() {
return R.xml.device_info_settings_v2;
return R.xml.device_info_settings;
}
@Override
@@ -148,10 +138,10 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
Activity activity, Fragment fragment, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new PhoneNumberPreferenceController(context));
controllers.add(new SimStatusPreferenceControllerV2(context, fragment));
controllers.add(new SimStatusPreferenceController(context, fragment));
controllers.add(new DeviceModelPreferenceController(context, fragment));
controllers.add(new ImeiInfoPreferenceControllerV2(context, fragment));
controllers.add(new FirmwareVersionPreferenceControllerV2(context, fragment));
controllers.add(new ImeiInfoPreferenceController(context, fragment));
controllers.add(new FirmwareVersionPreferenceController(context, fragment));
controllers.add(new ImsStatusPreferenceController(context, lifecycle));
controllers.add(new IpAddressPreferenceController(context, lifecycle));
controllers.add(new WifiMacAddressPreferenceController(context, lifecycle));
@@ -176,7 +166,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.device_info_settings_v2;
sir.xmlResId = R.xml.device_info_settings;
return Arrays.asList(sir);
}

View File

@@ -26,20 +26,19 @@ import android.text.TextUtils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
public class FirmwareVersionPreferenceControllerV2 extends AbstractPreferenceController implements
public class FirmwareVersionPreferenceController extends AbstractPreferenceController implements
PreferenceControllerMixin {
private final static String FIRMWARE_VERSION_KEY = "firmware_version";
private final Fragment mFragment;
public FirmwareVersionPreferenceControllerV2(Context context, Fragment fragment) {
public FirmwareVersionPreferenceController(Context context, Fragment fragment) {
super(context);
mFragment = fragment;
}
@Override
public boolean isAvailable() {
return true;

View File

@@ -35,7 +35,7 @@ import java.util.List;
/**
* Controller that manages preference for single and multi sim devices.
*/
public class ImeiInfoPreferenceControllerV2 extends
public class ImeiInfoPreferenceController extends
AbstractSimStatusImeiInfoPreferenceController implements PreferenceControllerMixin {
private static final String KEY_IMEI_INFO = "imei_info";
@@ -45,7 +45,7 @@ public class ImeiInfoPreferenceControllerV2 extends
private final List<Preference> mPreferenceList = new ArrayList<>();
private final Fragment mFragment;
public ImeiInfoPreferenceControllerV2(Context context, Fragment fragment) {
public ImeiInfoPreferenceController(Context context, Fragment fragment) {
super(context);
mFragment = fragment;

View File

@@ -32,7 +32,7 @@ import com.android.settingslib.deviceinfo.AbstractSimStatusImeiInfoPreferenceCon
import java.util.ArrayList;
import java.util.List;
public class SimStatusPreferenceControllerV2 extends
public class SimStatusPreferenceController extends
AbstractSimStatusImeiInfoPreferenceController implements PreferenceControllerMixin {
private static final String KEY_SIM_STATUS = "sim_status";
@@ -42,7 +42,7 @@ public class SimStatusPreferenceControllerV2 extends
private final Fragment mFragment;
private final List<Preference> mPreferenceList = new ArrayList<>();
public SimStatusPreferenceControllerV2(Context context, Fragment fragment) {
public SimStatusPreferenceController(Context context, Fragment fragment) {
super(context);
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

View File

@@ -20,6 +20,8 @@ import android.content.Context;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settingslib.utils.AsyncLoader;
import com.android.internal.annotations.VisibleForTesting;
/**
* Loader that can be used by classes to load BatteryInfo in a background thread. This loader will
* automatically grab enhanced battery estimates if available or fall back to the system estimate
@@ -30,9 +32,13 @@ public class BatteryInfoLoader extends AsyncLoader<BatteryInfo>{
BatteryStatsHelper mStatsHelper;
private static final String LOG_TAG = "BatteryInfoLoader";
@VisibleForTesting
BatteryUtils batteryUtils;
public BatteryInfoLoader(Context context, BatteryStatsHelper batteryStatsHelper) {
super(context);
mStatsHelper = batteryStatsHelper;
batteryUtils = BatteryUtils.getInstance(context);
}
@Override
@@ -42,7 +48,6 @@ public class BatteryInfoLoader extends AsyncLoader<BatteryInfo>{
@Override
public BatteryInfo loadInBackground() {
final BatteryUtils batteryUtils = BatteryUtils.getInstance(getContext());
return batteryUtils.getBatteryInfo(mStatsHelper, LOG_TAG);
}
}

View File

@@ -87,6 +87,8 @@ public class BatterySaverSettings extends SettingsPreferenceFragment
.setTitle(com.android.internal.R.string.battery_saver_description);
mContext = getActivity();
mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
mSwitchBar.setSwitchBarText(R.string.battery_saver_master_switch_title,
R.string.battery_saver_master_switch_title);
mSwitch = mSwitchBar.getSwitch();
mSwitchBar.show();

View File

@@ -109,4 +109,13 @@ public interface PowerUsageFeatureProvider {
* Checks whether to display the battery v2.
*/
boolean isBatteryV2Enabled();
/**
* Returns a signal to indicate if the device will need to warn the user they may not make it
* to their next charging time.
*
* @param id Optional string used to identify the caller for metrics. Usually the class name of
* the caller
*/
boolean getEarlyWarningSignal(Context context, String id);
}

View File

@@ -21,7 +21,6 @@ import static com.android.settings.core.FeatureFlags.BATTERY_SETTINGS_V2;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Process;
import android.util.FeatureFlagUtils;
import android.util.SparseIntArray;
@@ -132,4 +131,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
public boolean isBatteryV2Enabled() {
return FeatureFlagUtils.isEnabled(mContext, BATTERY_SETTINGS_V2);
}
@Override
public boolean getEarlyWarningSignal(Context context, String id) {
return false;
}
}

View File

@@ -266,7 +266,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
KEY_APP_LIST, lifecycle, activity, this);
controllers.add(mBatteryAppListPreferenceController);
mBatteryTipPreferenceController = new BatteryTipPreferenceController(context,
KEY_BATTERY_TIP, this, this);
KEY_BATTERY_TIP, (SettingsActivity) getActivity(), this, this);
controllers.add(mBatteryTipPreferenceController);
controllers.add(new BatterySaverController(context, getLifecycle()));
controllers.add(new BatteryPercentagePreferenceController(context));

View File

@@ -27,8 +27,10 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController.BatteryTipListener;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.HighUsageTip;
@@ -97,7 +99,11 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
if (lsn == null) {
return;
}
mBatteryTip.action();
final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(mBatteryTip,
(SettingsActivity) getActivity(), this);
if (action != null) {
action.handlePositiveAction();
}
lsn.onBatteryTipHandled(mBatteryTip);
}

View File

@@ -25,6 +25,7 @@ import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.detectors.BatteryTipDetector;
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
import com.android.settings.fuelgauge.batterytip.detectors.SmartBatteryDetector;
import com.android.settings.fuelgauge.batterytip.detectors.SummaryDetector;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
@@ -68,6 +69,8 @@ public class BatteryTipLoader extends AsyncLoader<List<BatteryTip>> {
addBatteryTipFromDetector(tips, new LowBatteryDetector(policy, batteryInfo));
addBatteryTipFromDetector(tips,
new HighUsageDetector(getContext(), policy, mBatteryStatsHelper));
addBatteryTipFromDetector(tips,
new SmartBatteryDetector(policy, getContext().getContentResolver()));
// Add summary detector at last since it need other detectors to update the mVisibleTips
addBatteryTipFromDetector(tips, new SummaryDetector(policy, mVisibleTips));

View File

@@ -23,7 +23,9 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
@@ -41,6 +43,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
private BatteryTipListener mBatteryTipListener;
private List<BatteryTip> mBatteryTips;
private Map<String, BatteryTip> mBatteryTipMap;
private SettingsActivity mSettingsActivity;
@VisibleForTesting
PreferenceGroup mPreferenceGroup;
@VisibleForTesting
@@ -48,15 +51,17 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
PreferenceFragment mFragment;
public BatteryTipPreferenceController(Context context, String preferenceKey) {
this(context, preferenceKey, null, null);
this(context, preferenceKey, null, null, null);
}
public BatteryTipPreferenceController(Context context, String preferenceKey,
PreferenceFragment fragment, BatteryTipListener batteryTipListener) {
SettingsActivity settingsActivity, PreferenceFragment fragment,
BatteryTipListener batteryTipListener) {
super(context, preferenceKey);
mBatteryTipListener = batteryTipListener;
mBatteryTipMap = new HashMap<>();
mFragment = fragment;
mSettingsActivity = settingsActivity;
}
@Override
@@ -107,7 +112,11 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
dialogFragment.show(mFragment.getFragmentManager(), TAG);
} else {
batteryTip.action();
final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(batteryTip,
mSettingsActivity, mFragment);
if (action != null) {
action.handlePositiveAction();
}
if (mBatteryTipListener != null) {
mBatteryTipListener.onBatteryTipHandled(batteryTip);
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterytip;
import android.app.Fragment;
import com.android.settings.SettingsActivity;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.actions.SmartBatteryAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
/**
* Utility class for {@link BatteryTip}
*/
public class BatteryTipUtils {
/**
* Get a corresponding action based on {@code batteryTip}
* @param batteryTip used to detect which action to choose
* @param settingsActivity used to populate {@link BatteryTipAction}
* @param fragment used to populate {@link BatteryTipAction}
* @return an action for {@code batteryTip}
*/
public static BatteryTipAction getActionForBatteryTip(BatteryTip batteryTip,
SettingsActivity settingsActivity, Fragment fragment) {
switch (batteryTip.getType()) {
case BatteryTip.TipType.SMART_BATTERY_MANAGER:
return new SmartBatteryAction(settingsActivity, fragment);
default:
return null;
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterytip.actions;
import android.content.Context;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
/**
* Abstract class for battery tip action, which is triggered if we need to handle the battery tip
*/
public abstract class BatteryTipAction {
protected Context mContext;
public BatteryTipAction(Context context) {
mContext = context;
}
/**
* Handle the action when user clicks positive button
*/
public abstract void handlePositiveAction();
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterytip.actions;
import android.app.Fragment;
import android.os.UserHandle;
import android.support.v14.preference.PreferenceFragment;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.fuelgauge.SmartBatterySettings;
public class SmartBatteryAction extends BatteryTipAction {
private SettingsActivity mSettingsActivity;
private Fragment mFragment;
public SmartBatteryAction(SettingsActivity settingsActivity, Fragment fragment) {
super(settingsActivity.getApplicationContext());
mSettingsActivity = settingsActivity;
mFragment = fragment;
}
/**
* Handle the action when user clicks positive button
*/
@Override
public void handlePositiveAction() {
mSettingsActivity.startPreferencePanelAsUser(mFragment,
SmartBatterySettings.class.getName(), null /* args */,
R.string.smart_battery_manager_title, null /* titleText */,
new UserHandle(UserHandle.myUserId()));
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterytip.detectors;
import android.content.ContentResolver;
import android.provider.Settings;
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SmartBatteryTip;
/**
* Detect whether to show smart battery tip.
*/
public class SmartBatteryDetector implements BatteryTipDetector {
private BatteryTipPolicy mPolicy;
private ContentResolver mContentResolver;
public SmartBatteryDetector(BatteryTipPolicy policy, ContentResolver contentResolver) {
mPolicy = policy;
mContentResolver = contentResolver;
}
@Override
public BatteryTip detect() {
// Show it if there is no other tips shown
final boolean smartBatteryOn = Settings.Global.getInt(mContentResolver,
Settings.Global.APP_STANDBY_ENABLED, 1) != 0;
final int state =
smartBatteryOn ? BatteryTip.StateType.INVISIBLE : BatteryTip.StateType.NEW;
return new SmartBatteryTip(state);
}
}

View File

@@ -105,11 +105,6 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
*/
public abstract void updateState(BatteryTip tip);
/**
* Execute the action for this {@link BatteryTip}
*/
public abstract void action();
public Preference buildPreference(Context context) {
Preference preference = new Preference(context);

View File

@@ -78,11 +78,6 @@ public class HighUsageTip extends BatteryTip {
mState = tip.mState;
}
@Override
public void action() {
// do nothing
}
public long getScreenTimeMs() {
return mScreenTimeMs;
}

View File

@@ -55,11 +55,6 @@ public class LowBatteryTip extends BatteryTip {
mState = tip.mState;
}
@Override
public void action() {
// do nothing
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public BatteryTip createFromParcel(Parcel in) {
return new LowBatteryTip(in);

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterytip.tips;
import android.content.Context;
import android.os.Parcel;
import android.provider.Settings;
import com.android.settings.R;
/**
* Tip to suggest turn on smart battery if it is not on
*/
public class SmartBatteryTip extends BatteryTip {
public SmartBatteryTip(@StateType int state) {
super(TipType.SMART_BATTERY_MANAGER, state, false /* showDialog */);
}
private SmartBatteryTip(Parcel in) {
super(in);
}
@Override
public CharSequence getTitle(Context context) {
return context.getString(R.string.battery_tip_smart_battery_title);
}
@Override
public CharSequence getSummary(Context context) {
return context.getString(R.string.battery_tip_smart_battery_summary);
}
@Override
public int getIconId() {
return R.drawable.ic_perm_device_information_red_24dp;
}
@Override
public void updateState(BatteryTip tip) {
mState = tip.mState;
}
public static final Creator CREATOR = new Creator() {
public BatteryTip createFromParcel(Parcel in) {
return new SmartBatteryTip(in);
}
public BatteryTip[] newArray(int size) {
return new SmartBatteryTip[size];
}
};
}

View File

@@ -55,11 +55,6 @@ public class SummaryTip extends BatteryTip {
mState = tip.mState;
}
@Override
public void action() {
// do nothing
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public BatteryTip createFromParcel(Parcel in) {
return new SummaryTip(in);

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.location;
import android.content.Context;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.R;
import android.support.annotation.VisibleForTesting;
public class LocationScanningPreferenceController extends BasePreferenceController {
@VisibleForTesting static final String KEY_LOCATION_SCANNING = "location_scanning";
public LocationScanningPreferenceController(Context context) {
super(context, KEY_LOCATION_SCANNING);
}
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_location_scanning)
? AVAILABLE
: DISABLED_UNSUPPORTED;
}
}

View File

@@ -31,6 +31,7 @@ import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.location.RecentLocationApps;
@@ -91,8 +92,10 @@ public class LocationSettings extends DashboardFragment {
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBarController = new LocationSwitchBarController(
activity, activity.getSwitchBar(), getLifecycle());
final SwitchBar switchBar = activity.getSwitchBar();
switchBar.setSwitchBarText(R.string.location_settings_master_switch_title,
R.string.location_settings_master_switch_title);
mSwitchBarController = new LocationSwitchBarController(activity, switchBar, getLifecycle());
}
@Override
@@ -138,6 +141,7 @@ public class LocationSettings extends DashboardFragment {
new RecentLocationRequestPreferenceController(context, fragment, lifecycle));
controllers.add(
new LocationServicePreferenceController(context, fragment, lifecycle));
controllers.add(new LocationScanningPreferenceController(context));
return controllers;
}

View File

@@ -21,6 +21,7 @@ import android.media.AudioManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.notification.VolumeSeekBarPreference.Callback;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class AlarmVolumePreferenceController extends
@@ -43,7 +44,8 @@ public class AlarmVolumePreferenceController extends
@Override
public boolean isAvailable() {
return !mHelper.isSingleVolume();
return mContext.getResources().getBoolean(R.bool.config_show_alarm_volume)
&& !mHelper.isSingleVolume();
}
@Override

View File

@@ -21,6 +21,7 @@ import static com.android.settings.notification.SettingPref.TYPE_GLOBAL;
import android.content.Context;
import android.provider.Settings.Global;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -33,7 +34,10 @@ public class ChargingSoundPreferenceController extends SettingPrefController {
super(context, parent, lifecycle);
mPreference = new SettingPref(
TYPE_GLOBAL, KEY_CHARGING_SOUNDS, Global.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
}
@Override
public boolean isAvailable() {
return mContext.getResources().getBoolean(R.bool.config_show_charging_sounds);
}
}

View File

@@ -19,6 +19,7 @@ package com.android.settings.notification;
import android.content.Context;
import android.media.AudioManager;
import com.android.settings.notification.VolumeSeekBarPreference.Callback;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class MediaVolumePreferenceController extends
@@ -32,7 +33,7 @@ public class MediaVolumePreferenceController extends
@Override
public boolean isAvailable() {
return true;
return mContext.getResources().getBoolean(R.bool.config_show_media_volume);
}
@Override

View File

@@ -19,6 +19,8 @@ package com.android.settings.notification;
import android.content.Context;
import android.media.RingtoneManager;
import com.android.settings.R;
public class NotificationRingtonePreferenceController extends RingtonePreferenceControllerBase {
private static final String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
@@ -27,6 +29,11 @@ public class NotificationRingtonePreferenceController extends RingtonePreference
super(context);
}
@Override
public boolean isAvailable() {
return mContext.getResources().getBoolean(R.bool.config_show_notification_ringtone);
}
@Override
public String getPreferenceKey() {
return KEY_NOTIFICATION_RINGTONE;

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.media.AudioManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.notification.VolumeSeekBarPreference.Callback;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -45,7 +46,8 @@ public class NotificationVolumePreferenceController extends
@Override
public boolean isAvailable() {
return !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume();
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
&& !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume();
}
@Override

View File

@@ -21,6 +21,7 @@ import static com.android.settings.notification.SettingPref.TYPE_SYSTEM;
import android.content.Context;
import android.provider.Settings.System;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -35,4 +36,8 @@ public class ScreenLockSoundPreferenceController extends SettingPrefController {
TYPE_SYSTEM, KEY_SCREEN_LOCKING_SOUNDS, System.LOCKSCREEN_SOUNDS_ENABLED, DEFAULT_ON);
}
@Override
public boolean isAvailable() {
return mContext.getResources().getBoolean(R.bool.config_show_screen_locking_sounds);
}
}

View File

@@ -33,6 +33,7 @@ import com.android.settings.R;
import com.android.settings.RingtonePreference;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -201,15 +202,45 @@ public class SoundSettings extends DashboardFragment {
controllers.add(new WorkSoundPreferenceController(context, fragment, lifecycle));
// === Other Sound Settings ===
controllers.add(new DialPadTonePreferenceController(context, fragment, lifecycle));
controllers.add(new ScreenLockSoundPreferenceController(context, fragment, lifecycle));
controllers.add(new ChargingSoundPreferenceController(context, fragment, lifecycle));
controllers.add(new DockingSoundPreferenceController(context, fragment, lifecycle));
controllers.add(new TouchSoundPreferenceController(context, fragment, lifecycle));
controllers.add(new VibrateOnTouchPreferenceController(context, fragment, lifecycle));
controllers.add(new DockAudioMediaPreferenceController(context, fragment, lifecycle));
controllers.add(new BootSoundPreferenceController(context));
controllers.add(new EmergencyTonePreferenceController(context, fragment, lifecycle));
final DialPadTonePreferenceController dialPadTonePreferenceController =
new DialPadTonePreferenceController(context, fragment, lifecycle);
final ScreenLockSoundPreferenceController screenLockSoundPreferenceController =
new ScreenLockSoundPreferenceController(context, fragment, lifecycle);
final ChargingSoundPreferenceController chargingSoundPreferenceController =
new ChargingSoundPreferenceController(context, fragment, lifecycle);
final DockingSoundPreferenceController dockingSoundPreferenceController =
new DockingSoundPreferenceController(context, fragment, lifecycle);
final TouchSoundPreferenceController touchSoundPreferenceController =
new TouchSoundPreferenceController(context, fragment, lifecycle);
final VibrateOnTouchPreferenceController vibrateOnTouchPreferenceController =
new VibrateOnTouchPreferenceController(context, fragment, lifecycle);
final DockAudioMediaPreferenceController dockAudioMediaPreferenceController =
new DockAudioMediaPreferenceController(context, fragment, lifecycle);
final BootSoundPreferenceController bootSoundPreferenceController =
new BootSoundPreferenceController(context);
final EmergencyTonePreferenceController emergencyTonePreferenceController =
new EmergencyTonePreferenceController(context, fragment, lifecycle);
controllers.add(dialPadTonePreferenceController);
controllers.add(screenLockSoundPreferenceController);
controllers.add(chargingSoundPreferenceController);
controllers.add(dockingSoundPreferenceController);
controllers.add(touchSoundPreferenceController);
controllers.add(vibrateOnTouchPreferenceController);
controllers.add(dockAudioMediaPreferenceController);
controllers.add(bootSoundPreferenceController);
controllers.add(emergencyTonePreferenceController);
controllers.add(new PreferenceCategoryController(context,
"other_sounds_and_vibrations_category",
Arrays.asList(dialPadTonePreferenceController,
screenLockSoundPreferenceController,
chargingSoundPreferenceController,
dockingSoundPreferenceController,
touchSoundPreferenceController,
vibrateOnTouchPreferenceController,
dockAudioMediaPreferenceController,
bootSoundPreferenceController,
emergencyTonePreferenceController)));
return controllers;
}

View File

@@ -23,6 +23,7 @@ import android.content.Context;
import android.media.AudioManager;
import android.os.AsyncTask;
import android.provider.Settings.System;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -53,4 +54,9 @@ public class TouchSoundPreferenceController extends SettingPrefController {
}
};
}
@Override
public boolean isAvailable() {
return mContext.getResources().getBoolean(R.bool.config_show_touch_sounds);
}
}

View File

@@ -103,11 +103,18 @@ public class ZenModeBackend {
}
protected int getPriorityCallSenders() {
return mPolicy.priorityCallSenders;
if (isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS)) {
return mPolicy.priorityCallSenders;
}
return SOURCE_NONE;
}
protected int getPriorityMessageSenders() {
return mPolicy.priorityMessageSenders;
if (isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)) {
return mPolicy.priorityMessageSenders;
}
return SOURCE_NONE;
}
protected void saveVisualEffectsPolicy(int category, boolean canBypass) {

View File

@@ -19,16 +19,27 @@ package com.android.settings.notification;
import android.app.NotificationManager;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class ZenModeCallsPreferenceController extends AbstractZenModePreferenceController {
public class ZenModeCallsPreferenceController extends AbstractZenModePreferenceController implements
Preference.OnPreferenceChangeListener {
protected static final String KEY = "zen_mode_calls";
private final ZenModeBackend mBackend;
private ListPreference mPreference;
private final String[] mListValues;
public ZenModeCallsPreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY, lifecycle);
mBackend = ZenModeBackend.getInstance(context);
mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
}
@Override
@@ -41,21 +52,55 @@ public class ZenModeCallsPreferenceController extends AbstractZenModePreferenceC
return true;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(KEY);
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
updateFromContactsValue(preference);
}
@Override
public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS,
ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
updateFromContactsValue(preference);
return true;
}
private void updateFromContactsValue(Preference preference) {
mPreference = (ListPreference) preference;
switch (getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
preference.setSummary(mBackend.getContactsSummary(mBackend.SOURCE_NONE));
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
break;
default:
preference.setEnabled(true);
preference.setSummary(mBackend.getContactsSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
final String currentVal = ZenModeBackend.getKeyFromSetting(
mBackend.getPriorityCallSenders());
mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
}
}
@VisibleForTesting
protected int getIndexOfSendersValue(String currentVal) {
int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
for (int i = 0; i < mListValues.length; i++) {
if (TextUtils.equals(currentVal, mListValues[i])) {
return i;
}
}
return index;
}
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.notification;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.widget.RadioButtonPickerFragment;
import java.util.ArrayList;
import java.util.List;
public class ZenModeCallsSettings extends RadioButtonPickerFragment {
private ZenModeBackend mBackend;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mBackend = ZenModeBackend.getInstance(context);
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.NOTIFICATION_ZEN_MODE_CALLS;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.zen_mode_calls_settings;
}
@Override
protected List<? extends RadioButtonPickerFragment.CandidateInfo> getCandidates() {
final String[] entries = entries();
final String[] values = keys();
final List<CallsCandidateInfo> candidates = new ArrayList<>();
if (entries == null || entries.length <= 0) return null;
if (values == null || values.length != entries.length) {
throw new IllegalArgumentException("Entries and values must be of the same length.");
}
for (int i = 0; i < entries.length; i++) {
candidates.add(new CallsCandidateInfo(entries[i], values[i]));
}
return candidates;
}
private String[] entries() {
return getResources().getStringArray(R.array.zen_mode_contacts_entries);
}
private String[] keys() {
return getResources().getStringArray(R.array.zen_mode_contacts_values);
}
@Override
protected String getDefaultKey() {
return mBackend.getSendersKey(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS);
}
@Override
protected boolean setDefaultKey(String key) {
mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS,
mBackend.getSettingFromPrefKey(key));
return true;
}
private static final class CallsCandidateInfo extends RadioButtonPickerFragment.CandidateInfo {
private final String name;
private final String key;
CallsCandidateInfo(String title, String value) {
super(true);
name = title;
key = value;
}
@Override
public CharSequence loadLabel() {
return name;
}
@Override
public Drawable loadIcon() {
return null;
}
@Override
public String getKey() {
return key;
}
}
}

View File

@@ -3,16 +3,28 @@ package com.android.settings.notification;
import android.app.NotificationManager;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class ZenModeMessagesPreferenceController extends AbstractZenModePreferenceController {
public class ZenModeMessagesPreferenceController extends AbstractZenModePreferenceController
implements Preference.OnPreferenceChangeListener {
protected static final String KEY = "zen_mode_messages";
private final ZenModeBackend mBackend;
private ListPreference mPreference;
private final String[] mListValues;
public ZenModeMessagesPreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY, lifecycle);
mBackend = ZenModeBackend.getInstance(context);
mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
}
@Override
@@ -25,20 +37,55 @@ public class ZenModeMessagesPreferenceController extends AbstractZenModePreferen
return true;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(KEY);
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
updateFromContactsValue(preference);
}
@Override
public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES,
ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
updateFromContactsValue(preference);
return true;
}
private void updateFromContactsValue(Preference preference) {
mPreference = (ListPreference) preference;
switch (getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
preference.setSummary(mBackend.getContactsSummary(mBackend.SOURCE_NONE));
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
break;
default:
preference.setEnabled(true);
preference.setSummary(mBackend.getContactsSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
final String currentVal = ZenModeBackend.getKeyFromSetting(
mBackend.getPriorityMessageSenders());
mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
}
}
@VisibleForTesting
protected int getIndexOfSendersValue(String currentVal) {
int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
for (int i = 0; i < mListValues.length; i++) {
if (TextUtils.equals(currentVal, mListValues[i])) {
return i;
}
}
return index;
}
}

View File

@@ -1,112 +0,0 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.notification;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.widget.RadioButtonPickerFragment;
import java.util.ArrayList;
import java.util.List;
public class ZenModeMessagesSettings extends RadioButtonPickerFragment {
private ZenModeBackend mBackend;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mBackend = ZenModeBackend.getInstance(context);
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.NOTIFICATION_ZEN_MODE_MESSAGES;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.zen_mode_messages_settings;
}
@Override
protected List<? extends RadioButtonPickerFragment.CandidateInfo> getCandidates() {
final String[] entries = entries();
final String[] values = keys();
final List<MessagesCandidateInfo> candidates = new ArrayList<>();
if (entries == null || entries.length <= 0) return null;
if (values == null || values.length != entries.length) {
throw new IllegalArgumentException("Entries and values must be of the same length.");
}
for (int i = 0; i < entries.length; i++) {
candidates.add(new MessagesCandidateInfo(entries[i], values[i]));
}
return candidates;
}
private String[] entries() {
return getResources().getStringArray(R.array.zen_mode_contacts_entries);
}
private String[] keys() {
return getResources().getStringArray(R.array.zen_mode_contacts_values);
}
@Override
protected String getDefaultKey() {
return mBackend.getSendersKey(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES);
}
@Override
protected boolean setDefaultKey(String key) {
mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES,
mBackend.getSettingFromPrefKey(key));
return true;
}
private final class MessagesCandidateInfo extends RadioButtonPickerFragment.CandidateInfo {
private final String name;
private final String key;
MessagesCandidateInfo(String title, String value) {
super(true);
name = title;
key = value;
}
@Override
public CharSequence loadLabel() {
return name;
}
@Override
public Drawable loadIcon() {
return null;
}
@Override
public String getKey() {
return key;
}
}
}

View File

@@ -19,7 +19,6 @@ package com.android.settings.search;
import android.support.annotation.VisibleForTesting;
import com.android.settings.DateTimeSettings;
import com.android.settings.DeviceInfoSettings;
import com.android.settings.DisplaySettings;
import com.android.settings.LegalSettings;
import com.android.settings.accessibility.AccessibilitySettings;
@@ -39,6 +38,7 @@ import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
import com.android.settings.datausage.DataUsageSummary;
import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
import com.android.settings.development.DevelopmentSettingsDashboardFragment;
import com.android.settings.deviceinfo.DeviceInfoSettings;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.StorageSettings;
import com.android.settings.display.AmbientDisplaySettings;

View File

@@ -19,7 +19,6 @@ package com.android.settings.security;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@@ -38,19 +37,16 @@ public class ScreenPinningPreferenceController extends BasePreferenceController
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final Preference preference = screen.findPreference(getPreferenceKey());
if (preference == null) {
return;
}
if (Settings.System.getInt(mContext.getContentResolver(),
Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) {
preference.setSummary(
mContext.getString(R.string.switch_on_text));
} else {
preference.setSummary(
mContext.getString(R.string.switch_off_text));
}
public String getSummary() {
return Settings.System.getInt(mContext.getContentResolver(),
Settings.System.LOCK_TO_APP_ENABLED, 0) != 0
? mContext.getString(R.string.switch_on_text)
: mContext.getString(R.string.switch_off_text);
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
preference.setSummary(getSummary());
}
}

View File

@@ -79,7 +79,7 @@ public class SettingsSliceProvider extends SliceProvider {
}
private Slice getHoldingSlice(Uri uri) {
return new ListBuilder(uri).build();
return new ListBuilder(getContext(), uri).build();
}
// TODO (b/70622039) remove this when the proper wifi slice is enabled.
@@ -106,7 +106,7 @@ public class SettingsSliceProvider extends SliceProvider {
}
boolean finalWifiEnabled = wifiEnabled;
return new ListBuilder(sliceUri)
return new ListBuilder(getContext(), sliceUri)
.setColor(R.color.material_blue_500)
.addRow(b -> b
.setTitle(getContext().getString(R.string.wifi_settings))

View File

@@ -59,7 +59,7 @@ public class SliceBuilderUtils {
? sliceData.getScreenTitle()
: summaryText;
RowBuilder builder = new RowBuilder(sliceData.getUri())
RowBuilder builder = new RowBuilder(context, sliceData.getUri())
.setTitle(sliceData.getTitle())
.setTitleItem(icon)
.setSubtitle(subtitleText)
@@ -75,7 +75,7 @@ public class SliceBuilderUtils {
sliceData.getKey());
}
return new ListBuilder(sliceData.getUri())
return new ListBuilder(context, sliceData.getUri())
.addRow(builder)
.build();
}
@@ -122,4 +122,4 @@ public class SliceBuilderUtils {
intent.setClassName("com.android.settings", SubSettings.class.getName());
return PendingIntent.getActivity(context, 0 /* requestCode */, intent, 0 /* flags */);
}
}
}

View File

@@ -136,7 +136,7 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
mContext.getSharedPreferences(SHARED_PREFS_TAG, Context.MODE_PRIVATE)
.edit()
.clear()
.commit();
.apply();
dropTables(db);
createDatabases(db);
}

View File

@@ -190,6 +190,9 @@ public class WifiSettings extends RestrictedSettingsFragment
.findViewById(R.id.progress_bar_animation);
setProgressBarVisible(false);
}
((SettingsActivity) activity).getSwitchBar().setSwitchBarText(
R.string.wifi_settings_master_switch_title,
R.string.wifi_settings_master_switch_title);
}
@Override

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wrapper;
import android.os.RemoteException;
import android.view.IWindowManager;
/**
* This class replicates a subset of the android.view.IWindowManager. The class
* exists so that we can use a thin wrapper around the IWindowManager in production code
* and a mock in tests.
*/
public class IWindowManagerWrapper {
private final IWindowManager mWindowManager;
public IWindowManagerWrapper(IWindowManager wm) {
mWindowManager = wm;
}
/**
* Returns true if window trace is enabled.
*/
public boolean isWindowTraceEnabled() throws RemoteException {
return mWindowManager.isWindowTraceEnabled();
}
/**
* Starts a window trace.
*/
public void startWindowTrace() throws RemoteException {
mWindowManager.startWindowTrace();
}
/**
* Stops a window trace.
*/
public void stopWindowTrace() throws RemoteException {
mWindowManager.stopWindowTrace();
}
}

View File

@@ -14,7 +14,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
LOCAL_JAVA_LIBRARIES := \
junit \
platform-robolectric-3.5.1-prebuilt \
platform-robolectric-3.6.1-prebuilt \
telephony-common
LOCAL_INSTRUMENTATION_FOR := Settings
@@ -42,4 +42,4 @@ LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src
LOCAL_ROBOTEST_TIMEOUT := 36000
include prebuilts/misc/common/robolectric/3.5.1/run_robotests.mk
include prebuilts/misc/common/robolectric/3.6.1/run_robotests.mk

2
tests/robotests/OWNERS Normal file
View File

@@ -0,0 +1,2 @@
# We do not guard tests - everyone is welcomed to contribute to tests.
per-file *.java=*

View File

@@ -22,11 +22,19 @@
<bool name="config_display_recent_apps">false</bool>
<bool name="config_show_wifi_settings">false</bool>
<bool name="config_show_high_power_apps">false</bool>
<bool name="config_show_alarm_volume">false</bool>
<bool name="config_show_charging_sounds">false</bool>
<bool name="config_show_media_volume">false</bool>
<bool name="config_show_notification_ringtone">false</bool>
<bool name="config_show_notification_volume">false</bool>
<bool name="config_show_screen_locking_sounds">false</bool>
<bool name="config_show_touch_sounds">false</bool>
<bool name="config_show_device_administrators">false</bool>
<bool name="config_show_premium_sms">false</bool>
<bool name="config_show_data_saver">false</bool>
<bool name="config_show_enabled_vr_listeners">false</bool>
<bool name="config_location_mode_available">false</bool>
<bool name="config_show_location_scanning">false</bool>
<bool name="config_show_wallpaper_attribution">false</bool>
<bool name="config_show_default_home">false</bool>
<bool name="config_show_accessibility_shortcut_preference">false</bool>
@@ -37,4 +45,6 @@
<bool name="config_show_tts_settings_summary">false</bool>
<bool name="config_show_pointer_speed">false</bool>
<bool name="config_show_vibrate_input_devices">false</bool>
<bool name="config_show_color_correction_preference">false</bool>
<bool name="config_show_color_inversion_preference">false</bool>
</resources>

View File

@@ -45,6 +45,8 @@ public class AccessibilitySettingsTest {
private Context mContext;
private AccessibilitySettings mFragment;
private boolean mAccessibilityShortcutPreferenceRemoved;
private boolean mColorInversionPreferenceRemoved;
private boolean mColorCorrectionPreferenceRemoved;
@Before
public void setUp() {
@@ -60,7 +62,16 @@ public class AccessibilitySettingsTest {
protected boolean removePreference(String key) {
if (AccessibilitySettings.ACCESSIBILITY_SHORTCUT_PREFERENCE.equals(key)) {
mAccessibilityShortcutPreferenceRemoved = true;
return true;
}
if (AccessibilitySettings.TOGGLE_INVERSION_PREFERENCE.equals(key)) {
mColorInversionPreferenceRemoved = true;
return true;
}
if (AccessibilitySettings.DISPLAY_DALTONIZER_PREFERENCE_SCREEN.equals(key)) {
mColorCorrectionPreferenceRemoved = true;
return true;
}
return false;
@@ -104,4 +115,38 @@ public class AccessibilitySettingsTest {
assertThat(niks).contains(AccessibilitySettings.ACCESSIBILITY_SHORTCUT_PREFERENCE);
}
@Test
public void testColorInversionPreference_byDefault_shouldBeShown() {
final Preference preference = new Preference(mContext);
mFragment.checkColorInversionVisibility(preference);
assertThat(mColorInversionPreferenceRemoved).isEqualTo(false);
}
@Test
@Config(qualifiers = "mcc999")
public void testColorInversionPreference_ifDisabled_shouldNotBeShown() {
final Preference preference = new Preference(mContext);
mFragment.checkColorInversionVisibility(preference);
assertThat(mColorInversionPreferenceRemoved).isEqualTo(true);
}
@Test
public void testColorCorrectionPreference_byDefault_shouldBeShown() {
final Preference preference = new Preference(mContext);
mFragment.checkColorCorrectionVisibility(preference);
assertThat(mColorCorrectionPreferenceRemoved).isEqualTo(false);
}
@Test
@Config(qualifiers = "mcc999")
public void testColorCorrectionPreference_ifDisabled_shouldNotBeShown() {
final Preference preference = new Preference(mContext);
mFragment.checkColorCorrectionVisibility(preference);
assertThat(mColorCorrectionPreferenceRemoved).isEqualTo(true);
}
}

View File

@@ -17,15 +17,14 @@
package com.android.settings.accounts;
import static android.arch.lifecycle.Lifecycle.Event.ON_RESUME;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
import android.accounts.Account;
import android.app.Activity;
import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.os.Bundle;
import android.os.UserHandle;
@@ -55,9 +54,9 @@ import org.robolectric.annotation.Implements;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class
manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class
)
public class AccountHeaderPreferenceControllerTest {
@@ -74,8 +73,8 @@ public class AccountHeaderPreferenceControllerTest {
private AccountHeaderPreferenceController mController;
private Lifecycle mLifecycle =
new Lifecycle(() -> AccountHeaderPreferenceControllerTest.this.mLifecycle);
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setUp() {
@@ -84,7 +83,8 @@ public class AccountHeaderPreferenceControllerTest {
mHeaderPreference = new LayoutPreference(
RuntimeEnvironment.application, R.layout.settings_entity_header);
doReturn(mContext).when(mActivity).getApplicationContext();
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
}
@Test

View File

@@ -26,6 +26,7 @@ import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
@@ -57,13 +58,15 @@ public class AssistContextPreferenceControllerTest {
private AssistContextPreferenceController.SettingObserver mObserver;
private Context mContext;
private AssistContextPreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mContext = RuntimeEnvironment.application;
mController = new AssistContextPreferenceController(mContext, mLifecycle);
ReflectionHelpers.setField(mController, "mSettingObserver", mObserver);

View File

@@ -28,6 +28,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -64,13 +65,15 @@ public class AssistFlashScreenPreferenceControllerTest {
private AssistFlashScreenPreferenceController.SettingObserver mObserver;
private Context mContext;
private AssistFlashScreenPreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mContext = RuntimeEnvironment.application;
mController = spy(new AssistFlashScreenPreferenceController(mContext, mLifecycle));
mLifecycle.addObserver(mController);

View File

@@ -196,11 +196,6 @@ public class ManageApplicationsTest {
.isFalse();
}
@Test
public void shouldUseStableItemHeight_notificationType_no() {
}
@Test
public void onRebuildComplete_shouldHideLoadingView() {
final Context context = RuntimeEnvironment.application;

View File

@@ -19,6 +19,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
@@ -44,6 +45,7 @@ import org.robolectric.annotation.Config;
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class BluetoothDetailsControllerTestBase {
protected Context mContext;
private LifecycleOwner mLifecycleOwner;
protected Lifecycle mLifecycle;
protected DeviceConfig mDeviceConfig;
protected BluetoothDevice mDevice;
@@ -73,7 +75,8 @@ public class BluetoothDetailsControllerTestBase {
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
mLifecycle = spy(new Lifecycle(() -> mLifecycle));
mLifecycleOwner = () -> mLifecycle;
mLifecycle = spy(new Lifecycle(mLifecycleOwner));
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothAdapter = mBluetoothManager.getAdapter();
}

View File

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

View File

@@ -22,6 +22,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
@@ -63,6 +64,7 @@ public class ConnectedDeviceGroupControllerTest {
private Context mContext;
private Preference mPreference;
private ConnectedDeviceGroupController mConnectedDeviceGroupController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
@@ -72,7 +74,8 @@ public class ConnectedDeviceGroupControllerTest {
mContext = RuntimeEnvironment.application;
mPreference = new Preference(mContext);
mPreference.setKey(PREFERENCE_KEY_1);
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mPreferenceGroup = spy(new PreferenceScreen(mContext, null));
doReturn(mPreferenceManager).when(mPreferenceGroup).getPreferenceManager();
doReturn(mContext).when(mDashboardFragment).getContext();

View File

@@ -24,6 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.LoaderManager;
import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import com.android.settings.TestConfig;
@@ -49,7 +50,9 @@ public class SuggestionControllerMixinTest {
@Mock
private SuggestionControllerMixin.SuggestionControllerHost mHost;
private Context mContext;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
private SuggestionControllerMixin mMixin;
@@ -58,7 +61,8 @@ public class SuggestionControllerMixinTest {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
FakeFeatureFactory.setupForTest();
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
}
@After

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import java.util.List;
import java.util.Locale;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DataLoaderTest {
@Test
public void testHasData() {
List<RegionInfo> regions = new DataLoader(Locale.US).loadRegionInfos();
// Sanity check. Real size is closer to 200.
assertNotNull(regions);
assertTrue(regions.size() > 100);
assertEquals("Afghanistan", regions.get(0).getName());
assertEquals("Zimbabwe", regions.get(regions.size() - 1).getName());
}
@Test
public void testRegionsWithTimeZone() {
List<RegionInfo> regions = new DataLoader(Locale.US).loadRegionInfos();
checkRegionHasTimeZone(regions, "AT", "Europe/Vienna");
checkRegionHasTimeZone(regions, "US", "America/Los_Angeles");
checkRegionHasTimeZone(regions, "CN", "Asia/Shanghai");
checkRegionHasTimeZone(regions, "AU", "Australia/Sydney");
}
@Test
public void testFixedOffsetTimeZones() {
List<TimeZoneInfo> timeZones = new DataLoader(Locale.US).loadFixedOffsets();
// Etc/GMT would be equivalent to Etc/UTC, except for how it is labelled. Users have
// explicitly asked for UTC to be supported, so make sure we label it as such.
checkHasTimeZone(timeZones, "Etc/UTC");
checkHasTimeZone(timeZones, "Etc/GMT-1");
checkHasTimeZone(timeZones, "Etc/GMT-14");
checkHasTimeZone(timeZones, "Etc/GMT+1");
checkHasTimeZone(timeZones, "Etc/GMT+12");
}
private void checkRegionHasTimeZone(List<RegionInfo> regions, String regionId, String tzId) {
RegionInfo ri = findRegion(regions, regionId);
assertTrue("Region " + regionId + " does not have time zone " + tzId,
ri.getTimeZoneIds().contains(tzId));
}
private void checkHasTimeZone(List<TimeZoneInfo> timeZoneInfos, String tzId) {
for (TimeZoneInfo tz : timeZoneInfos) {
if (tz.getId().equals(tzId)) {
return;
}
}
fail("Fixed offset time zones do not contain " + tzId);
}
private RegionInfo findRegion(List<RegionInfo> regions, String regionId) {
for (RegionInfo region : regions) {
if (region.getId().equals(regionId)) {
assertNotNull(region.getName());
return region;
}
}
fail("No region with id " + regionId + " found.");
return null; // can't reach.
}
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.datetime.timezone;
import android.icu.util.TimeZone;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.Collections;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class})
public class TimeZoneAdapterTest {
@Mock
private View.OnClickListener mOnClickListener;
private TimeZoneAdapter mTimeZoneAdapter;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mTimeZoneAdapter = new TimeZoneAdapter(mOnClickListener, RuntimeEnvironment.application);
}
@Test
public void getItemViewType_onDefaultTimeZone_returnsTypeSelected() {
final TimeZoneInfo tzi = dummyTimeZoneInfo(TimeZone.getDefault());
mTimeZoneAdapter.setTimeZoneInfos(Collections.singletonList(tzi));
assertThat(mTimeZoneAdapter.getItemViewType(0)).isEqualTo(TimeZoneAdapter.VIEW_TYPE_SELECTED);
}
@Test
public void getItemViewType_onNonDefaultTimeZone_returnsTypeNormal() {
final TimeZoneInfo tzi = dummyTimeZoneInfo(getNonDefaultTimeZone());
mTimeZoneAdapter.setTimeZoneInfos(Collections.singletonList(tzi));
assertThat(mTimeZoneAdapter.getItemViewType(0)).isEqualTo(TimeZoneAdapter.VIEW_TYPE_NORMAL);
}
@Test
public void bindViewHolder_onDstTimeZone_showsDstLabel() {
final TimeZoneInfo tzi = dummyTimeZoneInfo(TimeZone.getTimeZone("America/Los_Angeles"));
mTimeZoneAdapter.setTimeZoneInfos(Collections.singletonList(tzi));
final FrameLayout parent = new FrameLayout(RuntimeEnvironment.application);
final ViewHolder viewHolder = (ViewHolder) mTimeZoneAdapter.createViewHolder(parent, TimeZoneAdapter.VIEW_TYPE_NORMAL);
mTimeZoneAdapter.bindViewHolder(viewHolder, 0);
assertThat(viewHolder.mDstView.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void bindViewHolder_onNonDstTimeZone_hidesDstLabel() {
final TimeZoneInfo tzi = dummyTimeZoneInfo(TimeZone.getTimeZone("Etc/UTC"));
mTimeZoneAdapter.setTimeZoneInfos(Collections.singletonList(tzi));
final FrameLayout parent = new FrameLayout(RuntimeEnvironment.application);
final ViewHolder viewHolder = (ViewHolder) mTimeZoneAdapter.createViewHolder(parent, TimeZoneAdapter.VIEW_TYPE_NORMAL);
mTimeZoneAdapter.bindViewHolder(viewHolder, 0);
assertThat(viewHolder.mDstView.getVisibility()).isEqualTo(View.GONE);
}
// Pick an arbitrary time zone that's not the current default.
private static TimeZone getNonDefaultTimeZone() {
final String[] availableIDs = TimeZone.getAvailableIDs();
int index = 0;
if (TextUtils.equals(availableIDs[index], TimeZone.getDefault().getID())) {
index++;
}
return TimeZone.getTimeZone(availableIDs[index]);
}
private TimeZoneInfo dummyTimeZoneInfo(TimeZone timeZone) {
return new TimeZoneInfo.Builder(timeZone).setGmtOffset("GMT+0").setItemId(1).build();
}
}

View File

@@ -27,6 +27,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothCodecConfig;
import android.content.Context;
@@ -60,6 +61,7 @@ public class AbstractBluetoothA2dpPreferenceControllerTest {
@Mock
private BluetoothA2dpConfigStore mBluetoothA2dpConfigStore;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
private Context mContext;
private AbstractBluetoothA2dpPreferenceController mController;
@@ -68,7 +70,8 @@ public class AbstractBluetoothA2dpPreferenceControllerTest {
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new AbstractBluetoothA2dpPreferenceControllerImpl(mContext, mLifecycle,
mBluetoothA2dpConfigStore));
doReturn(mBluetoothCodecConfig).when(mController).getCodecConfig();

View File

@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothCodecConfig;
import android.content.Context;
import android.support.v7.preference.ListPreference;
@@ -61,13 +62,15 @@ public class BluetoothAudioBitsPerSamplePreferenceControllerTest {
private String[] mListValues;
private Context mContext;
private BluetoothAudioBitsPerSamplePreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new BluetoothAudioBitsPerSamplePreferenceController(mContext,
mLifecycle, mBluetoothA2dpConfigStore));
mListValues = mController.getListValues();

View File

@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothCodecConfig;
import android.content.Context;
import android.support.v7.preference.ListPreference;
@@ -60,13 +61,15 @@ public class BluetoothAudioChannelModePreferenceControllerTest {
private String[] mListValues;
private Context mContext;
private BluetoothAudioChannelModePreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new BluetoothAudioChannelModePreferenceController(mContext,
mLifecycle, mBluetoothA2dpConfigStore));
mListValues = mController.getListValues();

View File

@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothCodecConfig;
import android.content.Context;
import android.support.v7.preference.ListPreference;
@@ -65,13 +66,15 @@ public class BluetoothAudioCodecPreferenceControllerTest {
private String[] mListValues;
private Context mContext;
private BluetoothAudioCodecPreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new BluetoothAudioCodecPreferenceController(mContext, mLifecycle,
mBluetoothA2dpConfigStore));
mListValues = mController.getListValues();

View File

@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothCodecConfig;
import android.content.Context;
import android.support.v7.preference.ListPreference;
@@ -60,13 +61,15 @@ public class BluetoothAudioQualityPreferenceControllerTest {
private String[] mListValues;
private Context mContext;
private BluetoothAudioQualityPreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new BluetoothAudioQualityPreferenceController(mContext,
mLifecycle, mBluetoothA2dpConfigStore));
mListValues = mController.getListValues();

View File

@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.bluetooth.BluetoothCodecConfig;
import android.content.Context;
import android.support.v7.preference.ListPreference;
@@ -60,6 +61,7 @@ public class BluetoothAudioSampleRatePreferenceControllerTest {
* 4: 96.0 kHz
*/
private String[] mListValues;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
private Context mContext;
private BluetoothAudioSampleRatePreferenceController mController;
@@ -68,7 +70,8 @@ public class BluetoothAudioSampleRatePreferenceControllerTest {
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new BluetoothAudioSampleRatePreferenceController(mContext, mLifecycle,
mBluetoothA2dpConfigStore));
mListValues = mController.getListValues();

View File

@@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import android.arch.lifecycle.LifecycleOwner;
import android.content.Context;
import com.android.settings.TestConfig;
@@ -53,6 +54,7 @@ public class DevelopmentSwitchBarControllerTest {
@Mock
private DevelopmentSettingsDashboardFragment mSettings;
private Context mContext;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
private SwitchBar mSwitchBar;
private DevelopmentSwitchBarController mController;
@@ -61,7 +63,8 @@ public class DevelopmentSwitchBarControllerTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mSwitchBar = new SwitchBar(mContext);
when(mSettings.getContext()).thenReturn(mContext);
}

View File

@@ -37,6 +37,7 @@ import android.support.v7.preference.PreferenceScreen;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowParcel;
import org.junit.Before;
import org.junit.Test;

Some files were not shown because too many files have changed in this diff Show More