Merge "Time for dark theme doesnt format 24 hr correctly" into rvc-d1-dev am: e899f749a1 am: 5f44b7cf54
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12337522
Change-Id: I7f2ae48cbdcad2fa44d96382b7d2c175b7605f59
diff --git a/res/layout/bubble_preference.xml b/res/layout/bubble_preference.xml
index 8a64716..08f25b4 100644
--- a/res/layout/bubble_preference.xml
+++ b/res/layout/bubble_preference.xml
@@ -44,7 +44,7 @@
android:id="@+id/bubble_all_icon"
android:src="@drawable/ic_bubble_all"
android:background="@android:color/transparent"
- android:layout_gravity="center"
+ android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
@@ -53,6 +53,7 @@
android:id="@+id/bubble_all_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
android:ellipsize="end"
android:maxLines="2"
android:clickable="false"
@@ -75,7 +76,7 @@
android:id="@+id/bubble_selected_icon"
android:src="@drawable/ic_bubble_selected"
android:background="@android:color/transparent"
- android:layout_gravity="center"
+ android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
@@ -84,6 +85,7 @@
android:id="@+id/bubble_selected_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
android:ellipsize="end"
android:maxLines="2"
android:clickable="false"
@@ -106,7 +108,7 @@
android:id="@+id/bubble_none_icon"
android:src="@drawable/ic_bubble_none"
android:background="@android:color/transparent"
- android:layout_gravity="center"
+ android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
@@ -115,6 +117,7 @@
android:id="@+id/bubble_none_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
android:ellipsize="end"
android:maxLines="2"
android:clickable="false"
@@ -125,4 +128,4 @@
android:text="@string/bubble_app_setting_none"/>
</com.android.settings.notification.NotificationButtonRelativeLayout>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/notif_priority_conversation_preference.xml b/res/layout/notif_priority_conversation_preference.xml
index f68dbde..9c1a302 100644
--- a/res/layout/notif_priority_conversation_preference.xml
+++ b/res/layout/notif_priority_conversation_preference.xml
@@ -32,7 +32,7 @@
android:clickable="true"
android:focusable="true">
<ImageView
- android:id="@+id/priority_icon"
+ android:id="@+id/icon"
android:src="@drawable/ic_important_outline"
android:background="@android:color/transparent"
android:layout_gravity="center"
@@ -41,19 +41,19 @@
android:clickable="false"
android:focusable="false"/>
<TextView
- android:id="@+id/priority_label"
+ android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:clickable="false"
android:focusable="false"
- android:layout_toEndOf="@id/priority_icon"
+ android:layout_toEndOf="@id/icon"
android:layout_marginStart="@dimen/notification_importance_drawable_padding"
android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
android:text="@string/notification_priority_title"/>
<TextView
- android:id="@+id/priority_summary"
+ android:id="@+id/summary"
android:paddingTop="@dimen/notification_importance_button_padding"
android:text="@string/notification_channel_summary_priority"
android:layout_width="match_parent"
@@ -62,7 +62,7 @@
android:focusable="false"
android:ellipsize="end"
android:maxLines="3"
- android:layout_below="@id/priority_icon"
+ android:layout_below="@id/icon"
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
android:visibility="gone" />
</com.android.settings.notification.NotificationButtonRelativeLayout>
@@ -76,7 +76,7 @@
android:clickable="true"
android:focusable="true">
<ImageView
- android:id="@+id/alert_icon"
+ android:id="@+id/icon"
android:src="@drawable/ic_notifications_alert"
android:background="@android:color/transparent"
android:layout_gravity="center"
@@ -85,19 +85,19 @@
android:clickable="false"
android:focusable="false"/>
<TextView
- android:id="@+id/alert_label"
+ android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:clickable="false"
android:focusable="false"
- android:layout_toEndOf="@id/alert_icon"
+ android:layout_toEndOf="@id/icon"
android:layout_marginStart="@dimen/notification_importance_drawable_padding"
android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
android:text="@string/notification_alert_title"/>
<TextView
- android:id="@+id/alert_summary"
+ android:id="@+id/summary"
android:paddingTop="@dimen/notification_importance_button_padding"
android:text="@string/notification_channel_summary_default"
android:layout_width="match_parent"
@@ -106,7 +106,7 @@
android:focusable="false"
android:ellipsize="end"
android:maxLines="2"
- android:layout_below="@id/alert_icon"
+ android:layout_below="@id/icon"
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
android:visibility="gone" />
</com.android.settings.notification.NotificationButtonRelativeLayout>
@@ -120,7 +120,7 @@
android:clickable="true"
android:focusable="true">
<ImageView
- android:id="@+id/silence_icon"
+ android:id="@+id/icon"
android:src="@drawable/ic_notifications_off_24dp"
android:background="@android:color/transparent"
android:layout_gravity="center"
@@ -129,19 +129,19 @@
android:clickable="false"
android:focusable="false"/>
<TextView
- android:id="@+id/silence_label"
+ android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:clickable="false"
android:focusable="false"
- android:layout_toEndOf="@id/silence_icon"
+ android:layout_toEndOf="@id/icon"
android:layout_marginStart="@dimen/notification_importance_drawable_padding"
android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
android:text="@string/notification_silence_title"/>
<TextView
- android:id="@+id/silence_summary"
+ android:id="@+id/summary"
android:paddingTop="@dimen/notification_importance_button_padding"
android:text="@string/notification_conversation_summary_low"
android:layout_width="match_parent"
@@ -150,7 +150,7 @@
android:focusable="false"
android:ellipsize="end"
android:maxLines="2"
- android:layout_below="@id/silence_icon"
+ android:layout_below="@id/icon"
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
android:visibility="gone" />
</com.android.settings.notification.NotificationButtonRelativeLayout>
diff --git a/res/layout/notification_history_app_layout.xml b/res/layout/notification_history_app_layout.xml
index a1b3be7..aaca0fd 100644
--- a/res/layout/notification_history_app_layout.xml
+++ b/res/layout/notification_history_app_layout.xml
@@ -24,6 +24,7 @@
android:id="@+id/app_header"
android:layout_height="wrap_content"
android:layout_width="match_parent"
+ android:background="@drawable/button_ripple_radius"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="16dp">
@@ -54,17 +55,19 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingStart="6dp"
- android:layout_gravity="center_vertical"
+ android:layout_gravity="start|center_vertical"
+ android:textDirection="locale"
android:paddingTop="8dp"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"/>
</LinearLayout>
- <ImageButton
+ <ImageView
android:id="@+id/expand"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_height="48dp"
android:layout_width="48dp"
- android:background="@drawable/button_ripple_radius"
+ android:scaleType="center"
+ android:contentDescription="@null"
android:src="@*android:drawable/ic_expand_more"/>
</RelativeLayout>
diff --git a/res/layout/notification_sbn_log_row.xml b/res/layout/notification_sbn_log_row.xml
index 6156d26..ee143b0 100644
--- a/res/layout/notification_sbn_log_row.xml
+++ b/res/layout/notification_sbn_log_row.xml
@@ -130,6 +130,6 @@
<View
android:id="@+id/divider"
android:layout_width="match_parent"
- android:layout_height="0.5dp"
- android:background="@color/material_grey_300" />
+ android:layout_height="wrap_content"
+ android:background="?android:attr/listDivider" />
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/settings_base_layout.xml b/res/layout/settings_base_layout.xml
index 0a4437e..9fbc2a2 100644
--- a/res/layout/settings_base_layout.xml
+++ b/res/layout/settings_base_layout.xml
@@ -26,8 +26,7 @@
style="?android:attr/actionBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:theme="?android:attr/actionBarTheme"
- android:navigationContentDescription="@*android:string/back_button_label" />
+ android:theme="?android:attr/actionBarTheme" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 45ecd61..1914462 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -141,6 +141,24 @@
android:prompt="@string/wifi_eap_method" />
</LinearLayout>
+ <LinearLayout android:id="@+id/l_sim"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ style="@style/wifi_item" >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item_label"
+ android:text="@string/sim_card" />
+
+ <Spinner android:id="@+id/sim"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item_spinner"
+ android:prompt="@string/sim_card" />
+ </LinearLayout>
+
<LinearLayout android:id="@+id/l_phase2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -196,18 +214,6 @@
android:entries="@array/eap_ocsp_type" />
</LinearLayout>
- <LinearLayout android:id="@+id/no_ca_cert_warning"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone"
- style="@style/wifi_item" >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/wifi_item_warning"
- android:text="@string/wifi_do_not_validate_eap_server_warning" />
- </LinearLayout>
-
<LinearLayout android:id="@+id/l_domain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 4ce02ee..354da77 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -27,6 +27,7 @@
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
<color name="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->
<color name="notification_importance_button_unselected">#5F6368</color>
+ <color name="notification_history_background">#202124</color>
<color name="face_intro_outline">?android:attr/colorAccent</color>
<!-- Palette list preference colors. -->
<color name="palette_list_gradient_background">@android:color/black</color>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 06f135f..4904160 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -129,6 +129,7 @@
<color name="notification_importance_button_unselected">#DADCE0</color>
<color name="notification_importance_button_selected">#1967D2</color> <!-- material blue 700 -->
<color name="notification_importance_selection_bg">#FFFFFF</color>
+ <color name="notification_history_background">?android:attr/colorBackgroundFloating</color>
<!-- launcher icon color -->
<color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4543360..ca973d3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -730,6 +730,12 @@
<string name="security_settings_face_enroll_education_message"></string>
<!-- Button that takes the user to the enrollment activity [CHAR LIMIT=20] -->
<string name="security_settings_face_enroll_education_start">Start</string>
+ <!-- Confirmation dialog message shown when users with system accessibility features enabled try to start the non-accessibility version of enrollment [CHAR LIMIT=150] -->
+ <string name="security_settings_face_enroll_education_accessibility_dialog_message">If accessibility face unlock is turned off, some setup steps may not work properly with TalkBack.</string>
+ <!-- Negative button text for users who were shown the accessibility dialog [CHAR LIMIT=10] -->
+ <string name="security_settings_face_enroll_education_accessibility_dialog_negative">Go back</string>
+ <!-- Positive button text for users who were shown the accessibility dialog [CHAR LIMIT=20] -->
+ <string name="security_settings_face_enroll_education_accessibility_dialog_positive">Continue setup</string>
<!-- Button shown which shows accessibility toggles for face enrollment when clicked. [CHAR LIMIT=32] -->
<string name="security_settings_face_enroll_introduction_accessibility">Use accessibility setup</string>
<!-- Additional details shown when the accessibility toggle is expanded. [CHAR LIMIT=NONE]-->
@@ -2112,9 +2118,7 @@
when signal of the Wi-Fi network is reachable [CHAR LIMIT=50] -->
<string name="wifi_auto_connect_title">Auto\u2011connect</string>
<!-- Hint for Wi-Fi Auto-connect [CHAR LIMIT=NONE] -->
- <string name="wifi_auto_connect_summary" product="default">Allow phone to automatically connect near this network</string>
- <!-- Hint for Wi-Fi Auto-connect [CHAR LIMIT=NONE] -->
- <string name="wifi_auto_connect_summary" product="tablet">Allow tablet to automatically connect near this network</string>
+ <string name="wifi_auto_connect_summary">Allow connection to this network when in range</string>
<!-- Label for "Use a QR code to add a device to this network" [CHAR LIMIT=50] -->
<string name="wifi_dpp_add_device">Add device</string>
<!-- Hint for "Add device" [CHAR LIMIT=NONE] -->
@@ -2137,8 +2141,6 @@
<string name="wifi_do_not_provide_eap_user_cert">Do not provide</string>
<!-- Menu option for not validating the EAP server -->
<string name="wifi_do_not_validate_eap_server">Do not validate</string>
- <!-- Warning message displayed if user choses not to validate the EAP server -->
- <string name="wifi_do_not_validate_eap_server_warning">No certificate specified. Your connection will not be private.</string>
<!-- Warning message displayed if network name (ssid) is too long -->
<string name="wifi_ssid_too_long">Network name is too long.</string>
<!-- Warning message displayed if user does not specify a domain for the CA certificate.
@@ -11473,6 +11475,17 @@
<!-- Message informs the user that has no SIM card in personalized Settings [CHAR LIMIT=30] -->
<string name="no_sim_card">No SIM card</string>
+ <!-- A title for a SIM card spinner UI component which users can choose a SIM card. [CHAR LIMIT=NONE] -->
+ <string name="sim_card">SIM</string>
+ <!-- A label when there is no SIM card to choose. [CHAR LIMIT=NONE] -->
+ <string name="wifi_no_sim_card">No SIM</string>
+ <!-- A label when there is no SIM card information of a Wi-Fi network. [CHAR LIMIT=NONE] -->
+ <string name="wifi_no_related_sim_card">None</string>
+ <!-- A label wen a user needs a SIM to connect to the Wi-Fi network. [CHAR LIMIT=NONE] -->
+ <string name="wifi_require_sim_card_to_connect">Requires SIM to connect</string>
+ <!-- A label wen a user needs a specific SIM to connect to the Wi-Fi network. [CHAR LIMIT=NONE] -->
+ <string name="wifi_require_specific_sim_card_to_connect">Requires <xliff:g id="wireless_carrier" example="Verizon">%s</xliff:g> SIM to connect</string>
+
<!-- The following strings are summaries for preferred network modes in Mobile network settings,
and have a character limit of 100 -->
<!-- WCDMA preferred [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c74a1a2..1be8ba0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -618,7 +618,7 @@
<style name="TextAppearance.NotificationImportanceButton">
<item name="android:textSize">@dimen/notification_importance_button_text</item>
- <item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
+ <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
<item name="android:gravity">center</item>
</style>
diff --git a/res/xml/wifi_network_details_fragment2.xml b/res/xml/wifi_network_details_fragment2.xml
index 92f68cc..181b799 100644
--- a/res/xml/wifi_network_details_fragment2.xml
+++ b/res/xml/wifi_network_details_fragment2.xml
@@ -106,6 +106,11 @@
android:selectable="false"
settings:enableCopying="true"/>
<Preference
+ android:key="eap_sim_subscription"
+ android:title="@string/sim_card"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="mac_address"
android:title="@string/wifi_advanced_randomized_mac_address_title"
android:selectable="false"
diff --git a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
index 58907a7..28e0850 100644
--- a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
+++ b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
@@ -58,12 +58,12 @@
// Filters will appear sorted based on their value defined here.
public static final int FILTER_APPS_POWER_WHITELIST = 0;
public static final int FILTER_APPS_POWER_WHITELIST_ALL = 1;
- public static final int FILTER_APPS_ALL = 2;
- public static final int FILTER_APPS_ENABLED = 3;
- public static final int FILTER_APPS_INSTANT = 4;
- public static final int FILTER_APPS_DISABLED = 5;
- public static final int FILTER_APPS_RECENT = 6;
- public static final int FILTER_APPS_FREQUENT = 7;
+ public static final int FILTER_APPS_RECENT = 2;
+ public static final int FILTER_APPS_FREQUENT = 3;
+ public static final int FILTER_APPS_ALL = 4;
+ public static final int FILTER_APPS_ENABLED = 5;
+ public static final int FILTER_APPS_INSTANT = 6;
+ public static final int FILTER_APPS_DISABLED = 7;
public static final int FILTER_APPS_PERSONAL = 8;
public static final int FILTER_APPS_WORK = 9;
public static final int FILTER_APPS_USAGE_ACCESS = 10;
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 5ef1232..b46e11c 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -476,7 +476,7 @@
mFilterAdapter.enableFilter(FILTER_APPS_RECENT);
mFilterAdapter.enableFilter(FILTER_APPS_FREQUENT);
mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
- mFilterAdapter.disableFilter(FILTER_APPS_ALL);
+ mFilterAdapter.enableFilter(FILTER_APPS_ALL);
}
if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
@@ -1089,12 +1089,16 @@
mAppFilter = appFilter;
// Notification filters require resorting the list
- if (FILTER_APPS_FREQUENT == appFilter.getFilterType()) {
- rebuild(R.id.sort_order_frequent_notification);
- } else if (FILTER_APPS_RECENT == appFilter.getFilterType()) {
- rebuild(R.id.sort_order_recent_notification);
- } else if (FILTER_APPS_BLOCKED == appFilter.getFilterType()) {
- rebuild(R.id.sort_order_alpha);
+ if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
+ if (FILTER_APPS_FREQUENT == appFilter.getFilterType()) {
+ rebuild(R.id.sort_order_frequent_notification);
+ } else if (FILTER_APPS_RECENT == appFilter.getFilterType()) {
+ rebuild(R.id.sort_order_recent_notification);
+ } else if (FILTER_APPS_BLOCKED == appFilter.getFilterType()) {
+ rebuild(R.id.sort_order_alpha);
+ } else {
+ rebuild(R.id.sort_order_alpha);
+ }
} else {
rebuild();
}
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
index 727870c..e6b389a 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
@@ -40,20 +40,13 @@
private static final String TAG = "ZenAccessController";
- private final ActivityManager mActivityManager;
-
public ZenAccessController(Context context, String preferenceKey) {
super(context, preferenceKey);
- mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
}
@Override
public int getAvailabilityStatus() {
- return isSupported(mActivityManager) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
- }
-
- public static boolean isSupported(ActivityManager activityManager) {
- return !activityManager.isLowRamDevice();
+ return AVAILABLE;
}
public static Set<String> getPackagesRequestingNotificationPolicyAccess() {
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java
index a18e7d6..ba6bb1d 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java
@@ -50,9 +50,6 @@
@Override
protected boolean refreshUi() {
final Context context = getContext();
- if (!ZenAccessController.isSupported(context.getSystemService(ActivityManager.class))) {
- return false;
- }
// If this app didn't declare this permission in their manifest, don't bother showing UI.
final Set<String> needAccessApps =
ZenAccessController.getPackagesRequestingNotificationPolicyAccess();
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixin.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixin.java
index 30507ef..da238f6 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixin.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixin.java
@@ -53,9 +53,6 @@
@Override
public void onStart() {
- if (!ZenAccessController.isSupported(mContext.getSystemService(ActivityManager.class))) {
- return;
- }
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(
Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES),
@@ -69,9 +66,6 @@
@Override
public void onStop() {
- if (!ZenAccessController.isSupported(mContext.getSystemService(ActivityManager.class))) {
- return;
- }
mContext.getContentResolver().unregisterContentObserver(this /* observer */);
}
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityDialog.java b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityDialog.java
new file mode 100644
index 0000000..7042870
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityDialog.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.biometrics.face;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+
+/**
+ * Confirmation dialog shown to users with accessibility enabled who are trying to start the
+ * non-accessibility enrollment flow.
+ */
+public class FaceEnrollAccessibilityDialog extends InstrumentedDialogFragment {
+ private AlertDialog.OnClickListener mPositiveButtonListener;
+
+ /**
+ * @return new instance of the dialog
+ */
+ public static FaceEnrollAccessibilityDialog newInstance() {
+ return new FaceEnrollAccessibilityDialog();
+ }
+
+ public void setPositiveButtonListener(AlertDialog.OnClickListener listener) {
+ mPositiveButtonListener = listener;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+
+ final int titleResId =
+ R.string.security_settings_face_enroll_education_accessibility_dialog_message;
+ final int negativeButtonResId =
+ R.string.security_settings_face_enroll_education_accessibility_dialog_negative;
+ final int positiveButtonResId =
+ R.string.security_settings_face_enroll_education_accessibility_dialog_positive;
+
+ builder.setMessage(titleResId)
+ .setNegativeButton(negativeButtonResId, (dialog, which) -> {
+ dialog.cancel();
+ })
+ .setPositiveButton(positiveButtonResId, (dialog, which) -> {
+ mPositiveButtonListener.onClick(dialog, which);
+ });
+
+ return builder.create();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.FACE_ENROLL_INTRO;
+ }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index 3b84c35..4c4fa11 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -55,6 +55,7 @@
private Intent mResultIntent;
private TextView mDescriptionText;
private boolean mNextClicked;
+ private boolean mAccessibilityEnabled;
private CompoundButton.OnCheckedChangeListener mSwitchDiversityListener =
new CompoundButton.OnCheckedChangeListener() {
@@ -123,13 +124,12 @@
.setTheme(R.style.SudGlifButton_Primary)
.build();
- boolean accessibilityEnabled = false;
final AccessibilityManager accessibilityManager = getApplicationContext().getSystemService(
AccessibilityManager.class);
if (accessibilityManager != null) {
// Add additional check for touch exploration. This prevents other accessibility
// features such as Live Transcribe from defaulting to the accessibility setup.
- accessibilityEnabled = accessibilityManager.isEnabled()
+ mAccessibilityEnabled = accessibilityManager.isEnabled()
&& accessibilityManager.isTouchExplorationEnabled();
}
mFooterBarMixin.setPrimaryButton(footerButton);
@@ -147,7 +147,7 @@
mSwitchDiversity.getSwitch().toggle();
});
- if (accessibilityEnabled) {
+ if (mAccessibilityEnabled) {
accessibilityButton.callOnClick();
}
}
@@ -194,9 +194,20 @@
if (mResultIntent != null) {
intent.putExtras(mResultIntent);
}
- mNextClicked = true;
+
intent.putExtra(EXTRA_KEY_REQUIRE_DIVERSITY, !mSwitchDiversity.isChecked());
- startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
+
+ if (!mSwitchDiversity.isChecked() && mAccessibilityEnabled) {
+ FaceEnrollAccessibilityDialog dialog = FaceEnrollAccessibilityDialog.newInstance();
+ dialog.setPositiveButtonListener((dialog1, which) -> {
+ startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
+ mNextClicked = true;
+ });
+ dialog.show(getSupportFragmentManager(), FaceEnrollAccessibilityDialog.class.getName());
+ } else {
+ startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
+ mNextClicked = true;
+ }
}
protected void onSkipButtonClick(View view) {
diff --git a/src/com/android/settings/notification/app/BlockPreferenceController.java b/src/com/android/settings/notification/app/BlockPreferenceController.java
index f55ea8c..2738962 100644
--- a/src/com/android/settings/notification/app/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/app/BlockPreferenceController.java
@@ -106,8 +106,11 @@
// It's always safe to override the importance if it's meant to be blocked or if
// it was blocked and we are unblocking it.
if (blocked || originalImportance == IMPORTANCE_NONE) {
- final int importance = blocked ? IMPORTANCE_NONE
- : isDefaultChannel() ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_DEFAULT;
+ final int importance = blocked
+ ? IMPORTANCE_NONE
+ : isDefaultChannel()
+ ? IMPORTANCE_UNSPECIFIED
+ : mChannel.getOriginalImportance();
mChannel.setImportance(importance);
saveChannel();
}
diff --git a/src/com/android/settings/notification/app/BubblePreference.java b/src/com/android/settings/notification/app/BubblePreference.java
index 7e071ff..f0046d7 100644
--- a/src/com/android/settings/notification/app/BubblePreference.java
+++ b/src/com/android/settings/notification/app/BubblePreference.java
@@ -45,8 +45,6 @@
private int mSelectedPreference;
private Context mContext;
- private Drawable mSelectedBackground;
- private Drawable mUnselectedBackground;
private ButtonViewHolder mBubbleAllButton;
private ButtonViewHolder mBubbleSelectedButton;
@@ -72,8 +70,6 @@
mHelper = new RestrictedPreferenceHelper(context, this, attrs);
mHelper.useAdminDisabledSummary(true);
mContext = context;
- mSelectedBackground = mContext.getDrawable(R.drawable.button_border_selected);
- mUnselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected);
setLayoutResource(R.layout.bubble_preference);
}
@@ -167,7 +163,9 @@
}
void setSelected(Context context, boolean selected) {
- mView.setBackground(selected ? mSelectedBackground : mUnselectedBackground);
+ mView.setBackground(mContext.getDrawable(selected
+ ? R.drawable.button_border_selected
+ : R.drawable.button_border_unselected));
mView.setSelected(selected);
ColorStateList stateList = selected
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index b19fc71..8a34672 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -207,17 +207,14 @@
channelPref.setOnPreferenceChangeListener(
(preference, o) -> {
boolean value = (Boolean) o;
- int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
+ int importance = value ? channel.getOriginalImportance() : IMPORTANCE_NONE;
channel.setImportance(importance);
- channel.lockFields(
- NotificationChannel.USER_LOCKED_IMPORTANCE);
+ channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
channelPref1.setIcon(null);
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref1.setIcon(getAlertingIcon());
}
- toggleBehaviorIconState(channelPref1.getIcon(),
- importance != IMPORTANCE_NONE);
mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel);
return true;
@@ -234,24 +231,6 @@
return icon;
}
- private void toggleBehaviorIconState(Drawable icon, boolean enabled) {
- if (icon == null) return;
-
- LayerDrawable layerDrawable = (LayerDrawable) icon;
- GradientDrawable background =
- (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back);
-
- if (background == null) return;
-
- if (enabled) {
- background.clearColorFilter();
- } else {
- background.setColorFilter(new BlendModeColorFilter(
- mContext.getColor(R.color.material_grey_300),
- BlendMode.SRC_IN));
- }
- }
-
protected void onGroupBlockStateChanged(NotificationChannelGroup group) {
if (group == null) {
return;
diff --git a/src/com/android/settings/notification/app/ConversationPriorityPreference.java b/src/com/android/settings/notification/app/ConversationPriorityPreference.java
index 307abec..67bffbf 100644
--- a/src/com/android/settings/notification/app/ConversationPriorityPreference.java
+++ b/src/com/android/settings/notification/app/ConversationPriorityPreference.java
@@ -50,8 +50,6 @@
private View mAlertButton;
private View mPriorityButton;
private Context mContext;
- Drawable selectedBackground;
- Drawable unselectedBackground;
private static final int BUTTON_ANIM_TIME_MS = 100;
public ConversationPriorityPreference(Context context, AttributeSet attrs,
@@ -77,8 +75,6 @@
private void init(Context context) {
mContext = context;
- selectedBackground = mContext.getDrawable(R.drawable.button_border_selected);
- unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected);
setLayoutResource(R.layout.notif_priority_conversation_preference);
}
@@ -148,86 +144,43 @@
TransitionManager.beginDelayedTransition(parent, transition);
}
- ColorStateList colorAccent = getAccentTint();
- ColorStateList colorNormal = getRegularTint();
- ImageView silenceIcon = parent.findViewById(R.id.silence_icon);
- TextView silenceLabel = parent.findViewById(R.id.silence_label);
- TextView silenceSummary = parent.findViewById(R.id.silence_summary);
- ImageView alertIcon = parent.findViewById(R.id.alert_icon);
- TextView alertLabel = parent.findViewById(R.id.alert_label);
- TextView alertSummary = parent.findViewById(R.id.alert_summary);
- ImageView priorityIcon = parent.findViewById(R.id.priority_icon);
- TextView priorityLabel = parent.findViewById(R.id.priority_label);
- TextView prioritySummary = parent.findViewById(R.id.priority_summary);
-
if (importance <= IMPORTANCE_LOW && importance > IMPORTANCE_UNSPECIFIED) {
- alertSummary.setVisibility(GONE);
- alertIcon.setImageTintList(colorNormal);
- alertLabel.setTextColor(colorNormal);
-
- prioritySummary.setVisibility(GONE);
- priorityIcon.setImageTintList(colorNormal);
- priorityLabel.setTextColor(colorNormal);
-
- silenceIcon.setImageTintList(colorAccent);
- silenceLabel.setTextColor(colorAccent);
- silenceSummary.setVisibility(VISIBLE);
-
- mAlertButton.setBackground(unselectedBackground);
- mPriorityButton.setBackground(unselectedBackground);
- mSilenceButton.setBackground(selectedBackground);
- // a11y service won't always read the newly appearing text in the right order if the
- // selection happens too soon (readback happens on a different thread as layout). post
- // the selection to make that conflict less likely
- parent.post(() -> {
- mSilenceButton.setSelected(true);
- mAlertButton.setSelected(false);
- mPriorityButton.setSelected(false);
- });
+ setSelected(mPriorityButton, false);
+ setSelected(mAlertButton, false);
+ setSelected(mSilenceButton, true);
} else {
if (isPriority) {
- alertSummary.setVisibility(GONE);
- alertIcon.setImageTintList(colorNormal);
- alertLabel.setTextColor(colorNormal);
-
- prioritySummary.setVisibility(VISIBLE);
- priorityIcon.setImageTintList(colorAccent);
- priorityLabel.setTextColor(colorAccent);
-
- silenceIcon.setImageTintList(colorNormal);
- silenceLabel.setTextColor(colorNormal);
- silenceSummary.setVisibility(GONE);
-
- mAlertButton.setBackground(unselectedBackground);
- mPriorityButton.setBackground(selectedBackground);
- mSilenceButton.setBackground(unselectedBackground);
- parent.post(() -> {
- mSilenceButton.setSelected(false);
- mAlertButton.setSelected(false);
- mPriorityButton.setSelected(true);
- });
+ setSelected(mPriorityButton, true);
+ setSelected(mAlertButton, false);
+ setSelected(mSilenceButton, false);
} else {
- alertSummary.setVisibility(VISIBLE);
- alertIcon.setImageTintList(colorAccent);
- alertLabel.setTextColor(colorAccent);
-
- prioritySummary.setVisibility(GONE);
- priorityIcon.setImageTintList(colorNormal);
- priorityLabel.setTextColor(colorNormal);
-
- silenceIcon.setImageTintList(colorNormal);
- silenceLabel.setTextColor(colorNormal);
- silenceSummary.setVisibility(GONE);
-
- mAlertButton.setBackground(selectedBackground);
- mPriorityButton.setBackground(unselectedBackground);
- mSilenceButton.setBackground(unselectedBackground);
- parent.post(() -> {
- mSilenceButton.setSelected(false);
- mAlertButton.setSelected(true);
- mPriorityButton.setSelected(false);
- });
+ setSelected(mPriorityButton, false);
+ setSelected(mAlertButton, true);
+ setSelected(mSilenceButton, false);
}
}
}
+
+ void setSelected(View view, boolean selected) {
+ ColorStateList colorAccent = getAccentTint();
+ ColorStateList colorNormal = getRegularTint();
+
+ ImageView icon = view.findViewById(R.id.icon);
+ TextView label = view.findViewById(R.id.label);
+ TextView summary = view.findViewById(R.id.summary);
+
+ icon.setImageTintList(selected ? colorAccent : colorNormal);
+ label.setTextColor(selected ? colorAccent : colorNormal);
+ summary.setVisibility(selected ? VISIBLE : GONE);
+
+ view.setBackground(mContext.getDrawable(selected
+ ? R.drawable.button_border_selected
+ : R.drawable.button_border_unselected));
+ // a11y service won't always read the newly appearing text in the right order if the
+ // selection happens too soon (readback happens on a different thread as layout). post
+ // the selection to make that conflict less likely
+ view.post(() -> {
+ view.setSelected(selected);
+ });
+ }
}
diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
index 7635a4f..b184740 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
@@ -155,21 +155,22 @@
final View container = viewForPackage.findViewById(R.id.notification_list);
container.setVisibility(View.GONE);
- ImageButton expand = viewForPackage.findViewById(R.id.expand);
- expand.setContentDescription(container.getVisibility() == View.VISIBLE
+ View header = viewForPackage.findViewById(R.id.app_header);
+ ImageView expand = viewForPackage.findViewById(R.id.expand);
+ header.setStateDescription(container.getVisibility() == View.VISIBLE
? getString(R.string.condition_expand_hide)
: getString(R.string.condition_expand_show));
int finalI = i;
- expand.setOnClickListener(v -> {
+ header.setOnClickListener(v -> {
container.setVisibility(container.getVisibility() == View.VISIBLE
? View.GONE : View.VISIBLE);
expand.setImageResource(container.getVisibility() == View.VISIBLE
? R.drawable.ic_expand_less
: com.android.internal.R.drawable.ic_expand_more);
- expand.setContentDescription(container.getVisibility() == View.VISIBLE
+ header.setStateDescription(container.getVisibility() == View.VISIBLE
? getString(R.string.condition_expand_hide)
: getString(R.string.condition_expand_show));
- expand.sendAccessibilityEvent(TYPE_VIEW_ACCESSIBILITY_FOCUSED);
+ header.sendAccessibilityEvent(TYPE_VIEW_ACCESSIBILITY_FOCUSED);
mUiEventLogger.logWithPosition(
(container.getVisibility() == View.VISIBLE)
? NotificationHistoryEvent.NOTIFICATION_HISTORY_PACKAGE_HISTORY_OPEN
diff --git a/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java b/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
index 4991548..da1ed11 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
@@ -33,7 +33,6 @@
NotificationHistoryViewHolder(View itemView) {
super(itemView);
mTime = itemView.findViewById(R.id.timestamp);
- mTime.setShowRelativeTime(true);
mTitle = itemView.findViewById(R.id.title);
mSummary = itemView.findViewById(R.id.text);
}
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index ae36f35..6bd4c24 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -20,6 +20,7 @@
import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS;
import static android.provider.Settings.EXTRA_ENABLE_MMS_DATA_REQUEST_REASON;
import static android.provider.Settings.EXTRA_SUB_ID;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
@@ -209,6 +210,7 @@
.setContentText(resources.getText(R.string.sim_notification_summary))
.setAutoCancel(true);
Intent resultIntent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
+ resultIntent.setPackage(SETTINGS_PACKAGE_NAME);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 1579188..07d270d 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -37,6 +37,8 @@
import android.os.UserManager;
import android.security.Credentials;
import android.security.KeyStore;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.text.Editable;
import android.text.InputType;
import android.text.SpannableString;
@@ -80,7 +82,9 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.stream.Collectors;
/**
@@ -159,11 +163,11 @@
private String mMultipleCertSetString;
private String mUseSystemCertsString;
private String mDoNotProvideEapUserCertString;
- private String mDoNotValidateEapServerString;
private ScrollView mDialogContainer;
private Spinner mSecuritySpinner;
- private Spinner mEapMethodSpinner;
+ @VisibleForTesting Spinner mEapMethodSpinner;
+ @VisibleForTesting Spinner mEapSimSpinner; // For EAP-SIM, EAP-AKA and EAP-AKA-PRIME.
private Spinner mEapCaCertSpinner;
private Spinner mEapOcspSpinner;
private TextView mEapDomainView;
@@ -209,6 +213,8 @@
private final WifiManager mWifiManager;
+ private final List<SubscriptionInfo> mActiveSubscriptionInfos = new ArrayList<>();
+
public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
int mode) {
this (parent, view, accessPoint, mode, true /* requestFocus */);
@@ -264,8 +270,6 @@
mUseSystemCertsString = mContext.getString(R.string.wifi_use_system_certs);
mDoNotProvideEapUserCertString =
mContext.getString(R.string.wifi_do_not_provide_eap_user_cert);
- mDoNotValidateEapServerString =
- mContext.getString(R.string.wifi_do_not_validate_eap_server);
mSsidScanButton = (ImageButton) mView.findViewById(R.id.ssid_scanner_button);
mDialogContainer = mView.findViewById(R.id.dialog_scrollview);
@@ -554,12 +558,10 @@
// Disallow submit if the user has not selected a CA certificate for an EAP network
// configuration.
enabled = false;
- }
- if (caCertSelection.equals(mUseSystemCertsString)
- && mEapDomainView != null
+ } else if (mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
- // Disallow submit if the user chooses to use system certificates for EAP server
+ // Disallow submit if the user chooses to use a certificate for EAP server
// validation, but does not provide a domain.
enabled = false;
}
@@ -577,7 +579,6 @@
}
void showWarningMessagesIfAppropriate() {
- mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_user_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_domain_warning).setVisibility(View.GONE);
mView.findViewById(R.id.ssid_too_long_warning).setVisibility(View.GONE);
@@ -590,19 +591,11 @@
}
if (mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
- String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
- if (caCertSelection.equals(mDoNotValidateEapServerString)) {
- // Display warning if user chooses not to validate the EAP server with a
- // user-supplied CA certificate in an EAP network configuration.
- mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.VISIBLE);
- }
- if (caCertSelection.equals(mUseSystemCertsString)
- && mEapDomainView != null
+ if (mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
- // Display warning if user chooses to use pre-installed public CA certificates
- // without restricting the server domain that these certificates can be used to
- // validate.
+ // Display warning if user chooses to use a certificate without restricting the
+ // server domain that these certificates can be used to validate.
mView.findViewById(R.id.no_domain_warning).setVisibility(View.VISIBLE);
}
}
@@ -736,8 +729,7 @@
config.enterpriseConfig.setCaCertificateAliases(null);
config.enterpriseConfig.setCaPath(null);
config.enterpriseConfig.setDomainSuffixMatch(mEapDomainView.getText().toString());
- if (caCert.equals(mUnspecifiedCertString)
- || caCert.equals(mDoNotValidateEapServerString)) {
+ if (caCert.equals(mUnspecifiedCertString)) {
// ca_cert already set to null, so do nothing.
} else if (caCert.equals(mUseSystemCertsString)) {
config.enterpriseConfig.setCaPath(SYSTEM_CA_STORE_PATH);
@@ -771,8 +763,7 @@
}
// Only set OCSP option if there is a valid CA certificate.
- if (caCert.equals(mUnspecifiedCertString)
- || caCert.equals(mDoNotValidateEapServerString)) {
+ if (caCert.equals(mUnspecifiedCertString)) {
config.enterpriseConfig.setOcsp(WifiEnterpriseConfig.OCSP_NONE);
} else {
config.enterpriseConfig.setOcsp(mEapOcspSpinner.getSelectedItemPosition());
@@ -825,6 +816,12 @@
return null;
}
+ if (config.enterpriseConfig.isAuthenticationSimBased()
+ && mActiveSubscriptionInfos.size() > 0) {
+ config.carrierId = mActiveSubscriptionInfos
+ .get(mEapSimSpinner.getSelectedItemPosition()).getCarrierId();
+ }
+
config.setIpConfiguration(
new IpConfiguration(mIpAssignment, mProxySettings,
mStaticIpConfiguration, mHttpProxy));
@@ -1013,6 +1010,7 @@
initiateEnterpriseNetworkUi = true;
mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method);
mEapMethodSpinner.setOnItemSelectedListener(this);
+ mEapSimSpinner = (Spinner) mView.findViewById(R.id.sim);
mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
mPhase2Spinner.setOnItemSelectedListener(this);
mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
@@ -1049,18 +1047,20 @@
}
if (refreshCertificates) {
+ loadSims();
+
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
- mDoNotValidateEapServerString,
- false,
- true);
+ null /* noCertificateString */,
+ false /* showMultipleCerts */,
+ true /* showUsePreinstalledCertOption */);
loadCertificates(
mEapUserCertSpinner,
Credentials.USER_PRIVATE_KEY,
mDoNotProvideEapUserCertString,
- false,
- false);
+ false /* showMultipleCerts */,
+ false /* showUsePreinstalledCertOption */);
// To avoid the user connects to a non-secure network unexpectedly,
// request using system trusted certificates by default
// unless the user explicitly chooses "Do not validate" or other
@@ -1070,9 +1070,10 @@
// Modifying an existing network
if (initiateEnterpriseNetworkUi && mAccessPoint != null && mAccessPoint.isSaved()) {
- WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
- int eapMethod = enterpriseConfig.getEapMethod();
- int phase2Method = enterpriseConfig.getPhase2Method();
+ final WifiConfiguration wifiConfig = mAccessPoint.getConfig();
+ final WifiEnterpriseConfig enterpriseConfig = wifiConfig.enterpriseConfig;
+ final int eapMethod = enterpriseConfig.getEapMethod();
+ final int phase2Method = enterpriseConfig.getPhase2Method();
mEapMethodSpinner.setSelection(eapMethod);
showEapFieldsByMethod(eapMethod);
switch (eapMethod) {
@@ -1120,12 +1121,22 @@
default:
break;
}
+
+ if (enterpriseConfig.isAuthenticationSimBased()) {
+ for (int i = 0; i < mActiveSubscriptionInfos.size(); i++) {
+ if (wifiConfig.carrierId == mActiveSubscriptionInfos.get(i).getCarrierId()) {
+ mEapSimSpinner.setSelection(i);
+ break;
+ }
+ }
+ }
+
if (!TextUtils.isEmpty(enterpriseConfig.getCaPath())) {
setSelection(mEapCaCertSpinner, mUseSystemCertsString);
} else {
String[] caCerts = enterpriseConfig.getCaCertificateAliases();
if (caCerts == null) {
- setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
+ setSelection(mEapCaCertSpinner, mUnspecifiedCertString);
} else if (caCerts.length == 1) {
setSelection(mEapCaCertSpinner, caCerts[0]);
} else {
@@ -1133,9 +1144,9 @@
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
- mDoNotValidateEapServerString,
- true,
- true);
+ null /* noCertificateString */,
+ true /* showMultipleCerts */,
+ true /* showUsePreinstalledCertOption */);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
}
}
@@ -1208,6 +1219,7 @@
mView.findViewById(R.id.l_ocsp).setVisibility(View.VISIBLE);
mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.l_sim).setVisibility(View.VISIBLE);
Context context = mConfigUi.getContext();
switch (eapMethod) {
@@ -1218,12 +1230,14 @@
setDomainInvisible();
setAnonymousIdentInvisible();
setUserCertInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
case WIFI_EAP_METHOD_TLS:
mView.findViewById(R.id.l_user_cert).setVisibility(View.VISIBLE);
setPhase2Invisible();
setAnonymousIdentInvisible();
setPasswordInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
case WIFI_EAP_METHOD_PEAP:
// Reset adapter if needed
@@ -1245,6 +1259,7 @@
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
setUserCertInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
case WIFI_EAP_METHOD_SIM:
case WIFI_EAP_METHOD_AKA:
@@ -1262,8 +1277,7 @@
if (mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
String eapCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
- if (eapCertSelection.equals(mDoNotValidateEapServerString)
- || eapCertSelection.equals(mUnspecifiedCertString)) {
+ if (eapCertSelection.equals(mUnspecifiedCertString)) {
// Domain suffix matching is not relevant if the user hasn't chosen a CA
// certificate yet, or chooses not to validate the EAP server.
setDomainInvisible();
@@ -1282,11 +1296,13 @@
mEapIdentityView.setText("");
mView.findViewById(R.id.l_identity).setVisibility(View.GONE);
setPasswordInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.VISIBLE);
} else {
mView.findViewById(R.id.l_identity).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
}
}
@@ -1450,6 +1466,44 @@
}
@VisibleForTesting
+ void loadSims() {
+ List<SubscriptionInfo> activeSubscriptionInfos = mContext
+ .getSystemService(SubscriptionManager.class).getActiveSubscriptionInfoList();
+ if (activeSubscriptionInfos == null) {
+ activeSubscriptionInfos = Collections.EMPTY_LIST;
+ }
+ mActiveSubscriptionInfos.clear();
+
+ // De-duplicates active subscriptions and caches in mActiveSubscriptionInfos.
+ for (SubscriptionInfo newInfo : activeSubscriptionInfos) {
+ for (SubscriptionInfo cachedInfo : mActiveSubscriptionInfos) {
+ if (newInfo.getCarrierId() == cachedInfo.getCarrierId()) {
+ continue;
+ }
+ }
+ mActiveSubscriptionInfos.add(newInfo);
+ }
+
+ // Shows disabled 'No SIM' when there is no active subscription.
+ if (mActiveSubscriptionInfos.size() == 0) {
+ final String[] noSim = new String[]{mContext.getString(R.string.wifi_no_sim_card)};
+ mEapSimSpinner.setAdapter(getSpinnerAdapter(noSim));
+ mEapSimSpinner.setSelection(0 /* position */);
+ mEapSimSpinner.setEnabled(false);
+ return;
+ }
+
+ // Shows display name of each active subscription.
+ final String[] displayNames = mActiveSubscriptionInfos.stream().map(
+ SubscriptionInfo::getDisplayName).toArray(String[]::new);
+ mEapSimSpinner.setAdapter(getSpinnerAdapter(displayNames));
+ mEapSimSpinner.setSelection(0 /* position */);
+ if (displayNames.length == 1) {
+ mEapSimSpinner.setEnabled(false);
+ }
+ }
+
+ @VisibleForTesting
void loadCertificates(
Spinner spinner,
String prefix,
@@ -1485,7 +1539,8 @@
}).collect(Collectors.toList()));
}
- if (mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
+ if (!TextUtils.isEmpty(noCertificateString)
+ && mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
certs.add(noCertificateString);
}
@@ -1713,7 +1768,8 @@
mContext.getResources().getStringArray(contentStringArrayResId));
}
- private ArrayAdapter<CharSequence> getSpinnerAdapter(
+ @VisibleForTesting
+ ArrayAdapter<CharSequence> getSpinnerAdapter(
String[] contentStringArray) {
ArrayAdapter<CharSequence> spinnerAdapter = new ArrayAdapter<>(mContext,
android.R.layout.simple_spinner_item, contentStringArray);
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 99907f3..7ae6061 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -35,6 +35,8 @@
import android.os.UserManager;
import android.security.Credentials;
import android.security.KeyStore;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.text.Editable;
import android.text.InputType;
import android.text.SpannableString;
@@ -80,7 +82,9 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.stream.Collectors;
/**
@@ -156,11 +160,11 @@
private String mMultipleCertSetString;
private String mUseSystemCertsString;
private String mDoNotProvideEapUserCertString;
- private String mDoNotValidateEapServerString;
private ScrollView mDialogContainer;
private Spinner mSecuritySpinner;
- private Spinner mEapMethodSpinner;
+ @VisibleForTesting Spinner mEapMethodSpinner;
+ @VisibleForTesting Spinner mEapSimSpinner; // For EAP-SIM, EAP-AKA and EAP-AKA-PRIME.
private Spinner mEapCaCertSpinner;
private Spinner mEapOcspSpinner;
private TextView mEapDomainView;
@@ -205,6 +209,8 @@
private final WifiManager mWifiManager;
+ private final List<SubscriptionInfo> mActiveSubscriptionInfos = new ArrayList<>();
+
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
int mode) {
mConfigUi = parent;
@@ -253,8 +259,6 @@
mUseSystemCertsString = mContext.getString(R.string.wifi_use_system_certs);
mDoNotProvideEapUserCertString =
mContext.getString(R.string.wifi_do_not_provide_eap_user_cert);
- mDoNotValidateEapServerString =
- mContext.getString(R.string.wifi_do_not_validate_eap_server);
mSsidScanButton = (ImageButton) mView.findViewById(R.id.ssid_scanner_button);
mDialogContainer = mView.findViewById(R.id.dialog_scrollview);
@@ -533,12 +537,10 @@
// Disallow submit if the user has not selected a CA certificate for an EAP network
// configuration.
enabled = false;
- }
- if (caCertSelection.equals(mUseSystemCertsString)
- && mEapDomainView != null
+ } else if (mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
- // Disallow submit if the user chooses to use system certificates for EAP server
+ // Disallow submit if the user chooses to use a certificate for EAP server
// validation, but does not provide a domain.
enabled = false;
}
@@ -556,7 +558,6 @@
}
void showWarningMessagesIfAppropriate() {
- mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_user_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_domain_warning).setVisibility(View.GONE);
mView.findViewById(R.id.ssid_too_long_warning).setVisibility(View.GONE);
@@ -569,19 +570,11 @@
}
if (mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
- String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
- if (caCertSelection.equals(mDoNotValidateEapServerString)) {
- // Display warning if user chooses not to validate the EAP server with a
- // user-supplied CA certificate in an EAP network configuration.
- mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.VISIBLE);
- }
- if (caCertSelection.equals(mUseSystemCertsString)
- && mEapDomainView != null
+ if (mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
- // Display warning if user chooses to use pre-installed public CA certificates
- // without restricting the server domain that these certificates can be used to
- // validate.
+ // Display warning if user chooses to use a certificate without restricting the
+ // server domain that these certificates can be used to validate.
mView.findViewById(R.id.no_domain_warning).setVisibility(View.VISIBLE);
}
}
@@ -714,12 +707,17 @@
break;
}
+ if (config.enterpriseConfig.isAuthenticationSimBased()
+ && mActiveSubscriptionInfos.size() > 0) {
+ config.carrierId = mActiveSubscriptionInfos
+ .get(mEapSimSpinner.getSelectedItemPosition()).getCarrierId();
+ }
+
String caCert = (String) mEapCaCertSpinner.getSelectedItem();
config.enterpriseConfig.setCaCertificateAliases(null);
config.enterpriseConfig.setCaPath(null);
config.enterpriseConfig.setDomainSuffixMatch(mEapDomainView.getText().toString());
- if (caCert.equals(mUnspecifiedCertString)
- || caCert.equals(mDoNotValidateEapServerString)) {
+ if (caCert.equals(mUnspecifiedCertString)) {
// ca_cert already set to null, so do nothing.
} else if (caCert.equals(mUseSystemCertsString)) {
config.enterpriseConfig.setCaPath(SYSTEM_CA_STORE_PATH);
@@ -752,8 +750,7 @@
}
// Only set OCSP option if there is a valid CA certificate.
- if (caCert.equals(mUnspecifiedCertString)
- || caCert.equals(mDoNotValidateEapServerString)) {
+ if (caCert.equals(mUnspecifiedCertString)) {
config.enterpriseConfig.setOcsp(WifiEnterpriseConfig.OCSP_NONE);
} else {
config.enterpriseConfig.setOcsp(mEapOcspSpinner.getSelectedItemPosition());
@@ -994,6 +991,7 @@
initiateEnterpriseNetworkUi = true;
mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method);
mEapMethodSpinner.setOnItemSelectedListener(this);
+ mEapSimSpinner = (Spinner) mView.findViewById(R.id.sim);
mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
mPhase2Spinner.setOnItemSelectedListener(this);
mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
@@ -1031,18 +1029,20 @@
}
if (refreshCertificates) {
+ loadSims();
+
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
- mDoNotValidateEapServerString,
- false,
- true);
+ null /* noCertificateString */,
+ false /* showMultipleCerts */,
+ true /* showUsePreinstalledCertOption */);
loadCertificates(
mEapUserCertSpinner,
Credentials.USER_PRIVATE_KEY,
mDoNotProvideEapUserCertString,
- false,
- false);
+ false /* showMultipleCerts */,
+ false /* showUsePreinstalledCertOption */);
// To avoid the user connects to a non-secure network unexpectedly,
// request using system trusted certificates by default
// unless the user explicitly chooses "Do not validate" or other
@@ -1052,10 +1052,10 @@
// Modifying an existing network
if (initiateEnterpriseNetworkUi && mWifiEntry != null && mWifiEntry.isSaved()) {
- WifiEnterpriseConfig enterpriseConfig = mWifiEntry.getWifiConfiguration()
- .enterpriseConfig;
- int eapMethod = enterpriseConfig.getEapMethod();
- int phase2Method = enterpriseConfig.getPhase2Method();
+ final WifiConfiguration wifiConfig = mWifiEntry.getWifiConfiguration();
+ final WifiEnterpriseConfig enterpriseConfig = wifiConfig.enterpriseConfig;
+ final int eapMethod = enterpriseConfig.getEapMethod();
+ final int phase2Method = enterpriseConfig.getPhase2Method();
mEapMethodSpinner.setSelection(eapMethod);
showEapFieldsByMethod(eapMethod);
switch (eapMethod) {
@@ -1103,12 +1103,22 @@
default:
break;
}
+
+ if (enterpriseConfig.isAuthenticationSimBased()) {
+ for (int i = 0; i < mActiveSubscriptionInfos.size(); i++) {
+ if (wifiConfig.carrierId == mActiveSubscriptionInfos.get(i).getCarrierId()) {
+ mEapSimSpinner.setSelection(i);
+ break;
+ }
+ }
+ }
+
if (!TextUtils.isEmpty(enterpriseConfig.getCaPath())) {
setSelection(mEapCaCertSpinner, mUseSystemCertsString);
} else {
String[] caCerts = enterpriseConfig.getCaCertificateAliases();
if (caCerts == null) {
- setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
+ setSelection(mEapCaCertSpinner, mUnspecifiedCertString);
} else if (caCerts.length == 1) {
setSelection(mEapCaCertSpinner, caCerts[0]);
} else {
@@ -1116,9 +1126,9 @@
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
- mDoNotValidateEapServerString,
- true,
- true);
+ null /* noCertificateString */,
+ true /* showMultipleCerts */,
+ true /* showUsePreinstalledCertOption */);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
}
}
@@ -1191,6 +1201,7 @@
mView.findViewById(R.id.l_ocsp).setVisibility(View.VISIBLE);
mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.l_sim).setVisibility(View.VISIBLE);
Context context = mConfigUi.getContext();
switch (eapMethod) {
@@ -1201,12 +1212,14 @@
setDomainInvisible();
setAnonymousIdentInvisible();
setUserCertInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
case WIFI_EAP_METHOD_TLS:
mView.findViewById(R.id.l_user_cert).setVisibility(View.VISIBLE);
setPhase2Invisible();
setAnonymousIdentInvisible();
setPasswordInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
case WIFI_EAP_METHOD_PEAP:
// Reset adapter if needed
@@ -1228,6 +1241,7 @@
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
setUserCertInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
case WIFI_EAP_METHOD_SIM:
case WIFI_EAP_METHOD_AKA:
@@ -1245,8 +1259,7 @@
if (mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
String eapCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
- if (eapCertSelection.equals(mDoNotValidateEapServerString)
- || eapCertSelection.equals(mUnspecifiedCertString)) {
+ if (eapCertSelection.equals(mUnspecifiedCertString)) {
// Domain suffix matching is not relevant if the user hasn't chosen a CA
// certificate yet, or chooses not to validate the EAP server.
setDomainInvisible();
@@ -1265,11 +1278,13 @@
mEapIdentityView.setText("");
mView.findViewById(R.id.l_identity).setVisibility(View.GONE);
setPasswordInvisible();
+ mView.findViewById(R.id.l_sim).setVisibility(View.VISIBLE);
} else {
mView.findViewById(R.id.l_identity).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
+ mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
}
}
@@ -1433,6 +1448,44 @@
}
@VisibleForTesting
+ void loadSims() {
+ List<SubscriptionInfo> activeSubscriptionInfos = mContext
+ .getSystemService(SubscriptionManager.class).getActiveSubscriptionInfoList();
+ if (activeSubscriptionInfos == null) {
+ activeSubscriptionInfos = Collections.EMPTY_LIST;
+ }
+ mActiveSubscriptionInfos.clear();
+
+ // De-duplicates active subscriptions and caches in mActiveSubscriptionInfos.
+ for (SubscriptionInfo newInfo : activeSubscriptionInfos) {
+ for (SubscriptionInfo cachedInfo : mActiveSubscriptionInfos) {
+ if (newInfo.getCarrierId() == cachedInfo.getCarrierId()) {
+ continue;
+ }
+ }
+ mActiveSubscriptionInfos.add(newInfo);
+ }
+
+ // Shows disabled 'No SIM' when there is no active subscription.
+ if (mActiveSubscriptionInfos.size() == 0) {
+ final String[] noSim = new String[]{mContext.getString(R.string.wifi_no_sim_card)};
+ mEapSimSpinner.setAdapter(getSpinnerAdapter(noSim));
+ mEapSimSpinner.setSelection(0 /* position */);
+ mEapSimSpinner.setEnabled(false);
+ return;
+ }
+
+ // Shows display name of each active subscription.
+ final String[] displayNames = mActiveSubscriptionInfos.stream().map(
+ SubscriptionInfo::getDisplayName).toArray(String[]::new);
+ mEapSimSpinner.setAdapter(getSpinnerAdapter(displayNames));
+ mEapSimSpinner.setSelection(0 /* position */);
+ if (displayNames.length == 1) {
+ mEapSimSpinner.setEnabled(false);
+ }
+ }
+
+ @VisibleForTesting
void loadCertificates(
Spinner spinner,
String prefix,
@@ -1468,7 +1521,8 @@
}).collect(Collectors.toList()));
}
- if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
+ if (!TextUtils.isEmpty(noCertificateString)
+ && mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
certs.add(noCertificateString);
}
@@ -1696,7 +1750,8 @@
mContext.getResources().getStringArray(contentStringArrayResId));
}
- private ArrayAdapter<CharSequence> getSpinnerAdapter(
+ @VisibleForTesting
+ ArrayAdapter<CharSequence> getSpinnerAdapter(
String[] contentStringArray) {
ArrayAdapter<CharSequence> spinnerAdapter = new ArrayAdapter<>(mContext,
android.R.layout.simple_spinner_item, contentStringArray);
diff --git a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
index 742edd1..12a6d14 100644
--- a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
@@ -17,32 +17,22 @@
package com.android.settings.wifi;
import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkScoreManager;
-import android.net.wifi.WifiManager;
import android.os.Bundle;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Process;
-import android.os.SimpleClock;
-import android.os.SystemClock;
+import android.util.FeatureFlagUtils;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
import com.android.settings.wifi.details2.WifiNetworkDetailsFragment2;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.wifi.WifiEntryPreference;
-import com.android.wifitrackerlib.WifiEntry;
-import com.android.wifitrackerlib.WifiPickerTracker;
-
-import java.time.Clock;
-import java.time.ZoneOffset;
+import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
+import com.android.settingslib.wifi.WifiTracker;
+import com.android.settingslib.wifi.WifiTrackerFactory;
// TODO(b/151133650): Replace AbstractPreferenceController with BasePreferenceController.
/**
@@ -50,28 +40,21 @@
* controller class when there is a wifi connection present.
*/
public class WifiConnectionPreferenceController extends AbstractPreferenceController implements
- WifiPickerTracker.WifiPickerTrackerCallback {
+ WifiTracker.WifiListener {
private static final String TAG = "WifiConnPrefCtrl";
private static final String KEY = "active_wifi_connection";
- // Max age of tracked WifiEntries.
- private static final long MAX_SCAN_AGE_MILLIS = 15_000;
- // Interval between initiating WifiPickerTracker scans.
- private static final long SCAN_INTERVAL_MILLIS = 10_000;
-
private UpdateListener mUpdateListener;
private Context mPrefContext;
private String mPreferenceGroupKey;
private PreferenceGroup mPreferenceGroup;
- @VisibleForTesting
- public WifiPickerTracker mWifiPickerTracker;
- private WifiEntryPreference mPreference;
+ private WifiTracker mWifiTracker;
+ private AccessPointPreference mPreference;
+ private AccessPointPreference.UserBadgeCache mBadgeCache;
private int order;
private int mMetricsCategory;
- // Worker thread used for WifiPickerTracker work.
- private HandlerThread mWorkerThread;
/**
* Used to notify a parent controller that this controller has changed in availability, or has
@@ -99,34 +82,16 @@
super(context);
mUpdateListener = updateListener;
mPreferenceGroupKey = preferenceGroupKey;
+ mWifiTracker = WifiTrackerFactory.create(context, this, lifecycle, true /* includeSaved */,
+ true /* includeScans */);
this.order = order;
mMetricsCategory = metricsCategory;
-
- mWorkerThread = new HandlerThread(
- TAG + "{" + Integer.toHexString(System.identityHashCode(this)) + "}",
- Process.THREAD_PRIORITY_BACKGROUND);
- mWorkerThread.start();
- final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {
- @Override
- public long millis() {
- return SystemClock.elapsedRealtime();
- }
- };
- mWifiPickerTracker = new WifiPickerTracker(lifecycle, context,
- context.getSystemService(WifiManager.class),
- context.getSystemService(ConnectivityManager.class),
- context.getSystemService(NetworkScoreManager.class),
- new Handler(Looper.getMainLooper()),
- mWorkerThread.getThreadHandler(),
- elapsedRealtimeClock,
- MAX_SCAN_AGE_MILLIS,
- SCAN_INTERVAL_MILLIS,
- this);
+ mBadgeCache = new AccessPointPreference.UserBadgeCache(context.getPackageManager());
}
@Override
public boolean isAvailable() {
- return mWifiPickerTracker.getConnectedWifiEntry() != null;
+ return mWifiTracker.isConnected() && getCurrentAccessPoint() != null;
}
@Override
@@ -142,69 +107,88 @@
update();
}
- private void updatePreference(WifiEntry wifiEntry) {
+ private AccessPoint getCurrentAccessPoint() {
+ for (AccessPoint accessPoint : mWifiTracker.getAccessPoints()) {
+ if (accessPoint.isActive()) {
+ return accessPoint;
+ }
+ }
+ return null;
+ }
+
+ private void updatePreference(AccessPoint accessPoint) {
if (mPreference != null) {
mPreferenceGroup.removePreference(mPreference);
mPreference = null;
}
- if (wifiEntry == null || mPrefContext == null) {
+ if (accessPoint == null) {
return;
}
+ if (mPrefContext != null) {
+ mPreference = new AccessPointPreference(accessPoint, mPrefContext, mBadgeCache,
+ R.drawable.ic_wifi_signal_0, false /* forSavedNetworks */);
+ mPreference.setKey(KEY);
+ mPreference.refresh();
+ mPreference.setOrder(order);
- mPreference = new WifiEntryPreference(mPrefContext, wifiEntry);
- mPreference.setKey(KEY);
- mPreference.refresh();
- mPreference.setOrder(order);
- mPreference.setOnPreferenceClickListener(pref -> {
- final Bundle args = new Bundle();
- args.putString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY,
- wifiEntry.getKey());
- new SubSettingLauncher(mPrefContext)
- .setTitleRes(R.string.pref_title_network_details)
- .setDestination(WifiNetworkDetailsFragment2.class.getName())
- .setArguments(args)
- .setSourceMetricsCategory(mMetricsCategory)
- .launch();
- return true;
- });
- mPreferenceGroup.addPreference(mPreference);
+ if (FeatureFlagUtils.isEnabled(mPrefContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
+ mPreference.setOnPreferenceClickListener(pref -> {
+ Bundle args = new Bundle();
+ mPreference.getAccessPoint().saveWifiState(args);
+ new SubSettingLauncher(mPrefContext)
+ .setTitleRes(R.string.pref_title_network_details)
+ .setDestination(WifiNetworkDetailsFragment2.class.getName())
+ .setArguments(args)
+ .setSourceMetricsCategory(mMetricsCategory)
+ .launch();
+ return true;
+ });
+ } else {
+ mPreference.setOnPreferenceClickListener(pref -> {
+ Bundle args = new Bundle();
+ mPreference.getAccessPoint().saveWifiState(args);
+ new SubSettingLauncher(mPrefContext)
+ .setTitleRes(R.string.pref_title_network_details)
+ .setDestination(WifiNetworkDetailsFragment.class.getName())
+ .setArguments(args)
+ .setSourceMetricsCategory(mMetricsCategory)
+ .launch();
+ return true;
+ });
+ }
+ mPreferenceGroup.addPreference(mPreference);
+ }
}
private void update() {
- final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
- if (connectedWifiEntry == null) {
+ AccessPoint connectedAccessPoint = null;
+ if (mWifiTracker.isConnected()) {
+ connectedAccessPoint = getCurrentAccessPoint();
+ }
+ if (connectedAccessPoint == null) {
updatePreference(null);
} else {
- if (mPreference == null || !mPreference.getWifiEntry().equals(connectedWifiEntry)) {
- updatePreference(connectedWifiEntry);
- } else if (mPreference != null) {
- mPreference.refresh();
- }
+ if (mPreference == null || !mPreference.getAccessPoint().equals(connectedAccessPoint)) {
+ updatePreference(connectedAccessPoint);
+ } else if (mPreference != null) {
+ mPreference.refresh();
+ }
}
mUpdateListener.onChildrenUpdated();
}
- /** Called when the state of Wifi has changed. */
@Override
- public void onWifiStateChanged() {
- update();
- }
-
- /**
- * Update the results when data changes.
- */
- @Override
- public void onWifiEntriesChanged() {
+ public void onWifiStateChanged(int state) {
update();
}
@Override
- public void onNumSavedSubscriptionsChanged() {
- // Do nothing.
+ public void onConnectedChanged() {
+ update();
}
@Override
- public void onNumSavedNetworksChanged() {
- // Do nothing.
+ public void onAccessPointsChanged() {
+ update();
}
}
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index 5c48dfd..ef57e54 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -23,8 +23,10 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.app.settings.SettingsEnums;
+import android.content.AsyncQueryHandler;
import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@@ -41,9 +43,14 @@
import android.net.NetworkUtils;
import android.net.RouteInfo;
import android.net.Uri;
+import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Handler;
+import android.provider.Telephony.CarrierId;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
@@ -98,6 +105,7 @@
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
+import java.util.List;
import java.util.StringJoiner;
import java.util.stream.Collectors;
@@ -133,6 +141,8 @@
@VisibleForTesting
static final String KEY_SSID_PREF = "ssid";
@VisibleForTesting
+ static final String KEY_EAP_SIM_SUBSCRIPTION_PREF = "eap_sim_subscription";
+ @VisibleForTesting
static final String KEY_MAC_ADDRESS_PREF = "mac_address";
@VisibleForTesting
static final String KEY_IP_ADDRESS_PREF = "ip_address";
@@ -170,6 +180,7 @@
private Preference mFrequencyPref;
private Preference mSecurityPref;
private Preference mSsidPref;
+ private Preference mEapSimSubscriptionPref;
private Preference mMacAddressPref;
private Preference mIpAddressPref;
private Preference mGatewayPref;
@@ -187,6 +198,35 @@
private final NetworkRequest mNetworkRequest = new NetworkRequest.Builder()
.clearCapabilities().addTransportType(TRANSPORT_WIFI).build();
+ private CarrierIdAsyncQueryHandler mCarrierIdAsyncQueryHandler;
+ private static final int TOKEN_QUERY_CARRIER_ID_AND_UPDATE_SIM_SUMMARY = 1;
+ private static final int COLUMN_CARRIER_NAME = 0;
+
+ private class CarrierIdAsyncQueryHandler extends AsyncQueryHandler {
+
+ private CarrierIdAsyncQueryHandler(Context context) {
+ super(context.getContentResolver());
+ }
+
+ @Override
+ protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
+ if (token == TOKEN_QUERY_CARRIER_ID_AND_UPDATE_SIM_SUMMARY) {
+ if (mContext == null || cursor == null || !cursor.moveToFirst()) {
+ if (cursor != null) {
+ cursor.close();
+ }
+ mEapSimSubscriptionPref.setSummary(R.string.wifi_require_sim_card_to_connect);
+ return;
+ }
+ mEapSimSubscriptionPref.setSummary(mContext.getString(
+ R.string.wifi_require_specific_sim_card_to_connect,
+ cursor.getString(COLUMN_CARRIER_NAME)));
+ cursor.close();
+ return;
+ }
+ }
+ }
+
// Must be run on the UI thread since it directly manipulates UI state.
private final NetworkCallback mNetworkCallback = new NetworkCallback() {
@Override
@@ -336,6 +376,7 @@
mSecurityPref = screen.findPreference(KEY_SECURITY_PREF);
mSsidPref = screen.findPreference(KEY_SSID_PREF);
+ mEapSimSubscriptionPref = screen.findPreference(KEY_EAP_SIM_SUBSCRIPTION_PREF);
mMacAddressPref = screen.findPreference(KEY_MAC_ADDRESS_PREF);
mIpAddressPref = screen.findPreference(KEY_IP_ADDRESS_PREF);
mGatewayPref = screen.findPreference(KEY_GATEWAY_PREF);
@@ -507,6 +548,8 @@
refreshIpLayerInfo();
// SSID Pref
refreshSsid();
+ // EAP SIM subscription
+ refreshEapSimSubscription();
// MAC Address Pref
refreshMacAddress();
}
@@ -630,6 +673,62 @@
}
}
+ private void refreshEapSimSubscription() {
+ mEapSimSubscriptionPref.setVisible(false);
+
+ if (mWifiEntry.getSecurity() != WifiEntry.SECURITY_EAP) {
+ return;
+ }
+ final WifiConfiguration config = mWifiEntry.getWifiConfiguration();
+ if (config == null || config.enterpriseConfig == null) {
+ return;
+ }
+ if (!config.enterpriseConfig.isAuthenticationSimBased()) {
+ return;
+ }
+
+ mEapSimSubscriptionPref.setVisible(true);
+
+ // Checks if the SIM subscription is active.
+ final List<SubscriptionInfo> activeSubscriptionInfos = mContext
+ .getSystemService(SubscriptionManager.class).getActiveSubscriptionInfoList();
+ final int defaultDataSubscriptionId = SubscriptionManager.getDefaultDataSubscriptionId();
+ if (activeSubscriptionInfos != null) {
+ for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfos) {
+ if (config.carrierId == subscriptionInfo.getCarrierId()) {
+ mEapSimSubscriptionPref.setSummary(subscriptionInfo.getDisplayName());
+ return;
+ }
+
+ // When it's UNKNOWN_CARRIER_ID, devices connects it with the SIM subscription of
+ // defaultDataSubscriptionId.
+ if (config.carrierId == TelephonyManager.UNKNOWN_CARRIER_ID
+ && defaultDataSubscriptionId == subscriptionInfo.getSubscriptionId()) {
+ mEapSimSubscriptionPref.setSummary(subscriptionInfo.getDisplayName());
+ return;
+ }
+ }
+ }
+
+ if (config.carrierId == TelephonyManager.UNKNOWN_CARRIER_ID) {
+ mEapSimSubscriptionPref.setSummary(R.string.wifi_no_related_sim_card);
+ return;
+ }
+
+ // The Wi-Fi network has specified carrier id, query carrier name from CarrierIdProvider.
+ if (mCarrierIdAsyncQueryHandler == null) {
+ mCarrierIdAsyncQueryHandler = new CarrierIdAsyncQueryHandler(mContext);
+ }
+ mCarrierIdAsyncQueryHandler.cancelOperation(TOKEN_QUERY_CARRIER_ID_AND_UPDATE_SIM_SUMMARY);
+ mCarrierIdAsyncQueryHandler.startQuery(TOKEN_QUERY_CARRIER_ID_AND_UPDATE_SIM_SUMMARY,
+ null /* cookie */,
+ CarrierId.All.CONTENT_URI,
+ new String[]{CarrierId.CARRIER_NAME},
+ CarrierId.CARRIER_ID + "=?",
+ new String[] {Integer.toString(config.carrierId)},
+ null /* orderBy */);
+ }
+
private void refreshMacAddress() {
final String macAddress = mWifiEntry.getMacAddress();
if (TextUtils.isEmpty(macAddress)) {
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 4d420d1..a27e40d 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -570,12 +570,14 @@
mFragment.createHeader();
- assertThat(mFragment.mFilterAdapter.getCount()).isEqualTo(3);
+ assertThat(mFragment.mFilterAdapter.getCount()).isEqualTo(4);
assertThat(mFragment.mFilterAdapter.getItem(0)).isEqualTo(
mContext.getString(R.string.sort_order_recent_notification));
assertThat(mFragment.mFilterAdapter.getItem(1)).isEqualTo(
mContext.getString(R.string.sort_order_frequent_notification));
assertThat(mFragment.mFilterAdapter.getItem(2)).isEqualTo(
+ mContext.getString(R.string.filter_all_apps));
+ assertThat(mFragment.mFilterAdapter.getItem(3)).isEqualTo(
mContext.getString(R.string.filter_notif_blocked_apps));
}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessControllerTest.java
index 6041e9d..8febbc6 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessControllerTest.java
@@ -63,12 +63,6 @@
}
@Test
- public void isAvailable_lowMemory_false() {
- mActivityManager.setIsLowRamDevice(true);
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
public void logSpecialPermissionChange() {
ZenAccessController.logSpecialPermissionChange(true, "app", mContext);
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixinTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixinTest.java
index cba1a51..fb565b6 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixinTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessSettingObserverMixinTest.java
@@ -65,7 +65,7 @@
}
@Test
- public void onStart_lowMemory_shouldNotRegisterListener() {
+ public void onStart_shouldRegisterListener() {
final ShadowActivityManager sam = Shadow.extract(
mContext.getSystemService(ActivityManager.class));
sam.setIsLowRamDevice(true);
@@ -75,29 +75,11 @@
mContext.getContentResolver().notifyChange(Settings.Secure.getUriFor(
Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES), null);
- verify(mListener, never()).onZenAccessPolicyChanged();
- }
-
- @Test
- public void onStart_highMemory_shouldRegisterListener() {
- final ShadowActivityManager sam = Shadow.extract(
- mContext.getSystemService(ActivityManager.class));
- sam.setIsLowRamDevice(false);
-
- mLifecycle.handleLifecycleEvent(ON_START);
-
- mContext.getContentResolver().notifyChange(Settings.Secure.getUriFor(
- Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES), null);
-
verify(mListener).onZenAccessPolicyChanged();
}
@Test
public void onStop_shouldUnregisterListener() {
- final ShadowActivityManager sam = Shadow.extract(
- mContext.getSystemService(ActivityManager.class));
- sam.setIsLowRamDevice(false);
-
mLifecycle.handleLifecycleEvent(ON_START);
mLifecycle.handleLifecycleEvent(ON_STOP);
diff --git a/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java
index ea957c3..7037318 100644
--- a/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java
@@ -29,15 +29,12 @@
import android.content.Context;
-import androidx.lifecycle.LifecycleOwner;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
-
import com.android.settings.wifi.WifiConnectionPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.wifi.WifiEntryPreference;
-import com.android.wifitrackerlib.WifiEntry;
-import com.android.wifitrackerlib.WifiPickerTracker;
+import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
+import com.android.settingslib.wifi.WifiTracker;
+import com.android.settingslib.wifi.WifiTrackerFactory;
import org.junit.Before;
import org.junit.Test;
@@ -48,12 +45,19 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
@RunWith(RobolectricTestRunner.class)
public class WifiConnectionPreferenceControllerTest {
private static final String KEY = "wifi_connection";
@Mock
- WifiPickerTracker mWifiPickerTracker;
+ WifiTracker mWifiTracker;
@Mock
PreferenceScreen mScreen;
@Mock
@@ -70,6 +74,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ WifiTrackerFactory.setTestingWifiTracker(mWifiTracker);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
when(mScreen.findPreference(eq(KEY))).thenReturn(mPreferenceCategory);
@@ -78,51 +83,49 @@
mController = new WifiConnectionPreferenceController(mContext, mLifecycle, mUpdateListener,
KEY, 0, 0);
- mController.mWifiPickerTracker = mWifiPickerTracker;
}
@Test
- public void isAvailable_noConnectedWifiEntry_availableIsFalse() {
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(null);
-
+ public void isAvailable_noWiFiConnection_availableIsFalse() {
+ when(mWifiTracker.isConnected()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();
}
@Test
- public void displayPreference_noConnectedWifiEntry_noPreferenceAdded() {
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(null);
-
+ public void displayPreference_noWiFiConnection_noPreferenceAdded() {
+ when(mWifiTracker.isConnected()).thenReturn(false);
+ when(mWifiTracker.getAccessPoints()).thenReturn(new ArrayList<>());
mController.displayPreference(mScreen);
-
verify(mPreferenceCategory, never()).addPreference(any());
}
@Test
- public void displayPreference_hasConnectedWifiEntry_preferenceAdded() {
- final WifiEntry wifiEntry = mock(WifiEntry.class);
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(wifiEntry);
-
+ public void displayPreference_hasWiFiConnection_preferenceAdded() {
+ when(mWifiTracker.isConnected()).thenReturn(true);
+ final AccessPoint accessPoint = mock(AccessPoint.class);
+ when(accessPoint.isActive()).thenReturn(true);
+ when(mWifiTracker.getAccessPoints()).thenReturn(Arrays.asList(accessPoint));
mController.displayPreference(mScreen);
- verify(mPreferenceCategory).addPreference(any(WifiEntryPreference.class));
+ verify(mPreferenceCategory).addPreference(any(AccessPointPreference.class));
}
@Test
public void onConnectedChanged_wifiBecameDisconnected_preferenceRemoved() {
- final WifiEntry wifiEntry = mock(WifiEntry.class);
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(wifiEntry);
+ when(mWifiTracker.isConnected()).thenReturn(true);
+ final AccessPoint accessPoint = mock(AccessPoint.class);
+ when(accessPoint.isActive()).thenReturn(true);
+ when(mWifiTracker.getAccessPoints()).thenReturn(Arrays.asList(accessPoint));
mController.displayPreference(mScreen);
- final ArgumentCaptor<WifiEntryPreference> captor = ArgumentCaptor.forClass(
- WifiEntryPreference.class);
+ final ArgumentCaptor<AccessPointPreference> captor = ArgumentCaptor.forClass(
+ AccessPointPreference.class);
verify(mPreferenceCategory).addPreference(captor.capture());
- final WifiEntryPreference pref = captor.getValue();
+ final AccessPointPreference pref = captor.getValue();
- // Become disconnected.
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(null);
+ when(mWifiTracker.isConnected()).thenReturn(false);
+ when(mWifiTracker.getAccessPoints()).thenReturn(new ArrayList<>());
final int onUpdatedCountBefore = mOnChildUpdatedCount;
-
- mController.onWifiStateChanged();
-
+ mController.onConnectedChanged();
verify(mPreferenceCategory).removePreference(pref);
assertThat(mOnChildUpdatedCount).isEqualTo(onUpdatedCountBefore + 1);
}
@@ -130,24 +133,28 @@
@Test
public void onAccessPointsChanged_wifiBecameConnectedToDifferentAP_preferenceReplaced() {
- final WifiEntry wifiEntry1 = mock(WifiEntry.class);
- when(wifiEntry1.getKey()).thenReturn("KEY_1");
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(wifiEntry1);
- mController.displayPreference(mScreen);
- final ArgumentCaptor<WifiEntryPreference> captor = ArgumentCaptor.forClass(
- WifiEntryPreference.class);
+ when(mWifiTracker.isConnected()).thenReturn(true);
+ final AccessPoint accessPoint1 = mock(AccessPoint.class);
- final WifiEntry wifiEntry2 = mock(WifiEntry.class);
- when(wifiEntry1.getKey()).thenReturn("KEY_2");
- when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(wifiEntry2);
+ when(accessPoint1.isActive()).thenReturn(true);
+ when(mWifiTracker.getAccessPoints()).thenReturn(Arrays.asList(accessPoint1));
+ mController.displayPreference(mScreen);
+ final ArgumentCaptor<AccessPointPreference> captor = ArgumentCaptor.forClass(
+ AccessPointPreference.class);
+
+
+ final AccessPoint accessPoint2 = mock(AccessPoint.class);
+ when(accessPoint1.isActive()).thenReturn(false);
+ when(accessPoint2.isActive()).thenReturn(true);
+ when(mWifiTracker.getAccessPoints()).thenReturn(Arrays.asList(accessPoint1, accessPoint2));
final int onUpdatedCountBefore = mOnChildUpdatedCount;
- mController.onWifiEntriesChanged();
+ mController.onAccessPointsChanged();
verify(mPreferenceCategory, times(2)).addPreference(captor.capture());
- final WifiEntryPreference pref1 = captor.getAllValues().get(0);
- final WifiEntryPreference pref2 = captor.getAllValues().get(1);
- assertThat(pref1.getWifiEntry()).isEqualTo(wifiEntry1);
- assertThat(pref2.getWifiEntry()).isEqualTo(wifiEntry2);
+ final AccessPointPreference pref1 = captor.getAllValues().get(0);
+ final AccessPointPreference pref2 = captor.getAllValues().get(1);
+ assertThat(pref1.getAccessPoint()).isEqualTo(accessPoint1);
+ assertThat(pref2.getAccessPoint()).isEqualTo(accessPoint2);
verify(mPreferenceCategory).removePreference(eq(pref1));
assertThat(mOnChildUpdatedCount).isEqualTo(onUpdatedCountBefore + 1);
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
index d203c47..2ea240e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
@@ -368,6 +368,7 @@
public void testOnSwitchChanged_channel_nonDefault() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
+ channel.setOriginalImportance(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -375,7 +376,7 @@
assertEquals(IMPORTANCE_NONE, channel.getImportance());
mController.onSwitchChanged(null, true);
- assertEquals(IMPORTANCE_DEFAULT, channel.getImportance());
+ assertEquals(IMPORTANCE_HIGH, channel.getImportance());
verify(mBackend, times(2)).updateChannel(any(), anyInt(), any());
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceTest.java
index 12e1f35..2d2fcc8 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceTest.java
@@ -68,10 +68,6 @@
final LayoutInflater inflater = LayoutInflater.from(mContext);
PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
inflater.inflate(preference.getLayoutResource(), null));
- Drawable unselected = mock(Drawable.class);
- Drawable selected = mock(Drawable.class);
- preference.selectedBackground = selected;
- preference.unselectedBackground = unselected;
preference.setConfigurable(false);
preference.setImportance(IMPORTANCE_DEFAULT);
@@ -81,35 +77,6 @@
assertThat(holder.itemView.findViewById(R.id.silence).isEnabled()).isFalse();
assertThat(holder.itemView.findViewById(R.id.priority_group).isEnabled()).isFalse();
assertThat(holder.itemView.findViewById(R.id.alert).isEnabled()).isFalse();
-
- assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground())
- .isEqualTo(selected);
- assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
- .isEqualTo(unselected);
-
- // other button
- preference.setPriorityConversation(false);
- holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(preference.getLayoutResource(), null));
- preference.onBindViewHolder(holder);
-
- assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
- assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
- .isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground())
- .isEqualTo(unselected);
-
- // other other button
- preference.setImportance(IMPORTANCE_LOW);
- holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(preference.getLayoutResource(), null));
- preference.onBindViewHolder(holder);
-
- assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground())
- .isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
}
@Test
@@ -119,10 +86,6 @@
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
inflater.inflate(preference.getLayoutResource(), null));
- Drawable unselected = mock(Drawable.class);
- Drawable selected = mock(Drawable.class);
- preference.selectedBackground = selected;
- preference.unselectedBackground = unselected;
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_LOW);
@@ -130,12 +93,8 @@
preference.onBindViewHolder(holder);
- assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground())
- .isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
- .isEqualTo(selected);
- assertThat(holder.itemView.findViewById(R.id.silence_summary).getVisibility())
+ assertThat(holder.itemView.findViewById(R.id.silence)
+ .findViewById(R.id.summary).getVisibility())
.isEqualTo(View.VISIBLE);
}
@@ -146,10 +105,6 @@
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
inflater.inflate(preference.getLayoutResource(), null));
- Drawable unselected = mock(Drawable.class);
- Drawable selected = mock(Drawable.class);
- preference.selectedBackground = selected;
- preference.unselectedBackground = unselected;
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_DEFAULT);
@@ -161,12 +116,6 @@
silenceButton.callOnClick();
- assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground())
- .isEqualTo(unselected);
- assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
- .isEqualTo(selected);
-
verify(preference, times(1)).callChangeListener(new Pair(IMPORTANCE_LOW, false));
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
index e588799..779044c 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
@@ -21,6 +21,7 @@
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
import android.content.res.Resources;
@@ -32,6 +33,9 @@
import android.net.wifi.WifiManager;
import android.os.ServiceSpecificException;
import android.security.KeyStore;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -56,6 +60,9 @@
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowInputMethodManager;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+
+import java.util.Arrays;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowConnectivityManager.class)
@@ -71,6 +78,7 @@
private KeyStore mKeyStore;
private View mView;
private Spinner mHiddenSettingsSpinner;
+ private ShadowSubscriptionManager mShadowSubscriptionManager;
public WifiConfigController2 mController;
private static final String HEX_PSK = "01234567012345670123456701234567012345670123456701234567"
@@ -101,6 +109,7 @@
final Spinner ipSettingsSpinner = mView.findViewById(R.id.ip_settings);
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
ipSettingsSpinner.setSelection(DHCP);
+ mShadowSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
WifiConfigUiBase2.MODE_CONNECT);
@@ -225,6 +234,35 @@
}
@Test
+ public void isSubmittable_caCertWithoutDomain_shouldReturnFalse() {
+ when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
+ WifiConfigUiBase2.MODE_CONNECT);
+ mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
+ final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
+ eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
+ eapCaCertSpinner.setSelection(0);
+ mView.findViewById(R.id.l_domain).setVisibility(View.VISIBLE);
+
+ assertThat(mController.isSubmittable()).isFalse();
+ }
+
+ @Test
+ public void isSubmittable_caCertWithDomain_shouldReturnTrue() {
+ when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
+ WifiConfigUiBase2.MODE_CONNECT);
+ mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
+ final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
+ eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
+ eapCaCertSpinner.setSelection(0);
+ mView.findViewById(R.id.l_domain).setVisibility(View.VISIBLE);
+ ((TextView) mView.findViewById(R.id.domain)).setText("fakeDomain");
+
+ assertThat(mController.isSubmittable()).isTrue();
+ }
+
+ @Test
public void getSignalString_notReachable_shouldHaveNoSignalString() {
when(mWifiEntry.getLevel()).thenReturn(WifiEntry.WIFI_LEVEL_UNREACHABLE);
@@ -760,4 +798,41 @@
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
WifiConfigUiBase2.MODE_MODIFY);
}
+
+ @Test
+ public void loadSims_noSim_simSpinnerDefaultNoSim() {
+ when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
+ WifiConfigUiBase2.MODE_CONNECT);
+ final Spinner eapMethodSpinner = mock(Spinner.class);
+ when(eapMethodSpinner.getSelectedItemPosition()).thenReturn(
+ WifiConfigController2.WIFI_EAP_METHOD_SIM);
+ mController.mEapMethodSpinner = eapMethodSpinner;
+
+ mController.loadSims();
+
+ final WifiConfiguration wifiConfiguration = mController.getConfig();
+ assertThat(wifiConfiguration.carrierId).isEqualTo(TelephonyManager.UNKNOWN_CARRIER_ID);
+ }
+
+ @Test
+ public void loadSims_oneSim_simSpinnerDefaultSubscription() {
+ when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ final SubscriptionInfo subscriptionInfo = mock(SubscriptionInfo.class);
+ final int carrierId = 6;
+ when(subscriptionInfo.getCarrierId()).thenReturn(carrierId);
+ when(subscriptionInfo.getCarrierName()).thenReturn("FAKE-CARRIER");
+ mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(subscriptionInfo));
+ mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
+ WifiConfigUiBase2.MODE_CONNECT);
+ final Spinner eapMethodSpinner = mock(Spinner.class);
+ when(eapMethodSpinner.getSelectedItemPosition()).thenReturn(
+ WifiConfigController2.WIFI_EAP_METHOD_SIM);
+ mController.mEapMethodSpinner = eapMethodSpinner;
+
+ mController.loadSims();
+
+ final WifiConfiguration wifiConfiguration = mController.getConfig();
+ assertThat(wifiConfiguration.carrierId).isEqualTo(carrierId);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index 9146998..9e62b25 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -21,6 +21,7 @@
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
import android.content.res.Resources;
@@ -32,6 +33,9 @@
import android.net.wifi.WifiManager;
import android.os.ServiceSpecificException;
import android.security.KeyStore;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -56,6 +60,9 @@
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowInputMethodManager;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+
+import java.util.Arrays;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowConnectivityManager.class)
@@ -71,6 +78,7 @@
private KeyStore mKeyStore;
private View mView;
private Spinner mHiddenSettingsSpinner;
+ private ShadowSubscriptionManager mShadowSubscriptionManager;
public WifiConfigController mController;
private static final String HEX_PSK = "01234567012345670123456701234567012345670123456701234567"
@@ -95,6 +103,7 @@
final Spinner ipSettingsSpinner = mView.findViewById(R.id.ip_settings);
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
ipSettingsSpinner.setSelection(DHCP);
+ mShadowSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
WifiConfigUiBase.MODE_CONNECT);
@@ -219,6 +228,35 @@
}
@Test
+ public void isSubmittable_caCertWithoutDomain_shouldReturnFalse() {
+ when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+ mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
+ WifiConfigUiBase.MODE_CONNECT);
+ mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
+ final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
+ eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
+ eapCaCertSpinner.setSelection(0);
+ mView.findViewById(R.id.l_domain).setVisibility(View.VISIBLE);
+
+ assertThat(mController.isSubmittable()).isFalse();
+ }
+
+ @Test
+ public void isSubmittable_caCertWithDomain_shouldReturnTrue() {
+ when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+ mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
+ WifiConfigUiBase.MODE_CONNECT);
+ mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
+ final Spinner eapCaCertSpinner = mView.findViewById(R.id.ca_cert);
+ eapCaCertSpinner.setAdapter(mController.getSpinnerAdapter(new String[]{"certificate"}));
+ eapCaCertSpinner.setSelection(0);
+ mView.findViewById(R.id.l_domain).setVisibility(View.VISIBLE);
+ ((TextView) mView.findViewById(R.id.domain)).setText("fakeDomain");
+
+ assertThat(mController.isSubmittable()).isTrue();
+ }
+
+ @Test
public void getSignalString_notReachable_shouldHaveNoSignalString() {
when(mAccessPoint.isReachable()).thenReturn(false);
@@ -575,4 +613,41 @@
assertThat(advButton.getVisibility()).isEqualTo(View.GONE);
}
+
+ @Test
+ public void loadSims_noSim_simSpinnerDefaultNoSim() {
+ when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+ mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
+ WifiConfigUiBase.MODE_CONNECT);
+ final Spinner eapMethodSpinner = mock(Spinner.class);
+ when(eapMethodSpinner.getSelectedItemPosition()).thenReturn(
+ WifiConfigController2.WIFI_EAP_METHOD_SIM);
+ mController.mEapMethodSpinner = eapMethodSpinner;
+
+ mController.loadSims();
+
+ final WifiConfiguration wifiConfiguration = mController.getConfig();
+ assertThat(wifiConfiguration.carrierId).isEqualTo(TelephonyManager.UNKNOWN_CARRIER_ID);
+ }
+
+ @Test
+ public void loadSims_oneSim_simSpinnerDefaultSubscription() {
+ when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+ final SubscriptionInfo subscriptionInfo = mock(SubscriptionInfo.class);
+ final int carrierId = 6;
+ when(subscriptionInfo.getCarrierId()).thenReturn(carrierId);
+ when(subscriptionInfo.getCarrierName()).thenReturn("FAKE-CARRIER");
+ mShadowSubscriptionManager.setActiveSubscriptionInfoList(Arrays.asList(subscriptionInfo));
+ mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
+ WifiConfigUiBase.MODE_CONNECT);
+ final Spinner eapMethodSpinner = mock(Spinner.class);
+ when(eapMethodSpinner.getSelectedItemPosition()).thenReturn(
+ WifiConfigController2.WIFI_EAP_METHOD_SIM);
+ mController.mEapMethodSpinner = eapMethodSpinner;
+
+ mController.loadSims();
+
+ final WifiConfiguration wifiConfiguration = mController.getConfig();
+ assertThat(wifiConfiguration.carrierId).isEqualTo(carrierId);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
index 8d3405c..9aaaa43 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
@@ -53,10 +53,12 @@
import android.net.RouteInfo;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.provider.Settings;
+import android.telephony.TelephonyManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
@@ -175,6 +177,8 @@
@Mock
private Preference mMockSsidPref;
@Mock
+ private Preference mMockEapSimSubscriptionPref;
+ @Mock
private Preference mMockMacAddressPref;
@Mock
private Preference mMockIpAddressPref;
@@ -374,6 +378,8 @@
.thenReturn(mMockSecurityPref);
when(mMockScreen.findPreference(WifiDetailPreferenceController2.KEY_SSID_PREF))
.thenReturn(mMockSsidPref);
+ when(mMockScreen.findPreference(WifiDetailPreferenceController2
+ .KEY_EAP_SIM_SUBSCRIPTION_PREF)).thenReturn(mMockEapSimSubscriptionPref);
when(mMockScreen.findPreference(WifiDetailPreferenceController2.KEY_MAC_ADDRESS_PREF))
.thenReturn(mMockMacAddressPref);
when(mMockScreen.findPreference(WifiDetailPreferenceController2.KEY_IP_ADDRESS_PREF))
@@ -1582,6 +1588,82 @@
verify(mMockHeaderController).setSummary(expired);
}
+ @Test
+ public void refreshEapSimSubscription_nonEapSecurity_invisibleEapSimSubscriptionPref() {
+ setUpForDisconnectedNetwork();
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_NONE);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref, times(1)).setVisible(false);
+
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_OWE);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref, times(2)).setVisible(false);
+
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_PSK);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref, times(3)).setVisible(false);
+
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_SAE);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref, times(4)).setVisible(false);
+ verify(mMockEapSimSubscriptionPref, never()).setVisible(true);
+ }
+
+ @Test
+ public void refreshEapSimSubscription_nonSimEapMethod_invisibleEapSimSubscriptionPref() {
+ setUpForDisconnectedNetwork();
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ final WifiConfiguration mockWifiConfiguration = mock(WifiConfiguration.class);
+ final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
+ when(mockWifiEnterpriseConfig.isAuthenticationSimBased()).thenReturn(false);
+ mockWifiConfiguration.enterpriseConfig = mockWifiEnterpriseConfig;
+ when(mMockWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfiguration);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref, times(1)).setVisible(false);
+ }
+
+ @Test
+ public void refreshEapSimSubscription_simEapMethod_visibleEapSimSubscriptionPref() {
+ setUpForDisconnectedNetwork();
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ final WifiConfiguration mockWifiConfiguration = mock(WifiConfiguration.class);
+ final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
+ when(mockWifiEnterpriseConfig.isAuthenticationSimBased()).thenReturn(true);
+ mockWifiConfiguration.enterpriseConfig = mockWifiEnterpriseConfig;
+ when(mMockWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfiguration);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref).setVisible(true);
+ }
+
+ @Test
+ public void refreshEapSimSubscription_unknownCarrierId_noSimEapSimSubscriptionPref() {
+ setUpForDisconnectedNetwork();
+ when(mMockWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
+ final WifiConfiguration mockWifiConfiguration = mock(WifiConfiguration.class);
+ mockWifiConfiguration.carrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
+ final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
+ when(mockWifiEnterpriseConfig.isAuthenticationSimBased()).thenReturn(true);
+ mockWifiConfiguration.enterpriseConfig = mockWifiEnterpriseConfig;
+ when(mMockWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfiguration);
+
+ displayAndResume();
+
+ verify(mMockEapSimSubscriptionPref).setVisible(true);
+ verify(mMockEapSimSubscriptionPref).setSummary(R.string.wifi_no_related_sim_card);
+ }
+
private ActionButtonsPreference createMock() {
final ActionButtonsPreference pref = mock(ActionButtonsPreference.class);
when(pref.setButton1Text(anyInt())).thenReturn(pref);