Merge "Fine-tune the layout of shortcut preference."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 70f43e5..4300e58 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -70,7 +70,7 @@
<uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" />
<uses-permission android:name="android.permission.CONFIGURE_DISPLAY_COLOR_MODE" />
<uses-permission android:name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
- <uses-permission android:name="android.permission.SET_TIME" />
+ <uses-permission android:name="android.permission.SUGGEST_MANUAL_TIME_AND_ZONE" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATIONS" />
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
diff --git a/res/layout/daltonizer_preview.xml b/res/layout/daltonizer_preview.xml
new file mode 100644
index 0000000..24c0f76
--- /dev/null
+++ b/res/layout/daltonizer_preview.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/preview_viewport"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <com.android.settings.accessibility.PaletteListView
+ android:id="@+id/palette_listView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:contentDescription="@null" />
+
+</FrameLayout>
diff --git a/res/layout/palette_listview_item.xml b/res/layout/palette_listview_item.xml
new file mode 100644
index 0000000..e8cc940
--- /dev/null
+++ b/res/layout/palette_listview_item.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/item_textview"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="10dp"
+ android:textSize="20dp"
+ android:maxLength="20"
+ android:singleLine="true"/>
+
+</FrameLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index b1f9dfb..c88158b 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -22,11 +22,21 @@
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
<color name="contextual_card_background">@*android:color/material_grey_900</color>
<color name="search_bar_background">@*android:color/material_grey_800</color>
- <!-- Dialog background color -->
+ <!-- Dialog background color. -->
<color name="dialog_background">@*android:color/material_grey_800</color>
<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="face_intro_outline">?android:attr/colorAccent</color>
+ <!-- Palette list preference colors. -->
+ <color name="palette_list_gradient_background">@android:color/black</color>
+ <color name="palette_list_color_red">@color/palette_list_dark_mode_color_red</color>
+ <color name="palette_list_color_orange">@color/palette_list_dark_mode_color_orange</color>
+ <color name="palette_list_color_yellow">@color/palette_list_dark_mode_color_yellow</color>
+ <color name="palette_list_color_green">@color/palette_list_dark_mode_color_green</color>
+ <color name="palette_list_color_cyan">@color/palette_list_dark_mode_color_cyan</color>
+ <color name="palette_list_color_blue">@color/palette_list_dark_mode_color_blue</color>
+ <color name="palette_list_color_purple">@color/palette_list_dark_mode_color_purple</color>
+ <color name="palette_list_color_pink">@color/palette_list_dark_mode_color_pink</color>
</resources>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index f1b2626..e302905 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -23,19 +23,19 @@
strings. --> <skip />
<!-- The time zone picker screen has two levels. The first level allows the user to choose a region. -->
<string-array name="timezone_filters">
- <!-- The next level of the time zoner picker should show time zones from the Americas. -->
+ <!-- The next level of the time zoner picker should show time zones from the Americas. -->
<item>America</item>
- <!-- The next level of the time zoner picker should show time zones from Europe. -->
+ <!-- The next level of the time zoner picker should show time zones from Europe. -->
<item>Europe</item>
- <!-- The next level of the time zoner picker should show time zones from Africa. -->
+ <!-- The next level of the time zoner picker should show time zones from Africa. -->
<item>Africa</item>
- <!-- The next level of the time zoner picker should show time zones from Asia. -->
+ <!-- The next level of the time zoner picker should show time zones from Asia. -->
<item>Asia</item>
- <!-- The next level of the time zoner picker should show time zones from Australia. -->
+ <!-- The next level of the time zoner picker should show time zones from Australia. -->
<item>Australia</item>
- <!-- The next level of the time zoner picker should show time zones from Pacific. -->
+ <!-- The next level of the time zoner picker should show time zones from Pacific. -->
<item>Pacific</item>
- <!-- The next level of the time zoner picker should show time zones from ALL regions. -->
+ <!-- The next level of the time zoner picker should show time zones from ALL regions. -->
<item>All</item>
</string-array>
@@ -274,8 +274,8 @@
<item>Require all non-trusted certificate statuses</item>
</string-array>
- <!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
- <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
+ <!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
+ <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
<string-array translatable="false" name="wifi_ap_band_config_full">
<item>1</item>
<item>2</item>
@@ -301,8 +301,8 @@
<item>@string/wifi_ap_choose_2G</item>
</string-array>
- <!-- Wi-Fi WPS setup for p2p connections. -->
- <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
+ <!-- Wi-Fi WPS setup for p2p connections. -->
+ <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
<string-array name="wifi_p2p_wps_setup">
<!-- Push button based configuration involves pushing a button on two connecting devices [CHAR LIMIT=30]-->
<item>Push button</item>
@@ -320,7 +320,7 @@
<item>Unsuccessful</item>
<item>Available</item>
<item>Out-of-range</item>
- </string-array>
+ </string-array>
<!-- Bluetooth Settings -->
@@ -410,7 +410,7 @@
</string-array>
<!-- Wi-Fi IP settings. -->
- <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
+ <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
<string-array name="wifi_ip_settings">
<!-- Use DHCP (Dynamic Host Configuration Protocol) for obtaining IP settings [CHAR LIMIT=25] -->
<item>DHCP</item>
@@ -1432,15 +1432,15 @@
<!-- WiFi calling mode array -->
<string-array name="wifi_calling_mode_summaries" translatable="false">
- <item>@string/wifi_calling_mode_wifi_preferred_summary</item>
- <item>@string/wifi_calling_mode_cellular_preferred_summary</item>
- <item>@string/wifi_calling_mode_wifi_only_summary</item>
+ <item>@string/wifi_calling_mode_wifi_preferred_summary</item>
+ <item>@string/wifi_calling_mode_cellular_preferred_summary</item>
+ <item>@string/wifi_calling_mode_wifi_only_summary</item>
</string-array>
<!-- WiFi calling mode array without wifi only mode -->
<string-array name="wifi_calling_mode_summaries_without_wifi_only" translatable="false">
- <item>@string/wifi_calling_mode_wifi_preferred_summary</item>
- <item>@string/wifi_calling_mode_cellular_preferred_summary</item>
+ <item>@string/wifi_calling_mode_wifi_preferred_summary</item>
+ <item>@string/wifi_calling_mode_cellular_preferred_summary</item>
</string-array>
<!-- Carrier variant of Enhaced 4G LTE Mode title. [CHAR LIMIT=NONE] -->
@@ -1469,4 +1469,27 @@
<item>"com.google.android.googlequicksearchbox"</item>
</string-array>
-</resources>
+ <!-- Array of titles palette list for accessibility. -->
+ <string-array name="setting_palette_colors" translatable="false" >
+ <item>@string/color_red</item>
+ <item>@string/color_orange</item>
+ <item>@string/color_yellow</item>
+ <item>@string/color_green</item>
+ <item>@string/color_cyan</item>
+ <item>@string/color_blue</item>
+ <item>@string/color_purple</item>
+ <item>@string/color_pink</item>
+ </string-array>
+
+ <!-- Values for palette list view preference. -->
+ <array name="setting_palette_data" translatable="false" >
+ <item>@color/palette_list_color_red</item>
+ <item>@color/palette_list_color_orange</item>
+ <item>@color/palette_list_color_yellow</item>
+ <item>@color/palette_list_color_green</item>
+ <item>@color/palette_list_color_cyan</item>
+ <item>@color/palette_list_color_blue</item>
+ <item>@color/palette_list_color_purple</item>
+ <item>@color/palette_list_color_pink</item>
+ </array>
+</resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 3fd77e8..1c18c6a 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -148,4 +148,26 @@
<color name="face_intro_outline">#ffdadce0</color>
<color name="back_gesture_indicator">#4182ef</color>
+
+ <!-- Palette list preference colors. -->
+ <color name="palette_list_gradient_background">@android:color/white</color>
+ <color name="palette_list_color_red">#d93025</color> <!-- Material Red 600 -->
+ <color name="palette_list_color_orange">#e8710a</color> <!-- Material Orange 600 -->
+ <color name="palette_list_color_yellow">#f9ab00</color> <!-- Material Yellow 600 -->
+ <color name="palette_list_color_green">#1e8e3e</color> <!-- Material Green 600 -->
+ <color name="palette_list_color_cyan">#12b5cb</color> <!-- Material Cyan 600 -->
+ <color name="palette_list_color_blue">#1a73e8</color> <!-- Material Blue 600 -->
+ <color name="palette_list_color_purple">#9334e6</color> <!-- Material Purple 600 -->
+ <color name="palette_list_color_pink">#e52592</color> <!-- Material Pink 600 -->
+
+ <!-- Palette list preference dark mode colors. -->
+ <color name="palette_list_dark_mode_color_red">#f28b82</color> <!-- Material Red 300 -->
+ <color name="palette_list_dark_mode_color_orange">#fcad70</color> <!-- Material Orange 300 -->
+ <color name="palette_list_dark_mode_color_yellow">#fdd663</color> <!-- Material Yellow 300 -->
+ <color name="palette_list_dark_mode_color_green">#81c995</color> <!-- Material Green 300 -->
+ <color name="palette_list_dark_mode_color_cyan">#78d9ec</color> <!-- Material Cyan 300 -->
+ <color name="palette_list_dark_mode_color_blue">#8AB4F8</color> <!-- Material Blue 300 -->
+ <color name="palette_list_dark_mode_color_purple">#c58af9</color> <!-- Material Purple 300 -->
+ <color name="palette_list_dark_mode_color_pink">#ff8bcb</color> <!-- Material Pink 300 -->
+
</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 74f4621..1a480fe 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2091,6 +2091,10 @@
<string name="wifi_dpp_wifi_password">Wi\u2011Fi password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
<!-- Hint for Wi-Fi hotspot password [CHAR LIMIT=50] -->
<string name="wifi_dpp_hotspot_password">Hotspot password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
+ <!-- Label for specifying if a Wi-Fi network supports auto connection [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">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] -->
@@ -7228,6 +7232,8 @@
<string name="color_orange">Orange</string>
<!-- Purple label. [CHAR LIMIT=40] -->
<string name="color_purple">Purple</string>
+ <!-- Pink label. [CHAR LIMIT=40] -->
+ <string name="color_pink">Pink</string>
<!-- Message informing the user that no SIM card is inserted [CHAR LIMIT=60] -->
<string name="sim_no_inserted_msg">No SIM cards inserted</string>
<!-- SIM status title [CHAR LIMIT=40] -->
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index 22e0510..75386f5 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -21,6 +21,13 @@
android:persistent="false"
android:title="@string/accessibility_display_daltonizer_preference_title">
+ <com.android.settings.accessibility.PaletteListPreference
+ android:key="daltonizer_preview"
+ android:persistent="false"
+ android:selectable="false"
+ android:title="@string/summary_placeholder"
+ settings:searchable="false"/>
+
<com.android.settingslib.widget.RadioButtonPreference
android:key="daltonizer_mode_deuteranomaly"
android:persistent="false"
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 9a4add4..acd50ad 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -303,6 +303,13 @@
android:entries="@array/bluetooth_avrcp_versions"
android:entryValues="@array/bluetooth_avrcp_version_values" />
+ <ListPreference
+ android:key="bluetooth_select_map_version"
+ android:title="@string/bluetooth_select_map_version_string"
+ android:dialogTitle="@string/bluetooth_select_map_version_dialog_title"
+ android:entries="@array/bluetooth_map_versions"
+ android:entryValues="@array/bluetooth_map_version_values" />
+
<SwitchPreference
android:key="bluetooth_hd_audio_settings"
android:title="@string/bluetooth_profile_a2dp_high_quality_unknown_codec"/>
diff --git a/res/xml/wifi_network_details_fragment2.xml b/res/xml/wifi_network_details_fragment2.xml
new file mode 100644
index 0000000..3058678
--- /dev/null
+++ b/res/xml/wifi_network_details_fragment2.xml
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ settings:initialExpandedChildrenCount="5">
+
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="connection_header"
+ android:layout="@layout/settings_entity_header"
+ android:selectable="false"
+ android:order="-10000"
+ settings:allowDividerBelow="true"/>
+
+ <com.android.settings.datausage.DataUsageSummaryPreference
+ android:key="status_header"
+ android:selectable="false"
+ settings:isPreferenceVisible="false"/>
+
+ <!-- Buttons -->
+ <com.android.settingslib.widget.ActionButtonsPreference
+ android:key="buttons"
+ android:selectable="false" />
+
+ <!-- General Details Preferences -->
+ <Preference
+ android:key="signal_strength"
+ android:title="@string/wifi_signal"
+ android:selectable="false"
+ settings:allowDividerAbove="true"/>
+
+ <Preference
+ android:key="frequency"
+ android:icon="@drawable/ic_frequency_antenna"
+ android:title="@string/wifi_frequency"
+ android:selectable="false"/>
+
+ <Preference
+ android:key="security"
+ android:icon="@drawable/ic_security_lock_24dp"
+ android:title="@string/wifi_security"
+ android:selectable="false"/>
+
+ <DropDownPreference
+ android:key="metered"
+ android:icon="@drawable/ic_attach_money_black_24dp"
+ android:title="@string/wifi_metered_title"
+ android:entries="@array/wifi_metered_entries"
+ android:entryValues="@array/wifi_metered_values"/>
+
+ <DropDownPreference
+ android:key="privacy"
+ android:icon="@drawable/ic_wifi_privacy_24dp"
+ android:title="@string/wifi_privacy_settings"
+ android:entries="@array/wifi_privacy_entries"
+ android:entryValues="@array/wifi_privacy_values"/>
+
+ <SwitchPreference
+ android:key="auto_connect"
+ android:title="@string/wifi_auto_connect_title"
+ android:summary="@string/wifi_auto_connect_summary"
+ settings:allowDividerAbove="true"/>
+
+ <!-- Add device Preference -->
+ <Preference
+ android:key="add_device_to_network"
+ android:title="@string/wifi_dpp_add_device"
+ android:summary="@string/wifi_dpp_connect_network_using_qr_code"
+ settings:allowDividerAbove="true"/>
+
+ <!-- Network Details -->
+ <PreferenceCategory
+ android:key="ip_details_category"
+ android:title="@string/wifi_setup_detail">
+ <Preference
+ android:key="ssid"
+ android:title="@string/wifi_advanced_ssid_title"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="mac_address"
+ android:title="@string/wifi_advanced_randomized_mac_address_title"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="ip_address"
+ android:title="@string/wifi_ip_address"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="gateway"
+ android:title="@string/wifi_gateway"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="subnet_mask"
+ android:title="@string/wifi_details_subnet_mask"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="dns"
+ android:title="@string/wifi_details_dns"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="tx_link_speed"
+ android:title="@string/tx_wifi_speed"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
+ android:key="rx_link_speed"
+ android:title="@string/rx_wifi_speed"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ </PreferenceCategory>
+
+ <!-- IPv6 Details -->
+ <PreferenceCategory
+ android:key="ipv6_category"
+ android:title="@string/wifi_details_ipv6_address_header"
+ android:selectable="false">
+ <Preference
+ android:key="ipv6_addresses"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/PaletteListPreference.java b/src/com/android/settings/accessibility/PaletteListPreference.java
new file mode 100644
index 0000000..c75da7f
--- /dev/null
+++ b/src/com/android/settings/accessibility/PaletteListPreference.java
@@ -0,0 +1,88 @@
+/*
+ * 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.accessibility;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.widget.FrameLayout;
+import android.widget.ListView;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settingslib.widget.R;
+
+/** Preference that easier preview by matching name to color. */
+public class PaletteListPreference extends Preference {
+
+ /**
+ * Constructs a new PaletteListPreference with the given context's theme and the supplied
+ * attribute set.
+ *
+ * @param context The Context this is associated with, through which it can access the current
+ * theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the view.
+ */
+ public PaletteListPreference(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ /**
+ * Constructs a new PaletteListPreference with the given context's theme, the supplied
+ * attribute set, and default style attribute.
+ *
+ * @param context The Context this is associated with, through which it can access the
+ * current theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the view.
+ * @param defStyleAttr An attribute in the current theme that contains a reference to a style
+ * resource that supplies default
+ * values for the view. Can be 0 to not look for
+ * defaults.
+ */
+ public PaletteListPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ setLayoutResource(R.layout.daltonizer_preview);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ final View rootView = holder.itemView;
+ final ListView listView = rootView.findViewById(R.id.palette_listView);
+ listView.getViewTreeObserver().addOnGlobalLayoutListener(
+ new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ final int listViewHeight = listView.getMeasuredHeight();
+ final int listViewWidth = listView.getMeasuredWidth();
+ // Removes the callback after get result of measure view.
+ listView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+
+ // Resets layout parameters to display whole items from listView.
+ final FrameLayout.LayoutParams layoutParams =
+ (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.height = listViewHeight * listView.getAdapter().getCount();
+ layoutParams.width = listViewWidth;
+ listView.setLayoutParams(layoutParams);
+ listView.invalidateViews();
+ }
+ });
+ }
+}
diff --git a/src/com/android/settings/accessibility/PaletteListView.java b/src/com/android/settings/accessibility/PaletteListView.java
new file mode 100644
index 0000000..0030817
--- /dev/null
+++ b/src/com/android/settings/accessibility/PaletteListView.java
@@ -0,0 +1,292 @@
+/*
+ * 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.accessibility;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.GradientDrawable.Orientation;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.Display;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settingslib.widget.R;
+
+import com.google.common.collect.Iterables;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Custom ListView {@link ListView} which displays palette to deploy the color code preview.
+ *
+ * <p>The preview shows gradient from color white to specific color code on each list view item, in
+ * addition, text view adjusts the attribute of width for adapting the text length.
+ *
+ * <p>The text cannot fills the whole view for ensuring the gradient color preview can purely
+ * display also the view background shows the color beside the text variable end point.
+ */
+public class PaletteListView extends ListView {
+ private static final float VIEW_PITCH = 0.05f;
+ private final Context mContext;
+ private final DisplayAdapter mDisplayAdapter;
+ private final LayoutInflater mLayoutInflater;
+ private final String mDefaultGradientColorCodeString;
+ private final int mDefaultGradientColor;
+ private float mTextBound;
+
+ public PaletteListView(Context context) {
+ this(context, null);
+ }
+
+ public PaletteListView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public PaletteListView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ mContext = context;
+ mDisplayAdapter = new DisplayAdapter();
+ mLayoutInflater = LayoutInflater.from(context);
+ mDefaultGradientColorCodeString =
+ getResources().getString(R.color.palette_list_gradient_background);
+ mDefaultGradientColor =
+ getResources().getColor(R.color.palette_list_gradient_background, null);
+ mTextBound = 0.0f;
+ init();
+ }
+
+ private static int getScreenWidth(WindowManager windowManager) {
+ final Display display = windowManager.getDefaultDisplay();
+ final DisplayMetrics displayMetrics = new DisplayMetrics();
+ display.getMetrics(displayMetrics);
+ return displayMetrics.widthPixels;
+ }
+
+ private void init() {
+ final TypedArray colorNameArray = getResources().obtainTypedArray(
+ R.array.setting_palette_colors);
+ final TypedArray colorCodeArray = getResources().obtainTypedArray(
+ R.array.setting_palette_data);
+ final int colorNameArrayLength = colorNameArray.length();
+ final List<ColorAttributes> colorList = new ArrayList<>();
+ computeTextWidthBounds(colorNameArray);
+
+ for (int index = 0; index < colorNameArrayLength; index++) {
+ colorList.add(
+ new ColorAttributes(
+ /* colorName= */ colorNameArray.getString(index),
+ /* colorCode= */ colorCodeArray.getColor(index, mDefaultGradientColor),
+ /* textBound= */ mTextBound,
+ /* gradientDrawable= */
+ new GradientDrawable(Orientation.LEFT_RIGHT, null)));
+ }
+
+ mDisplayAdapter.setColorList(colorList);
+ setAdapter(mDisplayAdapter);
+ setDividerHeight(/* height= */ 0);
+ }
+
+ /**
+ * Sets string array that required the color name and color code for deploy the new color
+ * preview.
+ *
+ * <p>The parameters not allow null define but two array length inconsistent are acceptable, in
+ * addition, to prevent IndexOutOfBoundsException the algorithm will check array data, and base
+ * on the array size to display data, or fills color code array if length less than other.
+ *
+ * @param colorNames a string array of color name
+ * @param colorCodes a string array of color code
+ * @return true if new array data apply successful
+ */
+ @VisibleForTesting
+ boolean setPaletteListColors(@NonNull String[] colorNames, @NonNull String[] colorCodes) {
+ if (colorNames == null || colorCodes == null) {
+ return false;
+ }
+
+ final int colorNameArrayLength = colorNames.length;
+ final int colorCodeArrayLength = colorCodes.length;
+ final List<ColorAttributes> colorList = new ArrayList<>();
+ final String[] colorCodeArray = fillColorCodeArray(colorCodes, colorNameArrayLength,
+ colorCodeArrayLength);
+ computeTextWidthBounds(colorNames);
+
+ for (int index = 0; index < colorNameArrayLength; index++) {
+ colorList.add(
+ new ColorAttributes(
+ /* colorName= */ colorNames[index],
+ /* colorCode= */ Color.parseColor(colorCodeArray[index]),
+ /* textBound= */ mTextBound,
+ /* gradientDrawable= */
+ new GradientDrawable(Orientation.LEFT_RIGHT, null)));
+ }
+
+ mDisplayAdapter.setColorList(colorList);
+ mDisplayAdapter.notifyDataSetChanged();
+ return true;
+ }
+
+ private String[] fillColorCodeArray(String[] colorCodes, int colorNameArrayLength,
+ int colorCodeArrayLength) {
+ if (colorNameArrayLength == colorCodeArrayLength
+ || colorNameArrayLength < colorCodeArrayLength) {
+ return colorCodes;
+ }
+
+ final String[] colorCodeArray = new String[colorNameArrayLength];
+ for (int index = 0; index < colorNameArrayLength; index++) {
+ if (index < colorCodeArrayLength) {
+ colorCodeArray[index] = colorCodes[index];
+ } else {
+ colorCodeArray[index] = mDefaultGradientColorCodeString;
+ }
+ }
+ return colorCodeArray;
+ }
+
+ private void computeTextWidthBounds(TypedArray colorNameTypedArray) {
+ final int colorNameArrayLength = colorNameTypedArray.length();
+ final String[] colorNames = new String[colorNameArrayLength];
+ for (int index = 0; index < colorNameArrayLength; index++) {
+ colorNames[index] = colorNameTypedArray.getString(index);
+ }
+
+ measureBound(colorNames);
+ }
+
+ private void computeTextWidthBounds(String[] colorNameArray) {
+ final int colorNameArrayLength = colorNameArray.length;
+ final String[] colorNames = new String[colorNameArrayLength];
+ for (int index = 0; index < colorNameArrayLength; index++) {
+ colorNames[index] = colorNameArray[index];
+ }
+
+ measureBound(colorNames);
+ }
+
+ private void measureBound(String[] dataArray) {
+ final WindowManager windowManager = (WindowManager) mContext.getSystemService(
+ Context.WINDOW_SERVICE);
+ final View view = mLayoutInflater.inflate(R.layout.palette_listview_item, null);
+ final TextView textView = view.findViewById(R.id.item_textview);
+ final List<String> colorNameList = new ArrayList<>(Arrays.asList(dataArray));
+ Collections.sort(colorNameList, Comparator.comparing(String::length));
+ // Gets the last index of list which sort by text length.
+ textView.setText(Iterables.getLast(colorNameList));
+
+ final float textWidth = textView.getPaint().measureText(textView.getText().toString());
+ // Computes rate of text width compare to screen width, and measures the round the double
+ // to two decimal places manually.
+ final float textBound = Math.round(textWidth / getScreenWidth(windowManager) * 100) / 100f;
+ mTextBound = textBound + VIEW_PITCH;
+ }
+
+ private static class ViewHolder {
+ public TextView textView;
+ }
+
+ /** An adapter that converts color text title and color code to text views. */
+ private final class DisplayAdapter extends BaseAdapter {
+
+ private List<ColorAttributes> mColorList;
+
+ @Override
+ public int getCount() {
+ return mColorList.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mColorList.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ final ViewHolder viewHolder;
+ final ColorAttributes paletteAttribute = mColorList.get(position);
+ final String colorName = paletteAttribute.getColorName();
+ final GradientDrawable gradientDrawable = paletteAttribute.getGradientDrawable();
+
+ if (convertView == null) {
+ convertView = mLayoutInflater.inflate(R.layout.palette_listview_item, null);
+ viewHolder = new ViewHolder();
+ viewHolder.textView = convertView.findViewById(R.id.item_textview);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+
+ viewHolder.textView.setText(colorName);
+ viewHolder.textView.setBackground(gradientDrawable);
+ return convertView;
+ }
+
+ protected void setColorList(List<ColorAttributes> colorList) {
+ mColorList = colorList;
+ }
+ }
+
+ private final class ColorAttributes {
+ private final int mColorIndex = 2; // index for inject color.
+ private final int mColorOffsetIndex = 1; // index for offset effect.
+ private final String mColorName;
+ private final GradientDrawable mGradientDrawable;
+ private final int[] mGradientColors =
+ {/* startColor=*/ mDefaultGradientColor, /* centerColor=*/ mDefaultGradientColor,
+ /* endCode= */ 0};
+ private final float[] mGradientOffsets =
+ {/* starOffset= */ 0.0f, /* centerOffset= */ 0.5f, /* endOffset= */ 1.0f};
+
+ ColorAttributes(
+ String colorName, int colorCode, float textBound,
+ GradientDrawable gradientDrawable) {
+ mGradientColors[mColorIndex] = colorCode;
+ mGradientOffsets[mColorOffsetIndex] = textBound;
+ gradientDrawable.setColors(mGradientColors, mGradientOffsets);
+ mColorName = colorName;
+ mGradientDrawable = gradientDrawable;
+ }
+
+ public String getColorName() {
+ return mColorName;
+ }
+
+ public GradientDrawable getGradientDrawable() {
+ return mGradientDrawable;
+ }
+ }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index e1ca4f7..08cfa70 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -329,10 +329,13 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
- final FaceManager faceManager = context.getSystemService(FaceManager.class);
- final boolean hasEnrolled = faceManager.hasEnrolledTemplates(
- UserHandle.myUserId());
- keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK : PREF_KEY_DELETE_FACE_DATA);
+ if (isAvailable(context)) {
+ final FaceManager faceManager = context.getSystemService(FaceManager.class);
+ final boolean hasEnrolled = faceManager.hasEnrolledTemplates(
+ UserHandle.myUserId());
+ keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK
+ : PREF_KEY_DELETE_FACE_DATA);
+ }
return keys;
}
};
diff --git a/src/com/android/settings/development/BluetoothMapVersionPreferenceController.java b/src/com/android/settings/development/BluetoothMapVersionPreferenceController.java
new file mode 100644
index 0000000..ac20627
--- /dev/null
+++ b/src/com/android/settings/development/BluetoothMapVersionPreferenceController.java
@@ -0,0 +1,79 @@
+/*
+ * 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.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.text.TextUtils;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+/**
+ * Preference controller to control Bluetooth MAP version
+ */
+public class BluetoothMapVersionPreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String BLUETOOTH_SELECT_MAP_VERSION_KEY =
+ "bluetooth_select_map_version";
+
+ @VisibleForTesting
+ static final String BLUETOOTH_MAP_VERSION_PROPERTY = "persist.bluetooth.mapversion";
+
+ private final String[] mListValues;
+ private final String[] mListSummaries;
+
+ public BluetoothMapVersionPreferenceController(Context context) {
+ super(context);
+
+ mListValues = context.getResources().getStringArray(R.array.bluetooth_map_version_values);
+ mListSummaries = context.getResources().getStringArray(R.array.bluetooth_map_versions);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return BLUETOOTH_SELECT_MAP_VERSION_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ SystemProperties.set(BLUETOOTH_MAP_VERSION_PROPERTY, newValue.toString());
+ updateState(mPreference);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final ListPreference listPreference = (ListPreference) preference;
+ final String currentValue = SystemProperties.get(BLUETOOTH_MAP_VERSION_PROPERTY);
+ int index = 0; // Defaults to MAP 1.2
+ for (int i = 0; i < mListValues.length; i++) {
+ if (TextUtils.equals(currentValue, mListValues[i])) {
+ index = i;
+ break;
+ }
+ }
+ listPreference.setValue(mListValues[index]);
+ listPreference.setSummary(mListSummaries[index]);
+ }
+}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 88f2c50..1c08131 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -465,6 +465,7 @@
controllers.add(new BluetoothAbsoluteVolumePreferenceController(context));
controllers.add(new BluetoothGabeldorschePreferenceController(context));
controllers.add(new BluetoothAvrcpVersionPreferenceController(context));
+ controllers.add(new BluetoothMapVersionPreferenceController(context));
controllers.add(new BluetoothA2dpHwOffloadPreferenceController(context, fragment));
controllers.add(new BluetoothMaxConnectedAudioDevicesPreferenceController(context));
controllers.add(new ShowTapsPreferenceController(context));
diff --git a/src/com/android/settings/network/telephony/MmsMessagePreferenceController.java b/src/com/android/settings/network/telephony/MmsMessagePreferenceController.java
index 00f5ebc..b428b22 100644
--- a/src/com/android/settings/network/telephony/MmsMessagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/MmsMessagePreferenceController.java
@@ -88,7 +88,7 @@
@Override
public boolean setChecked(boolean isChecked) {
- return mSubscriptionManager.setAlwaysAllowMmsData(mSubId, isChecked);
+ return mTelephonyManager.setAlwaysAllowMmsData(isChecked);
}
@Override
diff --git a/src/com/android/settings/wifi/details2/WifiAutoConnectPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiAutoConnectPreferenceController2.java
new file mode 100644
index 0000000..ffbb682
--- /dev/null
+++ b/src/com/android/settings/wifi/details2/WifiAutoConnectPreferenceController2.java
@@ -0,0 +1,57 @@
+/*
+ * 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.wifi.details2;
+
+import android.content.Context;
+
+import com.android.settings.core.TogglePreferenceController;
+import com.android.wifitrackerlib.WifiEntry;
+
+/**
+ * {@link TogglePreferenceController} that controls whether the Wi-Fi Auto-connect feature should be
+ * enabled.
+ */
+public class WifiAutoConnectPreferenceController2 extends TogglePreferenceController {
+
+ private static final String KEY_AUTO_CONNECT = "auto_connect";
+
+ private WifiEntry mWifiEntry;
+
+ public WifiAutoConnectPreferenceController2(Context context) {
+ super(context, KEY_AUTO_CONNECT);
+ }
+
+ public void setWifiEntry(WifiEntry wifiEntry) {
+ mWifiEntry = wifiEntry;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mWifiEntry.canSetAutoJoinEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mWifiEntry.isAutoJoinEnabled();
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ mWifiEntry.setAutoJoinEnabled(isChecked);
+ return true;
+ }
+}
diff --git a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
index bdd63dc..d07d6d6 100644
--- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
+++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
@@ -91,7 +91,7 @@
@Override
protected int getPreferenceScreenResId() {
- return R.xml.wifi_network_details_fragment;
+ return R.xml.wifi_network_details_fragment2;
}
@Override
@@ -155,6 +155,11 @@
mMetricsFeatureProvider);
controllers.add(mWifiDetailPreferenceController2);
+ final WifiAutoConnectPreferenceController2 wifiAutoConnectPreferenceController2 =
+ new WifiAutoConnectPreferenceController2(context);
+ wifiAutoConnectPreferenceController2.setWifiEntry(wifiEntry);
+ controllers.add(wifiAutoConnectPreferenceController2);
+
final AddDevicePreferenceController2 addDevicePreferenceController2 =
new AddDevicePreferenceController2(context);
addDevicePreferenceController2.setWifiEntry(wifiEntry);
diff --git a/tests/robotests/assets/grandfather_slice_controller_not_in_xml b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
index 94d5815..5cd855f 100644
--- a/tests/robotests/assets/grandfather_slice_controller_not_in_xml
+++ b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
@@ -7,4 +7,5 @@
com.android.settings.testutils.FakeToggleController
com.android.settings.testutils.FakeSliderController
com.android.settings.testutils.FakeInvalidSliderController
+com.android.settings.wifi.details2.WifiAutoConnectPreferenceController2
diff --git a/tests/robotests/src/com/android/settings/accessibility/PaletteListViewTest.java b/tests/robotests/src/com/android/settings/accessibility/PaletteListViewTest.java
new file mode 100644
index 0000000..13e76d7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/PaletteListViewTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link PaletteListView} */
+@RunWith(RobolectricTestRunner.class)
+public class PaletteListViewTest {
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private PaletteListView mPaletteListView;
+
+ @Before
+ public void setUp() {
+ mPaletteListView = new PaletteListView(mContext);
+ }
+
+ @Test
+ public void setColors_applySameLengthArray_configureSuccessful() {
+ final String[] colorName = {"White", "Black", "Yellow"};
+ final String[] colorCode = {"#ffffff", "#000000", "#f9ab00"};
+
+ assertThat(mPaletteListView.setPaletteListColors(colorName, colorCode)).isTrue();
+ }
+
+ @Test
+ public void setColors_applyDifferentLengthArray_configureSuccessful() {
+ final String[] colorName = {"White", "Black", "Yellow", "Orange", "Red"};
+ final String[] colorCode = {"#ffffff", "#000000", "#f9ab00"};
+
+ assertThat(mPaletteListView.setPaletteListColors(colorName, colorCode)).isTrue();
+ }
+
+ @Test
+ public void setColors_configureFailed() {
+ final String[] colorName = null;
+ final String[] colorCode = null;
+
+ assertThat(mPaletteListView.setPaletteListColors(colorName, colorCode)).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothMapVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothMapVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..f897fdf
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/BluetoothMapVersionPreferenceControllerTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.development;
+import static com.android.settings.development.BluetoothMapVersionPreferenceController
+ .BLUETOOTH_MAP_VERSION_PROPERTY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.SystemProperties;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BluetoothMapVersionPreferenceControllerTest {
+ @Mock
+ private ListPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private Context mContext;
+ private BluetoothMapVersionPreferenceController mController;
+ /**
+ * 0: MAP 1.2 (Default)
+ * 1: MAP 1.3
+ * 2: MAP 1.4
+ */
+ private String[] mListValues;
+ private String[] mListSummaries;
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ final Resources resources = mContext.getResources();
+ mListValues = resources.getStringArray(R.array.bluetooth_map_version_values);
+ mListSummaries = resources.getStringArray(R.array.bluetooth_map_versions);
+ mController = new BluetoothMapVersionPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+ @Test
+ public void onPreferenceChange_setMap13_shouldEnableMap13() {
+ mController.onPreferenceChange(mPreference, mListValues[1]);
+
+ final String currentValue = SystemProperties.get(BLUETOOTH_MAP_VERSION_PROPERTY);
+ assertThat(currentValue).isEqualTo(mListValues[1]);
+ }
+ @Test
+ public void onPreferenceChange_setMap14_shouldEnableMap14() {
+ mController.onPreferenceChange(mPreference, mListValues[2]);
+
+ final String currentValue = SystemProperties.get(BLUETOOTH_MAP_VERSION_PROPERTY);
+ assertThat(currentValue).isEqualTo(mListValues[2]);
+ }
+ @Test
+ public void updateState_setMap13_shouldSetPreferenceToMap13() {
+ SystemProperties.set(BLUETOOTH_MAP_VERSION_PROPERTY, mListValues[1]);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setValue(mListValues[1]);
+ verify(mPreference).setSummary(mListSummaries[1]);
+ }
+ @Test
+ public void updateState_setMap14_shouldSetPreferenceToMap14() {
+ SystemProperties.set(BLUETOOTH_MAP_VERSION_PROPERTY, mListValues[2]);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setValue(mListValues[2]);
+ verify(mPreference).setSummary(mListSummaries[2]);
+ }
+ @Test
+ public void updateState_noValueSet_shouldSetDefaultToMap12() {
+ mController.updateState(mPreference);
+
+ verify(mPreference).setValue(mListValues[0]);
+ verify(mPreference).setSummary(mListSummaries[0]);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MmsMessagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/MmsMessagePreferenceControllerTest.java
index 0263fe9..a612657 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MmsMessagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MmsMessagePreferenceControllerTest.java
@@ -115,9 +115,9 @@
@Test
public void setChecked_setDataIntoSubscriptionManager() {
mController.setChecked(true);
- verify(mSubscriptionManager).setAlwaysAllowMmsData(SUB_ID, true);
+ verify(mTelephonyManager).setAlwaysAllowMmsData(true);
mController.setChecked(false);
- verify(mSubscriptionManager).setAlwaysAllowMmsData(SUB_ID, false);
+ verify(mTelephonyManager).setAlwaysAllowMmsData(false);
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiAutoConnectPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiAutoConnectPreferenceController2Test.java
new file mode 100644
index 0000000..7e604a3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiAutoConnectPreferenceController2Test.java
@@ -0,0 +1,89 @@
+/*
+ * 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.wifi.details2;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.android.wifitrackerlib.WifiEntry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiAutoConnectPreferenceController2Test {
+
+ private WifiAutoConnectPreferenceController2 mController;
+ @Mock
+ private WifiEntry mWifiEntry;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new WifiAutoConnectPreferenceController2(RuntimeEnvironment.application);
+ mController.setWifiEntry(mWifiEntry);
+ }
+
+ @Test
+ public void getAvailabilityStatus_shouldFollowCanSetAutoJoinEnabled() {
+ // Test able to set auto join.
+ when(mWifiEntry.canSetAutoJoinEnabled()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+
+ // Test not able to set auto join.
+ when(mWifiEntry.canSetAutoJoinEnabled()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void isChecked_shouldFollowIsAutoJoinEnabled() {
+ // Test auto join enabled.
+ when(mWifiEntry.isAutoJoinEnabled()).thenReturn(true);
+
+ assertThat(mController.isChecked()).isTrue();
+
+ // Test auto join disabled.
+ when(mWifiEntry.isAutoJoinEnabled()).thenReturn(false);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void setChecked_shouldSetAutoJoinEnabled() {
+ // Test checked.
+ mController.setChecked(true);
+
+ verify(mWifiEntry).setAutoJoinEnabled(true);
+
+ // Test unchecked.
+ mController.setChecked(false);
+
+ verify(mWifiEntry).setAutoJoinEnabled(false);
+ }
+}