Merge "Make the text appearance consistant in add vpn dialog"
diff --git a/Android.mk b/Android.mk
index e385b34..906cfc7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -47,6 +47,7 @@
guava \
jsr305 \
settings-contextual-card-protos-lite \
+ settings-log-bridge-protos-lite \
contextualcards \
settings-logtags \
zxing-core-1.7
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4166d6f..dbefdfa 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -196,6 +196,19 @@
android:value="true" />
</activity>
+ <activity android:name=".Settings$MobileNetworkListActivity"
+ android:label="@string/network_settings_title"
+ android:parentActivityName="Settings$NetworkDashboardActivity">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.MOBILE_NETWORK_LIST" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.network.MobileNetworkListFragment"/>
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
<activity
android:name=".Settings$ConnectedDeviceDashboardActivity"
android:label="@string/connected_devices_dashboard_title"
@@ -607,8 +620,7 @@
<activity
android:name="Settings$ManageAssistActivity"
- android:label="@string/assist_and_voice_input_title"
- android:parentActivityName="Settings">
+ android:label="@string/assist_and_voice_input_title">
<intent-filter android:priority="1">
<action android:name="android.settings.VOICE_INPUT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -782,7 +794,8 @@
<activity android:name="Settings$WallpaperSettingsActivity"
android:label="@string/wallpaper_settings_fragment_title"
- android:icon="@drawable/ic_wallpaper">
+ android:icon="@drawable/ic_wallpaper"
+ android:exported="true">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
</activity>
@@ -1381,7 +1394,7 @@
<activity android:name=".accessibility.AccessibilitySettingsForSetupWizardActivity"
android:icon="@drawable/ic_accessibility_suggestion"
android:label="@string/vision_settings_title"
- android:theme="@style/SetupWizardAccessibilityTheme">
+ android:theme="@style/GlifTheme.Light">
<intent-filter android:priority="1">
<action android:name="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -3042,9 +3055,8 @@
<activity android:name=".panel.SettingsPanelActivity"
android:label="@string/settings_panel_title"
android:theme="@style/Theme.BottomDialog"
+ android:documentLaunchMode="always"
android:excludeFromRecents="true"
- android:launchMode="singleTop"
- android:taskAffinity=".panel.SettingsPanelActivity"
android:exported="true">
<intent-filter>
<action android:name="android.settings.panel.action.INTERNET_CONNECTIVITY" />
diff --git a/protos/Android.bp b/protos/Android.bp
index 533dbca..5184218 100644
--- a/protos/Android.bp
+++ b/protos/Android.bp
@@ -5,4 +5,13 @@
type: "lite",
},
srcs: ["contextual_card_list.proto"],
+}
+
+java_library_static {
+ name: "settings-log-bridge-protos-lite",
+ host_supported: true,
+ proto: {
+ type: "lite",
+ },
+ srcs: ["settings_log_bridge.proto"],
}
\ No newline at end of file
diff --git a/protos/settings_log_bridge.proto b/protos/settings_log_bridge.proto
new file mode 100644
index 0000000..7b28e0d
--- /dev/null
+++ b/protos/settings_log_bridge.proto
@@ -0,0 +1,37 @@
+syntax = "proto2";
+
+package com.android.settings.intelligence;
+option java_outer_classname = "LogProto";
+
+message SettingsLog {
+ /**
+ * Where this SettingsUIChange event comes from. For example, if
+ * it's a PAGE_VISIBLE event, where the page is opened from.
+ */
+ optional int32 attribution = 1;
+
+ /**
+ * What the UI action is.
+ */
+ optional int32 action = 2;
+
+ /**
+ * Where the action is happening
+ */
+ optional int32 page_id = 3;
+
+ /**
+ * What preference changed in this event.
+ */
+ optional string changed_preference_key = 4;
+
+ /**
+ * The new value of the changed preference.
+ */
+ optional int32 changed_preference_int_value = 5;
+
+ /**
+ * The timestamp of a log event
+ */
+ optional string timestamp = 6;
+}
diff --git a/res/drawable/ic_cellular_1_bar.xml b/res/drawable/ic_cellular_1_bar.xml
new file mode 100644
index 0000000..b3d2624
--- /dev/null
+++ b/res/drawable/ic_cellular_1_bar.xml
@@ -0,0 +1,29 @@
+<!--
+ Copyright (C) 2019 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.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M4,44h40V4z"
+ android:fillColor="#000000"
+ android:fillAlpha=".3"/>
+ <path
+ android:pathData="M24,24L4,44h20z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/res/drawable/ic_color_inversion.xml b/res/drawable/ic_color_inversion.xml
index aa59f5a..5d20d05 100644
--- a/res/drawable/ic_color_inversion.xml
+++ b/res/drawable/ic_color_inversion.xml
@@ -13,8 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<vector android:height="192dp" android:viewportHeight="192.0"
- android:viewportWidth="192.0" android:width="192dp"
+<vector android:height="32dp" android:viewportHeight="192.0"
+ android:viewportWidth="192.0" android:width="32dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#546E7A" android:pathData="M37.2,173.6l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1L178.6,70c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.9,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.9 39,179.7 37.2,173.6z"/>
<path android:fillAlpha="0.2" android:fillColor="#263238"
diff --git a/res/drawable/ic_daltonizer.xml b/res/drawable/ic_daltonizer.xml
index 04e397d..38cce69 100644
--- a/res/drawable/ic_daltonizer.xml
+++ b/res/drawable/ic_daltonizer.xml
@@ -13,8 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<vector android:height="192dp" android:viewportHeight="192.0"
- android:viewportWidth="192.0" android:width="192dp"
+<vector android:height="32dp" android:viewportHeight="192.0"
+ android:viewportWidth="192.0" android:width="32dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00BCD4" android:pathData="M37.1,173.5l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.9,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.8 39,179.6 37.1,173.5z"/>
<path android:fillAlpha="0.2" android:fillColor="#263238"
diff --git a/res/drawable/ic_settings_aod.xml b/res/drawable/ic_settings_aod.xml
index 8d91349..b238e3a 100644
--- a/res/drawable/ic_settings_aod.xml
+++ b/res/drawable/ic_settings_aod.xml
@@ -18,7 +18,8 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
- android:viewportHeight="24">
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#000000"
diff --git a/res/drawable/ic_settings_camera.xml b/res/drawable/ic_settings_camera.xml
index 5309270..3c85532 100644
--- a/res/drawable/ic_settings_camera.xml
+++ b/res/drawable/ic_settings_camera.xml
@@ -20,7 +20,8 @@
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48"
- android:autoMirrored="true">
+ android:autoMirrored="true"
+ android:tint="?android:attr/colorControlNormal">
<path android:fillColor="#000000"
android:pathData="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64
diff --git a/res/drawable/ic_settings_disable.xml b/res/drawable/ic_settings_disable.xml
new file mode 100644
index 0000000..d0edf4a
--- /dev/null
+++ b/res/drawable/ic_settings_disable.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,2c-1.78,0 -3.44,0.46 -4.89,1.28l1.48,1.48C9.63,4.28 10.78,4 12,4c4.41,0 8,3.59 8,8c0,1.22 -0.28,2.37 -0.76,3.41l1.48,1.48C21.54,15.44 22,13.78 22,12C22,6.48 17.52,2 12,2zM18.12,17.13L6.87,5.87L3.31,2.31L1.89,3.72l2.19,2.19C2.77,7.59 2,9.71 2,12c0,5.52 4.48,10 10,10c2.29,0 4.41,-0.77 6.09,-2.08l2.19,2.19l1.41,-1.41L18.12,17.13zM12,20c-4.41,0 -8,-3.59 -8,-8c0,-1.74 0.56,-3.35 1.51,-4.66l11.15,11.15C15.35,19.44 13.74,20 12,20zM8.59,4.76L7.11,3.28"/>
+</vector>
diff --git a/res/drawable/ic_settings_enable.xml b/res/drawable/ic_settings_enable.xml
new file mode 100644
index 0000000..560daef
--- /dev/null
+++ b/res/drawable/ic_settings_enable.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M15.59,10.09L13,12.67V2h-2v10.67l-2.59,-2.58L7,11.5l5,5l5,-5L15.59,10.09zM15,2.46v2.13c2.93,1.19 5,4.06 5,7.41c0,4.41 -3.59,8 -8,8s-8,-3.59 -8,-8c0,-3.35 2.07,-6.22 5,-7.41V2.46C4.94,3.74 2,7.53 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,7.53 19.06,3.74 15,2.46z"/>
+</vector>
diff --git a/res/drawable/ic_settings_phone_idle.xml b/res/drawable/ic_settings_phone_idle.xml
new file mode 100644
index 0000000..7bb6c31
--- /dev/null
+++ b/res/drawable/ic_settings_phone_idle.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 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.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M14,48h4v-4h-4v4zM22,48h4v-4h-4v4zM26,4h-4v20h4L26,4zM33.13,8.87l-2.89,2.89C33.69,13.87 36,17.66 36,22c0,6.63 -5.37,12 -12,12s-12,-5.37 -12,-12c0,-4.34 2.31,-8.13 5.76,-10.24l-2.89,-2.89C10.72,11.76 8,16.56 8,22c0,8.84 7.16,16 16,16s16,-7.16 16,-16c0,-5.44 -2.72,-10.24 -6.87,-13.13zM30,48h4v-4h-4v4z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/res/drawable/ic_settings_voice_calls.xml b/res/drawable/ic_settings_voice_calls.xml
new file mode 100644
index 0000000..b455f0a
--- /dev/null
+++ b/res/drawable/ic_settings_voice_calls.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 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.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M40,31c-2.49,0 -4.89,-0.4 -7.14,-1.14 -0.69,-0.22 -1.48,-0.06 -2.03,0.49l-4.4,4.41c-5.67,-2.88 -10.29,-7.51 -13.18,-13.17l4.4,-4.41c0.55,-0.55 0.71,-1.34 0.49,-2.03C17.4,12.9 17,10.49 17,8c0,-1.11 -0.89,-2 -2,-2L8,6c-1.11,0 -2,0.89 -2,2 0,18.78 15.22,34 34,34 1.11,0 2,-0.89 2,-2v-7c0,-1.11 -0.89,-2 -2,-2zM38,24h4c0,-9.94 -8.06,-18 -18,-18v4c7.73,0 14,6.27 14,14zM30,24h4c0,-5.52 -4.48,-10 -10,-10v4c3.31,0 6,2.69 6,6z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/res/layout-land/choose_lock_pattern.xml b/res/layout-land/choose_lock_pattern.xml
index 1cc4352..5b06f0d 100644
--- a/res/layout-land/choose_lock_pattern.xml
+++ b/res/layout-land/choose_lock_pattern.xml
@@ -44,7 +44,7 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 21c9b1e..8bb713f 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -40,7 +40,7 @@
android:paddingBottom="24dp">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index ba2c420..734f8a3 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -49,7 +49,7 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml
index 28d982e..6d8794a 100644
--- a/res/layout-land/fingerprint_enroll_find_sensor.xml
+++ b/res/layout-land/fingerprint_enroll_find_sensor.xml
@@ -55,7 +55,7 @@
android:clipToPadding="false">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
index 7d292c6..e80176d 100644
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ b/res/layout-land/fingerprint_enroll_finish.xml
@@ -45,7 +45,7 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/choose_lock_pattern_common.xml b/res/layout/choose_lock_pattern_common.xml
index 2ebcd9b..5d3cbca 100644
--- a/res/layout/choose_lock_pattern_common.xml
+++ b/res/layout/choose_lock_pattern_common.xml
@@ -41,7 +41,7 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index a08d516..03d3367 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -33,7 +33,7 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suc_layout_icon"
+ android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/encryption_interstitial.xml b/res/layout/encryption_interstitial.xml
index 3e227cb1..a2305f8 100644
--- a/res/layout/encryption_interstitial.xml
+++ b/res/layout/encryption_interstitial.xml
@@ -17,7 +17,6 @@
<com.google.android.setupdesign.GlifLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_lock">
diff --git a/res/layout/face_enroll_enrolling.xml b/res/layout/face_enroll_enrolling.xml
index e7af493..7e1863b 100644
--- a/res/layout/face_enroll_enrolling.xml
+++ b/res/layout/face_enroll_enrolling.xml
@@ -17,7 +17,6 @@
<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"
diff --git a/res/layout/face_enroll_finish.xml b/res/layout/face_enroll_finish.xml
index 62176a7..d3c0479 100644
--- a/res/layout/face_enroll_finish.xml
+++ b/res/layout/face_enroll_finish.xml
@@ -17,7 +17,6 @@
<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"
style="?attr/face_layout_theme"
android:layout_width="match_parent"
diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml
index 3a476fa..eed6fab 100644
--- a/res/layout/fingerprint_enroll_enrolling_base.xml
+++ b/res/layout/fingerprint_enroll_enrolling_base.xml
@@ -17,7 +17,6 @@
<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"
diff --git a/res/layout/fingerprint_enroll_find_sensor_base.xml b/res/layout/fingerprint_enroll_find_sensor_base.xml
index c03ac5a..2bef539 100644
--- a/res/layout/fingerprint_enroll_find_sensor_base.xml
+++ b/res/layout/fingerprint_enroll_find_sensor_base.xml
@@ -17,7 +17,6 @@
<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"
style="?attr/fingerprint_layout_theme"
android:layout_width="match_parent"
diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml
index 2fa5da6..d85c56c 100644
--- a/res/layout/fingerprint_enroll_finish_base.xml
+++ b/res/layout/fingerprint_enroll_finish_base.xml
@@ -17,7 +17,6 @@
<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"
style="?attr/fingerprint_layout_theme"
android:layout_width="match_parent"
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 4ee7057..47d2f02 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -17,7 +17,6 @@
<com.google.android.setupdesign.GlifLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
style="?attr/fingerprint_layout_theme"
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
diff --git a/res/layout/storage_wizard_generic.xml b/res/layout/storage_wizard_generic.xml
index 2b96101..e7881d3 100644
--- a/res/layout/storage_wizard_generic.xml
+++ b/res/layout/storage_wizard_generic.xml
@@ -16,7 +16,6 @@
<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">
diff --git a/res/layout/storage_wizard_init.xml b/res/layout/storage_wizard_init.xml
index d02e871..8d9870f 100644
--- a/res/layout/storage_wizard_init.xml
+++ b/res/layout/storage_wizard_init.xml
@@ -16,7 +16,6 @@
<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">
diff --git a/res/layout/storage_wizard_progress.xml b/res/layout/storage_wizard_progress.xml
index cf5bc43..577ec3c 100644
--- a/res/layout/storage_wizard_progress.xml
+++ b/res/layout/storage_wizard_progress.xml
@@ -16,7 +16,6 @@
<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">
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 521d709..b8bd424 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1378,6 +1378,26 @@
<item>@string/wifi_calling_mode_cellular_preferred_summary</item>
</string-array>
+ <!-- Carrier variant of Enhaced 4G LTE Mode title. [CHAR LIMIT=NONE] -->
+ <string-array name="enhanced_4g_lte_mode_title_variant">
+ <!-- 0: Default -->
+ <item>@string/enhanced_4g_lte_mode_title</item>
+ <!-- 1: Verizon -->
+ <item>@string/enhanced_4g_lte_mode_title_advanced_calling</item>
+ <!-- 2: All carriers who want 4G -->
+ <item>@string/enhanced_4g_lte_mode_title_4g_calling</item>
+ </string-array>
+
+ <!-- Carrier variant of Enhaced 4G LTE Mode summary. [CHAR LIMIT=NONE] -->
+ <string-array name="enhanced_4g_lte_mode_sumary_variant">
+ <!-- 0: Default -->
+ <item>@string/enhanced_4g_lte_mode_summary</item>
+ <!-- 1: Verizon -->
+ <item>@string/enhanced_4g_lte_mode_summary</item>
+ <!-- 2: All carriers who want 4G -->
+ <item>@string/enhanced_4g_lte_mode_summary_4g_calling</item>
+ </string-array>
+
<!-- Bluetooth icon foreground colors -->
<integer-array name="bt_icon_fg_colors">
<item>@color/bt_color_icon_1</item>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index c333edb..ff040ee 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -100,7 +100,7 @@
<color name="homepage_privacy_background">#5E97F6</color>
<color name="homepage_card_stroke_color">#1f000000</color>
- <color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_100</color>
<color name="contextual_card_background">@*android:color/background_device_default_light</color>
<!-- End of dashboard/homepage icon background colors -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4a65bc9..034e4a3 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -346,6 +346,7 @@
<dimen name="homepage_card_icon_padding_start">14dp</dimen>
<dimen name="homepage_card_text_padding_start">16dp</dimen>
<dimen name="homepage_card_padding_end">16dp</dimen>
+ <dimen name="homepage_card_corner_radius">@*android:dimen/config_dialogCornerRadius</dimen>
<dimen name="homepage_full_card_padding_end">12dp</dimen>
<dimen name="homepage_half_card_padding_top">12dp</dimen>
<dimen name="homepage_half_card_padding_bottom">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9b23ca9..6da9260 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2284,6 +2284,8 @@
</plurals>
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. [CHAR LIMIT=30] -->
<string name="wifi_advanced_titlebar">Advanced Wi\u2011Fi</string>
+ <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's SSID. [CHAR LIMIT=20] -->
+ <string name="wifi_advanced_ssid_title">SSID</string>
<!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's MAC address. -->
<string name="wifi_advanced_mac_address_title">MAC address</string>
<!-- Title of the screen to adjust IP settings -->
@@ -2620,8 +2622,6 @@
<string name="sound_effects_enable_title">Tap sounds</string>
<!-- Sound settings screen, setting check box label -->
<string name="lock_sounds_enable_title">Screen lock sound</string>
- <!-- Sound settings screen, setting check box label -->
- <string name="haptic_feedback_enable_title">Vibrate on tap</string>
<!-- Sound settings screen, setting option name checkbox to enable/disable audio recording features that improve audio recording in noisy environments -->
<string name="audio_record_proc_title">Noise cancellation</string>
<!-- Volume description for media volume -->
@@ -5662,12 +5662,6 @@
<string name="battery_saver_schedule_settings_title">Set a schedule</string>
<!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
- <string name="battery_saver_sticky_title">Keep battery saver on</string>
-
- <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
- <string name="battery_saver_sticky_description">Battery saver will stay on even after device is fully charged</string>
-
- <!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
<string name="battery_saver_sticky_title_new">Turn off when fully charged</string>
<!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
@@ -6781,6 +6775,24 @@
<string name="help_uri_notifications" translatable="false"></string>
<!-- Help URI, Apps [DO NOT TRANSLATE] -->
<string name="help_uri_apps" translatable="false"></string>
+ <!-- Help URI, manage apps storage [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_storage" translatable="false"></string>
+ <!-- Help URI, manage apps power [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_high_power" translatable="false"></string>
+ <!-- Help URI, manage apps overlay [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_overlay" translatable="false"></string>
+ <!-- Help URI, manage apps write settings [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_write_settings" translatable="false"></string>
+ <!-- Help URI, manage apps manage sources [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_manage_sources" translatable="false"></string>
+ <!-- Help URI, manage apps games [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_games" translatable="false"></string>
+ <!-- Help URI, manage apps movies [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_movies" translatable="false"></string>
+ <!-- Help URI, manage apps photography [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_photography" translatable="false"></string>
+ <!-- Help URI, manage apps wifi access [DO NOT TRANSLATE] -->
+ <string name="help_uri_apps_wifi_access" translatable="false"></string>
<!-- Help URI, Storage [DO NOT TRANSLATE] -->
<string name="help_uri_storage" translatable="false"></string>
<!-- Help URI, Accessibility [DO NOT TRANSLATE] -->
@@ -6921,9 +6933,15 @@
<!-- Access point names title. [CHAR LIMIT=50] -->
<string name="access_point_names">Access point names</string>
<!-- Enhaced 4G LTE Mode title. [CHAR LIMIT=50] -->
- <string name="enhanced_4g_lte_mode_title">Enhanced 4G LTE Mode</string>
+ <string name="enhanced_4g_lte_mode_title">VoLTE</string>
+ <!-- Enhaced 4G LTE Mode title for carriers who want to show Advanced Calling. [CHAR LIMIT=50] -->
+ <string name="enhanced_4g_lte_mode_title_advanced_calling">Advanced Calling</string>
+ <!-- Enhaced 4G LTE Mode title for carriers who want to show 4G Calling. [CHAR LIMIT=50] -->
+ <string name="enhanced_4g_lte_mode_title_4g_calling">4G Calling</string>
<!-- Enhaced 4G LTE Mode summary. [CHAR LIMIT=100] -->
- <string name="enhanced_4g_lte_mode_summary">Use LTE data to enhance voice and communications (Recommended)</string>
+ <string name="enhanced_4g_lte_mode_summary">Use LTE services to improve voice and other communications (recommended)</string>
+ <!-- Enhaced 4G LTE Mode summary for 4g calling. [CHAR LIMIT=100] -->
+ <string name="enhanced_4g_lte_mode_summary_4g_calling">Use 4G services to improve voice and other communications (recommended)</string>
<!-- Preferred network type title. [CHAR LIMIT=50] -->
<string name="preferred_network_type_title">Preferred network type</string>
<!-- Preferred network type summary. [CHAR LIMIT=100] -->
@@ -7000,6 +7018,8 @@
<string name="sim_calls_always_use">Always use this for calls</string>
<!-- Message for selecting sim for data in settings. [CHAR LIMIT=40] -->
<string name="select_sim_for_data">Select a SIM for data</string>
+ <!-- Message for selecting sim for SMS in settings. [CHAR LIMIT=40] -->
+ <string name="select_sim_for_sms">Select a SIM for SMS</string>
<!-- Message for switching data SIM; switching takes a while -->
<string name="data_switch_started">Switching data SIM, this may take up to a minute...</string>
<!-- Message for selecting sim for call in settings. [CHAR LIMIT=40] -->
@@ -7118,6 +7138,24 @@
<!--Search Keywords [CHAR LIMIT=NONE]-->
<string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
+ <!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
+ <!-- Search keyword for "Adaptive brightness" settings. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_auto_brightness">Auto brightness</string>
+ <!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
+ <!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_time_format">Use 24-hour format</string>
+ <!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_storage_files">Download</string>
+ <!-- Search keyword for "Default Apps" settings [CHAR_LIMIT=NONE]-->
+ <string name="keywords_app_default">Open with</string>
+ <!-- Search keyword for "App info" settings [CHAR_LIMIT=NONE]-->
+ <string name="keywords_applications_settings">Applications</string>
+ <!-- Search keyword for "Time zone" settings [CHAR_LIMIT=NONE]-->
+ <string name="keywords_time_zone">timezone</string>
+ <!-- Search keyword for "Display over other apps" settings [CHAR_LIMIT=NONE]-->
+ <string name="keywords_draw_overlay">Chat head</string>
<string name="keywords_change_wifi_state">wifi, wi-fi, toggle, control</string>
<string name="keywords_more_default_sms_app">text message, texting, messages, messaging, default</string>
<string name="keywords_more_mobile_networks">cellular, mobile, cell carrier, wireless, data, 4g,3g, 2g, lte</string>
@@ -7128,7 +7166,8 @@
<string name="keywords_display_night_display">dim screen, night, tint, night shift, brightness, screen color, colour, color</string>
<string name="keywords_display_wallpaper">background, personalize, customize display</string>
<string name="keywords_display_font_size">text size</string>
- <string name="keywords_display_cast_screen">project, cast</string>
+ <!-- Search keyword for "Cast" settings [CHAR_LIMIT=NONE]-->
+ <string name="keywords_display_cast_screen">project, cast, Screen mirroring, Screen sharing, mirroring, share screen, screen casting</string>
<string name="keywords_storage">space, disk, hard drive, device usage</string>
<string name="keywords_battery">power usage, charge</string>
<string name="keywords_spell_checker">spelling, dictionary, spellcheck, auto-correct</string>
@@ -7181,7 +7220,7 @@
<string name="keywords_ambient_display_screen">Ambient display, Lock screen display</string>
<!-- Search keyword for lock screen notification setting [CHAR_LIMIT=NONE] -->
- <string name="keywords_lock_screen_notif">lock screen notification</string>
+ <string name="keywords_lock_screen_notif">lock screen notification, notifications</string>
<!-- Search keyword for face settings. -->
<string name="keywords_face_settings">face</string>
@@ -7368,6 +7407,12 @@
<!-- Sound: Other sounds: Title for the option enabling boot sounds. [CHAR LIMIT=30] -->
<string name="boot_sounds_title">Power on sounds</string>
+ <!-- Setting title for controlling how caption text display in real time [CHAR LIMIT=40]-->
+ <string name="live_caption_title">Live Caption</string>
+
+ <!-- Setting summary for controlling how caption text display in real time [CHAR LIMIT=NONE]-->
+ <string name="live_caption_summary">Automatically caption media</string>
+
<!-- Sound: Summary for the Do not Disturb option when there is no automatic rules turned on. [CHAR LIMIT=NONE]-->
<string name="zen_mode_settings_summary_off">Never</string>
@@ -7387,7 +7432,7 @@
<string name="zen_mode_behavior_settings_title">Exceptions</string>
<!-- Do not disturb: Title for the dnd duration setting (user can specify how long dnd will last when toggling dnd on from qs or settings) [CHAR LIMIT=30] -->
- <string name="zen_mode_duration_settings_title">Duration</string>
+ <string name="zen_mode_duration_settings_title">Default duration</string>
<!-- Do not disturb: Instructions indicating what types of sounds can bypass DND. [CHAR LIMIT=52] -->
<string name="zen_mode_behavior_allow_title">Allow sounds and vibrations from</string>
@@ -8789,7 +8834,7 @@
<string name="app_usage_preference">App usage preferences</string>
<!-- Link title to show stats about how much time user spent in an app [CHAR LIMIT=45] -->
- <string name="time_spent_in_app_pref_title">Time spent in app</string>
+ <string name="time_spent_in_app_pref_title">Screen time</string>
<!-- Description of the usage access setting [CHAR LIMIT=NONE] -->
<string name="usage_access_description">Usage access allows an app to track what other apps you\u2019re using and how often, as well as your carrier, language settings, and other details.</string>
@@ -10534,8 +10579,6 @@
<!-- Message informs the user that has no SIM card in personalized Settings [CHAR LIMIT=30] -->
<string name="no_sim_card">No SIM card</string>
- <!-- Carrier variant of Enhaced 4G LTE Mode title. [CHAR LIMIT=50] -->
- <string name="enhanced_4g_lte_mode_title_variant">Advanced Calling</string>
<!-- The following strings are summaries for preferred network modes in Mobile network settings,
and have a character limit of 100 -->
<!-- WCDMA preferred [CHAR LIMIT=NONE] -->
@@ -10885,7 +10928,7 @@
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
<string name="privacy_dashboard_title">Privacy</string>
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
- <string name="privacy_dashboard_summary">Permissions, web activity, personal data</string>
+ <string name="privacy_dashboard_summary">Permissions, account activity, personal data</string>
<!-- Label for button in contextual card for users to remove the card [CHAR LIMIT=30] -->
<string name="contextual_card_dismiss_remove">Remove</string>
@@ -10916,17 +10959,15 @@
<string name="permission_bar_chart_empty_text">0 apps used permissions</string>
<!-- Text for permission bar chart title in Privacy page. [CHAR LIMIT=NONE] -->
- <string name="permission_bar_chart_title">Most-used permissions in last 24 hours</string>
- <!-- Text for permission bar chart title in Privacy page. [CHAR LIMIT=NONE] -->
- <string name="permission_bar_chart_title_v2">In last 24 hr, apps on this device accessed</string>
+ <string name="permission_bar_chart_title">Permission usage in last 24 hours</string>
<!-- Text for permission bar chart details in Privacy page. [CHAR LIMIT=NONE] -->
- <string name="permission_bar_chart_details">View Permissions Dashboard</string>
+ <string name="permission_bar_chart_details">See all in Dashboard</string>
- <!-- Text for permission bar chart details in Privacy page. [CHAR LIMIT=NONE] -->
- <string name="permission_bar_chart_details_v2">See all permission usage in Dashboard</string>
- <!-- Text for permission bar chart details in Privacy page. [CHAR LIMIT=NONE] -->
- <string name="permission_bar_chart_details_v3">+ <xliff:g id="permissionCount" example="3">%1$d</xliff:g> other permissions</string>
+ <plurals name="permission_bar_chart_label">
+ <item quantity="one">1 app</item>
+ <item quantity="other"><xliff:g id="number" example="7">%s</xliff:g> apps</item>
+ </plurals>
<!-- Title for the accessibility usage preference in the Privacy page. [CHAR LIMIT=NONE] -->
<string name="accessibility_usage_title">Accessibility usage</string>
@@ -10974,11 +11015,11 @@
<!-- Message for forget passpoint dialog [CHAR LIMIT=none] -->
<string name="forget_passpoint_dialog_message">You may lose access to any remaining time or data. Check with your provider before removing.</string>
- <!-- Keywords for Content Capture feature [CHAR_LIMIT=32] -->
- <string name="keywords_content_capture">content capture</string>
+ <!-- Keywords for Content Capture / Smart Suggestions feature [CHAR_LIMIT=none] -->
+ <string name="keywords_content_capture">content capture, smart suggestions</string>
<!-- Title of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=none]-->
- <string name="content_capture">Content Capture</string>
- <!-- Description of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
+ <string name="content_capture">Smart Suggestions</string>
+ <!-- Description of the 'Content Capture / Smart Suggestions' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
<string name="content_capture_summary">Allow Android to save information seen on your screen or heard in video or audio content. Android makes helpful suggestions based on your device activity.</string>
<!-- Title for the button to initiate a heap dump for the system server. [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8fde9a0..8cd22fe 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -418,7 +418,7 @@
<item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
<item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
<item name="cardBackgroundColor">@color/contextual_card_background</item>
- <item name="cardCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
+ <item name="cardCornerRadius">@dimen/homepage_card_corner_radius</item>
<item name="cardElevation">0dp</item>
<item name="strokeColor">@color/homepage_card_stroke_color</item>
<item name="strokeWidth">1dp</item>
@@ -533,4 +533,9 @@
<item name="android:paddingEnd">8dp</item>
</style>
+ <style name="SetupWizardPartnerResource">
+ <!-- Disable to use partner overlay theme for outside setupwizard flow. -->
+ <item name="sucUsePartnerResource">false</item>
+ </style>
+
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index a8ae506..d777fd0 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -103,6 +103,7 @@
<item name="android:trackTint">@color/switchbar_switch_track_tint</item>
<item name="android:thumbTint">@color/switchbar_switch_thumb_tint</item>
<item name="android:minHeight">@dimen/min_tap_target_size</item>
+ <item name="android:minWidth">@dimen/min_tap_target_size</item>
</style>
<style name="Theme.CryptKeeper" parent="@android:style/Theme.Material.NoActionBar">
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index da103c5..0e417c9 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -58,12 +58,10 @@
android:title="@string/screen_zoom_title"
settings:searchable="false"/>
- <ListPreference
+ <Preference
android:key="dark_ui_mode_accessibility"
+ android:fragment="com.android.settings.display.DarkUISettings"
android:title="@string/dark_ui_mode"
- android:dialogTitle="@string/dark_ui_mode_title"
- android:entries="@array/dark_ui_mode_entries"
- android:entryValues="@array/dark_ui_mode_values"
settings:searchable="false" />
<Preference
@@ -132,6 +130,12 @@
android:key="audio_and_captions_category"
android:title="@string/audio_and_captions_category_title">
+ <Preference
+ android:key="live_caption"
+ android:title="@string/live_caption_title"
+ android:summary="@string/live_caption_summary"
+ settings:controller="com.android.settings.accessibility.LiveCaptionPreferenceController"/>
+
<SwitchPreference
android:key="toggle_master_mono"
android:title="@string/accessibility_toggle_master_mono_title"
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 9dd5fea..fd3725a 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -20,7 +20,7 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="apps_and_notification_screen"
android:title="@string/app_and_notification_dashboard_title"
- settings:initialExpandedChildrenCount="8">
+ settings:initialExpandedChildrenCount="3">
<!-- the initial count should include the dynamic tiles -->
<Preference
@@ -28,7 +28,8 @@
android:title="@string/applications_settings"
android:order="-999"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
- settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"/>
+ settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"
+ settings:keywords="@string/keywords_applications_settings"/>
<com.android.settingslib.widget.LayoutPreference
android:key="recent_open_apps"
diff --git a/res/xml/app_default_settings.xml b/res/xml/app_default_settings.xml
index c26c069..1f1b24a 100644
--- a/res/xml/app_default_settings.xml
+++ b/res/xml/app_default_settings.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="app_default_settings_screen"
- android:title="@string/app_default_dashboard_title">
+ android:title="@string/app_default_dashboard_title"
+ settings:keywords="@string/keywords_app_default">
<com.android.settingslib.widget.apppreference.AppPreference
android:key="assist_and_voice_input"
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index ae9d14d..c8d1d63 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -28,8 +28,8 @@
<SwitchPreference
android:key="battery_saver_sticky"
- android:title="@string/battery_saver_sticky_title"
- android:summary="@string/battery_saver_sticky_description"
+ android:title="@string/battery_saver_sticky_title_new"
+ android:summary="@string/summary_placeholder"
settings:keywords="@string/keywords_battery_saver_sticky"
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController"/>
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 3158819..14e0366 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -63,8 +63,7 @@
android:dialogTitle="@string/notification_channel_sound_title"
android:order="11"
android:showSilent="true"
- android:showDefault="true"
- android:ringtoneType="notification" />
+ android:showDefault="true"/>
<!-- Vibration -->
<com.android.settingslib.RestrictedSwitchPreference
diff --git a/res/xml/dark_ui_settings.xml b/res/xml/dark_ui_settings.xml
new file mode 100644
index 0000000..1f11eba
--- /dev/null
+++ b/res/xml/dark_ui_settings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/dark_ui_mode"
+ android:key="dark_ui_mode_screen"
+ settings:staticPreferenceLocation="append"
+ settings:keywords="@string/keywords_dark_ui_mode">
+</PreferenceScreen >
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index f98ce3d..2d5b24d 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -56,12 +56,14 @@
android:title="@string/date_time_set_timezone_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
- settings:userRestriction="no_config_date_time" />
+ settings:userRestriction="no_config_date_time"
+ settings:keywords="@string/keywords_time_zone"/>
</PreferenceCategory>
<PreferenceCategory
android:key="time_format_preference_category"
- android:title="@string/time_format_category_title">
+ android:title="@string/time_format_category_title"
+ settings:keywords="@string/keywords_time_format">
<SwitchPreference
android:key="auto_24hour"
android:title="@string/date_time_24hour_auto"/>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index a9af2d4..908529e 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -36,6 +36,10 @@
android:dialogTitle="@*android:string/bugreport_title" />
<Preference
+ android:key="system_server_heap_dump"
+ android:title="@string/capture_system_heap_dump_title" />
+
+ <Preference
android:key="local_backup_password"
android:title="@string/local_backup_password_title"
android:summary="@string/local_backup_password_summary_none"
@@ -151,6 +155,11 @@
android:title="@string/bugreport_in_power"
android:summary="@string/bugreport_in_power_summary" />
+ <SwitchPreference
+ android:key="automatic_system_server_heap_dumps"
+ android:title="@string/automatic_system_heap_dump_title"
+ android:summary="@string/automatic_system_heap_dump_summary" />
+
<Preference android:key="mock_location_app"
android:title="@string/mock_location_app" />
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 91fe656..940e6de 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -44,7 +44,8 @@
android:title="@string/auto_brightness_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.display.AutoBrightnessSettings"
- settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
+ settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
+ settings:keywords="@string/keywords_auto_brightness"/>
<com.android.settingslib.RestrictedPreference
android:key="wallpaper"
@@ -57,14 +58,13 @@
android:targetClass="@string/config_wallpaper_picker_class" />
</com.android.settingslib.RestrictedPreference>
- <ListPreference
+
+ <Preference
android:key="dark_ui_mode"
+ android:fragment="com.android.settings.display.DarkUISettings"
android:title="@string/dark_ui_mode"
- android:dialogTitle="@string/dark_ui_mode_title"
- android:entries="@array/dark_ui_mode_entries"
- android:entryValues="@array/dark_ui_mode_values"
- settings:keywords="@string/keywords_dark_ui_mode"
- settings:controller="com.android.settings.display.DarkUIPreferenceController" />
+ settings:searchable="false"
+ settings:controller="com.android.settings.display.DarkUIPreferenceController"/>
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
<com.android.settings.display.TimeoutListPreference
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 7eccd23..29d4048 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -14,49 +14,50 @@
limitations under the License.
-->
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="location_settings"
- android:title="@string/location_settings_title"
- settings:keywords="@string/keywords_location">
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="location_settings"
+ android:title="@string/location_settings_title"
+ settings:keywords="@string/keywords_location">
- <com.android.settingslib.widget.LayoutPreference
- android:key="apps_dashboard"
- android:layout="@layout/app_entities_header"
- android:selectable="false"
- settings:allowDividerBelow="true"/>
-
- <PreferenceCategory android:key="location_advanced_settings">
-
- <!-- This preference category gets removed if new_recent_location_ui is disabled -->
- <Preference
- android:key="app_level_permissions"
- android:title="@string/location_app_level_permissions">
- <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
- <extra android:name="android.intent.extra.PERMISSION_NAME"
- android:value="android.permission-group.LOCATION"/>
- </intent>
- </Preference>
-
- <Preference
- android:key="location_scanning"
- android:title="@string/location_scanning_screen_title"
- android:fragment="com.android.settings.location.ScanningSettings"/>
-
- <!-- This preference gets removed if there is no managed profile -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="managed_profile_location_switch"
- android:title="@string/managed_profile_location_switch_title"
- settings:useAdminDisabledSummary="true"
- android:enabled="false"
- android:selectable="true"/>
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="apps_dashboard"
+ android:layout="@layout/app_entities_header"
+ android:selectable="false"
+ settings:allowDividerBelow="true" />
<PreferenceCategory
- android:key="location_services"/>
- </PreferenceCategory>
+ android:key="location_advanced_settings"
+ settings:initialExpandedChildrenCount="2">
- <PreferenceCategory
- android:key="location_footer"
- settings:allowDividerAbove="false"/>
+ <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+ <Preference
+ android:key="app_level_permissions"
+ android:title="@string/location_app_level_permissions">
+ <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+ <extra android:name="android.intent.extra.PERMISSION_NAME"
+ android:value="android.permission-group.LOCATION" />
+ </intent>
+ </Preference>
+
+ <Preference
+ android:key="location_scanning"
+ android:title="@string/location_scanning_screen_title"
+ android:fragment="com.android.settings.location.ScanningSettings"/>
+
+ <!-- This preference gets removed if there is no managed profile -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="managed_profile_location_switch"
+ android:title="@string/managed_profile_location_switch_title"
+ settings:useAdminDisabledSummary="true"
+ android:enabled="false"
+ android:selectable="true" />
+
+ <PreferenceCategory
+ android:key="location_services" />
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="location_footer"
+ settings:allowDividerAbove="false"/>
</PreferenceScreen>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 94ead86..88f88f1 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -26,13 +26,11 @@
android:title="@string/summary_placeholder"
android:selectable="false"
android:layout="@layout/battery_header"
- settings:allowDividerBelow="true"
settings:controller="com.android.settings.fuelgauge.BatteryHeaderPreferenceController" />
<com.android.settings.widget.CardPreference
android:key="battery_tip"
android:title="@string/summary_placeholder"
- settings:allowDividerAbove="true"
settings:controller="com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController" />
<Preference
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index f39880c..45b9d19 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -62,26 +62,6 @@
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
- <!-- Content Capture -->
-
- <!-- NOTE: content capture has a different preference, depending whether or not the
- ContentCaptureService implementations defines a custom settings activitiy on its manifest.
- Hence, we show both here, but the controller itself will decide if it's available or not.
- -->
-
- <SwitchPreference
- android:key="content_capture"
- android:title="@string/content_capture"
- android:summary="@string/content_capture_summary"
- settings:controller="com.android.settings.privacy.EnableContentCapturePreferenceController"/>
-
- <com.android.settings.widget.MasterSwitchPreference
- android:key="content_capture_custom_settings"
- android:title="@string/content_capture"
- android:summary="@string/content_capture_summary"
- settings:controller="com.android.settings.privacy.EnableContentCaptureWithServiceSettingsPreferenceController">
- </com.android.settings.widget.MasterSwitchPreference>
-
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"/>
@@ -105,4 +85,24 @@
settings:searchable="false"/>
</PreferenceCategory>
+ <!-- Content Capture -->
+
+ <!-- NOTE: content capture has a different preference, depending whether or not the
+ ContentCaptureService implementations defines a custom settings activitiy on its manifest.
+ Hence, we show both here, but the controller itself will decide if it's available or not.
+ -->
+
+ <SwitchPreference
+ android:key="content_capture"
+ android:title="@string/content_capture"
+ android:summary="@string/content_capture_summary"
+ settings:controller="com.android.settings.privacy.EnableContentCapturePreferenceController"/>
+
+ <com.android.settings.widget.MasterSwitchPreference
+ android:key="content_capture_custom_settings"
+ android:title="@string/content_capture"
+ android:summary="@string/content_capture_summary"
+ settings:controller="com.android.settings.privacy.EnableContentCaptureWithServiceSettingsPreferenceController">
+ </com.android.settings.widget.MasterSwitchPreference>
+
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index 57bee1f..c3161d5 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -124,7 +124,8 @@
android:dialogTitle="@string/ringtone_title"
android:summary="@string/summary_placeholder"
android:ringtoneType="ringtone"
- android:order="-100"/>
+ android:order="-100"
+ settings:keywords="@string/sound_settings"/>
<!-- Default notification ringtone -->
<com.android.settings.DefaultRingtonePreference
@@ -180,7 +181,8 @@
<SwitchPreference
android:key="vibrate_on_touch"
android:title="@string/vibrate_on_touch_title"
- android:summary="@string/vibrate_on_touch_summary" />
+ android:summary="@string/vibrate_on_touch_summary"
+ settings:keywords="@string/keywords_vibrate_on_touch"/>
<!-- Dock speaker plays -->
<DropDownPreference
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index c4bd11d..63ce90b 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -62,7 +62,8 @@
android:key="pref_files"
android:title="@string/storage_files"
android:icon="@drawable/ic_folder_vd_theme_24"
- android:order="7" />
+ android:order="7"
+ settings:keywords="@string/keywords_storage_files"/>
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_system"
android:title="@string/storage_detail_system"
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 15ab1aa..c621466 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -36,7 +36,8 @@
android:key="notify_open_networks"
android:title="@string/wifi_notify_open_networks"
android:icon="@drawable/ic_open_wifi_notifications"
- android:summary="@string/wifi_notify_open_networks_summary" />
+ android:summary="@string/wifi_notify_open_networks_summary"
+ settings:keywords="@string/keywords_wifi_notify_open_networks"/>
<SwitchPreference
android:key="wifi_cellular_data_fallback"
diff --git a/res/xml/wifi_display_settings.xml b/res/xml/wifi_display_settings.xml
index 7ad214e..769e9ce 100644
--- a/res/xml/wifi_display_settings.xml
+++ b/res/xml/wifi_display_settings.xml
@@ -16,7 +16,9 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="wifi_display_settings_screen"
- android:title="@string/wifi_display_settings_title">
+ android:title="@string/wifi_display_settings_title"
+ settings:keywords="@string/keywords_display_cast_screen">
</PreferenceScreen>
diff --git a/res/xml/wifi_network_details_fragment.xml b/res/xml/wifi_network_details_fragment.xml
index 8979efc..8fb19cb 100644
--- a/res/xml/wifi_network_details_fragment.xml
+++ b/res/xml/wifi_network_details_fragment.xml
@@ -71,11 +71,25 @@
android:entryValues="@array/wifi_privacy_values"/>
</PreferenceCategory>
+ <!-- Add device Category -->
+ <PreferenceCategory
+ android:key="add_device_category" >
+ <Preference
+ android:key="add_device_to_network"
+ android:title="@string/wifi_dpp_add_device"
+ android:summary="@string/wifi_dpp_connect_network_using_qr_code"/>
+ </PreferenceCategory>
+
<!-- Network Details -->
<PreferenceCategory
android:key="ip_details_category"
android:title="@string/wifi_setup_detail">
<Preference
+ android:key="ssid"
+ android:title="@string/wifi_advanced_ssid_title"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="mac_address"
android:title="@string/wifi_advanced_mac_address_title"
android:selectable="false"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 7595657..bdb5889 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -162,6 +162,7 @@
public static class AdvancedConnectedDeviceActivity extends SettingsActivity { /* empty */ }
public static class BluetoothDeviceDetailActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
+ public static class MobileNetworkListActivity extends SettingsActivity {}
// Top level categories for new IA
public static class NetworkDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 001e65b..92a0f73 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -27,6 +27,7 @@
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources.Theme;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.UserHandle;
@@ -334,6 +335,12 @@
}
@Override
+ protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
+ theme.applyStyle(R.style.SetupWizardPartnerResource, true);
+ super.onApplyThemeResource(theme, resid, first);
+ }
+
+ @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
final List<Fragment> fragments = getSupportFragmentManager().getFragments();
diff --git a/src/com/android/settings/SetupWizardUtils.java b/src/com/android/settings/SetupWizardUtils.java
index 70ee2ca..166e065 100644
--- a/src/com/android/settings/SetupWizardUtils.java
+++ b/src/com/android/settings/SetupWizardUtils.java
@@ -67,9 +67,6 @@
}
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
- toIntent.putExtra(WizardManagerHelper.EXTRA_THEME,
- fromIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
- toIntent.putExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE,
- fromIntent.getBooleanExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false));
+ WizardManagerHelper.copyWizardManagerExtras(fromIntent, toIntent);
}
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 921af04..efa14f6 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -18,6 +18,8 @@
import static android.os.Vibrator.VibrationIntensity;
+import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_MEDIUM;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
@@ -136,6 +138,8 @@
"accessibility_control_timeout_preference_fragment";
private static final String DARK_UI_MODE_PREFERENCE =
"dark_ui_mode_accessibility";
+ private static final String LIVE_CAPTION_PREFERENCE_KEY =
+ "live_caption";
// Extras passed to sub-fragments.
@@ -236,11 +240,13 @@
private Preference mDisplayDaltonizerPreferenceScreen;
private Preference mHearingAidPreference;
private Preference mVibrationPreferenceScreen;
+ private Preference mLiveCaptionPreference;
private SwitchPreference mToggleInversionPreference;
private ColorInversionPreferenceController mInversionPreferenceController;
private AccessibilityHearingAidPreferenceController mHearingAidPreferenceController;
- private ListPreference mDarkUIModePreference;
+ private Preference mDarkUIModePreference;
private DarkUIPreferenceController mDarkUIPreferenceController;
+ private LiveCaptionPreferenceController mLiveCaptionPreferenceController;
private int mLongPressTimeoutDefault;
@@ -299,6 +305,9 @@
(context, HEARING_AID_PREFERENCE);
mHearingAidPreferenceController.setFragmentManager(getFragmentManager());
getLifecycle().addObserver(mHearingAidPreferenceController);
+
+ mLiveCaptionPreferenceController = new LiveCaptionPreferenceController(context,
+ LIVE_CAPTION_PREFERENCE_KEY);
}
@Override
@@ -487,6 +496,10 @@
// Captioning.
mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
+ // Live caption
+ mLiveCaptionPreference = findPreference(LIVE_CAPTION_PREFERENCE_KEY);
+ mLiveCaptionPreferenceController.displayPreference(getPreferenceScreen());
+
// Display magnification.
mDisplayMagnificationPreferenceScreen = findPreference(
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
@@ -583,6 +596,7 @@
preference.setKey(componentName.flattenToString());
preference.setTitle(title);
+ preference.setIconSize(ICON_SIZE_MEDIUM);
Utils.setSafeIcon(preference, icon);
final boolean serviceEnabled = enabledServices.contains(componentName);
String description = info.loadDescription(getPackageManager());
@@ -732,6 +746,8 @@
mHearingAidPreferenceController.updateState(mHearingAidPreference);
+ mLiveCaptionPreferenceController.updateState(mLiveCaptionPreference);
+
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
mCaptioningPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
@@ -752,7 +768,6 @@
}
void updateAccessibilityTimeoutSummary(ContentResolver resolver, Preference pref) {
-
String[] timeoutSummarys = getResources().getStringArray(
R.array.accessibility_timeout_summaries);
int[] timeoutValues = getResources().getIntArray(
@@ -821,7 +836,7 @@
pref.setSummary(entries[index]);
}
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
void updateVibrationSummary(Preference pref) {
final Context context = getContext();
final Vibrator vibrator = context.getSystemService(Vibrator.class);
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 46a6371..16f5fcd 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -23,13 +23,19 @@
import android.content.pm.ServiceInfo;
import android.os.Bundle;
import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import androidx.preference.Preference;
+import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.google.android.setupdesign.GlifPreferenceLayout;
+
import java.util.List;
/**
@@ -64,6 +70,23 @@
}
@Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
+ layout.setDividerInsets(Integer.MAX_VALUE, 0);
+
+ layout.setHeaderText(R.string.vision_settings_title);
+ }
+
+ @Override
+ public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
+ Bundle savedInstanceState) {
+ GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
+ return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
+ }
+
+ @Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.accessibility_settings_for_setup_wizard);
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index 9512f01..fc68d2c 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -34,14 +34,6 @@
private static final String SAVE_KEY_TITLE = "activity_title";
@Override
- protected void onCreate(Bundle savedState) {
- super.onCreate(savedState);
-
- // Finish configuring the content view.
- getActionBar().setDisplayHomeAsUpEnabled(true);
- }
-
- @Override
protected void onSaveInstanceState(Bundle savedState) {
savedState.putCharSequence(SAVE_KEY_TITLE, getTitle());
super.onSaveInstanceState(savedState);
diff --git a/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java b/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java
new file mode 100644
index 0000000..2d12f67
--- /dev/null
+++ b/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+public class LiveCaptionPreferenceController extends BasePreferenceController {
+
+ @VisibleForTesting
+ static final Intent LIVE_CAPTION_INTENT = new Intent(
+ "com.android.settings.action.live_caption");
+
+ private final PackageManager mPackageManager;
+
+ public LiveCaptionPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ mPackageManager = context.getPackageManager();
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ final List<ResolveInfo> resolved =
+ mPackageManager.queryIntentActivities(LIVE_CAPTION_INTENT, 0 /* flags */);
+ return resolved != null && !resolved.isEmpty()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setIntent(LIVE_CAPTION_INTENT);
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index 4bda99e..55e85f9 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -145,7 +145,7 @@
mContext.getString(R.string.config_settingsintelligence_package_name));
final LocationManager locationManager =
(LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
- final String locationHistoryPackage = locationManager.getLocationControllerExtraPackage();
+ final String locationHistoryPackage = locationManager.getExtraLocationControllerPackage();
if (locationHistoryPackage != null) {
keepEnabledPackages.add(locationHistoryPackage);
}
diff --git a/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java b/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java
index e118ed6..d9ddc2f 100644
--- a/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java
@@ -560,15 +560,15 @@
|| isSystemPackage(mActivity.getResources(), mPm, mPackageInfo)) {
// Disable button for core system applications.
mButtonsPref.setButton2Text(R.string.disable_text)
- .setButton2Icon(R.drawable.ic_settings_delete);
+ .setButton2Icon(R.drawable.ic_settings_disable);
} else if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
mButtonsPref.setButton2Text(R.string.disable_text)
- .setButton2Icon(R.drawable.ic_settings_delete);
+ .setButton2Icon(R.drawable.ic_settings_disable);
disableable = !mApplicationFeatureProvider.getKeepEnabledPackages()
.contains(mAppEntry.info.packageName);
} else {
mButtonsPref.setButton2Text(R.string.enable_text)
- .setButton2Icon(R.drawable.ic_settings_install);
+ .setButton2Icon(R.drawable.ic_settings_enable);
disableable = true;
}
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 4987286..183d384 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -187,6 +187,9 @@
if (!ensurePackageInfoAvailable(activity)) {
return;
}
+ if (!ensureDisplayableModule(activity)) {
+ return;
+ }
startListeningToPackageRemove();
setHasOptionsMenu(true);
@@ -260,8 +263,8 @@
new InstantAppButtonsPreferenceController(context, this, packageName, lifecycle);
controllers.add(mInstantAppButtonPreferenceController);
mAppButtonsPreferenceController = new AppButtonsPreferenceController(
- (SettingsActivity) getActivity(), this, lifecycle, packageName, mState,
- REQUEST_UNINSTALL, REQUEST_REMOVE_DEVICE_ADMIN);
+ (SettingsActivity) getActivity(), this, lifecycle, packageName, mState,
+ REQUEST_UNINSTALL, REQUEST_REMOVE_DEVICE_ADMIN);
controllers.add(mAppButtonsPreferenceController);
controllers.add(new AppBatteryPreferenceController(context, this, packageName, lifecycle));
controllers.add(new AppMemoryPreferenceController(context, this, lifecycle));
@@ -318,6 +321,23 @@
return true;
}
+ /**
+ * Ensures the package is displayable as directed by {@link AppUtils#isHiddenSystemModule}.
+ * If it's not, the fragment will finish.
+ *
+ * @return true if package is displayable.
+ */
+ @VisibleForTesting
+ boolean ensureDisplayableModule(Activity activity) {
+ if (AppUtils.isHiddenSystemModule(activity.getApplicationContext(), mPackageName)) {
+ mFinishing = true;
+ Log.w(TAG, "Package is hidden module, exiting: " + mPackageName);
+ activity.finishAndRemoveTask();
+ return false;
+ }
+ return true;
+ }
+
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 9839934..4faa158 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -625,12 +625,32 @@
@StringRes
int getHelpResource() {
- if (mListType == LIST_TYPE_MAIN) {
- return R.string.help_uri_apps;
- } else if (mListType == LIST_TYPE_USAGE_ACCESS) {
- return R.string.help_url_usage_access;
- } else {
- return R.string.help_uri_notifications;
+ switch (mListType) {
+ case LIST_TYPE_NOTIFICATION:
+ return R.string.help_uri_notifications;
+ case LIST_TYPE_USAGE_ACCESS:
+ return R.string.help_url_usage_access;
+ case LIST_TYPE_STORAGE:
+ return R.string.help_uri_apps_storage;
+ case LIST_TYPE_HIGH_POWER:
+ return R.string.help_uri_apps_high_power;
+ case LIST_TYPE_OVERLAY:
+ return R.string.help_uri_apps_overlay;
+ case LIST_TYPE_WRITE_SETTINGS:
+ return R.string.help_uri_apps_write_settings;
+ case LIST_TYPE_MANAGE_SOURCES:
+ return R.string.help_uri_apps_manage_sources;
+ case LIST_TYPE_GAMES:
+ return R.string.help_uri_apps_overlay;
+ case LIST_TYPE_MOVIES:
+ return R.string.help_uri_apps_movies;
+ case LIST_TYPE_PHOTOGRAPHY:
+ return R.string.help_uri_apps_photography;
+ case LIST_TYPE_WIFI_ACCESS:
+ return R.string.help_uri_apps_wifi_access;
+ default:
+ case LIST_TYPE_MAIN:
+ return R.string.help_uri_apps;
}
}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 9c9f4fa..a961921 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -21,6 +21,7 @@
import android.annotation.Nullable;
import android.content.Intent;
import android.content.res.Resources;
+import android.content.res.Resources.Theme;
import android.graphics.Color;
import android.os.Bundle;
import android.os.UserHandle;
@@ -97,6 +98,7 @@
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
+ theme.applyStyle(R.style.SetupWizardPartnerResource, true);
super.onApplyThemeResource(theme, resid, first);
}
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 2c4db1f..1d2d793 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -62,6 +62,7 @@
@VisibleForTesting
final Map<String, Bitmap> mIconCache;
private CachedBluetoothDevice mCachedDevice;
+ private BluetoothDevice mBluetoothDevice;
@VisibleForTesting
BluetoothAdapter mBluetoothAdapter;
@VisibleForTesting
@@ -102,6 +103,9 @@
@Override
public void onStart() {
+ if (!isAvailable()) {
+ return;
+ }
mCachedDevice.registerCallback(this::onDeviceAttributesChanged);
mBluetoothAdapter.registerMetadataListener(mCachedDevice.getDevice(), mMetadataListener,
mHandler);
@@ -109,6 +113,9 @@
@Override
public void onStop() {
+ if (!isAvailable()) {
+ return;
+ }
mCachedDevice.unregisterCallback(this::onDeviceAttributesChanged);
mBluetoothAdapter.unregisterMetadataListener(mCachedDevice.getDevice());
@@ -123,6 +130,7 @@
public void init(CachedBluetoothDevice cachedBluetoothDevice) {
mCachedDevice = cachedBluetoothDevice;
+ mBluetoothDevice = mCachedDevice.getDevice();
}
@VisibleForTesting
diff --git a/src/com/android/settings/core/HideNonSystemOverlayMixin.java b/src/com/android/settings/core/HideNonSystemOverlayMixin.java
index 59cef3b..4b8975d 100644
--- a/src/com/android/settings/core/HideNonSystemOverlayMixin.java
+++ b/src/com/android/settings/core/HideNonSystemOverlayMixin.java
@@ -22,9 +22,11 @@
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
import android.app.Activity;
+import android.os.Build;
import android.view.Window;
import android.view.WindowManager;
+import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
@@ -41,9 +43,14 @@
mActivity = activity;
}
+ @VisibleForTesting
+ boolean isEnabled() {
+ return !Build.IS_DEBUGGABLE;
+ }
+
@OnLifecycleEvent(ON_START)
public void onStart() {
- if (mActivity == null) {
+ if (mActivity == null || !isEnabled()) {
return;
}
mActivity.getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
@@ -53,7 +60,7 @@
@OnLifecycleEvent(ON_STOP)
public void onStop() {
- if (mActivity == null) {
+ if (mActivity == null || !isEnabled()) {
return;
}
final Window window = mActivity.getWindow();
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 10eec4e..31d54f9 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -97,6 +97,7 @@
import com.android.settings.location.ScanningSettings;
import com.android.settings.network.ApnEditor;
import com.android.settings.network.ApnSettings;
+import com.android.settings.network.MobileNetworkListFragment;
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings;
@@ -273,7 +274,8 @@
DataUsageList.class.getName(),
ToggleBackupSettingFragment.class.getName(),
PreviouslyConnectedDeviceDashboardFragment.class.getName(),
- BatterySaverScheduleSettings.class.getName()
+ BatterySaverScheduleSettings.class.getName(),
+ MobileNetworkListFragment.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java b/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
new file mode 100644
index 0000000..9498732
--- /dev/null
+++ b/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2019 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.core.instrumentation;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Process;
+import android.os.UserHandle;
+import android.text.TextUtils;
+import android.text.format.DateUtils;
+import android.util.Log;
+import android.util.Pair;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.intelligence.LogProto.SettingsLog;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.LogWriter;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.util.LinkedList;
+import java.util.List;
+
+public class SettingsIntelligenceLogWriter implements LogWriter {
+ private static final String TAG = "IntelligenceLogWriter";
+
+ private static final String LOG = "logs";
+ private static final long MESSAGE_DELAY = DateUtils.MINUTE_IN_MILLIS; // 1 minute
+
+ private List<SettingsLog> mSettingsLogList;
+ private SendLogHandler mLogHandler;
+
+ public SettingsIntelligenceLogWriter() {
+ mSettingsLogList = new LinkedList<>();
+ final HandlerThread workerThread = new HandlerThread("SettingsIntelligenceLogWriter",
+ Process.THREAD_PRIORITY_BACKGROUND);
+ workerThread.start();
+ mLogHandler = new SendLogHandler(workerThread.getLooper());
+ }
+
+ @Override
+ public void visible(Context context, int attribution, int pageId) {
+ action(attribution /* attribution */,
+ SettingsEnums.PAGE_VISIBLE /* action */,
+ pageId /* pageId */,
+ "" /* changedPreferenceKey */,
+ 0 /* changedPreferenceIntValue */);
+ }
+
+ @Override
+ public void hidden(Context context, int pageId) {
+ action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
+ SettingsEnums.PAGE_HIDE /* action */,
+ pageId /* pageId */,
+ "" /* changedPreferenceKey */,
+ 0 /* changedPreferenceIntValue */);
+ }
+
+ @Override
+ public void action(Context context, int action, Pair<Integer, Object>... taggedData) {
+ action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
+ action,
+ SettingsEnums.PAGE_UNKNOWN /* pageId */,
+ "" /* changedPreferenceKey */,
+ 0 /* changedPreferenceIntValue */);
+ }
+
+ @Override
+ public void action(Context context, int action, int value) {
+ action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
+ action,
+ SettingsEnums.PAGE_UNKNOWN /* pageId */,
+ "" /* changedPreferenceKey */,
+ value /* changedPreferenceIntValue */);
+ }
+
+ @Override
+ public void action(Context context, int action, boolean value) {
+ action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
+ action,
+ SettingsEnums.PAGE_UNKNOWN /* pageId */,
+ "" /* changedPreferenceKey */,
+ value ? 1 : 0 /* changedPreferenceIntValue */);
+ }
+
+ @Override
+ public void action(Context context, int action, String pkg) {
+ action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
+ action,
+ SettingsEnums.PAGE_UNKNOWN /* pageId */,
+ pkg /* changedPreferenceKey */,
+ 1 /* changedPreferenceIntValue */);
+ }
+
+ @Override
+ public void action(int attribution, int action, int pageId, String key, int value) {
+ final ZonedDateTime now = ZonedDateTime.now(ZoneId.systemDefault());
+ final SettingsLog settingsLog = SettingsLog.newBuilder()
+ .setAttribution(attribution)
+ .setAction(action)
+ .setPageId(pageId)
+ .setChangedPreferenceKey(key != null ? key : "")
+ .setChangedPreferenceIntValue(value)
+ .setTimestamp(now.toString())
+ .build();
+ mLogHandler.post(() -> {
+ mSettingsLogList.add(settingsLog);
+ });
+ mLogHandler.scheduleSendLog();
+ }
+
+ @VisibleForTesting
+ static byte[] serialize(List<SettingsLog> settingsLogs) {
+ final int size = settingsLogs.size();
+ final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ final DataOutputStream output = new DataOutputStream(bout);
+ // Data is "size, length, bytearray, length, bytearray ..."
+ try {
+ output.writeInt(size);
+ for (SettingsLog settingsLog : settingsLogs) {
+ final byte[] data = settingsLog.toByteArray();
+ output.writeInt(data.length);
+ output.write(data);
+ }
+ return bout.toByteArray();
+ } catch (Exception e) {
+ Log.e(TAG, "serialize error", e);
+ return null;
+ } finally {
+ try {
+ output.close();
+ } catch (Exception e) {
+ Log.e(TAG, "close error", e);
+ }
+ }
+ }
+
+ private class SendLogHandler extends Handler {
+
+ public SendLogHandler(Looper looper) {
+ super(looper);
+ }
+
+ public void scheduleSendLog() {
+ removeCallbacks(mSendLogsRunnable);
+ postDelayed(mSendLogsRunnable, MESSAGE_DELAY);
+ }
+ }
+
+ private final Runnable mSendLogsRunnable = () -> {
+ final Context context = FeatureFactory.getAppContext();
+ if (context == null) {
+ Log.e(TAG, "context is null");
+ return;
+ }
+ final String action = context.getString(R.string
+ .config_settingsintelligence_log_action);
+ if (!TextUtils.isEmpty(action) && !mSettingsLogList.isEmpty()) {
+ final Intent intent = new Intent();
+ intent.setPackage(context.getString(R.string
+ .config_settingsintelligence_package_name));
+ intent.setAction(action);
+ intent.putExtra(LOG, serialize(mSettingsLogList));
+ context.sendBroadcastAsUser(intent, UserHandle.CURRENT);
+ mSettingsLogList.clear();
+ }
+ };
+}
diff --git a/src/com/android/settings/core/instrumentation/SettingsMetricsFeatureProvider.java b/src/com/android/settings/core/instrumentation/SettingsMetricsFeatureProvider.java
index 93a5163..ec05757 100644
--- a/src/com/android/settings/core/instrumentation/SettingsMetricsFeatureProvider.java
+++ b/src/com/android/settings/core/instrumentation/SettingsMetricsFeatureProvider.java
@@ -16,6 +16,8 @@
package com.android.settings.core.instrumentation;
+import android.content.Context;
+
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class SettingsMetricsFeatureProvider extends MetricsFeatureProvider {
@@ -23,5 +25,6 @@
protected void installLogWriters() {
super.installLogWriters();
mLoggerWriters.add(new StatsLogWriter());
+ mLoggerWriters.add(new SettingsIntelligenceLogWriter());
}
}
diff --git a/src/com/android/settings/development/AutomaticSystemServerHeapDumpPreferenceController.java b/src/com/android/settings/development/AutomaticSystemServerHeapDumpPreferenceController.java
new file mode 100644
index 0000000..aa76bb8
--- /dev/null
+++ b/src/com/android/settings/development/AutomaticSystemServerHeapDumpPreferenceController.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.Build;
+import android.os.UserManager;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class AutomaticSystemServerHeapDumpPreferenceController extends
+ DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
+ PreferenceControllerMixin {
+
+ private static final String KEY_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS =
+ "automatic_system_server_heap_dumps";
+
+ private static final int SETTING_VALUE_OFF = 0;
+ private static final int SETTING_VALUE_ON = 1;
+
+ private final UserManager mUserManager;
+ private final boolean mIsConfigEnabled;
+
+ public AutomaticSystemServerHeapDumpPreferenceController(Context context) {
+ super(context);
+ mIsConfigEnabled = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_debugEnableAutomaticSystemServerHeapDumps);
+ mUserManager = context.getSystemService(UserManager.class);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return Build.IS_DEBUGGABLE && mIsConfigEnabled
+ && !mUserManager.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean isEnabled = (Boolean) newValue;
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS,
+ isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, SETTING_VALUE_ON);
+ ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, SETTING_VALUE_OFF);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index adc23a8..e9fc759 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -404,6 +404,7 @@
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new MemoryUsagePreferenceController(context));
controllers.add(new BugReportPreferenceController(context));
+ controllers.add(new SystemServerHeapDumpPreferenceController(context));
controllers.add(new LocalBackupPasswordPreferenceController(context));
controllers.add(new StayAwakePreferenceController(context, lifecycle));
controllers.add(new HdcpCheckingPreferenceController(context));
@@ -418,6 +419,7 @@
controllers.add(new ClearAdbKeysPreferenceController(context, fragment));
controllers.add(new LocalTerminalPreferenceController(context));
controllers.add(new BugReportInPowerPreferenceController(context));
+ controllers.add(new AutomaticSystemServerHeapDumpPreferenceController(context));
controllers.add(new MockLocationAppPreferenceController(context, fragment));
controllers.add(new DebugViewAttributesPreferenceController(context));
controllers.add(new SelectDebugAppPreferenceController(context, fragment));
diff --git a/src/com/android/settings/development/SystemServerHeapDumpPreferenceController.java b/src/com/android/settings/development/SystemServerHeapDumpPreferenceController.java
new file mode 100644
index 0000000..599162e
--- /dev/null
+++ b/src/com/android/settings/development/SystemServerHeapDumpPreferenceController.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.os.Build;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.os.UserManager;
+import android.util.Log;
+import android.widget.Toast;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class SystemServerHeapDumpPreferenceController extends DeveloperOptionsPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String KEY_SYSTEM_SERVER_HEAP_DUMP = "system_server_heap_dump";
+
+ /** How long to keep the preference disabled before re-enabling. */
+ private static final long ENABLE_TIMEOUT_MILLIS = 5000L;
+
+ private final UserManager mUserManager;
+
+ private Handler mHandler;
+
+ public SystemServerHeapDumpPreferenceController(Context context) {
+ super(context);
+
+ mUserManager = context.getSystemService(UserManager.class);
+ mHandler = new Handler();
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return Build.IS_DEBUGGABLE
+ && !mUserManager.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_SYSTEM_SERVER_HEAP_DUMP;
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!KEY_SYSTEM_SERVER_HEAP_DUMP.equals(preference.getKey())) {
+ return false;
+ }
+ try {
+ // Temporarily disable the preference so the user doesn't start two dumps in a row.
+ preference.setEnabled(false);
+ Toast.makeText(mContext, R.string.capturing_system_heap_dump_message,
+ Toast.LENGTH_SHORT).show();
+ ActivityManager.getService().requestSystemServerHeapDump();
+ mHandler.postDelayed(() -> preference.setEnabled(true), ENABLE_TIMEOUT_MILLIS);
+ return true;
+ } catch (RemoteException e) {
+ Log.e(TAG, "error taking system heap dump", e);
+ Toast.makeText(mContext, R.string.error_capturing_system_heap_dump_message,
+ Toast.LENGTH_SHORT).show();
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 638c7c1..94636e9 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.development.featureflags;
import android.content.Context;
+import android.os.Build;
import android.util.FeatureFlagUtils;
import androidx.preference.PreferenceGroup;
@@ -39,7 +40,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return Build.IS_DEBUGGABLE ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
index 48cdeeb..3873389 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardBase.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -24,6 +24,7 @@
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.content.Intent;
+import android.content.res.Resources.Theme;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.SystemClock;
@@ -123,6 +124,12 @@
super.onDestroy();
}
+ @Override
+ protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
+ theme.applyStyle(R.style.SetupWizardPartnerResource, true);
+ super.onApplyThemeResource(theme, resid, first);
+ }
+
protected FooterButton getBackButton() {
return mBack;
}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
index e2f4fae..174cb8c 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
@@ -17,11 +17,16 @@
package com.android.settings.deviceinfo.firmwareversion;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.FeatureFlags;
@@ -29,6 +34,9 @@
private static final String TAG = "MainlineModuleControl";
+ @VisibleForTesting
+ static final Intent MODULE_UPDATE_INTENT =
+ new Intent("android.settings.MODULE_UPDATE_SETTINGS");
private final PackageManager mPackageManager;
private String mModuleVersion;
@@ -66,6 +74,20 @@
}
@Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+
+ // Confirm MODULE_UPDATE_INTENT is handleable, and set it to Preference.
+ final ResolveInfo resolved =
+ mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0 /* flags */);
+ if (resolved != null) {
+ preference.setIntent(MODULE_UPDATE_INTENT);
+ } else {
+ preference.setIntent(null);
+ }
+ }
+
+ @Override
public CharSequence getSummary() {
return mModuleVersion;
}
diff --git a/src/com/android/settings/display/DarkUIPreferenceController.java b/src/com/android/settings/display/DarkUIPreferenceController.java
index 21af603..7d8fd56 100644
--- a/src/com/android/settings/display/DarkUIPreferenceController.java
+++ b/src/com/android/settings/display/DarkUIPreferenceController.java
@@ -27,8 +27,7 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
-public class DarkUIPreferenceController extends BasePreferenceController
- implements Preference.OnPreferenceChangeListener {
+public class DarkUIPreferenceController extends BasePreferenceController {
private UiModeManager mUiModeManager;
@@ -48,58 +47,8 @@
}
@Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- int value = mUiModeManager.getNightMode();
- ListPreference preference = screen.findPreference(getPreferenceKey());
- preference.setValue(modeToString(value));
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- mUiModeManager.setNightMode(modeToInt((String) newValue));
- refreshSummary(preference);
- return true;
- }
-
- @Override
public CharSequence getSummary() {
- return modeToDescription(mUiModeManager.getNightMode());
- }
-
- private String modeToDescription(int mode) {
- String[] values = mContext.getResources().getStringArray(R.array.dark_ui_mode_entries);
- switch (mode) {
- case UiModeManager.MODE_NIGHT_YES:
- return values[0];
- case UiModeManager.MODE_NIGHT_NO:
- case UiModeManager.MODE_NIGHT_AUTO:
- default:
- return values[1];
-
- }
- }
-
- private String modeToString(int mode) {
- switch (mode) {
- case UiModeManager.MODE_NIGHT_YES:
- return "yes";
- case UiModeManager.MODE_NIGHT_NO:
- case UiModeManager.MODE_NIGHT_AUTO:
- default:
- return "no";
-
- }
- }
-
- private int modeToInt(String mode) {
- switch (mode) {
- case "yes":
- return UiModeManager.MODE_NIGHT_YES;
- case "no":
- case "auto":
- default:
- return UiModeManager.MODE_NIGHT_NO;
- }
+ return DarkUISettingsRadioButtonsController.modeToDescription(
+ mContext, mUiModeManager.getNightMode());
}
}
diff --git a/src/com/android/settings/display/DarkUISettings.java b/src/com/android/settings/display/DarkUISettings.java
new file mode 100644
index 0000000..50fd386
--- /dev/null
+++ b/src/com/android/settings/display/DarkUISettings.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 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.display;
+
+import android.app.UiModeManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.SearchIndexableResource;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.CandidateInfo;
+import com.android.settingslib.widget.FooterPreference;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * The screen for selecting the dark theme preference for this device. Automatically updates
+ * the associated footer view with any needed information.
+ */
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class DarkUISettings extends RadioButtonPickerFragment implements Indexable {
+
+ private DarkUISettingsRadioButtonsController mController;
+ private Preference mFooter;
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.dark_ui_settings;
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ // TODO(b/128686189): add illustration once it is ready
+ setIllustration(0, 0);
+ mFooter = new FooterPreference(context);
+ mFooter.setIcon(android.R.color.transparent);
+ mController = new DarkUISettingsRadioButtonsController(context, mFooter);
+ }
+
+ @Override
+ protected List<? extends CandidateInfo> getCandidates() {
+ final Context context = getContext();
+ final List<CandidateInfo> candidates = new ArrayList<>();
+ candidates.add(new DarkUISettingsCandidateInfo(
+ DarkUISettingsRadioButtonsController.modeToDescription(
+ context, UiModeManager.MODE_NIGHT_YES),
+ /* summary */ null,
+ DarkUISettingsRadioButtonsController.KEY_DARK,
+ /* enabled */ true));
+ candidates.add(new DarkUISettingsCandidateInfo(
+ DarkUISettingsRadioButtonsController.modeToDescription(
+ context, UiModeManager.MODE_NIGHT_NO),
+ /* summary */ null,
+ DarkUISettingsRadioButtonsController.KEY_LIGHT,
+ /* enabled */ true));
+ return candidates;
+ }
+
+ @Override
+ protected void addStaticPreferences(PreferenceScreen screen) {
+ screen.addPreference(mFooter);
+ }
+
+ @Override
+ protected String getDefaultKey() {
+ return mController.getDefaultKey();
+ }
+
+ @Override
+ protected boolean setDefaultKey(String key) {
+ return mController.setDefaultKey(key);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.DARK_UI_SETTINGS;
+ }
+
+ static class DarkUISettingsCandidateInfo extends CandidateInfo {
+
+ private final CharSequence mLabel;
+ private final CharSequence mSummary;
+ private final String mKey;
+
+ DarkUISettingsCandidateInfo(CharSequence label, CharSequence summary, String key,
+ boolean enabled) {
+ super(enabled);
+ mLabel = label;
+ mKey = key;
+ mSummary = summary;
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ return mLabel;
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ return mKey;
+ }
+
+ public CharSequence getSummary() {
+ return mSummary;
+ }
+ }
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.dark_ui_settings;
+ return Arrays.asList(sir);
+ }
+ };
+}
diff --git a/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java b/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java
new file mode 100644
index 0000000..0fca306
--- /dev/null
+++ b/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2019 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.display;
+
+import android.app.UiModeManager;
+import android.content.Context;
+import androidx.preference.Preference;
+import com.android.settings.R;
+import androidx.annotation.VisibleForTesting;
+
+public class DarkUISettingsRadioButtonsController {
+
+ public static final String KEY_DARK = "key_dark_ui_settings_dark";
+ public static final String KEY_LIGHT = "key_dark_ui_settings_light";
+
+ @VisibleForTesting
+ UiModeManager mManager;
+
+ private Preference mFooter;
+
+ public DarkUISettingsRadioButtonsController(Context context, Preference footer) {
+ mManager = context.getSystemService(UiModeManager.class);
+ mFooter = footer;
+ }
+
+ public String getDefaultKey() {
+ final int mode = mManager.getNightMode();
+ updateFooter();
+ return mode == UiModeManager.MODE_NIGHT_YES ? KEY_DARK : KEY_LIGHT;
+ }
+
+ public boolean setDefaultKey(String key) {
+ switch(key) {
+ case KEY_DARK:
+ mManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
+ break;
+ case KEY_LIGHT:
+ mManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
+ break;
+ default:
+ throw new IllegalStateException(
+ "Not a valid key for " + this.getClass().getSimpleName() + ": " + key);
+ }
+ updateFooter();
+ return true;
+ }
+
+ public void updateFooter() {
+ final int mode = mManager.getNightMode();
+ switch (mode) {
+ case UiModeManager.MODE_NIGHT_YES:
+ mFooter.setSummary(R.string.dark_ui_settings_dark_summary);
+ break;
+ case UiModeManager.MODE_NIGHT_NO:
+ case UiModeManager.MODE_NIGHT_AUTO:
+ default:
+ mFooter.setSummary(R.string.dark_ui_settings_light_summary);
+ }
+ }
+
+ public static String modeToDescription(Context context, int mode) {
+ final String[] values = context.getResources().getStringArray(R.array.dark_ui_mode_entries);
+ switch (mode) {
+ case UiModeManager.MODE_NIGHT_YES:
+ return values[0];
+ case UiModeManager.MODE_NIGHT_NO:
+ case UiModeManager.MODE_NIGHT_AUTO:
+ default:
+ return values[1];
+ }
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index c91cc8f..38ae2b2 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -145,7 +145,7 @@
break;
case CELL:
name = context.getResources().getString(R.string.power_cell);
- iconId = R.drawable.ic_settings_cell_standby;
+ iconId = R.drawable.ic_cellular_1_bar;
break;
case PHONE:
name = context.getResources().getString(R.string.power_phone);
@@ -199,11 +199,11 @@
} break;
case UNACCOUNTED:
name = context.getResources().getString(R.string.power_unaccounted);
- iconId = R.drawable.ic_power_system;
+ iconId = R.drawable.ic_android;
break;
case OVERCOUNTED:
name = context.getResources().getString(R.string.power_overcounted);
- iconId = R.drawable.ic_power_system;
+ iconId = R.drawable.ic_android;
break;
case CAMERA:
name = context.getResources().getString(R.string.power_camera);
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
index 796df46..57bae45 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
@@ -20,6 +20,8 @@
import android.os.PowerManager;
import android.provider.Settings;
import android.provider.Settings.Global;
+import android.text.TextUtils;
+import com.android.settingslib.fuelgauge.BatterySaverUtils;
/**
* Responds to user actions in the Settings > Battery > Set a Schedule Screen
@@ -66,24 +68,34 @@
public boolean setDefaultKey(String key) {
final ContentResolver resolver = mContext.getContentResolver();
- switch(key) {
- case KEY_NO_SCHEDULE:
- Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
- PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
- Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
- break;
- case KEY_PERCENTAGE:
- Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
- PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
- Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
- break;
- case KEY_ROUTINE:
- Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
- PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
- break;
- default:
- throw new IllegalStateException(
- "Not a valid key for " + this.getClass().getSimpleName());
+
+ int mode = PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE;
+ int triggerLevel = 0;
+ if (!TextUtils.equals(key, KEY_NO_SCHEDULE)
+ && BatterySaverUtils.maybeShowBatterySaverConfirmation(
+ mContext, true /* confirmOnly */)) {
+ return true;
+ } else {
+ switch (key) {
+ case KEY_NO_SCHEDULE:
+ break;
+ case KEY_PERCENTAGE:
+ triggerLevel = 5;
+ break;
+ case KEY_ROUTINE:
+ mode = PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC;
+ break;
+ default:
+ throw new IllegalStateException(
+ "Not a valid key for " + this.getClass().getSimpleName());
+ }
+ }
+
+ // Trigger level is intentionally left alone when going between dynamic and percentage modes
+ // so that a users percentage based schedule is preserved when they toggle between the two.
+ Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE, mode);
+ if (mode != PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC) {
+ Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, triggerLevel);
}
mSeekBarController.updateSeekBar();
return true;
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
index 7a1f7f5..7d4bdac 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -1,37 +1,58 @@
package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
+import android.icu.text.NumberFormat;
import android.provider.Settings;
+import android.provider.Settings.Global;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
-import com.android.settings.core.BasePreferenceController;
+import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.core.TogglePreferenceController;
-public class BatterySaverStickyPreferenceController extends BasePreferenceController implements
+public class BatterySaverStickyPreferenceController extends TogglePreferenceController implements
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
- public static final String LOW_POWER_STICKY_AUTO_DISABLE_ENABLED =
- "low_power_sticky_auto_disable_enabled";
+ private Context mContext;
public BatterySaverStickyPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
+ mContext = context;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, 1) == 1;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
+ isChecked ? 1 : 0);
+ return true;
+ }
+
+ @Override
+ protected void refreshSummary(Preference preference) {
+ super.refreshSummary(preference);
+ final double stickyShutoffLevel = Settings.Global.getInt(
+ mContext.getContentResolver(), Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, 90);
+ final String percentage = NumberFormat
+ .getPercentInstance()
+ .format(stickyShutoffLevel / 100.0);
+ preference.setSummary(
+ mContext.getString(R.string.battery_saver_sticky_description_new, percentage));
}
@Override
public void updateState(Preference preference) {
int setting = Settings.Global.getInt(mContext.getContentResolver(),
- LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, 1);
- ((SwitchPreference) preference).setChecked(setting == 0);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- boolean keepActive = (Boolean) newValue;
- Settings.Global.putInt(mContext.getContentResolver(),
- LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
- keepActive ? 0 : 1);
- return true;
+ ((SwitchPreference) preference).setChecked(setting == 1);
+ refreshSummary(preference);
}
@Override
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCard.java b/src/com/android/settings/homepage/contextualcards/ContextualCard.java
index 7b8a0c3..ede12fb 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCard.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCard.java
@@ -71,6 +71,7 @@
private final Drawable mIconDrawable;
@LayoutRes
private final int mViewType;
+ private final boolean mIsPendingDismiss;
public String getName() {
return mName;
@@ -156,6 +157,10 @@
return mViewType;
}
+ public boolean isPendingDismiss() {
+ return mIsPendingDismiss;
+ }
+
public Builder mutate() {
return mBuilder;
}
@@ -181,6 +186,7 @@
mIconDrawable = builder.mIconDrawable;
mIsLargeCard = builder.mIsLargeCard;
mViewType = builder.mViewType;
+ mIsPendingDismiss = builder.mIsPendingDismiss;
}
ContextualCard(Cursor c) {
@@ -226,6 +232,8 @@
mBuilder.setIconDrawable(mIconDrawable);
mViewType = getViewTypeByCardType(mCardType);
mBuilder.setViewType(mViewType);
+ mIsPendingDismiss = false;
+ mBuilder.setIsPendingDismiss(mIsPendingDismiss);
}
@Override
@@ -277,6 +285,7 @@
private boolean mIsLargeCard;
@LayoutRes
private int mViewType;
+ private boolean mIsPendingDismiss;
public Builder setName(String name) {
mName = name;
@@ -373,6 +382,11 @@
return this;
}
+ public Builder setIsPendingDismiss(boolean isPendingDismiss) {
+ mIsPendingDismiss = isPendingDismiss;
+ return this;
+ }
+
public ContextualCard build() {
return new ContextualCard(this);
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
index b1e9d33..c296c7a 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
@@ -32,5 +32,5 @@
List<ContextualCard> hiddenCards);
/** When user clicks toggle/title area of a contextual card. */
- void logContextualCardClick(ContextualCard card, int row, int tapTarget);
+ void logContextualCardClick(ContextualCard card, int sliceRow, int tapTarget, int uiPosition);
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
index ce7777a..793134f 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
@@ -63,6 +63,9 @@
// contextual card tap target
private static final String EXTRA_CONTEXTUALCARD_TAP_TARGET = "target";
+ // contextual card ui position
+ private static final String EXTRA_CONTEXTUALCARD_UI_POSTITION = "ui_position";
+
// contextual homepage display latency
private static final String EXTRA_LATENCY = "latency";
@@ -122,7 +125,7 @@
@Override
public void logContextualCardClick(ContextualCard card, int row,
- int actionType) {
+ int actionType, int uiPosition) {
final Intent intent = new Intent();
intent.putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_CARD_CLICK);
intent.putExtra(EXTRA_CONTEXTUALCARD_NAME, card.getName());
@@ -130,6 +133,7 @@
intent.putExtra(EXTRA_CONTEXTUALCARD_SCORE, card.getRankingScore());
intent.putExtra(EXTRA_CONTEXTUALCARD_ROW, row);
intent.putExtra(EXTRA_CONTEXTUALCARD_TAP_TARGET, actionTypeToTapTarget(actionType));
+ intent.putExtra(EXTRA_CONTEXTUALCARD_UI_POSTITION, uiPosition);
sendBroadcast(intent);
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java b/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java
index 241834d..7be0e8e 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java
@@ -28,6 +28,7 @@
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardRenderer;
+import com.android.settings.homepage.contextualcards.slices.SwipeDismissalDelegate;
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer;
import java.util.ArrayList;
@@ -35,7 +36,7 @@
import java.util.Map;
public class ContextualCardsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
- implements ContextualCardUpdateListener {
+ implements ContextualCardUpdateListener, SwipeDismissalDelegate.Listener {
static final int SPAN_COUNT = 2;
private static final String TAG = "ContextualCardsAdapter";
@@ -136,4 +137,12 @@
//TODO(b/119465242): flickering conditional cards after collapsing/expanding
}
+
+ @Override
+ public void onSwiped(int position) {
+ final ContextualCard card = mContextualCards.get(position).mutate()
+ .setIsPendingDismiss(true).build();
+ mContextualCards.set(position, card);
+ notifyItemChanged(position);
+ }
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java b/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
index bd25866..0cf553c 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
@@ -27,9 +27,11 @@
import androidx.loader.app.LoaderManager;
import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.ItemTouchHelper;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.homepage.contextualcards.slices.SwipeDismissalDelegate;
import com.android.settings.overlay.FeatureFactory;
public class ContextualCardsFragment extends InstrumentedFragment implements
@@ -41,6 +43,7 @@
private GridLayoutManager mLayoutManager;
private ContextualCardsAdapter mContextualCardsAdapter;
private ContextualCardManager mContextualCardManager;
+ private ItemTouchHelper mItemTouchHelper;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -63,16 +66,20 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ final Context context = getContext();
final View rootView = inflater.inflate(R.layout.settings_homepage, container, false);
mCardsContainer = rootView.findViewById(R.id.card_container);
mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT,
GridLayoutManager.VERTICAL, false /* reverseLayout */);
mCardsContainer.setLayoutManager(mLayoutManager);
- mContextualCardsAdapter = new ContextualCardsAdapter(getContext(),
- this /* lifecycleOwner */, mContextualCardManager);
+ mContextualCardsAdapter = new ContextualCardsAdapter(context, this /* lifecycleOwner */,
+ mContextualCardManager);
mCardsContainer.setAdapter(mContextualCardsAdapter);
mContextualCardManager.setListener(mContextualCardsAdapter);
mCardsContainer.setListener(this);
+ mItemTouchHelper = new ItemTouchHelper(
+ new SwipeDismissalDelegate(context, mContextualCardsAdapter));
+ mItemTouchHelper.attachToRecyclerView(mCardsContainer);
return rootView;
}
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
index 664707d..61b24df 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
@@ -16,26 +16,40 @@
package com.android.settings.homepage.contextualcards.conditional;
+import android.Manifest;
import android.app.settings.SettingsEnums;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.hardware.display.ColorDisplayManager;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
+
import com.android.settings.R;
import com.android.settings.homepage.contextualcards.ContextualCard;
import java.net.URISyntaxException;
+import java.util.List;
import java.util.Objects;
public class GrayscaleConditionController implements ConditionalCardController {
static final int ID = Objects.hash("GrayscaleConditionController");
+ @VisibleForTesting
+ static final String ACTION_GRAYSCALE_CHANGED = "android.settings.action.GRAYSCALE_CHANGED";
+
private static final String TAG = "GrayscaleCondition";
+ private static final IntentFilter GRAYSCALE_CHANGED_FILTER = new IntentFilter(
+ ACTION_GRAYSCALE_CHANGED);
private final Context mAppContext;
private final ConditionManager mConditionManager;
private final ColorDisplayManager mColorDisplayManager;
+ private final Receiver mReceiver;
private Intent mIntent;
@@ -43,6 +57,7 @@
mAppContext = appContext;
mConditionManager = conditionManager;
mColorDisplayManager = mAppContext.getSystemService(ColorDisplayManager.class);
+ mReceiver = new Receiver();
}
@Override
@@ -72,6 +87,7 @@
public void onActionClick() {
// Turn off grayscale
mColorDisplayManager.setSaturationLevel(100 /* staturationLevel */);
+ sendBroadcast();
mConditionManager.onConditionChanged();
}
@@ -93,11 +109,31 @@
@Override
public void startMonitoringStateChange() {
-
+ mAppContext.registerReceiver(mReceiver, GRAYSCALE_CHANGED_FILTER,
+ Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS, null /* scheduler */);
}
@Override
public void stopMonitoringStateChange() {
+ mAppContext.unregisterReceiver(mReceiver);
+ }
+ private void sendBroadcast() {
+ final PackageManager pm = mAppContext.getPackageManager();
+ final Intent intent = new Intent(ACTION_GRAYSCALE_CHANGED);
+ final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(intent, 0 /* flags */);
+ for (ResolveInfo receiver : receivers) {
+ intent.setPackage(receiver.activityInfo.packageName);
+ mAppContext.sendBroadcast(intent);
+ }
+ }
+
+ public class Receiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (ACTION_GRAYSCALE_CHANGED.equals(intent.getAction())) {
+ mConditionManager.onConditionChanged();
+ }
+ }
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index c319dca..0278f90 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -131,6 +131,7 @@
protected final Context mContext;
@VisibleForTesting
NotificationBackend mNotificationBackend;
+ private NotificationBackend.AppRow mAppRow;
private String mPackageName;
private int mUid;
@@ -175,15 +176,10 @@
.setSubtitle(getSubTitle(mPackageName, mUid))
.setPrimaryAction(getPrimarySliceAction(icon, title, getIntent())));
- // Get rows by notification channel.
+ // Add notification channel rows.
final List<ListBuilder.RowBuilder> rows = getNotificationChannelRows(packageInfo, icon);
-
- // Get displayable notification channel count.
- final int channelCount = Math.min(rows.size(), DEFAULT_EXPANDED_ROW_COUNT);
-
- // According to the displayable channel count to add rows.
- for (int i = 0; i < channelCount; i++) {
- listBuilder.addRow(rows.get(i));
+ for (ListBuilder.RowBuilder rowBuilder : rows) {
+ listBuilder.addRow(rowBuilder);
}
return listBuilder.build();
@@ -200,21 +196,12 @@
final String packageName = intent.getStringExtra(PACKAGE_NAME);
final int uid = intent.getIntExtra(PACKAGE_UID, -1);
final String channelId = intent.getStringExtra(CHANNEL_ID);
- final PackageInfo packageInfo = getPackageInfo(packageName);
- final NotificationBackend.AppRow appRow = mNotificationBackend.loadAppRow(mContext,
- mContext.getPackageManager(), packageInfo);
-
- final List<NotificationChannel> notificationChannels = getEnabledChannels(packageName, uid,
- appRow);
- for (NotificationChannel channel : notificationChannels) {
- if (TextUtils.equals(channel.getId(), channelId)) {
- final int importance = newState ? IMPORTANCE_LOW : IMPORTANCE_NONE;
- channel.setImportance(importance);
- channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
- mNotificationBackend.updateChannel(packageName, uid, channel);
- return;
- }
- }
+ final NotificationChannel channel = mNotificationBackend.getChannel(packageName, uid,
+ channelId);
+ final int importance = newState ? IMPORTANCE_LOW : IMPORTANCE_NONE;
+ channel.setImportance(importance);
+ channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ mNotificationBackend.updateChannel(packageName, uid, channel);
}
@Override
@@ -287,16 +274,13 @@
private List<ListBuilder.RowBuilder> getNotificationChannelRows(PackageInfo packageInfo,
IconCompat icon) {
final List<ListBuilder.RowBuilder> notificationChannelRows = new ArrayList<>();
- final NotificationBackend.AppRow appRow = mNotificationBackend.loadAppRow(mContext,
- mContext.getPackageManager(), packageInfo);
- final List<NotificationChannel> enabledChannels = getEnabledChannels(mPackageName, mUid,
- appRow);
+ final List<NotificationChannel> displayableChannels = getDisplayableChannels(mAppRow);
- for (NotificationChannel channel : enabledChannels) {
+ for (NotificationChannel channel : displayableChannels) {
notificationChannelRows.add(new ListBuilder.RowBuilder()
.setTitle(channel.getName())
.setSubtitle(NotificationBackend.getSentSummary(
- mContext, appRow.sentByChannel.get(channel.getId()), false))
+ mContext, mAppRow.sentByChannel.get(channel.getId()), false))
.setPrimaryAction(buildRowSliceAction(channel, icon))
.addEndItem(SliceAction.createToggle(getToggleIntent(channel.getId()),
null /* actionTitle */, channel.getImportance() != IMPORTANCE_NONE)));
@@ -366,10 +350,9 @@
title);
}
- private List<NotificationChannel> getEnabledChannels(String packageName, int uid,
- NotificationBackend.AppRow appRow) {
+ private List<NotificationChannel> getDisplayableChannels(NotificationBackend.AppRow appRow) {
final List<NotificationChannelGroup> channelGroupList =
- mNotificationBackend.getGroups(packageName, uid).getList();
+ mNotificationBackend.getGroups(appRow.pkg, appRow.uid).getList();
final List<NotificationChannel> channels = channelGroupList.stream()
.flatMap(group -> group.getChannels().stream().filter(
channel -> isChannelEnabled(group, channel, appRow)))
@@ -386,8 +369,11 @@
}
// Sort the notification channels with notification sent count by descending.
- return channelStates.stream().sorted(CHANNEL_STATE_COMPARATOR).map(
- state -> state.getNotificationChannel()).collect(Collectors.toList());
+ return channelStates.stream()
+ .sorted(CHANNEL_STATE_COMPARATOR)
+ .map(state -> state.getNotificationChannel())
+ .limit(DEFAULT_EXPANDED_ROW_COUNT)
+ .collect(Collectors.toList());
}
private PackageInfo getMaxSentNotificationsPackage(List<PackageInfo> packageInfoList) {
@@ -401,18 +387,32 @@
for (PackageInfo packageInfo : packageInfoList) {
final NotificationBackend.AppRow appRow = mNotificationBackend.loadAppRow(mContext,
mContext.getPackageManager(), packageInfo);
+ // Ignore packages which are banned notifications or block all displayable channels.
+ if (appRow.banned || isAllChannelsBlocked(getDisplayableChannels(appRow))) {
+ continue;
+ }
+
// Get sent notification count from app.
final int sentCount = appRow.sentByApp.sentCount;
- if (!appRow.banned && sentCount >= MIN_NOTIFICATION_SENT_COUNT
- && sentCount > maxSentCount) {
+ if (sentCount >= MIN_NOTIFICATION_SENT_COUNT && sentCount > maxSentCount) {
maxSentCount = sentCount;
maxSentCountPackage = packageInfo;
+ mAppRow = appRow;
}
}
return maxSentCountPackage;
}
+ private boolean isAllChannelsBlocked(List<NotificationChannel> channels) {
+ for (NotificationChannel channel : channels) {
+ if (channel.getImportance() != IMPORTANCE_NONE) {
+ return false;
+ }
+ }
+ return true;
+ }
+
protected CharSequence getSubTitle(String packageName, int uid) {
final int channelCount = mNotificationBackend.getChannelCount(packageName, uid);
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index b9170a9..590afd2 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -64,7 +64,6 @@
private final Context mContext;
private final LifecycleOwner mLifecycleOwner;
private final ControllerRendererPool mControllerRendererPool;
- private final Set<ContextualCard> mCardSet;
private final SliceDeferredSetupCardRendererHelper mDeferredSetupCardHelper;
private final SliceFullCardRendererHelper mFullCardHelper;
private final SliceHalfCardRendererHelper mHalfCardHelper;
@@ -75,7 +74,6 @@
mLifecycleOwner = lifecycleOwner;
mSliceLiveDataMap = new ArrayMap<>();
mControllerRendererPool = controllerRendererPool;
- mCardSet = new ArraySet<>();
mFlippedCardSet = new ArraySet<>();
mLifecycleOwner.getLifecycle().addObserver(this);
mFullCardHelper = new SliceFullCardRendererHelper(context);
@@ -98,8 +96,6 @@
@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
final Uri uri = card.getSliceUri();
- //TODO(b/120629936): Take this out once blank card issue is fixed.
- Log.d(TAG, "bindView - uri = " + uri);
if (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
Log.w(TAG, "Invalid uri, skipping slice: " + uri);
@@ -112,7 +108,6 @@
sliceLiveData = SliceLiveData.fromUri(mContext, uri);
mSliceLiveDataMap.put(uri, sliceLiveData);
}
- mCardSet.add(card);
sliceLiveData.removeObservers(mLifecycleOwner);
sliceLiveData.observe(mLifecycleOwner, slice -> {
@@ -121,10 +116,8 @@
mContext.getContentResolver().notifyChange(CardContentProvider.REFRESH_CARD_URI,
null);
return;
- } else {
- //TODO(b/120629936): Take this out once blank card issue is fixed.
- Log.d(TAG, "Slice callback - uri = " + slice.getUri());
}
+
switch (holder.getItemViewType()) {
case VIEW_TYPE_DEFERRED_SETUP:
mDeferredSetupCardHelper.bindView(holder, card, slice);
@@ -133,7 +126,7 @@
mHalfCardHelper.bindView(holder, card, slice);
break;
default:
- mFullCardHelper.bindView(holder, card, slice, mCardSet);
+ mFullCardHelper.bindView(holder, card, slice);
}
});
@@ -142,23 +135,19 @@
// Deferred setup is never dismissible.
break;
case VIEW_TYPE_HALF_WIDTH:
- initDismissalActions(holder, card, R.id.content);
+ initDismissalActions(holder, card);
break;
default:
- initDismissalActions(holder, card, R.id.slice_view);
+ initDismissalActions(holder, card);
+ }
+
+ if (card.isPendingDismiss()) {
+ flipCardToDismissalView(holder);
+ mFlippedCardSet.add(holder);
}
}
- private void initDismissalActions(RecyclerView.ViewHolder holder, ContextualCard card,
- int initialViewId) {
- // initialView is the first view in the ViewFlipper.
- final View initialView = holder.itemView.findViewById(initialViewId);
- initialView.setOnLongClickListener(v -> {
- flipCardToDismissalView(holder);
- mFlippedCardSet.add(holder);
- return true;
- });
-
+ private void initDismissalActions(RecyclerView.ViewHolder holder, ContextualCard card) {
final Button btnKeep = holder.itemView.findViewById(R.id.keep);
btnKeep.setOnClickListener(v -> {
mFlippedCardSet.remove(holder);
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java
index d0d51e7..630839c 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java
@@ -68,7 +68,7 @@
final ContextualCardFeatureProvider contextualCardFeatureProvider =
FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
contextualCardFeatureProvider.logContextualCardClick(card, 0 /* row */,
- EventInfo.ACTION_TYPE_CONTENT);
+ EventInfo.ACTION_TYPE_CONTENT, view.getAdapterPosition());
});
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
index ef0a67d..1e1bde4 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -17,6 +17,7 @@
package com.android.settings.homepage.contextualcards.slices;
import android.content.Context;
+import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
@@ -36,13 +37,11 @@
/**
* Card renderer helper for {@link ContextualCard} built as slice full card.
*/
-class SliceFullCardRendererHelper implements SliceView.OnSliceActionListener {
+class SliceFullCardRendererHelper {
private static final String TAG = "SliceFCRendererHelper";
private final Context mContext;
- private Set<ContextualCard> mCardSet;
-
SliceFullCardRendererHelper(Context context) {
mContext = context;
}
@@ -51,17 +50,22 @@
return new SliceViewHolder(view);
}
- void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice,
- Set<ContextualCard> cardSet) {
+ void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
final SliceViewHolder cardHolder = (SliceViewHolder) holder;
cardHolder.sliceView.setScrollable(false);
cardHolder.sliceView.setTag(card.getSliceUri());
//TODO(b/114009676): We will soon have a field to decide what slice mode we should set.
cardHolder.sliceView.setMode(SliceView.MODE_LARGE);
cardHolder.sliceView.setSlice(slice);
- mCardSet = cardSet;
// Set this listener so we can log the interaction users make on the slice
- cardHolder.sliceView.setOnSliceActionListener(this);
+ cardHolder.sliceView.setOnSliceActionListener(
+ (eventInfo, sliceItem) -> {
+ final ContextualCardFeatureProvider contextualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(
+ mContext);
+ contextualCardFeatureProvider.logContextualCardClick(card, eventInfo.rowIndex,
+ eventInfo.actionType, cardHolder.getAdapterPosition());
+ });
// Customize slice view for Settings
cardHolder.sliceView.showTitleItems(true);
@@ -71,23 +75,6 @@
}
}
- @Override
- public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
- // sliceItem.getSlice().getUri() is like
- // content://android.settings.slices/action/wifi/_gen/0/_gen/0
- // contextualCard.getSliceUri() is prefix of sliceItem.getSlice().getUri()
- final ContextualCardFeatureProvider contextualCardFeatureProvider =
- FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
- for (ContextualCard card : mCardSet) {
- if (sliceItem.getSlice().getUri().toString().startsWith(
- card.getSliceUri().toString())) {
- contextualCardFeatureProvider.logContextualCardClick(card, eventInfo.rowIndex,
- eventInfo.actionType);
- break;
- }
- }
- }
-
static class SliceViewHolder extends RecyclerView.ViewHolder {
public final SliceView sliceView;
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
index 24d654d..6bb2208 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
@@ -66,7 +66,7 @@
final ContextualCardFeatureProvider contextualCardFeatureProvider =
FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
contextualCardFeatureProvider.logContextualCardClick(card, 0 /* row */,
- EventInfo.ACTION_TYPE_CONTENT);
+ EventInfo.ACTION_TYPE_CONTENT, view.getAdapterPosition());
});
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java b/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java
new file mode 100644
index 0000000..3564189
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2019 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.homepage.contextualcards.slices;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+import android.widget.ViewFlipper;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.ItemTouchHelper;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+
+public class SwipeDismissalDelegate extends ItemTouchHelper.Callback {
+
+ private static final String TAG = "SwipeDismissalDelegate";
+
+ public interface Listener {
+ void onSwiped(int position);
+ }
+
+ private final Context mContext;
+ private final SwipeDismissalDelegate.Listener mListener;
+ private final Drawable mIconDelete;
+ private final Paint mBgPaint;
+ private final int mBgCornerRadius;
+
+ public SwipeDismissalDelegate(Context context, SwipeDismissalDelegate.Listener listener) {
+ mContext = context;
+ mListener = listener;
+ mIconDelete = mContext.getDrawable(R.drawable.ic_delete);
+ mBgPaint = new Paint();
+ mBgPaint.setColor(mContext.getColor(R.color.homepage_card_dismissal_background));
+ mBgCornerRadius = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.homepage_card_corner_radius);
+ }
+
+ /**
+ * Determine whether the ability to drag or swipe should be enabled or not.
+ *
+ * Only allow swipe on {@link ContextualCard} built with view type
+ * {@link SliceContextualCardRenderer#VIEW_TYPE_FULL_WIDTH} or
+ * {@link SliceContextualCardRenderer#VIEW_TYPE_HALF_WIDTH}.
+ *
+ * When the dismissal view is displayed, the swipe will also be disabled.
+ */
+ @Override
+ public int getMovementFlags(@NonNull RecyclerView recyclerView,
+ @NonNull RecyclerView.ViewHolder viewHolder) {
+ switch (viewHolder.getItemViewType()) {
+ case SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH:
+ case SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH:
+ //TODO(b/129438972): Convert this to a regular view.
+ final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
+
+ // As we are using ViewFlipper to switch between the initial view and
+ // dismissal view, here we are making sure the current displayed view is the
+ // initial view of either slice full card or half card, and only allow swipe on
+ // these two types.
+ if (viewFlipper.getCurrentView().getId() != getInitialViewId(viewHolder)) {
+ // Disable swiping when we are in the dismissal view
+ return 0;
+ }
+ return makeMovementFlags(0 /*dragFlags*/,
+ ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/);
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public boolean onMove(@NonNull RecyclerView recyclerView,
+ @NonNull RecyclerView.ViewHolder viewHolder,
+ @NonNull RecyclerView.ViewHolder target) {
+ return false;
+ }
+
+ @Override
+ public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
+ mListener.onSwiped(viewHolder.getAdapterPosition());
+ }
+
+ @Override
+ public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView,
+ @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
+ boolean isCurrentlyActive) {
+ super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+
+ final View itemView = viewHolder.itemView;
+ final int iconMargin = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.homepage_card_dismissal_side_margin);
+ final int iconTop =
+ itemView.getTop() + (itemView.getHeight() - mIconDelete.getIntrinsicHeight()) / 2;
+ final int iconBottom = iconTop + mIconDelete.getIntrinsicHeight();
+
+ if (dX > 0) { //swipe to the right
+ final int iconLeft = itemView.getLeft() + iconMargin;
+ final int iconRight = iconLeft + mIconDelete.getIntrinsicWidth();
+ final RectF rect = new RectF(itemView.getLeft(), itemView.getTop(),
+ itemView.getLeft() + ((int) dX) + mBgCornerRadius, itemView.getBottom());
+ mIconDelete.setBounds(iconLeft, iconTop, iconRight, iconBottom);
+ c.drawRoundRect(rect, mBgCornerRadius, mBgCornerRadius, mBgPaint);
+ } else if (dX < 0) {
+ final int iconRight = itemView.getRight() - iconMargin;
+ final int iconLeft = iconRight - mIconDelete.getIntrinsicWidth();
+ final RectF rect = new RectF(itemView.getRight() + ((int) dX), itemView.getTop(),
+ itemView.getRight(), itemView.getBottom());
+ mIconDelete.setBounds(iconLeft, iconTop, iconRight, iconBottom);
+ c.drawRoundRect(rect, mBgCornerRadius, mBgCornerRadius, mBgPaint);
+ }
+ mIconDelete.draw(c);
+ }
+
+ private int getInitialViewId(RecyclerView.ViewHolder viewHolder) {
+ if (viewHolder.getItemViewType() == SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH) {
+ return R.id.content;
+ }
+ return R.id.slice_view;
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java b/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
index 4a409e1..9343493 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
@@ -174,7 +174,10 @@
mScreen.addPreference(createUserDictionaryPreference(null));
} else {
for (String locale : localeSet) {
- mScreen.addPreference(createUserDictionaryPreference(locale));
+ final Preference pref = createUserDictionaryPreference(locale);
+ if (mScreen.findPreference(pref.getKey()) == null) {
+ mScreen.addPreference(pref);
+ }
}
}
}
diff --git a/src/com/android/settings/media/MediaOutputIndicatorSlice.java b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
index eb0c81f..0023e3f 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorSlice.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
@@ -20,35 +20,51 @@
import android.annotation.ColorInt;
import android.app.PendingIntent;
+import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.util.Log;
-import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
import androidx.slice.builders.ListBuilder;
import androidx.slice.builders.SliceAction;
+import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SliceBackgroundWorker;
+import com.android.settingslib.bluetooth.A2dpProfile;
+import com.android.settingslib.bluetooth.HearingAidProfile;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import com.android.settingslib.media.MediaOutputSliceConstants;
+import java.util.ArrayList;
+import java.util.List;
+
public class MediaOutputIndicatorSlice implements CustomSliceable {
+ private static final String TAG = "MediaOutputIndicatorSlice";
+
private Context mContext;
- @VisibleForTesting
- MediaOutputIndicatorWorker mWorker;
+ private LocalBluetoothManager mLocalBluetoothManager;
+ private LocalBluetoothProfileManager mProfileManager;
public MediaOutputIndicatorSlice(Context context) {
mContext = context;
+ mLocalBluetoothManager = com.android.settings.bluetooth.Utils.getLocalBtManager(context);
+ if (mLocalBluetoothManager == null) {
+ Log.e(TAG, "Bluetooth is not supported on this device");
+ return;
+ }
+ mProfileManager = mLocalBluetoothManager.getProfileManager();
}
@Override
public Slice getSlice() {
- if (!getWorker().isVisible()) {
+ if (!isVisible()) {
return null;
}
final IconCompat icon = IconCompat.createWithResource(mContext,
@@ -66,18 +82,11 @@
.setAccentColor(color)
.addRow(new ListBuilder.RowBuilder()
.setTitle(title)
- .setSubtitle(getWorker().findActiveDeviceName())
+ .setSubtitle(findActiveDeviceName())
.setPrimaryAction(primarySliceAction));
return listBuilder.build();
}
- private MediaOutputIndicatorWorker getWorker() {
- if (mWorker == null) {
- mWorker = (MediaOutputIndicatorWorker) SliceBackgroundWorker.getInstance(getUri());
- }
- return mWorker;
- }
-
private Intent getMediaOutputSliceIntent() {
final Intent intent = new Intent()
.setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
@@ -101,4 +110,65 @@
public Class getBackgroundWorkerClass() {
return MediaOutputIndicatorWorker.class;
}
+
+ private boolean isVisible() {
+ // To decide Slice's visibility.
+ // return true if device is connected or previously connected, false for other cases.
+ return !CollectionUtils.isEmpty(getConnectableA2dpDevices())
+ || !CollectionUtils.isEmpty(getConnectableHearingAidDevices());
+ }
+
+ private List<BluetoothDevice> getConnectableA2dpDevices() {
+ // Get A2dp devices on all states
+ // (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING)
+ final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
+ if (a2dpProfile == null) {
+ return new ArrayList<>();
+ }
+ return a2dpProfile.getConnectableDevices();
+ }
+
+ private List<BluetoothDevice> getConnectableHearingAidDevices() {
+ // Get hearing aid profile devices on all states
+ // (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING)
+ final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
+ if (hapProfile == null) {
+ return new ArrayList<>();
+ }
+
+ return hapProfile.getConnectableDevices();
+ }
+
+ private CharSequence findActiveDeviceName() {
+ // Return Hearing Aid device name if it is active
+ BluetoothDevice activeDevice = findActiveHearingAidDevice();
+ if (activeDevice != null) {
+ return activeDevice.getAliasName();
+ }
+ // Return A2DP device name if it is active
+ final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
+ if (a2dpProfile != null) {
+ activeDevice = a2dpProfile.getActiveDevice();
+ if (activeDevice != null) {
+ return activeDevice.getAliasName();
+ }
+ }
+ // No active device, return default summary
+ return mContext.getText(R.string.media_output_default_summary);
+ }
+
+ private BluetoothDevice findActiveHearingAidDevice() {
+ final HearingAidProfile hearingAidProfile = mProfileManager.getHearingAidProfile();
+ if (hearingAidProfile == null) {
+ return null;
+ }
+
+ final List<BluetoothDevice> activeDevices = hearingAidProfile.getActiveDevices();
+ for (BluetoothDevice btDevice : activeDevices) {
+ if (btDevice != null) {
+ return btDevice;
+ }
+ }
+ return null;
+ }
}
diff --git a/src/com/android/settings/media/MediaOutputIndicatorWorker.java b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
index adee055..2d10fd3 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorWorker.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
@@ -16,26 +16,18 @@
package com.android.settings.media;
-import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.net.Uri;
import android.util.Log;
-import com.android.internal.util.CollectionUtils;
-import com.android.settings.R;
import com.android.settings.bluetooth.Utils;
import com.android.settings.slices.SliceBackgroundWorker;
-import com.android.settingslib.bluetooth.A2dpProfile;
import com.android.settingslib.bluetooth.BluetoothCallback;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
/**
* Listener for background change from {@code BluetoothCallback} to update media output indicator.
@@ -45,7 +37,6 @@
private static final String TAG = "MediaOutputIndicatorWorker";
private LocalBluetoothManager mLocalBluetoothManager;
- private LocalBluetoothProfileManager mProfileManager;
public MediaOutputIndicatorWorker(Context context, Uri uri) {
super(context, uri);
@@ -53,12 +44,11 @@
@Override
protected void onSlicePinned() {
- LocalBluetoothManager mLocalBluetoothManager = Utils.getLocalBtManager(getContext());
+ mLocalBluetoothManager = Utils.getLocalBtManager(getContext());
if (mLocalBluetoothManager == null) {
Log.e(TAG, "Bluetooth is not supported on this device");
return;
}
- mProfileManager = mLocalBluetoothManager.getProfileManager();
mLocalBluetoothManager.getEventManager().registerCallback(this);
}
@@ -74,7 +64,6 @@
@Override
public void close() throws IOException {
mLocalBluetoothManager = null;
- mProfileManager = null;
}
@Override
@@ -89,73 +78,4 @@
notifySliceChange();
}
}
-
- /**
- * To decide Slice's visibility.
- *
- * @return true if device is connected or previously connected, false for other cases.
- */
- public boolean isVisible() {
- return !CollectionUtils.isEmpty(getConnectableA2dpDevices())
- || !CollectionUtils.isEmpty(getConnectableHearingAidDevices());
- }
-
- private List<BluetoothDevice> getConnectableA2dpDevices() {
- // get A2dp devices on all states
- // (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING)
- final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
- if (a2dpProfile == null) {
- return new ArrayList<>();
- }
- return a2dpProfile.getConnectableDevices();
- }
-
- private List<BluetoothDevice> getConnectableHearingAidDevices() {
- // get hearing aid profile devices on all states
- // (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING)
- final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
- if (hapProfile == null) {
- return new ArrayList<>();
- }
-
- return hapProfile.getConnectableDevices();
- }
-
- /**
- * Get active devices name.
- *
- * @return active Bluetooth device alias, or default summary if no active device.
- */
- public CharSequence findActiveDeviceName() {
- // Return Hearing Aid device name if it is active
- BluetoothDevice activeDevice = findActiveHearingAidDevice();
- if (activeDevice != null) {
- return activeDevice.getAliasName();
- }
- // Return A2DP device name if it is active
- final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
- if (a2dpProfile != null) {
- activeDevice = a2dpProfile.getActiveDevice();
- if (activeDevice != null) {
- return activeDevice.getAliasName();
- }
- }
- // No active device, return default summary
- return getContext().getText(R.string.media_output_default_summary);
- }
-
- private BluetoothDevice findActiveHearingAidDevice() {
- final HearingAidProfile hearingAidProfile = mProfileManager.getHearingAidProfile();
- if (hearingAidProfile == null) {
- return null;
- }
-
- final List<BluetoothDevice> activeDevices = hearingAidProfile.getActiveDevices();
- for (BluetoothDevice btDevice : activeDevices) {
- if (btDevice != null) {
- return btDevice;
- }
- }
- return null;
- }
}
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
index c510294..161c218 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.content.Context;
+import android.content.res.Resources;
import android.os.Looper;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
@@ -52,12 +53,18 @@
ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
private final List<On4gLteUpdateListener> m4gLteListeners;
+ private final CharSequence[] mVariantTitles;
+ private final CharSequence[] mVariantSumaries;
public Enhanced4gLtePreferenceController(Context context, String key) {
super(context, key);
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
m4gLteListeners = new ArrayList<>();
mPhoneStateListener = new PhoneCallStateListener(Looper.getMainLooper());
+ mVariantTitles = context.getResources()
+ .getTextArray(R.array.enhanced_4g_lte_mode_title_variant);
+ mVariantSumaries = context.getResources()
+ .getTextArray(R.array.enhanced_4g_lte_mode_sumary_variant);
}
@Override
@@ -94,12 +101,20 @@
public void updateState(Preference preference) {
super.updateState(preference);
final SwitchPreference switchPreference = (SwitchPreference) preference;
- final boolean useVariant4glteTitle = mCarrierConfig.getInt(
- CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT) != 0;
- int enhanced4glteModeTitleId = useVariant4glteTitle ?
- R.string.enhanced_4g_lte_mode_title_variant :
- R.string.enhanced_4g_lte_mode_title;
- switchPreference.setTitle(enhanced4glteModeTitleId);
+ final int variant4glteTitleIndex = mCarrierConfig.getInt(
+ CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT);
+
+ // Default index 0 indicates the default title/sumary string
+ CharSequence enhanced4glteModeTitle = mVariantTitles[0];
+ CharSequence enhanced4glteModeSummary = mVariantSumaries[0];
+ if (variant4glteTitleIndex >= 0 && variant4glteTitleIndex < mVariantTitles.length) {
+ enhanced4glteModeTitle = mVariantTitles[variant4glteTitleIndex];
+ }
+ if (variant4glteTitleIndex >= 0 && variant4glteTitleIndex < mVariantSumaries.length) {
+ enhanced4glteModeSummary = mVariantSumaries[variant4glteTitleIndex];
+ }
+ switchPreference.setTitle(enhanced4glteModeTitle);
+ switchPreference.setSummary(enhanced4glteModeSummary);
switchPreference.setEnabled(is4gLtePrefEnabled());
switchPreference.setChecked(mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
&& mImsManager.isNonTtyOrTtyOnVolteEnabled());
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index dfa1271..96521ea 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -21,8 +21,10 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Looper;
+import android.os.PersistableBundle;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
+import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -50,17 +52,24 @@
private TelephonyManager mTelephonyManager;
@VisibleForTesting
+ CarrierConfigManager mCarrierConfigManager;
+ @VisibleForTesting
ImsManager mImsManager;
@VisibleForTesting
PhoneAccountHandle mSimCallManager;
private PhoneCallStateListener mPhoneStateListener;
private Preference mPreference;
+ private boolean mEditableWfcRoamingMode;
+ private boolean mUseWfcHomeModeForRoaming;
public WifiCallingPreferenceController(Context context, String key) {
super(context, key);
+ mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
mTelephonyManager = context.getSystemService(TelephonyManager.class);
mSimCallManager = context.getSystemService(TelecomManager.class).getSimCallManager();
mPhoneStateListener = new PhoneCallStateListener(Looper.getMainLooper());
+ mEditableWfcRoamingMode = true;
+ mUseWfcHomeModeForRoaming = false;
}
@Override
@@ -109,9 +118,9 @@
} else {
int resId = com.android.internal.R.string.wifi_calling_off_summary;
if (mImsManager.isWfcEnabledByUser()) {
+ boolean wfcRoamingEnabled = mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming;
final boolean isRoaming = mTelephonyManager.isNetworkRoaming();
- int wfcMode = mImsManager.getWfcMode(isRoaming);
-
+ int wfcMode = mImsManager.getWfcMode(isRoaming && wfcRoamingEnabled);
switch (wfcMode) {
case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
@@ -137,6 +146,16 @@
mSubId = subId;
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
+ if (mCarrierConfigManager != null) {
+ final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
+ if (carrierConfig != null) {
+ mEditableWfcRoamingMode = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL);
+ mUseWfcHomeModeForRoaming = carrierConfig.getBoolean(
+ CarrierConfigManager
+ .KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL);
+ }
+ }
}
private class PhoneCallStateListener extends PhoneStateListener {
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index e53a560..73cbad3 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -16,10 +16,14 @@
package com.android.settings.notification;
+import static android.media.AudioAttributes.USAGE_ALARM;
+import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
+
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
+import android.media.RingtoneManager;
import android.net.Uri;
import android.preference.PreferenceManager;
@@ -91,6 +95,16 @@
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY_SOUND.equals(preference.getKey()) && mFragment != null) {
NotificationSoundPreference pref = (NotificationSoundPreference) preference;
+ if (mChannel != null && mChannel.getAudioAttributes() != null) {
+ if (USAGE_ALARM == mChannel.getAudioAttributes().getUsage()) {
+ pref.setRingtoneType(RingtoneManager.TYPE_ALARM);
+ } else if (USAGE_NOTIFICATION_RINGTONE
+ == mChannel.getAudioAttributes().getUsage()) {
+ pref.setRingtoneType(RingtoneManager.TYPE_RINGTONE);
+ } else {
+ pref.setRingtoneType(RingtoneManager.TYPE_NOTIFICATION);
+ }
+ }
pref.onPrepareRingtonePickerIntent(pref.getIntent());
mFragment.startActivityForResult(preference.getIntent(), CODE);
return true;
diff --git a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
index cbf909f..b043cb1 100644
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
@@ -39,6 +39,8 @@
public class VibrateWhenRingPreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnResume, OnPause {
+ /** Flag for whether or not to apply ramping ringer on incoming phone calls. */
+ private static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
private final int DEFAULT_VALUE = 0;
private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
@@ -130,8 +132,8 @@
}
private boolean isRampingRingerEnabled() {
- return DeviceConfig.getBoolean(DeviceConfig.Telephony.NAMESPACE,
- DeviceConfig.Telephony.RAMPING_RINGER_ENABLED, false);
+ return DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
}
}
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index d89ad30..e0974fe 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -479,7 +479,7 @@
R.layout.choose_lock_pattern, container, false);
layout.setHeaderText(getActivity().getTitle());
if (getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
- View iconView = layout.findViewById(R.id.suc_layout_icon);
+ View iconView = layout.findViewById(R.id.sud_layout_icon);
if (iconView != null) {
iconView.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
index 7c55b51..9358392 100644
--- a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
+++ b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
@@ -16,6 +16,10 @@
package com.android.settings.privacy;
+import static android.Manifest.permission_group.CAMERA;
+import static android.Manifest.permission_group.LOCATION;
+import static android.Manifest.permission_group.MICROPHONE;
+
import static com.android.settingslib.widget.BarChartPreference.MAXIMUM_BAR_VIEWS;
import static java.util.concurrent.TimeUnit.DAYS;
@@ -131,8 +135,28 @@
@Override
public void onPermissionUsageResult(@NonNull List<RuntimePermissionUsageInfo> usageInfos) {
- usageInfos.sort(Comparator.comparingInt(
- RuntimePermissionUsageInfo::getAppAccessCount).reversed());
+ usageInfos.sort((x, y) -> {
+ int usageDiff = y.getAppAccessCount() - x.getAppAccessCount();
+ if (usageDiff != 0) {
+ return usageDiff;
+ }
+ String xName = x.getName();
+ String yName = y.getName();
+ if (xName.equals(LOCATION)) {
+ return -1;
+ } else if (yName.equals(LOCATION)) {
+ return 1;
+ } else if (xName.equals(MICROPHONE)) {
+ return -1;
+ } else if (yName.equals(MICROPHONE)) {
+ return 1;
+ } else if (xName.equals(CAMERA)) {
+ return -1;
+ } else if (yName.equals(CAMERA)) {
+ return 1;
+ }
+ return x.getName().compareTo(y.getName());
+ });
// If the result is different, we need to update bar views.
if (!areSamePermissionGroups(usageInfos)) {
@@ -163,18 +187,20 @@
for (int index = 0; index < barViewInfos.length; index++) {
final RuntimePermissionUsageInfo permissionGroupInfo = usageInfos.get(index);
+ final int count = permissionGroupInfo.getAppAccessCount();
+ final CharSequence permLabel = getPermissionGroupLabel(permissionGroupInfo.getName());
barViewInfos[index] = new BarViewInfo(
- getPermissionGroupIcon(permissionGroupInfo.getName()),
- permissionGroupInfo.getAppAccessCount(),
- R.string.storage_detail_apps,
- getPermissionGroupLabel(permissionGroupInfo.getName()));
+ getPermissionGroupIcon(permissionGroupInfo.getName()), count, permLabel,
+ mContext.getResources().getQuantityString(R.plurals.permission_bar_chart_label,
+ count, count), permLabel);
// Set the click listener for each bar view.
// The listener will navigate user to permission usage app.
barViewInfos[index].setClickListener((View v) -> {
final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE);
intent.putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, permissionGroupInfo.getName());
+ intent.putExtra(Intent.EXTRA_DURATION_MILLIS, DAYS.toMillis(1));
mContext.startActivity(intent);
});
}
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index 13148c8..487dace 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -254,7 +254,7 @@
builder.setTitle(R.string.select_sim_for_calls);
break;
case SMS_PICK:
- builder.setTitle(R.string.sim_card_select_title);
+ builder.setTitle(R.string.select_sim_for_sms);
break;
default:
throw new IllegalArgumentException("Invalid dialog type "
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 891d171..4f3b9bc 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -16,11 +16,11 @@
package com.android.settings.sim;
-import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_ID;
-import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE;
+import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE;
+import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@@ -52,8 +52,8 @@
int dialogType = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE);
- if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES) {
- int subId = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_ID,
+ if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL) {
+ int subId = intent.getIntExtra(EXTRA_SUBSCRIPTION_ID,
SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
int slotIndex = SubscriptionManager.getSlotIndex(subId);
// If there is only one subscription, ask if user wants to use if for everything
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 14564b1..0713872 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -28,10 +28,18 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.search.SearchIndexable;
import com.google.android.setupcompat.util.WizardManagerHelper;
-public class WallpaperSuggestionActivity extends Activity {
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class WallpaperSuggestionActivity extends Activity implements Indexable {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -79,4 +87,30 @@
return context.getResources().getBoolean(
com.android.internal.R.bool.config_enableWallpaperService);
}
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ private static final String SUPPORT_SEARCH_INDEX_KEY = "wallpaper_type";
+
+ @Override
+ public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+ boolean enabled) {
+
+ final List<SearchIndexableRaw> result = new ArrayList<>();
+
+ SearchIndexableRaw data = new SearchIndexableRaw(context);
+ data.title = context.getString(R.string.wallpaper_settings_fragment_title);
+ data.screenTitle = context.getString(
+ R.string.wallpaper_settings_fragment_title);
+ data.intentTargetPackage = context.getString(
+ R.string.config_wallpaper_picker_package);
+ data.intentTargetClass = context.getString(
+ R.string.config_wallpaper_picker_class);
+ data.intentAction = Intent.ACTION_MAIN;
+ data.key = SUPPORT_SEARCH_INDEX_KEY;
+ result.add(data);
+
+ return result;
+ }
+ };
}
diff --git a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
index 0e0f8df..2d4a16f 100644
--- a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
+++ b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
@@ -17,21 +17,11 @@
package com.android.settings.wallpaper;
import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.SearchIndexableRaw;
-import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
-import java.util.List;
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class WallpaperTypeSettings extends DashboardFragment {
private static final String TAG = "WallpaperTypeSettings";
@@ -54,42 +44,4 @@
protected int getPreferenceScreenResId() {
return R.xml.wallpaper_settings;
}
-
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<>();
-
- final Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
- final PackageManager pm = context.getPackageManager();
- final List<ResolveInfo> rList = pm.queryIntentActivities(intent,
- PackageManager.MATCH_DEFAULT_ONLY);
-
- // Add indexable data for package that is in config_wallpaper_picker_package
- final String wallpaperPickerPackage =
- context.getString(R.string.config_wallpaper_picker_package);
- for (ResolveInfo info : rList) {
- if (!wallpaperPickerPackage.equals(info.activityInfo.packageName)) {
- continue;
- }
- CharSequence label = info.loadLabel(pm);
- if (label == null) {
- label = info.activityInfo.packageName;
- }
- final SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = label.toString();
- data.key = "wallpaper_type_settings";
- data.screenTitle = context.getResources().getString(
- R.string.wallpaper_settings_fragment_title);
- data.intentAction = Intent.ACTION_SET_WALLPAPER;
- data.intentTargetPackage = info.activityInfo.packageName;
- data.intentTargetClass = info.activityInfo.name;
- data.keywords = context.getString(R.string.keywords_wallpaper);
- result.add(data);
- }
-
- return result;
- }
- };
}
diff --git a/src/com/android/settings/widget/RadioButtonPickerFragment.java b/src/com/android/settings/widget/RadioButtonPickerFragment.java
index 591cd21..8861c94 100644
--- a/src/com/android/settings/widget/RadioButtonPickerFragment.java
+++ b/src/com/android/settings/widget/RadioButtonPickerFragment.java
@@ -58,6 +58,9 @@
protected UserManager mUserManager;
protected int mUserId;
+ private int mIllustrationId;
+ private int mIllustrationPreviewId;
+ private VideoPreference mVideoPreference;
@Override
public void onAttach(Context context) {
@@ -164,6 +167,9 @@
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
+ if (mIllustrationId != 0) {
+ addIllustration(screen);
+ }
if (!mAppendStaticPreferences) {
addStaticPreferences(screen);
}
@@ -241,6 +247,23 @@
}
}
+ /**
+ * Allows you to set an illustration at the top of this screen. Set the illustration id to 0
+ * if you want to remove the illustration.
+ * @param illustrationId The res id for the raw of the illustration.
+ * @param previewId The res id for the drawable of the illustration
+ */
+ protected void setIllustration(int illustrationId, int previewId) {
+ mIllustrationId = illustrationId;
+ mIllustrationPreviewId = previewId;
+ }
+
+ private void addIllustration(PreferenceScreen screen) {
+ mVideoPreference = new VideoPreference(getContext());
+ mVideoPreference.setVideo(mIllustrationId, mIllustrationPreviewId);
+ screen.addPreference(mVideoPreference);
+ }
+
protected abstract List<? extends CandidateInfo> getCandidates();
protected abstract String getDefaultKey();
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index fd215d8..2d88673 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -55,22 +55,41 @@
private int mPreviewResource;
private boolean mViewVisible;
private Surface mSurface;
+ private int mAnimationId;
+
+ public VideoPreference(Context context) {
+ super(context);
+ mContext = context;
+ initialize(context, null);
+ }
public VideoPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
+ initialize(context, attrs);
+ }
+
+ private void initialize(Context context, AttributeSet attrs) {
TypedArray attributes = context.getTheme().obtainStyledAttributes(
attrs,
- com.android.settings.R.styleable.VideoPreference,
+ R.styleable.VideoPreference,
0, 0);
try {
- int animation = attributes.getResourceId(R.styleable.VideoPreference_animation, 0);
+ // if these are already set that means they were set dynamically and don't need
+ // to be loaded from xml
+ mAnimationId = mAnimationId == 0
+ ? attributes.getResourceId(R.styleable.VideoPreference_animation, 0)
+ : mAnimationId;
mVideoPath = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(context.getPackageName())
- .appendPath(String.valueOf(animation))
+ .appendPath(String.valueOf(mAnimationId))
.build();
- mPreviewResource = attributes.getResourceId(
- R.styleable.VideoPreference_preview, 0);
+ mPreviewResource = mPreviewResource == 0
+ ? attributes.getResourceId(R.styleable.VideoPreference_preview, 0)
+ : mPreviewResource;
+ if (mPreviewResource == 0 && mAnimationId == 0) {
+ return;
+ }
initMediaPlayer();
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
setVisible(true);
@@ -103,20 +122,9 @@
imageView.setImageResource(mPreviewResource);
layout.setAspectRatio(mAspectRadio);
+ updateViewStates(imageView, playButton);
- video.setOnClickListener(v -> {
- if (mMediaPlayer != null) {
- if (mMediaPlayer.isPlaying()) {
- mMediaPlayer.pause();
- playButton.setVisibility(View.VISIBLE);
- mVideoPaused = true;
- } else {
- mMediaPlayer.start();
- playButton.setVisibility(View.GONE);
- mVideoPaused = false;
- }
- }
- });
+ video.setOnClickListener(v -> updateViewStates(imageView, playButton));
video.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
@@ -161,6 +169,23 @@
});
}
+ @VisibleForTesting
+ void updateViewStates(ImageView imageView, ImageView playButton) {
+ if (mMediaPlayer != null) {
+ if (mMediaPlayer.isPlaying()) {
+ mMediaPlayer.pause();
+ playButton.setVisibility(View.VISIBLE);
+ imageView.setVisibility(View.VISIBLE);
+ mVideoPaused = true;
+ } else {
+ imageView.setVisibility(View.GONE);
+ playButton.setVisibility(View.GONE);
+ mMediaPlayer.start();
+ mVideoPaused = false;
+ }
+ }
+ }
+
@Override
public void onDetached() {
releaseMediaPlayer();
@@ -178,6 +203,20 @@
releaseMediaPlayer();
}
+ /**
+ * Sets the video for this preference. If a previous video was set this one will override it
+ * and properly release any resources and re-initialize the preference to play the new video.
+ *
+ * @param videoId The raw res id of the video
+ * @param previewId The drawable res id of the preview image to use if the video fails to load.
+ */
+ public void setVideo(int videoId, int previewId) {
+ mAnimationId = videoId;
+ mPreviewResource = previewId;
+ releaseMediaPlayer();
+ initialize(mContext, null);
+ }
+
private void initMediaPlayer() {
if (mMediaPlayer == null) {
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 0adbd8d..0887fc5 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -637,7 +637,7 @@
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
.BIP_GMAC_256);
- config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
+ // allowedSuiteBCiphers will be set according to certificate type
}
config.enterpriseConfig = new WifiEnterpriseConfig();
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 585cf71..9167210 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -41,6 +41,7 @@
import android.os.Looper;
import android.os.PowerManager;
import android.provider.Settings;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -57,6 +58,7 @@
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.SettingsActivity;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.location.ScanningSettings;
@@ -960,8 +962,10 @@
private void launchNetworkDetailsFragment(ConnectedAccessPointPreference pref) {
final AccessPoint accessPoint = pref.getAccessPoint();
final Context context = getContext();
- final CharSequence title = SavedAccessPointsWifiSettings.usingDetailsFragment(context) ?
- accessPoint.getTitle() : context.getText(R.string.pref_title_network_details);
+ final CharSequence title =
+ FeatureFlagUtils.isEnabled(context, FeatureFlags.WIFI_DETAILS_DATAUSAGE_HEADER)
+ ? accessPoint.getTitle()
+ : context.getText(R.string.pref_title_network_details);
new SubSettingLauncher(getContext())
.setTitleText(title)
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index a22bdba..9b3c1b3 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -198,7 +198,7 @@
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
.BIP_GMAC_256);
- config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
+ // allowedSuiteBCiphers will be set according to certificate type
}
if (!TextUtils.isEmpty(password)) {
diff --git a/src/com/android/settings/wifi/details/AddDevicePreferenceController.java b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
new file mode 100644
index 0000000..61804a2
--- /dev/null
+++ b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2019 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.details;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.wifi.dpp.WifiDppUtils;
+
+import com.android.settingslib.wifi.AccessPoint;
+
+/**
+ * {@link AbstractPreferenceController} that launches Wi-Fi Easy Connect configurator flow
+ */
+public class AddDevicePreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "AddDevicePreferenceController";
+
+ private static final String KEY_ADD_DEVICE_CATEGORY = "add_device_category";
+ private static final String KEY_ADD_DEVICE = "add_device_to_network";
+
+ private AccessPoint mAccessPoint;
+ private WifiManager mWifiManager;
+
+ public AddDevicePreferenceController(Context context) {
+ super(context, KEY_ADD_DEVICE_CATEGORY);
+
+ mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ }
+
+ public AddDevicePreferenceController init(AccessPoint accessPoint) {
+ mAccessPoint = accessPoint;
+
+ return this;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mAccessPoint)) {
+ return AVAILABLE;
+ } else {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY_ADD_DEVICE.equals(preference.getKey())) {
+ WifiDppUtils.showLockScreen(mContext, () -> launchWifiDppConfiguratorQrCodeScanner());
+ return true; /* click is handled */
+ }
+
+ return false; /* click is not handled */
+ }
+
+ private void launchWifiDppConfiguratorQrCodeScanner() {
+ final Intent intent = WifiDppUtils.getConfiguratorQrCodeScannerIntentOrNull(mContext,
+ mWifiManager, mAccessPoint);
+
+ if (intent == null) {
+ Log.e(TAG, "Launch Wi-Fi QR code scanner with a wrong Wi-Fi network!");
+ } else {
+ mContext.startActivity(intent);
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index cf59dbd..f880a19 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -41,6 +41,7 @@
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
+import android.os.CountDownTimer;
import android.os.Handler;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
@@ -84,6 +85,7 @@
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.time.Duration;
import java.util.StringJoiner;
import java.util.stream.Collectors;
@@ -113,6 +115,8 @@
@VisibleForTesting
static final String KEY_SECURITY_PREF = "security";
@VisibleForTesting
+ static final String KEY_SSID_PREF = "ssid";
+ @VisibleForTesting
static final String KEY_MAC_ADDRESS_PREF = "mac_address";
@VisibleForTesting
static final String KEY_IP_ADDRESS_PREF = "ip_address";
@@ -127,6 +131,19 @@
@VisibleForTesting
static final String KEY_IPV6_ADDRESSES_PREF = "ipv6_addresses";
+ private static final int STATE_NONE = 1;
+ private static final int STATE_ENABLE_WIFI = 2;
+ private static final int STATE_ENABLE_WIFI_FAILED = 3;
+ private static final int STATE_CONNECTING = 4;
+ private static final int STATE_CONNECTED = 5;
+ private static final int STATE_FAILED = 6;
+ private static final int STATE_NOT_IN_RANGE = 7;
+ private static final int STATE_DISCONNECTED = 8;
+ private static final long TIMEOUT = Duration.ofSeconds(10).toMillis();
+
+ // Be static to avoid too much object not be reset.
+ private static CountDownTimer mTimer;
+
private AccessPoint mAccessPoint;
private final ConnectivityManager mConnectivityManager;
private final Fragment mFragment;
@@ -143,6 +160,9 @@
private final WifiTracker mWifiTracker;
private final MetricsFeatureProvider mMetricsFeatureProvider;
private boolean mIsOutOfRange;
+ private boolean mConnected;
+ private int mConnectingState;
+ private WifiManager.ActionListener mConnectListener;
// UI elements - in order of appearance
private ActionButtonsPreference mButtonsPref;
@@ -152,6 +172,7 @@
private Preference mRxLinkSpeedPref;
private Preference mFrequencyPref;
private Preference mSecurityPref;
+ private Preference mSsidPref;
private Preference mMacAddressPref;
private Preference mIpAddressPref;
private Preference mGatewayPref;
@@ -182,7 +203,7 @@
// fall through
case WifiManager.NETWORK_STATE_CHANGED_ACTION:
case WifiManager.RSSI_CHANGED_ACTION:
- updateNetworkInfo();
+ refreshPage();
break;
}
}
@@ -197,7 +218,7 @@
public void onLinkPropertiesChanged(Network network, LinkProperties lp) {
if (network.equals(mNetwork) && !lp.equals(mLinkProperties)) {
mLinkProperties = lp;
- updateIpLayerInfo();
+ refreshIpLayerInfo();
}
}
@@ -224,12 +245,17 @@
}
mNetworkCapabilities = nc;
refreshButtons();
- updateIpLayerInfo();
+ refreshIpLayerInfo();
}
}
@Override
public void onLost(Network network) {
+ // If support detail page for saved network, should update as disconnect but not exit.
+ if (SavedAccessPointsWifiSettings.usingDetailsFragment(mContext)) {
+ return;
+ }
+
if (network.equals(mNetwork)) {
exitActivity();
}
@@ -240,13 +266,23 @@
/** Called when the state of Wifi has changed. */
public void onWifiStateChanged(int state) {
Log.d(TAG, "onWifiStateChanged(" + state + ")");
- // Do nothing.
+ if (mConnectingState == STATE_ENABLE_WIFI && state == WifiManager.WIFI_STATE_ENABLED) {
+ updateConnectingState(STATE_CONNECTING);
+ }
}
/** Called when the connection state of wifi has changed. */
public void onConnectedChanged() {
- Log.d(TAG, "onConnectedChanged");
- // Do nothing.
+ updateAccessPointFromScannedList();
+ if (mConnected != mAccessPoint.isActive()) {
+ Log.d(TAG, "Connection state changed!");
+ mConnected = mAccessPoint.isActive();
+ if (mAccessPoint.isActive()) {
+ updateConnectingState(STATE_CONNECTED);
+ } else {
+ updateConnectingState(STATE_DISCONNECTED);
+ }
+ }
}
/**
@@ -254,8 +290,7 @@
* {@link WifiTracker#getAccessPoints()} should be called to get the updated list.
*/
public void onAccessPointsChanged() {
- Log.d(TAG, "onAccessPointsChanged");
- updateNetworkInfo();
+ refreshPage();
}
};
@@ -314,6 +349,19 @@
} else {
mWifiTracker = null;
}
+ mConnected = mAccessPoint.isActive();
+ mConnectingState = STATE_NONE;
+ mConnectListener = new WifiManager.ActionListener() {
+ @Override
+ public void onSuccess() {
+ // Do nothing
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ updateConnectingState(STATE_FAILED);
+ }
+ };
}
@Override
@@ -339,10 +387,14 @@
.setButton1OnClickListener(view -> forgetNetwork())
.setButton2Text(R.string.wifi_sign_in_button_text)
.setButton2OnClickListener(view -> signIntoNetwork())
- .setButton3Text(R.string.share)
- .setButton3Icon(R.drawable.ic_qrcode_24dp)
- .setButton3OnClickListener(view -> shareNetwork())
- .setButton3Visible(WifiDppUtils.isSuportConfigurator(mContext, mAccessPoint));
+ .setButton3Text(R.string.wifi_connect)
+ .setButton3Icon(R.drawable.ic_settings_wireless)
+ .setButton3OnClickListener(view -> connectNetwork())
+ .setButton3Enabled(true)
+ .setButton4Text(R.string.share)
+ .setButton4Icon(R.drawable.ic_qrcode_24dp)
+ .setButton4OnClickListener(view -> shareNetwork())
+ .setButton4Visible(WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mAccessPoint));
mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
@@ -350,6 +402,7 @@
mFrequencyPref = screen.findPreference(KEY_FREQUENCY_PREF);
mSecurityPref = screen.findPreference(KEY_SECURITY_PREF);
+ mSsidPref = screen.findPreference(KEY_SSID_PREF);
mMacAddressPref = screen.findPreference(KEY_MAC_ADDRESS_PREF);
mIpAddressPref = screen.findPreference(KEY_IP_ADDRESS_PREF);
mGatewayPref = screen.findPreference(KEY_GATEWAY_PREF);
@@ -397,14 +450,18 @@
}
}
+ private void updateNetworkInfo() {
+ mNetwork = mWifiManager.getCurrentNetwork();
+ mLinkProperties = mConnectivityManager.getLinkProperties(mNetwork);
+ mNetworkCapabilities = mConnectivityManager.getNetworkCapabilities(mNetwork);
+ }
+
@Override
public void onResume() {
// Ensure mNetwork is set before any callbacks above are delivered, since our
// NetworkCallback only looks at changes to mNetwork.
- mNetwork = mWifiManager.getCurrentNetwork();
- mLinkProperties = mConnectivityManager.getLinkProperties(mNetwork);
- mNetworkCapabilities = mConnectivityManager.getNetworkCapabilities(mNetwork);
updateNetworkInfo();
+ refreshPage();
mContext.registerReceiver(mReceiver, mFilter);
mConnectivityManager.registerNetworkCallback(mNetworkRequest, mNetworkCallback,
mHandler);
@@ -421,11 +478,13 @@
mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
}
- private void updateNetworkInfo() {
+ private void refreshPage() {
if(!updateAccessPoint()) {
return;
}
+ Log.d(TAG, "Update UI!");
+
// refresh header
refreshEntityHeader();
@@ -441,26 +500,39 @@
// Receive Link Speed Pref
refreshRxSpeed();
// IP related information
- updateIpLayerInfo();
+ refreshIpLayerInfo();
+ // SSID Pref
+ refreshSsid();
// MAC Address Pref
refreshMacAddress();
-
}
private boolean updateAccessPoint() {
boolean changed = false;
if (mWifiTracker != null) {
+ // remember mIsOutOfRange as old before updated
+ boolean oldState = mIsOutOfRange;
updateAccessPointFromScannedList();
// refresh UI if signal level changed for disconnect network.
changed = mRssiSignalLevel != mAccessPoint.getLevel();
+ changed |= oldState != mIsOutOfRange;
}
if (mAccessPoint.isActive()) {
- // No need to fetch LinkProperties and NetworkCapabilities, they are updated by the
- // callbacks. mNetwork doesn't change except in onResume.
+ // Sometimes {@link WifiManager#getCurrentNetwork()} return null after connected,
+ // refresh it if needed.
+ if (mNetwork == null) {
+ updateNetworkInfo();
+ }
mNetworkInfo = mConnectivityManager.getNetworkInfo(mNetwork);
mWifiInfo = mWifiManager.getConnectionInfo();
if (mNetwork == null || mNetworkInfo == null || mWifiInfo == null) {
+ // Once connected, can't get mNetworkInfo immediately, return false and wait for
+ // next time to update UI.
+ if (SavedAccessPointsWifiSettings.usingDetailsFragment(mContext)) {
+ return false;
+ }
+
exitActivity();
return false;
}
@@ -474,6 +546,8 @@
}
private void updateAccessPointFromScannedList() {
+ if (mWifiTracker == null) return;
+
mIsOutOfRange = true;
if (mAccessPoint.getConfig() == null) {
@@ -484,7 +558,7 @@
if (ap.getConfig() != null
&& mAccessPoint.matches(ap.getConfig())) {
mAccessPoint = ap;
- mIsOutOfRange = false;
+ mIsOutOfRange = !mAccessPoint.isReachable();
return;
}
}
@@ -543,6 +617,11 @@
band = mContext.getResources().getString(R.string.wifi_band_5ghz);
} else {
Log.e(TAG, "Unexpected frequency " + frequency);
+ // Connecting state is unstable, make it disappeared if unexpected
+ if (mConnectingState == STATE_CONNECTING) {
+ mFrequencyPref.setVisible(false);
+ }
+ return;
}
mFrequencyPref.setSummary(band);
mFrequencyPref.setVisible(true);
@@ -572,6 +651,15 @@
R.string.rx_link_speed, mWifiInfo.getRxLinkSpeedMbps()));
}
+ private void refreshSsid() {
+ if (mAccessPoint.isPasspoint() || mAccessPoint.isOsuProvider()) {
+ mSsidPref.setVisible(true);
+ mSsidPref.setSummary(mAccessPoint.getSsidStr());
+ } else {
+ mSsidPref.setVisible(false);
+ }
+ }
+
private void refreshMacAddress() {
String macAddress = getMacAddress();
if (macAddress == null) {
@@ -590,7 +678,8 @@
}
// return randomized MAC address
- if (mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
+ if (mWifiConfig != null &&
+ mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
return mWifiConfig.getRandomizedMacAddress().toString();
}
@@ -616,12 +705,21 @@
private void refreshButtons() {
mButtonsPref.setButton1Visible(canForgetNetwork());
mButtonsPref.setButton2Visible(canSignIntoNetwork());
- mButtonsPref.setButton3Visible(canShareNetwork());
- mButtonsPref.setVisible(
- canSignIntoNetwork() || canForgetNetwork() || canShareNetwork());
+ mButtonsPref.setButton3Visible(canConnectNetwork());
+ mButtonsPref.setButton4Visible(canShareNetwork());
+ mButtonsPref.setVisible(canSignIntoNetwork()
+ || canForgetNetwork()
+ || canShareNetwork()
+ || canConnectNetwork());
}
- private void updateIpLayerInfo() {
+ private boolean canConnectNetwork() {
+ // Display connect button for disconnected AP even not in the range.
+ return SavedAccessPointsWifiSettings.usingDetailsFragment(mContext)
+ && !mAccessPoint.isActive();
+ }
+
+ private void refreshIpLayerInfo() {
// Hide IP layer info if not a connected network.
if (!mAccessPoint.isActive() || mNetwork == null || mLinkProperties == null) {
mIpAddressPref.setVisible(false);
@@ -757,11 +855,11 @@
* Show QR code to share the network represented by this preference.
*/
public void launchWifiDppConfiguratorActivity() {
- final Intent intent = WifiDppUtils.getConfiguratorIntentOrNull(mContext, mWifiManager,
- mAccessPoint);
+ final Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntentOrNull(mContext,
+ mWifiManager, mAccessPoint);
if (intent == null) {
- Log.e(TAG, "Launch Wi-Fi DPP configurator with a wrong Wi-Fi network!");
+ Log.e(TAG, "Launch Wi-Fi DPP QR code generator with a wrong Wi-Fi network!");
} else {
mContext.startActivity(intent);
}
@@ -823,4 +921,169 @@
private boolean usingDataUsageHeader(Context context) {
return FeatureFlagUtils.isEnabled(context, FeatureFlags.WIFI_DETAILS_DATAUSAGE_HEADER);
}
+
+ private void connectNetwork() {
+ final Activity activity = mFragment.getActivity();
+ // error handling, connected/saved network should have mWifiConfig.
+ if (mWifiConfig == null) {
+ Toast.makeText(activity,
+ R.string.wifi_failed_connect_message,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ // init state before connect
+ mConnectingState = STATE_NONE;
+
+ if (mWifiManager.isWifiEnabled()) {
+ updateConnectingState(STATE_CONNECTING);
+ } else {
+ // Enable Wi-Fi automatically to connect AP
+ updateConnectingState(STATE_ENABLE_WIFI);
+ }
+ }
+
+ private void updateConnectingState(int state) {
+ final Activity activity = mFragment.getActivity();
+ Log.d(TAG, "updateConnectingState from " + mConnectingState + " to " + state);
+ switch (mConnectingState) {
+ case STATE_NONE:
+ case STATE_ENABLE_WIFI:
+ if (state == STATE_ENABLE_WIFI) {
+ Log.d(TAG, "Turn on Wi-Fi automatically!");
+ updateConnectedButton(STATE_ENABLE_WIFI);
+ Toast.makeText(activity,
+ R.string.wifi_turned_on_message,
+ Toast.LENGTH_SHORT).show();
+ mWifiManager.setWifiEnabled(true);
+ // start timer for error handling
+ startTimer();
+ } else if (state == STATE_CONNECTING) {
+ Log.d(TAG, "connecting...");
+ updateConnectedButton(STATE_CONNECTING);
+ mWifiManager.connect(mWifiConfig.networkId, mConnectListener);
+ // start timer for error handling since framework didn't call back if failed
+ startTimer();
+ } else if (state == STATE_ENABLE_WIFI_FAILED) {
+ Log.e(TAG, "Wi-Fi failed to enable network!");
+ stopTimer();
+ // reset state
+ state = STATE_NONE;
+ Toast.makeText(activity,
+ R.string.wifi_failed_connect_message,
+ Toast.LENGTH_SHORT).show();
+ updateConnectedButton(STATE_ENABLE_WIFI_FAILED);
+ }
+ // Do not break here for disconnected event.
+ case STATE_CONNECTED:
+ if (state == STATE_DISCONNECTED) {
+ Log.d(TAG, "disconnected");
+ // reset state
+ state = STATE_NONE;
+ updateConnectedButton(STATE_DISCONNECTED);
+ refreshPage();
+ // clear for getting MAC Address from saved configuration
+ mWifiInfo = null;
+ }
+ break;
+ case STATE_CONNECTING:
+ if (state == STATE_CONNECTED) {
+ Log.d(TAG, "connected");
+ stopTimer();
+ updateConnectedButton(STATE_CONNECTED);
+ Toast.makeText(activity,
+ mContext.getString(R.string.wifi_connected_to_message,
+ mAccessPoint.getTitle()),
+ Toast.LENGTH_SHORT).show();
+
+ updateNetworkInfo();
+ refreshPage();
+ } else if (state == STATE_NOT_IN_RANGE) {
+ Log.d(TAG, "AP not in range");
+ stopTimer();
+ // reset state
+ state = STATE_NONE;
+ Toast.makeText(activity,
+ R.string.wifi_not_in_range_message,
+ Toast.LENGTH_SHORT).show();
+ updateConnectedButton(STATE_NOT_IN_RANGE);
+ } else if (state == STATE_FAILED) {
+ Log.d(TAG, "failed");
+ stopTimer();
+ // reset state
+ state = STATE_NONE;
+ Toast.makeText(activity,
+ R.string.wifi_failed_connect_message,
+ Toast.LENGTH_SHORT).show();
+ updateConnectedButton(STATE_FAILED);
+ }
+ break;
+ default:
+ Log.e(TAG, "Invalid state : " + mConnectingState);
+ // don't update invalid state
+ return;
+ }
+
+ mConnectingState = state;
+ }
+
+ private void updateConnectedButton(int state) {
+ switch (state) {
+ case STATE_ENABLE_WIFI:
+ case STATE_CONNECTING:
+ mButtonsPref.setButton3Text(R.string.wifi_connecting)
+ .setButton3Enabled(false);
+ break;
+ case STATE_CONNECTED:
+ mButtonsPref.setButton3Visible(false);
+ break;
+ case STATE_DISCONNECTED:
+ case STATE_NOT_IN_RANGE:
+ case STATE_FAILED:
+ case STATE_ENABLE_WIFI_FAILED:
+ mButtonsPref.setButton3Text(R.string.wifi_connect)
+ .setButton3Icon(R.drawable.ic_settings_wireless)
+ .setButton3Enabled(true)
+ .setButton3Visible(true);
+ break;
+ default:
+ Log.e(TAG, "Invalid connect button state : " + state);
+ break;
+ }
+ }
+
+ private void startTimer() {
+ if (mTimer != null) {
+ stopTimer();
+ }
+
+ mTimer = new CountDownTimer(TIMEOUT, TIMEOUT + 1) {
+ @Override
+ public void onTick(long millisUntilFinished) {
+ // Do nothing
+ }
+ @Override
+ public void onFinish() {
+ Log.e(TAG, "Timeout for state:" + mConnectingState);
+ if (mConnectingState == STATE_ENABLE_WIFI) {
+ updateConnectingState(STATE_ENABLE_WIFI_FAILED);
+ } else if (mConnectingState == STATE_CONNECTING) {
+ updateAccessPointFromScannedList();
+ if (mIsOutOfRange) {
+ updateConnectingState(STATE_NOT_IN_RANGE);
+ } else {
+ updateConnectingState(STATE_FAILED);
+ }
+ }
+ }
+ };
+ mTimer.start();
+ }
+
+ private void stopTimer() {
+ if (mTimer == null) return;
+
+ mTimer.cancel();
+ mTimer = null;
+ }
}
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 66587ed..10d1d48 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -134,11 +134,14 @@
mMetricsFeatureProvider);
controllers.add(mWifiDetailPreferenceController);
+ controllers.add(new AddDevicePreferenceController(context).init(mAccessPoint));
controllers.add(new WifiMeteredPreferenceController(context, mAccessPoint.getConfig()));
WifiPrivacyPreferenceController privacyController = new WifiPrivacyPreferenceController(
context);
privacyController.setWifiConfiguration(mAccessPoint.getConfig());
privacyController.setIsEphemeral(mAccessPoint.isEphemeral());
+ privacyController.setIsPasspoint(
+ mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig());
controllers.add(privacyController);
return controllers;
diff --git a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
index a549e21..7bec411 100644
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
@@ -41,6 +41,7 @@
private WifiConfiguration mWifiConfiguration;
private WifiManager mWifiManager;
private boolean mIsEphemeral = false;
+ private boolean mIsPasspoint = false;
public WifiPrivacyPreferenceController(Context context) {
super(context, KEY_WIFI_PRIVACY);
@@ -56,6 +57,10 @@
mIsEphemeral = isEphemeral;
}
+ public void setIsPasspoint(boolean isPasspoint) {
+ mIsPasspoint = isPasspoint;
+ }
+
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
@@ -71,7 +76,7 @@
updateSummary(dropDownPreference, randomizationLevel);
// Makes preference not selectable, when this is a ephemeral network.
- if (mIsEphemeral) {
+ if (mIsEphemeral || mIsPasspoint) {
preference.setSelectable(false);
dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
index 4e6a0d6..d388931 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
@@ -95,35 +95,15 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- final WifiNetworkConfig wifiNetworkConfig = getWifiNetworkConfigFromHostActivity();
- MenuItem menuItem;
- if (!wifiNetworkConfig.isHotspot() &&
- wifiNetworkConfig.isSupportWifiDpp(getActivity())) {
- menuItem = menu.add(0, Menu.FIRST, 0, R.string.next_label);
- menuItem.setIcon(R.drawable.ic_scan_24dp);
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
- } else {
- menuItem = menu.findItem(Menu.FIRST);
- if (menuItem != null) {
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- }
+ final MenuItem menuItem = menu.findItem(Menu.FIRST);
+ if (menuItem != null) {
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}
super.onCreateOptionsMenu(menu, inflater);
}
@Override
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- switch (menuItem.getItemId()) {
- case Menu.FIRST:
- mListener.onQrCodeGeneratorFragmentAddButtonClicked();
- return true;
- default:
- return super.onOptionsItemSelected(menuItem);
- }
- }
-
- @Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.wifi_dpp_qrcode_generator_fragment, container,
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index bf78b3f..6c6444c 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -165,9 +165,8 @@
}
/**
- * Returns an intent to launch QR code generator or scanner according to the Wi-Fi network
- * security. It may return null if the security is not supported by QR code generator nor
- * scanner.
+ * Returns an intent to launch QR code generator. It may return null if the security is not
+ * supported by QR code generator.
*
* Do not use this method for Wi-Fi hotspot network, use
* {@code getHotspotConfiguratorIntentOrNull} instead.
@@ -177,12 +176,34 @@
* @param accessPoint An instance of {@link AccessPoint}
* @return Intent for launching QR code generator
*/
- public static Intent getConfiguratorIntentOrNull(Context context,
+ public static Intent getConfiguratorQrCodeGeneratorIntentOrNull(Context context,
WifiManager wifiManager, AccessPoint accessPoint) {
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
if (isSupportConfiguratorQrCodeGenerator(accessPoint)) {
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
- } else if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
+ } else {
+ return null;
+ }
+
+ final WifiConfiguration wifiConfiguration = accessPoint.getConfig();
+ setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration);
+
+ return intent;
+ }
+
+ /**
+ * Returns an intent to launch QR code scanner. It may return null if the security is not
+ * supported by QR code scanner.
+ *
+ * @param context The context to use for the content resolver
+ * @param wifiManager An instance of {@link WifiManager}
+ * @param accessPoint An instance of {@link AccessPoint}
+ * @return Intent for launching QR code scanner
+ */
+ public static Intent getConfiguratorQrCodeScannerIntentOrNull(Context context,
+ WifiManager wifiManager, AccessPoint accessPoint) {
+ final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
+ if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
} else {
return null;
@@ -259,18 +280,6 @@
}
/**
- * Android Q supports Wi-Fi configurator by:
- *
- * 1. QR code generator of ZXing's Wi-Fi network config format.
- * and
- * 2. QR code scanner of Wi-Fi DPP QR code format.
- */
- public static boolean isSuportConfigurator(Context context, AccessPoint accessPoint) {
- return isSupportConfiguratorQrCodeScanner(context, accessPoint) ||
- isSupportConfiguratorQrCodeGenerator(accessPoint);
- }
-
- /**
* Shows authentication screen to confirm credentials (pin, pattern or password) for the current
* user of the device.
*
@@ -314,7 +323,7 @@
}
}
- private static boolean isSupportConfiguratorQrCodeScanner(Context context,
+ public static boolean isSupportConfiguratorQrCodeScanner(Context context,
AccessPoint accessPoint) {
if (!isWifiDppEnabled(context)) {
return false;
@@ -329,7 +338,7 @@
return false;
}
- private static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
+ public static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
// QR code generator produces QR code with ZXing's Wi-Fi network config format,
// it supports PSK and WEP and non security
final int security = accessPoint.getSecurity();
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
index 84f1c36..2bf411a 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
@@ -34,7 +34,6 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.wifi.AddNetworkFragment;
-import com.android.settings.wifi.savedaccesspoints.SavedNetworkComparator;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.WifiSavedConfigUtils;
@@ -43,6 +42,7 @@
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
public class WifiNetworkListFragment extends SettingsPreferenceFragment implements
WifiTracker.WifiListener, AccessPoint.AccessPointListener {
@@ -282,27 +282,38 @@
return;
}
- // TODO(b/128942314): Lists reachable AccessPoints on top of the list
- final List<AccessPoint> savedAccessPoints =
+ List<AccessPoint> savedAccessPoints =
WifiSavedConfigUtils.getAllConfigs(getContext(), mWifiManager);
- Collections.sort(savedAccessPoints, SavedNetworkComparator.INSTANCE);
+
+ savedAccessPoints = savedAccessPoints.stream()
+ .filter(accessPoint -> isValidForDppConfiguration(accessPoint))
+ .map(accessPoint -> getScannedAccessPointIfAvailable(accessPoint))
+ .sorted((ap1, ap2) -> {
+ // orders reachable Wi-Fi networks on top
+ if (ap1.isReachable() && !ap2.isReachable()) {
+ return -1;
+ } else if (!ap1.isReachable() && ap2.isReachable()) {
+ return 1;
+ }
+
+ String ap1Title = nullToEmpty(ap1.getTitle());
+ String ap2Title = nullToEmpty(ap2.getTitle());
+
+ return ap1Title.compareToIgnoreCase(ap2Title);
+ }).collect(Collectors.toList());
int index = 0;
mAccessPointsPreferenceCategory.removeAll();
for (AccessPoint savedAccessPoint : savedAccessPoints) {
- if (isValidForDppConfiguration(savedAccessPoint)) {
- // Replaces with an AccessPoint from scanned result for signal information
- savedAccessPoint = getScannedAccessPointIfAvailable(savedAccessPoint);
- final AccessPointPreference preference =
- createAccessPointPreference(savedAccessPoint);
+ final AccessPointPreference preference =
+ createAccessPointPreference(savedAccessPoint);
- preference.setOrder(index++);
- preference.setEnabled(savedAccessPoint.isReachable());
- savedAccessPoint.setListener(this);
+ preference.setOrder(index++);
+ preference.setEnabled(savedAccessPoint.isReachable());
+ savedAccessPoint.setListener(this);
- preference.refresh();
- mAccessPointsPreferenceCategory.addPreference(preference);
- }
+ preference.refresh();
+ mAccessPointsPreferenceCategory.addPreference(preference);
}
mAddPreference.setOrder(index);
mAccessPointsPreferenceCategory.addPreference(mAddPreference);
@@ -312,6 +323,11 @@
}
}
+ private String nullToEmpty(String string) {
+ return (string == null) ? "" : string;
+ }
+
+ // Replaces with an AccessPoint from scanned result for signal information
private AccessPoint getScannedAccessPointIfAvailable(AccessPoint savedAccessPoint) {
final List<AccessPoint> scannedAccessPoints = mWifiTracker.getAccessPoints();
final WifiConfiguration savedWifiConfiguration = savedAccessPoint.getConfig();
diff --git a/src/com/android/settings/wifi/qrcode/QrDecorateView.java b/src/com/android/settings/wifi/qrcode/QrDecorateView.java
index 2be1eab..5df0cd0 100644
--- a/src/com/android/settings/wifi/qrcode/QrDecorateView.java
+++ b/src/com/android/settings/wifi/qrcode/QrDecorateView.java
@@ -46,6 +46,7 @@
final private Paint mBackgroundPaint;
final private float mRadius;
+ final private float mInnerRidus;
private Bitmap mMaskBitmap;
private Canvas mMaskCanvas;
@@ -73,6 +74,9 @@
mFocused = false;
mRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, CORNER_RADIUS,
getResources().getDisplayMetrics());
+ // Inner radius needs to minus stroke width for keeping the width of border consistent.
+ mInnerRidus = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ CORNER_RADIUS - CORNER_STROKE_WIDTH, getResources().getDisplayMetrics());
mCornerColor = context.getResources().getColor(R.color.qr_corner_line_color);
mFocusedCornerColor = context.getResources().getColor(R.color.qr_focused_corner_line_color);
@@ -111,7 +115,7 @@
// Draw outer corner.
mMaskCanvas.drawRoundRect(mOuterFrame, mRadius, mRadius, mStrokePaint);
// Draw inner transparent corner.
- mMaskCanvas.drawRoundRect(mInnerFrame, mRadius, mRadius, mTransparentPaint);
+ mMaskCanvas.drawRoundRect(mInnerFrame, mInnerRidus, mInnerRidus, mTransparentPaint);
canvas.drawBitmap(mMaskBitmap, 0, 0, mBackgroundPaint);
super.onDraw(canvas);
@@ -123,7 +127,7 @@
final float cornerLineLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
CORNER_LINE_LENGTH, getResources().getDisplayMetrics()) / 2;
final float strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- CORNER_STROKE_WIDTH, getResources().getDisplayMetrics()) / 2;
+ CORNER_STROKE_WIDTH, getResources().getDisplayMetrics());
mOuterFrame = new RectF(centralX - cornerLineLength, centralY - cornerLineLength,
centralX + cornerLineLength, centralY + cornerLineLength);
@@ -131,7 +135,7 @@
mOuterFrame.right - strokeWidth, mOuterFrame.bottom - strokeWidth);
}
- // Draws green lines if focued. Otherwise, draws white lines.
+ // Draws green lines if focused. Otherwise, draws white lines.
public void setFocused(boolean focused) {
mFocused = focused;
invalidate();
diff --git a/tests/robotests/Android.mk b/tests/robotests/Android.mk
index b0733f4..727da06 100644
--- a/tests/robotests/Android.mk
+++ b/tests/robotests/Android.mk
@@ -49,6 +49,7 @@
guava \
jsr305 \
settings-contextual-card-protos-lite \
+ settings-log-bridge-protos-lite \
contextualcards \
settings-logtags \
zxing-core-1.7
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 015502b..d7e5585 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -19,6 +19,7 @@
com.android.settings.applications.ProcessStatsUi
com.android.settings.applications.RunningServices
com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails
+com.android.settings.applications.specialaccess.zenaccess.ZenAccessDetails
com.android.settings.applications.UsageAccessDetails
com.android.settings.backup.ToggleBackupSettingFragment
com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment
@@ -74,6 +75,7 @@
com.android.settings.users.UserDetailsSettings
com.android.settings.vpn2.AppManagementFragment
com.android.settings.vpn2.VpnSettings
+com.android.settings.wallpaper.WallpaperTypeSettings
com.android.settings.wifi.calling.WifiCallingSettingsForSub
com.android.settings.wifi.ChangeWifiStateDetails
com.android.settings.wifi.details.WifiNetworkDetailsFragment
diff --git a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
index f718a67..4fe8fa8a 100644
--- a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
@@ -36,12 +36,12 @@
Intent fromIntent = new Intent();
final String theme = "TEST_THEME";
fromIntent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
- fromIntent.putExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, true);
+ fromIntent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
Intent toIntent = new Intent();
SetupWizardUtils.copySetupExtras(fromIntent, toIntent);
assertThat(theme).isEqualTo(toIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
- assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false))
+ assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, false))
.isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
new file mode 100644
index 0000000..d6b12c3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Intent;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.settings.R;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+@SmallTest
+public class AccessibilitySettingsForSetupWizardActivityTest {
+
+ @Test
+ public void createSetupAccessibilityActivity_shouldBeSUWTheme() {
+ final Intent intent = new Intent();
+ AccessibilitySettingsForSetupWizardActivity activity =
+ Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class, intent).get();
+
+ assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifTheme_Light);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index 8c53019..0cc9dc4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -156,7 +156,7 @@
@Test
public void testDarkUIModePreferenceSummary_shouldUpdateSummary() {
- final ListPreference darkUIModePreference = new ListPreference(mContext);
+ final Preference darkUIModePreference = new Preference(mContext);
final DarkUIPreferenceController mController;
doReturn(darkUIModePreference).when(mSettings).findPreference(
DARK_UI_MODE_PREFERENCE);
diff --git a/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
new file mode 100644
index 0000000..9e0ce9c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.pm.ResolveInfo;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Collections;
+
+@RunWith(RobolectricTestRunner.class)
+public class LiveCaptionPreferenceControllerTest {
+
+ private LiveCaptionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mController = new LiveCaptionPreferenceController(RuntimeEnvironment.application,
+ "test_key");
+ }
+
+ @Test
+ public void getAvailabilityStatus_canResolveIntent_shouldReturnAvailable() {
+ final ShadowPackageManager pm = Shadows.shadowOf(
+ RuntimeEnvironment.application.getPackageManager());
+ pm.addResolveInfoForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
+ new ResolveInfo());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noResolveIntent_shouldReturnUnavailable() {
+ final ShadowPackageManager pm = Shadows.shadowOf(
+ RuntimeEnvironment.application.getPackageManager());
+ pm.setResolveInfosForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
+ Collections.emptyList());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index ebbf5e0..e22b29b 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -272,7 +272,7 @@
// Spy the real context to mock LocationManager.
Context spyContext = spy(RuntimeEnvironment.application);
- when(mLocationManager.getLocationControllerExtraPackage()).thenReturn(testLocationHistory);
+ when(mLocationManager.getExtraLocationControllerPackage()).thenReturn(testLocationHistory);
when(spyContext.getSystemService(Context.LOCATION_SERVICE)).thenReturn(mLocationManager);
ReflectionHelpers.setField(mProvider, "mContext", spyContext);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
index f3d85d3..59aea3d 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
@@ -324,7 +324,7 @@
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.uninstall_text);
+ verify(mButtonPrefs).setButton2Text(R.string.disable_text);
assertThat(controllable).isFalse();
}
@@ -336,7 +336,7 @@
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.uninstall_text);
+ verify(mButtonPrefs).setButton2Text(R.string.disable_text);
assertThat(controllable).isTrue();
}
@@ -348,7 +348,7 @@
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.install_text);
+ verify(mButtonPrefs).setButton2Text(R.string.enable_text);
assertThat(controllable).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
index 9e44c95..56e59f7 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
@@ -17,8 +17,7 @@
package com.android.settings.applications.appinfo;
import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.ARG_PACKAGE_NAME;
-import static com.android.settings.applications.appinfo.AppInfoDashboardFragment
- .UNINSTALL_ALL_USERS_MENU;
+import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.UNINSTALL_ALL_USERS_MENU;
import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.UNINSTALL_UPDATES;
import static com.google.common.truth.Truth.assertThat;
@@ -43,6 +42,7 @@
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserManager;
+import android.util.ArraySet;
import android.view.Menu;
import android.view.MenuItem;
@@ -53,6 +53,7 @@
import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -63,10 +64,14 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
@RunWith(RobolectricTestRunner.class)
public final class AppInfoDashboardFragmentTest {
@@ -101,6 +106,11 @@
(InstantAppDataProvider) (i -> false));
}
+ @After
+ public void tearDown() {
+ ShadowAppUtils.reset();
+ }
+
@Test
public void shouldShowUninstallForAll_installForOneOtherUserOnly_shouldReturnTrue() {
when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
@@ -187,6 +197,24 @@
}
@Test
+ @Config(shadows = ShadowAppUtils.class)
+ public void ensureDisplayableModule_hiddenModule_shouldReturnFalse() {
+ ShadowAppUtils.addHiddenModule(PACKAGE_NAME);
+ ReflectionHelpers.setField(mFragment, "mPackageName", PACKAGE_NAME);
+
+
+ assertThat(mFragment.ensureDisplayableModule(mActivity)).isFalse();
+ }
+
+ @Test
+ @Config(shadows = ShadowAppUtils.class)
+ public void ensureDisplayableModule_regularApp_shouldReturnTrue() {
+ ReflectionHelpers.setField(mFragment, "mPackageName", PACKAGE_NAME);
+
+ assertThat(mFragment.ensureDisplayableModule(mActivity)).isTrue();
+ }
+
+ @Test
public void createPreference_hasNoPackageInfo_shouldSkip() {
ReflectionHelpers.setField(mFragment, "mPackageInfo", null);
@@ -240,7 +268,8 @@
doReturn(true).when(mFragment).refreshUi();
mFragment
- .onActivityResult(AppInfoDashboardFragment.REQUEST_UNINSTALL, 0, mock(Intent.class));
+ .onActivityResult(AppInfoDashboardFragment.REQUEST_UNINSTALL, 0,
+ mock(Intent.class));
verify(mActivity).invalidateOptionsMenu();
}
@@ -347,4 +376,24 @@
.containsKey(ARG_PACKAGE_NAME))
.isTrue();
}
+
+ @Implements(AppUtils.class)
+ public static class ShadowAppUtils {
+
+ public static Set<String> sHiddenModules = new ArraySet<>();
+
+ @Resetter
+ public static void reset() {
+ sHiddenModules.clear();
+ }
+
+ public static void addHiddenModule(String pkg) {
+ sHiddenModules.add(pkg);
+ }
+
+ @Implementation
+ protected static boolean isHiddenSystemModule(Context context, String packageName) {
+ return sHiddenModules.contains(packageName);
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
index ca99361..fdbf8b9 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
@@ -16,43 +16,26 @@
package com.android.settings.applications.appinfo;
-import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-
-import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.settings.SettingsEnums;
-import android.view.Window;
import android.view.WindowManager.LayoutParams;
-import androidx.fragment.app.FragmentActivity;
-
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.shadow.ShadowAppInfoBase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
public class DrawOverlayDetailsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private FragmentActivity mActivity;
-
- @Mock
- private Window mWindow;
-
private LayoutParams layoutParams;
private FakeFeatureFactory mFeatureFactory;
@@ -82,23 +65,4 @@
MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_APPDRAW_DENY,
mFragment.getMetricsCategory(), "app", 0);
}
-
- @Test
- @Config(shadows = {ShadowAppInfoBase.class})
- public void hideNonSystemOverlaysWhenResumed() {
- when(mFragment.getActivity()).thenReturn(mActivity);
- when(mActivity.getWindow()).thenReturn(mWindow);
- when(mWindow.getAttributes()).thenReturn(layoutParams);
-
- mFragment.onResume();
- verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
-
- mFragment.onPause();
-
- // There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
- ArgumentCaptor<LayoutParams> paramCaptor = ArgumentCaptor.forClass(LayoutParams.class);
- verify(mWindow).setAttributes(paramCaptor.capture());
- assertEquals(0,
- paramCaptor.getValue().privateFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
index 5f2a514..5e5239d 100644
--- a/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
@@ -18,17 +18,9 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.util.IconDrawableFactory;
-import android.view.View;
-import android.widget.ProgressBar;
-
-import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settingslib.applications.ApplicationsState;
@@ -64,21 +56,6 @@
assertThat(pref.getLayoutResource()).isEqualTo(R.layout.preference_app);
}
- @Test
- public void onBindViewHolder_shouldSetAppendixViewToGone() {
- final DomainAppPreference pref = new DomainAppPreference(
- mContext, mIconDrawableFactory, mAppEntry);
- final View holderView = mock(View.class);
- final View appendixView = mock(View.class);
- when(holderView.findViewById(R.id.summary_container)).thenReturn(mock(View.class));
- when(holderView.findViewById(android.R.id.progress)).thenReturn(mock(ProgressBar.class));
- when(holderView.findViewById(R.id.appendix)).thenReturn(appendixView);
-
- pref.onBindViewHolder(PreferenceViewHolder.createInstanceForTests(holderView));
-
- verify(appendixView).setVisibility(View.GONE);
- }
-
private ApplicationInfo createApplicationInfo(String packageName) {
ApplicationInfo appInfo = new ApplicationInfo();
appInfo.sourceDir = "foo";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 5538155..b961669 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -78,6 +79,7 @@
mContext = RuntimeEnvironment.application;
mController = new AdvancedBluetoothDetailsHeaderController(mContext, "pref_Key");
+ when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
mController.init(mCachedDevice);
mLayoutPreference = new LayoutPreference(mContext,
LayoutInflater.from(mContext).inflate(R.layout.advanced_bt_entity_header, null));
@@ -166,7 +168,10 @@
}
@Test
- public void onStart_registerCallback() {
+ public void onStart_isAvailable_registerCallback() {
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
+ .thenReturn("true");
+
mController.onStart();
verify(mBluetoothAdapter).registerMetadataListener(mBluetoothDevice,
@@ -174,12 +179,36 @@
}
@Test
- public void onStop_unregisterCallback() {
+ public void onStop_isAvailable_unregisterCallback() {
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
+ .thenReturn("true");
+
mController.onStop();
verify(mBluetoothAdapter).unregisterMetadataListener(mBluetoothDevice);
}
+ @Test
+ public void onStart_notAvailable_registerCallback() {
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
+ .thenReturn("false");
+
+ mController.onStart();
+
+ verify(mBluetoothAdapter, never()).registerMetadataListener(mBluetoothDevice,
+ mController.mMetadataListener, mController.mHandler);
+ }
+
+ @Test
+ public void onStop_notAvailable_unregisterCallback() {
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
+ .thenReturn("false");
+
+ mController.onStop();
+
+ verify(mBluetoothAdapter, never()).unregisterMetadataListener(mBluetoothDevice);
+ }
+
private void assertBatteryLevel(LinearLayout linearLayout, int batteryLevel) {
final TextView textView = linearLayout.findViewById(R.id.bt_battery_summary);
assertThat(textView.getText().toString()).isEqualTo(
diff --git a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerSignatureInspector.java b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerSignatureInspector.java
index 28e394f..2d1dc5c 100644
--- a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerSignatureInspector.java
+++ b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerSignatureInspector.java
@@ -58,12 +58,17 @@
if (constructors == null || constructors.length == 0) {
badClasses.append(c.getName()).append(",");
}
+
+ boolean hasValidConstructor = false;
for (Constructor constructor : constructors) {
- if (!hasValidConstructorSignature(constructor)) {
- badClasses.append(className).append(",");
- continue;
+ if (hasValidConstructorSignature(constructor)) {
+ hasValidConstructor = true;
+ break;
}
}
+ if (!hasValidConstructor) {
+ badClasses.append(className).append(",");
+ }
}
assertWithMessage("All BasePreferenceController (and subclasses) constructor must either"
diff --git a/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java b/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
index 579cba0..d4f43e2 100644
--- a/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
+++ b/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
@@ -20,6 +20,7 @@
import static com.google.common.truth.Truth.assertThat;
+import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;
@@ -33,8 +34,8 @@
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class HideNonSystemOverlayMixinTest {
@@ -43,7 +44,6 @@
@Before
public void setUp() {
- RuntimeEnvironment.application.setTheme(R.style.Theme_AppCompat);
mActivityController = Robolectric.buildActivity(TestActivity.class);
}
@@ -68,10 +68,25 @@
.isEqualTo(0);
}
+ @Test
+ public void isEnabled_debug_false() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
+
+ assertThat(new HideNonSystemOverlayMixin(null).isEnabled()).isFalse();
+ }
+
+ @Test
+ public void isEnabled_user_true() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+
+ assertThat(new HideNonSystemOverlayMixin(null).isEnabled()).isTrue();
+ }
+
public static class TestActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setTheme(R.style.Theme_AppCompat);
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
}
}
diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriterTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriterTest.java
new file mode 100644
index 0000000..30a2594
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriterTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 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.core.instrumentation;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.intelligence.LogProto.SettingsLog;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SettingsIntelligenceLogWriterTest {
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ public void serialize_hasSizeOne_returnCorrectData() throws IOException {
+ final SettingsLog event = SettingsLog.newBuilder()
+ .setAttribution(SettingsEnums.DASHBOARD_SUMMARY)
+ .setAction(SettingsEnums.ACTION_SET_NEW_PASSWORD)
+ .setPageId(SettingsEnums.SET_NEW_PASSWORD_ACTIVITY)
+ .setChangedPreferenceKey("package")
+ .setChangedPreferenceIntValue(100)
+ .build();
+ List<SettingsLog> events = new ArrayList<>();
+ events.add(event);
+
+ // execute
+ final byte[] data = SettingsIntelligenceLogWriter.serialize(events);
+
+ // parse data
+ final ByteArrayInputStream bin = new ByteArrayInputStream(data);
+ final DataInputStream inputStream = new DataInputStream(bin);
+ final int size = inputStream.readInt();
+ final byte[] change = new byte[inputStream.readInt()];
+ inputStream.read(change);
+ inputStream.close();
+ final SettingsLog settingsLog = SettingsLog.parseFrom(change);
+
+ // assert
+ assertThat(events.size()).isEqualTo(size);
+ assertThat(settingsLog.getAttribution()).isEqualTo(SettingsEnums.DASHBOARD_SUMMARY);
+ assertThat(settingsLog.getAction()).isEqualTo(SettingsEnums.ACTION_SET_NEW_PASSWORD);
+ assertThat(settingsLog.getPageId()).isEqualTo(SettingsEnums.SET_NEW_PASSWORD_ACTIVITY);
+ assertThat(settingsLog.getChangedPreferenceKey()).isEqualTo("package");
+ assertThat(settingsLog.getChangedPreferenceIntValue()).isEqualTo(100);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
index 2e15967..cf97544 100644
--- a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.development.featureflags;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
@@ -26,6 +27,8 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.Build;
+import android.os.SystemProperties;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -37,6 +40,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class FeatureFlagPreferenceControllerTest {
@@ -59,10 +63,18 @@
}
@Test
- public void getAvailability_available() {
+ public void getAvailability_debug_available() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
+
+ @Test
+ public void getAvailability_user_unavailable() {
+ ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
@Test
public void onStart_shouldRefreshFeatureFlags() {
mController.onStart();
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
index 2761b2f..f391aac 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
@@ -18,6 +18,7 @@
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+import static com.android.settings.deviceinfo.firmwareversion.MainlineModuleVersionPreferenceController.MODULE_UPDATE_INTENT;
import static com.google.common.truth.Truth.assertThat;
@@ -29,8 +30,11 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.util.FeatureFlagUtils;
+import androidx.preference.Preference;
+
import com.android.settings.core.FeatureFlags;
import org.junit.Before;
@@ -48,11 +52,13 @@
private PackageManager mPackageManager;
private Context mContext;
+ private Preference mPreference;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ mPreference = new Preference(mContext);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, true);
@@ -82,7 +88,6 @@
@Test
public void getAvailabilityStatus_noMainlineModulePackageInfo_unavailable() throws Exception {
-
final String provider = "test.provider";
when(mContext.getString(
com.android.internal.R.string.config_defaultModuleMetadataProvider))
@@ -98,6 +103,43 @@
@Test
public void getAvailabilityStatus_hasMainlineModulePackageInfo_available() throws Exception {
+ setupModulePackage();
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void updateStates_canHandleIntent_setIntentToPreference() throws Exception {
+ setupModulePackage();
+ when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
+ .thenReturn(new ResolveInfo());
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ controller.updateState(mPreference);
+
+ assertThat(mPreference.getIntent()).isEqualTo(MODULE_UPDATE_INTENT);
+ }
+
+ @Test
+ public void updateStates_cannotHandleIntent_setNullToPreference() throws Exception {
+ setupModulePackage();
+ when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
+ .thenReturn(null);
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ controller.updateState(mPreference);
+
+ assertThat(mPreference.getIntent()).isNull();
+ }
+
+ private void setupModulePackage() throws Exception {
final String provider = "test.provider";
final String version = "test version 123";
final PackageInfo info = new PackageInfo();
@@ -106,11 +148,5 @@
com.android.internal.R.string.config_defaultModuleMetadataProvider))
.thenReturn(provider);
when(mPackageManager.getPackageInfo(eq(provider), anyInt())).thenReturn(info);
-
- final MainlineModuleVersionPreferenceController controller =
- new MainlineModuleVersionPreferenceController(mContext, "key");
-
- assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
-
}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
deleted file mode 100644
index c8f847b..0000000
--- a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.display;
-
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.UiModeManager;
-import android.content.Context;
-
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class DarkUIPreferenceControllerTest {
-
- private Context mContext;
- @Mock
- private ListPreference mPreference;
- @Mock
- private PreferenceScreen mPreferenceScreen;
- @Mock
- private UiModeManager mUiModeManager;
- private DarkUIPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new DarkUIPreferenceController(mContext, "dark_ui_mode");
- mController.setUiModeManager(mUiModeManager);
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
- .thenReturn(mPreference);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void onPreferenceChanged_setAuto() {
- // Auto was deprecated, it should default to NO.
- mController.onPreferenceChange(mPreference, "auto");
- verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_NO));
- }
-
- @Test
- public void onPreferenceChanged_setNightMode() {
- mController.onPreferenceChange(mPreference, "yes");
- verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_YES));
- }
-
- @Test
- public void onPreferenceChanged_setDayMode() {
- mController.onPreferenceChange(mPreference, "no");
- verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_NO));
- }
-
- public int getCurrentMode() {
- final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
- return uiModeManager.getNightMode();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java
new file mode 100644
index 0000000..76142a4
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java
@@ -0,0 +1,52 @@
+package com.android.settings.display;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+import android.app.UiModeManager;
+import android.content.Context;
+import androidx.preference.Preference;
+import com.android.settings.R;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class DarkUISettingsRadioButtonsControllerTest {
+
+ @Mock
+ private UiModeManager mUiModeManager;
+ @Mock
+ private Preference mFooter;
+ private Context mContext;
+ private DarkUISettingsRadioButtonsController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new DarkUISettingsRadioButtonsController(mContext, mFooter);
+ mController.mManager = mUiModeManager;
+ }
+
+ @Test
+ public void footerUpdatesCorrectly() {
+ doReturn(UiModeManager.MODE_NIGHT_YES).when(mUiModeManager).getNightMode();
+ mController.updateFooter();
+ verify(mFooter).setSummary(eq(R.string.dark_ui_settings_dark_summary));
+
+ doReturn(UiModeManager.MODE_NIGHT_NO).when(mUiModeManager).getNightMode();
+ mController.updateFooter();
+ verify(mFooter).setSummary(eq(R.string.dark_ui_settings_light_summary));
+ }
+
+ public int getCurrentMode() {
+ final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
+ return uiModeManager.getNightMode();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
index 6012dbb..8654a4e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
@@ -7,6 +7,7 @@
import android.os.PowerManager;
import android.provider.Settings;
import android.provider.Settings.Global;
+import android.provider.Settings.Secure;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -54,4 +55,13 @@
assertThat(mController.getDefaultKey())
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
}
+
+ @Test
+ public void setDefaultKey_any_defaultsToNoScheduleIfWarningNotSeen() {
+ Secure.putString(
+ mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, "null");
+ mController.setDefaultKey(BatterySaverScheduleRadioButtonsController.KEY_ROUTINE);
+ assertThat(mController.getDefaultKey())
+ .isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
index 0ee9cfc..0e7c312 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -16,11 +16,11 @@
package com.android.settings.fuelgauge.batterysaver;
-import static com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController.LOW_POWER_STICKY_AUTO_DISABLE_ENABLED;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.Settings;
+import android.provider.Settings.Global;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,21 +43,21 @@
private int getAutoDisableSetting() {
return Settings.Global.getInt(mContext.getContentResolver(),
- LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
1);
}
@Test
- public void testOnPreferenceChange_turnOnKeepActive_autoDisableOff() {
- mController.onPreferenceChange(null, true);
+ public void testOnPreferenceChange_turnOnAutoOff_autoDisableOn() {
+ mController.setChecked(true);
final int isOn = getAutoDisableSetting();
- assertThat(isOn).isEqualTo(0);
+ assertThat(isOn).isEqualTo(1);
}
@Test
- public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
- mController.onPreferenceChange(null, false);
+ public void testOnPreferenceChange_TurnOffAutoOff_autoDisableOff() {
+ mController.setChecked(false);
final int isOn = getAutoDisableSetting();
- assertThat(isOn).isEqualTo(1);
+ assertThat(isOn).isEqualTo(0);
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
index 8c24735..11e76b5 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
@@ -18,11 +18,15 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ResolveInfo;
import android.hardware.display.ColorDisplayManager;
import org.junit.Before;
@@ -32,7 +36,9 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowPackageManager;
@RunWith(RobolectricTestRunner.class)
public class GrayscaleConditionControllerTest {
@@ -43,6 +49,7 @@
private ColorDisplayManager mColorDisplayManager;
private Context mContext;
private GrayscaleConditionController mController;
+ private ShadowPackageManager mPackageManager;
@Before
public void setUp() {
@@ -51,6 +58,7 @@
mColorDisplayManager = spy(mContext.getSystemService(ColorDisplayManager.class));
doReturn(mColorDisplayManager).when(mContext).getSystemService(ColorDisplayManager.class);
mController = new GrayscaleConditionController(mContext, mConditionManager);
+ mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
}
@Test
@@ -80,4 +88,16 @@
verify(mConditionManager).onConditionChanged();
}
+
+ @Test
+ public void onActionClick_shouldSendBroadcast() {
+ final Intent intent = new Intent(GrayscaleConditionController.ACTION_GRAYSCALE_CHANGED);
+ final ResolveInfo info = new ResolveInfo();
+ info.activityInfo = new ActivityInfo();
+ mPackageManager.addResolveInfoForIntent(intent, info);
+
+ mController.onActionClick();
+
+ verify(mContext).sendBroadcast(any(Intent.class));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
index a744e68..12513f6 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
@@ -16,6 +16,7 @@
package com.android.settings.homepage.contextualcards.slices;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.slice.Slice.HINT_LIST_ITEM;
import static android.app.slice.SliceItem.FORMAT_SLICE;
@@ -116,7 +117,8 @@
public void getSlice_hasSuggestedApp_shouldHaveNotificationChannelTitle() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -130,7 +132,8 @@
public void getSlice_hasSuggestedApp_shouldSortByNotificationSentCount() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -157,7 +160,8 @@
public void getSlice_noRecentlyInstalledApp_shouldHaveNoSuggestedAppTitle() {
addMockPackageToPackageManager(false /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -169,7 +173,8 @@
public void getSlice_noMultiChannelApp_shouldHaveNoSuggestedAppTitle() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(1 /* channelCount */, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(1 /* channelCount */, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -178,10 +183,12 @@
}
@Test
+ @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
public void getSlice_insufficientNotificationSentCount_shouldHaveNoSuggestedAppTitle() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT, 1 /* notificationCount */, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, 1 /* notificationCount */, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -192,7 +199,8 @@
@Test
public void getSlice_isSystemApp_shouldHaveNoSuggestedAppTitle() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */, ApplicationInfo.FLAG_SYSTEM);
- mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -204,7 +212,8 @@
public void getSlice_isNotificationBanned_shouldHaveNoSuggestedAppTitle() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, true /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, true /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -218,7 +227,7 @@
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
mockNotificationBackend(NotificationChannelSlice.DEFAULT_EXPANDED_ROW_COUNT * 2,
- NOTIFICATION_COUNT, false /* banned */);
+ NOTIFICATION_COUNT, false /* banned */, false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -234,7 +243,8 @@
public void getSlice_channelCountIsLessThanDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT - 1, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT - 1, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -249,7 +259,8 @@
public void getSlice_channelCountIsEqualToDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -263,7 +274,8 @@
public void getSlice_channelCountIsMoreThanDefaultRows_subTitleShouldHaveTapToManagerAll() {
addMockPackageToPackageManager(true /* isRecentlyInstalled */,
ApplicationInfo.FLAG_INSTALLED);
- mockNotificationBackend(CHANNEL_COUNT + 1, NOTIFICATION_COUNT, false /* banned */);
+ mockNotificationBackend(CHANNEL_COUNT + 1, NOTIFICATION_COUNT, false /* banned */,
+ false /* isChannelBlocked */);
final Slice slice = mNotificationChannelSlice.getSlice();
@@ -273,6 +285,20 @@
CHANNEL_COUNT + 1));
}
+ @Test
+ @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
+ public void getSlice_isAllDisplayableChannelBlocked_shouldHaveNoSuggestedAppTitle() {
+ addMockPackageToPackageManager(true /* isRecentlyInstalled */,
+ ApplicationInfo.FLAG_INSTALLED);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+ true /* isChannelBlocked */);
+
+ final Slice slice = mNotificationChannelSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_suggested_app));
+ }
+
private void addMockPackageToPackageManager(boolean isRecentlyInstalled, int flags) {
final ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.name = APP_LABEL;
@@ -294,8 +320,10 @@
return System.currentTimeMillis();
}
- private void mockNotificationBackend(int channelCount, int notificationCount, boolean banned) {
- final List<NotificationChannel> channels = buildNotificationChannel(channelCount);
+ private void mockNotificationBackend(int channelCount, int notificationCount, boolean banned,
+ boolean isChannelBlocked) {
+ final List<NotificationChannel> channels = buildNotificationChannel(channelCount,
+ isChannelBlocked);
final AppRow appRow = buildAppRow(channelCount, notificationCount, banned);
doReturn(buildNotificationChannelGroups(channels)).when(mNotificationBackend).getGroups(
@@ -308,6 +336,8 @@
private AppRow buildAppRow(int channelCount, int sentCount, boolean banned) {
final AppRow appRow = new AppRow();
+ appRow.pkg = PACKAGE_NAME;
+ appRow.uid = UID;
appRow.banned = banned;
appRow.channelCount = channelCount;
appRow.sentByApp = new NotificationsSentState();
@@ -317,11 +347,12 @@
return appRow;
}
- private List<NotificationChannel> buildNotificationChannel(int channelCount) {
+ private List<NotificationChannel> buildNotificationChannel(int channelCount,
+ boolean isChannelBlock) {
final List<NotificationChannel> channels = new ArrayList<>();
for (int i = 0; i < channelCount; i++) {
channels.add(new NotificationChannel(CHANNEL_NAME_PREFIX + i, CHANNEL_NAME_PREFIX + i,
- IMPORTANCE_NONE));
+ isChannelBlock ? IMPORTANCE_NONE : IMPORTANCE_LOW));
}
return channels;
@@ -369,4 +400,4 @@
// Index 0: title; Index 1: summary.
return rowSliceItems.get(1).getText();
}
-}
\ No newline at end of file
+}
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 e08d845..a53ade2 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
@@ -16,13 +16,11 @@
package com.android.settings.homepage.contextualcards.slices;
-import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_DEFERRED_SETUP;
import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import android.app.Activity;
@@ -118,34 +116,25 @@
}
@Test
- public void longClick_shouldFlipCard() {
+ public void bindView_isPendingDismiss_shouldFlipToDismissalView() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
- final View card = viewHolder.itemView.findViewById(R.id.slice_view);
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));
+ final ContextualCard card = buildContextualCard(
+ TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
- card.performLongClick();
+ mRenderer.bindView(viewHolder, card);
assertThat(viewFlipper.getCurrentView()).isEqualTo(dismissalView);
}
@Test
- public void longClick_deferredSetupCard_shouldNotBeClickable() {
- final RecyclerView.ViewHolder viewHolder = getDeferredSetupViewHolder();
- final View contentView = viewHolder.itemView.findViewById(R.id.content);
- mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
-
- assertThat(contentView.isLongClickable()).isFalse();
- }
-
- @Test
- public void longClick_shouldAddViewHolderToSet() {
+ public void bindView_isPendingDismiss_shouldAddViewHolderToSet() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
- final View card = viewHolder.itemView.findViewById(R.id.slice_view);
- mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
+ final ContextualCard card = buildContextualCard(
+ TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
- card.performLongClick();
+ mRenderer.bindView(viewHolder, card);
assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
}
@@ -232,18 +221,6 @@
return mRenderer.createViewHolder(view, VIEW_TYPE_FULL_WIDTH);
}
- private RecyclerView.ViewHolder getDeferredSetupViewHolder() {
- final RecyclerView recyclerView = new RecyclerView(mActivity);
- recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
- final View view = LayoutInflater.from(mActivity).inflate(VIEW_TYPE_DEFERRED_SETUP,
- recyclerView, false);
- final RecyclerView.ViewHolder viewHolder = spy(
- mRenderer.createViewHolder(view, VIEW_TYPE_DEFERRED_SETUP));
- doReturn(VIEW_TYPE_DEFERRED_SETUP).when(viewHolder).getItemViewType();
-
- return viewHolder;
- }
-
private ContextualCard buildContextualCard(Uri sliceUri) {
return new ContextualCard.Builder()
.setName("test_name")
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
index 8882009..395748b 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
@@ -78,7 +78,7 @@
public void bindView_shouldSetScrollableToFalse() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
- mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice());
assertThat(((SliceViewHolder) viewHolder).sliceView.isScrollable()).isFalse();
}
@@ -88,7 +88,7 @@
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final ContextualCard card = buildContextualCard();
- mHelper.bindView(viewHolder, card, buildSlice(), Collections.emptySet());
+ mHelper.bindView(viewHolder, card, buildSlice());
assertThat(((SliceViewHolder) viewHolder).sliceView.getTag()).isEqualTo(card.getSliceUri());
}
@@ -97,7 +97,7 @@
public void bindView_shouldSetModeToLarge() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
- mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice());
assertThat(((SliceViewHolder) viewHolder).sliceView.getMode()).isEqualTo(
SliceView.MODE_LARGE);
@@ -107,7 +107,7 @@
public void bindView_shouldSetSlice() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
- mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice());
assertThat(((SliceViewHolder) viewHolder).sliceView.getSlice().getUri()).isEqualTo(
TEST_SLICE_URI);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java
new file mode 100644
index 0000000..00b7815
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 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.homepage.contextualcards.slices;
+
+import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_DEFERRED_SETUP;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.app.Activity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ViewFlipper;
+
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardRenderer;
+import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardRenderer.ConditionalCardHolder;
+import com.android.settings.homepage.contextualcards.slices.SliceDeferredSetupCardRendererHelper.DeferredSetupCardViewHolder;
+import com.android.settings.homepage.contextualcards.slices.SliceFullCardRendererHelper.SliceViewHolder;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.android.controller.ActivityController;
+
+@RunWith(RobolectricTestRunner.class)
+public class SwipeDismissalDelegateTest {
+
+ @Mock
+ private SwipeDismissalDelegate.Listener mDismissalDelegateListener;
+
+ private Activity mActivity;
+ private RecyclerView mRecyclerView;
+ private SwipeDismissalDelegate mDismissalDelegate;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final ActivityController<Activity> activityController = Robolectric.buildActivity(
+ Activity.class);
+ mActivity = activityController.get();
+ mActivity.setTheme(R.style.Theme_Settings_Home);
+ activityController.create();
+ mRecyclerView = new RecyclerView(mActivity);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
+ mDismissalDelegate = new SwipeDismissalDelegate(mActivity, mDismissalDelegateListener);
+ }
+
+ @Test
+ public void getMovementFlags_conditionalViewHolder_shouldDisableSwipe() {
+ assertThat(mDismissalDelegate.getMovementFlags(mRecyclerView, getConditionalViewHolder()))
+ .isEqualTo(0);
+ }
+
+ @Test
+ public void getMovementFlags_deferredSetupViewHolder_shouldDisableSwipe() {
+ assertThat(mDismissalDelegate.getMovementFlags(mRecyclerView, getDeferredSetupViewHolder()))
+ .isEqualTo(0);
+ }
+
+ @Test
+ public void getMovementFlags_dismissalView_shouldDisableSwipe() {
+ final RecyclerView.ViewHolder holder = getSliceViewHolder();
+ final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
+ viewFlipper.showNext();
+ final View dismissalView = holder.itemView.findViewById(R.id.dismissal_view);
+
+ assertThat(viewFlipper.getCurrentView()).isEqualTo(dismissalView);
+ assertThat(mDismissalDelegate.getMovementFlags(mRecyclerView, holder)).isEqualTo(0);
+ }
+
+ @Test
+ public void getMovementFlags_SliceViewHolder_shouldEnableSwipe() {
+ final RecyclerView.ViewHolder holder = getSliceViewHolder();
+ final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
+ viewFlipper.setDisplayedChild(0);
+ final View sliceView = holder.itemView.findViewById(R.id.slice_view);
+
+ assertThat(viewFlipper.getCurrentView()).isEqualTo(sliceView);
+ assertThat(mDismissalDelegate.getMovementFlags(mRecyclerView, getSliceViewHolder()))
+ .isNotEqualTo(0);
+ }
+
+ @Test
+ public void onSwipe_shouldNotifyListener() {
+ mDismissalDelegate.onSwiped(getSliceViewHolder(), 1);
+
+ verify(mDismissalDelegateListener).onSwiped(anyInt());
+ }
+
+ private RecyclerView.ViewHolder getSliceViewHolder() {
+ final View view = LayoutInflater.from(mActivity)
+ .inflate(SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH, mRecyclerView, false);
+ final RecyclerView.ViewHolder viewHolder = spy(new SliceViewHolder(view));
+ doReturn(SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH).when(
+ viewHolder).getItemViewType();
+
+ return viewHolder;
+ }
+
+ private RecyclerView.ViewHolder getConditionalViewHolder() {
+ final View view = LayoutInflater.from(mActivity)
+ .inflate(ConditionContextualCardRenderer.VIEW_TYPE_FULL_WIDTH, mRecyclerView,
+ false);
+ final RecyclerView.ViewHolder viewHolder = spy(new ConditionalCardHolder(view));
+ doReturn(ConditionContextualCardRenderer.VIEW_TYPE_FULL_WIDTH).when(
+ viewHolder).getItemViewType();
+
+ return viewHolder;
+ }
+
+ private RecyclerView.ViewHolder getDeferredSetupViewHolder() {
+ final View view = LayoutInflater.from(mActivity)
+ .inflate(VIEW_TYPE_DEFERRED_SETUP, mRecyclerView, false);
+ final RecyclerView.ViewHolder viewHolder = spy(new DeferredSetupCardViewHolder(view));
+ doReturn(VIEW_TYPE_DEFERRED_SETUP).when(viewHolder).getItemViewType();
+
+ return viewHolder;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
index ab3f4de..b39f77e 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
@@ -17,32 +17,27 @@
package com.android.settings.media;
-import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
-
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothManager;
import android.content.Context;
-import android.content.Intent;
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.shadow.ShadowBluetoothAdapter;
-import com.android.settingslib.media.LocalMediaManager;
-import com.android.settingslib.media.MediaDevice;
-import com.android.settingslib.media.MediaOutputSliceConstants;
+import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
+import com.android.settingslib.bluetooth.A2dpProfile;
+import com.android.settingslib.bluetooth.HearingAidProfile;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import org.junit.Before;
import org.junit.Test;
@@ -52,58 +47,108 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowBluetoothAdapter.class})
+@Config(shadows = {ShadowBluetoothUtils.class})
public class MediaOutputIndicatorSliceTest {
- private static final String TEST_DEVICE_NAME = "test_device_name";
- private static final int TEST_DEVICE_1_ICON =
- com.android.internal.R.drawable.ic_bt_headphones_a2dp;
+ private static final String TEST_A2DP_DEVICE_NAME = "Test_A2DP_BT_Device_NAME";
+ private static final String TEST_HAP_DEVICE_NAME = "Test_HAP_BT_Device_NAME";
+ private static final String TEST_A2DP_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
+ private static final String TEST_HAP_DEVICE_ADDRESS = "00:B2:B2:B2:B2:B2";
@Mock
- private LocalMediaManager mLocalMediaManager;
+ private A2dpProfile mA2dpProfile;
+ @Mock
+ private HearingAidProfile mHearingAidProfile;
+ @Mock
+ private LocalBluetoothManager mLocalBluetoothManager;
+ @Mock
+ private LocalBluetoothProfileManager mLocalBluetoothProfileManager;
- private final List<MediaDevice> mDevices = new ArrayList<>();
-
+ private BluetoothAdapter mBluetoothAdapter;
+ private BluetoothDevice mA2dpDevice;
+ private BluetoothDevice mHapDevice;
+ private BluetoothManager mBluetoothManager;
private Context mContext;
+ private List<BluetoothDevice> mDevicesList;
private MediaOutputIndicatorSlice mMediaOutputIndicatorSlice;
- private MediaOutputIndicatorWorker mMediaOutputIndicatorWorker;
- private ShadowBluetoothAdapter mShadowBluetoothAdapter;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
-
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ // Setup Bluetooth environment
+ ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
+ mBluetoothManager = new BluetoothManager(mContext);
+ mBluetoothAdapter = mBluetoothManager.getAdapter();
+ when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+ when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
+ when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
+
+ // Setup A2dp device
+ mA2dpDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_A2DP_DEVICE_ADDRESS));
+ when(mA2dpDevice.getName()).thenReturn(TEST_A2DP_DEVICE_NAME);
+ when(mA2dpDevice.isConnected()).thenReturn(true);
+ // Setup HearingAid device
+ mHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_HAP_DEVICE_ADDRESS));
+ when(mHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME);
+ when(mHapDevice.isConnected()).thenReturn(true);
+
mMediaOutputIndicatorSlice = new MediaOutputIndicatorSlice(mContext);
- mMediaOutputIndicatorWorker = spy(new MediaOutputIndicatorWorker(
- mContext, MEDIA_OUTPUT_INDICATOR_SLICE_URI));
- mMediaOutputIndicatorSlice.mWorker = mMediaOutputIndicatorWorker;
+ mDevicesList = new ArrayList<>();
}
@Test
- public void getSlice_invisible_returnNull() {
- when(mMediaOutputIndicatorWorker.isVisible()).thenReturn(false);
+ public void getSlice_noConnectableDevice_returnNull() {
+ mDevicesList.clear();
+ when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
assertThat(mMediaOutputIndicatorSlice.getSlice()).isNull();
}
@Test
- public void getSlice_withActiveDevice_checkContent() {
- when(mMediaOutputIndicatorWorker.isVisible()).thenReturn(true);
- when(mMediaOutputIndicatorWorker.findActiveDeviceName()).thenReturn(TEST_DEVICE_NAME);
+ public void getSlice_noActiveDevice_verifyDefaultName() {
+ mDevicesList.add(mA2dpDevice);
+ when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
+ when(mA2dpProfile.getActiveDevice()).thenReturn(null);
+
+ // Verify slice title and subtitle
final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
- // Verify slice title and subtitle
assertThat(metadata.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
- assertThat(metadata.getSubtitle()).isEqualTo(TEST_DEVICE_NAME);
+ assertThat(metadata.getSubtitle()).isEqualTo(mContext.getText(
+ R.string.media_output_default_summary));
+ }
+
+ @Test
+ public void getSlice_A2dpDeviceActive_verifyName() {
+ mDevicesList.add(mA2dpDevice);
+ when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
+ when(mA2dpProfile.getActiveDevice()).thenReturn(mA2dpDevice);
+
+ final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
+ final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
+ assertThat(metadata.getSubtitle()).isEqualTo(TEST_A2DP_DEVICE_NAME);
+ }
+
+ @Test
+ public void getSlice_HADeviceActive_verifyName() {
+ mDevicesList.add(mHapDevice);
+ when(mHearingAidProfile.getConnectableDevices()).thenReturn(mDevicesList);
+ when(mHearingAidProfile.getActiveDevices()).thenReturn(mDevicesList);
+
+ // Verify slice title and subtitle
+ final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
+ final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
+ assertThat(metadata.getSubtitle()).isEqualTo(TEST_HAP_DEVICE_NAME);
}
}
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
index 4a5662e..3671d81 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
@@ -16,25 +16,16 @@
package com.android.settings.media;
-import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.net.Uri;
-import com.android.settings.R;
-import com.android.settings.bluetooth.Utils;
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
-import com.android.settingslib.bluetooth.A2dpProfile;
import com.android.settingslib.bluetooth.BluetoothEventManager;
-import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import org.junit.Before;
import org.junit.Test;
@@ -44,118 +35,38 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowBluetoothDevice;
-
-import java.util.ArrayList;
-import java.util.List;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowBluetoothUtils.class,
- ShadowBluetoothDevice.class})
+@Config(shadows = {ShadowBluetoothUtils.class})
public class MediaOutputIndicatorWorkerTest {
-
- private static final String TEST_A2DP_DEVICE_NAME = "Test_A2DP_BT_Device_NAME";
- private static final String TEST_HAP_DEVICE_NAME = "Test_HAP_BT_Device_NAME";
- private static final String TEST_A2DP_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
- private static final String TEST_HAP_DEVICE_ADDRESS = "00:B2:B2:B2:B2:B2";
private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
@Mock
- private A2dpProfile mA2dpProfile;
- @Mock
- private HearingAidProfile mHearingAidProfile;
- @Mock
- private LocalBluetoothManager mLocalManager;
- @Mock
private BluetoothEventManager mBluetoothEventManager;
@Mock
- private LocalBluetoothProfileManager mLocalBluetoothProfileManager;
-
- private BluetoothAdapter mBluetoothAdapter;
- private BluetoothDevice mA2dpDevice;
- private BluetoothDevice mHapDevice;
- private BluetoothManager mBluetoothManager;
- private Context mContext;
- private List<BluetoothDevice> mDevicesList;
private LocalBluetoothManager mLocalBluetoothManager;
+ private Context mContext;
private MediaOutputIndicatorWorker mMediaDeviceUpdateWorker;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
- mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
+ ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
- when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
- when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
- when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
- mBluetoothManager = new BluetoothManager(mContext);
- mBluetoothAdapter = mBluetoothManager.getAdapter();
-
- // Setup A2dp device
- mA2dpDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_A2DP_DEVICE_ADDRESS));
- when(mA2dpDevice.getName()).thenReturn(TEST_A2DP_DEVICE_NAME);
- when(mA2dpDevice.isConnected()).thenReturn(true);
- // Setup HearingAid device
- mHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_HAP_DEVICE_ADDRESS));
- when(mHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME);
- when(mHapDevice.isConnected()).thenReturn(true);
-
mMediaDeviceUpdateWorker = new MediaOutputIndicatorWorker(mContext, URI);
- mDevicesList = new ArrayList<>();
}
@Test
- public void isVisible_noConnectableDevice_returnFalse() {
- mDevicesList.clear();
- when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
-
- assertThat(mMediaDeviceUpdateWorker.isVisible()).isFalse();
+ public void onSlicePinned_registerCallback() {
+ mMediaDeviceUpdateWorker.onSlicePinned();
+ verify(mBluetoothEventManager).registerCallback(mMediaDeviceUpdateWorker);
}
@Test
- public void isVisible_withConnectableA2dpDevice_returnTrue() {
- mDevicesList.clear();
- mDevicesList.add(mA2dpDevice);
- when(mHearingAidProfile.getConnectableDevices()).thenReturn(mDevicesList);
-
- assertThat(mMediaDeviceUpdateWorker.isVisible()).isTrue();
- }
-
- @Test
- public void isVisible_withConnectableHADevice_returnTrue() {
- mDevicesList.clear();
- mDevicesList.add(mHapDevice);
- when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
-
- assertThat(mMediaDeviceUpdateWorker.isVisible()).isTrue();
- }
-
- @Test
- public void findActiveDeviceName_A2dpDeviceActive_verifyName() {
- when(mA2dpProfile.getActiveDevice()).thenReturn(mA2dpDevice);
-
- assertThat(mMediaDeviceUpdateWorker.findActiveDeviceName())
- .isEqualTo(mA2dpDevice.getAliasName());
- }
-
- @Test
- public void findActiveDeviceName_HADeviceActive_verifyName() {
- mDevicesList.add(mHapDevice);
- when(mHearingAidProfile.getActiveDevices()).thenReturn(mDevicesList);
-
- assertThat(mMediaDeviceUpdateWorker.findActiveDeviceName())
- .isEqualTo(mHapDevice.getAliasName());
- }
-
- @Test
- public void findActiveDeviceName_noActiveDevice_verifyDefaultName() {
- when(mA2dpProfile.getActiveDevice()).thenReturn(null);
- mDevicesList.clear();
- when(mHearingAidProfile.getActiveDevices()).thenReturn(mDevicesList);
-
- assertThat(mMediaDeviceUpdateWorker.findActiveDeviceName())
- .isEqualTo(mContext.getText(R.string.media_output_default_summary));
+ public void onSliceUnpinned_unRegisterCallback() {
+ mMediaDeviceUpdateWorker.onSlicePinned();
+ mMediaDeviceUpdateWorker.onSliceUnpinned();
+ verify(mBluetoothEventManager).unregisterCallback(mMediaDeviceUpdateWorker);
}
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
index 78ed4b5..9957cde 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
@@ -102,13 +102,27 @@
}
@Test
- public void updateState_variant4gLte_useVariantTitle() {
- mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 1);
-
+ public void updateState_variant4gLte_useVariantTitleAndSummary() {
+ mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 0);
mController.updateState(mPreference);
-
assertThat(mPreference.getTitle()).isEqualTo(
- mContext.getString(R.string.enhanced_4g_lte_mode_title_variant));
+ mContext.getString(R.string.enhanced_4g_lte_mode_title));
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_summary));
+
+ mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 1);
+ mController.updateState(mPreference);
+ assertThat(mPreference.getTitle()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_title_advanced_calling));
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_summary));
+
+ mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 2);
+ mController.updateState(mPreference);
+ assertThat(mPreference.getTitle()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_title_4g_calling));
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.enhanced_4g_lte_mode_summary_4g_calling));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index c0b1dab..9eb62f6 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -18,11 +18,14 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -32,6 +35,7 @@
import com.android.ims.ImsConfig;
import com.android.ims.ImsManager;
+import com.android.internal.R;
import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
@@ -47,6 +51,8 @@
private static final int SUB_ID = 2;
@Mock
+ private CarrierConfigManager mCarrierConfigManager;
+ @Mock
private TelephonyManager mTelephonyManager;
@Mock
private ImsManager mImsManager;
@@ -57,6 +63,7 @@
private Preference mPreference;
private PreferenceCategory mPreferenceCategory;
private Context mContext;
+ private PersistableBundle mCarrierConfig;
@Before
public void setUp() {
@@ -69,10 +76,14 @@
mPreference = new Preference(mContext);
mController = new WifiCallingPreferenceController(mContext, "wifi_calling");
+ mController.mCarrierConfigManager = mCarrierConfigManager;
mController.init(SUB_ID);
mController.mImsManager = mImsManager;
mPreference.setKey(mController.getPreferenceKey());
+ mCarrierConfig = new PersistableBundle();
+ when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(mCarrierConfig);
+
mPreferenceCategory = new PreferenceCategory(mContext);
when(mPreferenceScreen.findPreference(
WifiCallingPreferenceController.KEY_PREFERENCE_CATEGORY)).thenReturn(
@@ -103,6 +114,42 @@
}
@Test
+ public void updateState_wfcNonRoaming() {
+ assertNull(mController.mSimCallManager);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, false);
+ // update the config value by calling init again.
+ mController.init(SUB_ID);
+ mController.mImsManager = mImsManager;
+
+ when(mImsManager.getWfcMode(true)).thenReturn(
+ ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
+ when(mImsManager.getWfcMode(false)).thenReturn(
+ ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED);
+ when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
+ when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
+
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary())
+ .isEqualTo(mContext.getString(R.string.wfc_mode_cellular_preferred_summary));
+ }
+
+ @Test
+ public void updateState_wfcRoaming() {
+ assertNull(mController.mSimCallManager);
+
+ when(mImsManager.getWfcMode(true)).thenReturn(
+ ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
+ when(mImsManager.getWfcMode(false)).thenReturn(
+ ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED);
+ when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
+ when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
+
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary())
+ .isEqualTo(mContext.getString(R.string.wfc_mode_wifi_preferred_summary));
+ }
+
+ @Test
public void displayPreference_notAvailable_setCategoryInvisible() {
mController.init(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
diff --git a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
deleted file mode 100644
index 9555a56..0000000
--- a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.android.settings.notification;
-
-import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-
-import static org.junit.Assert.assertEquals;
-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.view.Window;
-import android.view.WindowManager;
-
-import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentManager;
-
-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.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-
-@RunWith(RobolectricTestRunner.class)
-public class AppNotificationSettingsTest {
-
- private WindowManager.LayoutParams mLayoutParams;
- private AppNotificationSettings mFragment;
- private FragmentActivity mActivity;
- @Mock
- private Window mWindow;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mLayoutParams = new WindowManager.LayoutParams();
- mActivity = spy(Robolectric.setupActivity(FragmentActivity.class));
- mFragment = spy(new AppNotificationSettings());
- when(mFragment.getActivity()).thenReturn(mActivity);
- when(mFragment.getFragmentManager()).thenReturn(mock(FragmentManager.class));
- when(mActivity.getWindow()).thenReturn(mWindow);
- when(mWindow.getAttributes()).thenReturn(mLayoutParams);
- }
-
- @Test
- @Config(shadows = {ShadowNotificationSettingsBase.class})
- public void onResume_shouldHideSystemOverlay() {
- mFragment.onResume();
-
- verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- }
-
- @Test
- @Config(shadows = {ShadowNotificationSettingsBase.class})
- public void onPause_shouldRemoveHideSystemOverlay() {
- mFragment.onResume();
-
- verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
-
- mFragment.onPause();
-
- // There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
- ArgumentCaptor<WindowManager.LayoutParams> paramCaptor = ArgumentCaptor.forClass(
- WindowManager.LayoutParams.class);
- verify(mWindow).setAttributes(paramCaptor.capture());
- assertEquals(0,
- paramCaptor.getValue().privateFlags
- & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- }
-
- @Implements(NotificationSettingsBase.class)
- public static class ShadowNotificationSettingsBase {
-
- protected void __constructor__() {
- // Do nothing
- }
-
- @Implementation
- protected void onResume() {
- // No-op.
- }
-
- @Implementation
- protected void onPause() {
- // No-op.
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index 1b4ede5..866f866 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -39,6 +39,8 @@
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
+import android.media.AudioAttributes;
+import android.media.RingtoneManager;
import android.net.Uri;
import android.os.UserManager;
import android.provider.Settings;
@@ -54,6 +56,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
@@ -231,6 +234,69 @@
}
@Test
+ public void testOnPreferenceTreeClick_alarmSound() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ channel.setSound(null, new AudioAttributes.Builder().setUsage(
+ AudioAttributes.USAGE_ALARM).build());
+ mController.onResume(appRow, channel, null, null);
+
+ AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+ NotificationSoundPreference pref =
+ spy(new NotificationSoundPreference(mContext, attributeSet));
+ pref.setKey(mController.getPreferenceKey());
+ mController.handlePreferenceTreeClick(pref);
+
+ ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(pref, times(1)).onPrepareRingtonePickerIntent(intentArgumentCaptor.capture());
+ assertEquals(RingtoneManager.TYPE_ALARM,
+ intentArgumentCaptor.getValue().getIntExtra(
+ RingtoneManager.EXTRA_RINGTONE_TYPE, 0));
+ }
+
+ @Test
+ public void testOnPreferenceTreeClick_ringtoneSound() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ channel.setSound(null, new AudioAttributes.Builder().setUsage(
+ AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build());
+ mController.onResume(appRow, channel, null, null);
+
+ AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+ NotificationSoundPreference pref =
+ spy(new NotificationSoundPreference(mContext, attributeSet));
+ pref.setKey(mController.getPreferenceKey());
+ mController.handlePreferenceTreeClick(pref);
+
+ ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(pref, times(1)).onPrepareRingtonePickerIntent(intentArgumentCaptor.capture());
+ assertEquals(RingtoneManager.TYPE_RINGTONE,
+ intentArgumentCaptor.getValue().getIntExtra(
+ RingtoneManager.EXTRA_RINGTONE_TYPE, 0));
+ }
+
+ @Test
+ public void testOnPreferenceTreeClick_otherSound() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ channel.setSound(null, new AudioAttributes.Builder().setUsage(
+ AudioAttributes.USAGE_UNKNOWN).build());
+ mController.onResume(appRow, channel, null, null);
+
+ AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+ NotificationSoundPreference pref =
+ spy(new NotificationSoundPreference(mContext, attributeSet));
+ pref.setKey(mController.getPreferenceKey());
+ mController.handlePreferenceTreeClick(pref);
+
+ ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(pref, times(1)).onPrepareRingtonePickerIntent(intentArgumentCaptor.capture());
+ assertEquals(RingtoneManager.TYPE_NOTIFICATION,
+ intentArgumentCaptor.getValue().getIntExtra(
+ RingtoneManager.EXTRA_RINGTONE_TYPE, 0));
+ }
+
+ @Test
public void testOnActivityResult() {
NotificationSoundPreference pref = mock(NotificationSoundPreference.class);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index 3509d75..48ebbec 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -107,7 +107,7 @@
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
- View iconView = fragment.getView().findViewById(R.id.suc_layout_icon);
+ View iconView = fragment.getView().findViewById(R.id.sud_layout_icon);
assertThat(iconView.getVisibility()).isEqualTo(View.GONE);
}
diff --git a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
index 332156e..9888168 100644
--- a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
@@ -16,6 +16,14 @@
package com.android.settings.privacy;
+import static android.Manifest.permission_group.CALENDAR;
+import static android.Manifest.permission_group.CAMERA;
+import static android.Manifest.permission_group.CONTACTS;
+import static android.Manifest.permission_group.LOCATION;
+import static android.Manifest.permission_group.MICROPHONE;
+import static android.Manifest.permission_group.PHONE;
+import static android.Manifest.permission_group.SMS;
+
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
@@ -221,4 +229,27 @@
verify(mFragment).setLoadingEnabled(false /* enabled */);
verify(mPreference).updateLoadingState(false /* isLoading */);
}
+
+ @Test
+ public void onPermissionUsageResult_shouldBeSorted() {
+ final List<RuntimePermissionUsageInfo> infos = new ArrayList<>();
+ infos.add(new RuntimePermissionUsageInfo(PHONE, 10));
+ infos.add(new RuntimePermissionUsageInfo(LOCATION, 10));
+ infos.add(new RuntimePermissionUsageInfo(CAMERA, 10));
+ infos.add(new RuntimePermissionUsageInfo(SMS, 1));
+ infos.add(new RuntimePermissionUsageInfo(MICROPHONE, 10));
+ infos.add(new RuntimePermissionUsageInfo(CONTACTS, 42));
+ infos.add(new RuntimePermissionUsageInfo(CALENDAR, 10));
+ mController.displayPreference(mScreen);
+
+ mController.onPermissionUsageResult(infos);
+
+ assertThat(infos.get(0).getName()).isEqualTo(CONTACTS);
+ assertThat(infos.get(1).getName()).isEqualTo(LOCATION);
+ assertThat(infos.get(2).getName()).isEqualTo(MICROPHONE);
+ assertThat(infos.get(3).getName()).isEqualTo(CAMERA);
+ assertThat(infos.get(4).getName()).isEqualTo(CALENDAR);
+ assertThat(infos.get(5).getName()).isEqualTo(PHONE);
+ assertThat(infos.get(6).getName()).isEqualTo(SMS);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
index 57c6e01..6340b16 100644
--- a/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
@@ -35,8 +35,6 @@
@RunWith(RobolectricTestRunner.class)
public class AppCheckBoxPreferenceTest {
- private static final String SUMMARY = "summary info";
-
private Context mContext;
private AppCheckBoxPreference mPreference;
private AppCheckBoxPreference mAttrPreference;
@@ -58,26 +56,6 @@
}
@Test
- public void onBindViewHolder_noSummary_layoutGone() {
- mPreference.setSummary("");
-
- mPreference.onBindViewHolder(mPreferenceViewHolder);
-
- assertThat(mPreferenceViewHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.GONE);
- }
-
- @Test
- public void onBindViewHolder_hasSummary_layoutVisible() {
- mPreference.setSummary(SUMMARY);
-
- mPreference.onBindViewHolder(mPreferenceViewHolder);
-
- assertThat(mPreferenceViewHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.VISIBLE);
- }
-
- @Test
public void onBindViewHolder_appendixGone() {
mPreference.onBindViewHolder(mPreferenceViewHolder);
diff --git a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
deleted file mode 100644
index aa5e3e7..0000000
--- a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.widget;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.view.View;
-
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class AppSwitchPreferenceTest {
-
- private Context mContext;
- private View mRootView;
- private AppSwitchPreference mPref;
- private PreferenceViewHolder mHolder;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
- mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
- mPref = new AppSwitchPreference(mContext);
- }
-
- @Test
- public void setSummary_showSummaryContainer() {
- mPref.setSummary("test");
- mPref.onBindViewHolder(mHolder);
-
- assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.VISIBLE);
- }
-
- @Test
- public void noSummary_hideSummaryContainer() {
- mPref.setSummary(null);
- mPref.onBindViewHolder(mHolder);
-
- assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
- .isEqualTo(View.GONE);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 4cd6be4..b53f364 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -18,6 +18,10 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -29,6 +33,8 @@
import android.view.LayoutInflater;
import android.view.TextureView;
+import android.view.View;
+import android.widget.ImageView;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
@@ -45,8 +51,13 @@
public class VideoPreferenceTest {
private static final int VIDEO_WIDTH = 100;
private static final int VIDEO_HEIGHT = 150;
+
@Mock
private MediaPlayer mMediaPlayer;
+ @Mock
+ private ImageView fakePreview;
+ @Mock
+ private ImageView fakePlayButton;
private Context mContext;
private VideoPreference mVideoPreference;
private PreferenceViewHolder mPreferenceViewHolder;
@@ -83,8 +94,8 @@
(TextureView) mPreferenceViewHolder.findViewById(R.id.video_texture_view);
mVideoPreference.mAnimationAvailable = true;
mVideoPreference.mVideoReady = true;
- mVideoPreference.onBindViewHolder(mPreferenceViewHolder);
mVideoPreference.onViewInvisible();
+ mVideoPreference.onBindViewHolder(mPreferenceViewHolder);
when(mMediaPlayer.isPlaying()).thenReturn(false);
final TextureView.SurfaceTextureListener listener = video.getSurfaceTextureListener();
@@ -101,4 +112,30 @@
verify(mMediaPlayer).release();
}
+
+ @Test
+ public void updateViewStates_paused_updatesViews() {
+ when(mMediaPlayer.isPlaying()).thenReturn(true);
+ mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
+ verify(fakePlayButton).setVisibility(eq(View.VISIBLE));
+ verify(fakePreview).setVisibility(eq(View.VISIBLE));
+ verify(mMediaPlayer).pause();
+ }
+
+ @Test
+ public void updateViewStates_playing_updatesViews() {
+ when(mMediaPlayer.isPlaying()).thenReturn(false);
+ mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
+ verify(fakePlayButton).setVisibility(eq(View.GONE));
+ verify(fakePreview).setVisibility(eq(View.GONE));
+ verify(mMediaPlayer).start();
+ }
+
+ @Test
+ public void updateViewStates_noMediaPlayer_skips() {
+ mVideoPreference.mMediaPlayer = null;
+ mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
+ verify(fakePlayButton, never()).setVisibility(anyInt());
+ verify(fakePreview, never()).setVisibility(anyInt());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
index 6c221e7..25fa737 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
@@ -35,6 +35,7 @@
import android.view.ViewGroup;
import android.widget.Button;
+import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.OnScrollListener;
@@ -60,7 +61,7 @@
public class WifiCallingDisclaimerFragmentTest {
@Mock
- private Activity mActivity;
+ private FragmentActivity mActivity;
@Mock
private DisclaimerItem mDisclaimerItem;
@Mock
@@ -89,7 +90,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- mActivity = Robolectric.setupActivity(Activity.class);
+ mActivity = Robolectric.setupActivity(FragmentActivity.class);
mFragment = spy(new WifiCallingDisclaimerFragment());
doReturn(mActivity).when(mFragment).getActivity();
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 574d0d6..f177b5e 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -53,6 +53,7 @@
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.provider.Settings;
+import android.util.FeatureFlagUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
@@ -104,6 +105,7 @@
private static final int RSSI = -55;
private static final int TX_LINK_SPEED = 123;
private static final int RX_LINK_SPEED = 54;
+ private static final String SSID = "ssid";
private static final String MAC_ADDRESS = WifiInfo.DEFAULT_MAC_ADDRESS;
private static final String SECURITY = "None";
@@ -153,6 +155,8 @@
@Mock
private Preference mockSecurityPref;
@Mock
+ private Preference mockSsidPref;
+ @Mock
private Preference mockMacAddressPref;
@Mock
private Preference mockIpAddressPref;
@@ -244,6 +248,7 @@
when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
when(mockAccessPoint.getLevel()).thenReturn(LEVEL);
when(mockAccessPoint.getSecurityString(false)).thenReturn(SECURITY);
+ when(mockAccessPoint.getSsidStr()).thenReturn(SSID);
when(mockConnectivityManager.getNetworkInfo(any(Network.class)))
.thenReturn(mockNetworkInfo);
doNothing().when(mockConnectivityManager).registerNetworkCallback(
@@ -272,6 +277,11 @@
when(mockIconInjector.getIcon(anyInt())).thenReturn(new ColorDrawable());
setupMockedPreferenceScreen();
+
+ // Disable saved network detail page feature for this test
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.WIFI_DETAILS_SAVED_SCREEN, false);
+ when(mockAccessPoint.isActive()).thenReturn(true);
+
mController = newWifiDetailPreferenceController();
}
@@ -308,6 +318,8 @@
.thenReturn(mockFrequencyPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SECURITY_PREF))
.thenReturn(mockSecurityPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SSID_PREF))
+ .thenReturn(mockSsidPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_MAC_ADDRESS_PREF))
.thenReturn(mockMacAddressPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_IP_ADDRESS_PREF))
@@ -457,6 +469,50 @@
}
@Test
+ public void ssidPref_shouldHaveDetailTextSet() {
+ when(mockAccessPoint.isPasspoint()).thenReturn(true);
+ when(mockAccessPoint.isOsuProvider()).thenReturn(false);
+
+ displayAndResume();
+
+ verify(mockSsidPref, times(1)).setSummary(SSID);
+
+ when(mockAccessPoint.isPasspoint()).thenReturn(false);
+ when(mockAccessPoint.isOsuProvider()).thenReturn(true);
+
+ displayAndResume();
+
+ verify(mockSsidPref, times(2)).setSummary(SSID);
+ }
+
+ @Test
+ public void ssidPref_shouldShowIfPasspointOrOsu() {
+ when(mockAccessPoint.isPasspoint()).thenReturn(true);
+ when(mockAccessPoint.isOsuProvider()).thenReturn(false);
+
+ displayAndResume();
+
+ verify(mockSsidPref, times(1)).setVisible(true);
+
+ when(mockAccessPoint.isPasspoint()).thenReturn(false);
+ when(mockAccessPoint.isOsuProvider()).thenReturn(true);
+
+ displayAndResume();
+
+ verify(mockSsidPref, times(2)).setVisible(true);
+ }
+
+ @Test
+ public void ssidPref_shouldNotShowIfNotPasspoint() {
+ when(mockAccessPoint.isPasspoint()).thenReturn(false);
+ when(mockAccessPoint.isOsuProvider()).thenReturn(false);
+
+ displayAndResume();
+
+ verify(mockSsidPref).setVisible(false);
+ }
+
+ @Test
public void macAddressPref_shouldHaveDetailTextSet() {
displayAndResume();
@@ -946,6 +1002,12 @@
when(pref.setButton3Visible(anyBoolean())).thenReturn(pref);
when(pref.setButton3OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
+ when(pref.setButton4Text(anyInt())).thenReturn(pref);
+ when(pref.setButton4Icon(anyInt())).thenReturn(pref);
+ when(pref.setButton4Enabled(anyBoolean())).thenReturn(pref);
+ when(pref.setButton4Visible(anyBoolean())).thenReturn(pref);
+ when(pref.setButton4OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
+
return pref;
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
index a1af8bf..2e588b5 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
@@ -109,4 +109,20 @@
assertThat(mDropDownPreference.isSelectable()).isFalse();
}
+
+ @Test
+ public void testUpdateState_isNotPasspointNetwork_shouldBeSelectable() {
+ mPreferenceController.setIsPasspoint(false);
+ mPreferenceController.updateState(mDropDownPreference);
+
+ assertThat(mDropDownPreference.isSelectable()).isTrue();
+ }
+
+ @Test
+ public void testUpdateState_isPasspointNetwork_shouldNotSelectable() {
+ mPreferenceController.setIsPasspoint(true);
+ mPreferenceController.updateState(mDropDownPreference);
+
+ assertThat(mDropDownPreference.isSelectable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 75a9e11..e9f35d8 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -139,7 +139,7 @@
private AccessPoint createAccessPoint(String name, boolean active, boolean reachable) {
final AccessPoint accessPoint = mock(AccessPoint.class);
- doReturn(name).when(accessPoint).getConfigName();
+ doReturn(name).when(accessPoint).getTitle();
doReturn(active).when(accessPoint).isActive();
doReturn(reachable).when(accessPoint).isReachable();
if (active) {