Merge "Ignore the outdated entitlement check" into qt-dev
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 02b00e2..e0a0206 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -3357,4 +3357,20 @@
column="5"/>
</issue>
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" android:color="@color/notification_importance_button_unselected""
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/button_border_unselected.xml"
+ line="21"
+ column="10"/>
+ </issue>
+
</issues>
diff --git a/res/anim/enrollment_fingerprint_background_2_path_animation.xml b/res/anim/enrollment_fingerprint_background_2_path_animation.xml
index b24e1dd..aed30c0 100644
--- a/res/anim/enrollment_fingerprint_background_2_path_animation.xml
+++ b/res/anim/enrollment_fingerprint_background_2_path_animation.xml
@@ -22,7 +22,7 @@
android:duration="300"
android:propertyName="fillColor"
android:valueFrom="#000000"
- android:valueTo="#EA4335"
+ android:valueTo="#4285F4"
android:valueType="intType"
android:interpolator="@android:interpolator/linear_out_slow_in" />
<objectAnimator
@@ -37,7 +37,7 @@
<objectAnimator
android:duration="300"
android:propertyName="fillColor"
- android:valueFrom="#EA4335"
+ android:valueFrom="#4285F4"
android:valueTo="#000000"
android:valueType="intType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
diff --git a/res/anim/enrollment_fingerprint_background_6_path_animation.xml b/res/anim/enrollment_fingerprint_background_6_path_animation.xml
index 5748f77..aed30c0 100644
--- a/res/anim/enrollment_fingerprint_background_6_path_animation.xml
+++ b/res/anim/enrollment_fingerprint_background_6_path_animation.xml
@@ -22,7 +22,7 @@
android:duration="300"
android:propertyName="fillColor"
android:valueFrom="#000000"
- android:valueTo="#FBBC04"
+ android:valueTo="#4285F4"
android:valueType="intType"
android:interpolator="@android:interpolator/linear_out_slow_in" />
<objectAnimator
@@ -37,7 +37,7 @@
<objectAnimator
android:duration="300"
android:propertyName="fillColor"
- android:valueFrom="#FBBC04"
+ android:valueFrom="#4285F4"
android:valueTo="#000000"
android:valueType="intType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
diff --git a/res/anim/enrollment_fingerprint_background_7_path_animation.xml b/res/anim/enrollment_fingerprint_background_7_path_animation.xml
index c458d32..aed30c0 100644
--- a/res/anim/enrollment_fingerprint_background_7_path_animation.xml
+++ b/res/anim/enrollment_fingerprint_background_7_path_animation.xml
@@ -22,7 +22,7 @@
android:duration="300"
android:propertyName="fillColor"
android:valueFrom="#000000"
- android:valueTo="#34A853"
+ android:valueTo="#4285F4"
android:valueType="intType"
android:interpolator="@android:interpolator/linear_out_slow_in" />
<objectAnimator
@@ -37,7 +37,7 @@
<objectAnimator
android:duration="300"
android:propertyName="fillColor"
- android:valueFrom="#34A853"
+ android:valueFrom="#4285F4"
android:valueTo="#000000"
android:valueType="intType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
diff --git a/res/drawable-nodpi/adaptive_sleep b/res/drawable-nodpi/adaptive_sleep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/drawable-nodpi/adaptive_sleep
diff --git a/res/drawable/button_border_selected.xml b/res/drawable/button_border_selected.xml
new file mode 100644
index 0000000..2681bf0
--- /dev/null
+++ b/res/drawable/button_border_selected.xml
@@ -0,0 +1,23 @@
+<?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.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <stroke
+ android:width="2dp"
+ android:color="?android:attr/colorAccent"/>
+ <corners android:radius="@dimen/rect_button_radius" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/button_border_unselected.xml b/res/drawable/button_border_unselected.xml
new file mode 100644
index 0000000..72e9076
--- /dev/null
+++ b/res/drawable/button_border_unselected.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.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <stroke
+ android:width="2dp"
+ android:color="@color/notification_importance_button_unselected"/>
+
+ <corners android:radius="@dimen/rect_button_radius" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/button_ripple_radius.xml b/res/drawable/button_ripple_radius.xml
new file mode 100644
index 0000000..511520c
--- /dev/null
+++ b/res/drawable/button_ripple_radius.xml
@@ -0,0 +1,26 @@
+<?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.
+ -->
+<ripple
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+ <corners android:radius="@dimen/rect_button_radius" />
+ </shape>
+ </item>
+</ripple>
\ No newline at end of file
diff --git a/res/drawable/enrollment_fingerprint_isolated.xml b/res/drawable/enrollment_fingerprint_isolated.xml
index 26451de..960552f 100644
--- a/res/drawable/enrollment_fingerprint_isolated.xml
+++ b/res/drawable/enrollment_fingerprint_isolated.xml
@@ -30,7 +30,7 @@
<path
android:name="ridge_5_path"
android:pathData="M 24.9488677979,32.3508300781 c -1.81059265137,0.338500976562 -3.58520507812,0.447387695312 -4.62879943848,0.447387695312 c -4.12730407715,0.0 -8.05894470215,-0.96842956543 -11.5207061768,-3.45275878906 c -5.33699035645,-3.830078125 -8.56369018555,-10.0885009766 -8.56369018555,-17.1589355469"
- android:strokeColor="#4DEA4335"
+ android:strokeColor="#4D4285F4"
android:strokeWidth="5"
android:strokeLineCap="round"
android:trimPathEnd="0" />
@@ -40,7 +40,7 @@
<path
android:name="ridge_7_path"
android:pathData="M -9.23379516602,40.8356933594 c -3.24549865723,-3.46032714844 -5.1540222168,-5.77195739746 -7.87710571289,-10.9068603516 c -2.76379394531,-5.21166992188 -4.04838562012,-11.3482666016 -4.04838562012,-17.6915283203 c 0.0,-11.6563720703 9.44940185547,-21.1059570312 21.1058959961,-21.1059570312 c 11.6564941406,0.0 21.1058959961,9.44958496094 21.1058959961,21.1059570312"
- android:strokeColor="#4DFBBC04"
+ android:strokeColor="#4D4285F4"
android:strokeWidth="5"
android:strokeLineCap="round"
android:trimPathEnd="0" />
@@ -60,7 +60,7 @@
<path
android:name="ridge_2_path"
android:pathData="M -34.4861907959,-11.6943359375 c 3.78790283203,-5.64636230469 8.36389160156,-9.94665527344 14.3594970703,-13.2164306641 c 5.99560546875,-3.26977539062 12.8716125488,-5.1279296875 20.1817016602,-5.1279296875 c 7.27980041504,0.0 14.129196167,1.84289550781 20.1071014404,5.08740234375 c 5.97790527344,3.24450683594 10.7957000732,7.759765625 14.5897064209,13.3666992188"
- android:strokeColor="#4D34A853"
+ android:strokeColor="#4D4285F4"
android:strokeWidth="5"
android:strokeLineCap="round"
android:trimPathStart="1" />
diff --git a/res/drawable/fingerprint_enroll_finish.xml b/res/drawable/fingerprint_enroll_finish.xml
index 9bc7283..925e6bc 100644
--- a/res/drawable/fingerprint_enroll_finish.xml
+++ b/res/drawable/fingerprint_enroll_finish.xml
@@ -74,16 +74,16 @@
android:pathData="M73.98,154.31c-1.52,0.58 -3.21,-0.23 -3.73,-1.69c0.6,1.81 2.09,3.08 3.73,2.69c1.52,-0.53 2.85,-1.63 1.81,-4.34c-0.02,-0.04 -0.03,-0.09 -0.05,-0.13C76.15,152.28 75.41,153.81 73.98,154.31z"
android:strokeAlpha="0.25" />
<path
- android:fillColor="#F9BB00"
+ android:fillColor="#4285F4"
android:pathData="M147.89,70.07c-0.47,0 -0.93,-0.12 -1.34,-0.35c-11.2,-5.78 -20.88,-8.23 -32.49,-8.23c-11.55,0 -22.52,2.74 -32.49,8.23c-1.4,0.76 -3.15,0.23 -3.97,-1.17c-0.76,-1.4 -0.23,-3.21 1.17,-3.97c10.85,-5.89 22.75,-8.93 35.29,-8.93c12.43,0 23.27,2.74 35.18,8.87c1.46,0.76 1.98,2.51 1.22,3.91C149.93,69.49 148.94,70.07 147.89,70.07z" />
<path
- android:fillColor="#E74133"
+ android:fillColor="#4285F4"
android:pathData="M64.42,100.7c-0.58,0 -1.17,-0.17 -1.69,-0.53c-1.34,-0.93 -1.63,-2.74 -0.7,-4.08c5.78,-8.17 13.12,-14.58 21.88,-19.08c18.32,-9.45 41.77,-9.51 60.14,-0.06c8.75,4.49 16.1,10.85 21.88,18.96c0.93,1.28 0.64,3.15 -0.7,4.08s-3.15,0.64 -4.08,-0.7c-5.25,-7.35 -11.9,-13.12 -19.77,-17.15c-16.74,-8.57 -38.15,-8.57 -54.83,0.06c-7.93,4.08 -14.58,9.92 -19.83,17.27C66.22,100.29 65.35,100.7 64.42,100.7z" />
<path
- android:fillColor="#32A753"
+ android:fillColor="#4285F4"
android:pathData="M100.87,171.11c-0.76,0 -1.52,-0.29 -2.04,-0.88c-5.08,-5.07 -7.82,-8.34 -11.72,-15.4c-4.03,-7.17 -6.12,-15.92 -6.12,-25.32c0,-17.32 14.82,-31.44 33.02,-31.44s33.02,14.12 33.02,31.44c0,1.63 -1.28,2.92 -2.92,2.92c-1.63,0 -2.92,-1.28 -2.92,-2.92c0,-14.12 -12.19,-25.61 -27.18,-25.61s-27.18,11.49 -27.18,25.61c0,8.4 1.87,16.16 5.43,22.46c3.73,6.71 6.3,9.57 10.79,14.12c1.11,1.17 1.11,2.98 0,4.14C102.39,170.82 101.63,171.11 100.87,171.11z" />
<path
- android:fillColor="#F9BB00"
+ android:fillColor="#4285F4"
android:pathData="M142.7,160.32c-6.94,0 -13.07,-1.75 -18.08,-5.19c-8.69,-5.89 -13.88,-15.46 -13.88,-25.61c0,-1.63 1.28,-2.92 2.92,-2.92s2.92,1.28 2.92,2.92c0,8.22 4.2,15.98 11.32,20.77c4.14,2.8 8.98,4.14 14.82,4.14c1.4,0 3.73,-0.18 6.07,-0.58c1.57,-0.29 3.09,0.76 3.38,2.39c0.29,1.58 -0.76,3.09 -2.39,3.38C146.43,160.26 143.52,160.32 142.7,160.32z" />
<path
android:fillColor="#4285F4"
diff --git a/res/drawable/fingerprint_enroll_introduction.xml b/res/drawable/fingerprint_enroll_introduction.xml
index 2a5c62a..9781c54 100644
--- a/res/drawable/fingerprint_enroll_introduction.xml
+++ b/res/drawable/fingerprint_enroll_introduction.xml
@@ -24,25 +24,25 @@
android:fillColor="#34A853"
android:pathData="M73.79,58.17h-7V38.96c0,-15.39 9.16,-29.21 23.34,-35.21l2.73,6.45c-11.58,4.9 -19.06,16.19 -19.06,28.76V58.17z" />
<path
- android:fillColor="#FBBC05"
+ android:fillColor="#34A853"
android:pathData="M131.29,22.13C125.51,13.12 115.68,7.75 105,7.75c-4.21,0 -8.3,0.82 -12.15,2.45l-2.73,-6.45c4.71,-1.99 9.72,-3 14.87,-3c13.08,0 25.11,6.58 32.18,17.6L131.29,22.13z" />
<path
- android:fillColor="#EA4335"
+ android:fillColor="#34A853"
android:pathData="M143.21,62.11h-7V38.96c0,-5.99 -1.7,-11.81 -4.92,-16.83l5.89,-3.78c3.94,6.15 6.03,13.27 6.03,20.6V62.11z" />
<path
- android:fillColor="#3E82F1"
+ android:fillColor="#34A853"
android:pathData="M136.21,62.11h7v19.4h-7z" />
<path
- android:fillColor="#FBBC05"
+ android:fillColor="#3E82F1"
android:pathData="M125.03,118.78c-0.28,0 -0.55,-0.07 -0.79,-0.2c-6.61,-3.37 -12.33,-4.79 -19.19,-4.79c-6.82,0 -13.3,1.6 -19.19,4.79c-0.83,0.44 -1.86,0.14 -2.34,-0.68c-0.45,-0.82 -0.14,-1.87 0.69,-2.31c6.41,-3.43 13.44,-5.2 20.84,-5.2c7.34,0 13.75,1.6 20.77,5.17c0.86,0.44 1.17,1.46 0.72,2.28C126.24,118.44 125.65,118.78 125.03,118.78z" />
<path
- android:fillColor="#E74133"
+ android:fillColor="#3E82F1"
android:pathData="M75.73,136.63c-0.34,0 -0.69,-0.1 -1,-0.31c-0.79,-0.54 -0.96,-1.6 -0.41,-2.38c3.41,-4.76 7.75,-8.5 12.92,-11.12c10.82,-5.51 24.67,-5.54 35.52,-0.03c5.17,2.62 9.51,6.32 12.92,11.05c0.55,0.75 0.38,1.84 -0.41,2.38c-0.79,0.54 -1.86,0.37 -2.41,-0.41c-3.1,-4.28 -7.03,-7.65 -11.68,-10c-9.89,-5 -22.53,-5 -32.38,0.03c-4.69,2.38 -8.61,5.78 -11.71,10.06C76.8,136.39 76.28,136.63 75.73,136.63z" />
<path
- android:fillColor="#32A753"
+ android:fillColor="#3E82F1"
android:pathData="M97.27,177.67c-0.45,0 -0.9,-0.17 -1.21,-0.51c-3,-2.96 -4.62,-4.86 -6.92,-8.98c-2.38,-4.18 -3.62,-9.28 -3.62,-14.76c0,-10.1 8.75,-18.33 19.5,-18.33s19.5,8.23 19.5,18.33c0,0.95 -0.76,1.7 -1.72,1.7s-1.72,-0.75 -1.72,-1.7c0,-8.23 -7.2,-14.93 -16.05,-14.93s-16.05,6.7 -16.05,14.93c0,4.9 1.1,9.42 3.2,13.09c2.2,3.91 3.72,5.58 6.37,8.23c0.65,0.68 0.65,1.73 0,2.41C98.16,177.5 97.71,177.67 97.27,177.67z" />
<path
- android:fillColor="#FBBC05"
+ android:fillColor="#3E82F1"
android:pathData="M121.97,171.38c-4.1,0 -7.72,-1.02 -10.68,-3.03c-5.13,-3.43 -8.2,-9.01 -8.2,-14.93c0,-0.95 0.76,-1.7 1.72,-1.7s1.72,0.75 1.72,1.7c0,4.79 2.48,9.32 6.68,12.1c2.45,1.63 5.31,2.41 8.75,2.41c0.83,0 2.2,-0.1 3.58,-0.34c0.93,-0.17 1.83,0.44 2,1.39c0.17,0.92 -0.45,1.8 -1.41,1.97C124.17,171.34 122.45,171.38 121.97,171.38z" />
<path
android:fillColor="#3E82F1"
diff --git a/res/drawable/ic_notification_alert.xml b/res/drawable/ic_notification_alert.xml
index 07e7b48..927f7cc 100644
--- a/res/drawable/ic_notification_alert.xml
+++ b/res/drawable/ic_notification_alert.xml
@@ -19,25 +19,23 @@
android:id="@+id/back">
<shape android:shape="oval">
<solid
- android:color="@android:color/transparent" />
+ android:color="@color/notification_alert_color" />
<size
- android:height="48dp"
- android:width="48dp"/>
- <stroke android:width="1dp"
- android:color="@color/notification_alert_color"/>
+ android:height="24dp"
+ android:width="24dp"/>
</shape>
</item>
<item
android:id="@+id/fore"
android:gravity="center">
<vector
- android:height="24dp"
- android:width="24dp"
- android:viewportHeight="24"
- android:viewportWidth="24">
+ android:width="13dp"
+ android:height="13dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
<path
- android:fillColor="@color/notification_alert_color"
- android:pathData="M7.58 4.08L6.15 2.65C3.75 4.48 2.17 7.3 2.03 10.5h2c.15-2.65 1.51-4.97 3.55-6.42zm12.39 6.42h2c-.15-3.2-1.73-6.02-4.12-7.85l-1.42 1.43c2.02 1.45 3.39 3.77 3.54 6.42zM18 11c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2v-5zm-6 11c.14 0 .27-.01.4-.04.65-.14 1.18-.58 1.44-1.18.1-.24.15-.5.15-.78h-4c.01 1.1.9 2 2.01 2z"/>
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M8.98,16.65c-0.47,0 -0.91,-0.27 -1.12,-0.69l-1.93,-4.61L5.46,12.3c-0.21,0.43 -0.64,0.69 -1.12,0.69H2v-2h1.88l1,-2C5.1,8.56 5.52,8.3 6,8.3s0.9,0.26 1.12,0.69l1.73,4.14l2,-7c0.2,-0.46 0.65,-0.76 1.15,-0.76s0.95,0.3 1.15,0.76l0.04,0.12l1.96,6.88l1.7,-4.08c0.49,-0.98 1.84,-0.91 2.26,-0.06l1,2H22v2h-2.35c-0.47,0 -0.91,-0.27 -1.12,-0.7l-0.47,-0.95l-1.9,4.55c-0.25,0.5 -0.69,0.77 -1.18,0.75c-0.48,-0.01 -0.92,-0.31 -1.11,-0.76l-0.04,-0.12L12,9.37l-1.87,6.52c-0.19,0.45 -0.63,0.74 -1.11,0.76C9.01,16.65 9,16.65 8.98,16.65zM20.32,11.4L20.32,11.4C20.32,11.4 20.32,11.4 20.32,11.4z" />
</vector>
</item>
</layer-list>
\ No newline at end of file
diff --git a/res/drawable/ic_notification_silence.xml b/res/drawable/ic_notification_silence.xml
index 673340f..9da56dd 100644
--- a/res/drawable/ic_notification_silence.xml
+++ b/res/drawable/ic_notification_silence.xml
@@ -19,25 +19,23 @@
android:id="@+id/back">
<shape android:shape="oval">
<solid
- android:color="@android:color/transparent" />
+ android:color="@color/notification_silence_color" />
<size
- android:height="48dp"
- android:width="48dp"/>
- <stroke android:width="1dp"
- android:color="@color/notification_silence_color"/>
+ android:height="24dp"
+ android:width="24dp"/>
</shape>
</item>
<item
android:id="@+id/fore"
android:gravity="center">
<vector
- android:height="24dp"
- android:width="24dp"
- android:viewportHeight="24"
- android:viewportWidth="24">
+ android:width="13dp"
+ android:height="13dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
<path
- android:fillColor="@color/notification_silence_color"
- android:pathData="M20 18.69L7.84 6.14 5.27 3.49 4 4.76l2.8 2.8v.01c-.52.99-.8 2.16-.8 3.42v5l-2 2v1h13.73l2 2L21 19.72l-1-1.03zM12 22c1.11 0 2-.89 2-2h-4c0 1.11.89 2 2 2zm6-7.32V11c0-3.08-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68c-.15.03-.29.08-.42.12-.1.03-.2.07-.3.11h-.01c-.01 0-.01 0-.02.01-.23.09-.46.2-.68.31 0 0-.01 0-.01.01L18 14.68z" />
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M15,14.5c-1.38,0 -2.5,-1.12 -2.5,-2.5c0,-0.28 -0.22,-0.5 -0.5,-0.5s-0.5,0.22 -0.5,0.5c0,1.38 -1.12,2.5 -2.5,2.5S6.5,13.38 6.5,12c0,-0.28 -0.22,-0.5 -0.5,-0.5c-0.24,0 -0.46,0.18 -0.49,0.42C5.41,12.55 4.89,13 4.27,13H2v-2h1.71C4.1,10.11 5,9.5 6,9.5c1.38,0 2.5,1.12 2.5,2.5c0,0.28 0.22,0.5 0.5,0.5s0.5,-0.22 0.5,-0.5c0,-1.38 1.12,-2.5 2.5,-2.5s2.5,1.12 2.5,2.5c0,0.28 0.22,0.5 0.5,0.5s0.5,-0.22 0.5,-0.5c0,-1.38 1.12,-2.5 2.5,-2.5c1.02,0 1.91,0.6 2.29,1.5H22v2h-2.27c-0.62,0 -1.14,-0.45 -1.23,-1.08c-0.04,-0.24 -0.25,-0.42 -0.49,-0.42c-0.28,0 -0.5,0.22 -0.5,0.5C17.5,13.38 16.38,14.5 15,14.5z"/>
</vector>
</item>
-</layer-list>
\ No newline at end of file
+</layer-list>
diff --git a/res/drawable/ic_privacy_shield_24dp.xml b/res/drawable/ic_privacy_shield_24dp.xml
index 6bb69c0..a051e88 100644
--- a/res/drawable/ic_privacy_shield_24dp.xml
+++ b/res/drawable/ic_privacy_shield_24dp.xml
@@ -18,8 +18,12 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0">
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/textColorSecondary">>
<path
android:fillColor="#FF000000"
- android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/>
+ android:pathData="M12,2L3.82,5.64v5.45c0,5.05 3.49,9.76 8.18,10.91c4.69,-1.15 8.18,-5.86 8.18,-10.91V5.64L12,2zM18.18,11.09c0,1.55 -0.41,3.05 -1.1,4.38C15.77,14.5 13.4,14 12,14s-3.77,0.5 -5.08,1.47c-0.69,-1.33 -1.1,-2.83 -1.1,-4.38V6.94L12,4.19l6.18,2.75V11.09z"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,10.5m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0"/>
</vector>
diff --git a/res/layout-land/choose_lock_pattern.xml b/res/layout-land/choose_lock_pattern.xml
index 5b06f0d..331d4a4 100644
--- a/res/layout-land/choose_lock_pattern.xml
+++ b/res/layout-land/choose_lock_pattern.xml
@@ -73,7 +73,7 @@
android:layout_marginEnd="0dp"/>
<TextView
- android:id="@+id/message"
+ android:id="@+id/sud_layout_description"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml
index d140bad..544dd26 100644
--- a/res/layout-land/confirm_lock_password.xml
+++ b/res/layout-land/confirm_lock_password.xml
@@ -39,7 +39,7 @@
<TextView
style="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:id="@+id/detailsText"
+ android:id="@+id/sud_layout_description"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="8dp"
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index bcfd907..20a7bfc 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -47,7 +47,7 @@
<TextView
style="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:id="@+id/detailsText"
+ android:id="@+id/sud_layout_description"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginTop="12dp"
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 8bb713f..ded8d1a 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -55,7 +55,7 @@
<TextView
style="@style/SudDescription.Glif"
- android:id="@+id/detailsText"
+ android:id="@+id/sud_layout_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="?attr/sudMarginSides"
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index 734f8a3..3b77b84 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -72,7 +72,7 @@
<TextView
style="@style/SudDescription.Glif"
- android:id="@+id/start_message"
+ android:id="@+id/sud_layout_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_start_message"/>
diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml
index 6d8794a..fe9b3d7 100644
--- a/res/layout-land/fingerprint_enroll_find_sensor.xml
+++ b/res/layout-land/fingerprint_enroll_find_sensor.xml
@@ -73,6 +73,7 @@
android:layout_marginEnd="0dp" />
<TextView
+ android:id="@+id/sud_layout_description"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
index e80176d..4159516 100644
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ b/res/layout-land/fingerprint_enroll_finish.xml
@@ -64,7 +64,7 @@
android:layout_marginRight="0dp"/>
<TextView
- android:id="@+id/message"
+ android:id="@+id/sud_layout_description"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml
index 22934ba..ed25e74 100644
--- a/res/layout/confirm_lock_password_base.xml
+++ b/res/layout/confirm_lock_password_base.xml
@@ -42,7 +42,7 @@
<TextView
style="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:id="@+id/detailsText"
+ android:id="@+id/sud_layout_description"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="12dp"
diff --git a/res/layout/confirm_lock_pattern_base.xml b/res/layout/confirm_lock_pattern_base.xml
index 25fa08f..b02f9c0 100644
--- a/res/layout/confirm_lock_pattern_base.xml
+++ b/res/layout/confirm_lock_pattern_base.xml
@@ -51,7 +51,7 @@
<TextView
style="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:id="@+id/detailsText"
+ android:id="@+id/sud_layout_description"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="12dp"
diff --git a/res/layout/notif_importance_preference.xml b/res/layout/notif_importance_preference.xml
index 5d79ff3..bc0d5aa 100644
--- a/res/layout/notif_importance_preference.xml
+++ b/res/layout/notif_importance_preference.xml
@@ -21,84 +21,53 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
- android:orientation="horizontal">
+ android:orientation="vertical">
<LinearLayout
- android:id="@+id/block"
- android:layout_width="0dp"
- android:layout_weight="33.33"
+ android:id="@+id/buttons"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
- android:layout_marginTop="16dp"
- android:orientation="vertical"
+ android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
+ android:orientation="horizontal"
android:gravity="center">
- <ImageButton
- android:id="@+id/block_icon"
- android:layout_width="@dimen/notification_importance_toggle_size"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:src="@drawable/ic_notification_block"
- android:contentDescription="@string/notification_block_title" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/notification_block_title"
- android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
- android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
+ <Button
+ android:id="@+id/alert"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/notification_importance_toggle_size"
+ android:minWidth="@dimen/notification_importance_button_width"
+ android:paddingStart="@dimen/notification_importance_button_horiz_padding"
+ android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
+ android:drawablePadding="@dimen/notification_importance_drawable_padding"
+ android:foreground="@drawable/button_ripple_radius"
+ android:drawableLeft="@drawable/ic_notification_alert"
+ android:text="@string/notification_alert_title" />
+
+ <Button
+ android:id="@+id/silence"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/notification_importance_toggle_size"
+ android:minWidth="@dimen/notification_importance_button_width"
+ android:paddingStart="@dimen/notification_importance_button_horiz_padding"
+ android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
+ android:drawablePadding="@dimen/notification_importance_drawable_padding"
+ android:foreground="@drawable/button_ripple_radius"
+ android:layout_marginStart="@dimen/notification_importance_button_separation"
+ android:drawableLeft="@drawable/ic_notification_silence"
+ android:text="@string/notification_silence_title" />
+
</LinearLayout>
- <LinearLayout
- android:id="@+id/silence"
- android:layout_width="0dp"
- android:layout_weight="33.33"
+ <TextView
+ android:id="@+id/description"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
- android:layout_marginTop="16dp"
- android:orientation="vertical"
- android:gravity="center">
-
- <ImageButton
- android:id="@+id/silence_icon"
- android:layout_width="@dimen/notification_importance_toggle_size"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:src="@drawable/ic_notification_silence"
- android:contentDescription="@string/notification_silence_title" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/notification_silence_title"
- android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
- android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/alert"
- android:layout_width="0dp"
- android:layout_weight="33.33"
- android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
- android:layout_marginTop="16dp"
- android:orientation="vertical"
- android:gravity="center">
-
- <ImageButton
- android:id="@+id/alert_icon"
- android:layout_width="@dimen/notification_importance_toggle_size"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:src="@drawable/ic_notification_alert"
- android:contentDescription="@string/notification_alert_title" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/notification_alert_title"
- android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
- android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
- </LinearLayout>
+ android:text="@string/notification_alert_title"
+ android:gravity="center"
+ android:layout_marginTop="@dimen/notification_importance_text_marginTop"
+ android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
+ android:paddingStart="@dimen/notification_importance_description_padding"
+ android:paddingEnd="@dimen/notification_importance_description_padding"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" />
</LinearLayout>
\ No newline at end of file
diff --git a/res/raw/adaptive_sleep.mp4 b/res/raw/adaptive_sleep.mp4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/adaptive_sleep.mp4
diff --git a/res/raw/notification_interruption_model.mp4 b/res/raw/notification_interruption_model.mp4
new file mode 100644
index 0000000..5782091
--- /dev/null
+++ b/res/raw/notification_interruption_model.mp4
Binary files differ
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 23fe255..d4363b1 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -124,8 +124,9 @@
<!-- notification settings -->
<color name="notification_block_color">#ffff0000</color>
- <color name="notification_silence_color">#fbbc04</color>
- <color name="notification_alert_color">#30a751</color>
+ <color name="notification_silence_color">#FF32c1de</color>
+ <color name="notification_alert_color">#FFF87B2B</color>
+ <color name="notification_importance_button_unselected">#FFDADCE0</color>
<!-- launcher icon color -->
<color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index 496b5d2..1dbe079 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -363,4 +363,7 @@
<!-- Grayscale settings intent -->
<string name="config_grayscale_settings_intent" translate="false"></string>
+
+ <!-- List containing the injected tile keys which are suppressed. -->
+ <string-array name="config_suppress_injected_tile_keys" translatable="false"/>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0982855..c871ac8 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -69,11 +69,22 @@
<dimen name="notification_app_icon_badge_size">20dp</dimen>
<dimen name="notification_app_icon_badge_margin">4dp</dimen>
<dimen name="notification_importance_toggle_size">48dp</dimen>
- <dimen name="notification_importance_toggle_marginTop">8dp</dimen>
- <dimen name="notification_importance_toggle_marginBottom">16dp</dimen>
+ <dimen name="notification_importance_toggle_marginTop">28dp</dimen>
+ <dimen name="notification_importance_toggle_marginBottom">28dp</dimen>
+ <dimen name="notification_importance_text_marginTop">20dp</dimen>
+ <dimen name="notification_importance_button_separation">16dp</dimen>
+ <dimen name="notification_importance_button_width">178dp</dimen>
+ <dimen name="notification_importance_button_horiz_padding">36dp</dimen>
+ <dimen name="notification_importance_drawable_padding">8dp</dimen>
+ <dimen name="notification_importance_description_padding">20dp</dimen>
+ <dimen name="notification_importance_description_text">14sp</dimen>
+ <dimen name="notification_importance_button_text">16sp</dimen>
+
<dimen name="zen_schedule_rule_checkbox_padding">7dp</dimen>
<dimen name="zen_schedule_day_margin">17dp</dimen>
+ <dimen name="rect_button_radius">8dp</dimen>
+
<!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. -->
<dimen name="caption_preview_text_size">48dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 61d952a..d5b0ae6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7795,17 +7795,20 @@
<!-- Configure Notifications: Work profile section header [CHAR LIMIT=30] -->
<string name="profile_section_header">Work notifications</string>
+ <!-- Configure Notifications: section header for prioritizer settings [CHAR LIMIT=80] -->
+ <string name="smart_notifications_title">Smart notifications</string>
+
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
- <string name="asst_capability_prioritizer_title">Automatic Notification Prioritizer</string>
+ <string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=200] -->
- <string name="asst_capability_prioritizer_summary">Automatically silence and demote less important notifications</string>
+ <string name="asst_capability_prioritizer_summary">Automatically de-prioritize less important notifications to the gentle section</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="asst_capabilities_actions_replies_title">Smart actions and replies</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=200] -->
- <string name="asst_capabilities_actions_replies_summary">Automatically add contextual notification actions and quick replies to notifications</string>
+ <string name="asst_capabilities_actions_replies_summary">Automatically add suggested actions and replies to notifications</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="hide_silent_icons_title">Hide silent notification status icons</string>
@@ -7951,10 +7954,10 @@
<string name="notification_block_title">Block</string>
<!-- [CHAR LIMIT=100] Notification Importance title -->
- <string name="notification_silence_title">Show silently</string>
+ <string name="notification_silence_title">Gentle</string>
<!-- [CHAR LIMIT=100] Notification Importance title -->
- <string name="notification_alert_title">Alert</string>
+ <string name="notification_alert_title">Prioritized</string>
<!-- [CHAR LIMIT=40] Notification importance title. This setting controls how notifications in older apps may alert the user (eg, sound, visual, vibrate). -->
<string name="allow_interruption">Allow interruptions</string>
@@ -7964,17 +7967,26 @@
<!-- Channel summaries for the app notification page -->
- <!-- [CHAR LIMIT=100] Notification Importance title: min importance level title -->
- <string name="notification_channel_summary_min">Low importance</string>
+ <!-- [CHAR LIMIT=100] Notification Importance title: min importance level summary -->
+ <string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: low importance level title -->
- <string name="notification_channel_summary_low">Medium importance</string>
+ <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low">Gentle notifications will display in pull-down list</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: normal importance level title -->
- <string name="notification_channel_summary_default">High importance</string>
+ <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low_status">Gentle notifications will display in pull-down list & status bar</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: high importance level title -->
- <string name="notification_channel_summary_high">Urgent importance</string>
+ <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low_lock">Gentle notifications will display in pull-down list & on lock screen</string>
+
+ <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low_status_lock">Gentle notifications will display in pull-down list, status bar & on lock screen</string>
+
+ <!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary -->
+ <string name="notification_channel_summary_default">Prioritized notifications will alert and display in pull-down list, status bar & on lock screen</string>
+
+ <!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary -->
+ <string name="notification_channel_summary_high">When phone is unlocked, show notifications as a banner across top of screen</string>
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
<string name="notification_switch_label">Show notifications</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9a02fcd..8678e6e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -542,4 +542,24 @@
<item name="sudUsePartnerHeavyTheme">true</item>
</style>
+ <style name="TextAppearance.NotificationImportanceDetail">
+ <item name="android:textSize">@dimen/notification_importance_description_text</item>
+ <item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
+ <item name="android:gravity">center</item>
+ </style>
+
+ <style name="TextAppearance.NotificationImportanceButton">
+ <item name="android:textSize">@dimen/notification_importance_button_text</item>
+ <item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
+ <item name="android:gravity">center</item>
+ </style>
+
+ <style name="TextAppearance.NotificationImportanceButton.Selected" parent="TextAppearance.NotificationImportanceButton">
+ <item name="android:textColor">?android:attr/colorAccent</item>
+ </style>
+
+ <style name="TextAppearance.NotificationImportanceButton.Unselected" parent="TextAppearance.NotificationImportanceButton">
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ </style>
+
</resources>
diff --git a/res/xml/adaptive_sleep_detail.xml b/res/xml/adaptive_sleep_detail.xml
index e97a758..cada2e8 100644
--- a/res/xml/adaptive_sleep_detail.xml
+++ b/res/xml/adaptive_sleep_detail.xml
@@ -25,8 +25,8 @@
<com.android.settings.widget.VideoPreference
android:key="adaptive_sleep_video"
android:title="@string/summary_placeholder"
- settings:animation="@raw/aab_brightness"
- settings:preview="@drawable/aab_brightness"
+ settings:animation="@raw/adaptive_sleep"
+ settings:preview="@drawable/adaptive_sleep"
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<com.android.settingslib.RestrictedSwitchPreference
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index cdeb35e..eccb0d1 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="3">
+ settings:initialExpandedChildrenCount="4">
<!-- the initial count should include the dynamic tiles -->
<Preference
@@ -43,6 +43,7 @@
<!-- Empty category to draw divider -->
<PreferenceCategory
android:key="recent_apps_divider"
+ android:layout="@layout/preference_category_no_label"
android:order="-997"/>
<!-- Notifications (appears before manage_perms), default apps (appears after) -->
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 14e0366..267281f 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -25,6 +25,11 @@
android:order="1"
android:layout="@layout/settings_entity_header" />
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="block"
+ android:order="2"
+ android:layout="@layout/styled_switch_bar" />
+
<!-- Importance toggle -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="allow_sound"
@@ -43,13 +48,15 @@
android:key="min_importance"
android:order="5"
settings:allowDividerAbove="true"
- android:title="@string/notification_importance_min_title"/>
+ android:title="@string/notification_importance_min_title"
+ android:summary="@string/notification_channel_summary_min"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="high_importance"
android:order="6"
settings:allowDividerAbove="true"
- android:title="@string/notification_importance_high_title"/>
+ android:title="@string/notification_importance_high_title"
+ android:summary="@string/notification_channel_summary_high"/>
<PreferenceCategory
android:key="channel_advanced"
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index cf25a15..dd2cf86 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -19,17 +19,12 @@
android:title="@string/configure_notification_settings"
android:key="configure_notification_settings">
- <SwitchPreference
- android:key="asst_capability_prioritizer"
- android:title="@string/asst_capability_prioritizer_title"
- android:summary="@string/asst_capability_prioritizer_summary"
- settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
-
- <SwitchPreference
- android:key="asst_capabilities_actions_replies"
- android:title="@string/asst_capabilities_actions_replies_title"
- android:summary="@string/asst_capabilities_actions_replies_summary"
- settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
+ <com.android.settings.widget.VideoPreference
+ android:key="notification_model_illustration"
+ android:title="@string/summary_placeholder"
+ settings:animation="@raw/notification_interruption_model"
+ settings:controller="com.android.settings.widget.VideoPreferenceController"
+ android:persistent="false" />
<SwitchPreference
android:key="hide_silent_icons"
@@ -38,6 +33,23 @@
settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController" />
<PreferenceCategory
+ android:key="configure_notifications_smart"
+ android:title="@string/smart_notifications_title"
+ android:order="3">
+ <SwitchPreference
+ android:key="asst_capability_prioritizer"
+ android:title="@string/asst_capability_prioritizer_title"
+ android:summary="@string/asst_capability_prioritizer_summary"
+ settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
+
+ <SwitchPreference
+ android:key="asst_capabilities_actions_replies"
+ android:title="@string/asst_capabilities_actions_replies_title"
+ android:summary="@string/asst_capabilities_actions_replies_summary"
+ settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="configure_notifications_advanced"
android:order="15"
settings:initialExpandedChildrenCount="0">
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 2f43ce8..9ab80a7 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -28,6 +28,7 @@
<PreferenceCategory
android:key="location_advanced_settings"
+ android:layout="@layout/preference_category_no_label"
settings:initialExpandedChildrenCount="2">
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
@@ -54,7 +55,8 @@
android:selectable="true" />
<PreferenceCategory
- android:key="location_services" />
+ android:key="location_services"
+ android:layout="@layout/preference_category_no_label"/>
<!-- This preference gets removed if there is no managed profile -->
<PreferenceCategory
@@ -65,5 +67,6 @@
<PreferenceCategory
android:key="location_footer"
+ android:layout="@layout/preference_category_no_label"
settings:allowDividerAbove="false"/>
</PreferenceScreen>
diff --git a/res/xml/managed_profile_settings.xml b/res/xml/managed_profile_settings.xml
index bd44cc1..7b65a3d 100644
--- a/res/xml/managed_profile_settings.xml
+++ b/res/xml/managed_profile_settings.xml
@@ -32,11 +32,18 @@
settings:useAdditionalSummary="true"
settings:controller="com.android.settings.accounts.ContactSearchPreferenceController"/>
- <com.android.settingslib.RestrictedSwitchPreference
+ <!-- Only one of these preferences will be visible at a time, depending on
+ CrossProfileCalendarPreferenceController#isCrossProfileCalendarDisallowedByAdmin -->
+ <SwitchPreference
android:key="cross_profile_calendar"
android:summary="@string/cross_profile_calendar_summary"
android:title="@string/cross_profile_calendar_title"
- settings:useAdditionalSummary="true"
settings:controller="com.android.settings.accounts.CrossProfileCalendarPreferenceController"/>
+ <Preference
+ android:key="cross_profile_calendar_disabled"
+ android:summary="@string/cross_profile_calendar_restricted_summary"
+ android:title="@string/cross_profile_calendar_title"
+ android:enabled="false"
+ settings:controller="com.android.settings.accounts.CrossProfileCalendarDisabledPreferenceController"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 45b9d19..aa789b9 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -64,7 +64,8 @@
<!-- Privacy Service -->
<PreferenceCategory
- android:key="privacy_services"/>
+ android:key="privacy_services"
+ android:layout="@layout/preference_category_no_label"/>
<PreferenceCategory
android:key="dashboard_tile_placeholder"/>
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
index 9fe3d5b..6a896ce 100644
--- a/res/xml/security_dashboard_settings.xml
+++ b/res/xml/security_dashboard_settings.xml
@@ -96,7 +96,8 @@
<PreferenceCategory
android:order="40"
- android:key="security_settings_device_admin_category">
+ android:key="security_settings_device_admin_category"
+ android:layout="@layout/preference_category_no_label">
<Preference
android:key="manage_device_admin"
diff --git a/res/xml/smart_battery_detail.xml b/res/xml/smart_battery_detail.xml
index abf5e43..fa1b20b 100644
--- a/res/xml/smart_battery_detail.xml
+++ b/res/xml/smart_battery_detail.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="smart_battery_detail"
- android:title="@string/smart_battery_manager_title">
+ android:title="@string/smart_battery_manager_title"
+ settings:searchable="false">
<com.android.settings.widget.VideoPreference
android:key="auto_awesome_battery"
diff --git a/src/com/android/settings/accounts/AccountDetailDashboardFragment.java b/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
index ad6ecaf..1485500 100644
--- a/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
@@ -150,6 +150,9 @@
@Override
protected boolean displayTile(Tile tile) {
+ if (!super.displayTile(tile)) {
+ return false;
+ }
if (mAccountType == null) {
return false;
}
diff --git a/src/com/android/settings/accounts/CrossProfileCalendarDisabledPreferenceController.java b/src/com/android/settings/accounts/CrossProfileCalendarDisabledPreferenceController.java
new file mode 100644
index 0000000..c087982
--- /dev/null
+++ b/src/com/android/settings/accounts/CrossProfileCalendarDisabledPreferenceController.java
@@ -0,0 +1,47 @@
+/*
+ * 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.accounts;
+import static com.android.settings.accounts.CrossProfileCalendarPreferenceController.isCrossProfileCalendarDisallowedByAdmin;
+
+import android.content.Context;
+import android.os.UserHandle;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class CrossProfileCalendarDisabledPreferenceController extends BasePreferenceController {
+ private UserHandle mManagedUser;
+
+ public void setManagedUser(UserHandle managedUser) {
+ mManagedUser = managedUser;
+ }
+
+ public CrossProfileCalendarDisabledPreferenceController(Context context,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (mManagedUser != null
+ && isCrossProfileCalendarDisallowedByAdmin(
+ mContext, mManagedUser.getIdentifier())) {
+ return AVAILABLE;
+ }
+
+ return DISABLED_FOR_USER;
+ }
+}
diff --git a/src/com/android/settings/accounts/CrossProfileCalendarPreferenceController.java b/src/com/android/settings/accounts/CrossProfileCalendarPreferenceController.java
index aa314d6..863e790 100644
--- a/src/com/android/settings/accounts/CrossProfileCalendarPreferenceController.java
+++ b/src/com/android/settings/accounts/CrossProfileCalendarPreferenceController.java
@@ -15,19 +15,21 @@
import static android.provider.Settings.Secure.CROSS_PROFILE_CALENDAR_ENABLED;
+import android.app.admin.DevicePolicyManager;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.os.UserHandle;
import android.provider.Settings;
-
-import androidx.preference.Preference;
+import android.util.Log;
import com.android.settings.core.TogglePreferenceController;
-import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.android.settingslib.RestrictedSwitchPreference;
+
+import java.util.Set;
public class CrossProfileCalendarPreferenceController extends TogglePreferenceController {
+ private static final String TAG = "CrossProfileCalendarPreferenceController";
+
private UserHandle mManagedUser;
public CrossProfileCalendarPreferenceController(Context context, String key) {
@@ -40,19 +42,13 @@
@Override
public int getAvailabilityStatus() {
- return (mManagedUser != null) ? AVAILABLE : DISABLED_FOR_USER;
- }
-
- @Override
- public void updateState(Preference preference) {
- super.updateState(preference);
- if (preference instanceof RestrictedSwitchPreference && mManagedUser != null) {
- final RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
- final RestrictedLockUtils.EnforcedAdmin enforcedAdmin =
- RestrictedLockUtilsInternal.getCrossProfileCalendarEnforcingAdmin(
- mContext, mManagedUser.getIdentifier());
- pref.setDisabledByAdmin(enforcedAdmin);
+ if (mManagedUser != null
+ && !isCrossProfileCalendarDisallowedByAdmin(
+ mContext, mManagedUser.getIdentifier())) {
+ return AVAILABLE;
}
+
+ return DISABLED_FOR_USER;
}
@Override
@@ -74,4 +70,25 @@
return Settings.Secure.putIntForUser(mContext.getContentResolver(),
CROSS_PROFILE_CALENDAR_ENABLED, value, mManagedUser.getIdentifier());
}
+
+ static boolean isCrossProfileCalendarDisallowedByAdmin(Context context, int userId) {
+ final Context managedProfileContext = createPackageContextAsUser(context, userId);
+ final DevicePolicyManager dpm = managedProfileContext.getSystemService(
+ DevicePolicyManager.class);
+ if (dpm == null) {
+ return true;
+ }
+ final Set<String> packages = dpm.getCrossProfileCalendarPackages();
+ return packages != null && packages.isEmpty();
+ }
+
+ private static Context createPackageContextAsUser(Context context, int userId) {
+ try {
+ return context.createPackageContextAsUser(
+ context.getPackageName(), 0 /* flags */, UserHandle.of(userId));
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Failed to create user context", e);
+ }
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/accounts/ManagedProfileSettings.java b/src/com/android/settings/accounts/ManagedProfileSettings.java
index a4105ef..1f18d07 100644
--- a/src/com/android/settings/accounts/ManagedProfileSettings.java
+++ b/src/com/android/settings/accounts/ManagedProfileSettings.java
@@ -16,17 +16,23 @@
package com.android.settings.accounts;
+import android.app.admin.DevicePolicyManager;
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.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.util.Log;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceManager;
+
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
@@ -36,6 +42,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
* Setting page for managed profile.
@@ -72,6 +79,7 @@
use(WorkModePreferenceController.class).setManagedUser(mManagedUser);
use(ContactSearchPreferenceController.class).setManagedUser(mManagedUser);
use(CrossProfileCalendarPreferenceController.class).setManagedUser(mManagedUser);
+ use(CrossProfileCalendarDisabledPreferenceController.class).setManagedUser(mManagedUser);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 05ee7be..b8ec103 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -22,6 +22,7 @@
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import androidx.annotation.VisibleForTesting;
@@ -38,6 +39,7 @@
*/
public class FingerprintEnrollFinish extends BiometricEnrollBase {
+ private static final String TAG = "FingerprintEnrollFinish";
@VisibleForTesting
static final int REQUEST_ADD_ANOTHER = 1;
@VisibleForTesting
@@ -70,6 +72,13 @@
}
@Override
+ public void onBackPressed() {
+ super.onBackPressed();
+
+ updateFingerprintSuggestionEnableState();
+ }
+
+ @Override
protected void onResume() {
super.onResume();
@@ -93,12 +102,12 @@
@Override
protected void onNextButtonClick(View view) {
- setFingerprintSuggestionEnabled();
+ updateFingerprintSuggestionEnableState();
setResult(RESULT_FINISHED);
finish();
}
- private void setFingerprintSuggestionEnabled() {
+ private void updateFingerprintSuggestionEnableState() {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
if (fpm != null) {
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
@@ -114,6 +123,7 @@
FINGERPRINT_SUGGESTION_ACTIVITY);
getPackageManager().setComponentEnabledSetting(
componentName, flag, PackageManager.DONT_KILL_APP);
+ Log.d(TAG, FINGERPRINT_SUGGESTION_ACTIVITY + " enabled state = " + (enrolled == 1));
}
}
@@ -123,7 +133,7 @@
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- setFingerprintSuggestionEnabled();
+ updateFingerprintSuggestionEnableState();
if (requestCode == REQUEST_ADD_ANOTHER && resultCode != RESULT_CANCELED) {
setResult(resultCode, data);
finish();
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index d6a668e..112d7b8 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -26,6 +26,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
+import android.provider.DeviceConfig;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
@@ -38,6 +39,7 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.fuelgauge.BatteryMeterView;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -64,7 +66,6 @@
@VisibleForTesting
final Map<String, Bitmap> mIconCache;
private CachedBluetoothDevice mCachedDevice;
- private BluetoothDevice mBluetoothDevice;
@VisibleForTesting
BluetoothAdapter mBluetoothAdapter;
@VisibleForTesting
@@ -88,9 +89,11 @@
@Override
public int getAvailabilityStatus() {
+ final boolean advancedEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, true);
final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(
mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
- return untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return advancedEnabled && untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
@@ -138,7 +141,6 @@
public void init(CachedBluetoothDevice cachedBluetoothDevice) {
mCachedDevice = cachedBluetoothDevice;
- mBluetoothDevice = mCachedDevice.getDevice();
}
@VisibleForTesting
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index ee63045..f509605 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -19,12 +19,14 @@
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.provider.DeviceConfig;
import android.util.Pair;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -53,8 +55,11 @@
@Override
public boolean isAvailable() {
- return !BluetoothUtils.getBooleanMetaData(mCachedDevice.getDevice(),
- BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
+ final boolean advancedEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, true);
+ return !advancedEnabled
+ || !BluetoothUtils.getBooleanMetaData(mCachedDevice.getDevice(),
+ BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
}
@Override
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index 36cbd5d..c31b13e 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -22,7 +22,7 @@
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.Bundle;
-import android.util.FeatureFlagUtils;
+import android.provider.DeviceConfig;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -30,7 +30,7 @@
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
+import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.slices.BlockingSlicePrefController;
@@ -117,10 +117,10 @@
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
context).getBluetoothFeatureProvider(context);
- final boolean injectionEnabled = FeatureFlagUtils.isEnabled(context,
- FeatureFlags.SLICE_INJECTION);
+ final boolean sliceEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_SLICE_SETTINGS_ENABLED, true);
- use(BlockingSlicePrefController.class).setSliceUri(injectionEnabled
+ use(BlockingSlicePrefController.class).setSliceUri(sliceEnabled
? featureProvider.getBluetoothDeviceSettingsUri(mCachedDevice.getDevice())
: null);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 260297a..0e935c0 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -115,6 +115,8 @@
for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {
update(cachedBluetoothDevice);
}
+ } else {
+ removeAllDevicesFromPreference();
}
}
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index d5cfdcc..cbabb06 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -18,11 +18,13 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.Uri;
+import android.provider.DeviceConfig;
import android.provider.SearchIndexableResource;
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
+import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.slices.SlicePreferenceController;
@@ -86,12 +88,15 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
+ final boolean nearbyEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true);
use(AvailableMediaDeviceGroupController.class).init(this);
use(ConnectedDeviceGroupController.class).init(this);
use(PreviouslyConnectedDevicePreferenceController.class).init(this);
use(DiscoverableFooterPreferenceController.class).init(this);
- use(SlicePreferenceController.class).setSliceUri(
- Uri.parse(getString(R.string.config_nearby_devices_slice_uri)));
+ use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
+ ? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
+ : null);
}
/**
diff --git a/src/com/android/settings/core/SettingsUIDeviceConfig.java b/src/com/android/settings/core/SettingsUIDeviceConfig.java
new file mode 100644
index 0000000..b7aa281
--- /dev/null
+++ b/src/com/android/settings/core/SettingsUIDeviceConfig.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Class to store keys for settings related features, which comes from
+ * {@link android.provider.DeviceConfig}
+ */
+public class SettingsUIDeviceConfig {
+ /**
+ * {@code true} if slice settings is enabled in BT device detail page
+ */
+ public static final String BT_SLICE_SETTINGS_ENABLED = "bt_slice_settings_enabled";
+ /**
+ * {@code true} if advanced header is enabled in BT device detail page
+ */
+ public static final String BT_ADVANCED_HEADER_ENABLED = "bt_advanced_header_enabled";
+ /**
+ * {@code true} if near by device suggestion is enabled in connected device page
+ */
+ public static final String BT_NEAR_BY_SUGGESTION_ENABLED = "bt_near_by_suggestion_enabled";
+}
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 1630311..f2e3d73 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -24,12 +24,14 @@
import android.util.ArraySet;
import android.util.Log;
+import androidx.annotation.CallSuper;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerListHelper;
@@ -43,6 +45,7 @@
import com.android.settingslib.drawer.Tile;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -65,12 +68,15 @@
private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
private boolean mListeningToCategoryChange;
private SummaryLoader mSummaryLoader;
+ private List<String> mSuppressInjectedTileKeys;
@VisibleForTesting
UiBlockerController mBlockerController;
@Override
public void onAttach(Context context) {
super.onAttach(context);
+ mSuppressInjectedTileKeys = Arrays.asList(context.getResources().getStringArray(
+ R.array.config_suppress_injected_tile_keys));
mDashboardFeatureProvider = FeatureFactory.getFactory(context).
getDashboardFeatureProvider(context);
final List<AbstractPreferenceController> controllers = new ArrayList<>();
@@ -283,7 +289,12 @@
/**
* Returns true if this tile should be displayed
*/
+ @CallSuper
protected boolean displayTile(Tile tile) {
+ if (mSuppressInjectedTileKeys != null && tile.hasKey()) {
+ // For suppressing injected tiles for OEMs.
+ return !mSuppressInjectedTileKeys.contains(tile.getKey(getContext()));
+ }
return true;
}
diff --git a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
index 855a988..dd522bf 100644
--- a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -38,6 +38,7 @@
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.slices.Sliceable;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -91,7 +92,27 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
+ @Override
+ public boolean isCopyableSlice() {
+ return true;
+ }
+
+ @Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
+ public void copy() {
+ Sliceable.setCopyContent(mContext, getSummary(), mContext.getText(R.string.build_number));
}
@Override
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceController.java
index c568f07..53f5ff9 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceController.java
@@ -16,16 +16,10 @@
package com.android.settings.deviceinfo.firmwareversion;
-import static android.content.Context.CLIPBOARD_SERVICE;
-
-import android.content.ClipData;
-import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.text.BidiFormatter;
-import android.widget.Toast;
-import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class SimpleBuildNumberPreferenceController extends BasePreferenceController {
@@ -37,38 +31,11 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return AVAILABLE_UNSEARCHABLE;
}
@Override
public CharSequence getSummary() {
return BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY);
}
-
- @Override
- public boolean isSliceable() {
- return true;
- }
-
- @Override
- public boolean isCopyableSlice() {
- return true;
- }
-
- @Override
- public boolean useDynamicSliceSummary() {
- return true;
- }
-
- @Override
- public void copy() {
- final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
- CLIPBOARD_SERVICE);
- final ClipData clip = ClipData.newPlainText("text", getSummary());
- clipboard.setPrimaryClip(clip);
-
- final String toast = mContext.getString(R.string.copyable_slice_toast,
- mContext.getText(R.string.build_number));
- Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
- }
}
diff --git a/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java b/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java
index f882390..e7f6423 100644
--- a/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java
@@ -21,6 +21,7 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.slices.Sliceable;
public class HardwareRevisionPreferenceController extends BasePreferenceController {
@@ -45,6 +46,17 @@
}
@Override
+ public boolean isCopyableSlice() {
+ return true;
+ }
+
+ @Override
+ public void copy() {
+ Sliceable.setCopyContent(mContext, getSummary(),
+ mContext.getText(R.string.hardware_revision));
+ }
+
+ @Override
public CharSequence getSummary() {
return SystemProperties.get("ro.boot.hardware.revision");
}
diff --git a/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java b/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
index 04e3b13..c8447cb 100644
--- a/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
@@ -82,7 +82,8 @@
@Override
public int getMin() {
- return ColorDisplayManager.getMinimumColorTemperature(mContext);
+ // The min should always be 0 in this case.
+ return 0;
}
/**
diff --git a/src/com/android/settings/display/WallpaperPreferenceController.java b/src/com/android/settings/display/WallpaperPreferenceController.java
index 126be11..3ba39e9 100644
--- a/src/com/android/settings/display/WallpaperPreferenceController.java
+++ b/src/com/android/settings/display/WallpaperPreferenceController.java
@@ -53,8 +53,27 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
Preference preference = screen.findPreference(getPreferenceKey());
- preference.setTitle(mContext.getString(areStylesAvailable()
- ? R.string.style_and_wallpaper_settings_title : R.string.wallpaper_settings_title));
+ preference.setTitle(getTitle());
+ }
+
+ public String getTitle() {
+ return mContext.getString(areStylesAvailable()
+ ? R.string.style_and_wallpaper_settings_title : R.string.wallpaper_settings_title);
+ }
+
+ public ComponentName getComponentName() {
+ return new ComponentName(mWallpaperPackage,
+ areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass);
+ }
+
+ public String getKeywords() {
+ StringBuilder sb = new StringBuilder(mContext.getString(R.string.keywords_wallpaper));
+ if (areStylesAvailable()) {
+ // TODO(b/130759285): Create a new string keywords_styles_and_wallpaper
+ sb.append(", ").append(mContext.getString(R.string.theme_customization_category))
+ .append(", ").append(mContext.getString(R.string.keywords_dark_ui_mode));
+ }
+ return sb.toString();
}
@Override
@@ -75,9 +94,7 @@
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (getPreferenceKey().equals(preference.getKey())) {
- final ComponentName componentName = new ComponentName(mWallpaperPackage,
- areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass);
- preference.getContext().startActivity(new Intent().setComponent(componentName));
+ preference.getContext().startActivity(new Intent().setComponent(getComponentName()));
return true;
}
return super.handlePreferenceTreeClick(preference);
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index c851a71..33f2553 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -34,6 +34,8 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.UsageView;
import com.android.settingslib.R;
+import com.android.settingslib.fuelgauge.Estimate;
+import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.PowerUtil;
import com.android.settingslib.utils.StringUtil;
@@ -44,7 +46,7 @@
public int batteryLevel;
public boolean discharging = true;
public long remainingTimeUs = 0;
- public long averageTimeToDischarge = Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN;
+ public long averageTimeToDischarge = EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN;
public String batteryPercentString;
public String statusLabel;
public String suggestionLabel;
@@ -202,7 +204,7 @@
final Estimate estimate = new Estimate(
PowerUtil.convertUsToMs(prediction),
false, /* isBasedOnUsage */
- Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
+ EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
BatteryUtils.logRuntime(LOG_TAG, "time for regular BatteryInfo", startTime);
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
estimate, elapsedRealtimeUs, shortString);
@@ -214,7 +216,7 @@
Estimate estimate = new Estimate(
PowerUtil.convertUsToMs(stats.computeBatteryTimeRemaining(elapsedRealtimeUs)),
false,
- Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
+ EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
return getBatteryInfo(context, batteryBroadcast, stats, estimate, elapsedRealtimeUs,
shortString);
}
@@ -228,7 +230,7 @@
info.batteryLevel = Utils.getBatteryLevel(batteryBroadcast);
info.batteryPercentString = Utils.formatPercentage(info.batteryLevel);
info.mCharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
- info.averageTimeToDischarge = estimate.averageDischargeTime;
+ info.averageTimeToDischarge = estimate.getAverageDischargeTime();
final Resources resources = context.getResources();
info.statusLabel = Utils.getBatteryStatus(resources, batteryBroadcast);
@@ -269,20 +271,20 @@
private static void updateBatteryInfoDischarging(Context context, boolean shortString,
Estimate estimate, BatteryInfo info) {
- final long drainTimeUs = PowerUtil.convertMsToUs(estimate.estimateMillis);
+ final long drainTimeUs = PowerUtil.convertMsToUs(estimate.getEstimateMillis());
if (drainTimeUs > 0) {
info.remainingTimeUs = drainTimeUs;
info.remainingLabel = PowerUtil.getBatteryRemainingStringFormatted(
context,
PowerUtil.convertUsToMs(drainTimeUs),
null /* percentageString */,
- estimate.isBasedOnUsage && !shortString
+ estimate.isBasedOnUsage() && !shortString
);
info.chargeLabel = PowerUtil.getBatteryRemainingStringFormatted(
context,
PowerUtil.convertUsToMs(drainTimeUs),
info.batteryPercentString,
- estimate.isBasedOnUsage && !shortString
+ estimate.isBasedOnUsage() && !shortString
);
info.suggestionLabel = PowerUtil.getBatteryTipStringFormatted(
context, PowerUtil.convertUsToMs(drainTimeUs));
diff --git a/src/com/android/settings/fuelgauge/BatteryMeterView.java b/src/com/android/settings/fuelgauge/BatteryMeterView.java
index 4485508..27923ef 100644
--- a/src/com/android/settings/fuelgauge/BatteryMeterView.java
+++ b/src/com/android/settings/fuelgauge/BatteryMeterView.java
@@ -82,7 +82,7 @@
}
public int getBatteryLevel() {
- return mDrawable.getLevel();
+ return mDrawable.getBatteryLevel();
}
public void setCharging(boolean charging) {
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 6f77953..cb22356 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -47,6 +47,8 @@
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
import com.android.settings.fuelgauge.batterytip.StatsManagerConfig;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.fuelgauge.Estimate;
+import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
import com.android.settingslib.utils.PowerUtil;
import com.android.settingslib.utils.ThreadUtils;
@@ -460,7 +462,7 @@
estimate = new Estimate(
PowerUtil.convertUsToMs(stats.computeBatteryTimeRemaining(elapsedRealtimeUs)),
false /* isBasedOnUsage */,
- Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
+ EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
}
BatteryUtils.logRuntime(tag, "BatteryInfoLoader post query", startTime);
diff --git a/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java b/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
index d27e4dc..c8dbb59 100644
--- a/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
+++ b/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
@@ -23,6 +23,8 @@
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.fuelgauge.Estimate;
+import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.AsyncLoaderCompat;
import com.android.settingslib.utils.PowerUtil;
@@ -60,7 +62,7 @@
Estimate estimate = powerUsageFeatureProvider.getEnhancedBatteryPrediction(context);
if (estimate == null) {
- estimate = new Estimate(0, false, Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
+ estimate = new Estimate(0, false, EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
}
BatteryInfo newInfo = BatteryInfo.getBatteryInfo(getContext(), batteryBroadcast, stats,
estimate, elapsedRealtimeUs, false);
diff --git a/src/com/android/settings/fuelgauge/Estimate.java b/src/com/android/settings/fuelgauge/Estimate.java
deleted file mode 100644
index f59bbf1..0000000
--- a/src/com/android/settings/fuelgauge/Estimate.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.android.settings.fuelgauge;
-
-public class Estimate {
-
- // Value to indicate averageTimeToDischarge could not be obtained
- public static final int AVERAGE_TIME_TO_DISCHARGE_UNKNOWN = -1;
-
- public final long estimateMillis;
- public final boolean isBasedOnUsage;
- public final long averageDischargeTime;
-
- public Estimate(long estimateMillis, boolean isBasedOnUsage,
- long averageDischargeTime) {
- this.estimateMillis = estimateMillis;
- this.isBasedOnUsage = isBasedOnUsage;
- this.averageDischargeTime = averageDischargeTime;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
index a6474fb..4f292dd 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java
@@ -21,6 +21,7 @@
import android.util.SparseIntArray;
import com.android.internal.os.BatterySipper;
+import com.android.settingslib.fuelgauge.Estimate;
/**
* Feature Provider used in power usage
diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
index b76aef0..ab71c97 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
@@ -24,6 +24,7 @@
import com.android.internal.os.BatterySipper;
import com.android.internal.util.ArrayUtils;
+import com.android.settingslib.fuelgauge.Estimate;
public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 75db215..82ff4c2 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -45,6 +45,7 @@
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.utils.PowerUtil;
import com.android.settingslib.utils.StringUtil;
@@ -313,7 +314,7 @@
@VisibleForTesting
void updateLastFullChargePreference() {
if (mBatteryInfo != null && mBatteryInfo.averageTimeToDischarge
- != Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN) {
+ != EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN) {
mLastFullChargePref.setTitle(R.string.battery_full_charge_last);
mLastFullChargePref.setSubtitle(
StringUtil.formatElapsedTime(getContext(), mBatteryInfo.averageTimeToDischarge,
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index aa66aed..a1fb076 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -23,7 +23,6 @@
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.detectors.EarlyWarningDetector;
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
@@ -33,6 +32,7 @@
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
+import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.AsyncLoaderCompat;
import java.util.ArrayList;
@@ -87,7 +87,7 @@
private List<BatteryTip> getFakeData() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new SummaryTip(BatteryTip.StateType.NEW,
- Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
+ EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */,
"Fake data"));
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index b0dc926..d615db6 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -26,13 +26,13 @@
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.CardPreference;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.fuelgauge.EstimateKt;
import java.util.HashMap;
import java.util.List;
@@ -93,7 +93,7 @@
// Add summary tip in advance to avoid UI flakiness
final SummaryTip summaryTip = new SummaryTip(BatteryTip.StateType.NEW,
- Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
+ EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
summaryTip.updatePreference(mCardPreference);
}
diff --git a/src/com/android/settings/notification/AllowSoundPreferenceController.java b/src/com/android/settings/notification/AllowSoundPreferenceController.java
index cbabd2d..7862f4b 100644
--- a/src/com/android/settings/notification/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/AllowSoundPreferenceController.java
@@ -62,7 +62,7 @@
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
- pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
+ pref.setEnabled(!pref.isDisabledByAdmin());
pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT
|| mChannel.getImportance() == IMPORTANCE_UNSPECIFIED);
} else { Log.i(TAG, "tried to updatestate on a null channel?!"); }
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index e056d67..531d8fa 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -33,6 +33,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -255,7 +256,7 @@
int childCount = groupGroup.getPreferenceCount();
for (int i = 0; i < childCount; i++) {
Preference pref = groupGroup.getPreference(i);
- if (pref instanceof ChannelSummaryPreference) {
+ if (pref instanceof MasterSwitchPreference) {
toRemove.add(pref);
}
}
diff --git a/src/com/android/settings/notification/BadgePreferenceController.java b/src/com/android/settings/notification/BadgePreferenceController.java
index 67332a4..e40324e 100644
--- a/src/com/android/settings/notification/BadgePreferenceController.java
+++ b/src/com/android/settings/notification/BadgePreferenceController.java
@@ -72,7 +72,7 @@
pref.setDisabledByAdmin(mAdmin);
if (mChannel != null) {
pref.setChecked(mChannel.canShowBadge());
- pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
+ pref.setEnabled(!pref.isDisabledByAdmin());
} else {
pref.setChecked(mAppRow.showBadge);
}
diff --git a/src/com/android/settings/notification/BubblePreferenceController.java b/src/com/android/settings/notification/BubblePreferenceController.java
index e5a1a62..f373752 100644
--- a/src/com/android/settings/notification/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/BubblePreferenceController.java
@@ -81,7 +81,7 @@
pref.setDisabledByAdmin(mAdmin);
if (mChannel != null) {
pref.setChecked(mChannel.canBubble());
- pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
+ pref.setEnabled(!pref.isDisabledByAdmin());
} else {
pref.setChecked(mAppRow.allowBubbles
&& Settings.Secure.getInt(mContext.getContentResolver(),
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 850fde2..9f9d438 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -94,6 +94,7 @@
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
mControllers = new ArrayList<>();
mControllers.add(new HeaderPreferenceController(context, this));
+ mControllers.add(new BlockPreferenceController(context, mImportanceListener, mBackend));
mControllers.add(new ImportancePreferenceController(
context, mImportanceListener, mBackend));
mControllers.add(new MinImportancePreferenceController(
diff --git a/src/com/android/settings/notification/ChannelSummaryPreference.java b/src/com/android/settings/notification/ChannelSummaryPreference.java
deleted file mode 100644
index 338e5e0..0000000
--- a/src/com/android/settings/notification/ChannelSummaryPreference.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.notification;
-
-import android.content.Context;
-import android.content.Intent;
-import android.view.View;
-import android.widget.CheckBox;
-
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-import com.android.settingslib.TwoTargetPreference;
-
-/**
- * A custom preference that provides inline checkbox and tappable target.
- */
-public class ChannelSummaryPreference extends TwoTargetPreference {
-
- private Context mContext;
- private Intent mIntent;
- private CheckBox mCheckBox;
- private boolean mChecked;
- private boolean mEnableCheckBox = true;
-
- public ChannelSummaryPreference(Context context) {
- super(context);
- setLayoutResource(R.layout.preference_checkable_two_target);
- mContext = context;
- setWidgetLayoutResource(R.layout.zen_rule_widget);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder view) {
- super.onBindViewHolder(view);
- View settingsWidget = view.findViewById(android.R.id.widget_frame);
- View divider = view.findViewById(R.id.two_target_divider);
- if (mIntent != null) {
- divider.setVisibility(View.VISIBLE);
- settingsWidget.setVisibility(View.VISIBLE);
- settingsWidget.setOnClickListener(v -> mContext.startActivity(mIntent));
- } else {
- divider.setVisibility(View.GONE);
- settingsWidget.setVisibility(View.GONE);
- settingsWidget.setOnClickListener(null);
- }
-
- View checkboxContainer = view.findViewById(R.id.checkbox_container);
- if (checkboxContainer != null) {
- checkboxContainer.setOnClickListener(mOnCheckBoxClickListener);
- }
- mCheckBox = (CheckBox) view.findViewById(com.android.internal.R.id.checkbox);
- if (mCheckBox != null) {
- mCheckBox.setChecked(mChecked);
- mCheckBox.setEnabled(mEnableCheckBox);
- }
- }
-
- public boolean isChecked() {
- return mChecked;
- }
-
- @Override
- public void setIntent(Intent intent) {
- mIntent = intent;
- }
-
- @Override
- public void onClick() {
- mOnCheckBoxClickListener.onClick(null);
- }
-
- public void setChecked(boolean checked) {
- mChecked = checked;
- if (mCheckBox != null) {
- mCheckBox.setChecked(checked);
- }
- }
-
- public void setCheckBoxEnabled(boolean enabled) {
- mEnableCheckBox = enabled;
- if (mCheckBox != null) {
- mCheckBox.setEnabled(enabled);
- }
- }
-
- private View.OnClickListener mOnCheckBoxClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mCheckBox != null && !mCheckBox.isEnabled()) {
- return;
- }
- setChecked(!mChecked);
- if (!callChangeListener(mChecked)) {
- setChecked(!mChecked);
- } else {
- persistBoolean(mChecked);
- }
- }
- };
-}
diff --git a/src/com/android/settings/notification/DndPreferenceController.java b/src/com/android/settings/notification/DndPreferenceController.java
index a615221..4ec76f1 100644
--- a/src/com/android/settings/notification/DndPreferenceController.java
+++ b/src/com/android/settings/notification/DndPreferenceController.java
@@ -50,7 +50,7 @@
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
- pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
+ pref.setEnabled(!pref.isDisabledByAdmin());
pref.setChecked(mChannel.canBypassDnd());
}
}
diff --git a/src/com/android/settings/notification/HighImportancePreferenceController.java b/src/com/android/settings/notification/HighImportancePreferenceController.java
index fe843fd..b82cb1f 100644
--- a/src/com/android/settings/notification/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/HighImportancePreferenceController.java
@@ -61,8 +61,8 @@
@Override
public void updateState(Preference preference) {
- if (mAppRow!= null && mChannel != null) {
- preference.setEnabled(mAdmin == null && isChannelConfigurable());
+ if (mAppRow != null && mChannel != null) {
+ preference.setEnabled(mAdmin == null && isChannelBlockable());
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setChecked(mChannel.getImportance() >= IMPORTANCE_HIGH);
diff --git a/src/com/android/settings/notification/ImportancePreference.java b/src/com/android/settings/notification/ImportancePreference.java
index b8f3e45..5572b12 100644
--- a/src/com/android/settings/notification/ImportancePreference.java
+++ b/src/com/android/settings/notification/ImportancePreference.java
@@ -20,17 +20,12 @@
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
-import static android.app.NotificationManager.IMPORTANCE_NONE;
import android.content.Context;
-import android.graphics.Color;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.LayerDrawable;
-import android.util.ArrayMap;
import android.util.AttributeSet;
-import android.view.View;
-import android.widget.ImageButton;
+import android.widget.Button;
+import android.widget.TextView;
import com.android.settingslib.R;
@@ -39,14 +34,15 @@
public class ImportancePreference extends Preference {
- boolean mIsBlockable = true;
- boolean mIsConfigurable = true;
- int mImportance;
- ImageButton blockButton;
- ImageButton silenceButton;
- ImageButton alertButton;
- ArrayMap<ImageButton, Integer> mImageButtons = new ArrayMap<>();
- Context mContext;
+ private boolean mIsConfigurable = true;
+ private int mImportance;
+ private boolean mDisplayInStatusBar;
+ private boolean mDisplayOnLockscreen;
+ private Button mSilenceButton;
+ private Button mAlertButton;
+ private Context mContext;
+ Drawable selectedBackground;
+ Drawable unselectedBackground;
public ImportancePreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
@@ -71,6 +67,8 @@
private void init(Context context) {
mContext = context;
+ selectedBackground = mContext.getDrawable(R.drawable.button_border_selected);
+ unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected);
setLayoutResource(R.layout.notif_importance_preference);
}
@@ -78,94 +76,81 @@
mImportance = importance;
}
- public void setBlockable(boolean blockable) {
- mIsBlockable = blockable;
- }
-
public void setConfigurable(boolean configurable) {
mIsConfigurable = configurable;
}
+ public void setDisplayInStatusBar(boolean display) {
+ mDisplayInStatusBar = display;
+ }
+
+ public void setDisplayOnLockscreen(boolean display) {
+ mDisplayOnLockscreen = display;
+ }
+
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- View blockView = holder.itemView.findViewById(R.id.block);
- View alertView = holder.itemView.findViewById(R.id.alert);
- View silenceView = holder.itemView.findViewById(R.id.silence);
- if (!mIsBlockable) {
- blockView.setVisibility(View.GONE);
- if (mImportance == IMPORTANCE_NONE) {
- mImportance = IMPORTANCE_LOW;
- callChangeListener(IMPORTANCE_LOW);
- }
+ TextView textView = (TextView) holder.findViewById(R.id.description);
+ mSilenceButton = (Button) holder.findViewById(R.id.silence);
+ mAlertButton = (Button) holder.findViewById(R.id.alert);
+ if (!mIsConfigurable) {
+ mSilenceButton.setEnabled(false);
+ mAlertButton.setEnabled(false);
}
- blockButton = blockView.findViewById(R.id.block_icon);
- silenceButton = silenceView.findViewById(R.id.silence_icon);
- alertButton = alertView.findViewById(R.id.alert_icon);
- mImageButtons.put(blockButton, mContext.getColor(R.color.notification_block_color));
- mImageButtons.put(silenceButton, mContext.getColor(R.color.notification_silence_color));
- mImageButtons.put(alertButton, mContext.getColor(R.color.notification_alert_color));
switch (mImportance) {
- case IMPORTANCE_NONE:
- colorizeImageButton(blockButton.getId());
- if (!mIsConfigurable) {
- alertView.setVisibility(View.GONE);
- silenceView.setVisibility(View.GONE);
- }
- break;
case IMPORTANCE_MIN:
case IMPORTANCE_LOW:
- colorizeImageButton(silenceButton.getId());
- if (!mIsConfigurable) {
- alertView.setVisibility(View.GONE);
- blockView.setVisibility(View.GONE);
- }
+ mAlertButton.setBackground(unselectedBackground);
+ mSilenceButton.setBackground(selectedBackground);
break;
case IMPORTANCE_HIGH:
default:
- colorizeImageButton(alertButton.getId());
- if (!mIsConfigurable) {
- blockView.setVisibility(View.GONE);
- silenceView.setVisibility(View.GONE);
- }
+ mSilenceButton.setBackground(unselectedBackground);
+ mAlertButton.setBackground(selectedBackground);
break;
}
+ setImportanceSummary(textView, mImportance);
- blockButton.setOnClickListener(v -> {
- callChangeListener(IMPORTANCE_NONE);
- colorizeImageButton(blockButton.getId());
- });
- silenceButton.setOnClickListener(v -> {
+ mSilenceButton.setOnClickListener(v -> {
callChangeListener(IMPORTANCE_LOW);
- colorizeImageButton(silenceButton.getId());
+ mAlertButton.setBackground(unselectedBackground);
+ mSilenceButton.setBackground(selectedBackground);
+ mSilenceButton.setTextAppearance(
+ R.style.TextAppearance_NotificationImportanceButton_Selected);
+ mAlertButton.setTextAppearance(
+ R.style.TextAppearance_NotificationImportanceButton_Unselected);
+ setImportanceSummary(textView, IMPORTANCE_LOW);
});
- alertButton.setOnClickListener(v -> {
+ mAlertButton.setOnClickListener(v -> {
callChangeListener(IMPORTANCE_DEFAULT);
- colorizeImageButton(alertButton.getId());
+ mSilenceButton.setBackground(unselectedBackground);
+ mAlertButton.setBackground(selectedBackground);
+ mAlertButton.setTextAppearance(
+ R.style.TextAppearance_NotificationImportanceButton_Selected);
+ mSilenceButton.setTextAppearance(
+ R.style.TextAppearance_NotificationImportanceButton_Unselected);
+ setImportanceSummary(textView, IMPORTANCE_DEFAULT);
});
}
- private void colorizeImageButton(int buttonId) {
- if (mImageButtons != null) {
- for (int i = 0; i < mImageButtons.size(); i++) {
- final ImageButton imageButton = mImageButtons.keyAt(i);
- final int color = mImageButtons.valueAt(i);
- if (imageButton != null) {
- LayerDrawable drawable = (LayerDrawable) imageButton.getDrawable();
- Drawable foreground = drawable.findDrawableByLayerId(R.id.fore);
- GradientDrawable background =
- (GradientDrawable) drawable.findDrawableByLayerId(R.id.back);
- if (buttonId == imageButton.getId()) {
- foreground.setTint(Color.WHITE);
- background.setColor(color);
- } else {
- foreground.setTint(color);
- background.setColor(Color.TRANSPARENT);
- }
- }
+ void setImportanceSummary(TextView view, int importance) {
+ if (importance >= IMPORTANCE_DEFAULT) {
+ view.setText(R.string.notification_channel_summary_default);
+ } else {
+ if (mDisplayInStatusBar) {
+ if (mDisplayOnLockscreen) {
+ view.setText(R.string.notification_channel_summary_low_status_lock);
+ } else {
+ view.setText(R.string.notification_channel_summary_low_status);
+ }
+ } else if (mDisplayOnLockscreen) {
+ view.setText(R.string.notification_channel_summary_low_lock);
+ } else {
+ view.setText(R.string.notification_channel_summary_low);
}
}
}
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 94a268b..708fc15 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -47,32 +47,24 @@
@Override
public boolean isAvailable() {
- if (mAppRow == null) {
- return false;
- }
- if (mAppRow.banned) {
+ if (!super.isAvailable()) {
return false;
}
if (mChannel == null) {
return false;
}
- if (isDefaultChannel()) {
- return false;
- }
- if (mChannelGroup != null && mChannelGroup.isBlocked()) {
- return false;
- }
- return true;
+ return !isDefaultChannel();
}
@Override
public void updateState(Preference preference) {
if (mAppRow!= null && mChannel != null) {
- preference.setEnabled(mAdmin == null && isChannelConfigurable());
+ preference.setEnabled(mAdmin == null && isChannelBlockable());
ImportancePreference pref = (ImportancePreference) preference;
- pref.setBlockable(isChannelBlockable());
- pref.setConfigurable(isChannelConfigurable());
+ pref.setConfigurable(isChannelBlockable());
pref.setImportance(mChannel.getImportance());
+ pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
+ // TODO: b/128445911 pass along lock screen setting
}
}
diff --git a/src/com/android/settings/notification/LightsPreferenceController.java b/src/com/android/settings/notification/LightsPreferenceController.java
index 04f2551..21dabbf 100644
--- a/src/com/android/settings/notification/LightsPreferenceController.java
+++ b/src/com/android/settings/notification/LightsPreferenceController.java
@@ -56,7 +56,7 @@
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
- pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
+ pref.setEnabled(!pref.isDisabledByAdmin());
pref.setChecked(mChannel.shouldShowLights());
}
}
diff --git a/src/com/android/settings/notification/MinImportancePreferenceController.java b/src/com/android/settings/notification/MinImportancePreferenceController.java
index 771ac60..84cead1 100644
--- a/src/com/android/settings/notification/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/MinImportancePreferenceController.java
@@ -61,8 +61,8 @@
@Override
public void updateState(Preference preference) {
- if (mAppRow!= null && mChannel != null) {
- preference.setEnabled(mAdmin == null && isChannelConfigurable());
+ if (mAppRow != null && mChannel != null) {
+ preference.setEnabled(mAdmin == null && isChannelBlockable());
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setChecked(mChannel.getImportance() == IMPORTANCE_MIN);
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 765193b..f27f979 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -360,6 +360,15 @@
return new ArrayList<>();
}
+ public boolean showSilentInStatusBar(String pkg) {
+ try {
+ return !sINM.shouldHideSilentStatusIcons(pkg);
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ }
+ return false;
+ }
+
protected void recordAggregatedUsageEvents(Context context, AppRow appRow) {
long now = System.currentTimeMillis();
long startTime = now - (DateUtils.DAY_IN_MILLIS * DAYS_TO_CHECK);
diff --git a/src/com/android/settings/notification/NotificationPreferenceController.java b/src/com/android/settings/notification/NotificationPreferenceController.java
index 99f7e20..1bfe47e 100644
--- a/src/com/android/settings/notification/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationPreferenceController.java
@@ -110,7 +110,7 @@
}
}
- protected boolean isChannelConfigurable() {
+ private boolean isChannelConfigurable() {
if (mAppRow != null && mAppRow.lockedImportance) {
return false;
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index b9fabb6..163671a 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -34,6 +34,12 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.graphics.BlendMode;
+import android.graphics.BlendModeColorFilter;
+import android.graphics.ColorFilter;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
@@ -50,6 +56,7 @@
import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.RestrictedLockUtilsInternal;
import java.util.ArrayList;
@@ -272,11 +279,14 @@
protected Preference populateSingleChannelPrefs(PreferenceGroup parent,
final NotificationChannel channel, final boolean groupBlocked) {
- ChannelSummaryPreference channelPref = new ChannelSummaryPreference(getPrefContext());
- channelPref.setCheckBoxEnabled(mSuspendedAppsAdmin == null
+ MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
+ channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null
&& isChannelBlockable(channel)
&& isChannelConfigurable(channel)
&& !groupBlocked);
+ channelPref.setIcon(channel.getImportance() > IMPORTANCE_LOW
+ ? R.drawable.ic_notification_alert : R.drawable.ic_notification_silence);
+ channelPref.setIconSize(MasterSwitchPreference.ICON_SIZE_SMALL);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setSummary(NotificationBackend.getSentSummary(
@@ -295,19 +305,21 @@
.toIntent());
channelPref.setOnPreferenceChangeListener(
- new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference,
- Object o) {
- boolean value = (Boolean) o;
- int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
- channel.setImportance(importance);
- channel.lockFields(
- NotificationChannel.USER_LOCKED_IMPORTANCE);
- mBackend.updateChannel(mPkg, mUid, channel);
+ (preference, o) -> {
+ boolean value = (Boolean) o;
+ int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
+ channel.setImportance(importance);
+ channel.lockFields(
+ NotificationChannel.USER_LOCKED_IMPORTANCE);
+ MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
+ channelPref1.setIcon(channel.getImportance() > IMPORTANCE_LOW
+ ? R.drawable.ic_notification_alert
+ : R.drawable.ic_notification_silence);
+ toggleBehaviorIconState(channelPref1.getIcon(),
+ importance != IMPORTANCE_NONE);
+ mBackend.updateChannel(mPkg, mUid, channel);
- return true;
- }
+ return true;
});
if (parent.findPreference(channelPref.getKey()) == null) {
parent.addPreference(channelPref);
@@ -315,6 +327,19 @@
return channelPref;
}
+ private void toggleBehaviorIconState(Drawable icon, boolean enabled) {
+ LayerDrawable layerDrawable = (LayerDrawable) icon;
+ GradientDrawable background =
+ (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back);
+ if (enabled) {
+ background.clearColorFilter();
+ } else {
+ background.setColorFilter(new BlendModeColorFilter(
+ mContext.getColor(R.color.material_grey_300),
+ BlendMode.SRC_IN));
+ }
+ }
+
protected boolean isChannelConfigurable(NotificationChannel channel) {
if (channel != null && mAppRow != null) {
return !channel.getId().equals(mAppRow.lockedChannelId);
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index 73cbad3..566f3f2 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -77,7 +77,7 @@
public void updateState(Preference preference) {
if (mAppRow!= null && mChannel != null) {
NotificationSoundPreference pref = (NotificationSoundPreference) preference;
- pref.setEnabled(mAdmin == null && isChannelConfigurable());
+ pref.setEnabled(mAdmin == null);
pref.setRingtone(mChannel.getSound());
}
}
diff --git a/src/com/android/settings/notification/VibrationPreferenceController.java b/src/com/android/settings/notification/VibrationPreferenceController.java
index ec5554a..e6024d0 100644
--- a/src/com/android/settings/notification/VibrationPreferenceController.java
+++ b/src/com/android/settings/notification/VibrationPreferenceController.java
@@ -56,7 +56,7 @@
if (mChannel != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
- pref.setEnabled(!pref.isDisabledByAdmin() && isChannelConfigurable());
+ pref.setEnabled(!pref.isDisabledByAdmin());
pref.setChecked(mChannel.shouldVibrate());
}
}
diff --git a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
index 0a8b931..d931f6c 100644
--- a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
@@ -16,7 +16,9 @@
package com.android.settings.notification;
+import android.app.NotificationManager;
import android.content.Context;
+import android.provider.Settings;
import androidx.preference.Preference;
@@ -50,6 +52,16 @@
public void updateState(Preference preference) {
super.updateState(preference);
- preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ preference.setEnabled(false);
+ preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
+ }
}
}
diff --git a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
index 2e41f20..d51be27 100644
--- a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
@@ -16,7 +16,9 @@
package com.android.settings.notification;
+import android.app.NotificationManager;
import android.content.Context;
+import android.provider.Settings;
import androidx.preference.Preference;
@@ -49,6 +51,16 @@
public void updateState(Preference preference) {
super.updateState(preference);
- preference.setSummary(mSummaryBuilder.getMessagesSettingSummary(getPolicy()));
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ preference.setEnabled(false);
+ preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mSummaryBuilder.getMessagesSettingSummary(getPolicy()));
+ }
}
}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index e244413..dcd878e 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -44,6 +44,12 @@
public class PanelSlicesAdapter
extends RecyclerView.Adapter<PanelSlicesAdapter.SliceRowViewHolder> {
+ /**
+ * Maximum number of slices allowed on the panel view.
+ */
+ @VisibleForTesting
+ static final int MAX_NUM_OF_SLICES = 5;
+
private final List<LiveData<Slice>> mSliceLiveData;
private final int mMetricsCategory;
private final PanelFragment mPanelFragment;
@@ -70,14 +76,21 @@
sliceRowViewHolder.onBind(mSliceLiveData.get(position));
}
+ /**
+ * Return the number of available items in the adapter with max number of slices enforced.
+ */
@Override
public int getItemCount() {
- return mSliceLiveData.size();
+ return Math.min(mSliceLiveData.size(), MAX_NUM_OF_SLICES);
}
+ /**
+ * Return the available data from the adapter. If the number of Slices over the max number
+ * allowed, the list will only have the first MAX_NUM_OF_SLICES of slices.
+ */
@VisibleForTesting
List<LiveData<Slice>> getData() {
- return mSliceLiveData;
+ return mSliceLiveData.subList(0, getItemCount());
}
/**
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 3bdcb13..9b5fbd8 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -18,9 +18,11 @@
import static android.Manifest.permission.READ_SEARCH_INDEXABLES;
+import android.app.PendingIntent;
import android.app.slice.SliceManager;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.StrictMode;
@@ -32,6 +34,8 @@
import android.util.Log;
import android.util.Pair;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArraySet;
import androidx.slice.Slice;
@@ -295,6 +299,16 @@
return descendants;
}
+ @Nullable
+ @Override
+ public PendingIntent onCreatePermissionRequest(@NonNull Uri sliceUri,
+ @NonNull String callingPackage) {
+ final Intent settingsIntent = new Intent(Settings.ACTION_SETTINGS);
+ final PendingIntent noOpIntent = PendingIntent.getActivity(getContext(),
+ 0 /* requestCode */, settingsIntent, 0 /* flags */);
+ return noOpIntent;
+ }
+
@VisibleForTesting
static void grantWhitelistedPackagePermissions(Context context, List<Uri> descendants) {
if (descendants == null) {
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 0713872..fe23d74 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -19,6 +19,7 @@
import android.app.Activity;
import android.app.WallpaperManager;
import android.app.settings.SettingsEnums;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -28,6 +29,7 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.display.WallpaperPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
@@ -46,8 +48,8 @@
super.onCreate(savedInstanceState);
final PackageManager pm = getPackageManager();
final Intent intent = new Intent()
- .setClassName(getString(R.string.config_wallpaper_picker_package),
- getString(R.string.config_wallpaper_picker_class))
+ .setComponent(new WallpaperPreferenceController(this, "dummy key")
+ .getComponentName())
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
// passing the necessary extra to next page
@@ -95,21 +97,19 @@
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
-
final List<SearchIndexableRaw> result = new ArrayList<>();
-
+ WallpaperPreferenceController controller =
+ new WallpaperPreferenceController(context, "dummy key");
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.title = controller.getTitle();
+ data.screenTitle = data.title;
+ ComponentName component = controller.getComponentName();
+ data.intentTargetPackage = component.getPackageName();
+ data.intentTargetClass = component.getClassName();
data.intentAction = Intent.ACTION_MAIN;
data.key = SUPPORT_SEARCH_INDEX_KEY;
+ data.keywords = controller.getKeywords();
result.add(data);
-
return result;
}
};
diff --git a/src/com/android/settings/widget/DisabledCheckBoxPreference.java b/src/com/android/settings/widget/DisabledCheckBoxPreference.java
index be6deb3..15c17dc 100644
--- a/src/com/android/settings/widget/DisabledCheckBoxPreference.java
+++ b/src/com/android/settings/widget/DisabledCheckBoxPreference.java
@@ -20,6 +20,7 @@
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.TextView;
import androidx.preference.CheckBoxPreference;
import androidx.preference.PreferenceViewHolder;
@@ -89,6 +90,12 @@
mCheckBox = holder.findViewById(android.R.id.checkbox);
enableCheckbox(mEnabledCheckBox);
+
+ TextView title = (TextView) holder.findViewById(android.R.id.title);
+ if (title != null) {
+ title.setSingleLine(false);
+ title.setMaxLines(2);
+ }
}
@Override
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index 2a7ac17..eb7d78f 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -377,7 +377,9 @@
final TextView titleView = view.findViewById(android.R.id.title);
if (titleView != null) {
- titleView.setText(accessPoint.getSsidStr());
+ // Shows whole SSID for better UX.
+ titleView.setSingleLine(false);
+ titleView.setText(accessPoint.getTitle());
}
final TextView summary = view.findViewById(android.R.id.summary);
diff --git a/tests/robotests/Android.mk b/tests/robotests/Android.mk
index 56b2607..727da06 100644
--- a/tests/robotests/Android.mk
+++ b/tests/robotests/Android.mk
@@ -109,6 +109,3 @@
LOCAL_ROBOTEST_TIMEOUT := 36000
include external/robolectric-shadows/run_robotests.mk
-
-# include separate settings robotest moduldes
-include $(LOCAL_PATH)/settings_robotest_modules.mk
\ No newline at end of file
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 78c3c08..a6a84c9 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -88,4 +88,9 @@
<!-- Grayscale settings intent -->
<string name="config_grayscale_settings_intent" translate="false">intent:#Intent;action=test.test;end</string>
+
+ <!-- List containing the injected tile keys which are suppressed. -->
+ <string-array name="config_suppress_injected_tile_keys" translatable="false">
+ <item>injected_tile_key</item>
+ </string-array>
</resources>
diff --git a/tests/robotests/settings_robotest_modules.mk b/tests/robotests/settings_robotest_modules.mk
deleted file mode 100644
index f7bc07a..0000000
--- a/tests/robotests/settings_robotest_modules.mk
+++ /dev/null
@@ -1,86 +0,0 @@
-# This is included by Android.mk located in the same folder.
-# It sets up all robotest sub-modules for RunSettingsRoboTests,
-# where the name of each target is defined based on the package
-# name under com.android.settings and order the targets
-# alphabetically.
-#
-# Nameing pattern for the target:
-# RunSettingsRoboTests-<package_name>
-#
-# For example:
-# RunSettingsRoboTests-core
-#
-#
-# TODO(b/130745039):decouple dependencies among each module
-
-#############################################################
-# Settings runner target to run applications module. #
-#############################################################
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := RunSettingsRoboTests-applications
-ROBOTEST_FILTER := applications
-
-LOCAL_JAVA_LIBRARIES := \
- SettingsRoboTests \
- robolectric_android-all-stub \
- Robolectric_all-target \
- mockito-robolectric-prebuilt \
- truth-prebuilt
-
-LOCAL_TEST_PACKAGE := SettingsRoboTestStub
-
-LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src \
- frameworks/base/packages/SettingsLib/search/src \
-
-LOCAL_ROBOTEST_TIMEOUT := 36000
-
-include external/robolectric-shadows/run_robotests.mk
-
-#############################################################
-# Settings runner target to run development module. #
-#############################################################
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := RunSettingsRoboTests-development
-ROBOTEST_FILTER := development
-
-LOCAL_JAVA_LIBRARIES := \
- SettingsRoboTests \
- robolectric_android-all-stub \
- Robolectric_all-target \
- mockito-robolectric-prebuilt \
- truth-prebuilt
-
-LOCAL_TEST_PACKAGE := SettingsRoboTestStub
-
-LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src \
- frameworks/base/packages/SettingsLib/search/src \
-
-LOCAL_ROBOTEST_TIMEOUT := 36000
-
-include external/robolectric-shadows/run_robotests.mk
-
-#############################################################
-# Settings runner target to run wifi module. #
-#############################################################
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := RunSettingsRoboTests-wifi
-ROBOTEST_FILTER := wifi
-
-LOCAL_JAVA_LIBRARIES := \
- SettingsRoboTests \
- robolectric_android-all-stub \
- Robolectric_all-target \
- mockito-robolectric-prebuilt \
- truth-prebuilt
-
-LOCAL_TEST_PACKAGE := SettingsRoboTestStub
-
-LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src \
- frameworks/base/packages/SettingsLib/search/src \
-
-LOCAL_ROBOTEST_TIMEOUT := 36000
-
-include external/robolectric-shadows/run_robotests.mk
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarDisabledPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarDisabledPreferenceControllerTest.java
new file mode 100644
index 0000000..2226e2c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarDisabledPreferenceControllerTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.accounts;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+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 static org.mockito.Mockito.when;
+import static org.robolectric.RuntimeEnvironment.application;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.UserHandle;
+
+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;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowDevicePolicyManager;
+
+import java.util.Collections;
+
+@RunWith(RobolectricTestRunner.class)
+public class CrossProfileCalendarDisabledPreferenceControllerTest {
+
+ private static final String PREF_KEY = "cross_profile_calendar_disabled";
+ private static final int MANAGED_USER_ID = 10;
+ private static final String TEST_PACKAGE_NAME = "com.test";
+ private static final ComponentName TEST_COMPONENT_NAME = new ComponentName("test", "test");
+
+ @Mock
+ private UserHandle mManagedUser;
+
+ private Context mContext;
+ private CrossProfileCalendarDisabledPreferenceController mController;
+ private ShadowDevicePolicyManager mDpm;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mController = new CrossProfileCalendarDisabledPreferenceController(mContext, PREF_KEY);
+ mController.setManagedUser(mManagedUser);
+ mDpm = Shadows.shadowOf(application.getSystemService(DevicePolicyManager.class));
+
+ when(mManagedUser.getIdentifier()).thenReturn(MANAGED_USER_ID);
+ doReturn(mContext).when(mContext).createPackageContextAsUser(
+ any(String.class), anyInt(), any(UserHandle.class));
+ }
+
+ @Test
+ public void getAvailabilityStatus_noPackageAllowed_shouldBeAvailable() {
+ mDpm.setProfileOwner(TEST_COMPONENT_NAME);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_somePackagesAllowed_shouldBeDisabledForUser() {
+ mDpm.setProfileOwner(TEST_COMPONENT_NAME);
+ mDpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME,
+ Collections.singleton(TEST_PACKAGE_NAME));
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getAvailabilityStatus_allPackagesAllowed_shouldBeDisabledForUser() {
+ mDpm.setProfileOwner(TEST_COMPONENT_NAME);
+ mDpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME, null);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarPreferenceControllerTest.java
index c6a48a8..7c60774 100644
--- a/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/CrossProfileCalendarPreferenceControllerTest.java
@@ -17,6 +17,9 @@
import static android.provider.Settings.Secure.CROSS_PROFILE_CALENDAR_ENABLED;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -37,6 +40,7 @@
import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -88,6 +92,7 @@
}
@Test
+ @Ignore("b/130896049")
public void getAvailabilityStatus_hasManagedUser_AVAILABLE() {
mController.setManagedUser(mManagedUser);
assertThat(mController.getAvailabilityStatus())
@@ -117,30 +122,27 @@
}
@Test
- public void updateState_noPackageAllowed_preferenceShouldBeDisabled() throws Exception {
+ public void getAvailabilityStatus_noPackageAllowed_shouldBeDisabledForUser() throws Exception {
dpm.setProfileOwner(TEST_COMPONENT_NAME);
- mController.updateState(mPreference);
- verify(mPreference).setDisabledByAdmin(any());
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
}
@Test
- public void updateState_somePackagesAllowed_preferenceShouldNotBeDisabled() throws Exception {
+ public void getAvailabilityStatus_somePackagesAllowed_shouldBeAvailable() throws Exception {
dpm.setProfileOwner(TEST_COMPONENT_NAME);
dpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME,
Collections.singleton(TEST_PACKAGE_NAME));
- mController.updateState(mPreference);
- verify(mPreference).setDisabledByAdmin(null);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
- public void updateState_allPackagesAllowed_preferenceShouldNotBeDisabled() throws Exception {
+ public void getAvailabilityStatus_allPackagesAllowed_shouldBeAvailable() throws Exception {
dpm.setProfileOwner(TEST_COMPONENT_NAME);
dpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME, null);
- mController.updateState(mPreference);
- verify(mPreference).setDisabledByAdmin(null);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java
index 74b35c9..57a56fc 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java
@@ -142,4 +142,24 @@
assertThat(application.getPackageManager().getComponentEnabledSetting(
mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
+
+ @Test
+ public void onBackPressed_fingerprintCountIsNotOne_fingerprintSuggestionActivityDisabled() {
+ Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(2);
+
+ mActivity.onBackPressed();
+
+ assertThat(application.getPackageManager().getComponentEnabledSetting(
+ mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
+ }
+
+ @Test
+ public void onBackPressed_fingerprintCountIsOne_fngerprintSuggestionActivityEnabled() {
+ Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(1);
+
+ mActivity.onBackPressed();
+
+ assertThat(application.getPackageManager().getComponentEnabledSetting(
+ mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
+ }
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 362b003..03e9b6f 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -27,6 +27,7 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
+import android.provider.DeviceConfig;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -35,7 +36,9 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.fuelgauge.BatteryMeterView;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.widget.LayoutPreference;
@@ -50,8 +53,8 @@
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowEntityHeaderController.class)
-public class AdvancedBluetoothDetailsHeaderControllerTest{
+@Config(shadows = {ShadowEntityHeaderController.class, ShadowDeviceConfig.class})
+public class AdvancedBluetoothDetailsHeaderControllerTest {
private static final int BATTERY_LEVEL_MAIN = 30;
private static final int BATTERY_LEVEL_LEFT = 25;
private static final int BATTERY_LEVEL_RIGHT = 45;
@@ -141,7 +144,9 @@
}
@Test
- public void getAvailabilityStatus_untetheredHeadset_returnAvailable() {
+ public void getAvailabilityStatus_untetheredHeadsetWithConfigOn_returnAvailable() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
@@ -150,7 +155,31 @@
}
@Test
- public void getAvailabilityStatus_notUntetheredHeadset_returnUnavailable() {
+ public void getAvailabilityStatus_untetheredHeadsetWithConfigOff_returnUnavailable() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "false", true);
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+ .thenReturn("true".getBytes());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notUntetheredHeadsetWithConfigOn_returnUnavailable() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+ .thenReturn("false".getBytes());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notUntetheredHeadsetWithConfigOff_returnUnavailable() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "false", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("false".getBytes());
@@ -169,17 +198,21 @@
@Test
public void onStart_isAvailable_registerCallback() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
mController.onStart();
verify(mBluetoothAdapter).addOnMetadataChangedListener(mBluetoothDevice,
- mContext.getMainExecutor() ,mController.mMetadataListener);
+ mContext.getMainExecutor(), mController.mMetadataListener);
}
@Test
public void onStop_isAvailable_unregisterCallback() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
@@ -197,7 +230,7 @@
mController.onStart();
verify(mBluetoothAdapter, never()).addOnMetadataChangedListener(mBluetoothDevice,
- mContext.getMainExecutor() ,mController.mMetadataListener);
+ mContext.getMainExecutor(), mController.mMetadataListener);
}
@Test
@@ -213,6 +246,8 @@
@Test
public void onDestroy_isAvailable_recycleBitmap() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
mController.mIconCache.put(ICON_URI, mBitmap);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
index 1ee1de6..94f8cc5 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
@@ -27,7 +27,9 @@
import android.graphics.drawable.Drawable;
import com.android.settings.R;
+import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
@@ -44,7 +46,7 @@
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowEntityHeaderController.class)
+@Config(shadows = {ShadowEntityHeaderController.class, ShadowDeviceConfig.class})
public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsControllerTestBase {
private BluetoothDetailsHeaderController mController;
@@ -123,10 +125,24 @@
}
@Test
- public void isAvailable_untetheredHeadset_returnFalse() {
+ public void isAvailable_untetheredHeadsetWithConfigOn_returnFalse() {
+ android.provider.DeviceConfig.setProperty(
+ android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("true".getBytes());
assertThat(mController.isAvailable()).isFalse();
}
+
+ @Test
+ public void isAvailable_untetheredHeadsetWithConfigOff_returnTrue() {
+ android.provider.DeviceConfig.setProperty(
+ android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI,
+ SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "false", true);
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("true".getBytes());
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index 24aae85..1066552 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -215,11 +215,14 @@
}
@Test
- public void forceUpdate_bluetoothDisabled_doNothing() {
+ public void forceUpdate_bluetoothDisabled_removeAllDevicesFromPreference() {
mShadowBluetoothAdapter.setEnabled(false);
+ mBluetoothDeviceUpdater.mPreferenceMap.put(mBluetoothDevice, mPreference);
+
mBluetoothDeviceUpdater.forceUpdate();
- verify(mDevicePreferenceCallback, never()).onDeviceAdded(any(Preference.class));
+ verify(mDevicePreferenceCallback).onDeviceRemoved(mPreference);
+ assertThat(mBluetoothDeviceUpdater.mPreferenceMap).isEmpty();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspectionTest.java b/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspectionTest.java
index 4062bfb..5fdadb4 100644
--- a/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspectionTest.java
+++ b/tests/robotests/src/com/android/settings/core/codeinspection/CodeInspectionTest.java
@@ -24,6 +24,7 @@
import com.android.settings.slices.SliceControllerInXmlCodeInspector;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,6 +47,7 @@
}
@Test
+ @Ignore("b/130897640")
public void runInstrumentableFragmentCodeInspection() {
new InstrumentableFragmentCodeInspector(mClasses).run();
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
index 438dfc1..9aae249 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
@@ -16,6 +16,7 @@
package com.android.settings.dashboard;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.DASHBOARD_CONTAINER;
+import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_KEYHINT;
import static com.google.common.truth.Truth.assertThat;
@@ -53,6 +54,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -79,6 +81,8 @@
mActivityInfo = new ActivityInfo();
mActivityInfo.packageName = "pkg";
mActivityInfo.name = "class";
+ mActivityInfo.metaData = new Bundle();
+ mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "injected_tile_key");
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mDashboardCategory = new DashboardCategory("key");
mDashboardCategory.addTile(new Tile(mActivityInfo, mDashboardCategory.key));
@@ -144,6 +148,20 @@
}
@Test
+ @Config(qualifiers = "mcc999")
+ public void displayTilesAsPreference_shouldNotAddSuppressedTiles() {
+ when(mFakeFeatureFactory.dashboardFeatureProvider
+ .getTilesForCategory(nullable(String.class)))
+ .thenReturn(mDashboardCategory);
+ when(mFakeFeatureFactory.dashboardFeatureProvider
+ .getDashboardKeyForTile(nullable(Tile.class)))
+ .thenReturn("test_key");
+ mTestFragment.onCreatePreferences(new Bundle(), "rootKey");
+
+ verify(mTestFragment.mScreen, never()).addPreference(nullable(Preference.class));
+ }
+
+ @Test
public void onAttach_shouldCreatePlaceholderPreferenceController() {
final AbstractPreferenceController controller = mTestFragment.use(
DashboardTilePlaceholderPreferenceController.class);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index 18ddd8a..4543114 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -16,6 +16,8 @@
package com.android.settings.deviceinfo;
+import static android.content.Context.CLIPBOARD_SERVICE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -24,6 +26,7 @@
import static org.mockito.Mockito.verify;
import android.app.Activity;
+import android.content.ClipboardManager;
import android.content.Context;
import android.os.Process;
import android.os.UserManager;
@@ -190,4 +193,14 @@
assertThat(activityResultHandled).isTrue();
assertThat(DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)).isTrue();
}
+
+ @Test
+ public void copy_shouldCopyBuildNumberToClipboard() {
+ mController.copy();
+
+ final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
+ CLIPBOARD_SERVICE);
+ final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
+ assertThat(data.toString()).isEqualTo(mController.getSummary());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceControllerTest.java
index 3784f08..3f050db 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SimpleBuildNumberPreferenceControllerTest.java
@@ -16,11 +16,10 @@
package com.android.settings.deviceinfo.firmwareversion;
-import static android.content.Context.CLIPBOARD_SERVICE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.google.common.truth.Truth.assertThat;
-import android.content.ClipboardManager;
import android.content.Context;
import org.junit.Before;
@@ -45,12 +44,7 @@
}
@Test
- public void copy_shouldCopyBuildNumberToClipboard() {
- mController.copy();
-
- final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
- CLIPBOARD_SERVICE);
- final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
- assertThat(data.toString()).isEqualTo(mController.getSummary());
+ public void getAvailabilityStatus_unsearchable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java
new file mode 100644
index 0000000..98ffbd0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.deviceinfo.hardwareinfo;
+
+import static android.content.Context.CLIPBOARD_SERVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.os.SystemProperties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class HardwareRevisionPreferenceControllerTest {
+
+ private Context mContext;
+ private HardwareRevisionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new HardwareRevisionPreferenceController(mContext,
+ "hardware_info_device_revision");
+ }
+
+ @Test
+ public void isSliceable_shouldBeSliceable() {
+ assertThat(mController.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isCopyableSlice_shouldBeCopyableSlice() {
+ assertThat(mController.isCopyableSlice()).isTrue();
+ }
+
+ @Test
+ public void copy_shouldCopyHardwareRevisionToClipboard() {
+ final String fakeHardwareVer = "FakeVer1.0";
+ SystemProperties.set("ro.boot.hardware.revision", fakeHardwareVer);
+
+ mController.copy();
+
+ final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
+ CLIPBOARD_SERVICE);
+ final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
+
+ assertThat(data.toString()).isEqualTo(fakeHardwareVer);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
index 9adb1ad..8938873 100644
--- a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
@@ -32,6 +32,7 @@
import com.android.settingslib.RestrictedPreference;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -40,6 +41,7 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
+@Ignore("b/130897305")
public class AdaptiveSleepPreferenceControllerTest {
private static final String PREFERENCE_KEY = "adaptive_sleep";
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java b/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java
index 7a8bded..87284ed 100644
--- a/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java
@@ -28,6 +28,7 @@
import android.content.SharedPreferences;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -49,6 +50,7 @@
}
@Test
+ @Ignore("b/130897882")
public void dialogDismissedOnConfirmation() {
doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
SharedPreferences prefs = RuntimeEnvironment.application.getSharedPreferences(
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
index 2e2d631..b9c2abd 100644
--- a/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
@@ -85,10 +85,24 @@
}
@Test
+ public void rangeOfSlider_staysWithinValidRange() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.integer.config_nightDisplayColorTemperatureMin, 2950);
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.integer.config_nightDisplayColorTemperatureMax, 3050);
+
+ assertThat(mPreferenceController.getMax() - mPreferenceController.getMin())
+ .isGreaterThan(0);
+ }
+
+ @Test
+ public void getMin_alwaysReturnsZero() {
+ assertThat(mPreferenceController.getMin()).isEqualTo(0);
+ }
+
+ @Test
public void isSliceableCorrectKey_returnsTrue() {
- final NightDisplayIntensityPreferenceController controller =
- new NightDisplayIntensityPreferenceController(mContext, "night_display_temperature");
- assertThat(controller.isSliceable()).isTrue();
+ assertThat(mPreferenceController.isSliceable()).isTrue();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
index ca9dfcc..c9a6978 100644
--- a/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
@@ -116,6 +116,30 @@
}
@Test
+ public void getKeywords_withoutStyles() {
+ mShadowPackageManager.setResolveInfosForIntent(
+ mStylesAndWallpaperIntent, Lists.newArrayList());
+
+ assertThat(mController.getKeywords())
+ .contains(mContext.getString(R.string.keywords_wallpaper));
+ assertThat(mController.getKeywords())
+ .doesNotContain(mContext.getString(R.string.theme_customization_category));
+ }
+
+ @Test
+ public void getKeywords_withStyles() {
+ mShadowPackageManager.setResolveInfosForIntent(
+ mStylesAndWallpaperIntent,
+ Lists.newArrayList(mock(ResolveInfo.class)));
+
+ assertThat(mController.areStylesAvailable()).isTrue();
+ assertThat(mController.getKeywords())
+ .contains(mContext.getString(R.string.keywords_wallpaper));
+ assertThat(mController.getKeywords())
+ .contains(mContext.getString(R.string.theme_customization_category));
+ }
+
+ @Test
public void handlePreferenceTreeClick_wallpaperOnly() {
mShadowPackageManager.setResolveInfosForIntent(
mWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index d5e0ed8..6b917f0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -41,6 +41,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.widget.UsageView;
import com.android.settingslib.R;
+import com.android.settingslib.fuelgauge.Estimate;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index e911902..df9a194 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -28,7 +28,6 @@
import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
-import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.HighUsageTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
@@ -37,6 +36,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settingslib.fuelgauge.EstimateKt;
import org.junit.Before;
import org.junit.Test;
@@ -96,7 +96,7 @@
mUnrestrictAppTip = new UnrestrictAppTip(BatteryTip.StateType.NEW, mAppInfo);
mSummaryTip = spy(new SummaryTip(BatteryTip.StateType.NEW,
- Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
+ EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
index 88f8303..9d27541 100644
--- a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
@@ -139,7 +139,7 @@
}
@Test
- public void testUpdateState_notConfigurable() {
+ public void testUpdateState_notBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -150,7 +150,7 @@
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
+ assertTrue(pref.isEnabled());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java
index 8265295..9ea201a 100644
--- a/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BadgePreferenceControllerTest.java
@@ -187,7 +187,7 @@
}
@Test
- public void testUpdateState_channelNotConfigurable() {
+ public void testUpdateState_channelNotBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -198,7 +198,7 @@
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
+ assertTrue(pref.isEnabled());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
index 54bbd08..0d0b485 100644
--- a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
@@ -202,7 +202,7 @@
}
@Test
- public void testUpdateState_channelNotConfigurable() {
+ public void testUpdateState_channelNotBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -213,7 +213,7 @@
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
+ assertTrue(pref.isEnabled());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/ChannelSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/notification/ChannelSummaryPreferenceTest.java
deleted file mode 100644
index 408b2b6..0000000
--- a/tests/robotests/src/com/android/settings/notification/ChannelSummaryPreferenceTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.notification;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.CheckBox;
-import android.widget.LinearLayout;
-
-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;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
-
-@RunWith(RobolectricTestRunner.class)
-public class ChannelSummaryPreferenceTest {
-
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- }
-
- @Test
- public void createNewPreference_shouldSetLayout() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- assertThat(preference.getLayoutResource()).isEqualTo(
- R.layout.preference_checkable_two_target);
- assertThat(preference.getWidgetLayoutResource()).isEqualTo(
- R.layout.zen_rule_widget);
- }
-
- @Test
- public void setChecked_shouldUpdateButtonCheckedState() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.preference_checkable_two_target, null));
- final LinearLayout widgetView = holder.itemView.findViewById(R.id.checkbox_container);
- inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
- final CheckBox toggle = (CheckBox) holder.findViewById(com.android.internal.R.id.checkbox);
- preference.onBindViewHolder(holder);
-
- preference.setChecked(true);
- assertThat(toggle.isChecked()).isTrue();
-
- preference.setChecked(false);
- assertThat(toggle.isChecked()).isFalse();
- }
-
- @Test
- public void setCheckboxEnabled_shouldUpdateButtonEnabledState() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.preference_checkable_two_target, null));
- final LinearLayout widgetView = holder.itemView.findViewById(R.id.checkbox_container);
- inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
- final CheckBox toggle = (CheckBox) holder.findViewById(com.android.internal.R.id.checkbox);
- preference.onBindViewHolder(holder);
-
- preference.setCheckBoxEnabled(true);
- assertThat(toggle.isEnabled()).isTrue();
-
- preference.setCheckBoxEnabled(false);
- assertThat(toggle.isEnabled()).isFalse();
- }
-
- @Test
- public void setCheckBoxEnabled_shouldUpdateButtonEnabledState_beforeViewBound() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.preference_checkable_two_target, null));
- final LinearLayout widgetView = holder.itemView.findViewById(R.id.checkbox_container);
- inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
- final CheckBox toggle = (CheckBox) holder.findViewById(com.android.internal.R.id.checkbox);
-
- preference.setCheckBoxEnabled(false);
- preference.onBindViewHolder(holder);
- assertThat(toggle.isEnabled()).isFalse();
- }
-
- @Test
- public void clickWidgetView_shouldToggleButton() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.preference_checkable_two_target, null));
- final LinearLayout widgetView = holder.itemView.findViewById(R.id.checkbox_container);
- assertThat(widgetView).isNotNull();
-
- inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
- final CheckBox toggle = (CheckBox) holder.findViewById(com.android.internal.R.id.checkbox);
- preference.onBindViewHolder(holder);
-
- widgetView.performClick();
- assertThat(toggle.isChecked()).isTrue();
-
- widgetView.performClick();
- assertThat(toggle.isChecked()).isFalse();
- }
-
- @Test
- public void clickWidgetView_shouldNotToggleButtonIfDisabled() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.preference_checkable_two_target, null));
- final LinearLayout widgetView = holder.itemView.findViewById(R.id.checkbox_container);
- assertThat(widgetView).isNotNull();
-
- inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
- final CheckBox toggle = (CheckBox) holder.findViewById(com.android.internal.R.id.checkbox);
- preference.onBindViewHolder(holder);
- toggle.setEnabled(false);
-
- widgetView.performClick();
- assertThat(toggle.isChecked()).isFalse();
- }
-
- @Test
- public void clickWidgetView_shouldNotifyPreferenceChanged() {
- final ChannelSummaryPreference preference = new ChannelSummaryPreference(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- LayoutInflater.from(mContext).inflate(
- R.layout.preference_checkable_two_target, null));
- final View widgetView = holder.findViewById(R.id.checkbox_container);
- final Preference.OnPreferenceChangeListener
- listener = mock(Preference.OnPreferenceChangeListener.class);
- preference.setOnPreferenceChangeListener(listener);
- preference.onBindViewHolder(holder);
-
- preference.setChecked(false);
- widgetView.performClick();
- verify(listener).onPreferenceChange(preference, true);
-
- preference.setChecked(true);
- widgetView.performClick();
- verify(listener).onPreferenceChange(preference, false);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java
index 0b2af49..929c14d 100644
--- a/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DndPreferenceControllerTest.java
@@ -110,7 +110,7 @@
}
@Test
- public void testUpdateState_notConfigurable() {
+ public void testUpdateState_notBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -121,7 +121,7 @@
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
+ assertTrue(pref.isEnabled());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
index cee7a06..c9f62e9 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
@@ -117,12 +117,12 @@
}
@Test
- public void testIsAvailable_evenIfChannelBlocked() {
+ public void testIsAvailable_ifChannelBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
mController.onResume(appRow, channel, null, null);
- assertTrue(mController.isAvailable());
+ assertFalse(mController.isAvailable());
}
@Test
@@ -183,8 +183,8 @@
mController.updateState(pref);
verify(pref, times(1)).setConfigurable(anyBoolean());
- verify(pref, times(1)).setBlockable(anyBoolean());
verify(pref, times(1)).setImportance(IMPORTANCE_HIGH);
+ verify(pref, times(1)).setDisplayInStatusBar(false);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
index eebfbd1..63bc828 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
@@ -27,18 +27,12 @@
import static org.mockito.Mockito.verify;
import android.content.Context;
-import android.graphics.Color;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.LayerDrawable;
import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.Switch;
+import android.widget.Button;
+import android.widget.TextView;
import com.android.settings.R;
-import com.android.settingslib.RestrictedLockUtils;
import org.junit.Before;
import org.junit.Test;
@@ -46,7 +40,6 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
@RunWith(RobolectricTestRunner.class)
@@ -59,11 +52,6 @@
mContext = RuntimeEnvironment.application;
}
- private GradientDrawable getBackground(ImageButton button) {
- return (GradientDrawable) ((LayerDrawable) button.getDrawable())
- .findDrawableByLayerId(R.id.back);
- }
-
@Test
public void createNewPreference_shouldSetLayout() {
final ImportancePreference preference = new ImportancePreference(mContext);
@@ -72,36 +60,26 @@
}
@Test
- public void onBindViewHolder_hideBlockNonBlockable() {
- final ImportancePreference preference = new ImportancePreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.notif_importance_preference, null));
-
- preference.setBlockable(false);
- preference.setConfigurable(true);
- preference.setImportance(IMPORTANCE_DEFAULT);
- preference.onBindViewHolder(holder);
-
- assertThat(holder.itemView.findViewById(R.id.block).getVisibility()).isEqualTo(View.GONE);
- }
-
- @Test
- public void onBindViewHolder_hideNonSelectedNonConfigurable() {
+ public void onBindViewHolder_nonConfigurable() {
final ImportancePreference preference = new ImportancePreference(mContext);
final LayoutInflater inflater = LayoutInflater.from(mContext);
PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
inflater.inflate(R.layout.notif_importance_preference, null));
+ Drawable unselected = mock(Drawable.class);
+ Drawable selected = mock(Drawable.class);
+ preference.selectedBackground = selected;
+ preference.unselectedBackground = unselected;
- preference.setBlockable(true);
preference.setConfigurable(false);
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
- assertThat(holder.itemView.findViewById(R.id.block).getVisibility()).isEqualTo(View.GONE);
- assertThat(holder.itemView.findViewById(R.id.silence).getVisibility()).isEqualTo(View.GONE);
- assertThat(holder.itemView.findViewById(R.id.alert).getVisibility())
- .isEqualTo(View.VISIBLE);
+ assertThat(holder.itemView.findViewById(R.id.silence).isEnabled()).isFalse();
+ assertThat(holder.itemView.findViewById(R.id.alert).isEnabled()).isFalse();
+
+ assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
+ assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
+ .isEqualTo(unselected);
// other button
preference.setImportance(IMPORTANCE_LOW);
@@ -109,37 +87,31 @@
inflater.inflate(R.layout.notif_importance_preference, null));
preference.onBindViewHolder(holder);
- assertThat(holder.itemView.findViewById(R.id.block).getVisibility()).isEqualTo(View.GONE);
- assertThat(holder.itemView.findViewById(R.id.silence).getVisibility())
- .isEqualTo(View.VISIBLE);
- assertThat(holder.itemView.findViewById(R.id.alert).getVisibility())
- .isEqualTo(View.GONE);
+ assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
+ assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
}
@Test
- public void onBindViewHolder_selectButton() {
+ public void onBindViewHolder_selectButtonAndText() {
final ImportancePreference preference = new ImportancePreference(mContext);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
inflater.inflate(R.layout.notif_importance_preference, null));
+ Drawable unselected = mock(Drawable.class);
+ Drawable selected = mock(Drawable.class);
+ preference.selectedBackground = selected;
+ preference.unselectedBackground = unselected;
- preference.setBlockable(true);
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_DEFAULT);
- ImageButton blockButton = (ImageButton) holder.findViewById(R.id.block_icon);
- ImageButton silenceButton = (ImageButton) holder.findViewById(R.id.silence_icon);
- ImageButton alertButton = (ImageButton) holder.findViewById(R.id.alert_icon);
-
preference.onBindViewHolder(holder);
- // selected has full color background. others are transparent
- assertThat(getBackground(alertButton).getColor().getColors()[0]).isNotEqualTo(
- Color.TRANSPARENT);
- assertThat(getBackground(silenceButton).getColor().getColors()[0]).isEqualTo(
- Color.TRANSPARENT);
- assertThat(getBackground(blockButton).getColor().getColors()[0]).isEqualTo(
- Color.TRANSPARENT);
+ assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
+ assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
+ .isEqualTo(unselected);
+ assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_default));
}
@Test
@@ -148,45 +120,84 @@
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
inflater.inflate(R.layout.notif_importance_preference, null));
+ Drawable unselected = mock(Drawable.class);
+ Drawable selected = mock(Drawable.class);
+ preference.selectedBackground = selected;
+ preference.unselectedBackground = unselected;
- preference.setBlockable(true);
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
- ImageButton blockButton = (ImageButton) holder.findViewById(R.id.block_icon);
- ImageButton silenceButton = (ImageButton) holder.findViewById(R.id.silence_icon);
- ImageButton alertButton = (ImageButton) holder.findViewById(R.id.alert_icon);
+ Button silenceButton = holder.itemView.findViewById(R.id.silence);
silenceButton.callOnClick();
- // selected has full color background. others are transparent
- assertThat(getBackground(silenceButton).getColor().getColors()[0]).isNotEqualTo(
- Color.TRANSPARENT);
- assertThat(getBackground(alertButton).getColor().getColors()[0]).isEqualTo(
- Color.TRANSPARENT);
- assertThat(getBackground(blockButton).getColor().getColors()[0]).isEqualTo(
- Color.TRANSPARENT);
+ assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
+ assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
+ assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_low));
verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
}
@Test
- public void onBindViewHolder_allButtonsVisible() {
- final ImportancePreference preference = new ImportancePreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
- inflater.inflate(R.layout.notif_importance_preference, null));
+ public void setImportanceSummary_status() {
+ TextView tv = new TextView(mContext);
- preference.setBlockable(true);
- preference.setConfigurable(true);
- preference.onBindViewHolder(holder);
+ final ImportancePreference preference = spy(new ImportancePreference(mContext));
- assertThat(holder.itemView.findViewById(R.id.block).getVisibility())
- .isEqualTo(View.VISIBLE);
- assertThat(holder.itemView.findViewById(R.id.silence).getVisibility())
- .isEqualTo(View.VISIBLE);
- assertThat(holder.itemView.findViewById(R.id.alert).getVisibility())
- .isEqualTo(View.VISIBLE);
+ preference.setDisplayInStatusBar(true);
+ preference.setDisplayOnLockscreen(false);
+
+ preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+
+ assertThat(tv.getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_low_status));
+ }
+
+ @Test
+ public void setImportanceSummary_lock() {
+ TextView tv = new TextView(mContext);
+
+ final ImportancePreference preference = spy(new ImportancePreference(mContext));
+
+ preference.setDisplayInStatusBar(false);
+ preference.setDisplayOnLockscreen(true);
+
+ preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+
+ assertThat(tv.getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_low_lock));
+ }
+
+ @Test
+ public void setImportanceSummary_statusLock() {
+ TextView tv = new TextView(mContext);
+
+ final ImportancePreference preference = spy(new ImportancePreference(mContext));
+
+ preference.setDisplayInStatusBar(true);
+ preference.setDisplayOnLockscreen(true);
+
+ preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+
+ assertThat(tv.getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_low_status_lock));
+ }
+
+ @Test
+ public void setImportanceSummary_statusLock_default() {
+ TextView tv = new TextView(mContext);
+
+ final ImportancePreference preference = spy(new ImportancePreference(mContext));
+
+ preference.setDisplayInStatusBar(true);
+ preference.setDisplayOnLockscreen(true);
+
+ preference.setImportanceSummary(tv, IMPORTANCE_DEFAULT);
+
+ assertThat(tv.getText()).isEqualTo(
+ mContext.getString(R.string.notification_channel_summary_default));
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
index dd6a620..3724ddb 100644
--- a/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
@@ -158,7 +158,7 @@
}
@Test
- public void testUpdateState_notConfigurable() {
+ public void testUpdateState_notBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -169,19 +169,6 @@
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
- }
-
- @Test
- public void testUpdateState_configurable() {
- NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- NotificationChannel channel = mock(NotificationChannel.class);
- when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
-
- Preference pref = new RestrictedSwitchPreference(mContext);
- mController.updateState(pref);
-
assertTrue(pref.isEnabled());
}
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
index 626d2e3..a72597b 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
@@ -83,7 +83,6 @@
mController.updateState(mock(Preference.class));
assertFalse(mController.checkCanBeVisible(IMPORTANCE_UNSPECIFIED));
mController.saveChannel();
- assertFalse(mController.isChannelConfigurable());
assertFalse(mController.isChannelBlockable());
assertFalse(mController.isChannelGroupBlockable());
}
@@ -204,33 +203,36 @@
}
@Test
- public void testIsConfigurable() {
+ public void testIsBlockable_channelLevelWhitelist() {
String sameId = "bananas";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = sameId;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn(sameId);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
mController.onResume(appRow, channel, null, null);
- assertFalse(mController.isChannelConfigurable());
+ assertFalse(mController.isChannelBlockable());
when(channel.getId()).thenReturn("something new");
mController.onResume(appRow, channel, null, null);
- assertTrue(mController.isChannelConfigurable());
+ assertTrue(mController.isChannelBlockable());
}
@Test
- public void testIsConfigurable_appLevel() {
+ public void testIsBlockable_appLevelWhitelist() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = "something";
appRow.lockedImportance = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
- assertFalse(mController.isChannelConfigurable());
+ mController.onResume(appRow, channel, null, null);
+ assertFalse(mController.isChannelBlockable());
appRow.lockedImportance = false;
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
- assertTrue(mController.isChannelConfigurable());
+ assertTrue(mController.isChannelBlockable());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index 866f866..1d9836e 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -161,7 +161,7 @@
}
@Test
- public void testUpdateState_notConfigurable() {
+ public void testUpdateState_notBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -173,7 +173,7 @@
Preference pref = new NotificationSoundPreference(mContext, attributeSet);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
+ assertTrue(pref.isEnabled());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java
index e1d5b73..adc10f4 100644
--- a/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VibrationPreferenceControllerTest.java
@@ -140,7 +140,7 @@
}
@Test
- public void testUpdateState_notConfigurable() {
+ public void testUpdateState_notBlockable() {
String lockedId = "locked";
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = lockedId;
@@ -151,7 +151,7 @@
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
- assertFalse(pref.isEnabled());
+ assertTrue(pref.isEnabled());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index fd2e806..793b44d 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -36,6 +36,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -105,6 +106,7 @@
}
@Test
+ @Ignore("b/130896218")
public void onDestroy_logCloseEvent() {
mPanelFragment.onDestroy();
verify(mFakeFeatureFactory.metricsFeatureProvider).action(
@@ -115,6 +117,7 @@
0); }
@Test
+ @Ignore("b/130896218")
public void panelSeeMoreClick_logsCloseEvent() {
final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
@@ -130,6 +133,7 @@
}
@Test
+ @Ignore("b/130896218")
public void panelDoneClick_logsCloseEvent() {
final View.OnClickListener listener = mPanelFragment.getCloseListener();
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index 14a7db9..922e629 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -16,12 +16,14 @@
package com.android.settings.panel;
+import static com.android.settings.panel.PanelSlicesAdapter.MAX_NUM_OF_SLICES;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
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.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -40,7 +42,6 @@
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.Test;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
@@ -62,11 +63,6 @@
private FakePanelContent mFakePanelContent;
private List<LiveData<Slice>> mData = new ArrayList<>();
- @Mock
- private LiveData<Slice> mLiveData;
-
- private Slice mSlice;
-
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -91,17 +87,18 @@
}
- private void constructTestLiveData(Uri uri) {
+ private void addTestLiveData(Uri uri) {
// Create a slice to return for the LiveData
- mSlice = spy(new Slice());
- doReturn(uri).when(mSlice).getUri();
- when(mLiveData.getValue()).thenReturn(mSlice);
- mData.add(mLiveData);
+ final Slice slice = spy(new Slice());
+ doReturn(uri).when(slice).getUri();
+ final LiveData<Slice> liveData = mock(LiveData.class);
+ when(liveData.getValue()).thenReturn(slice);
+ mData.add(liveData);
}
@Test
public void onCreateViewHolder_returnsSliceRowViewHolder() {
- constructTestLiveData(DATA_URI);
+ addTestLiveData(DATA_URI);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final ViewGroup view = new FrameLayout(mContext);
@@ -112,8 +109,26 @@
}
@Test
+ public void sizeOfAdapter_shouldNotExceedMaxNum() {
+ for (int i = 0; i < MAX_NUM_OF_SLICES + 2; i++) {
+ addTestLiveData(DATA_URI);
+ }
+
+ assertThat(mData.size()).isEqualTo(MAX_NUM_OF_SLICES + 2);
+
+ final PanelSlicesAdapter adapter =
+ new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
+ final ViewGroup view = new FrameLayout(mContext);
+ final PanelSlicesAdapter.SliceRowViewHolder viewHolder =
+ adapter.onCreateViewHolder(view, 0);
+
+ assertThat(adapter.getItemCount()).isEqualTo(MAX_NUM_OF_SLICES);
+ assertThat(adapter.getData().size()).isEqualTo(MAX_NUM_OF_SLICES);
+ }
+
+ @Test
public void nonMediaOutputIndicatorSlice_shouldAllowDividerAboveAndBelow() {
- constructTestLiveData(DATA_URI);
+ addTestLiveData(DATA_URI);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
@@ -129,7 +144,7 @@
@Test
public void mediaOutputIndicatorSlice_shouldNotAllowDividerAbove() {
- constructTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
+ addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index fa15aa0..4ca6395 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -35,6 +35,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -89,6 +90,7 @@
}
@Test
+ @Ignore("b/130896218")
public void onTouchEvent_outsideAction_logsPanelClosed() {
final MotionEvent event = mock(MotionEvent.class);
when(event.getAction()).thenReturn(MotionEvent.ACTION_OUTSIDE);
diff --git a/tests/robotests/src/com/android/settings/panel/VolumePanelTest.java b/tests/robotests/src/com/android/settings/panel/VolumePanelTest.java
index 11de7b3..154428d 100644
--- a/tests/robotests/src/com/android/settings/panel/VolumePanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/VolumePanelTest.java
@@ -23,6 +23,7 @@
import com.android.settings.slices.CustomSliceRegistry;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -41,6 +42,7 @@
}
@Test
+ @Ignore("b/130896218")
public void getSlices_containsNecessarySlices() {
final List<Uri> uris = mPanel.getSlices();
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 9f12130..96aaf46 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -31,10 +31,12 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.PendingIntent;
import android.app.slice.SliceManager;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.StrictMode;
@@ -445,6 +447,16 @@
}
@Test
+ public void onCreatePermissionRequest_returnsSettingIntent() {
+ final PendingIntent pendingIntent = mProvider.onCreatePermissionRequest(
+ CustomSliceRegistry.FLASHLIGHT_SLICE_URI, "com.android.whaaaat");
+ PendingIntent settingsPendingIntent =
+ PendingIntent.getActivity(mContext, 0, new Intent(Settings.ACTION_SETTINGS), 0);
+
+ assertThat(pendingIntent).isEqualTo(settingsPendingIntent);
+ }
+
+ @Test
public void bindSlice_wifiSlice_returnsWifiSlice() {
final Slice wifiSlice = mProvider.onBindSlice(CustomSliceRegistry.WIFI_SLICE_URI);
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 2acfc4a..906c55c 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -83,6 +83,7 @@
import com.android.settingslib.wifi.WifiTrackerFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -105,6 +106,7 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDevicePolicyManager.class, ShadowEntityHeaderController.class})
+@Ignore("b/130896210")
public class WifiDetailPreferenceControllerTest {
private static final int LEVEL = 1;