Merge "[Settings] Make UI be able to update current status, after SIM absent." into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index aa2a142..60dbb24 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1323,7 +1323,8 @@
<activity
android:name=".notification.history.NotificationHistoryActivity"
android:exported="true"
- android:label="@string/notification_history_title">
+ android:label="@string/notification_history_title"
+ android:theme="@style/Theme.Settings.NoActionBar">
<intent-filter android:priority="1">
<action android:name="android.settings.NOTIFICATION_HISTORY" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1517,7 +1518,8 @@
<activity android:name=".applications.specialaccess.deviceadmin.DeviceAdminAdd"
android:label="@string/device_admin_add_title"
android:exported="true"
- android:clearTaskOnLaunch="true">
+ android:clearTaskOnLaunch="true"
+ android:theme="@style/Theme.Settings.NoActionBar">
<intent-filter>
<action android:name="android.app.action.ADD_DEVICE_ADMIN" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/drawable-night/ic_enhanced_connectivity.xml b/res/drawable-night/ic_enhanced_connectivity.xml
new file mode 100644
index 0000000..cd25667
--- /dev/null
+++ b/res/drawable-night/ic_enhanced_connectivity.xml
@@ -0,0 +1,91 @@
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="412dp"
+ android:height="300dp"
+ android:viewportWidth="412"
+ android:viewportHeight="300">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M28.1,0L383.9,0A28.1,28.1 0,0 1,412 28.1L412,271.9A28.1,28.1 0,0 1,383.9 300L28.1,300A28.1,28.1 0,0 1,0 271.9L0,28.1A28.1,28.1 0,0 1,28.1 0z"/>
+ <path
+ android:pathData="M206,150m-108.79,0a108.79,108.79 0,1 1,217.58 0a108.79,108.79 0,1 1,-217.58 0"
+ android:strokeAlpha="0.2"
+ android:fillColor="#d2e3fc"
+ android:fillAlpha="0.2"/>
+ <path
+ android:pathData="M206,150m-93.27,0a93.27,93.27 0,1 1,186.54 0a93.27,93.27 0,1 1,-186.54 0"
+ android:strokeAlpha="0.2"
+ android:fillColor="#d2e3fc"
+ android:fillAlpha="0.2"/>
+ <path
+ android:pathData="M206,150m-77.85,0a77.85,77.85 0,1 1,155.7 0a77.85,77.85 0,1 1,-155.7 0"
+ android:strokeAlpha="0.2"
+ android:fillColor="#d2e3fc"
+ android:fillAlpha="0.2"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M153.7,35.5H256.88A7.09,7.09 0,0 1,264 42.57V257.19a7.09,7.09 0,0 1,-7.12 7.06H153.7a7.09,7.09 0,0 1,-7.13 -7.06V42.57A7.1,7.1 0,0 1,153.7 35.5Z"/>
+ <path
+ android:pathData="M267.85,102.26L267.85,93.58a2.17,2.17 0,0 0,-2.17 -2.17L265.68,45.83A10.87,10.87 0,0 0,254.83 35L155,35a10.87,10.87 0,0 0,-10.85 10.85L144.15,254.17A10.87,10.87 0,0 0,155 265h99.83a10.87,10.87 0,0 0,10.85 -10.85L265.68,147.83a2.17,2.17 0,0 0,2.17 -2.17L267.85,124a2.17,2.17 0,0 0,-2.17 -2.17L265.68,104.43A2.17,2.17 0,0 0,267.85 102.26ZM263.51,254.17a8.7,8.7 0,0 1,-8.68 8.68L155,262.85a8.7,8.7 0,0 1,-8.68 -8.68L146.32,45.83A8.7,8.7 0,0 1,155 37.15h99.83a8.7,8.7 0,0 1,8.68 8.68Z"
+ android:fillColor="#80868b"/>
+ <path
+ android:pathData="M199.72,230.82h14a4.45,4.45 0,0 1,4.45 4.45h0a4.46,4.46 0,0 1,-4.45 4.46h-14a4.46,4.46 0,0 1,-4.45 -4.46h0a4.45,4.45 0,0 1,4.45 -4.45Z"
+ android:fillColor="#3c4043"/>
+ <path
+ android:pathData="M211.83,228.91h0a6.36,6.36 0,0 1,6.36 6.36h0a6.36,6.36 0,0 1,-6.35 6.37h0a6.37,6.37 0,0 1,-6.37 -6.37h0a6.36,6.36 0,0 1,6.36 -6.36Z"
+ android:fillColor="#669df6"/>
+ <path
+ android:pathData="M206.59,179.58m-15.27,0a15.27,15.27 0,1 1,30.54 0a15.27,15.27 0,1 1,-30.54 0"
+ android:fillColor="#f1f3f4"/>
+ <path
+ android:pathData="M191.32,179.58a15.27,15.24 0,1 0,30.54 0a15.27,15.24 0,1 0,-30.54 0z"
+ android:fillColor="#feefc3"/>
+ <path
+ android:pathData="M206.59,172.63l-5.72,4.29l0,8.59l3.57,0l0,-5.01l4.3,0l0,5.01l3.57,0l0,-8.59l-5.72,-4.29z"
+ android:fillColor="#fcc934"/>
+ <path
+ android:pathData="M168.97,105.11m-15.24,0a15.24,15.24 0,1 1,30.48 0a15.24,15.24 0,1 1,-30.48 0"
+ android:fillColor="#fad2cf"/>
+ <path
+ android:pathData="M172.6,111.39L172.6,100.28a0.92,0.92 0,0 0,-0.92 -0.92h-1.22L170.46,97.87h-2.9v1.42h-1.2a0.93,0.93 0,0 0,-0.93 0.92v11.07a0.93,0.93 0,0 0,0.93 0.92h5.31A0.92,0.92 0,0 0,172.6 111.39ZM171.15,100.77L171.15,106h-4.34v-5.2Z"
+ android:fillColor="#ee675c"/>
+ <path
+ android:pathData="M243.03,151.92m-15.27,0a15.27,15.27 0,1 1,30.54 0a15.27,15.27 0,1 1,-30.54 0"
+ android:fillColor="#fad2cf"/>
+ <path
+ android:pathData="M248.3,146.31a1.09,1.09 0,0 0,-1 -0.73h-8a1.1,1.1 0,0 0,-1 0.73l-1.5,4.34v5.8a0.71,0.71 0,0 0,0.71 0.73h0.79a0.72,0.72 0,0 0,0.72 -0.72h0v-0.72h8.68v0.72a0.73,0.73 0,0 0,0.73 0.73h0.72a0.73,0.73 0,0 0,0.73 -0.73v-5.79ZM240,153.54a1.09,1.09 0,1 1,1.09 -1.09h0a1.08,1.08 0,0 1,-1 1.12h0ZM246.52,153.54a1.09,1.09 0,1 1,1.08 -1.1v0a1.09,1.09 0,0 1,-1 1.12ZM238.75,149.28 L239.53,147.03L247,147.03l0.78,2.25Z"
+ android:fillColor="#ee675c"/>
+ <path
+ android:pathData="M168.97,151.92m-15.27,0a15.27,15.27 0,1 1,30.54 0a15.27,15.27 0,1 1,-30.54 0"
+ android:fillColor="#d2e3fc"/>
+ <path
+ android:pathData="M175.8,149.23a3.68,3.68 0,0 0,-3.69 -3.08h-5.63a3.73,3.73 0,0 0,-3.69 3.08s-1.17,6.76 -1.17,6.86a1.61,1.61 0,0 0,2.72 1.15l2.66,-2.63h4.61l2.66,2.63a1.61,1.61 0,0 0,2.73 -1.15C177,156 175.8,149.23 175.8,149.23ZM168.51,150.77L167,150.77v1.53h-0.77v-1.53h-1.53L164.7,150h1.53v-1.54L167,148.46L167,150h1.54ZM170.67,151a0.62,0.62 0,1 1,0.61 -0.63h0a0.62,0.62 0,0 1,-0.61 0.62ZM171.97,152.3a0.61,0.61 0,0 1,-0.63 -0.6,0.62 0.62,0 0,1 1.24,0h0a0.61,0.61 0,0 1,-0.61 0.61ZM171.97,149.69a0.62,0.62 0,1 1,0.61 -0.63h0a0.62,0.62 0,0 1,-0.61 0.62ZM173.28,151a0.62,0.62 0,1 1,0.62 -0.62h0a0.62,0.62 0,0 1,-0.62 0.62Z"
+ android:fillColor="#669df6"/>
+ <path
+ android:pathData="M243.03,105.11m-15.24,0a15.24,15.24 0,1 1,30.48 0a15.24,15.24 0,1 1,-30.48 0"
+ android:fillColor="#d2e3fc"/>
+ <path
+ android:pathData="M240,100.65a4.16,4.16 0,0 0,-0.1 5.88l0.1,0.1 0.76,-0.76a3.28,3.28 0,0 1,-0.92 -2.24,3 3,0 0,1 0.92,-2.22ZM247.51,99.12 L246.75,99.88a5.39,5.39 0,0 1,0 7.51l0.76,0.76a6.22,6.22 0,0 0,1.85 -4.52A6.52,6.52 0,0 0,247.54 99.12ZM239.22,99.88 L238.46,99.12a6.45,6.45 0,0 0,0 9l0.76,-0.76A5.39,5.39 0,0 1,239.25 99.88ZM245.96,100.65 L245.2,101.41a3.18,3.18 0,0 1,0.92 2.22,3 3,0 0,1 -0.92,2.24l0.76,0.76a4.24,4.24 0,0 0,1.28 -3,4.55 4.55,0 0,0 -1.26,-3ZM242.96,102.06a1.58,1.58 0,0 0,-1.6 1.56v0a1.63,1.63 0,0 0,0.92 1.47v5.53h1.28v-5.53a1.63,1.63 0,0 0,0.92 -1.47A1.58,1.58 0,0 0,243 102.06Z"
+ android:fillColor="#669df6"/>
+ <path
+ android:pathData="M206.59,77.45m-15.21,0a15.21,15.21 0,1 1,30.42 0a15.21,15.21 0,1 1,-30.42 0"
+ android:fillColor="#ceead6"/>
+ <path
+ android:pathData="M211.66,72.38h-1.9L211,74.92h-1.9l-1.29,-2.54h-1.27l1.27,2.54L206,74.92l-1.26,-2.54h-1.32l1.27,2.54h-1.9l-1.27,-2.54a1.26,1.26 0,0 0,-1.26 1.26h0v7.61a1.25,1.25 0,0 0,1.26 1.26h10.14a1.26,1.26 0,0 0,1.27 -1.26L212.93,73.65a1.27,1.27 0,0 0,-1.27 -1.27ZM211.66,81.26L201.52,81.26L201.52,76.19h10.14Z"
+ android:fillColor="#5bb974"/>
+</vector>
diff --git a/res/drawable/ic_enhanced_connectivity.xml b/res/drawable/ic_enhanced_connectivity.xml
new file mode 100644
index 0000000..45767bd
--- /dev/null
+++ b/res/drawable/ic_enhanced_connectivity.xml
@@ -0,0 +1,91 @@
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="412dp"
+ android:height="300dp"
+ android:viewportWidth="412"
+ android:viewportHeight="300">
+ <path
+ android:pathData="M28.1,0L383.9,0A28.1,28.1 0,0 1,412 28.1L412,271.9A28.1,28.1 0,0 1,383.9 300L28.1,300A28.1,28.1 0,0 1,0 271.9L0,28.1A28.1,28.1 0,0 1,28.1 0z"
+ android:fillColor="#fff"/>
+ <path
+ android:pathData="M206,150m-108.79,0a108.79,108.79 0,1 1,217.58 0a108.79,108.79 0,1 1,-217.58 0"
+ android:strokeAlpha="0.2"
+ android:fillColor="#669df6"
+ android:fillAlpha="0.2"/>
+ <path
+ android:pathData="M206,150m-93.27,0a93.27,93.27 0,1 1,186.54 0a93.27,93.27 0,1 1,-186.54 0"
+ android:strokeAlpha="0.2"
+ android:fillColor="#669df6"
+ android:fillAlpha="0.2"/>
+ <path
+ android:pathData="M206,150m-77.85,0a77.85,77.85 0,1 1,155.7 0a77.85,77.85 0,1 1,-155.7 0"
+ android:strokeAlpha="0.2"
+ android:fillColor="#669df6"
+ android:fillAlpha="0.2"/>
+ <path
+ android:pathData="M153.7,35.5H256.88A7.09,7.09 0,0 1,264 42.57V257.19a7.09,7.09 0,0 1,-7.12 7.06H153.7a7.09,7.09 0,0 1,-7.13 -7.06V42.57A7.1,7.1 0,0 1,153.7 35.5Z"
+ android:fillColor="#fff"/>
+ <path
+ android:pathData="M267.85,102.26L267.85,93.58a2.17,2.17 0,0 0,-2.17 -2.17L265.68,45.83A10.87,10.87 0,0 0,254.83 35L155,35a10.87,10.87 0,0 0,-10.85 10.85L144.15,254.17A10.87,10.87 0,0 0,155 265h99.83a10.87,10.87 0,0 0,10.85 -10.85L265.68,147.83a2.17,2.17 0,0 0,2.17 -2.17L267.85,124a2.17,2.17 0,0 0,-2.17 -2.17L265.68,104.43A2.17,2.17 0,0 0,267.85 102.26ZM263.51,254.17a8.7,8.7 0,0 1,-8.68 8.68L155,262.85a8.7,8.7 0,0 1,-8.68 -8.68L146.32,45.83A8.7,8.7 0,0 1,155 37.15h99.83a8.7,8.7 0,0 1,8.68 8.68Z"
+ android:fillColor="#dadce0"/>
+ <path
+ android:pathData="M199.72,230.82h14a4.45,4.45 0,0 1,4.45 4.45h0a4.46,4.46 0,0 1,-4.45 4.46h-14a4.46,4.46 0,0 1,-4.45 -4.46h0a4.45,4.45 0,0 1,4.45 -4.45Z"
+ android:fillColor="#e8f0fe"/>
+ <path
+ android:pathData="M211.83,228.91h0a6.36,6.36 0,0 1,6.36 6.36h0a6.36,6.36 0,0 1,-6.35 6.37h0a6.37,6.37 0,0 1,-6.37 -6.37h0a6.36,6.36 0,0 1,6.36 -6.36Z"
+ android:fillColor="#1a73e8"/>
+ <path
+ android:pathData="M206.59,179.58m-15.27,0a15.27,15.27 0,1 1,30.54 0a15.27,15.27 0,1 1,-30.54 0"
+ android:fillColor="#f1f3f4"/>
+ <path
+ android:pathData="M191.32,179.58a15.27,15.24 0,1 0,30.54 0a15.27,15.24 0,1 0,-30.54 0z"
+ android:fillColor="#feefc3"/>
+ <path
+ android:pathData="M206.59,172.63l-5.72,4.29l0,8.59l3.57,0l0,-5.01l4.3,0l0,5.01l3.57,0l0,-8.59l-5.72,-4.29z"
+ android:fillColor="#f9ab00"/>
+ <path
+ android:pathData="M168.97,105.11m-15.24,0a15.24,15.24 0,1 1,30.48 0a15.24,15.24 0,1 1,-30.48 0"
+ android:fillColor="#fad2cf"/>
+ <path
+ android:pathData="M172.6,111.39L172.6,100.28a0.92,0.92 0,0 0,-0.92 -0.92h-1.22L170.46,97.87h-2.9v1.42h-1.2a0.93,0.93 0,0 0,-0.93 0.92v11.07a0.93,0.93 0,0 0,0.93 0.92h5.31A0.92,0.92 0,0 0,172.6 111.39ZM171.15,100.77L171.15,106h-4.34v-5.2Z"
+ android:fillColor="#d93025"/>
+ <path
+ android:pathData="M243.03,151.92m-15.27,0a15.27,15.27 0,1 1,30.54 0a15.27,15.27 0,1 1,-30.54 0"
+ android:fillColor="#fad2cf"/>
+ <path
+ android:pathData="M248.3,146.31a1.09,1.09 0,0 0,-1 -0.73h-8a1.1,1.1 0,0 0,-1 0.73l-1.5,4.34v5.8a0.71,0.71 0,0 0,0.71 0.73h0.79a0.72,0.72 0,0 0,0.72 -0.72h0v-0.72h8.68v0.72a0.73,0.73 0,0 0,0.73 0.73h0.72a0.73,0.73 0,0 0,0.73 -0.73v-5.79ZM240,153.54a1.09,1.09 0,1 1,1.09 -1.09h0a1.08,1.08 0,0 1,-1 1.12h0ZM246.52,153.54a1.09,1.09 0,1 1,1.08 -1.1v0a1.09,1.09 0,0 1,-1 1.12ZM238.75,149.28 L239.53,147.03L247,147.03l0.78,2.25Z"
+ android:fillColor="#d93025"/>
+ <path
+ android:pathData="M168.97,151.92m-15.27,0a15.27,15.27 0,1 1,30.54 0a15.27,15.27 0,1 1,-30.54 0"
+ android:fillColor="#d2e3fc"/>
+ <path
+ android:pathData="M175.8,149.23a3.68,3.68 0,0 0,-3.69 -3.08h-5.63a3.73,3.73 0,0 0,-3.69 3.08s-1.17,6.76 -1.17,6.86a1.61,1.61 0,0 0,2.72 1.15l2.66,-2.63h4.61l2.66,2.63a1.61,1.61 0,0 0,2.73 -1.15C177,156 175.8,149.23 175.8,149.23ZM168.51,150.77L167,150.77v1.53h-0.77v-1.53h-1.53L164.7,150h1.53v-1.54L167,148.46L167,150h1.54ZM170.67,151a0.62,0.62 0,1 1,0.61 -0.63h0a0.62,0.62 0,0 1,-0.61 0.62ZM171.97,152.3a0.61,0.61 0,0 1,-0.63 -0.6,0.62 0.62,0 0,1 1.24,0h0a0.61,0.61 0,0 1,-0.61 0.61ZM171.97,149.69a0.62,0.62 0,1 1,0.61 -0.63h0a0.62,0.62 0,0 1,-0.61 0.62ZM173.28,151a0.62,0.62 0,1 1,0.62 -0.62h0a0.62,0.62 0,0 1,-0.62 0.62Z"
+ android:fillColor="#1a73e8"/>
+ <path
+ android:pathData="M243.03,105.11m-15.24,0a15.24,15.24 0,1 1,30.48 0a15.24,15.24 0,1 1,-30.48 0"
+ android:fillColor="#d2e3fc"/>
+ <path
+ android:pathData="M240,100.65a4.16,4.16 0,0 0,-0.1 5.88l0.1,0.1 0.76,-0.76a3.28,3.28 0,0 1,-0.92 -2.24,3 3,0 0,1 0.92,-2.22ZM247.51,99.12 L246.75,99.88a5.39,5.39 0,0 1,0 7.51l0.76,0.76a6.22,6.22 0,0 0,1.85 -4.52A6.52,6.52 0,0 0,247.54 99.12ZM239.22,99.88 L238.46,99.12a6.45,6.45 0,0 0,0 9l0.76,-0.76A5.39,5.39 0,0 1,239.25 99.88ZM245.96,100.65 L245.2,101.41a3.18,3.18 0,0 1,0.92 2.22,3 3,0 0,1 -0.92,2.24l0.76,0.76a4.24,4.24 0,0 0,1.28 -3,4.55 4.55,0 0,0 -1.26,-3ZM242.96,102.06a1.58,1.58 0,0 0,-1.6 1.56v0a1.63,1.63 0,0 0,0.92 1.47v5.53h1.28v-5.53a1.63,1.63 0,0 0,0.92 -1.47A1.58,1.58 0,0 0,243 102.06Z"
+ android:fillColor="#1a73e8"/>
+ <path
+ android:pathData="M206.59,77.45m-15.21,0a15.21,15.21 0,1 1,30.42 0a15.21,15.21 0,1 1,-30.42 0"
+ android:fillColor="#ceead6"/>
+ <path
+ android:pathData="M211.66,72.38h-1.9L211,74.92h-1.9l-1.29,-2.54h-1.27l1.27,2.54L206,74.92l-1.26,-2.54h-1.32l1.27,2.54h-1.9l-1.27,-2.54a1.26,1.26 0,0 0,-1.26 1.26h0v7.61a1.25,1.25 0,0 0,1.26 1.26h10.14a1.26,1.26 0,0 0,1.27 -1.26L212.93,73.65a1.27,1.27 0,0 0,-1.27 -1.27ZM211.66,81.26L201.52,81.26L201.52,76.19h10.14Z"
+ android:fillColor="#1e8e3e"/>
+</vector>
diff --git a/res/drawable/ic_power_settings.xml b/res/drawable/ic_power_settings.xml
deleted file mode 100644
index b56e332..0000000
--- a/res/drawable/ic_power_settings.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
- Copyright (C) 2021 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:pathData="M11,2h2v10h-2zM18.37,5.64l-1.41,1.41c2.73,2.73 2.72,7.16 -0.01,9.89 -2.73,2.73 -7.17,2.73 -9.89,0.01 -2.73,-2.73 -2.74,-7.18 -0.01,-9.91l-1.41,-1.4c-3.51,3.51 -3.51,9.21 0.01,12.73 3.51,3.51 9.21,3.51 12.72,-0.01 3.51,-3.51 3.51,-9.2 0,-12.72z"
- android:fillColor="@android:color/white"/>
-</vector>
\ No newline at end of file
diff --git a/res/layout/accessibility_autoclick_preview.xml b/res/layout/accessibility_autoclick_preview.xml
deleted file mode 100644
index 4fa3f8f..0000000
--- a/res/layout/accessibility_autoclick_preview.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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.
- -->
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="@dimen/autoclick_preview_height"
- android:contentDescription="@null"
- android:scaleType="fitCenter"
- android:src="@drawable/accessibility_dwell"/>
-
-</FrameLayout>
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 65c1497..5f82879 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -98,7 +98,7 @@
android:paddingTop="24dp">
<ImageView
- android:id="@+id/icon_fingerprint"
+ android:id="@+id/icon_device_locked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
@@ -133,7 +133,7 @@
android:paddingTop="24dp">
<ImageView
- android:id="@+id/icon_fingerprint"
+ android:id="@+id/icon_trash_can"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index d814164..f8f4a76 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -14,50 +14,48 @@
limitations under the License.
-->
-<FrameLayout
+<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/apps_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipToPadding="false"
+ android:scrollbars="none"
+ android:visibility="invisible"
+ settings:fastScrollEnabled="true"
+ settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
+ settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"
+ settings:layout_constraintTop_toBottomOf="@id/pinned_header"/>
+
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:gravity="center"
+ android:textAlignment="gravity"
+ android:text="@string/no_applications"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:visibility="invisible"
+ settings:layout_constraintTop_toBottomOf="@id/pinned_header"
+ settings:layout_constraintBottom_toBottomOf="parent"/>
+
+ <include layout="@layout/loading_container"
+ settings:layout_constraintTop_toBottomOf="@id/pinned_header"
+ settings:layout_constraintBottom_toBottomOf="parent"/>
+
<FrameLayout
android:id="@+id/pinned_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:elevation="2dp"/>
+ android:background="?android:colorBackground"
+ settings:layout_constraintTop_toTopOf="parent"/>
- <FrameLayout
- android:id="@+id/list_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/apps_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipToPadding="false"
- android:scrollbars="none"
- settings:fastScrollEnabled="true"
- settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
- settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
- settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
- settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
-
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="bottom|center_horizontal"
- android:layout_gravity="center"
- android:text="@string/no_applications"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:visibility="invisible"/>
-
- </FrameLayout>
-
- <include layout="@layout/loading_container"/>
-
-</FrameLayout>
-
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/preference_animated_image.xml b/res/layout/preference_animated_image.xml
deleted file mode 100644
index 64cfc98..0000000
--- a/res/layout/preference_animated_image.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?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.
- -->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="@dimen/settingslib_illustration_height"
- android:gravity="center"
- android:padding="@dimen/settingslib_illustration_padding"
- android:orientation="vertical"
- android:importantForAccessibility="noHideDescendants">
-
- <ImageView
- android:id="@+id/animated_img"
- android:maxWidth="@dimen/settingslib_illustration_width"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="@drawable/protection_background"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"/>
-
- <com.airbnb.lottie.LottieAnimationView
- android:id="@+id/lottie_view"
- android:maxWidth="@dimen/settingslib_illustration_width"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="@drawable/protection_background"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"
- android:clipToOutline="true"/>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/raw/lottie_swipe_for_notifications.json b/res/raw/lottie_swipe_for_notifications.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/lottie_swipe_for_notifications.json
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index fe0ada0..1b8179a 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -149,8 +149,6 @@
<dimen name="wifi_assistant_height">182dp</dimen>
<dimen name="wifi_assistant_image_top">32dp</dimen>
<dimen name="wifi_assistant_image_start">24dp</dimen>
- <!-- appbar height is equal search bar height (48dp) plus search bar top and bottom margin -->
- <dimen name="app_bar_height">80dp</dimen>
<!-- CryptKeeper top margin for password/pin screen -->
<dimen name="crypt_keeper_password_top_margin">88dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2ddbae3..23c020a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -926,16 +926,8 @@
<string name="security_settings_fingerprint_enroll_introduction_cancel">Cancel</string>
<!-- Button text to cancel enrollment [CHAR LIMIT=30] -->
<string name="security_settings_fingerprint_enroll_introduction_no_thanks">No thanks</string>
- <!-- Button text to skip enrollment [CHAR LIMIT=30] -->
- <string name="security_settings_fingerprint_enroll_introduction_skip">No thanks</string>
- <!-- Button text to continue to the next screen from the introduction [CHAR LIMIT=22] -->
- <string name="security_settings_fingerprint_enroll_introduction_continue">Continue</string>
<!-- Button text to agree the consent and continue to the next screen from the introduction [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_enroll_introduction_agree">I agree</string>
- <!-- Button text to cancel enrollment from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
- <string name="security_settings_fingerprint_enroll_introduction_cancel_setup">Skip</string>
- <!-- Button text to continue to the next screen from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
- <string name="security_settings_fingerprint_enroll_introduction_continue_setup">Next</string>
<!-- Title of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup. [CHAR LIMIT=30] -->
<string name="setup_fingerprint_enroll_skip_title">Skip fingerprint?</string>
<!-- Body text of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup [CHAR LIMIT=NONE] -->
@@ -6163,11 +6155,11 @@
<!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_summary">To preserve your battery. Learn more.</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
- <string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
+ <string name="battery_tip_dialog_message" product="default">Because you’ve used your phone more than usual, your battery may run out sooner than it normally would.\n\nApps using most battery:</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
- <string name="battery_tip_dialog_message" product="tablet">Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
+ <string name="battery_tip_dialog_message" product="tablet">Because you’ve used your tablet more than usual, your battery may run out sooner than it normally would.\n\nApps using most battery:</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
- <string name="battery_tip_dialog_message" product="device">Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
+ <string name="battery_tip_dialog_message" product="device">Because you’ve used your device more than usual, your battery may run out sooner than it normally would.\n\nApps using most battery:</string>
<!-- Footer message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
<string name="battery_tip_dialog_message_footer">Includes high-power background activity</string>
<!-- Title for restricted app preference, showing how many app need to be restricted [CHAR LIMIT=NONE] -->
@@ -12892,6 +12884,8 @@
<string name="sim_action_reboot">Restart</string>
<!-- Button on a dialog to reject SIM operations. [CHAR LIMIT=30] -->
<string name="sim_action_no_thanks">No thanks</string>
+ <!-- Button text to cancel operations proposed by a sim operation dialog [CHAR LIMIT=20] -->
+ <string name="sim_action_cancel">Cancel</string>
<!-- Button which will disconnect the user from one mobile network and immediately connect to another. [CHAR LIMIT=30] -->
<string name="sim_switch_button">Switch</string>
<!-- Title of DSDS activation failure dialog [CHAR LIMIT=40] -->
@@ -13203,23 +13197,29 @@
<string name="cards_passes_lower">cards & passes</string>
<!-- Power menu setting name [CHAR LIMIT=NONE] -->
- <string name="power_menu_setting_name">Power menu</string>
+ <string name="power_menu_setting_name">Press and hold power button</string>
- <!-- Power menu setting title [CHAR LIMIT=NONE] -->
- <string name="power_menu_setting_title">Power button menu</string>
-
- <!-- Power menu setting option none [CHAR LIMIT=NONE] -->
- <string name="power_menu_none">Don\u2019t show any content</string>
+ <!-- Power menu setting summary to describe press and hold power button for Assistant is enabled. [CHAR LIMIT=NONE] -->
+ <string name="power_menu_summary_long_press_for_assist_enabled">Press and hold for the Assistant</string>
+ <!-- Power menu setting summary to describe press and hold power button for Assistant is disabled and power menu will appear. [CHAR LIMIT=NONE] -->
+ <string name="power_menu_summary_long_press_for_assist_disabled_with_power_menu">Press and hold for the power menu</string>
+ <!-- Power menu setting summary to describe press and hold power button for Assistant is disabled and nothing will happen. [CHAR LIMIT=NONE] -->
+ <string name="power_menu_summary_long_press_for_assist_disabled_no_action">Press and hold disabled</string>
<!-- Power menu setting privacy no secure screen lock set [CHAR_LIMIT=NONE] -->
<string name="lockscreen_privacy_not_secure">To use, first set a screen lock</string>
- <!-- Power menu setting use long press power to invoke assistant. [CHAR_LIMIT=NONE] -->
+ <!-- Power menu setting use long press power to invoke assistant. [CHAR LIMIT=NONE] -->
<string name="power_menu_long_press_for_assist">Hold for Assistant</string>
- <!-- Power menu setting use log press power to invoke assistant summary. [CHAR_LIMIT=NONE] -->
+ <!-- Power menu setting use log press power to invoke assistant summary. [CHAR LIMIT=NONE] -->
<string name="power_menu_long_press_for_assist_summary">Trigger the Assistant by holding the power button</string>
+ <!-- Power menu explanation to press power and volume up to show power and emergency menu. [CHAR LIMIT=NONE] -->
+ <string name="power_menu_power_volume_up_hint">Power & Emergency Menu:\nPress Power and Volume up at the same time.</string>
+ <!-- Power menu explanation where to find prevent ringing option. [CHAR LIMIT=NONE] -->
+ <string name="power_menu_power_prevent_ringing_hint">Prevent ringing:\nShortcut available in the volume menu.</string>
+
<!-- Wallet (formerly Cards and passes) toggle name [CHAR LIMIT=60] -->
<string name="lockscreen_privacy_wallet_setting_toggle">Show wallet</string>
<!-- Wallet (formerly Cards and passes) summary [CHAR LIMIT=NONE] -->
@@ -13383,7 +13383,7 @@
<string name="mobile_data_no_connection">No connection</string>
<!-- Provider Model:
Summary indicating that a SIM has no mobile data connection [CHAR LIMIT=50] -->
- <string name="mobile_data_off_summary">Internet won\u0027t auto\u2011connect</string>
+ <string name="mobile_data_off_summary">Mobile data won\u0027t auto\u2011connect</string>
<!-- Provider Model: Summary indicating that no other networks available [CHAR LIMIT=50] -->
<string name="non_carrier_network_unavailable">No other networks available</string>
<!-- Provider Model: Summary indicating that no networks available [CHAR LIMIT=50] -->
diff --git a/res/xml/accessibility_autoclick_settings.xml b/res/xml/accessibility_autoclick_settings.xml
index ee27cea..06b3dce 100644
--- a/res/xml/accessibility_autoclick_settings.xml
+++ b/res/xml/accessibility_autoclick_settings.xml
@@ -19,14 +19,13 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/accessibility_autoclick_preference_title">
- <com.android.settingslib.widget.LayoutPreference
- android:key="accessibility_autoclick_preview"
- android:layout="@layout/accessibility_autoclick_preview"
+ <com.android.settingslib.widget.IllustrationPreference
+ android:key="accessibility_autoclick_banner"
android:persistent="false"
android:selectable="false"
- android:title="@string/summary_placeholder"
settings:allowDividerBelow="true"
- settings:searchable="false" />
+ settings:searchable="false"
+ settings:lottie_rawRes="@drawable/accessibility_dwell" />
<com.android.settingslib.widget.RadioButtonPreference
android:key="accessibility_control_autoclick_default"
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index c8627e7..71bfc18 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -37,7 +37,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
- android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index e0ba71b..b01c235 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
- android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index 1c4c6aa..c24ea6f 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_work"
- android:title="@string/autofill_app"
settings:searchable="false">
<extra
android:name="for_work"
diff --git a/res/xml/adaptive_connectivity_settings.xml b/res/xml/adaptive_connectivity_settings.xml
index ff9bdb0..d5941ad 100644
--- a/res/xml/adaptive_connectivity_settings.xml
+++ b/res/xml/adaptive_connectivity_settings.xml
@@ -19,20 +19,18 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/adaptive_connectivity_title">
- <com.android.settingslib.widget.LayoutPreference
- android:key="adaptive_connectivity_header"
- android:layout="@layout/adaptive_connectivity_header"
- android:persistent="false"
- android:selectable="false"
- android:title="@string/summary_placeholder"
- settings:allowDividerBelow="true"
- settings:searchable="false"/>
+ <com.android.settingslib.widget.TopIntroPreference
+ settings:searchable="false"
+ android:title="@string/adaptive_connectivity_summary"/>
- <SwitchPreference
+ <com.android.settingslib.widget.IllustrationPreference
+ android:key="adaptive_connectivity_header"
+ settings:searchable="false"
+ settings:lottie_rawRes="@drawable/ic_enhanced_connectivity"/>
+
+ <com.android.settingslib.widget.MainSwitchPreference
android:key="adaptive_connectivity"
android:title="@string/adaptive_connectivity_title"
- android:summary="@string/adaptive_connectivity_summary"
- settings:allowDividerAbove="true"
settings:controller="com.android.settings.network.AdaptiveConnectivityTogglePreferenceController"/>
</PreferenceScreen>
diff --git a/res/xml/apps.xml b/res/xml/apps.xml
index a7d823b..e6314da 100644
--- a/res/xml/apps.xml
+++ b/res/xml/apps.xml
@@ -55,7 +55,7 @@
settings:searchable="false"/>
<Preference
- android:key="default_apps_v2"
+ android:key="default_apps"
android:title="@string/app_default_dashboard_title"
android:order="-996"
settings:controller="com.android.settings.applications.DefaultAppsPreferenceController">
@@ -85,7 +85,7 @@
</Preference>
<Preference
- android:key="special_access_v2"
+ android:key="special_access"
android:fragment="com.android.settings.applications.specialaccess.SpecialAccessSettings"
android:title="@string/special_access"
android:order="20"
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index 6de9c1a..175a826 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -86,4 +86,10 @@
android:title="@string/gesture_prevent_ringing_screen_title"
android:fragment="com.android.settings.gestures.PreventRingingGestureSettings"
settings:controller="com.android.settings.gestures.PreventRingingParentPreferenceController" />
+
+ <Preference
+ android:key="gesture_power_menu_summary"
+ android:title="@string/power_menu_setting_name"
+ android:fragment="com.android.settings.gestures.PowerMenuSettings"
+ settings:controller="com.android.settings.gestures.PowerMenuPreferenceController" />
</PreferenceScreen>
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
index f88531e..caaeb97 100644
--- a/res/xml/power_menu_settings.xml
+++ b/res/xml/power_menu_settings.xml
@@ -1,19 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2020 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
@@ -26,4 +23,10 @@
android:summary="@string/power_menu_long_press_for_assist_summary"
settings:controller="com.android.settings.gestures.LongPressPowerButtonPreferenceController"
/>
+
+ <com.android.settingslib.widget.FooterPreference
+ android:key="power_menu_power_volume_up_hint"
+ android:title="@string/power_menu_power_volume_up_hint"
+ android:selectable="false"
+ settings:searchable="false" />
</PreferenceScreen>
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 6737775..9228ddd 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -43,14 +43,6 @@
android:fragment="com.android.settings.datetime.DateTimeSettings"
settings:controller="com.android.settings.datetime.DateTimePreferenceController"/>
- <Preference
- android:key="gesture_power_menu_summary"
- android:title="@string/power_menu_setting_name"
- android:icon="@drawable/ic_power_settings"
- android:order="-220"
- android:fragment="com.android.settings.gestures.PowerMenuSettings"
- settings:controller="com.android.settings.gestures.PowerMenuPreferenceController" />
-
<!-- System updates -->
<Preference
android:key="additional_system_update_settings"
diff --git a/src/com/android/settings/PointerSpeedPreference.java b/src/com/android/settings/PointerSpeedPreference.java
index d48d26c..6a93477 100644
--- a/src/com/android/settings/PointerSpeedPreference.java
+++ b/src/com/android/settings/PointerSpeedPreference.java
@@ -73,6 +73,7 @@
mOldSpeed = mIm.getPointerSpeed(getContext());
mSeekBar.setProgress(mOldSpeed - InputManager.MIN_POINTER_SPEED);
mSeekBar.setOnSeekBarChangeListener(this);
+ mSeekBar.setContentDescription(getTitle());
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 12f63ea..f3cdd6c 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -574,7 +574,7 @@
/**
* Switch to a specific Fragment with taking care of validation, Title and BackStack
*/
- private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
+ private void switchToFragment(String fragmentName, Bundle args, boolean validate,
int titleResId, CharSequence title) {
Log.d(LOG_TAG, "Switching to fragment " + fragmentName);
if (validate && !isValidFragment(fragmentName)) {
@@ -582,6 +582,9 @@
+ fragmentName);
}
Fragment f = Utils.getTargetFragment(this, fragmentName, args);
+ if (f == null) {
+ return;
+ }
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_content, f);
if (titleResId > 0) {
@@ -592,7 +595,6 @@
transaction.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
Log.d(LOG_TAG, "Executed frag manager pendingTransactions");
- return f;
}
private void updateTilesList() {
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 708dbed..e79852b 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1158,13 +1158,17 @@
== ProfileSelectFragment.ProfileType.PERSONAL : false;
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.ProfileType.WORK : false;
- if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
- && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
- && !isWork && !isPersonal) {
- f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
- args);
- } else {
- f = Fragment.instantiate(activity, fragmentName, args);
+ try {
+ if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
+ && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
+ && !isWork && !isPersonal) {
+ f = Fragment.instantiate(activity,
+ ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName), args);
+ } else {
+ f = Fragment.instantiate(activity, fragmentName, args);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to get target fragment", e);
}
return f;
}
diff --git a/src/com/android/settings/accessibility/AnimatedImagePreference.java b/src/com/android/settings/accessibility/AnimatedImagePreference.java
deleted file mode 100644
index c707e5c..0000000
--- a/src/com/android/settings/accessibility/AnimatedImagePreference.java
+++ /dev/null
@@ -1,181 +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.accessibility;
-
-import android.content.Context;
-import android.graphics.drawable.Animatable;
-import android.graphics.drawable.Animatable2;
-import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-import com.airbnb.lottie.LottieAnimationView;
-import com.airbnb.lottie.LottieDrawable;
-
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Objects;
-
-/**
- * A custom {@link ImageView} preference for showing animated or static image, such as <a
- * href="https://developers.google.com/speed/webp/">animated webp</a> and static png.
- */
-public class AnimatedImagePreference extends Preference {
-
- private static final String TAG = "AnimatedImagePreference";
- private Uri mImageUri;
- private int mMaxHeight = -1;
-
- private final Animatable2.AnimationCallback mAnimationCallback =
- new Animatable2.AnimationCallback() {
- @Override
- public void onAnimationEnd(Drawable drawable) {
- ((Animatable2) drawable).start();
- }
- };
-
- AnimatedImagePreference(Context context) {
- super(context);
- setLayoutResource(R.layout.preference_animated_image);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
- super.onBindViewHolder(holder);
-
- final ImageView imageView = holder.itemView.findViewById(R.id.animated_img);
- final LottieAnimationView lottieView = holder.itemView.findViewById(R.id.lottie_view);
- if (imageView == null || lottieView == null) {
- return;
- }
-
- if (mImageUri != null) {
- resetAnimations(imageView, lottieView);
- hideAllChildViews(holder.itemView);
-
- imageView.setImageURI(mImageUri);
- if (imageView.getDrawable() != null) {
- startAnimationWith(imageView);
- } else {
- // The lottie image from the raw folder also returns null.
- startLottieAnimationWith(lottieView);
- }
- }
-
- if (mMaxHeight > -1) {
- imageView.setMaxHeight(mMaxHeight);
- lottieView.setMaxHeight(mMaxHeight);
- }
- }
-
- /**
- * Sets image uri to display image in {@link ImageView}
- *
- * @param imageUri the Uri of an image
- */
- public void setImageUri(Uri imageUri) {
- if (imageUri != null && !imageUri.equals(mImageUri)) {
- mImageUri = imageUri;
- notifyChanged();
- }
- }
-
- /**
- * Sets the maximum height of the view.
- *
- * @param maxHeight the maximum height of ImageView in terms of pixels.
- */
- public void setMaxHeight(int maxHeight) {
- if (maxHeight != mMaxHeight) {
- mMaxHeight = maxHeight;
- notifyChanged();
- }
- }
-
- private void startAnimationWith(ImageView imageView) {
- startAnimation(imageView.getDrawable());
-
- imageView.setVisibility(View.VISIBLE);
- }
-
- private void startLottieAnimationWith(LottieAnimationView lottieView) {
- final InputStream inputStream = getInputStreamFromUri(mImageUri);
- Objects.requireNonNull(inputStream, "Invalid resource.");
- lottieView.setAnimation(inputStream, /* cacheKey= */ null);
- lottieView.setRepeatCount(LottieDrawable.INFINITE);
- lottieView.playAnimation();
-
- lottieView.setVisibility(View.VISIBLE);
- }
-
- private void startAnimation(Drawable drawable) {
- if (!(drawable instanceof Animatable)) {
- return;
- }
-
- if (drawable instanceof Animatable2) {
- ((Animatable2) drawable).registerAnimationCallback(mAnimationCallback);
- } else if (drawable instanceof AnimationDrawable) {
- ((AnimationDrawable) drawable).setOneShot(false);
- }
-
- ((Animatable) drawable).start();
- }
-
- private void resetAnimations(ImageView imageView, LottieAnimationView lottieView) {
- resetAnimation(imageView.getDrawable());
-
- lottieView.cancelAnimation();
- }
-
- private void resetAnimation(Drawable drawable) {
- if (!(drawable instanceof Animatable)) {
- return;
- }
-
- if (drawable instanceof Animatable2) {
- ((Animatable2) drawable).clearAnimationCallbacks();
- }
-
- ((Animatable) drawable).stop();
- }
-
- private InputStream getInputStreamFromUri(Uri uri) {
- try {
- return getContext().getContentResolver().openInputStream(uri);
- } catch (FileNotFoundException e) {
- Log.w(TAG, "Cannot find content uri: " + uri, e);
- return null;
- }
- }
-
- private void hideAllChildViews(View itemView) {
- final ViewGroup viewGroup = (ViewGroup) itemView;
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
- viewGroup.getChildAt(i).setVisibility(View.GONE);
- }
- }
-}
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 640ae53..510f8d3 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -59,6 +59,7 @@
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.accessibility.AccessibilityUtils;
+import com.android.settingslib.widget.IllustrationPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -398,15 +399,13 @@
return;
}
- final int screenHalfHeight = AccessibilityUtil.getScreenHeightPixels(getPrefContext()) / 2;
- final AnimatedImagePreference animatedImagePreference =
- new AnimatedImagePreference(getPrefContext());
- animatedImagePreference.setImageUri(mImageUri);
- animatedImagePreference.setSelectable(false);
- animatedImagePreference.setMaxHeight(screenHalfHeight);
- animatedImagePreference.setKey(KEY_ANIMATED_IMAGE);
+ final IllustrationPreference illustrationPreference =
+ new IllustrationPreference(getPrefContext());
+ illustrationPreference.setImageUri(mImageUri);
+ illustrationPreference.setSelectable(false);
+ illustrationPreference.setKey(KEY_ANIMATED_IMAGE);
- getPreferenceScreen().addPreference(animatedImagePreference);
+ getPreferenceScreen().addPreference(illustrationPreference);
}
private void initToggleServiceSwitchPreference() {
diff --git a/src/com/android/settings/applications/AppDashboardFragment.java b/src/com/android/settings/applications/AppDashboardFragment.java
index ff12595..7e203b0 100644
--- a/src/com/android/settings/applications/AppDashboardFragment.java
+++ b/src/com/android/settings/applications/AppDashboardFragment.java
@@ -69,6 +69,7 @@
use(SpecialAppAccessPreferenceController.class).setSession(getSettingsLifecycle());
mAppsPreferenceController = use(AppsPreferenceController.class);
mAppsPreferenceController.setFragment(this /* fragment */);
+ getSettingsLifecycle().addObserver(mAppsPreferenceController);
final HibernatedAppsPreferenceController hibernatedAppsPreferenceController =
use(HibernatedAppsPreferenceController.class);
diff --git a/src/com/android/settings/applications/AppsPreferenceController.java b/src/com/android/settings/applications/AppsPreferenceController.java
index 72d4492..9fbd5c1 100644
--- a/src/com/android/settings/applications/AppsPreferenceController.java
+++ b/src/com/android/settings/applications/AppsPreferenceController.java
@@ -26,6 +26,9 @@
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -45,7 +48,8 @@
* This controller displays up to four recently used apps.
* If there is no recently used app, we only show up an "App Info" preference.
*/
-public class AppsPreferenceController extends BasePreferenceController {
+public class AppsPreferenceController extends BasePreferenceController implements
+ LifecycleObserver {
public static final int SHOW_RECENT_APP_COUNT = 4;
@@ -73,6 +77,7 @@
Preference mSeeAllPref;
private Fragment mHost;
+ private boolean mInitialLaunch = false;
public AppsPreferenceController(Context context) {
super(context, KEY_RECENT_APPS_CATEGORY);
@@ -95,12 +100,23 @@
super.displayPreference(screen);
initPreferences(screen);
refreshUi();
+ mInitialLaunch = true;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
- refreshUi();
+ if (!mInitialLaunch) {
+ refreshUi();
+ }
+ }
+
+ /**
+ * Called when the apps page pauses.
+ */
+ @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
+ public void onPause() {
+ mInitialLaunch = false;
}
@VisibleForTesting
@@ -109,11 +125,15 @@
mRecentApps = loadRecentApps();
if (!mRecentApps.isEmpty()) {
displayRecentApps();
+ mAllAppsInfoPref.setVisible(false);
mRecentAppsCategory.setVisible(true);
mGeneralCategory.setVisible(true);
mSeeAllPref.setVisible(true);
} else {
mAllAppsInfoPref.setVisible(true);
+ mRecentAppsCategory.setVisible(false);
+ mGeneralCategory.setVisible(false);
+ mSeeAllPref.setVisible(false);
}
}
diff --git a/src/com/android/settings/applications/RunningServices.java b/src/com/android/settings/applications/RunningServices.java
index 4d13241..b1689d5 100644
--- a/src/com/android/settings/applications/RunningServices.java
+++ b/src/com/android/settings/applications/RunningServices.java
@@ -72,7 +72,11 @@
public void onResume() {
super.onResume();
boolean haveData = mRunningProcessesView.doResume(this, mRunningProcessesAvail);
- mLoadingViewController.handleLoadingContainer(haveData /* done */, false /* animate */);
+ if (haveData) {
+ mLoadingViewController.showContent(false /* animate */);
+ } else {
+ mLoadingViewController.showLoadingView();
+ }
}
@Override
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
index fd6f4c2..d962692 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
@@ -65,11 +65,19 @@
((TwoTargetPreference) preference).setIconSize(ICON_SIZE_MEDIUM);
}
if (!TextUtils.isEmpty(defaultAppLabel)) {
- preference.setSummary(defaultAppLabel);
+ if (showLabelAsTitle()) {
+ preference.setTitle(defaultAppLabel);
+ } else {
+ preference.setSummary(defaultAppLabel);
+ }
preference.setIcon(Utils.getSafeIcon(getDefaultAppIcon()));
} else {
Log.d(TAG, "No default app");
- preference.setSummary(R.string.app_list_preference_none);
+ if (showLabelAsTitle()) {
+ preference.setTitle(R.string.app_list_preference_none);
+ } else {
+ preference.setSummary(R.string.app_list_preference_none);
+ }
preference.setIcon(null);
}
mayUpdateGearIcon(app, preference);
@@ -102,6 +110,13 @@
return null;
}
+ /**
+ * Whether to show the default app label as the title, instead of as the summary.
+ */
+ protected boolean showLabelAsTitle() {
+ return false;
+ }
+
public Drawable getDefaultAppIcon() {
if (!isAvailable()) {
return null;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
index d32322b..1493e30 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
@@ -69,4 +69,9 @@
}
return null;
}
+
+ @Override
+ protected boolean showLabelAsTitle() {
+ return true;
+ }
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 6d67524..43e929b 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -208,7 +208,6 @@
private ApplicationsAdapter mApplications;
private View mLoadingContainer;
- private View mListContainer;
private SearchView mSearchView;
// Size resource used for packages whose size computation failed for some reason
@@ -402,25 +401,21 @@
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
- mListContainer = mRootView.findViewById(R.id.list_container);
- if (mListContainer != null) {
- // Create adapter and list view here
- mEmptyView = mListContainer.findViewById(android.R.id.empty);
+ mEmptyView = mRootView.findViewById(android.R.id.empty);
+ mRecyclerView = mRootView.findViewById(R.id.apps_list);
- mApplications = new ApplicationsAdapter(mApplicationsState, this, mFilter,
- savedInstanceState);
- if (savedInstanceState != null) {
- mApplications.mHasReceivedLoadEntries =
- savedInstanceState.getBoolean(EXTRA_HAS_ENTRIES, false);
- mApplications.mHasReceivedBridgeCallback =
- savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
- }
- mRecyclerView = mListContainer.findViewById(R.id.apps_list);
- mRecyclerView.setItemAnimator(null);
- mRecyclerView.setLayoutManager(new LinearLayoutManager(
- getContext(), RecyclerView.VERTICAL, false /* reverseLayout */));
- mRecyclerView.setAdapter(mApplications);
+ mApplications = new ApplicationsAdapter(mApplicationsState, this, mFilter,
+ savedInstanceState);
+ if (savedInstanceState != null) {
+ mApplications.mHasReceivedLoadEntries =
+ savedInstanceState.getBoolean(EXTRA_HAS_ENTRIES, false);
+ mApplications.mHasReceivedBridgeCallback =
+ savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
}
+ mRecyclerView.setItemAnimator(null);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(
+ getContext(), RecyclerView.VERTICAL, false /* reverseLayout */));
+ mRecyclerView.setAdapter(mApplications);
// We have to do this now because PreferenceFrameLayout looks at it
// only when the view is added.
@@ -985,16 +980,8 @@
// overlapped by floating filter.
if (hasFilter) {
mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE);
- mManageApplications.mRecyclerView.setPadding(0 /* left */,
- mContext.getResources().getDimensionPixelSize(
- R.dimen.app_bar_height) /* top */,
- 0 /* right */,
- 0 /* bottom */);
} else {
mManageApplications.mSpinnerHeader.setVisibility(View.GONE);
- mManageApplications.mRecyclerView.setPadding(0 /* left */, 0 /* top */,
- 0 /* right */,
- 0 /* bottom */);
}
}
}
@@ -1044,7 +1031,8 @@
mManageApplications = manageApplications;
mLoadingViewController = new LoadingViewController(
mManageApplications.mLoadingContainer,
- mManageApplications.mListContainer
+ mManageApplications.mRecyclerView,
+ mManageApplications.mEmptyView
);
mContext = manageApplications.getActivity();
mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
@@ -1303,11 +1291,9 @@
mOriginalEntries = entries;
notifyDataSetChanged();
if (getItemCount() == 0) {
- mManageApplications.mRecyclerView.setVisibility(View.GONE);
- mManageApplications.mEmptyView.setVisibility(View.VISIBLE);
+ mLoadingViewController.showEmpty(false /* animate */);
} else {
- mManageApplications.mEmptyView.setVisibility(View.GONE);
- mManageApplications.mRecyclerView.setVisibility(View.VISIBLE);
+ mLoadingViewController.showContent(false /* animate */);
if (mManageApplications.mSearchView != null
&& mManageApplications.mSearchView.isVisibleToUser()) {
@@ -1324,10 +1310,6 @@
mLastIndex = -1;
}
- if (mSession.getAllApps().size() != 0
- && mManageApplications.mListContainer.getVisibility() != View.VISIBLE) {
- mLoadingViewController.showContent(true /* animate */);
- }
if (mManageApplications.mListType == LIST_TYPE_USAGE_ACCESS) {
// No enabled or disabled filters for usage access.
return;
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index 3b8f255..26d8a45 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -242,6 +242,7 @@
// This will need to be updated if the device has sensors other than BIOMETRIC_STRONG
if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) {
launchCredentialOnlyEnroll();
+ finish();
} else if (canUseFace && canUseFingerprint) {
if (mParentalOptionsRequired && mGkPwHandle != null) {
launchFaceAndFingerprintEnroll();
@@ -405,22 +406,6 @@
super.onApplyThemeResource(theme, newResid, first);
}
- @Override
- protected void onStop() {
- super.onStop();
-
- if (mConfirmingCredentials
- || mParentalOptionsRequired
- || mMultiBiometricEnrollHelper != null) {
- return;
- }
-
- if (!isChangingConfigurations()) {
- Log.d(TAG, "Finishing in onStop");
- finish();
- }
- }
-
private void setOrConfirmCredentialsNow() {
if (!mConfirmingCredentials) {
mConfirmingCredentials = true;
diff --git a/src/com/android/settings/biometrics/face/FaceProfileStatusPreferenceController.java b/src/com/android/settings/biometrics/face/FaceProfileStatusPreferenceController.java
index 56b325b..c46ddcf 100644
--- a/src/com/android/settings/biometrics/face/FaceProfileStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceProfileStatusPreferenceController.java
@@ -19,16 +19,20 @@
import android.content.Context;
import android.os.UserHandle;
-import com.android.settings.R;
-
import androidx.preference.Preference;
+import com.android.settings.R;
+
public class FaceProfileStatusPreferenceController extends FaceStatusPreferenceController {
private static final String KEY_FACE_SETTINGS = "face_settings_profile";
public FaceProfileStatusPreferenceController(Context context) {
- super(context, KEY_FACE_SETTINGS);
+ this(context, KEY_FACE_SETTINGS);
+ }
+
+ public FaceProfileStatusPreferenceController(Context context, String key) {
+ super(context, key);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 8c3b1ce..a75fb0f 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -64,9 +64,13 @@
super.onCreate(savedInstanceState);
final ImageView iconFingerprint = findViewById(R.id.icon_fingerprint);
+ final ImageView iconDeviceLocked = findViewById(R.id.icon_device_locked);
+ final ImageView iconTrashCan = findViewById(R.id.icon_trash_can);
final ImageView iconInfo = findViewById(R.id.icon_info);
final ImageView iconLink = findViewById(R.id.icon_link);
iconFingerprint.getDrawable().setColorFilter(getIconColorFilter());
+ iconDeviceLocked.getDrawable().setColorFilter(getIconColorFilter());
+ iconTrashCan.getDrawable().setColorFilter(getIconColorFilter());
iconInfo.getDrawable().setColorFilter(getIconColorFilter());
iconLink.getDrawable().setColorFilter(getIconColorFilter());
@@ -87,7 +91,7 @@
@StringRes
int getNegativeButtonTextId() {
- return R.string.security_settings_fingerprint_enroll_introduction_skip;
+ return R.string.security_settings_fingerprint_enroll_introduction_no_thanks;
}
@StringRes
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceController.java b/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceController.java
index 23873f9..0d9893d 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceController.java
@@ -25,7 +25,11 @@
public static final String KEY_FINGERPRINT_SETTINGS = "fingerprint_settings_profile";
public FingerprintProfileStatusPreferenceController(Context context) {
- super(context, KEY_FINGERPRINT_SETTINGS);
+ this(context, KEY_FINGERPRINT_SETTINGS);
+ }
+
+ public FingerprintProfileStatusPreferenceController(Context context, String key) {
+ super(context, key);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
index e105911..4bd8afd 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
@@ -26,7 +26,6 @@
import android.view.View;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricUtils;
@@ -34,8 +33,6 @@
import com.android.settings.password.SetupChooseLockGeneric;
import com.android.settings.password.SetupSkipDialog;
-import com.google.android.setupcompat.template.FooterButton;
-
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction {
/**
* Returns the number of fingerprint enrolled.
@@ -57,11 +54,6 @@
}
@Override
- int getNegativeButtonTextId() {
- return R.string.security_settings_face_enroll_introduction_cancel;
- }
-
- @Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_LOCK_SCREEN_PRESENT, mAlreadyHadLockScreenSetup);
@@ -79,19 +71,6 @@
}
@Override
- protected void initViews() {
- super.initViews();
-
- FooterButton nextButton = getNextButton();
- nextButton.setText(
- this, R.string.security_settings_fingerprint_enroll_introduction_continue_setup);
-
- final FooterButton cancelButton = getCancelButton();
- cancelButton.setText(
- this, R.string.security_settings_fingerprint_enroll_introduction_cancel_setup);
- }
-
- @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if lock was already present, do not return intent data since it must have been
// reported in previous attempts
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
index 8d14cf9..8850acd 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
@@ -107,7 +107,7 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
return checkIfUsbDataSignalingIsDisabled(
- context, UserHandle.myUserId()) != null;
+ context, UserHandle.myUserId()) == null;
}
@Override
diff --git a/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java b/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
index 0a60ed3..ec311f4 100644
--- a/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
@@ -54,7 +54,7 @@
SettingsMainSwitchPreference pref = (SettingsMainSwitchPreference) screen.findPreference(
getPreferenceKey());
pref.addOnSwitchChangeListener(this);
- pref.updateStatus(isChecked());
+ pref.setChecked(isChecked());
}
@Override
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
index ccc7436..f898ab2 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
@@ -65,7 +65,8 @@
R.layout.admin_support_details_dialog, null);
mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
.createInstance(mActivity, restriction,
- new DeviceAdminStringProviderImpl(mActivity));
+ new DeviceAdminStringProviderImpl(mActivity),
+ UserHandle.SYSTEM);
}
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java b/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java
index ca8a982..7575066 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java
@@ -28,17 +28,23 @@
private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
private final PrivacyPreferenceControllerHelper mPrivacyPreferenceControllerHelper;
+ private final String mPreferenceKey;
public EnterprisePrivacyPreferenceController(Context context) {
- this(Objects.requireNonNull(context), new PrivacyPreferenceControllerHelper(context));
+ this(Objects.requireNonNull(context), KEY_ENTERPRISE_PRIVACY);
+ }
+
+ public EnterprisePrivacyPreferenceController(Context context, String key) {
+ this(Objects.requireNonNull(context), new PrivacyPreferenceControllerHelper(context), key);
}
@VisibleForTesting
- EnterprisePrivacyPreferenceController(
- Context context, PrivacyPreferenceControllerHelper privacyPreferenceControllerHelper) {
+ EnterprisePrivacyPreferenceController(Context context,
+ PrivacyPreferenceControllerHelper privacyPreferenceControllerHelper, String key) {
super(Objects.requireNonNull(context));
mPrivacyPreferenceControllerHelper = Objects.requireNonNull(
privacyPreferenceControllerHelper);
+ this.mPreferenceKey = key;
}
@Override
@@ -54,6 +60,6 @@
@Override
public String getPreferenceKey() {
- return KEY_ENTERPRISE_PRIVACY;
+ return mPreferenceKey;
}
}
diff --git a/src/com/android/settings/enterprise/FinancedPrivacyPreferenceController.java b/src/com/android/settings/enterprise/FinancedPrivacyPreferenceController.java
index aca21b6..dd7b2e7 100644
--- a/src/com/android/settings/enterprise/FinancedPrivacyPreferenceController.java
+++ b/src/com/android/settings/enterprise/FinancedPrivacyPreferenceController.java
@@ -32,17 +32,23 @@
private static final String PREF_KEY_FINANCED_PRIVACY = "financed_privacy";
private final PrivacyPreferenceControllerHelper mPrivacyPreferenceControllerHelper;
+ private final String mPreferenceKey;
public FinancedPrivacyPreferenceController(Context context) {
- this(Objects.requireNonNull(context), new PrivacyPreferenceControllerHelper(context));
+ this(Objects.requireNonNull(context), PREF_KEY_FINANCED_PRIVACY);
+ }
+
+ public FinancedPrivacyPreferenceController(Context context, String key) {
+ this(Objects.requireNonNull(context), new PrivacyPreferenceControllerHelper(context), key);
}
@VisibleForTesting
- FinancedPrivacyPreferenceController(
- Context context, PrivacyPreferenceControllerHelper privacyPreferenceControllerHelper) {
+ FinancedPrivacyPreferenceController(Context context,
+ PrivacyPreferenceControllerHelper privacyPreferenceControllerHelper, String key) {
super(Objects.requireNonNull(context));
mPrivacyPreferenceControllerHelper = Objects.requireNonNull(
privacyPreferenceControllerHelper);
+ this.mPreferenceKey = key;
}
@Override
@@ -57,6 +63,6 @@
@Override
public String getPreferenceKey() {
- return PREF_KEY_FINANCED_PRIVACY;
+ return mPreferenceKey;
}
}
diff --git a/src/com/android/settings/gestures/LongPressPowerButtonPreferenceController.java b/src/com/android/settings/gestures/LongPressPowerButtonPreferenceController.java
index 96db2c9..3e9c80f 100644
--- a/src/com/android/settings/gestures/LongPressPowerButtonPreferenceController.java
+++ b/src/com/android/settings/gestures/LongPressPowerButtonPreferenceController.java
@@ -16,45 +16,30 @@
package com.android.settings.gestures;
-import android.content.ContentResolver;
import android.content.Context;
-import android.content.pm.PackageManager;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.Looper;
import android.provider.Settings;
-import androidx.annotation.Nullable;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
-import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
+
/**
* Configures the behaviour of long press power button action.
*/
-public class LongPressPowerButtonPreferenceController extends TogglePreferenceController implements
- LifecycleObserver {
+public class LongPressPowerButtonPreferenceController extends TogglePreferenceController {
private static final String POWER_BUTTON_LONG_PRESS_SETTING =
Settings.Global.POWER_BUTTON_LONG_PRESS;
- private static final Uri POWER_BUTTON_LONG_PRESS_SETTING_URI =
- Settings.Global.getUriFor(POWER_BUTTON_LONG_PRESS_SETTING);
private static final String KEY_CHORD_POWER_VOLUME_UP_SETTING =
Settings.Global.KEY_CHORD_POWER_VOLUME_UP;
- // Used for fallback to global actions if necessary.
- @VisibleForTesting
- static final String CARDS_AVAILABLE_KEY =
- Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
- @VisibleForTesting
- static final String CARDS_ENABLED_KEY = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
+ private static final String FOOTER_HINT_KEY = "power_menu_power_volume_up_hint";
+ private static final String ASSIST_SWITCH_KEY = "gesture_power_menu_long_press_for_assist";
/**
* Values used for long press power button behaviour when Assist setting is enabled.
@@ -63,9 +48,9 @@
* source of the value.
*/
@VisibleForTesting
- static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
+ static final int LONG_PRESS_POWER_NO_ACTION = 0;
@VisibleForTesting
- static final int LONG_PRESS_POWER_SHUT_OFF = 2;
+ static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
@VisibleForTesting
static final int LONG_PRESS_POWER_ASSISTANT_VALUE = 5; // Settings.Secure.ASSISTANT
@@ -89,13 +74,18 @@
* power menu, depending on their respective settings.
*/
private static final int POWER_BUTTON_LONG_PRESS_DEFAULT_VALUE_RESOURCE =
- R.integer.config_longPressOnPowerBehavior;
+ com.android.internal.R.integer.config_longPressOnPowerBehavior;
private static final int KEY_CHORD_POWER_VOLUME_UP_DEFAULT_VALUE_RESOURCE =
- R.integer.config_keyChordPowerVolumeUp;
+ com.android.internal.R.integer.config_keyChordPowerVolumeUp;
- @Nullable
- private SettingObserver mSettingsObserver;
+ @MonotonicNonNull
+ @VisibleForTesting
+ Preference mFooterHint;
+
+ @MonotonicNonNull
+ @VisibleForTesting
+ Preference mAssistSwitch;
public LongPressPowerButtonPreferenceController(Context context, String key) {
super(context, key);
@@ -104,26 +94,22 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mSettingsObserver = new SettingObserver(screen.findPreference(getPreferenceKey()));
+ mFooterHint = screen.findPreference(FOOTER_HINT_KEY);
+ mAssistSwitch = screen.findPreference(ASSIST_SWITCH_KEY);
+ refreshStateDisplay();
}
- /**
- * Called when the settings pages resumes.
- */
- @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
- public void onResume() {
- if (mSettingsObserver != null) {
- mSettingsObserver.register();
- }
- }
-
- /**
- * Called when the settings page pauses.
- */
- @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
- public void onPause() {
- if (mSettingsObserver != null) {
- mSettingsObserver.unregister();
+ @Override
+ public CharSequence getSummary() {
+ final int powerButtonValue = getPowerButtonValue();
+ if (powerButtonValue == LONG_PRESS_POWER_ASSISTANT_VALUE) {
+ return mContext.getString(R.string.power_menu_summary_long_press_for_assist_enabled);
+ } else if (powerButtonValue == LONG_PRESS_POWER_GLOBAL_ACTIONS) {
+ return mContext.getString(
+ R.string.power_menu_summary_long_press_for_assist_disabled_with_power_menu);
+ } else {
+ return mContext.getString(
+ R.string.power_menu_summary_long_press_for_assist_disabled_no_action);
}
}
@@ -136,10 +122,7 @@
@Override
public boolean isChecked() {
- final int powerButtonValue = Settings.Global.getInt(mContext.getContentResolver(),
- POWER_BUTTON_LONG_PRESS_SETTING,
- mContext.getResources().getInteger(POWER_BUTTON_LONG_PRESS_DEFAULT_VALUE_RESOURCE));
- return powerButtonValue == LONG_PRESS_POWER_ASSISTANT_VALUE;
+ return getPowerButtonValue() == LONG_PRESS_POWER_ASSISTANT_VALUE;
}
@Override
@@ -148,12 +131,48 @@
// The key chord value is dependant on the long press setting and it always
// toggled in tandem. POWER_BUTTON_LONG_PRESS_SETTING is always the source
// of truth for both.
- return setPowerVolumeChordValue(isChecked);
+ setPowerVolumeChordValue(isChecked);
+ refreshStateDisplay();
+ return true;
}
return false;
}
+ private void refreshStateDisplay() {
+ if (mAssistSwitch != null) {
+ mAssistSwitch.setSummary(getSummary());
+ }
+
+ if (mFooterHint != null) {
+ String footerHintText = mContext.getString(R.string.power_menu_power_volume_up_hint);
+ // If the device supports hush gesture, we need to notify the user where to find
+ // the setting.
+ if (mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled)) {
+ footerHintText = footerHintText + "\n\n" + mContext.getString(
+ R.string.power_menu_power_prevent_ringing_hint);
+ }
+
+ mFooterHint.setSummary(footerHintText);
+ mFooterHint.setVisible(isPowerMenuKeyChordEnabled(mContext));
+ }
+ }
+
+ private int getPowerButtonValue() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ POWER_BUTTON_LONG_PRESS_SETTING,
+ mContext.getResources().getInteger(POWER_BUTTON_LONG_PRESS_DEFAULT_VALUE_RESOURCE));
+ }
+
+ private static boolean isPowerMenuKeyChordEnabled(Context context) {
+ return Settings.Global.getInt(context.getContentResolver(),
+ KEY_CHORD_POWER_VOLUME_UP_SETTING,
+ context.getResources().getInteger(
+ com.android.internal.R.integer.config_keyChordPowerVolumeUp))
+ == KEY_CHORD_POWER_VOLUME_UP_GLOBAL_ACTIONS;
+ }
+
private boolean setPowerLongPressValue(boolean isChecked) {
if (isChecked) {
return Settings.Global.putInt(mContext.getContentResolver(),
@@ -162,14 +181,12 @@
// We need to determine the right disabled value - we set it to device default
// if it's different than Assist, otherwise we fallback to either global actions or power
- //menu.
+ // menu.
final int defaultPowerButtonValue = mContext.getResources().getInteger(
POWER_BUTTON_LONG_PRESS_DEFAULT_VALUE_RESOURCE);
if (defaultPowerButtonValue == LONG_PRESS_POWER_ASSISTANT_VALUE) {
- final int fallbackValue = isCardsOrControlsAvailable() ? LONG_PRESS_POWER_GLOBAL_ACTIONS
- : LONG_PRESS_POWER_SHUT_OFF;
return Settings.Global.putInt(mContext.getContentResolver(),
- POWER_BUTTON_LONG_PRESS_SETTING, fallbackValue);
+ POWER_BUTTON_LONG_PRESS_SETTING, LONG_PRESS_POWER_NO_ACTION);
}
return Settings.Global.putInt(mContext.getContentResolver(),
@@ -187,53 +204,11 @@
KEY_CHORD_POWER_VOLUME_UP_SETTING, KEY_CHORD_POWER_VOLUME_UP_GLOBAL_ACTIONS);
}
- // If the key chord defaults to mute toggle, we restore that setting if LPP option is
- // disabled. Otherwise we default to no action.
- boolean isMuteToggleKeyChordDefault = mContext.getResources().getInteger(
- KEY_CHORD_POWER_VOLUME_UP_DEFAULT_VALUE_RESOURCE)
- == KEY_CHORD_POWER_VOLUME_UP_MUTE_TOGGLE;
+ // We restore key chord to the default value.
+ int keyChordDefaultValue = mContext.getResources().getInteger(
+ KEY_CHORD_POWER_VOLUME_UP_DEFAULT_VALUE_RESOURCE);
return Settings.Global.putInt(mContext.getContentResolver(),
- KEY_CHORD_POWER_VOLUME_UP_SETTING, isMuteToggleKeyChordDefault
- ? KEY_CHORD_POWER_VOLUME_UP_MUTE_TOGGLE
- : KEY_CHORD_POWER_VOLUME_UP_NO_ACTION);
- }
-
- /**
- * Returns true if the global actions menu on power button click is enabled via any of the
- * content options.
- */
- private boolean isCardsOrControlsAvailable() {
- final ContentResolver resolver = mContext.getContentResolver();
- final boolean cardsAvailable = Settings.Secure.getInt(resolver, CARDS_AVAILABLE_KEY, 0)
- != 0;
- final boolean controlsAvailable = mContext.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_CONTROLS);
- return cardsAvailable || controlsAvailable;
- }
-
- private final class SettingObserver extends ContentObserver {
-
- private final Preference mPreference;
-
- SettingObserver(Preference preference) {
- super(new Handler(Looper.getMainLooper()));
- mPreference = preference;
- }
-
- public void register() {
- final ContentResolver cr = mContext.getContentResolver();
- cr.registerContentObserver(POWER_BUTTON_LONG_PRESS_SETTING_URI, false, this);
- }
-
- public void unregister() {
- final ContentResolver cr = mContext.getContentResolver();
- cr.unregisterContentObserver(this);
- }
-
- @Override
- public void onChange(boolean selfChange) {
- updateState(mPreference);
- }
+ KEY_CHORD_POWER_VOLUME_UP_SETTING, keyChordDefaultValue);
}
}
diff --git a/src/com/android/settings/gestures/OneHandedSettings.java b/src/com/android/settings/gestures/OneHandedSettings.java
index 6d1cbfd..51c6b66 100644
--- a/src/com/android/settings/gestures/OneHandedSettings.java
+++ b/src/com/android/settings/gestures/OneHandedSettings.java
@@ -16,19 +16,18 @@
package com.android.settings.gestures;
+import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.os.UserHandle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.widget.IllustrationPreference;
/**
* Fragment for One-handed mode settings
@@ -37,13 +36,27 @@
* providing basic accessibility shortcut service setup.
*/
public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
+
private static final String ONE_HANDED_SHORTCUT_KEY = "one_handed_shortcuts_preference";
+ private static final String ONE_HANDED_ILLUSTRATION_KEY = "one_handed_header";
private String mFeatureName;
+ private OneHandedSettingsUtils mUtils;
@Override
protected void updatePreferenceStates() {
OneHandedSettingsUtils.setUserId(UserHandle.myUserId());
super.updatePreferenceStates();
+
+ final IllustrationPreference preference =
+ (IllustrationPreference) getPreferenceScreen().findPreference(
+ ONE_HANDED_ILLUSTRATION_KEY);
+ if (preference != null) {
+ final boolean isSwipeDownNotification =
+ OneHandedSettingsUtils.isSwipeDownNotificationEnabled(getContext());
+ preference.setLottieAnimationResId(
+ isSwipeDownNotification ? R.raw.lottie_swipe_for_notifications
+ : R.raw.lottie_one_hand_mode);
+ }
}
@Override
@@ -69,9 +82,21 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return super.onCreateView(inflater, container, savedInstanceState);
+ public void onStart() {
+ super.onStart();
+ mUtils = new OneHandedSettingsUtils(this.getContext());
+ mUtils.registerToggleAwareObserver(uri -> {
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.runOnUiThread(() -> updatePreferenceStates());
+ }
+ });
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ mUtils.unregisterToggleAwareObserver();
}
@Override
diff --git a/src/com/android/settings/gestures/PowerMenuPreferenceController.java b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
index 0693753..0d5f810 100644
--- a/src/com/android/settings/gestures/PowerMenuPreferenceController.java
+++ b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
@@ -17,28 +17,54 @@
package com.android.settings.gestures;
import android.content.Context;
+import android.provider.Settings;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class PowerMenuPreferenceController extends BasePreferenceController {
+ private static final String POWER_BUTTON_LONG_PRESS_SETTING =
+ Settings.Global.POWER_BUTTON_LONG_PRESS;
+
+ @VisibleForTesting
+ static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
+ @VisibleForTesting
+ static final int LONG_PRESS_POWER_ASSISTANT_VALUE = 5;
+
public PowerMenuPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public CharSequence getSummary() {
- return mContext.getText(R.string.power_menu_long_press_for_assist);
+ final int powerButtonValue = getPowerButtonLongPressValue(mContext);
+ if (powerButtonValue == LONG_PRESS_POWER_ASSISTANT_VALUE) {
+ return mContext.getText(R.string.power_menu_summary_long_press_for_assist_enabled);
+ } else if (powerButtonValue == LONG_PRESS_POWER_GLOBAL_ACTIONS) {
+ return mContext.getText(
+ R.string.power_menu_summary_long_press_for_assist_disabled_with_power_menu);
+ } else {
+ return mContext.getText(
+ R.string.power_menu_summary_long_press_for_assist_disabled_no_action);
+ }
}
@Override
public int getAvailabilityStatus() {
- return isAssistInvocationAvailable() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return isAssistInvocationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
private boolean isAssistInvocationAvailable() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable);
}
+
+ private static int getPowerButtonLongPressValue(Context context) {
+ return Settings.Global.getInt(context.getContentResolver(),
+ POWER_BUTTON_LONG_PRESS_SETTING,
+ context.getResources().getInteger(
+ com.android.internal.R.integer.config_longPressOnPowerBehavior));
+ }
}
diff --git a/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java b/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java
index e1e56a8..e3d779c 100644
--- a/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java
+++ b/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java
@@ -22,12 +22,14 @@
import androidx.preference.PreferenceScreen;
-import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.widget.SettingsMainSwitchPreferenceController;
/**
- * {@link TogglePreferenceController} that controls whether Adaptive connectivity option is enabled.
+ * {@link SettingsMainSwitchPreferenceController}
+ * that controls whether Adaptive connectivity option is enabled.
*/
-public class AdaptiveConnectivityTogglePreferenceController extends TogglePreferenceController {
+public class AdaptiveConnectivityTogglePreferenceController extends
+ SettingsMainSwitchPreferenceController {
private final WifiManager mWifiManager;
diff --git a/src/com/android/settings/network/InternetResetHelper.java b/src/com/android/settings/network/InternetResetHelper.java
new file mode 100644
index 0000000..d6c5476
--- /dev/null
+++ b/src/com/android/settings/network/InternetResetHelper.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2021 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.network;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.wifi.WifiManager;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Process;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.UiThread;
+import androidx.annotation.VisibleForTesting;
+import androidx.annotation.WorkerThread;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+
+import com.android.settingslib.connectivity.ConnectivitySubsystemsRecoveryManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Helper class to restart connectivity for all requested subsystems.
+ */
+public class InternetResetHelper implements LifecycleObserver,
+ ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback {
+
+ protected static final String TAG = "InternetResetHelper";
+ public static final long RESTART_TIMEOUT_MS = 15_000; // 15 seconds
+
+ protected final Context mContext;
+ protected Preference mResettingPreference;
+ protected NetworkMobileProviderController mMobileNetworkController;
+ protected Preference mWifiTogglePreferences;
+ protected List<PreferenceCategory> mWifiNetworkPreferences =
+ new ArrayList<PreferenceCategory>();
+
+ protected final WifiManager mWifiManager;
+ protected final IntentFilter mWifiStateFilter;
+ protected final BroadcastReceiver mWifiStateReceiver = new BroadcastReceiver() {
+ @Override
+ @WorkerThread
+ public void onReceive(Context context, Intent intent) {
+ if (intent != null && TextUtils.equals(intent.getAction(),
+ WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
+ updateWifiStateChange();
+ }
+ }
+ };
+
+ protected ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
+ protected HandlerThread mWorkerThread;
+ protected boolean mIsRecoveryReady;
+ protected boolean mIsWifiReady;
+ protected HandlerInjector mHandlerInjector;
+ protected final Runnable mResumeRunnable = () -> {
+ resumePreferences();
+ };
+ protected final Runnable mTimeoutRunnable = () -> {
+ mIsRecoveryReady = true;
+ mIsWifiReady = true;
+ resumePreferences();
+ };
+
+ public InternetResetHelper(Context context, Lifecycle lifecycle) {
+ mContext = context;
+ mHandlerInjector = new HandlerInjector(context);
+ mWifiManager = mContext.getSystemService(WifiManager.class);
+ mWifiStateFilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+
+ mWorkerThread = new HandlerThread(TAG
+ + "{" + Integer.toHexString(System.identityHashCode(this)) + "}",
+ Process.THREAD_PRIORITY_BACKGROUND);
+ mWorkerThread.start();
+ mConnectivitySubsystemsRecoveryManager = new ConnectivitySubsystemsRecoveryManager(
+ mContext, mWorkerThread.getThreadHandler());
+
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ /** @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) */
+ @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
+ public void onResume() {
+ mContext.registerReceiver(mWifiStateReceiver, mWifiStateFilter);
+ }
+
+ /** @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) */
+ @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
+ public void onPause() {
+ mContext.unregisterReceiver(mWifiStateReceiver);
+ }
+
+ /** @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) */
+ @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
+ public void onDestroy() {
+ mHandlerInjector.removeCallbacks(mResumeRunnable);
+ mHandlerInjector.removeCallbacks(mTimeoutRunnable);
+ mWorkerThread.quit();
+ }
+
+ @Override
+ @WorkerThread
+ public void onSubsystemRestartOperationBegin() {
+ Log.d(TAG, "The connectivity subsystem is starting for recovery.");
+ }
+
+ @Override
+ @WorkerThread
+ public void onSubsystemRestartOperationEnd() {
+ Log.d(TAG, "The connectivity subsystem is done for recovery.");
+ if (!mIsRecoveryReady) {
+ mIsRecoveryReady = true;
+ mHandlerInjector.postDelayed(mResumeRunnable, 0 /* delayMillis */);
+ }
+ }
+
+ @VisibleForTesting
+ @WorkerThread
+ protected void updateWifiStateChange() {
+ if (!mIsWifiReady && mWifiManager.isWifiEnabled()) {
+ Log.d(TAG, "The Wi-Fi subsystem is done for recovery.");
+ mIsWifiReady = true;
+ mHandlerInjector.postDelayed(mResumeRunnable, 0 /* delayMillis */);
+ }
+ }
+
+ /**
+ * Sets the resetting preference.
+ */
+ @UiThread
+ public void setResettingPreference(Preference preference) {
+ mResettingPreference = preference;
+ }
+
+ /**
+ * Sets the mobile network controller.
+ */
+ @UiThread
+ public void setMobileNetworkController(NetworkMobileProviderController controller) {
+ mMobileNetworkController = controller;
+ }
+
+ /**
+ * Sets the Wi-Fi toggle preference.
+ */
+ @UiThread
+ public void setWifiTogglePreference(Preference preference) {
+ mWifiTogglePreferences = preference;
+ }
+
+ /**
+ * Adds the Wi-Fi network preference.
+ */
+ @UiThread
+ public void addWifiNetworkPreference(PreferenceCategory preference) {
+ if (preference != null) {
+ mWifiNetworkPreferences.add(preference);
+ }
+ }
+
+ @UiThread
+ protected void suspendPreferences() {
+ Log.d(TAG, "Suspend the subsystem preferences");
+ if (mMobileNetworkController != null) {
+ mMobileNetworkController.hidePreference(true /* hide */, true /* immediately */);
+ }
+ if (mWifiTogglePreferences != null) {
+ mWifiTogglePreferences.setVisible(false);
+ }
+ for (PreferenceCategory pref : mWifiNetworkPreferences) {
+ pref.removeAll();
+ pref.setVisible(false);
+ }
+ if (mResettingPreference != null) {
+ mResettingPreference.setVisible(true);
+ }
+ }
+
+ @UiThread
+ protected void resumePreferences() {
+ if (mIsRecoveryReady && mMobileNetworkController != null) {
+ Log.d(TAG, "Resume the Mobile Network controller");
+ mMobileNetworkController.hidePreference(false /* hide */, false /* immediately */);
+ }
+ if (mIsWifiReady && mWifiTogglePreferences != null) {
+ Log.d(TAG, "Resume the Wi-Fi preferences");
+ mWifiTogglePreferences.setVisible(true);
+ for (PreferenceCategory pref : mWifiNetworkPreferences) {
+ pref.setVisible(true);
+ }
+ }
+ if (mIsRecoveryReady && mIsWifiReady) {
+ mHandlerInjector.removeCallbacks(mTimeoutRunnable);
+ if (mResettingPreference != null) {
+ Log.d(TAG, "Resume the Resetting preference");
+ mResettingPreference.setVisible(false);
+ }
+ }
+ }
+
+ /**
+ * Restart connectivity for all requested subsystems.
+ */
+ @UiThread
+ public void restart() {
+ if (!mConnectivitySubsystemsRecoveryManager.isRecoveryAvailable()) {
+ Log.e(TAG, "The connectivity subsystem is not available to restart.");
+ return;
+ }
+
+ Log.d(TAG, "The connectivity subsystem is restarting for recovery.");
+ suspendPreferences();
+ mIsRecoveryReady = false;
+ mIsWifiReady = !mWifiManager.isWifiEnabled();
+ mHandlerInjector.postDelayed(mTimeoutRunnable, RESTART_TIMEOUT_MS);
+ mConnectivitySubsystemsRecoveryManager.triggerSubsystemRestart(null /* reason */, this);
+ }
+
+ /**
+ * Wrapper for testing compatibility.
+ */
+ @VisibleForTesting
+ static class HandlerInjector {
+ protected final Handler mHandler;
+
+ HandlerInjector(Context context) {
+ mHandler = context.getMainThreadHandler();
+ }
+
+ public void postDelayed(Runnable runnable, long delayMillis) {
+ mHandler.postDelayed(runnable, delayMillis);
+ }
+
+ public void removeCallbacks(Runnable runnable) {
+ mHandler.removeCallbacks(runnable);
+ }
+ }
+}
diff --git a/src/com/android/settings/network/NetworkMobileProviderController.java b/src/com/android/settings/network/NetworkMobileProviderController.java
index 5dc6c0d..33123b3 100644
--- a/src/com/android/settings/network/NetworkMobileProviderController.java
+++ b/src/com/android/settings/network/NetworkMobileProviderController.java
@@ -50,6 +50,7 @@
private SubscriptionsPreferenceController mSubscriptionsController;
private int mOriginalExpandedChildrenCount;
+ private boolean mHide;
public NetworkMobileProviderController(Context context, String key) {
super(context, key);
@@ -94,7 +95,7 @@
@Override
public int getAvailabilityStatus() {
- if (mSubscriptionsController == null) {
+ if (mHide || mSubscriptionsController == null) {
return CONDITIONALLY_UNAVAILABLE;
}
return mSubscriptionsController.isAvailable() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
@@ -122,4 +123,14 @@
mSubscriptionsController.setWifiPickerTrackerHelper(helper);
}
}
+
+ /**
+ * Hides the preference.
+ */
+ public void hidePreference(boolean hide, boolean immediately) {
+ mHide = hide;
+ if (immediately) {
+ mPreferenceCategory.setVisible(hide ? false : isAvailable());
+ }
+ }
}
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index 88e732a..f6e7917 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -32,9 +32,7 @@
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
-import android.os.HandlerThread;
import android.os.PowerManager;
-import android.os.Process;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -78,7 +76,6 @@
import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.android.settingslib.connectivity.ConnectivitySubsystemsRecoveryManager;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.utils.ThreadUtils;
@@ -101,7 +98,6 @@
public class NetworkProviderSettings extends RestrictedSettingsFragment
implements Indexable, WifiPickerTracker.WifiPickerTrackerCallback,
WifiDialog2.WifiDialog2Listener, DialogInterface.OnDismissListener,
- ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback,
AirplaneModeEnabler.OnAirplaneModeChangedListener, InternetUpdater.InternetChangeListener {
public static final String ACTION_NETWORK_PROVIDER_SETTINGS =
@@ -192,9 +188,7 @@
private WifiManager.ActionListener mSaveListener;
private WifiManager.ActionListener mForgetListener;
- @VisibleForTesting
- protected ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
- private HandlerThread mRecoveryThread;
+ protected InternetResetHelper mInternetResetHelper;
/**
* The state of {@link #isUiRestricted()} at {@link #onCreate(Bundle)}}. This is necessary to
@@ -1274,39 +1268,17 @@
}
private void fixConnectivity() {
- if (mConnectivitySubsystemsRecoveryManager == null) {
- mRecoveryThread = new HandlerThread(TAG
- + "{" + Integer.toHexString(System.identityHashCode(this)) + "}",
- Process.THREAD_PRIORITY_BACKGROUND);
- mRecoveryThread.start();
- mConnectivitySubsystemsRecoveryManager = new ConnectivitySubsystemsRecoveryManager(
- getContext(), mRecoveryThread.getThreadHandler());
+ if (mInternetResetHelper == null) {
+ mInternetResetHelper = new InternetResetHelper(getContext(), getLifecycle());
+ mInternetResetHelper.setResettingPreference(mResetInternetPreference);
+ mInternetResetHelper.setMobileNetworkController(mNetworkMobileProviderController);
+ mInternetResetHelper.setWifiTogglePreference(
+ findPreference(WifiSwitchPreferenceController.KEY));
+ mInternetResetHelper.addWifiNetworkPreference(mConnectedWifiEntryPreferenceCategory);
+ mInternetResetHelper.addWifiNetworkPreference(mFirstWifiEntryPreferenceCategory);
+ mInternetResetHelper.addWifiNetworkPreference(mWifiEntryPreferenceCategory);
}
- if (mConnectivitySubsystemsRecoveryManager.isRecoveryAvailable()) {
- mConnectivitySubsystemsRecoveryManager.triggerSubsystemRestart(null /* reason */, this);
- }
- }
-
- /**
- * Callback for the internet recovery started.
- */
- public void onSubsystemRestartOperationBegin() {
- if (mResetInternetPreference != null) {
- mResetInternetPreference.setVisible(true);
- }
- updateAirplaneModeMsgPreference(false /* visible */);
- }
-
- /**
- * Callback for the internet recovery ended.
- */
- public void onSubsystemRestartOperationEnd() {
- if (mResetInternetPreference != null) {
- mResetInternetPreference.setVisible(false);
- }
- if (mAirplaneModeEnabler.isAirplaneModeOn()) {
- updateAirplaneModeMsgPreference(true /* visible */);
- }
+ mInternetResetHelper.restart();
}
/**
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index df705cd..146b11a 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -212,6 +212,8 @@
R.string.mobile_data_disable_message_default_carrier);
}
showMobileDataDisableDialog(getMobileDataDisableDialog(defaultSubId, carrierName));
+ // If we need to display a reminder dialog box, do nothing here.
+ return;
} else {
MobileNetworkUtils.setMobileDataEnabled(mContext, defaultSubId, newState,
false /* disableOtherSubscriptions */);
@@ -229,13 +231,24 @@
.setTitle(R.string.mobile_data_disable_title)
.setMessage(mContext.getString(R.string.mobile_data_disable_message,
carrierName))
- .setNegativeButton(android.R.string.cancel, null)
+ .setNegativeButton(android.R.string.cancel,
+ (dialog, which) -> {
+ // Because the toggle of mobile data will be turned off first, if the
+ // user cancels the operation, we need to update the slice to correct
+ // the toggle state.
+ final NetworkProviderWorker worker = getWorker();
+ if (worker != null) {
+ worker.updateSlice();
+ }
+ })
.setPositiveButton(
com.android.internal.R.string.alert_windows_notification_turn_off_action,
(dialog, which) -> {
MobileNetworkUtils.setMobileDataEnabled(mContext, defaultSubId,
false /* enabled */,
false /* disableOtherSubscriptions */);
+ doCarrierNetworkAction(true /* isToggleAction */,
+ false /* isDataEanbed */, defaultSubId);
if (mSharedPref != null) {
SharedPreferences.Editor editor = mSharedPref.edit();
editor.putBoolean(PREF_HAS_TURNED_OFF_MOBILE_DATA, false);
diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
index 0064e6c..e67ac42 100644
--- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
+++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
@@ -338,7 +338,7 @@
getString(R.string.sim_action_restart_title),
getString(R.string.sim_action_enable_dsds_text),
getString(R.string.sim_action_reboot),
- getString(R.string.cancel));
+ getString(R.string.sim_action_cancel));
}
/* Displays the SIM toggling confirmation dialog. */
@@ -359,7 +359,7 @@
title,
null,
getString(R.string.yes),
- getString(R.string.cancel));
+ getString(R.string.sim_action_cancel));
}
private void showEnableSimConfirmDialog() {
@@ -384,7 +384,7 @@
getSwitchSubscriptionTitle(),
getSwitchDialogBodyMsg(activeSub, isBetweenEsim),
getSwitchDialogPosBtnText(),
- getString(android.R.string.cancel));
+ getString(R.string.sim_action_cancel));
}
private void showNonSwitchSimConfirmDialog() {
@@ -395,7 +395,7 @@
getEnableSubscriptionTitle(),
null /* msg */,
getString(R.string.yes),
- getString(android.R.string.cancel));
+ getString(R.string.sim_action_cancel));
}
private String getSwitchDialogPosBtnText() {
diff --git a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
index c98b036..166ee5d 100644
--- a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
+++ b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
@@ -65,9 +65,6 @@
}
void setTitle(CharSequence title) {
- if (title == null) {
- return;
- }
mTitle.setText(title);
}
diff --git a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
index 8e1a4f8..d44c100 100644
--- a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
@@ -37,9 +37,17 @@
private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
+ private final String mPreferenceKey;
+
public ChangeProfileScreenLockPreferenceController(Context context,
SettingsPreferenceFragment host) {
+ this(context, host, KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
+ }
+
+ public ChangeProfileScreenLockPreferenceController(Context context,
+ SettingsPreferenceFragment host, String key) {
super(context, host);
+ this.mPreferenceKey = key;
}
public boolean isAvailable() {
@@ -65,7 +73,7 @@
@Override
public String getPreferenceKey() {
- return KEY_UNLOCK_SET_OR_CHANGE_PROFILE;
+ return mPreferenceKey;
}
@Override
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index b6e215c..2a9fced 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -26,7 +26,6 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
-import android.util.Log;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -74,6 +73,7 @@
private RestrictedSwitchPreference mUnifyProfile;
+ private final String mPreferenceKey;
private LockscreenCredential mCurrentDevicePassword;
private LockscreenCredential mCurrentProfilePassword;
@@ -82,10 +82,15 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mUnifyProfile = screen.findPreference(KEY_UNIFICATION);
+ mUnifyProfile = screen.findPreference(mPreferenceKey);
}
public LockUnificationPreferenceController(Context context, SettingsPreferenceFragment host) {
+ this(context, host, KEY_UNIFICATION);
+ }
+
+ public LockUnificationPreferenceController(
+ Context context, SettingsPreferenceFragment host, String key) {
super(context);
mHost = host;
mUm = context.getSystemService(UserManager.class);
@@ -96,6 +101,7 @@
mProfileUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
mCurrentDevicePassword = LockscreenCredential.createNone();
mCurrentProfilePassword = LockscreenCredential.createNone();
+ this.mPreferenceKey = key;
}
@Override
@@ -106,7 +112,7 @@
@Override
public String getPreferenceKey() {
- return KEY_UNIFICATION;
+ return mPreferenceKey;
}
@Override
diff --git a/src/com/android/settings/security/ScreenPinningPreferenceController.java b/src/com/android/settings/security/ScreenPinningPreferenceController.java
index 442380d..a5fdf8b 100644
--- a/src/com/android/settings/security/ScreenPinningPreferenceController.java
+++ b/src/com/android/settings/security/ScreenPinningPreferenceController.java
@@ -27,7 +27,11 @@
private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
public ScreenPinningPreferenceController(Context context) {
- super(context, KEY_SCREEN_PINNING);
+ this(context, KEY_SCREEN_PINNING);
+ }
+
+ public ScreenPinningPreferenceController(Context context, String key) {
+ super(context, key);
}
@Override
diff --git a/src/com/android/settings/security/SimLockPreferenceController.java b/src/com/android/settings/security/SimLockPreferenceController.java
index 03983b5..3b85888 100644
--- a/src/com/android/settings/security/SimLockPreferenceController.java
+++ b/src/com/android/settings/security/SimLockPreferenceController.java
@@ -41,7 +41,11 @@
private TelephonyManager mTelephonyManager;
public SimLockPreferenceController(Context context) {
- super(context, KEY_SIM_LOCK);
+ this(context, KEY_SIM_LOCK);
+ }
+
+ public SimLockPreferenceController(Context context, String key) {
+ super(context, key);
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mCarrierConfigManager = (CarrierConfigManager)
mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
diff --git a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
index 2db8c24..64ca853 100644
--- a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
+++ b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
@@ -55,9 +55,15 @@
this(context, null /* lifecycle */);
}
- // TODO (b/73074893) Replace this constructor without Lifecycle using setter method instead.
public VisiblePatternProfilePreferenceController(Context context, Lifecycle lifecycle) {
- super(context, KEY_VISIBLE_PATTERN_PROFILE);
+ this(context, lifecycle, KEY_VISIBLE_PATTERN_PROFILE);
+ }
+
+
+ // TODO (b/73074893) Replace this constructor without Lifecycle using setter method instead.
+ public VisiblePatternProfilePreferenceController(
+ Context context, Lifecycle lifecycle, String key) {
+ super(context, key);
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
mLockPatternUtils = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider()
diff --git a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
index 056c1f2..b0f991e 100644
--- a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
@@ -38,7 +38,11 @@
private TrustAgentManager mTrustAgentManager;
public ManageTrustAgentsPreferenceController(Context context) {
- super(context, KEY_MANAGE_TRUST_AGENTS);
+ this(context, KEY_MANAGE_TRUST_AGENTS);
+ }
+
+ public ManageTrustAgentsPreferenceController(Context context, String key) {
+ super(context, key);
final SecurityFeatureProvider securityFeatureProvider = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider();
mLockPatternUtils = securityFeatureProvider.getLockPatternUtils(context);
diff --git a/src/com/android/settings/widget/LoadingViewController.java b/src/com/android/settings/widget/LoadingViewController.java
index 294e55e..66eebf3 100644
--- a/src/com/android/settings/widget/LoadingViewController.java
+++ b/src/com/android/settings/widget/LoadingViewController.java
@@ -22,34 +22,66 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
+import androidx.annotation.Nullable;
+
/**
- * A helper class that manages show/hide loading spinner.
+ * A helper class that manages show/hide loading spinner, content view and empty view (optional).
*/
public class LoadingViewController {
private static final long DELAY_SHOW_LOADING_CONTAINER_THRESHOLD_MS = 100L;
- public final Handler mFgHandler;
- public final View mLoadingView;
- public final View mContentView;
+ private final Handler mFgHandler;
+ private final View mLoadingView;
+ private final View mContentView;
+ private final View mEmptyView;
public LoadingViewController(View loadingView, View contentView) {
+ this(loadingView, contentView, null /* emptyView*/);
+ }
+
+ public LoadingViewController(View loadingView, View contentView, @Nullable View emptyView) {
mLoadingView = loadingView;
mContentView = contentView;
+ mEmptyView = emptyView;
mFgHandler = new Handler(Looper.getMainLooper());
}
private Runnable mShowLoadingContainerRunnable = new Runnable() {
public void run() {
- handleLoadingContainer(false /* done */, false /* animate */);
+ showLoadingView();
}
};
+ /**
+ * Shows content view and hides loading view & empty view.
+ */
public void showContent(boolean animate) {
// Cancel any pending task to show the loading animation and show the list of
// apps directly.
mFgHandler.removeCallbacks(mShowLoadingContainerRunnable);
- handleLoadingContainer(true /* show */, animate);
+ handleLoadingContainer(true /* showContent */, false /* showEmpty*/, animate);
+ }
+
+ /**
+ * Shows empty view and hides loading view & content view.
+ */
+ public void showEmpty(boolean animate) {
+ if (mEmptyView == null) {
+ return;
+ }
+
+ // Cancel any pending task to show the loading animation and show the list of
+ // apps directly.
+ mFgHandler.removeCallbacks(mShowLoadingContainerRunnable);
+ handleLoadingContainer(false /* showContent */, true /* showEmpty */, animate);
+ }
+
+ /**
+ * Shows loading view and hides content view & empty view.
+ */
+ public void showLoadingView() {
+ handleLoadingContainer(false /* showContent */, false /* showEmpty */, false /* animate */);
}
public void showLoadingViewDelayed() {
@@ -57,8 +89,9 @@
mShowLoadingContainerRunnable, DELAY_SHOW_LOADING_CONTAINER_THRESHOLD_MS);
}
- public void handleLoadingContainer(boolean done, boolean animate) {
- handleLoadingContainer(mLoadingView, mContentView, done, animate);
+ private void handleLoadingContainer(boolean showContent, boolean showEmpty, boolean animate) {
+ handleLoadingContainer(mLoadingView, mContentView, mEmptyView,
+ showContent, showEmpty, animate);
}
/**
@@ -75,6 +108,25 @@
setViewShown(content, done, animate);
}
+ /**
+ * Show/hide loading view and content view and empty view.
+ *
+ * @param loading The loading spinner view
+ * @param content The content view
+ * @param empty The empty view shows no item summary to users.
+ * @param showContent If true, content is set visible and loading is set invisible.
+ * @param showEmpty If true, empty is set visible and loading is set invisible.
+ * @param animate Whether or not content/loading views should animate in/out.
+ */
+ public static void handleLoadingContainer(View loading, View content, View empty,
+ boolean showContent, boolean showEmpty, boolean animate) {
+ if (empty != null) {
+ setViewShown(empty, showEmpty, animate);
+ }
+ setViewShown(content, showContent, animate);
+ setViewShown(loading, !showContent && !showEmpty, animate);
+ }
+
private static void setViewShown(final View view, boolean shown, boolean animate) {
if (animate) {
Animation animation = AnimationUtils.loadAnimation(view.getContext(),
diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreference.java b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
index 09e1ca4..f0e8d95 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchPreference.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
@@ -86,9 +86,12 @@
mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
}
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
+ initMainSwitchBar();
if (mIsVisible) {
mMainSwitchBar.show();
- updateStatus(isChecked());
+ if (mMainSwitchBar.isChecked() != isChecked()) {
+ setChecked(isChecked());
+ }
registerListenerToSwitchBar();
} else {
mMainSwitchBar.hide();
@@ -145,18 +148,6 @@
}
/**
- * Update the switch status of preference
- */
- public void updateStatus(boolean checked) {
- setChecked(checked);
- if (mMainSwitchBar != null) {
- mMainSwitchBar.setTitle(mTitle);
- mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
- mMainSwitchBar.show();
- }
- }
-
- /**
* Show the MainSwitchBar
*/
public void show() {
@@ -251,6 +242,13 @@
}
}
+ private void initMainSwitchBar() {
+ if (mMainSwitchBar != null) {
+ mMainSwitchBar.setTitle(mTitle);
+ mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
+ }
+ }
+
private void registerListenerToSwitchBar() {
for (OnBeforeCheckedChangeListener listener : mBeforeCheckedChangeListeners) {
mMainSwitchBar.setOnBeforeCheckedChangeListener(listener);
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 75e6307..59f6504 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -233,6 +233,9 @@
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
final Intent intent = new Intent("android.settings.NETWORK_PROVIDER_SETTINGS");
+ // Add FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK to avoid multiple
+ // instances issue. (e.g. b/191956700)
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
final Bundle extras = getActivity().getIntent().getExtras();
if (extras != null) {
intent.putExtras(extras);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
deleted file mode 100644
index c7e5b13..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.graphics.drawable.AnimatedImageDrawable;
-import android.graphics.drawable.AnimatedVectorDrawable;
-import android.graphics.drawable.AnimationDrawable;
-import android.net.Uri;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-import com.airbnb.lottie.LottieAnimationView;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.io.InputStream;
-
-/** Tests for {@link AnimatedImagePreference}. */
-@RunWith(RobolectricTestRunner.class)
-public class AnimatedImagePreferenceTest {
- private final Context mContext = RuntimeEnvironment.application;
- private Uri mImageUri;
- private PreferenceViewHolder mViewHolder;
- private AnimatedImagePreference mAnimatedImagePreference;
-
- @Mock
- private ViewGroup mRootView;
-
- @Spy
- private ImageView mImageView;
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
-
- mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(mRootView));
- doReturn(new LottieAnimationView(mContext)).when(mRootView).findViewById(R.id.lottie_view);
- mImageView = spy(new ImageView(mContext));
-
- mAnimatedImagePreference = new AnimatedImagePreference(mContext);
- mImageUri = new Uri.Builder().build();
- }
-
- @Test
- public void playAnimation_animatedImageDrawable_success() {
- final AnimatedImageDrawable drawable = mock(AnimatedImageDrawable.class);
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(drawable).when(mImageView).getDrawable();
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(drawable).start();
- }
-
- @Test
- public void playAnimation_animatedVectorDrawable_success() {
- final AnimatedVectorDrawable drawable = mock(AnimatedVectorDrawable.class);
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(drawable).when(mImageView).getDrawable();
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(drawable).start();
- }
-
- @Test
- public void playAnimation_animationDrawable_success() {
- final AnimationDrawable drawable = mock(AnimationDrawable.class);
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(drawable).when(mImageView).getDrawable();
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(drawable).start();
- }
-
- @Test
- public void setImageUri_viewNotExist_setFail() {
- doReturn(null).when(mRootView).findViewById(R.id.animated_img);
-
- mAnimatedImagePreference.setImageUri(mImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(mImageView, never()).setImageURI(mImageUri);
- }
-
- @Test
- public void setMaxHeight_success() {
- final int maxHeight = 100;
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
-
- mAnimatedImagePreference.setMaxHeight(maxHeight);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- assertThat(mImageView.getMaxHeight()).isEqualTo(maxHeight);
- }
-
- @Test
- public void setImageUriAndRebindViewHolder_lottieImageFromRawFolder_setAnimation() {
- final int fakeLottieResId = 111111;
- final Uri lottieImageUri =
- new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
- .authority(mContext.getPackageName())
- .appendPath(String.valueOf(fakeLottieResId))
- .build();
- final LottieAnimationView lottieView = spy(new LottieAnimationView(mContext));
- doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(lottieView).when(mRootView).findViewById(R.id.lottie_view);
-
- mAnimatedImagePreference.setImageUri(lottieImageUri);
- mAnimatedImagePreference.onBindViewHolder(mViewHolder);
-
- verify(lottieView).setAnimation(any(InputStream.class), eq(null));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 86f5fe8..25eca7a 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -28,7 +28,6 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -49,7 +48,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.SearchView;
import androidx.fragment.app.FragmentActivity;
@@ -156,22 +154,6 @@
}
@Test
- public void onCreateView_shouldNotShowLoadingContainer() {
- ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
- doNothing().when(mFragment).createHeader();
-
- final LayoutInflater layoutInflater = mock(LayoutInflater.class);
- final View view = mock(View.class);
- final View loadingContainer = mock(View.class);
- when(layoutInflater.inflate(anyInt(), eq(null))).thenReturn(view);
- when(view.findViewById(R.id.loading_container)).thenReturn(loadingContainer);
-
- mFragment.onCreateView(layoutInflater, mock(ViewGroup.class), null);
-
- verify(loadingContainer, never()).setVisibility(View.VISIBLE);
- }
-
- @Test
public void onCreateOptionsMenu_shouldSetSearchQueryListener() {
final SearchView searchView = mock(SearchView.class);
final MenuItem searchMenu = mock(MenuItem.class);
@@ -221,7 +203,6 @@
@Test
public void updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer() {
ReflectionHelpers.setField(mFragment, "mLoadingContainer", mock(View.class));
- ReflectionHelpers.setField(mFragment, "mListContainer", mock(View.class));
final ManageApplications.ApplicationsAdapter adapter =
spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
@@ -243,7 +224,6 @@
@Test
public void updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer() {
ReflectionHelpers.setField(mFragment, "mLoadingContainer", mock(View.class));
- ReflectionHelpers.setField(mFragment, "mListContainer", mock(View.class));
final ManageApplications.ApplicationsAdapter adapter =
spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
@@ -272,7 +252,6 @@
when(listContainer.getVisibility()).thenReturn(View.INVISIBLE);
when(listContainer.getContext()).thenReturn(context);
ReflectionHelpers.setField(mFragment, "mLoadingContainer", loadingContainer);
- ReflectionHelpers.setField(mFragment, "mListContainer", listContainer);
final ManageApplications.ApplicationsAdapter adapter =
spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
@@ -296,7 +275,7 @@
adapter.onRebuildComplete(null);
- verify(loadingViewController).showContent(true /* animate */);
+ verify(loadingViewController).showEmpty(false /* animate */);
}
@Test
@@ -304,15 +283,16 @@
final String query = "Test";
final RecyclerView recyclerView = mock(RecyclerView.class);
final View emptyView = mock(View.class);
+ final View loadingContainer = mock(View.class);
ReflectionHelpers.setField(mFragment, "mRecyclerView", recyclerView);
ReflectionHelpers.setField(mFragment, "mEmptyView", emptyView);
+ ReflectionHelpers.setField(mFragment, "mLoadingContainer", loadingContainer);
final SearchView searchView = mock(SearchView.class);
ReflectionHelpers.setField(mFragment, "mSearchView", searchView);
when(searchView.isVisibleToUser()).thenReturn(true);
when(searchView.getQuery()).thenReturn(query);
final View listContainer = mock(View.class);
when(listContainer.getVisibility()).thenReturn(View.VISIBLE);
- ReflectionHelpers.setField(mFragment, "mListContainer", listContainer);
ReflectionHelpers.setField(
mFragment, "mFilterAdapter", mock(ManageApplications.FilterSpinnerAdapter.class));
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
@@ -491,8 +471,6 @@
mFragment.mFilterAdapter.updateFilterView(true);
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE);
- assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(
- mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java
index f4410a3..0fa4a9c 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintProfileStatusPreferenceControllerTest.java
@@ -101,4 +101,16 @@
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
}
+
+ @Test
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
+ assertThat(mController.getPreferenceKey()).isEqualTo("fingerprint_settings_profile");
+ }
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new FingerprintProfileStatusPreferenceController(mContext, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
index 2bac8f1..afb1971 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
@@ -48,7 +48,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new EnterprisePrivacyPreferenceController(
- mContext, mPrivacyPreferenceControllerHelper);
+ mContext, mPrivacyPreferenceControllerHelper, KEY_ENTERPRISE_PRIVACY);
}
@Test
@@ -90,7 +90,15 @@
}
@Test
- public void testGetPreferenceKey() {
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
assertThat(mController.getPreferenceKey()).isEqualTo(KEY_ENTERPRISE_PRIVACY);
}
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new EnterprisePrivacyPreferenceController(
+ mContext, mPrivacyPreferenceControllerHelper, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java
index f8adf6f..61da68e 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java
@@ -48,7 +48,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new FinancedPrivacyPreferenceController(
- mContext, mPrivacyPreferenceControllerHelper);
+ mContext, mPrivacyPreferenceControllerHelper, PREF_KEY_FINANCED_PRIVACY);
}
@Test
@@ -81,7 +81,15 @@
}
@Test
- public void testGetPreferenceKey() {
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
assertThat(mController.getPreferenceKey()).isEqualTo(PREF_KEY_FINANCED_PRIVACY);
}
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new FinancedPrivacyPreferenceController(
+ mContext, mPrivacyPreferenceControllerHelper, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java
index 085e53d..053fa5a 100644
--- a/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java
@@ -18,20 +18,28 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Application;
import android.content.res.Resources;
import android.provider.Settings;
+import androidx.annotation.StringRes;
+import androidx.preference.Preference;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class LongPressPowerButtonPreferenceControllerTest {
@@ -46,14 +54,20 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
+ mContext = spy(ApplicationProvider.getApplicationContext());
mResources = mock(Resources.class);
when(mContext.getResources()).thenReturn(mResources);
+ when(mResources.getString(anyInt())).thenAnswer((Answer<String>) invocation -> {
+ int id = invocation.getArgument(0);
+ return getString(id);
+ });
when(mResources.getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(true);
mController = new LongPressPowerButtonPreferenceController(mContext,
KEY_LONG_PRESS_POWER_BUTTON);
+ mController.mAssistSwitch = mock(Preference.class);
+ mController.mFooterHint = mock(Preference.class);
}
@Test
@@ -75,6 +89,60 @@
}
@Test
+ public void preferenceChecked_powerMenuHintTextShown() {
+ mController.onPreferenceChange(null, true);
+
+ verify(mController.mFooterHint).setSummary(
+ getString(
+ R.string.power_menu_power_volume_up_hint));
+ verify(mController.mFooterHint).setVisible(true);
+ }
+
+
+ @Test
+ public void preferenceUnchecked_keyChordEnabled_powerMenuHintTextShown() {
+ when(mResources.getInteger(
+ com.android.internal.R.integer.config_keyChordPowerVolumeUp))
+ .thenReturn(
+ LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_GLOBAL_ACTIONS);
+
+ mController.onPreferenceChange(null, false);
+
+ verify(mController.mFooterHint).setSummary(
+ getString(
+ R.string.power_menu_power_volume_up_hint));
+ verify(mController.mFooterHint).setVisible(true);
+ }
+
+ @Test
+ public void preferenceChecked_hushGestureEnabled_powerMenuHintTextIncludesHushHint() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled))
+ .thenReturn(true);
+
+ mController.onPreferenceChange(null, true);
+
+ verify(mController.mFooterHint).setSummary(
+ getString(
+ R.string.power_menu_power_volume_up_hint) + "\n\n"
+ + getString(
+ R.string.power_menu_power_prevent_ringing_hint));
+ verify(mController.mFooterHint).setVisible(true);
+ }
+
+
+ @Test
+ public void preferenceUnchecked_keyChordDisabled_powerMenuHintTextHidden() {
+ mController.onPreferenceChange(null, false);
+ when(mResources.getInteger(
+ com.android.internal.R.integer.config_keyChordPowerVolumeUp))
+ .thenReturn(
+ LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_NO_ACTION);
+
+ verify(mController.mFooterHint).setVisible(false);
+ }
+
+ @Test
public void preferenceChecked_longPressPowerSettingSetToAssistant() {
mController.onPreferenceChange(null, true);
@@ -84,21 +152,29 @@
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.KEY_CHORD_POWER_VOLUME_UP, -1)).isEqualTo(
LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_GLOBAL_ACTIONS);
+ verify(mController.mAssistSwitch).setSummary(
+ getString(
+ R.string.power_menu_summary_long_press_for_assist_enabled));
}
@Test
public void preferenceUnchecked_longPressPowerSettingSetToDefaultValue() {
- // Value out of range chosen deliberately.
when(mResources.getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior))
- .thenReturn(8);
+ .thenReturn(
+ LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_GLOBAL_ACTIONS);
mController.onPreferenceChange(null, false);
+
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.POWER_BUTTON_LONG_PRESS, -1)).isEqualTo(8);
+ Settings.Global.POWER_BUTTON_LONG_PRESS, -1)).isEqualTo(
+ LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_GLOBAL_ACTIONS);
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.KEY_CHORD_POWER_VOLUME_UP, -1)).isEqualTo(
LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_NO_ACTION);
+ verify(mController.mAssistSwitch).setSummary(
+ getString(
+ R.string.power_menu_summary_long_press_for_assist_disabled_with_power_menu));
}
@Test
@@ -110,9 +186,10 @@
when(mResources.getInteger(
com.android.internal.R.integer.config_keyChordPowerVolumeUp))
.thenReturn(
- LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_MUTE_TOGGLE);
+ LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_MUTE_TOGGLE);
mController.onPreferenceChange(null, false);
+
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.POWER_BUTTON_LONG_PRESS, -1)).isEqualTo(8);
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
@@ -121,7 +198,7 @@
}
@Test
- public void preferenceUnchecked_assistDefault_setShutOff() {
+ public void preferenceUnchecked_assistDefault_setNoAction() {
// Value out of range chosen deliberately.
when(mResources.getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior))
@@ -129,33 +206,19 @@
LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_ASSISTANT_VALUE);
mController.onPreferenceChange(null, false);
+
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.POWER_BUTTON_LONG_PRESS, -1)).isEqualTo(
- LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_SHUT_OFF);
+ LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_NO_ACTION);
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.KEY_CHORD_POWER_VOLUME_UP, -1)).isEqualTo(
LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_NO_ACTION);
+ verify(mController.mAssistSwitch).setSummary(
+ getString(
+ R.string.power_menu_summary_long_press_for_assist_disabled_no_action));
}
-
- @Test
- public void preferenceUnchecked_assistDefaultGlobalActionsEnabled_setGlobalActions() {
- // Value out of range chosen deliberately.
- when(mResources.getInteger(
- com.android.internal.R.integer.config_longPressOnPowerBehavior))
- .thenReturn(
- LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_ASSISTANT_VALUE);
- Settings.Secure.putInt(mContext.getContentResolver(),
- LongPressPowerButtonPreferenceController.CARDS_AVAILABLE_KEY, 1);
- Settings.Secure.putInt(mContext.getContentResolver(),
- LongPressPowerButtonPreferenceController.CARDS_ENABLED_KEY, 1);
-
- mController.onPreferenceChange(null, false);
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.POWER_BUTTON_LONG_PRESS, -1)).isEqualTo(
- LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_GLOBAL_ACTIONS);
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.KEY_CHORD_POWER_VOLUME_UP, -1)).isEqualTo(
- LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_NO_ACTION);
+ private String getString(@StringRes int id) {
+ return ApplicationProvider.getApplicationContext().getString(id);
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
index 811ed70..1a82a13 100644
--- a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
@@ -70,6 +70,6 @@
.thenReturn(false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(
- BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+ BasePreferenceController.UNSUPPORTED_ON_DEVICE);
}
}
diff --git a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
index 9951449..47cd87c 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
@@ -66,7 +66,6 @@
import com.android.settings.wifi.ConnectedWifiEntryPreference;
import com.android.settings.wifi.WifiConfigController2;
import com.android.settings.wifi.WifiDialog2;
-import com.android.settingslib.connectivity.ConnectivitySubsystemsRecoveryManager;
import com.android.settingslib.widget.LayoutPreference;
import com.android.settingslib.wifi.LongPressWifiEntryPreference;
import com.android.wifitrackerlib.WifiEntry;
@@ -105,7 +104,7 @@
@Mock
private PreferenceManager mPreferenceManager;
@Mock
- private ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
+ private InternetResetHelper mInternetResetHelper;
@Mock
private Preference mAirplaneModeMsgPreference;
@Mock
@@ -439,49 +438,14 @@
}
@Test
- public void onOptionsItemSelected_fixConnectivity_triggerSubsystemRestart() {
- doReturn(true).when(mConnectivitySubsystemsRecoveryManager).isRecoveryAvailable();
- mNetworkProviderSettings.mConnectivitySubsystemsRecoveryManager =
- mConnectivitySubsystemsRecoveryManager;
+ public void onOptionsItemSelected_fixConnectivity_restartInternet() {
+ mNetworkProviderSettings.mInternetResetHelper = mInternetResetHelper;
doReturn(false).when(mNetworkProviderSettings).isPhoneOnCall();
doReturn(NetworkProviderSettings.MENU_FIX_CONNECTIVITY).when(mMenuItem).getItemId();
mNetworkProviderSettings.onOptionsItemSelected(mMenuItem);
- verify(mConnectivitySubsystemsRecoveryManager).triggerSubsystemRestart(any(), any());
- }
-
- @Test
- public void onOptionsItemSelected_fixConnectivityOnCall_neverTriggerSubsystemRestart() {
- doReturn(true).when(mConnectivitySubsystemsRecoveryManager).isRecoveryAvailable();
- mNetworkProviderSettings.mConnectivitySubsystemsRecoveryManager =
- mConnectivitySubsystemsRecoveryManager;
- doReturn(true).when(mNetworkProviderSettings).isPhoneOnCall();
- doNothing().when(mNetworkProviderSettings).showResetInternetDialog();
- doReturn(NetworkProviderSettings.MENU_FIX_CONNECTIVITY).when(mMenuItem).getItemId();
-
- mNetworkProviderSettings.onOptionsItemSelected(mMenuItem);
-
- verify(mConnectivitySubsystemsRecoveryManager, never()).triggerSubsystemRestart(any(),
- any());
- }
-
- @Test
- public void onSubsystemRestartOperationBegin_showResetInternetHideApmMsg() {
- mNetworkProviderSettings.onSubsystemRestartOperationBegin();
-
- verify(mResetInternetPreference).setVisible(true);
- verify(mAirplaneModeMsgPreference).setVisible(false);
- }
-
- @Test
- public void onSubsystemRestartOperationEnd_showApmMsgHideResetInternet() {
- doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
-
- mNetworkProviderSettings.onSubsystemRestartOperationEnd();
-
- verify(mResetInternetPreference).setVisible(false);
- verify(mAirplaneModeMsgPreference).setVisible(true);
+ verify(mInternetResetHelper).restart();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
index be5593f..8a65e14 100644
--- a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
@@ -98,4 +98,18 @@
assertThat(mController.isAvailable()).isTrue();
}
+
+ @Test
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
+ init();
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("unification");
+ }
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new LockUnificationPreferenceController(mContext, mHost, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/security/ScreenPinningPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/ScreenPinningPreferenceControllerTest.java
index 9b041d4..f63f4c1 100644
--- a/tests/robotests/src/com/android/settings/security/ScreenPinningPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/ScreenPinningPreferenceControllerTest.java
@@ -89,4 +89,16 @@
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.switch_on_text));
}
+
+ @Test
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
+ assertThat(mController.getPreferenceKey()).isEqualTo("screen_pinning_settings");
+ }
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new ScreenPinningPreferenceController(mContext, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java
index 0ab4256..6f9c1ba 100644
--- a/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/SimLockPreferenceControllerTest.java
@@ -65,6 +65,7 @@
private SimLockPreferenceController mController;
private Preference mPreference;
+ private Context mContext;
@Before
public void setUp() {
@@ -75,8 +76,9 @@
shadowApplication.setSystemService(Context.CARRIER_CONFIG_SERVICE, mCarrierManager);
shadowApplication.setSystemService(Context.USER_SERVICE, mUserManager);
shadowApplication.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
- mController = new SimLockPreferenceController(RuntimeEnvironment.application);
- mPreference = new Preference(RuntimeEnvironment.application);
+ mContext = RuntimeEnvironment.application;
+ mController = new SimLockPreferenceController(mContext);
+ mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
@@ -136,6 +138,18 @@
assertThat(mPreference.isEnabled()).isTrue();
}
+ @Test
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
+ assertThat(mController.getPreferenceKey()).isEqualTo("sim_lock_settings");
+ }
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new SimLockPreferenceController(mContext, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
+
private void setupMockIcc() {
final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
SubscriptionInfo info = mock(SubscriptionInfo.class);
diff --git a/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java
index e474b2b..11d7016 100644
--- a/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/VisiblePatternProfilePreferenceControllerTest.java
@@ -115,4 +115,16 @@
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
+
+ @Test
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
+ assertThat(mController.getPreferenceKey()).isEqualTo("visiblepattern_profile");
+ }
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new VisiblePatternProfilePreferenceController(mContext, mLifecycle, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
index 9be374c..a7a3b64 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
@@ -117,4 +117,16 @@
.isEqualTo(mContext.getResources().getQuantityString(
R.plurals.manage_trust_agents_summary_on, 1, 1));
}
+
+ @Test
+ public void getPreferenceKey_byDefault_returnsDefaultValue() {
+ assertThat(mController.getPreferenceKey()).isEqualTo("manage_trust_agents");
+ }
+
+ @Test
+ public void getPreferenceKey_whenGivenValue_returnsGivenValue() {
+ mController = new ManageTrustAgentsPreferenceController(mContext, "key");
+
+ assertThat(mController.getPreferenceKey()).isEqualTo("key");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java
index c0c4fd7..31d10d9 100644
--- a/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java
@@ -59,8 +59,8 @@
}
@Test
- public void updateStatus_isRestricted_restrictIconShouldDisplay() {
- mPreference.updateStatus(true);
+ public void onBindViewHolder_isRestricted_restrictIconShouldDisplay() {
+ mPreference.onBindViewHolder(mHolder);
final SettingsMainSwitchBar switchBar = mPreference.getSwitchBar();
final ImageView restrictedIcon = switchBar.findViewById(
diff --git a/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java b/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java
index 4f7ecc8..0b0b8e5 100644
--- a/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java
+++ b/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java
@@ -111,7 +111,7 @@
@Test
public void showHelpPage_works() {
- mImpl.showHelpPage(mActivity, URL);
+ mImpl.showHelpPage(mActivity, URL, CONTEXT_USER);
verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(CONTEXT_USER));
assertActionViewIntent(mIntentCaptor.getValue());
diff --git a/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java b/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java
new file mode 100644
index 0000000..00ca8e1
--- /dev/null
+++ b/tests/unit/src/com/android/settings/network/InternetResetHelperTest.java
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2021 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.network;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.IntentFilter;
+import android.net.wifi.WifiManager;
+import android.os.HandlerThread;
+import android.os.Looper;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settingslib.connectivity.ConnectivitySubsystemsRecoveryManager;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+@RunWith(AndroidJUnit4.class)
+public class InternetResetHelperTest {
+
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Mock
+ private WifiManager mWifiManager;
+ @Mock
+ public HandlerThread mWorkerThread;
+ @Mock
+ public ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
+ @Mock
+ public NetworkMobileProviderController mMobileNetworkController;
+
+ private Context mContext;
+ private InternetResetHelper mInternetResetHelper;
+ private Preference mResettingPreference;
+ private Preference mWifiTogglePreferences;
+ private PreferenceCategory mConnectedWifiEntryPreferences;
+ private PreferenceCategory mWifiEntryPreferences;
+
+ private FakeHandlerInjector mFakeHandlerInjector;
+
+ private static class FakeHandlerInjector extends InternetResetHelper.HandlerInjector {
+
+ private Runnable mRunnable;
+
+ FakeHandlerInjector(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void postDelayed(Runnable runnable, long delayMillis) {
+ mRunnable = runnable;
+ }
+
+ public Runnable getRunnable() {
+ return mRunnable;
+ }
+ }
+
+ @Before
+ public void setUp() {
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ mResettingPreference = new Preference(mContext);
+ mWifiTogglePreferences = new Preference(mContext);
+ mConnectedWifiEntryPreferences = spy(new PreferenceCategory(mContext));
+ mWifiEntryPreferences = spy(new PreferenceCategory(mContext));
+
+ final Lifecycle lifecycle = mock(Lifecycle.class);
+ mInternetResetHelper = new InternetResetHelper(mContext, lifecycle);
+ mInternetResetHelper.mWorkerThread = mWorkerThread;
+ mFakeHandlerInjector = new FakeHandlerInjector(mContext);
+ mInternetResetHelper.mHandlerInjector = mFakeHandlerInjector;
+ mInternetResetHelper.mConnectivitySubsystemsRecoveryManager =
+ mConnectivitySubsystemsRecoveryManager;
+ mInternetResetHelper.setResettingPreference(mResettingPreference);
+ mInternetResetHelper.setMobileNetworkController(mMobileNetworkController);
+ mInternetResetHelper.setWifiTogglePreference(mWifiTogglePreferences);
+ mInternetResetHelper.addWifiNetworkPreference(mConnectedWifiEntryPreferences);
+ mInternetResetHelper.addWifiNetworkPreference(mWifiEntryPreferences);
+ }
+
+ @Test
+ public void onResume_registerReceiver() {
+ mInternetResetHelper.onResume();
+
+ verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
+ }
+
+ @Test
+ public void onPause_unregisterReceiver() {
+ mInternetResetHelper.onResume();
+
+ mInternetResetHelper.onPause();
+
+ verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
+ }
+
+ @Test
+ public void onDestroy_quitWorkerThread() {
+ mInternetResetHelper.onDestroy();
+
+ verify(mWorkerThread).quit();
+ }
+
+ @Test
+ public void onSubsystemRestartOperationEnd_recoveryIsNotReady_postResumeRunnable() {
+ mInternetResetHelper.mIsRecoveryReady = false;
+
+ mInternetResetHelper.onSubsystemRestartOperationEnd();
+
+ assertThat(mInternetResetHelper.mIsRecoveryReady).isTrue();
+ assertThat(mFakeHandlerInjector.getRunnable())
+ .isEqualTo(mInternetResetHelper.mResumeRunnable);
+ }
+
+ @Test
+ public void onSubsystemRestartOperationEnd_recoveryIsReady_doNothing() {
+ mInternetResetHelper.mIsRecoveryReady = true;
+
+ mInternetResetHelper.onSubsystemRestartOperationEnd();
+
+ assertThat(mFakeHandlerInjector.getRunnable()).isNull();
+ }
+
+ @Test
+ public void updateWifiStateChange_wifiIsNotReadyAndWifiDisabled_doNothing() {
+ mInternetResetHelper.mIsWifiReady = false;
+ when(mWifiManager.isWifiEnabled()).thenReturn(false);
+
+ mInternetResetHelper.updateWifiStateChange();
+
+ assertThat(mInternetResetHelper.mIsWifiReady).isFalse();
+ assertThat(mFakeHandlerInjector.getRunnable()).isNull();
+ }
+
+ @Test
+ public void updateWifiStateChange_wifiIsNotReadyAndWifiEnabled_postResumeRunnable() {
+ mInternetResetHelper.mIsWifiReady = false;
+ when(mWifiManager.isWifiEnabled()).thenReturn(true);
+
+ mInternetResetHelper.updateWifiStateChange();
+
+ assertThat(mInternetResetHelper.mIsWifiReady).isTrue();
+ assertThat(mFakeHandlerInjector.getRunnable())
+ .isEqualTo(mInternetResetHelper.mResumeRunnable);
+ }
+
+ @Test
+ public void updateWifiStateChange_wifiIsReady_doNothing() {
+ mInternetResetHelper.mIsWifiReady = true;
+
+ mInternetResetHelper.updateWifiStateChange();
+
+ assertThat(mInternetResetHelper.mIsWifiReady).isTrue();
+ assertThat(mFakeHandlerInjector.getRunnable()).isNull();
+ }
+
+ @Test
+ public void suspendPreferences_shouldShowResettingHideSubSys() {
+ mInternetResetHelper.suspendPreferences();
+
+ // Show resetting preference
+ assertThat(mResettingPreference.isVisible()).isTrue();
+ // Hide subsystem preferences
+ verify(mMobileNetworkController).hidePreference(true /* hide */, true /* immediately*/);
+ assertThat(mWifiTogglePreferences.isVisible()).isFalse();
+ verify(mConnectedWifiEntryPreferences).removeAll();
+ assertThat(mConnectedWifiEntryPreferences.isVisible()).isFalse();
+ verify(mWifiEntryPreferences).removeAll();
+ assertThat(mWifiEntryPreferences.isVisible()).isFalse();
+ }
+
+ @Test
+ public void resumePreferences_onlyRecoveryReady_shouldShowSubSysHideResetting() {
+ mInternetResetHelper.suspendPreferences();
+ mInternetResetHelper.mIsRecoveryReady = true;
+ mInternetResetHelper.mIsWifiReady = false;
+
+ mInternetResetHelper.resumePreferences();
+
+ // Show resetting preference
+ assertThat(mResettingPreference.isVisible()).isTrue();
+ // Show Mobile Network controller
+ verify(mMobileNetworkController).hidePreference(false /* hide */, false /* immediately*/);
+ // Hide Wi-Fi preferences
+ assertThat(mWifiTogglePreferences.isVisible()).isFalse();
+ assertThat(mConnectedWifiEntryPreferences.isVisible()).isFalse();
+ assertThat(mWifiEntryPreferences.isVisible()).isFalse();
+ }
+
+ @Test
+ public void resumePreferences_onlyWifiReady_shouldShowSubSysHideResetting() {
+ mInternetResetHelper.suspendPreferences();
+ mInternetResetHelper.mIsRecoveryReady = false;
+ mInternetResetHelper.mIsWifiReady = true;
+
+ mInternetResetHelper.resumePreferences();
+
+ // Show resetting preference
+ assertThat(mResettingPreference.isVisible()).isTrue();
+ // Show Wi-Fi preferences
+ assertThat(mWifiTogglePreferences.isVisible()).isTrue();
+ assertThat(mConnectedWifiEntryPreferences.isVisible()).isTrue();
+ assertThat(mWifiEntryPreferences.isVisible()).isTrue();
+ // Hide Mobile Network controller
+ verify(mMobileNetworkController, never())
+ .hidePreference(false /* hide */, false /* immediately*/);
+ }
+
+ @Test
+ public void resumePreferences_allReady_shouldShowSubSysHideResetting() {
+ mInternetResetHelper.suspendPreferences();
+ mInternetResetHelper.mIsRecoveryReady = true;
+ mInternetResetHelper.mIsWifiReady = true;
+ mInternetResetHelper.resumePreferences();
+
+ // Show subsystem preferences
+ verify(mMobileNetworkController).hidePreference(false, false);
+ assertThat(mWifiTogglePreferences.isVisible()).isTrue();
+ assertThat(mConnectedWifiEntryPreferences.isVisible()).isTrue();
+ assertThat(mWifiEntryPreferences.isVisible()).isTrue();
+ // Hide resetting preference
+ assertThat(mResettingPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void restart_recoveryNotAvailable_shouldDoTriggerSubsystemRestart() {
+ when(mConnectivitySubsystemsRecoveryManager.isRecoveryAvailable()).thenReturn(false);
+
+ mInternetResetHelper.restart();
+
+ verify(mConnectivitySubsystemsRecoveryManager, never())
+ .triggerSubsystemRestart(any(), any());
+ }
+
+ @Test
+ public void restart_recoveryAvailable_triggerSubsystemRestart() {
+ when(mConnectivitySubsystemsRecoveryManager.isRecoveryAvailable()).thenReturn(true);
+
+ mInternetResetHelper.restart();
+
+ assertThat(mFakeHandlerInjector.getRunnable())
+ .isEqualTo(mInternetResetHelper.mTimeoutRunnable);
+ verify(mConnectivitySubsystemsRecoveryManager).triggerSubsystemRestart(any(), any());
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/NetworkMobileProviderControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkMobileProviderControllerTest.java
index 31c68da..b626bff 100644
--- a/tests/unit/src/com/android/settings/network/NetworkMobileProviderControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkMobileProviderControllerTest.java
@@ -173,6 +173,44 @@
assertEquals(mPreferenceScreen.getInitialExpandedChildrenCount(), Integer.MAX_VALUE);
}
+ @Test
+ public void hidePreference_hidePreferenceTrue_preferenceIsNotVisible() {
+ when(mSubscriptionsController.isAvailable()).thenReturn(true);
+ setupNetworkMobileProviderController();
+ mPreferenceCategory.setVisible(true);
+
+ mNetworkMobileProviderController.hidePreference(true /* hide */, true /* immediately*/);
+
+ assertThat(mPreferenceCategory.isVisible()).isFalse();
+ }
+
+ @Test
+ public void hidePreference_hidePreferenceFalse_preferenceIsVisible() {
+ when(mSubscriptionsController.isAvailable()).thenReturn(true);
+ setupNetworkMobileProviderController();
+
+ mNetworkMobileProviderController.hidePreference(false /* hide */, true /* immediately*/);
+
+ assertThat(mPreferenceCategory.isVisible()).isTrue();
+ }
+
+ @Test
+ public void hidePreference_hidePreferenceFalse_preferenceIsNotVisibleImmediately() {
+ when(mSubscriptionsController.isAvailable()).thenReturn(true);
+ setupNetworkMobileProviderController();
+ mPreferenceCategory.setVisible(false);
+
+ mNetworkMobileProviderController.hidePreference(false /* hide */, false /* immediately*/);
+
+ // The preference is not visible immediately.
+ assertThat(mPreferenceCategory.isVisible()).isFalse();
+
+ mNetworkMobileProviderController.displayPreference(mPreferenceScreen);
+
+ // The preference is visible after displayPreference() updated.
+ assertThat(mPreferenceCategory.isVisible()).isTrue();
+ }
+
private void setupNetworkMobileProviderController() {
mNetworkMobileProviderController.init(mLifecycle);
mNetworkMobileProviderController.displayPreference(mPreferenceScreen);