Merge "Support Bluetooth activation in BluetoothDevicesSlice"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3933b9c..871f609 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2973,11 +2973,16 @@
android:label="@string/settings_panel_title"
android:theme="@style/Theme.BottomDialog"
android:excludeFromRecents="true"
- android:launchMode="singleTask">
+ android:launchMode="singleTask"
+ android:exported="true">
<intent-filter>
- <action android:name="android.settings.SETTINGSPANEL" />
+ <action android:name="android.settings.panel.action.INTERNET_CONNECTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
+ <intent-filter>
+ <action android:name="android.settings.panel.action.VOLUME" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<provider android:name=".slices.SettingsSliceProvider"
diff --git a/OWNERS b/OWNERS
index 37124b2..bed20a9 100644
--- a/OWNERS
+++ b/OWNERS
@@ -8,6 +8,7 @@
dhnishi@google.com
dling@google.com
edgarwang@google.com
+emilychuang@google.com
jackqdyulei@google.com
mfritze@google.com
rafftsai@google.com
@@ -18,4 +19,4 @@
miket@google.com
# Exempt resource files (because they are in a flat directory and too hard to manage via OWNERS)
-per-file *.xml=*
\ No newline at end of file
+per-file *.xml=*
diff --git a/res/drawable/ic_friction_lock_closed.xml b/res/drawable/ic_friction_lock_closed.xml
index dab8c91..56256a9 100644
--- a/res/drawable/ic_friction_lock_closed.xml
+++ b/res/drawable/ic_friction_lock_closed.xml
@@ -21,5 +21,5 @@
android:height="18dp">
<path
android:pathData="M36 16l-2 0 0 -4C34 6.48 29.52 2 24 2 18.48 2 14 6.48 14 12l0 4 -2 0c-2.21 0 -4 1.79 -4 4l0 20c0 2.21 1.79 4 4 4l24 0c2.21 0 4 -1.79 4 -4l0 -20c0 -2.21 -1.79 -4 -4 -4zM24 34c-2.21 0 -4 -1.79 -4 -4 0 -2.21 1.79 -4 4 -4 2.21 0 4 1.79 4 4 0 2.21 -1.79 4 -4 4zm6.2 -18l-12.4 0 0 -4c0 -3.42 2.78 -6.2 6.2 -6.2 3.42 0 6.2 2.78 6.2 6.2l0 4z"
- android:fillColor="?attr/frictionIconColor" />
+ android:fillColor="?android:attr/colorControlNormal" />
</vector>
diff --git a/res/drawable/ic_friction_money.xml b/res/drawable/ic_friction_money.xml
index b170921..fb1904a 100644
--- a/res/drawable/ic_friction_money.xml
+++ b/res/drawable/ic_friction_money.xml
@@ -20,7 +20,7 @@
android:width="18dp"
android:height="18dp">
- <path android:fillColor="?attr/frictionIconColor"
+ <path android:fillColor="?android:attr/colorControlNormal"
android:pathData="M9.56 8.1c-1.6-.51-2.66-.71-2.66-1.88 0-.83 .72 -1.62 2.1-1.62 1.59 0 2.1 .88
2.1 1.94H13c0-1.79-1.17-3.09-3-3.44V1H8v2.11c-1.58 .32 -3 1.37-3 3.12 0 2.25
1.78 2.8 4 3.52 1.88 .61 2.25 1.04 2.25 2.09 0 .9-.67 1.56-2.25 1.56-1.2
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
index 1187c20..97a4de2 100644
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ b/res/layout-land/fingerprint_enroll_finish.xml
@@ -70,41 +70,6 @@
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <com.google.android.setupdesign.view.ButtonBarLayout
- style="@style/SuwGlifButtonBar.Stackable"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:clipChildren="false"
- android:clipToPadding="false">
-
- <Button
- style="@style/SetupWizardButton.Negative"
- android:id="@+id/add_another_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="8dp"
- android:text="@string/fingerprint_enroll_button_add" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- style="@style/SetupWizardButton.Positive"
- android:id="@+id/next_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_fingerprint_enroll_done" />
-
- </com.google.android.setupdesign.view.ButtonBarLayout>
-
</LinearLayout>
<com.google.android.setupdesign.view.FillContentLayout
diff --git a/res/layout/face_enroll_accessibility_toggle.xml b/res/layout/face_enroll_accessibility_toggle.xml
new file mode 100644
index 0000000..4dda2a7
--- /dev/null
+++ b/res/layout/face_enroll_accessibility_toggle.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingEnd="16dp"
+ android:paddingStart="16dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/title"/>
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ <View
+ android:layout_width="1dp"
+ android:layout_height="match_parent"
+ android:background="?android:attr/listDivider" />
+
+ <Switch
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/toggle"
+ android:checked="true"/>
+
+</LinearLayout>
diff --git a/res/layout/face_enroll_enrolling.xml b/res/layout/face_enroll_enrolling.xml
index e596ff9..7aef9b6 100644
--- a/res/layout/face_enroll_enrolling.xml
+++ b/res/layout/face_enroll_enrolling.xml
@@ -21,8 +21,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- style="?attr/face_layout_theme"
- app:sucFooter="@layout/face_enroll_enrolling_footer">
+ style="?attr/face_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/face_enroll_enrolling_footer.xml b/res/layout/face_enroll_enrolling_footer.xml
deleted file mode 100644
index e3c5872..0000000
--- a/res/layout/face_enroll_enrolling_footer.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2018 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- style="@style/SuwGlifButton.Secondary"
- android:id="@+id/skip_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_enrolling_skip" />
-
-</LinearLayout>
diff --git a/res/layout/face_enroll_finish.xml b/res/layout/face_enroll_finish.xml
index 6b3e6ab..df46098 100644
--- a/res/layout/face_enroll_finish.xml
+++ b/res/layout/face_enroll_finish.xml
@@ -21,8 +21,7 @@
android:id="@+id/setup_wizard_layout"
style="?attr/face_layout_theme"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/face_enroll_finish_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/face_enroll_finish_footer.xml b/res/layout/face_enroll_finish_footer.xml
deleted file mode 100644
index b33cde7..0000000
--- a/res/layout/face_enroll_finish_footer.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2018 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<com.google.android.setupdesign.view.ButtonBarLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar.Stackable"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- style="@style/SuwGlifButton.Primary"
- android:id="@+id/next_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_done" />
-
-</com.google.android.setupdesign.view.ButtonBarLayout>
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index 7a5c172..df3cf72 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -18,11 +18,11 @@
<com.google.android.setupdesign.GlifLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:FaceEnrollAccessibilitySwitch="http://schemas.android.com/apk/res/com.android.settings"
style="?attr/face_layout_theme"
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/face_enroll_introduction_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
@@ -59,6 +59,41 @@
</com.google.android.setupdesign.view.FillContentLayout>
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ <Button
+ android:id="@+id/accessibility_button"
+ style="@style/SuwGlifButton.Secondary"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_accessibility" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:id="@+id/accessibility_layout"
+ android:orientation="vertical"
+ android:visibility="invisible">
+
+ <com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
+ android:id="@+id/toggle_diversity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_diversity"/>
+
+ <com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
+ android:id="@+id/toggle_vision"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_vision"/>
+
+ </LinearLayout>
+ </FrameLayout>
+
</LinearLayout>
</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/face_enroll_introduction_footer.xml b/res/layout/face_enroll_introduction_footer.xml
deleted file mode 100644
index 15993f0..0000000
--- a/res/layout/face_enroll_introduction_footer.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2018 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<com.google.android.setupdesign.view.ButtonBarLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar.Stackable"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/face_cancel_button"
- style="@style/SuwGlifButton.Secondary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_introduction_cancel" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/face_next_button"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/wizard_next" />
-
-</com.google.android.setupdesign.view.ButtonBarLayout>
diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml
index 5a2b60f..6ca3fdc 100644
--- a/res/layout/fingerprint_enroll_enrolling_base.xml
+++ b/res/layout/fingerprint_enroll_enrolling_base.xml
@@ -21,8 +21,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- style="?attr/fingerprint_layout_theme"
- app:sucFooter="@layout/fingerprint_enroll_enrolling_base_footer">
+ style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/fingerprint_enroll_enrolling_base_footer.xml b/res/layout/fingerprint_enroll_enrolling_base_footer.xml
deleted file mode 100644
index b4ed37e..0000000
--- a/res/layout/fingerprint_enroll_enrolling_base_footer.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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.
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- style="@style/SuwGlifButton.Secondary"
- android:id="@+id/skip_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_fingerprint_enroll_enrolling_skip" />
-
-</LinearLayout>
diff --git a/res/layout/fingerprint_enroll_find_sensor_base.xml b/res/layout/fingerprint_enroll_find_sensor_base.xml
index 18941a2..56d3ea4 100644
--- a/res/layout/fingerprint_enroll_find_sensor_base.xml
+++ b/res/layout/fingerprint_enroll_find_sensor_base.xml
@@ -21,8 +21,7 @@
android:id="@+id/setup_wizard_layout"
style="?attr/fingerprint_layout_theme"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/fingerprint_enroll_find_sensor_base_footer">
+ android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/fingerprint_enroll_find_sensor_base_footer.xml b/res/layout/fingerprint_enroll_find_sensor_base_footer.xml
deleted file mode 100644
index e93fae9..0000000
--- a/res/layout/fingerprint_enroll_find_sensor_base_footer.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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.
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- style="@style/SuwGlifButton.Secondary"
- android:id="@+id/skip_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/skip_label" />
-
-</LinearLayout>
diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml
index 5224dab..7120d90 100644
--- a/res/layout/fingerprint_enroll_finish_base.xml
+++ b/res/layout/fingerprint_enroll_finish_base.xml
@@ -21,8 +21,7 @@
android:id="@+id/setup_wizard_layout"
style="?attr/fingerprint_layout_theme"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/fingerprint_enroll_finish_base_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/fingerprint_enroll_finish_base_footer.xml b/res/layout/fingerprint_enroll_finish_base_footer.xml
deleted file mode 100644
index 91164bd..0000000
--- a/res/layout/fingerprint_enroll_finish_base_footer.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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.
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<com.google.android.setupdesign.view.ButtonBarLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar.Stackable"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- style="@style/SuwGlifButton.Secondary"
- android:id="@+id/add_another_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/fingerprint_enroll_button_add" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- style="@style/SuwGlifButton.Primary"
- android:id="@+id/next_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_fingerprint_enroll_done" />
-
-</com.google.android.setupdesign.view.ButtonBarLayout>
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 701d94a..adb46e5 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -21,8 +21,7 @@
style="?attr/fingerprint_layout_theme"
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/fingerprint_enroll_introduction_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/fingerprint_enroll_introduction_footer.xml b/res/layout/fingerprint_enroll_introduction_footer.xml
deleted file mode 100644
index 47d7657..0000000
--- a/res/layout/fingerprint_enroll_introduction_footer.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<com.google.android.setupdesign.view.ButtonBarLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar.Stackable"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/fingerprint_cancel_button"
- style="@style/SuwGlifButton.Secondary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_fingerprint_enroll_introduction_cancel" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/fingerprint_next_button"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/wizard_next" />
-
-</com.google.android.setupdesign.view.ButtonBarLayout>
diff --git a/res/layout/homepage_dismissal_view.xml b/res/layout/homepage_dismissal_view.xml
new file mode 100644
index 0000000..e60b375
--- /dev/null
+++ b/res/layout/homepage_dismissal_view.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/dismissal_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="@dimen/homepage_card_padding_start"
+ android:layout_marginTop="@dimen/homepage_card_padding_start"
+ android:text="@string/contextual_card_dismiss_confirm_message"
+ android:textAppearance="@style/TextAppearance.ContextualCardDismissalText"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="bottom|end">
+
+ <Button
+ android:id="@+id/keep"
+ style="@style/ContextualCardDismissalButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/contextual_card_dismiss_keep"/>
+
+ <Button
+ android:id="@+id/remove"
+ style="@style/ContextualCardDismissalButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/contextual_card_dismiss_remove"/>
+
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/homepage_slice_half_tile.xml b/res/layout/homepage_slice_half_tile.xml
new file mode 100644
index 0000000..7de9eb6
--- /dev/null
+++ b/res/layout/homepage_slice_half_tile.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<com.google.android.material.card.MaterialCardView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ContextualCardStyle">
+
+ <ViewFlipper
+ android:id="@+id/view_flipper"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="@dimen/homepage_card_padding_start"
+ android:paddingEnd="@dimen/homepage_card_padding_end"
+ android:paddingTop="@dimen/homepage_half_card_padding_top"
+ android:paddingBottom="@dimen/homepage_half_card_padding_bottom"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@android:id/icon"
+ android:layout_width="@dimen/homepage_card_icon_size"
+ android:layout_height="@dimen/homepage_card_icon_size"
+ android:tint="?android:attr/colorAccent"/>
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:maxLines="2"
+ android:minLines="1"
+ android:ellipsize="end"
+ android:layout_marginTop="@dimen/homepage_half_card_title_margin_top"
+ android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
+
+ </LinearLayout>
+
+ <!--dismissal view-->
+ <include layout="@layout/homepage_dismissal_view"/>
+
+ </ViewFlipper>
+</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 9165abc..9fa7d61 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -22,7 +22,7 @@
style="@style/ContextualCardStyle">
<ViewFlipper
- android:id="@+id/viewFlipper"
+ android:id="@+id/view_flipper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -34,40 +34,7 @@
android:paddingEnd="@dimen/homepage_card_padding_end"/>
<!--dismissal view-->
- <LinearLayout
- android:id="@+id/dismissal_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ <include layout="@layout/homepage_dismissal_view"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/homepage_card_padding_start"
- android:layout_marginTop="@dimen/homepage_card_padding_start"
- android:text="@string/contextual_card_dismiss_confirm_message"
- style="@style/TextAppearance.ContextualCardDismissalText"/>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="bottom|end">
-
- <Button
- android:id="@+id/keep"
- style="@style/ContextualCardDismissalButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/contextual_card_dismiss_keep"/>
-
- <Button
- android:id="@+id/remove"
- style="@style/ContextualCardDismissalButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/contextual_card_dismiss_remove"/>
-
- </LinearLayout>
- </LinearLayout>
</ViewFlipper>
</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/res/layout/panel_layout.xml b/res/layout/panel_layout.xml
index a6f62a4..c466ce8 100644
--- a/res/layout/panel_layout.xml
+++ b/res/layout/panel_layout.xml
@@ -22,7 +22,7 @@
android:orientation="vertical">
<TextView
- android:id="@+id/title"
+ android:id="@+id/panel_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
diff --git a/res/layout/storage_wizard_footer.xml b/res/layout/storage_wizard_footer.xml
deleted file mode 100644
index a4cda18..0000000
--- a/res/layout/storage_wizard_footer.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/storage_back_button"
- style="@style/SuwGlifButton.Secondary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="onNavigateBack"
- android:visibility="gone"
- android:text="@string/wizard_back" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/storage_next_button"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="onNavigateNext"
- android:visibility="gone"
- android:text="@string/wizard_next" />
-
-</LinearLayout>
diff --git a/res/layout/storage_wizard_generic.xml b/res/layout/storage_wizard_generic.xml
index 77aff9c..0e7c1fd 100644
--- a/res/layout/storage_wizard_generic.xml
+++ b/res/layout/storage_wizard_generic.xml
@@ -19,8 +19,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/storage_wizard_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/storage_wizard_init.xml b/res/layout/storage_wizard_init.xml
index 3b7a5de..73af8da 100644
--- a/res/layout/storage_wizard_init.xml
+++ b/res/layout/storage_wizard_init.xml
@@ -19,8 +19,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/storage_wizard_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/storage_wizard_navigation.xml b/res/layout/storage_wizard_navigation.xml
deleted file mode 100644
index 94f9baf..0000000
--- a/res/layout/storage_wizard_navigation.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/suw_layout_navigation_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/suw_navbar_back"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:visibility="gone" />
-
- <View
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/suw_navbar_more"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:visibility="gone" />
-
- <Button
- android:id="@+id/suw_navbar_next"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginBottom="16dp"
- android:layout_marginEnd="16dp"
- android:text="@string/wizard_next"
- android:textColor="@android:color/white"
- android:backgroundTint="@color/storage_wizard_button" />
-
-</LinearLayout>
diff --git a/res/layout/storage_wizard_progress.xml b/res/layout/storage_wizard_progress.xml
index e1d685b..a68750f 100644
--- a/res/layout/storage_wizard_progress.xml
+++ b/res/layout/storage_wizard_progress.xml
@@ -19,8 +19,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/storage_wizard_footer">
+ android:layout_height="match_parent">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/storage_wizard_ready.xml b/res/layout/storage_wizard_ready.xml
deleted file mode 100644
index e947758..0000000
--- a/res/layout/storage_wizard_ready.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-
-<com.google.android.setupdesign.GlifLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/setup_wizard_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/storage_wizard_footer">
-
- <LinearLayout
- style="@style/SuwContentFrame"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/storage_wizard_ready_body"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
- android:textColor="?android:attr/textColorPrimary" />
-
- </LinearLayout>
-
-</com.google.android.setupdesign.GlifLayout>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index f95809e..eb5b99a 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -219,7 +219,7 @@
</string-array>
<!-- Values for security type for wireless tether -->
- <string-array name="wifi_tether_security_values">
+ <string-array name="wifi_tether_security_values" translatable="false">
<!-- Do not translate. -->
<item>4</item>
<!-- Do not translate. -->
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 383506d..a88d6f6 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -146,6 +146,11 @@
<attr name="thickness" format="dimension" />
</declare-styleable>
+ <!-- For Face enroll accessibility toggle -->
+ <declare-styleable name="FaceEnrollAccessibilityToggle">
+ <attr name="messageText" format="reference" />
+ </declare-styleable>
+
<!-- For TwoStatesButtonPreference -->
<declare-styleable name="TwoStateButtonPreference">
<attr name="textOn" format="reference" />
@@ -163,6 +168,4 @@
<attr name="ic_menu_moreoverflow" format="reference" />
<attr name="side_margin" format="reference|dimension" />
<attr name="wifi_signal_color" format="reference" />
-
- <attr name="frictionIconColor" format="reference|color" />
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a6c6c37..a109d57 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -329,6 +329,9 @@
<dimen name="homepage_card_side_margin">4dp</dimen>
<dimen name="homepage_card_padding_start">16dp</dimen>
<dimen name="homepage_card_padding_end">16dp</dimen>
+ <dimen name="homepage_half_card_padding_top">12dp</dimen>
+ <dimen name="homepage_half_card_padding_bottom">16dp</dimen>
+ <dimen name="homepage_half_card_title_margin_top">12dp</dimen>
<!-- Horizontal divider size and margin -->
<dimen name="horizontal_divider_margin_top">4dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d07cc53..da05a41 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -877,6 +877,12 @@
<string name="security_settings_face_preference_summary_none">Tap to set up face authentication</string>
<!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=32] -->
<string name="security_settings_face_preference_title">Face authentication</string>
+ <!-- Button shown which shows accessibility toggles for face enrollment when clicked. [CHAR LIMIT=32] -->
+ <string name="security_settings_face_enroll_introduction_accessibility">Use accessibility setup</string>
+ <!-- Message shown for a toggle which when disabled, allows the user to enroll using a simpler flow for accessibility [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_accessibility_diversity"></string>
+ <!-- Message shown for a toggle which when disabled, allows the user to enroll using a simpler flow for accessibility [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_accessibility_vision"></string>
<!-- Button text to cancel enrollment from the introduction [CHAR LIMIT=22] -->
<string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index f22d111..6b05a7c 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -37,7 +37,6 @@
<item name="wifi_signal">@drawable/wifi_signal</item>
<item name="wifi_signal_color">?android:attr/colorAccent</item>
<item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="frictionIconColor">?android:colorControlNormal</item>
<item name="side_margin">@dimen/settings_side_margin</item>
<item name="suwListItemIconColor">?android:attr/colorAccent</item>
@@ -187,7 +186,7 @@
<item name="preferenceTheme">@style/PreferenceTheme</item>
<!-- action bar, needed for search bar icon tinting -->
- <item name="android:actionBarTheme">@*android:style/ThemeOverlay.DeviceDefault.ActionBar.Accent</item>
+ <item name="android:actionBarTheme">@*android:style/ThemeOverlay.DeviceDefault.ActionBar</item>
<!-- For battery status icons in -->
<item name="batteryGoodColor">@color/battery_good_color_light</item>
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index cc914ad..c6eb3e7 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -17,7 +17,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="mobile_network_pref_screen"
- android:title="@string/network_settings_title"
settings:initialExpandedChildrenCount="4">
<Preference
diff --git a/src/com/android/settings/ManualDisplayActivity.java b/src/com/android/settings/ManualDisplayActivity.java
index 8be4fee..8effc7b 100644
--- a/src/com/android/settings/ManualDisplayActivity.java
+++ b/src/com/android/settings/ManualDisplayActivity.java
@@ -22,7 +22,6 @@
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
-import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -35,8 +34,7 @@
public class ManualDisplayActivity extends Activity {
private static final String TAG = "SettingsManualActivity";
- private static final String DEFAULT_MANUAL_PATH = "/system/etc/MANUAL.html.gz";
- private static final String PROPERTY_MANUAL_PATH = "ro.config.manual_path";
+ private static final String MANUAL_PATH = "/system/etc/MANUAL.html.gz";
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -47,16 +45,9 @@
finish(); // No manual to display for this device
}
- final String path = SystemProperties.get(PROPERTY_MANUAL_PATH, DEFAULT_MANUAL_PATH);
- if (TextUtils.isEmpty(path)) {
- Log.e(TAG, "The system property for the manual is empty");
- showErrorAndFinish();
- return;
- }
-
- final File file = new File(path);
+ final File file = new File(MANUAL_PATH);
if (!file.exists() || file.length() == 0) {
- Log.e(TAG, "Manual file " + path + " does not exist");
+ Log.e(TAG, "Manual file " + MANUAL_PATH + " does not exist");
showErrorAndFinish();
return;
}
diff --git a/src/com/android/settings/SettingsLicenseActivity.java b/src/com/android/settings/SettingsLicenseActivity.java
index 2581ed9..6f62057 100644
--- a/src/com/android/settings/SettingsLicenseActivity.java
+++ b/src/com/android/settings/SettingsLicenseActivity.java
@@ -21,7 +21,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -44,8 +43,7 @@
LoaderManager.LoaderCallbacks<File> {
private static final String TAG = "SettingsLicenseActivity";
- private static final String DEFAULT_LICENSE_PATH = "/system/etc/NOTICE.html.gz";
- private static final String PROPERTY_LICENSE_PATH = "ro.config.license_path";
+ private static final String LICENSE_PATH = "/system/etc/NOTICE.html.gz";
private static final int LOADER_ID_LICENSE_HTML_LOADER = 0;
@@ -53,10 +51,9 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- final String licenseHtmlPath =
- SystemProperties.get(PROPERTY_LICENSE_PATH, DEFAULT_LICENSE_PATH);
- if (isFilePathValid(licenseHtmlPath)) {
- showSelectedFile(licenseHtmlPath);
+ File file = new File(LICENSE_PATH);
+ if (isFileValid(file)) {
+ showHtmlFromUri(Uri.fromFile(file));
} else {
showHtmlFromDefaultXmlFiles();
}
@@ -95,22 +92,6 @@
}
}
- private void showSelectedFile(final String path) {
- if (TextUtils.isEmpty(path)) {
- Log.e(TAG, "The system property for the license file is empty");
- showErrorAndFinish();
- return;
- }
-
- final File file = new File(path);
- if (!isFileValid(file)) {
- Log.e(TAG, "License file " + path + " does not exist");
- showErrorAndFinish();
- return;
- }
- showHtmlFromUri(Uri.fromFile(file));
- }
-
private void showHtmlFromUri(Uri uri) {
// Kick off external viewer due to WebView security restrictions; we
// carefully point it at HTMLViewer, since it offers to decompress
@@ -139,10 +120,6 @@
finish();
}
- private boolean isFilePathValid(final String path) {
- return !TextUtils.isEmpty(path) && isFileValid(new File(path));
- }
-
@VisibleForTesting
boolean isFileValid(final File file) {
return file.exists() && file.length() != 0;
diff --git a/src/com/android/settings/SetupWizardUtils.java b/src/com/android/settings/SetupWizardUtils.java
index 0dbb2dc..1b911c7 100644
--- a/src/com/android/settings/SetupWizardUtils.java
+++ b/src/com/android/settings/SetupWizardUtils.java
@@ -17,7 +17,7 @@
package com.android.settings;
import android.content.Intent;
-import android.os.SystemProperties;
+import android.sysprop.SetupWizardProperties;
import androidx.annotation.VisibleForTesting;
@@ -27,13 +27,10 @@
public class SetupWizardUtils {
- @VisibleForTesting
- static final String SYSTEM_PROP_SETUPWIZARD_THEME = "setupwizard.theme";
-
public static int getTheme(Intent intent) {
String theme = intent.getStringExtra(WizardManagerHelper.EXTRA_THEME);
if (theme == null) {
- theme = SystemProperties.get(SYSTEM_PROP_SETUPWIZARD_THEME);
+ theme = SetupWizardProperties.theme().orElse("");
}
if (theme != null) {
switch (theme) {
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 2597b29..4b1c9bc 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -24,7 +24,6 @@
import android.os.UserHandle;
import android.text.TextUtils;
import android.view.View;
-import android.widget.Button;
import android.widget.TextView;
import com.android.settings.R;
@@ -33,15 +32,18 @@
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
import com.google.android.setupdesign.GlifLayout;
/**
* Base activity for all biometric enrollment steps.
*/
-public abstract class BiometricEnrollBase extends InstrumentedActivity
- implements View.OnClickListener {
- public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
+public abstract class BiometricEnrollBase extends InstrumentedActivity {
+ public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
+ public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
+ public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
/**
* Used by the choose fingerprint wizard to indicate the wizard is
@@ -76,6 +78,7 @@
protected boolean mLaunchedConfirmLock;
protected byte[] mToken;
protected int mUserId;
+ protected ButtonFooterMixin mButtonFooterMixin;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -110,10 +113,6 @@
protected void initViews() {
getWindow().setStatusBarColor(Color.TRANSPARENT);
- Button nextButton = getNextButton();
- if (nextButton != null) {
- nextButton.setOnClickListener(this);
- }
}
protected GlifLayout getLayout() {
@@ -137,18 +136,14 @@
setHeaderText(resId, false /* force */);
}
- protected Button getNextButton() {
- return (Button) findViewById(R.id.next_button);
- }
-
- @Override
- public void onClick(View v) {
- if (v == getNextButton()) {
- onNextButtonClick();
+ protected FooterButton getNextButton() {
+ if (mButtonFooterMixin != null) {
+ return mButtonFooterMixin.getPrimaryButton();
}
+ return null;
}
- protected void onNextButtonClick() {
+ protected void onNextButtonClick(View view) {
}
protected Intent getFingerprintEnrollingIntent() {
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 8a2a8ec..0ddc1fc 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -22,13 +22,13 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.view.View;
-import android.widget.Button;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.google.android.setupcompat.item.FooterButton;
import com.google.android.setupdesign.span.LinkSpan;
/**
@@ -70,12 +70,12 @@
/**
* @return the cancel button
*/
- protected abstract Button getCancelButton();
+ protected abstract FooterButton getCancelButton();
/**
* @return the next button
*/
- protected abstract Button getNextButton();
+ protected abstract FooterButton getNextButton();
/**
* @return the error TextView
@@ -127,9 +127,6 @@
setHeaderText(getHeaderResDefault());
}
- Button cancelButton = getCancelButton();
- cancelButton.setOnClickListener(v -> onCancelButtonClick());
-
mErrorText = getErrorTextView();
mUserManager = UserManager.get(this);
@@ -164,7 +161,7 @@
}
@Override
- protected void onNextButtonClick() {
+ protected void onNextButtonClick(View view) {
// Lock thingy is already set up, launch directly to the next page
launchNextEnrollingActivity(mToken);
}
@@ -234,7 +231,7 @@
super.onActivityResult(requestCode, resultCode, data);
}
- protected void onCancelButtonClick() {
+ protected void onCancelButtonClick(View view) {
finish();
}
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 033fb4b..7ad2d17 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -85,16 +85,9 @@
super.onBackPressed();
}
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.skip_button:
- setResult(RESULT_SKIP);
- finish();
- break;
- default:
- super.onClick(v);
- }
+ protected void onSkipButtonClick(View view) {
+ setResult(RESULT_SKIP);
+ finish();
}
public void startEnrollment() {
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
new file mode 100644
index 0000000..49f4f7f
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
@@ -0,0 +1,66 @@
+/*
+ * 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.biometrics.face;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.widget.LinearLayout;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import com.android.settings.R;
+
+/**
+ * A layout that contains a start-justified title, and an end-justified switch.
+ */
+public class FaceEnrollAccessibilityToggle extends LinearLayout {
+
+ private Switch mSwitch;
+
+ public FaceEnrollAccessibilityToggle(Context context) {
+ this(context, null /* attrs */);
+ }
+
+ public FaceEnrollAccessibilityToggle(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public FaceEnrollAccessibilityToggle(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+
+ LayoutInflater.from(context).inflate(R.layout.face_enroll_accessibility_toggle,
+ this, true /* attachToRoot */);
+
+ final TypedArray a =
+ context.obtainStyledAttributes(attrs, R.styleable.FaceEnrollAccessibilityToggle);
+ try {
+ final CharSequence title =
+ a.getText(R.styleable.FaceEnrollAccessibilityToggle_messageText);
+ final TextView titleTextView = findViewById(R.id.title);
+ titleTextView.setText(title);
+ } finally {
+ a.recycle();
+ }
+ mSwitch = findViewById(R.id.toggle);
+ }
+
+ public boolean isChecked() {
+ return mSwitch.isChecked();
+ }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
index bb46b18..9ef04cb 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
@@ -24,17 +24,19 @@
import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import android.widget.Button;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
-import com.android.settings.Utils;
+import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricEnrollSidecar;
import com.android.settings.biometrics.BiometricErrorDialog;
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
-import com.android.settings.password.ChooseLockSettingsHelper;
+import java.util.ArrayList;
+
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
@@ -46,6 +48,8 @@
private Interpolator mLinearOutSlowInInterpolator;
private FaceEnrollPreviewFragment mPreviewFragment;
+ private ArrayList<Integer> mDisabledFeatures = new ArrayList<>();
+
private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() {
@Override
public void onEnrolled() {
@@ -88,8 +92,22 @@
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(
this, android.R.interpolator.linear_out_slow_in);
- Button skipButton = findViewById(R.id.skip_button);
- skipButton.setOnClickListener(this);
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.security_settings_face_enroll_enrolling_skip,
+ this::onSkipButtonClick,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
+
+ if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_DIVERSITY, true)) {
+ mDisabledFeatures.add(FaceManager.FEATURE_REQUIRE_REQUIRE_DIVERSITY);
+ }
+ if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_VISION, true)) {
+ mDisabledFeatures.add(FaceManager.FEATURE_REQUIRE_ATTENTION);
+ }
startEnrollment();
}
@@ -114,7 +132,12 @@
@Override
protected BiometricEnrollSidecar getSidecar() {
- return new FaceEnrollSidecar();
+ final int[] disabledFeatures = new int[mDisabledFeatures.size()];
+ for (int i = 0; i < mDisabledFeatures.size(); i++) {
+ disabledFeatures[i] = mDisabledFeatures.get(i);
+ }
+
+ return new FaceEnrollSidecar(disabledFeatures);
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
index 7062fe3..f0ff523 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
@@ -17,11 +17,15 @@
package com.android.settings.biometrics.face;
import android.os.Bundle;
+import android.view.View;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.biometrics.BiometricEnrollBase;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
/**
* Activity which concludes face enrollment.
*/
@@ -32,6 +36,16 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.face_enroll_finish);
setHeaderText(R.string.security_settings_face_enroll_finish_title);
+
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ this,
+ R.string.security_settings_face_enroll_done,
+ this::onNextButtonClick,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
}
@Override
@@ -40,7 +54,7 @@
}
@Override
- public void onNextButtonClick() {
+ public void onNextButtonClick(View view) {
setResult(RESULT_FINISHED);
finish();
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index b720ff4..1c36ea8 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -20,7 +20,9 @@
import android.content.Intent;
import android.hardware.face.FaceManager;
import android.os.Bundle;
+import android.view.View;
import android.widget.Button;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
@@ -30,6 +32,8 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
import com.google.android.setupdesign.span.LinkSpan;
public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@@ -37,11 +41,41 @@
private static final String TAG = "FaceIntro";
private FaceManager mFaceManager;
+ private FaceEnrollAccessibilityToggle mSwitchVision;
+ private FaceEnrollAccessibilityToggle mSwitchDiversity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFaceManager = Utils.getFaceManagerOrNull(this);
+ final LinearLayout accessibilityLayout = findViewById(R.id.accessibility_layout);
+ final Button accessibilityButton = findViewById(R.id.accessibility_button);
+ accessibilityButton.setOnClickListener(view -> {
+ accessibilityButton.setVisibility(View.INVISIBLE);
+ accessibilityLayout.setVisibility(View.VISIBLE);
+ });
+
+ mSwitchVision = findViewById(R.id.toggle_vision);
+ mSwitchDiversity = findViewById(R.id.toggle_diversity);
+
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.security_settings_face_enroll_introduction_cancel,
+ this::onCancelButtonClick,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
+
+ mButtonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ this,
+ R.string.wizard_next,
+ this::onNextButtonClick,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
}
@Override
@@ -71,13 +105,19 @@
}
@Override
- protected Button getCancelButton() {
- return findViewById(R.id.face_cancel_button);
+ protected FooterButton getCancelButton() {
+ if (mButtonFooterMixin != null) {
+ return mButtonFooterMixin.getSecondaryButton();
+ }
+ return null;
}
@Override
- protected Button getNextButton() {
- return findViewById(R.id.face_next_button);
+ protected FooterButton getNextButton() {
+ if (mButtonFooterMixin != null) {
+ return mButtonFooterMixin.getPrimaryButton();
+ }
+ return null;
}
@Override
@@ -116,7 +156,10 @@
@Override
protected Intent getEnrollingIntent() {
- return new Intent(this, FaceEnrollEnrolling.class);
+ final Intent intent = new Intent(this, FaceEnrollEnrolling.class);
+ intent.putExtra(EXTRA_KEY_REQUIRE_VISION, mSwitchVision.isChecked());
+ intent.putExtra(EXTRA_KEY_REQUIRE_DIVERSITY, mSwitchDiversity.isChecked());
+ return intent;
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java b/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
index 2433fcb..7519530 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
@@ -24,13 +24,22 @@
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollSidecar;
+import java.util.ArrayList;
+import java.util.Arrays;
+
/**
* Sidecar fragment to handle the state around face enrollment
*/
public class FaceEnrollSidecar extends BiometricEnrollSidecar {
+ private final int[] mDisabledFeatures;
+
private FaceManager mFaceManager;
+ public FaceEnrollSidecar(int[] disabledFeatures) {
+ mDisabledFeatures = Arrays.copyOf(disabledFeatures, disabledFeatures.length);
+ }
+
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
@@ -43,9 +52,9 @@
if (mUserId != UserHandle.USER_NULL) {
mFaceManager.setActiveUser(mUserId);
}
- // TODO: Send the list of disabled features
+
mFaceManager.enroll(mToken, mEnrollmentCancel,
- mEnrollmentCallback, new int[0] /* disabledFeatures */);
+ mEnrollmentCallback, mDisabledFeatures);
}
private FaceManager.EnrollmentCallback mEnrollmentCallback
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index fb6a221..5953c10 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -35,7 +35,6 @@
import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -48,6 +47,9 @@
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
/**
* Activity which handles the actual enrolling for fingerprint.
*/
@@ -135,8 +137,15 @@
mProgressBar = (ProgressBar) findViewById(R.id.fingerprint_progress_bar);
mVibrator = getSystemService(Vibrator.class);
- Button skipButton = findViewById(R.id.skip_button);
- skipButton.setOnClickListener(this);
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.security_settings_fingerprint_enroll_enrolling_skip,
+ this::onSkipButtonClick,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
final LayerDrawable fingerprintDrawable = (LayerDrawable) mProgressBar.getBackground();
mIconAnimationDrawable = (AnimatedVectorDrawable)
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 0772c66..b8a0f40 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -20,7 +20,6 @@
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.view.View;
-import android.widget.Button;
import androidx.annotation.Nullable;
@@ -30,6 +29,8 @@
import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricEnrollSidecar.Listener;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
/**
* Activity explaining the fingerprint sensor location for fingerprint enrollment.
@@ -46,8 +47,15 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentView());
- Button skipButton = findViewById(R.id.skip_button);
- skipButton.setOnClickListener(this);
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.skip_label,
+ this::onSkipButtonClick,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title);
@@ -120,18 +128,7 @@
}
}
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.skip_button:
- onSkipButtonClick();
- break;
- default:
- super.onClick(v);
- }
- }
-
- protected void onSkipButtonClick() {
+ protected void onSkipButtonClick(View view) {
setResult(RESULT_SKIP);
finish();
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index db6b5bc..76f1d1f 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -20,13 +20,15 @@
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.view.View;
-import android.widget.Button;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollBase;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
/**
* Activity which concludes fingerprint enrollment.
*/
@@ -39,13 +41,32 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.fingerprint_enroll_finish);
setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
+
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.fingerprint_enroll_button_add,
+ null,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
+
+ mButtonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ this,
+ R.string.security_settings_fingerprint_enroll_done,
+ this::onNextButtonClick,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
}
@Override
protected void onResume() {
super.onResume();
- Button addButton = (Button) findViewById(R.id.add_another_button);
+ FooterButton addButton = mButtonFooterMixin.getSecondaryButton();
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
boolean hideAddAnother = false;
@@ -59,22 +80,18 @@
// Don't show "Add" button if too many fingerprints already added
addButton.setVisibility(View.INVISIBLE);
} else {
- addButton.setOnClickListener(this);
+ addButton.setOnClickListener(this::onAddAnotherButtonClick);
}
}
@Override
- protected void onNextButtonClick() {
+ protected void onNextButtonClick(View view) {
setResult(RESULT_FINISHED);
finish();
}
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.add_another_button) {
- startActivityForResult(getFingerprintEnrollingIntent(), REQUEST_ADD_ANOTHER);
- }
- super.onClick(v);
+ private void onAddAnotherButtonClick(View view) {
+ startActivityForResult(getFingerprintEnrollingIntent(), REQUEST_ADD_ANOTHER);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 61c67a5..4eca87d 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -22,7 +22,6 @@
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.util.Log;
-import android.widget.Button;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
@@ -33,6 +32,8 @@
import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
import com.google.android.setupdesign.span.LinkSpan;
public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
@@ -45,6 +46,25 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFingerprintManager = Utils.getFingerprintManagerOrNull(this);
+
+ mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.security_settings_face_enroll_introduction_cancel,
+ this::onCancelButtonClick,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
+
+ mButtonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ this,
+ R.string.wizard_next,
+ this::onNextButtonClick,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
}
@Override
@@ -74,13 +94,19 @@
}
@Override
- protected Button getCancelButton() {
- return findViewById(R.id.fingerprint_cancel_button);
+ protected FooterButton getCancelButton() {
+ if (mButtonFooterMixin != null) {
+ return mButtonFooterMixin.getSecondaryButton();
+ }
+ return null;
}
@Override
- protected Button getNextButton() {
- return findViewById(R.id.fingerprint_next_button);
+ protected FooterButton getNextButton() {
+ if (mButtonFooterMixin != null) {
+ return mButtonFooterMixin.getPrimaryButton();
+ }
+ return null;
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivity.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivity.java
index f5fe92b..704ed13 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivity.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivity.java
@@ -19,19 +19,21 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
-import android.widget.Button;
import com.android.settings.R;
import com.android.settings.Utils;
+import com.google.android.setupcompat.item.FooterButton;
+
public class FingerprintSuggestionActivity extends SetupFingerprintEnrollIntroduction {
@Override
protected void initViews() {
super.initViews();
- final Button cancelButton = findViewById(R.id.fingerprint_cancel_button);
- cancelButton.setText(R.string.security_settings_fingerprint_enroll_introduction_cancel);
+ final FooterButton cancelButton = getCancelButton();
+ cancelButton.setText(
+ this, R.string.security_settings_fingerprint_enroll_introduction_cancel);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
index 8ab9252..5f1a240 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -22,6 +22,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
+import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
@@ -53,7 +54,7 @@
}
@Override
- protected void onSkipButtonClick() {
+ protected void onSkipButtonClick(View view) {
new SkipFingerprintDialog().show(getSupportFragmentManager());
}
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinish.java
index 49eac16..6afbb84 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinish.java
@@ -25,6 +25,8 @@
import com.android.settings.SetupWizardUtils;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.google.android.setupcompat.item.FooterButton;
+
public class SetupFingerprintEnrollFinish extends FingerprintEnrollFinish {
@Override
@@ -41,8 +43,8 @@
@Override
protected void initViews() {
super.initViews();
- Button nextButton = findViewById(R.id.next_button);
- nextButton.setText(R.string.next_label);
+ FooterButton nextButton = getNextButton();
+ nextButton.setText(this, R.string.next_label);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
index 08f5c7e..a74bbba 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
@@ -23,7 +23,7 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.os.storage.StorageManager;
-import android.widget.Button;
+import android.view.View;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -34,6 +34,8 @@
import com.android.settings.password.SetupChooseLockGeneric;
import com.android.settings.password.SetupSkipDialog;
+import com.google.android.setupcompat.item.FooterButton;
+
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction {
private static final String KEY_LOCK_SCREEN_PRESENT = "wasLockScreenPresent";
private boolean mAlreadyHadLockScreenSetup = false;
@@ -84,13 +86,13 @@
description.setText(
R.string.security_settings_fingerprint_enroll_introduction_message_setup);
- Button nextButton = getNextButton();
+ FooterButton nextButton = getNextButton();
nextButton.setText(
- R.string.security_settings_fingerprint_enroll_introduction_continue_setup);
+ this, R.string.security_settings_fingerprint_enroll_introduction_continue_setup);
- final Button cancelButton = (Button) findViewById(R.id.fingerprint_cancel_button);
+ final FooterButton cancelButton = getCancelButton();
cancelButton.setText(
- R.string.security_settings_fingerprint_enroll_introduction_cancel_setup);
+ this, R.string.security_settings_fingerprint_enroll_introduction_cancel_setup);
}
@Override
@@ -116,7 +118,7 @@
}
@Override
- protected void onCancelButtonClick() {
+ protected void onCancelButtonClick(View view) {
if (isKeyguardSecure()) {
// If the keyguard is already set up securely (maybe the user added a backup screen
// lock and skipped fingerprint), return RESULT_SKIP directly.
diff --git a/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
index befdf29..0be1438 100644
--- a/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
+++ b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
@@ -15,9 +15,12 @@
*/
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
import android.content.Context;
import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -43,7 +46,7 @@
UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
(connected, functions, powerRole, dataRole) -> {
if (connected) {
- mUsbPreference.setSummary(getSummary(dataRole == UsbPort.DATA_ROLE_DEVICE
+ mUsbPreference.setSummary(getSummary(dataRole == DATA_ROLE_DEVICE
? functions : UsbManager.FUNCTION_NONE, powerRole));
mDevicePreferenceCallback.onDeviceAdded(mUsbPreference);
} else {
@@ -100,7 +103,7 @@
public static int getSummary(long functions, int power) {
switch (power) {
- case UsbPort.POWER_ROLE_SINK:
+ case POWER_ROLE_SINK:
if (functions == UsbManager.FUNCTION_MTP) {
return R.string.usb_summary_file_transfers;
} else if (functions == UsbManager.FUNCTION_RNDIS) {
@@ -112,7 +115,7 @@
} else {
return R.string.usb_summary_charging_only;
}
- case UsbPort.POWER_ROLE_SOURCE:
+ case POWER_ROLE_SOURCE:
if (functions == UsbManager.FUNCTION_MTP) {
return R.string.usb_summary_file_transfers_power;
} else if (functions == UsbManager.FUNCTION_RNDIS) {
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
index f68a4a0..556f76d 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbBackend.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -15,6 +15,13 @@
*/
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+import static android.service.usb.UsbPortStatusProto.DATA_ROLE_HOST;
+import static android.service.usb.UsbPortStatusProto.DATA_ROLE_NONE;
+import static android.service.usb.UsbPortStatusProto.POWER_ROLE_SINK;
+
import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -27,6 +34,8 @@
import androidx.annotation.VisibleForTesting;
+import java.util.List;
+
/**
* Provides access to underlying system USB functionality.
*/
@@ -96,30 +105,30 @@
public int getPowerRole() {
updatePorts();
- return mPortStatus == null ? UsbPort.POWER_ROLE_NONE : mPortStatus.getCurrentPowerRole();
+ return mPortStatus == null ? POWER_ROLE_NONE : mPortStatus.getCurrentPowerRole();
}
public int getDataRole() {
updatePorts();
- return mPortStatus == null ? UsbPort.DATA_ROLE_NONE : mPortStatus.getCurrentDataRole();
+ return mPortStatus == null ? DATA_ROLE_NONE : mPortStatus.getCurrentDataRole();
}
public void setPowerRole(int role) {
int newDataRole = getDataRole();
if (!areAllRolesSupported()) {
switch (role) {
- case UsbPort.POWER_ROLE_SINK:
- newDataRole = UsbPort.DATA_ROLE_DEVICE;
+ case POWER_ROLE_SINK:
+ newDataRole = DATA_ROLE_DEVICE;
break;
- case UsbPort.POWER_ROLE_SOURCE:
- newDataRole = UsbPort.DATA_ROLE_HOST;
+ case POWER_ROLE_SOURCE:
+ newDataRole = DATA_ROLE_HOST;
break;
default:
- newDataRole = UsbPort.DATA_ROLE_NONE;
+ newDataRole = DATA_ROLE_NONE;
}
}
if (mPort != null) {
- mUsbManager.setPortRoles(mPort, role, newDataRole);
+ mPort.setRoles(role, newDataRole);
}
}
@@ -127,31 +136,27 @@
int newPowerRole = getPowerRole();
if (!areAllRolesSupported()) {
switch (role) {
- case UsbPort.DATA_ROLE_DEVICE:
- newPowerRole = UsbPort.POWER_ROLE_SINK;
+ case DATA_ROLE_DEVICE:
+ newPowerRole = POWER_ROLE_SINK;
break;
- case UsbPort.DATA_ROLE_HOST:
- newPowerRole = UsbPort.POWER_ROLE_SOURCE;
+ case DATA_ROLE_HOST:
+ newPowerRole = POWER_ROLE_SOURCE;
break;
default:
- newPowerRole = UsbPort.POWER_ROLE_NONE;
+ newPowerRole = POWER_ROLE_NONE;
}
}
if (mPort != null) {
- mUsbManager.setPortRoles(mPort, newPowerRole, role);
+ mPort.setRoles(newPowerRole, role);
}
}
public boolean areAllRolesSupported() {
return mPort != null && mPortStatus != null
- && mPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE)
- && mPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST)
- && mPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE)
- && mPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+ && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE)
+ && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST)
+ && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE)
+ && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
}
public static String usbFunctionsToString(long functions) {
@@ -205,17 +210,14 @@
private void updatePorts() {
mPort = null;
mPortStatus = null;
- UsbPort[] ports = mUsbManager.getPorts();
- if (ports == null) {
- return;
- }
+ List<UsbPort> ports = mUsbManager.getPorts();
// For now look for a connected port, in the future we should identify port in the
// notification and pick based on that.
- final int N = ports.length;
+ final int N = ports.size();
for (int i = 0; i < N; i++) {
- UsbPortStatus status = mUsbManager.getPortStatus(ports[i]);
+ UsbPortStatus status = ports.get(i).getStatus();
if (status.isConnected()) {
- mPort = ports[i];
+ mPort = ports.get(i);
mPortStatus = status;
break;
}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
index 1d43371..beb2375 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
@@ -49,8 +49,8 @@
mUsbBackend = backend;
mFunctions = UsbManager.FUNCTION_NONE;
- mDataRole = UsbPort.DATA_ROLE_NONE;
- mPowerRole = UsbPort.POWER_ROLE_NONE;
+ mDataRole = UsbPortStatus.DATA_ROLE_NONE;
+ mPowerRole = UsbPortStatus.POWER_ROLE_NONE;
}
@Override
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
index 84576b1..a584c11 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
@@ -16,6 +16,10 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+
import android.content.Context;
import android.hardware.usb.UsbPort;
@@ -55,23 +59,23 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
- mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(UsbPort.DATA_ROLE_HOST),
+ mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_HOST),
R.string.usb_control_host);
- mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(UsbPort.DATA_ROLE_DEVICE),
+ mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_DEVICE),
R.string.usb_control_device);
}
@Override
protected void refresh(boolean connected, long functions, int powerRole, int dataRole) {
- if (dataRole == UsbPort.DATA_ROLE_DEVICE) {
+ if (dataRole == DATA_ROLE_DEVICE) {
mDevicePref.setChecked(true);
mHostPref.setChecked(false);
mPreferenceCategory.setEnabled(true);
- } else if (dataRole == UsbPort.DATA_ROLE_HOST) {
+ } else if (dataRole == DATA_ROLE_HOST) {
mDevicePref.setChecked(false);
mHostPref.setChecked(true);
mPreferenceCategory.setEnabled(true);
- } else if (!connected || dataRole == UsbPort.DATA_ROLE_NONE){
+ } else if (!connected || dataRole == DATA_ROLE_NONE){
mPreferenceCategory.setEnabled(false);
if (mNextRolePref == null) {
// Disconnected with no operation pending, so clear subtexts
@@ -80,7 +84,7 @@
}
}
- if (mNextRolePref != null && dataRole != UsbPort.DATA_ROLE_NONE) {
+ if (mNextRolePref != null && dataRole != DATA_ROLE_NONE) {
if (UsbBackend.dataRoleFromString(mNextRolePref.getKey()) == dataRole) {
// Clear switching text if switch succeeded
mNextRolePref.setSummary("");
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index f74dc0f..283e56b 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -16,6 +16,7 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
import static android.net.ConnectivityManager.TETHERING_USB;
import android.content.Context;
@@ -88,7 +89,7 @@
@Override
protected void refresh(boolean connected, long functions, int powerRole, int dataRole) {
- if (!connected || dataRole != UsbPort.DATA_ROLE_DEVICE) {
+ if (!connected || dataRole != DATA_ROLE_DEVICE) {
mProfilesContainer.setEnabled(false);
} else {
// Functions are only available in device mode
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
index 30314f6..b59890a 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
@@ -16,8 +16,13 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
import android.content.Context;
import android.hardware.usb.UsbPort;
+import android.hardware.usb.UsbPortStatus;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceClickListener;
@@ -40,16 +45,16 @@
private int mNextPowerRole;
private final Runnable mFailureCallback = () -> {
- if (mNextPowerRole != UsbPort.POWER_ROLE_NONE) {
+ if (mNextPowerRole != POWER_ROLE_NONE) {
mSwitchPreference.setSummary(R.string.usb_switching_failed);
- mNextPowerRole = UsbPort.POWER_ROLE_NONE;
+ mNextPowerRole = POWER_ROLE_NONE;
}
};
public UsbDetailsPowerRoleController(Context context, UsbDetailsFragment fragment,
UsbBackend backend) {
super(context, fragment, backend);
- mNextPowerRole = UsbPort.POWER_ROLE_NONE;
+ mNextPowerRole = POWER_ROLE_NONE;
}
@Override
@@ -70,20 +75,21 @@
} else if (connected && mUsbBackend.areAllRolesSupported()){
mFragment.getPreferenceScreen().addPreference(mPreferenceCategory);
}
- if (powerRole == UsbPort.POWER_ROLE_SOURCE) {
+ if (powerRole == POWER_ROLE_SOURCE) {
mSwitchPreference.setChecked(true);
mPreferenceCategory.setEnabled(true);
- } else if (powerRole == UsbPort.POWER_ROLE_SINK) {
+ } else if (powerRole == POWER_ROLE_SINK) {
mSwitchPreference.setChecked(false);
mPreferenceCategory.setEnabled(true);
- } else if (!connected || powerRole == UsbPort.POWER_ROLE_NONE){
+ } else if (!connected || powerRole == POWER_ROLE_NONE){
mPreferenceCategory.setEnabled(false);
- if (mNextPowerRole == UsbPort.POWER_ROLE_NONE) {
+ if (mNextPowerRole == POWER_ROLE_NONE) {
mSwitchPreference.setSummary("");
}
}
- if (mNextPowerRole != UsbPort.POWER_ROLE_NONE && powerRole != UsbPort.POWER_ROLE_NONE) {
+ if (mNextPowerRole != POWER_ROLE_NONE
+ && powerRole != POWER_ROLE_NONE) {
if (mNextPowerRole == powerRole) {
// Clear switching text if switch succeeded
mSwitchPreference.setSummary("");
@@ -91,16 +97,16 @@
// Set failure text if switch failed
mSwitchPreference.setSummary(R.string.usb_switching_failed);
}
- mNextPowerRole = UsbPort.POWER_ROLE_NONE;
+ mNextPowerRole = POWER_ROLE_NONE;
mHandler.removeCallbacks(mFailureCallback);
}
}
@Override
public boolean onPreferenceClick(Preference preference) {
- int newRole = mSwitchPreference.isChecked() ? UsbPort.POWER_ROLE_SOURCE
- : UsbPort.POWER_ROLE_SINK;
- if (mUsbBackend.getPowerRole() != newRole && mNextPowerRole == UsbPort.POWER_ROLE_NONE
+ int newRole = mSwitchPreference.isChecked() ? POWER_ROLE_SOURCE
+ : POWER_ROLE_SINK;
+ if (mUsbBackend.getPowerRole() != newRole && mNextPowerRole == POWER_ROLE_NONE
&& !Utils.isMonkeyRunning()) {
mUsbBackend.setPowerRole(newRole);
diff --git a/src/com/android/settings/core/InstrumentedPreferenceFragment.java b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
index cafef00..f5f245f 100644
--- a/src/com/android/settings/core/InstrumentedPreferenceFragment.java
+++ b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
@@ -22,6 +22,7 @@
import android.util.Log;
import androidx.annotation.XmlRes;
+import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.overlay.FeatureFactory;
@@ -78,6 +79,14 @@
updateActivityTitleWithScreenTitle(getPreferenceScreen());
}
+ @Override
+ public <T extends Preference> T findPreference(CharSequence key) {
+ if (key == null) {
+ return null;
+ }
+ return super.findPreference(key);
+ }
+
protected final Context getPrefContext() {
return getPreferenceManager().getContext();
}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
index 50c908a..9950d3f 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardBase.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -35,7 +35,6 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -45,6 +44,8 @@
import com.android.settings.R;
import com.android.settingslib.Utils;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
import com.google.android.setupdesign.GlifLayout;
import java.text.NumberFormat;
@@ -62,8 +63,9 @@
protected VolumeInfo mVolume;
protected DiskInfo mDisk;
- private Button mBack;
- private Button mNext;
+ private ButtonFooterMixin mButtonFooterMixin;
+ private FooterButton mBack;
+ private FooterButton mNext;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -92,8 +94,25 @@
public void setContentView(@LayoutRes int layoutResID) {
super.setContentView(layoutResID);
- mBack = requireViewById(R.id.storage_back_button);
- mNext = requireViewById(R.id.storage_next_button);
+ mButtonFooterMixin = getGlifLayout().getMixin(ButtonFooterMixin.class);
+ mButtonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ this,
+ R.string.wizard_back,
+ this::onNavigateBack,
+ FooterButton.ButtonType.OTHER,
+ R.style.SuwGlifButton_Secondary)
+ );
+ mButtonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ this,
+ R.string.wizard_next,
+ this::onNavigateNext,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
+ mBack = mButtonFooterMixin.getSecondaryButton();
+ mNext = mButtonFooterMixin.getPrimaryButton();
setIcon(com.android.internal.R.drawable.ic_sd_card_48dp);
}
@@ -104,11 +123,11 @@
super.onDestroy();
}
- protected Button getBackButton() {
+ protected FooterButton getBackButton() {
return mBack;
}
- protected Button getNextButton() {
+ protected FooterButton getNextButton() {
return mNext;
}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java
index 51dd74b..907f58c 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardInit.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java
@@ -30,7 +30,6 @@
import com.android.settings.overlay.FeatureFactory;
public class StorageWizardInit extends StorageWizardBase {
- private Button mExternal;
private Button mInternal;
private boolean mIsPermittedToAdopt;
@@ -49,7 +48,6 @@
setHeaderText(R.string.storage_wizard_init_v2_title, getDiskShortDescription());
- mExternal = requireViewById(R.id.storage_wizard_init_external);
mInternal = requireViewById(R.id.storage_wizard_init_internal);
setBackButtonText(R.string.storage_wizard_init_v2_later);
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 997d86b..88478e3 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -21,7 +21,7 @@
import static androidx.slice.widget.SliceLiveData.SUPPORTED_SPECS;
import static com.android.settings.slices.CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI;
-import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
+import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
@@ -204,7 +204,7 @@
}
private boolean isLargeCard(ContextualCard card) {
- return card.getSliceUri().equals(WIFI_SLICE_URI)
+ return card.getSliceUri().equals(CONTEXTUAL_WIFI_SLICE_URI)
|| card.getSliceUri().equals(BLUETOOTH_DEVICES_SLICE_URI);
}
diff --git a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
index d5500fb..5797043 100644
--- a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
@@ -34,8 +34,8 @@
public ContextualCardList getContextualCards() {
final ContextualCard wifiCard =
ContextualCard.newBuilder()
- .setSliceUri(CustomSliceRegistry.WIFI_SLICE_URI.toString())
- .setCardName(CustomSliceRegistry.WIFI_SLICE_URI.toString())
+ .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())
+ .setCardName(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())
.setCardCategory(ContextualCard.Category.IMPORTANT)
.build();
final ContextualCard connectedDeviceCard =
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
index 41c2757..ab1b4c9 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
@@ -98,10 +98,10 @@
ListBuilder.ICON_IMAGE,
batteryTip.getTitle(mContext));
sliceBuilder.addRow(new RowBuilder()
+ .setTitleItem(icon, ListBuilder.ICON_IMAGE)
.setTitle(batteryTip.getTitle(mContext))
.setSubtitle(batteryTip.getSummary(mContext))
- .setPrimaryAction(primaryAction)
- .addEndItem(icon, ListBuilder.ICON_IMAGE));
+ .setPrimaryAction(primaryAction));
break;
}
}
@@ -144,9 +144,9 @@
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
ListBuilder.ICON_IMAGE, title);
sliceBuilder.addRow(new RowBuilder()
+ .setTitleItem(icon, ListBuilder.ICON_IMAGE)
.setTitle(title)
- .setPrimaryAction(primaryAction)
- .addEndItem(icon, ListBuilder.ICON_IMAGE))
+ .setPrimaryAction(primaryAction))
.setIsError(isError);
return sliceBuilder.build();
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java b/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java
index e0f3116..03e4301 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java
@@ -119,15 +119,10 @@
PendingIntent.getActivity(mContext, 0, getIntent(), 0), icon,
ListBuilder.ICON_IMAGE, title);
- /**
- * TODO(b/114808204): Contextual Home Page - "Low Storage"
- * Slices doesn't support "Icon on the left" in header. Now we intend to start with Icon
- * right aligned. Will update the icon to left until Slices support it.
- */
return new RowBuilder()
+ .setTitleItem(icon, ListBuilder.ICON_IMAGE)
.setTitle(title)
.setSubtitle(summary)
- .addEndItem(icon, ListBuilder.ICON_IMAGE)
.setPrimaryAction(primarySliceAction);
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 17e9d48..7ca6e9a 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -132,6 +132,7 @@
cardHolder.sliceView.setOnSliceActionListener(this);
// Customize slice view for Settings
+ cardHolder.sliceView.showTitleItems(true);
if (card.isLargeCard()) {
cardHolder.sliceView.showHeaderDivider(true);
cardHolder.sliceView.showActionDividers(true);
@@ -195,7 +196,7 @@
public SliceViewHolder(View view) {
super(view);
sliceView = view.findViewById(R.id.slice_view);
- viewFlipper = view.findViewById(R.id.viewFlipper);
+ viewFlipper = view.findViewById(R.id.view_flipper);
}
public void resetCard() {
diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java
index 261d889..2b47c70 100755
--- a/src/com/android/settings/network/ApnSettings.java
+++ b/src/com/android/settings/network/ApnSettings.java
@@ -277,7 +277,7 @@
private void fillList() {
final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
: SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- final Uri simApnUri = Uri.withAppendedPath(Telephony.Carriers.SIM_APN_LIST,
+ final Uri simApnUri = Uri.withAppendedPath(Telephony.Carriers.SIM_APN_URI,
String.valueOf(subId));
StringBuilder where = new StringBuilder("NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND "
+ "user_visible!=0");
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 9e55341..bf6d39c 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -20,10 +20,13 @@
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
import android.content.Context;
+import android.content.Intent;
+import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import com.android.settings.R;
+import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.Map;
@@ -125,7 +128,7 @@
mSubscriptionPreferences = new ArrayMap<>();
int order = mStartOrder;
- for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager) ) {
+ for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
final int subId = info.getSubscriptionId();
Preference pref = existingPrefs.remove(subId);
if (pref == null) {
@@ -139,8 +142,9 @@
// TODO(asargent) - set summary here to indicate default for calls/sms and data
pref.setOnPreferenceClickListener(clickedPref -> {
- // TODO(asargent) - make this start MobileNetworkActivity once we've
- // added support for it to take a subscription id
+ final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
+ intent.putExtra(Settings.EXTRA_SUB_ID, subId);
+ mContext.startActivity(intent);
return true;
});
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 9f3dfb2..c101db4 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -25,7 +25,6 @@
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.util.Log;
import android.view.Menu;
import android.view.View;
@@ -43,14 +42,12 @@
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Objects;
public class MobileNetworkActivity extends SettingsBaseActivity {
- private static final String TAG = "MobileSettingsActivity";
+ private static final String TAG = "MobileNetworkActivity";
@VisibleForTesting
static final String MOBILE_SETTINGS_TAG = "mobile_settings:";
@VisibleForTesting
@@ -94,6 +91,13 @@
actionBar.setDisplayHomeAsUpEnabled(true);
}
+ // Set the title to the name of the subscription. If we don't have subscription info, the
+ // title will just default to the label for this activity that's already specified in
+ // AndroidManifest.xml.
+ final SubscriptionInfo subscription = getSubscription();
+ if (subscription != null) {
+ setTitle(subscription.getDisplayName());
+ }
updateSubscriptions(savedInstanceState);
}
@@ -136,25 +140,41 @@
}
/**
- * Get the current subId to display. First check whether intent has {@link
- * Settings#EXTRA_SUB_ID}. If not, just display first one in list
- * since it is already sorted by sim slot.
+ * Get the current subscription to display. First check whether intent has {@link
+ * Settings#EXTRA_SUB_ID} and if so find the subscription with that id. If not, just return the
+ * first one in the mSubscriptionInfos list since it is already sorted by sim slot.
*/
@VisibleForTesting
- int getSubscriptionId() {
+ SubscriptionInfo getSubscription() {
final Intent intent = getIntent();
if (intent != null) {
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
- if (subId != SUB_ID_NULL && mSubscriptionManager.isActiveSubscriptionId(subId)) {
- return subId;
+ if (subId != SUB_ID_NULL) {
+ for (SubscriptionInfo subscription :
+ mSubscriptionManager.getAvailableSubscriptionInfoList()) {
+ if (subscription.getSubscriptionId() == subId) {
+ return subscription;
+ }
+ }
}
}
if (CollectionUtils.isEmpty(mSubscriptionInfos)) {
- return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ return null;
}
+ return mSubscriptionInfos.get(0);
+ }
- return mSubscriptionInfos.get(0).getSubscriptionId();
+ /**
+ * Get the current subId to display.
+ */
+ @VisibleForTesting
+ int getSubscriptionId() {
+ final SubscriptionInfo subscription = getSubscription();
+ if (subscription != null) {
+ return subscription.getSubscriptionId();
+ }
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
@VisibleForTesting
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreference.java b/src/com/android/settings/notification/VolumeSeekBarPreference.java
index 2ef33d4..13f6300 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreference.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreference.java
@@ -80,6 +80,11 @@
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}
+ @Override
+ public boolean isSelectable() {
+ return false;
+ }
+
public void setStream(int stream) {
mStream = stream;
setMax(mAudioManager.getStreamMaxVolume(mStream));
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index 503a5c3..ade2ffd 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -17,15 +17,16 @@
package com.android.settings.panel;
import android.content.Context;
+import android.provider.Settings;
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
@Override
public PanelContent getPanel(Context context, String panelType) {
switch (panelType) {
- case SettingsPanelActivity.PANEL_TYPE_WIFI:
+ case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
- case SettingsPanelActivity.PANEL_TYPE_VOLUME:
+ case Settings.Panel.ACTION_VOLUME:
return VolumePanel.create(context);
}
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index e61b8f8..7655be8 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -69,7 +69,7 @@
mPanelSlices = view.findViewById(R.id.panel_parent_layout);
mSeeMoreButton = view.findViewById(R.id.see_more);
mDoneButton = view.findViewById(R.id.done);
- mTitleView = view.findViewById(R.id.title);
+ mTitleView = view.findViewById(R.id.panel_title);
final Bundle arguments = getArguments();
final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 09bead4..ffe94f8 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -16,11 +16,9 @@
package com.android.settings.panel;
-import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
-import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.Window;
@@ -35,8 +33,6 @@
/**
* Dialog Activity to host Settings Slices.
- *
- * TODO link to action / framework API
*/
public class SettingsPanelActivity extends FragmentActivity {
@@ -47,28 +43,10 @@
*/
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
-
- // TODO (b/117804442) move to framework
- public static final String EXTRA_PANEL_TYPE = "com.android.settings.panel.extra";
-
- // TODO (b/117804442) move to framework
- public static final String PANEL_TYPE_WIFI = "wifi_panel";
-
- // TODO (b/117804442) move to framework
- public static final String PANEL_TYPE_VOLUME = "volume_panel";
-
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- final ComponentName callingActivityName = getCallingActivity();
-
- if (callingActivityName == null) {
- Log.e(TAG, "Must start with startActivityForResult. Closing.");
- finish();
- return;
- }
-
final Intent callingIntent = getIntent();
if (callingIntent == null) {
Log.e(TAG, "Null intent, closing Panel Activity");
@@ -76,12 +54,6 @@
return;
}
- final String typeExtra = callingIntent.getStringExtra(EXTRA_PANEL_TYPE);
- if (TextUtils.isEmpty(typeExtra)) {
- Log.e(TAG, "No intent passed, closing Panel Activity");
- return;
- }
-
setContentView(R.layout.settings_panel);
// Move the window to the bottom of screen, and make it take up the entire screen width.
@@ -90,9 +62,8 @@
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
-
final Bundle bundle = new Bundle();
- bundle.putString(KEY_PANEL_TYPE_ARGUMENT, typeExtra);
+ bundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
final PanelFragment panelFragment = new PanelFragment();
panelFragment.setArguments(bundle);
diff --git a/src/com/android/settings/slices/CustomSliceManager.java b/src/com/android/settings/slices/CustomSliceManager.java
index 4a9de15..bb47df2 100644
--- a/src/com/android/settings/slices/CustomSliceManager.java
+++ b/src/com/android/settings/slices/CustomSliceManager.java
@@ -32,7 +32,8 @@
import com.android.settings.homepage.contextualcards.slices.BluetoothDevicesSlice;
import com.android.settings.homepage.contextualcards.slices.LowStorageSlice;
import com.android.settings.location.LocationSlice;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.wifi.slice.ContextualWifiSlice;
+import com.android.settings.wifi.slice.WifiSlice;
import java.util.Map;
import java.util.WeakHashMap;
@@ -107,6 +108,7 @@
mUriMap.put(CustomSliceRegistry.BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatterySlice.class);
mUriMap.put(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI, BluetoothDevicesSlice.class);
+ mUriMap.put(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
mUriMap.put(CustomSliceRegistry.DATA_USAGE_SLICE_URI, DataUsageSlice.class);
mUriMap.put(CustomSliceRegistry.DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
mUriMap.put(CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI, EmergencyInfoSlice.class);
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
index 1b8cffe..bdf8b35 100644
--- a/src/com/android/settings/slices/CustomSliceRegistry.java
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -80,6 +80,17 @@
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
.appendPath("bluetooth_devices")
.build();
+
+ /**
+ * Backing Uri for the Wifi Slice.
+ */
+ public static final Uri CONTEXTUAL_WIFI_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSlicesContract.AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("contextual_wifi")
+ .build();
+
/**
* Backing Uri for the Data usage Slice.
*/
@@ -216,6 +227,7 @@
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
.appendPath(KEY_WIFI)
.build();
+
/**
* Backing Uri for the Zen Mode Slice.
*/
diff --git a/src/com/android/settings/widget/SeekBarPreference.java b/src/com/android/settings/widget/SeekBarPreference.java
index 2c57bb3..f4d2aac 100644
--- a/src/com/android/settings/widget/SeekBarPreference.java
+++ b/src/com/android/settings/widget/SeekBarPreference.java
@@ -92,6 +92,11 @@
}
@Override
+ public boolean isSelectable() {
+ return false;
+ }
+
+ @Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
view.itemView.setOnKeyListener(this);
diff --git a/src/com/android/settings/wifi/WifiDialogActivity.java b/src/com/android/settings/wifi/WifiDialogActivity.java
index 9ef6a39..c32bcf3 100644
--- a/src/com/android/settings/wifi/WifiDialogActivity.java
+++ b/src/com/android/settings/wifi/WifiDialogActivity.java
@@ -38,6 +38,8 @@
private static final String TAG = "WifiDialogActivity";
+ public static final String KEY_ACCESS_POINT_STATE = "access_point_state";
+
/**
* Boolean extra indicating whether this activity should connect to an access point on the
* caller's behalf. If this is set to false, the caller should check
@@ -46,9 +48,8 @@
*/
@VisibleForTesting
static final String KEY_CONNECT_FOR_CALLER = "connect_for_caller";
- static final String KEY_ACCESS_POINT_STATE = "access_point_state";
- private static final String KEY_WIFI_CONFIGURATION = "wifi_configuration";
+ private static final String KEY_WIFI_CONFIGURATION = "wifi_configuration";
private static final int RESULT_CONNECTED = RESULT_FIRST_USER;
private static final int RESULT_FORGET = RESULT_FIRST_USER + 1;
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 3275695..cc75d44 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -58,25 +58,7 @@
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
public static final String EXTRA_WIFI_HIDDEN_SSID = "hiddenSsid";
- /**
- * Acceptable QR code string may be a standard W-Fi DPP bootstrapping information or the Wi-Fi
- * Network config format described in
- * https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11
- *
- * Wi-Fi Network config format example:
- *
- * WIFI:T:WPA;S:mynetwork;P:mypass;;
- *
- * parameter Example Description
- * T WPA Authentication type; can be WEP or WPA, or 'nopass' for no password. Or,
- * omit for no password.
- * S mynetwork Network SSID. Required. Enclose in double quotes if it is an ASCII name,
- * but could be interpreted as hex (i.e. "ABCD")
- * P mypass Password, ignored if T is "nopass" (in which case it may be omitted).
- * Enclose in double quotes if it is an ASCII name, but could be interpreted as
- * hex (i.e. "ABCD")
- * H true Optional. True if the network SSID is hidden.
- */
+ /** @see WifiQrCode */
public static final String EXTRA_QR_CODE = "qrCode";
/**
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
index 439de98..bb64e05 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
@@ -19,15 +19,20 @@
import android.content.Intent;
import android.text.TextUtils;
+import androidx.annotation.Keep;
+
/**
- * Contains the Wi-Fi Network config parameters described in
- * https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11
+ * Wraps the parameters of ZXing reader library's Wi-Fi Network config format.
+ * Please check {@code WifiQrCode} for detail of the format.
*
* Checks below members of {@code WifiDppUtils} for more information.
* EXTRA_WIFI_SECURITY / EXTRA_WIFI_SSID / EXTRA_WIFI_PRE_SHARED_KEY / EXTRA_WIFI_HIDDEN_SSID /
* EXTRA_QR_CODE
*/
public class WifiNetworkConfig {
+ // Ignores password if security is NO_PASSWORD or absent
+ public static final String NO_PASSWORD = "nopass";
+
private String mSecurity;
private String mSsid;
private String mPreSharedKey;
@@ -42,9 +47,18 @@
}
public WifiNetworkConfig(WifiNetworkConfig config) {
- mSecurity = new String(config.mSecurity);
- mSsid = new String(config.mSsid);
- mPreSharedKey = new String(config.mPreSharedKey);
+ if (config.mSecurity != null) {
+ mSecurity = new String(config.mSecurity);
+ }
+
+ if (config.mSsid != null) {
+ mSsid = new String(config.mSsid);
+ }
+
+ if (config.mPreSharedKey != null) {
+ mPreSharedKey = new String(config.mPreSharedKey);
+ }
+
mHiddenSsid = config.mHiddenSsid;
}
@@ -69,12 +83,13 @@
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
boolean hiddenSsid = intent.getBooleanExtra(WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID, false);
- if (!isValidConfig(security, ssid, hiddenSsid)) {
- return null;
- }
+ return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid);
+ }
- if (ssid == null) {
- ssid = "";
+ public static WifiNetworkConfig getValidConfigOrNull(String security, String ssid,
+ String preSharedKey, boolean hiddenSsid) {
+ if (!isValidConfig(security, ssid, preSharedKey, hiddenSsid)) {
+ return null;
}
return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid);
@@ -84,13 +99,17 @@
if (config == null) {
return false;
} else {
- return isValidConfig(config.mSecurity, config.mSsid, config.mHiddenSsid);
+ return isValidConfig(config.mSecurity, config.mSsid, config.mPreSharedKey,
+ config.mHiddenSsid);
}
}
- public static boolean isValidConfig(String security, String ssid, boolean hiddenSsid) {
- if (TextUtils.isEmpty(security)) {
- return false;
+ public static boolean isValidConfig(String security, String ssid, String preSharedKey,
+ boolean hiddenSsid) {
+ if (!TextUtils.isEmpty(security) && !NO_PASSWORD.equals(security)) {
+ if (TextUtils.isEmpty(preSharedKey)) {
+ return false;
+ }
}
if (!hiddenSsid && TextUtils.isEmpty(ssid)) {
@@ -100,18 +119,22 @@
return true;
}
+ @Keep
public String getSecurity() {
- return new String(mSecurity);
+ return mSecurity;
}
+ @Keep
public String getSsid() {
- return new String(mSsid);
+ return mSsid;
}
+ @Keep
public String getPreSharedKey() {
- return new String(mPreSharedKey);
+ return mPreSharedKey;
}
+ @Keep
public boolean getHiddenSsid() {
return mHiddenSsid;
}
diff --git a/src/com/android/settings/wifi/dpp/WifiQrCode.java b/src/com/android/settings/wifi/dpp/WifiQrCode.java
new file mode 100644
index 0000000..ebc39c3
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiQrCode.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.dpp;
+
+import android.content.Intent;
+import android.text.TextUtils;
+
+import androidx.annotation.Keep;
+import androidx.annotation.VisibleForTesting;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Supports to parse 2 types of QR code
+ *
+ * 1. Standard Wi-Fi DPP bootstrapping information or
+ * 2. ZXing reader library's Wi-Fi Network config format described in
+ * https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11
+ *
+ * ZXing reader library's Wi-Fi Network config format example:
+ *
+ * WIFI:T:WPA;S:mynetwork;P:mypass;;
+ *
+ * parameter Example Description
+ * T WPA Authentication type; can be WEP or WPA, or 'nopass' for no password. Or,
+ * omit for no password.
+ * S mynetwork Network SSID. Required. Enclose in double quotes if it is an ASCII name,
+ * but could be interpreted as hex (i.e. "ABCD")
+ * P mypass Password, ignored if T is "nopass" (in which case it may be omitted).
+ * Enclose in double quotes if it is an ASCII name, but could be interpreted as
+ * hex (i.e. "ABCD")
+ * H true Optional. True if the network SSID is hidden.
+ *
+ */
+@Keep
+public class WifiQrCode {
+ public static final String SCHEME_DPP = "DPP";
+ public static final String SCHEME_ZXING_WIFI_NETWORK_CONFIG = "WIFI";
+ public static final String PREFIX_DPP = "DPP:";
+ public static final String PREFIX_ZXING_WIFI_NETWORK_CONFIG = "WIFI:";
+
+ public static final String PREFIX_DPP_PUBLIC_KEY = "K:";
+ public static final String PREFIX_DPP_INFORMATION = "I:";
+
+ public static final String PREFIX_ZXING_SECURITY = "T:";
+ public static final String PREFIX_ZXING_SSID = "S:";
+ public static final String PREFIX_ZXING_PASSWORD = "P:";
+ public static final String PREFIX_ZXING_HIDDEN_SSID = "H:";
+
+ public static final String SUFFIX_QR_CODE = ";";
+
+ private String mQrCode;
+
+ /**
+ * SCHEME_DPP for standard Wi-Fi device provision protocol; SCHEME_ZXING_WIFI_NETWORK_CONFIG
+ * for ZXing reader library' Wi-Fi Network config format
+ */
+ private String mScheme;
+
+ // Data from parsed Wi-Fi DPP QR code
+ private String mPublicKey;
+ private String mInformation;
+
+ // Data from parsed ZXing reader library's Wi-Fi Network config format
+ private WifiNetworkConfig mWifiNetworkConfig;
+
+ @Keep
+ public WifiQrCode(String qrCode) throws IllegalArgumentException {
+ if (TextUtils.isEmpty(qrCode)) {
+ throw new IllegalArgumentException("Empty QR code");
+ }
+
+ mQrCode = qrCode;
+
+ if (qrCode.startsWith(PREFIX_DPP)) {
+ mScheme = SCHEME_DPP;
+ parseWifiDppQrCode(qrCode);
+ } else if (qrCode.startsWith(PREFIX_ZXING_WIFI_NETWORK_CONFIG)) {
+ mScheme = SCHEME_ZXING_WIFI_NETWORK_CONFIG;
+ parseZxingWifiQrCode(qrCode);
+ } else {
+ throw new IllegalArgumentException("Invalid scheme");
+ }
+ }
+
+ /** Parses Wi-Fi DPP QR code string */
+ private void parseWifiDppQrCode(String qrCode) throws IllegalArgumentException {
+ String publicKey = getSubStringOrNull(qrCode, PREFIX_DPP_PUBLIC_KEY, SUFFIX_QR_CODE);
+ if (TextUtils.isEmpty(publicKey)) {
+ throw new IllegalArgumentException("Invalid format");
+ }
+ mPublicKey = publicKey;
+
+ mInformation = getSubStringOrNull(qrCode, PREFIX_DPP_INFORMATION, SUFFIX_QR_CODE);
+ }
+
+ /** Parses ZXing reader library's Wi-Fi Network config format */
+ private void parseZxingWifiQrCode(String qrCode) throws IllegalArgumentException {
+ String security = getSubStringOrNull(qrCode, PREFIX_ZXING_SECURITY, SUFFIX_QR_CODE);
+ String ssid = getSubStringOrNull(qrCode, PREFIX_ZXING_SSID, SUFFIX_QR_CODE);
+ String password = getSubStringOrNull(qrCode, PREFIX_ZXING_PASSWORD, SUFFIX_QR_CODE);
+ String hiddenSsidString = getSubStringOrNull(qrCode, PREFIX_ZXING_HIDDEN_SSID,
+ SUFFIX_QR_CODE);
+ boolean hiddenSsid = "true".equalsIgnoreCase(hiddenSsidString);
+
+ //"\", ";", "," and ":" are escaped with a backslash "\", should remove at first
+ security = removeBackSlash(security);
+ ssid = removeBackSlash(ssid);
+ password = removeBackSlash(password);
+
+ mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid, password,
+ hiddenSsid);
+
+ if (mWifiNetworkConfig == null) {
+ throw new IllegalArgumentException("Invalid format");
+ }
+ }
+
+ /**
+ * Gets the substring between prefix & suffix from input.
+ *
+ * @param prefix the string before the returned substring
+ * @param suffix the string after the returned substring
+ * @return null if not exists, non-null otherwise
+ */
+ private static String getSubStringOrNull(String input, String prefix, String suffix) {
+ StringBuilder sb = new StringBuilder();
+ String regex = sb.append(prefix).append("(.*?)").append(suffix).toString();
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(input);
+
+ if (!matcher.find()) {
+ return null;
+ }
+
+ String target = matcher.group(1);
+ if (TextUtils.isEmpty(target)) {
+ return null;
+ }
+
+ return target;
+ }
+
+ @Keep
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected static String removeBackSlash(String input) {
+ if (input == null) {
+ return null;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ boolean backSlash = false;
+ for (char ch : input.toCharArray()) {
+ if (ch != '\\') {
+ sb.append(ch);
+ backSlash = false;
+ } else {
+ if (backSlash) {
+ sb.append(ch);
+ backSlash = false;
+ continue;
+ }
+
+ backSlash = true;
+ }
+ }
+
+ return sb.toString();
+ }
+
+ @Keep
+ public String getQrCode() {
+ return mQrCode;
+ }
+
+ /**
+ * Uses to check type of QR code
+ *
+ * SCHEME_DPP for standard Wi-Fi device provision protocol; SCHEME_ZXING_WIFI_NETWORK_CONFIG
+ * for ZXing reader library' Wi-Fi Network config format
+ */
+ @Keep
+ public String getScheme() {
+ return mScheme;
+ }
+
+ /** Available when {@code getScheme()} returns SCHEME_DPP */
+ @Keep
+ public String getPublicKey() {
+ return mPublicKey;
+ }
+
+ /** May be available when {@code getScheme()} returns SCHEME_DPP */
+ @Keep
+ public String getInformation() {
+ return mInformation;
+ }
+
+ /** Available when {@code getScheme()} returns SCHEME_ZXING_WIFI_NETWORK_CONFIG */
+ @Keep
+ public WifiNetworkConfig getWifiNetworkConfig() {
+ if (mWifiNetworkConfig == null) {
+ return null;
+ }
+
+ return new WifiNetworkConfig(mWifiNetworkConfig);
+ }
+}
diff --git a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
new file mode 100644
index 0000000..fa8c267
--- /dev/null
+++ b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.slice;
+
+import android.content.Context;
+import android.net.Uri;
+import android.net.wifi.WifiSsid;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.slice.Slice;
+
+import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.CustomSliceable;
+
+/**
+ * {@link CustomSliceable} for Wi-Fi, used by contextual homepage.
+ */
+public class ContextualWifiSlice extends WifiSlice {
+
+ private static final String TAG = "ContextualWifiSlice";
+ @VisibleForTesting
+ boolean mPreviouslyDisplayed;
+
+ public ContextualWifiSlice(Context context) {
+ super(context);
+ }
+
+ @Override
+ public Uri getUri() {
+ return CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
+ }
+
+ @Override
+ public Slice getSlice() {
+ if (!mPreviouslyDisplayed && !TextUtils.equals(getActiveSSID(), WifiSsid.NONE)) {
+ Log.d(TAG, "Wifi is connected, no point showing any suggestion.");
+ return null;
+ }
+ // Set mPreviouslyDisplayed to true - we will show *something* on the screen. So we should
+ // keep showing this card to keep UI stable, even if wifi connects to a network later.
+ mPreviouslyDisplayed = true;
+
+ return super.getSlice();
+ }
+}
diff --git a/src/com/android/settings/wifi/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
similarity index 95%
rename from src/com/android/settings/wifi/WifiSlice.java
rename to src/com/android/settings/wifi/slice/WifiSlice.java
index 9f05783..4d3a95a 100644
--- a/src/com/android/settings/wifi/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.wifi;
+package com.android.settings.wifi.slice;
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import static android.provider.SettingsSlicesContract.KEY_WIFI;
@@ -46,6 +46,8 @@
import com.android.settings.slices.CustomSliceable;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settings.slices.SliceBuilderUtils;
+import com.android.settings.wifi.WifiDialogActivity;
+import com.android.settings.wifi.WifiSettings;
import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.WifiTracker;
@@ -54,15 +56,15 @@
import java.util.List;
/**
- * Utility class to build a Wifi Slice, and handle all associated actions.
+ * {@link CustomSliceable} for Wi-Fi, used by generic clients.
*/
public class WifiSlice implements CustomSliceable {
@VisibleForTesting
static final int DEFAULT_EXPANDED_ROW_COUNT = 3;
+ protected final WifiManager mWifiManager;
private final Context mContext;
- private final WifiManager mWifiManager;
public WifiSlice(Context context) {
mContext = context;
@@ -77,6 +79,7 @@
@Override
public Slice getSlice() {
final boolean isWifiEnabled = isWifiEnabled();
+
final IconCompat icon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_wireless);
final String title = mContext.getString(R.string.wifi_settings);
@@ -208,6 +211,13 @@
return intent;
}
+ protected String getActiveSSID() {
+ if (mWifiManager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
+ return WifiSsid.NONE;
+ }
+ return WifiInfo.removeDoubleQuotes(mWifiManager.getConnectionInfo().getSSID());
+ }
+
private boolean isWifiEnabled() {
switch (mWifiManager.getWifiState()) {
case WifiManager.WIFI_STATE_ENABLED:
@@ -221,8 +231,7 @@
private CharSequence getSummary() {
switch (mWifiManager.getWifiState()) {
case WifiManager.WIFI_STATE_ENABLED:
- final String ssid = WifiInfo.removeDoubleQuotes(mWifiManager.getConnectionInfo()
- .getSSID());
+ final String ssid = getActiveSSID();
if (TextUtils.equals(ssid, WifiSsid.NONE)) {
return mContext.getText(R.string.disconnected);
}
diff --git a/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml b/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
index 50e2a37..83eb781 100644
--- a/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
+++ b/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
@@ -21,8 +21,7 @@
android:id="@+id/setup_wizard_layout"
style="?attr/fingerprint_layout_theme"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sucFooter="@layout/fingerprint_enroll_find_sensor_base_footer">
+ android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
diff --git a/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java b/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java
index 6c57309..e98ca31 100644
--- a/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java
@@ -25,7 +25,6 @@
import android.app.Application;
import android.content.Intent;
import android.net.Uri;
-import android.os.SystemProperties;
import org.junit.Before;
import org.junit.Test;
@@ -66,8 +65,6 @@
@Test
public void testOnCreateWithValidHtmlFile() {
- SystemProperties.set("ro.config.license_path", "/system/etc/NOTICE.html.gz");
-
doReturn(true).when(mActivity).isFileValid(any());
mActivity.onCreate(null);
diff --git a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
index 6007791..f718a67 100644
--- a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
@@ -19,7 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Intent;
-import android.os.SystemProperties;
+import android.sysprop.SetupWizardProperties;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;
@@ -47,8 +47,7 @@
@Test
public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
- SystemProperties.set(SetupWizardUtils.SYSTEM_PROP_SETUPWIZARD_THEME,
- ThemeHelper.THEME_GLIF);
+ SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
Intent intent = new Intent();
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
@@ -57,8 +56,7 @@
@Test
public void testGetTheme_withEmptyIntent_shouldReturnSystemProperty() {
- SystemProperties.set(SetupWizardUtils.SYSTEM_PROP_SETUPWIZARD_THEME,
- ThemeHelper.THEME_GLIF_V2_LIGHT);
+ SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
Intent intent = new Intent();
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
@@ -66,8 +64,7 @@
@Test
public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
- SystemProperties.set(SetupWizardUtils.SYSTEM_PROP_SETUPWIZARD_THEME,
- ThemeHelper.THEME_GLIF_V3_LIGHT);
+ SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
Intent intent = new Intent();
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index db14cca..951f203 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -33,7 +33,6 @@
import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.Intent;
-import android.content.IntentFilter;
import androidx.preference.Preference;
@@ -51,13 +50,13 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowApplication;
import java.util.ArrayList;
import java.util.List;
@@ -76,6 +75,7 @@
private Activity mContext;
private Preference mHearingAidPreference;
private AccessibilityHearingAidPreferenceController mPreferenceController;
+ private ShadowApplication mShadowApplication;
@Mock
private CachedBluetoothDevice mCachedBluetoothDevice;
@@ -91,6 +91,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mShadowApplication = ShadowApplication.getInstance();
mContext = spy(Robolectric.setupActivity(Activity.class));
setupBluetoothEnvironment();
setupHearingAidEnvironment();
@@ -202,11 +203,9 @@
}
private void sendIntent(Intent intent) {
- ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor =
- ArgumentCaptor.forClass(BroadcastReceiver.class);
- verify(mContext).registerReceiver(broadcastReceiverCaptor.capture(), any());
- BroadcastReceiver br = broadcastReceiverCaptor.getValue();
- br.onReceive(mContext, intent);
+ for (BroadcastReceiver receiver : mShadowApplication.getReceiversForIntent(intent)) {
+ receiver.onReceive(mContext, intent);
+ }
}
private List<BluetoothDevice> generateHearingAidDeviceList() {
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
index d6adb5c..67c03d5 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
@@ -37,6 +37,9 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -133,8 +136,8 @@
@Test
public void clickSkip_shouldReturnResultSkip() {
- Button skipButton = mActivity.findViewById(R.id.skip_button);
- skipButton.performClick();
+ PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
assertThat(shadowActivity.getResultCode()).named("result code")
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java
index 76dc736..82124f9 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java
@@ -31,6 +31,9 @@
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
import com.android.settings.testutils.shadow.ShadowUserManager;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -62,7 +65,10 @@
mController.create().resume();
- final Button cancelButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
+ PartnerCustomizationLayout layout =
+ mController.get().findViewById(R.id.setup_wizard_layout);
+ final Button cancelButton =
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
assertThat(cancelButton.getText().toString()).isEqualTo("Cancel");
assertThat(cancelButton.getVisibility()).named("Cancel visible").isEqualTo(View.VISIBLE);
cancelButton.performClick();
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
index 7e97149..b112c8a 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
@@ -32,6 +32,9 @@
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -71,8 +74,8 @@
Robolectric.buildActivity(SetupFingerprintEnrollFindSensor.class,
intent).setup().get();
- final Button skipButton = activity.findViewById(R.id.skip_button);
- skipButton.performClick();
+ PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().performClick();
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
index d9d9197..12bf1e2 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
@@ -37,6 +37,9 @@
import com.android.settings.testutils.shadow.ShadowStorageManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -83,7 +86,10 @@
mController.create().resume();
- final Button skipButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
+ PartnerCustomizationLayout layout =
+ mController.get().findViewById(R.id.setup_wizard_layout);
+ final Button skipButton =
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
assertThat(skipButton.getVisibility()).named("Skip visible").isEqualTo(View.VISIBLE);
skipButton.performClick();
@@ -99,7 +105,10 @@
mController.create().resume();
- final Button skipButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
+ PartnerCustomizationLayout layout =
+ mController.get().findViewById(R.id.setup_wizard_layout);
+ final Button skipButton =
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
assertThat(skipButton.getVisibility()).named("Skip visible").isEqualTo(View.VISIBLE);
skipButton.performClick();
@@ -141,7 +150,9 @@
getShadowKeyguardManager().setIsKeyguardSecure(false);
SetupFingerprintEnrollIntroduction activity = mController.create().resume().get();
- final Button skipButton = activity.findViewById(R.id.fingerprint_cancel_button);
+ PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ final Button skipButton =
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
getShadowKeyguardManager().setIsKeyguardSecure(true);
skipButton.performClick();
@@ -156,7 +167,9 @@
getShadowKeyguardManager().setIsKeyguardSecure(true);
SetupFingerprintEnrollIntroduction activity = mController.create().resume().get();
- final Button skipButton = activity.findViewById(R.id.fingerprint_cancel_button);
+ PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ final Button skipButton =
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
skipButton.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
@@ -199,8 +212,9 @@
SetupFingerprintEnrollIntroduction activity = mController.get();
- final Button nextButton = activity.findViewById(R.id.fingerprint_next_button);
- nextButton.performClick();
+ PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getPrimaryButtonView().performClick();
+
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
index b698b3a..7c6a305 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
@@ -15,6 +15,11 @@
*/
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
@@ -22,7 +27,6 @@
import android.content.Context;
import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
import com.android.settings.R;
import com.android.settings.connecteddevice.DevicePreferenceCallback;
@@ -78,7 +82,7 @@
public void initUsbPreference_usbConnected_preferenceAdded() {
mDeviceUpdater.initUsbPreference(mContext);
mDeviceUpdater.mUsbConnectionListener.onUsbConnectionChanged(true /* connected */,
- UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+ UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
verify(mDevicePreferenceCallback).onDeviceAdded(mDeviceUpdater.mUsbPreference);
}
@@ -87,7 +91,7 @@
public void initUsbPreference_usbDisconnected_preferenceRemoved() {
mDeviceUpdater.initUsbPreference(mContext);
mDeviceUpdater.mUsbConnectionListener.onUsbConnectionChanged(false /* connected */,
- UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ UsbManager.FUNCTION_NONE, POWER_ROLE_NONE, DATA_ROLE_NONE);
verify(mDevicePreferenceCallback).onDeviceRemoved(mDeviceUpdater.mUsbPreference);
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
index 333d2b6..4e5897d 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
@@ -16,6 +16,11 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
@@ -40,6 +45,8 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import java.util.Collections;
+
@RunWith(RobolectricTestRunner.class)
public class UsbBackendTest {
@@ -64,9 +71,9 @@
when((Object) mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
.thenReturn(mConnectivityManager);
- when(mUsbManager.getPorts()).thenReturn(new UsbPort[] {mUsbPort});
+ when(mUsbManager.getPorts()).thenReturn(Collections.singletonList(mUsbPort));
when(mUsbPortStatus.isConnected()).thenReturn(true);
- when(mUsbManager.getPortStatus(mUsbPort)).thenReturn(mUsbPortStatus);
+ when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
}
@Test
@@ -74,22 +81,22 @@
final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+ .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST))
+ .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE))
+ .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+ .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
.thenReturn(true);
- when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(POWER_ROLE_SINK);
- usbBackend.setDataRole(UsbPort.DATA_ROLE_HOST);
+ usbBackend.setDataRole(DATA_ROLE_HOST);
- verify(mUsbManager).setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST);
+ verify(mUsbPort).setRoles(POWER_ROLE_SINK, DATA_ROLE_HOST);
}
@Test
@@ -97,17 +104,16 @@
final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+ .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+ .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
.thenReturn(true);
- when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(POWER_ROLE_SINK);
- usbBackend.setDataRole(UsbPort.DATA_ROLE_HOST);
+ usbBackend.setDataRole(DATA_ROLE_HOST);
- verify(mUsbManager)
- .setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+ verify(mUsbPort).setRoles(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
}
@Test
@@ -115,23 +121,22 @@
final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+ .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST))
+ .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE))
+ .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+ .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
.thenReturn(true);
- when(mUsbPortStatus.getCurrentDataRole()).thenReturn(UsbPort.DATA_ROLE_DEVICE);
+ when(mUsbPortStatus.getCurrentDataRole()).thenReturn(DATA_ROLE_DEVICE);
- usbBackend.setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ usbBackend.setPowerRole(POWER_ROLE_SOURCE);
- verify(mUsbManager)
- .setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE);
+ verify(mUsbPort).setRoles(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE);
}
@Test
@@ -139,17 +144,16 @@
final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+ .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
.thenReturn(true);
when(mUsbPortStatus
- .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+ .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
.thenReturn(true);
- when(mUsbPortStatus.getCurrentDataRole()).thenReturn(UsbPort.DATA_ROLE_DEVICE);
+ when(mUsbPortStatus.getCurrentDataRole()).thenReturn(DATA_ROLE_DEVICE);
- usbBackend.setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ usbBackend.setPowerRole(POWER_ROLE_SOURCE);
- verify(mUsbManager)
- .setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+ verify(mUsbPort).setRoles(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
index 1689ee7..1da97f5 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
@@ -15,6 +15,11 @@
*/
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
@@ -22,7 +27,6 @@
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
import org.junit.Before;
@@ -63,7 +67,7 @@
mReceiver.onReceive(mContext, intent);
verify(mListener).onUsbConnectionChanged(true /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
}
@Test
@@ -75,7 +79,7 @@
mReceiver.onReceive(mContext, intent);
verify(mListener).onUsbConnectionChanged(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
}
@Test
@@ -89,21 +93,21 @@
mReceiver.onReceive(mContext, intent);
verify(mListener).onUsbConnectionChanged(true /* connected */, UsbManager.FUNCTION_MTP,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
}
@Test
public void onReceive_usbPortStatus_invokeCallback() {
final Intent intent = new Intent();
intent.setAction(UsbManager.ACTION_USB_PORT_CHANGED);
- final UsbPortStatus status = new UsbPortStatus(0, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE, 0);
+ final UsbPortStatus status = new UsbPortStatus(0, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE, 0);
intent.putExtra(UsbManager.EXTRA_PORT_STATUS, status);
mReceiver.onReceive(mContext, intent);
verify(mListener).onUsbConnectionChanged(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+ POWER_ROLE_SINK, DATA_ROLE_DEVICE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java
index 3eda3d1..91e680b 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java
@@ -16,6 +16,12 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyLong;
@@ -24,7 +30,6 @@
import android.content.Context;
import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
import android.os.Handler;
import androidx.fragment.app.FragmentActivity;
@@ -92,11 +97,11 @@
public void displayRefresh_deviceRole_shouldCheckDevice() {
mDetailsDataRoleController.displayPreference(mScreen);
- mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
- final RadioButtonPreference hostPref = getRadioPreference(UsbPort.DATA_ROLE_HOST);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
+ final RadioButtonPreference hostPref = getRadioPreference(DATA_ROLE_HOST);
assertThat(devicePref.isChecked()).isTrue();
assertThat(hostPref.isChecked()).isFalse();
}
@@ -105,11 +110,11 @@
public void displayRefresh_hostRole_shouldCheckHost() {
mDetailsDataRoleController.displayPreference(mScreen);
- mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_HOST);
+ mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_HOST);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
- final RadioButtonPreference hostPref = getRadioPreference(UsbPort.DATA_ROLE_HOST);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
+ final RadioButtonPreference hostPref = getRadioPreference(DATA_ROLE_HOST);
assertThat(devicePref.isChecked()).isFalse();
assertThat(hostPref.isChecked()).isTrue();
}
@@ -118,8 +123,8 @@
public void displayRefresh_disconnected_shouldDisable() {
mDetailsDataRoleController.displayPreference(mScreen);
- mDetailsDataRoleController.refresh(false, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsDataRoleController.refresh(false, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
assertThat(mPreference.isEnabled()).isFalse();
}
@@ -127,12 +132,12 @@
@Test
public void onClickDevice_hostEnabled_shouldSetDevice() {
mDetailsDataRoleController.displayPreference(mScreen);
- when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+ when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
- verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+ verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
assertThat(devicePref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
}
@@ -140,50 +145,50 @@
@Test
public void onClickDeviceTwice_hostEnabled_shouldSetDeviceOnce() {
mDetailsDataRoleController.displayPreference(mScreen);
- when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+ when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
assertThat(devicePref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
devicePref.performClick();
- verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+ verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
}
@Test
public void onClickDeviceAndRefresh_success_shouldClearSubtext() {
mDetailsDataRoleController.displayPreference(mScreen);
- when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+ when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
- verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+ verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
assertThat(devicePref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsDataRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
mDetailsDataRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+ POWER_ROLE_SINK, DATA_ROLE_DEVICE);
assertThat(devicePref.getSummary()).isEqualTo("");
}
@Test
public void onClickDeviceAndRefresh_failed_shouldShowFailureText() {
mDetailsDataRoleController.displayPreference(mScreen);
- when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+ when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
- verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+ verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
assertThat(devicePref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsDataRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
mDetailsDataRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST);
+ POWER_ROLE_SINK, DATA_ROLE_HOST);
assertThat(devicePref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching_failed));
}
@@ -191,18 +196,18 @@
@Test
public void onClickDevice_timedOut_shouldShowFailureText() {
mDetailsDataRoleController.displayPreference(mScreen);
- when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+ when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
- final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+ final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
- verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+ verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(mHandler).postDelayed(captor.capture(), anyLong());
assertThat(devicePref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsDataRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
captor.getValue().run();
assertThat(devicePref.getSummary())
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
index fc93a58..11fa613 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
@@ -16,6 +16,8 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
import static android.net.ConnectivityManager.TETHERING_USB;
import static com.google.common.truth.Truth.assertThat;
@@ -105,8 +107,8 @@
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
mDetailsFunctionsController.displayPreference(mScreen);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
List<RadioButtonPreference> prefs = getRadioPreferences();
Iterator<Long> iter = UsbDetailsFunctionsController.FUNCTIONS_MAP.keySet().iterator();
@@ -120,7 +122,7 @@
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
mDetailsFunctionsController.refresh(false, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+ POWER_ROLE_SINK, DATA_ROLE_DEVICE);
assertThat(mPreferenceCategory.isEnabled()).isFalse();
}
@@ -131,8 +133,8 @@
when(mUsbBackend.areFunctionsSupported(UsbManager.FUNCTION_PTP)).thenReturn(false);
when(mUsbBackend.areFunctionsSupported(UsbManager.FUNCTION_RNDIS)).thenReturn(false);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
List<RadioButtonPreference> prefs = getRadioPreferences();
assertThat(prefs.size()).isEqualTo(1);
assertThat(prefs.get(0).getKey())
@@ -143,8 +145,8 @@
public void displayRefresh_mtpEnabled_shouldCheckSwitches() {
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
List<RadioButtonPreference> prefs = getRadioPreferences();
assertThat(prefs.get(0).getKey())
@@ -156,8 +158,8 @@
public void onClickMtp_noneEnabled_shouldEnableMtp() {
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_NONE);
List<RadioButtonPreference> prefs = getRadioPreferences();
prefs.get(0).performClick();
@@ -165,8 +167,8 @@
assertThat(prefs.get(0).getKey())
.isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_MTP);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
assertThat(prefs.get(0).isChecked()).isTrue();
}
@@ -174,8 +176,8 @@
public void onClickMtp_ptpEnabled_shouldEnableMtp() {
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_PTP, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_PTP, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_PTP);
List<RadioButtonPreference> prefs = getRadioPreferences();
prefs.get(0).performClick();
@@ -183,8 +185,8 @@
assertThat(prefs.get(0).getKey())
.isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_MTP);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
assertThat(prefs.get(0).isChecked()).isTrue();
assertThat(prefs.get(3).getKey())
.isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_PTP));
@@ -195,8 +197,8 @@
public void onClickNone_mtpEnabled_shouldDisableMtp() {
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_MTP);
List<RadioButtonPreference> prefs = getRadioPreferences();
prefs.get(4).performClick();
@@ -204,8 +206,8 @@
assertThat(prefs.get(4).getKey())
.isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_NONE));
verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_NONE);
- mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
assertThat(prefs.get(0).isChecked()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
index d72214f..280b8d4 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
@@ -16,6 +16,9 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -101,8 +104,8 @@
@Test
public void displayRefresh_charging_shouldSetHeader() {
mDetailsHeaderController.displayPreference(mScreen);
- mDetailsHeaderController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsHeaderController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
verify(mHeaderController).setLabel(mContext.getString(R.string.usb_pref));
verify(mHeaderController).setIcon(argThat((ArgumentMatcher<Drawable>) t -> {
DrawableTestHelper.assertDrawableResId(t, R.drawable.ic_usb);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java
index b16a453..aa62741 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java
@@ -16,6 +16,13 @@
package com.android.settings.connecteddevice.usb;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyLong;
@@ -25,7 +32,6 @@
import android.content.Context;
import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
import android.os.Handler;
import androidx.fragment.app.FragmentActivity;
@@ -95,8 +101,8 @@
mDetailsPowerRoleController.displayPreference(mScreen);
when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
- mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
SwitchPreference pref = getPreference();
assertThat(pref.isChecked()).isFalse();
@@ -108,7 +114,7 @@
when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+ POWER_ROLE_SOURCE, DATA_ROLE_HOST);
SwitchPreference pref = getPreference();
assertThat(pref.isChecked()).isTrue();
@@ -120,7 +126,7 @@
when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
mDetailsPowerRoleController.refresh(false, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+ POWER_ROLE_SINK, DATA_ROLE_DEVICE);
assertThat(mPreference.isEnabled()).isFalse();
assertThat((Preference) mScreen.findPreference(
@@ -132,8 +138,8 @@
mDetailsPowerRoleController.displayPreference(mScreen);
when(mUsbBackend.areAllRolesSupported()).thenReturn(false);
- mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
- UsbPort.DATA_ROLE_DEVICE);
+ mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+ DATA_ROLE_DEVICE);
assertThat((Preference) mScreen.findPreference(
mDetailsPowerRoleController.getPreferenceKey())).isNull();
@@ -142,12 +148,12 @@
@Test
public void onClick_sink_shouldSetSource() {
mDetailsPowerRoleController.displayPreference(mScreen);
- when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
SwitchPreference pref = getPreference();
pref.performClick();
- verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
}
@@ -155,7 +161,7 @@
@Test
public void onClickTwice_sink_shouldSetSourceOnce() {
mDetailsPowerRoleController.displayPreference(mScreen);
- when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
SwitchPreference pref = getPreference();
pref.performClick();
@@ -163,42 +169,42 @@
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
pref.performClick();
- verify(mUsbBackend, times(1)).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ verify(mUsbBackend, times(1)).setPowerRole(POWER_ROLE_SOURCE);
}
@Test
public void onClickDeviceAndRefresh_success_shouldClearSubtext() {
mDetailsPowerRoleController.displayPreference(mScreen);
- when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
SwitchPreference pref = getPreference();
pref.performClick();
- verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsPowerRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
mDetailsPowerRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE);
+ POWER_ROLE_SOURCE, DATA_ROLE_DEVICE);
assertThat(pref.getSummary()).isEqualTo("");
}
@Test
public void onClickDeviceAndRefresh_failed_shouldShowFailureText() {
mDetailsPowerRoleController.displayPreference(mScreen);
- when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
SwitchPreference pref = getPreference();
pref.performClick();
- verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsPowerRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
mDetailsPowerRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+ POWER_ROLE_SINK, DATA_ROLE_DEVICE);
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching_failed));
}
@@ -206,18 +212,18 @@
@Test
public void onClickDevice_timedOut_shouldShowFailureText() {
mDetailsPowerRoleController.displayPreference(mScreen);
- when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+ when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
SwitchPreference pref = getPreference();
pref.performClick();
- verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+ verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(mHandler).postDelayed(captor.capture(), anyLong());
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsPowerRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
- UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+ POWER_ROLE_NONE, DATA_ROLE_NONE);
captor.getValue().run();
assertThat(pref.getSummary())
.isEqualTo(mContext.getString(R.string.usb_switching_failed));
diff --git a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
index 8b006fc..dc466df 100644
--- a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
@@ -19,6 +19,7 @@
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.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -40,7 +41,6 @@
import com.android.settings.R;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -52,6 +52,8 @@
import org.robolectric.shadows.ShadowPackageManager;
import org.robolectric.util.ReflectionHelpers;
+import java.util.Arrays;
+
@RunWith(RobolectricTestRunner.class)
public class DevelopmentTilePreferenceControllerTest {
@@ -83,7 +85,6 @@
}
@Test
- @Ignore("b/119829673")
public void display_hasTileService_shouldDisplay() {
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE)
.setPackage(mContext.getPackageName());
@@ -92,11 +93,11 @@
info.serviceInfo.name = "abc";
info.serviceInfo.icon = R.drawable.ic_settings_24dp;
info.serviceInfo.packageName = mContext.getPackageName();
- mShadowPackageManager.addResolveInfoForIntent(tileProbe, info);
+ mShadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
mController.displayPreference(mScreen);
- verify(mScreen).addPreference(any(Preference.class));
+ verify(mScreen, atLeastOnce()).addPreference(any(Preference.class));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index 101ca75..c62a6bb 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -145,7 +145,7 @@
cards.add(new ContextualCard.Builder()
.setName("test_wifi")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(CustomSliceRegistry.WIFI_SLICE_URI)
+ .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI)
.build());
cards.add(new ContextualCard.Builder()
.setName("test_flashlight")
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
index 8f36ea5..d4b67f5 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
@@ -70,11 +70,12 @@
}
@Test
- public void getContextualCards_wifiSlice_shouldGetCorrectCategory() {
+ public void getContextualCards_wifiSlice_shouldGetImportantCategory() {
final ContextualCardList cards = mProvider.getContextualCards();
ContextualCard wifiCard = null;
for (ContextualCard card : cards.getCardList()) {
- if (card.getSliceUri().equals(CustomSliceRegistry.WIFI_SLICE_URI.toString())) {
+ if (card.getSliceUri().equals(
+ CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())) {
wifiCard = card;
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
index 3407ee3..0b87525 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
@@ -128,7 +128,7 @@
public void longClick_shouldFlipCard() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final View card = viewHolder.itemView.findViewById(R.id.slice_view);
- final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.viewFlipper);
+ final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
final View dismissalView = viewHolder.itemView.findViewById(R.id.dismissal_view);
mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
@@ -153,7 +153,7 @@
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final View card = viewHolder.itemView.findViewById(R.id.slice_view);
final Button btnKeep = viewHolder.itemView.findViewById(R.id.keep);
- final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.viewFlipper);
+ final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
card.performLongClick();
@@ -212,7 +212,7 @@
public void onStop_cardIsFlipped_shouldFlipBack() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final View card = viewHolder.itemView.findViewById(R.id.slice_view);
- final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.viewFlipper);
+ final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
card.performLongClick();
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index 016a885..7053699 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -16,33 +16,40 @@
package com.android.settings.network;
+import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.Preference;
@@ -70,7 +77,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
+ mContext = spy(Robolectric.setupActivity(Activity.class));
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
@@ -83,6 +90,11 @@
KEY, 5);
}
+ @After
+ public void tearDown() {
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(null);
+ }
+
@Test
public void isAvailable_oneSubscription_availableFalse() {
SubscriptionUtil.setAvailableSubscriptionsForTesting(
@@ -215,4 +227,57 @@
verify(mPreferenceCategory, times(3)).addPreference(captor.capture());
assertThat(captor.getValue().getTitle()).isEqualTo("sub3");
}
+
+
+ /**
+ * Helper to create a specified number of subscriptions, display them, and then click on one and
+ * verify that the intent fires and has the right subscription id extra.
+ *
+ * @param subscriptionCount the number of subscriptions
+ * @param selectedPrefIndex index of the subscription to click on
+ */
+ private void runPreferenceClickTest(int subscriptionCount, int selectedPrefIndex) {
+ final ArrayList<SubscriptionInfo> subscriptions = new ArrayList<>();
+ for (int i = 0; i < subscriptionCount; i++) {
+ final SubscriptionInfo sub = mock(SubscriptionInfo.class);
+ doReturn(i + 1).when(sub).getSubscriptionId();
+ subscriptions.add(sub);
+ }
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(subscriptions);
+ mController.displayPreference(mScreen);
+ final ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
+ verify(mPreferenceCategory, times(subscriptionCount)).addPreference(prefCaptor.capture());
+ final List<Preference> prefs = prefCaptor.getAllValues();
+ final Preference pref = prefs.get(selectedPrefIndex);
+ pref.getOnPreferenceClickListener().onPreferenceClick(pref);
+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).startActivity(intentCaptor.capture());
+ final Intent intent = intentCaptor.getValue();
+ assertThat(intent).isNotNull();
+ assertThat(intent.hasExtra(Settings.EXTRA_SUB_ID)).isTrue();
+ final int subIdFromIntent = intent.getIntExtra(Settings.EXTRA_SUB_ID,
+ INVALID_SUBSCRIPTION_ID);
+ assertThat(subIdFromIntent).isEqualTo(
+ subscriptions.get(selectedPrefIndex).getSubscriptionId());
+ }
+
+ @Test
+ public void twoPreferences_firstPreferenceClicked_correctIntentFires() {
+ runPreferenceClickTest(2, 0);
+ }
+
+ @Test
+ public void twoPreferences_secondPreferenceClicked_correctIntentFires() {
+ runPreferenceClickTest(2, 1);
+ }
+
+ @Test
+ public void threePreferences_secondPreferenceClicked_correctIntentFires() {
+ runPreferenceClickTest(3, 1);
+ }
+
+ @Test
+ public void threePreferences_thirdPreferenceClicked_correctIntentFires() {
+ runPreferenceClickTest(3, 2);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index f13746c..29472f5 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -143,6 +143,9 @@
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, CURRENT_SUB_ID);
doReturn(intent).when(mMobileNetworkActivity).getIntent();
+ mSubscriptionInfos.add(mSubscriptionInfo);
+ mSubscriptionInfos.add(mSubscriptionInfo2);
+ doReturn(mSubscriptionInfos).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(CURRENT_SUB_ID);
assertThat(mMobileNetworkActivity.getSubscriptionId()).isEqualTo(CURRENT_SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 60f0d5d..1d79952 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -29,7 +29,7 @@
*/
public class FakePanelContent implements PanelContent {
- public static final String FAKE_KEY = "fake_key";
+ public static final String FAKE_ACTION = "fake_action";
public static final CharSequence TITLE = "title";
diff --git a/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java b/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java
index afd0bec..2a62b54 100644
--- a/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java
+++ b/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java
@@ -27,8 +27,7 @@
@Override
public Intent getIntent() {
- final Intent intent = new Intent();
- intent.putExtra(SettingsPanelActivity.EXTRA_PANEL_TYPE, FakePanelContent.FAKE_KEY);
+ final Intent intent = new Intent(FakePanelContent.FAKE_ACTION);
return intent;
}
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
index 754c937..99d5d6c 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
@@ -20,6 +20,7 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import android.provider.Settings;
import org.junit.Before;
import org.junit.Test;
@@ -43,8 +44,16 @@
@Test
public void getPanel_internetConnectivityKey_returnsCorrectPanel() {
final PanelContent panel = mProvider.getPanel(mContext,
- SettingsPanelActivity.PANEL_TYPE_WIFI);
+ Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
assertThat(panel).isInstanceOf(InternetConnectivityPanel.class);
}
+
+ @Test
+ public void getPanel_volume_returnsCorrectPanel() {
+ final PanelContent panel = mProvider.getPanel(mContext,
+ Settings.Panel.ACTION_VOLUME);
+
+ assertThat(panel).isInstanceOf(VolumePanel.class);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index b129267..7eae3e4 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -55,7 +55,7 @@
import com.android.settings.testutils.shadow.ShadowThreadUtils;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settings.testutils.shadow.ShadowUtils;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.wifi.slice.WifiSlice;
import com.android.settingslib.wifi.WifiTracker;
import org.junit.After;
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
new file mode 100644
index 0000000..bf5fba8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.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.wifi.slice;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.slice.Slice;
+import androidx.slice.SliceItem;
+import androidx.slice.SliceMetadata;
+import androidx.slice.SliceProvider;
+import androidx.slice.core.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SliceTester;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class ContextualWifiSliceTest {
+
+ private Context mContext;
+ private ContentResolver mResolver;
+ private WifiManager mWifiManager;
+ private ContextualWifiSlice mWifiSlice;
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mResolver = mock(ContentResolver.class);
+ doReturn(mResolver).when(mContext).getContentResolver();
+ mWifiManager = mContext.getSystemService(WifiManager.class);
+
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ mWifiManager.setWifiEnabled(true);
+
+ mWifiSlice = new ContextualWifiSlice(mContext);
+ }
+
+ @Test
+ public void getWifiSlice_hasActiveConnection_shouldReturnNull() {
+ final WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "123";
+ mWifiManager.connect(config, null /* listener */);
+
+ final Slice wifiSlice = mWifiSlice.getSlice();
+
+ assertThat(wifiSlice).isNull();
+ }
+
+ @Test
+ public void getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle() {
+ mWifiSlice.mPreviouslyDisplayed = true;
+ final WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "123";
+ mWifiManager.connect(config, null /* listener */);
+
+ final Slice wifiSlice = mWifiSlice.getSlice();
+ final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+
+ final List<SliceAction> toggles = metadata.getToggles();
+ assertThat(toggles).hasSize(1);
+
+ final SliceAction primaryAction = metadata.getPrimaryAction();
+ final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
+ R.drawable.ic_settings_wireless);
+ assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
+
+ final List<SliceItem> sliceItems = wifiSlice.getItems();
+ SliceTester.assertTitle(sliceItems, mContext.getString(R.string.wifi_settings));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
similarity index 96%
rename from tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
rename to tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 2d4dd04..3c78749 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -12,16 +12,15 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
-package com.android.settings.wifi;
+package com.android.settings.wifi.slice;
import static android.app.slice.Slice.HINT_LIST_ITEM;
import static android.app.slice.SliceItem.FORMAT_SLICE;
import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
-import static com.android.settings.wifi.WifiSlice.DEFAULT_EXPANDED_ROW_COUNT;
+import static com.android.settings.wifi.slice.WifiSlice.DEFAULT_EXPANDED_ROW_COUNT;
import static com.google.common.truth.Truth.assertThat;
@@ -29,7 +28,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import android.content.ContentResolver;
import android.content.Context;
diff --git a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinishTest.java b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinishTest.java
index 3a88873..0a46403 100644
--- a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinishTest.java
+++ b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinishTest.java
@@ -36,6 +36,9 @@
import com.android.settings.R;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,7 +60,9 @@
intending(hasComponent(enrollingComponent))
.respondWith(new ActivityResult(Activity.RESULT_CANCELED, null));
- onView(withId(R.id.add_another_button)).perform(click());
+ PartnerCustomizationLayout layout =
+ mActivityRule.getActivity().findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getPrimaryButtonView().performClick();
intended(hasComponent(enrollingComponent));
assertFalse(mActivityRule.getActivity().isFinishing());
@@ -72,7 +77,9 @@
intending(hasComponent(enrollingComponent))
.respondWith(new ActivityResult(Activity.RESULT_OK, null));
- onView(withId(R.id.add_another_button)).perform(click());
+ PartnerCustomizationLayout layout =
+ mActivityRule.getActivity().findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getPrimaryButtonView().performClick();
intended(hasComponent(enrollingComponent));
assertTrue(mActivityRule.getActivity().isFinishing());
diff --git a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
index e937b7f..5078cc2 100644
--- a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
+++ b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
@@ -32,6 +32,9 @@
import com.android.settings.R;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -80,7 +83,8 @@
final TextView errorTextView = (TextView) mActivity.findViewById(R.id.error_text);
assertNotNull(errorTextView.getText().toString());
- final Button nextButton = (Button) mActivity.findViewById(R.id.fingerprint_next_button);
+ PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
+ final Button nextButton = layout.getMixin(ButtonFooterMixin.class).getPrimaryButtonView();
assertEquals(View.GONE, nextButton.getVisibility());
}
diff --git a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
index be593a9..d068ce0 100644
--- a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
+++ b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
@@ -196,17 +196,6 @@
}
@Test
- public void noSavedNetworks_wifiEnabled_shouldNotShowSavedNetworksButton() {
- setWifiState(WifiManager.WIFI_STATE_ENABLED);
- when(mWifiTracker.getNumSavedNetworks()).thenReturn(0);
-
- launchActivity();
-
- onView(withText(resourceId(STRING, WIFI_SAVED_ACCESS_POINTS_LABEL))).check(
- matches(not(isDisplayed())));
- }
-
- @Test
public void noSavedNetworks_wifiDisabled_shouldNotShowSavedNetworksButton() {
setWifiState(WifiManager.WIFI_STATE_DISABLED);
when(mWifiTracker.getNumSavedNetworks()).thenReturn(0);
@@ -342,24 +331,4 @@
onView(withId(resourceId(ID, PASSWORD_LAYOUT))).check(matches(isDisplayed()));
onView(withId(resourceId(ID, PASSWORD))).check(matches(isDisplayed()));
}
-
- @Ignore("b/73796195")
- @Test
- public void onConnectedChanged_shouldNotFetchAPs() {
- setWifiState(WifiManager.WIFI_STATE_ENABLED);
- when(mWifiTracker.isConnected()).thenReturn(true);
-
- launchActivity();
-
- verify(mWifiTracker, times(1)).getAccessPoints();
- onView(withText(WIFI_DISPLAY_STATUS_CONNECTED)).check(matches(isDisplayed()));
-
- // Invoke onConnectedChanged
- when(mWifiTracker.isConnected()).thenReturn(false);
- mWifiListener.onConnectedChanged();
-
- // Verify no additional call to getAccessPoints
- getInstrumentation().waitForIdleSync();
- verify(mWifiTracker, times(1)).getAccessPoints();
- }
}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodetest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodetest.java
new file mode 100644
index 0000000..775ca48
--- /dev/null
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodetest.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.dpp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class WifiQrCodetest {
+ // Valid Wi-Fi DPP QR code & it's parameters
+ private static final String VALID_WIFI_DPP_QR_CODE = "DPP:I:SN=4774LH2b4044;M:010203040506;K:"
+ + "MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;";
+
+ private static final String PUBLIC_KEY_OF_VALID_WIFI_DPP_QR_CODE =
+ "MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=";
+
+ private static final String INFORMATION_OF_VALID_WIFI_DPP_QR_CODE =
+ "SN=4774LH2b4044";
+
+ // Valid ZXing reader library's Wi-Fi Network config format & it's parameters
+ private static final String VALID_ZXING_WIFI_QR_CODE =
+ "WIFI:T:WPA;S:mynetwork;P:mypass;H:true;;";
+
+ // Valid ZXing reader library's Wi-Fi Network config format - security type nopass and no password
+ private static final String VALID_ZXING_WIFI_QR_CODE_NOPASS_AND_NO_PASSWORD =
+ "WIFI:T:nopass;S:mynetwork;;";
+
+ // Valid ZXing reader library's Wi-Fi Network config format - no security and no password
+ private static final String VALID_ZXING_WIFI_QR_CODE_NO_SECURITY_AND_NO_PASSWORD =
+ "WIFI:T:;S:mynetwork;P:;H:false;;";
+
+ private static final String SECURITY_OF_VALID_ZXING_WIFI_QR_CODE = "WPA";
+ private static final String SECURITY_OF_VALID_ZXING_WIFI_QR_CODE_NOPASS = "nopass";
+ private static final String SSID_OF_VALID_ZXING_WIFI_QR_CODE = "mynetwork";
+ private static final String PASSWORD_OF_VALID_ZXING_WIFI_QR_CODE = "mypass";
+
+ // Invalid scheme QR code
+ private static final String INVALID_SCHEME_QR_CODE = "BT:T:WPA;S:mynetwork;P:mypass;H:true;;";
+
+ // Invalid Wi-Fi DPP QR code - no public key - case 1
+ private static final String INVALID_WIFI_DPP_QR_CODE_NO_PUBLIC_KEY_1 =
+ "DPP:I:SN=4774LH2b4044;M:010203040506;K:;;";
+
+ // Invalid Wi-Fi DPP QR code - no public key - case 2
+ private static final String INVALID_WIFI_DPP_QR_CODE_NO_PUBLIC_KEY_2 =
+ "DPP:I:SN=4774LH2b4044;M:010203040506;;";
+
+ // Invalid ZXing reader library's Wi-Fi Network config format - no password
+ private static final String INVALID_ZXING_WIFI_QR_CODE_NO_PASSWORD =
+ "WIFI:T:WPA;S:mynetwork;P:;;";
+
+ // Invalid ZXing reader library's Wi-Fi Network config format - no SSID
+ private static final String INVALID_ZXING_WIFI_QR_CODE_NO_SSID =
+ "WIFI:T:WPA;P:mypass;;";
+
+ @Test
+ public void parseValidWifiDppQrCode() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_WIFI_DPP_QR_CODE);
+
+ assertEquals(WifiQrCode.SCHEME_DPP, wifiQrCode.getScheme());
+ assertEquals(PUBLIC_KEY_OF_VALID_WIFI_DPP_QR_CODE, wifiQrCode.getPublicKey());
+ assertEquals(INFORMATION_OF_VALID_WIFI_DPP_QR_CODE, wifiQrCode.getInformation());
+ }
+
+ @Test
+ public void parseValidZxingWifiQrCode() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_ZXING_WIFI_QR_CODE);
+ WifiNetworkConfig config = wifiQrCode.getWifiNetworkConfig();
+
+ assertEquals(WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG, wifiQrCode.getScheme());
+ assertNotNull(config);
+ assertEquals(SECURITY_OF_VALID_ZXING_WIFI_QR_CODE, config.getSecurity());
+ assertEquals(SSID_OF_VALID_ZXING_WIFI_QR_CODE, config.getSsid());
+ assertEquals(PASSWORD_OF_VALID_ZXING_WIFI_QR_CODE, config.getPreSharedKey());
+ assertEquals(true, config.getHiddenSsid());
+ }
+
+ @Test
+ public void parseValidZxingWifiQrCode_noPass_and_no_password() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_ZXING_WIFI_QR_CODE_NOPASS_AND_NO_PASSWORD);
+ WifiNetworkConfig config = wifiQrCode.getWifiNetworkConfig();
+
+ assertEquals(WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG, wifiQrCode.getScheme());
+ assertNotNull(config);
+ assertEquals(SECURITY_OF_VALID_ZXING_WIFI_QR_CODE_NOPASS, config.getSecurity());
+ assertEquals(SSID_OF_VALID_ZXING_WIFI_QR_CODE, config.getSsid());
+ assertNull(config.getPreSharedKey());
+ assertEquals(false, config.getHiddenSsid());
+ }
+
+ @Test
+ public void parseValidZxingWifiQrCode_no_security_and_no_password() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_ZXING_WIFI_QR_CODE_NO_SECURITY_AND_NO_PASSWORD);
+ WifiNetworkConfig config = wifiQrCode.getWifiNetworkConfig();
+
+ assertEquals(WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG, wifiQrCode.getScheme());
+ assertNotNull(config);
+ assertNull(config.getSecurity());
+ assertEquals(SSID_OF_VALID_ZXING_WIFI_QR_CODE, config.getSsid());
+ assertNull(config.getPreSharedKey());
+ assertEquals(false, config.getHiddenSsid());
+ }
+
+ @Test
+ public void testRemoveBackSlash() {
+ assertEquals("\\", WifiQrCode.removeBackSlash("\\\\"));
+ assertEquals("ab", WifiQrCode.removeBackSlash("a\\b"));
+ assertEquals("a", WifiQrCode.removeBackSlash("\\a"));
+ assertEquals("\\b", WifiQrCode.removeBackSlash("\\\\b"));
+ assertEquals("c\\", WifiQrCode.removeBackSlash("c\\\\"));
+ }
+
+ @Test
+ public void parseEmptyQrCode_shouldThrowIllegalArgumentException() {
+ try {
+ new WifiQrCode(null);
+ fail("Null QR code");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+
+ try {
+ new WifiQrCode("");
+ fail("Empty string QR code");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+
+ try {
+ new WifiQrCode("DPP:;");
+ fail("Empty content WIFI DPP QR code");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+
+ try {
+ new WifiQrCode("WIFI:;");
+ fail("Empty content ZXing WIFI QR code");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+ }
+
+ @Test
+ public void parseInvalidSchemeQrCode_shouldThrowIllegalArgumentException() {
+ try {
+ new WifiQrCode(INVALID_SCHEME_QR_CODE);
+ fail("Invalid scheme");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+ }
+
+ @Test
+ public void parseInvalidWifiDppQrCode_noPublicKey_shouldThrowIllegalArgumentException() {
+ try {
+ new WifiQrCode(INVALID_WIFI_DPP_QR_CODE_NO_PUBLIC_KEY_1);
+ fail("No public key case 1");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+
+ try {
+ new WifiQrCode(INVALID_WIFI_DPP_QR_CODE_NO_PUBLIC_KEY_2);
+ fail("No public key case 2");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+ }
+
+ @Test
+ public void parseInvalidZxingWifiQrCode_noPassword_shouldThrowIllegalArgumentException() {
+ try {
+ new WifiQrCode(INVALID_ZXING_WIFI_QR_CODE_NO_PASSWORD);
+ fail("No password");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+ }
+
+ @Test
+ public void parseInvalidZxingWifiQrCode_noSsid_shouldThrowIllegalArgumentException() {
+ try {
+ new WifiQrCode(INVALID_ZXING_WIFI_QR_CODE_NO_SSID);
+ fail("No SSID");
+ } catch (IllegalArgumentException e) {
+ // Do nothing
+ }
+ }
+}