Merge "Move restriction check for dev settings into controller"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c526d6f..1740b2b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -109,7 +109,7 @@
<!-- Settings -->
<activity android:name="Settings"
- android:taskAffinity="com.android.settings"
+ android:taskAffinity="com.android.settings.root"
android:label="@string/settings_label_launcher"
android:launchMode="singleTask">
<intent-filter android:priority="1">
@@ -122,7 +122,7 @@
<!-- Alias for launcher activity only, as this belongs to each profile. -->
<activity-alias android:name="Settings"
- android:taskAffinity="com.android.settings"
+ android:taskAffinity="com.android.settings.root"
android:label="@string/settings_label_launcher"
android:launchMode="singleTask"
android:targetActivity="Settings">
@@ -143,8 +143,7 @@
<activity android:name=".SubSettings"
android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
- </activity>
+ android:parentActivityName="Settings" />
<activity android:name=".shortcut.CreateShortcut"
android:label="@string/settings_shortcut">
@@ -155,11 +154,12 @@
</activity>
<!-- Wireless Controls -->
- <activity android:name=".Settings$NetworkDashboardActivity"
- android:taskAffinity="com.android.settings"
+ <activity
+ android:name=".Settings$NetworkDashboardActivity"
android:label="@string/network_dashboard_title"
android:icon="@drawable/ic_homepage_network"
- android:parentActivityName="Settings">
+ android:parentActivityName="Settings"
+ android:taskAffinity="com.android.settings">
<intent-filter android:priority="1">
<action android:name="android.settings.WIRELESS_SETTINGS" />
<action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
@@ -181,15 +181,20 @@
android:value="true" />
</activity>
- <activity android:name=".Settings$ConnectedDeviceDashboardActivity"
- android:taskAffinity="com.android.settings"
+ <activity
+ android:name=".Settings$ConnectedDeviceDashboardActivity"
android:label="@string/connected_devices_dashboard_title"
android:icon="@drawable/ic_homepage_connected_device"
+ android:taskAffinity="com.android.settings"
android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.NFC_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.BLUETOOTH_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -206,12 +211,13 @@
android:value="true" />
</activity>
- <activity android:name=".Settings$ConnectedDeviceDashboardActivityOld"
- android:enabled="false"
- android:taskAffinity="com.android.settings"
- android:label="@string/connected_devices_dashboard_title"
- android:icon="@drawable/ic_homepage_connected_device"
- android:parentActivityName="Settings">
+ <activity
+ android:name=".Settings$ConnectedDeviceDashboardActivityOld"
+ android:enabled="false"
+ android:label="@string/connected_devices_dashboard_title"
+ android:icon="@drawable/ic_homepage_connected_device"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.NFC_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -253,13 +259,13 @@
</intent-filter>
</activity>
- <!-- Top-level settings -->
-
- <activity android:name="Settings$WifiSettingsActivity"
- android:taskAffinity=""
- android:label="@string/wifi_settings"
- android:icon="@drawable/ic_settings_wireless"
- android:configChanges="orientation|keyboardHidden|screenSize">
+ <activity
+ android:name="Settings$WifiSettingsActivity"
+ android:label="@string/wifi_settings"
+ android:icon="@drawable/ic_settings_wireless"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.WIFI_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -278,21 +284,10 @@
android:value="content://com.android.settings.slices/wifi" />
</activity>
- <!-- Keep compatibility with old shortcuts. -->
- <activity-alias android:name=".wifi.WifiSettings"
- android:taskAffinity="com.android.settings"
- android:label="@string/wifi_settings"
- android:icon="@drawable/ic_settings_wireless"
- android:targetActivity="Settings$WifiSettingsActivity"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:exported="true">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.wifi.WifiSettings" />
- </activity-alias>
-
- <activity android:name=".wifi.WifiPickerActivity"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
+ <activity
+ android:name=".wifi.WifiPickerActivity"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
<category android:name="android.intent.category.DEFAULT" />
@@ -305,12 +300,13 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ConfigureWifiSettingsActivity"
- android:taskAffinity="com.android.settings"
- android:label="@string/wifi_configure_settings_preference_title"
- android:icon="@drawable/ic_settings_wireless"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:parentActivityName="Settings$WifiSettingsActivity">
+ <activity
+ android:name="Settings$ConfigureWifiSettingsActivity"
+ android:label="@string/wifi_configure_settings_preference_title"
+ android:icon="@drawable/ic_settings_wireless"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.WIFI_IP_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -326,12 +322,13 @@
android:value="true" />
</activity>
- <activity android:name="Settings$SavedAccessPointsSettingsActivity"
- android:taskAffinity="com.android.settings"
- android:label="@string/wifi_saved_access_points_label"
- android:icon="@drawable/ic_settings_wireless"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:parentActivityName="Settings$WifiSettingsActivity">
+ <activity
+ android:name="Settings$SavedAccessPointsSettingsActivity"
+ android:label="@string/wifi_saved_access_points_label"
+ android:icon="@drawable/ic_settings_wireless"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.WIFI_SAVED_NETWORK_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -346,9 +343,7 @@
android:value="true" />
</activity>
- <activity android:name=".Settings$WifiInfoActivity"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$WifiSettingsActivity">
+ <activity android:name=".Settings$WifiInfoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -358,9 +353,7 @@
android:value="com.android.settings.wifi.WifiInfo" />
</activity>
- <activity android:name=".wifi.WifiConfigInfo"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$WifiSettingsActivity">
+ <activity android:name=".wifi.WifiConfigInfo">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -428,14 +421,13 @@
android:value="com.android.settings.ApnSettings" />
</activity>
- <activity android:name="Settings$BluetoothSettingsActivity"
- android:label="@string/bluetooth_settings_title"
- android:icon="@drawable/ic_settings_bluetooth"
- android:taskAffinity="">
- <intent-filter android:priority="1">
- <action android:name="android.settings.BLUETOOTH_SETTINGS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
+ <activity
+ android:name="Settings$BluetoothSettingsActivity"
+ android:label="@string/bluetooth_settings_title"
+ android:icon="@drawable/ic_settings_bluetooth"
+ android:enabled="false"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
@@ -446,10 +438,19 @@
android:value="com.android.settings.bluetooth.BluetoothSettings" />
</activity>
+ <!-- Keep compatibility with old shortcuts. -->
+ <activity-alias android:name=".bluetooth.BluetoothSettings"
+ android:label="@string/bluetooth_settings_title"
+ android:targetActivity="Settings$BluetoothSettingsActivity"
+ android:exported="true"
+ android:clearTaskOnLaunch="true">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.bluetooth.BluetoothSettings" />
+ </activity-alias>
+
<activity android:name="Settings$AssistGestureSettingsActivity"
android:label="@string/assist_gesture_title"
- android:icon="@drawable/ic_settings_gestures"
- android:taskAffinity="">
+ android:icon="@drawable/ic_settings_gestures">
<intent-filter>
<action android:name="android.settings.ASSIST_GESTURE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -458,16 +459,6 @@
android:value="com.android.settings.gestures.AssistGestureSettings" />
</activity>
- <!-- Keep compatibility with old shortcuts. -->
- <activity-alias android:name=".bluetooth.BluetoothSettings"
- android:label="@string/bluetooth_settings_title"
- android:targetActivity="Settings$BluetoothSettingsActivity"
- android:exported="true"
- android:clearTaskOnLaunch="true">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.bluetooth.BluetoothSettings" />
- </activity-alias>
-
<activity android:name=".bluetooth.DevicePickerActivity"
android:label="@string/device_picker"
android:clearTaskOnLaunch="true">
@@ -492,10 +483,12 @@
</intent-filter>
</activity>
- <activity android:name="Settings$TetherSettingsActivity"
- android:label="@string/tether_settings_title_all"
- android:icon="@drawable/ic_settings_wireless"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$TetherSettingsActivity"
+ android:label="@string/tether_settings_title_all"
+ android:icon="@drawable/ic_settings_wireless"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -517,8 +510,8 @@
</activity-alias>
<activity android:name="Settings$WifiP2pSettingsActivity"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$WifiSettingsActivity">
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -528,11 +521,12 @@
android:value="com.android.settings.wifi.p2p.WifiP2pSettings" />
</activity>
-
- <activity android:name="Settings$VpnSettingsActivity"
- android:label="@string/vpn_settings_title"
- android:icon="@drawable/ic_settings_wireless"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$VpnSettingsActivity"
+ android:label="@string/vpn_settings_title"
+ android:icon="@drawable/ic_settings_wireless"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.VPN_SETTINGS" />
<action android:name="android.net.vpn.SETTINGS" />
@@ -550,10 +544,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$DateTimeSettingsActivity"
- android:label="@string/date_and_time"
- android:icon="@drawable/ic_settings_date_time"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$DateTimeSettingsActivity"
+ android:label="@string/date_and_time"
+ android:icon="@drawable/ic_settings_date_time"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.DATE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -575,11 +571,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$LocalePickerActivity"
- android:label="@string/language_picker_title"
- android:icon="@drawable/ic_settings_language"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+ <activity
+ android:name="Settings$LocalePickerActivity"
+ android:label="@string/language_picker_title"
+ android:icon="@drawable/ic_settings_language"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
<intent-filter android:priority="1">
<action android:name="android.settings.LOCALE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -595,11 +592,12 @@
android:value="true" />
</activity>
- <activity android:name=".Settings$LanguageAndInputSettingsActivity"
+ <activity
+ android:name=".Settings$LanguageAndInputSettingsActivity"
android:label="@string/language_settings"
android:icon="@drawable/ic_settings_language"
android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$SystemDashboardActivity">
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
@@ -628,10 +626,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ManageAssistActivity"
- android:label="@string/assist_and_voice_input_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$ManageApplicationsActivity">
+ <activity
+ android:name="Settings$ManageAssistActivity"
+ android:label="@string/assist_and_voice_input_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.VOICE_INPUT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -680,10 +679,11 @@
android:value="com.android.settings.language.LanguageAndInputSettings" />
</activity-alias>
- <activity android:name="Settings$SpellCheckersSettingsActivity"
- android:label="@string/spellcheckers_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+ <activity
+ android:name="Settings$SpellCheckersSettingsActivity"
+ android:label="@string/spellcheckers_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
@@ -709,10 +709,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$UserDictionarySettingsActivity"
- android:label="@string/user_dict_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+ <activity
+ android:name="Settings$UserDictionarySettingsActivity"
+ android:label="@string/user_dict_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.USER_DICTIONARY_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -751,11 +752,13 @@
android:value="com.android.settings.UserDictionarySettings" />
</activity-alias>
- <activity android:name="Settings$ZenModeSettingsActivity"
- android:label="@string/zen_mode_settings_title"
- android:icon="@drawable/ic_settings_notifications"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenModeSettingsActivity"
+ android:label="@string/zen_mode_settings_title"
+ android:icon="@drawable/ic_settings_notifications"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ZEN_MODE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -771,11 +774,13 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ZenModeBehaviorSettingsActivity"
- android:label="@string/zen_mode_behavior_settings_title"
- android:icon="@drawable/ic_settings_notifications"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenModeBehaviorSettingsActivity"
+ android:label="@string/zen_mode_behavior_settings_title"
+ android:icon="@drawable/ic_settings_notifications"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -786,11 +791,13 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ZenModeAutomationSettingsActivity"
- android:label="@string/zen_mode_automation_settings_title"
- android:icon="@drawable/ic_settings_notifications"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenModeAutomationSettingsActivity"
+ android:label="@string/zen_mode_automation_settings_title"
+ android:icon="@drawable/ic_settings_notifications"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ZEN_MODE_AUTOMATION_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -807,8 +814,7 @@
<activity android:name="Settings$WallpaperSettingsActivity"
android:label="@string/wallpaper_settings_fragment_title"
- android:icon="@drawable/ic_wallpaper"
- android:taskAffinity="">
+ android:icon="@drawable/ic_wallpaper">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
</activity>
@@ -850,9 +856,11 @@
android:resource="@string/new_device_suggestion_summary" />
</activity>
- <activity android:name="Settings$ZenModeScheduleRuleSettingsActivity"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenModeScheduleRuleSettingsActivity"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -867,9 +875,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ZenModeEventRuleSettingsActivity"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenModeEventRuleSettingsActivity"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -884,9 +894,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ZenModeExternalRuleSettingsActivity"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenModeExternalRuleSettingsActivity"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -901,10 +913,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$DisplaySettingsActivity"
- android:label="@string/display_settings"
- android:icon="@drawable/ic_homepage_display"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$DisplaySettingsActivity"
+ android:label="@string/display_settings"
+ android:icon="@drawable/ic_homepage_display"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="com.android.settings.DISPLAY_SETTINGS" />
<action android:name="android.settings.DISPLAY_SETTINGS" />
@@ -938,11 +952,13 @@
android:value="com.android.settings.DisplaySettings" />
</activity-alias>
- <activity android:name="Settings$NightDisplaySettingsActivity"
- android:label="@string/night_display_title"
- android:enabled="@*android:bool/config_nightDisplayAvailable"
- android:icon="@drawable/ic_settings_night_display"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$NightDisplaySettingsActivity"
+ android:label="@string/night_display_title"
+ android:enabled="@*android:bool/config_nightDisplayAvailable"
+ android:icon="@drawable/ic_settings_night_display"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -958,9 +974,9 @@
android:value="true" />
</activity>
- <activity android:name="Settings$NightDisplaySuggestionActivity"
+ <activity
+ android:name="Settings$NightDisplaySuggestionActivity"
android:enabled="@*android:bool/config_nightDisplayAvailable"
- android:taskAffinity=""
android:icon="@drawable/ic_settings_night_display">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -978,11 +994,13 @@
android:value="com.android.settings.display.NightDisplaySettings" />
</activity>
- <activity android:name="Settings$DeviceInfoSettingsActivity"
- android:label="@string/device_info_settings"
- android:icon="@drawable/ic_settings_about"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
+ <activity
+ android:name="Settings$DeviceInfoSettingsActivity"
+ android:label="@string/device_info_settings"
+ android:icon="@drawable/ic_settings_about"
+ android:taskAffinity="com.android.settings"
+ android:enabled="false"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.DEVICE_INFO_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1005,7 +1023,6 @@
android:value="true" />
</activity>
-
<activity android:name=".Settings$MyDeviceInfoActivity"
android:label="@string/device_info_settings"
android:icon="@drawable/ic_settings_about"
@@ -1034,10 +1051,12 @@
android:value="true" />
</activity>
- <activity android:name="SettingsLicenseActivity"
- android:label="@string/settings_license_activity_title"
- android:theme="@android:style/Theme.DeviceDefault.Light.Panel"
- android:configChanges="orientation|screenSize">
+ <activity
+ android:name="SettingsLicenseActivity"
+ android:label="@string/settings_license_activity_title"
+ android:configChanges="orientation|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.LICENSE" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1046,9 +1065,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ManageApplicationsActivity"
- android:label="@string/applications_settings"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ManageApplicationsActivity"
+ android:label="@string/applications_settings"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.APPLICATION_SETTINGS" />
<action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
@@ -1067,10 +1088,20 @@
android:value="true" />
</activity>
- <activity android:name="Settings$ManageDomainUrlsActivity"
- android:taskAffinity="com.android.settings"
- android:label="@string/domain_urls_title"
- android:icon="@drawable/ic_settings_memory">
+ <!-- Keep compatibility with old shortcuts. -->
+ <activity-alias android:name=".applications.ManageApplications"
+ android:label="@string/applications_settings"
+ android:exported="true"
+ android:targetActivity="Settings$ManageApplicationsActivity">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.manageapplications.ManageApplications" />
+ </activity-alias>
+
+ <activity
+ android:name="Settings$ManageDomainUrlsActivity"
+ android:label="@string/domain_urls_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.settings.MANAGE_DOMAIN_URLS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1081,8 +1112,7 @@
<activity android:name="Settings$MemorySettingsActivity"
android:label="@string/memory_settings_title"
- android:icon="@drawable/ic_settings_memory"
- android:taskAffinity="">
+ android:icon="@drawable/ic_settings_memory">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.SHORTCUT" />
@@ -1102,9 +1132,11 @@
android:value="com.android.settings.applications.ProcessStatsUi" />
</activity>
- <activity android:name="Settings$HighPowerApplicationsActivity"
- android:label="@string/high_power_apps"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$HighPowerApplicationsActivity"
+ android:label="@string/high_power_apps"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1115,9 +1147,9 @@
android:value="true" />
</activity>
- <activity android:name=".datausage.AppDataUsageActivity"
- android:taskAffinity=""
- android:noHistory="true">
+ <activity
+ android:name=".datausage.AppDataUsageActivity"
+ android:noHistory="true">
<intent-filter android:priority="1">
<action android:name="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1125,10 +1157,10 @@
</intent-filter>
</activity>
- <activity android:name=".fuelgauge.RequestIgnoreBatteryOptimizations"
- android:label="@string/high_power_apps"
- android:taskAffinity=""
- android:theme="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert">
+ <activity
+ android:name=".fuelgauge.RequestIgnoreBatteryOptimizations"
+ android:label="@string/high_power_apps"
+ android:theme="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert">
<intent-filter android:priority="1">
<action android:name="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1136,15 +1168,6 @@
</intent-filter>
</activity>
- <!-- Keep compatibility with old shortcuts. -->
- <activity-alias android:name=".applications.ManageApplications"
- android:label="@string/applications_settings"
- android:exported="true"
- android:targetActivity="Settings$ManageApplicationsActivity">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.applications.manageapplications.ManageApplications" />
- </activity-alias>
-
<!-- Provide direct entry into manage apps showing running services.
This is for compatibility with old shortcuts. -->
<activity-alias android:name=".RunningServices"
@@ -1170,10 +1193,7 @@
InstalledAppDetails. -->
<activity android:name=".applications.InstalledAppDetailsTop"
android:label="@string/application_info_label"
- android:exported="true"
- android:taskAffinity=""
- android:parentActivityName="Settings$ManageApplicationsActivity">
- </activity>
+ android:exported="true" />
<!-- Keep compatibility with old shortcuts. -->
<activity-alias android:name=".applications.InstalledAppDetails"
@@ -1205,10 +1225,11 @@
</activity>
<!-- Provide direct entry into manage apps showing storage usage of apps. -->
- <activity android:name="Settings$StorageUseActivity"
- android:label="@string/storageuse_settings_title"
- android:taskAffinity=""
- android:parentActivityName="Settings">
+ <activity
+ android:name="Settings$StorageUseActivity"
+ android:label="@string/storageuse_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MANAGE_PACKAGE_STORAGE" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1225,9 +1246,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$NotificationStationActivity"
- android:label="@string/notification_log_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$NotificationStationActivity"
+ android:label="@string/notification_log_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1249,7 +1272,6 @@
<activity android:name="Settings$BackgroundCheckSummaryActivity"
android:label="@string/background_check_title"
- android:taskAffinity=""
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -1259,11 +1281,13 @@
android:value="com.android.settings.applications.BackgroundCheckSummary" />
</activity>
- <activity android:name="Settings$LocationSettingsActivity"
- android:label="@string/location_settings_title"
- android:icon="@drawable/ic_settings_location"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$LocationSettingsActivity"
+ android:label="@string/location_settings_title"
+ android:icon="@drawable/ic_settings_location"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1280,12 +1304,13 @@
android:value="true" />
</activity>
- <activity android:name=".Settings$SecurityDashboardActivity"
- android:label="@string/security_settings_title"
- android:icon="@drawable/ic_homepage_security"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:taskAffinity=""
- android:parentActivityName="Settings">
+ <activity
+ android:name=".Settings$SecurityDashboardActivity"
+ android:label="@string/security_settings_title"
+ android:icon="@drawable/ic_homepage_security"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.SECURITY_SETTINGS" />
<action android:name="android.credentials.UNLOCK" />
@@ -1322,10 +1347,12 @@
</intent-filter>
</activity>
- <activity android:name="Settings$TrustedCredentialsSettingsActivity"
- android:label="@string/trusted_credentials"
- android:icon="@drawable/ic_settings_security"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$TrustedCredentialsSettingsActivity"
+ android:label="@string/trusted_credentials"
+ android:icon="@drawable/ic_settings_security"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="com.android.settings.TRUSTED_CREDENTIALS" />
<action android:name="com.android.settings.TRUSTED_CREDENTIALS_USER" />
@@ -1356,8 +1383,7 @@
<activity android:name="SetFullBackupPassword"
android:label="@string/local_backup_password_title"
- android:exported="false">
- </activity>
+ android:exported="false" />
<activity android:name="CredentialStorage"
android:theme="@style/Transparent"
@@ -1371,10 +1397,11 @@
</intent-filter>
</activity>
- <activity android:name="Settings$DeviceAdminSettingsActivity"
- android:label="@string/device_admin_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName=".Settings$SecurityDashboardActivity">
+ <activity
+ android:name="Settings$DeviceAdminSettingsActivity"
+ android:label="@string/device_admin_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1402,10 +1429,20 @@
</intent-filter>
</activity>
- <activity android:name="Settings$UsageAccessSettingsActivity"
- android:label="@string/usage_access_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName=".Settings$SecurityDashboardActivity">
+ <activity-alias android:name="SetProfileOwner"
+ android:label="@string/profile_owner_add_title"
+ android:targetActivity="DeviceAdminAdd">
+ <intent-filter android:priority="1000">
+ <action android:name="android.app.action.SET_PROFILE_OWNER" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity-alias>
+
+ <activity
+ android:name="Settings$UsageAccessSettingsActivity"
+ android:label="@string/usage_access_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1418,15 +1455,6 @@
android:value="com.android.settings.applications.manageapplications.ManageApplications" />
</activity>
- <activity-alias android:name="SetProfileOwner"
- android:label="@string/profile_owner_add_title"
- android:targetActivity="DeviceAdminAdd">
- <intent-filter android:priority="1000">
- <action android:name="android.app.action.SET_PROFILE_OWNER" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity-alias>
-
<activity android:name="Settings$IccLockSettingsActivity"
android:label="@string/sim_lock_settings"
android:process="com.android.phone">
@@ -1439,11 +1467,13 @@
android:value="com.android.settings.IccLockSettings" />
</activity>
- <activity android:name="Settings$AccessibilitySettingsActivity"
- android:label="@string/accessibility_settings"
- android:icon="@drawable/ic_homepage_accessibility"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$AccessibilitySettingsActivity"
+ android:label="@string/accessibility_settings"
+ android:icon="@drawable/ic_homepage_accessibility"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ACCESSIBILITY_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1490,10 +1520,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$AccessibilityDaltonizerSettingsActivity"
- android:label="@string/accessibility_display_daltonizer_preference_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$AccessibilitySettingsActivity">
+ <activity
+ android:name="Settings$AccessibilityDaltonizerSettingsActivity"
+ android:label="@string/accessibility_display_daltonizer_preference_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1508,10 +1539,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$CaptioningSettingsActivity"
- android:label="@string/accessibility_captioning_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$AccessibilitySettingsActivity">
+ <activity
+ android:name="Settings$CaptioningSettingsActivity"
+ android:label="@string/accessibility_captioning_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.CAPTIONING_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1526,10 +1558,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$TextToSpeechSettingsActivity"
- android:label="@string/tts_settings"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+ <activity
+ android:name="Settings$TextToSpeechSettingsActivity"
+ android:label="@string/tts_settings"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="com.android.settings.TTS_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1540,10 +1573,11 @@
android:value="true" />
</activity>
- <activity android:name="Settings$EnterprisePrivacySettingsActivity"
- android:label="@string/enterprise_privacy_settings"
- android:taskAffinity="com.android.settings"
- android:parentActivityName=".Settings$SecurityDashboardActivity">
+ <activity
+ android:name="Settings$EnterprisePrivacySettingsActivity"
+ android:label="@string/enterprise_privacy_settings"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.settings.ENTERPRISE_PRIVACY_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1552,8 +1586,6 @@
android:value="com.android.settings.enterprise.EnterprisePrivacySettings" />
</activity>
- <!-- Second and third-level settings -->
-
<!-- Lock screen settings -->
<activity android:name=".password.ConfirmDeviceCredentialActivity"
android:exported="true"
@@ -1769,11 +1801,12 @@
<activity android:name=".EncryptionInterstitial"
android:theme="@style/GlifTheme.Light" />
- <activity android:name=".Settings$StorageDashboardActivity"
- android:label="@string/storage_settings"
- android:icon="@drawable/ic_homepage_storage"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
+ <activity
+ android:name=".Settings$StorageDashboardActivity"
+ android:label="@string/storage_settings"
+ android:icon="@drawable/ic_homepage_storage"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.INTERNAL_STORAGE_SETTINGS" />
<action android:name="android.settings.MEMORY_CARD_SETTINGS" />
@@ -1797,18 +1830,18 @@
android:value="true" />
</activity>
- <activity android:name="Settings$PrivateVolumeSettingsActivity"
- android:label="@string/storage_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$StorageDashboardActivity">
+ <activity
+ android:name="Settings$PrivateVolumeSettingsActivity"
+ android:label="@string/storage_settings_title">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.deviceinfo.PrivateVolumeSettings" />
+ android:value="com.android.settings.deviceinfo.PrivateVolumeSettings" />
</activity>
- <activity android:name="Settings$PublicVolumeSettingsActivity"
- android:label="@string/storage_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$StorageDashboardActivity">
+ <activity
+ android:name="Settings$PublicVolumeSettingsActivity"
+ android:label="@string/storage_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.provider.action.DOCUMENT_ROOT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1821,12 +1854,11 @@
android:value="com.android.settings.deviceinfo.PublicVolumeSettings" />
</activity>
- <activity android:name="Settings$PrivateVolumeForgetActivity"
- android:label="@string/storage_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$StorageDashboardActivity"
- android:exported="true"
- android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
+ <activity
+ android:name="Settings$PrivateVolumeForgetActivity"
+ android:label="@string/storage_settings_title"
+ android:exported="true"
+ android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.deviceinfo.PrivateVolumeForget" />
</activity>
@@ -1898,12 +1930,13 @@
android:value="com.android.settings.ApnEditor" />
</activity>
- <activity android:name="Settings$DevelopmentSettingsDashboardActivity"
- android:label="@string/development_settings_title"
- android:icon="@drawable/ic_settings_development"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings"
- android:enabled="false">
+ <activity
+ android:name="Settings$DevelopmentSettingsDashboardActivity"
+ android:label="@string/development_settings_title"
+ android:icon="@drawable/ic_settings_development"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings"
+ android:enabled="false">
<intent-filter android:priority="1">
<action android:name="android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
<action android:name="com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
@@ -1936,11 +1969,12 @@
</intent-filter>
</activity>
- <activity android:name="Settings$PrintSettingsActivity"
- android:label="@string/print_settings"
- android:icon="@drawable/ic_settings_print"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
+ <activity
+ android:name="Settings$PrintSettingsActivity"
+ android:label="@string/print_settings"
+ android:icon="@drawable/ic_settings_print"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ACTION_PRINT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1977,10 +2011,7 @@
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" />
<activity android:name="Settings$WebViewAppPickerActivity"
- android:label="@string/select_webview_provider_dialog_title">
- </activity>
-
- <!-- Bluetooth stuff -->
+ android:label="@string/select_webview_provider_dialog_title" />
<activity android:name=".bluetooth.BluetoothPairingDialog"
android:excludeFromRecents="true"
@@ -2085,10 +2116,11 @@
</activity>
<!-- NFC settings -->
- <activity android:name="Settings$AndroidBeamSettingsActivity"
- android:label="@string/android_beam_settings_title"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$ConnectedDeviceDashboardActivity">
+ <activity
+ android:name="Settings$AndroidBeamSettingsActivity"
+ android:label="@string/android_beam_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.NFCSHARING_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2103,10 +2135,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$WifiDisplaySettingsActivity"
- android:label="@string/wifi_display_settings_title"
- android:icon="@drawable/ic_cast_24dp"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$WifiDisplaySettingsActivity"
+ android:label="@string/wifi_display_settings_title"
+ android:icon="@drawable/ic_cast_24dp"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.CAST_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2124,17 +2158,9 @@
android:value="com.android.settings.wfd.WifiDisplaySettings" />
</activity>
- <activity android:name="Display" android:label="@string/display_label"
- android:configChanges="fontScale"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
- </intent-filter>
- </activity>
-
- <activity android:name="RadioInfo" android:label="@string/phone_info_label"
+ <activity
+ android:name="RadioInfo"
+ android:label="@string/phone_info_label"
android:process="com.android.phone">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -2190,7 +2216,8 @@
</intent-filter>
</activity>
- <activity android:name="UsageStatsActivity" android:label="@string/usage_stats_label"
+ <activity android:name="UsageStatsActivity"
+ android:label="@string/usage_stats_label"
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings">
<intent-filter>
@@ -2199,10 +2226,13 @@
</intent-filter>
</activity>
- <activity android:name="Settings$PowerUsageSummaryActivity"
- android:label="@string/power_usage_summary_title"
- android:icon="@drawable/ic_homepage_battery"
- android:enabled="false">
+ <activity
+ android:name="Settings$PowerUsageSummaryActivity"
+ android:label="@string/power_usage_summary_title"
+ android:icon="@drawable/ic_homepage_battery"
+ android:enabled="false"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2221,18 +2251,11 @@
android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
</activity>
- <!-- Keep compatibility with old shortcuts. -->
- <activity-alias android:name=".fuelgauge.PowerUsageSummary"
- android:label="@string/power_usage_summary_title"
- android:exported="true"
- android:targetActivity="Settings$PowerUsageSummaryActivity">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
- </activity-alias>
-
<activity android:name=".Settings$PowerUsageSummaryLegacyActivity"
android:label="@string/power_usage_summary_title"
- android:icon="@drawable/ic_homepage_battery">
+ android:icon="@drawable/ic_homepage_battery"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2246,10 +2269,12 @@
android:value="com.android.settings.fuelgauge.PowerUsageSummaryLegacy" />
</activity>
- <activity android:name="Settings$BatterySaverSettingsActivity"
- android:label="@string/battery_saver"
- android:icon="@drawable/ic_settings_battery"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$BatterySaverSettingsActivity"
+ android:label="@string/battery_saver"
+ android:icon="@drawable/ic_settings_battery"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.BATTERY_SAVER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2271,9 +2296,10 @@
</intent-filter>
</activity>
- <activity android:name="Settings$AccountSyncSettingsActivity"
+ <activity
+ android:name="Settings$AccountSyncSettingsActivity"
android:label="@string/account_sync_settings_title"
- android:taskAffinity=""
+ android:taskAffinity="com.android.settings"
android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ACCOUNT_SYNC_SETTINGS" />
@@ -2288,9 +2314,10 @@
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
- <activity android:name="Settings$ManagedProfileSettingsActivity"
+ <activity
+ android:name="Settings$ManagedProfileSettingsActivity"
android:label="@string/managed_profile_settings_title"
- android:taskAffinity=""
+ android:taskAffinity="com.android.settings"
android:parentActivityName="Settings"
android:permission="android.permission.MANAGE_USERS">
<intent-filter android:priority="1">
@@ -2301,12 +2328,13 @@
android:value="com.android.settings.accounts.ManagedProfileSettings" />
</activity>
- <activity android:name="com.android.settings.accounts.AddAccountSettings"
+ <activity
+ android:name="com.android.settings.accounts.AddAccountSettings"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/header_add_an_account"
android:taskAffinity="com.android.settings"
- android:parentActivityName=".Settings$AccountDashboardActivity">
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2383,33 +2411,14 @@
android:value="com.android.settings.security.CryptKeeperSettings" />
</activity>
- <activity android:name="Settings$DataPlanUsageSummaryActivity"
- android:label="@string/data_usage_summary_title"
- android:icon="@drawable/ic_settings_data_usage"
- android:taskAffinity="">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="com.android.settings.SHORTCUT" />
- </intent-filter>
- <intent-filter android:priority="10">
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.wireless" />
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.datausage.DataPlanUsageSummary" />
- </activity>
-
- <activity android:name="Settings$DataUsageSummaryActivity"
- android:label="@string/data_usage_summary_title"
- android:icon="@drawable/ic_settings_data_usage"
- android:taskAffinity="">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="com.android.settings.SHORTCUT" />
- </intent-filter>
+ <activity
+ android:name="Settings$DataUsageSummaryActivity"
+ android:label="@string/data_usage_summary_title"
+ android:icon="@drawable/ic_settings_data_usage"
+ android:enabled="false"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
+ <!-- TODO(b/70950124): add shortcut intent-filter -->
<intent-filter android:priority="10">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
@@ -2419,9 +2428,31 @@
android:value="com.android.settings.datausage.DataUsageSummary" />
</activity>
- <activity android:name="Settings$MobileDataUsageListActivity"
- android:label="@string/cellular_data_usage"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$DataUsageSummaryLegacyActivity"
+ android:label="@string/data_usage_summary_title"
+ android:icon="@drawable/ic_settings_data_usage"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="com.android.settings.SHORTCUT" />
+ </intent-filter>
+ <intent-filter android:priority="10">
+ <action android:name="com.android.settings.action.SETTINGS" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.category"
+ android:value="com.android.settings.category.ia.wireless" />
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.datausage.DataUsageSummaryLegacy" />
+ </activity>
+
+ <activity
+ android:name="Settings$MobileDataUsageListActivity"
+ android:label="@string/cellular_data_usage"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.MOBILE_DATA_USAGE" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2430,10 +2461,12 @@
android:value="com.android.settings.datausage.DataUsageList" />
</activity>
- <activity android:name="Settings$DreamSettingsActivity"
- android:label="@string/screensaver_settings_title"
- android:icon="@drawable/ic_settings_display"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$DreamSettingsActivity"
+ android:label="@string/screensaver_settings_title"
+ android:icon="@drawable/ic_settings_display"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.DREAM_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2449,10 +2482,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$UserSettingsActivity"
- android:label="@string/user_settings_title"
- android:icon="@drawable/ic_settings_multiuser"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$UserSettingsActivity"
+ android:label="@string/user_settings_title"
+ android:icon="@drawable/ic_settings_multiuser"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.USER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2472,10 +2507,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$PaymentSettingsActivity"
- android:label="@string/nfc_payment_settings_title"
- android:icon="@drawable/ic_settings_nfc_payment"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$PaymentSettingsActivity"
+ android:label="@string/nfc_payment_settings_title"
+ android:icon="@drawable/ic_settings_nfc_payment"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.NFC_PAYMENT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2504,7 +2541,7 @@
<activity android:name=".nfc.HowItWorks"
android:label="@string/nfc_payment_settings_title"
- android:parentActivityName="Settings$PaymentSettingsActivity">
+ android:parentActivityName="Settings$PaymentSettingsActivity"
android:excludeFromRecents="true">
</activity>
@@ -2518,9 +2555,11 @@
</intent-filter>
</activity>
- <activity android:name="Settings$NotificationAccessSettingsActivity"
- android:label="@string/manage_notification_access_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$NotificationAccessSettingsActivity"
+ android:label="@string/manage_notification_access_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2533,9 +2572,11 @@
android:value="com.android.settings.notification.NotificationAccessSettings" />
</activity>
- <activity android:name="Settings$VrListenersSettingsActivity"
- android:label="@string/vr_listeners_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$VrListenersSettingsActivity"
+ android:label="@string/vr_listeners_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.VR_LISTENER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2548,9 +2589,11 @@
android:value="com.android.settings.applications.VrListenerSettings" />
</activity>
- <activity android:name="Settings$PictureInPictureSettingsActivity"
+ <activity
+ android:name="Settings$PictureInPictureSettingsActivity"
android:label="@string/picture_in_picture_title"
- android:taskAffinity="">
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.PICTURE_IN_PICTURE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2563,9 +2606,11 @@
android:value="com.android.settings.applications.appinfo.PictureInPictureSettings" />
</activity>
- <activity android:name="Settings$AppPictureInPictureSettingsActivity"
+ <activity
+ android:name="Settings$AppPictureInPictureSettingsActivity"
android:label="@string/picture_in_picture_title"
- android:taskAffinity="">
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.settings.PICTURE_IN_PICTURE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2575,9 +2620,11 @@
android:value="com.android.settings.applications.appinfo.PictureInPictureDetails" />
</activity>
- <activity android:name="Settings$ZenAccessSettingsActivity"
- android:label="@string/manage_zen_access_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ZenAccessSettingsActivity"
+ android:label="@string/manage_zen_access_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2590,10 +2637,12 @@
android:value="com.android.settings.notification.ZenAccessSettings" />
</activity>
- <activity android:name="Settings$ConfigureNotificationSettingsActivity"
- android:label="@string/configure_notification_settings"
- android:exported="true"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ConfigureNotificationSettingsActivity"
+ android:label="@string/configure_notification_settings"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.NOTIFICATION_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2615,11 +2664,13 @@
</activity>
<!-- Keep compatibility with old shortcuts. -->
- <activity android:name="Settings$SoundSettingsActivity"
- android:label="@string/sound_settings"
- android:icon="@drawable/ic_homepage_sound"
- android:taskAffinity=""
- android:exported="true">
+ <activity
+ android:name="Settings$SoundSettingsActivity"
+ android:label="@string/sound_settings"
+ android:icon="@drawable/ic_homepage_sound"
+ android:exported="true"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="com.android.settings.SOUND_SETTINGS" />
<action android:name="android.settings.SOUND_SETTINGS" />
@@ -2645,15 +2696,6 @@
android:resource="@string/sound_dashboard_summary"/>
</activity>
- <!-- Keep compatibility with old shortcuts. -->
- <activity-alias android:name="SoundSettings"
- android:label="@string/sound_settings"
- android:exported="true"
- android:targetActivity="Settings$SoundSettingsActivity">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.notification.SoundSettings" />
- </activity-alias>
-
<!-- Show application-level notification settings (app passed in as extras) -->
<activity android:name="Settings$AppNotificationSettingsActivity"
android:exported="true">
@@ -2680,7 +2722,6 @@
android:value="com.android.settings.notification.ChannelGroupNotificationSettings" />
</activity>
-
<!-- Show channel-level notification settings (channel passed in as extras) -->
<activity android:name="Settings$ChannelNotificationSettingsActivity"
android:exported="true">
@@ -2697,10 +2738,12 @@
</activity>
<!-- Show Manual (from settings item) -->
- <activity android:name="ManualDisplayActivity"
- android:label="@string/manual"
- android:taskAffinity=""
- android:enabled="@bool/config_show_manual">
+ <activity
+ android:name="ManualDisplayActivity"
+ android:label="@string/manual"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings"
+ android:enabled="@bool/config_show_manual">
<intent-filter>
<action android:name="android.settings.SHOW_MANUAL" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2710,10 +2753,12 @@
</activity>
<!-- Show regulatory info (from settings item or dialing "*#07#") -->
- <activity android:name="RegulatoryInfoDisplayActivity"
- android:label="@string/regulatory_labels"
- android:taskAffinity=""
- android:enabled="@bool/config_show_regulatory_info">
+ <activity
+ android:name="RegulatoryInfoDisplayActivity"
+ android:label="@string/regulatory_labels"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings"
+ android:enabled="@bool/config_show_regulatory_info">
<intent-filter>
<action android:name="android.settings.SHOW_REGULATORY_INFO" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2772,10 +2817,12 @@
android:resource="@xml/file_paths" />
</provider>
- <activity android:name="Settings$SimSettingsActivity"
- android:label="@string/sim_settings_title"
- android:icon="@drawable/ic_settings_sim"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$SimSettingsActivity"
+ android:label="@string/sim_settings_title"
+ android:icon="@drawable/ic_settings_sim"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2797,11 +2844,11 @@
<activity android:name=".sim.SimPreferenceDialog"
android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
- android:excludeFromRecents="true">
- </activity>
+ android:excludeFromRecents="true" />
- <activity android:name=".wifi.RequestToggleWiFiActivity"
- android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
+ <activity
+ android:name=".wifi.RequestToggleWiFiActivity"
+ android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
android:excludeFromRecents="true"
android:permission="android.permission.CHANGE_WIFI_STATE">
<intent-filter>
@@ -2811,7 +2858,8 @@
</intent-filter>
</activity>
- <activity android:name=".wifi.WifiDialogActivity"
+ <activity
+ android:name=".wifi.WifiDialogActivity"
android:label=""
android:theme="@style/Transparent"
android:excludeFromRecents="true"
@@ -2833,9 +2881,11 @@
</intent-filter>
</activity>
- <activity android:name="Settings$WifiCallingSettingsActivity"
- android:label="@string/wifi_calling_settings_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$WifiCallingSettingsActivity"
+ android:label="@string/wifi_calling_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.WIFI_CALLING_SETTINGS" />
@@ -2850,8 +2900,7 @@
<activity android:name=".wifi.WifiCallingSuggestionActivity"
android:label="@string/wifi_calling_settings_title"
- android:icon="@drawable/ic_settings_wireless"
- android:taskAffinity="">
+ android:icon="@drawable/ic_settings_wireless">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
@@ -2887,9 +2936,11 @@
</intent-filter>
</provider>
- <activity android:name="Settings$OverlaySettingsActivity"
- android:label="@string/draw_overlay"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$OverlaySettingsActivity"
+ android:label="@string/draw_overlay"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2898,9 +2949,11 @@
android:value="com.android.settings.applications.manageapplications.ManageApplications" />
</activity>
- <activity android:name="Settings$AppDrawOverlaySettingsActivity"
- android:label="@string/draw_overlay"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$AppDrawOverlaySettingsActivity"
+ android:label="@string/draw_overlay"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2910,9 +2963,11 @@
android:value="com.android.settings.applications.appinfo.DrawOverlayDetails" />
</activity>
- <activity android:name="Settings$WriteSettingsActivity"
- android:label="@string/write_settings_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$WriteSettingsActivity"
+ android:label="@string/write_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2921,10 +2976,11 @@
android:value="com.android.settings.applications.manageapplications.ManageApplications" />
</activity>
-
- <activity android:name="Settings$AppWriteSettingsActivity"
- android:label="@string/write_settings_title"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$AppWriteSettingsActivity"
+ android:label="@string/write_settings_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2934,9 +2990,11 @@
android:value="com.android.settings.applications.appinfo.WriteSettingsDetails" />
</activity>
- <activity android:name="Settings$ManageExternalSourcesActivity"
- android:label="@string/install_other_apps"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$ManageExternalSourcesActivity"
+ android:label="@string/install_other_apps"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.MANAGE_UNKNOWN_APP_SOURCES" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2967,10 +3025,12 @@
</intent-filter>
</activity>
- <activity android:name="Settings$AdvancedAppsActivity"
- android:taskAffinity=""
- android:exported="true"
- android:label="@string/app_default_dashboard_title">
+ <activity
+ android:name="Settings$AdvancedAppsActivity"
+ android:exported="true"
+ android:label="@string/app_default_dashboard_title"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.MANAGE_DEFAULT_APPS_SETTINGS" />
<action android:name="android.settings.HOME_SETTINGS" />
@@ -3026,10 +3086,12 @@
android:value="true" />
</activity>
- <activity android:name="Settings$AutomaticStorageManagerSettingsActivity"
- android:exported="@bool/config_storage_manager_settings_enabled"
- android:label="@string/automatic_storage_manager_settings"
- android:taskAffinity="">
+ <activity
+ android:name="Settings$AutomaticStorageManagerSettingsActivity"
+ android:exported="@bool/config_storage_manager_settings_enabled"
+ android:label="@string/automatic_storage_manager_settings"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.STORAGE_MANAGER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -3037,12 +3099,13 @@
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.deletionhelper.AutomaticStorageManagerSettings" />
</activity>
- <!-- Information architecture host activities -->
- <!-- Alias for battery settings in new IA. Remove and merge metadata into TargetActivity -->
- <activity android:name=".Settings$AppAndNotificationDashboardActivity"
- android:label="@string/app_and_notification_dashboard_title"
- android:icon="@drawable/ic_homepage_apps">
+ <activity
+ android:name=".Settings$AppAndNotificationDashboardActivity"
+ android:label="@string/app_and_notification_dashboard_title"
+ android:icon="@drawable/ic_homepage_apps"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="9">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3054,9 +3117,12 @@
android:resource="@string/app_and_notification_dashboard_summary"/>
</activity>
- <activity android:name=".Settings$AccountDashboardActivity"
- android:label="@string/account_dashboard_title"
- android:icon="@drawable/ic_homepage_accounts">
+ <activity
+ android:name=".Settings$AccountDashboardActivity"
+ android:label="@string/account_dashboard_title"
+ android:icon="@drawable/ic_homepage_accounts"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="3">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3070,9 +3136,12 @@
android:value="com.android.settings.category.ia.homepage"/>
</activity>
- <activity android:name=".Settings$SystemDashboardActivity"
- android:label="@string/header_category_system"
- android:icon="@drawable/ic_homepage_system_dashboard">
+ <activity
+ android:name=".Settings$SystemDashboardActivity"
+ android:label="@string/header_category_system"
+ android:icon="@drawable/ic_homepage_system_dashboard"
+ android:taskAffinity="com.android.settings"
+ android:parentActivityName="Settings">
<intent-filter android:priority="-1">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3102,8 +3171,6 @@
android:resource="@string/support_summary"/>
</activity>
- <!-- End of information architecture host activities -->
-
<service
android:name=".SettingsDumpService"
android:exported="true"
diff --git a/res/drawable-hdpi/ic_wps_dark.png b/res/drawable-hdpi/ic_wps_dark.png
deleted file mode 100644
index 918b0cc..0000000
--- a/res/drawable-hdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_wps_light.png b/res/drawable-hdpi/ic_wps_light.png
deleted file mode 100644
index 5ad9f3e..0000000
--- a/res/drawable-hdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_wps_dark.png b/res/drawable-mdpi/ic_wps_dark.png
deleted file mode 100644
index 77d73a8..0000000
--- a/res/drawable-mdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_wps_light.png b/res/drawable-mdpi/ic_wps_light.png
deleted file mode 100644
index ef560fa..0000000
--- a/res/drawable-mdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_wps_dark.png b/res/drawable-xhdpi/ic_wps_dark.png
deleted file mode 100644
index 3ea4a3b..0000000
--- a/res/drawable-xhdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_wps_light.png b/res/drawable-xhdpi/ic_wps_light.png
deleted file mode 100644
index f913d2c..0000000
--- a/res/drawable-xhdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_wps_dark.png b/res/drawable-xxhdpi/ic_wps_dark.png
deleted file mode 100644
index 8b38db8..0000000
--- a/res/drawable-xxhdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_wps_light.png b/res/drawable-xxhdpi/ic_wps_light.png
deleted file mode 100644
index 0084175..0000000
--- a/res/drawable-xxhdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/data_plans_sync_time_preference.xml b/res/layout/data_plans_sync_time_preference.xml
deleted file mode 100644
index bb9da90..0000000
--- a/res/layout/data_plans_sync_time_preference.xml
+++ /dev/null
@@ -1,26 +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.
--->
-
-<!-- Shows the data plans sync time -->
-<TextView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:gravity="end"
- android:textColor="?android:attr/textColorSecondary"/>
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
new file mode 100644
index 0000000..445e7cd
--- /dev/null
+++ b/res/layout/data_usage_summary_preference.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="@dimen/preference_no_icon_padding_start"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:orientation="vertical"
+ android:background="@drawable/selectable_card_grey"
+ android:selectable="false"
+ style="@style/EntityHeader">
+
+ <TextView
+ android:id="@+id/usage_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary"
+ android:paddingBottom="5dp"
+ android:text="@string/data_usage_title" />
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="5dp"
+ android:fontFamily="@*android:string/config_headlineFontFamily"
+ android:textColor="?android:attr/colorAccent"
+ android:textAppearance="@android:style/TextAppearance.Material.Large" />
+
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary"
+ android:paddingBottom="5dp" />
+
+ <com.android.settings.widget.LinearColorBar
+ android:id="@+id/color_bar"
+ android:layout_width="match_parent"
+ android:layout_height="28dp" />
+
+ <LinearLayout
+ android:id="@+id/label_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="2dp"
+ android:orientation="horizontal">
+
+ <TextView android:id="@android:id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary" />
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <TextView android:id="@android:id/text2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:textColor="?android:attr/textColorSecondary" />
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/cycle_left_time"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="5dp" />
+
+ <TextView
+ android:id="@+id/carrier_and_update"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="5dp" />
+
+ <Button
+ android:id="@+id/launch_mdp_app_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:text="@string/launch_mdp_app_text"
+ style="@style/ActionPrimaryButton" />
+
+ <TextView
+ android:id="@+id/data_limits"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="5dp" />
+
+</LinearLayout>
+
diff --git a/res/layout/manage_data_plans_preference.xml b/res/layout/manage_data_plans_preference.xml
deleted file mode 100644
index 0db5698..0000000
--- a/res/layout/manage_data_plans_preference.xml
+++ /dev/null
@@ -1,32 +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.
--->
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="8dp"
- android:paddingBottom="16dp">
- <Button
- android:id="@+id/manage_data_plans"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/data_plan_usage_manage_plans_button_text"
- android:textAllCaps="true"
- style="@style/ActionPrimaryButton" />
-</FrameLayout>
diff --git a/res/layout/styled_switch_bar.xml b/res/layout/styled_switch_bar.xml
index 1777c0f..3baaac3 100644
--- a/res/layout/styled_switch_bar.xml
+++ b/res/layout/styled_switch_bar.xml
@@ -16,13 +16,13 @@
<!-- For use in a LayoutPreference -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="0px"
- android:layout_width="match_parent"
- android:layout_weight="1" >
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent" >
<com.android.settings.widget.SwitchBar
android:id="@+id/switch_bar"
- android:layout_height="?android:attr/actionBarSize"
+ android:minHeight="?android:attr/actionBarSize"
+ android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingStart="0dp"
android:theme="?attr/switchBarTheme" />
diff --git a/res/layout/wifi_wps_dialog.xml b/res/layout/wifi_wps_dialog.xml
deleted file mode 100644
index a86823d..0000000
--- a/res/layout/wifi_wps_dialog.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="300sp"
- android:layout_height="wrap_content">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="8dip"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/wps_dialog_txt"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dip" />
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginTop="8dip"
- android:src="?attr/ic_wps" />
-
- <ProgressBar
- android:id="@+id/wps_timeout_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dip"
- style="?android:attr/progressBarStyleHorizontal" />
-
- <ProgressBar
- android:id="@+id/wps_progress_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dip"
- style="?android:attr/progressBarStyle" />
-
- <RelativeLayout
- android:gravity="center"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/wps_dialog_btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/cancel" />
- </RelativeLayout>
- </LinearLayout>
-</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d462450..72db253 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1845,12 +1845,8 @@
<string name="wifi_configure_settings_preference_summary_wakeup_off">Wi\u2011Fi doesn\u0027t turn back on automatically</string>
<!-- Header for the list of wifi networks-->
<string name="wifi_access_points">Wi\u2011Fi networks</string>
- <!-- Menu option to do WPS Push Button [CHAR LIMIT=25]-->
- <string name="wifi_menu_wps_pbc">WPS Push Button</string>
<!-- Content description for menu button in Wifi setup. Not shown on the screen. [CHAR LIMIT=NONE] -->
<string name="wifi_menu_more_options">More options</string>
- <!-- Menu option to do WPS Pin Entry [CHAR LIMIT=25]-->
- <string name="wifi_menu_wps_pin">WPS Pin Entry</string>
<!-- Menu option to launch Wi-Fi Direct settings [CHAR LIMIT=20]-->
<string name="wifi_menu_p2p">Wi\u2011Fi Direct</string>
<!-- Menu option to scan Wi-Fi networks -->
@@ -1887,32 +1883,6 @@
<string name="wifi_advanced_toggle_description_expanded">Drop down list Advanced Options. Double-tap to collapse.</string>
<!-- Message for talkback to say when Advanced Options is collapsed [CHAR LIMIT=NONE] -->
<string name="wifi_advanced_toggle_description_collapsed">Drop down list Advanced Options. Double-tap to expand.</string>
- <!-- Title for the WPS setup dialog [CHAR LIMIT=50] -->
- <string name="wifi_wps_setup_title">Wi\u2011Fi Protected Setup</string>
- <!-- Message in WPS dialog at start up [CHAR LIMIT=150] -->
- <string name="wifi_wps_setup_msg">Starting WPS\u2026</string>
- <!-- Message in WPS dialog for PBC after start up [CHAR LIMIT=150] -->
- <string name="wifi_wps_onstart_pbc">Press the Wi\u2011Fi Protected Setup button on your router. It may be called \u201cWPS\u201d or marked with this symbol:</string>
- <!-- Message in WPS dialog for PIN after start up [CHAR LIMIT=150] -->
- <string name="wifi_wps_onstart_pin">Enter pin <xliff:g id="number">%1$s</xliff:g> on your Wi\u2011Fi router. The setup can take up to two minutes to complete.</string>
- <!-- Text displayed when WPS succeeds [CHAR LIMIT=150] -->
- <string name="wifi_wps_complete">WPS succeeded. Connecting to the network\u2026</string>
- <!-- Text displayed when Wi-Fi is connected through WPS [CHAR LIMIT=150] -->
- <string name="wifi_wps_connected">Connected to Wi\u2011Fi network <xliff:g id="network_name">%s</xliff:g></string>
- <!-- Text displayed when WPS setup is in progress [CHAR LIMIT=150] -->
- <string name="wifi_wps_in_progress">WPS is already in progress and can take up to two minutes to complete</string>
- <!-- Text displayed when WPS fails to start [CHAR LIMIT=150] -->
- <string name="wifi_wps_failed_generic">WPS failed. Please try again in a few minutes.</string>
- <!-- Text displayed when WPS fails due to WEP [CHAR LIMIT=150] -->
- <string name="wifi_wps_failed_wep">The wireless router security setting (WEP) is not supported</string>
- <!-- Text displayed when WPS fails to TKIP [CHAR LIMIT=150] -->
- <string name="wifi_wps_failed_tkip">The wireless router security setting (TKIP) is not supported</string>
- <!-- Text displayed when WPS fails due to authentication issues [CHAR LIMIT=150] -->
- <string name="wifi_wps_failed_auth">Authentication failure. Please try again.</string>
- <!-- Text displayed when WPS fails due to another session [CHAR LIMIT=150] -->
- <string name="wifi_wps_failed_overlap">Another WPS session was detected. Please try again in a few minutes.</string>
- <!-- Text displayed when WPS fails due to wifi disconnected [CHAR LIMIT=150] -->
- <string name="wifi_wps_failed_wifi_disconnected">Wi\u2011Fi disconnected. WPS setup canceled.</string>
<!-- Label for the SSID of the network -->
<string name="wifi_ssid">Network name</string>
<!-- Hint for a text field to enter the SSID of a hidden wifi network. [CHAR LIMIT=35] -->
@@ -5775,9 +5745,6 @@
<!-- action to select all [CHAR LIMIT=30] -->
<string name="select_all">Select all</string>
- <!-- A button that gets displayed in data plan usage preference in settings page to manage data plans [CHAR LIMIT=25] -->
- <string name="data_plan_usage_manage_plans_button_text">Manage plans</string>
-
<!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
<string name="data_usage_summary_title">Data usage</string>
<!-- Activity title for Appk data usage summary. [CHAR LIMIT=25] -->
@@ -5877,6 +5844,8 @@
<string name="data_usage_enable_3g">2G-3G data</string>
<!-- Toggle switch title for enabling 4G data network connection. [CHAR LIMIT=32] -->
<string name="data_usage_enable_4g">4G data</string>
+ <!-- Toggle switch title for enabling roaming on the primary data SIM card. [CHAR LIMIT=32] -->
+ <string name="data_roaming_enable_mobile">Roaming</string>
<!-- Data Usage Foreground label. [CHAR LIMIT=40] -->
<string name="data_usage_forground_label">Foreground:</string>
@@ -7086,7 +7055,7 @@
<string name="notification_pulse_title">Blink light</string>
<!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
- <string name="lock_screen_notifications_title">On the lock screen</string>
+ <string name="lock_screen_notifications_title">On lock screen</string>
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
shown in notifications shown on a secure lock screen
@@ -7096,7 +7065,7 @@
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
hidden or redacted from notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
- <string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
+ <string name="lock_screen_notifications_summary_hide">Hide sensitive content</string>
<!-- Configure Notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
[CHAR LIMIT=50] -->
@@ -7116,7 +7085,7 @@
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
hidden or redacted from work notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
- <string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work notification content</string>
+ <string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work content</string>
<!-- Configure Notifications: Value for lockscreen notifications: work notifications will not appear on a secure lock screen
[CHAR LIMIT=50] -->
@@ -7376,7 +7345,7 @@
<string name="app_notification_override_dnd_summary">Let these notifications continue to interrupt when Do Not Disturb is set to Priority Only</string>
<!-- [CHAR LIMIT=NONE] App notification settings: Visibility override option title -->
- <string name="app_notification_visibility_override_title">On the lock screen</string>
+ <string name="app_notification_visibility_override_title">On lock screen</string>
<!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when allowed -->
<string name="app_notification_row_banned">Blocked</string>
@@ -8688,6 +8657,27 @@
<item quantity="other"><xliff:g id="count" example="10">%1$d</xliff:g> apps allowed to use unrestricted data when Data Saver is on</item>
</plurals>
+ <!-- Data usage title text [CHAR LIMIT=30] -->
+ <string name="data_usage_title">Primary data</string>
+
+ <!-- Data usage string [CHAR LIMIT=30] -->
+ <string name="data_used"><xliff:g name="bytes" example="2 GB">^1</xliff:g> used</string>
+
+ <!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
+ <string name="data_remaining"><xliff:g name="bytes" example="2 GB">, ^1</xliff:g> left</string>
+
+ <!-- Informational text about time left in billing cycle [CHAR LIMIT=30] -->
+ <string name="cycle_left_time_text"><xliff:g name="time" example="2d">%1$s</xliff:g> left in this cycle</string>
+
+ <!-- Informational text about carrier and update time [CHAR LIMIT=30] -->
+ <string name="carrier_and_update_text">Updated by <xliff:g name="carrier" example="T-mobile">%1$s</xliff:g> <xliff:g name="time" example="3m">%2$s</xliff:g></string>
+
+ <!-- Informational text about update time only, without carrier [CHAR LIMIT=30] -->
+ <string name="no_carrier_update_text">Updated <xliff:g name="time" example="3m">%1$s</xliff:g></string>
+
+ <!-- Button to launch external data plan app [CHAR LIMIT=30] -->
+ <string name="launch_mdp_app_text">VIEW PLAN</string>
+
<!-- Name of Data Saver screens [CHAR LIMIT=30] -->
<string name="data_saver_title">Data saver</string>
@@ -9372,4 +9362,6 @@
<!-- Settings item summary for automatic Bluetooth on while driving preference [CHAR LIMIT=100] -->
<string name="bluetooth_on_while_driving_summary">Turn on Bluetooth automatically when driving</string>
+ <!-- Title for item to go to old battery settings page when clicking [CHAR LIMIT=100] -->
+ <string name="dev_android_o_battery_settings_title">See Android 8.0 battery settings</string>
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index e0f3989..d960654 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -17,7 +17,6 @@
<resources>
<attr name="fingerprint_layout_theme" format="reference" />
<attr name="ic_menu_moreoverflow" format="reference" />
- <attr name="ic_wps" format="reference" />
<attr name="side_margin" format="reference|dimension" />
<attr name="wifi_signal_color" format="reference" />
@@ -28,7 +27,6 @@
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="ic_wps">@drawable/ic_wps_dark</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
@@ -47,7 +45,6 @@
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="ic_wps">@drawable/ic_wps_light</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
@@ -65,7 +62,6 @@
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="ic_wps">@drawable/ic_wps_dark</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
@@ -84,7 +80,6 @@
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="ic_wps">@drawable/ic_wps_light</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
@@ -102,7 +97,6 @@
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="ic_wps">@drawable/ic_wps_dark</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
@@ -121,7 +115,6 @@
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="ic_wps">@drawable/ic_wps_light</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
@@ -221,7 +214,6 @@
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_holo_dark</item>
- <item name="ic_wps">@drawable/ic_wps_light</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
<item name="wifi_signal_color">?android:attr/colorAccent</item>
<item name="wifi_friction">@drawable/wifi_friction</item>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 47199c2..9e32440 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -16,6 +16,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/battery_saver"
android:key="battery_saver">
@@ -23,12 +24,15 @@
<SwitchPreference
android:key="auto_battery_saver"
android:title="@string/battery_saver_auto_title"
- android:summary="@string/battery_saver_auto_summary"/>
+ android:summary="@string/battery_saver_auto_summary"
+ settings:controller="com.android.settings.fuelgauge.batterysaver.AutoBatterySaverPreferenceController"/>
+
<com.android.settings.widget.SeekBarPreference
android:key="battery_saver_seek_bar"
android:title="@string/battery_saver_seekbar_title"
android:max="75"
android:min="5"/>
+
<com.android.settings.applications.LayoutPreference
android:key="battery_saver_button_container"
android:selectable="false"
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index 0b75abf..83a63e4 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -25,8 +25,8 @@
android:title="@string/bluetooth_settings_title"
android:icon="@drawable/ic_settings_bluetooth"
android:summary="@string/bluetooth_pref_summary"
- settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"
- android:order="-7"/>
+ android:order="-7"
+ settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"/>
<SwitchPreference
android:key="toggle_nfc"
@@ -54,6 +54,7 @@
android:title="@string/bluetooth_on_while_driving_pref"
android:icon="@drawable/ic_settings_bluetooth"
android:summary="@string/bluetooth_on_while_driving_summary"
+ settings:controller="com.android.settings.connecteddevice.BluetoothOnWhileDrivingPreferenceController"
android:order="-2"/>
<Preference
diff --git a/res/xml/data_plan_usage.xml b/res/xml/data_plan_usage.xml
deleted file mode 100644
index 4691198..0000000
--- a/res/xml/data_plan_usage.xml
+++ /dev/null
@@ -1,25 +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:title="@string/data_usage_summary_title">
-
- <PreferenceCategory
- android:key="data_plan_usage"
- android:title="@string/usage">
-
- </PreferenceCategory>
-</PreferenceScreen>
diff --git a/res/xml/data_plan_usage_cell_data_preference_screen.xml b/res/xml/data_plan_usage_cell_data_preference_screen.xml
deleted file mode 100644
index 08f21c5..0000000
--- a/res/xml/data_plan_usage_cell_data_preference_screen.xml
+++ /dev/null
@@ -1,30 +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:title="@string/data_usage_summary_title">
-
- <com.android.settings.datausage.TemplatePreferenceCategory
- android:key="data_usage_mobile_category"
- android:title="@string/data_usage_tab_mobile">
-
- <com.android.settings.datausage.CellDataPreference
- android:key="data_usage_enable"
- android:title="@string/data_usage_enable_mobile" />
- </com.android.settings.datausage.TemplatePreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/data_usage.xml b/res/xml/data_usage.xml
index 958459c..88d7f32 100644
--- a/res/xml/data_usage.xml
+++ b/res/xml/data_usage.xml
@@ -20,24 +20,8 @@
android:key="data_usage_screen"
android:title="@string/data_usage_summary_title">
- <PreferenceCategory
- android:key="data_usage_category"
- android:title="@string/usage">
-
- <com.android.settings.SummaryPreference
+ <com.android.settings.datausage.DataUsageSummaryPreference
android:key="status_header"
android:selectable="false" />
- <Preference
- android:key="limit_summary"
- android:selectable="false"
- settings:allowDividerBelow="true" />
-
- <com.android.settings.datausage.DataSaverPreference
- android:key="restrict_background"
- android:title="@string/data_saver_title"
- android:fragment="com.android.settings.datausage.DataSaverSummary" />
-
- </PreferenceCategory>
-
</PreferenceScreen>
diff --git a/res/xml/data_usage_legacy.xml b/res/xml/data_usage_legacy.xml
new file mode 100644
index 0000000..958459c
--- /dev/null
+++ b/res/xml/data_usage_legacy.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="data_usage_screen"
+ android:title="@string/data_usage_summary_title">
+
+ <PreferenceCategory
+ android:key="data_usage_category"
+ android:title="@string/usage">
+
+ <com.android.settings.SummaryPreference
+ android:key="status_header"
+ android:selectable="false" />
+
+ <Preference
+ android:key="limit_summary"
+ android:selectable="false"
+ settings:allowDividerBelow="true" />
+
+ <com.android.settings.datausage.DataSaverPreference
+ android:key="restrict_background"
+ android:title="@string/data_saver_title"
+ android:fragment="com.android.settings.datausage.DataSaverSummary" />
+
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 5a0d249..a88a97b 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -77,6 +77,11 @@
android:fragment="com.android.settings.applications.RunningServices" />
<Preference
+ android:key="android_o_battery_settings"
+ android:fragment="com.android.settings.fuelgauge.PowerUsageSummaryLegacy"
+ android:title="@string/dev_android_o_battery_settings_title" />
+
+ <Preference
android:key="convert_to_file_encryption"
android:title="@string/convert_to_file_encryption"
android:summary="@string/convert_to_file_encryption_enabled"
@@ -471,7 +476,6 @@
android:entries="@array/app_process_limit_entries"
android:entryValues="@array/app_process_limit_values" />
-
<Preference
android:key="background_check"
android:fragment="com.android.settings.applications.appops.BackgroundCheckSummary"
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 4d0c992..3cafc3f 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -43,8 +43,9 @@
<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:keywords="@string/keywords_display_auto_brightness"
+ settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
settings:useAdminDisabledSummary="true"
settings:userRestriction="no_config_brightness" />
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
index dafd36c..00eaa7e 100644
--- a/res/xml/security_dashboard_settings.xml
+++ b/res/xml/security_dashboard_settings.xml
@@ -79,7 +79,8 @@
<SwitchPreference
android:key="visiblepattern_profile"
android:summary="@string/summary_placeholder"
- android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile" />
+ android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"
+ settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController"/>
<Preference
android:key="fingerprint_settings_profile"
@@ -103,7 +104,8 @@
<SwitchPreference
android:key="show_password"
android:title="@string/show_password"
- android:summary="@string/show_password_summary" />
+ android:summary="@string/show_password_summary"
+ settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
</PreferenceCategory>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 1da1de5..3d3bfd0 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -16,6 +16,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="security_lockscreen_settings_screen"
android:title="@string/lockscreen_settings_title">
@@ -36,7 +37,8 @@
<SwitchPreference
android:key="security_setting_lockdown_enabled"
android:title="@string/lockdown_settings_title"
- android:summary="@string/lockdown_settings_summary" />
+ android:summary="@string/lockdown_settings_summary"
+ settings:controller="com.android.settings.security.LockdownButtonPreferenceController"/>
<PreferenceCategory
android:key="security_setting_lock_screen_notif_work_header"
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 6993f26..eae6faa 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -64,14 +64,6 @@
android:fragment="com.android.settings.wifi.p2p.WifiP2pSettings"/>
<Preference
- android:key="wps_push_button"
- android:title="@string/wifi_menu_wps_pbc" />
-
- <Preference
- android:key="wps_pin_entry"
- android:title="@string/wifi_menu_wps_pin" />
-
- <Preference
android:key="mac_address"
android:title="@string/wifi_advanced_mac_address_title"/>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 741bfda..599d6fb 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -78,8 +78,8 @@
public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
- public static class DataPlanUsageSummaryActivity extends SettingsActivity { /* empty */ }
public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
+ public static class DataUsageSummaryLegacyActivity extends SettingsActivity { /* empty */ }
public static class MobileDataUsageListActivity extends SettingsActivity { /* empty */ }
public static class ConfigureWifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class SavedAccessPointsSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index e80b2536..f9aaf84 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -46,6 +46,7 @@
import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils;
import android.transition.TransitionManager;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
@@ -57,6 +58,7 @@
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.backup.BackupSettingsActivity;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.gateway.SettingsGateway;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.DashboardSummary;
@@ -731,31 +733,11 @@
pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin)
|| somethingChanged;
- boolean isDataPlanFeatureEnabled = FeatureFactory.getFactory(this)
- .getDataPlanFeatureProvider()
- .isEnabled();
-
- // When the data plan feature flag is turned on we disable DataUsageSummaryActivity
- // and enable DataPlanUsageSummaryActivity. When the feature flag is turned off we do the
- // reverse.
-
- // Disable DataUsageSummaryActivity if the data plan feature flag is turned on otherwise
- // disable DataPlanUsageSummaryActivity.
- somethingChanged = setTileEnabled(
- new ComponentName(packageName,
- isDataPlanFeatureEnabled
- ? Settings.DataUsageSummaryActivity.class.getName()
- : Settings.DataPlanUsageSummaryActivity.class.getName()),
- false /* enabled */,
- isAdmin) || somethingChanged;
// Enable DataUsageSummaryActivity if the data plan feature flag is turned on otherwise
// enable DataPlanUsageSummaryActivity.
somethingChanged = setTileEnabled(
- new ComponentName(packageName,
- isDataPlanFeatureEnabled
- ? Settings.DataPlanUsageSummaryActivity.class.getName()
- : Settings.DataUsageSummaryActivity.class.getName()),
+ new ComponentName(packageName, Settings.DataUsageSummaryActivity.class.getName()),
Utils.isBandwidthControlEnabled() /* enabled */,
isAdmin) || somethingChanged;
@@ -791,6 +773,19 @@
Settings.PowerUsageSummaryLegacyActivity.class.getName()),
mBatteryPresent && !isBatterySettingsV2Enabled, isAdmin) || somethingChanged;
+ final boolean isDataUsageSettingsV2Enabled =
+ FeatureFlagUtils.isEnabled(this, FeatureFlags.DATA_USAGE_SETTINGS_V2);
+ // Enable new data usage page if v2 enabled
+ somethingChanged = setTileEnabled(new ComponentName(packageName,
+ Settings.DataUsageSummaryActivity.class.getName()),
+ Utils.isBandwidthControlEnabled() && isDataUsageSettingsV2Enabled, isAdmin)
+ || somethingChanged;
+ // Enable legacy data usage page if v2 disabled
+ somethingChanged = setTileEnabled(new ComponentName(packageName,
+ Settings.DataUsageSummaryLegacyActivity.class.getName()),
+ Utils.isBandwidthControlEnabled() && !isDataUsageSettingsV2Enabled, isAdmin)
+ || somethingChanged;
+
somethingChanged = setTileEnabled(new ComponentName(packageName,
Settings.UserSettingsActivity.class.getName()),
UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers()
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index 01d98b8..4bd7ba4 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -30,6 +30,8 @@
* Abstract class to consolidate utility between preference controllers and act as an interface
* for Slices. The abstract classes that inherit from this class will act as the direct interfaces
* for each type when plugging into Slices.
+ *
+ * TODO (b/73074893) Add Lifecycle Setting method.
*/
public abstract class BasePreferenceController extends AbstractPreferenceController {
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index 8fa1bb3..fd756df 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -26,4 +26,5 @@
public static final String ZONE_PICKER_V2 = "settings_zone_picker_v2";
public static final String ABOUT_PHONE_V2 = "settings_about_phone_v2";
public static final String BLUETOOTH_WHILE_DRIVING = "settings_bluetooth_while_driving";
+ public static final String DATA_USAGE_SETTINGS_V2 = "settings_data_usage_v2";
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 19d0cd1..76def2c 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -33,16 +33,16 @@
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
import com.android.settings.accessibility.CaptionPropertiesFragment;
import com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment;
+import com.android.settings.accounts.AccountDashboardFragment;
import com.android.settings.accounts.AccountSyncSettings;
import com.android.settings.accounts.ChooseAccountActivity;
import com.android.settings.accounts.ManagedProfileSettings;
-import com.android.settings.accounts.AccountDashboardFragment;
import com.android.settings.applications.AppAndNotificationDashboardFragment;
import com.android.settings.applications.DefaultAppSettings;
+import com.android.settings.applications.DirectoryAccessDetails;
import com.android.settings.applications.ManageDomainUrls;
import com.android.settings.applications.ProcessStatsSummary;
import com.android.settings.applications.ProcessStatsUi;
-import com.android.settings.applications.DirectoryAccessDetails;
import com.android.settings.applications.UsageAccessDetails;
import com.android.settings.applications.VrListenerSettings;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
@@ -59,9 +59,9 @@
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
-import com.android.settings.datausage.DataPlanUsageSummary;
import com.android.settings.datausage.DataUsageList;
import com.android.settings.datausage.DataUsageSummary;
+import com.android.settings.datausage.DataUsageSummaryLegacy;
import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
import com.android.settings.development.DevelopmentSettingsDashboardFragment;
import com.android.settings.deviceinfo.DeviceInfoSettings;
@@ -187,8 +187,8 @@
PickupGestureSettings.class.getName(),
DoubleTwistGestureSettings.class.getName(),
CryptKeeperSettings.class.getName(),
- DataPlanUsageSummary.class.getName(),
DataUsageSummary.class.getName(),
+ DataUsageSummaryLegacy.class.getName(),
DreamSettings.class.getName(),
UserSettings.class.getName(),
NotificationAccessSettings.class.getName(),
@@ -273,7 +273,6 @@
SupportDashboardActivity.class.getName(),
// Home page > Network & Internet
Settings.WifiSettingsActivity.class.getName(),
- Settings.DataPlanUsageSummaryActivity.class.getName(),
Settings.DataUsageSummaryActivity.class.getName(),
Settings.SimSettingsActivity.class.getName(),
// Home page > Connected devices
diff --git a/src/com/android/settings/datausage/DataPlanFeatureProvider.java b/src/com/android/settings/datausage/DataPlanFeatureProvider.java
deleted file mode 100644
index eb5b48f..0000000
--- a/src/com/android/settings/datausage/DataPlanFeatureProvider.java
+++ /dev/null
@@ -1,27 +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.datausage;
-
-/**
- * Feature provider for data plan feature.
- */
-public interface DataPlanFeatureProvider {
- /**
- * @return whether data plan feature is enabled.
- */
- boolean isEnabled();
-}
diff --git a/src/com/android/settings/datausage/DataPlanFeatureProviderImpl.java b/src/com/android/settings/datausage/DataPlanFeatureProviderImpl.java
deleted file mode 100644
index d5f435c..0000000
--- a/src/com/android/settings/datausage/DataPlanFeatureProviderImpl.java
+++ /dev/null
@@ -1,31 +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.datausage;
-
-import android.os.SystemProperties;
-
-/**
- * Impl for data plan feature provider.
- */
-public final class DataPlanFeatureProviderImpl implements DataPlanFeatureProvider {
- private static final String ENABLE_SETTINGS_DATA_PLAN = "enable.settings.data.plan";
-
- @Override
- public boolean isEnabled() {
- return SystemProperties.getBoolean(ENABLE_SETTINGS_DATA_PLAN, false /* default */);
- }
-}
diff --git a/src/com/android/settings/datausage/DataPlanSummaryPreference.java b/src/com/android/settings/datausage/DataPlanSummaryPreference.java
deleted file mode 100644
index f48e04d..0000000
--- a/src/com/android/settings/datausage/DataPlanSummaryPreference.java
+++ /dev/null
@@ -1,90 +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.datausage;
-
-import android.content.Context;
-import android.support.annotation.ColorRes;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-import android.widget.TextView;
-import com.android.settings.R;
-import com.android.settings.widget.DonutView;
-
-/**
- * Provides a summary of data plans as preferences on settings page.
- */
-public final class DataPlanSummaryPreference extends Preference {
- private String mName;
- private String mDescription;
- private double mPercentageUsage;
- private int mUsageTextColor;
- private int mMeterBackgroundColor;
- private int mMeterConsumedColor;
-
- public DataPlanSummaryPreference(Context context) {
- super(context);
- setLayoutResource(R.layout.settings_data_plan_summary_preference);
- }
-
- public DataPlanSummaryPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- setLayoutResource(R.layout.settings_data_plan_summary_preference);
- }
-
- public void setName(String planName) {
- mName = planName;
- notifyChanged();
- }
-
- public void setDescription(String planDescription) {
- mDescription = planDescription;
- notifyChanged();
- }
-
- public void setPercentageUsage(double percentageUsage) {
- mPercentageUsage = percentageUsage;
- notifyChanged();
- }
-
- public void setUsageTextColor(@ColorRes int planUsageTextColor) {
- mUsageTextColor = planUsageTextColor;
- notifyChanged();
- }
-
- public void setMeterBackgroundColor(@ColorRes int meterBackgroundColor) {
- mMeterBackgroundColor = meterBackgroundColor;
- notifyChanged();
- }
-
- public void setMeterConsumedColor(@ColorRes int meterConsumedColor) {
- mMeterConsumedColor = meterConsumedColor;
- notifyChanged();
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
- super.onBindViewHolder(holder);
- holder.setDividerAllowedAbove(false);
- TextView titleView = (TextView) holder.findViewById(android.R.id.title);
- titleView.setTextColor(mUsageTextColor);
- ((TextView) holder.findViewById(android.R.id.text1)).setText(mName);
- ((TextView) holder.findViewById(android.R.id.text2)).setText(mDescription);
- DonutView donutView = (DonutView) holder.findViewById(R.id.donut);
- donutView.setPercentage(mPercentageUsage);
- donutView.setMeterBackgroundColor(mMeterBackgroundColor);
- donutView.setMeterConsumedColor(mMeterConsumedColor);
- }
-}
diff --git a/src/com/android/settings/datausage/DataPlanUsageSummary.java b/src/com/android/settings/datausage/DataPlanUsageSummary.java
deleted file mode 100644
index 9489322..0000000
--- a/src/com/android/settings/datausage/DataPlanUsageSummary.java
+++ /dev/null
@@ -1,359 +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.datausage;
-
-import static android.net.NetworkPolicy.LIMIT_DISABLED;
-
-import android.annotation.IdRes;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.NetworkPolicy;
-import android.net.NetworkPolicyManager;
-import android.net.NetworkTemplate;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceScreen;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.text.TextUtils;
-import android.text.format.Formatter;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settingslib.NetworkPolicyEditor;
-import com.android.settingslib.net.DataUsageController;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @deprecated This fragment was supposed to be new version of {@link DataUsageSummary} however
- * unfinished and used nowhere. Keep it in case we may bring it back someday.
- */
-@Deprecated
-public class DataPlanUsageSummary extends DataUsageBase {
-
- public static final String KEY_DATA_PLAN_USAGE = "data_plan_usage";
-
- public static final String KEY_STATUS_HEADER = "status_header";
- public static final String KEY_LIMIT_SUMMARY = "plan_summary";
-
- // Mobile data keys
- public static final String KEY_MOBILE_USAGE_TITLE = "data_usage_mobile_category";
- public static final String KEY_MOBILE_DATA_USAGE_TOGGLE = "data_usage_enable";
-
- // Wifi keys
- public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
- public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
- public static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
-
- private DataUsageController mDataUsageController;
- private DataUsageInfoController mDataInfoController;
- private List<DataPlanSummaryPreference> mDataPlanSummaryPreferenceList;
- private Preference mLimitPreference;
- private NetworkTemplate mDefaultTemplate;
- private NetworkRestrictionsPreference mNetworkRestrictionPreference;
- private WifiManager mWifiManager;
- private NetworkPolicyEditor mPolicyEditor;
-
- @Override
- public int getHelpResource() {
- return R.string.help_url_data_usage;
- }
-
- @Override
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
-
- final Context context = getContext();
- NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- mPolicyEditor = new NetworkPolicyEditor(policyManager);
- mDataUsageController = new DataUsageController(context);
- mDataInfoController = new DataUsageInfoController();
-
- int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
- boolean hasMobileData = DataUsageUtils.hasMobileData(context);
- if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- hasMobileData = false;
- }
- mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
-
- if (hasMobileData) {
- addDataPlanSection(defaultSubId);
- }
-
- if (DataUsageUtils.hasWifiRadio(context)) {
- addWifiSection();
- }
-
- if (hasEthernet(context)) {
- addEthernetSection();
- }
- setHasOptionsMenu(true);
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (UserManager.get(getContext()).isAdminUser()) {
- inflater.inflate(R.menu.data_usage, menu);
- }
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.data_usage_menu_cellular_networks: {
- final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
- startActivity(intent);
- return true;
- }
- }
- return false;
- }
-
- private void addDataPlanSection(int defaultSubId) {
- Context context = getPrefContext();
- addPreferencesFromResource(R.xml.data_plan_usage);
- PreferenceScreen screen = getPreferenceScreen();
- screen.setTitle(context.getString(R.string.data_usage_summary_title));
-
- PreferenceCategory preferenceCategory =
- (PreferenceCategory) findPreference(KEY_DATA_PLAN_USAGE);
- screen.addPreference(preferenceCategory);
-
- Preference dataPlansSyncTimePreference = new Preference(context);
- dataPlansSyncTimePreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
- dataPlansSyncTimePreference.setTitle(MockDataPlanUsage.SYNC_TIME);
- preferenceCategory.addPreference(dataPlansSyncTimePreference);
-
- mDataPlanSummaryPreferenceList = new ArrayList<>(MockDataPlanUsage.DATA_PLAN_USAGES.length);
- for (int i = 0; i < MockDataPlanUsage.DATA_PLAN_USAGES.length; i++) {
- DataPlanSummaryPreference dataPlanSummaryPreference =
- new DataPlanSummaryPreference(context);
- dataPlanSummaryPreference.setKey(KEY_STATUS_HEADER + (i + 1));
- mDataPlanSummaryPreferenceList.add(dataPlanSummaryPreference);
- preferenceCategory.addPreference(dataPlanSummaryPreference);
- }
-
- Preference preference = new Preference(context);
- preference.setLayoutResource(R.layout.manage_data_plans_preference);
- preferenceCategory.addPreference(preference);
- setPreferenceScreen(screen);
-
- mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
- List<SubscriptionInfo> subscriptions =
- services.mSubscriptionManager.getActiveSubscriptionInfoList();
-
- if (subscriptions == null || subscriptions.isEmpty()) {
- addMobileSection(defaultSubId);
- }
-
- for (int i = 0, subscriptionsSize = subscriptions != null ? subscriptions.size() : 0;
- i < subscriptionsSize; i++) {
- SubscriptionInfo subInfo = subscriptions.get(i);
- if (subscriptionsSize > 1) {
- addMobileSection(subInfo.getSubscriptionId(), subInfo);
- } else {
- addMobileSection(subInfo.getSubscriptionId());
- }
- }
- }
-
- private void addMobileSection(int subId) {
- addMobileSection(subId, null);
- }
-
- private void addMobileSection(int subId, SubscriptionInfo subInfo) {
- TemplatePreferenceCategory category = (TemplatePreferenceCategory)
- inflatePreferences(R.xml.data_plan_usage_cell_data_preference_screen);
- category.setTemplate(getNetworkTemplate(subId), subId, services);
- category.pushTemplates(services);
- if (subInfo != null && !TextUtils.isEmpty(subInfo.getDisplayName())) {
- Preference title = category.findPreference(KEY_MOBILE_USAGE_TITLE);
- title.setTitle(subInfo.getDisplayName());
- }
- }
-
- private void addWifiSection() {
- TemplatePreferenceCategory category = (TemplatePreferenceCategory)
- inflatePreferences(R.xml.data_usage_wifi);
- category.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(), 0 /* subId */, services);
- mNetworkRestrictionPreference =
- (NetworkRestrictionsPreference) category.findPreference(KEY_NETWORK_RESTRICTIONS);
- }
-
- private void addEthernetSection() {
- TemplatePreferenceCategory category = (TemplatePreferenceCategory)
- inflatePreferences(R.xml.data_usage_ethernet);
- category.setTemplate(NetworkTemplate.buildTemplateEthernet(), 0 /* subId */, services);
- }
-
- private Preference inflatePreferences(@IdRes int resId) {
- PreferenceScreen rootPreferences = getPreferenceManager().inflateFromResource(
- getPrefContext(), resId, null);
- Preference pref = rootPreferences.getPreference(0);
- rootPreferences.removeAll();
-
- PreferenceScreen screen = getPreferenceScreen();
- pref.setOrder(screen.getPreferenceCount());
- screen.addPreference(pref);
-
- return pref;
- }
-
- private NetworkTemplate getNetworkTemplate(int subscriptionId) {
- NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
- services.mTelephonyManager.getSubscriberId(subscriptionId));
- return NetworkTemplate.normalize(mobileAll,
- services.mTelephonyManager.getMergedSubscriberIds());
- }
-
- @Override
- public void onResume() {
- super.onResume();
- updateState();
- }
-
- private void updateState() {
- DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
- mDefaultTemplate);
-
- Context context = getContext();
- mDataInfoController.updateDataLimit(info,
- services.mPolicyEditor.getPolicy(mDefaultTemplate));
-
- // TODO(b/63391323): Get rid of MockDataPlanUsage once we integrate with data plan APIs
- if (mDataPlanSummaryPreferenceList != null && !mDataPlanSummaryPreferenceList.isEmpty()) {
- MockDataPlanUsage[] dataPlanUsages = MockDataPlanUsage.getDataPlanUsage();
- for (int i = 0; i < dataPlanUsages.length; i++) {
- DataPlanSummaryPreference dataPlanSummaryPreference =
- mDataPlanSummaryPreferenceList.get(i);
- MockDataPlanUsage dataPlanUsage = dataPlanUsages[i];
- dataPlanSummaryPreference.setTitle(dataPlanUsage.mUsage);
- dataPlanSummaryPreference.setUsageTextColor(dataPlanUsage.mUsageTextColor);
- dataPlanSummaryPreference.setName(dataPlanUsage.mName);
- dataPlanSummaryPreference.setPercentageUsage(dataPlanUsage.mPercentageUsage);
- dataPlanSummaryPreference
- .setMeterBackgroundColor(dataPlanUsage.mMeterBackgroundColor);
- dataPlanSummaryPreference.setMeterConsumedColor(dataPlanUsage.mMeterConsumedColor);
- dataPlanSummaryPreference.setDescription(dataPlanUsage.mDescription);
- }
- }
-
- if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
- String warning = Formatter.formatFileSize(context, info.warningLevel);
- String limit = Formatter.formatFileSize(context, info.limitLevel);
- mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
- : R.string.cell_warning_and_limit, warning, limit));
- } else if (mLimitPreference != null) {
- mLimitPreference.setSummary(null);
- }
-
- updateNetworkRestrictionSummary(mNetworkRestrictionPreference);
-
- PreferenceScreen screen = getPreferenceScreen();
- for (int i = 1, preferenceCount = screen.getPreferenceCount(); i < preferenceCount; i++) {
- ((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
- }
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.DATA_USAGE_SUMMARY;
- }
-
- @VisibleForTesting
- void updateNetworkRestrictionSummary(NetworkRestrictionsPreference preference) {
- if (preference == null) {
- return;
- }
- mPolicyEditor.read();
- int count = 0;
- List<WifiConfiguration> configuredNetworks = mWifiManager.getConfiguredNetworks();
- for (int i = 0, configuredNetworksSize = configuredNetworks.size();
- i < configuredNetworksSize; i++) {
- WifiConfiguration config = configuredNetworks.get(i);
- if (isMetered(config)) {
- count++;
- }
- }
- preference.setSummary(getResources().getQuantityString(
- R.plurals.network_restrictions_summary, count, count));
- }
-
- @VisibleForTesting
- boolean isMetered(WifiConfiguration config) {
- if (config.SSID == null) {
- return false;
- }
- final String networkId = config.isPasspoint() ? config.providerFriendlyName : config.SSID;
- final NetworkPolicy policy =
- mPolicyEditor.getPolicyMaybeUnquoted(NetworkTemplate.buildTemplateWifi(networkId));
- if (policy == null) {
- return false;
- }
- if (policy.limitBytes != LIMIT_DISABLED) {
- return true;
- }
- return policy.metered;
- }
-
- private static class SummaryProvider
- implements SummaryLoader.SummaryProvider {
-
- private final Activity mActivity;
- private final SummaryLoader mSummaryLoader;
- private final DataUsageController mDataController;
-
- public SummaryProvider(Activity activity, SummaryLoader summaryLoader) {
- mActivity = activity;
- mSummaryLoader = summaryLoader;
- mDataController = new DataUsageController(activity);
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
- String used;
- if (info == null) {
- used = Formatter.formatFileSize(mActivity, 0);
- } else if (info.limitLevel <= 0) {
- used = Formatter.formatFileSize(mActivity, info.usageLevel);
- } else {
- used = Utils.formatPercentage(info.usageLevel, info.limitLevel);
- }
- mSummaryLoader.setSummary(this,
- mActivity.getString(R.string.data_usage_summary_format, used));
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = SummaryProvider::new;
-}
-
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index b63cee3..339de7c 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -18,7 +18,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.net.NetworkPolicyManager;
import android.net.NetworkTemplate;
import android.os.Bundle;
import android.os.UserManager;
@@ -28,6 +27,7 @@
import android.support.v7.preference.PreferenceScreen;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
+import android.telephony.SubscriptionPlan;
import android.text.BidiFormatter;
import android.text.Spannable;
import android.text.SpannableString;
@@ -40,7 +40,6 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
-import com.android.settings.SummaryPreference;
import com.android.settings.Utils;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -65,7 +64,6 @@
public static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
private static final String KEY_STATUS_HEADER = "status_header";
- private static final String KEY_LIMIT_SUMMARY = "limit_summary";
// Mobile data keys
public static final String KEY_MOBILE_USAGE_TITLE = "mobile_category";
@@ -77,13 +75,9 @@
public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
- private DataUsageController mDataUsageController;
- private DataUsageInfoController mDataInfoController;
- private SummaryPreference mSummaryPreference;
- private Preference mLimitPreference;
+ private DataUsageSummaryPreference mSummaryPreference;
+ private DataUsageSummaryPreferenceController mSummaryController;
private NetworkTemplate mDefaultTemplate;
- private int mDataUsageTemplate;
- private NetworkPolicyEditor mPolicyEditor;
@Override
public int getHelpResource() {
@@ -95,25 +89,20 @@
super.onCreate(icicle);
final Context context = getContext();
- NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
- mPolicyEditor = new NetworkPolicyEditor(policyManager);
boolean hasMobileData = DataUsageUtils.hasMobileData(context);
- mDataUsageController = new DataUsageController(context);
- mDataInfoController = new DataUsageInfoController();
int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
hasMobileData = false;
}
mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
- mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
+ mSummaryPreference = (DataUsageSummaryPreference) findPreference(KEY_STATUS_HEADER);
if (!hasMobileData || !isAdmin()) {
removePreference(KEY_RESTRICT_BACKGROUND);
}
if (hasMobileData) {
- mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
List<SubscriptionInfo> subscriptions =
services.mSubscriptionManager.getActiveSubscriptionInfoList();
if (subscriptions == null || subscriptions.size() == 0) {
@@ -127,10 +116,6 @@
addMobileSection(subInfo.getSubscriptionId());
}
}
- mSummaryPreference.setSelectable(true);
- } else {
- removePreference(KEY_LIMIT_SUMMARY);
- mSummaryPreference.setSelectable(false);
}
boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
if (hasWifiRadio) {
@@ -139,10 +124,6 @@
if (hasEthernet(context)) {
addEthernetSection();
}
- mDataUsageTemplate = hasMobileData ? R.string.cell_data_template
- : hasWifiRadio ? R.string.wifi_data_template
- : R.string.ethernet_data_template;
-
setHasOptionsMenu(true);
}
@@ -189,7 +170,11 @@
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
- return null;
+ final ArrayList<AbstractPreferenceController> controllers = new ArrayList<>();
+ mSummaryController =
+ new DataUsageSummaryPreferenceController(context);
+ controllers.add(mSummaryController);
+ return controllers;
}
private void addMobileSection(int subId) {
@@ -269,36 +254,6 @@
}
private void updateState() {
- DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
- mDefaultTemplate);
- Context context = getContext();
- mDataInfoController.updateDataLimit(info,
- services.mPolicyEditor.getPolicy(mDefaultTemplate));
-
- if (mSummaryPreference != null) {
- mSummaryPreference.setTitle(
- formatUsage(context, getString(mDataUsageTemplate), info.usageLevel));
- final long limit = mDataInfoController.getSummaryLimit(info);
- mSummaryPreference.setSummary(info.period);
- if (limit <= 0) {
- mSummaryPreference.setChartEnabled(false);
- } else {
- mSummaryPreference.setChartEnabled(true);
- mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0),
- Formatter.formatFileSize(context, limit));
- mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0,
- (limit - info.usageLevel) / (float) limit);
- }
- }
- if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
- String warning = Formatter.formatFileSize(context, info.warningLevel);
- String limit = Formatter.formatFileSize(context, info.limitLevel);
- mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
- : R.string.cell_warning_and_limit, warning, limit));
- } else if (mLimitPreference != null) {
- mLimitPreference.setSummary(null);
- }
-
PreferenceScreen screen = getPreferenceScreen();
for (int i = 1; i < screen.getPreferenceCount(); i++) {
((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
@@ -323,6 +278,7 @@
@Override
public void updateDataUsage() {
updateState();
+ mSummaryController.updateState(mSummaryPreference);
}
private static class SummaryProvider
@@ -341,17 +297,39 @@
@Override
public void setListening(boolean listening) {
if (listening) {
- DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
- String used;
- if (info == null) {
- used = Formatter.formatFileSize(mActivity, 0);
- } else if (info.limitLevel <= 0) {
- used = Formatter.formatFileSize(mActivity, info.usageLevel);
- } else {
- used = Utils.formatPercentage(info.usageLevel, info.limitLevel);
- }
mSummaryLoader.setSummary(this,
- mActivity.getString(R.string.data_usage_summary_format, used));
+ mActivity.getString(R.string.data_usage_summary_format, formatUsedData()));
+ }
+ }
+
+ private String formatUsedData() {
+ SubscriptionManager subscriptionManager = (SubscriptionManager) mActivity
+ .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+ int defaultSubId = subscriptionManager.getDefaultSubscriptionId();
+ if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return formatFallbackData();
+ }
+ SubscriptionPlan dfltPlan = DataUsageSummaryPreferenceController
+ .getPrimaryPlan(subscriptionManager, defaultSubId);
+ if (dfltPlan == null) {
+ return formatFallbackData();
+ }
+ if (DataUsageSummaryPreferenceController.unlimited(dfltPlan.getDataLimitBytes())) {
+ return Formatter.formatFileSize(mActivity, dfltPlan.getDataUsageBytes());
+ } else {
+ return Utils.formatPercentage(dfltPlan.getDataUsageBytes(),
+ dfltPlan.getDataLimitBytes());
+ }
+ }
+
+ private String formatFallbackData() {
+ DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
+ if (info == null) {
+ return Formatter.formatFileSize(mActivity, 0);
+ } else if (info.limitLevel <= 0) {
+ return Formatter.formatFileSize(mActivity, info.usageLevel);
+ } else {
+ return Utils.formatPercentage(info.usageLevel, info.limitLevel);
}
}
}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryLegacy.java b/src/com/android/settings/datausage/DataUsageSummaryLegacy.java
new file mode 100644
index 0000000..6a241eb
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageSummaryLegacy.java
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2016 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.datausage;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkPolicyManager;
+import android.net.NetworkTemplate;
+import android.os.Bundle;
+import android.os.UserManager;
+import android.provider.SearchIndexableResource;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.text.BidiFormatter;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.format.Formatter;
+import android.text.style.RelativeSizeSpan;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.SummaryPreference;
+import com.android.settings.Utils;
+import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.net.DataUsageController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Legacy {@link DataUsageSummary} fragment.
+ */
+public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Indexable,
+ DataUsageEditController {
+
+ private static final String TAG = "DataUsageSummaryLegacy";
+
+ static final boolean LOGD = false;
+
+ public static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
+
+ private static final String KEY_STATUS_HEADER = "status_header";
+ private static final String KEY_LIMIT_SUMMARY = "limit_summary";
+
+ // Mobile data keys
+ public static final String KEY_MOBILE_USAGE_TITLE = "mobile_category";
+ public static final String KEY_MOBILE_DATA_USAGE_TOGGLE = "data_usage_enable";
+ public static final String KEY_MOBILE_DATA_USAGE = "cellular_data_usage";
+ public static final String KEY_MOBILE_BILLING_CYCLE = "billing_preference";
+
+ // Wifi keys
+ public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
+ public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
+
+ private DataUsageController mDataUsageController;
+ private DataUsageInfoController mDataInfoController;
+ private SummaryPreference mSummaryPreference;
+ private Preference mLimitPreference;
+ private NetworkTemplate mDefaultTemplate;
+ private int mDataUsageTemplate;
+ private NetworkPolicyEditor mPolicyEditor;
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_url_data_usage;
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ final Context context = getContext();
+ NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
+ mPolicyEditor = new NetworkPolicyEditor(policyManager);
+
+ boolean hasMobileData = DataUsageUtils.hasMobileData(context);
+ mDataUsageController = new DataUsageController(context);
+ mDataInfoController = new DataUsageInfoController();
+
+ int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
+ if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ hasMobileData = false;
+ }
+ mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
+ mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
+
+ if (!hasMobileData || !isAdmin()) {
+ removePreference(KEY_RESTRICT_BACKGROUND);
+ }
+ if (hasMobileData) {
+ mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
+ List<SubscriptionInfo> subscriptions =
+ services.mSubscriptionManager.getActiveSubscriptionInfoList();
+ if (subscriptions == null || subscriptions.size() == 0) {
+ addMobileSection(defaultSubId);
+ }
+ for (int i = 0; subscriptions != null && i < subscriptions.size(); i++) {
+ SubscriptionInfo subInfo = subscriptions.get(i);
+ if (subscriptions.size() > 1) {
+ addMobileSection(subInfo.getSubscriptionId(), subInfo);
+ } else {
+ addMobileSection(subInfo.getSubscriptionId());
+ }
+ }
+ mSummaryPreference.setSelectable(true);
+ } else {
+ removePreference(KEY_LIMIT_SUMMARY);
+ mSummaryPreference.setSelectable(false);
+ }
+ boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
+ if (hasWifiRadio) {
+ addWifiSection();
+ }
+ if (hasEthernet(context)) {
+ addEthernetSection();
+ }
+ mDataUsageTemplate = hasMobileData ? R.string.cell_data_template
+ : hasWifiRadio ? R.string.wifi_data_template
+ : R.string.ethernet_data_template;
+
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ if (UserManager.get(getContext()).isAdminUser()) {
+ inflater.inflate(R.menu.data_usage, menu);
+ }
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.data_usage_menu_cellular_networks: {
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setComponent(new ComponentName("com.android.phone",
+ "com.android.phone.MobileNetworkSettings"));
+ startActivity(intent);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(Preference preference) {
+ if (preference == findPreference(KEY_STATUS_HEADER)) {
+ BillingCycleSettings.BytesEditorFragment.show(this, false);
+ return false;
+ }
+ return super.onPreferenceTreeClick(preference);
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.data_usage_legacy;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+ return null;
+ }
+
+ private void addMobileSection(int subId) {
+ addMobileSection(subId, null);
+ }
+
+ private void addMobileSection(int subId, SubscriptionInfo subInfo) {
+ TemplatePreferenceCategory category = (TemplatePreferenceCategory)
+ inflatePreferences(R.xml.data_usage_cellular);
+ category.setTemplate(getNetworkTemplate(subId), subId, services);
+ category.pushTemplates(services);
+ if (subInfo != null && !TextUtils.isEmpty(subInfo.getDisplayName())) {
+ Preference title = category.findPreference(KEY_MOBILE_USAGE_TITLE);
+ title.setTitle(subInfo.getDisplayName());
+ }
+ }
+
+ private void addWifiSection() {
+ TemplatePreferenceCategory category = (TemplatePreferenceCategory)
+ inflatePreferences(R.xml.data_usage_wifi);
+ category.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(), 0, services);
+ }
+
+ private void addEthernetSection() {
+ TemplatePreferenceCategory category = (TemplatePreferenceCategory)
+ inflatePreferences(R.xml.data_usage_ethernet);
+ category.setTemplate(NetworkTemplate.buildTemplateEthernet(), 0, services);
+ }
+
+ private Preference inflatePreferences(int resId) {
+ PreferenceScreen rootPreferences = getPreferenceManager().inflateFromResource(
+ getPrefContext(), resId, null);
+ Preference pref = rootPreferences.getPreference(0);
+ rootPreferences.removeAll();
+
+ PreferenceScreen screen = getPreferenceScreen();
+ pref.setOrder(screen.getPreferenceCount());
+ screen.addPreference(pref);
+
+ return pref;
+ }
+
+ private NetworkTemplate getNetworkTemplate(int subscriptionId) {
+ NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
+ services.mTelephonyManager.getSubscriberId(subscriptionId));
+ return NetworkTemplate.normalize(mobileAll,
+ services.mTelephonyManager.getMergedSubscriberIds());
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ updateState();
+ }
+
+ @VisibleForTesting
+ static CharSequence formatUsage(Context context, String template, long usageLevel) {
+ final float LARGER_SIZE = 1.25f * 1.25f; // (1/0.8)^2
+ final float SMALLER_SIZE = 1.0f / LARGER_SIZE; // 0.8^2
+ final int FLAGS = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
+
+ final Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(),
+ usageLevel, Formatter.FLAG_CALCULATE_ROUNDED);
+ final SpannableString enlargedValue = new SpannableString(usedResult.value);
+ enlargedValue.setSpan(new RelativeSizeSpan(LARGER_SIZE), 0, enlargedValue.length(), FLAGS);
+
+ final SpannableString amountTemplate = new SpannableString(
+ context.getString(com.android.internal.R.string.fileSizeSuffix)
+ .replace("%1$s", "^1").replace("%2$s", "^2"));
+ final CharSequence formattedUsage = TextUtils.expandTemplate(amountTemplate,
+ enlargedValue, usedResult.units);
+
+ final SpannableString fullTemplate = new SpannableString(template);
+ fullTemplate.setSpan(new RelativeSizeSpan(SMALLER_SIZE), 0, fullTemplate.length(), FLAGS);
+ return TextUtils.expandTemplate(fullTemplate,
+ BidiFormatter.getInstance().unicodeWrap(formattedUsage.toString()));
+ }
+
+ private void updateState() {
+ DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
+ mDefaultTemplate);
+ Context context = getContext();
+ mDataInfoController.updateDataLimit(info,
+ services.mPolicyEditor.getPolicy(mDefaultTemplate));
+
+ if (mSummaryPreference != null) {
+ mSummaryPreference.setTitle(
+ formatUsage(context, getString(mDataUsageTemplate), info.usageLevel));
+ final long limit = mDataInfoController.getSummaryLimit(info);
+ mSummaryPreference.setSummary(info.period);
+ if (limit <= 0) {
+ mSummaryPreference.setChartEnabled(false);
+ } else {
+ mSummaryPreference.setChartEnabled(true);
+ mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0),
+ Formatter.formatFileSize(context, limit));
+ mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0,
+ (limit - info.usageLevel) / (float) limit);
+ }
+ }
+ if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
+ String warning = Formatter.formatFileSize(context, info.warningLevel);
+ String limit = Formatter.formatFileSize(context, info.limitLevel);
+ mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
+ : R.string.cell_warning_and_limit, warning, limit));
+ } else if (mLimitPreference != null) {
+ mLimitPreference.setSummary(null);
+ }
+
+ PreferenceScreen screen = getPreferenceScreen();
+ for (int i = 1; i < screen.getPreferenceCount(); i++) {
+ ((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
+ }
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.DATA_USAGE_SUMMARY;
+ }
+
+ @Override
+ public NetworkPolicyEditor getNetworkPolicyEditor() {
+ return services.mPolicyEditor;
+ }
+
+ @Override
+ public NetworkTemplate getNetworkTemplate() {
+ return mDefaultTemplate;
+ }
+
+ @Override
+ public void updateDataUsage() {
+ updateState();
+ }
+
+ private static class SummaryProvider
+ implements SummaryLoader.SummaryProvider {
+
+ private final Activity mActivity;
+ private final SummaryLoader mSummaryLoader;
+ private final DataUsageController mDataController;
+
+ public SummaryProvider(Activity activity, SummaryLoader summaryLoader) {
+ mActivity = activity;
+ mSummaryLoader = summaryLoader;
+ mDataController = new DataUsageController(activity);
+ }
+
+ @Override
+ public void setListening(boolean listening) {
+ if (listening) {
+ DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
+ String used;
+ if (info == null) {
+ used = Formatter.formatFileSize(mActivity, 0);
+ } else if (info.limitLevel <= 0) {
+ used = Formatter.formatFileSize(mActivity, info.usageLevel);
+ } else {
+ used = Utils.formatPercentage(info.usageLevel, info.limitLevel);
+ }
+ mSummaryLoader.setSummary(this,
+ mActivity.getString(R.string.data_usage_summary_format, used));
+ }
+ }
+ }
+
+ public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
+ = SummaryProvider::new;
+
+ /**
+ * For search
+ */
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ List<SearchIndexableResource> resources = new ArrayList<>();
+ SearchIndexableResource resource = new SearchIndexableResource(context);
+ resource.xmlResId = R.xml.data_usage;
+ resources.add(resource);
+
+ resource = new SearchIndexableResource(context);
+ resource.xmlResId = R.xml.data_usage_cellular;
+ resources.add(resource);
+
+ resource = new SearchIndexableResource(context);
+ resource.xmlResId = R.xml.data_usage_wifi;
+ resources.add(resource);
+
+ return resources;
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ List<String> keys = super.getNonIndexableKeys(context);
+
+ if (!DataUsageUtils.hasMobileData(context)) {
+ keys.add(KEY_MOBILE_USAGE_TITLE);
+ keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE);
+ keys.add(KEY_MOBILE_DATA_USAGE);
+ keys.add(KEY_MOBILE_BILLING_CYCLE);
+ }
+
+ if (!DataUsageUtils.hasWifiRadio(context)) {
+ keys.add(KEY_WIFI_DATA_USAGE);
+ }
+
+ // This title is named Wifi, and will confuse users.
+ keys.add(KEY_WIFI_USAGE_TITLE);
+
+ return keys;
+ }
+ };
+}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
new file mode 100644
index 0000000..984df02
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -0,0 +1,117 @@
+/*
+ * 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.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.SummaryPreference;
+import com.android.settingslib.utils.StringUtil;
+
+import libcore.util.Objects;
+
+/**
+ * Provides a summary of data usage.
+ */
+public class DataUsageSummaryPreference extends SummaryPreference {
+
+ private int mNumPlans;
+ /** The ending time of the billing cycle in milliseconds since epoch. */
+ private long mCycleEndTimeMs;
+ /** The time of the last update in standard milliseconds since the epoch */
+ private long mSnapshotTimeMs;
+ /** Name of carrier, or null if not available */
+ private CharSequence mCarrierName;
+ private String mLimitInfoText;
+ private Intent mLaunchIntent;
+
+ public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setLayoutResource(R.layout.data_usage_summary_preference);
+ }
+
+ public void setLimitInfo(String text) {
+ if (!Objects.equal(text, mLimitInfoText)) {
+ mLimitInfoText = text;
+ notifyChanged();
+ }
+ }
+
+ public void setUsageInfo(long cycleEnd, long snapshotTime, CharSequence carrierName,
+ int numPlans, Intent launchIntent) {
+ mCycleEndTimeMs = cycleEnd;
+ mSnapshotTimeMs = snapshotTime;
+ mCarrierName = carrierName;
+ mNumPlans = numPlans;
+ mLaunchIntent = launchIntent;
+ notifyChanged();
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
+ usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
+
+ TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
+ cycleTime.setText(getContext().getString(R.string.cycle_left_time_text,
+ StringUtil.formatElapsedTime(getContext(),
+ mCycleEndTimeMs - System.currentTimeMillis(),false /* withSeconds */)));
+
+ TextView carrierInfo = (TextView) holder.findViewById(R.id.carrier_and_update);
+ setCarrierInfo(carrierInfo, mCarrierName, mSnapshotTimeMs);
+
+ Button launchButton = (Button) holder.findViewById(R.id.launch_mdp_app_button);
+ launchButton.setOnClickListener((view) -> {
+ getContext().sendBroadcast(mLaunchIntent);
+ });
+ if (mLaunchIntent != null) {
+ launchButton.setVisibility(View.VISIBLE);
+ } else {
+ launchButton.setVisibility(View.GONE);
+ }
+
+ TextView limitInfo = (TextView) holder.findViewById(R.id.data_limits);
+ limitInfo.setVisibility(
+ mLimitInfoText == null || mLimitInfoText.isEmpty() ? View.GONE : View.VISIBLE);
+ limitInfo.setText(mLimitInfoText);
+ }
+
+ private void setCarrierInfo(TextView carrierInfo, CharSequence carrierName, long updateAge) {
+ if (mNumPlans > 0 && updateAge >= 0L) {
+ carrierInfo.setVisibility(View.VISIBLE);
+ if (carrierName != null) {
+ carrierInfo.setText(getContext().getString(R.string.carrier_and_update_text,
+ carrierName, StringUtil.formatRelativeTime(
+ getContext(), updateAge, false /* withSeconds */)));
+ } else {
+ carrierInfo.setText(getContext().getString(R.string.no_carrier_update_text,
+ StringUtil.formatRelativeTime(
+ getContext(), updateAge, false /* withSeconds */)));
+ }
+ } else {
+ carrierInfo.setVisibility(View.GONE);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
new file mode 100644
index 0000000..11da829
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -0,0 +1,286 @@
+/*
+ * 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.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkPolicyManager;
+import android.net.NetworkTemplate;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.SubscriptionPlan;
+import android.text.BidiFormatter;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.format.Formatter;
+import android.text.style.RelativeSizeSpan;
+import android.util.Log;
+import android.util.RecurrenceRule;
+
+import com.android.internal.util.CollectionUtils;
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.net.DataUsageController;
+
+import java.util.List;
+
+/**
+ * This is the controller for the top of the data usage screen that retrieves carrier data from the
+ * new subscriptions framework API if available. The controller reads subscription information from
+ * the framework and falls back to legacy usage data if none are available.
+ */
+public class DataUsageSummaryPreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "DataUsageController";
+ private static final String KEY = "status_header";
+ private static final long PETA = 1000000000000000L;
+ private static final float RELATIVE_SIZE_LARGE = 1.25f * 1.25f; // (1/0.8)^2
+ private static final float RELATIVE_SIZE_SMALL = 1.0f / RELATIVE_SIZE_LARGE; // 0.8^2
+
+ private final DataUsageController mDataUsageController;
+ private final DataUsageInfoController mDataInfoController;
+ private final NetworkTemplate mDefaultTemplate;
+ private final NetworkPolicyEditor mPolicyEditor;
+ private final int mDataUsageTemplate;
+ private final boolean mHasMobileData;
+ private final SubscriptionManager mSubscriptionManager;
+
+ /** Name of the carrier, or null if not available */
+ private CharSequence mCarrierName;
+
+ /** The number of registered plans, [0,N] */
+ private int mDataplanCount;
+
+ /** The time of the last update in milliseconds since the epoch, or -1 if unknown */
+ private long mSnapshotTime;
+
+ /**
+ * The size of the first registered plan if one exists or the size of the warning if it is set.
+ * -1 if no information is available.
+ */
+ private long mDataplanSize;
+ /** The number of bytes used since the start of the cycle. */
+ private long mDataplanUse;
+ /** The starting time of the billing cycle in ms since the epoch */
+ private long mCycleStart;
+ /** The ending time of the billing cycle in ms since the epoch */
+ private long mCycleEnd;
+
+ private Intent mManageSubscriptionIntent;
+
+ public DataUsageSummaryPreferenceController(Context context) {
+ super(context, KEY);
+
+ final int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
+ mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
+ NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
+ mPolicyEditor = new NetworkPolicyEditor(policyManager);
+
+ mHasMobileData = DataUsageUtils.hasMobileData(context)
+ && defaultSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+ mDataUsageController = new DataUsageController(context);
+ mDataInfoController = new DataUsageInfoController();
+
+ if (mHasMobileData) {
+ mDataUsageTemplate = R.string.cell_data_template;
+ } else if (DataUsageUtils.hasWifiRadio(context)) {
+ mDataUsageTemplate = R.string.wifi_data_template;
+ } else {
+ mDataUsageTemplate = R.string.ethernet_data_template;
+ }
+
+ mSubscriptionManager = (SubscriptionManager)
+ mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+ }
+
+ @VisibleForTesting
+ DataUsageSummaryPreferenceController(
+ Context context,
+ DataUsageController dataUsageController,
+ DataUsageInfoController dataInfoController,
+ NetworkTemplate defaultTemplate,
+ NetworkPolicyEditor policyEditor,
+ int dataUsageTemplate,
+ boolean hasMobileData,
+ SubscriptionManager subscriptionManager) {
+ super(context, KEY);
+ mDataUsageController = dataUsageController;
+ mDataInfoController = dataInfoController;
+ mDefaultTemplate = defaultTemplate;
+ mPolicyEditor = policyEditor;
+ mDataUsageTemplate = dataUsageTemplate;
+ mHasMobileData = hasMobileData;
+ mSubscriptionManager = subscriptionManager;
+ }
+
+ @VisibleForTesting
+ void setPlanValues(int dataPlanCount, long dataPlanSize, long dataPlanUse) {
+ mDataplanCount = dataPlanCount;
+ mDataplanSize = dataPlanSize;
+ mDataplanUse = dataPlanUse;
+ }
+
+ @VisibleForTesting
+ void setCarrierValues(String carrierName, long snapshotTime, long cycleEnd, Intent intent) {
+ mCarrierName = carrierName;
+ mSnapshotTime = snapshotTime;
+ mCycleEnd = cycleEnd;
+ mManageSubscriptionIntent = intent;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ DataUsageSummaryPreference summaryPreference = (DataUsageSummaryPreference) preference;
+ DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
+ mDefaultTemplate);
+
+ mDataInfoController.updateDataLimit(info, mPolicyEditor.getPolicy(mDefaultTemplate));
+
+ if (mSubscriptionManager != null) {
+ refreshDataplanInfo(info);
+ }
+
+ if (mDataplanCount == 0 && (info.warningLevel > 0 || info.limitLevel > 0)) {
+ final String warning = Formatter.formatFileSize(mContext, info.warningLevel);
+ final String limit = Formatter.formatFileSize(mContext, info.limitLevel);
+ summaryPreference.setLimitInfo(mContext.getString(info.limitLevel <= 0
+ ? R.string.cell_warning_only
+ : R.string.cell_warning_and_limit, warning, limit));
+ } else {
+ summaryPreference.setLimitInfo(null);
+ }
+
+ final StringBuilder title = new StringBuilder();
+ if (mHasMobileData) {
+ title.append(formatUsage(mContext, mContext.getString(R.string.data_used),
+ mDataplanUse));
+ if (mDataplanCount >= 0 && mDataplanSize > 0L) {
+ title.append(formatUsage(mContext, mContext.getString(R.string.data_remaining),
+ mDataplanSize - mDataplanUse));
+ }
+ } else {
+ title.append(formatUsage(mContext, mContext.getString(mDataUsageTemplate),
+ mDataplanUse));
+ }
+ summaryPreference.setTitle(title.toString());
+
+ if (mDataplanSize <= 0) {
+ summaryPreference.setChartEnabled(false);
+ } else {
+ summaryPreference.setChartEnabled(true);
+ summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
+ Formatter.formatFileSize(mContext, mDataplanSize));
+ summaryPreference.setRatios(mDataplanUse / (float) mDataplanSize, 0 /* middle */,
+ (mDataplanSize - mDataplanUse) / (float) mDataplanSize);
+ }
+ summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
+ mDataplanCount, mManageSubscriptionIntent);
+ }
+
+ // TODO(b/70950124) add test for this method once the robolectric shadow run script is
+ // completed (b/3526807)
+ private void refreshDataplanInfo(DataUsageController.DataUsageInfo info) {
+ // reset data before overwriting
+ mCarrierName = null;
+ mDataplanCount = 0;
+ mDataplanSize = mDataInfoController.getSummaryLimit(info);
+ mDataplanUse = info.usageLevel;
+ mCycleStart = info.cycleStart;
+ mCycleEnd = info.cycleEnd;
+ mSnapshotTime = -1L;
+
+ final int defaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+ final SubscriptionInfo subInfo = mSubscriptionManager.getDefaultDataSubscriptionInfo();
+ if (subInfo != null && mHasMobileData) {
+ mCarrierName = subInfo.getCarrierName();
+ List<SubscriptionPlan> plans = mSubscriptionManager.getSubscriptionPlans(defaultSubId);
+ final SubscriptionPlan primaryPlan = getPrimaryPlan(mSubscriptionManager, defaultSubId);
+ if (primaryPlan != null) {
+ mDataplanCount = plans.size();
+ mDataplanSize = primaryPlan.getDataLimitBytes();
+ if (unlimited(mDataplanSize)) {
+ mDataplanSize = 0L;
+ }
+ mDataplanUse = primaryPlan.getDataUsageBytes();
+
+ RecurrenceRule rule = primaryPlan.getCycleRule();
+ if (rule != null && rule.start != null && rule.end != null) {
+ mCycleStart = rule.start.toEpochSecond() * 1000L;
+ mCycleEnd = rule.end.toEpochSecond() * 1000L;
+ }
+ mSnapshotTime = System.currentTimeMillis() - primaryPlan.getDataUsageTime();
+ }
+ }
+ mManageSubscriptionIntent =
+ mSubscriptionManager.createManageSubscriptionIntent(defaultSubId);
+ Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + defaultSubId
+ + ", intent " + mManageSubscriptionIntent);
+ }
+
+ public static SubscriptionPlan getPrimaryPlan(SubscriptionManager subManager, int primaryId) {
+ List<SubscriptionPlan> plans = subManager.getSubscriptionPlans(primaryId);
+ if (CollectionUtils.isEmpty(plans)) {
+ return null;
+ }
+ // First plan in the list is the primary plan
+ SubscriptionPlan plan = plans.get(0);
+ return plan.getDataLimitBytes() > 0
+ && saneSize(plan.getDataUsageBytes())
+ && plan.getCycleRule() != null ? plan : null;
+ }
+
+ private static boolean saneSize(long value) {
+ return value >= 0L && value < PETA;
+ }
+
+ public static boolean unlimited(long size) {
+ return size == SubscriptionPlan.BYTES_UNLIMITED;
+ }
+
+ @VisibleForTesting
+ private static CharSequence formatUsage(Context context, String template, long usageLevel) {
+ final int FLAGS = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
+
+ final Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(),
+ usageLevel, Formatter.FLAG_CALCULATE_ROUNDED);
+ final SpannableString enlargedValue = new SpannableString(usedResult.value);
+ enlargedValue.setSpan(
+ new RelativeSizeSpan(RELATIVE_SIZE_LARGE), 0, enlargedValue.length(), FLAGS);
+
+ final SpannableString amountTemplate = new SpannableString(
+ context.getString(com.android.internal.R.string.fileSizeSuffix)
+ .replace("%1$s", "^1").replace("%2$s", "^2"));
+ final CharSequence formattedUsage = TextUtils.expandTemplate(amountTemplate,
+ enlargedValue, usedResult.units);
+
+ final SpannableString fullTemplate = new SpannableString(template);
+ fullTemplate.setSpan(
+ new RelativeSizeSpan(RELATIVE_SIZE_SMALL), 0, fullTemplate.length(), FLAGS);
+ return TextUtils.expandTemplate(fullTemplate,
+ BidiFormatter.getInstance().unicodeWrap(formattedUsage.toString()));
+ }
+}
diff --git a/src/com/android/settings/datausage/MockDataPlanUsage.java b/src/com/android/settings/datausage/MockDataPlanUsage.java
deleted file mode 100644
index e3aa97a..0000000
--- a/src/com/android/settings/datausage/MockDataPlanUsage.java
+++ /dev/null
@@ -1,63 +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.datausage;
-
-import android.graphics.Color;
-
-/**
- * Mock data plan usage data.
- */
-@Deprecated // This class is only needed because we don't have working API yet.
-final class MockDataPlanUsage {
- static final MockDataPlanUsage[] DATA_PLAN_USAGES = new MockDataPlanUsage[3];
- static final String SYNC_TIME = "Today 12:24pm";
- final String mUsage;
- final int mUsageTextColor;
- final String mName;
- final double mPercentageUsage;
- final int mMeterBackgroundColor;
- final int mMeterConsumedColor;
- final String mDescription;
-
- private MockDataPlanUsage(String usage, int usageTextColor, String name,
- double percentageUsage, int meterBackgroundColor, int meterConsumedColor,
- String description) {
- mUsage = usage;
- mUsageTextColor = usageTextColor;
- mName = name;
- mPercentageUsage = percentageUsage;
- mMeterBackgroundColor = meterBackgroundColor;
- mMeterConsumedColor = meterConsumedColor;
- mDescription = description;
- }
-
- static MockDataPlanUsage[] getDataPlanUsage() {
- DATA_PLAN_USAGES[0] = new MockDataPlanUsage("100 MB and 14 days left",
- Color.parseColor("#FF5C94F1"), "GigaMaxLite / 1GB", 0.27D,
- Color.parseColor("#FFDBDCDC"), Color.parseColor("#FF5C94F1"),
- "Premium plan from Telekomsel");
-
- DATA_PLAN_USAGES[1] = new MockDataPlanUsage("1.25 GB and 14 days left",
- Color.parseColor("#FF673AB7"), "GigaMaxLite 4G / 5GB", 0.47D,
- Color.parseColor("#FFDBDCDC"), Color.parseColor("#FF673AB7"),
- "Plenty of 4G data");
-
- DATA_PLAN_USAGES[2] = new MockDataPlanUsage("700 MB and 14 days left",
- Color.parseColor("#FF4CAF50"), "GigaMaxLite Video / 7GB", 0.67D,
- Color.parseColor("#FFDBDCDC"), Color.parseColor("#FF4CAF50"),
- "Use certain video apps for free");
- return DATA_PLAN_USAGES;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index 2095f25..2f93d0a 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -62,7 +62,8 @@
*/
public class BatteryAppListPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin, LifecycleObserver, OnPause, OnDestroy {
- private static final boolean USE_FAKE_DATA = true;
+ @VisibleForTesting
+ static final boolean USE_FAKE_DATA = false;
private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10;
private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
private static final int STATS_TYPE = BatteryStats.STATS_SINCE_CHARGED;
diff --git a/src/com/android/settings/notification/VisibilityPreferenceController.java b/src/com/android/settings/notification/VisibilityPreferenceController.java
index 62ca183..dac90ef 100644
--- a/src/com/android/settings/notification/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/VisibilityPreferenceController.java
@@ -84,14 +84,17 @@
| DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
}
- final String summaryHideEntry =
- mContext.getString(R.string.lock_screen_notifications_summary_hide);
- final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
- entries.add(summaryHideEntry);
- values.add(summaryHideEntryValue);
- setRestrictedIfNotificationFeaturesDisabled(pref,
- summaryHideEntry, summaryHideEntryValue,
- DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
+ if (getLockscreenNotificationsEnabled()) {
+ final String summaryHideEntry =
+ mContext.getString(R.string.lock_screen_notifications_summary_hide);
+ final String summaryHideEntryValue = Integer.toString(
+ Notification.VISIBILITY_PRIVATE);
+ entries.add(summaryHideEntry);
+ values.add(summaryHideEntryValue);
+ setRestrictedIfNotificationFeaturesDisabled(pref,
+ summaryHideEntry, summaryHideEntryValue,
+ DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
+ }
entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable));
values.add(Integer.toString(Notification.VISIBILITY_SECRET));
pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 80d435f..585a2c1 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -27,13 +27,12 @@
import com.android.settings.connecteddevice.SmsMirroringFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
-import com.android.settings.datausage.DataPlanFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
import com.android.settings.localepicker.LocaleFeatureProvider;
-import com.android.settings.security.SecurityFeatureProvider;
import com.android.settings.search.SearchFeatureProvider;
+import com.android.settings.security.SecurityFeatureProvider;
import com.android.settings.slices.SlicesFeatureProvider;
import com.android.settings.users.UserFeatureProvider;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -104,8 +103,6 @@
public abstract BluetoothFeatureProvider getBluetoothFeatureProvider(Context context);
- public abstract DataPlanFeatureProvider getDataPlanFeatureProvider();
-
public abstract SmsMirroringFeatureProvider getSmsMirroringFeatureProvider();
public abstract SlicesFeatureProvider getSlicesFeatureProvider();
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 55f408d..965bfb1 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -35,8 +35,6 @@
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
-import com.android.settings.datausage.DataPlanFeatureProvider;
-import com.android.settings.datausage.DataPlanFeatureProviderImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
@@ -77,7 +75,6 @@
private AssistGestureFeatureProvider mAssistGestureFeatureProvider;
private UserFeatureProvider mUserFeatureProvider;
private BluetoothFeatureProvider mBluetoothFeatureProvider;
- private DataPlanFeatureProvider mDataPlanFeatureProvider;
private SmsMirroringFeatureProvider mSmsMirroringFeatureProvider;
private SlicesFeatureProvider mSlicesFeatureProvider;
private AccountFeatureProvider mAccountFeatureProvider;
@@ -192,14 +189,6 @@
}
@Override
- public DataPlanFeatureProvider getDataPlanFeatureProvider() {
- if (mDataPlanFeatureProvider == null) {
- mDataPlanFeatureProvider = new DataPlanFeatureProviderImpl();
- }
- return mDataPlanFeatureProvider;
- }
-
- @Override
public AssistGestureFeatureProvider getAssistGestureFeatureProvider() {
if (mAssistGestureFeatureProvider == null) {
mAssistGestureFeatureProvider = new AssistGestureFeatureProviderImpl();
diff --git a/src/com/android/settings/search/CursorToSearchResultConverter.java b/src/com/android/settings/search/CursorToSearchResultConverter.java
deleted file mode 100644
index 8e5577d..0000000
--- a/src/com/android/settings/search/CursorToSearchResultConverter.java
+++ /dev/null
@@ -1,213 +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.search;
-
-import static com.android.settings.search.DatabaseResultLoader.BASE_RANKS;
-import static com.android.settings.search.SearchResult.TOP_RANK;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.drawable.Drawable;
-import android.os.BadParcelableException;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Controller to Build search results from {@link Cursor} Objects.
- *
- * Each converted {@link Cursor} has the following fields:
- * - String Title
- * - String Summary
- * - int rank
- * - {@link Drawable} icon
- * - {@link ResultPayload} payload
- */
-public class CursorToSearchResultConverter {
-
- private static final String TAG = "CursorConverter";
-
- /**
- * These indices are used to match the columns of the this loader's SELECT statement.
- * These are not necessarily the same order nor similar coverage as the schema defined in
- * IndexDatabaseHelper
- */
- public static final int COLUMN_INDEX_ID = 0;
- public static final int COLUMN_INDEX_TITLE = 1;
- public static final int COLUMN_INDEX_SUMMARY_ON = 2;
- public static final int COLUMN_INDEX_SUMMARY_OFF = 3;
- public static final int COLUMN_INDEX_CLASS_NAME = 4;
- public static final int COLUMN_INDEX_SCREEN_TITLE = 5;
- public static final int COLUMN_INDEX_ICON = 6;
- public static final int COLUMN_INDEX_INTENT_ACTION = 7;
- public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 8;
- public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 9;
- public static final int COLUMN_INDEX_KEY = 10;
- public static final int COLUMN_INDEX_PAYLOAD_TYPE = 11;
- public static final int COLUMN_INDEX_PAYLOAD = 12;
-
- private final Context mContext;
-
- private final int LONG_TITLE_LENGTH = 20;
-
- private static final String[] whiteList = {
- "main_toggle_wifi",
- "main_toggle_bluetooth",
- "main_toggle_bluetooth_obsolete",
- "toggle_airplane",
- "tether_settings",
- "battery_saver",
- "toggle_nfc",
- "restrict_background",
- "data_usage_enable",
- "button_roaming_key",
- };
- private static final Set<String> prioritySettings = new HashSet(Arrays.asList(whiteList));
-
-
- public CursorToSearchResultConverter(Context context) {
- mContext = context;
- }
-
- public Set<SearchResult> convertCursor(Cursor cursorResults, int baseRank) {
- if (cursorResults == null) {
- return null;
- }
- final Map<String, Context> contextMap = new HashMap<>();
- final Set<SearchResult> results = new HashSet<>();
-
- while (cursorResults.moveToNext()) {
- SearchResult result = buildSingleSearchResultFromCursor(contextMap, cursorResults,
- baseRank);
- if (result != null) {
- results.add(result);
- }
- }
- return results;
- }
-
- public static ResultPayload getUnmarshalledPayload(byte[] marshalledPayload,
- int payloadType) {
- try {
- switch (payloadType) {
- case ResultPayload.PayloadType.INTENT:
- return ResultPayloadUtils.unmarshall(marshalledPayload,
- ResultPayload.CREATOR);
- case ResultPayload.PayloadType.INLINE_SWITCH:
- return ResultPayloadUtils.unmarshall(marshalledPayload,
- InlineSwitchPayload.CREATOR);
- case ResultPayload.PayloadType.INLINE_LIST:
- return ResultPayloadUtils.unmarshall(marshalledPayload,
- InlineListPayload.CREATOR);
- }
- } catch (BadParcelableException e) {
- Log.w(TAG, "Error creating parcelable: " + e);
- }
- return null;
- }
-
- private SearchResult buildSingleSearchResultFromCursor(Map<String, Context> contextMap,
- Cursor cursor, int baseRank) {
- final int docId = cursor.getInt(COLUMN_INDEX_ID);
- final String pkgName = cursor.getString(COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE);
- final String title = cursor.getString(COLUMN_INDEX_TITLE);
- final String summaryOn = cursor.getString(COLUMN_INDEX_SUMMARY_ON);
- final String className = cursor.getString(COLUMN_INDEX_CLASS_NAME);
- final String key = cursor.getString(COLUMN_INDEX_KEY);
- final String iconResStr = cursor.getString(COLUMN_INDEX_ICON);
- final int payloadType = cursor.getInt(COLUMN_INDEX_PAYLOAD_TYPE);
- final byte[] marshalledPayload = cursor.getBlob(COLUMN_INDEX_PAYLOAD);
- final ResultPayload payload = getUnmarshalledPayload(marshalledPayload, payloadType);
-
- final int rank = getRank(title, baseRank, key);
-
- final SearchResult.Builder builder = new SearchResult.Builder()
- .setStableId(docId)
- .setTitle(title)
- .setSummary(summaryOn)
- .setRank(rank)
- .setIcon(getIconForPackage(contextMap, pkgName, className, iconResStr))
- .setPayload(payload);
- return builder.build();
- }
-
- private Drawable getIconForPackage(Map<String, Context> contextMap, String pkgName,
- String className, String iconResStr) {
- final int iconId = TextUtils.isEmpty(iconResStr)
- ? 0 : Integer.parseInt(iconResStr);
- Drawable icon;
- Context packageContext;
- if (iconId == 0) {
- icon = null;
- } else {
- if (TextUtils.isEmpty(className) && !TextUtils.isEmpty(pkgName)) {
- packageContext = contextMap.get(pkgName);
- if (packageContext == null) {
- try {
- packageContext = mContext.createPackageContext(pkgName, 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Cannot create Context for package: " + pkgName);
- return null;
- }
- contextMap.put(pkgName, packageContext);
- }
- } else {
- packageContext = mContext;
- }
- try {
- icon = packageContext.getDrawable(iconId);
- } catch (Resources.NotFoundException nfe) {
- icon = null;
- }
- }
- return icon;
- }
-
-
- /** Uses the breadcrumbs to determine the offset to the base rank.
- * There are three checks
- * A) If the result is prioritized and the highest base level
- * B) If the query matches the highest level menu title
- * C) If the query is longer than 20
- *
- * If the query matches A, set it to TOP_RANK
- * If the query matches B, the offset is 0.
- * If the query matches C, the offset is 1
-
- * @param title of the result.
- * @param baseRank of the result. Lower if it's a better result.
- * @return
- */
- private int getRank(String title, int baseRank, String key) {
- // The result can only be prioritized if it is a top ranked result.
- if (prioritySettings.contains(key) && baseRank < BASE_RANKS[1]) {
- return TOP_RANK;
- }
- if (title.length() > LONG_TITLE_LENGTH) {
- return baseRank + 1;
- }
- return baseRank;
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/search/DatabaseIndexingManager.java b/src/com/android/settings/search/DatabaseIndexingManager.java
index 7b9a635..0c02b67 100644
--- a/src/com/android/settings/search/DatabaseIndexingManager.java
+++ b/src/com/android/settings/search/DatabaseIndexingManager.java
@@ -18,10 +18,10 @@
package com.android.settings.search;
-import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_ID;
-import static com.android.settings.search.CursorToSearchResultConverter
+import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_ID;
+import static com.android.settings.search.DatabaseResultLoader
.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
-import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_KEY;
+import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_KEY;
import static com.android.settings.search.DatabaseResultLoader.SELECT_COLUMNS;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.CLASS_NAME;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_ENTRIES;
diff --git a/src/com/android/settings/search/DatabaseResultLoader.java b/src/com/android/settings/search/DatabaseResultLoader.java
index 3b5cc47..7902eef 100644
--- a/src/com/android/settings/search/DatabaseResultLoader.java
+++ b/src/com/android/settings/search/DatabaseResultLoader.java
@@ -43,14 +43,11 @@
};
/**
- * Base ranks defines the best possible rank based on what the query matches.
- * If the query matches the prefix of the first word in the title, the best rank it can be
- * is 1
- * If the query matches the prefix of the other words in the title, the best rank it can be
- * is 3
- * If the query only matches the summary, the best rank it can be is 7
- * If the query only matches keywords or entries, the best rank it can be is 9
+ * These indices are used to match the columns of the this loader's SELECT statement.
+ * These are not necessarily the same order nor similar coverage as the schema defined in
+ * IndexDatabaseHelper
*/
- public static final int[] BASE_RANKS = {1, 3, 7, 9};
-
+ public static final int COLUMN_INDEX_ID = 0;
+ public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 8;
+ public static final int COLUMN_INDEX_KEY = 10;
}
\ No newline at end of file
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index 2b25512..55235a4 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -22,6 +22,7 @@
import com.android.settings.DisplaySettings;
import com.android.settings.LegalSettings;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
+import com.android.settings.datausage.DataUsageSummaryLegacy;
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
@@ -112,6 +113,7 @@
addIndex(BluetoothSettings.class);
addIndex(SimSettings.class);
addIndex(DataUsageSummary.class);
+ addIndex(DataUsageSummaryLegacy.class);
addIndex(ScreenZoomSettings.class);
addIndex(DisplaySettings.class);
addIndex(AmbientDisplaySettings.class);
diff --git a/src/com/android/settings/search/SearchResult.java b/src/com/android/settings/search/SearchResult.java
deleted file mode 100644
index d96661a..0000000
--- a/src/com/android/settings/search/SearchResult.java
+++ /dev/null
@@ -1,186 +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.search;
-
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.List;
-
-/**
- * Data class as an interface for all Search Results.
- */
-public class SearchResult implements Comparable<SearchResult> {
-
- private static final String TAG = "SearchResult";
-
- /**
- * Defines the lowest rank for a search result to be considered as ranked. Results with ranks
- * higher than this have no guarantee for sorting order.
- */
- public static final int BOTTOM_RANK = 10;
-
- /**
- * Defines the highest rank for a search result. Used for special search results only.
- */
- public static final int TOP_RANK = 0;
-
- /**
- * The title of the result and main text displayed.
- * Intent Results: Displays as the primary
- */
- public final CharSequence title;
-
- /**
- * Summary / subtitle text
- * Intent Results: Displays the text underneath the title
- */
- final public CharSequence summary;
-
- /**
- * An ordered list of the information hierarchy.
- * Intent Results: Displayed a hierarchy of selections to reach the setting from the home screen
- */
- public final List<String> breadcrumbs;
-
- /**
- * A suggestion for the ranking of the result.
- * Based on Settings Rank:
- * 1 is a near perfect match
- * 9 is the weakest match
- * TODO subject to change
- */
- public final int rank;
-
- /**
- * Identifier for the recycler view adapter.
- */
- @ResultPayload.PayloadType
- public final int viewType;
-
- /**
- * Metadata for the specific result types.
- */
- public final ResultPayload payload;
-
- /**
- * Result's icon.
- */
- public final Drawable icon;
-
- /**
- * Stable id for this object.
- */
- public final int stableId;
-
- protected SearchResult(Builder builder) {
- stableId = builder.mStableId;
- title = builder.mTitle;
- summary = builder.mSummary;
- breadcrumbs = builder.mBreadcrumbs;
- rank = builder.mRank;
- icon = builder.mIcon;
- payload = builder.mResultPayload;
- viewType = payload.getType();
- }
-
- @Override
- public int compareTo(SearchResult searchResult) {
- if (searchResult == null) {
- return -1;
- }
- return this.rank - searchResult.rank;
- }
-
- @Override
- public boolean equals(Object that) {
- if (this == that) {
- return true;
- }
- if (!(that instanceof SearchResult)) {
- return false;
- }
- return this.stableId == ((SearchResult) that).stableId;
- }
-
- @Override
- public int hashCode() {
- return stableId;
- }
-
- public static class Builder {
- protected CharSequence mTitle;
- protected CharSequence mSummary;
- protected List<String> mBreadcrumbs;
- protected int mRank = 42;
- protected ResultPayload mResultPayload;
- protected Drawable mIcon;
- protected int mStableId;
-
- public Builder setTitle(CharSequence title) {
- mTitle = title;
- return this;
- }
-
- public Builder setSummary(CharSequence summary) {
- mSummary = summary;
- return this;
- }
-
- public Builder addBreadcrumbs(List<String> breadcrumbs) {
- mBreadcrumbs = breadcrumbs;
- return this;
- }
-
- public Builder setRank(int rank) {
- if (rank >= 0 && rank <= 9) {
- mRank = rank;
- }
- return this;
- }
-
- public Builder setIcon(Drawable icon) {
- mIcon = icon;
- return this;
- }
-
- public Builder setPayload(ResultPayload payload) {
- mResultPayload = payload;
- return this;
- }
-
- public Builder setStableId(int stableId) {
- mStableId = stableId;
- return this;
- }
-
- public SearchResult build() {
- // Check that all of the mandatory fields are set.
- if (TextUtils.isEmpty(mTitle)) {
- throw new IllegalStateException("SearchResult missing title argument");
- } else if (mStableId == 0) {
- Log.v(TAG, "No stable ID on SearchResult with title: " + mTitle);
- throw new IllegalStateException("SearchResult missing stableId argument");
- } else if (mResultPayload == null) {
- throw new IllegalStateException("SearchResult missing Payload argument");
- }
- return new SearchResult(this);
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
index a9e56f4..55448e2 100644
--- a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
+++ b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
@@ -44,6 +44,11 @@
private Preference mPreference;
+ public VisiblePatternProfilePreferenceController(Context context) {
+ this(context, null /* lifecycle */);
+ }
+
+ // TODO (b/73074893) Replace this constructor without Lifecycle using setter method instead.
public VisiblePatternProfilePreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY_VISIBLE_PATTERN_PROFILE);
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
diff --git a/src/com/android/settings/widget/MasterCheckBoxPreference.java b/src/com/android/settings/widget/MasterCheckBoxPreference.java
index 552f51c..fceeac2 100644
--- a/src/com/android/settings/widget/MasterCheckBoxPreference.java
+++ b/src/com/android/settings/widget/MasterCheckBoxPreference.java
@@ -83,6 +83,7 @@
if (mCheckBox != null) {
mCheckBox.setContentDescription(getTitle());
mCheckBox.setChecked(mChecked);
+ mCheckBox.setEnabled(mEnableCheckBox);
}
}
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index b359bf3..1607b74 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -92,8 +92,6 @@
controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), wifiManager));
controllers.add(new CellularFallbackPreferenceController(context));
controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), wifiManager));
- controllers.add(new WpsPreferenceController(
- context, getLifecycle(), wifiManager, getFragmentManager()));
return controllers;
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index e392b1f..69dc130 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -85,16 +85,12 @@
private static final String TAG = "WifiSettings";
- /* package */ static final int MENU_ID_WPS_PBC = Menu.FIRST;
- private static final int MENU_ID_WPS_PIN = Menu.FIRST + 1;
private static final int MENU_ID_CONNECT = Menu.FIRST + 6;
private static final int MENU_ID_FORGET = Menu.FIRST + 7;
private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
private static final int MENU_ID_WRITE_NFC = Menu.FIRST + 9;
public static final int WIFI_DIALOG_ID = 1;
- /* package */ static final int WPS_PBC_DIALOG_ID = 2;
- private static final int WPS_PIN_DIALOG_ID = 3;
private static final int WRITE_NFC_DIALOG_ID = 6;
// Instance state keys
@@ -464,24 +460,6 @@
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // If the user is not allowed to configure wifi, do not handle menu selections.
- if (mIsRestricted) {
- return false;
- }
-
- switch (item.getItemId()) {
- case MENU_ID_WPS_PBC:
- showDialog(WPS_PBC_DIALOG_ID);
- return true;
- case MENU_ID_WPS_PIN:
- showDialog(WPS_PIN_DIALOG_ID);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
Preference preference = (Preference) view.getTag();
@@ -639,10 +617,6 @@
mSelectedAccessPoint = mDlgAccessPoint;
return mDialog;
- case WPS_PBC_DIALOG_ID:
- return new WpsDialog(getActivity(), WpsInfo.PBC);
- case WPS_PIN_DIALOG_ID:
- return new WpsDialog(getActivity(), WpsInfo.DISPLAY);
case WRITE_NFC_DIALOG_ID:
if (mSelectedAccessPoint != null) {
mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(
@@ -664,10 +638,6 @@
switch (dialogId) {
case WIFI_DIALOG_ID:
return MetricsEvent.DIALOG_WIFI_AP_EDIT;
- case WPS_PBC_DIALOG_ID:
- return MetricsEvent.DIALOG_WIFI_PBC;
- case WPS_PIN_DIALOG_ID:
- return MetricsEvent.DIALOG_WIFI_PIN;
case WRITE_NFC_DIALOG_ID:
return MetricsEvent.DIALOG_WIFI_WRITE_NFC;
default:
diff --git a/src/com/android/settings/wifi/WpsDialog.java b/src/com/android/settings/wifi/WpsDialog.java
deleted file mode 100644
index 440b72d..0000000
--- a/src/com/android/settings/wifi/WpsDialog.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (C) 2012 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.wifi;
-
-import android.app.AlertDialog;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.NetworkInfo;
-import android.net.NetworkInfo.DetailedState;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WpsInfo;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.View;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.android.settings.R;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-
-/**
- * Dialog to show WPS progress.
- */
-public class WpsDialog extends AlertDialog {
-
- private final static String TAG = "WpsDialog";
- private static final String DIALOG_STATE = "android:dialogState";
- private static final String DIALOG_MSG_STRING = "android:dialogMsg";
-
- private View mView;
- private TextView mTextView;
- private ProgressBar mTimeoutBar;
- private ProgressBar mProgressBar;
- private Button mButton;
- private Timer mTimer;
-
- private static final int WPS_TIMEOUT_S = 120;
-
- private WifiManager mWifiManager;
- private WifiManager.WpsCallback mWpsListener;
- private int mWpsSetup;
-
- private final IntentFilter mFilter;
- private BroadcastReceiver mReceiver;
-
- private Context mContext;
- private Handler mHandler = new Handler();
- private String mMsgString = "";
-
- private enum DialogState {
- WPS_INIT,
- WPS_START,
- WPS_COMPLETE,
- CONNECTED, //WPS + IP config is done
- WPS_FAILED
- }
- DialogState mDialogState = DialogState.WPS_INIT;
-
- public WpsDialog(Context context, int wpsSetup) {
- super(context);
- mContext = context;
- mWpsSetup = wpsSetup;
-
- class WpsListener extends WifiManager.WpsCallback {
-
- public void onStarted(String pin) {
- if (pin != null) {
- updateDialog(DialogState.WPS_START, String.format(
- mContext.getString(R.string.wifi_wps_onstart_pin), pin));
- } else {
- updateDialog(DialogState.WPS_START, mContext.getString(
- R.string.wifi_wps_onstart_pbc));
- }
- }
-
- public void onSucceeded() {
- updateDialog(DialogState.WPS_COMPLETE,
- mContext.getString(R.string.wifi_wps_complete));
- }
-
- public void onFailed(int reason) {
- String msg;
- switch (reason) {
- case WifiManager.WPS_OVERLAP_ERROR:
- msg = mContext.getString(R.string.wifi_wps_failed_overlap);
- break;
- case WifiManager.WPS_WEP_PROHIBITED:
- msg = mContext.getString(R.string.wifi_wps_failed_wep);
- break;
- case WifiManager.WPS_TKIP_ONLY_PROHIBITED:
- msg = mContext.getString(R.string.wifi_wps_failed_tkip);
- break;
- case WifiManager.IN_PROGRESS:
- msg = mContext.getString(R.string.wifi_wps_in_progress);
- break;
- default:
- msg = mContext.getString(R.string.wifi_wps_failed_generic);
- break;
- }
- updateDialog(DialogState.WPS_FAILED, msg);
- }
- }
-
- mWpsListener = new WpsListener();
-
-
- mFilter = new IntentFilter();
- mFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
- mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
- mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- handleEvent(context, intent);
- }
- };
- setCanceledOnTouchOutside(false);
- }
-
- @Override
- public Bundle onSaveInstanceState () {
- Bundle bundle = super.onSaveInstanceState();
- bundle.putString(DIALOG_STATE, mDialogState.toString());
- bundle.putString(DIALOG_MSG_STRING, mMsgString.toString());
- return bundle;
- }
-
- @Override
- public void onRestoreInstanceState(Bundle savedInstanceState) {
- if (savedInstanceState != null) {
- super.onRestoreInstanceState(savedInstanceState);
- DialogState dialogState = mDialogState.valueOf(savedInstanceState.getString(DIALOG_STATE));
- String msg = savedInstanceState.getString(DIALOG_MSG_STRING);
- updateDialog(dialogState, msg);
- if (dialogState == DialogState.WPS_START) {
- startWps();
- }
- }
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- mView = getLayoutInflater().inflate(R.layout.wifi_wps_dialog, null);
-
- mTextView = (TextView) mView.findViewById(R.id.wps_dialog_txt);
- mTextView.setText(R.string.wifi_wps_setup_msg);
-
- mTimeoutBar = ((ProgressBar) mView.findViewById(R.id.wps_timeout_bar));
- mTimeoutBar.setMax(WPS_TIMEOUT_S);
- mTimeoutBar.setProgress(0);
-
- mProgressBar = ((ProgressBar) mView.findViewById(R.id.wps_progress_bar));
- mProgressBar.setVisibility(View.GONE);
-
- mButton = ((Button) mView.findViewById(R.id.wps_dialog_btn));
- mButton.setText(R.string.wifi_cancel);
- mButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dismiss();
- }
- });
-
- mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
-
- setView(mView);
- if (savedInstanceState == null) {
- startWps();
- }
- super.onCreate(savedInstanceState);
- }
-
- @Override
- protected void onStart() {
- /*
- * increment timeout bar per second.
- */
- mTimer = new Timer(false);
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- mHandler.post(new Runnable() {
-
- @Override
- public void run() {
- mTimeoutBar.incrementProgressBy(1);
- }
- });
- }
- }, 1000, 1000);
-
- mContext.registerReceiver(mReceiver, mFilter);
-
- }
-
- @Override
- protected void onStop() {
- if (mDialogState != DialogState.WPS_COMPLETE) {
- mWifiManager.cancelWps(null);
- }
-
- if (mReceiver != null) {
- mContext.unregisterReceiver(mReceiver);
- mReceiver = null;
- }
-
- if (mTimer != null) {
- mTimer.cancel();
- }
- }
-
- private void updateDialog(final DialogState state, final String msg) {
- if (mDialogState.ordinal() >= state.ordinal()) {
- //ignore.
- return;
- }
- mDialogState = state;
- mMsgString = msg;
-
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- switch(state) {
- case WPS_COMPLETE:
- mTimeoutBar.setVisibility(View.GONE);
- mProgressBar.setVisibility(View.VISIBLE);
- break;
- case CONNECTED:
- case WPS_FAILED:
- mButton.setText(mContext.getString(R.string.dlg_ok));
- mTimeoutBar.setVisibility(View.GONE);
- mProgressBar.setVisibility(View.GONE);
- if (mReceiver != null) {
- mContext.unregisterReceiver(mReceiver);
- mReceiver = null;
- }
- break;
- }
- mTextView.setText(msg);
- }
- });
- }
-
- private void handleEvent(Context context, Intent intent) {
- String action = intent.getAction();
- if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
- final int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
- WifiManager.WIFI_STATE_UNKNOWN);
- if (state == WifiManager.WIFI_STATE_DISABLED) {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- String msg = mContext.getString(R.string.wifi_wps_failed_wifi_disconnected);
- updateDialog(DialogState.WPS_FAILED, msg);
- }
- } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
- NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
- WifiManager.EXTRA_NETWORK_INFO);
- final NetworkInfo.DetailedState state = info.getDetailedState();
- if (state == DetailedState.CONNECTED &&
- mDialogState == DialogState.WPS_COMPLETE) {
- WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
- if (wifiInfo != null) {
- String msg = String.format(mContext.getString(
- R.string.wifi_wps_connected), wifiInfo.getSSID());
- updateDialog(DialogState.CONNECTED, msg);
- }
- }
- }
- }
-
- private void startWps() {
- WpsInfo wpsConfig = new WpsInfo();
- wpsConfig.setup = mWpsSetup;
- mWifiManager.startWps(wpsConfig, mWpsListener);
- }
-}
diff --git a/src/com/android/settings/wifi/WpsPreferenceController.java b/src/com/android/settings/wifi/WpsPreferenceController.java
deleted file mode 100644
index f636593..0000000
--- a/src/com/android/settings/wifi/WpsPreferenceController.java
+++ /dev/null
@@ -1,155 +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.wifi;
-
-import android.app.Dialog;
-import android.app.FragmentManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WpsInfo;
-import android.os.Bundle;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-
-/**
- * {@link PreferenceControllerMixin} that shows Dialog for WPS progress. Disabled when Wi-Fi is off.
- */
-public class WpsPreferenceController extends AbstractPreferenceController
- implements PreferenceControllerMixin, LifecycleObserver, OnPause, OnResume {
-
- private static final String KEY_WPS_PUSH = "wps_push_button";
- private static final String KEY_WPS_PIN = "wps_pin_entry";
-
- private final WifiManager mWifiManager;
- private final FragmentManager mFragmentManager;
- @VisibleForTesting
- final BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- togglePreferences();
- }
- };
- private final IntentFilter mFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
-
- private Preference mWpsPushPref;
- private Preference mWpsPinPref;
-
- public WpsPreferenceController(
- Context context,
- Lifecycle lifecycle,
- WifiManager wifiManager,
- FragmentManager fragmentManager) {
- super(context);
- mWifiManager = wifiManager;
- mFragmentManager = fragmentManager;
- lifecycle.addObserver(this);
- }
-
- @Override
- public boolean isAvailable() {
- // Always show preference.
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- // Returns null because this controller contains more than 1 preference.
- return null;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mWpsPushPref = screen.findPreference(KEY_WPS_PUSH);
- mWpsPinPref = screen.findPreference(KEY_WPS_PIN);
- if (mWpsPushPref == null || mWpsPinPref == null) {
- return;
- }
- // WpsDialog: Create the dialog like WifiSettings does.
- mWpsPushPref.setOnPreferenceClickListener((arg) -> {
- WpsFragment wpsFragment = new WpsFragment(WpsInfo.PBC);
- wpsFragment.show(mFragmentManager, KEY_WPS_PUSH);
- return true;
- }
- );
-
- // WpsDialog: Create the dialog like WifiSettings does.
- mWpsPinPref.setOnPreferenceClickListener((arg) -> {
- WpsFragment wpsFragment = new WpsFragment(WpsInfo.DISPLAY);
- wpsFragment.show(mFragmentManager, KEY_WPS_PIN);
- return true;
- });
- togglePreferences();
- }
-
- @Override
- public void onResume() {
- mContext.registerReceiver(mReceiver, mFilter);
- }
-
- @Override
- public void onPause() {
- mContext.unregisterReceiver(mReceiver);
- }
-
- private void togglePreferences() {
- if (mWpsPushPref != null && mWpsPinPref != null) {
- boolean enabled = mWifiManager.isWifiEnabled();
- mWpsPushPref.setEnabled(enabled);
- mWpsPinPref.setEnabled(enabled);
- }
- }
-
- /**
- * Fragment for Dialog to show WPS progress.
- */
- public static class WpsFragment extends InstrumentedDialogFragment {
- private static int mWpsSetup;
-
- // Public default constructor is required for rotation.
- public WpsFragment() {
- super();
- }
-
- public WpsFragment(int wpsSetup) {
- super();
- mWpsSetup = wpsSetup;
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.DIALOG_WPS_SETUP;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new WpsDialog(getActivity(), mWpsSetup);
- }
- }
-}
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index ece35fb..5a3c044 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -15,7 +15,6 @@
com.android.settings.inputmethod.UserDictionaryList
com.android.settings.datausage.DataSaverSummary
com.android.settings.datausage.AppDataUsage
-com.android.settings.datausage.DataPlanUsageSummary
com.android.settings.accessibility.FontSizePreferenceFragmentForSetupWizard
com.android.settings.applications.ManageDomainUrls
com.android.settings.applications.appinfo.WriteSettingsDetails
@@ -72,4 +71,4 @@
com.android.settings.ApnEditor
com.android.settings.UserCredentialsSettings
com.android.settings.TestingSettings
-com.android.settings.applications.DirectoryAccessDetails
\ No newline at end of file
+com.android.settings.applications.DirectoryAccessDetails
diff --git a/tests/robotests/assets/grandfather_slice_controller_not_in_xml b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
new file mode 100644
index 0000000..f11027e
--- /dev/null
+++ b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
@@ -0,0 +1 @@
+com.android.settings.testutils.FakeToggleController
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
deleted file mode 100644
index 9ddce53..0000000
--- a/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
+++ /dev/null
@@ -1,122 +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.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.DonutView;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
- shadows = {
- SettingsShadowResources.class,
- SettingsShadowResources.SettingsShadowTheme.class
- }
-)
-public final class DataPlanSummaryPreferenceTest {
-
- private static final String TEST_PLAN_USAGE = "Test plan usage";
- private static final String TEST_PLAN_NAME = "Test plan name";
- private static final String TEST_PLAN_DESCRIPTION = "Test plan description";
- private static int sPlanUsageTextColor;
- private static int sMeterBackgroundColor;
- private static int sMeterConsumedColor;
-
- @BeforeClass
- public static void beforeClass() {
- sPlanUsageTextColor = Color.parseColor("#FF5C94F1");
- sMeterBackgroundColor = Color.parseColor("#FFDBDCDC");
- sMeterConsumedColor = Color.parseColor("#FF5C94F1");
- }
-
- private DataPlanSummaryPreference mPreference;
- private PreferenceViewHolder mHolder;
-
- @Before
- public void setUp() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.string.config_headlineFontFamily, "");
- Context context = RuntimeEnvironment.application;
- mPreference = new DataPlanSummaryPreference(context);
- LayoutInflater inflater = LayoutInflater.from(context);
- View view = inflater.inflate(mPreference.getLayoutResource(),
- new LinearLayout(context), false);
- mHolder = PreferenceViewHolder.createInstanceForTests(view);
- }
-
- @After
- public void tearDown() {
- SettingsShadowResources.reset();
- }
-
- @Test
- public void shouldRender_withoutData() {
- mPreference.onBindViewHolder(mHolder);
-
- TextView planUsageTextView = (TextView) mHolder.findViewById(android.R.id.title);
- assertThat(planUsageTextView.getText().toString()).isEmpty();
- TextView planNameTextView = (TextView) mHolder.findViewById(android.R.id.text1);
- assertThat(planNameTextView.getText().toString()).isEmpty();
- TextView planDescriptionTextView = (TextView) mHolder.findViewById(android.R.id.text2);
- assertThat(planDescriptionTextView.getText().toString()).isEmpty();
- }
-
- @Test
- public void shouldRender_withData() {
- mPreference.setTitle(TEST_PLAN_USAGE);
- mPreference.setUsageTextColor(sPlanUsageTextColor);
- mPreference.setName(TEST_PLAN_NAME);
- mPreference.setDescription(TEST_PLAN_DESCRIPTION);
- mPreference.setPercentageUsage(0.25D);
- mPreference.setMeterBackgroundColor(sMeterBackgroundColor);
- mPreference.setMeterConsumedColor(sMeterConsumedColor);
-
- mPreference.onBindViewHolder(mHolder);
-
- TextView planUsageTextView = (TextView) mHolder.findViewById(android.R.id.title);
- assertThat(planUsageTextView.getTextColors().getDefaultColor())
- .isEqualTo(sPlanUsageTextColor);
- assertThat(planUsageTextView.getText()).isEqualTo(TEST_PLAN_USAGE);
-
- TextView planNameTextView = (TextView) mHolder.findViewById(android.R.id.text1);
- assertThat(planNameTextView.getText()).isEqualTo(TEST_PLAN_NAME);
-
- TextView planDescriptionTextView = (TextView) mHolder.findViewById(android.R.id.text2);
- assertThat(planDescriptionTextView.getText()).isEqualTo(TEST_PLAN_DESCRIPTION);
-
- DonutView donutView = (DonutView) mHolder.findViewById(R.id.donut);
- assertThat(donutView.getMeterBackgroundColor()).isEqualTo(sMeterBackgroundColor);
- assertThat(donutView.getMeterConsumedColor()).isEqualTo(sMeterConsumedColor);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
deleted file mode 100644
index 748c317..0000000
--- a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
+++ /dev/null
@@ -1,133 +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.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkPolicy;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.NetworkPolicyEditor;
-import java.util.ArrayList;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class DataPlanUsageSummaryTest {
- @Mock
- private ConnectivityManager mManager;
-
- private Context mContext;
- private DataPlanUsageSummary mDataUsageSummary;
- private NetworkPolicyEditor mPolicyEditor;
- private WifiConfiguration mWifiConfiguration;
- private NetworkPolicy mNetworkPolicy;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- ShadowApplication shadowContext = ShadowApplication.getInstance();
- shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
- mContext = shadowContext.getApplicationContext();
- when(mManager.isNetworkSupported(anyInt())).thenReturn(true);
- }
-
- @Test
- public void testUpdateNetworkRestrictionSummary_shouldSetSummary() {
- mDataUsageSummary = spy(new DataPlanUsageSummary());
- NetworkRestrictionsPreference preference = mock(NetworkRestrictionsPreference.class);
- mPolicyEditor = mock(NetworkPolicyEditor.class);
- WifiManager wifiManager = mock(WifiManager.class);
- ReflectionHelpers.setField(mDataUsageSummary, "mPolicyEditor", mPolicyEditor);
- ReflectionHelpers.setField(mDataUsageSummary, "mWifiManager", wifiManager);
- when(wifiManager.getConfiguredNetworks()).thenReturn(new ArrayList<>());
- doReturn(mContext.getResources()).when(mDataUsageSummary).getResources();
-
- mDataUsageSummary.updateNetworkRestrictionSummary(preference);
-
- verify(preference).setSummary(mContext.getResources().getQuantityString(
- R.plurals.network_restrictions_summary, 0, 0));
- }
-
- @Test
- public void testIsMetered_noSsid_shouldReturnFalse() {
- initTest();
-
- assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse();
- }
-
- @Test
- public void testIsMetered_noNetworkPolicy_shouldReturnFalse() {
- initTest();
- mWifiConfiguration.SSID = "network1";
- doReturn(null).when(mPolicyEditor).getPolicyMaybeUnquoted(any());
-
- assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse();
- }
-
- @Test
- public void testIsMetered_policyHasLimit_shouldReturnTrue() {
- initTest();
- mWifiConfiguration.SSID = "network1";
- mNetworkPolicy = mock(NetworkPolicy.class);
- mNetworkPolicy.limitBytes = 100;
- doReturn(mNetworkPolicy).when(mPolicyEditor).getPolicyMaybeUnquoted(any());
-
- assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isTrue();
- }
-
- @Test
- public void testIsMetered_noPolicyLimit_shouldReturnMeteredValue() {
- initTest();
- mWifiConfiguration.SSID = "network1";
- mNetworkPolicy = mock(NetworkPolicy.class);
- mNetworkPolicy.limitBytes = NetworkPolicy.LIMIT_DISABLED;
- doReturn(mNetworkPolicy).when(mPolicyEditor).getPolicyMaybeUnquoted(any());
-
- mNetworkPolicy.metered = true;
- assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isTrue();
-
- mNetworkPolicy.metered = false;
- assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse();
- }
-
- private void initTest() {
- mDataUsageSummary = new DataPlanUsageSummary();
- mPolicyEditor = mock(NetworkPolicyEditor.class);
- ReflectionHelpers.setField(mDataUsageSummary, "mPolicyEditor", mPolicyEditor);
- mWifiConfiguration = mock(WifiConfiguration.class);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
deleted file mode 100644
index ba2d5f1..0000000
--- a/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
+++ /dev/null
@@ -1,66 +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.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class DataPlansSyncTimePreferenceTest {
- private static final String SYNC_TIME = "Today 12:24pm";
-
- private Preference mPreference;
- private PreferenceViewHolder mHolder;
-
- @Before
- public void setUp() {
- Context context = RuntimeEnvironment.application;
- mPreference = new Preference(context);
- mPreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
-
- LayoutInflater inflater = LayoutInflater.from(context);
- View view = inflater.inflate(mPreference.getLayoutResource(),
- new LinearLayout(context), false);
- mHolder = PreferenceViewHolder.createInstanceForTests(view);
- }
-
- @Test
- public void shouldRender_withData() {
- mPreference.setTitle(SYNC_TIME);
-
- mPreference.onBindViewHolder(mHolder);
-
- TextView syncTimeTextView = (TextView) mHolder.findViewById(android.R.id.title);
- assertThat(syncTimeTextView.getText()).isEqualTo(SYNC_TIME);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryLegacyTest.java
new file mode 100644
index 0000000..ad1defb
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryLegacyTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2016 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.datausage;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settingslib.NetworkPolicyEditor;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DataUsageSummaryLegacyTest {
+ @Mock
+ private ConnectivityManager mManager;
+ private Context mContext;
+
+ /**
+ * This set up is contrived to get a passing test so that the build doesn't block without tests.
+ * These tests should be updated as code gets refactored to improve testability.
+ */
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowContext = ShadowApplication.getInstance();
+ shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
+ mContext = shadowContext.getApplicationContext();
+ when(mManager.isNetworkSupported(anyInt())).thenReturn(true);
+ }
+
+ @Test
+ @Config(shadows = {
+ SettingsShadowResources.class,
+ SettingsShadowResources.SettingsShadowTheme.class
+ })
+ public void formatUsage_shouldLookLikeFormatFileSize() {
+ SettingsShadowResources.overrideResource(com.android.internal.R.string.fileSizeSuffix,
+ "%1$s %2$s");
+ final long usage = 2147483648L; // 2GB
+ final String formattedUsage =
+ DataUsageSummaryLegacy.formatUsage(mContext, "^1", usage).toString();
+ final String formattedAsFileSize = Formatter.formatFileSize(mContext, usage);
+ assertThat(formattedUsage).isEqualTo(formattedAsFileSize);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
new file mode 100644
index 0000000..ea1d29b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkTemplate;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.net.DataUsageController;
+
+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.concurrent.TimeUnit;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DataUsageSummaryPreferenceControllerTest {
+ private static final long UPDATE_BACKOFF_MS = TimeUnit.MINUTES.toMillis(13);
+ private static final long CYCLE_BACKOFF_MS = TimeUnit.DAYS.toMillis(6);
+ private static final long CYCLE_LENGTH_MS = TimeUnit.DAYS.toMillis(30);
+ private static final long USAGE1 = 373000000L;
+ private static final long LIMIT1 = 1000000000L;
+ private static final String CARRIER_NAME = "z-mobile";
+ private static final String PERIOD = "Feb";
+
+ @Mock
+ private DataUsageController mDataUsageController;
+ @Mock
+ private DataUsageInfoController mDataInfoController;
+ @Mock
+ private DataUsageSummaryPreference mSummaryPreference;
+ @Mock
+ private NetworkPolicyEditor mPolicyEditor;
+ @Mock
+ private NetworkTemplate mNetworkTemplate;
+
+ private Context mContext;
+ private DataUsageSummaryPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+
+ mController = new DataUsageSummaryPreferenceController(
+ mContext,
+ mDataUsageController,
+ mDataInfoController,
+ mNetworkTemplate,
+ mPolicyEditor,
+ R.string.cell_data_template,
+ true,
+ null);
+ }
+
+ @Test
+ public void testSummaryUpdate_onePlan_basic() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+ final Intent intent = new Intent();
+
+ when(mDataUsageController.getDataUsageInfo()).thenReturn(info);
+ mController.setPlanValues(1 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+ mController.updateState(mSummaryPreference);
+ verify(mSummaryPreference).setLimitInfo(null);
+ verify(mSummaryPreference).setUsageInfo(info.cycleEnd, now - UPDATE_BACKOFF_MS,
+ CARRIER_NAME, 1 /* numPlans */, intent);
+ verify(mSummaryPreference).setChartEnabled(true);
+ }
+
+ @Test
+ public void testSummaryUpdate_noPlan_basic() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+ final Intent intent = new Intent();
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+ mController.updateState(mSummaryPreference);
+ verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+ verify(mSummaryPreference).setUsageInfo(info.cycleEnd, now - UPDATE_BACKOFF_MS,
+ CARRIER_NAME, 0 /* numPlans */, intent);
+ verify(mSummaryPreference).setChartEnabled(true);
+ }
+
+ @Test
+ public void testSummaryUpdate_noCarrier_basic() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(null /* carrierName */, -1L /* snapshotTime */,
+ info.cycleEnd, null /* intent */);
+ mController.updateState(mSummaryPreference);
+
+ verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+ verify(mSummaryPreference).setUsageInfo(
+ info.cycleEnd,
+ -1L /* snapshotTime */,
+ null /* carrierName */,
+ 0 /* numPlans */,
+ null /* launchIntent */);
+ verify(mSummaryPreference).setChartEnabled(true);
+ }
+
+ @Test
+ public void testSummaryUpdate_noPlanData_basic() {
+ final long now = System.currentTimeMillis();
+
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, -1L /* dataPlanSize */, USAGE1);
+ mController.setCarrierValues(null /* carrierName */, -1L /* snapshotTime */,
+ info.cycleEnd, null /* intent */);
+ mController.updateState(mSummaryPreference);
+
+ verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+ verify(mSummaryPreference).setUsageInfo(
+ info.cycleEnd,
+ -1L /* snapshotTime */,
+ null /* carrierName */,
+ 0 /* numPlans */,
+ null /* launchIntent */);
+ verify(mSummaryPreference).setChartEnabled(false);
+ }
+
+ private DataUsageController.DataUsageInfo createTestDataUsageInfo(long now) {
+ DataUsageController.DataUsageInfo info = new DataUsageController.DataUsageInfo();
+ info.carrier = CARRIER_NAME;
+ info.period = PERIOD;
+ info.startDate = now;
+ info.limitLevel = LIMIT1;
+ info.warningLevel = LIMIT1 >> 1;
+ info.usageLevel = USAGE1;
+ info.cycleStart = now - CYCLE_BACKOFF_MS;
+ info.cycleEnd = info.cycleStart + CYCLE_LENGTH_MS;
+ return info;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
new file mode 100644
index 0000000..769d9e7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settingslib.utils.StringUtil;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
+ SettingsShadowResourcesImpl.class)
+public class DataUsageSummaryPreferenceTest {
+ private static final long CYCLE_DURATION_MILLIS = 1000000000L;
+ private static final long UPDATE_LAG_MILLIS = 10000000L;
+ private static final String DUMMY_CARRIER = "z-mobile";
+
+ private Context mContext;
+ private PreferenceViewHolder mHolder;
+ private DataUsageSummaryPreference mSummaryPreference;
+ private TextView mUsageTitle;
+ private TextView mCycleTime;
+ private TextView mCarrierInfo;
+ private TextView mDataLimits;
+ private Button mLaunchButton;
+
+ private long mCycleEnd;
+ private long mUpdateTime;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mSummaryPreference = new DataUsageSummaryPreference(mContext, null /* attrs */);
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ View view = inflater.inflate(mSummaryPreference.getLayoutResource(), null /* root */,
+ false /* attachToRoot */);
+
+ mHolder = PreferenceViewHolder.createInstanceForTests(view);
+
+ final long now = System.currentTimeMillis();
+ mCycleEnd = now + CYCLE_DURATION_MILLIS;
+ mUpdateTime = now - UPDATE_LAG_MILLIS;
+ }
+
+ @Test
+ public void testSetUsageInfo_withLaunchIntent_launchButtonShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void testSetUsageInfo_withoutLaunchIntent_launchButtonNotShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ null /* launchIntent */);
+
+ bindViewHolder();
+ assertThat(mLaunchButton.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testSetUsageInfo_withDataPlans_carrierInfoShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 1 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void testSetUsageInfo_withNoDataPlans_carrierInfoNotShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testSetUsageInfo_withNoDataPlans_usageTitleNotShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mUsageTitle.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testSetUsageInfo_withMultipleDataPlans_usageTitleShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 2 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mUsageTitle.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void testSetUsageInfo_cycleRemainingTimeShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+ String cyclePrefix = StringUtil.formatElapsedTime(mContext, CYCLE_DURATION_MILLIS,
+ false /* withSeconds */).toString();
+ String text = mContext.getString(R.string.cycle_left_time_text, cyclePrefix);
+
+ bindViewHolder();
+ assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mCycleTime.getText()).isEqualTo(text);
+ }
+
+ @Test
+ public void testSetLimitInfo_withLimitInfo_dataLimitsShown() {
+ final String limitText = "test limit text";
+ mSummaryPreference.setLimitInfo(limitText);
+
+ bindViewHolder();
+ assertThat(mDataLimits.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mDataLimits.getText()).isEqualTo(limitText);
+ }
+
+ @Test
+ public void testSetLimitInfo_withNullLimitInfo_dataLimitsNotShown() {
+ mSummaryPreference.setLimitInfo(null);
+
+ bindViewHolder();
+ assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ private void bindViewHolder() {
+ mSummaryPreference.onBindViewHolder(mHolder);
+ mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
+ mCycleTime = (TextView) mHolder.findViewById(R.id.cycle_left_time);
+ mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
+ mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
+ mLaunchButton = (Button) mHolder.findViewById(R.id.launch_mdp_app_button);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
deleted file mode 100644
index 6eff393..0000000
--- a/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
+++ /dev/null
@@ -1,62 +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.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class ManageDataPlansPreferenceTest {
- private Preference mPreference;
- private PreferenceViewHolder mHolder;
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mPreference = new Preference(mContext);
- mPreference.setLayoutResource(R.layout.manage_data_plans_preference);
- LayoutInflater inflater = LayoutInflater.from(mContext);
- View view = inflater.inflate(mPreference.getLayoutResource(),
- new LinearLayout(mContext), false);
- mHolder = PreferenceViewHolder.createInstanceForTests(view);
- }
-
- @Test
- public void shouldRender_withData() {
- mPreference.onBindViewHolder(mHolder);
- Button managePlanButton = (Button) mHolder.findViewById(R.id.manage_data_plans);
- assertThat(managePlanButton.getText())
- .isEqualTo(mContext.getString(R.string.data_plan_usage_manage_plans_button_text));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
index a814989..cee84de 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
@@ -220,4 +220,9 @@
assertThat(mPreferenceController.isAvailable()).isFalse();
}
+
+ @Test
+ public void testNeverUseFakeData() {
+ assertThat(BatteryAppListPreferenceController.USE_FAKE_DATA).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
index 25dba80..d3863db 100644
--- a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
@@ -16,6 +16,7 @@
package com.android.settings.notification;
+import static android.app.Notification.VISIBILITY_PRIVATE;
import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_MIN;
@@ -114,14 +115,14 @@
}
@Test
- public void testNoCrashIfNoOnResume() throws Exception {
+ public void testNoCrashIfNoOnResume() {
mController.isAvailable();
mController.updateState(mock(RestrictedListPreference.class));
mController.onPreferenceChange(mock(RestrictedListPreference.class), true);
}
@Test
- public void testIsAvailable_notSecure() throws Exception {
+ public void testIsAvailable_notSecure() {
when(mLockUtils.isSecure(anyInt())).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
@@ -130,7 +131,7 @@
}
@Test
- public void testIsAvailable_notIfNotImportant() throws Exception {
+ public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
mController.onResume(appRow, channel, null, null);
@@ -138,7 +139,7 @@
}
@Test
- public void testIsAvailable() throws Exception {
+ public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
@@ -151,7 +152,7 @@
}
@Test
- public void testUpdateState_disabledByAdmin_disableSecure() throws Exception {
+ public void testUpdateState_disabledByAdmin_disableSecure() {
ShadowRestrictionUtils.setRestricted(true);
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
@@ -173,7 +174,7 @@
}
@Test
- public void testUpdateState_disabledByAdmin_disableUnredacted() throws Exception {
+ public void testUpdateState_disabledByAdmin_disableUnredacted() {
ShadowRestrictionUtils.setRestricted(true);
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
@@ -195,7 +196,7 @@
}
@Test
- public void testUpdateState_noLockScreenNotificationsGlobally() throws Exception {
+ public void testUpdateState_noLockScreenNotificationsGlobally() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
@@ -211,10 +212,14 @@
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
assertFalse(toStringList(argumentCaptor.getValue())
.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
+ assertFalse(toStringList(argumentCaptor.getValue())
+ .contains(String.valueOf(VISIBILITY_PRIVATE)));
}
@Test
- public void testUpdateState_noPrivateLockScreenNotificationsGlobally() throws Exception {
+ public void testUpdateState_noPrivateLockScreenNotificationsGlobally() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
@@ -228,12 +233,13 @@
ArgumentCaptor<CharSequence[]> argumentCaptor =
ArgumentCaptor.forClass(CharSequence[].class);
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
+ assertEquals(2, toStringList(argumentCaptor.getValue()).size());
assertFalse(toStringList(argumentCaptor.getValue())
.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
}
@Test
- public void testUpdateState_noGlobalRestriction() throws Exception {
+ public void testUpdateState_noGlobalRestriction() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
mController.onResume(appRow, channel, null, null);
@@ -247,7 +253,7 @@
List<String> values = toStringList(argumentCaptor.getValue());
assertEquals(3, values.size());
assertTrue(values.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
- assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_PRIVATE)));
+ assertTrue(values.contains(String.valueOf(VISIBILITY_PRIVATE)));
assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_SECRET)));
}
@@ -260,7 +266,7 @@
}
@Test
- public void testUpdateState_noChannelOverride() throws Exception {
+ public void testUpdateState_noChannelOverride() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
@@ -275,11 +281,11 @@
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
verify(pref, times(1)).setValue(argumentCaptor.capture());
- assertEquals(String.valueOf(Notification.VISIBILITY_PRIVATE), argumentCaptor.getValue());
+ assertEquals(String.valueOf(VISIBILITY_PRIVATE), argumentCaptor.getValue());
}
@Test
- public void testUpdateState_channelOverride() throws Exception {
+ public void testUpdateState_channelOverride() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
@@ -310,7 +316,7 @@
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
- mController.onPreferenceChange(pref, String.valueOf(Notification.VISIBILITY_PRIVATE));
+ mController.onPreferenceChange(pref, String.valueOf(VISIBILITY_PRIVATE));
assertEquals(VISIBILITY_NO_OVERRIDE, channel.getLockscreenVisibility());
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
diff --git a/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java b/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
index 6c6d7ab..260e3ae 100644
--- a/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
+++ b/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
@@ -137,7 +137,6 @@
final List<String> nonIndexableKeys = provider
.getNonIndexableKeys(RuntimeEnvironment.application);
- assertThat(nonIndexableKeys).containsAllOf("status_header", "limit_summary",
- "restrict_background");
+ assertThat(nonIndexableKeys).contains("status_header");
}
}
diff --git a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
deleted file mode 100644
index a1cafc5..0000000
--- a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
+++ /dev/null
@@ -1,347 +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.search;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.graphics.drawable.Drawable;
-
-import com.android.settings.DisplaySettings;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.gestures.SwipeToNotificationSettings;
-import com.android.settings.search.ResultPayload.Availability;
-import com.android.settings.search.ResultPayload.PayloadType;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wifi.WifiSettings;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class CursorToSearchResultConverterTest {
-
- private static final List<String> TITLES = Arrays.asList("title1", "title2", "title3");
- private static final String SUMMARY = "summary";
- private static final String TARGET_PACKAGE = "a.b.c";
- private static final String TARGET_CLASS = "a.b.c.class";
- private static final String KEY = "key";
- private static final int ICON = R.drawable.ic_search_24dp;
- private static final int BASE_RANK = 1;
- private static Intent sIntent;
-
- @BeforeClass
- public static void beforeClass() {
- sIntent = new Intent("com.android.settings");
- }
-
- private Drawable mDrawable;
- private CursorToSearchResultConverter mConverter;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- Context context = Robolectric.buildActivity(Activity.class).get();
- mDrawable = context.getDrawable(ICON);
- mConverter = new CursorToSearchResultConverter(context);
- }
-
- @Test
- public void testParseCursor_MatchesIcon() {
- final MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
- final byte[] payload = ResultPayloadUtils.marshall(new ResultPayload(sIntent));
- final String BLANK = "";
- cursor.addRow(new Object[] {
- KEY.hashCode(), // Doc ID
- "Longer than 20 characters", // Title
- SUMMARY, // Summary on
- SUMMARY, // summary off
- DisplaySettings.class.getName(),
- BLANK, // screen title
- ICON, // icon
- BLANK, // action
- null, // target package
- BLANK, // target class
- KEY, // Key
- PayloadType.INTENT, // Payload Type
- payload // Payload
- });
-
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- Drawable resultDrawable = result.icon;
- assertThat(resultDrawable).isNotNull();
- assertThat(resultDrawable.toString()).isEqualTo(mDrawable.toString());
- }
- }
-
- @Test
- public void testParseCursor_NoIcon() {
- final Set<SearchResult> results = mConverter.convertCursor(
- getDummyCursor("noIcon" /* key */, "" /* className */), BASE_RANK);
- for (SearchResult result : results) {
- assertThat(result.icon).isNull();
- }
- }
-
- @Test
- public void testParseCursor_MatchesPayloadType() {
- final Set<SearchResult> results = mConverter.convertCursor(getDummyCursor(), BASE_RANK);
- ResultPayload payload;
- for (SearchResult result : results) {
- payload = result.payload;
- assertThat(payload.getType()).isEqualTo(PayloadType.INTENT);
- }
- }
-
- @Test
- public void testLongTitle_PenalizedInRank() {
- final MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
- final byte[] payload = ResultPayloadUtils.marshall(new ResultPayload(sIntent));
- final String BLANK = "";
- cursor.addRow(new Object[] {
- KEY.hashCode(), // Doc ID
- "Longer than 20 characters", // Title
- SUMMARY, // Summary on
- SUMMARY, // summary off
- DisplaySettings.class.getName(),
- BLANK, // screen title
- null, // icon
- BLANK, // action
- null, // target package
- BLANK, // target class
- KEY, // Key
- PayloadType.INTENT, // Payload Type
- payload // Payload
- });
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(BASE_RANK + 1);
- }
- }
-
- @Test
- public void testParseCursor_MatchesResultPayload() {
- final Set<SearchResult> results = mConverter.convertCursor(getDummyCursor(), BASE_RANK);
- ResultPayload payload;
- for (SearchResult result : results) {
- payload = result.payload;
- Intent intent = payload.getIntent();
- assertThat(intent.getAction()).isEqualTo(sIntent.getAction());
- }
- }
-
-
- @Test
- public void testParseCursor_MatchesInlineSwitchPayload() {
- MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
- final String BLANK = "";
- final String uri = "test.com";
- final int type = ResultPayload.PayloadType.INLINE_SWITCH;
- final int source = ResultPayload.SettingsSource.SECURE;
- final String intentKey = "key";
- final String intentVal = "value";
- final Intent intent = new Intent();
- intent.putExtra(intentKey, intentVal);
- final InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1 /* onValue */,
- intent, true /* isDeviceSupported */, 0 /* defautValue */);
-
- cursor.addRow(new Object[] {
- KEY.hashCode(), // Doc ID
- TITLES.get(0), // Title
- SUMMARY, // Summary on
- SUMMARY, // summary off
- SwipeToNotificationSettings.class.getName(),
- BLANK, // screen title
- null, // icon
- BLANK, // action
- null, // target package
- BLANK, // target class
- KEY, // Key
- type, // Payload Type
- ResultPayloadUtils.marshall(payload) // Payload
- });
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- final InlineSwitchPayload newPayload = (InlineSwitchPayload) result.payload;
- final Intent rebuiltIntent = newPayload.getIntent();
- assertThat(newPayload.getKey()).isEqualTo(uri);
- assertThat(newPayload.getType()).isEqualTo(type);
- assertThat(newPayload.mSettingSource).isEqualTo(source);
- assertThat(newPayload.isStandard()).isTrue();
- assertThat(newPayload.getAvailability()).isEqualTo(Availability.AVAILABLE);
- assertThat(rebuiltIntent.getStringExtra(intentKey)).isEqualTo(intentVal);
- }
- }
-
- // The following tests are temporary, and should be removed when we replace the Search
- // White-list solution for elevating ranking.
-
- @Test
- public void testWifiKey_PrioritizedResult() {
- final String key = "main_toggle_wifi";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testBluetoothKey_PrioritizedResult() {
- final String key = "main_toggle_bluetooth";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testAirplaneKey_PrioritizedResult() {
- final String key = "toggle_airplane";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testHotspotKey_PrioritizedResult() {
- final String key = "tether_settings";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testBatterySaverKey_PrioritizedResult() {
- final String key = "battery_saver";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testNFCKey_PrioritizedResult() {
- final String key = "toggle_nfc";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testDataSaverKey_PrioritizedResult() {
- final String key = "restrict_background";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testDataUsageKey_PrioritizedResult() {
- final String key = "data_usage_enable";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- @Test
- public void testRoamingKey_PrioritizedResult() {
- final String key = "button_roaming_key";
- final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
- final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
- for (SearchResult result : results) {
- assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
- }
- }
-
- // End of temporary tests
-
- private MatrixCursor getDummyCursor() {
- String[] keys = new String[] {KEY + "1", KEY + "2", KEY + "3"};
- return getDummyCursor(keys, "" /* className */);
- }
-
- private MatrixCursor getDummyCursor(String key, String className) {
- String[] keys = new String[] {key};
- return getDummyCursor(keys, className);
- }
-
- private MatrixCursor getDummyCursor(String[] keys, String className) {
- MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
- final String BLANK = "";
- final byte[] payload = ResultPayloadUtils.marshall(new ResultPayload(sIntent));
-
- for (int i = 0; i < keys.length; i++) {
- ArrayList<Object> item = new ArrayList<>(DatabaseResultLoader.SELECT_COLUMNS.length);
- item.add(keys[i].hashCode()); // Doc ID
- item.add(TITLES.get(i)); // Title
- item.add(SUMMARY); // Summary on
- item.add(BLANK); // summary off
- item.add(className); // classname
- item.add(BLANK); // screen title
- item.add(null); // Icon
- item.add(sIntent.getAction()); // Intent action
- item.add(TARGET_PACKAGE); // target package
- item.add(TARGET_CLASS); // target class
- item.add(keys[i]); // Key
- item.add(Integer.toString(0)); // Payload Type
- item.add(payload); // Payload
-
- cursor.addRow(item);
- }
- return cursor;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java b/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
deleted file mode 100644
index cd77b25..0000000
--- a/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2016 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.search;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.search.SearchResult.Builder;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-
-import java.util.ArrayList;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SearchResultBuilderTest {
-
- private static final String TITLE = "title";
- private static final String SUMMARY = "summary";
-
- private Builder mBuilder;
- private ArrayList<String> mBreadcrumbs;
- private int mRank;
- private ResultPayload mResultPayload;
- private Drawable mIcon;
-
- @Before
- public void setUp() {
- mBuilder = new Builder();
- mBreadcrumbs = new ArrayList<>();
- mRank = 3;
- mResultPayload = new ResultPayload(new Intent());
-
- final Context context = ShadowApplication.getInstance().getApplicationContext();
- mIcon = context.getDrawable(R.drawable.ic_search_24dp);
- }
-
- @Test
- public void testAllInfo_BuildSearchResult() {
- mBuilder.setTitle(TITLE)
- .setSummary(SUMMARY)
- .setRank(mRank)
- .addBreadcrumbs(mBreadcrumbs)
- .setIcon(mIcon)
- .setPayload(mResultPayload)
- .setStableId(1);
- SearchResult result = mBuilder.build();
-
- assertThat(result).isNotNull();
- assertThat(result.title).isEqualTo(TITLE);
- assertThat(result.summary).isEqualTo(SUMMARY);
- assertThat(result.rank).isEqualTo(mRank);
- assertThat(result.breadcrumbs).isEqualTo(mBreadcrumbs);
- assertThat(result.icon).isEqualTo(mIcon);
- assertThat(result.payload).isEqualTo(mResultPayload);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testNoStableId_BuildSearchResultException() {
- mBuilder.setTitle(TITLE)
- .setSummary(SUMMARY)
- .setRank(mRank)
- .addBreadcrumbs(mBreadcrumbs)
- .setIcon(mIcon)
- .setPayload(mResultPayload);
-
- mBuilder.build();
- }
-
- @Test(expected = IllegalStateException.class)
- public void testNoTitle_BuildSearchResultException() {
- mBuilder.setSummary(SUMMARY)
- .setRank(mRank)
- .addBreadcrumbs(mBreadcrumbs)
- .setIcon(mIcon)
- .setPayload(mResultPayload)
- .setStableId(1);
-
- mBuilder.build();
- }
-
- @Test
- public void testNoRank_BuildSearchResult_pass() {
- mBuilder.setTitle(TITLE)
- .setSummary(SUMMARY)
- .addBreadcrumbs(mBreadcrumbs)
- .setIcon(mIcon)
- .setPayload(mResultPayload)
- .setStableId(1);
-
- assertThat(mBuilder.build()).isNotNull();
- }
-
- @Test
- public void testNoIcon_BuildSearchResult_pass() {
- mBuilder.setTitle(TITLE)
- .setSummary(SUMMARY)
- .setRank(mRank)
- .addBreadcrumbs(mBreadcrumbs)
- .setPayload(mResultPayload)
- .setStableId(1);
-
- assertThat(mBuilder.build()).isNotNull();
- }
-
- @Test(expected = IllegalStateException.class)
- public void testNoPayload_BuildSearchResultException() {
- mBuilder.setTitle(TITLE)
- .setSummary(SUMMARY)
- .setRank(mRank)
- .addBreadcrumbs(mBreadcrumbs)
- .setIcon(mIcon)
- .setStableId(1);
-
- mBuilder.build();
- }
-}
-
-
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 340d04b..3512ded 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -31,6 +31,7 @@
import com.android.settings.TestConfig;
import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.FakeToggleController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.After;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java
index f5d5ff0..1c5899d 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java
@@ -31,6 +31,7 @@
import com.android.settings.search.SearchFeatureProvider;
import com.android.settings.search.SearchFeatureProviderImpl;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.FakeToggleController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.After;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index 0923571..88e4695 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -29,6 +29,7 @@
import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.testutils.FakeToggleController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java b/tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java
new file mode 100644
index 0000000..66ed459
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java
@@ -0,0 +1,201 @@
+/*
+ * 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.slices;
+
+import static com.android.settings.TestConfig.SDK_VERSION;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.content.res.XmlResourceParser;
+import android.provider.SearchIndexableResource;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Xml;
+
+import com.android.settings.TestConfig;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.core.codeinspection.ClassScanner;
+import com.android.settings.core.codeinspection.CodeInspector;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.DatabaseIndexingUtils;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchFeatureProvider;
+import com.android.settings.search.SearchFeatureProviderImpl;
+import com.android.settings.search.XmlParserUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.xmlpull.v1.XmlPullParser;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = SDK_VERSION)
+public class SliceControllerInXmlTest {
+
+ private static final List<Class> mSliceControllerClasses = new ArrayList<>(Arrays.asList(
+ TogglePreferenceController.class
+ ));
+
+ private final List<String> mXmlDeclaredControllers = new ArrayList<>();
+ private final List<String> mGrandfatheredClasses = new ArrayList<>();
+
+ private final String ERROR_MISSING_CONTROLLER =
+ "The following controllers were expected to be declared by "
+ + "'settings:controller=Controller_Class_Name' in their corresponding Xml. "
+ + "If it should not appear in XML, add the controller's classname to "
+ + "grandfather_slice_controller_not_in_xml. Controllers:\n";
+
+ private Context mContext;
+
+ SearchFeatureProvider mSearchProvider;
+ private FakeFeatureFactory mFakeFeatureFactory;
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+
+ mSearchProvider = new SearchFeatureProviderImpl();
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
+ mFakeFeatureFactory.searchFeatureProvider = mSearchProvider;
+
+ CodeInspector.initializeGrandfatherList(mGrandfatheredClasses,
+ "grandfather_slice_controller_not_in_xml");
+ initDeclaredControllers();
+ }
+
+ private void initDeclaredControllers() {
+ final List<Integer> xmlResources = getIndexableXml();
+ XmlResourceParser parser;
+
+ for (int xmlResId : xmlResources) {
+ try {
+ parser = mContext.getResources().getXml(xmlResId);
+
+ int type;
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && type != XmlPullParser.START_TAG) {
+ // Parse next until start tag is found
+ }
+
+ final int outerDepth = parser.getDepth();
+ final AttributeSet attrs = Xml.asAttributeSet(parser);
+ String controllerClassName;
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+ controllerClassName = XmlParserUtils.getController(mContext, attrs);
+
+ if (!TextUtils.isEmpty(controllerClassName)) {
+ mXmlDeclaredControllers.add(controllerClassName);
+ }
+ }
+ } catch (Exception e) {
+ // Assume an issue with robolectric resources
+ }
+ }
+ }
+
+ @Test
+ public void testAllControllersDeclaredInXml() throws Exception {
+ final List<Class<?>> classes = new ClassScanner().getClassesForPackage(
+ mContext.getPackageName());
+ final List<String> missingControllersInXml = new ArrayList<>();
+
+ for (Class<?> clazz : classes) {
+ if (!isInlineSliceClass(clazz)) {
+ // Only care about inline-slice controller classes.
+ continue;
+ }
+
+ if (!mXmlDeclaredControllers.contains(clazz.getName())) {
+ // Class clazz should have been declared in XML (unless whitelisted).
+ missingControllersInXml.add(clazz.getName());
+ }
+ }
+
+ // Removed whitelisted classes
+ missingControllersInXml.removeAll(mGrandfatheredClasses);
+
+ final String missingControllerError = buildErrorMessage(ERROR_MISSING_CONTROLLER,
+ missingControllersInXml);
+
+ assertWithMessage(missingControllerError).that(missingControllersInXml).isEmpty();
+ }
+
+ private boolean isInlineSliceClass(Class clazz) {
+ while (clazz != null) {
+ clazz = clazz.getSuperclass();
+ if (mSliceControllerClasses.contains(clazz)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private String buildErrorMessage(String errorSummary, List<String> errorClasses) {
+ final StringBuilder error = new StringBuilder(errorSummary);
+ for (String c : errorClasses) {
+ error.append(c).append("\n");
+ }
+ return error.toString();
+ }
+
+ private List<Integer> getIndexableXml() {
+ final List<Integer> xmlResSet = new ArrayList<>();
+
+ final Collection<Class> indexableClasses = FeatureFactory.getFactory(
+ mContext).getSearchFeatureProvider().getSearchIndexableResources()
+ .getProviderValues();
+
+ for (Class clazz : indexableClasses) {
+
+ Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(
+ clazz);
+
+ if (provider == null) {
+ continue;
+ }
+
+ List<SearchIndexableResource> resources = provider.getXmlResourcesToIndex(mContext,
+ true);
+
+ if (resources == null) {
+ continue;
+ }
+
+ for (SearchIndexableResource resource : resources) {
+ // Add '0's anyway. It won't break the test.
+ xmlResSet.add(resource.xmlResId);
+ }
+ }
+ return xmlResSet;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index ad72e6b..57244c1 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -27,7 +27,6 @@
import com.android.settings.connecteddevice.SmsMirroringFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
-import com.android.settings.datausage.DataPlanFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -62,7 +61,6 @@
public final UserFeatureProvider userFeatureProvider;
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
public final BluetoothFeatureProvider bluetoothFeatureProvider;
- public final DataPlanFeatureProvider dataPlanFeatureProvider;
public final SmsMirroringFeatureProvider smsMirroringFeatureProvider;
public final SlicesFeatureProvider slicesFeatureProvider;
public SearchFeatureProvider searchFeatureProvider;
@@ -103,7 +101,6 @@
userFeatureProvider = mock(UserFeatureProvider.class);
assistGestureFeatureProvider = mock(AssistGestureFeatureProvider.class);
bluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
- dataPlanFeatureProvider = mock(DataPlanFeatureProvider.class);
smsMirroringFeatureProvider = mock(SmsMirroringFeatureProvider.class);
slicesFeatureProvider = mock(SlicesFeatureProvider.class);
mAccountFeatureProvider = mock(AccountFeatureProvider.class);
@@ -175,11 +172,6 @@
}
@Override
- public DataPlanFeatureProvider getDataPlanFeatureProvider() {
- return dataPlanFeatureProvider;
- }
-
- @Override
public AssistGestureFeatureProvider getAssistGestureFeatureProvider() {
return assistGestureFeatureProvider;
}
diff --git a/tests/robotests/src/com/android/settings/slices/FakeToggleController.java b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/slices/FakeToggleController.java
rename to tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
index 1b08e35..c984c6c 100644
--- a/tests/robotests/src/com/android/settings/slices/FakeToggleController.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
@@ -15,7 +15,7 @@
*
*/
-package com.android.settings.slices;
+package com.android.settings.testutils;
import android.content.Context;
import android.provider.Settings;
diff --git a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
index ac3e0b6..55ce27f 100644
--- a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
@@ -106,6 +106,24 @@
}
@Test
+ public void onBindViewHolder_shouldSetCheckboxEnabledState() {
+ final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
+ LayoutInflater.from(mContext).inflate(
+ R.layout.preference_widget_master_checkbox, null));
+ final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
+
+ mPreference.setCheckBoxEnabled(false);
+ mPreference.onBindViewHolder(holder);
+
+ assertThat(mPreference.isEnabled()).isTrue();
+ assertThat(checkBox.isEnabled()).isFalse();
+
+ mPreference.setCheckBoxEnabled(true);
+ assertThat(mPreference.isEnabled()).isTrue();
+ assertThat(checkBox.isEnabled()).isTrue();
+ }
+
+ @Test
public void clickWidgetView_shouldToggleCheckBox() {
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
diff --git a/tests/robotests/src/com/android/settings/wifi/WpsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WpsPreferenceControllerTest.java
deleted file mode 100644
index e4dfea4..0000000
--- a/tests/robotests/src/com/android/settings/wifi/WpsPreferenceControllerTest.java
+++ /dev/null
@@ -1,140 +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.wifi;
-
-import static android.arch.lifecycle.Lifecycle.Event.ON_PAUSE;
-import static android.arch.lifecycle.Lifecycle.Event.ON_RESUME;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.FragmentManager;
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.wifi.WifiManager;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class WpsPreferenceControllerTest {
-
- @Mock
- private Context mContext;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private WifiManager mWifiManager;
- @Mock
- private FragmentManager mFragmentManager;
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private Preference mWpsPushPref;
- @Mock
- private Preference mWpsPinPref;
-
- private Lifecycle mLifecycle;
- private LifecycleOwner mLifecycleOwner;
- private WpsPreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- when(mContext.getSystemService(WifiManager.class))
- .thenReturn(mWifiManager);
- when(mScreen.findPreference(anyString()))
- .thenReturn(mWpsPushPref)
- .thenReturn(mWpsPinPref);
- mController = new WpsPreferenceController(
- mContext, mLifecycle, mWifiManager, mFragmentManager);
- }
-
- @Test
- public void testIsAvailable_shouldAlwaysReturnTrue() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void testOnResume_shouldRegisterListener() {
- mLifecycle.handleLifecycleEvent(ON_RESUME);
- verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
- }
- @Test
- public void testOnPause_shouldUnregisterListener() {
- mLifecycle.handleLifecycleEvent(ON_RESUME);
- mLifecycle.handleLifecycleEvent(ON_PAUSE);
- verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
- }
-
- @Test
- public void testWifiStateChange_shouldToggleEnabledState() {
- when(mWifiManager.isWifiEnabled()).thenReturn(true);
-
- //Sets the preferences.
- mController.displayPreference(mScreen);
- verify(mWpsPushPref).setEnabled(true);
- verify(mWpsPinPref).setEnabled(true);
-
- Intent dummyIntent = new Intent();
- mController.mReceiver.onReceive(mContext, dummyIntent);
- verify(mWpsPushPref, times(2)).setEnabled(true);
- verify(mWpsPinPref, times(2)).setEnabled(true);
-
- when(mWifiManager.isWifiEnabled()).thenReturn(false);
- mController.mReceiver.onReceive(mContext, dummyIntent);
- verify(mWpsPushPref).setEnabled(false);
- verify(mWpsPinPref).setEnabled(false);
- }
-
- @Test
- public void testDisplayPreference_shouldSetPreferenceClickListenerAndToggleEnabledState() {
- when(mWifiManager.isWifiEnabled()).thenReturn(true);
- mController.displayPreference(mScreen);
- verify(mWpsPushPref).setOnPreferenceClickListener(any());
- verify(mWpsPinPref).setOnPreferenceClickListener(any());
- verify(mWpsPushPref).setEnabled(true);
- verify(mWpsPinPref).setEnabled(true);
- }
-
- @Test
- public void testDisplayPreference_shouldDisablePreferenceWhenWifiDisabled() {
- when(mWifiManager.isWifiEnabled()).thenReturn(false);
- mController.displayPreference(mScreen);
- verify(mWpsPushPref).setEnabled(false);
- verify(mWpsPinPref).setEnabled(false);
- }
-}