Merge "Change title for advanced connected device page"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index facfeab..bf241d3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3104,13 +3104,6 @@
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.deletionhelper.AutomaticStorageManagerSettings" />
</activity>
-
- <activity android:name="Settings$LegacySupportActivity"
- android:label="@string/page_tab_title_support">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.dashboard.SupportFragment"/>
- </activity>
-
<!-- Information architecture host activities -->
<!-- Alias for battery settings in new IA. Remove and merge metadata into TargetActivity -->
diff --git a/res/layout/choose_lock_password_footer.xml b/res/layout/choose_lock_password_footer.xml
index 41306e9..0b7791c 100644
--- a/res/layout/choose_lock_password_footer.xml
+++ b/res/layout/choose_lock_password_footer.xml
@@ -21,12 +21,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
- <!-- left : cancel -->
- <Button android:id="@+id/cancel_button"
+ <!-- left : skip -->
+ <Button android:id="@+id/skip_button"
style="@style/SuwGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/lockpassword_cancel_label" />
+ android:text="@string/skip_label"
+ android:visibility="gone" />
<!-- left : clear -->
diff --git a/res/layout/choose_lock_pattern_common.xml b/res/layout/choose_lock_pattern_common.xml
index 949d130..6aee0f9 100644
--- a/res/layout/choose_lock_pattern_common.xml
+++ b/res/layout/choose_lock_pattern_common.xml
@@ -107,6 +107,14 @@
android:textSize="14sp"
android:visibility="gone"/>
+ <Button
+ android:id="@+id/screen_lock_options"
+ style="@style/SuwGlifButton.Tertiary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/setup_lock_settings_options_button_label"
+ android:visibility="gone" />
+
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
</com.android.setupwizardlib.GlifLayout>
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 16152a4..652bc63 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -14,43 +14,56 @@
limitations under the License.
-->
-<RadioGroup
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/private_dns_radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dip">
+ android:orientation="vertical"
+ android:padding="8dp">
- <RadioButton
- android:id="@+id/private_dns_mode_off"
- android:text="@string/private_dns_mode_off"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dip"/>
+ <RadioGroup
+ android:id="@+id/private_dns_radio_group"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
- <RadioButton
- android:id="@+id/private_dns_mode_opportunistic"
- android:text="@string/private_dns_mode_opportunistic"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dip"/>
+ <RadioButton
+ android:id="@+id/private_dns_mode_off"
+ android:text="@string/private_dns_mode_off"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
- <RadioButton
- android:id="@+id/private_dns_mode_provider"
- android:text="@string/private_dns_mode_provider"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dip"/>
+ <RadioButton
+ android:id="@+id/private_dns_mode_opportunistic"
+ android:text="@string/private_dns_mode_opportunistic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
- <EditText
- android:id="@+id/private_dns_mode_provider_hostname"
- android:hint="@string/private_dns_mode_provider_hostname_hint"
- style="@android:style/Widget.CompoundButton.RadioButton"
- android:imeOptions="actionDone"
- android:inputType="textFilter|textUri"
+ <RadioButton
+ android:id="@+id/private_dns_mode_provider"
+ android:text="@string/private_dns_mode_provider"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <EditText
+ android:id="@+id/private_dns_mode_provider_hostname"
+ android:hint="@string/private_dns_mode_provider_hostname_hint"
+ style="@android:style/Widget.CompoundButton.RadioButton"
+ android:imeOptions="actionDone"
+ android:inputType="textFilter|textUri"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="40dp"
+ android:layout_marginEnd="8dp"/>
+ </RadioGroup>
+
+ <TextView
+ android:id="@+id/private_dns_help_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="40dip"
- android:layout_marginEnd="8dip"/>
-
-</RadioGroup>
+ android:layout_marginTop="16dp"
+ android:paddingStart="16dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"/>
+</LinearLayout>
diff --git a/res/layout/support_account_spinner_item.xml b/res/layout/support_account_spinner_item.xml
deleted file mode 100644
index fe37a85..0000000
--- a/res/layout/support_account_spinner_item.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/text1"
- style="?android:attr/spinnerItemStyle"
- android:singleLine="true"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="marquee"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textAlignment="inherit"/>
diff --git a/res/layout/support_disclaimer_content.xml b/res/layout/support_disclaimer_content.xml
deleted file mode 100644
index 1e81f1a..0000000
--- a/res/layout/support_disclaimer_content.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="24dp">
-
- <com.android.settingslib.widget.LinkTextView
- android:id="@+id/support_disclaimer_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="24dp"/>
-
- <CheckBox
- android:id="@+id/support_disclaimer_do_not_show_again"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/support_disclaimer_do_not_show"
- android:textColor="?android:attr/textColorSecondary"/>
- </LinearLayout>
-</ScrollView>
diff --git a/res/layout/support_escalation_options.xml b/res/layout/support_escalation_options.xml
deleted file mode 100644
index ae208f1..0000000
--- a/res/layout/support_escalation_options.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SupportEscalationCard"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView
- android:id="@+id/tile_title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:textAppearance="@style/TextAppearance.SupportTitle"/>
- <TextView
- android:id="@+id/tile_summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:paddingTop="8dp"
- android:paddingBottom="30dp"
- android:textAppearance="?android:attr/textAppearanceSmall"/>
- <TextView
- android:id="@+id/account_request_prefix"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:text="@string/support_account_request_prefix"
- android:textAppearance="?android:attr/textAppearanceSmall"/>
- <Spinner
- android:id="@+id/account_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:layout_marginStart="16dp"
- android:gravity="center_horizontal"/>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="30dp"
- android:gravity="center_horizontal"
- android:orientation="horizontal">
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_marginEnd="8dp"
- android:gravity="center_horizontal"
- android:orientation="vertical">
- <Button
- android:id="@android:id/text1"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dp"/>
- <TextView
- android:id="@+id/summary1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="14dp"
- android:textAppearance="?android:attr/textAppearanceSmall"/>
- </LinearLayout>
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_marginEnd="8dp"
- android:gravity="center_horizontal"
- android:orientation="vertical">
- <Button
- android:id="@android:id/text2"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dp"/>
- <TextView
- android:id="@+id/summary2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="14dp"
- android:textAppearance="?android:attr/textAppearanceSmall"/>
- </LinearLayout>
- </LinearLayout>
-</LinearLayout>
diff --git a/res/layout/support_fragment.xml b/res/layout/support_fragment.xml
deleted file mode 100644
index 6864d32..0000000
--- a/res/layout/support_fragment.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipChildren="false"
- android:clipToPadding="false"
- android:focusable="false"
- android:paddingStart="@dimen/dashboard_padding_start"
- android:paddingEnd="@dimen/dashboard_padding_end">
- <android.support.v7.widget.RecyclerView
- android:id="@+id/support_items"
- android:layout_height="match_parent"
- android:layout_width="match_parent"/>
-</FrameLayout>
diff --git a/res/layout/support_offline_escalation_options.xml b/res/layout/support_offline_escalation_options.xml
deleted file mode 100644
index 09863d3..0000000
--- a/res/layout/support_offline_escalation_options.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SupportEscalationCard"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView
- android:id="@+id/tile_title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:textAppearance="@style/TextAppearance.SupportTitle"/>
- <TextView
- android:id="@+id/tile_summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:paddingTop="8dp"
- android:paddingBottom="10dp"
- android:textAppearance="@style/TextAppearance.Small"
- android:textColor="?android:attr/textColorSecondary"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/support_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="8dp"
- android:text="@string/support_country_list_title"
- android:textAppearance="@style/TextAppearance.Small"
- android:textColor="?android:attr/textColorSecondary"/>
- <Spinner
- android:id="@+id/spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:dropDownWidth="196dp"/>
- </LinearLayout>
- <Button
- android:id="@android:id/text1"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dp"
- android:layoutDirection="ltr"/>
- <Button
- android:id="@android:id/text2"
- style="@style/SupportSecondaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minHeight="48dp"
- android:visibility="gone"/>
-</LinearLayout>
diff --git a/res/layout/support_phone_dialog_content.xml b/res/layout/support_phone_dialog_content.xml
deleted file mode 100644
index ce6d2bb..0000000
--- a/res/layout/support_phone_dialog_content.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingStart="24dp"
- android:paddingEnd="24dp"
- android:paddingTop="12dp"
- android:paddingBottom="12dp">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="16dp"
- android:text="@string/support_international_phone_summary"/>
- <LinearLayout
- android:id="@+id/phone_number_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground"
- android:gravity="center_vertical"
- android:minHeight="48dp"
- android:orientation="horizontal">
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="32dp"
- android:src="@drawable/ic_call_24dp"/>
- <TextView
- android:id="@+id/phone_number"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="@style/TextAppearance.TileTitle"/>
- </LinearLayout>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/support_sign_in_button.xml b/res/layout/support_sign_in_button.xml
deleted file mode 100644
index 5bea068..0000000
--- a/res/layout/support_sign_in_button.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SupportEscalationCard"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView
- android:id="@+id/tile_title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:textAppearance="@style/TextAppearance.SupportTitle"/>
- <TextView
- android:id="@+id/tile_summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:paddingTop="8dp"
- android:paddingBottom="30dp"
- android:textAppearance="@style/TextAppearance.Small"
- android:textColor="?android:attr/textColorSecondary"/>
- <Button
- android:id="@android:id/text1"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dp"/>
- <Button
- android:id="@android:id/text2"
- style="@style/SupportSecondaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
- android:minHeight="48dp"/>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/support_tile.xml b/res/layout/support_tile.xml
deleted file mode 100644
index a42faf0..0000000
--- a/res/layout/support_tile.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground"
- android:gravity="center_vertical"
- android:minHeight="@dimen/support_tile_min_height"
- android:orientation="horizontal">
- <ImageView
- android:id="@android:id/icon"
- android:layout_width="@dimen/dashboard_tile_image_size"
- android:layout_height="@dimen/dashboard_tile_image_size"
- android:scaleType="centerInside"
- android:layout_marginStart="@dimen/dashboard_tile_image_margin"
- android:layout_marginEnd="@dimen/dashboard_tile_image_margin"/>
- <TextView
- android:id="@+id/tile_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxLines="2"
- android:textAppearance="@style/TextAppearance.TileTitle"
- android:ellipsize="end"
- android:fadingEdge="horizontal"/>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/support_tile_spacer.xml b/res/layout/support_tile_spacer.xml
deleted file mode 100644
index aa86e1e..0000000
--- a/res/layout/support_tile_spacer.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<View
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="@dimen/support_spacer_height"/>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index aa8a586..dbcfee1 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -309,6 +309,24 @@
<item>Never time out</item>
</string-array>
+ <!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
+ <string-array name="bluetooth_max_connected_audio_devices">
+ <item>1 (Default)</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ </string-array>
+
+ <!-- Bluetooth developer settings: Values for maximum number of connected audio devices -->
+ <string-array name="bluetooth_max_connected_audio_devices_values">
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ </string-array>
+
<!-- Match this with drawable.wifi_signal. --> <skip />
<!-- Wi-Fi settings. The signal strength a Wi-Fi network has. -->
<string-array name="wifi_signal">
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 6df9d6c..687d5bd 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -80,4 +80,7 @@
<!-- Whether accessibility shortcut preference should be shown or not. -->
<bool name="config_show_accessibility_shortcut_preference">true</bool>
+
+ <!-- Whether assist_and_voice_input should be shown or not. -->
+ <bool name="config_show_assist_and_voice_input">true</bool>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ef4d269..557318b 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -279,17 +279,8 @@
<dimen name="gestures_play_button_size">36dp</dimen>
<dimen name="gesture_animation_padding">0dp</dimen>
- <!-- Support tile minimum height -->
- <dimen name="support_tile_min_height">48dp</dimen>
- <!-- support spacer layout height -->
- <dimen name="support_spacer_height">8dp</dimen>
-
<dimen name="password_requirement_textsize">14sp</dimen>
- <!-- Padding for the escalation card in normal dimens -->
- <dimen name="support_escalation_card_padding_start">40dp</dimen>
- <dimen name="support_escalation_card_padding_end">40dp</dimen>
-
<!-- Padding between the donut and the storage summary. -->
<dimen name="storage_summary_padding_end">16dp</dimen>
<!-- Text size of the big number in the donut. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5c1fd98..74737ad 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1629,6 +1629,11 @@
<!-- Bluetooth settings. Dock Setting Dialog - Remember setting and don't ask user again -->
<string name="bluetooth_dock_settings_remember">Remember settings</string>
+ <!-- Bluetooth developer settings: Maximum number of connected audio devices -->
+ <string name="bluetooth_max_connected_audio_devices_string">Maximum connected Bluetooth audio devices</string>
+ <!-- Bluetooth developer settings: Maximum number of connected audio devices -->
+ <string name="bluetooth_max_connected_audio_devices_dialog_title">Select maximum number of connected Bluetooth audio devices</string>
+
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
<string name="wifi_display_settings_title">Cast</string>
<!-- Wifi Display settings. The title of a menu item to enable wireless display [CHAR LIMIT=40] -->
@@ -2269,7 +2274,8 @@
<string name="emergency_address_title">Emergency Address</string>
<!-- Summary of Update Emergency Address preference, explaining usage of emergency address [CHAR LIMIT=NONE] -->
<string name="emergency_address_summary">Used as your location when you make an emergency call over Wi\u2011Fi</string>
-
+ <!-- Message of private dns that provides a help link. [CHAR LIMIT=NONE] -->
+ <string name="private_dns_help_message"><annotation id="url">Learn more</annotation> about Private DNS features</string>
<!-- Sound and alerts settings -->
<skip/>
@@ -6341,6 +6347,7 @@
<string name="help_url_icc_lock" translatable="false"></string>
<string name="help_uri_process_stats_summary" translatable="false"></string>
<string name="help_uri_process_stats_apps" translatable="false"></string>
+ <string name="help_uri_private_dns" translatable="false"></string>
<!-- User account title [CHAR LIMIT=30] -->
<string name="user_account_title">Account for content</string>
@@ -8648,93 +8655,6 @@
<!-- [CHAR LIMIT=60] Name of dev option to enable extra quick settings tiles -->
<string name="quick_settings_developer_tiles">Quick settings developer tiles</string>
- <!-- Title text for connecting to customer support [CHAR LIMIT=80]-->
- <string name="support_escalation_title">We\'re here to help</string>
-
- <!-- Title text for connecting to 24/7 available customer support [CHAR LIMIT=80]-->
- <string name="support_escalation_24_7_title">We\'re here for you 24/7</string>
-
- <!-- Content description for connecting customer support. The "24 7" part indicates
- support is available 24 hours a day, 7 days a week. It's used by screenreaders so it
- cannot contain any symbol other that space. [CHAR LIMIT=80]-->
- <string name="support_escalation_24_7_content_description">We\'re here for you 24 7</string>
-
- <!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
- <string name="support_escalation_summary">Our support team is here to help address any issue</string>
-
- <!-- Summary text for connecting to 24/7 customer support [CHAR LIMIT=NONE]-->
- <string name="support_escalation_24_7_summary">Our support team is available all day, every day</string>
-
- <!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]-->
- <string name="support_escalation_closed_summary">Search help or come back during support hours (local time):<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
-
- <!-- Summary text to call customer support when there is no internet. [CHAR LIMIT=NONE]-->
- <string name="support_escalation_no_internet_summary">Phone support hours (local time)<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
-
- <!-- Summary text when customer support is unavailable in the region. [CHAR LIMIT=NONE]-->
- <string name="support_escalation_unavailable_summary">Search help or explore tips & tricks</string>
-
- <!-- Template for formatting support hours eg Mon - Fri, 8:00 AM - 19:30 PM. [CHAR LIMIT=NONE]-->
- <string name="support_hour_format" translatable="false">
- <xliff:g id="start_day">%1$s</xliff:g> - <xliff:g id="end_day">%2$s</xliff:g>, <xliff:g id="start_time">%3$s</xliff:g> - <xliff:g id="end_time">%4$s</xliff:g><br>
- </string>
-
- <!-- Button label for choosing country for phone support. [CHAR LIMIT=40]-->
- <string name="support_country_list_title">Support for:</string>
-
- <!-- Template for formatting country and language. eg Canada - French [CHAR LIMIT=NONE]-->
- <string name="support_country_format"><xliff:g id="country" example="Canada">%1$s</xliff:g> - <xliff:g id="language" example="French">%2$s</xliff:g></string>
-
- <!-- Template for formatting phone number and language. eg English (800-000-0000) [CHAR LIMIT=NONE]-->
- <string name ="support_phone_international_format">
- <xliff:g id="language" example="English">%1$s</xliff:g> (<xliff:g id="phone" example="800-000-0000">%2$s</xliff:g>)
- </string>
-
- <!-- Title text for a list of international support phone numbers. [CHAR LIMIT=60]-->
- <string name="support_international_phone_title">Traveling abroad?</string>
-
- <!-- Description text warning international phone charge may apply when dialing support numbers. [CHAR LIMIT=NONE]-->
- <string name="support_international_phone_summary">International charges may apply</string>
-
- <!-- Button label for contacting customer support by phone [CHAR LIMIT=20]-->
- <string name="support_escalation_by_phone">Phone</string>
-
- <!-- Button label for contacting customer support by chat [CHAR LIMIT=20]-->
- <string name="support_escalation_by_chat">Chat</string>
-
- <!-- Button label for visiting the tips & tricks site [CHAR LIMIT=60]-->
- <string name="support_tips_and_tricks_title">Explore tips & tricks</string>
-
- <!-- Button label for visiting help and/or send feedback [CHAR LIMIT=60]-->
- <string name="support_help_feedback_title">Search help & send feedback</string>
-
- <!-- Title text that indicates user needs to sign in to get customer support. [CHAR LIMIT=80]-->
- <string name="support_sign_in_required_title">Contact support</string>
-
- <!-- Summary text that indicates user needs to sign-in to get real time customer support. [CHAR LIMIT=NONE]-->
- <string name="support_sign_in_required_summary" translatable="false"></string>
-
- <!-- Button label for signing in an account [CHAR LIMIT=40]-->
- <string name="support_sign_in_button_text">Sign in</string>
-
- <!-- Button label that redirects user who needs help for signin to help screen [CHAR LIMIT=NONE]-->
- <string name="support_sign_in_required_help">Can\'t sign in?</string>
-
- <!-- Dialog title displayed before initiating real time support [CHAR LIMIT=80]-->
- <string name="support_disclaimer_title">Send system information</string>
-
- <!-- Checkbox text, when checked dialog will not show again [CHAR LIMIT=80] -->
- <string name="support_disclaimer_do_not_show">Do not show again</string>
-
- <!-- Prefix text for the account picker, e.g. "Requesting as user@gmail.com" [CHAR LIMIT=60] -->
- <string name="support_account_request_prefix">Requesting as</string>
-
- <!-- Spinner dropdown text, when selected will try to add account [CHAR LIMIT=60] -->
- <string name="support_account_picker_add_account">Add account</string>
-
- <!-- Title for the dialog containing system information shown [CHAR LIMIT=30] -->
- <string name="support_system_information_title">System information</string>
-
<!-- [CHAR LIMIT=60] Title of work profile setting page -->
<string name="managed_profile_settings_title">Work profile settings</string>
<!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search -->
@@ -8760,9 +8680,6 @@
<item quantity="other"><xliff:g id="number" example="7">%s</xliff:g> seconds</item>
</plurals>
- <!-- Estimated wait time range for real time supports -->
- <string name="support_estimated_wait_time">~<xliff:g id="ESTIMATE" example="2 minutes">%1$s</xliff:g> wait</string>
-
<!-- Used as title on the automatic storage manager settings. [CHAR LIMIT=60] -->
<string name="automatic_storage_manager_settings">Manage storage</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a07bade..579ee48 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -330,19 +330,6 @@
<item name="android:textColor">?android:attr/colorError</item>
</style>
- <style name="TextAppearance.SupportTitle"
- parent="@android:style/TextAppearance.Material.Subhead">
- <item name="android:textColor">?android:attr/colorAccent</item>
- <item name="android:textSize">24sp</item>
- </style>
-
- <style name="TextAppearance.SupportSummary" parent="TextAppearance.CategoryTitle"/>
-
- <style name="SupportSecondaryButton"
- parent="android:Widget.DeviceDefault.Button.Borderless.Colored">
- <item name="android:textSize">12sp</item>
- </style>
-
<style name="FingerprintLayoutTheme">
<item name="android:icon">@drawable/ic_fingerprint_header</item>
</style>
@@ -386,14 +373,6 @@
<item name="android:textAppearance">@android:style/TextAppearance.Material.Subhead</item>
</style>
- <style name="SupportEscalationCard">
- <item name="android:background">?android:attr/colorSecondary</item>
- <item name="android:gravity">center</item>
- <item name="android:minHeight">368dp</item>
- <item name="android:paddingStart">@dimen/support_escalation_card_padding_start</item>
- <item name="android:paddingEnd">@dimen/support_escalation_card_padding_end</item>
- </style>
-
<style name="FingerprintHeaderStyle" parent="android:style/TextAppearance.Material.Subhead">
<item name="android:paddingTop">16dp</item>
<item name="android:textColor">@color/primary_dark_material_light</item>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 18aeeef..aad5d23 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -286,6 +286,13 @@
android:entries="@array/bluetooth_a2dp_codec_ldac_playback_quality_titles"
android:entryValues="@array/bluetooth_a2dp_codec_ldac_playback_quality_values" />
+ <ListPreference
+ android:key="bluetooth_max_connected_audio_devices"
+ android:title="@string/bluetooth_max_connected_audio_devices_string"
+ android:dialogTitle="@string/bluetooth_max_connected_audio_devices_dialog_title"
+ android:entries="@array/bluetooth_max_connected_audio_devices"
+ android:entryValues="@array/bluetooth_max_connected_audio_devices_values" />
+
</PreferenceCategory>
<PreferenceCategory android:key="debug_input_category"
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 0aec18f..5d6c9e9 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -31,23 +31,7 @@
android:layout="@layout/preference_category_no_title"/>
<PreferenceCategory
- android:key="device_usage_list">
-
- <com.android.settings.fuelgauge.PowerGaugePreference
- android:key="last_full_charge"
- android:title="@string/battery_last_full_charge"
- android:selectable="false"/>
-
- <com.android.settings.fuelgauge.PowerGaugePreference
- android:key="screen_usage"
- android:title="@string/device_screen_usage"
- android:selectable="false"/>
-
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="power_management"
- android:title="@string/battery_power_management">
+ android:key="power_management">
<com.android.settings.widget.MasterSwitchPreference
android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
@@ -59,26 +43,20 @@
android:title="@string/battery_percentage"
android:summary="@string/battery_percentage_description"/>
- <!-- Cross-listed item, if you change this, also change it in display_settings.xml -->
- <SwitchPreference
- android:key="auto_brightness_battery"
- android:title="@string/auto_brightness_title"
- android:summary="@string/auto_brightness_summary"
- settings:keywords="@string/keywords_display_auto_brightness"/>
+ </PreferenceCategory>
- <!-- Cross-listed item, if you change this, also change it in display_settings.xml -->
- <com.android.settings.TimeoutListPreference
- android:key="screen_timeout_battery"
- android:title="@string/screen_timeout"
- android:summary="@string/screen_timeout_summary"
- android:entries="@array/screen_timeout_entries"
- android:entryValues="@array/screen_timeout_values"/>
+ <PreferenceCategory
+ android:key="device_usage_list">
- <!-- Cross-listed item, if you change this, also change it in display_settings.xml -->
- <Preference
- android:key="ambient_display_battery"
- android:title="@string/ambient_display_screen_title"
- android:fragment="com.android.settings.display.AmbientDisplaySettings" />
+ <com.android.settings.fuelgauge.PowerGaugePreference
+ android:key="last_full_charge"
+ android:title="@string/battery_last_full_charge"
+ android:selectable="false"/>
+
+ <com.android.settings.fuelgauge.PowerGaugePreference
+ android:key="screen_usage"
+ android:title="@string/device_screen_usage"
+ android:selectable="false"/>
</PreferenceCategory>
diff --git a/res/xml/security_settings_v2.xml b/res/xml/security_settings_v2.xml
index 86f542c..571e51f 100644
--- a/res/xml/security_settings_v2.xml
+++ b/res/xml/security_settings_v2.xml
@@ -47,6 +47,7 @@
<Preference
android:key="lockscreen_preferences"
android:title="@string/lockscreen_settings_title"
+ android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.security.LockscreenDashboardFragment" />
<Preference
@@ -77,6 +78,7 @@
<SwitchPreference
android:key="visiblepattern_profile"
+ android:summary="@string/summary_placeholder"
android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile" />
<Preference
@@ -95,8 +97,8 @@
<Preference
android:key="location"
android:title="@string/location_settings_title"
- android:fragment="com.android.settings.location.LocationSettings">
- </Preference>
+ android:summary="@string/summary_placeholder"
+ android:fragment="com.android.settings.location.LocationSettings" />
<SwitchPreference
android:key="show_password"
@@ -109,15 +111,17 @@
android:order="40"
android:key="security_settings_device_admin_category">
- <Preference android:key="manage_device_admin"
- android:title="@string/manage_device_admin"
- android:persistent="false"
- android:fragment="com.android.settings.DeviceAdminSettings" />
+ <Preference
+ android:key="manage_device_admin"
+ android:title="@string/manage_device_admin"
+ android:summary="@string/summary_placeholder"
+ android:fragment="com.android.settings.DeviceAdminSettings" />
- <Preference android:key="enterprise_privacy"
- android:title="@string/enterprise_privacy_settings"
- android:persistent="false"
- android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings" />
+ <Preference
+ android:key="enterprise_privacy"
+ android:title="@string/enterprise_privacy_settings"
+ android:summary="@string/summary_placeholder"
+ android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings" />
</PreferenceCategory>
@@ -144,7 +148,7 @@
android:order="70"
android:key="manage_trust_agents"
android:title="@string/manage_trust_agents"
- android:persistent="false"
+ android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.security.trustagent.TrustAgentSettings" />
<Preference
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index d21a061..505977d 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -162,7 +162,6 @@
}
}
public static class WebViewAppPickerActivity extends SettingsActivity { /* empty */ }
- public static class LegacySupportActivity extends SettingsActivity{ /* empty */ }
// Top level categories for new IA
public static class NetworkDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 6b0a5b8..cd64799 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1222,7 +1222,7 @@
public static FingerprintManager getFingerprintManagerOrNull(Context context) {
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
- return context.getSystemService(FingerprintManager.class);
+ return (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
} else {
return null;
}
diff --git a/src/com/android/settings/applications/RunningServices.java b/src/com/android/settings/applications/RunningServices.java
index 4e3d629..bf48492 100644
--- a/src/com/android/settings/applications/RunningServices.java
+++ b/src/com/android/settings/applications/RunningServices.java
@@ -42,8 +42,6 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
-
getActivity().setTitle(R.string.runningservices_settings_title);
}
@@ -64,9 +62,9 @@
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
mOptionsMenu = menu;
menu.add(0, SHOW_RUNNING_SERVICES, 1, R.string.show_running_services)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(0, SHOW_BACKGROUND_PROCESSES, 2, R.string.show_background_processes)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
updateOptionsMenu();
}
diff --git a/src/com/android/settings/applications/assist/DefaultAssistPreferenceController.java b/src/com/android/settings/applications/assist/DefaultAssistPreferenceController.java
index cba08c8..f78548b 100644
--- a/src/com/android/settings/applications/assist/DefaultAssistPreferenceController.java
+++ b/src/com/android/settings/applications/assist/DefaultAssistPreferenceController.java
@@ -26,6 +26,7 @@
import android.support.annotation.VisibleForTesting;
import com.android.internal.app.AssistUtils;
+import com.android.settings.R;
import com.android.settings.applications.defaultapps.DefaultAppInfo;
import com.android.settings.applications.defaultapps.DefaultAppPreferenceController;
@@ -73,7 +74,7 @@
@Override
public boolean isAvailable() {
- return true;
+ return mContext.getResources().getBoolean(R.bool.config_show_assist_and_voice_input);
}
@Override
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 4c861fb..664dda8 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -59,7 +59,6 @@
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
-import com.android.settings.dashboard.SupportFragment;
import com.android.settings.datausage.DataPlanUsageSummary;
import com.android.settings.datausage.DataUsageList;
import com.android.settings.datausage.DataUsageSummary;
@@ -242,7 +241,6 @@
NightDisplaySettings.class.getName(),
ManageDomainUrls.class.getName(),
AutomaticStorageManagerSettings.class.getName(),
- SupportFragment.class.getName(),
StorageDashboardFragment.class.getName(),
SystemDashboardFragment.class.getName(),
NetworkDashboardFragment.class.getName(),
@@ -270,6 +268,7 @@
Settings.PowerUsageSummaryLegacyActivity.class.getName(),
Settings.UserAndAccountDashboardActivity.class.getName(),
Settings.SecuritySettingsActivity.class.getName(),
+ Settings.SecuritySettingsActivityV2.class.getName(),
Settings.AccessibilitySettingsActivity.class.getName(),
Settings.SystemDashboardActivity.class.getName(),
SupportDashboardActivity.class.getName(),
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 9ef38b8..048f6ed 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -218,6 +218,10 @@
preference.setSummary(tile.summary);
} else if (tile.metaData != null
&& tile.metaData.containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
+ // Set a placeholder summary before starting to fetch real summary, this is necessary
+ // to avoid preference height change.
+ preference.setSummary(R.string.summary_placeholder);
+
ThreadUtils.postOnBackgroundThread(() -> {
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
final String uri = tile.metaData.getString(META_DATA_PREFERENCE_SUMMARY_URI);
diff --git a/src/com/android/settings/dashboard/SupportFragment.java b/src/com/android/settings/dashboard/SupportFragment.java
deleted file mode 100644
index fcc9f78..0000000
--- a/src/com/android/settings/dashboard/SupportFragment.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.dashboard;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.OnAccountsUpdateListener;
-import android.app.Activity;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.Network;
-import android.net.NetworkCapabilities;
-import android.net.NetworkInfo;
-import android.net.NetworkRequest;
-import android.os.Bundle;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.core.InstrumentedFragment;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.overlay.SupportFeatureProvider;
-import com.android.settingslib.utils.ThreadUtils;
-
-/**
- * Fragment for support tab in SettingsGoogle.
- */
-public final class SupportFragment extends InstrumentedFragment implements View.OnClickListener,
- OnAccountsUpdateListener {
-
- private final ConnectivityManager.NetworkCallback mNetworkCallback =
- new ConnectivityManager.NetworkCallback() {
-
- @Override
- public void onCapabilitiesChanged(Network network,
- NetworkCapabilities capabilities) {
- postConnectivityChanged();
- }
-
- @Override
- public void onAvailable(Network network) {
- postConnectivityChanged();
- }
-
- @Override
- public void onLost(Network network) {
- postConnectivityChanged();
- }
- };
-
- private Activity mActivity;
- private View mContent;
- private RecyclerView mRecyclerView;
- private SupportItemAdapter mSupportItemAdapter;
- private AccountManager mAccountManager;
- private SupportFeatureProvider mSupportFeatureProvider;
- private ConnectivityManager mConnectivityManager;
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.SUPPORT_FRAGMENT;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
- mActivity = getActivity();
- mAccountManager = AccountManager.get(mActivity);
- mSupportFeatureProvider =
- FeatureFactory.getFactory(mActivity).getSupportFeatureProvider(mActivity);
- mSupportItemAdapter = new SupportItemAdapter(mActivity, savedInstanceState,
- mSupportFeatureProvider, mMetricsFeatureProvider, this /* itemClickListener */);
- mConnectivityManager =
- (ConnectivityManager) mActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- mContent = inflater.inflate(R.layout.support_fragment, container, false);
- mRecyclerView = (RecyclerView) mContent.findViewById(R.id.support_items);
- mRecyclerView.setLayoutManager(new LinearLayoutManager(
- getActivity(), LinearLayoutManager.VERTICAL, false /* reverseLayout */));
- mRecyclerView.setAdapter(mSupportItemAdapter);
- return mContent;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- // Monitor account change.
- mAccountManager.addOnAccountsUpdatedListener(
- this /* listener */, null /* handler */, true /* updateImmediately */);
- // Monitor connectivity
- mConnectivityManager.registerNetworkCallback(
- new NetworkRequest.Builder()
- .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
- .build(),
- mNetworkCallback);
- mSupportItemAdapter.setHasInternet(hasInternet());
- mSupportItemAdapter.refreshData();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- // Stop monitor account change.
- mAccountManager.removeOnAccountsUpdatedListener(this /* listener */);
- // Stop monitor connectivity.
- mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mSupportItemAdapter.onSaveInstanceState(outState);
- }
-
- @Override
- public void onAccountsUpdated(Account[] accounts) {
- // Account changed, update support items.
- mSupportItemAdapter.setAccounts(
- mSupportFeatureProvider.getSupportEligibleAccounts(mActivity));
- }
-
- @Override
- public void onClick(View v) {
- final SupportItemAdapter.ViewHolder vh =
- (SupportItemAdapter.ViewHolder) mRecyclerView.getChildViewHolder(v);
- mSupportItemAdapter.onItemClicked(vh.getAdapterPosition());
- }
-
- private void postConnectivityChanged() {
- ThreadUtils.postOnMainThread(() -> {
- if (mSupportItemAdapter != null) {
- mSupportItemAdapter.setHasInternet(hasInternet());
- }
- });
- }
-
- private boolean hasInternet() {
- final NetworkInfo activeNetwork = mConnectivityManager.getActiveNetworkInfo();
- return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
- }
-}
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
deleted file mode 100644
index 54c5ae6..0000000
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ /dev/null
@@ -1,823 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.dashboard;
-
-import android.accounts.Account;
-import android.annotation.DrawableRes;
-import android.annotation.LayoutRes;
-import android.annotation.StringRes;
-import android.app.Activity;
-import android.app.ActivityManager;
-import android.app.DialogFragment;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.util.ArrayUtils;
-import com.android.settings.R;
-import com.android.settings.core.instrumentation.MetricsFeatureProvider;
-import com.android.settings.overlay.SupportFeatureProvider;
-import com.android.settings.support.SupportDisclaimerDialogFragment;
-import com.android.settings.support.SupportPhone;
-import com.android.settings.support.SupportPhoneDialogFragment;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static com.android.settings.overlay.SupportFeatureProvider.SupportType.CHAT;
-import static com.android.settings.overlay.SupportFeatureProvider.SupportType.PHONE;
-
-/**
- * Item adapter for support tiles.
- */
-public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAdapter.ViewHolder> {
-
- private static final String STATE_SELECTED_COUNTRY = "STATE_SELECTED_COUNTRY";
- private static final String ACCOUNT_SELECTED_INDEX = "ACCOUNT_SELECTED_INDEX";
- private static final int TYPE_ESCALATION_OPTIONS = R.layout.support_escalation_options;
- private static final int TYPE_ESCALATION_OPTIONS_OFFLINE =
- R.layout.support_offline_escalation_options;
- private static final int TYPE_SUPPORT_TILE = R.layout.support_tile;
- private static final int TYPE_SUPPORT_TILE_SPACER = R.layout.support_tile_spacer;
- private static final int TYPE_SIGN_IN_BUTTON = R.layout.support_sign_in_button;
-
- private final Activity mActivity;
- private final EscalationClickListener mEscalationClickListener;
- private final OfflineSpinnerItemSelectListener mOfflineSpinnerItemSelectListener;
- private final OnlineSpinnerItemSelectListener mOnlineSpinnerItemSelectListener;
- private final SupportFeatureProvider mSupportFeatureProvider;
- private final MetricsFeatureProvider mMetricsFeatureProvider;
- private final View.OnClickListener mItemClickListener;
- private final List<SupportData> mSupportData;
-
- private String mSelectedCountry;
- private boolean mHasInternet;
- private Account[] mAccounts;
- private int mSelectedAccountIndex;
-
- public SupportItemAdapter(Activity activity, Bundle savedInstanceState,
- SupportFeatureProvider supportFeatureProvider,
- MetricsFeatureProvider metricsFeatureProvider,
- View.OnClickListener itemClickListener) {
- mActivity = activity;
- mSupportFeatureProvider = supportFeatureProvider;
- mMetricsFeatureProvider = metricsFeatureProvider;
- mItemClickListener = itemClickListener;
- mEscalationClickListener = new EscalationClickListener();
- mOfflineSpinnerItemSelectListener = new OfflineSpinnerItemSelectListener();
- mOnlineSpinnerItemSelectListener = new OnlineSpinnerItemSelectListener();
- mSupportData = new ArrayList<>();
- // Optimistically assume we have Internet access. It will be updated later to correct value.
- mHasInternet = true;
- if (savedInstanceState != null) {
- mSelectedCountry = savedInstanceState.getString(STATE_SELECTED_COUNTRY);
- mSelectedAccountIndex = savedInstanceState.getInt(ACCOUNT_SELECTED_INDEX);
- } else {
- mSelectedCountry = mSupportFeatureProvider.getCurrentCountryCodeIfHasConfig(PHONE);
- mSelectedAccountIndex = 0;
- }
-
- mAccounts = mSupportFeatureProvider.getSupportEligibleAccounts(mActivity);
- refreshData();
- }
-
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(
- viewType, parent, false));
- }
-
- @Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- final SupportData data = mSupportData.get(position);
- switch (holder.getItemViewType()) {
- case TYPE_SIGN_IN_BUTTON:
- bindSignInPromoTile(holder, (EscalationData) data);
- break;
- case TYPE_ESCALATION_OPTIONS:
- bindEscalationOptions(holder, (EscalationData) data);
- break;
- case TYPE_ESCALATION_OPTIONS_OFFLINE:
- bindOfflineEscalationOptions(holder, (OfflineEscalationData) data);
- break;
- case TYPE_SUPPORT_TILE_SPACER:
- break;
- default:
- bindSupportTile(holder, data);
- break;
- }
- }
-
- @Override
- public int getItemViewType(int position) {
- return mSupportData.get(position).type;
- }
-
- @Override
- public int getItemCount() {
- return mSupportData.size();
- }
-
- /**
- * Called when a support item is clicked.
- */
- public void onItemClicked(int position) {
- if (position >= 0 && position < mSupportData.size()) {
- final SupportData data = mSupportData.get(position);
- if (data.intent != null &&
- mActivity.getPackageManager().resolveActivity(data.intent, 0) != null) {
- if (data.metricsEvent >= 0) {
- mMetricsFeatureProvider.action(mActivity, data.metricsEvent);
- }
- mActivity.startActivityForResult(data.intent, 0);
- }
- }
- }
-
- public void setHasInternet(boolean hasInternet) {
- if (mHasInternet != hasInternet) {
- mHasInternet = hasInternet;
- refreshEscalationCards();
- }
- }
-
- public void setAccounts(Account accounts[]) {
- if (!Arrays.equals(mAccounts, accounts)) {
- if (mAccounts.length == 0) {
- mSelectedAccountIndex = 0;
- } else {
- final int index = ArrayUtils.indexOf(accounts, mAccounts[mSelectedAccountIndex]);
- mSelectedAccountIndex = index != -1 ? index : 0;
- }
-
- mAccounts = accounts;
- mSupportFeatureProvider.refreshOperationRules();
- refreshEscalationCards();
- }
- }
-
- public void onSaveInstanceState(Bundle outState) {
- outState.putString(STATE_SELECTED_COUNTRY, mSelectedCountry);
- outState.putInt(ACCOUNT_SELECTED_INDEX, mSelectedAccountIndex);
- }
-
- /**
- * Create data for the adapter. If there is already data in the adapter, they will be
- * destroyed and recreated.
- */
- void refreshData() {
- mSupportData.clear();
- addEscalationCards();
- addMoreHelpItems();
- notifyDataSetChanged();
- }
-
- /**
- * Adds 1 escalation card. Based on current phone state, the escalation card can display
- * different content.
- */
- private void addEscalationCards() {
- if (mAccounts.length == 0) {
- addSignInPromo();
- } else if (mHasInternet) {
- addOnlineEscalationCards();
- } else {
- addOfflineEscalationCards();
- }
- }
-
- /**
- * Finds and refreshes escalation card data.
- */
- private void refreshEscalationCards() {
- if (getItemCount() > 0) {
- final int itemType = getItemViewType(0 /* position */);
- if (itemType == TYPE_SIGN_IN_BUTTON
- || itemType == TYPE_ESCALATION_OPTIONS
- || itemType == TYPE_ESCALATION_OPTIONS_OFFLINE) {
- mSupportData.remove(0 /* position */);
- addEscalationCards();
- notifyItemChanged(0 /* position */);
- }
- }
- }
-
- private void addOnlineEscalationCards() {
- final boolean hasPhoneOperation =
- mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE);
- final boolean hasChatOperation =
- mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT);
- final EscalationData.Builder builder = new EscalationData.Builder(mActivity);
- if (!hasPhoneOperation && !hasChatOperation) {
- // No support at all.
- builder.setTileTitle(R.string.support_escalation_title)
- .setTileSummary(R.string.support_escalation_unavailable_summary);
- } else if (mSupportFeatureProvider.isAlwaysOperating(PHONE, null /* countryCode */)
- || mSupportFeatureProvider.isAlwaysOperating(CHAT, null /* countryCode */)) {
- // Support is available.
- builder.setTileTitle(R.string.support_escalation_24_7_title)
- .setTileTitleDescription(R.string.support_escalation_24_7_content_description)
- .setTileSummary(mActivity.getString(R.string.support_escalation_24_7_summary));
- } else if (mSupportFeatureProvider.isOperatingNow(PHONE)
- || mSupportFeatureProvider.isOperatingNow(CHAT)) {
- // Support is available now.
- builder.setTileTitle(R.string.support_escalation_title)
- .setTileSummary(R.string.support_escalation_summary);
- } else {
- // Support is now temporarily unavailable.
- builder.setTileTitle(R.string.support_escalation_title)
- .setTileSummary(
- mSupportFeatureProvider.getOperationHours(mActivity, PHONE, null,
- true /* hasInternet */));
- }
- if (hasPhoneOperation) {
- builder.setText1(R.string.support_escalation_by_phone)
- .setSummary1(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, PHONE))
- .setEnabled1(mSupportFeatureProvider.isOperatingNow(PHONE));
- }
- if (hasChatOperation) {
- builder.setText2(R.string.support_escalation_by_chat)
- .setSummary2(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, CHAT))
- .setEnabled2(mSupportFeatureProvider.isOperatingNow(CHAT));
- }
- mSupportData.add(0 /* index */, builder.build());
- }
-
- private void addOfflineEscalationCards() {
- final CharSequence operatingHours;
- final boolean isPhoneSupportAlwaysOperating =
- mSupportFeatureProvider.isAlwaysOperating(PHONE, mSelectedCountry);
- if (isPhoneSupportAlwaysOperating) {
- operatingHours = mActivity.getString(R.string.support_escalation_24_7_summary);
- } else {
- operatingHours = mSupportFeatureProvider.getOperationHours(mActivity,
- PHONE, mSelectedCountry, false /* hasInternet */);
- }
- mSupportData.add(0 /* index */, new OfflineEscalationData.Builder(mActivity)
- .setCountries(mSupportFeatureProvider.getPhoneSupportCountries())
- .setTollFreePhone(mSupportFeatureProvider.getSupportPhones(
- mSelectedCountry, true /* isTollFree */))
- .setTolledPhone(mSupportFeatureProvider.getSupportPhones(
- mSelectedCountry, false /* isTollFree */))
- .setTileTitle(isPhoneSupportAlwaysOperating
- ? R.string.support_escalation_24_7_title
- : R.string.support_escalation_title)
- .setTileTitleDescription(isPhoneSupportAlwaysOperating
- ? R.string.support_escalation_24_7_content_description
- : R.string.support_escalation_title)
- .setTileSummary(operatingHours)
- .build());
- }
-
- private void addSignInPromo() {
- mSupportData.add(0 /* index */, new EscalationData.Builder(mActivity, TYPE_SIGN_IN_BUTTON)
- .setText1(R.string.support_sign_in_button_text)
- .setText2(R.string.support_sign_in_required_help)
- .setTileTitle(R.string.support_sign_in_required_title)
- .setTileSummary(R.string.support_sign_in_required_summary)
- .build());
- }
-
- private void addMoreHelpItems() {
- mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE_SPACER).build());
- PackageManager packageManager = mActivity.getPackageManager();
- Intent intent = mSupportFeatureProvider.getHelpIntent(mActivity);
- if (packageManager.resolveActivity(intent, 0) != null) {
- mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE)
- .setIcon(R.drawable.ic_help_24dp)
- .setTileTitle(R.string.support_help_feedback_title)
- .setIntent(intent)
- .setMetricsEvent(MetricsProto.MetricsEvent.ACTION_SUPPORT_HELP_AND_FEEDBACK)
- .build());
- }
- intent = mSupportFeatureProvider.getTipsAndTricksIntent(mActivity);
- if (packageManager.resolveActivity(intent, 0) != null) {
- mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE)
- .setIcon(R.drawable.ic_lightbulb_outline_24)
- .setTileTitle(R.string.support_tips_and_tricks_title)
- .setIntent(intent)
- .setMetricsEvent(MetricsProto.MetricsEvent.ACTION_SUPPORT_TIPS_AND_TRICKS)
- .build());
- }
- }
-
- private void bindEscalationOptions(ViewHolder holder, EscalationData data) {
- holder.tileTitleView.setText(data.tileTitle);
- holder.tileTitleView.setContentDescription(data.tileTitleDescription);
- holder.tileSummaryView.setText(data.tileSummary);
- if (data.text1 == 0) {
- holder.text1View.setVisibility(View.GONE);
- } else {
- holder.text1View.setText(data.text1);
- holder.text1View.setOnClickListener(mEscalationClickListener);
- holder.text1View.setEnabled(data.enabled1 && mHasInternet);
- holder.text1View.setVisibility(View.VISIBLE);
- }
- if (TextUtils.isEmpty(data.text2)) {
- holder.text2View.setVisibility(View.GONE);
- } else {
- holder.text2View.setText(data.text2);
- holder.text2View.setOnClickListener(mEscalationClickListener);
- holder.text2View.setEnabled(data.enabled2 && mHasInternet);
- holder.text2View.setVisibility(View.VISIBLE);
- }
- if (holder.summary1View != null) {
- holder.summary1View.setText(data.summary1);
- holder.summary1View.setVisibility(mHasInternet && !TextUtils.isEmpty(data.summary1)
- ? View.VISIBLE : View.GONE);
- }
- if (holder.summary2View != null) {
- holder.summary2View.setText(data.summary2);
- holder.summary2View.setVisibility(mHasInternet && !TextUtils.isEmpty(data.summary2)
- ? View.VISIBLE : View.GONE);
- }
-
- bindAccountPicker(holder);
- }
-
- @VisibleForTesting
- public void bindAccountPicker(ViewHolder holder) {
- final Spinner spinner = (Spinner) holder.itemView.findViewById(R.id.account_spinner);
-
- final ArrayAdapter<String> adapter = new ArrayAdapter(
- mActivity, R.layout.support_account_spinner_item,
- extractAccountNames(mAccounts));
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spinner.setAdapter(adapter);
- spinner.setOnItemSelectedListener(mOnlineSpinnerItemSelectListener);
- spinner.setSelection(mSelectedAccountIndex);
- }
-
- private void bindOfflineEscalationOptions(ViewHolder holder, OfflineEscalationData data) {
- // Bind Title
- holder.tileTitleView.setText(data.tileTitle);
- holder.tileTitleView.setContentDescription(data.tileTitleDescription);
- holder.tileSummaryView.setText(data.tileSummary);
- // Bind spinner
- final Spinner spinner = (Spinner) holder.itemView.findViewById(R.id.spinner);
- final ArrayAdapter<String> adapter = new ArrayAdapter(
- mActivity, android.R.layout.simple_spinner_dropdown_item, data.countries);
- spinner.setAdapter(adapter);
- final List<String> countryCodes = mSupportFeatureProvider.getPhoneSupportCountryCodes();
- for (int i = 0; i < countryCodes.size(); i++) {
- if (TextUtils.equals(countryCodes.get(i), mSelectedCountry)) {
- spinner.setSelection(i);
- break;
- }
- }
- spinner.setOnItemSelectedListener(mOfflineSpinnerItemSelectListener);
- // Bind buttons
- if (data.tollFreePhone != null) {
- holder.text1View.setText(data.tollFreePhone.number);
- holder.text1View.setVisibility(View.VISIBLE);
- holder.text1View.setOnClickListener(mEscalationClickListener);
- } else {
- holder.text1View.setVisibility(View.GONE);
- }
- if (data.tolledPhone != null) {
- holder.text2View.setText(
- mActivity.getString(R.string.support_international_phone_title));
- holder.text2View.setVisibility(View.VISIBLE);
- holder.text2View.setOnClickListener(mEscalationClickListener);
- } else {
- holder.text2View.setVisibility(View.GONE);
- }
-
- if (ActivityManager.isUserAMonkey()) {
- holder.text1View.setVisibility(View.GONE);
- holder.text2View.setVisibility(View.GONE);
- spinner.setVisibility(View.GONE);
- holder.itemView.findViewById(R.id.support_text).setVisibility(View.GONE);
- }
- }
-
- private void bindSignInPromoTile(ViewHolder holder, EscalationData data) {
- holder.tileTitleView.setText(data.tileTitle);
- holder.tileTitleView.setContentDescription(data.tileTitleDescription);
- holder.tileSummaryView.setText(data.tileSummary);
- holder.text1View.setText(data.text1);
- holder.text2View.setText(data.text2);
- holder.text1View.setOnClickListener(mEscalationClickListener);
- holder.text2View.setOnClickListener(mEscalationClickListener);
- }
-
- private void bindSupportTile(ViewHolder holder, SupportData data) {
- if (holder.iconView != null) {
- holder.iconView.setImageResource(data.icon);
- }
- if (holder.tileTitleView != null) {
- holder.tileTitleView.setText(data.tileTitle);
- holder.tileTitleView.setContentDescription(data.tileTitleDescription);
- }
- if (holder.tileSummaryView != null) {
- holder.tileSummaryView.setText(data.tileSummary);
- }
- holder.itemView.setOnClickListener(mItemClickListener);
- }
-
- /**
- * Show a disclaimer dialog and start support action after disclaimer has been acknowledged.
- */
- private void tryStartDisclaimerAndSupport(final @SupportFeatureProvider.SupportType int type) {
- if (mSupportFeatureProvider.shouldShowDisclaimerDialog(mActivity)) {
- DialogFragment fragment = SupportDisclaimerDialogFragment.newInstance(
- mAccounts[mSelectedAccountIndex], type);
- fragment.show(mActivity.getFragmentManager(), SupportDisclaimerDialogFragment.TAG);
- return;
- }
- mSupportFeatureProvider.startSupport(mActivity, mAccounts[mSelectedAccountIndex], type);
- }
-
- private String[] extractAccountNames(Account[] accounts) {
- String[] accountNames = new String[accounts.length+1];
- for (int i = 0; i < accounts.length; i++) {
- accountNames[i] = accounts[i].name;
- }
- accountNames[accounts.length] = mActivity.getString(
- R.string.support_account_picker_add_account);
-
- return accountNames;
- }
-
- /**
- * Click handler for starting escalation options.
- */
- private final class EscalationClickListener implements View.OnClickListener {
- @Override
- public void onClick(final View v) {
- if (mAccounts.length == 0) {
- switch (v.getId()) {
- case android.R.id.text1:
- mMetricsFeatureProvider.action(mActivity,
- MetricsProto.MetricsEvent.ACTION_SUPPORT_SIGN_IN);
- mActivity.startActivityForResult(
- mSupportFeatureProvider.getAccountLoginIntent(),
- 0 /* requestCode */);
- break;
- case android.R.id.text2:
- mActivity.startActivityForResult(
- mSupportFeatureProvider.getSignInHelpIntent(mActivity),
- 0 /* requestCode */);
- break;
- }
- } else if (mHasInternet) {
- switch (v.getId()) {
- case android.R.id.text1:
- mMetricsFeatureProvider.action(mActivity,
- MetricsProto.MetricsEvent.ACTION_SUPPORT_PHONE);
- tryStartDisclaimerAndSupport(PHONE);
- break;
- case android.R.id.text2:
- mMetricsFeatureProvider.action(mActivity,
- MetricsProto.MetricsEvent.ACTION_SUPPORT_CHAT);
- tryStartDisclaimerAndSupport(CHAT);
- break;
- }
- } else {
- switch (v.getId()) {
- case android.R.id.text1: {
- final SupportPhone phone = mSupportFeatureProvider
- .getSupportPhones(mSelectedCountry, true /* isTollFree */);
- if (phone != null) {
- final Intent intent = phone.getDialIntent();
- final boolean canDial = !mActivity.getPackageManager()
- .queryIntentActivities(intent, 0)
- .isEmpty();
- if (canDial) {
- mMetricsFeatureProvider.action(mActivity,
- MetricsProto.MetricsEvent.ACTION_SUPPORT_DAIL_TOLLFREE);
- mActivity.startActivity(intent);
- }
- }
- break;
- }
- case android.R.id.text2: {
- final SupportPhone phone = mSupportFeatureProvider
- .getSupportPhones(mSelectedCountry, false /* isTollFree */);
- final SupportPhoneDialogFragment fragment =
- SupportPhoneDialogFragment.newInstance(phone);
- mMetricsFeatureProvider.action(mActivity,
- MetricsProto.MetricsEvent.ACTION_SUPPORT_VIEW_TRAVEL_ABROAD_DIALOG);
- fragment.show(mActivity.getFragmentManager(),
- SupportPhoneDialogFragment.TAG);
- break;
- }
- }
- }
- }
- }
-
- private final class OfflineSpinnerItemSelectListener
- implements AdapterView.OnItemSelectedListener {
-
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- final List<String> countryCodes = mSupportFeatureProvider.getPhoneSupportCountryCodes();
- final String selectedCountry = countryCodes.get(position);
- if (!TextUtils.equals(selectedCountry, mSelectedCountry)) {
- mSelectedCountry = selectedCountry;
- refreshEscalationCards();
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- // Do nothing.
- }
- }
-
- private final class OnlineSpinnerItemSelectListener
- implements AdapterView.OnItemSelectedListener {
-
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- if (position == mAccounts.length) {
- mActivity.startActivity(mSupportFeatureProvider.getAccountLoginIntent());
- // Make sure "Add account" is not shown as selected item
- parent.setSelection(mSelectedAccountIndex);
- } else if (position != mSelectedAccountIndex) {
- mSelectedAccountIndex = position;
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- // Do nothing.
- }
- }
-
- /**
- * {@link RecyclerView.ViewHolder} for support items.
- */
- static final class ViewHolder extends RecyclerView.ViewHolder {
-
- final ImageView iconView;
- final TextView tileTitleView;
- final TextView tileSummaryView;
- final TextView text1View;
- final TextView text2View;
- final TextView summary1View;
- final TextView summary2View;
-
- ViewHolder(View itemView) {
- super(itemView);
- iconView = (ImageView) itemView.findViewById(android.R.id.icon);
- tileTitleView = (TextView) itemView.findViewById(R.id.tile_title);
- tileSummaryView = (TextView) itemView.findViewById(R.id.tile_summary);
- text1View = (TextView) itemView.findViewById(android.R.id.text1);
- text2View = (TextView) itemView.findViewById(android.R.id.text2);
- summary1View = (TextView) itemView.findViewById(R.id.summary1);
- summary2View = (TextView) itemView.findViewById(R.id.summary2);
- }
- }
-
- /**
- * Data for a single support item.
- */
- @VisibleForTesting
- static class SupportData {
-
- final Intent intent;
- final int metricsEvent;
- @LayoutRes
- final int type;
- @DrawableRes
- final int icon;
- @StringRes
- final int tileTitle;
- final CharSequence tileTitleDescription;
- final CharSequence tileSummary;
-
-
- private SupportData(Builder builder) {
- this.type = builder.mType;
- this.icon = builder.mIcon;
- this.tileTitle = builder.mTileTitle;
- this.tileTitleDescription = builder.mTileTitleDescription;
- this.tileSummary = builder.mTileSummary;
- this.intent = builder.mIntent;
- this.metricsEvent = builder.mMetricsEvent;
- }
-
- static class Builder {
-
- protected final Context mContext;
- @LayoutRes
- private final int mType;
- @DrawableRes
- private int mIcon;
- @StringRes
- private int mTileTitle;
- private CharSequence mTileTitleDescription;
- private CharSequence mTileSummary;
- private Intent mIntent;
- private int mMetricsEvent = -1;
-
- Builder(Context context, @LayoutRes int type) {
- mContext = context;
- mType = type;
- }
-
- Builder setIcon(@DrawableRes int icon) {
- mIcon = icon;
- return this;
- }
-
- Builder setTileTitle(@StringRes int title) {
- mTileTitle = title;
- return this;
- }
-
- Builder setTileTitleDescription(@StringRes int titleDescription) {
- mTileTitleDescription = mContext.getString(titleDescription);
- return this;
- }
-
- Builder setTileSummary(@StringRes int summary) {
- mTileSummary = mContext.getString(summary);
- return this;
- }
-
- Builder setTileSummary(CharSequence summary) {
- mTileSummary = summary;
- return this;
- }
-
- Builder setMetricsEvent(int metricsEvent) {
- mMetricsEvent = metricsEvent;
- return this;
- }
-
- Builder setIntent(Intent intent) {
- mIntent = intent;
- return this;
- }
-
- SupportData build() {
- return new SupportData(this);
- }
- }
- }
-
- /**
- * Data model for escalation cards.
- */
- @VisibleForTesting
- static class EscalationData extends SupportData {
-
- @StringRes
- final int text1;
- final CharSequence text2;
- final boolean enabled1;
- final boolean enabled2;
- final CharSequence summary1;
- final CharSequence summary2;
-
- private EscalationData(Builder builder) {
- super(builder);
- this.text1 = builder.mText1;
- this.text2 = builder.mText2;
- this.summary1 = builder.mSummary1;
- this.summary2 = builder.mSummary2;
- this.enabled1 = builder.mEnabled1;
- this.enabled2 = builder.mEnabled2;
- }
-
- static class Builder extends SupportData.Builder {
-
- @StringRes
- private int mText1;
- private CharSequence mText2;
- private CharSequence mSummary1;
- private CharSequence mSummary2;
- private boolean mEnabled1;
- private boolean mEnabled2;
-
- protected Builder(Context context, @LayoutRes int type) {
- super(context, type);
- }
-
- Builder(Context context) {
- this(context, TYPE_ESCALATION_OPTIONS);
- }
-
- Builder setEnabled1(boolean enabled) {
- mEnabled1 = enabled;
- return this;
- }
-
- Builder setText1(@StringRes int text1) {
- mText1 = text1;
- return this;
- }
-
- Builder setText2(@StringRes int text2) {
- mText2 = mContext.getString(text2);
- return this;
- }
-
- Builder setText2(CharSequence text2) {
- mText2 = text2;
- return this;
- }
-
- Builder setSummary1(String summary1) {
- mSummary1 = summary1;
- return this;
- }
-
- Builder setEnabled2(boolean enabled) {
- mEnabled2 = enabled;
- return this;
- }
-
- Builder setSummary2(String summary2) {
- mSummary2 = summary2;
- return this;
- }
-
- EscalationData build() {
- return new EscalationData(this);
- }
- }
- }
-
- /**
- * Support data for offline mode.
- */
- private static final class OfflineEscalationData extends EscalationData {
-
- final List<String> countries;
- final SupportPhone tollFreePhone;
- final SupportPhone tolledPhone;
-
- private OfflineEscalationData(Builder builder) {
- super(builder);
- countries = builder.mCountries;
- tollFreePhone = builder.mTollFreePhone;
- tolledPhone = builder.mTolledPhone;
- }
-
- static final class Builder extends EscalationData.Builder {
-
- private List<String> mCountries;
- private SupportPhone mTollFreePhone;
- private SupportPhone mTolledPhone;
-
- Builder(Context context) {
- super(context, TYPE_ESCALATION_OPTIONS_OFFLINE);
- }
-
- Builder setCountries(List<String> countries) {
- mCountries = countries;
- return this;
- }
-
- Builder setTollFreePhone(SupportPhone phone) {
- mTollFreePhone = phone;
- return this;
- }
-
- Builder setTolledPhone(SupportPhone phone) {
- mTolledPhone = phone;
- return this;
- }
-
- OfflineEscalationData build() {
- return new OfflineEscalationData(this);
- }
- }
- }
-
- @VisibleForTesting
- List<SupportData> getSupportData() {
- return mSupportData;
- }
-}
diff --git a/src/com/android/settings/datausage/BillingCycleSettings.java b/src/com/android/settings/datausage/BillingCycleSettings.java
index fb8119c..34d18e9 100644
--- a/src/com/android/settings/datausage/BillingCycleSettings.java
+++ b/src/com/android/settings/datausage/BillingCycleSettings.java
@@ -24,8 +24,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
-import android.icu.text.MeasureFormat;
-import android.icu.util.MeasureUnit;
import android.net.NetworkPolicy;
import android.net.NetworkTemplate;
import android.os.Bundle;
@@ -36,7 +34,6 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.NumberPicker;
import android.widget.Spinner;
@@ -256,17 +253,6 @@
: editor.getPolicyWarningBytes(template);
final long limitDisabled = isLimit ? LIMIT_DISABLED : WARNING_DISABLED;
- final MeasureFormat formatter = MeasureFormat.getInstance(
- getContext().getResources().getConfiguration().locale,
- MeasureFormat.FormatWidth.SHORT);
- final String[] unitNames = new String[] {
- formatter.getUnitDisplayName(MeasureUnit.MEGABYTE),
- formatter.getUnitDisplayName(MeasureUnit.GIGABYTE)
- };
- final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
- getContext(), R.layout.data_usage_spinner_item, unitNames);
- type.setAdapter(adapter);
-
if (bytes > 1.5f * GB_IN_BYTES) {
final String bytesText = formatText(bytes / (float) GB_IN_BYTES);
bytesPicker.setText(bytesText);
diff --git a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
new file mode 100644
index 0000000..5512685
--- /dev/null
+++ b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
+ DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
+ PreferenceControllerMixin {
+
+ private static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY =
+ "bluetooth_max_connected_audio_devices";
+
+ @VisibleForTesting
+ static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
+ "persist.bluetooth.maxconnectedaudiodevices";
+
+ private final String[] mListValues;
+ private final String[] mListSummaries;
+ private ListPreference mPreference;
+
+ public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
+ super(context);
+
+ mListValues = context.getResources()
+ .getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
+ mListSummaries = context.getResources()
+ .getStringArray(R.array.bluetooth_max_connected_audio_devices);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+
+ mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValue.toString());
+ updateState(preference);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final String currentValue = SystemProperties.get(
+ BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
+ int index = 0; // Defaults to 1 device
+ for (int i = 0; i < mListValues.length; i++) {
+ if (TextUtils.equals(currentValue, mListValues[i])) {
+ index = i;
+ break;
+ }
+ }
+ mPreference.setValue(mListValues[index]);
+ mPreference.setSummary(mListSummaries[index]);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchEnabled() {
+ mPreference.setEnabled(true);
+ updateState(mPreference);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ mPreference.setEnabled(false);
+ SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, mListValues[0]);
+ mPreference.setValue(mListValues[0]);
+ mPreference.setSummary(mListSummaries[0]);
+ }
+}
+
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index e736798..a404bc0 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -417,6 +417,7 @@
bluetoothA2dpConfigStore));
controllers.add(new BluetoothAudioQualityPreferenceController(context, lifecycle,
bluetoothA2dpConfigStore));
+ controllers.add(new BluetoothMaxConnectedAudioDevicesPreferenceController(context));
controllers.add(new ShowTapsPreferenceController(context));
controllers.add(new PointerLocationPreferenceController(context));
controllers.add(new ShowSurfaceUpdatesPreferenceController(context));
diff --git a/src/com/android/settings/security/FingerprintProfileStatusPreferenceController.java b/src/com/android/settings/fingerprint/FingerprintProfileStatusPreferenceController.java
similarity index 96%
rename from src/com/android/settings/security/FingerprintProfileStatusPreferenceController.java
rename to src/com/android/settings/fingerprint/FingerprintProfileStatusPreferenceController.java
index 1c72a46..68d2ade 100644
--- a/src/com/android/settings/security/FingerprintProfileStatusPreferenceController.java
+++ b/src/com/android/settings/fingerprint/FingerprintProfileStatusPreferenceController.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.security;
+package com.android.settings.fingerprint;
import android.content.Context;
import android.os.UserHandle;
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index 5d178d2..de7187c 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -25,12 +25,10 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
-import android.os.CancellationSignal;
import android.os.Handler;
import android.os.UserHandle;
import android.os.UserManager;
@@ -41,12 +39,7 @@
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
-import android.text.Annotation;
-import android.text.SpannableString;
-import android.text.SpannableStringBuilder;
-import android.text.TextPaint;
import android.text.TextUtils;
-import android.text.style.URLSpan;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
@@ -61,6 +54,7 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
@@ -103,6 +97,9 @@
private static final long LOCKOUT_DURATION = 30000; // time we have to wait for fp to reset, ms
+ public static final String ANNOTATION_URL = "url";
+ public static final String ANNOTATION_ADMIN_DETAILS = "admin_details";
+
public static final String KEY_FINGERPRINT_SETTINGS = "fingerprint_settings";
@Override
@@ -162,6 +159,20 @@
private FingerprintRemoveSidecar mRemovalSidecar;
private HashMap<Integer, String> mFingerprintsRenaming;
+ final AnnotationSpan.LinkInfo mUrlLinkInfo = new AnnotationSpan.LinkInfo(
+ ANNOTATION_URL, (view) -> {
+ final Context context = view.getContext();
+ Intent intent = HelpUtils.getHelpIntent(context, getString(getHelpResource()),
+ context.getClass().getName());
+ if (intent != null) {
+ try {
+ view.startActivityForResult(intent, 0);
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "Activity was not found for intent, " + intent.toString());
+ }
+ }
+ });
+
FingerprintAuthenticateSidecar.Listener mAuthenticateListener =
new FingerprintAuthenticateSidecar.Listener() {
@Override
@@ -346,10 +357,15 @@
final FooterPreference pref = mFooterPreferenceMixin.createFooterPreference();
final EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
activity, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId);
- pref.setTitle(LearnMoreSpan.linkify(getText(admin != null
- ? R.string.security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled
+ final AnnotationSpan.LinkInfo adminLinkInfo = new AnnotationSpan.LinkInfo(
+ ANNOTATION_ADMIN_DETAILS, (view) -> {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(activity, admin);
+ });
+ pref.setTitle(AnnotationSpan.linkify(getText(admin != null
+ ? R.string
+ .security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled
: R.string.security_settings_fingerprint_enroll_disclaimer),
- getString(getHelpResource()), admin));
+ mUrlLinkInfo, adminLinkInfo));
}
protected void removeFingerprintPreference(int fingerprintId) {
@@ -906,74 +922,6 @@
}
}
- private static class LearnMoreSpan extends URLSpan {
- private static final String TAG = "LearnMoreSpan";
- private static final Typeface TYPEFACE_MEDIUM =
- Typeface.create("sans-serif-medium", Typeface.NORMAL);
-
- private static final String ANNOTATION_URL = "url";
- private static final String ANNOTATION_ADMIN_DETAILS = "admin_details";
-
- private EnforcedAdmin mEnforcedAdmin = null;
-
- private LearnMoreSpan(String url) {
- super(url);
- }
-
- private LearnMoreSpan(EnforcedAdmin admin) {
- super((String) null);
- mEnforcedAdmin = admin;
- }
-
- @Override
- public void onClick(View widget) {
- Context ctx = widget.getContext();
- if (mEnforcedAdmin != null) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(ctx, mEnforcedAdmin);
- } else {
- Intent intent = HelpUtils.getHelpIntent(ctx, getURL(), ctx.getClass().getName());
- if (intent == null) {
- Log.w(LearnMoreSpan.TAG, "Null help intent.");
- return;
- }
- try {
- widget.startActivityForResult(intent, 0);
- } catch (ActivityNotFoundException e) {
- Log.w(FingerprintSettingsFragment.TAG,
- "Actvity was not found for intent, " + intent.toString());
- }
- }
- }
-
- @Override
- public void updateDrawState(TextPaint ds) {
- super.updateDrawState(ds);
- ds.setUnderlineText(false);
- ds.setTypeface(TYPEFACE_MEDIUM);
- }
-
- public static CharSequence linkify(CharSequence rawText, String uri, EnforcedAdmin admin) {
- SpannableString msg = new SpannableString(rawText);
- Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
- SpannableStringBuilder builder = new SpannableStringBuilder(msg);
- for (Annotation annotation : spans) {
- final String key = annotation.getValue();
- int start = msg.getSpanStart(annotation);
- int end = msg.getSpanEnd(annotation);
- LearnMoreSpan link = null;
- if (ANNOTATION_URL.equals(key)) {
- link = new LearnMoreSpan(uri);
- } else if (ANNOTATION_ADMIN_DETAILS.equals(key)) {
- link = new LearnMoreSpan(admin);
- }
- if (link != null) {
- builder.setSpan(link, start, end, msg.getSpanFlags(link));
- }
- }
- return builder;
- }
- }
-
/**
* @deprecated in favor of new SecuritySettings.
*/
diff --git a/src/com/android/settings/security/FingerprintStatusPreferenceController.java b/src/com/android/settings/fingerprint/FingerprintStatusPreferenceController.java
similarity index 95%
rename from src/com/android/settings/security/FingerprintStatusPreferenceController.java
rename to src/com/android/settings/fingerprint/FingerprintStatusPreferenceController.java
index 2985f40..19eb4bb 100644
--- a/src/com/android/settings/security/FingerprintStatusPreferenceController.java
+++ b/src/com/android/settings/fingerprint/FingerprintStatusPreferenceController.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.security;
+package com.android.settings.fingerprint;
import android.content.Context;
import android.content.Intent;
@@ -28,8 +28,6 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
-import com.android.settings.fingerprint.FingerprintSettings;
import com.android.settings.overlay.FeatureFactory;
import java.util.List;
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index a5b6c08..0315f03 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -84,10 +84,6 @@
private static final String KEY_SCREEN_USAGE = "screen_usage";
private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";
-
- private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness_battery";
- private static final String KEY_SCREEN_TIMEOUT = "screen_timeout_battery";
- private static final String KEY_AMBIENT_DISPLAY = "ambient_display_battery";
private static final String KEY_BATTERY_SAVER_SUMMARY = "battery_saver_summary";
@VisibleForTesting
@@ -272,14 +268,9 @@
mBatteryTipPreferenceController = new BatteryTipPreferenceController(context,
KEY_BATTERY_TIP, this);
controllers.add(mBatteryTipPreferenceController);
- controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
- controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
controllers.add(new BatterySaverController(context, getLifecycle()));
controllers.add(new BatteryPercentagePreferenceController(context));
- controllers.add(new AmbientDisplayPreferenceController(
- context,
- new AmbientDisplayConfiguration(context),
- KEY_AMBIENT_DISPLAY));
+
return controllers;
}
@@ -544,10 +535,6 @@
public List<String> getNonIndexableKeys(Context context) {
List<String> niks = super.getNonIndexableKeys(context);
niks.add(KEY_BATTERY_SAVER_SUMMARY);
- // Duplicates in display
- niks.add(KEY_AUTO_BRIGHTNESS);
- niks.add(KEY_SCREEN_TIMEOUT);
- niks.add(KEY_AMBIENT_DISPLAY);
return niks;
}
};
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogFragment.java b/src/com/android/settings/network/PrivateDnsModeDialogFragment.java
index 5704fb9..8b7ccce 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogFragment.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogFragment.java
@@ -22,22 +22,30 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.FragmentManager;
+import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.text.Editable;
import android.text.TextWatcher;
+import android.text.method.LinkMovementMethod;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
+import android.widget.TextView;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.utils.AnnotationSpan;
+import com.android.settingslib.HelpUtils;
import java.util.HashMap;
import java.util.Map;
@@ -48,6 +56,8 @@
public class PrivateDnsModeDialogFragment extends InstrumentedDialogFragment implements
DialogInterface.OnClickListener, RadioGroup.OnCheckedChangeListener, TextWatcher {
+ public static final String ANNOTATION_URL = "url";
+
private static final String TAG = "PrivateDnsModeDialogFragment";
// DNS_MODE -> RadioButton id
private static final Map<String, Integer> PRIVATE_DNS_MAP;
@@ -73,6 +83,21 @@
@VisibleForTesting
String mMode;
+ private final AnnotationSpan.LinkInfo mUrlLinkInfo = new AnnotationSpan.LinkInfo(
+ ANNOTATION_URL, (widget) -> {
+ final Context context = widget.getContext();
+ final Intent intent = HelpUtils.getHelpIntent(context,
+ getString(R.string.help_uri_private_dns),
+ context.getClass().getName());
+ if (intent != null) {
+ try {
+ widget.startActivityForResult(intent, 0);
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "Activity was not found for intent, " + intent.toString());
+ }
+ }
+ });
+
public static void show(FragmentManager fragmentManager) {
if (fragmentManager.findFragmentByTag(TAG) == null) {
final PrivateDnsModeDialogFragment fragment = new PrivateDnsModeDialogFragment();
@@ -112,25 +137,30 @@
mRadioGroup.setOnCheckedChangeListener(this);
mRadioGroup.check(PRIVATE_DNS_MAP.getOrDefault(mMode, R.id.private_dns_mode_opportunistic));
+ final TextView helpTextView = view.findViewById(R.id.private_dns_help_info);
+ helpTextView.setMovementMethod(LinkMovementMethod.getInstance());
+ helpTextView.setText(AnnotationSpan.linkify(
+ context.getText(R.string.private_dns_help_message), mUrlLinkInfo));
+
return view;
}
@Override
public void onClick(DialogInterface dialog, int which) {
- //TODO(b/34953048): add metric action
if (mMode.equals(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME)) {
// Only clickable if hostname is valid, so we could save it safely
Settings.Global.putString(getContext().getContentResolver(), HOSTNAME_KEY,
mEditText.getText().toString());
}
+ mMetricsFeatureProvider.action(getContext(),
+ MetricsProto.MetricsEvent.ACTION_PRIVATE_DNS_MODE, mMode);
Settings.Global.putString(getContext().getContentResolver(), MODE_KEY, mMode);
}
@Override
public int getMetricsCategory() {
- //TODO(b/68030013): add metric id
- return 0;
+ return MetricsProto.MetricsEvent.DIALOG_PRIVATE_DNS;
}
@Override
diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java
index 55d5d0e..ad68a74 100644
--- a/src/com/android/settings/overlay/SupportFeatureProvider.java
+++ b/src/com/android/settings/overlay/SupportFeatureProvider.java
@@ -46,89 +46,27 @@
}
/**
- * Returns a intent that will open help & feedback.
- */
- Intent getHelpIntent(Context context);
-
- /**
- * Whether or not a support type is enabled.
- */
- boolean isSupportTypeEnabled(Context context, @SupportType int type);
-
- /**
* Refreshes all operation rules.
*/
void refreshOperationRules();
/**
- * Whether or not a support type is in operation 24/7. If country is null, use
- * current country.
- */
- boolean isAlwaysOperating(@SupportType int type, String countryCode);
-
- /**
- * Whether or not a support type is operating now.
- */
- boolean isOperatingNow(@SupportType int type);
-
- /**
* Returns the current country code if it has a operation config, otherwise returns null.
*/
String getCurrentCountryCodeIfHasConfig(@SupportType int type);
/**
- * Returns localized string for operation hours in specified country. If country is null, use
- * current country to figure out operation hours.
- */
- CharSequence getOperationHours(Context context, @SupportType int type, String countryCode,
- boolean hasInternet);
-
- /**
- * Returns a localized string indicating estimated wait time for a support time.
- */
- String getEstimatedWaitTime(Context context, @SupportType int type);
-
- /**
- * Returns a list of country codes that have phone support.
- */
- List<String> getPhoneSupportCountryCodes();
-
- /**
- * Returns a list of countries that have phone support.
- */
- List<String> getPhoneSupportCountries();
-
- /**
* Returns a support phone for specified country.
*/
SupportPhone getSupportPhones(String countryCode, boolean isTollfree);
/**
- * Whether or not a disclaimer dialog should be displayed.
- */
- boolean shouldShowDisclaimerDialog(Context context);
-
- /**
- * Sets whether or not a disclaimer dialog should be displayed.
- */
- void setShouldShowDisclaimerDialog(Context context, boolean shouldShow);
-
- /**
* Returns array of {@link Account} that's eligible for support options.
*/
@NonNull
Account[] getSupportEligibleAccounts(Context context);
/**
- * Starts support activity of specified type
- *
- * @param activity Calling activity
- * @param account A account that selected by user
- * @param type The type of support account needs.
- */
- void startSupport(Activity activity, Account account, @SupportType int type);
-
- /**
* Starts support v2, invokes the support home page. Will no-op if support v2 is not enabled.
*
* @param activity Calling activity.
@@ -136,39 +74,6 @@
void startSupportV2(Activity activity);
/**
- * Checks if support v2 is enabled for this device.
- *
- * @return a boolean indicating if support v2 is enabled.
- */
- boolean isSupportV2Enabled();
-
- /**
- * Returns an {@link Intent} that opens help and allow user get help on sign in.
- */
- Intent getSignInHelpIntent(Context context);
-
- /**
- * Returns an intent that will start the add account UI.
- */
- Intent getAccountLoginIntent();
-
- /**
- * Returns an intent that will launch the tips and tricks UI.
- */
- Intent getTipsAndTricksIntent(Context context);
-
- /**
- * Returns the string for the disclaimer in the Support dialog.
- */
- @StringRes
- int getDisclaimerStringResId();
-
- /**
- * launches the fragment that displays the system information being sent to support agents.
- */
- void launchSystemInfoFragment(Bundle args, FragmentManager manager);
-
- /**
* Returns a url with information to introduce user to new device.
*/
String getNewDeviceIntroUrl(Context context);
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 4e54f3c..11efec3 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -210,7 +210,7 @@
private String mFirstPin;
private RecyclerView mPasswordRestrictionView;
protected boolean mIsAlphaMode;
- protected Button mCancelButton;
+ protected Button mSkipButton;
private Button mClearButton;
private Button mNextButton;
private TextView mMessage;
@@ -377,8 +377,8 @@
ViewGroup container = view.findViewById(R.id.password_container);
container.setOpticalInsets(Insets.NONE);
- mCancelButton = (Button) view.findViewById(R.id.cancel_button);
- mCancelButton.setOnClickListener(this);
+ mSkipButton = (Button) view.findViewById(R.id.skip_button);
+ mSkipButton.setOnClickListener(this);
mNextButton = (Button) view.findViewById(R.id.next_button);
mNextButton.setOnClickListener(this);
mClearButton = view.findViewById(R.id.clear_button);
@@ -774,10 +774,6 @@
handleNext();
break;
- case R.id.cancel_button:
- getActivity().finish();
- break;
-
case R.id.clear_button:
mPasswordEntry.setText("");
break;
@@ -901,7 +897,6 @@
}
mClearButton.setVisibility(toVisibility(mUiStage != Stage.Introduction));
- mCancelButton.setVisibility(toVisibility(mUiStage == Stage.Introduction));
setNextText(mUiStage.buttonText);
mPasswordEntryInputDisabler.setInputEnabled(canInput);
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 7cd9db8..746a977 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -290,8 +290,6 @@
* The states of the left footer button.
*/
enum LeftButtonMode {
- Cancel(R.string.cancel, true),
- CancelDisabled(R.string.cancel, false),
Retry(R.string.lockpattern_retry_button_text, true),
RetryDisabled(R.string.lockpattern_retry_button_text, false),
Gone(ID_EMPTY_MESSAGE, false);
@@ -342,7 +340,7 @@
R.string.lock_settings_picker_fingerprint_added_security_message,
R.string.lockpassword_choose_your_pattern_message,
R.string.lockpattern_recording_intro_header,
- LeftButtonMode.Cancel, RightButtonMode.ContinueDisabled,
+ LeftButtonMode.Gone, RightButtonMode.ContinueDisabled,
ID_EMPTY_MESSAGE, true),
HelpScreen(
ID_EMPTY_MESSAGE, ID_EMPTY_MESSAGE, R.string.lockpattern_settings_help_how_to_record,
@@ -360,15 +358,15 @@
LeftButtonMode.Retry, RightButtonMode.Continue, ID_EMPTY_MESSAGE, false),
NeedToConfirm(
ID_EMPTY_MESSAGE, ID_EMPTY_MESSAGE, R.string.lockpattern_need_to_confirm,
- LeftButtonMode.Cancel, RightButtonMode.ConfirmDisabled,
+ LeftButtonMode.Gone, RightButtonMode.ConfirmDisabled,
ID_EMPTY_MESSAGE, true),
ConfirmWrong(
ID_EMPTY_MESSAGE, ID_EMPTY_MESSAGE, R.string.lockpattern_need_to_unlock_wrong,
- LeftButtonMode.Cancel, RightButtonMode.ConfirmDisabled,
+ LeftButtonMode.Gone, RightButtonMode.ConfirmDisabled,
ID_EMPTY_MESSAGE, true),
ChoiceConfirmed(
ID_EMPTY_MESSAGE, ID_EMPTY_MESSAGE, R.string.lockpattern_pattern_confirmed_header,
- LeftButtonMode.Cancel, RightButtonMode.Confirm, ID_EMPTY_MESSAGE, false);
+ LeftButtonMode.Gone, RightButtonMode.Confirm, ID_EMPTY_MESSAGE, false);
/**
@@ -413,7 +411,7 @@
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private SaveAndFinishWorker mSaveAndFinishWorker;
- private int mUserId;
+ protected int mUserId;
private boolean mForFingerprint;
private static final String KEY_UI_STAGE = "uiStage";
@@ -558,8 +556,6 @@
mChosenPattern = null;
mLockPatternView.clearPattern();
updateStage(Stage.Introduction);
- } else if (mUiStage.leftMode == LeftButtonMode.Cancel) {
- getActivity().finish();
} else {
throw new IllegalStateException("left footer button pressed, but stage of " +
mUiStage + " doesn't make sense");
diff --git a/src/com/android/settings/password/ChooseLockTypeDialogFragment.java b/src/com/android/settings/password/ChooseLockTypeDialogFragment.java
index 13dc996..6a66ffb 100644
--- a/src/com/android/settings/password/ChooseLockTypeDialogFragment.java
+++ b/src/com/android/settings/password/ChooseLockTypeDialogFragment.java
@@ -16,6 +16,7 @@
package com.android.settings.password;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
@@ -24,6 +25,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -33,8 +35,11 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
+import com.android.setupwizardlib.util.WizardManagerHelper;
import java.util.List;
@@ -60,6 +65,36 @@
public interface OnLockTypeSelectedListener {
void onLockTypeSelected(ScreenLockType lock);
+
+ default void startChooseLockActivity(ScreenLockType selectedLockType, Activity activity) {
+ Intent activityIntent = activity.getIntent();
+ Intent intent = new Intent(activity, SetupChooseLockGeneric.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+
+ // Copy the original extras into the new intent
+ if (activityIntent.hasExtra(
+ ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS)) {
+ intent.putExtras(activityIntent.getBundleExtra(
+ ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS));
+ }
+ intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, selectedLockType.defaultQuality);
+
+ // Propagate the fingerprint challenge
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE,
+ activityIntent.getBooleanExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE,
+ activityIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0));
+
+ // The user is already given the choice of the what screen lock to set up. No need to
+ // show this button again.
+ intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
+
+ WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
+
+ activity.startActivity(intent);
+ activity.finish();
+ }
}
@Override
diff --git a/src/com/android/settings/password/SetupChooseLockPassword.java b/src/com/android/settings/password/SetupChooseLockPassword.java
index 79cfef3..5c70736 100644
--- a/src/com/android/settings/password/SetupChooseLockPassword.java
+++ b/src/com/android/settings/password/SetupChooseLockPassword.java
@@ -28,13 +28,9 @@
import android.widget.Button;
import android.widget.LinearLayout;
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.SetupRedactionInterstitial;
-import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.password.ChooseLockTypeDialogFragment.OnLockTypeSelectedListener;
-import com.android.setupwizardlib.util.WizardManagerHelper;
/**
* Setup Wizard's version of ChooseLockPassword screen. It inherits the logic and basic structure
@@ -75,9 +71,6 @@
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment
implements OnLockTypeSelectedListener {
- @VisibleForTesting
- static final int REQUEST_SCREEN_LOCK_OPTIONS = 1;
-
@Nullable
private Button mOptionsButton;
@@ -90,8 +83,7 @@
boolean anyOptionsShown = chooseLockGenericController.getVisibleScreenLockTypes(
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false).size() > 0;
boolean showOptionsButton = activity.getIntent().getBooleanExtra(
- ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
-
+ ChooseLockGeneric.ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
if (!anyOptionsShown) {
Log.w(TAG, "Visible screen lock types is empty!");
}
@@ -107,9 +99,10 @@
public void onClick(View v) {
switch (v.getId()) {
case R.id.screen_lock_options:
- launchChooseLockGeneric();
+ ChooseLockTypeDialogFragment.newInstance(mUserId)
+ .show(getChildFragmentManager(), null);
break;
- case R.id.cancel_button:
+ case R.id.skip_button:
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
getActivity().getIntent()
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
@@ -120,11 +113,6 @@
}
}
- private void launchChooseLockGeneric() {
- ChooseLockTypeDialogFragment.newInstance(mUserId)
- .show(getChildFragmentManager(), null);
- }
-
@Override
protected Intent getRedactionInterstitialIntent(Context context) {
// Setup wizard's redaction interstitial is deferred to optional step. Enable that
@@ -137,57 +125,16 @@
public void onLockTypeSelected(ScreenLockType lock) {
ScreenLockType currentLockType = mIsAlphaMode ?
ScreenLockType.PASSWORD : ScreenLockType.PIN;
- if (currentLockType.equals(lock)) {
- // ignore same lock type.
+ if (lock == currentLockType) {
return;
}
- Intent activityIntent = getActivity().getIntent();
- Intent intent = new Intent(getContext(), SetupChooseLockGeneric.class);
-
- // Copy the original extras into the new intent
- if (activityIntent
- .hasExtra(ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS)) {
- intent.putExtras(activityIntent.getBundleExtra(
- ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS));
- }
- intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, lock.defaultQuality);
-
- // Propagate the fingerprint challenge
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE,
- activityIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE,
- false));
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE,
- activityIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0));
-
- // The user is already given the choice of the what screen lock to set up. No need to
- // show this button again.
- intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
-
- WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
-
- startActivityForResult(intent, REQUEST_SCREEN_LOCK_OPTIONS);
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == REQUEST_SCREEN_LOCK_OPTIONS) {
- if (resultCode != Activity.RESULT_CANCELED) {
- Activity activity = getActivity();
- activity.setResult(resultCode, data);
- activity.finish();
- }
- }
+ startChooseLockActivity(lock, getActivity());
}
@Override
protected void updateUi() {
super.updateUi();
- if (mForFingerprint) {
- mCancelButton.setVisibility(View.GONE);
- } else {
- mCancelButton.setText(R.string.skip_label);
- }
+ mSkipButton.setVisibility(mForFingerprint ? View.GONE : View.VISIBLE);
if (mOptionsButton != null) {
mOptionsButton.setVisibility(
diff --git a/src/com/android/settings/password/SetupChooseLockPattern.java b/src/com/android/settings/password/SetupChooseLockPattern.java
index b1e3d0d..b1c9fac 100644
--- a/src/com/android/settings/password/SetupChooseLockPattern.java
+++ b/src/com/android/settings/password/SetupChooseLockPattern.java
@@ -19,7 +19,11 @@
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import com.android.settings.R;
import com.android.settings.SetupRedactionInterstitial;
/**
@@ -46,7 +50,26 @@
return SetupChooseLockPatternFragment.class;
}
- public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment {
+ public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment
+ implements ChooseLockTypeDialogFragment.OnLockTypeSelectedListener {
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ Button optionsButton = (Button) view.findViewById(R.id.screen_lock_options);
+ optionsButton.setVisibility(View.VISIBLE);
+ optionsButton.setOnClickListener((btn) ->
+ ChooseLockTypeDialogFragment.newInstance(mUserId)
+ .show(getChildFragmentManager(), null));
+ }
+
+ @Override
+ public void onLockTypeSelected(ScreenLockType lock) {
+ if (ScreenLockType.PATTERN == lock) {
+ return;
+ }
+ startChooseLockActivity(lock, getActivity());
+ }
@Override
protected Intent getRedactionInterstitialIntent(Context context) {
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index c4e178f..0207c94 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -75,7 +75,7 @@
import com.android.settings.security.EncryptionAndCredential;
import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.security.ScreenPinningSettings;
-import com.android.settings.security.SecuritySettings;
+import com.android.settings.security.SecuritySettingsV2;
import com.android.settings.security.screenlock.ScreenLockSettings;
import com.android.settings.sim.SimSettings;
import com.android.settings.support.SupportDashboardActivity;
@@ -135,7 +135,7 @@
addIndex(LocationSettings.class);
addIndex(LocationMode.class);
addIndex(ScanningSettings.class);
- addIndex(SecuritySettings.class);
+ addIndex(SecuritySettingsV2.class);
addIndex(ScreenLockSettings.class);
addIndex(EncryptionAndCredential.class);
addIndex(ScreenPinningSettings.class);
@@ -179,5 +179,7 @@
private SearchIndexableResources() {
}
- public static Collection<Class> providerValues() { return sProviders;}
+ public static Collection<Class> providerValues() {
+ return sProviders;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
index 612dd6d..9a33ec3 100644
--- a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
@@ -30,7 +30,6 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.password.ChooseLockGeneric;
-import com.android.settings.widget.GearPreference;
public class ChangeProfileScreenLockPreferenceController extends
ChangeScreenLockPreferenceController {
@@ -42,12 +41,6 @@
super(context, host);
}
- @Override
- public void onGearClick(GearPreference p) {
-
- }
-
- @Override
public boolean isAvailable() {
if (mProfileChallengeUserId == UserHandle.USER_NULL ||
!mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
diff --git a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
index 3cd235f..67b78fc 100644
--- a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
@@ -79,13 +79,19 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
- if (mPreference != null && mPreference instanceof GearPreference) {
- ((GearPreference) mPreference).setOnGearClickListener(this);
- }
}
@Override
public void updateState(Preference preference) {
+ if (mPreference != null && mPreference instanceof GearPreference) {
+ if (mLockPatternUtils.isSecure(mUserId)
+ || !mLockPatternUtils.isLockScreenDisabled(mUserId)) {
+ ((GearPreference) mPreference).setOnGearClickListener(this);
+ } else {
+ ((GearPreference) mPreference).setOnGearClickListener(null);
+ }
+ }
+
updateSummary(preference, mUserId);
disableIfPasswordQualityManaged(mUserId);
if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
@@ -148,6 +154,7 @@
break;
}
}
+ mPreference.setEnabled(true);
}
/**
diff --git a/src/com/android/settings/security/EncryptionAndCredential.java b/src/com/android/settings/security/EncryptionAndCredential.java
index aa35dd3..627cf3e 100644
--- a/src/com/android/settings/security/EncryptionAndCredential.java
+++ b/src/com/android/settings/security/EncryptionAndCredential.java
@@ -66,7 +66,8 @@
Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final EncryptionStatusPreferenceController encryptStatusController =
- new EncryptionStatusPreferenceController(context, PREF_KEY_ENCRYPTION_DETAIL_PAGE);
+ new EncryptionStatusPreferenceController(context,
+ PREF_KEY_ENCRYPTION_DETAIL_PAGE);
controllers.add(encryptStatusController);
controllers.add(new PreferenceCategoryController(context,
"encryption_and_credentials_status_category",
diff --git a/src/com/android/settings/security/SecuritySettingsV2.java b/src/com/android/settings/security/SecuritySettingsV2.java
index 7ae6ca7..323c0f4 100644
--- a/src/com/android/settings/security/SecuritySettingsV2.java
+++ b/src/com/android/settings/security/SecuritySettingsV2.java
@@ -1,33 +1,31 @@
package com.android.settings.security;
-import static com.android.settings.security.EncryptionStatusPreferenceController.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
+import static com.android.settings.security.EncryptionStatusPreferenceController
+ .PREF_KEY_ENCRYPTION_SECURITY_PAGE;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.hardware.fingerprint.FingerprintManager;
-import android.os.UserHandle;
-import android.os.UserManager;
import android.provider.SearchIndexableResource;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
+import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceController;
+import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
import com.android.settings.location.LocationPreferenceController;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.security.screenlock.LockScreenPreferenceController;
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
+import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.ArrayList;
import java.util.List;
@@ -43,60 +41,12 @@
public static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
public static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
-
- // Security status
- private static final String KEY_SECURITY_STATUS = "security_status";
- private static final String SECURITY_STATUS_KEY_PREFIX = "security_status_";
-
- private static final int MY_USER_ID = UserHandle.myUserId();
-
- private DashboardFeatureProvider mDashboardFeatureProvider;
- private SecurityFeatureProvider mSecurityFeatureProvider;
- private UserManager mUm;
-
- private ChooseLockSettingsHelper mChooseLockSettingsHelper;
- private LockPatternUtils mLockPatternUtils;
-
- private int mProfileChallengeUserId;
-
- private LocationPreferenceController mLocationController;
- private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController;
- private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController;
- private EncryptionStatusPreferenceController mEncryptionStatusPreferenceController;
- private ManageTrustAgentsPreferenceController mManageTrustAgentsPreferenceController;
- private ScreenPinningPreferenceController mScreenPinningPreferenceController;
- private SimLockPreferenceController mSimLockPreferenceController;
- private ShowPasswordPreferenceController mShowPasswordPreferenceController;
- private TrustAgentListPreferenceController mTrustAgentListPreferenceController;
- private LockScreenPreferenceController mLockScreenPreferenceController;
- private ChangeScreenLockPreferenceController mChangeScreenLockPreferenceController;
- private ChangeProfileScreenLockPreferenceController
- mChangeProfileScreenLockPreferenceController;
- private LockUnificationPreferenceController mLockUnificationPreferenceController;
- private VisiblePatternProfilePreferenceController mVisiblePatternProfilePreferenceController;
- private FingerprintStatusPreferenceController mFingerprintStatusPreferenceController;
- private FingerprintProfileStatusPreferenceController
- mFingerprintProfileStatusPreferenceController;
-
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SECURITY;
}
@Override
- public void onAttach(Context context) {
- super.onAttach(context);
- mSecurityFeatureProvider = FeatureFactory.getFactory(context).getSecurityFeatureProvider();
- mLocationController = new LocationPreferenceController(context, getLifecycle());
- mLockPatternUtils = mSecurityFeatureProvider.getLockPatternUtils(context);
- mUm = UserManager.get(context);
- mDashboardFeatureProvider = FeatureFactory.getFactory(context)
- .getDashboardFeatureProvider(context);
-
- mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
- }
-
- @Override
protected int getPreferenceScreenResId() {
return R.xml.security_settings_v2;
}
@@ -106,7 +56,6 @@
return TAG;
}
-
@Override
public int getHelpResource() {
return R.string.help_url_security;
@@ -114,161 +63,7 @@
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
- mManageDeviceAdminPreferenceController
- = new ManageDeviceAdminPreferenceController(context);
- mEnterprisePrivacyPreferenceController
- = new EnterprisePrivacyPreferenceController(context);
- mManageTrustAgentsPreferenceController = new ManageTrustAgentsPreferenceController(context);
- mScreenPinningPreferenceController = new ScreenPinningPreferenceController(context);
- mSimLockPreferenceController = new SimLockPreferenceController(context);
- mShowPasswordPreferenceController = new ShowPasswordPreferenceController(context);
- mEncryptionStatusPreferenceController = new EncryptionStatusPreferenceController(
- context, PREF_KEY_ENCRYPTION_SECURITY_PAGE);
- mTrustAgentListPreferenceController = new TrustAgentListPreferenceController(getActivity(),
- this /* host */, getLifecycle());
- mLockScreenPreferenceController = new LockScreenPreferenceController(context);
- mChangeScreenLockPreferenceController = new ChangeScreenLockPreferenceController(context,
- this /* host */);
- mChangeProfileScreenLockPreferenceController =
- new ChangeProfileScreenLockPreferenceController(context, this /* host */);
- mLockUnificationPreferenceController = new LockUnificationPreferenceController(context,
- this /* host */);
- mVisiblePatternProfilePreferenceController =
- new VisiblePatternProfilePreferenceController(context);
- mFingerprintStatusPreferenceController = new FingerprintStatusPreferenceController(context);
- mFingerprintProfileStatusPreferenceController =
- new FingerprintProfileStatusPreferenceController(context);
- return null;
- }
-
- /**
- * Important!
- *
- * Don't forget to update the SecuritySearchIndexProvider if you are doing any change in the
- * logic or adding/removing preferences here.
- */
- private PreferenceScreen createPreferenceHierarchy() {
- final PreferenceScreen root = getPreferenceScreen();
- mTrustAgentListPreferenceController.displayPreference(root);
- mLockScreenPreferenceController.displayPreference(root);
- mChangeScreenLockPreferenceController.displayPreference(root);
- mChangeProfileScreenLockPreferenceController.displayPreference(root);
- mLockUnificationPreferenceController.displayPreference(root);
- mVisiblePatternProfilePreferenceController.displayPreference(root);
- mFingerprintStatusPreferenceController.displayPreference(root);
- mFingerprintProfileStatusPreferenceController.displayPreference(root);
-
- mSimLockPreferenceController.displayPreference(root);
- mScreenPinningPreferenceController.displayPreference(root);
-
- // Advanced Security features
- mManageTrustAgentsPreferenceController.displayPreference(root);
-
-// PreferenceGroup securityStatusPreferenceGroup =
-// (PreferenceGroup) root.findPreference(KEY_SECURITY_STATUS);
-// final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(
-// getActivity(), getPrefContext(), getMetricsCategory(),
-// CategoryKey.CATEGORY_SECURITY);
-// int numSecurityStatusPrefs = 0;
-// if (tilePrefs != null && !tilePrefs.isEmpty()) {
-// for (Preference preference : tilePrefs) {
-// if (!TextUtils.isEmpty(preference.getKey())
-// && preference.getKey().startsWith(SECURITY_STATUS_KEY_PREFIX)) {
-// // Injected security status settings are placed under the Security status
-// // category.
-// securityStatusPreferenceGroup.addPreference(preference);
-// numSecurityStatusPrefs++;
-// } else {
-// // Other injected settings are placed under the Security preference screen.
-// root.addPreference(preference);
-// }
-// }
-// }
-//
-// if (numSecurityStatusPrefs == 0) {
-// root.removePreference(securityStatusPreferenceGroup);
-// } else if (numSecurityStatusPrefs > 0) {
-// // Update preference data with tile data. Security feature provider only updates the
-// // data if it actually needs to be changed.
-// mSecurityFeatureProvider.updatePreferences(getActivity(), root,
-// mDashboardFeatureProvider.getTilesForCategory(
-// CategoryKey.CATEGORY_SECURITY));
-// }
-
- mLocationController.displayPreference(root);
- mManageDeviceAdminPreferenceController.updateState(
- root.findPreference(mManageDeviceAdminPreferenceController.getPreferenceKey()));
- mEnterprisePrivacyPreferenceController.displayPreference(root);
- final Preference enterprisePrivacyPreference = root.findPreference(
- mEnterprisePrivacyPreferenceController.getPreferenceKey());
- mEnterprisePrivacyPreferenceController.updateState(enterprisePrivacyPreference);
-
- return root;
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- // Make sure we reload the preference hierarchy since some of these settings
- // depend on others...
- createPreferenceHierarchy();
-
- final Preference visiblePatternProfilePref = getPreferenceScreen().findPreference(
- mVisiblePatternProfilePreferenceController.getPreferenceKey());
- if (visiblePatternProfilePref != null) {
- visiblePatternProfilePref
- .setOnPreferenceChangeListener(mVisiblePatternProfilePreferenceController);
- mVisiblePatternProfilePreferenceController.updateState(visiblePatternProfilePref);
- }
-
- final Preference showPasswordPref = getPreferenceScreen().findPreference(
- mShowPasswordPreferenceController.getPreferenceKey());
- showPasswordPref.setOnPreferenceChangeListener(mShowPasswordPreferenceController);
- mShowPasswordPreferenceController.updateState(showPasswordPref);
-
- final Preference lockUnificationPref = getPreferenceScreen().findPreference(
- mLockUnificationPreferenceController.getPreferenceKey());
- lockUnificationPref.setOnPreferenceChangeListener(mLockUnificationPreferenceController);
- mLockUnificationPreferenceController.updateState(lockUnificationPref);
-
- final Preference changeDeviceLockPref = getPreferenceScreen().findPreference(
- mChangeScreenLockPreferenceController.getPreferenceKey());
- mChangeScreenLockPreferenceController.updateState(changeDeviceLockPref);
-
- mFingerprintStatusPreferenceController.updateState(
- getPreferenceScreen().findPreference(
- mFingerprintStatusPreferenceController.getPreferenceKey()));
-
- mFingerprintProfileStatusPreferenceController.updateState(
- getPreferenceScreen().findPreference(
- mFingerprintProfileStatusPreferenceController.getPreferenceKey()));
-
- final Preference changeProfileLockPref = getPreferenceScreen().findPreference(
- mChangeProfileScreenLockPreferenceController.getPreferenceKey());
- mChangeProfileScreenLockPreferenceController.updateState(changeProfileLockPref);
-
- final Preference encryptionStatusPref = getPreferenceScreen().findPreference(
- mEncryptionStatusPreferenceController.getPreferenceKey());
- mEncryptionStatusPreferenceController.updateState(encryptionStatusPref);
- mTrustAgentListPreferenceController.onResume();
- mLocationController.updateSummary();
- }
-
-
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- if (mTrustAgentListPreferenceController.handlePreferenceTreeClick(preference)) {
- return true;
- }
- if (mChangeScreenLockPreferenceController.handlePreferenceTreeClick(preference)) {
- return true;
- }
- if (mChangeProfileScreenLockPreferenceController.handlePreferenceTreeClick(preference)) {
- return true;
- }
- // If we didn't handle it, let preferences handle it.
- return super.onPreferenceTreeClick(preference);
+ return buildPreferenceControllers(context, getLifecycle(), this /* host*/);
}
/**
@@ -276,50 +71,85 @@
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (getPreferenceController(TrustAgentListPreferenceController.class)
+ .handleActivityResult(requestCode, resultCode)) {
+ return;
+ }
+ if (getPreferenceController(LockUnificationPreferenceController.class)
+ .handleActivityResult(requestCode, resultCode, data)) {
+ return;
+ }
super.onActivityResult(requestCode, resultCode, data);
- if (mTrustAgentListPreferenceController.handleActivityResult(requestCode, resultCode)) {
- return;
- }
- if (mLockUnificationPreferenceController.handleActivityResult(
- requestCode, resultCode, data)) {
- return;
- }
- createPreferenceHierarchy();
+ }
+
+ void launchConfirmDeviceLockForUnification() {
+ getPreferenceController(LockUnificationPreferenceController.class)
+ .launchConfirmDeviceLockForUnification();
+ }
+
+ void unifyUncompliantLocks() {
+ getPreferenceController(LockUnificationPreferenceController.class).unifyUncompliantLocks();
+ }
+
+ void updateUnificationPreference() {
+ getPreferenceController(LockUnificationPreferenceController.class).updateState(null);
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle, SecuritySettingsV2 host) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new LocationPreferenceController(context, lifecycle));
+ controllers.add(new ManageDeviceAdminPreferenceController(context));
+ controllers.add(new EnterprisePrivacyPreferenceController(context));
+ controllers.add(new ManageTrustAgentsPreferenceController(context));
+ controllers.add(new ScreenPinningPreferenceController(context));
+ controllers.add(new SimLockPreferenceController(context));
+ controllers.add(new ShowPasswordPreferenceController(context));
+ controllers.add(new FingerprintStatusPreferenceController(context));
+ controllers.add(new EncryptionStatusPreferenceController(context,
+ PREF_KEY_ENCRYPTION_SECURITY_PAGE));
+ controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
+ controllers.add(new LockScreenPreferenceController(context, lifecycle));
+ controllers.add(new ChangeScreenLockPreferenceController(context, host));
+
+ final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
+ profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
+ context, host));
+ profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
+ profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
+ context, lifecycle));
+ profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
+ controllers.add(new PreferenceCategoryController(context, "security_category_profile",
+ profileSecurityControllers));
+ controllers.addAll(profileSecurityControllers);
+
+ return controllers;
}
/**
* For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
*/
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new SecuritySearchIndexProvider();
+ new BaseSearchIndexProvider() {
- void launchConfirmDeviceLockForUnification() {
- mLockUnificationPreferenceController.launchConfirmDeviceLockForUnification();
- }
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final List<SearchIndexableResource> index = new ArrayList<>();
+ // Append the rest of the settings
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.security_settings_v2;
+ index.add(sir);
+ return index;
+ }
- void unifyUncompliantLocks() {
- mLockUnificationPreferenceController.unifyUncompliantLocks();
- }
-
- void updateUnificationPreference() {
- mLockUnificationPreferenceController.updateState(null);
- }
-
- private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider {
-
- // TODO (b/68001777) Refactor indexing to include all XML and block other settings.
-
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final List<SearchIndexableResource> index = new ArrayList<>();
- // Append the rest of the settings
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.security_settings_v2;
- index.add(sir);
- return index;
- }
- }
+ @Override
+ public List<AbstractPreferenceController> getPreferenceControllers(Context
+ context) {
+ return buildPreferenceControllers(context, null /* lifecycle */,
+ null /* host*/);
+ }
+ };
static class SummaryProvider implements SummaryLoader.SummaryProvider {
diff --git a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
index 39b1916..a9e56f4 100644
--- a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
+++ b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
@@ -21,13 +21,19 @@
import android.content.Context;
import android.os.UserHandle;
import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnResume;
-public class VisiblePatternProfilePreferenceController extends TogglePreferenceController {
+public class VisiblePatternProfilePreferenceController extends TogglePreferenceController
+ implements LifecycleObserver, OnResume {
private static final String KEY_VISIBLE_PATTERN_PROFILE = "visiblepattern_profile";
@@ -36,13 +42,18 @@
private final int mUserId = UserHandle.myUserId();
private final int mProfileChallengeUserId;
- public VisiblePatternProfilePreferenceController(Context context) {
+ private Preference mPreference;
+
+ public VisiblePatternProfilePreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY_VISIBLE_PATTERN_PROFILE);
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
mLockPatternUtils = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider()
.getLockPatternUtils(context);
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
}
@Override
@@ -69,4 +80,15 @@
mLockPatternUtils.setVisiblePatternEnabled(isChecked, mProfileChallengeUserId);
return true;
}
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void onResume() {
+ mPreference.setVisible(isAvailable());
+ }
}
diff --git a/src/com/android/settings/security/LockScreenPreferenceController.java b/src/com/android/settings/security/screenlock/LockScreenPreferenceController.java
similarity index 71%
rename from src/com/android/settings/security/LockScreenPreferenceController.java
rename to src/com/android/settings/security/screenlock/LockScreenPreferenceController.java
index 213c39c..d42af2d 100644
--- a/src/com/android/settings/security/LockScreenPreferenceController.java
+++ b/src/com/android/settings/security/screenlock/LockScreenPreferenceController.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.security;
+package com.android.settings.security.screenlock;
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
@@ -27,18 +27,32 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnResume;
-public class LockScreenPreferenceController extends BasePreferenceController {
+public class LockScreenPreferenceController extends BasePreferenceController implements
+ LifecycleObserver, OnResume {
static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
private static final int MY_USER_ID = UserHandle.myUserId();
private final LockPatternUtils mLockPatternUtils;
+ private Preference mPreference;
- public LockScreenPreferenceController(Context context) {
+ public LockScreenPreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY_LOCKSCREEN_PREFERENCES);
mLockPatternUtils = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider().getLockPatternUtils(context);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
@@ -54,12 +68,13 @@
}
@Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- final Preference lockscreenPreferences = screen.findPreference(getPreferenceKey());
- if (lockscreenPreferences != null) {
- lockscreenPreferences.setSummary(
- LockScreenNotificationPreferenceController.getSummaryResource(mContext));
- }
+ public void updateState(Preference preference) {
+ preference.setSummary(
+ LockScreenNotificationPreferenceController.getSummaryResource(mContext));
+ }
+
+ @Override
+ public void onResume() {
+ mPreference.setVisible(isAvailable());
}
}
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 8d198e7..99aa6a4 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -19,6 +19,7 @@
import static com.android.settings.security.SecuritySettingsV2.CHANGE_TRUST_AGENT_SETTINGS;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
@@ -56,20 +57,18 @@
private final LockPatternUtils mLockPatternUtils;
private final TrustAgentManager mTrustAgentManager;
- private final Activity mActivity;
private final SecuritySettingsV2 mHost;
private Intent mTrustAgentClickIntent;
private PreferenceCategory mSecurityCategory;
- public TrustAgentListPreferenceController(Activity activity, SecuritySettingsV2 host,
+ public TrustAgentListPreferenceController(Context context, SecuritySettingsV2 host,
Lifecycle lifecycle) {
- super(activity);
- final SecurityFeatureProvider provider = FeatureFactory.getFactory(activity)
+ super(context);
+ final SecurityFeatureProvider provider = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider();
- mActivity = activity;
mHost = host;
- mLockPatternUtils = provider.getLockPatternUtils(activity);
+ mLockPatternUtils = provider.getLockPatternUtils(context);
mTrustAgentManager = provider.getTrustAgentManager();
if (lifecycle != null) {
lifecycle.addObserver(this);
@@ -90,6 +89,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mSecurityCategory = (PreferenceCategory) screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
+ updateTrustAgents();
}
@Override
@@ -112,7 +112,8 @@
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
return super.handlePreferenceTreeClick(preference);
}
- final ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(mActivity, mHost);
+ final ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(
+ mHost.getActivity(), mHost);
mTrustAgentClickIntent = preference.getIntent();
boolean confirmationLaunched = helper.launchConfirmationActivity(
CHANGE_TRUST_AGENT_SETTINGS, preference.getTitle());
@@ -127,6 +128,10 @@
@Override
public void onResume() {
+ updateTrustAgents();
+ }
+
+ private void updateTrustAgents() {
if (mSecurityCategory == null) {
return;
}
@@ -167,7 +172,7 @@
public boolean handleActivityResult(int requestCode, int resultCode) {
if (requestCode == CHANGE_TRUST_AGENT_SETTINGS && resultCode == Activity.RESULT_OK) {
- if (mTrustAgentClickIntent != null){
+ if (mTrustAgentClickIntent != null) {
mHost.startActivity(mTrustAgentClickIntent);
mTrustAgentClickIntent = null;
}
diff --git a/src/com/android/settings/support/SupportDashboardActivity.java b/src/com/android/settings/support/SupportDashboardActivity.java
index d3fcf9a..3b5d623 100644
--- a/src/com/android/settings/support/SupportDashboardActivity.java
+++ b/src/com/android/settings/support/SupportDashboardActivity.java
@@ -21,7 +21,6 @@
import android.os.Bundle;
import com.android.settings.R;
-import com.android.settings.Settings.LegacySupportActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -43,12 +42,10 @@
.getSupportFeatureProvider(this);
// try to launch support v2 if we have the feature provider
- if (supportFeatureProvider != null && supportFeatureProvider.isSupportV2Enabled()) {
- supportFeatureProvider.startSupportV2(this);
- } else {
- startActivity(new Intent(this, LegacySupportActivity.class));
+ if (supportFeatureProvider != null) {
+ supportFeatureProvider.startSupportV2(this);
+ finish();
}
- finish();
}
/**
diff --git a/src/com/android/settings/support/SupportDisclaimerDialogFragment.java b/src/com/android/settings/support/SupportDisclaimerDialogFragment.java
deleted file mode 100644
index 07a451a..0000000
--- a/src/com/android/settings/support/SupportDisclaimerDialogFragment.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.support;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.text.Annotation;
-import android.text.Spannable;
-import android.text.Spanned;
-import android.text.TextPaint;
-import android.text.TextUtils;
-import android.text.style.URLSpan;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.CheckBox;
-import android.widget.TextView;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.overlay.SupportFeatureProvider;
-
-/**
- * {@link DialogFragment} for support disclaimer.
- */
-public final class SupportDisclaimerDialogFragment extends InstrumentedDialogFragment
- implements DialogInterface.OnClickListener {
-
- public static final String TAG = "SupportDisclaimerDialog";
- public static final String EXTRA_TYPE = "extra_type";
- public static final String EXTRA_ACCOUNT = "extra_account";
-
- public static SupportDisclaimerDialogFragment newInstance(Account account,
- @SupportFeatureProvider.SupportType int type) {
- final SupportDisclaimerDialogFragment fragment = new SupportDisclaimerDialogFragment();
- final Bundle bundle = new Bundle(2);
- bundle.putParcelable(SupportDisclaimerDialogFragment.EXTRA_ACCOUNT, account);
- bundle.putInt(SupportDisclaimerDialogFragment.EXTRA_TYPE, type);
- fragment.setArguments(bundle);
- return fragment;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
- .setTitle(R.string.support_disclaimer_title)
- .setPositiveButton(android.R.string.ok, this)
- .setNegativeButton(android.R.string.cancel, this);
- final View content = LayoutInflater.from(builder.getContext())
- .inflate(R.layout.support_disclaimer_content, null);
- final TextView disclaimer = (TextView) content.findViewById(R.id.support_disclaimer_text);
- final Activity activity = getActivity();
- final SupportFeatureProvider supportFeatureProvider =
- FeatureFactory.getFactory(activity).getSupportFeatureProvider(activity);
-
- // sets the two links that go to privacy policy and terms of service
- disclaimer.setText(supportFeatureProvider.getDisclaimerStringResId());
- Spannable viewText = (Spannable) disclaimer.getText();
- stripUnderlines(viewText);
- SystemInformationSpan.linkify(viewText, this);
- // sets the link that launches a dialog to expose the signals we are sending
- return builder
- .setView(content)
- .create();
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == Dialog.BUTTON_NEGATIVE) {
- mMetricsFeatureProvider.action(getContext(),
- MetricsProto.MetricsEvent.ACTION_SUPPORT_DISCLAIMER_CANCEL);
- return;
- }
- final Activity activity = getActivity();
- final CheckBox doNotShow =
- (CheckBox) getDialog().findViewById(R.id.support_disclaimer_do_not_show_again);
- final boolean isChecked = doNotShow.isChecked();
- final SupportFeatureProvider supportFeatureProvider =
- FeatureFactory.getFactory(activity).getSupportFeatureProvider(activity);
- supportFeatureProvider.setShouldShowDisclaimerDialog(getContext(), !isChecked);
- final Bundle bundle = getArguments();
- if (isChecked) {
- mMetricsFeatureProvider.action(activity,
- MetricsProto.MetricsEvent.ACTION_SKIP_DISCLAIMER_SELECTED);
- }
- mMetricsFeatureProvider.action(activity,
- MetricsProto.MetricsEvent.ACTION_SUPPORT_DISCLAIMER_OK);
- supportFeatureProvider.startSupport(getActivity(),
- bundle.getParcelable(EXTRA_ACCOUNT), bundle.getInt(EXTRA_TYPE));
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- super.onCancel(dialog);
- mMetricsFeatureProvider.action(getContext(),
- MetricsProto.MetricsEvent.ACTION_SUPPORT_DISCLAIMER_CANCEL);
- }
-
- /**
- * Removes the underlines of {@link android.text.style.URLSpan}s.
- */
- private static void stripUnderlines(Spannable input) {
- final URLSpan[] urls = input.getSpans(0, input.length(), URLSpan.class);
-
- for (URLSpan span : urls) {
- final int start = input.getSpanStart(span);
- final int end = input.getSpanEnd(span);
- if (!TextUtils.isEmpty(span.getURL())) {
- input.removeSpan(span);
- input.setSpan(new NoUnderlineUrlSpan(span.getURL()), start, end,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- }
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.DIALOG_SUPPORT_DISCLAIMER;
- }
-
- /**
- * A {@link URLSpan} that doesn't decorate the link with underline.
- */
- public static class NoUnderlineUrlSpan extends URLSpan {
-
- public NoUnderlineUrlSpan(String url) {
- super(url);
- }
-
- @Override
- public void updateDrawState(TextPaint ds) {
- super.updateDrawState(ds);
- ds.setUnderlineText(false);
- }
- }
-
- /**
- * A {@link URLSpan} that opens a dialog when clicked
- */
- public static class SystemInformationSpan extends URLSpan {
-
- private static final String ANNOTATION_URL = "url";
- private final DialogFragment mDialog;
- private SupportFeatureProvider mSupport;
-
- public SystemInformationSpan(DialogFragment parent) {
- // sets the url to empty string so we can prevent the NoUnderlineUrlSpan from stripping
- // this one
- super("");
- mSupport = FeatureFactory.getFactory(parent.getContext())
- .getSupportFeatureProvider(parent.getContext());
- mDialog = parent;
- }
-
- @Override
- public void onClick(View widget) {
- Activity activity = mDialog.getActivity();
- if (mSupport != null && activity != null) {
- // launch the system info fragment
- mSupport.launchSystemInfoFragment(mDialog.getArguments(),
- activity.getFragmentManager());
-
- // dismiss this fragment
- mDialog.dismiss();
- }
- }
-
- @Override
- public void updateDrawState(TextPaint ds) {
- super.updateDrawState(ds);
- // remove underline
- ds.setUnderlineText(false);
- }
-
- /**
- * This method takes a string and turns it into a url span that will launch a
- * SupportSystemInformationDialogFragment
- * @param msg The text to turn into a link
- * @param parent The dialog the text is in
- * @return A CharSequence containing the original text content as a url
- */
- public static CharSequence linkify(Spannable msg, DialogFragment parent) {
- Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
- for (Annotation annotation : spans) {
- int start = msg.getSpanStart(annotation);
- int end = msg.getSpanEnd(annotation);
- if (ANNOTATION_URL.equals(annotation.getValue())) {
- SystemInformationSpan link = new SystemInformationSpan(parent);
- msg.removeSpan(annotation);
- msg.setSpan(link, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- }
- return msg;
- }
-
- @VisibleForTesting
- public void setSupportProvider(SupportFeatureProvider prov) {
- mSupport = prov;
- }
- }
-}
diff --git a/src/com/android/settings/support/SupportPhoneDialogFragment.java b/src/com/android/settings/support/SupportPhoneDialogFragment.java
deleted file mode 100644
index 8abdae0..0000000
--- a/src/com/android/settings/support/SupportPhoneDialogFragment.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.support;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-
-import java.util.Locale;
-
-/**
- * A dialog fragment that displays support phone numbers.
- */
-public final class SupportPhoneDialogFragment extends InstrumentedDialogFragment
- implements View.OnClickListener {
-
- public static final String TAG = "SupportPhoneDialog";
- private static final String EXTRA_PHONE = "extra_phone";
-
- public static SupportPhoneDialogFragment newInstance(SupportPhone phone) {
- final SupportPhoneDialogFragment fragment = new SupportPhoneDialogFragment();
- final Bundle bundle = new Bundle(2);
- bundle.putParcelable(EXTRA_PHONE, phone);
- fragment.setArguments(bundle);
- return fragment;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final SupportPhone phone = getArguments().getParcelable(EXTRA_PHONE);
- final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
- .setTitle(R.string.support_international_phone_title);
- final View content = LayoutInflater.from(builder.getContext())
- .inflate(R.layout.support_phone_dialog_content, null);
- final View phoneNumberContainer = content.findViewById(R.id.phone_number_container);
- final TextView phoneView = (TextView) content.findViewById(R.id.phone_number);
- final String formattedPhoneNumber = getContext().getString(
- R.string.support_phone_international_format,
- new Locale(phone.language).getDisplayLanguage(), phone.number);
- phoneView.setText(formattedPhoneNumber);
- phoneNumberContainer.setOnClickListener(this);
- return builder
- .setView(content)
- .create();
- }
-
- @Override
- public void onClick(View v) {
- final SupportPhone phone = getArguments().getParcelable(EXTRA_PHONE);
- final Activity activity = getActivity();
- final Intent intent = phone.getDialIntent();
- final boolean canDial = !activity.getPackageManager()
- .queryIntentActivities(intent, 0)
- .isEmpty();
- if (canDial) {
- mMetricsFeatureProvider.action(getActivity(),
- MetricsProto.MetricsEvent.ACTION_SUPPORT_DIAL_TOLLED);
- getActivity().startActivity(intent);
- }
- dismiss();
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.DIALOG_SUPPORT_PHONE;
- }
-}
diff --git a/src/com/android/settings/utils/AnnotationSpan.java b/src/com/android/settings/utils/AnnotationSpan.java
new file mode 100644
index 0000000..645351d
--- /dev/null
+++ b/src/com/android/settings/utils/AnnotationSpan.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.utils;
+
+import android.text.Annotation;
+import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
+import android.text.TextPaint;
+import android.text.style.URLSpan;
+import android.view.View;
+
+/**
+ * This class is used to add {@link View.OnClickListener} for the text been wrapped by
+ * annotation.
+ */
+public class AnnotationSpan extends URLSpan {
+ private final View.OnClickListener mClickListener;
+
+ private AnnotationSpan(View.OnClickListener lsn) {
+ super((String) null);
+ mClickListener = lsn;
+ }
+
+ @Override
+ public void onClick(View widget) {
+ if (mClickListener != null) {
+ mClickListener.onClick(widget);
+ }
+ }
+
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setUnderlineText(false);
+ }
+
+ public static CharSequence linkify(CharSequence rawText, LinkInfo... linkInfos) {
+ SpannableString msg = new SpannableString(rawText);
+ Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
+ SpannableStringBuilder builder = new SpannableStringBuilder(msg);
+ for (Annotation annotation : spans) {
+ final String key = annotation.getValue();
+ int start = msg.getSpanStart(annotation);
+ int end = msg.getSpanEnd(annotation);
+ AnnotationSpan link = null;
+ for (LinkInfo linkInfo : linkInfos) {
+ if (linkInfo.annotation.equals(key)) {
+ link = new AnnotationSpan(linkInfo.listener);
+ break;
+ }
+ }
+ if (link != null) {
+ builder.setSpan(link, start, end, msg.getSpanFlags(link));
+ }
+ }
+ return builder;
+ }
+
+ /**
+ * Data class to store the annotation and the click action
+ */
+ public static class LinkInfo {
+ public final String annotation;
+ public final View.OnClickListener listener;
+
+ public LinkInfo(String annotation, View.OnClickListener listener) {
+ this.annotation = annotation;
+ this.listener = listener;
+ }
+ }
+}
diff --git a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
index 146893c..6a831b0 100644
--- a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
+++ b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
@@ -1,3 +1,3 @@
com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
com.android.settings.search.indexing.FakeSettingsFragment
-com.android.settings.security.SecuritySettingsV2
\ No newline at end of file
+com.android.settings.security.SecuritySettings
\ No newline at end of file
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 7ae7c1f..e10fee1 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -30,4 +30,5 @@
<bool name="config_show_wallpaper_attribution">false</bool>
<bool name="config_show_default_home">false</bool>
<bool name="config_show_accessibility_shortcut_preference">false</bool>
+ <bool name="config_show_assist_and_voice_input">false</bool>
</resources>
diff --git a/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java
index 60972ee..1f701c2 100644
--- a/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java
@@ -21,9 +21,12 @@
import static org.robolectric.RuntimeEnvironment.application;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.UserHandle;
+import android.view.View;
+import android.widget.Button;
import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
import com.android.settings.password.ChooseLockPattern.IntentBuilder;
@@ -40,6 +43,7 @@
import org.robolectric.Robolectric;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowAlertDialog;
import org.robolectric.shadows.ShadowPackageManager.ComponentState;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -85,6 +89,19 @@
.isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
+ @Test
+ public void screenLockOptions_shouldBeVisible() {
+ Button button = mActivity.findViewById(R.id.screen_lock_options);
+ assertThat(button).isNotNull();
+ assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
+
+ button.performClick();
+ AlertDialog chooserDialog = ShadowAlertDialog.getLatestAlertDialog();
+ assertThat(chooserDialog).isNotNull();
+ int count = Shadows.shadowOf(chooserDialog).getAdapter().getCount();
+ assertThat(count).named("List items shown").isEqualTo(3);
+ }
+
private ChooseLockPatternFragment findFragment(Activity activity) {
return (ChooseLockPatternFragment)
activity.getFragmentManager().findFragmentById(R.id.main_content);
diff --git a/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java
index 180abbb..eeaba21 100644
--- a/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java
@@ -50,6 +50,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -62,26 +63,33 @@
private static final String TEST_KEY = "test_pref_key";
@Mock
- private Context mContext;
- @Mock
private SearchManager mSearchManager;
@Mock
private PackageManager mPackageManager;
+
+ private Context mContext;
private DefaultAssistPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
mController = new DefaultAssistPreferenceController(mContext, TEST_KEY,
true /* showSetting */);
}
@Test
- public void isAlwaysAvailable() {
+ public void testAssistAndVoiceInput_byDefault_shouldBeShown() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
+ @Config(qualifiers = "mcc999")
+ public void testAssistAndVoiceInput_ifDisabled_shouldNotBeShown() {
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
public void getPrefKey_shouldReturnKey() {
assertThat(mController.getPreferenceKey())
.isEqualTo(TEST_KEY);
@@ -91,7 +99,8 @@
@Config(shadows = {ShadowSecureSettings.class})
public void getDefaultAppInfo_hasDefaultAssist_shouldReturnKey() {
final String flattenKey = "com.android.settings/assist";
- Settings.Secure.putString(null, Settings.Secure.ASSISTANT, flattenKey);
+ Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.ASSISTANT,
+ flattenKey);
DefaultAppInfo appInfo = mController.getDefaultAppInfo();
assertThat(appInfo.getKey()).isEqualTo(flattenKey);
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java
index cda9a22..7ec2c58 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardItemAnimatorTest.java
@@ -17,10 +17,11 @@
package com.android.settings.dashboard;
import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
import android.widget.TextView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
-import com.android.settings.dashboard.SupportItemAdapter.ViewHolder;
import com.android.settingslib.drawer.Tile;
import org.junit.Before;
import org.junit.Test;
@@ -68,4 +69,12 @@
.animateChange(mViewHolder, mViewHolder, 0, 1, 0, 1);
assertThat(hasPendingAnimation).isFalse();
}
+
+ // Sample viewholder to use for test
+ static final class ViewHolder extends RecyclerView.ViewHolder {
+
+ ViewHolder(View itemView) {
+ super(itemView);
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java
deleted file mode 100644
index 3dd5266..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/SupportItemAdapterTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.dashboard;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.content.Intent;
-import android.provider.Settings;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Spinner;
-import android.widget.SpinnerAdapter;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.core.instrumentation.MetricsFeatureProvider;
-import com.android.settings.dashboard.SupportItemAdapter.EscalationData;
-import com.android.settings.overlay.SupportFeatureProvider;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowActivity;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.robolectric.Shadows.shadowOf;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SupportItemAdapterTest {
- private static final String ACCOUNT_TYPE = "com.google";
- private final Account USER_1 = new Account("user1", ACCOUNT_TYPE);
- private final Account USER_2 = new Account("user2", ACCOUNT_TYPE);
- private final Account TWO_ACCOUNTS[] = {USER_1, USER_2};
- private final Account ONE_ACCOUNT[] = {USER_1};
- private final Account ZERO_ACCOUNT[] = {};
-
- private ShadowActivity mShadowActivity;
- private Activity mActivity;
- private SupportItemAdapter mSupportItemAdapter;
- private SupportItemAdapter.ViewHolder mViewHolder;
- @Mock
- private SupportFeatureProvider mSupportFeatureProvider;
- @Mock
- private MetricsFeatureProvider mMetricsFeatureProvider;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mActivity = Robolectric.setupActivity(Activity.class);
- mShadowActivity = shadowOf(mActivity);
-
- final View itemView = LayoutInflater.from(mActivity).inflate(
- R.layout.support_escalation_options, null);
- mViewHolder = new SupportItemAdapter.ViewHolder(itemView);
-
- // Mock this to prevent crash in testing
- when(mSupportFeatureProvider.getAccountLoginIntent()).thenReturn(
- new Intent(Settings.ACTION_ADD_ACCOUNT));
- }
-
- @Test
- public void testBindAccountPicker_TwoAccounts_ShouldHaveTwoAccounts() {
- testBindAccountPickerInner(mViewHolder, TWO_ACCOUNTS);
- }
-
- @Test
- public void testBindAccountPicker_OneAccount_ShouldHaveOneAccount() {
- testBindAccountPickerInner(mViewHolder, ONE_ACCOUNT);
- }
-
- @Test
- public void testOnSpinnerItemClick_AddAccountClicked_AccountLoginIntentInvoked() {
- bindAccountPickerInner(mViewHolder, TWO_ACCOUNTS);
-
- final Spinner spinner = (Spinner) mViewHolder.itemView.findViewById(R.id.account_spinner);
- spinner.setSelection(TWO_ACCOUNTS.length);
-
- Robolectric.flushForegroundThreadScheduler();
-
- verify(mSupportFeatureProvider).getAccountLoginIntent();
- }
-
- @Test
- public void testSetAccount_AccountEmpty_NotCrash() {
- when(mSupportFeatureProvider.getSupportEligibleAccounts(mActivity)).thenReturn(
- ZERO_ACCOUNT);
- mSupportItemAdapter = new SupportItemAdapter(mActivity, null, mSupportFeatureProvider,
- mMetricsFeatureProvider, null);
-
- // Should not crash in this method
- mSupportItemAdapter.setAccounts(ONE_ACCOUNT);
-
- verify(mSupportFeatureProvider).getSupportEligibleAccounts(mActivity);
- }
-
- @Test
- public void testRefreshData_CardUpdatedOnEnteringOrLeavingSupportHours() {
- // pretend we have support right now
- when(mSupportFeatureProvider.isSupportTypeEnabled(any(), anyInt()))
- .thenReturn(true);
- when(mSupportFeatureProvider.isOperatingNow(anyInt())).thenReturn(true);
- when(mSupportFeatureProvider.getSupportEligibleAccounts(any())).thenReturn(ONE_ACCOUNT);
- mSupportItemAdapter = new SupportItemAdapter(mActivity, null, mSupportFeatureProvider,
- mMetricsFeatureProvider, null);
-
- // If this doesn't return escalation data something has gone wrong
- EscalationData data = (EscalationData) mSupportItemAdapter.getSupportData().get(0);
-
- // precondition, support is enabled
- assertThat(data.enabled1).isTrue();
-
- // pretend we support hours are over
- when(mSupportFeatureProvider.isOperatingNow(anyInt())).thenReturn(false);
- mSupportItemAdapter.refreshData();
- data = (EscalationData) mSupportItemAdapter.getSupportData().get(0);
-
- assertThat(data.enabled1).isFalse();
-
- // pretend support hours have started again
- when(mSupportFeatureProvider.isOperatingNow(anyInt())).thenReturn(true);
- mSupportItemAdapter.refreshData();
- data = (EscalationData) mSupportItemAdapter.getSupportData().get(0);
-
- assertThat(data.enabled1).isTrue();
- }
-
- /**
- * Check after {@link SupportItemAdapter#bindAccountPicker(SupportItemAdapter.ViewHolder)} is
- * invoked, whether the spinner in {@paramref viewHolder} has all the data from {@paramref
- * accounts}
- *
- * @param viewHolder holds the view that contains the spinner to test
- * @param accounts holds the accounts info to be showed in spinner.
- */
- private void testBindAccountPickerInner(SupportItemAdapter.ViewHolder viewHolder,
- Account accounts[]) {
- bindAccountPickerInner(viewHolder, accounts);
-
- final Spinner spinner = (Spinner) viewHolder.itemView.findViewById(R.id.account_spinner);
- final SpinnerAdapter adapter = spinner.getAdapter();
-
- // Contains "Add account" option, so should be 'count+1'
- assertThat(adapter.getCount()).isEqualTo(accounts.length + 1);
- for (int i = 0; i < accounts.length; i++) {
- assertThat(adapter.getItem(i)).isEqualTo(accounts[i].name);
- }
- }
-
- /**
- * Create {@link SupportItemAdapter} and bind the account picker view into
- * {@paramref viewholder}
- *
- * @param viewHolder holds the view that contains the spinner to test
- * @param accounts holds the accounts info to be showed in spinner.
- */
- private void bindAccountPickerInner(SupportItemAdapter.ViewHolder viewHolder,
- Account accounts[]) {
- when(mSupportFeatureProvider.getSupportEligibleAccounts(mActivity)).thenReturn(accounts);
- mSupportItemAdapter = new SupportItemAdapter(mActivity, null, mSupportFeatureProvider,
- mMetricsFeatureProvider, null);
-
- mSupportItemAdapter.bindAccountPicker(viewHolder);
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
new file mode 100644
index 0000000..cf892f8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import static com.android.settings.development.BluetoothMaxConnectedAudioDevicesPreferenceController
+ .BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {SettingsShadowSystemProperties.class})
+public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private ListPreference mPreference;
+ private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
+
+ /**
+ * 0: 1 device maximum (Default)
+ * 1: 2 devices maximum
+ * 2: 3 devices maximum
+ * 3: 4 devices maximum
+ * 4: 5 devices maximum
+ */
+ private String[] mListValues;
+ private String[] mListSummaries;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mPreference = new ListPreference(mContext);
+ mListValues = mContext.getResources().getStringArray(
+ R.array.bluetooth_max_connected_audio_devices_values);
+ mListSummaries = mContext.getResources().getStringArray(
+ R.array.bluetooth_max_connected_audio_devices);
+ mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+ mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @After
+ public void teardown() {
+ SettingsShadowSystemProperties.clear();
+ }
+
+ @Test
+ public void onPreferenceChange_setNumberOfDevices() {
+ for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
+ mController.onPreferenceChange(mPreference, mListValues[numberOfDevices]);
+
+ final String currentValue = SystemProperties.get(
+ BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
+
+ assertThat(currentValue).isEqualTo(mListValues[numberOfDevices]);
+ assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
+ assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
+ }
+ }
+
+ @Test
+ public void updateState_NumberOfDevicesUpdated_shouldSetPreference() {
+ for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
+ SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
+ mListValues[numberOfDevices]);
+
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
+ assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
+ }
+ }
+
+ @Test
+ public void updateState_noValueSet_shouldSetDefaultTo1device() {
+ SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "garbage");
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
+ assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
+ mController.onDeveloperOptionsSwitchDisabled();
+
+ assertThat(mPreference.isEnabled()).isFalse();
+ assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
+ assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
+ final String currentValue = SystemProperties.get(
+ BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
+ assertThat(currentValue).isEqualTo(mListValues[0]);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
+ for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
+ mController.onDeveloperOptionsSwitchDisabled();
+ assertThat(mPreference.isEnabled()).isFalse();
+
+ SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
+ mListValues[numberOfDevices]);
+ mController.onDeveloperOptionsSwitchEnabled();
+
+ assertThat(mPreference.isEnabled()).isTrue();
+ assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
+ assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java
index e299fd5..66114aa 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollSuggestionActivityTest.java
@@ -58,7 +58,8 @@
.thenReturn(mDevicePolicyManager);
when(mDevicePolicyManager.getKeyguardDisabledFeatures(any(), anyInt()))
.thenReturn(0);
- when(mContext.getSystemService(FingerprintManager.class)).thenReturn(mFingerprintManager);
+ when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
+ .thenReturn(mFingerprintManager);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java
new file mode 100644
index 0000000..9993a95
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fingerprint;
+
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
+import android.os.UserManager;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class FingerprintProfileStatusPreferenceControllerTest {
+
+ private static final int FAKE_PROFILE_USER_ID = 1234;
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private FingerprintManager mFingerprintManager;
+ @Mock
+ private UserManager mUm;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
+ private FingerprintProfileStatusPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
+ ShadowApplication.getInstance().setSystemService(Context.FINGERPRINT_SERVICE,
+ mFingerprintManager);
+ ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
+ .thenReturn(mLockPatternUtils);
+ when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {1234});
+ mController = new FingerprintProfileStatusPreferenceController(mContext);
+ }
+
+ @Test
+ public void getUserId_shouldReturnProfileId() {
+ assertThat(mController.getUserId()).isEqualTo(FAKE_PROFILE_USER_ID);
+ }
+
+ @Test
+ public void isUserSupported_separateChallengeAllowed_true() {
+ when(mLockPatternUtils.isSeparateProfileChallengeAllowed(anyInt())).thenReturn(true);
+ assertThat(mController.isUserSupported()).isTrue();
+ }
+
+ @Test
+ public void isUserSupported_separateChallengeNotAllowed_false() {
+ when(mLockPatternUtils.isSeparateProfileChallengeAllowed(anyInt())).thenReturn(false);
+
+ assertThat(mController.isUserSupported()).isFalse();
+ }
+
+ @Test
+ public void getAvailabilityStatus_userNotSupported_DISABLED() {
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+ when(mLockPatternUtils.isSeparateProfileChallengeAllowed(anyInt())).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintStatusPreferenceControllerTest.java
new file mode 100644
index 0000000..ab53382
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintStatusPreferenceControllerTest.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fingerprint;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.Fingerprint;
+import android.hardware.fingerprint.FingerprintManager;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.Arrays;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class FingerprintStatusPreferenceControllerTest {
+
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private FingerprintManager mFingerprintManager;
+ @Mock
+ private UserManager mUm;
+ @Mock
+ private PackageManager mPackageManager;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
+ private FingerprintStatusPreferenceController mController;
+ private Preference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
+ ShadowApplication.getInstance().setSystemService(Context.FINGERPRINT_SERVICE,
+ mFingerprintManager);
+ ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
+ mPreference = new Preference(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
+ .thenReturn(mLockPatternUtils);
+ when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {1234});
+ mController = new FingerprintStatusPreferenceController(mContext);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noFingerprintManger_DISABLED() {
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hasFingerprintManger_AVAILABLE() {
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void updateState_notSupported_shouldDoNothing() {
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
+
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void updateState_noFingerprint_shouldShowDefaultSummary() {
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.security_settings_fingerprint_preference_summary_none));
+ assertThat(mPreference.isVisible()).isTrue();
+ assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
+ }
+
+ @Test
+ public void updateState_hasFingerprint_shouldShowSummary() {
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+ when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
+ .thenReturn(Arrays.asList(mock(Fingerprint.class)));
+
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.security_settings_fingerprint_preference_summary, 1, 1));
+ assertThat(mPreference.isVisible()).isTrue();
+ assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
index bc5b1d7..45448a9 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
@@ -401,18 +401,6 @@
}
@Test
- public void testNonIndexableKeys_MatchPreferenceKeys() {
- final Context context = RuntimeEnvironment.application;
- final List<String> niks = PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER
- .getNonIndexableKeys(context);
-
- final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context,
- R.xml.power_usage_summary);
-
- assertThat(keys).containsAllIn(niks);
- }
-
- @Test
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
final Context context = RuntimeEnvironment.application;
final PowerUsageSummary fragment = new PowerUsageSummary();
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index f3cc2ca..86fd267 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -59,8 +59,7 @@
MockitoAnnotations.initMocks(this);
mController = new SwipeToNotificationPreferenceController(mContext, null, KEY_SWIPE_DOWN);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
- // Explicit casting to object due to MockitoCast bug
- when((Object) mContext.getSystemService(FingerprintManager.class))
+ when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
.thenReturn(mFingerprintManager);
}
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
index f1d7a73..bba689b 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
@@ -50,7 +50,6 @@
private PrivateDnsModeDialogFragment mFragment;
private Button mSaveButton;
-
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
index 28be616..cd5fcc2 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
@@ -135,11 +135,9 @@
fragment.onLockTypeSelected(ScreenLockType.PATTERN);
ShadowActivity shadowActivity = shadowOf(activity);
- IntentForResult chooseLockIntent = shadowActivity.getNextStartedActivityForResult();
- assertThat(chooseLockIntent).isNotNull();
- assertThat(chooseLockIntent.requestCode)
- .isEqualTo(SetupChooseLockPasswordFragment.REQUEST_SCREEN_LOCK_OPTIONS);
- assertThat(chooseLockIntent.intent.getStringExtra("foo")).named("Foo extra")
+ final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
+ assertThat(nextStartedActivity).isNotNull();
+ assertThat(nextStartedActivity.getStringExtra("foo")).named("Foo extra")
.isEqualTo("bar");
}
diff --git a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
new file mode 100644
index 0000000..7a5a9fa
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class LockUnificationPreferenceControllerTest {
+
+ private static final int FAKE_PROFILE_USER_ID = 1234;
+
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private UserManager mUm;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private SecuritySettingsV2 mHost;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
+ private LockUnificationPreferenceController mController;
+ private Preference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
+ when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {FAKE_PROFILE_USER_ID});
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
+ .thenReturn(mLockPatternUtils);
+
+ mController = new LockUnificationPreferenceController(mContext, mHost);
+ when(mScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mPreference = new Preference(mContext);
+ }
+
+ @Test
+ public void isAvailable_noProfile_false() {
+ ReflectionHelpers.setField(mController, "mProfileChallengeUserId", UserHandle.USER_NULL);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_separateChallengeNotAllowed_false() {
+ when(mLockPatternUtils.isSeparateProfileChallengeAllowed(anyInt())).thenReturn(false);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_separateChallengeAllowed_true() {
+ when(mLockPatternUtils.isSeparateProfileChallengeAllowed(anyInt())).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
index 81e1481..3171c3d 100644
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
@@ -23,13 +23,10 @@
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.Context;
-import android.content.pm.PackageManager;
-import android.hardware.fingerprint.FingerprintManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager.EnforcingUser;
@@ -87,54 +84,6 @@
}
@Test
- public void testSummaryProvider_notListening() {
- mSummaryProvider.setListening(false);
-
- verifyNoMoreInteractions(mSummaryLoader);
- }
-
- @Test
- public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
- final FingerprintManager fpm = mock(FingerprintManager.class);
- when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
- .thenReturn(true);
-
- // Cast to Object to workaround a robolectric casting bug
- when((Object) mContext.getSystemService(FingerprintManager.class)).thenReturn(fpm);
- when(fpm.isHardwareDetected()).thenReturn(true);
-
- mSummaryProvider.setListening(true);
-
- verify(mContext).getString(R.string.security_dashboard_summary);
- }
-
- @Test
- public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
- final FingerprintManager fpm = mock(FingerprintManager.class);
- when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
- .thenReturn(false);
-
- mSummaryProvider.setListening(true);
-
- verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
- }
-
- @Test
- public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
- final FingerprintManager fpm = mock(FingerprintManager.class);
- when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
- .thenReturn(true);
-
- // Cast to Object to workaround a robolectric casting bug
- when((Object) mContext.getSystemService(FingerprintManager.class)).thenReturn(fpm);
- when(fpm.isHardwareDetected()).thenReturn(false);
-
- mSummaryProvider.setListening(true);
-
- verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
- }
-
- @Test
public void testInitTrustAgentPreference_secure_shouldSetSummaryToNumberOfTrustAgent() {
final Preference preference = mock(Preference.class);
final PreferenceScreen screen = mock(PreferenceScreen.class);
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java
new file mode 100644
index 0000000..f77903b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class SecuritySettingsV2Test {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private SummaryLoader mSummaryLoader;
+ @Mock
+ private FingerprintManager mFingerprintManager;
+ private SecuritySettings.SummaryProvider mSummaryProvider;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
+ .thenReturn(mFingerprintManager);
+
+ mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
+ }
+
+ @Test
+ public void testSummaryProvider_notListening() {
+ mSummaryProvider.setListening(false);
+
+ verifyNoMoreInteractions(mSummaryLoader);
+ }
+
+ @Test
+ public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
+ when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+ .thenReturn(true);
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+
+ mSummaryProvider.setListening(true);
+
+ verify(mContext).getString(R.string.security_dashboard_summary);
+ }
+
+ @Test
+ public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
+ when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+ .thenReturn(false);
+
+ mSummaryProvider.setListening(true);
+
+ verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+ }
+
+ @Test
+ public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
+ when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+ .thenReturn(true);
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
+
+ mSummaryProvider.setListening(true);
+
+ verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java
new file mode 100644
index 0000000..dd98372
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
+import android.os.UserManager;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class VisiblePatternProfilePreferenceControllerTest {
+
+ private static final int FAKE_PROFILE_USER_ID = 1234;
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private FingerprintManager mFingerprintManager;
+ @Mock
+ private UserManager mUm;
+
+ private Lifecycle mLifecycle;
+ private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
+ private VisiblePatternProfilePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
+ ShadowApplication.getInstance().setSystemService(Context.FINGERPRINT_SERVICE,
+ mFingerprintManager);
+ ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
+ .thenReturn(mLockPatternUtils);
+ when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {FAKE_PROFILE_USER_ID});
+
+ mLifecycle = new Lifecycle(() -> mLifecycle);
+ mController = new VisiblePatternProfilePreferenceController(mContext, mLifecycle);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notSecure_DISABLED() {
+ when(mLockPatternUtils.isSecure(FAKE_PROFILE_USER_ID)).thenReturn(false);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(FAKE_PROFILE_USER_ID))
+ .thenReturn(PASSWORD_QUALITY_UNSPECIFIED);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getAvailabilityStatus_secureWithPassword_DISABLED() {
+ when(mLockPatternUtils.isSecure(FAKE_PROFILE_USER_ID)).thenReturn(true);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(FAKE_PROFILE_USER_ID))
+ .thenReturn(PASSWORD_QUALITY_ALPHABETIC);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getAvailabilityStatus_secureWithPattern_AVAILABLE() {
+ when(mLockPatternUtils.isSecure(FAKE_PROFILE_USER_ID)).thenReturn(true);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(FAKE_PROFILE_USER_ID))
+ .thenReturn(PASSWORD_QUALITY_SOMETHING);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
new file mode 100644
index 0000000..671807b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security.screenlock;
+
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
+import static android.arch.lifecycle.Lifecycle.Event.ON_RESUME;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class LockScreenPreferenceControllerTest {
+
+ private static final int FAKE_PROFILE_USER_ID = 1234;
+
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private UserManager mUm;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private Lifecycle mLifecycle;
+ private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
+ private LockScreenPreferenceController mController;
+ private Preference mPreference;
+
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
+ .thenReturn(mLockPatternUtils);
+ when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {FAKE_PROFILE_USER_ID});
+ mPreference = new Preference(mContext);
+ when(mScreen.findPreference(anyString())).thenReturn(mPreference);
+ mLifecycle = new Lifecycle(() -> mLifecycle);
+ mController = new LockScreenPreferenceController(mContext, mLifecycle);
+
+ }
+
+ @Test
+ public void getAvailabilityStatus_notSecure_lockscreenDisabled_DISABLED() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
+ when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notSecure_lockscreenEnabled_AVAILABLE() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
+ when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_secure_hasLockScreen_AVAILABLE() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
+ .thenReturn(PASSWORD_QUALITY_ALPHABETIC);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_secure_noLockScreen_DISABLED() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
+ .thenReturn(PASSWORD_QUALITY_UNSPECIFIED);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void onResume_available_shouldShow() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
+ .thenReturn(PASSWORD_QUALITY_ALPHABETIC);
+
+ mController.displayPreference(mScreen);
+ mLifecycle.handleLifecycleEvent(ON_RESUME);
+
+ assertThat(mPreference.isVisible()).isTrue();
+ }
+
+ @Test
+ public void onResume_unavailable_shouldHide() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
+ when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
+ .thenReturn(PASSWORD_QUALITY_UNSPECIFIED);
+
+ mController.displayPreference(mScreen);
+ mLifecycle.handleLifecycleEvent(ON_RESUME);
+
+ assertThat(mPreference.isVisible()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
index a97780b..6913c0c 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
@@ -23,6 +23,7 @@
.PREF_KEY_TRUST_AGENT;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -127,6 +128,6 @@
mController.displayPreference(mScreen);
mController.onResume();
- verify(mCategory).addPreference(any(Preference.class));
+ verify(mCategory, atLeastOnce()).addPreference(any(Preference.class));
}
}
diff --git a/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java b/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java
deleted file mode 100644
index 6aebe36..0000000
--- a/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.android.settings.support;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.robolectric.shadow.api.Shadow.directlyOn;
-
-import android.accounts.Account;
-import android.annotation.NonNull;
-import android.annotation.StringRes;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.Resources.NotFoundException;
-import android.text.Spannable;
-import android.text.style.URLSpan;
-import android.widget.CheckBox;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.core.instrumentation.MetricsFeatureProvider;
-import com.android.settings.overlay.SupportFeatureProvider;
-import com.android.settings.overlay.SupportFeatureProvider.SupportType;
-import com.android.settings.support.SupportDisclaimerDialogFragmentTest.SupportDisclaimerShadowResources;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.util.FragmentTestUtil;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
- shadows = {SupportDisclaimerShadowResources.class})
-public class SupportDisclaimerDialogFragmentTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- Context mContext;
- private FakeFeatureFactory mFakeFeatureFactory;
- private MetricsFeatureProvider mMetricsFeatureProvider;
- private SupportFeatureProvider mSupportFeatureProvider;
-
- private final Account mFakeAccount = new Account("user1", "fake_type");
-
- private static final int FAKE_RES_ID = -1000;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
- mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
- mSupportFeatureProvider = mFakeFeatureFactory.getSupportFeatureProvider(mContext);
- when(mSupportFeatureProvider.getDisclaimerStringResId())
- .thenReturn(FAKE_RES_ID);
- }
-
- @Test
- public void onClick_DoNotShowCheckedLogsAction() {
- SupportDisclaimerDialogFragment fragment =
- SupportDisclaimerDialogFragment.newInstance(mFakeAccount, SupportType.CHAT);
- FragmentTestUtil.startFragment(fragment);
-
- // pretend the user selected to skip the dialog in the future
- CheckBox doNotShow = (CheckBox) fragment.getDialog()
- .findViewById(R.id.support_disclaimer_do_not_show_again);
- doNotShow.setChecked(true);
-
- // verify we logged the action
- fragment.onClick(fragment.getDialog(), Dialog.BUTTON_POSITIVE);
- verify(mMetricsFeatureProvider, times(1)).action(any(),
- eq(MetricsProto.MetricsEvent.ACTION_SKIP_DISCLAIMER_SELECTED));
- }
-
- @Test
- public void onClick_DoNotShowUncheckedDoesNotLogAction() {
- SupportDisclaimerDialogFragment fragment =
- SupportDisclaimerDialogFragment.newInstance(mFakeAccount, SupportType.CHAT);
- FragmentTestUtil.startFragment(fragment);
-
- // pretend the user selected to skip the dialog in the future
- CheckBox doNotShow = (CheckBox) fragment.getDialog()
- .findViewById(R.id.support_disclaimer_do_not_show_again);
- doNotShow.setChecked(false);
-
- // verify we logged the action
- fragment.onClick(fragment.getDialog(), Dialog.BUTTON_POSITIVE);
- verify(mMetricsFeatureProvider, never()).action(any(),
- eq(MetricsProto.MetricsEvent.ACTION_SKIP_DISCLAIMER_SELECTED));
- }
-
- @Implements(Resources.class)
- public static class SupportDisclaimerShadowResources extends SettingsShadowResources {
-
- @Implementation
- @NonNull public CharSequence getText(@StringRes int id) throws NotFoundException {
- if (id == FAKE_RES_ID) {
- Spannable text = Spannable.Factory.getInstance()
- .newSpannable("string with url");
- text.setSpan(new URLSpan("https://google.com"), 0, 1,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- return text;
- }
- return directlyOn(realResources, Resources.class).getText(id);
- }
- }
-
-}