Merge "Clean up LayoutPreference"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1bd458a..2d2f584 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3018,6 +3018,9 @@
<action android:name="android.content.action.SETTINGS_HOMEPAGE_DATA"/>
</intent-filter>
</provider>
+
+ <activity
+ android:name=".wifi.dpp.WifiDppConfiguratorActivity"/>
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/res/drawable/ic_launcher_settings.xml b/res/drawable/ic_launcher_settings.xml
index cdf9e35..9ede59d 100644
--- a/res/drawable/ic_launcher_settings.xml
+++ b/res/drawable/ic_launcher_settings.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
- <background android:drawable="@*android:color/accent_device_default_light"/>
+ <background android:drawable="@color/icon_launcher_setting_color"/>
<foreground android:drawable="@mipmap/ic_launcher_settings"/>
</adaptive-icon>
diff --git a/res/drawable/ic_settings_backup.xml b/res/drawable/ic_settings_backup.xml
index 231eadd..715a2e8 100644
--- a/res/drawable/ic_settings_backup.xml
+++ b/res/drawable/ic_settings_backup.xml
@@ -21,5 +21,5 @@
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FFFFFFFF"
- android:pathData="M17.92,10.02C17.45,7.18 14.97,5 12,5C9.82,5 7.83,6.18 6.78,8.06C4.09,8.41 2,10.74 2,13.5C2,16.53 4.47,19 7.5,19h10c2.48,0 4.5,-2.02 4.5,-4.5C22,12.16 20.21,10.23 17.92,10.02zM17.5,17h-10C5.57,17 4,15.43 4,13.5c0,-1.89 1.54,-3.46 3.44,-3.49L8.08,10l0.26,-0.59C8.97,7.94 10.41,7 12,7c2.21,0 4,1.79 4,4v1h1.5c1.38,0 2.5,1.12 2.5,2.5S18.88,17 17.5,17zM14.09,11.09l1.41,1.41l-2.79,2.79L12,16l-0.71,-0.71L8.5,12.5l1.41,-1.41L11,12.17V9.5h2v2.67L14.09,11.09z"/>
+ android:pathData="M17.92,10.02C17.45,7.18 14.97,5 12,5C9.82,5 7.83,6.18 6.78,8.06C4.09,8.41 2,10.74 2,13.5C2,16.53 4.47,19 7.5,19h10c2.48,0 4.5,-2.02 4.5,-4.5C22,12.16 20.21,10.23 17.92,10.02zM17.5,17h-10C5.57,17 4,15.43 4,13.5c0,-1.89 1.54,-3.46 3.44,-3.49L8.08,10l0.26,-0.59C8.97,7.94 10.41,7 12,7c2.21,0 4,1.79 4,4v1h1.5c1.38,0 2.5,1.12 2.5,2.5S18.88,17 17.5,17zM9.91,14.41L8.5,13l2.79,-2.79L12,9.5l0.71,0.71L15.5,13l-1.41,1.41L13,13.33V16h-2v-2.67L9.91,14.41z"/>
</vector>
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index dbdb91b..e062dba 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -30,8 +30,6 @@
android:id="@+id/slice_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/homepage_card_vertical_margin"
- android:layout_marginTop="@dimen/homepage_card_vertical_margin"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"/>
diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml
index 7a84e32..42b78b4 100644
--- a/res/layout/settings_homepage_container.xml
+++ b/res/layout/settings_homepage_container.xml
@@ -42,7 +42,9 @@
<FrameLayout
android:id="@+id/contextual_cards_content"
android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/homepage_card_side_margin"
+ android:layout_marginEnd="@dimen/homepage_card_side_margin"/>
<FrameLayout
android:id="@+id/main_content"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 72eb011..bb2946d 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -83,12 +83,13 @@
style="@style/wifi_item_label"
android:text="@string/wifi_security" />
+ <!-- Entries are added dynamically to this spinner -->
+ <!-- See WifiConfigController.configureSecuritySpinner -->
<Spinner android:id="@+id/security"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/wifi_item_spinner"
- android:prompt="@string/wifi_security"
- android:entries="@array/wifi_security" />
+ android:prompt="@string/wifi_security" />
</LinearLayout>
</LinearLayout>
diff --git a/res/layout/wifi_dpp_activity.xml b/res/layout/wifi_dpp_activity.xml
new file mode 100644
index 0000000..a833dcc
--- /dev/null
+++ b/res/layout/wifi_dpp_activity.xml
@@ -0,0 +1,36 @@
+<?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:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_wifi_signal_4"
+ android:layout_gravity="center"/>
+
+ <LinearLayout
+ android:id="@+id/fragment_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+</LinearLayout>
diff --git a/res/layout/wifi_dpp_fragment_footer.xml b/res/layout/wifi_dpp_fragment_footer.xml
new file mode 100644
index 0000000..98c6485
--- /dev/null
+++ b/res/layout/wifi_dpp_fragment_footer.xml
@@ -0,0 +1,44 @@
+<?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="match_parent"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/button_left"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|start"
+ android:text="left"
+ style="?android:attr/borderlessButtonStyle"/>
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ <Button
+ android:id="@+id/button_right"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|end"
+ android:text="right"/>
+
+</LinearLayout>
diff --git a/res/layout/wifi_dpp_fragment_header.xml b/res/layout/wifi_dpp_fragment_header.xml
new file mode 100644
index 0000000..99b246f
--- /dev/null
+++ b/res/layout/wifi_dpp_fragment_header.xml
@@ -0,0 +1,34 @@
+<?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:orientation="vertical">
+
+ <TextView android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"/>
+
+ <TextView android:id="@+id/description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"/>
+
+</LinearLayout>
diff --git a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
new file mode 100644
index 0000000..130bb6d
--- /dev/null
+++ b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
@@ -0,0 +1,52 @@
+<?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"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <SurfaceView
+ android:id="@+id/preview_view"
+ android:layout_width="320dp"
+ android:layout_height="426dp"
+ android:layout_gravity="center"/>
+ <ImageView
+ android:id="@+id/decorate_view"
+ android:layout_width="320dp"
+ android:layout_height="426dp"
+ android:layout_gravity="center"/>
+ </FrameLayout>
+
+ <TextView android:id="@+id/error_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"/>
+
+ <include layout="@layout/wifi_dpp_fragment_footer"
+ android:gravity="center|bottom"/>
+
+</LinearLayout>
+
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 80224bd..0ddd3ea 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -210,29 +210,6 @@
<item>Temporarily avoiding poor connection</item>
</string-array>
- <!-- Match this with the constants in AccessPoint. --> <skip />
- <!-- Wi-Fi security choices used when manually added a Wi-Fi network -->
- <string-array name="wifi_security">
- <!-- The Wi-Fi network does not have any security. -->
- <item>@string/wifi_security_none</item>
- <item translatable="false">@string/wifi_security_wep</item>
- <item translatable="false">@string/wifi_security_psk_generic</item>
- <item translatable="false">@string/wifi_security_eap</item>
- <item translatable="false">@string/wifi_security_owe</item>
- <item translatable="false">@string/wifi_security_sae</item>
- <item translatable="false">@string/wifi_security_eap_suiteb</item>
- </string-array>
-
- <!-- Match this with the constants in AccessPoint. --> <skip />
- <!-- Wi-Fi security types for New User Dialog. EAP is not configurable. -->
- <string-array name="wifi_security_no_eap">
- <!-- The Wi-Fi network does not have any security. -->
- <item>@string/wifi_security_none</item>
- <item translatable="false">@string/wifi_security_wep</item>
- <item translatable="false">@string/wifi_security_psk_generic</item>
- <item translatable="false">@string/wifi_security_sae</item>
- </string-array>
-
<!-- Security types for wireless tether -->
<string-array name="wifi_tether_security">
<!-- Do not translate. -->
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 34885b4..5dfc0b9 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -149,5 +149,8 @@
<color name="face_anim_particle_color_3">#ff4caf50</color> <!-- Material Green 500 -->
<color name="face_anim_particle_color_4">#fffdd835</color> <!-- Material Yellow 600 -->
<color name="face_anim_particle_error">#ff9e9e9e</color> <!-- Material Gray 500 -->
+
+ <!-- launcher icon color -->
+ <color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index d487f46..917f14d 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -150,4 +150,14 @@
<string name="config_settingsintelligence_package_name" translatable="false">
com.android.settings.intelligence
</string>
+
+ <!-- Emergency app package name -->
+ <string name="config_emergency_package_name" translatable="false">
+ com.android.emergency
+ </string>
+ <!-- Emergency app intent action -->
+ <string name="config_emergency_intent_action" translatable="false">
+ android.settings.EDIT_EMERGENCY_INFO
+ </string>
+
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 8f44c69..075979d 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -329,8 +329,8 @@
<dimen name="homepage_card_icon_size">24dp</dimen>
<dimen name="homepage_card_corner_radius">8dp</dimen>
<dimen name="homepage_card_elevation">2dp</dimen>
- <dimen name="homepage_card_vertical_margin">4dp</dimen>
- <dimen name="homepage_card_side_margin">8dp</dimen>
+ <dimen name="homepage_card_vertical_margin">8dp</dimen>
+ <dimen name="homepage_card_side_margin">4dp</dimen>
<dimen name="homepage_card_padding_start">16dp</dimen>
<dimen name="homepage_card_padding_end">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 151ea14..eb7cc2b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2050,6 +2050,10 @@
<string name="wifi_ip_settings">IP settings</string>
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
<string name="wifi_privacy_settings">Privacy</string>
+ <!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_add_device_to_network">Add a device to this network</string>
+ <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
+ <string name="wifi_dpp_center_qr_code">Center the device\u2019s QR code below to add device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Label for the check box to share a network with other users on the same device -->
<string name="wifi_shared">Share with other device users</string>
<!-- Hint for unchanged fields -->
@@ -4574,22 +4578,24 @@
<!-- Summary for the accessibility preference for master mono. [CHAR LIMIT=50] -->
<string name="accessibility_toggle_master_mono_summary">Combine channels when playing audio</string>
- <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <!-- Option heading to leave the timeout requirement for accessibility users at its default level. [CHAR LIMIT=35] -->
<string name="accessibility_timeout_default">Default</string>
- <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <!-- Option heading to leave the timeout requirement for accessibility users at 10 secs. [CHAR LIMIT=35] -->
<string name="accessibility_timeout_10secs">10 seconds</string>
- <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <!-- Option heading to leave the timeout requirement for accessibility users at 30 secs. [CHAR LIMIT=35] -->
<string name="accessibility_timeout_30secs">30 seconds</string>
- <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <!-- Option heading to leave the timeout requirement for accessibility users at 1 min. [CHAR LIMIT=35] -->
<string name="accessibility_timeout_1min">1 minute</string>
- <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <!-- Option heading to leave the timeout requirement for accessibility users at 2 mins. [CHAR LIMIT=35] -->
<string name="accessibility_timeout_2mins">2 minutes</string>
- <!-- Title for accessibility preference to accessibility message_timeout. [CHAR LIMIT=35] -->
- <string name="accessibility_accessibility_content_timeout_preference_title">Content Timeout</string>
- <!-- Title for accessibility preference to accessibility message_timeout. [CHAR LIMIT=35] -->
- <string name="accessibility_accessibility_control_timeout_preference_title">Control Timeout</string>
- <!-- Title for accessibility preference to accessibility message_timeout. [CHAR LIMIT=NONE] -->
- <string name="accessibility_accessibility_timeout_preference_summary">Choose how long it takes before automatically disappearing messages go away.\nSome apps may not support this setting yet.</string>
+ <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <string name="accessibility_content_timeout_preference_title">Time to read</string>
+ <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
+ <string name="accessibility_control_timeout_preference_title">Time to take action</string>
+ <!-- Descriptive text for accessibility preference to accessibility content timeout. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_content_timeout_preference_summary">Choose how much time you want to read and take action on messages that automatically go away.\n\nSupport for this setting is up to each app.</string>
+ <!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_control_timeout_preference_summary">Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting.</string>
<!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
<string name="accessibility_long_press_timeout_preference_title">Touch & hold delay</string>
@@ -5420,9 +5426,9 @@
<string name="battery_saver_turn_on_automatically_pct">at <xliff:g id="percent">%1$s</xliff:g> battery</string>
<!-- [CHAR_LIMIT=40] Battery percentage: Title -->
- <string name="battery_percentage">Battery percentage</string>
+ <string name="battery_info">Battery Information</string>
<!-- [CHAR_LIMIT=NONE] Battery percentage: Description for preference -->
- <string name="battery_percentage_description">Show battery percentage in status bar</string>
+ <string name="battery_info_description">Show percentage and time left before charge is needed</string>
<!-- Process Stats strings -->
<skip />
@@ -10075,6 +10081,9 @@
<!-- Title for HFP(hands free profile) output switch button in settings. -->
<string name="take_call_on_title">Take call on</string>
+ <!-- Toast that appears when users tap an APN for which parameters cannot be viewed. [CHAR LIMIT=NONE] -->
+ <string name="cannot_change_apn_toast">This APN cannot be changed.</string>
+
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cfc5fd3..3ce1193 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -482,7 +482,6 @@
</style>
<style name="ContextualCardStyle">
- <item name="android:layout_marginTop">@dimen/homepage_card_vertical_margin</item>
<item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
<item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
<item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
diff --git a/res/xml/accessibility_content_timeout_settings.xml b/res/xml/accessibility_content_timeout_settings.xml
index 51573c9..d450449 100644
--- a/res/xml/accessibility_content_timeout_settings.xml
+++ b/res/xml/accessibility_content_timeout_settings.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="accessibility_content_timeout_preference"
- android:title="@string/accessibility_accessibility_content_timeout_preference_title"
+ android:title="@string/accessibility_content_timeout_preference_title"
android:persistent="false" >
<com.android.settings.widget.VideoPreference
@@ -32,7 +32,7 @@
android:key="accessibility_content_timeout_summary"
android:selectable="false"
android:enabled="true"
- android:summary="@string/accessibility_accessibility_timeout_preference_summary"
+ android:summary="@string/accessibility_content_timeout_preference_summary"
android:persistent="false" />
<com.android.settings.widget.RadioButtonPreference
diff --git a/res/xml/accessibility_control_timeout_settings.xml b/res/xml/accessibility_control_timeout_settings.xml
index 4559650..6d8e1d0 100644
--- a/res/xml/accessibility_control_timeout_settings.xml
+++ b/res/xml/accessibility_control_timeout_settings.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="accessibility_control_timeout_preference"
- android:title="@string/accessibility_accessibility_control_timeout_preference_title"
+ android:title="@string/accessibility_control_timeout_preference_title"
android:persistent="false" >
<com.android.settings.widget.VideoPreference
@@ -32,7 +32,7 @@
android:key="accessibility_control_timeout_summary"
android:selectable="false"
android:enabled="true"
- android:summary="@string/accessibility_accessibility_timeout_preference_summary"
+ android:summary="@string/accessibility_control_timeout_preference_summary"
android:persistent="false" />
<com.android.settings.widget.RadioButtonPreference
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 1cd4a48..cc07ce1 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -75,8 +75,7 @@
<Preference
android:fragment="com.android.settings.accessibility.AccessibilityContentTimeoutPreferenceFragment"
android:key="accessibility_content_timeout_preference_fragment"
- android:title="@string/accessibility_accessibility_content_timeout_preference_title"
- android:icon="@drawable/ic_accessibility_generic"
+ android:title="@string/accessibility_content_timeout_preference_title"
android:persistent="false" />
</PreferenceCategory>
@@ -111,8 +110,7 @@
<Preference
android:fragment="com.android.settings.accessibility.AccessibilityControlTimeoutPreferenceFragment"
android:key="accessibility_control_timeout_preference_fragment"
- android:title="@string/accessibility_accessibility_control_timeout_preference_title"
- android:icon="@drawable/ic_accessibility_generic"
+ android:title="@string/accessibility_control_timeout_preference_title"
android:persistent="false" />
<Preference
diff --git a/res/xml/app_data_usage.xml b/res/xml/app_data_usage.xml
index 5eaee96..e64a1c5 100644
--- a/res/xml/app_data_usage.xml
+++ b/res/xml/app_data_usage.xml
@@ -21,7 +21,8 @@
android:title="@string/data_usage_app_summary_title">
<com.android.settings.datausage.SpinnerPreference
- android:key="cycle" />
+ android:key="cycle"
+ settings:isPreferenceVisible="false" />
<PreferenceCategory
android:key="app_data_usage_summary_category">
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index b4db4ed..48e1276 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -50,8 +50,8 @@
<SwitchPreference
android:key="battery_percentage"
- android:title="@string/battery_percentage"
- android:summary="@string/battery_percentage_description"
+ android:title="@string/battery_info"
+ android:summary="@string/battery_info_description"
settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 5d11936..79e2e71 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -21,6 +21,7 @@
android:key="privacy_dashboard_page"
android:title="@string/privacy_dashboard_title">
+ <!-- App permissions -->
<Preference
android:key="privacy_manage_perms"
android:title="@string/app_permissions"
@@ -29,6 +30,14 @@
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference>
+ <!-- On lock screen notifications -->
+ <com.android.settings.RestrictedListPreference
+ android:key="privacy_lock_screen_notifications"
+ android:title="@string/lock_screen_notifications_title"
+ android:summary="@string/summary_placeholder"
+ settings:searchable="false"/>
+
+ <!-- Show passwords -->
<SwitchPreference
android:key="show_password"
android:title="@string/show_password"
@@ -42,4 +51,20 @@
<PreferenceCategory
android:key="dashboard_tile_placeholder"/>
+ <!-- Work profile settings are at the bottom with high order value to avoid users thinking that
+ any of the above settings (including dynamic) are specific to the work profile. -->
+ <PreferenceCategory
+ android:key="privacy_work_profile_notifications_category"
+ android:title="@string/profile_section_header"
+ android:order="998"
+ settings:searchable="false">
+
+ <com.android.settings.RestrictedListPreference
+ android:key="privacy_lock_screen_work_profile_notifications"
+ android:title="@string/locked_work_profile_notification_title"
+ android:summary="@string/summary_placeholder"
+ android:order="999"
+ settings:searchable="false"/>
+ </PreferenceCategory>
+
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 1966484..2014308 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -37,11 +37,6 @@
android:title="@string/zen_mode_messages_title"
android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
- <!-- Alarms -->
- <SwitchPreference
- android:key="zen_mode_behavior_alarms"
- android:title="@string/zen_mode_alarms"/>
-
<!-- All sounds -->
<Preference
android:key="zen_sound_vibration_settings"
diff --git a/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java b/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java
index 31e5613..408db09 100644
--- a/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java
+++ b/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java
@@ -22,6 +22,7 @@
import android.content.res.Resources;
import android.os.UserHandle;
import android.os.UserManager;
+import android.util.FeatureFlagUtils;
import androidx.preference.Preference;
@@ -63,7 +64,7 @@
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY_EMERGENCY_INFO.equals(preference.getKey())) {
- Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
+ Intent intent = new Intent(getIntentAction(mContext));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mContext.startActivity(intent);
return true;
@@ -73,7 +74,7 @@
@Override
public boolean isAvailable() {
- Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage(PACKAGE_NAME_EMERGENCY);
+ Intent intent = new Intent(getIntentAction(mContext)).setPackage(getPackageName(mContext));
List<ResolveInfo> infos = mContext.getPackageManager().queryIntentActivities(intent, 0);
return infos != null && !infos.isEmpty();
}
@@ -82,4 +83,20 @@
public String getPreferenceKey() {
return KEY_EMERGENCY_INFO;
}
+
+ private String getIntentAction(Context context) {
+ if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
+ return context.getResources().getString(R.string.config_emergency_intent_action);
+ }
+
+ return ACTION_EDIT_EMERGENCY_INFO;
+ }
+
+ private String getPackageName(Context context) {
+ if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
+ return context.getResources().getString(R.string.config_emergency_package_name);
+ }
+
+ return PACKAGE_NAME_EMERGENCY;
+ }
}
diff --git a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
index 858c8eb..6af0911 100644
--- a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
+++ b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
@@ -16,7 +16,7 @@
package com.android.settings.datetime.timezone.model;
-import libcore.util.CountryTimeZones;
+import libcore.timezone.CountryTimeZones;
import java.util.Collections;
import java.util.List;
diff --git a/src/com/android/settings/datetime/timezone/model/TimeZoneData.java b/src/com/android/settings/datetime/timezone/model/TimeZoneData.java
index c914845..61244f2 100644
--- a/src/com/android/settings/datetime/timezone/model/TimeZoneData.java
+++ b/src/com/android/settings/datetime/timezone/model/TimeZoneData.java
@@ -18,9 +18,9 @@
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArraySet;
-import libcore.util.CountryTimeZones;
-import libcore.util.CountryZonesFinder;
-import libcore.util.TimeZoneFinder;
+import libcore.timezone.CountryTimeZones;
+import libcore.timezone.CountryZonesFinder;
+import libcore.timezone.TimeZoneFinder;
import java.lang.ref.WeakReference;
import java.util.Collections;
diff --git a/src/com/android/settings/network/ApnPreference.java b/src/com/android/settings/network/ApnPreference.java
index a7fbb6e..f039539 100755
--- a/src/com/android/settings/network/ApnPreference.java
+++ b/src/com/android/settings/network/ApnPreference.java
@@ -27,6 +27,7 @@
import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioButton;
+import android.widget.Toast;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
@@ -54,6 +55,7 @@
private static CompoundButton mCurrentChecked = null;
private boolean mProtectFromCheckedChange = false;
private boolean mSelectable = true;
+ private boolean mHideDetails = false;
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
@@ -113,6 +115,11 @@
super.onClick();
Context context = getContext();
if (context != null) {
+ if (mHideDetails) {
+ Toast.makeText(context, context.getString(
+ R.string.cannot_change_apn_toast), Toast.LENGTH_LONG).show();
+ return;
+ }
int pos = Integer.parseInt(getKey());
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
@@ -132,4 +139,8 @@
public void setSubId(int subId) {
mSubId = subId;
}
+
+ public void setHideDetails() {
+ mHideDetails = true;
+ }
}
diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java
index a71dfaa..3b1e14c 100755
--- a/src/com/android/settings/network/ApnSettings.java
+++ b/src/com/android/settings/network/ApnSettings.java
@@ -78,12 +78,23 @@
public static final String MVNO_TYPE = "mvno_type";
public static final String MVNO_MATCH_DATA = "mvno_match_data";
+ private static final String[] CARRIERS_PROJECTION = new String[] {
+ Telephony.Carriers._ID,
+ Telephony.Carriers.NAME,
+ Telephony.Carriers.APN,
+ Telephony.Carriers.TYPE,
+ Telephony.Carriers.MVNO_TYPE,
+ Telephony.Carriers.MVNO_MATCH_DATA,
+ Telephony.Carriers.EDITED,
+ };
+
private static final int ID_INDEX = 0;
private static final int NAME_INDEX = 1;
private static final int APN_INDEX = 2;
private static final int TYPES_INDEX = 3;
private static final int MVNO_TYPE_INDEX = 4;
private static final int MVNO_MATCH_DATA_INDEX = 5;
+ private static final int EDITED_INDEX = 6;
private static final int MENU_NEW = Menu.FIRST;
private static final int MENU_RESTORE = Menu.FIRST + 1;
@@ -116,6 +127,7 @@
private boolean mHideImsApn;
private boolean mAllowAddingApns;
+ private boolean mHidePresetApnDetails;
public ApnSettings() {
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
@@ -196,6 +208,7 @@
mAllowAddingApns = false;
}
}
+ mHidePresetApnDetails = b.getBoolean(CarrierConfigManager.KEY_HIDE_PRESET_APN_DETAILS_BOOL);
mUserManager = UserManager.get(activity);
}
@@ -277,9 +290,8 @@
where.append(" AND NOT (type='ims')");
}
- Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
- "_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, where.toString(),
- null, Telephony.Carriers.DEFAULT_SORT_ORDER);
+ Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI,
+ CARRIERS_PROJECTION, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (cursor != null) {
IccRecords r = null;
@@ -304,14 +316,19 @@
String type = cursor.getString(TYPES_INDEX);
String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
+ int edited = cursor.getInt(EDITED_INDEX);
ApnPreference pref = new ApnPreference(getPrefContext());
pref.setKey(key);
pref.setTitle(name);
- pref.setSummary(apn);
pref.setPersistent(false);
pref.setSubId(subId);
+ if (mHidePresetApnDetails && edited == Telephony.Carriers.UNEDITED) {
+ pref.setHideDetails();
+ } else {
+ pref.setSummary(apn);
+ }
boolean selectable = ((type == null) || !type.equals("mms"));
pref.setSelectable(selectable);
diff --git a/src/com/android/settings/network/telephony/CarrierPreferenceController.java b/src/com/android/settings/network/telephony/CarrierPreferenceController.java
index 8210c4b..3dab15e 100644
--- a/src/com/android/settings/network/telephony/CarrierPreferenceController.java
+++ b/src/com/android/settings/network/telephony/CarrierPreferenceController.java
@@ -17,6 +17,10 @@
package com.android.settings.network.telephony;
import android.content.Context;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
@@ -62,10 +66,31 @@
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (getPreferenceKey().equals(preference.getKey())) {
- //TODO(b/117651939): start carrier settings activity
+ final Intent carrierSettingsIntent = getCarrierSettingsActivityIntent(mSubId);
+ if (carrierSettingsIntent != null) {
+ mContext.startActivity(carrierSettingsIntent);
+ }
return true;
}
return false;
}
+
+ private Intent getCarrierSettingsActivityIntent(int subId) {
+ final PersistableBundle config = mCarrierConfigManager.getConfigForSubId(subId);
+ final ComponentName cn = ComponentName.unflattenFromString(
+ config == null ? "" : config.getString(
+ CarrierConfigManager.KEY_CARRIER_SETTINGS_ACTIVITY_COMPONENT_NAME_STRING,
+ "" /* default value */));
+
+ if (cn == null) return null;
+
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setComponent(cn);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ final PackageManager pm = mContext.getPackageManager();
+ final ResolveInfo resolveInfo = pm.resolveActivity(intent, 0 /* flags */);
+ return resolveInfo != null ? intent : null;
+ }
}
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 3a270d2..293c429 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -86,8 +86,6 @@
"zen_mode_behavior_calls"));
controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
"zen_mode_behavior_messages"));
- controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
- "zen_mode_behavior_alarms"));
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle));
controllers.add(new ZenModeAutomationPreferenceController(context));
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index dd4c8fa..91e85b3 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -22,7 +22,10 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
@@ -31,6 +34,11 @@
@SearchIndexable
public class PrivacyDashboardFragment extends DashboardFragment {
private static final String TAG = "PrivacyDashboardFragment";
+ private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "privacy_lock_screen_notifications";
+ private static final String KEY_WORK_PROFILE_CATEGORY =
+ "privacy_work_profile_notifications_category";
+ private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
+ "privacy_lock_screen_work_profile_notifications";
@Override
public int getMetricsCategory() {
@@ -52,6 +60,28 @@
return R.string.help_url_privacy_dashboard;
}
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getSettingsLifecycle());
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(
+ Context context, Lifecycle lifecycle) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ final LockScreenNotificationPreferenceController notificationController =
+ new LockScreenNotificationPreferenceController(context,
+ KEY_LOCK_SCREEN_NOTIFICATIONS,
+ KEY_WORK_PROFILE_CATEGORY,
+ KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS);
+ if (lifecycle != null) {
+ lifecycle.addObserver(notificationController);
+ }
+ controllers.add(notificationController);
+
+ return controllers;
+
+ }
+
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
@@ -64,5 +94,11 @@
result.add(sir);
return result;
}
+
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(
+ Context context) {
+ return buildPreferenceControllers(context, null);
+ }
};
}
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 853313f..267838c 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -321,7 +321,7 @@
}
actionBar.setBackgroundDrawable(
new ColorDrawable(
- Utils.getColorAttrDefaultColor(activity, android.R.attr.colorPrimary)));
+ Utils.getColorAttrDefaultColor(activity, android.R.attr.colorPrimaryDark)));
actionBar.setElevation(0);
if (mRecyclerView != null && mLifecycle != null) {
ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index c58ff57..7078ae0 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -19,9 +19,18 @@
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
+import android.graphics.drawable.Drawable;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
+import android.net.wifi.WifiManager.NetworkRequestMatchCallback;
import android.os.Handler;
import android.os.Message;
+import android.widget.BaseAdapter;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
+import androidx.preference.internal.PreferenceImageView;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -32,20 +41,23 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settingslib.Utils;
import com.android.settingslib.wifi.AccessPoint;
import java.util.ArrayList;
import java.util.List;
public class NetworkRequestDialogFragment extends InstrumentedDialogFragment implements
- DialogInterface.OnClickListener {
+ DialogInterface.OnClickListener, NetworkRequestMatchCallback {
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
/** Delayed time to stop scanning wifi. */
- private static final int DELAY_TIME_STOP_SCAN_MS = 30*1000;
+ private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
private List<AccessPoint> mAccessPointList;
+ private AccessPointAdapter mDialogAdapter;
+ private NetworkRequestUserSelectionCallback mUserSelectionCallback;
public static NetworkRequestDialogFragment newInstance() {
NetworkRequestDialogFragment dialogFragment = new NetworkRequestDialogFragment();
@@ -54,28 +66,29 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- Context context = getContext();
+ final Context context = getContext();
// Prepares title.
- LayoutInflater inflater = LayoutInflater.from(context);
- View customTitle = inflater.inflate(R.layout.network_request_dialog_title, null);
+ final LayoutInflater inflater = LayoutInflater.from(context);
+ final View customTitle = inflater.inflate(R.layout.network_request_dialog_title, null);
- TextView title = customTitle.findViewById(R.id.network_request_title_text);
+ final TextView title = customTitle.findViewById(R.id.network_request_title_text);
title.setText(R.string.network_connection_request_dialog_title);
- ProgressBar progressBar = customTitle.findViewById(R.id.network_request_title_progress);
+ final ProgressBar progressBar = customTitle.findViewById(R.id.network_request_title_progress);
progressBar.setVisibility(View.VISIBLE);
// Prepares adapter.
- AccessPointAdapter adapter = new AccessPointAdapter(context,
+ mDialogAdapter = new AccessPointAdapter(context,
R.layout.preference_access_point, getAccessPointList());
- AlertDialog.Builder builder = new AlertDialog.Builder(context)
+ final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCustomTitle(customTitle)
- .setAdapter(adapter, this)
+ .setAdapter(mDialogAdapter, this)
.setPositiveButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
return builder.create();
}
+ @NonNull
List<AccessPoint> getAccessPointList() {
// Initials list for adapter, in case of display crashing.
if (mAccessPointList == null) {
@@ -84,8 +97,24 @@
return mAccessPointList;
}
+ private BaseAdapter getDialogAdapter() {
+ return mDialogAdapter;
+ }
+
@Override
public void onClick(DialogInterface dialog, int which) {
+ final List<AccessPoint> accessPointList = getAccessPointList();
+ if (accessPointList.size() == 0) {
+ return; // Invalid values.
+ }
+ if (mUserSelectionCallback == null) {
+ return; // Callback is missing or not ready.
+ }
+
+ if (which < accessPointList.size()) {
+ WifiConfiguration wifiConfig = accessPointList.get(which).getConfig();
+ mUserSelectionCallback.select(wifiConfig);
+ }
}
@Override
@@ -93,19 +122,27 @@
super.onPause();
mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
+ final WifiManager wifiManager = getContext().getApplicationContext()
+ .getSystemService(WifiManager.class);
+ if (wifiManager != null) {
+ wifiManager.unregisterNetworkRequestMatchCallback(this);
+ }
}
@Override
public void onResume() {
super.onResume();
- // TODO(b/117399926): Starts to scan current WiFi.
-
+ final WifiManager wifiManager = getContext().getApplicationContext()
+ .getSystemService(WifiManager.class);
+ if (wifiManager != null) {
+ wifiManager.registerNetworkRequestMatchCallback(this, mHandler);
+ }
// Sets time-out to stop scanning.
mHandler.sendEmptyMessageDelayed(MESSAGE_STOP_SCAN_WIFI_LIST, DELAY_TIME_STOP_SCAN_MS);
}
- private Handler mHandler = new Handler() {
+ private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -121,8 +158,12 @@
};
protected void stopScanningAndPopTimeoutDialog() {
+ // Dismisses current dialog.
dismiss();
- NetworkRequestTimeoutDialogFragment fragment = NetworkRequestTimeoutDialogFragment.newInstance();
+
+ // Throws new timeout dialog.
+ final NetworkRequestTimeoutDialogFragment fragment = NetworkRequestTimeoutDialogFragment
+ .newInstance();
fragment.show(getActivity().getSupportFragmentManager(), null);
}
@@ -146,14 +187,108 @@
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
view = mInflater.inflate(mResourceId, parent, false);
+
+ final View divider = view.findViewById(com.android.settingslib.R.id.two_target_divider);
+ divider.setVisibility(View.GONE);
}
- // TODO: Sets correct information to list item.
- final View divider = view.findViewById(com.android.settingslib.R.id.two_target_divider);
- divider.setVisibility(View.GONE);
+ final AccessPoint accessPoint = getItem(position);
+
+ final TextView titleView = view.findViewById(android.R.id.title);
+ if (titleView != null) {
+ titleView.setText(accessPoint.getSsidStr());
+ }
+
+ final TextView summary = view.findViewById(android.R.id.summary);
+ if (summary != null) {
+ summary.setText(accessPoint.getSettingsSummary());
+ }
+
+ final PreferenceImageView imageView = view.findViewById(android.R.id.icon);
+ final int level = accessPoint.getLevel();
+ if (imageView != null) {
+ final Drawable drawable = getContext().getDrawable(Utils.getWifiIconResource(level));
+ drawable.setTintList(Utils.getColorAttr(getContext(), android.R.attr.colorControlNormal));
+ imageView.setImageDrawable(drawable);
+ }
return view;
}
}
-}
+ @Override
+ public void onAbort() {
+ // TODO(b/117399926): We should have a UI notify user here.
+ }
+
+ @Override
+ public void onUserSelectionCallbackRegistration(
+ NetworkRequestUserSelectionCallback userSelectionCallback) {
+ mUserSelectionCallback = userSelectionCallback;
+ }
+
+ @Override
+ public void onMatch(List<ScanResult> scanResults) {
+ // TODO(b/119846365): Checks if we could escalate the converting effort.
+ // Converts ScanResult to WifiConfiguration.
+ List<WifiConfiguration> wifiConfigurations = null;
+ final WifiManager wifiManager = getContext().getApplicationContext()
+ .getSystemService(WifiManager.class);
+ if (wifiManager != null) {
+ wifiConfigurations = wifiManager.getAllMatchingWifiConfigs(scanResults);
+ }
+
+ setUpAccessPointList(wifiConfigurations);
+
+ if (getDialogAdapter() != null) {
+ getDialogAdapter().notifyDataSetChanged();
+ }
+ }
+
+ @Override
+ public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
+ if (getDialogAdapter() != null) {
+ updateAccessPointListItem(wificonfiguration);
+ getDialogAdapter().notifyDataSetChanged();
+ }
+ }
+
+ @Override
+ public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
+ if (mDialogAdapter != null) {
+ updateAccessPointListItem(wificonfiguration);
+ getDialogAdapter().notifyDataSetChanged();
+ }
+ }
+
+ private void updateAccessPointListItem(WifiConfiguration wificonfiguration) {
+ if (wificonfiguration == null) {
+ return;
+ }
+
+ final List<AccessPoint> accessPointList = getAccessPointList();
+ final int accessPointListSize = accessPointList.size();
+
+ for (int i = 0; i < accessPointListSize; i++) {
+ AccessPoint accessPoint = accessPointList.get(i);
+ // It is the same AccessPoint SSID, and should be replaced to update latest properties.
+ if (accessPoint.matches(wificonfiguration)) {
+ accessPointList.set(i, new AccessPoint(getContext(), wificonfiguration));
+ break;
+ }
+ }
+ }
+
+ private void setUpAccessPointList(List<WifiConfiguration> wifiConfigurations) {
+ // Grants for zero size input, since maybe current wifi is off or somethings are wrong.
+ if (wifiConfigurations == null) {
+ return;
+ }
+
+ final List<AccessPoint> accessPointList = getAccessPointList();
+ accessPointList.clear();
+ for (WifiConfiguration config : wifiConfigurations) {
+ accessPointList.add(new AccessPoint(getContext(), config));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 70837a6..2e3b76a 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -34,6 +34,7 @@
import android.net.wifi.WifiEnterpriseConfig.Eap;
import android.net.wifi.WifiEnterpriseConfig.Phase2;
import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
import android.os.UserManager;
import android.security.Credentials;
import android.security.KeyStore;
@@ -119,9 +120,9 @@
/* Phase2 methods supported by PEAP are limited */
- private final ArrayAdapter<String> mPhase2PeapAdapter;
+ private ArrayAdapter<String> mPhase2PeapAdapter;
/* Full list of phase2 methods */
- private final ArrayAdapter<String> mPhase2FullAdapter;
+ private ArrayAdapter<String> mPhase2FullAdapter;
// e.g. AccessPoint.SECURITY_NONE
@VisibleForTesting
@@ -174,6 +175,9 @@
private TextView mSsidView;
private Context mContext;
+ private Integer mSecurityInPosition[];
+
+ private final WifiManager mWifiManager;
public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
int mode) {
@@ -181,11 +185,31 @@
mView = view;
mAccessPoint = accessPoint;
+ mContext = mConfigUi.getContext();
+
+ // Init Wi-Fi manager
+ mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
+ initWifiConfigController(accessPoint, mode);
+ }
+
+ @VisibleForTesting
+ public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
+ int mode, WifiManager wifiManager) {
+ mConfigUi = parent;
+
+ mView = view;
+ mAccessPoint = accessPoint;
+ mContext = mConfigUi.getContext();
+ mWifiManager = wifiManager;
+ initWifiConfigController(accessPoint, mode);
+ }
+
+ private void initWifiConfigController(AccessPoint accessPoint, int mode) {
+
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
accessPoint.getSecurity();
mMode = mode;
- mContext = mConfigUi.getContext();
final Resources res = mContext.getResources();
mLevels = res.getStringArray(R.array.wifi_signal);
@@ -234,24 +258,10 @@
mHiddenSettingsSpinner.getSelectedItemPosition() == NOT_HIDDEN_NETWORK
? View.GONE
: View.VISIBLE);
+ mSecurityInPosition = new Integer[AccessPoint.SECURITY_MAX_VAL];
if (mAccessPoint == null) { // new network
- mConfigUi.setTitle(R.string.wifi_add_network);
-
- mSsidView = (TextView) mView.findViewById(R.id.ssid);
- mSsidView.addTextChangedListener(this);
- mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
- mSecuritySpinner.setOnItemSelectedListener(this);
- mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
-
- showIpConfigFields();
- showProxyFields();
- mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
- // Hidden option can be changed only when the user adds a network manually.
- mView.findViewById(R.id.hidden_settings_field).setVisibility(View.VISIBLE);
- ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
- .setOnCheckedChangeListener(this);
-
+ configureSecuritySpinner();
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
} else {
if (!mAccessPoint.isPasspointConfig()) {
@@ -1414,7 +1424,8 @@
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (parent == mSecuritySpinner) {
- mAccessPointSecurity = position;
+ // Convert menu position to actual Wi-Fi security type
+ mAccessPointSecurity = mSecurityInPosition[position];
showSecurityFields();
} else if (parent == mEapMethodSpinner || parent == mEapCaCertSpinner) {
showSecurityFields();
@@ -1459,4 +1470,53 @@
public AccessPoint getAccessPoint() {
return mAccessPoint;
}
+
+ private void configureSecuritySpinner() {
+ mConfigUi.setTitle(R.string.wifi_add_network);
+
+ mSsidView = (TextView) mView.findViewById(R.id.ssid);
+ mSsidView.addTextChangedListener(this);
+ mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
+ mSecuritySpinner.setOnItemSelectedListener(this);
+
+ ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext,
+ android.R.layout.simple_spinner_item, android.R.id.text1);
+ spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mSecuritySpinner.setAdapter(spinnerAdapter);
+ int idx = 0;
+
+ // Populate the Wi-Fi security spinner with the various supported key management types
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_none));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_NONE;
+ if (mWifiManager.isOweSupported()) {
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_owe));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_OWE;
+ }
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_wep));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_WEP;
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_wpa_wpa2));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_PSK;
+ if (mWifiManager.isWpa3SaeSupported()) {
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_sae));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_SAE;
+ }
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
+ if (mWifiManager.isWpa3SuiteBSupported()) {
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_suiteb));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP_SUITE_B;
+ }
+
+ spinnerAdapter.notifyDataSetChanged();
+
+ mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
+
+ showIpConfigFields();
+ showProxyFields();
+ mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
+ // Hidden option can be changed only when the user adds a network manually.
+ mView.findViewById(R.id.hidden_settings_field).setVisibility(View.VISIBLE);
+ ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
+ .setOnCheckedChangeListener(this);
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
new file mode 100644
index 0000000..bccb53a
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -0,0 +1,91 @@
+/*
+ * 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.wifi.dpp;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
+import com.android.internal.logging.nano.MetricsProto;
+
+import com.android.settings.core.InstrumentedActivity;
+import com.android.settings.R;
+
+public class WifiDppConfiguratorActivity extends InstrumentedActivity {
+ private static final String TAG = "WifiDppConfiguratorActivity";
+
+ private FragmentManager mFragmentManager;
+ private FragmentTransaction mFragmentTransaction;
+
+ public static final String EXTRA_LAUNCH_MODE =
+ "com.android.settings.wifi.dpp.EXTRA_LAUNCH_MODE";
+ public static final String EXTRA_SSID = "com.android.settings.wifi.dpp.EXTRA_SSID";
+
+ public enum LaunchMode {
+ LAUNCH_MODE_QR_CODE_SCANNER(1),
+ LAUNCH_MODE_QR_CODE_GENERATOR(2),
+ LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK(3),
+ LAUNCH_MODE_NOT_DEFINED(-1);
+
+ private int mMode;
+
+ LaunchMode(int mode) {
+ this.mMode = mode;
+ }
+
+ public int getMode() {
+ return mMode;
+ }
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ //TODO:Should we use a new metrics category for Wi-Fi DPP?
+ return MetricsProto.MetricsEvent.WIFI_NETWORK_DETAILS;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.wifi_dpp_activity);
+
+ // Hide action bar
+ ActionBar action = getActionBar();
+ if (action != null) {
+ action.hide();
+ }
+
+ mFragmentManager = getSupportFragmentManager();
+ mFragmentTransaction = getSupportFragmentManager().beginTransaction();
+
+ final int launchMode = getIntent().getIntExtra(EXTRA_LAUNCH_MODE,
+ LaunchMode.LAUNCH_MODE_NOT_DEFINED.getMode());
+ if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode()) {
+ WifiDppQrCodeScannerFragment scanFragment = new WifiDppQrCodeScannerFragment();
+ mFragmentTransaction.add(R.id.fragment_container, scanFragment);
+ mFragmentTransaction.commit();
+ } else {
+ Log.e(TAG, "Launch with an invalid mode extra");
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
new file mode 100644
index 0000000..004cb18
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
@@ -0,0 +1,107 @@
+/*
+ * 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.wifi.dpp;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.internal.logging.nano.MetricsProto;
+
+import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.R;
+
+public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
+ private TextView mTitle;
+ private TextView mDescription;
+ private SurfaceView mPreviewView;
+ private TextView mErrorMessage; //optional, view used to surface connectivity errors to the user
+ private Button mButtonLeft;
+ private Button mButtonRight;
+
+ abstract protected int getLayout();
+
+ @Override
+ public int getMetricsCategory() {
+ //TODO:Should we use a new metrics category for Wi-Fi DPP?
+ return MetricsProto.MetricsEvent.WIFI_NETWORK_DETAILS;
+ }
+
+ @Override
+ public final void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public final View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(getLayout(), container, false);
+ initView(view);
+ return view;
+ }
+
+ private void initView(View view) {
+ mTitle = view.findViewById(R.id.title);
+ mDescription = view.findViewById(R.id.description);
+ mPreviewView = view.findViewById(R.id.preview_view);
+ mErrorMessage = view.findViewById(R.id.error_message);
+ mButtonLeft = view.findViewById(R.id.button_left);
+ mButtonRight = view.findViewById(R.id.button_right);
+ }
+
+ protected void setTitle(String title) {
+ mTitle.setText(title);
+ }
+
+ protected void setDescription(String description) {
+ mDescription.setText(description);
+ }
+
+ protected void setErrorMessage(String errorMessage) {
+ if (mErrorMessage != null) {
+ mErrorMessage.setText(errorMessage);
+ }
+ }
+
+ protected void setLeftButtonText(String text) {
+ mButtonLeft.setText(text);
+ }
+
+ protected void setRightButtonText(String text) {
+ mButtonRight.setText(text);
+ }
+
+ protected void hideLeftButton() {
+ mButtonLeft.setVisibility(View.INVISIBLE);
+ }
+
+ protected void hideRightButton() {
+ mButtonRight.setVisibility(View.INVISIBLE);
+ }
+
+ protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
+ mButtonLeft.setOnClickListener(listener);
+ }
+
+ protected void setRightButtonOnClickListener(View.OnClickListener listener) {
+ mButtonRight.setOnClickListener(listener);
+ }
+}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
new file mode 100644
index 0000000..0ee8434
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.dpp;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import android.view.ViewGroup;
+import com.android.settings.R;
+
+public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment {
+ @Override
+ protected int getLayout() {
+ return R.layout.wifi_dpp_qrcode_scanner_fragment;
+ }
+
+ @Override
+ public void onActivityCreated (Bundle savedInstanceState) {
+ super.onActivityCreated (savedInstanceState);
+
+ setTitle(getString(R.string.wifi_dpp_add_device_to_network));
+
+ String ssid = "";
+ Intent intent = getActivity().getIntent();
+ if (intent != null)
+ ssid = intent.getStringExtra(WifiDppConfiguratorActivity.EXTRA_SSID);
+ String description = getString(R.string.wifi_dpp_center_qr_code, ssid);
+ setDescription(description);
+
+ hideRightButton();
+
+ setLeftButtonText(getString(android.R.string.cancel));
+
+ setLeftButtonOnClickListener((view) -> {
+ getActivity().setResult(Activity.RESULT_CANCELED);
+ getActivity().finish();});
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java
index 9f3453d..d7a54db 100644
--- a/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/timezone/FixedOffsetPickerTest.java
@@ -27,7 +27,7 @@
import com.android.settings.datetime.timezone.model.TimeZoneData;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import libcore.util.CountryZonesFinder;
+import libcore.timezone.CountryZonesFinder;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java
index e7e01c9..08759a2 100644
--- a/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/timezone/RegionSearchPickerTest.java
@@ -34,7 +34,7 @@
import com.android.settings.datetime.timezone.model.TimeZoneData;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import libcore.util.CountryZonesFinder;
+import libcore.timezone.CountryZonesFinder;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
index d7fdd2c..0310c76 100644
--- a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
@@ -23,9 +23,9 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import libcore.util.CountryTimeZones;
-import libcore.util.CountryTimeZones.TimeZoneMapping;
-import libcore.util.CountryZonesFinder;
+import libcore.timezone.CountryTimeZones;
+import libcore.timezone.CountryTimeZones.TimeZoneMapping;
+import libcore.timezone.CountryZonesFinder;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/robotests/src/com/android/settings/network/telephony/CarrierPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/CarrierPreferenceControllerTest.java
index 8673de8..054a6bd 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/CarrierPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/CarrierPreferenceControllerTest.java
@@ -21,10 +21,18 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import android.content.Context;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
@@ -38,12 +46,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.mockito.ArgumentCaptor;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
public class CarrierPreferenceControllerTest {
private static final int SUB_ID = 2;
+ private static final String CARRIER_SETTINGS_COMPONENT = "packageName/className";
@Mock
private TelephonyManager mTelephonyManager;
@@ -106,4 +117,55 @@
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
+
+ @Test
+ public void handlePreferenceClick_activityFound_openCarrierSettingActivity() {
+ final PersistableBundle bundle = new PersistableBundle();
+ bundle.putString(
+ CarrierConfigManager.KEY_CARRIER_SETTINGS_ACTIVITY_COMPONENT_NAME_STRING,
+ CARRIER_SETTINGS_COMPONENT);
+ doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
+ PackageManager pm = Mockito.mock(PackageManager.class);
+ doReturn(pm).when(mContext).getPackageManager();
+ doReturn(new ResolveInfo()).when(pm).resolveActivity(any(Intent.class), anyInt());
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).startActivity(captor.capture());
+ final Intent intent = captor.getValue();
+ assertThat(intent.getComponent()).isEqualTo(
+ ComponentName.unflattenFromString(CARRIER_SETTINGS_COMPONENT));
+ }
+
+ @Test
+ public void handlePreferenceClick_activityNotFound_DoNothing() {
+ final PersistableBundle bundle = new PersistableBundle();
+ bundle.putString(
+ CarrierConfigManager.KEY_CARRIER_SETTINGS_ACTIVITY_COMPONENT_NAME_STRING,
+ CARRIER_SETTINGS_COMPONENT);
+ doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
+ PackageManager pm = Mockito.mock(PackageManager.class);
+ doReturn(pm).when(mContext).getPackageManager();
+ doReturn(null).when(pm).resolveActivity(any(Intent.class), anyInt());
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext, never()).startActivity(captor.capture());
+ }
+
+ @Test
+ public void handlePreferenceClick_activityNotConfigured_DoNothing() {
+ final PersistableBundle bundle = new PersistableBundle();
+ doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
+ PackageManager pm = Mockito.mock(PackageManager.class);
+ doReturn(pm).when(mContext).getPackageManager();
+ doReturn(new ResolveInfo()).when(pm).resolveActivity(any(Intent.class), anyInt());
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext, never()).startActivity(captor.capture());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 17718a6..2e806dd 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -17,18 +17,34 @@
package com.android.settings.wifi;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
import android.content.DialogInterface;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
+import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+import com.android.settingslib.wifi.AccessPoint;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import org.robolectric.shadows.ShadowLooper;
@@ -37,13 +53,17 @@
@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowAlertDialogCompat.class})
public class NetworkRequestDialogFragmentTest {
+ final String KEY_SSID = "key_ssid";
+
private FragmentActivity mActivity;
private NetworkRequestDialogFragment networkRequestDialogFragment;
+ private Context mContext;
@Before
public void setUp() {
mActivity = Robolectric.setupActivity(FragmentActivity.class);
networkRequestDialogFragment = spy(NetworkRequestDialogFragment.newInstance());
+ mContext = spy(RuntimeEnvironment.application);
}
@Test
@@ -88,4 +108,137 @@
bCalledStopAndPop = true;
}
}
+
+ @Test
+ public void onResume_shouldRegisterCallback() {
+ when(networkRequestDialogFragment.getContext()).thenReturn(mContext);
+ Context applicationContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ when(mContext.getApplicationContext()).thenReturn(applicationContext);
+ WifiManager wifiManager = mock(WifiManager.class);
+ when(applicationContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(wifiManager);
+
+ networkRequestDialogFragment.onResume();
+
+ verify(wifiManager).registerNetworkRequestMatchCallback(any(), any());
+ }
+
+ @Test
+ public void onPause_shouldUnRegisterCallback() {
+ when(networkRequestDialogFragment.getContext()).thenReturn(mContext);
+ Context applicationContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ when(mContext.getApplicationContext()).thenReturn(applicationContext);
+ WifiManager wifiManager = mock(WifiManager.class);
+ when(applicationContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(wifiManager);
+
+ networkRequestDialogFragment.onPause();
+
+ verify(wifiManager).unregisterNetworkRequestMatchCallback(networkRequestDialogFragment);
+ }
+
+ @Test
+ public void updateAccessPointList_onUserSelectionConnectSuccess_updateCorrectly() {
+ List<AccessPoint> accessPointList = spy(new ArrayList<>());
+ Bundle bundle = new Bundle();
+ bundle.putString(KEY_SSID, "Test AP 1");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 2");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 3");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 4");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+
+ when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
+
+ // Test if config would update list.
+ WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "Test AP 3";
+ networkRequestDialogFragment.onUserSelectionConnectSuccess(config);
+
+ AccessPoint verifyAccessPoint = new AccessPoint(mContext, config);
+ verify(accessPointList, times(1)).set(2, verifyAccessPoint);
+ }
+
+ @Test
+ public void updateAccessPointList_onUserSelectionConnectFailure_updateCorrectly() {
+ List<AccessPoint> accessPointList = spy(new ArrayList<>());
+ Bundle bundle = new Bundle();
+ bundle.putString(KEY_SSID, "Test AP 1");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 2");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 3");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 4");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+
+ when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
+
+ // Test if config would update list.
+ WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "Test AP 3";
+ networkRequestDialogFragment.onUserSelectionConnectFailure(config);
+
+ AccessPoint verifyAccessPoint = new AccessPoint(mContext, config);
+ verify(accessPointList, times(1)).set(2, verifyAccessPoint);
+ }
+
+ @Test
+ public void onUserSelectionCallbackRegistration_shouldCallSelect() {
+ List<AccessPoint> accessPointList = spy(new ArrayList<>());
+ Bundle bundle = new Bundle();
+ bundle.putString(KEY_SSID, "Test AP 1");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 2");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ bundle.putString(KEY_SSID, "Test AP 3");
+ AccessPoint clickedAccessPoint = new AccessPoint(mContext, bundle);
+ accessPointList.add(clickedAccessPoint);
+ bundle.putString(KEY_SSID, "Test AP 4");
+ accessPointList.add(new AccessPoint(mContext, bundle));
+ when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
+
+ NetworkRequestUserSelectionCallback selectionCallback = mock(
+ NetworkRequestUserSelectionCallback.class);
+ AlertDialog dialog = mock(AlertDialog.class);
+ networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
+
+ networkRequestDialogFragment.onClick(dialog, 2);
+
+ verify(selectionCallback, times(1)).select(clickedAccessPoint.getConfig());
+ }
+
+ @Test
+ public void onMatch_shouldUpdatedList() {
+ // Prepares WifiManager.
+ when(networkRequestDialogFragment.getContext()).thenReturn(mContext);
+ Context applicationContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ when(mContext.getApplicationContext()).thenReturn(applicationContext);
+ WifiManager wifiManager = mock(WifiManager.class);
+ when(applicationContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(wifiManager);
+
+ List<WifiConfiguration> wifiConfigurationList = new ArrayList<>();
+ WifiConfiguration config = new WifiConfiguration();
+ final String SSID_AP1 = "Test AP 1";
+ config.SSID = SSID_AP1;
+ wifiConfigurationList.add(config);
+ config = new WifiConfiguration();
+ final String SSID_AP2 = "Test AP 2";
+ config.SSID = SSID_AP2;
+ wifiConfigurationList.add(config);
+
+ // Prepares callback converted data.
+ List<ScanResult> scanResults = new ArrayList<>();
+ when(wifiManager.getAllMatchingWifiConfigs(scanResults)).thenReturn(wifiConfigurationList);
+
+ networkRequestDialogFragment.onMatch(scanResults);
+
+ List<AccessPoint> accessPointList = networkRequestDialogFragment.getAccessPointList();
+ assertThat(accessPointList).isNotEmpty();
+ assertThat(accessPointList.size()).isEqualTo(2);
+ assertThat(accessPointList.get(0).getSsid()).isEqualTo(SSID_AP1);
+ assertThat(accessPointList.get(1).getSsid()).isEqualTo(SSID_AP2);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index 471c991..411e68e 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -22,16 +22,19 @@
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.net.wifi.WifiManager;
import android.os.ServiceSpecificException;
import android.security.KeyStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
@@ -298,6 +301,74 @@
assertThat(hiddenField.getVisibility()).isEqualTo(View.VISIBLE);
}
+ @Test
+ public void securitySpinner_saeSuitebAndOweNotVisible() {
+ securitySpinnerTestHelper(false, false, false);
+ }
+
+ @Test
+ public void securitySpinner_saeSuitebAndOweVisible() {
+ securitySpinnerTestHelper(true, true, true);
+ }
+
+ @Test
+ public void securitySpinner_saeVisible_suitebAndOweNotVisible() {
+ securitySpinnerTestHelper(true, false, false);
+ }
+
+ @Test
+ public void securitySpinner_oweVisible_suitebAndSaeNotVisible() {
+ securitySpinnerTestHelper(false, false, true);
+ }
+
+ private void securitySpinnerTestHelper(boolean saeVisible, boolean suitebVisible,
+ boolean oweVisible) {
+ WifiManager wifiManager = mock(WifiManager.class);
+ when(wifiManager.isWpa3SaeSupported()).thenReturn(saeVisible ? true : false);
+ when(wifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible ? true : false);
+ when(wifiManager.isOweSupported()).thenReturn(oweVisible ? true : false);
+
+ mController = new TestWifiConfigController(mConfigUiBase, mView, null /* accessPoint */,
+ WifiConfigUiBase.MODE_MODIFY, wifiManager);
+
+ final Spinner securitySpinner = ((Spinner) mView.findViewById(R.id.security));
+ final ArrayAdapter<String> adapter = (ArrayAdapter) securitySpinner.getAdapter();
+ boolean saeFound = false;
+ boolean suitebFound = false;
+ boolean oweFound = false;
+ for (int i = 0; i < adapter.getCount(); i++) {
+ String val = adapter.getItem(i);
+
+ if (val.compareTo(mContext.getString(R.string.wifi_security_sae)) == 0) {
+ saeFound = true;
+ }
+
+ if (val.compareTo(mContext.getString(R.string.wifi_security_eap_suiteb)) == 0) {
+ suitebFound = true;
+ }
+
+ if (val.compareTo(mContext.getString(R.string.wifi_security_owe)) == 0) {
+ oweFound = true;
+ }
+ }
+
+ if (saeVisible) {
+ assertThat(saeFound).isTrue();
+ } else {
+ assertThat(saeFound).isFalse();
+ }
+ if (suitebVisible) {
+ assertThat(suitebFound).isTrue();
+ } else {
+ assertThat(suitebFound).isFalse();
+ }
+ if (oweVisible) {
+ assertThat(oweFound).isTrue();
+ } else {
+ assertThat(oweFound).isFalse();
+ }
+ }
+
public class TestWifiConfigController extends WifiConfigController {
private TestWifiConfigController(
@@ -305,6 +376,12 @@
super(parent, view, accessPoint, mode);
}
+ private TestWifiConfigController(
+ WifiConfigUiBase parent, View view, AccessPoint accessPoint, int mode,
+ WifiManager wifiManager) {
+ super(parent, view, accessPoint, mode, wifiManager);
+ }
+
@Override
boolean isSplitSystemUser() {
return false;
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java
index e8d13df..bbf15ad 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java
@@ -66,11 +66,11 @@
public void onPreferenceChange_securityValueUpdated() {
mController.onPreferenceChange(mPreference, WPA2_PSK);
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
- assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
+ assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
mController.onPreferenceChange(mPreference, NONE);
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.NONE);
- assertThat(mPreference.getSummary()).isEqualTo("None");
+ assertThat(mPreference.getSummary().toString()).isEqualTo("None");
}
@Test
@@ -79,7 +79,7 @@
when(mWifiManager.getWifiApConfiguration()).thenReturn(null);
mController.updateDisplay();
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
- assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
+ assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
// test open tether network
when(mWifiManager.getWifiApConfiguration()).thenReturn(mConfig);
@@ -87,13 +87,13 @@
mConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
mController.updateDisplay();
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.NONE);
- assertThat(mPreference.getSummary()).isEqualTo("None");
+ assertThat(mPreference.getSummary().toString()).isEqualTo("None");
// test WPA2-Personal tether network
mConfig.allowedKeyManagement.clear();
mConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA2_PSK);
mController.updateDisplay();
assertThat(mController.getSecurityType()).isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
- assertThat(mPreference.getSummary()).isEqualTo("WPA2-Personal");
+ assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
}
}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
new file mode 100644
index 0000000..d101c92
--- /dev/null
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.wifi.dpp;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class WifiDppConfiguratorActivityTest {
+ @Rule
+ public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
+ new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
+
+ @Test
+ public void testLaunchModeQrCodeScanner_shouldNotAutoFinish() {
+ Intent intent = new Intent();
+ intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
+ WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
+ mActivityRule.launchActivity(intent);
+
+ assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
+ mActivityRule.finishActivity();
+ }
+
+ @Test
+ public void testNoLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
+ // If we do not specify launch mode, the activity will finish itself right away
+ Intent intent = new Intent();
+ mActivityRule.launchActivity(intent);
+
+ assertThat(mActivityRule.getActivityResult().getResultCode()).
+ isEqualTo(Activity.RESULT_CANCELED);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
new file mode 100644
index 0000000..58fa61f
--- /dev/null
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.dpp;
+
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static android.support.test.espresso.Espresso.onView;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class WifiDppQrCodeScannerFragmentTest {
+ @Rule
+ public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
+ new ActivityTestRule<>(WifiDppConfiguratorActivity.class, true);
+
+ @Before
+ public void setUp() {
+ Intent intent = new Intent();
+ intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
+ WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
+ mActivityRule.launchActivity(intent);
+ }
+
+ @Test
+ public void testLeftButton_shouldFinishActivityWithResultCodeCanceled() {
+ onView(withText("Cancel")).perform(click());
+ assertThat(mActivityRule.getActivityResult().getResultCode()).
+ isEqualTo(Activity.RESULT_CANCELED);
+ }
+}