[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: 8214e3f395 -s ours am: 1a2b17caf7 -s ours
am skip reason: subject contains skip directive
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12291931
Change-Id: I2e4a71eca15320d4bfb7067de08a027d6da229a8
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/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 45ecd61..a0f49e4 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -196,18 +196,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..d78a7b8 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.
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/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..9b4ef60 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -159,7 +159,6 @@
private String mMultipleCertSetString;
private String mUseSystemCertsString;
private String mDoNotProvideEapUserCertString;
- private String mDoNotValidateEapServerString;
private ScrollView mDialogContainer;
private Spinner mSecuritySpinner;
@@ -264,8 +263,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 +551,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 +572,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 +584,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 +722,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 +756,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());
@@ -1052,15 +1036,15 @@
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
@@ -1125,7 +1109,7 @@
} 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 +1117,9 @@
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
- mDoNotValidateEapServerString,
- true,
- true);
+ null /* noCertificateString */,
+ true /* showMultipleCerts */,
+ true /* showUsePreinstalledCertOption */);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
}
}
@@ -1262,8 +1246,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();
@@ -1485,7 +1468,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 +1697,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..576ffa2 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -156,7 +156,6 @@
private String mMultipleCertSetString;
private String mUseSystemCertsString;
private String mDoNotProvideEapUserCertString;
- private String mDoNotValidateEapServerString;
private ScrollView mDialogContainer;
private Spinner mSecuritySpinner;
@@ -253,8 +252,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 +530,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 +551,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 +563,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);
}
}
@@ -718,8 +704,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);
@@ -752,8 +737,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());
@@ -1034,15 +1018,15 @@
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
@@ -1108,7 +1092,7 @@
} 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 +1100,9 @@
loadCertificates(
mEapCaCertSpinner,
Credentials.CA_CERTIFICATE,
- mDoNotValidateEapServerString,
- true,
- true);
+ null /* noCertificateString */,
+ true /* showMultipleCerts */,
+ true /* showUsePreinstalledCertOption */);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
}
}
@@ -1245,8 +1229,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();
@@ -1468,7 +1451,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 +1680,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/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..06697fb 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
@@ -225,6 +225,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);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index 9146998..39f9cda 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -219,6 +219,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);