Merge "Correct behavior of "Mobile data" button on opportunistic subscriptions."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6cb0023..a94801f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -41,7 +41,7 @@
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
<uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
@@ -443,7 +443,7 @@
android:exported="true"
android:permission="android.permission.TETHER_PRIVILEGED" />
- <activity android:name="network.TetherProvisioningActivity"
+ <activity android:name=".network.TetherProvisioningActivity"
android:exported="true"
android:permission="android.permission.TETHER_PRIVILEGED"
android:excludeFromRecents="true"
@@ -736,7 +736,7 @@
<activity
android:name=".notification.ZenSuggestionActivity"
android:label="@string/zen_mode_settings_title"
- android:icon="@drawable/ic_do_not_disturb_on_24dp"
+ android:icon="@drawable/ic_suggestion_dnd"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -796,7 +796,7 @@
<activity android:name=".wallpaper.WallpaperSuggestionActivity"
android:label="@string/wallpaper_settings_title"
- android:icon="@drawable/ic_wallpaper"
+ android:icon="@drawable/ic_suggestion_wallpaper"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -889,7 +889,7 @@
<activity
android:name="Settings$NightDisplaySuggestionActivity"
android:enabled="@*android:bool/config_nightDisplayAvailable"
- android:icon="@drawable/ic_settings_night_display">
+ android:icon="@drawable/ic_suggestion_night_display">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
@@ -1628,7 +1628,7 @@
</activity>
<activity android:name=".password.ScreenLockSuggestionActivity"
- android:icon="@drawable/ic_settings_security">
+ android:icon="@drawable/ic_suggestion_security">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.DEFAULT" />
@@ -2635,7 +2635,7 @@
<activity android:name=".wifi.calling.WifiCallingSuggestionActivity"
android:label="@string/wifi_calling_settings_title"
- android:icon="@drawable/ic_settings_wireless">
+ android:icon="@drawable/ic_suggestion_wireless">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
diff --git a/protos/contextual_card_list.proto b/protos/contextual_card_list.proto
index 37383ba..69c3741 100644
--- a/protos/contextual_card_list.proto
+++ b/protos/contextual_card_list.proto
@@ -18,7 +18,6 @@
SUGGESTION = 1;
POSSIBLE = 2;
IMPORTANT = 3;
- EXCLUSIVE = 4 [deprecated = true];
DEFERRED_SETUP = 5;
}
diff --git a/res/drawable/ic_airplanemode_active.xml b/res/drawable/ic_airplanemode_active.xml
index 10dd7ed..7ade8b2 100644
--- a/res/drawable/ic_airplanemode_active.xml
+++ b/res/drawable/ic_airplanemode_active.xml
@@ -20,9 +20,6 @@
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
- android:pathData="M20.8,13.56L13.5,9V3.5C13.5,2.67,12.83,2,12,2s-1.5,0.67-1.5,1.5V9l-7.3,4.56c-0.43,0.27-0.7,0.75-0.7,1.27v0.49
-c0,0.34,0.33,0.58,0.65,0.48l7.35-2.3V19l-1.6,1.2c-0.25,0.19-0.4,0.49-0.4,0.8v0.67c0,0.17,0.14,0.28,0.31,0.24
-c1.94-0.55,1.3-0.37,3.19-0.91c1.21,0.35,1.99,0.57,3.19,0.91c0.17,0.04,0.31-0.07,0.31-0.24V21c0-0.31-0.15-0.61-0.4-0.8L13.5,19
-v-5.5l7.35,2.3c0.32,0.1,0.65-0.14,0.65-0.48v-0.49C21.5,14.31,21.23,13.83,20.8,13.56z"
+ android:pathData="M21,16v-2l-8,-5V3.5C13,2.67 12.33,2 11.5,2S10,2.67 10,3.5V9l-8,5v2l8,-2.5V19l-2,1.5V22l3.5,-1l3.5,1v-1.5L13,19v-5.5L21,16z"
android:fillColor="#FFFFFFFF"/>
</vector>
diff --git a/res/drawable/ic_battery_saver_accent_24dp.xml b/res/drawable/ic_battery_saver_accent_24dp.xml
index c8def54..764402d 100644
--- a/res/drawable/ic_battery_saver_accent_24dp.xml
+++ b/res/drawable/ic_battery_saver_accent_24dp.xml
@@ -22,8 +22,8 @@
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FF000000"
- android:pathData="M15,14l-2,0l0,2l-2,0l0,-2l-2,0l0,-2l2,0l0,-2l2,0l0,2l2,0z"/>
+ android:pathData="M16.67,4H14.5V2h-5v2H7.33C6.6,4 6,4.6 6,5.33V15v5.67C6,21.4 6.6,22 7.33,22h9.33C17.4,22 18,21.4 18,20.67V15V5.33C18,4.6 17.4,4 16.67,4zM16,15v5H8v-5V6h8V15z"/>
<path
android:fillColor="#FF000000"
- android:pathData="M16.2,22.5H7.8c-1.3,0 -2.3,-1 -2.3,-2.3V5.8c0,-1.3 1,-2.3 2.3,-2.3h0.7v-2h7v2h0.7c1.3,0 2.3,1.1 2.3,2.3v14.3C18.5,21.5 17.5,22.5 16.2,22.5zM7.8,5.5c-0.2,0 -0.3,0.2 -0.3,0.3v14.3c0,0.2 0.2,0.3 0.3,0.3h8.3c0.2,0 0.3,-0.1 0.3,-0.3V5.8c0,-0.2 -0.1,-0.3 -0.3,-0.3h-2.7v-2h-3v2H7.8z"/>
+ android:pathData="M15,12l-2,0l0,-2l-2,0l0,2l-2,0l0,2l2,0l0,2l2,0l0,-2l2,0z"/>
</vector>
diff --git a/res/drawable/ic_friction_lock_closed.xml b/res/drawable/ic_friction_lock_closed.xml
index 56256a9..2f035e7 100644
--- a/res/drawable/ic_friction_lock_closed.xml
+++ b/res/drawable/ic_friction_lock_closed.xml
@@ -15,11 +15,11 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:viewportWidth="48"
- android:viewportHeight="48"
- android:width="18dp"
- android:height="18dp">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
<path
- android:pathData="M36 16l-2 0 0 -4C34 6.48 29.52 2 24 2 18.48 2 14 6.48 14 12l0 4 -2 0c-2.21 0 -4 1.79 -4 4l0 20c0 2.21 1.79 4 4 4l24 0c2.21 0 4 -1.79 4 -4l0 -20c0 -2.21 -1.79 -4 -4 -4zM24 34c-2.21 0 -4 -1.79 -4 -4 0 -2.21 1.79 -4 4 -4 2.21 0 4 1.79 4 4 0 2.21 -1.79 4 -4 4zm6.2 -18l-12.4 0 0 -4c0 -3.42 2.78 -6.2 6.2 -6.2 3.42 0 6.2 2.78 6.2 6.2l0 4z"
- android:fillColor="?android:attr/colorControlNormal" />
+ android:fillColor="?android:attr/colorControlNormal"
+ android:pathData="M18,8h-1V6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10C20,8.9 19.1,8 18,8zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2H9V6zM18,20H6V10h12V20zM12,17c1.1,0 2,-0.9 2,-2c0,-1.1 -0.9,-2 -2,-2c-1.1,0 -2,0.9 -2,2C10,16.1 10.9,17 12,17z"/>
</vector>
diff --git a/res/drawable/ic_settings.xml b/res/drawable/ic_settings.xml
deleted file mode 100644
index 3d8563d..0000000
--- a/res/drawable/ic_settings.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorAccent">
- <path
- android:fillColor="#FF000000"
- android:pathData="M21.4 14.2l-1.94-1.45c.03-.25 .04 -.5 .04 -.76s-.01-.51-.04-.76L21.4 9.8c.42-.31
-.52 -.94 .24 -1.41l-1.6-2.76c-.28-.48-.88-.7-1.36-.5l-2.14 .91
-c-.48-.37-1.01-.68-1.57-.92l-.27-2.2c-.06-.52-.56-.92-1.11-.92h-3.18c-.55 0-1.05
-.4 -1.11 .92 l-.26 2.19c-.57 .24 -1.1 .55 -1.58 .92 l-2.14-.91c-.48-.2-1.08 .02
--1.36 .5 l-1.6 2.76c-.28 .48 -.18 1.1 .24 1.42l1.94 1.45c-.03 .24 -.04 .49 -.04
-.75 s.01 .51 .04 .76 L2.6 14.2c-.42 .31 -.52 .94 -.24 1.41l1.6 2.76c.28 .48 .88
-.7 1.36 .5 l2.14-.91c.48 .37 1.01 .68 1.57 .92 l.27 2.19c.06 .53 .56 .93 1.11
-.93 h3.18c.55 0 1.04-.4 1.11-.92l.27-2.19c.56-.24 1.09-.55 1.57-.92l2.14 .91
-c.48 .2 1.08-.02 1.36-.5l1.6-2.76c.28-.48 .18 -1.1-.24-1.42zM12 15.5c-1.93
-0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/>
-</vector>
diff --git a/res/drawable/ic_settings_accent.xml b/res/drawable/ic_settings_accent.xml
new file mode 100644
index 0000000..7d871bc
--- /dev/null
+++ b/res/drawable/ic_settings_accent.xml
@@ -0,0 +1,29 @@
+<!--
+ Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorAccent">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M13.85,22.25h-3.7c-0.74,0 -1.36,-0.54 -1.45,-1.27l-0.27,-1.89c-0.27,-0.14 -0.53,-0.29 -0.79,-0.46l-1.8,0.72c-0.7,0.26 -1.47,-0.03 -1.81,-0.65L2.2,15.53c-0.35,-0.66 -0.2,-1.44 0.36,-1.88l1.53,-1.19c-0.01,-0.15 -0.02,-0.3 -0.02,-0.46c0,-0.15 0.01,-0.31 0.02,-0.46l-1.52,-1.19C1.98,9.9 1.83,9.09 2.2,8.47l1.85,-3.19c0.34,-0.62 1.11,-0.9 1.79,-0.63l1.81,0.73c0.26,-0.17 0.52,-0.32 0.78,-0.46l0.27,-1.91c0.09,-0.7 0.71,-1.25 1.44,-1.25h3.7c0.74,0 1.36,0.54 1.45,1.27l0.27,1.89c0.27,0.14 0.53,0.29 0.79,0.46l1.8,-0.72c0.71,-0.26 1.48,0.03 1.82,0.65l1.84,3.18c0.36,0.66 0.2,1.44 -0.36,1.88l-1.52,1.19c0.01,0.15 0.02,0.3 0.02,0.46s-0.01,0.31 -0.02,0.46l1.52,1.19c0.56,0.45 0.72,1.23 0.37,1.86l-1.86,3.22c-0.34,0.62 -1.11,0.9 -1.8,0.63l-1.8,-0.72c-0.26,0.17 -0.52,0.32 -0.78,0.46l-0.27,1.91C15.21,21.71 14.59,22.25 13.85,22.25zM13.32,20.72c0,0.01 0,0.01 0,0.02L13.32,20.72zM10.68,20.7l0,0.02C10.69,20.72 10.69,20.71 10.68,20.7zM10.62,20.25h2.76l0.37,-2.55l0.53,-0.22c0.44,-0.18 0.88,-0.44 1.34,-0.78l0.45,-0.34l2.38,0.96l1.38,-2.4l-2.03,-1.58l0.07,-0.56c0.03,-0.26 0.06,-0.51 0.06,-0.78c0,-0.27 -0.03,-0.53 -0.06,-0.78l-0.07,-0.56l2.03,-1.58l-1.39,-2.4l-2.39,0.96l-0.45,-0.35c-0.42,-0.32 -0.87,-0.58 -1.33,-0.77L13.75,6.3l-0.37,-2.55h-2.76L10.25,6.3L9.72,6.51C9.28,6.7 8.84,6.95 8.38,7.3L7.93,7.63L5.55,6.68L4.16,9.07l2.03,1.58l-0.07,0.56C6.09,11.47 6.06,11.74 6.06,12c0,0.26 0.02,0.53 0.06,0.78l0.07,0.56l-2.03,1.58l1.38,2.4l2.39,-0.96l0.45,0.35c0.43,0.33 0.86,0.58 1.33,0.77l0.53,0.22L10.62,20.25zM18.22,17.72c0,0.01 -0.01,0.02 -0.01,0.03L18.22,17.72zM5.77,17.71l0.01,0.02C5.78,17.72 5.77,17.71 5.77,17.71zM3.93,9.47L3.93,9.47C3.93,9.47 3.93,9.47 3.93,9.47zM18.22,6.27c0,0.01 0.01,0.02 0.01,0.02L18.22,6.27zM5.79,6.25L5.78,6.27C5.78,6.27 5.79,6.26 5.79,6.25zM13.31,3.28c0,0.01 0,0.01 0,0.02L13.31,3.28zM10.69,3.26l0,0.02C10.69,3.27 10.69,3.27 10.69,3.26z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12,12m-3.5,0a3.5,3.5 0,1 1,7 0a3.5,3.5 0,1 1,-7 0"/>
+</vector>
diff --git a/res/drawable/ic_settings_night_display.xml b/res/drawable/ic_settings_night_display.xml
index 3292ed4..4cd1347 100644
--- a/res/drawable/ic_settings_night_display.xml
+++ b/res/drawable/ic_settings_night_display.xml
@@ -21,5 +21,5 @@
android:viewportWidth="24">
<path
android:fillColor="#FF000000"
- android:pathData="M15.5,22c1.05,0 2.05,-0.16 3,-0.46c-4.06,-1.27 -7,-5.06 -7,-9.54s2.94,-8.27 7,-9.54C17.55,2.16 16.55,2 15.5,2c-5.52,0 -10,4.48 -10,10S9.98,22 15.5,22L15.5,22z"/>
+ android:pathData="M6.28,4.81c0,0.16 0.01,0.32 0.02,0.48c0.38,6.58 5.83,12.03 12.41,12.41c0.16,0.01 0.32,0.02 0.47,0.02c-1.58,1.2 -3.53,1.88 -5.56,1.88c-0.46,0 -0.93,-0.03 -1.4,-0.1c-3.96,-0.58 -7.13,-3.75 -7.71,-7.71C4.13,9.24 4.8,6.75 6.28,4.81M8.27,0.6c-0.08,0 -0.17,0.02 -0.25,0.07c-3.8,2.2 -6.2,6.56 -5.49,11.4c0.7,4.82 4.59,8.7 9.4,9.4c0.57,0.08 1.13,0.12 1.69,0.12c4.15,0 7.78,-2.26 9.72,-5.62c0.2,-0.35 -0.07,-0.76 -0.44,-0.76c-0.05,0 -0.1,0.01 -0.15,0.02c-1.03,0.31 -2.12,0.48 -3.25,0.48c-0.22,0 -0.44,-0.01 -0.67,-0.02C13.23,15.38 8.62,10.77 8.29,5.17C8.21,3.81 8.38,2.49 8.75,1.26C8.86,0.91 8.59,0.6 8.27,0.6L8.27,0.6z"/>
</vector>
diff --git a/res/drawable/ic_suggestion_dnd.xml b/res/drawable/ic_suggestion_dnd.xml
new file mode 100644
index 0000000..816b148
--- /dev/null
+++ b/res/drawable/ic_suggestion_dnd.xml
@@ -0,0 +1,28 @@
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10c5.52,0 10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8c0,-4.41 3.59,-8 8,-8c4.41,0 8,3.59 8,8C20,16.41 16.41,20 12,20z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M7,11h10v2h-10z"/>
+</vector>
diff --git a/res/drawable/ic_suggestion_night_display.xml b/res/drawable/ic_suggestion_night_display.xml
new file mode 100644
index 0000000..16cb04e
--- /dev/null
+++ b/res/drawable/ic_suggestion_night_display.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="?android:attr/colorControlNormal"
+ android:viewportHeight="24"
+ android:viewportWidth="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M6.28,4.81c0,0.16 0.01,0.32 0.02,0.48c0.38,6.58 5.83,12.03 12.41,12.41c0.16,0.01 0.32,0.02 0.47,0.02c-1.58,1.2 -3.53,1.88 -5.56,1.88c-0.46,0 -0.93,-0.03 -1.4,-0.1c-3.96,-0.58 -7.13,-3.75 -7.71,-7.71C4.13,9.24 4.8,6.75 6.28,4.81M8.27,0.6c-0.08,0 -0.17,0.02 -0.25,0.07c-3.8,2.2 -6.2,6.56 -5.49,11.4c0.7,4.82 4.59,8.7 9.4,9.4c0.57,0.08 1.13,0.12 1.69,0.12c4.15,0 7.78,-2.26 9.72,-5.62c0.2,-0.35 -0.07,-0.76 -0.44,-0.76c-0.05,0 -0.1,0.01 -0.15,0.02c-1.03,0.31 -2.12,0.48 -3.25,0.48c-0.22,0 -0.44,-0.01 -0.67,-0.02C13.23,15.38 8.62,10.77 8.29,5.17C8.21,3.81 8.38,2.49 8.75,1.26C8.86,0.91 8.59,0.6 8.27,0.6L8.27,0.6z"/>
+</vector>
diff --git a/res/drawable/ic_suggestion_security.xml b/res/drawable/ic_suggestion_security.xml
new file mode 100644
index 0000000..e2d3a90
--- /dev/null
+++ b/res/drawable/ic_suggestion_security.xml
@@ -0,0 +1,28 @@
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12,15m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M18.5,1C16.01,1 14,3.01 14,5.5V8H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10c0,-1.1 -0.9,-2 -2,-2h-2V5.5C16,4.12 17.12,3 18.5,3C19.88,3 21,4.12 21,5.5V6h2V5.5C23,3.01 20.99,1 18.5,1zM18,10v10H6V10H18z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_suggestion_wallpaper.xml b/res/drawable/ic_suggestion_wallpaper.xml
new file mode 100644
index 0000000..32defce
--- /dev/null
+++ b/res/drawable/ic_suggestion_wallpaper.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M9,12.71l2.14,2.58l3,-3.87L18,16.57H6L9,12.71zM5,5h6V3H5C3.9,3 3,3.9 3,5v6h2V5zM19,19h-6v2h6c1.1,0 2,-0.9 2,-2v-6h-2V19zM5,19v-6H3v6c0,1.1 0.9,2 2,2h6v-2H5zM19,5v6h2V5c0,-1.1 -0.9,-2 -2,-2h-6v2H19zM16,9c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1c-0.55,0 -1,0.45 -1,1S15.45,9 16,9z"/>
+</vector>
diff --git a/res/drawable/ic_suggestion_wireless.xml b/res/drawable/ic_suggestion_wireless.xml
new file mode 100644
index 0000000..74b4cee
--- /dev/null
+++ b/res/drawable/ic_suggestion_wireless.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M1,9l2,2c4.97,-4.97 13.03,-4.97 18,0l2,-2C16.93,2.93 7.08,2.93 1,9zM9,17l3,3l3,-3C13.35,15.34 10.66,15.34 9,17zM5,13l2,2c2.76,-2.76 7.24,-2.76 10,0l2,-2C15.14,9.14 8.87,9.14 5,13z"/>
+</vector>
diff --git a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml b/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
deleted file mode 100644
index 070b9a1..0000000
--- a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Variant of progress_indeterminate_horizontal_material in frameworks/base/core/res, which
- draws the whole height of the progress bar instead having blank space above and below the
- bar. -->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" >
- <target
- android:name="rect2_grp"
- android:animation="@*android:anim/progress_indeterminate_horizontal_rect2" />
- <target
- android:name="rect1_grp"
- android:animation="@*android:anim/progress_indeterminate_horizontal_rect1" />
-</animated-vector>
diff --git a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml b/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
deleted file mode 100644
index 39e3a37..0000000
--- a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Variant of vector_drawable_progress_indeterminate_horizontal in frameworks/base/core/res, which
- draws the whole height of the progress bar instead having blank space above and below the
- bar. -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:height="10dp"
- android:width="360dp"
- android:viewportHeight="10"
- android:viewportWidth="360" >
- <group
- android:name="progress_group"
- android:translateX="180"
- android:translateY="5" >
- <path
- android:name="background_track"
- android:pathData="M -180.0,-5.0 l 360.0,0 l 0,10.0 l -360.0,0 Z"
- android:fillColor="?android:attr/colorControlActivated"
- android:fillAlpha="?android:attr/disabledAlpha"/>
- <group
- android:name="rect2_grp"
- android:translateX="-197.60001"
- android:scaleX="0.1" >
- <path
- android:name="rect2"
- android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
- android:fillColor="?android:attr/colorControlActivated" />
- </group>
- <group
- android:name="rect1_grp"
- android:translateX="-522.59998"
- android:scaleX="0.1" >
- <path
- android:name="rect1"
- android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
- android:fillColor="?android:attr/colorControlActivated" />
- </group>
- </group>
-</vector>
diff --git a/res/layout-land/storage_summary_donut.xml b/res/layout-land/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-land/storage_summary_donut.xml
+++ b/res/layout-land/storage_summary_donut.xml
@@ -18,7 +18,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
android:gravity="center_vertical"
android:orientation="horizontal" >
diff --git a/res/layout-sw360dp/homepage_condition_full_tile.xml b/res/layout-sw360dp/homepage_condition_full_tile.xml
deleted file mode 100644
index e1c7b01..0000000
--- a/res/layout-sw360dp/homepage_condition_full_tile.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<com.google.android.material.card.MaterialCardView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="@style/ContextualCardStyle">
-
- <LinearLayout
- android:id="@+id/content"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/homepage_card_padding_start"
- android:paddingEnd="@dimen/homepage_full_card_padding_end"
- android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
- android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
- android:orientation="horizontal"
- android:gravity="center_vertical">
-
- <ImageView
- android:id="@android:id/icon"
- android:layout_width="@dimen/homepage_card_icon_size"
- android:layout_height="@dimen/homepage_card_icon_size"
- android:tint="?android:attr/colorAccent"/>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
- android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
- android:orientation="vertical">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
- android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
-
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
-
- </LinearLayout>
-
- <include layout="@layout/vertical_divider"/>
-
- <Button
- android:id="@+id/first_action"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/ConditionFullCardBorderlessButton"/>
-
- </LinearLayout>
-
-</com.google.android.material.card.MaterialCardView>
diff --git a/res/layout-sw360dp/storage_summary_donut.xml b/res/layout-sw360dp/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-sw360dp/storage_summary_donut.xml
+++ b/res/layout-sw360dp/storage_summary_donut.xml
@@ -18,7 +18,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
android:gravity="center_vertical"
android:orientation="horizontal" >
diff --git a/res/layout/apps_filter_spinner.xml b/res/layout/apps_filter_spinner.xml
index c9b1e07..50f0fde 100644
--- a/res/layout/apps_filter_spinner.xml
+++ b/res/layout/apps_filter_spinner.xml
@@ -18,7 +18,8 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:background="@android:color/transparent">
<com.android.settingslib.widget.settingsspinner.SettingsSpinner
android:id="@+id/filter_spinner"
diff --git a/res/layout/card_preference_layout.xml b/res/layout/card_preference_layout.xml
index d4a06d6..bcaeb86 100644
--- a/res/layout/card_preference_layout.xml
+++ b/res/layout/card_preference_layout.xml
@@ -25,6 +25,10 @@
android:layout_height="wrap_content"
android:layout_margin="8dp"
style="@style/ContextualCardStyle">
- <include layout="@layout/preference_material" />
+ <include
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="-8dp"
+ layout="@layout/preference_material" />
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
diff --git a/res/layout/homepage_condition_full_tile.xml b/res/layout/homepage_condition_full_tile.xml
index 2de1464..3d261ca 100644
--- a/res/layout/homepage_condition_full_tile.xml
+++ b/res/layout/homepage_condition_full_tile.xml
@@ -22,18 +22,20 @@
style="@style/ContextualCardStyle">
<LinearLayout
- android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/homepage_condition_half_card_padding_top"
android:orientation="vertical">
<LinearLayout
+ android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/homepage_card_padding_start"
- android:paddingEnd="@dimen/homepage_card_padding_end"
- android:orientation="vertical">
+ android:paddingEnd="@dimen/homepage_full_card_padding_end"
+ android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
+ android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
+ android:orientation="horizontal"
+ android:gravity="center_vertical">
<ImageView
android:id="@android:id/icon"
@@ -41,35 +43,45 @@
android:layout_height="@dimen/homepage_card_icon_size"
android:tint="?android:attr/colorAccent"/>
- <TextView
- android:id="@android:id/title"
- android:layout_width="match_parent"
+ <LinearLayout
+ android:layout_width="0dp"
android:layout_height="wrap_content"
- android:maxLines="1"
- android:ellipsize="end"
- android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top"
- android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
- android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
+ android:layout_weight="1"
+ android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
+ android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
+ android:orientation="vertical">
- <TextView
- android:id="@android:id/summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:maxLines="1"
- android:ellipsize="end"
- android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
- android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
+ android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
- <include layout="@layout/horizontal_divider"/>
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
+
+ </LinearLayout>
</LinearLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="12dp"
+ android:layout_marginEnd="12dp">
+ <include
+ layout="@layout/horizontal_divider"/>
+ </FrameLayout>
+
<Button
android:id="@+id/first_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:scrollbars="none"
- style="@style/ConditionHalfCardBorderlessButton"/>
-
+ style="@style/ConditionFullCardBorderlessButton"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
diff --git a/res/layout/homepage_condition_half_tile.xml b/res/layout/homepage_condition_half_tile.xml
index 8f5af02..308b3a6 100644
--- a/res/layout/homepage_condition_half_tile.xml
+++ b/res/layout/homepage_condition_half_tile.xml
@@ -55,14 +55,22 @@
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:maxLines="1"
+ android:lines="2"
android:ellipsize="end"
android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
- <include layout="@layout/horizontal_divider"/>
-
</LinearLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="12dp"
+ android:layout_marginEnd="12dp">
+ <include
+ layout="@layout/horizontal_divider"/>
+ </FrameLayout>
+
<Button
android:id="@+id/first_action"
android:layout_width="match_parent"
diff --git a/res/layout/homepage_slice_deferred_setup_tile.xml b/res/layout/homepage_slice_deferred_setup_tile.xml
index 8c83c09..73199d4 100644
--- a/res/layout/homepage_slice_deferred_setup_tile.xml
+++ b/res/layout/homepage_slice_deferred_setup_tile.xml
@@ -32,10 +32,10 @@
android:layout_height="match_parent"
android:gravity="left"
android:orientation="vertical"
- android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom"
- android:paddingEnd="@dimen/homepage_card_padding_end"
android:paddingStart="@dimen/homepage_card_padding_start"
- android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top">
+ android:paddingEnd="@dimen/homepage_card_padding_end"
+ android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top"
+ android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom">
<ImageView
android:id="@android:id/icon"
diff --git a/res/layout/homepage_slice_half_tile.xml b/res/layout/homepage_slice_half_tile.xml
index 46f3cda..fc99561 100644
--- a/res/layout/homepage_slice_half_tile.xml
+++ b/res/layout/homepage_slice_half_tile.xml
@@ -39,8 +39,7 @@
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/homepage_card_icon_size"
- android:layout_height="@dimen/homepage_card_icon_size"
- android:tint="?android:attr/colorAccent"/>
+ android:layout_height="@dimen/homepage_card_icon_size"/>
<TextView
android:id="@android:id/title"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 2b7c1b0..807c26b 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -31,8 +31,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:paddingStart="@dimen/homepage_card_padding_start"
- android:paddingEnd="@dimen/homepage_card_padding_end"/>
+ style="@style/SliceViewStyle"/>
<!--dismissal view-->
<include layout="@layout/homepage_dismissal_view"/>
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index 021a61e..87db820 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -21,57 +21,50 @@
android:layout_height="match_parent"
android:orientation="vertical">
- <androidx.core.widget.NestedScrollView
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:fillViewport="true"
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
- <FrameLayout
- android:id="@+id/content_container"
+ <LinearLayout
+ android:id="@+id/list_container"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="gone">
- <LinearLayout
- android:id="@+id/list_container"
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:visibility="gone">
+ android:layout_height="match_parent">
- <FrameLayout
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/apps_list"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:clipToPadding="false"
+ settings:fastScrollEnabled="true"
+ settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
+ settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/apps_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- 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="center"
+ android:layout_gravity="center"
+ android:text="@string/no_applications"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:visibility="invisible"/>
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:layout_gravity="center"
- android:text="@string/no_applications"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:visibility="invisible"/>
+ </FrameLayout>
- </FrameLayout>
+ </LinearLayout>
- </LinearLayout>
+ <include layout="@layout/loading_container"/>
- <include layout="@layout/loading_container"/>
-
- </FrameLayout>
-
- </androidx.core.widget.NestedScrollView>
+ </FrameLayout>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
diff --git a/res/layout/preference_app_restrictions.xml b/res/layout/preference_app_restrictions.xml
index 65fd06c..698f1ed 100644
--- a/res/layout/preference_app_restrictions.xml
+++ b/res/layout/preference_app_restrictions.xml
@@ -83,7 +83,7 @@
android:layout_height="fill_parent"
android:paddingStart="12dip"
android:paddingEnd="12dp"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/apps_with_restrictions_settings_button"
android:layout_gravity="center"
android:clickable="true"
diff --git a/res/layout/preference_widget_gear.xml b/res/layout/preference_widget_gear.xml
index f533dcf..11870ac 100644
--- a/res/layout/preference_widget_gear.xml
+++ b/res/layout/preference_widget_gear.xml
@@ -25,6 +25,6 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
android:scaleType="center"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/settings_button" />
diff --git a/res/layout/preference_widget_gear_no_bg.xml b/res/layout/preference_widget_gear_no_bg.xml
index 89d34d4..6a26fc8 100644
--- a/res/layout/preference_widget_gear_no_bg.xml
+++ b/res/layout/preference_widget_gear_no_bg.xml
@@ -22,6 +22,6 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="center"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/settings_button" />
diff --git a/res/layout/preference_widget_gear_optional_background.xml b/res/layout/preference_widget_gear_optional_background.xml
index d02f638..0c826df 100644
--- a/res/layout/preference_widget_gear_optional_background.xml
+++ b/res/layout/preference_widget_gear_optional_background.xml
@@ -25,7 +25,7 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="center"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/settings_button" />
<!-- Additional overdraw background to stop parent's material ripple -->
<FrameLayout
@@ -42,7 +42,7 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
android:scaleType="center"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/settings_button" />
</FrameLayout>
</FrameLayout>
diff --git a/res/layout/restricted_preference_user_delete_widget.xml b/res/layout/restricted_preference_user_delete_widget.xml
index 7bafacc..71f1dd7 100644
--- a/res/layout/restricted_preference_user_delete_widget.xml
+++ b/res/layout/restricted_preference_user_delete_widget.xml
@@ -35,7 +35,7 @@
android:layout_height="fill_parent"
android:paddingStart="16dip"
android:paddingEnd="16dip"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/settings_label"
android:layout_gravity="center"
android:background="?android:attr/selectableItemBackground" />
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index 1637189..88f5b36 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -17,7 +17,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="32dp"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index df676fc..8ee2fba 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -56,6 +56,7 @@
<EditText android:id="@+id/ssid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
style="@style/wifi_item_edit_content"
android:hint="@string/wifi_ssid_hint"
android:singleLine="true"
@@ -64,12 +65,11 @@
android:id="@+id/ssid_scanner_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@null"
android:src="@drawable/ic_scan_24dp"
- android:visibility="gone"
android:contentDescription="@string/wifi_add_network" />
</RelativeLayout>
@@ -291,6 +291,7 @@
<EditText android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
style="@style/wifi_item_edit_content"
android:singleLine="true"
android:password="true" />
@@ -299,12 +300,11 @@
android:id="@+id/password_scanner_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@null"
android:src="@drawable/ic_scan_24dp"
- android:visibility="gone"
android:contentDescription="@string/wifi_add_network" />
</RelativeLayout>
</LinearLayout>
diff --git a/res/layout/wifi_display_preference.xml b/res/layout/wifi_display_preference.xml
index 99cb89c..4532441 100644
--- a/res/layout/wifi_display_preference.xml
+++ b/res/layout/wifi_display_preference.xml
@@ -37,7 +37,7 @@
android:layout_gravity="center_vertical"
android:padding="8dip"
android:background="?android:attr/selectableItemBackground"
- android:src="@drawable/ic_settings"
+ android:src="@drawable/ic_settings_accent"
android:contentDescription="@string/wifi_display_details" />
</LinearLayout>
diff --git a/res/layout/wifi_progress_header.xml b/res/layout/wifi_progress_header.xml
deleted file mode 100644
index 3f5d428..0000000
--- a/res/layout/wifi_progress_header.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout
- android:layout_width="match_parent"
- android:layout_height="3dp"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <View
- android:id="@+id/progress_bar_background"
- style="@style/TrimmedHorizontalProgressBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?android:attr/colorSecondary" />
- <ProgressBar
- android:id="@+id/progress_bar_animation"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="@style/TrimmedHorizontalProgressBar"
- android:indeterminate="true" />
-</FrameLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index cdbeada..617feb3 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -23,6 +23,7 @@
<color name="homepage_support_background">#3F5FBD</color>
<!-- 80% black for status bar of homepage -->
<color name="homepage_status_bar_color">#cc000000</color>
- <color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
+ <color name="contextual_card_background">@*android:color/material_grey_900</color>
</resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 7f707d2..82c3fef 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -15,7 +15,6 @@
-->
<resources>
- <dimen name="settings_side_margin">112dp</dimen>
<!-- ActionBar contentInsetStart -->
<dimen name="actionbar_contentInsetStart">128dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 6accad7..c701044 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -17,8 +17,6 @@
<resources>
<dimen name="pager_tabs_padding">0dp</dimen>
- <dimen name="settings_side_margin">64dp</dimen>
-
<!-- Weight of the left pane in a multi-pane preference layout. -->
<integer name="preferences_left_pane_weight">1</integer>
<!-- Weight of the right pane in a multi-pane preference layout. So the split is 1:2 -->
diff --git a/res/values/colors.xml b/res/values/colors.xml
index f6723a8..a10d1d7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -100,8 +100,10 @@
<color name="homepage_location_background">#2EC7DC</color>
<color name="homepage_about_background">#9FA8DA</color>
<color name="homepage_privacy_background">#5E97F6</color>
+
<color name="homepage_card_stroke_color">#1f000000</color>
<color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
+ <color name="contextual_card_background">@*android:color/background_device_default_light</color>
<!-- End of dashboard/homepage icon background colors -->
<color name="switchbar_text_color">@android:color/white</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d42f073..963d19f 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -368,8 +368,8 @@
<dimen name="homepage_condition_half_card_padding_top">12dp</dimen>
<dimen name="homepage_condition_half_card_title_margin_top">12dp</dimen>
<dimen name="homepage_condition_half_card_summary_margin_bottom">12dp</dimen>
- <dimen name="homepage_condition_full_card_padding_start">24dp</dimen>
- <dimen name="homepage_condition_full_card_padding_end">24dp</dimen>
+ <dimen name="homepage_condition_full_card_padding_start">12dp</dimen>
+ <dimen name="homepage_condition_full_card_padding_end">16dp</dimen>
<dimen name="homepage_condition_full_card_padding_top">12dp</dimen>
<dimen name="homepage_condition_full_card_padding_bottom">12dp</dimen>
<dimen name="homepage_condition_header_padding_top">10dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9281979..b787473 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1433,13 +1433,13 @@
<string name="unlock_change_lock_password_title">Change unlock password</string>
<!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and that it requests for a strong PIN or password [CHAR LIMIT=NONE] -->
- <string name="unlock_footer_high_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a strong PIN or password.</string>
+ <string name="unlock_footer_high_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a strong PIN or password and may not work as expected without one</string>
<!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and that it requests for a medium strength PIN or password [CHAR LIMIT=NONE] -->
- <string name="unlock_footer_medium_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new PIN or password.</string>
+ <string name="unlock_footer_medium_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new PIN or password and may not work as expected without one</string>
<!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and it requests for any screen lock [CHAR LIMIT=NONE] -->
- <string name="unlock_footer_low_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new pattern, PIN or password.</string>
+ <string name="unlock_footer_low_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new pattern, PIN, or password and may not work as expected without one</string>
<!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock [CHAR LIMIT=NONE] -->
- <string name="unlock_footer_none_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new screen lock.</string>
+ <string name="unlock_footer_none_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new screen lock</string>
<!-- Message shown on the lock screen when the user incorrectly enters their lock and it counts towards the max attempts before their data on the device is wiped. [CHAR LIMIT=NONE] -->
@@ -2102,6 +2102,8 @@
<string name="wifi_ip_settings">IP settings</string>
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
<string name="wifi_privacy_settings">Privacy</string>
+ <!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=25] -->
+ <string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
<string name="wifi_dpp_add_device_to_network">Add a device</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
@@ -6857,10 +6859,10 @@
<!-- Wizard finish button label [CHAR LIMIT=25] -->
<string name="wizard_finish">Finish</string>
- <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
- <string name="user_image_take_photo" msgid="7496128293167402354">Take photo</string>
- <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
- <string name="user_image_choose_photo" msgid="3746334626214970837">Choose photo from Gallery</string>
+ <!-- An option in a photo selection dialog to take a new photo [CHAR LIMIT=50] -->
+ <string name="user_image_take_photo" msgid="7496128293167402354">Take a photo</string>
+ <!-- An option in a photo selection dialog to choose a pre-existing image [CHAR LIMIT=50] -->
+ <string name="user_image_choose_photo" msgid="3746334626214970837">Choose an image</string>
<!-- Accessibility message for the photo selector which is a button/popup with the current photo [CHAR LIMIT=50] -->
<string name="user_image_photo_selector">Select photo</string>
@@ -7078,7 +7080,7 @@
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
- <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention</string>
+ <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
<!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
@@ -9169,8 +9171,11 @@
<!-- Title of condition that do not disturb is on [CHAR LIMIT=36] -->
<string name="condition_zen_title">Do Not Disturb is on</string>
- <!-- Summary of condition that do not disturb is on [CHAR LIMIT=36] -->
- <string name="condition_zen_summary">Impacts what you hear and see</string>
+ <!-- Summary of condition that do not disturb is on and all exceptions set to off [CHAR LIMIT=36] -->
+ <string name="condition_zen_summary_phone_muted">Phone muted</string>
+
+ <!-- Summary of condition that do not disturb is on and some exceptions are allowed [CHAR LIMIT=36] -->
+ <string name="condition_zen_summary_with_exceptions">With exceptions</string>
<!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
<string name="condition_battery_title">Battery Saver is on</string>
@@ -9200,25 +9205,16 @@
<string name="condition_device_muted_action_turn_on_sound">Turn on sound</string>
<!-- Title of condition that indicates device is muted [CHAR LIMIT=50] -->
- <string name="condition_device_muted_title" product="tablet">Device is muted</string>
-
- <!-- Title of condition that indicates device is muted [CHAR LIMIT=50] -->
- <string name="condition_device_muted_title" product="default">Phone muted</string>
+ <string name="condition_device_muted_title">Ringer muted</string>
<!-- Summary of condition that indicates device is muted -->
<string name="condition_device_muted_summary">For calls & notifications</string>
<!-- Title of condition that indicates device is set to vibrate [CHAR LIMIT=50] -->
- <string name="condition_device_vibrate_title" product="tablet">Device is set to vibrate</string>
-
- <!-- Title of condition that indicates device is muted [CHAR LIMIT=50] -->
- <string name="condition_device_vibrate_title" product="default">Vibration only</string>
+ <string name="condition_device_vibrate_title">Vibration only</string>
<!-- Summary of condition that indicates device is set to vibrate -->
- <string name="condition_device_vibrate_summary" product="tablet">Calls and notifications will vibrate device</string>
-
- <!-- Summary of condition that indicates device is set to vibrate -->
- <string name="condition_device_vibrate_summary" product="default">For calls & notifications</string>
+ <string name="condition_device_vibrate_summary">For calls & notifications</string>
<!-- Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=46] -->
<string name="night_display_suggestion_title">Set Night Light schedule</string>
@@ -10442,27 +10438,27 @@
</plurals>
<!-- Network & internet page. Summary indicating that a SIM is used by default for calls when
- multiple SIMs are present. [CHAR LIMIT=40] -->
+ multiple SIMs are present. [CHAR LIMIT=50] -->
<string name="default_for_calls">Default for calls</string>
<!-- Network & internet page. Summary indicating that a SIM is used by default for SMS messages
- when multiple SIMs are present. [CHAR LIMIT=40] -->
+ when multiple SIMs are present. [CHAR LIMIT=50] -->
<string name="default_for_sms">Default for SMS</string>
<!-- Network & internet page. Summary indicating that a SIM is used by default for calls and SMS
- messages when multiple SIMs are present. [CHAR LIMIT=40] -->
+ messages when multiple SIMs are present. [CHAR LIMIT=50] -->
<string name="default_for_calls_and_sms">Default for calls & SMS</string>
<!-- Network & internet page. Summary indicating that a SIM is used by default for mobile data
- when multiple SIMs are present. [CHAR LIMIT=40] -->
+ when multiple SIMs are present. [CHAR LIMIT=50] -->
<string name="default_for_mobile_data">Default for mobile data</string>
<!-- Network & internet page. Summary indicating that a SIM has an active mobile data connection
- when multiple SIMs are present. [CHAR LIMIT=40] -->
+ when multiple SIMs are present. [CHAR LIMIT=50] -->
<string name="mobile_data_active">Mobile data active</string>
<!-- Network & internet page. Summary indicating that a SIM is used by default for mobile data
when multiple SIMs are present, but mobile data is currently turned off.
- [CHAR LIMIT=40] -->
+ [CHAR LIMIT=50] -->
<string name="mobile_data_off">Mobile data off</string>
<!-- Network & internet page. Summary indicating that a SIM is available to be used for services
such as calls, SMS, or data when multiple SIMs are present, but is not currently the
- default SIM for any of those services. [CHAR LIMIT=40] -->
+ default SIM for any of those services. [CHAR LIMIT=50] -->
<string name="subscription_available">Available</string>
<!-- Title of item shown at the bottom of the page listing multiple mobile service
@@ -10566,6 +10562,8 @@
<string name="network_connection_errorstate_dialog_message">Something came up. The application has cancelled the request to choose a device.</string>
<!-- Toast message when connection is successful [CHAR LIMIT=30] -->
<string name="network_connection_connect_successful">Connection successful</string>
+ <!-- Neutral button for Network connection request Dialog [CHAR LIMIT=30] -->
+ <string name="network_connection_request_dialog_showall">Show all</string>
<!-- Summary for bluetooth devices count in Bluetooth devices slice. [CHAR LIMIT=NONE] -->
<plurals name="show_bluetooth_devices">
@@ -10636,6 +10634,15 @@
<!-- Text for permission bar chart details in Privacy page. [CHAR LIMIT=NONE] -->
<string name="permission_bar_chart_details">See all usage</string>
+ <!-- Title for the accessibility usage preference in the Privacy page. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_usage_title">Accessibility usage</string>
+
+ <!-- Summary for the accessibility usage preference in the Privacy page. [CHAR LIMIT=NONE] -->
+ <plurals name="accessibility_usage_summary">
+ <item quantity="one">1 service has full access to your device</item>
+ <item quantity="other"><xliff:g id="service_count">%1$d</xliff:g> services have full access to your device</item>
+ </plurals>
+
<!-- Title for notification channel slice. [CHAR LIMIT=NONE] -->
<string name="manage_app_notification">Manage <xliff:g id="app_name" example="Settings">%1$s</xliff:g> Notifications</string>
<!-- Title for no suggested app in notification channel slice. [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 84c8831..747210e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -82,15 +82,6 @@
<item name="android:scrollbarStyle">outsideOverlay</item>
</style>
- <style name="TrimmedHorizontalProgressBar"
- parent="android:Widget.Material.ProgressBar.Horizontal">
- <item name="android:indeterminateDrawable">
- @drawable/progress_indeterminate_horizontal_material_trimmed
- </item>
- <item name="android:minHeight">3dip</item>
- <item name="android:maxHeight">3dip</item>
- </style>
-
<style name="bt_item">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
@@ -286,6 +277,7 @@
<style name="TextAppearance.ConditionCardTitle"
parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
+ <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
<item name="android:textSize">16sp</item>
</style>
@@ -419,6 +411,7 @@
<item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
<item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
<item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
+ <item name="cardBackgroundColor">@color/contextual_card_background</item>
<item name="cardCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
<item name="cardElevation">0dp</item>
<item name="strokeColor">@color/homepage_card_stroke_color</item>
@@ -448,8 +441,9 @@
<style name="ConditionFullCardBorderlessButton"
parent="@style/ConditionCardBorderlessButton">
- <item name="android:minWidth">24dp</item>
- <item name="android:layout_marginStart">20dp</item>
+ <item name="android:textAlignment">viewStart</item>
+ <item name="android:paddingStart">50dp</item>
+ <item name="android:paddingEnd">50dp</item>
</style>
<style name="ContextualCardDismissalButton"
@@ -460,6 +454,7 @@
<style name="Widget.SliceView.Settings">
<item name="titleSize">@*android:dimen/text_size_subhead_material</item>
+ <item name="rowStyle">@style/SliceRowStyle.Settings</item>
</style>
<style name="TextAppearance.DeferredSetupCardTitle">
@@ -482,4 +477,41 @@
<item name="android:textSize">14sp</item>
</style>
+ <style name="SliceViewStyle">
+ <!-- 4dp start padding for the start icon -->
+ <item name="android:paddingStart">4dp</item>
+
+ <!-- End margin of content without end items is 24dp.
+ android:paddingEnd = 24 - 16(contentEndPadding) -->
+ <item name="android:paddingEnd">8dp</item>
+
+ <item name="rowStyle">@style/SliceRowStyle</item>
+ </style>
+
+ <style name="SliceRowStyle">
+ <item name="titleItemEndPadding">0dp</item>
+
+ <!-- Padding between content and the start icon is 12dp. -->
+ <item name="contentStartPadding">12dp</item>
+ <!-- Padding between content and end items is 16dp. -->
+ <item name="contentEndPadding">16dp</item>
+
+ <!-- Both side margins of end item are 16dp.
+ endItemEndPadding = 16 - 8(android:paddingEnd) -->
+ <item name="endItemStartPadding">16dp</item>
+ <item name="endItemEndPadding">8dp</item>
+
+ <!-- Both side margins of bottom divider are 12dp.
+ bottomDividerStartPadding = 12 - 4(android:paddingStart)
+ bottomDividerEndPadding = 12 - 8(android:paddingEnd) -->
+ <item name="bottomDividerStartPadding">8dp</item>
+ <item name="bottomDividerEndPadding">4dp</item>
+
+ <item name="actionDividerHeight">32dp</item>
+ </style>
+
+ <style name="SliceRowStyle.Settings">
+ <!-- Padding between content and the start icon is 8dp. -->
+ <item name="contentStartPadding">8dp</item>
+ </style>
</resources>
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 44ac10a..eaca161 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -20,13 +20,22 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="privacy_dashboard_page"
android:title="@string/privacy_dashboard_title"
- settings:initialExpandedChildrenCount="3">
+ settings:initialExpandedChildrenCount="4">
<com.android.settingslib.widget.BarChartPreference
android:key="permission_bar_chart"
android:title="@string/privacy_dashboard_title"
settings:controller="com.android.settings.privacy.PermissionBarChartPreferenceController"/>
+ <!-- Accessibility usage -->
+ <Preference
+ android:key="privacy_accessibility_usage"
+ android:title="@string/accessibility_usage_title"
+ settings:allowDividerAbove="true"
+ settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
+ <intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
+ </Preference>
+
<!-- App permissions -->
<Preference
android:key="privacy_manage_perms"
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index c5765d3..6833922 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -60,6 +60,12 @@
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
<Preference
+ android:key="ambient_display_wake_screen"
+ android:title="@string/ambient_display_wake_screen_title"
+ android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
+ settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
+
+ <Preference
android:key="ambient_display_tap"
android:title="@string/ambient_display_tap_screen_title"
android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
@@ -77,12 +83,6 @@
android:fragment="com.android.settings.gestures.PickupGestureSettings"
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
- <Preference
- android:key="ambient_display_wake_screen"
- android:title="@string/ambient_display_wake_screen_title"
- android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
- settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
-
<SwitchPreference
android:key="ambient_display_notification"
android:title="@string/doze_title"
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 8dad57f..58bc58c 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -65,10 +65,10 @@
import com.android.settings.password.ConfirmLockPattern;
import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.google.android.setupcompat.TemplateLayout;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupdesign.GlifLayout;
import java.util.List;
@@ -416,7 +416,7 @@
return;
}
- final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
+ final GlifLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
new FooterButton.Builder(getActivity())
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index c25f2af..618dd2c 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -44,10 +44,10 @@
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.google.android.setupcompat.TemplateLayout;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupdesign.GlifLayout;
/**
* Confirm and execute a reset of the device to a clean "just out of the box"
@@ -152,7 +152,7 @@
* Configure the UI for the final confirmation interaction
*/
private void establishFinalConfirmationState() {
- final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
+ final GlifLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
diff --git a/src/com/android/settings/SmsDefaultDialog.java b/src/com/android/settings/SmsDefaultDialog.java
index e4b49ee..c25961d 100644
--- a/src/com/android/settings/SmsDefaultDialog.java
+++ b/src/com/android/settings/SmsDefaultDialog.java
@@ -16,6 +16,8 @@
package com.android.settings;
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -30,6 +32,8 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
@@ -60,6 +64,21 @@
}
@Override
+ protected void onStart() {
+ super.onStart();
+ getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ final Window window = getWindow();
+ final WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+ window.setAttributes(attrs);
+ }
+
+ @Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case BUTTON_POSITIVE:
@@ -84,7 +103,7 @@
}
private boolean buildDialog(String packageName) {
- TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
+ TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (!tm.isSmsCapable()) {
// No phone, no SMS
return false;
@@ -198,7 +217,7 @@
} else {
view.findViewById(R.id.default_label).setVisibility(View.GONE);
}
- ImageView imageView = (ImageView)view.findViewById(android.R.id.icon);
+ ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
imageView.setImageDrawable(item.icon);
return view;
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 65cfdf6..37643b3 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -89,6 +89,7 @@
import android.widget.TabWidget;
import androidx.annotation.StringRes;
+import androidx.core.graphics.drawable.IconCompat;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
@@ -950,24 +951,30 @@
bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) original).getBitmap(), width,
height, false);
} else {
- bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- final Canvas canvas = new Canvas(bitmap);
- original.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- original.draw(canvas);
+ bitmap = createBitmap(original, width, height);
}
return new BitmapDrawable(null, bitmap);
}
/**
- * Converts the {@link Drawable} to a {@link Bitmap}.
+ * Create an Icon pointing to a drawable.
*/
- public static Bitmap drawableToBitmap(Drawable drawable) {
+ public static IconCompat createIconWithDrawable(Drawable drawable) {
+ Bitmap bitmap;
if (drawable instanceof BitmapDrawable) {
- return ((BitmapDrawable)drawable).getBitmap();
+ bitmap = ((BitmapDrawable)drawable).getBitmap();
+ } else {
+ final int width = drawable.getIntrinsicWidth();
+ final int height = drawable.getIntrinsicHeight();
+ bitmap = createBitmap(drawable,
+ width > 0 ? width : 1,
+ height > 0 ? height : 1);
}
+ return IconCompat.createWithBitmap(bitmap);
+ }
- final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
- drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+ private static Bitmap createBitmap(Drawable drawable, int width, int height) {
+ final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
diff --git a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
index 617a9bb..1881ca7 100644
--- a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
@@ -148,7 +148,8 @@
mFragmentManager = fragmentManager;
}
- private CachedBluetoothDevice getConnectedHearingAidDevice() {
+ @VisibleForTesting
+ CachedBluetoothDevice getConnectedHearingAidDevice() {
if (!mHearingAidProfileSupported) {
return null;
}
@@ -158,9 +159,11 @@
final List<BluetoothDevice> deviceList = mLocalBluetoothManager.getProfileManager()
.getHearingAidProfile().getConnectedDevices();
final Iterator it = deviceList.iterator();
- if (it.hasNext()) {
+ while (it.hasNext()) {
BluetoothDevice obj = (BluetoothDevice)it.next();
- return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+ if (!mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(obj)) {
+ return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+ }
}
return null;
}
diff --git a/src/com/android/settings/accounts/AccountHeaderPreferenceController.java b/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
index d762095..11fcaff 100644
--- a/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
@@ -84,7 +84,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mHeaderPreference = (LayoutPreference) screen.findPreference(KEY_ACCOUNT_HEADER);
+ mHeaderPreference = screen.findPreference(KEY_ACCOUNT_HEADER);
}
@Override
diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
index 5523cce..938606b 100644
--- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
+++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
@@ -66,8 +66,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- final LayoutPreference removeAccountPreference =
- (LayoutPreference) screen.findPreference(KEY_REMOVE_ACCOUNT);
+ final LayoutPreference removeAccountPreference = screen.findPreference(KEY_REMOVE_ACCOUNT);
Button removeAccountButton = (Button) removeAccountPreference.findViewById(R.id.button);
removeAccountButton.setOnClickListener(this);
}
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 364aeff..6e0ae45 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -138,7 +138,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+ mCategory = screen.findPreference(getPreferenceKey());
mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
mDivider = screen.findPreference(KEY_DIVIDER);
super.displayPreference(screen);
diff --git a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
index f65bb9b..c9f0e31 100644
--- a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
@@ -63,7 +63,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mHeader = (LayoutPreference) screen.findPreference(KEY_HEADER);
+ mHeader = screen.findPreference(KEY_HEADER);
final Activity activity = mParent.getActivity();
mEntityHeaderController = EntityHeaderController
.newInstance(activity, mParent, mHeader.findViewById(R.id.entity_header))
diff --git a/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java b/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
index 23c0121..21e641d 100644
--- a/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
@@ -77,7 +77,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (LayoutPreference) screen.findPreference(KEY_INSTANT_APP_BUTTONS);
+ mPreference = screen.findPreference(KEY_INSTANT_APP_BUTTONS);
initButtons(mPreference.findViewById(R.id.instant_app_button_container));
}
@@ -85,7 +85,7 @@
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (!TextUtils.isEmpty(mLaunchUri)) {
menu.add(0, AppInfoDashboardFragment.INSTALL_INSTANT_APP_MENU, 2, R.string.install_text)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}
}
@@ -137,7 +137,7 @@
private void showDialog() {
final DialogFragment newFragment =
- InstantAppButtonDialogFragment.newInstance(mPackageName);
+ InstantAppButtonDialogFragment.newInstance(mPackageName);
newFragment.setTargetFragment(mParent, 0);
newFragment.show(mParent.getFragmentManager(), KEY_INSTANT_APP_BUTTONS);
}
@@ -148,7 +148,7 @@
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setPackage(mPackageName);
final List<ResolveInfo> infos = manager.queryIntentActivities(
- intent, PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT);
+ intent, PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT);
for (ResolveInfo info : infos) {
final Bundle metaData = info.activityInfo.metaData;
if (metaData != null) {
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 816b44a..a9de206 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -186,7 +186,6 @@
private View mLoadingContainer;
private View mListContainer;
- private RecyclerView mRecyclerView;
private SearchView mSearchView;
// Size resource used for packages whose size computation failed for some reason
@@ -220,7 +219,7 @@
@VisibleForTesting
FilterSpinnerAdapter mFilterAdapter;
@VisibleForTesting
- View mContentContainer;
+ RecyclerView mRecyclerView;
private View mRootView;
private Spinner mFilterSpinner;
@@ -330,7 +329,6 @@
Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
- mContentContainer = mRootView.findViewById(R.id.content_container);
mListContainer = mRootView.findViewById(R.id.list_container);
if (mListContainer != null) {
// Create adapter and list view here
@@ -861,14 +859,14 @@
// overlapped by floating filter.
if (hasFilter) {
mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE);
- mManageApplications.mContentContainer.setPadding(0 /* left */,
+ 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.mContentContainer.setPadding(0 /* left */, 0 /* top */,
+ mManageApplications.mRecyclerView.setPadding(0 /* left */, 0 /* top */,
0 /* right */,
0 /* bottom */);
}
diff --git a/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java b/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
index 12d1512..c859db2 100644
--- a/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
+++ b/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
@@ -63,7 +63,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mDomainAppList = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mDomainAppList = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 0ff4233..319d62f 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -116,7 +116,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mPreferenceGroup = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 4e2c711..490580d 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -58,7 +58,9 @@
private FaceSettingsAttentionPreferenceController mAttentionController;
private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
- getActivity().finish();
+ if (getActivity() != null) {
+ getActivity().finish();
+ }
};
public static boolean isAvailable(Context context) {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
index b910fe5..da7e9b5 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (SwitchPreference) screen.findPreference(KEY);
+ mPreference = screen.findPreference(KEY);
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
index 8c063b5..4edbb67 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
@@ -44,7 +44,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mVideoPreference = (VideoPreference) screen.findPreference(KEY_VIDEO);
+ mVideoPreference = screen.findPreference(KEY_VIDEO);
mVideoPreference.onViewVisible(false /* paused */);
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index 95b16b9..994daa7 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -52,8 +52,7 @@
@Override
protected void init(PreferenceScreen screen) {
- final LayoutPreference headerPreference =
- (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+ final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
headerPreference.findViewById(R.id.entity_header));
screen.addPreference(headerPreference);
diff --git a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
index 3239dd5..9706c17 100644
--- a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
@@ -68,7 +68,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- mPreference = (Preference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
}
diff --git a/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java b/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
index 2681288..be82284 100644
--- a/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
@@ -84,7 +84,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+ mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
updateTitle();
mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
@@ -127,7 +127,7 @@
@VisibleForTesting
public void setBluetoothDeviceUpdater(BluetoothDeviceUpdater bluetoothDeviceUpdater) {
- mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
+ mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
}
@Override
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
index daa9932..aa83e67 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
@@ -74,7 +74,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+ mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
final Context context = screen.getContext();
diff --git a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
index ffcd1fc..45f128d 100644
--- a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
@@ -47,7 +47,7 @@
super(context, preferenceKey);
mSavedDockUpdater = FeatureFactory.getFactory(
- context).getDockUpdaterFeatureProvider().getSavedDockUpdater(context, this);
+ context).getDockUpdaterFeatureProvider().getSavedDockUpdater(context, this);
}
@Override
@@ -60,7 +60,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mPreferenceGroup = screen.findPreference(getPreferenceKey());
mPreferenceGroup.setVisible(false);
if (isAvailable()) {
diff --git a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
index 951f3d1..e1dc750 100644
--- a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
@@ -74,7 +74,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
if (isAvailable()) {
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+ mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
final Context context = screen.getContext();
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
index 01977d8..4b08b74 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
@@ -57,7 +57,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+ mPreferenceCategory = screen.findPreference(getPreferenceKey());
mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_HOST),
R.string.usb_control_host);
mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_DEVICE),
@@ -74,7 +74,7 @@
mDevicePref.setChecked(false);
mHostPref.setChecked(true);
mPreferenceCategory.setEnabled(true);
- } else if (!connected || dataRole == DATA_ROLE_NONE){
+ } else if (!connected || dataRole == DATA_ROLE_NONE) {
mPreferenceCategory.setEnabled(false);
if (mNextRolePref == null) {
// Disconnected with no operation pending, so clear subtexts
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index 77ae13f..858a01c 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -68,14 +68,14 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mProfilesContainer = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+ mProfilesContainer = screen.findPreference(getPreferenceKey());
}
/**
* Gets a switch preference for the particular option, creating it if needed.
*/
private RadioButtonPreference getProfilePreference(String key, int titleId) {
- RadioButtonPreference pref = (RadioButtonPreference) mProfilesContainer.findPreference(key);
+ RadioButtonPreference pref = mProfilesContainer.findPreference(key);
if (pref == null) {
pref = new RadioButtonPreference(mProfilesContainer.getContext());
pref.setKey(key);
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
index 26b21a1..e151258 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
@@ -40,8 +40,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- final LayoutPreference headerPreference =
- (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+ final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
headerPreference.findViewById(R.id.entity_header));
}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
index 42c5bae..13b3076 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
@@ -58,7 +58,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+ mPreferenceCategory = screen.findPreference(getPreferenceKey());
mSwitchPreference = new SwitchPreference(mPreferenceCategory.getContext());
mSwitchPreference.setTitle(R.string.usb_use_power_only);
mSwitchPreference.setOnPreferenceClickListener(this);
@@ -70,7 +70,7 @@
// Hide this option if this is not a PD compatible connection
if (connected && !mUsbBackend.areAllRolesSupported()) {
mFragment.getPreferenceScreen().removePreference(mPreferenceCategory);
- } else if (connected && mUsbBackend.areAllRolesSupported()){
+ } else if (connected && mUsbBackend.areAllRolesSupported()) {
mFragment.getPreferenceScreen().addPreference(mPreferenceCategory);
}
if (powerRole == POWER_ROLE_SOURCE) {
@@ -79,7 +79,7 @@
} else if (powerRole == POWER_ROLE_SINK) {
mSwitchPreference.setChecked(false);
mPreferenceCategory.setEnabled(true);
- } else if (!connected || powerRole == POWER_ROLE_NONE){
+ } else if (!connected || powerRole == POWER_ROLE_NONE) {
mPreferenceCategory.setEnabled(false);
if (mNextPowerRole == POWER_ROLE_NONE) {
mSwitchPreference.setSummary("");
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index 1c85009..324b509 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -15,7 +15,6 @@
import android.annotation.IntDef;
import android.content.Context;
-import android.content.IntentFilter;
import android.text.TextUtils;
import android.util.Log;
@@ -24,6 +23,7 @@
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.slices.SliceData;
+import com.android.settings.slices.Sliceable;
import com.android.settingslib.core.AbstractPreferenceController;
import java.lang.annotation.Retention;
@@ -37,7 +37,8 @@
* for Slices. The abstract classes that inherit from this class will act as the direct interfaces
* for each type when plugging into Slices.
*/
-public abstract class BasePreferenceController extends AbstractPreferenceController {
+public abstract class BasePreferenceController extends AbstractPreferenceController implements
+ Sliceable {
private static final String TAG = "SettingsPrefController";
@@ -119,7 +120,7 @@
final Class<?> clazz = Class.forName(controllerName);
final Constructor<?> preferenceConstructor =
clazz.getConstructor(Context.class, String.class);
- final Object[] params = new Object[] {context, key};
+ final Object[] params = new Object[]{context, key};
return (BasePreferenceController) preferenceConstructor.newInstance(params);
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException |
IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
@@ -137,7 +138,7 @@
try {
final Class<?> clazz = Class.forName(controllerName);
final Constructor<?> preferenceConstructor = clazz.getConstructor(Context.class);
- final Object[] params = new Object[] {context};
+ final Object[] params = new Object[]{context};
return (BasePreferenceController) preferenceConstructor.newInstance(params);
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException |
IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
@@ -227,41 +228,6 @@
}
/**
- * @return an {@link IntentFilter} that includes all broadcasts which can affect the state of
- * this Setting.
- */
- public IntentFilter getIntentFilter() {
- return null;
- }
-
- /**
- * Determines if the controller should be used as a Slice.
- * <p>
- * Important criteria for a Slice are:
- * - Must be secure
- * - Must not be a privacy leak
- * - Must be understandable as a stand-alone Setting.
- * <p>
- * This does not guarantee the setting is available. {@link #isAvailable()} should sill be
- * called.
- *
- * @return {@code true} if the controller should be used externally as a Slice.
- */
- public boolean isSliceable() {
- return false;
- }
-
- /**
- * @return {@code true} if the setting update asynchronously.
- * <p>
- * For example, a Wifi controller would return true, because it needs to update the radio
- * and wait for it to turn on.
- */
- public boolean hasAsyncUpdate() {
- return false;
- }
-
- /**
* Updates non-indexable keys for search provider.
*
* Called by SearchIndexProvider#getNonIndexableKeys
@@ -293,6 +259,7 @@
/**
* Set {@link UiBlockListener}
+ *
* @param uiBlockListener listener to set
*/
public void setUiBlockListener(UiBlockListener uiBlockListener) {
@@ -306,6 +273,7 @@
/**
* To notify client that UI related background work is finished.
* (i.e. Slice is fully loaded.)
+ *
* @param controller Controller that contains background work
*/
void onBlockerWorkFinished(BasePreferenceController controller);
@@ -321,5 +289,6 @@
*
* This music be used in {@link BasePreferenceController}
*/
- public interface UiBlocker {}
+ public interface UiBlocker {
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index d1c2fd5..78fdfe7 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -26,7 +26,6 @@
public static final String MOBILE_NETWORK_V2 = "settings_mobile_network_v2";
public static final String WIFI_MAC_RANDOMIZATION = "settings_wifi_mac_randomization";
public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
- public static final String WIFI_SHARING = "settings_wifi_sharing";
public static final String SLICE_INJECTION = "settings_slice_injection";
public static final String MAINLINE_MODULE = "settings_mainline_module";
}
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index 15c7754..8bab256 100644
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -52,6 +52,7 @@
import com.android.settingslib.net.UidDetail;
import com.android.settingslib.net.UidDetailProvider;
+import java.util.ArrayList;
import java.util.List;
public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceChangeListener,
@@ -59,8 +60,10 @@
private static final String TAG = "AppDataUsage";
- public static final String ARG_APP_ITEM = "app_item";
- public static final String ARG_NETWORK_TEMPLATE = "network_template";
+ static final String ARG_APP_ITEM = "app_item";
+ static final String ARG_NETWORK_TEMPLATE = "network_template";
+ static final String ARG_NETWORK_CYCLES = "network_cycles";
+ static final String ARG_SELECTED_CYCLE = "selected_cycle";
private static final String KEY_TOTAL_USAGE = "total_usage";
private static final String KEY_FOREGROUND_USAGE = "foreground_usage";
@@ -99,6 +102,8 @@
private RestrictedSwitchPreference mUnrestrictedData;
private DataSaverBackend mDataSaverBackend;
private Context mContext;
+ private ArrayList<Long> mCycles;
+ private long mSelectedCycle;
@Override
public void onCreate(Bundle icicle) {
@@ -110,6 +115,10 @@
mAppItem = (args != null) ? (AppItem) args.getParcelable(ARG_APP_ITEM) : null;
mTemplate = (args != null) ? (NetworkTemplate) args.getParcelable(ARG_NETWORK_TEMPLATE)
: null;
+ mCycles = (args != null) ? (ArrayList) args.getSerializable(ARG_NETWORK_CYCLES)
+ : null;
+ mSelectedCycle = (args != null) ? args.getLong(ARG_SELECTED_CYCLE) : 0L;
+
if (mTemplate == null) {
mTemplate = DataUsageUtils.getDefaultTemplate(mContext,
SubscriptionManager.getDefaultDataSubscriptionId());
@@ -393,6 +402,9 @@
} else {
builder.addUid(mAppItem.key);
}
+ if (mCycles != null) {
+ builder.setCycles(mCycles);
+ }
return builder.build();
}
@@ -401,7 +413,23 @@
List<NetworkCycleDataForUid> data) {
mUsageData = data;
mCycleAdapter.updateCycleList(data);
- bindData(0 /* position */);
+ if (mSelectedCycle > 0L) {
+ final int numCycles = data.size();
+ int position = 0;
+ for (int i = 0; i < numCycles; i++) {
+ final NetworkCycleDataForUid cycleData = data.get(i);
+ if (cycleData.getEndTime() == mSelectedCycle) {
+ position = i;
+ break;
+ }
+ }
+ if (position > 0) {
+ mCycle.setSelection(position);
+ }
+ bindData(position);
+ } else {
+ bindData(0 /* position */);
+ }
}
@Override
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 8eeb925..e5158ff 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -109,6 +109,7 @@
@VisibleForTesting
int mNetworkType;
private List<NetworkCycleChartData> mCycleData;
+ private ArrayList<Long> mCycles;
private LoadingViewController mLoadingViewController;
private UidDetailProvider mUidDetailProvider;
@@ -411,10 +412,23 @@
}
}
- private void startAppDataUsage(AppItem item) {
+ @VisibleForTesting
+ void startAppDataUsage(AppItem item) {
final Bundle args = new Bundle();
args.putParcelable(AppDataUsage.ARG_APP_ITEM, item);
args.putParcelable(AppDataUsage.ARG_NETWORK_TEMPLATE, mTemplate);
+ if (mCycles == null) {
+ mCycles = new ArrayList<>();
+ for (NetworkCycleChartData data : mCycleData) {
+ if (mCycles.isEmpty()) {
+ mCycles.add(data.getEndTime());
+ }
+ mCycles.add(data.getStartTime());
+ }
+ }
+ args.putSerializable(AppDataUsage.ARG_NETWORK_CYCLES, mCycles);
+ args.putLong(AppDataUsage.ARG_SELECTED_CYCLE,
+ mCycleData.get(mCycleSpinner.getSelectedItemPosition()).getEndTime());
new SubSettingLauncher(getContext())
.setDestination(AppDataUsage.class.getName())
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index 0f21dee..0f429c7 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -65,7 +65,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
// Set a default value because BluetoothCodecConfig is null initially.
mPreference.setValue(mListValues[getDefaultIndex()]);
@@ -177,7 +177,7 @@
@VisibleForTesting
void setCodecConfigPreference(BluetoothDevice device,
- BluetoothCodecConfig config) {
+ BluetoothCodecConfig config) {
mBluetoothA2dp.setCodecConfigPreference(device, config);
}
diff --git a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
index d26f0dd..d698436 100644
--- a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
@@ -55,8 +55,7 @@
mListEntries = context.getResources().getStringArray(R.array.bt_hci_snoop_log_entries);
}
- // Default mode is FILTERED on userdebug/eng build, DISABLED on user build,
- // or can be changed by modifying the global setting.
+ // Default mode is DISABLED. It can also be changed by modifying the global setting.
public int getDefaultModeIndex() {
if (!Build.IS_DEBUGGABLE) {
return BTSNOOP_LOG_MODE_DISABLED_INDEX;
@@ -71,7 +70,7 @@
}
}
- return BTSNOOP_LOG_MODE_FILTERED_INDEX;
+ return BTSNOOP_LOG_MODE_DISABLED_INDEX;
}
@Override
diff --git a/src/com/android/settings/development/OemUnlockPreferenceController.java b/src/com/android/settings/development/OemUnlockPreferenceController.java
index b6b4d17..2a397f1 100644
--- a/src/com/android/settings/development/OemUnlockPreferenceController.java
+++ b/src/com/android/settings/development/OemUnlockPreferenceController.java
@@ -77,7 +77,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/development/OverlayCategoryPreferenceController.java b/src/com/android/settings/development/OverlayCategoryPreferenceController.java
index 0ba9d79..7a2ee08 100644
--- a/src/com/android/settings/development/OverlayCategoryPreferenceController.java
+++ b/src/com/android/settings/development/OverlayCategoryPreferenceController.java
@@ -41,7 +41,6 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import java.util.Optional;
/**
* Preference controller to allow users to choose an overlay from a list for a given category.
@@ -91,7 +90,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- setPreference((ListPreference) screen.findPreference(getPreferenceKey()));
+ setPreference(screen.findPreference(getPreferenceKey()));
}
@VisibleForTesting
@@ -124,7 +123,8 @@
if (PACKAGE_DEVICE_DEFAULT.equals(packageName)) {
return mOverlayManager.setEnabled(currentPackageName, false, USER_SYSTEM);
} else {
- return mOverlayManager.setEnabledExclusiveInCategory(packageName, USER_SYSTEM);
+ return mOverlayManager.setEnabledExclusiveInCategory(packageName,
+ USER_SYSTEM);
}
} catch (RemoteException re) {
Log.w(TAG, "Error enabling overlay.", re);
diff --git a/src/com/android/settings/development/PictureColorModePreferenceController.java b/src/com/android/settings/development/PictureColorModePreferenceController.java
index 3cf1f4e..1acf5d0 100644
--- a/src/com/android/settings/development/PictureColorModePreferenceController.java
+++ b/src/com/android/settings/development/PictureColorModePreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ColorModePreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
if (mPreference != null) {
mPreference.updateCurrentAndSupported();
}
diff --git a/src/com/android/settings/development/StayAwakePreferenceController.java b/src/com/android/settings/development/StayAwakePreferenceController.java
index 4091537..25a92b2 100644
--- a/src/com/android/settings/development/StayAwakePreferenceController.java
+++ b/src/com/android/settings/development/StayAwakePreferenceController.java
@@ -40,7 +40,7 @@
public class StayAwakePreferenceController extends DeveloperOptionsPreferenceController
- implements Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause,
+ implements Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause,
PreferenceControllerMixin {
private static final String TAG = "StayAwakeCtrl";
@@ -72,7 +72,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 1c4df4c..638c7c1 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -45,7 +45,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mGroup = screen.findPreference(getPreferenceKey());
}
@Override
@@ -60,6 +60,6 @@
mGroup.removeAll();
final Context prefContext = mGroup.getContext();
featureMap.keySet().stream().sorted().forEach(feature ->
- mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
+ mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
}
}
diff --git a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
index 3877c45..09659be 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
@@ -55,8 +55,8 @@
*/
public class GameDriverAppPreferenceController extends BasePreferenceController
implements Preference.OnPreferenceChangeListener,
- GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
- OnStart, OnStop {
+ GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
+ OnStart, OnStop {
private final Context mContext;
private final ContentResolver mContentResolver;
@@ -103,9 +103,9 @@
@Override
public int getAvailabilityStatus() {
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
- && (Settings.Global.getInt(mContentResolver,
- Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
- != GAME_DRIVER_OFF)
+ && (Settings.Global.getInt(mContentResolver,
+ Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
+ != GAME_DRIVER_OFF)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -113,7 +113,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mPreferenceGroup = screen.findPreference(getPreferenceKey());
final Context context = mPreferenceGroup.getContext();
for (AppInfo appInfo : mAppInfos) {
@@ -179,6 +179,7 @@
info = applicationInfo;
label = packageManager.getApplicationLabel(applicationInfo).toString();
}
+
final ApplicationInfo info;
final String label;
}
diff --git a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
index 95c02fd..50027f2 100644
--- a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
@@ -61,7 +61,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mSwitch = (MasterSwitchPreference) screen.findPreference(getPreferenceKey());
+ mSwitch = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index ee9fad6..c78d108 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -49,8 +49,10 @@
private static final int USER_PROFILE_INSERTION_LOCATION = 6;
private static final int SIZE_NOT_SET = -1;
- private @NonNull UserInfo mUser;
- private @Nullable StorageItemPreference mStoragePreference;
+ private @NonNull
+ UserInfo mUser;
+ private @Nullable
+ StorageItemPreference mStoragePreference;
private Drawable mUserIcon;
private long mSize;
private long mTotalSizeBytes;
@@ -58,7 +60,8 @@
/**
* Adds the appropriate controllers to a controller list for handling all secondary users on
* a device.
- * @param context Context for initializing the preference controllers.
+ *
+ * @param context Context for initializing the preference controllers.
* @param userManager UserManagerWrapper for figuring out which controllers to add.
*/
public static List<AbstractPreferenceController> getSecondaryUserControllers(
@@ -91,8 +94,9 @@
/**
* Constructor for a given secondary user.
+ *
* @param context Context to initialize the underlying {@link AbstractPreferenceController}.
- * @param info {@link UserInfo} for the secondary user which this controllers covers.
+ * @param info {@link UserInfo} for the secondary user which this controllers covers.
*/
@VisibleForTesting
SecondaryUserController(Context context, @NonNull UserInfo info) {
@@ -107,7 +111,7 @@
mStoragePreference = new StorageItemPreference(screen.getContext());
PreferenceGroup group =
- (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+ screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
mStoragePreference.setTitle(mUser.name);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
if (mSize != SIZE_NOT_SET) {
@@ -140,6 +144,7 @@
/**
* Sets the size for the preference.
+ *
* @param size Size in bytes.
*/
public void setSize(long size) {
@@ -151,6 +156,7 @@
/**
* Sets the total size for the preference for the progress bar.
+ *
* @param totalSizeBytes Total size in bytes.
*/
public void setTotalSize(long totalSizeBytes) {
@@ -185,8 +191,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- PreferenceGroup group =
- (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+ final PreferenceGroup group = screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
if (group == null) {
return;
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 4bc7cde..525a887 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -77,7 +77,7 @@
static final String FILES_KEY = "pref_files";
private final Fragment mFragment;
- private final MetricsFeatureProvider mMetricsFeatureProvider;
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
private final StorageVolumeProvider mSvp;
private VolumeInfo mVolume;
private int mUserId;
@@ -225,7 +225,7 @@
private static Drawable applyTint(Context context, Drawable icon) {
TypedArray array =
- context.obtainStyledAttributes(new int[] {android.R.attr.colorControlNormal});
+ context.obtainStyledAttributes(new int[]{android.R.attr.colorControlNormal});
icon = icon.mutate();
icon.setTint(array.getColor(0, 0));
array.recycle();
@@ -235,13 +235,13 @@
@Override
public void displayPreference(PreferenceScreen screen) {
mScreen = screen;
- mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
- mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
- mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
- mMoviesPreference = (StorageItemPreference) screen.findPreference(MOVIES_KEY);
- mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
- mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
- mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
+ mPhotoPreference = screen.findPreference(PHOTO_KEY);
+ mAudioPreference = screen.findPreference(AUDIO_KEY);
+ mGamePreference = screen.findPreference(GAME_KEY);
+ mMoviesPreference = screen.findPreference(MOVIES_KEY);
+ mAppPreference = screen.findPreference(OTHER_APPS_KEY);
+ mSystemPreference = screen.findPreference(SYSTEM_KEY);
+ mFilePreference = screen.findPreference(FILES_KEY);
setFilesPreferenceVisibility();
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
index 1dd3d98..d450a2a 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
@@ -46,7 +46,6 @@
/**
* Converts a used storage amount to a formatted text.
*
- * @param context Context
* @param usedBytes used bytes of storage
* @return a formatted text.
*/
@@ -59,7 +58,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mSummary = (StorageSummaryDonutPreference) screen.findPreference("pref_summary");
+ mSummary = screen.findPreference("pref_summary");
mSummary.setEnabled(true);
}
@@ -94,7 +93,7 @@
/**
* Updates the state of the donut preference for the next update.
*
- * @param used Total number of used bytes on the summarized volume.
+ * @param used Total number of used bytes on the summarized volume.
* @param total Total number of bytes on the summarized volume.
*/
public void updateBytes(long used, long total) {
diff --git a/src/com/android/settings/display/NightModePreferenceController.java b/src/com/android/settings/display/NightModePreferenceController.java
index 5846a65..a4d96f6 100644
--- a/src/com/android/settings/display/NightModePreferenceController.java
+++ b/src/com/android/settings/display/NightModePreferenceController.java
@@ -52,8 +52,7 @@
setVisible(screen, KEY_NIGHT_MODE, false /* visible */);
return;
}
- ListPreference mNightModePreference = (ListPreference) screen.findPreference(
- KEY_NIGHT_MODE);
+ final ListPreference mNightModePreference = screen.findPreference(KEY_NIGHT_MODE);
if (mNightModePreference != null) {
final UiModeManager uiManager =
(UiModeManager) mContext.getSystemService(UI_MODE_SERVICE);
diff --git a/src/com/android/settings/dream/StartNowPreferenceController.java b/src/com/android/settings/dream/StartNowPreferenceController.java
index 9e45ea3..0541bca 100644
--- a/src/com/android/settings/dream/StartNowPreferenceController.java
+++ b/src/com/android/settings/dream/StartNowPreferenceController.java
@@ -54,8 +54,8 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
- Button startButton = (Button)pref.findViewById(R.id.dream_start_now_button);
+ LayoutPreference pref = screen.findPreference(getPreferenceKey());
+ Button startButton = pref.findViewById(R.id.dream_start_now_button);
startButton.setOnClickListener(v -> mBackend.startDreaming());
}
@@ -63,7 +63,7 @@
public void updateState(Preference preference) {
super.updateState(preference);
- Button startButton = (Button)((LayoutPreference)preference)
+ Button startButton = ((LayoutPreference) preference)
.findViewById(R.id.dream_start_now_button);
startButton.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
}
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index e2d1c53..5366ba1 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -143,7 +143,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPrefContext = screen.getContext();
- mAppListGroup = (PreferenceGroup) screen.findPreference(mPreferenceKey);
+ mAppListGroup = screen.findPreference(mPreferenceKey);
}
@Override
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
index ce85be8..c4da670 100644
--- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
@@ -80,7 +80,9 @@
}
CharSequence label;
final BidiFormatter formatter = BidiFormatter.getInstance();
- if (info.remainingLabel == null) {
+ if (!info.discharging && info.chargeLabel != null) {
+ label = info.chargeLabel;
+ } else if (info.remainingLabel == null) {
label = info.batteryPercentString;
} else {
label = context.getString(R.string.power_remaining_settings_home_page,
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 80a72e6..bb12d1a 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -72,7 +72,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (TwoStateButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/gestures/GesturePreferenceController.java b/src/com/android/settings/gestures/GesturePreferenceController.java
index a4274bf..d7b386a 100644
--- a/src/com/android/settings/gestures/GesturePreferenceController.java
+++ b/src/com/android/settings/gestures/GesturePreferenceController.java
@@ -51,7 +51,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- mVideoPreference = (VideoPreference) screen.findPreference(getVideoPrefKey());
+ mVideoPreference = screen.findPreference(getVideoPrefKey());
}
}
diff --git a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
index d22e42a..04f7e476 100644
--- a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
@@ -45,9 +45,11 @@
implements RadioButtonPreference.OnClickListener, LifecycleObserver, OnSaveInstanceState,
OnResume, OnPause, OnCreate, PreferenceControllerMixin {
- @VisibleForTesting static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
+ @VisibleForTesting
+ static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
- @VisibleForTesting static final String KEY_MUTE = "prevent_ringing_option_mute";
+ @VisibleForTesting
+ static final String KEY_MUTE = "prevent_ringing_option_mute";
private final String KEY_VIDEO_PAUSED = "key_video_paused";
private final String PREF_KEY_VIDEO = "gesture_prevent_ringing_video";
@@ -57,9 +59,12 @@
private VideoPreference mVideoPreference;
private boolean mVideoPaused;
- @VisibleForTesting PreferenceCategory mPreferenceCategory;
- @VisibleForTesting RadioButtonPreference mVibratePref;
- @VisibleForTesting RadioButtonPreference mMutePref;
+ @VisibleForTesting
+ PreferenceCategory mPreferenceCategory;
+ @VisibleForTesting
+ RadioButtonPreference mVibratePref;
+ @VisibleForTesting
+ RadioButtonPreference mMutePref;
private SettingObserver mSettingObserver;
@@ -75,17 +80,18 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- if (isAvailable()) {
- mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
- mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
- mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
-
- if (mPreferenceCategory != null) {
- mSettingObserver = new SettingObserver(mPreferenceCategory);
- }
-
- mVideoPreference = (VideoPreference) screen.findPreference(getVideoPrefKey());
+ if (!isAvailable()) {
+ return;
}
+ mPreferenceCategory = screen.findPreference(getPreferenceKey());
+ mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
+ mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
+
+ if (mPreferenceCategory != null) {
+ mSettingObserver = new SettingObserver(mPreferenceCategory);
+ }
+
+ mVideoPreference = screen.findPreference(getVideoPrefKey());
}
@Override
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
index b94cfff..35ff2ec 100644
--- a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -35,13 +35,14 @@
import com.android.settingslib.widget.LayoutPreference;
public class PreventRingingSwitchPreferenceController extends AbstractPreferenceController
- implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
+ implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
private static final String KEY = "gesture_prevent_ringing_switch";
private final Context mContext;
private SettingObserver mSettingObserver;
- @VisibleForTesting SwitchBar mSwitch;
+ @VisibleForTesting
+ SwitchBar mSwitch;
public PreventRingingSwitchPreferenceController(Context context) {
super(context);
@@ -57,7 +58,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+ LayoutPreference pref = screen.findPreference(getPreferenceKey());
if (pref != null) {
mSettingObserver = new SettingObserver(pref);
mSwitch = pref.findViewById(R.id.switch_bar);
diff --git a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
index a43fad1..96a3580 100644
--- a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
@@ -53,7 +53,18 @@
|| !mFeatureProvider.isSupported(mContext)) {
return UNSUPPORTED_ON_DEVICE;
}
- return mFeatureProvider.isEnabled(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+
+ if (!mFeatureProvider.isEnabled(mContext)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+
+ return getAmbientConfig().alwaysOnEnabled(mUserId)
+ ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ }
+
+ @Override
+ protected boolean canHandleClicks() {
+ return getAmbientConfig().alwaysOnEnabled(mUserId);
}
@Override
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
index 43ff537..5f95de4 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.provider.Settings;
+import android.service.notification.ZenModeConfig;
import androidx.annotation.VisibleForTesting;
@@ -97,7 +98,7 @@
.setName(mAppContext.getPackageName() + "/"
+ mAppContext.getText(R.string.condition_zen_title))
.setTitleText(mAppContext.getText(R.string.condition_zen_title).toString())
- .setSummaryText(mAppContext.getText(R.string.condition_zen_summary).toString())
+ .setSummaryText(getSummary())
.setIconDrawable(mAppContext.getDrawable(R.drawable.ic_do_not_disturb_on_24dp))
.setViewType(ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH)
.build();
@@ -112,4 +113,11 @@
}
}
}
+
+ private String getSummary() {
+ if (ZenModeConfig.areAllZenBehaviorSoundsMuted(mNotificationManager.getZenModeConfig())) {
+ return mAppContext.getText(R.string.condition_zen_summary_phone_muted).toString();
+ }
+ return mAppContext.getText(R.string.condition_zen_summary_with_exceptions).toString();
+ }
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 5673948..95412a8 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -37,7 +37,6 @@
import com.android.settings.SubSettings;
import com.android.settings.Utils;
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
-import com.android.settings.bluetooth.BluetoothPairingDetail;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.slices.CustomSliceRegistry;
@@ -127,11 +126,6 @@
listBuilder.addRow(rows.get(i));
}
- // Add "Pair new device" if need.
- if (rows.size() < DEFAULT_EXPANDED_ROW_COUNT) {
- listBuilder.addRow(getPairNewDeviceRowBuilder());
- }
-
return listBuilder.build();
}
@@ -220,7 +214,7 @@
.getBtClassDrawableWithDescription(mContext, device);
if (pair.first != null) {
- return IconCompat.createWithBitmap(Utils.drawableToBitmap(pair.first));
+ return Utils.createIconWithDrawable(pair.first);
} else {
return IconCompat.createWithResource(mContext,
com.android.internal.R.drawable.ic_settings_bluetooth);
@@ -268,26 +262,4 @@
return mContext.getResources().getQuantityString(R.plurals.show_bluetooth_devices,
deviceCount, deviceCount);
}
-
- private ListBuilder.RowBuilder getPairNewDeviceRowBuilder() {
- final CharSequence title = mContext.getText(R.string.bluetooth_pairing_pref_title);
- final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_menu_add);
- final SliceAction sliceAction = SliceAction.createDeeplink(
- getPairNewDeviceIntent(), icon, ListBuilder.ICON_IMAGE, title);
-
- return new ListBuilder.RowBuilder()
- .setTitleItem(icon, ListBuilder.ICON_IMAGE)
- .setTitle(title)
- .setPrimaryAction(sliceAction);
- }
-
- private PendingIntent getPairNewDeviceIntent() {
- final Intent intent = new SubSettingLauncher(mContext)
- .setDestination(BluetoothPairingDetail.class.getName())
- .setTitleRes(R.string.bluetooth_pairing_page_title)
- .setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING)
- .toIntent();
-
- return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
- }
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index 692dc0a..c2c2ece 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -30,9 +30,6 @@
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -243,7 +240,7 @@
return null;
}
- return IconCompat.createWithBitmap(Utils.drawableToBitmap(drawable));
+ return Utils.createIconWithDrawable(drawable);
}
@VisibleForTesting
diff --git a/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java b/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
index 4be70d5..4a409e1 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
@@ -79,7 +79,7 @@
@NonNull
public static TreeSet<String> getUserDictionaryLocalesSet(Context context) {
final Cursor cursor = context.getContentResolver().query(
- UserDictionary.Words.CONTENT_URI, new String[] {UserDictionary.Words.LOCALE},
+ UserDictionary.Words.CONTENT_URI, new String[]{UserDictionary.Words.LOCALE},
null, null, null);
final TreeSet<String> localeSet = new TreeSet<>();
if (cursor == null) {
@@ -124,14 +124,14 @@
// enabled subtypes. If we already have the locale-without-country version of the system
// locale, we don't add the system locale to avoid confusion even though it's technically
// correct to add it.
- if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
+ if (!localeSet.contains(Locale.getDefault().getLanguage())) {
localeSet.add(Locale.getDefault().toString());
}
return localeSet;
}
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
TreeSet<String> getUserDictLocalesSet(Context context) {
return getUserDictionaryLocalesSet(context);
}
@@ -140,7 +140,6 @@
* Creates the entries that allow the user to go into the user dictionary for each locale.
*/
private void createUserDictSettings() {
-
final TreeSet<String> localeSet = getUserDictLocalesSet(mContext);
final int prefCount = mScreen.getPreferenceCount();
String prefKey;
@@ -160,8 +159,8 @@
if (prefCount > 0) {
for (int i = prefCount - 1; i >= 0; i--) {
prefKey = mScreen.getPreference(i).getKey();
- if (KEY_ALL_LANGUAGE.equals(prefKey)) {
- prefKey = "";
+ if (TextUtils.isEmpty(prefKey) || TextUtils.equals(KEY_ALL_LANGUAGE, prefKey)) {
+ continue;
}
if (!localeSet.isEmpty() && localeSet.contains(prefKey)) {
localeSet.remove(prefKey);
diff --git a/src/com/android/settings/location/LocationForWorkPreferenceController.java b/src/com/android/settings/location/LocationForWorkPreferenceController.java
index 580f888..1208ea2 100644
--- a/src/com/android/settings/location/LocationForWorkPreferenceController.java
+++ b/src/com/android/settings/location/LocationForWorkPreferenceController.java
@@ -57,8 +57,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference =
- (RestrictedSwitchPreference) screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
+ mPreference = screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
}
@Override
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java
index 43d35f1..e604261 100644
--- a/src/com/android/settings/location/LocationServicePreferenceController.java
+++ b/src/com/android/settings/location/LocationServicePreferenceController.java
@@ -84,8 +84,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mCategoryLocationServices =
- (PreferenceCategory) screen.findPreference(KEY_LOCATION_SERVICES);
+ mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
}
@Override
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index 214dcd5..44d600e 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -69,8 +69,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- final LayoutPreference preference = (LayoutPreference) screen.findPreference(
- KEY_APPS_DASHBOARD);
+ final LayoutPreference preference = screen.findPreference(KEY_APPS_DASHBOARD);
final View view = preference.findViewById(R.id.app_entities_header);
mController = AppEntitiesHeaderController.newInstance(mContext, view)
.setHeaderTitleRes(R.string.location_category_recent_location_access)
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 5c5eb88..d52b441 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -23,8 +23,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.UserHandle;
@@ -87,7 +85,7 @@
final Drawable drawable =
Utils.getBadgedIcon(mIconDrawableFactory, pm, mPackageName, UserHandle.myUserId());
- final IconCompat icon = IconCompat.createWithBitmap(getBitmapFromDrawable(drawable));
+ final IconCompat icon = Utils.createIconWithDrawable(drawable);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final SliceAction primarySliceAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
@@ -134,17 +132,6 @@
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
}
- private Bitmap getBitmapFromDrawable(Drawable drawable) {
- final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
- drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
- final Canvas canvas = new Canvas(bitmap);
-
- drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- drawable.draw(canvas);
-
- return bitmap;
- }
-
private ListBuilder.RowBuilder getMediaDeviceRow(MediaDevice device) {
final String title = device.getName();
final PendingIntent broadcastAction =
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 1490e8a..5c1913b 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -81,7 +81,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- mAirplaneModePreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
+ mAirplaneModePreference = screen.findPreference(getPreferenceKey());
}
}
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index fff1fea..dd282c6 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -31,6 +31,7 @@
import com.android.settings.R;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.widget.AddPreference;
+import com.android.settingslib.Utils;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.List;
@@ -50,6 +51,7 @@
private SubscriptionManager mSubscriptionManager;
private SubscriptionsChangeListener mChangeListener;
private TelephonyManager mTelephonyMgr;
+ private EuiccManager mEuiccManager;
private AddPreference mPreference;
/**
@@ -71,6 +73,7 @@
super(context);
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
mTelephonyMgr = mContext.getSystemService(TelephonyManager.class);
+ mEuiccManager = mContext.getSystemService(EuiccManager.class);
mChangeListener = new SubscriptionsChangeListener(context, this);
lifecycle.addObserver(this);
}
@@ -97,7 +100,11 @@
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
mSubscriptionManager);
if (subs.isEmpty()) {
- return mContext.getResources().getString(R.string.mobile_network_summary_add_a_network);
+ if (mEuiccManager.isEnabled()) {
+ return mContext.getResources().getString(
+ R.string.mobile_network_summary_add_a_network);
+ }
+ return null;
} else if (subs.size() == 1) {
return subs.get(0).getDisplayName();
} else {
@@ -112,20 +119,22 @@
mContext.startActivity(intent);
}
- private boolean shouldEnableAddButton() {
- // The add button should only show up if the device is in multi-sim mode.
- return mTelephonyMgr.getMultiSimConfiguration() != UNKNOWN;
+ private boolean shouldShowAddButton() {
+ // The add button should only show up if the device is in multi-sim mode and the eSIM
+ // manager is enabled.
+ return mTelephonyMgr.getMultiSimConfiguration() != UNKNOWN && mEuiccManager.isEnabled();
}
private void update() {
if (mPreference == null) {
return;
}
- final boolean enableAddButton = shouldEnableAddButton();
+ final boolean showAddButton = shouldShowAddButton();
refreshSummary(mPreference);
- if (!enableAddButton) {
+ if (!showAddButton) {
mPreference.setOnAddClickListener(null);
} else {
+ mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
mPreference.setOnAddClickListener(p -> {
startAddSimFlow();
});
@@ -134,11 +143,11 @@
mSubscriptionManager);
mPreference.setOnPreferenceClickListener(null);
mPreference.setFragment(null);
- mPreference.setEnabled(true);
+ mPreference.setEnabled(!mChangeListener.isAirplaneModeOn());
if (subs.isEmpty()) {
- if (enableAddButton) {
+ if (showAddButton) {
mPreference.setEnabled(false);
- } else {
+ } else if (mEuiccManager.isEnabled()) {
mPreference.setOnPreferenceClickListener((Preference pref) -> {
startAddSimFlow();
return true;
@@ -157,7 +166,7 @@
@Override
public boolean isAvailable() {
- return true;
+ return !Utils.isWifiOnly(mContext);
}
@Override
@@ -167,6 +176,7 @@
@Override
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
+ update();
}
@Override
diff --git a/src/com/android/settings/network/MultiNetworkHeaderController.java b/src/com/android/settings/network/MultiNetworkHeaderController.java
index 938c753..ba201a5 100644
--- a/src/com/android/settings/network/MultiNetworkHeaderController.java
+++ b/src/com/android/settings/network/MultiNetworkHeaderController.java
@@ -65,7 +65,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceCategory = (PreferenceCategory) screen.findPreference(mPreferenceKey);
+ mPreferenceCategory = screen.findPreference(mPreferenceKey);
mPreferenceCategory.setVisible(isAvailable());
mWifiController.displayPreference(screen);
mSubscriptionsController.displayPreference(screen);
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 237e08a..224fc41 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -38,7 +38,7 @@
if (sResultsForTesting != null) {
return sResultsForTesting;
}
- List<SubscriptionInfo> subscriptions = manager.getAvailableSubscriptionInfoList();
+ List<SubscriptionInfo> subscriptions = manager.getSelectableSubscriptionInfoList();
if (subscriptions == null) {
subscriptions = new ArrayList<>();
}
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index a639782..b6e8f58 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -107,7 +107,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(mPreferenceGroupKey);
+ mPreferenceGroup = screen.findPreference(mPreferenceGroupKey);
update();
}
@@ -129,7 +129,7 @@
mSubscriptionPreferences = new ArrayMap<>();
int order = mStartOrder;
- for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
+ for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
final int subId = info.getSubscriptionId();
Preference pref = existingPrefs.remove(subId);
if (pref == null) {
@@ -209,7 +209,6 @@
}
/**
- *
* @return true if there are at least 2 available subscriptions.
*/
@Override
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 9c5a98e..94b1761 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -54,6 +54,8 @@
public int getAvailabilityStatus(int subId) {
boolean visible;
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ final TelephonyManager telephonyManager = TelephonyManager
+ .from(mContext).createForSubscriptionId(subId);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false;
} else if (carrierConfig == null) {
@@ -63,8 +65,8 @@
visible = false;
} else if (carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
- && !mTelephonyManager.getServiceState().getRoaming()
- && mTelephonyManager.getServiceState().getDataRegState()
+ && !telephonyManager.getServiceState().getRoaming()
+ && telephonyManager.getServiceState().getDataRegState()
== ServiceState.STATE_IN_SERVICE) {
visible = false;
} else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
@@ -175,18 +177,21 @@
R.array.enabled_networks_tdscdma_choices);
preference.setEntryValues(
R.array.enabled_networks_tdscdma_values);
- } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)
+ } else if (carrierConfig != null
+ && !carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)
&& !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
preference.setEntries(R.array.enabled_networks_except_gsm_lte_choices);
preference.setEntryValues(R.array.enabled_networks_except_gsm_lte_values);
- } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)) {
+ } else if (carrierConfig != null
+ && !carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)) {
int select = mShow4GForLTE
? R.array.enabled_networks_except_gsm_4g_choices
: R.array.enabled_networks_except_gsm_choices;
preference.setEntries(select);
preference.setEntryValues(
R.array.enabled_networks_except_gsm_values);
- } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
+ } else if (carrierConfig != null
+ && !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
preference.setEntries(
R.array.enabled_networks_except_lte_choices);
preference.setEntryValues(
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 821b1e1e..3c0940d 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -160,7 +160,7 @@
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
if (subId != SUB_ID_NULL) {
for (SubscriptionInfo subscription :
- mSubscriptionManager.getAvailableSubscriptionInfoList()) {
+ mSubscriptionManager.getSelectableSubscriptionInfoList()) {
if (subscription.getSubscriptionId() == subId) {
return subscription;
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 8e44dd4..42c1b93 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -347,6 +347,7 @@
final PersistableBundle carrierConfig = context.getSystemService(
CarrierConfigManager.class).getConfigForSubId(subId);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
+ || carrierConfig == null
|| !carrierConfig.getBoolean(
CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL)
|| (carrierConfig.getBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL)
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index ff04583..2495ca5 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -122,7 +122,7 @@
final Activity activity = getActivity();
if (activity != null) {
- mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+ mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
.findViewById(R.id.progress_bar_animation);
setProgressBarVisible(false);
}
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index 27a7bce..294f05f 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -30,7 +30,6 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
/**
* Preference controller for "Preferred network mode"
@@ -51,6 +50,8 @@
@Override
public int getAvailabilityStatus(int subId) {
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ final TelephonyManager telephonyManager = TelephonyManager
+ .from(mContext).createForSubscriptionId(subId);
boolean visible;
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false;
@@ -61,8 +62,8 @@
visible = false;
} else if (carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
- && !mTelephonyManager.getServiceState().getRoaming()
- && mTelephonyManager.getServiceState().getDataRegState()
+ && !telephonyManager.getServiceState().getRoaming()
+ && telephonyManager.getServiceState().getDataRegState()
== ServiceState.STATE_IN_SERVICE) {
visible = false;
} else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 44984e6..8c32df0 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -34,7 +34,6 @@
import androidx.preference.SwitchPreference;
import com.android.ims.ImsManager;
-import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -49,7 +48,6 @@
private Preference mPreference;
private TelephonyManager mTelephonyManager;
private CarrierConfigManager mCarrierConfigManager;
- private PersistableBundle mCarrierConfig;
@VisibleForTesting
ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@@ -67,7 +65,7 @@
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& MobileNetworkUtils.isWifiCallingEnabled(mContext,
SubscriptionManager.getPhoneId(subId))
- && isVideoCallEnabled()
+ && isVideoCallEnabled(subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -94,7 +92,7 @@
public void updateState(Preference preference) {
super.updateState(preference);
final SwitchPreference switchPreference = (SwitchPreference) preference;
- final boolean videoCallEnabled = isVideoCallEnabled();
+ final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
switchPreference.setVisible(videoCallEnabled);
if (videoCallEnabled) {
final boolean is4gLteEnabled = mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
@@ -119,7 +117,6 @@
public VideoCallingPreferenceController init(int subId) {
mSubId = subId;
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
- mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
}
@@ -127,15 +124,25 @@
return this;
}
+ private boolean isVideoCallEnabled(int subId) {
+ final ImsManager imsManager = subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+ ? ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId))
+ : null;
+ return isVideoCallEnabled(subId, imsManager);
+ }
+
@VisibleForTesting
- boolean isVideoCallEnabled() {
- return mCarrierConfig != null && mImsManager != null
- && mImsManager.isVtEnabledByPlatform()
- && mImsManager.isVtProvisionedOnDevice()
- && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
- && (mCarrierConfig.getBoolean(
+ boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
+ final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ final TelephonyManager telephonyManager = TelephonyManager
+ .from(mContext).createForSubscriptionId(subId);
+ return carrierConfig != null && imsManager != null
+ && imsManager.isVtEnabledByPlatform()
+ && imsManager.isVtProvisionedOnDevice()
+ && MobileNetworkUtils.isImsServiceStateReady(imsManager)
+ && (carrierConfig.getBoolean(
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
- || mTelephonyManager.isDataEnabled());
+ || telephonyManager.isDataEnabled());
}
@Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 26c4d06..dfa1271 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -67,7 +67,7 @@
public int getAvailabilityStatus(int subId) {
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& MobileNetworkUtils.isWifiCallingEnabled(mContext,
- SubscriptionManager.getPhoneId(mSubId))
+ SubscriptionManager.getPhoneId(subId))
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
index a5498bc..ea7d82f 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
@@ -29,8 +29,8 @@
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
-import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.telephony.MobileNetworkUtils;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -38,7 +38,7 @@
/**
* Preference controller related to CDMA category
*/
-public abstract class CdmaBasePreferenceController extends BasePreferenceController
+public abstract class CdmaBasePreferenceController extends TelephonyBasePreferenceController
implements LifecycleObserver, OnStart, OnStop {
protected Preference mPreference;
@@ -64,8 +64,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.isCdmaOptions(mContext, subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
index c653890..e6c1c22 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
@@ -44,8 +44,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.isCdmaOptions(mContext, mSubId) && deviceSupportsNvAndRuim()
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.isCdmaOptions(mContext, subId) && deviceSupportsNvAndRuim()
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index fdc9f7f..7db9df0 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -29,9 +29,9 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.core.TogglePreferenceController;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyTogglePreferenceController;
import java.util.ArrayList;
import java.util.List;
@@ -39,7 +39,7 @@
/**
* Preference controller for "Auto Select Network"
*/
-public class AutoSelectPreferenceController extends TogglePreferenceController {
+public class AutoSelectPreferenceController extends TelephonyTogglePreferenceController {
private int mSubId;
private TelephonyManager mTelephonyManager;
@@ -54,8 +54,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext,mSubId)
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -112,8 +112,10 @@
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
final PersistableBundle carrierConfig = mContext.getSystemService(
CarrierConfigManager.class).getConfigForSubId(mSubId);
- mOnlyAutoSelectInHome = carrierConfig.getBoolean(
- CarrierConfigManager.KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL);
+ mOnlyAutoSelectInHome = carrierConfig != null
+ ? carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL)
+ : false;
return this;
}
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index e8a392a..9ac0d12 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -33,11 +33,13 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
/**
* Preference controller for "Open network select"
*/
-public class OpenNetworkSelectPagePreferenceController extends BasePreferenceController implements
+public class OpenNetworkSelectPagePreferenceController extends
+ TelephonyBasePreferenceController implements
AutoSelectPreferenceController.OnNetworkSelectModeListener {
private int mSubId;
@@ -51,8 +53,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, mSubId)
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
index b784dc5..15c15aa 100644
--- a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
+++ b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
@@ -47,8 +47,7 @@
return;
}
- final RestrictedPreference restrictedPreference =
- (RestrictedPreference) screen.findPreference(getPreferenceKey());
+ final RestrictedPreference restrictedPreference = screen.findPreference(getPreferenceKey());
mAndroidBeamEnabler = new AndroidBeamEnabler(mContext, restrictedPreference);
}
@@ -57,7 +56,7 @@
public int getAvailabilityStatus() {
PackageManager pm = mContext.getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) {
- return UNSUPPORTED_ON_DEVICE;
+ return UNSUPPORTED_ON_DEVICE;
}
return mNfcAdapter != null
? AVAILABLE
diff --git a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
index b0c9168..b02608e 100644
--- a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
@@ -81,16 +81,16 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (DropDownPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
if (mPreference == null) {
return;
}
- mPreference.setEntries(new CharSequence[] {
+ mPreference.setEntries(new CharSequence[]{
mContext.getText(R.string.nfc_payment_favor_open),
mContext.getText(R.string.nfc_payment_favor_default)
});
- mPreference.setEntryValues(new CharSequence[] {"1", "0"});
+ mPreference.setEntryValues(new CharSequence[]{"1", "0"});
}
@Override
@@ -124,7 +124,7 @@
mPaymentBackend.setForegroundMode(foregroundMode);
mMetricsFeatureProvider.action(mContext,
foregroundMode ? SettingsEnums.ACTION_NFC_PAYMENT_FOREGROUND_SETTING
- : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
+ : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
return true;
}
diff --git a/src/com/android/settings/nfc/NfcPaymentPreferenceController.java b/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
index a7dd2a6..5215243 100644
--- a/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
@@ -98,7 +98,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (NfcPaymentPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
if (mPreference != null) {
mPreference.initialize(this);
}
diff --git a/src/com/android/settings/nfc/SecureNfcPreferenceController.java b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
index 2c23672..cbff3ea 100644
--- a/src/com/android/settings/nfc/SecureNfcPreferenceController.java
+++ b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
@@ -17,7 +17,6 @@
import android.content.Context;
import android.nfc.NfcAdapter;
-import android.os.SystemProperties;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@@ -30,7 +29,6 @@
public class SecureNfcPreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnResume, OnPause {
- public static final String KEY_TOGGLE_NFC = "nfc_secure_setting";
private final NfcAdapter mNfcAdapter;
private SecureNfcEnabler mSecureNfcEnabler;
@@ -47,8 +45,7 @@
return;
}
- final SwitchPreference switchPreference =
- (SwitchPreference) screen.findPreference(getPreferenceKey());
+ final SwitchPreference switchPreference = screen.findPreference(getPreferenceKey());
mSecureNfcEnabler = new SecureNfcEnabler(mContext, switchPreference);
}
@@ -69,8 +66,9 @@
if (mNfcAdapter == null) {
return UNSUPPORTED_ON_DEVICE;
}
- return mNfcAdapter.deviceSupportsNfcSecure() ? AVAILABLE
- : UNSUPPORTED_ON_DEVICE;
+ return mNfcAdapter.deviceSupportsNfcSecure()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 3977e45..5553dd7 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -51,6 +51,8 @@
private static String KEY_ADVANCED_CATEGORY = "app_advanced";
private static String KEY_BADGE = "badge";
private static String KEY_APP_LINK = "app_link";
+ private static String KEY_BUBBLE = "bubble";
+ private static String[] LEGACY_NON_ADVANCED_KEYS = {KEY_BADGE, KEY_APP_LINK, KEY_BUBBLE};
private List<NotificationChannelGroup> mChannelGroupList;
@@ -65,21 +67,16 @@
final PreferenceScreen screen = getPreferenceScreen();
if (mShowLegacyChannelConfig && screen != null) {
// if showing legacy settings, pull advanced settings out of the advanced category
- Preference badge = findPreference(KEY_BADGE);
- Preference appLink = findPreference(KEY_APP_LINK);
PreferenceGroup advanced = (PreferenceGroup) findPreference(KEY_ADVANCED_CATEGORY);
removePreference(KEY_ADVANCED_CATEGORY);
- if (badge != null) {
- if (advanced != null) {
- advanced.removePreference(badge);
+ if (advanced != null) {
+ for (String key : LEGACY_NON_ADVANCED_KEYS) {
+ Preference pref = advanced.findPreference(key);
+ advanced.removePreference(pref);
+ if (pref != null) {
+ screen.addPreference(pref);
+ }
}
- screen.addPreference(badge);
- }
- if (appLink != null) {
- if (advanced != null) {
- advanced.removePreference(appLink);
- }
- screen.addPreference(appLink);
}
}
}
@@ -255,7 +252,7 @@
int childCount = groupGroup.getPreferenceCount();
for (int i = 0; i < childCount; i++) {
Preference pref = groupGroup.getPreference(i);
- if (pref instanceof MasterCheckBoxPreference) {
+ if (pref instanceof ChannelSummaryPreference) {
toRemove.add(pref);
}
}
diff --git a/src/com/android/settings/notification/BootSoundPreferenceController.java b/src/com/android/settings/notification/BootSoundPreferenceController.java
index a687163..2e7327d 100644
--- a/src/com/android/settings/notification/BootSoundPreferenceController.java
+++ b/src/com/android/settings/notification/BootSoundPreferenceController.java
@@ -43,7 +43,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- SwitchPreference preference = (SwitchPreference) screen.findPreference(KEY_BOOT_SOUNDS);
+ SwitchPreference preference = screen.findPreference(KEY_BOOT_SOUNDS);
preference.setChecked(SystemProperties.getBoolean(PROPERTY_BOOT_SOUNDS, true));
}
}
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index 1563bc4..1c024e3 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -92,13 +92,13 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mLockscreen = (RestrictedListPreference) screen.findPreference(mSettingKey);
+ mLockscreen = screen.findPreference(mSettingKey);
if (mLockscreen == null) {
Log.i(TAG, "Preference not found: " + mSettingKey);
return;
}
if (mProfileUserId != UserHandle.USER_NULL) {
- mLockscreenProfile = (RestrictedListPreference) screen.findPreference(mWorkSettingKey);
+ mLockscreenProfile = screen.findPreference(mWorkSettingKey);
mLockscreenProfile.setRequiresActiveUnlockedProfile(true);
mLockscreenProfile.setProfileUserId(mProfileUserId);
} else {
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 19aeb51..b9fabb6 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -309,7 +309,9 @@
return true;
}
});
- parent.addPreference(channelPref);
+ if (parent.findPreference(channelPref.getKey()) == null) {
+ parent.addPreference(channelPref);
+ }
return channelPref;
}
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 1c8c88e..1ec3c4f 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -118,7 +118,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+ mCategory = screen.findPreference(getPreferenceKey());
mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
mDivider = screen.findPreference(KEY_DIVIDER);
super.displayPreference(screen);
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index d0b098c..e53a560 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -67,7 +67,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (NotificationSoundPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
public void updateState(Preference preference) {
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java b/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
index 32f2aa6..fff9aaf 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
@@ -54,7 +54,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
- mPreference = (VolumeSeekBarPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setCallback(mVolumePreferenceCallback);
mPreference.setStream(getAudioStream());
mPreference.setMuteIcon(getMuteIcon());
diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java
index c708b37..e23d9ea 100644
--- a/src/com/android/settings/notification/WorkSoundPreferenceController.java
+++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java
@@ -100,7 +100,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mWorkPreferenceCategory = (PreferenceGroup) screen.findPreference(KEY_WORK_CATEGORY);
+ mWorkPreferenceCategory = screen.findPreference(KEY_WORK_CATEGORY);
}
@Override
diff --git a/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java b/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
index e5ca754..807d944 100644
--- a/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
+++ b/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- LayoutPreference pref = (LayoutPreference) screen.findPreference(KEY);
+ LayoutPreference pref = screen.findPreference(KEY);
mSwitchBar = pref.findViewById(R.id.switch_bar);
if (mSwitchBar != null) {
diff --git a/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java b/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
index 7da90c8..499bfbc 100644
--- a/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+ mPreferenceCategory = screen.findPreference(getPreferenceKey());
mPreferenceCategory.setPersistent(false);
}
diff --git a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
index 9872188..cec97f5 100644
--- a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ListPreference) screen.findPreference(KEY);
+ mPreference = screen.findPreference(KEY);
}
@Override
diff --git a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
index cfda367..752edf2 100644
--- a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ListPreference) screen.findPreference(KEY);
+ mPreference = screen.findPreference(KEY);
}
@Override
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
index 07e3429..14285d6 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
@@ -49,7 +49,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnRadioButtonClickListener(this);
}
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
index 6948669..837f999 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
@@ -51,7 +51,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnGearClickListener(p -> {
launchCustomSettings();
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
index 7f729c7..4a58c62 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
@@ -49,7 +49,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnRadioButtonClickListener(this);
}
diff --git a/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java b/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
index e41d55f..527803df 100644
--- a/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
@@ -39,7 +39,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnGearClickListener(p -> {
setCustomPolicy();
diff --git a/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java b/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
index da40e6c..b4036fa 100644
--- a/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
@@ -40,7 +40,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnRadioButtonClickListener(p -> {
mRule.setZenPolicy(null);
diff --git a/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java b/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
index 1c6874e..7b7eae2 100644
--- a/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
@@ -41,7 +41,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnRadioButtonClickListener(p -> {
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_ZEN_SOUND_ONLY,
diff --git a/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
index 3cdd86a..2314c5a 100644
--- a/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
@@ -41,7 +41,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
mPreference.setOnGearClickListener(p -> {
launchCustomSettings();
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index d20b75a..4e4fc0c 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -16,6 +16,7 @@
package com.android.settings.panel;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -64,4 +65,9 @@
public Intent getSeeMoreIntent() {
return new Intent(Settings.ACTION_WIRELESS_SETTINGS);
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_INTERNET_CONNECTIVITY;
+ }
}
diff --git a/src/com/android/settings/panel/MediaOutputPanel.java b/src/com/android/settings/panel/MediaOutputPanel.java
index f7639d9..c42906d 100644
--- a/src/com/android/settings/panel/MediaOutputPanel.java
+++ b/src/com/android/settings/panel/MediaOutputPanel.java
@@ -19,6 +19,7 @@
import static com.android.settings.media.MediaOutputSlice.MEDIA_PACKAGE_NAME;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -71,4 +72,9 @@
public Intent getSeeMoreIntent() {
return null;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_MEDIA_OUTPUT;
+ }
}
diff --git a/src/com/android/settings/panel/NfcPanel.java b/src/com/android/settings/panel/NfcPanel.java
index 70452a3..8fa41d9 100644
--- a/src/com/android/settings/panel/NfcPanel.java
+++ b/src/com/android/settings/panel/NfcPanel.java
@@ -50,4 +50,9 @@
intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
return intent;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_NFC;
+ }
}
diff --git a/src/com/android/settings/panel/PanelContent.java b/src/com/android/settings/panel/PanelContent.java
index bd84c2f..496bac3 100644
--- a/src/com/android/settings/panel/PanelContent.java
+++ b/src/com/android/settings/panel/PanelContent.java
@@ -19,12 +19,14 @@
import android.content.Intent;
import android.net.Uri;
+import com.android.settingslib.core.instrumentation.Instrumentable;
+
import java.util.List;
/**
* Represents the data class needed to create a Settings Panel. See {@link PanelFragment}.
*/
-public interface PanelContent {
+public interface PanelContent extends Instrumentable {
/**
* @return a string for the title of the Panel.
diff --git a/src/com/android/settings/panel/PanelFeatureProvider.java b/src/com/android/settings/panel/PanelFeatureProvider.java
index 5af5ac8..85e098d 100644
--- a/src/com/android/settings/panel/PanelFeatureProvider.java
+++ b/src/com/android/settings/panel/PanelFeatureProvider.java
@@ -21,7 +21,8 @@
public interface PanelFeatureProvider {
/**
- * Returns {@link PanelContent} as specified by the {@code panelType} and {@code packageName}.
+ * Returns {@link PanelContent} as specified by the {@param panelType}, and
+ * {@param mediaPackageName}.
*/
- PanelContent getPanel(Context context, String panelType, String packageName);
+ PanelContent getPanel(Context context, String panelType, String mediaPackageName);
}
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index c3d611d..6b096a1 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -24,7 +24,7 @@
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
@Override
- public PanelContent getPanel(Context context, String panelType, String packageName) {
+ public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
switch (panelType) {
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
@@ -33,7 +33,7 @@
case Settings.Panel.ACTION_NFC:
return NfcPanel.create(context);
case ACTION_MEDIA_OUTPUT:
- return MediaOutputPanel.create(context, packageName);
+ return MediaOutputPanel.create(context, mediaPackageName);
}
throw new IllegalStateException("No matching panel for: " + panelType);
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index db0bf0e..a222d36 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -16,9 +16,9 @@
package com.android.settings.panel;
-import android.content.Intent;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -35,6 +35,8 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class PanelFragment extends Fragment {
@@ -45,15 +47,15 @@
private Button mDoneButton;
private RecyclerView mPanelSlices;
+ private PanelContent mPanel;
+ private final MetricsFeatureProvider mMetricsProvider;
+
@VisibleForTesting
PanelSlicesAdapter mAdapter;
- private View.OnClickListener mDoneButtonListener = (v) -> {
- Log.d(TAG, "Closing dialog");
- getActivity().finish();
- };
-
public PanelFragment() {
+ final Context context = getActivity();
+ mMetricsProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Nullable
@@ -69,38 +71,70 @@
mTitleView = view.findViewById(R.id.panel_title);
final Bundle arguments = getArguments();
- final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
- final String packageName =
- arguments.getString(SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME);
+ final String panelType =
+ arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
+ final String callingPackageName =
+ arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
+ final String mediaPackageName =
+ arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
- final PanelContent panel = FeatureFactory.getFactory(activity)
+ // TODO (b/124399577) transform interface to take a context and bundle.
+ mPanel = FeatureFactory.getFactory(activity)
.getPanelFeatureProvider()
- .getPanel(activity, panelType, packageName);
+ .getPanel(activity, panelType, mediaPackageName);
- mAdapter = new PanelSlicesAdapter(this, panel.getSlices());
+ // Log panel opened.
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_VISIBLE /* opened panel - Action */,
+ mPanel.getMetricsCategory(),
+ callingPackageName,
+ 0 /* value */);
+
+ mAdapter = new PanelSlicesAdapter(this, mPanel);
mPanelSlices.setHasFixedSize(true);
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
mPanelSlices.setAdapter(mAdapter);
- mTitleView.setText(panel.getTitle());
+ mTitleView.setText(mPanel.getTitle());
- mSeeMoreButton.setOnClickListener(getSeeMoreListener(panel.getSeeMoreIntent()));
- mDoneButton.setOnClickListener(mDoneButtonListener);
+ mSeeMoreButton.setOnClickListener(getSeeMoreListener());
+ mDoneButton.setOnClickListener(getCloseListener());
//If getSeeMoreIntent() is null, hide the mSeeMoreButton.
- if (panel.getSeeMoreIntent() == null) {
+ if (mPanel.getSeeMoreIntent() == null) {
mSeeMoreButton.setVisibility(View.GONE);
}
return view;
}
- private View.OnClickListener getSeeMoreListener(final Intent intent) {
+ @VisibleForTesting
+ View.OnClickListener getSeeMoreListener() {
return (v) -> {
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_HIDE ,
+ mPanel.getMetricsCategory(),
+ PanelClosedKeys.KEY_SEE_MORE,
+ 0 /* value */);
final FragmentActivity activity = getActivity();
- activity.startActivity(intent);
+ activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
activity.finish();
};
}
+
+ @VisibleForTesting
+ View.OnClickListener getCloseListener() {
+ return (v) -> {
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_HIDE,
+ mPanel.getMetricsCategory(),
+ PanelClosedKeys.KEY_DONE,
+ 0 /* value */);
+ getActivity().finish();
+ };
+ }
}
diff --git a/src/com/android/settings/panel/PanelLoggingContract.java b/src/com/android/settings/panel/PanelLoggingContract.java
new file mode 100644
index 0000000..e149186
--- /dev/null
+++ b/src/com/android/settings/panel/PanelLoggingContract.java
@@ -0,0 +1,46 @@
+/*
+ * 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.panel;
+
+/**
+ * Simple contract class to track keys in Panel logging.
+ *
+ * <p>
+ * Constants should only be removed if underlying panel, or use case is removed.
+ * </p>
+ */
+public class PanelLoggingContract {
+
+ /**
+ * Keys tracking different ways users exit Panels.
+ */
+ interface PanelClosedKeys {
+ /**
+ * The user clicked the See More button linking deeper into Settings.
+ */
+ String KEY_SEE_MORE = "see_more";
+
+ /**
+ * The user clicked the Done button, closing the Panel.
+ */
+ String KEY_DONE = "done";
+
+ /**
+ * The user clicked outside the dialog, closing the Panel.
+ */
+ String KEY_CLICKED_OUT = "clicked_out";
+ }
+}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index f688512..c1cb049 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -16,6 +16,7 @@
package com.android.settings.panel;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
@@ -31,8 +32,8 @@
import androidx.slice.widget.SliceView;
import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -43,10 +44,12 @@
private final List<Uri> mSliceUris;
private final PanelFragment mPanelFragment;
+ private final PanelContent mPanelContent;
- public PanelSlicesAdapter(PanelFragment fragment, List<Uri> sliceUris) {
+ public PanelSlicesAdapter(PanelFragment fragment, PanelContent panel) {
mPanelFragment = fragment;
- mSliceUris = new ArrayList<>(sliceUris);
+ mSliceUris = panel.getSlices();
+ mPanelContent = panel;
}
@NonNull
@@ -56,7 +59,7 @@
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.panel_slice_row, viewGroup, false);
- return new SliceRowViewHolder(view);
+ return new SliceRowViewHolder(view, mPanelContent);
}
@Override
@@ -79,22 +82,38 @@
*/
public static class SliceRowViewHolder extends RecyclerView.ViewHolder {
+ private final PanelContent mPanelContent;
+
@VisibleForTesting
LiveData<Slice> sliceLiveData;
@VisibleForTesting
final SliceView sliceView;
- public SliceRowViewHolder(View view) {
+ public SliceRowViewHolder(View view, PanelContent panelContent) {
super(view);
sliceView = view.findViewById(R.id.slice_view);
sliceView.setMode(SliceView.MODE_LARGE);
+ mPanelContent = panelContent;
}
public void onBind(PanelFragment fragment, Uri sliceUri) {
final Context context = sliceView.getContext();
sliceLiveData = SliceLiveData.fromUri(context, sliceUri);
sliceLiveData.observe(fragment.getViewLifecycleOwner(), sliceView);
+
+ // Log Panel interaction
+ sliceView.setOnSliceActionListener(
+ ((eventInfo, sliceItem) -> {
+ FeatureFactory.getFactory(context)
+ .getMetricsFeatureProvider()
+ .action(0 /* attribution */,
+ SettingsEnums.ACTION_PANEL_INTERACTION,
+ mPanelContent.getMetricsCategory(),
+ sliceUri.toString() /* log key */,
+ eventInfo.actionType /* value */);
+ })
+ );
}
}
}
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 4cf535e..3819c80 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -19,11 +19,13 @@
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
+import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
+import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
@@ -34,6 +36,8 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
/**
* Dialog Activity to host Settings Slices.
@@ -49,7 +53,16 @@
* Key specifying which Panel the app is requesting.
*/
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
- public static final String KEY_PANEL_PACKAGE_NAME = "PANEL_PACKAGE_NAME";
+
+ /**
+ * Key specifying the package which requested the Panel.
+ */
+ public static final String KEY_CALLING_PACKAGE_NAME = "PANEL_CALLING_PACKAGE_NAME";
+
+ /**
+ * Key specifying the package name for which the
+ */
+ public static final String KEY_MEDIA_PACKAGE_NAME = "PANEL_MEDIA_PACKAGE_NAME";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -62,12 +75,12 @@
return;
}
- final String packageName =
+ final String mediaPackageName =
callingIntent.getStringExtra(EXTRA_PACKAGE_NAME);
if (TextUtils.equals(ACTION_MEDIA_OUTPUT, callingIntent.getAction())
- && TextUtils.isEmpty(packageName)) {
- Log.e(TAG, "Null package name, closing Panel Activity");
+ && TextUtils.isEmpty(mediaPackageName)) {
+ Log.e(TAG, "Missing EXTRA_PACKAGE_NAME, closing Panel Activity");
finish();
return;
}
@@ -81,7 +94,8 @@
WindowManager.LayoutParams.WRAP_CONTENT);
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
- mBundle.putString(KEY_PANEL_PACKAGE_NAME, packageName);
+ mBundle.putString(KEY_CALLING_PACKAGE_NAME, getCallingPackage());
+ mBundle.putString(KEY_MEDIA_PACKAGE_NAME, mediaPackageName);
final PanelFragment panelFragment = new PanelFragment();
panelFragment.setArguments(mBundle);
@@ -92,4 +106,21 @@
fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
}
}
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+ final PanelContent panelContent = FeatureFactory.getFactory(this)
+ .getPanelFeatureProvider()
+ .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
+ FeatureFactory.getFactory(this)
+ .getMetricsFeatureProvider()
+ .action(0 /* attribution */,
+ SettingsEnums.PAGE_HIDE,
+ panelContent.getMetricsCategory(),
+ PanelClosedKeys.KEY_CLICKED_OUT,
+ 0 /* value */);
+ }
+ return super.onTouchEvent(event);
+ }
}
diff --git a/src/com/android/settings/panel/VolumePanel.java b/src/com/android/settings/panel/VolumePanel.java
index 352fed5..20c2272 100644
--- a/src/com/android/settings/panel/VolumePanel.java
+++ b/src/com/android/settings/panel/VolumePanel.java
@@ -21,6 +21,7 @@
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -62,4 +63,9 @@
public Intent getSeeMoreIntent() {
return new Intent(Settings.ACTION_SOUND_SETTINGS);
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_VOLUME;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 236e3d9..ec1e835 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -184,7 +184,7 @@
} else {
bpBundle = new Bundle();
bpBundle.putString(BiometricPrompt.KEY_TITLE, mTitle);
- bpBundle.putString(BiometricPrompt.KEY_SUBTITLE, mDetails);
+ bpBundle.putString(BiometricPrompt.KEY_DESCRIPTION, mDetails);
}
boolean launchedBiometric = false;
diff --git a/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
new file mode 100644
index 0000000..bcf8f47
--- /dev/null
+++ b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
@@ -0,0 +1,59 @@
+/*
+ * 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.privacy;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.view.accessibility.AccessibilityManager;
+
+import androidx.annotation.NonNull;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+
+public class AccessibilityUsagePreferenceController extends BasePreferenceController {
+
+ private final @NonNull List<AccessibilityServiceInfo> mEnabledServiceInfos;
+
+ public AccessibilityUsagePreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+
+ final AccessibilityManager accessibilityManager = context.getSystemService(
+ AccessibilityManager.class);
+ mEnabledServiceInfos = accessibilityManager.getEnabledAccessibilityServiceList(
+ AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return (mEnabledServiceInfos.isEmpty() || !Boolean.parseBoolean(
+ DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
+ DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED)))
+ ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return mContext.getResources().getQuantityString(R.plurals.accessibility_usage_summary,
+ mEnabledServiceInfos.size(), mEnabledServiceInfos.size());
+ }
+}
diff --git a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
index 8b9b595..2c6368e 100644
--- a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
+++ b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
@@ -31,28 +31,29 @@
import android.view.View;
import androidx.annotation.NonNull;
-import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.Utils;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.widget.BarChartInfo;
import com.android.settingslib.widget.BarChartPreference;
import com.android.settingslib.widget.BarViewInfo;
-import com.android.settingslib.Utils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import java.util.concurrent.Executors;
public class PermissionBarChartPreferenceController extends BasePreferenceController implements
- PermissionControllerManager.OnPermissionUsageResultCallback {
+ PermissionControllerManager.OnPermissionUsageResultCallback, LifecycleObserver, OnStart {
private static final String TAG = "BarChartPreferenceCtl";
private PackageManager mPackageManager;
+ private PrivacyDashboardFragment mParent;
private BarChartPreference mBarChartPreference;
private List<RuntimePermissionUsageInfo> mOldUsageInfos;
@@ -62,6 +63,10 @@
mPackageManager = context.getPackageManager();
}
+ public void setFragment(PrivacyDashboardFragment fragment) {
+ mParent = fragment;
+ }
+
@Override
public int getAvailabilityStatus() {
return Boolean.parseBoolean(
@@ -73,7 +78,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mBarChartPreference = (BarChartPreference) screen.findPreference(getPreferenceKey());
+ mBarChartPreference = screen.findPreference(getPreferenceKey());
final BarChartInfo info = new BarChartInfo.Builder()
.setTitle(R.string.permission_bar_chart_title)
@@ -90,7 +95,13 @@
}
@Override
- public void updateState(Preference preference) {
+ public void onStart() {
+ if (!isAvailable()) {
+ return;
+ }
+
+ mBarChartPreference.updateLoadingState(true /* isLoading */);
+ mParent.setLoadingEnabled(true /* enabled */);
retrievePermissionUsageData();
}
@@ -104,6 +115,9 @@
mBarChartPreference.setBarViewInfos(createBarViews(usageInfos));
mOldUsageInfos = usageInfos;
}
+
+ mBarChartPreference.updateLoadingState(false /* isLoading */);
+ mParent.setLoadingEnabled(false /* enabled */);
}
private void retrievePermissionUsageData() {
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index 8f1d4c7..be6701e 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -16,9 +16,16 @@
package com.android.settings.privacy;
+import android.app.ActionBar;
+import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import android.provider.SearchIndexableResource;
+import android.util.Log;
+import android.view.View;
+
+import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -27,19 +34,25 @@
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.ActionBarShadowController;
import java.util.ArrayList;
import java.util.List;
@SearchIndexable
public class PrivacyDashboardFragment extends DashboardFragment {
- private static final String TAG = "PrivacyDashboardFragment";
+ private static final String TAG = "PrivacyDashboardFrag";
private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "privacy_lock_screen_notifications";
private static final String KEY_WORK_PROFILE_CATEGORY =
"privacy_work_profile_notifications_category";
private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
"privacy_lock_screen_work_profile_notifications";
+ @VisibleForTesting
+ View mProgressHeader;
+ @VisibleForTesting
+ View mProgressAnimation;
+
@Override
public int getMetricsCategory() {
return SettingsEnums.TOP_LEVEL_PRIVACY;
@@ -65,6 +78,52 @@
return buildPreferenceControllers(context, getSettingsLifecycle());
}
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ use(PermissionBarChartPreferenceController.class).setFragment(this /* fragment */);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ styleActionBar();
+ initLoadingBar();
+ }
+
+ @VisibleForTesting
+ void styleActionBar() {
+ final Activity activity = getActivity();
+ final ActionBar actionBar = activity.getActionBar();
+ final Lifecycle lifecycle = getSettingsLifecycle();
+ final View scrollView = getListView();
+
+ if (actionBar == null) {
+ Log.w(TAG, "No actionbar, cannot style actionbar.");
+ return;
+ }
+
+ actionBar.setElevation(0);
+ if (lifecycle != null && scrollView != null) {
+ ActionBarShadowController.attachToView(activity, lifecycle, scrollView);
+ }
+ }
+
+ @VisibleForTesting
+ void initLoadingBar() {
+ mProgressHeader = setPinnedHeaderView(R.layout.progress_header);
+ mProgressAnimation = mProgressHeader.findViewById(R.id.progress_bar_animation);
+ setLoadingEnabled(false);
+ }
+
+ @VisibleForTesting
+ void setLoadingEnabled(boolean enabled) {
+ if (mProgressHeader != null && mProgressAnimation != null) {
+ mProgressHeader.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+ mProgressAnimation.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
+
private static List<AbstractPreferenceController> buildPreferenceControllers(
Context context, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
diff --git a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
index a58c528..650b1e3 100644
--- a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
@@ -79,7 +79,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index 1aebe24..978986c 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -77,7 +77,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mUnifyProfile = (RestrictedSwitchPreference) screen.findPreference(KEY_UNIFICATION);
+ mUnifyProfile = screen.findPreference(KEY_UNIFICATION);
}
public LockUnificationPreferenceController(Context context, SecuritySettings host) {
diff --git a/src/com/android/settings/security/OwnerInfoPreferenceController.java b/src/com/android/settings/security/OwnerInfoPreferenceController.java
index f7a20ba..5276722 100644
--- a/src/com/android/settings/security/OwnerInfoPreferenceController.java
+++ b/src/com/android/settings/security/OwnerInfoPreferenceController.java
@@ -61,7 +61,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
- mOwnerInfoPref = (RestrictedPreference) screen.findPreference(KEY_OWNER_INFO);
+ mOwnerInfoPref = screen.findPreference(KEY_OWNER_INFO);
}
@Override
diff --git a/src/com/android/settings/security/ResetCredentialsPreferenceController.java b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
index ee09bca..0700b46 100644
--- a/src/com/android/settings/security/ResetCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
@@ -52,7 +52,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 6f5d7eb..eb50b7c 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -91,7 +91,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mSecurityCategory = (PreferenceCategory) screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
+ mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
updateTrustAgents();
}
diff --git a/src/com/android/settings/slices/CustomSliceable.java b/src/com/android/settings/slices/CustomSliceable.java
index 220cdc8..d32e266 100644
--- a/src/com/android/settings/slices/CustomSliceable.java
+++ b/src/com/android/settings/slices/CustomSliceable.java
@@ -52,7 +52,7 @@
* <p>
* If you implement this interface, you should add your Slice to {@link CustomSliceManager}.
*/
-public interface CustomSliceable {
+public interface CustomSliceable extends Sliceable {
/**
* @return an complete instance of the {@link Slice}.
@@ -79,17 +79,6 @@
Intent getIntent();
/**
- * Settings Slices which can represent components that are updatable by the framework should
- * listen to changes matched to the {@link IntentFilter} returned here.
- *
- * @return an {@link IntentFilter} for updates related to the {@link Slice} returned by
- * {@link #getSlice()}.
- */
- default IntentFilter getIntentFilter() {
- return null;
- }
-
- /**
* Settings Slices which require background work, such as updating lists should implement a
* {@link SliceBackgroundWorker} and return it here. An example of background work is updating
* a list of Wifi networks available in the area.
@@ -116,12 +105,16 @@
PendingIntent.FLAG_CANCEL_CURRENT);
}
+ @Override
+ default boolean isSliceable() {
+ return true;
+ }
+
/**
* Build an instance of a {@link CustomSliceable} which has a {@link Context}-only constructor.
*/
static CustomSliceable createInstance(Context context, Class<CustomSliceable> sliceableClass) {
try {
- //final Class<CustomSliceable> clazz = Class.forName(sliceableClassName);
final Constructor<CustomSliceable> sliceable =
sliceableClass.getConstructor(Context.class);
final Object[] params = new Object[]{context};
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index d1648e0..5c662e5 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -129,8 +129,6 @@
@VisibleForTesting
Map<Uri, SliceData> mSliceDataCache;
- final Set<Uri> mRegisteredUris = new ArraySet<>();
-
final Map<Uri, SliceBackgroundWorker> mPinnedWorkers = new ArrayMap<>();
public SettingsSliceProvider() {
@@ -173,14 +171,8 @@
@Override
public void onSliceUnpinned(Uri sliceUri) {
- if (mRegisteredUris.contains(sliceUri)) {
- Log.d(TAG, "Unregistering uri broadcast relay: " + sliceUri);
- SliceBroadcastRelay.unregisterReceivers(getContext(), sliceUri);
- mRegisteredUris.remove(sliceUri);
- }
- ThreadUtils.postOnMainThread(() -> {
- stopBackgroundWorker(sliceUri);
- });
+ SliceBroadcastRelay.unregisterReceivers(getContext(), sliceUri);
+ ThreadUtils.postOnMainThread(() -> stopBackgroundWorker(sliceUri));
mSliceDataCache.remove(sliceUri);
}
@@ -419,9 +411,7 @@
@VisibleForTesting
void loadSliceInBackground(Uri uri) {
- ThreadUtils.postOnBackgroundThread(() -> {
- loadSlice(uri);
- });
+ ThreadUtils.postOnBackgroundThread(() -> loadSlice(uri));
}
/**
@@ -462,8 +452,6 @@
* {@param intentFilter} happen.
*/
void registerIntentToUri(IntentFilter intentFilter, Uri sliceUri) {
- Log.d(TAG, "Registering Uri for broadcast relay: " + sliceUri);
- mRegisteredUris.add(sliceUri);
SliceBroadcastRelay.registerReceiver(getContext(), sliceUri, SliceRelayReceiver.class,
intentFilter);
}
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index 8b4bb74..8f85431 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -449,14 +449,14 @@
int iconResource = data.getIconResource();
if (iconResource == 0) {
- iconResource = R.drawable.ic_settings;
+ iconResource = R.drawable.ic_settings_accent;
}
try {
return IconCompat.createWithResource(context, iconResource);
} catch (Exception e) {
Log.w(TAG, "Falling back to settings icon because there is an error getting slice icon "
+ data.getUri(), e);
- return IconCompat.createWithResource(context, R.drawable.ic_settings);
+ return IconCompat.createWithResource(context, R.drawable.ic_settings_accent);
}
}
}
diff --git a/src/com/android/settings/slices/Sliceable.java b/src/com/android/settings/slices/Sliceable.java
new file mode 100644
index 0000000..ddec2e1
--- /dev/null
+++ b/src/com/android/settings/slices/Sliceable.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.slices;
+
+import android.content.IntentFilter;
+
+/**
+ * A collection of API making a PreferenceController "sliceable"
+ */
+public interface Sliceable {
+ /**
+ * @return an {@link IntentFilter} that includes all broadcasts which can affect the state of
+ * this Setting.
+ */
+ default IntentFilter getIntentFilter() {
+ return null;
+ }
+
+ /**
+ * Determines if the controller should be used as a Slice.
+ * <p>
+ * Important criteria for a Slice are:
+ * - Must be secure
+ * - Must not be a privacy leak
+ * - Must be understandable as a stand-alone Setting.
+ * <p>
+ * This does not guarantee the setting is available.
+ *
+ * @return {@code true} if the controller should be used externally as a Slice.
+ */
+ default boolean isSliceable() {
+ return false;
+ }
+
+ /**
+ * @return {@code true} if the setting update asynchronously.
+ * <p>
+ * For example, a Wifi controller would return true, because it needs to update the radio
+ * and wait for it to turn on.
+ */
+ default boolean hasAsyncUpdate() {
+ return false;
+ }
+}
diff --git a/src/com/android/settings/widget/AdaptiveHomepageIcon.java b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
index bec5d8d..bc7aaa7 100644
--- a/src/com/android/settings/widget/AdaptiveHomepageIcon.java
+++ b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
@@ -72,11 +72,13 @@
// If found anything, use it.
if (bgColor != 0) {
setBackgroundColor(bgColor);
+ return;
}
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
}
+ setBackgroundColor(context.getColor(R.color.homepage_generic_icon_background));
}
public void setBackgroundColor(int color) {
diff --git a/src/com/android/settings/widget/AddPreference.java b/src/com/android/settings/widget/AddPreference.java
index ce36ab3..2183fd4 100644
--- a/src/com/android/settings/widget/AddPreference.java
+++ b/src/com/android/settings/widget/AddPreference.java
@@ -34,6 +34,7 @@
private OnAddClickListener mListener;
private View mWidgetFrame;
+ private View mAddWidget;
public AddPreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -53,6 +54,12 @@
}
}
+ public void setAddWidgetEnabled(boolean enabled) {
+ if (mAddWidget != null) {
+ mAddWidget.setEnabled(enabled);
+ }
+ }
+
@Override
protected int getSecondTargetResId() {
return R.layout.preference_widget_add;
@@ -67,9 +74,9 @@
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
mWidgetFrame = holder.findViewById(android.R.id.widget_frame);
- final View addWidget = holder.findViewById(getAddWidgetResId());
- addWidget.setEnabled(true);
- addWidget.setOnClickListener(this);
+ mAddWidget = holder.findViewById(getAddWidgetResId());
+ mAddWidget.setEnabled(true);
+ mAddWidget.setOnClickListener(this);
}
@Override
diff --git a/src/com/android/settings/widget/VideoPreferenceController.java b/src/com/android/settings/widget/VideoPreferenceController.java
index a7bb754..78a837c 100644
--- a/src/com/android/settings/widget/VideoPreferenceController.java
+++ b/src/com/android/settings/widget/VideoPreferenceController.java
@@ -43,7 +43,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mVideoPreference = (VideoPreference) screen.findPreference(getPreferenceKey());
+ mVideoPreference = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/wifi/AddNetworkFragment.java b/src/com/android/settings/wifi/AddNetworkFragment.java
index e4d0fb1..656f8ef 100644
--- a/src/com/android/settings/wifi/AddNetworkFragment.java
+++ b/src/com/android/settings/wifi/AddNetworkFragment.java
@@ -40,6 +40,7 @@
final static int SUBMIT_BUTTON_ID = android.R.id.button1;
@VisibleForTesting
final static int CANCEL_BUTTON_ID = android.R.id.button2;
+ final static int SCANNER_BUTTON_ID = R.id.ssid_scanner_button;
private WifiConfigController mUIController;
private Button mSubmitBtn;
@@ -62,22 +63,12 @@
mSubmitBtn = rootView.findViewById(SUBMIT_BUTTON_ID);
mCancelBtn = rootView.findViewById(CANCEL_BUTTON_ID);
+ final ImageButton scannerButton = rootView.findViewById(SCANNER_BUTTON_ID);
mSubmitBtn.setOnClickListener(this);
mCancelBtn.setOnClickListener(this);
+ scannerButton.setOnClickListener(this);
mUIController = new WifiConfigController(this, rootView, null, getMode());
- if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
- final ImageButton scannerButton = rootView.findViewById(R.id.ssid_scanner_button);
- if (scannerButton != null) {
- scannerButton.setVisibility(View.VISIBLE);
- scannerButton.setOnClickListener((View v) -> {
- // Launch QR code scanner to join a network.
- getContext().startActivity(
- WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
- });
- }
- }
-
return rootView;
}
@@ -96,6 +87,11 @@
case CANCEL_BUTTON_ID:
handleCancelAction();
break;
+ case SCANNER_BUTTON_ID:
+ // Launch QR code scanner to join a network.
+ getContext().startActivity(
+ WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
+ break;
}
}
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index d1df7f0..ba29e3a 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -37,6 +37,7 @@
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
+import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -69,8 +70,12 @@
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
- /** Spec defines there should be 5 wifi ap on the list at most. */
+ /**
+ * Spec defines there should be 5 wifi ap on the list at most or just show all if {@code
+ * mShowLimitedItem} is false.
+ */
private static final int MAX_NUMBER_LIST_ITEM = 5;
+ private boolean mShowLimitedItem = true;
/** Delayed time to stop scanning wifi. */
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
@@ -110,13 +115,29 @@
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCustomTitle(customTitle)
.setAdapter(mDialogAdapter, this)
- .setPositiveButton(R.string.cancel, (dialog, which) -> getActivity().finish());
+ .setPositiveButton(R.string.cancel, (dialog, which) -> getActivity().finish())
+ // Do nothings, will replace the onClickListener to avoid auto closing dialog.
+ .setNeutralButton(R.string.network_connection_request_dialog_showall,
+ null /* OnClickListener */);
// Clicking list item is to connect wifi ap.
final AlertDialog dialog = builder.create();
dialog.getListView()
.setOnItemClickListener(
(parent, view, position, id) -> this.onClick(dialog, position));
+
+ dialog.setOnShowListener((dialogInterface) -> {
+ // Replace NeutralButton onClickListener to avoid closing dialog
+ final Button neutralBtn = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
+ neutralBtn.setVisibility(View.GONE);
+ neutralBtn.setOnClickListener(v -> {
+ mShowLimitedItem = false;
+ renewAccessPointList(null /* List<ScanResult> */);
+ notifyAdapterRefresh();
+ neutralBtn.setVisibility(View.GONE);
+ });
+ });
+
return dialog;
}
@@ -202,6 +223,18 @@
}
}
+ private void showNeutralButton() {
+ final AlertDialog alertDialog = (AlertDialog) getDialog();
+ if (alertDialog == null) {
+ return;
+ }
+
+ final Button neutralBtn = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
+ if (neutralBtn != null) {
+ neutralBtn.setVisibility(View.VISIBLE);
+ }
+ }
+
@Override
public void onResume() {
super.onResume();
@@ -394,6 +427,10 @@
mAccessPointKeys.add(key);
}
}
+
+ if (mShowLimitedItem && (mAccessPointKeys.size() > MAX_NUMBER_LIST_ITEM)) {
+ showNeutralButton();
+ }
}
/**
@@ -414,7 +451,7 @@
count++;
// Limits how many count of items could show.
- if (count >= MAX_NUMBER_LIST_ITEM) {
+ if (mShowLimitedItem && count >= MAX_NUMBER_LIST_ITEM) {
break;
}
}
diff --git a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
index 33eaceb..36c4455 100644
--- a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
@@ -99,7 +99,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(mPreferenceGroupKey);
+ mPreferenceGroup = screen.findPreference(mPreferenceGroupKey);
mPrefContext = screen.getContext();
update();
}
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 9420c4c..7d5f3b3 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -80,20 +80,17 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, /* root */ null);
- if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
- final ImageButton scannerButton = mView.findViewById(R.id.password_scanner_button);
- if (scannerButton != null) {
- scannerButton.setVisibility(View.VISIBLE);
- scannerButton.setOnClickListener((View v) -> {
- String ssid = null;
- if (mAccessPoint != null) {
- ssid = mAccessPoint.getSsidStr();
- }
- // Launch QR code scanner to join a network.
- getContext().startActivity(
- WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid));
- });
- }
+ final ImageButton scannerButton = mView.findViewById(R.id.password_scanner_button);
+ if (scannerButton != null) {
+ scannerButton.setOnClickListener((View v) -> {
+ String ssid = null;
+ if (mAccessPoint != null) {
+ ssid = mAccessPoint.getSsidStr();
+ }
+ // Launch QR code scanner to join a network.
+ getContext().startActivity(
+ WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid));
+ });
}
setView(mView);
mController = new WifiConfigController(this, mView, mAccessPoint, mMode);
diff --git a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
index 692608c..6a4774b 100644
--- a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
@@ -53,7 +53,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mWifiPreference = (MasterSwitchPreference) screen.findPreference(KEY_TOGGLE_WIFI);
+ mWifiPreference = screen.findPreference(KEY_TOGGLE_WIFI);
}
@Override
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 881e3d2..4ca9f86 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -203,7 +203,7 @@
super.onViewCreated(view, savedInstanceState);
final Activity activity = getActivity();
if (activity != null) {
- mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+ mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
.findViewById(R.id.progress_bar_animation);
setProgressBarVisible(false);
}
@@ -239,14 +239,12 @@
mAddPreference = new ButtonPreference(prefContext);
mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setTitle(R.string.wifi_add_network);
- if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
- mAddPreference.setButtonIcon(R.drawable.ic_scan_24dp);
- mAddPreference.setButtonOnClickListener((View v) -> {
- // Launch QR code scanner to join a network.
- getContext().startActivity(
- WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
- });
- }
+ mAddPreference.setButtonIcon(R.drawable.ic_scan_24dp);
+ mAddPreference.setButtonOnClickListener((View v) -> {
+ // Launch QR code scanner to join a network.
+ getContext().startActivity(
+ WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
+ });
mStatusMessagePreference = (LinkablePreference) findPreference(PREF_KEY_STATUS_MESSAGE);
mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 435f8f1..15bffd9 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -62,7 +62,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = (SwitchPreference) screen.findPreference(KEY_ENABLE_WIFI_WAKEUP);
+ mPreference = screen.findPreference(KEY_ENABLE_WIFI_WAKEUP);
updateState(mPreference);
}
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 40cc0dc..9ed2035 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -29,6 +29,7 @@
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -44,7 +45,9 @@
import androidx.preference.PreferenceScreen;
import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
import com.android.ims.ImsManager;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.Phone;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -152,6 +155,19 @@
}
};
+ private final ProvisioningManager.Callback mProvisioningCallback =
+ new ProvisioningManager.Callback() {
+ @Override
+ public void onProvisioningIntChanged(int item, int value) {
+ if (item == ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED
+ || item == ImsConfig.ConfigConstants.VLT_SETTING_ENABLED) {
+ // The provisioning policy might have changed. Update the body to make sure
+ // this change takes effect if needed.
+ updateBody();
+ }
+ }
+ };
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -221,6 +237,11 @@
return 0;
}
+ @VisibleForTesting
+ ImsManager getImsManager() {
+ return ImsManager.getInstance(getActivity(), SubscriptionManager.getPhoneId(mSubId));
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -236,8 +257,7 @@
FRAGMENT_BUNDLE_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
}
- mImsManager = ImsManager.getInstance(
- getActivity(), SubscriptionManager.getPhoneId(mSubId));
+ mImsManager = getImsManager();
mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
.createForSubscriptionId(mSubId);
@@ -277,6 +297,13 @@
}
private void updateBody() {
+ if (!mImsManager.isWfcProvisionedOnDevice()) {
+ // This screen is not allowed to be shown due to provisioning policy and should
+ // therefore be closed.
+ finish();
+ return;
+ }
+
CarrierConfigManager configManager = (CarrierConfigManager)
getSystemService(Context.CARRIER_CONFIG_SERVICE);
boolean isWifiOnlySupported = true;
@@ -336,6 +363,14 @@
if (intent.getBooleanExtra(Phone.EXTRA_KEY_ALERT_SHOW, false)) {
showAlert(intent);
}
+
+ // Register callback for provisioning changes.
+ try {
+ mImsManager.getConfigInterface().addConfigCallback(mProvisioningCallback);
+ } catch (ImsException e) {
+ Log.w(TAG, "onResume: Unable to register callback for provisioning changes.");
+ }
+
}
@Override
@@ -354,6 +389,15 @@
}
context.unregisterReceiver(mIntentReceiver);
+
+ // Remove callback for provisioning changes.
+ try {
+ mImsManager.getConfigInterface().removeConfigCallback(
+ mProvisioningCallback.getBinder());
+ } catch (ImsException e) {
+ Log.w(TAG, "onPause: Unable to remove callback for provisioning changes");
+ }
+
}
/**
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 27db7cd..8e72f65 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -305,14 +305,14 @@
mSubnetPref = screen.findPreference(KEY_SUBNET_MASK_PREF);
mDnsPref = screen.findPreference(KEY_DNS_PREF);
- mIpv6Category = (PreferenceCategory) screen.findPreference(KEY_IPV6_CATEGORY);
+ mIpv6Category = screen.findPreference(KEY_IPV6_CATEGORY);
mIpv6AddressPref = screen.findPreference(KEY_IPV6_ADDRESSES_PREF);
mSecurityPref.setSummary(mAccessPoint.getSecurityString(/* concise */ false));
}
private void setupEntityHeader(PreferenceScreen screen) {
- LayoutPreference headerPref = (LayoutPreference) screen.findPreference(KEY_HEADER);
+ LayoutPreference headerPref = screen.findPreference(KEY_HEADER);
mEntityHeaderController =
EntityHeaderController.newInstance(
mFragment.getActivity(), mFragment,
@@ -502,7 +502,7 @@
private static String ipv4PrefixLengthToSubnetMask(int prefixLength) {
try {
InetAddress all = InetAddress.getByAddress(
- new byte[] {(byte) 255, (byte) 255, (byte) 255, (byte) 255});
+ new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
return NetworkUtils.getNetworkPart(all, prefixLength).getHostAddress();
} catch (UnknownHostException e) {
return null;
@@ -534,8 +534,7 @@
* Returns whether the user can share the network represented by this preference with QR code.
*/
private boolean canShareNetwork() {
- return mAccessPoint.getConfig() != null && FeatureFlagUtils.isEnabled(mContext,
- FeatureFlags.WIFI_SHARING);
+ return mAccessPoint.getConfig() != null;
}
/**
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index ec43b0f..225ddbc 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -141,6 +141,7 @@
WifiPrivacyPreferenceController preferenceController = new WifiPrivacyPreferenceController(
context);
preferenceController.setWifiConfiguration(mAccessPoint.getConfig());
+ preferenceController.setIsEphemeral(mAccessPoint.isEphemeral());
controllers.add(preferenceController);
return controllers;
diff --git a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
index a20adc9..b79f2d4 100644
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
@@ -25,6 +25,7 @@
import androidx.preference.DropDownPreference;
import androidx.preference.Preference;
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.FeatureFlags;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -39,6 +40,7 @@
private static final String KEY_WIFI_PRIVACY = "privacy";
private WifiConfiguration mWifiConfiguration;
private WifiManager mWifiManager;
+ private boolean mIsEphemeral = false;
public WifiPrivacyPreferenceController(Context context) {
super(context, KEY_WIFI_PRIVACY);
@@ -50,6 +52,10 @@
mWifiConfiguration = wifiConfiguration;
}
+ public void setIsEphemeral(boolean isEphemeral) {
+ mIsEphemeral = isEphemeral;
+ }
+
@Override
public int getAvailabilityStatus() {
return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.WIFI_MAC_RANDOMIZATION)
@@ -62,6 +68,12 @@
final int randomizationLevel = getRandomizationValue();
dropDownPreference.setValue(Integer.toString(randomizationLevel));
updateSummary(dropDownPreference, randomizationLevel);
+
+ // Makes preference not selectable, when this is a ephemeral network.
+ if (mIsEphemeral) {
+ preference.setSelectable(false);
+ dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
+ }
}
@Override
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 7bc80e0..8b333e2 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -75,14 +75,6 @@
public static final String EXTRA_TEST = "test";
/**
- * Returns whether the user can share the network represented by this preference with QR code.
- */
- public static boolean isSharingNetworkEnabled(Context context) {
- return FeatureFlagUtils.isEnabled(context,
- com.android.settings.core.FeatureFlags.WIFI_SHARING);
- }
-
- /**
* Returns whether the device support WiFi DPP.
*/
public static boolean isWifiDppEnabled(Context context) {
diff --git a/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java b/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
index ac8113b..032649c 100644
--- a/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
+++ b/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
@@ -42,7 +42,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mCategory = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mCategory = screen.findPreference(getPreferenceKey());
}
public void removeAllChildren() {
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
index dea4443..4155ef7 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -76,7 +76,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ mPreferenceGroup = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
index 7a6d1fa..5761ae5 100644
--- a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
+++ b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
@@ -90,7 +90,7 @@
}
d.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
- return IconCompat.createWithBitmap(Utils.drawableToBitmap(d));
+ return Utils.createIconWithDrawable(d);
}
@Override
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 6e30b9e..b6fc17c 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -159,7 +159,7 @@
private IconCompat getEndIcon(AccessPoint accessPoint) {
if (accessPoint.isActive()) {
- return IconCompat.createWithResource(mContext, R.drawable.ic_settings);
+ return IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
} else if (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
return IconCompat.createWithResource(mContext, R.drawable.ic_friction_lock_closed);
} else if (accessPoint.isMetered()) {
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index c10e0d6..37186ca 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -34,6 +34,11 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.VectorDrawable;
import android.net.ConnectivityManager;
import android.net.LinkAddress;
import android.net.LinkProperties;
@@ -48,6 +53,8 @@
import android.widget.EditText;
import android.widget.TextView;
+import androidx.core.graphics.drawable.IconCompat;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -96,7 +103,7 @@
}
@Test
- public void testGetWifiIpAddresses_succeeds() throws Exception {
+ public void getWifiIpAddresses_succeeds() throws Exception {
when(wifiManager.getCurrentNetwork()).thenReturn(network);
LinkAddress address = new LinkAddress(InetAddress.getByName("127.0.0.1"), 0);
LinkProperties lp = new LinkProperties();
@@ -107,7 +114,7 @@
}
@Test
- public void testGetWifiIpAddresses_nullLinkProperties() {
+ public void getWifiIpAddresses_nullLinkProperties() {
when(wifiManager.getCurrentNetwork()).thenReturn(network);
// Explicitly set the return value to null for readability sake.
when(connectivityManager.getLinkProperties(network)).thenReturn(null);
@@ -116,7 +123,7 @@
}
@Test
- public void testGetWifiIpAddresses_nullNetwork() {
+ public void getWifiIpAddresses_nullNetwork() {
// Explicitly set the return value to null for readability sake.
when(wifiManager.getCurrentNetwork()).thenReturn(null);
@@ -124,7 +131,7 @@
}
@Test
- public void testInitializeVolumeDoesntBreakOnNullVolume() {
+ public void initializeVolumeDoesntBreakOnNullVolume() {
VolumeInfo info = new VolumeInfo("id", 0, new DiskInfo("id", 0), "");
StorageManager storageManager = mock(StorageManager.class, RETURNS_DEEP_STUBS);
when(storageManager.findVolumeById(anyString())).thenReturn(info);
@@ -133,13 +140,13 @@
}
@Test
- public void testGetInstallationStatus_notInstalled_shouldReturnUninstalled() {
+ public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
assertThat(Utils.getInstallationStatus(new ApplicationInfo()))
.isEqualTo(R.string.not_installed);
}
@Test
- public void testGetInstallationStatus_enabled_shouldReturnInstalled() {
+ public void getInstallationStatus_enabled_shouldReturnInstalled() {
final ApplicationInfo info = new ApplicationInfo();
info.flags = ApplicationInfo.FLAG_INSTALLED;
info.enabled = true;
@@ -148,7 +155,7 @@
}
@Test
- public void testGetInstallationStatus_disabled_shouldReturnDisabled() {
+ public void getInstallationStatus_disabled_shouldReturnDisabled() {
final ApplicationInfo info = new ApplicationInfo();
info.flags = ApplicationInfo.FLAG_INSTALLED;
info.enabled = false;
@@ -157,7 +164,7 @@
}
@Test
- public void testIsProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
+ public void isProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
when(mDevicePolicyManager.isDeviceOwnerAppOnAnyUser(PACKAGE_NAME)).thenReturn(true);
assertThat(Utils.isProfileOrDeviceOwner(mUserManager, mDevicePolicyManager, PACKAGE_NAME))
@@ -165,7 +172,7 @@
}
@Test
- public void testIsProfileOrDeviceOwner_profileOwnerApp_returnTrue() {
+ public void isProfileOrDeviceOwner_profileOwnerApp_returnTrue() {
final List<UserInfo> userInfos = new ArrayList<>();
userInfos.add(new UserInfo());
@@ -178,7 +185,7 @@
}
@Test
- public void testSetEditTextCursorPosition_shouldGetExpectedEditTextLenght() {
+ public void setEditTextCursorPosition_shouldGetExpectedEditTextLenght() {
final EditText editText = new EditText(mContext);
final CharSequence text = "test";
editText.setText(text, TextView.BufferType.EDITABLE);
@@ -189,7 +196,36 @@
}
@Test
- public void testGetBadgedIcon_usePackageNameAndUserId()
+ public void createIconWithDrawable_BitmapDrawable() {
+ final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
+ final BitmapDrawable drawable = new BitmapDrawable(mContext.getResources(), bitmap);
+
+ final IconCompat icon = Utils.createIconWithDrawable(drawable);
+
+ assertThat(icon.getBitmap()).isNotNull();
+ }
+
+ @Test
+ public void createIconWithDrawable_ColorDrawable() {
+ final ColorDrawable drawable = new ColorDrawable(Color.BLACK);
+
+ final IconCompat icon = Utils.createIconWithDrawable(drawable);
+
+ assertThat(icon.getBitmap()).isNotNull();
+ }
+
+ @Test
+ public void createIconWithDrawable_VectorDrawable() {
+ final VectorDrawable drawable = VectorDrawable.create(mContext.getResources(),
+ R.drawable.ic_settings_accent);
+
+ final IconCompat icon = Utils.createIconWithDrawable(drawable);
+
+ assertThat(icon.getBitmap()).isNotNull();
+ }
+
+ @Test
+ public void getBadgedIcon_usePackageNameAndUserId()
throws PackageManager.NameNotFoundException {
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfoAsUser(
PACKAGE_NAME, PackageManager.GET_META_DATA, USER_ID);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index 951f203..3f4e82d 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -181,6 +181,15 @@
verify(mContext, never()).unregisterReceiver(any());
}
+ @Test
+ public void getConnectedHearingAidDevice_doNotReturnSubDevice() {
+ when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
+ when(mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(mBluetoothDevice))
+ .thenReturn(true);
+
+ assertThat(mPreferenceController.getConnectedHearingAidDevice()).isNull();
+ }
+
private void setupBluetoothEnvironment() {
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
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 27aeccc..419fc49 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -466,27 +466,27 @@
@Test
public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() {
- mFragment.mContentContainer = new View(mContext);
+ mFragment.mRecyclerView = new RecyclerView(mContext);
mFragment.mSpinnerHeader = new View(mContext);
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
mFragment.mFilterAdapter.updateFilterView(true);
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE);
- assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(
+ assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(
mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height));
}
@Test
public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() {
- mFragment.mContentContainer = new View(mContext);
+ mFragment.mRecyclerView = new RecyclerView(mContext);
mFragment.mSpinnerHeader = new View(mContext);
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
mFragment.mFilterAdapter.updateFilterView(false);
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE);
- assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(0);
+ assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(0);
}
private void setUpOptionMenus() {
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index 4561ab6..6cecd98 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -345,6 +345,70 @@
assertThat(uids.get(2)).isEqualTo(789);
}
+ @Test
+ public void onCreateLoader_hasCyclesSpecified_shouldQueryDataUsageForSpecifiedCycles() {
+ final long startTime = 1521583200000L;
+ final long endTime = 1521676800000L;
+ ArrayList<Long> testCycles = new ArrayList<>();
+ testCycles.add(endTime);
+ testCycles.add(startTime);
+ final int uid = 123;
+ final AppItem appItem = new AppItem(uid);
+ appItem.category = AppItem.CATEGORY_APP;
+ appItem.addUid(uid);
+
+ mFragment = new AppDataUsage();
+ ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
+ ReflectionHelpers.setField(mFragment, "mCycles", testCycles);
+ ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
+ ReflectionHelpers.setField(mFragment, "mTemplate",
+ NetworkTemplate.buildTemplateWifiWildcard());
+
+ final NetworkCycleDataForUidLoader loader = (NetworkCycleDataForUidLoader)
+ mFragment.mUidDataCallbacks.onCreateLoader(0 /* id */, Bundle.EMPTY /* args */);
+
+ final ArrayList<Long> cycles = loader.getCycles();
+ assertThat(cycles).hasSize(2);
+ assertThat(cycles.get(0)).isEqualTo(endTime);
+ assertThat(cycles.get(1)).isEqualTo(startTime);
+ }
+
+ @Test
+ public void onLoadFinished_hasSelectedCycleSpecified_shouldSelectSpecifiedCycle() {
+ final long now = System.currentTimeMillis();
+ final long tenDaysAgo = now - (DateUtils.DAY_IN_MILLIS * 10);
+ final long twentyDaysAgo = now - (DateUtils.DAY_IN_MILLIS * 20);
+ final long thirtyDaysAgo = now - (DateUtils.DAY_IN_MILLIS * 30);
+ final List<NetworkCycleDataForUid> data = new ArrayList<>();
+ NetworkCycleDataForUid.Builder builder = new NetworkCycleDataForUid.Builder();
+ builder.setStartTime(thirtyDaysAgo).setEndTime(twentyDaysAgo).setTotalUsage(9876L);
+ data.add(builder.build());
+ builder = new NetworkCycleDataForUid.Builder();
+ builder.setStartTime(twentyDaysAgo).setEndTime(tenDaysAgo).setTotalUsage(5678L);
+ data.add(builder.build());
+ builder = new NetworkCycleDataForUid.Builder();
+ builder.setStartTime(tenDaysAgo).setEndTime(now).setTotalUsage(1234L);
+ data.add(builder.build());
+
+ mFragment = new AppDataUsage();
+ ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
+ ReflectionHelpers.setField(mFragment, "mCycleAdapter", mock(CycleAdapter.class));
+ ReflectionHelpers.setField(mFragment, "mSelectedCycle", tenDaysAgo);
+ final Preference backgroundPref = mock(Preference.class);
+ ReflectionHelpers.setField(mFragment, "mBackgroundUsage", backgroundPref);
+ final Preference foregroundPref = mock(Preference.class);
+ ReflectionHelpers.setField(mFragment, "mForegroundUsage", foregroundPref);
+ final Preference totalPref = mock(Preference.class);
+ ReflectionHelpers.setField(mFragment, "mTotalUsage", totalPref);
+ final SpinnerPreference cycle = mock(SpinnerPreference.class);
+ ReflectionHelpers.setField(mFragment, "mCycle", cycle);
+
+ mFragment.mUidDataCallbacks.onLoadFinished(null /* loader */, data);
+
+ verify(cycle).setSelection(1);
+ }
+
+ @Test
@Config(shadows = {ShadowDataUsageUtils.class, ShadowSubscriptionManager.class})
public void onCreate_noNetworkTemplateAndInvalidDataSubscription_shouldUseWifiTemplate() {
ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true;
@@ -355,6 +419,10 @@
mFragment = spy(new AppDataUsage());
doReturn(Robolectric.setupActivity(FragmentActivity.class)).when(mFragment).getActivity();
doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
+ final UidDetailProvider uidDetailProvider = mock(UidDetailProvider.class);
+ doReturn(uidDetailProvider).when(mFragment).getUidDetailProvider();
+ doReturn(new UidDetail()).when(uidDetailProvider).getUidDetail(anyInt(), anyBoolean());
+
ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
final Bundle args = new Bundle();
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
index 427550c..7d042ce 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
@@ -30,19 +30,27 @@
import android.net.NetworkTemplate;
import android.os.Bundle;
import android.provider.Settings;
+import android.widget.Spinner;
+import com.android.settings.SettingsActivity;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settingslib.AppItem;
import com.android.settingslib.NetworkPolicyEditor;
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
+import com.android.settingslib.net.NetworkCycleChartData;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.util.ReflectionHelpers;
+import java.util.ArrayList;
+import java.util.List;
+
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceManager;
@@ -124,4 +132,32 @@
assertThat(mDataUsageList.mTemplate).isNotNull();
assertThat(mDataUsageList.mSubId).isEqualTo(3);
}
+
+ @Test
+ public void startAppDataUsage_shouldAddCyclesInfoToLaunchArguments() {
+ final long startTime = 1521583200000L;
+ final long endTime = 1521676800000L;
+ final List<NetworkCycleChartData> data = new ArrayList<>();
+ final NetworkCycleChartData.Builder builder = new NetworkCycleChartData.Builder();
+ builder.setStartTime(startTime)
+ .setEndTime(endTime);
+ data.add(builder.build());
+ ReflectionHelpers.setField(mDataUsageList, "mCycleData", data);
+ final Spinner spinner = mock(Spinner.class);
+ when(spinner.getSelectedItemPosition()).thenReturn(0);
+ ReflectionHelpers.setField(mDataUsageList, "mCycleSpinner", spinner);
+ final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+
+ mDataUsageList.startAppDataUsage(new AppItem());
+
+ verify(mContext).startActivity(intent.capture());
+ final Bundle arguments =
+ intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
+ assertThat(arguments.getLong(AppDataUsage.ARG_SELECTED_CYCLE)).isEqualTo(endTime);
+ final ArrayList<Long> cycles =
+ (ArrayList) arguments.getSerializable(AppDataUsage.ARG_NETWORK_CYCLES);
+ assertThat(cycles).hasSize(2);
+ assertThat(cycles.get(0)).isEqualTo(endTime);
+ assertThat(cycles.get(1)).isEqualTo(startTime);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
index 7568987..58ed6b4 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
@@ -61,5 +61,9 @@
info.remainingLabel = "Phone will shut down soon";
assertThat(getDashboardLabel(mContext, info)).isEqualTo("3% - Phone will shut down soon");
+
+ info.discharging = false;
+ info.chargeLabel = "5% - charging";
+ assertThat(getDashboardLabel(mContext, info)).isEqualTo("5% - charging");
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
index 6149539..ecda5fd 100644
--- a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
@@ -17,12 +17,14 @@
package com.android.settings.gestures;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -77,6 +79,7 @@
@Test
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
final int availabilityStatus = mController.getAvailabilityStatus();
@@ -85,6 +88,7 @@
@Test
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
final int availabilityStatus = mController.getAvailabilityStatus();
@@ -92,6 +96,25 @@
}
@Test
+ public void getAvailabilityStatus_gestureSupported_DISABLED_DEPENDENT_SETTING() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+ when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void canHandleClicks_onlyWhenAlwaysOn() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+ assertThat(mController.canHandleClicks()).isEqualTo(false);
+
+ reset(mAmbientDisplayConfiguration);
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+ assertThat(mController.canHandleClicks()).isEqualTo(true);
+ }
+
+ @Test
public void isSliceableCorrectKey_returnsTrue() {
final WakeScreenGesturePreferenceController controller =
new WakeScreenGesturePreferenceController(mContext, "gesture_wake_screen");
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
index 5d72ee4..dcd0963 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
@@ -16,13 +16,22 @@
package com.android.settings.homepage.contextualcards.conditional;
+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.spy;
import static org.mockito.Mockito.verify;
+import android.app.NotificationManager;
import android.content.Context;
+import android.service.notification.ZenModeConfig;
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.testutils.shadow.ShadowNotificationManager;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,7 +39,10 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+@Config(shadows = ShadowNotificationManager.class)
@RunWith(RobolectricTestRunner.class)
public class DndConditionalCardControllerTest {
@@ -38,12 +50,14 @@
private ConditionManager mConditionManager;
private Context mContext;
private DndConditionCardController mController;
+ private ShadowNotificationManager mNotificationManager;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mController = new DndConditionCardController(mContext, mConditionManager);
+ mNotificationManager = Shadow.extract(mContext.getSystemService(NotificationManager.class));
}
@Test
@@ -55,4 +69,58 @@
eq(DndConditionCardController.DND_FILTER));
verify(mContext).unregisterReceiver(any(DndConditionCardController.Receiver.class));
}
+
+ @Test
+ public void buildContextualCard_allSoundsMuted_shouldHavePhoneMutedSummary() {
+ mNotificationManager.setZenModeConfig(getMutedAllConfig());
+
+ final ContextualCard card = mController.buildContextualCard();
+
+ assertThat(card.getSummaryText()).isEqualTo(
+ mContext.getString(R.string.condition_zen_summary_phone_muted));
+ }
+
+ @Test
+ public void buildContextualCard_allowSomeSounds_shouldHaveWittExceptionsSummary() {
+ mNotificationManager.setZenModeConfig(getCustomConfig());
+
+ final ContextualCard card = mController.buildContextualCard();
+
+ assertThat(card.getSummaryText()).isEqualTo(
+ mContext.getString(R.string.condition_zen_summary_with_exceptions));
+ }
+
+ private ZenModeConfig getCustomConfig() {
+ final ZenModeConfig config = new ZenModeConfig();
+ // Some sounds allowed
+ config.allowAlarms = true;
+ config.allowMedia = false;
+ config.allowSystem = false;
+ config.allowCalls = true;
+ config.allowRepeatCallers = true;
+ config.allowMessages = false;
+ config.allowReminders = false;
+ config.allowEvents = false;
+ config.areChannelsBypassingDnd = false;
+ config.allowCallsFrom = ZenModeConfig.SOURCE_ANYONE;
+ config.allowMessagesFrom = ZenModeConfig.SOURCE_ANYONE;
+ config.suppressedVisualEffects = 0;
+ return config;
+ }
+
+ private ZenModeConfig getMutedAllConfig() {
+ final ZenModeConfig config = new ZenModeConfig();
+ // No sounds allowed
+ config.allowAlarms = false;
+ config.allowMedia = false;
+ config.allowSystem = false;
+ config.allowCalls = false;
+ config.allowRepeatCallers = false;
+ config.allowMessages = false;
+ config.allowReminders = false;
+ config.allowEvents = false;
+ config.areChannelsBypassingDnd = false;
+ config.suppressedVisualEffects = 0;
+ return config;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index 02d7a9d..77fc5d9 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -30,7 +30,6 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
-import android.text.TextUtils;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
@@ -123,18 +122,6 @@
}
@Test
- public void getSlice_hasBluetoothDevices_shouldHavePairNewDevice() {
- mockBluetoothDeviceList(1);
- doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
-
- final Slice slice = mBluetoothDevicesSlice.getSlice();
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertAnySliceItemContainsTitle(sliceItems,
- mContext.getString(R.string.bluetooth_pairing_pref_title));
- }
-
- @Test
public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
@@ -146,17 +133,6 @@
}
@Test
- public void getSlice_noBluetoothDevices_shouldNotHavePairNewDevice() {
- doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
-
- final Slice slice = mBluetoothDevicesSlice.getSlice();
-
- final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
- assertThat(hasTitle(metadata,
- mContext.getString(R.string.bluetooth_pairing_pref_title))).isFalse();
- }
-
- @Test
public void getSlice_exceedDefaultRowCount_shouldOnlyShowDefaultRows() {
mockBluetoothDeviceList(BluetoothDevicesSlice.DEFAULT_EXPANDED_ROW_COUNT + 1);
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
@@ -204,9 +180,4 @@
mBluetoothDeviceList.add(mCachedBluetoothDevice);
}
}
-
- private boolean hasTitle(SliceMetadata metadata, String title) {
- final CharSequence sliceTitle = metadata.getTitle();
- return TextUtils.equals(sliceTitle, title);
- }
}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java
index ff3f0ec..fd6d6a1 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java
@@ -142,9 +142,9 @@
String sortOrder) {
if (hasDictionary) {
final MatrixCursor cursor = new MatrixCursor(
- new String[] {UserDictionary.Words.LOCALE});
- cursor.addRow(new Object[] {"en"});
- cursor.addRow(new Object[] {"es"});
+ new String[]{UserDictionary.Words.LOCALE});
+ cursor.addRow(new Object[]{"en"});
+ cursor.addRow(new Object[]{"es"});
return cursor;
} else {
return null;
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index 6a1abd1..ba152b9 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -24,6 +24,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.notNull;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -33,9 +34,12 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccManager;
+import android.text.TextUtils;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.widget.AddPreference;
@@ -61,7 +65,8 @@
private Lifecycle mLifecycle;
@Mock
private TelephonyManager mTelephonyManager;
-
+ @Mock
+ private EuiccManager mEuiccManager;
@Mock
private PreferenceScreen mPreferenceScreen;
@@ -74,7 +79,9 @@
MockitoAnnotations.initMocks(this);
mContext = spy(Robolectric.setupActivity(Activity.class));
when(mContext.getSystemService(eq(TelephonyManager.class))).thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(UNKNOWN);
+ when(mEuiccManager.isEnabled()).thenReturn(true);
mController = new MobileNetworkSummaryController(mContext, mLifecycle);
mPreference = spy(new AddPreference(mContext, null));
@@ -89,6 +96,14 @@
}
@Test
+ public void isAvailable_wifiOnlyMode_notAvailable() {
+ ConnectivityManager cm = mock(ConnectivityManager.class);
+ when(cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
+ when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(cm);
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
public void getSummary_noSubscriptions_correctSummaryAndClickHandler() {
mController.displayPreference(mPreferenceScreen);
mController.onResume();
@@ -102,6 +117,14 @@
}
@Test
+ public void getSummary_noSubscriptionsNoEuiccMgr_correctSummaryAndClickHandler() {
+ when(mEuiccManager.isEnabled()).thenReturn(false);
+ assertThat(TextUtils.isEmpty(mController.getSummary())).isTrue();
+ assertThat(mPreference.getOnPreferenceClickListener()).isNull();
+ assertThat(mPreference.getFragment()).isNull();
+ }
+
+ @Test
public void getSummary_oneSubscription_correctSummaryAndClickHandler() {
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
when(sub1.getSubscriptionId()).thenReturn(1);
@@ -205,6 +228,15 @@
}
@Test
+ public void addButton_noSubscriptionsMultiSimModeNoEuiccMgr_noAddClickListener() {
+ when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+ when(mEuiccManager.isEnabled()).thenReturn(false);
+ mController.displayPreference(mPreferenceScreen);
+ mController.onResume();
+ verify(mPreference, never()).setOnAddClickListener(notNull());
+ }
+
+ @Test
public void addButton_noSubscriptionsMultiSimMode_hasAddClickListenerAndPrefDisabled() {
when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
mController.displayPreference(mPreferenceScreen);
@@ -236,4 +268,73 @@
verify(mPreference, never()).setOnAddClickListener(isNull());
verify(mPreference).setOnAddClickListener(notNull());
}
+
+ @Test
+ public void addButton_oneSubscriptionAirplaneModeTurnedOn_addButtonGetsDisabled() {
+ when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+ final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+ mController.displayPreference(mPreferenceScreen);
+ mController.onResume();
+
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+ mController.onAirplaneModeChanged(true);
+
+ ArgumentCaptor<Boolean> captor = ArgumentCaptor.forClass(Boolean.class);
+ verify(mPreference, atLeastOnce()).setAddWidgetEnabled(captor.capture());
+ assertThat(captor.getValue()).isFalse();
+ }
+
+ @Test
+ public void onResume_oneSubscriptionAirplaneMode_isDisabled() {
+ when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+ final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+ mController.displayPreference(mPreferenceScreen);
+ mController.onResume();
+
+ assertThat(mPreference.isEnabled()).isFalse();
+
+ ArgumentCaptor<Boolean> captor = ArgumentCaptor.forClass(Boolean.class);
+ verify(mPreference, atLeastOnce()).setAddWidgetEnabled(captor.capture());
+ assertThat(captor.getValue()).isFalse();
+ }
+
+ @Test
+ public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOn_isDisabled() {
+ final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+ mController.displayPreference(mPreferenceScreen);
+ mController.onResume();
+
+ assertThat(mPreference.isEnabled()).isTrue();
+
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+ mController.onAirplaneModeChanged(true);
+
+ assertThat(mPreference.isEnabled()).isFalse();
+ }
+
+ @Test
+ public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOff_isEnabled() {
+ when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+ final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+ SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+ mController.displayPreference(mPreferenceScreen);
+ mController.onResume();
+
+ assertThat(mPreference.isEnabled()).isFalse();
+
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
+ mController.onAirplaneModeChanged(false);
+
+ assertThat(mPreference.isEnabled()).isTrue();
+
+ ArgumentCaptor<Boolean> captor = ArgumentCaptor.forClass(Boolean.class);
+ verify(mPreference, atLeastOnce()).setAddWidgetEnabled(eq(false));
+ verify(mPreference, atLeastOnce()).setAddWidgetEnabled(captor.capture());
+ assertThat(captor.getValue()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index e0334b1..dbc122a 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -47,7 +47,7 @@
@Test
public void getAvailableSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(null);
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(null);
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
assertThat(subs).isEmpty();
@@ -57,7 +57,7 @@
public void getAvailableSubscriptions_oneSubscription_oneResult() {
final SubscriptionInfo info = mock(SubscriptionInfo.class);
when(info.getMncString()).thenReturn("fake1234");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
assertThat(subs).hasSize(1);
@@ -69,7 +69,7 @@
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
when(info1.getMncString()).thenReturn("fake1234");
when(info2.getMncString()).thenReturn("fake5678");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
assertThat(subs).hasSize(2);
@@ -82,7 +82,7 @@
final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(1);
when(info1.getMncString()).thenReturn("fake1234");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(
new ArrayList<>(Arrays.asList(info1, info2, info3)));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
@@ -100,7 +100,7 @@
when(info1.getMncString()).thenReturn("fake1234");
when(info4.getSubscriptionId()).thenReturn(4);
when(info4.getMncString()).thenReturn("fake5678");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(new ArrayList<>(
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(new ArrayList<>(
Arrays.asList(info1, info2, info3, info4)));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index 447931e..3b5cdf9 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -148,7 +148,7 @@
doReturn(intent).when(mMobileNetworkActivity).getIntent();
mSubscriptionInfos.add(mSubscriptionInfo);
mSubscriptionInfos.add(mSubscriptionInfo2);
- doReturn(mSubscriptionInfos).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
+ doReturn(mSubscriptionInfos).when(mSubscriptionManager).getSelectableSubscriptionInfoList();
doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(CURRENT_SUB_ID);
assertThat(mMobileNetworkActivity.getSubscriptionId()).isEqualTo(CURRENT_SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index a057022..d904ab3 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -84,14 +84,14 @@
@Test
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
- assertThat(mController.isVideoCallEnabled()).isTrue();
+ assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
}
@Test
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
- assertThat(mController.isVideoCallEnabled()).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
}
@Test
@@ -100,7 +100,7 @@
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
doReturn(false).when(mTelephonyManager).isDataEnabled();
- assertThat(mController.isVideoCallEnabled()).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java
index 6639aae..e9cd731 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java
@@ -111,4 +111,12 @@
mContext.getString(R.string.manual_mode_disallowed_summary,
mTelephonyManager.getSimOperatorName()));
}
+
+ @Test
+ public void init_carrierConfigNull_shouldNotCrash() {
+ when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(null);
+
+ // Should not crash
+ mController.init(SUB_ID);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 1d79952..8f54115 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -18,6 +18,7 @@
import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
+import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.net.Uri;
@@ -53,4 +54,9 @@
public Intent getSeeMoreIntent() {
return INTENT;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.TESTING;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index 389c31e..be8d8bc 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -22,10 +22,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.View;
import android.widget.LinearLayout;
import com.android.settings.R;
@@ -71,13 +74,14 @@
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
+
+ final Bundle bundle = new Bundle();
+ bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
+ doReturn(bundle).when(mPanelFragment).getArguments();
}
@Test
public void onCreateView_adapterGetsDataset() {
- final Bundle bundle = new Bundle();
- bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
- doReturn(bundle).when(mPanelFragment).getArguments();
mPanelFragment.onCreateView(LayoutInflater.from(mContext),
new LinearLayout(mContext), null);
PanelSlicesAdapter adapter = mPanelFragment.mAdapter;
@@ -85,4 +89,43 @@
assertThat(adapter.getData()).containsAllIn(mFakePanelContent.getSlices());
}
+ @Test
+ public void onCreate_logsOpenEvent() {
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_VISIBLE,
+ mFakePanelContent.getMetricsCategory(),
+ null,
+ 0);
+ }
+
+ @Test
+ public void panelSeeMoreClick_logsCloseEvent() {
+ final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
+
+ listener.onClick(null);
+
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_HIDE,
+ mFakePanelContent.getMetricsCategory(),
+ PanelLoggingContract.PanelClosedKeys.KEY_SEE_MORE,
+ 0
+ );
+ }
+
+ @Test
+ public void panelDoneClick_logsCloseEvent() {
+ final View.OnClickListener listener = mPanelFragment.getCloseListener();
+
+ listener.onClick(null);
+
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_HIDE,
+ mFakePanelContent.getMetricsCategory(),
+ PanelLoggingContract.PanelClosedKeys.KEY_DONE,
+ 0
+ );
+ }
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index abefa67..4dce15e 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -71,7 +71,7 @@
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
- mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent.getSlices());
+ mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index 359cf5d..a51b7b0 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -16,13 +16,25 @@
package com.android.settings.panel;
-import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME;
+import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME;
import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
import static com.google.common.truth.Truth.assertThat;
-import android.content.Intent;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.view.MotionEvent;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -31,6 +43,22 @@
@RunWith(RobolectricTestRunner.class)
public class SettingsPanelActivityTest {
+ private FakeFeatureFactory mFakeFeatureFactory;
+ private FakeSettingsPanelActivity mSettingsPanelActivity;
+ private PanelFeatureProvider mPanelFeatureProvider;
+ private FakePanelContent mFakePanelContent;
+
+ @Before
+ public void setUp() {
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
+ mSettingsPanelActivity = Robolectric.buildActivity(FakeSettingsPanelActivity.class)
+ .create().get();
+ mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
+ mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
+ mFakePanelContent = new FakePanelContent();
+ doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+ }
+
@Test
public void startMediaOutputSlice_withPackageName_bundleShouldHaveValue() {
final Intent intent = new Intent()
@@ -41,7 +69,7 @@
final SettingsPanelActivity activity =
Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
- assertThat(activity.mBundle.getString(KEY_PANEL_PACKAGE_NAME))
+ assertThat(activity.mBundle.getString(KEY_MEDIA_PACKAGE_NAME))
.isEqualTo("com.google.android.music");
assertThat(activity.mBundle.getString(KEY_PANEL_TYPE_ARGUMENT))
.isEqualTo("com.android.settings.panel.action.MEDIA_OUTPUT");
@@ -55,7 +83,23 @@
final SettingsPanelActivity activity =
Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
- assertThat(activity.mBundle.containsKey(KEY_PANEL_PACKAGE_NAME)).isFalse();
+ assertThat(activity.mBundle.containsKey(KEY_MEDIA_PACKAGE_NAME)).isFalse();
assertThat(activity.mBundle.containsKey(KEY_PANEL_TYPE_ARGUMENT)).isFalse();
}
+
+ @Test
+ public void onTouchEvent_outsideAction_logsPanelClosed() {
+ final MotionEvent event = mock(MotionEvent.class);
+ when(event.getAction()).thenReturn(MotionEvent.ACTION_OUTSIDE);
+
+ mSettingsPanelActivity.onTouchEvent(event);
+
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_HIDE,
+ SettingsEnums.TESTING,
+ PanelLoggingContract.PanelClosedKeys.KEY_CLICKED_OUT,
+ 0
+ );
+ }
}
diff --git a/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
new file mode 100644
index 0000000..05ce30a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.privacy;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.view.accessibility.AccessibilityManager;
+
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowAccessibilityManager;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
+public class AccessibilityUsagePreferenceControllerTest {
+
+ private Context mContext;
+ private ShadowAccessibilityManager mAccessibilityManager;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mAccessibilityManager = Shadow.extract(
+ RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
+ }
+
+ @After
+ public void tearDown() {
+ ShadowAccessibilityManager.reset();
+ ShadowDeviceConfig.reset();
+ }
+
+ @Test
+ public void isAvailable_permissionHubNotSet_shouldReturnUnsupported() {
+ mAccessibilityManager.setEnabledAccessibilityServiceList(new ArrayList<>());
+ AccessibilityUsagePreferenceController controller =
+ new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+ // We have not yet set the property to show the Permissions Hub.
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noEnabledServices_shouldReturnUnsupported() {
+ DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+ DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
+ mAccessibilityManager.setEnabledAccessibilityServiceList(new ArrayList<>());
+ AccessibilityUsagePreferenceController controller =
+ new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_enabledServices_shouldReturnAvailableUnsearchable() {
+ DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+ DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
+ mAccessibilityManager.setEnabledAccessibilityServiceList(
+ new ArrayList<>(Arrays.asList(new AccessibilityServiceInfo())));
+ AccessibilityUsagePreferenceController controller =
+ new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
index b947630..f9913f6 100644
--- a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
@@ -22,18 +22,25 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserManager;
import android.permission.RuntimePermissionUsageInfo;
import android.provider.DeviceConfig;
import androidx.preference.PreferenceScreen;
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+import com.android.settings.testutils.shadow.ShadowPermissionControllerManager;
+import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.widget.BarChartInfo;
import com.android.settingslib.widget.BarChartPreference;
import com.android.settingslib.widget.BarViewInfo;
@@ -47,26 +54,41 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowDeviceConfig.class})
+@Config(shadows = {ShadowDeviceConfig.class, ShadowUserManager.class,
+ ShadowPermissionControllerManager.class})
public class PermissionBarChartPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
private PermissionBarChartPreferenceController mController;
private BarChartPreference mPreference;
+ private PrivacyDashboardFragment mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- Context Context = RuntimeEnvironment.application;
- mController = new PermissionBarChartPreferenceController(Context, "test_key");
- mPreference = spy(new BarChartPreference(Context));
+ final Context context = RuntimeEnvironment.application;
+ final UserManager userManager = context.getSystemService(UserManager.class);
+ final ShadowUserManager shadowUserManager = Shadow.extract(userManager);
+ shadowUserManager.addProfile(new UserInfo(123, null, 0));
+ when(FakeFeatureFactory.setupForTest().securityFeatureProvider.getLockPatternUtils(
+ any(Context.class))).thenReturn(mLockPatternUtils);
+
+ mController = spy(new PermissionBarChartPreferenceController(context, "test_key"));
+ mFragment = spy(FragmentController.of(new PrivacyDashboardFragment())
+ .create().start().get());
+ mController.setFragment(mFragment);
+ mPreference = spy(new BarChartPreference(context));
when(mScreen.findPreference(mController.getPreferenceKey()))
.thenReturn((BarChartPreference) mPreference);
}
@@ -130,4 +152,41 @@
verify(mPreference, times(1)).setBarViewInfos(any(BarViewInfo[].class));
}
+
+ @Test
+ public void onStart_permissionHubEnabled_shouldShowProgressBar() {
+ DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+ DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
+ mController.displayPreference(mScreen);
+
+ mController.onStart();
+
+ verify(mFragment).setLoadingEnabled(true /* enabled */);
+ verify(mPreference).updateLoadingState(true /* isLoading */);
+ }
+
+ @Test
+ public void onStart_permissionHubDisabled_shouldNotShowProgressBar() {
+ DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+ DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "false", false);
+
+ mController.onStart();
+
+ verify(mFragment, never()).setLoadingEnabled(true /* enabled */);
+ verify(mPreference, never()).updateLoadingState(true /* isLoading */);
+ }
+
+ @Test
+ public void onPermissionUsageResult_shouldHideProgressBar() {
+ final List<RuntimePermissionUsageInfo> infos1 = new ArrayList<>();
+ final RuntimePermissionUsageInfo info1 =
+ new RuntimePermissionUsageInfo("permission 1", 10);
+ infos1.add(info1);
+ mController.displayPreference(mScreen);
+
+ mController.onPermissionUsageResult(infos1);
+
+ verify(mFragment).setLoadingEnabled(false /* enabled */);
+ verify(mPreference).updateLoadingState(false /* isLoading */);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
new file mode 100644
index 0000000..161c39a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.privacy;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.Bundle;
+import android.os.UserManager;
+import android.permission.PermissionControllerManager;
+import android.view.View;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.ShadowPermissionControllerManager;
+import com.android.settings.testutils.shadow.ShadowUserManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
+
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class, ShadowPermissionControllerManager.class})
+public class PrivacyDashboardFragmentTest {
+
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private PermissionControllerManager mPCM;
+
+ private Context mContext;
+ private PrivacyDashboardFragment mFragment;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ final UserManager userManager = mContext.getSystemService(UserManager.class);
+ final ShadowUserManager shadowUserManager = Shadow.extract(userManager);
+ shadowUserManager.addProfile(new UserInfo(123, null, 0));
+ when(FakeFeatureFactory.setupForTest().securityFeatureProvider.getLockPatternUtils(
+ any(Context.class))).thenReturn(mLockPatternUtils);
+ mFragment = spy(FragmentController.of(new PrivacyDashboardFragment())
+ .create().start().get());
+ }
+
+ @Test
+ public void onViewCreated_shouldCallStyleActionBar() {
+ mFragment.onViewCreated(new View(mContext), new Bundle());
+
+ verify(mFragment).styleActionBar();
+ }
+
+ @Test
+ public void onViewCreated_shouldInitLinearProgressBar() {
+ mFragment.onViewCreated(new View(mContext), new Bundle());
+
+ verify(mFragment).initLoadingBar();
+ }
+
+ @Test
+ public void updateLinearProgressbar_isVisible_shouldShowProgressBar() {
+ mFragment.setLoadingEnabled(true /* enabled */);
+
+ assertThat(mFragment.mProgressHeader.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mFragment.mProgressAnimation.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void updateLinearProgressbar_isInVisible_shouldHideProgressBar() {
+ mFragment.setLoadingEnabled(false /* enabled */);
+
+ assertThat(mFragment.mProgressHeader.getVisibility()).isEqualTo(View.INVISIBLE);
+ assertThat(mFragment.mProgressAnimation.getVisibility()).isEqualTo(View.INVISIBLE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index efdcc26..726e4bd 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -99,7 +99,7 @@
private static final String SUMMARY = "summary";
private static final String SCREEN_TITLE = "screen title";
private static final String FRAGMENT_NAME = "fragment name";
- private static final int ICON = R.drawable.ic_settings;
+ private static final int ICON = R.drawable.ic_settings_accent;
private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private static final String PREF_CONTROLLER = FakeToggleController.class.getName();
@@ -578,7 +578,7 @@
values.put(SlicesDatabaseHelper.IndexColumns.TITLE, TITLE);
values.put(SlicesDatabaseHelper.IndexColumns.SUMMARY, "s");
values.put(SlicesDatabaseHelper.IndexColumns.SCREENTITLE, "s");
- values.put(SlicesDatabaseHelper.IndexColumns.ICON_RESOURCE, R.drawable.ic_settings);
+ values.put(SlicesDatabaseHelper.IndexColumns.ICON_RESOURCE, R.drawable.ic_settings_accent);
values.put(SlicesDatabaseHelper.IndexColumns.FRAGMENT, "test");
values.put(SlicesDatabaseHelper.IndexColumns.CONTROLLER, PREF_CONTROLLER);
values.put(SlicesDatabaseHelper.IndexColumns.PLATFORM_SLICE, isPlatformSlice);
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index c2d1e93..0a42f42 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -63,7 +63,7 @@
private final String SCREEN_TITLE = "screen title";
private final String KEYWORDS = "a, b, c";
private final String FRAGMENT_NAME = "fragment name";
- private final int ICON = R.drawable.ic_settings;
+ private final int ICON = R.drawable.ic_settings_accent;
private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private final Class TOGGLE_CONTROLLER = FakeToggleController.class;
private final Class SLIDER_CONTROLLER = FakeSliderController.class;
@@ -431,7 +431,7 @@
@Test
public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings).toIcon().getResId();
+ R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT,
0x0);
@@ -446,7 +446,7 @@
@Test
public void buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings).toIcon().getResId();
+ R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
@@ -465,7 +465,7 @@
@Test
public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings).toIcon().getResId();
+ R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData dummyData = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
0x0);
@@ -480,7 +480,7 @@
@Test
public void buildSliderSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings).toIcon().getResId();
+ R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
@@ -493,7 +493,7 @@
@Test
public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
- final int settingsIcon = R.drawable.ic_settings;
+ final int settingsIcon = R.drawable.ic_settings_accent;
final int zeroIcon = 0x0;
final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
zeroIcon);
@@ -507,7 +507,7 @@
@Test
public void getSafeIcon_invalidResource_shouldFallbackToSettingsIcon() {
- final int settingsIcon = R.drawable.ic_settings;
+ final int settingsIcon = R.drawable.ic_settings_accent;
final int badIcon = 0x12345678;
final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
badIcon);
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java
index a1b1a23..8325777 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java
@@ -18,6 +18,7 @@
import android.app.NotificationManager;
import android.net.Uri;
+import android.service.notification.ZenModeConfig;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@@ -26,6 +27,7 @@
public class ShadowNotificationManager {
private int mZenMode;
+ private ZenModeConfig mZenModeConfig;
@Implementation
protected void setZenMode(int mode, Uri conditionId, String reason) {
@@ -36,4 +38,13 @@
protected int getZenMode() {
return mZenMode;
}
+
+ @Implementation
+ public ZenModeConfig getZenModeConfig() {
+ return mZenModeConfig;
+ }
+
+ public void setZenModeConfig(ZenModeConfig config) {
+ mZenModeConfig = config;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java
new file mode 100644
index 0000000..091b244
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java
@@ -0,0 +1,44 @@
+/*
+ * 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.testutils.shadow;
+
+import android.annotation.CallbackExecutor;
+import android.content.Context;
+import android.permission.PermissionControllerManager;
+
+import androidx.annotation.NonNull;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.util.concurrent.Executor;
+
+@Implements(PermissionControllerManager.class)
+public class ShadowPermissionControllerManager {
+
+ protected void __constructor__(Context context) {
+ // no nothing, everything is shadowed
+ }
+
+ @Implementation
+ public void getPermissionUsages(boolean countSystem, long numMillis,
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull PermissionControllerManager.OnPermissionUsageResultCallback callback) {
+
+ // Do nothing
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
index 722df77..8736fe8 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
@@ -43,6 +43,6 @@
@Implementation
protected static Pair<String, Integer> getIconFromUri(Context context, String packageName,
String uriString, Map<String, IContentProvider> providerMap) {
- return Pair.create(RuntimeEnvironment.application.getPackageName(), R.drawable.ic_settings);
+ return Pair.create(RuntimeEnvironment.application.getPackageName(), R.drawable.ic_settings_accent);
}
}
diff --git a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
index 32690a3..05a9cfb 100644
--- a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
@@ -87,7 +87,7 @@
public void setBackgroundColor_externalTileWithBackgroundColorRawValue_shouldUpdateIcon() {
final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB, 0xff0000);
- doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
+ doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
.when(tile).getIcon(mContext);
final AdaptiveHomepageIcon icon =
new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
@@ -97,11 +97,25 @@
}
@Test
+ public void setBackgroundColor_tileWithoutBackgroundColor_shouldSetDefaultBackgroundColor() {
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+ doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
+ .when(tile).getIcon(mContext);
+ final AdaptiveHomepageIcon icon =
+ new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+
+ icon.setBackgroundColor(mContext, tile);
+
+ assertThat(icon.mBackgroundColor).isEqualTo(
+ mContext.getColor(R.color.homepage_generic_icon_background));
+ }
+
+ @Test
public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() {
final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
R.color.material_blue_500);
- doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
+ doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
.when(tile).getIcon(mContext);
final AdaptiveHomepageIcon icon =
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 0286d07..21b68f2 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -33,6 +33,7 @@
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
import android.os.Bundle;
+import android.view.View;
import android.widget.Button;
import android.widget.TextView;
@@ -264,20 +265,77 @@
private List<AccessPoint> createAccessPointList() {
List<AccessPoint> accessPointList = spy(new ArrayList<>());
Bundle bundle = new Bundle();
+
bundle.putString(KEY_SSID, "Test AP 1");
bundle.putInt(KEY_SECURITY, 1);
accessPointList.add(new AccessPoint(mContext, bundle));
+
bundle.putString(KEY_SSID, "Test AP 2");
bundle.putInt(KEY_SECURITY, 1);
accessPointList.add(new AccessPoint(mContext, bundle));
+
bundle.putString(KEY_SSID, "Test AP 3");
bundle.putInt(KEY_SECURITY, 2);
- AccessPoint clickedAccessPoint = new AccessPoint(mContext, bundle);
- accessPointList.add(clickedAccessPoint);
+ accessPointList.add(new AccessPoint(mContext, bundle));
+
bundle.putString(KEY_SSID, "Test AP 4");
bundle.putInt(KEY_SECURITY, 0);
accessPointList.add(new AccessPoint(mContext, bundle));
return accessPointList;
}
+
+ @Test
+ public void display_shouldNotShowNeutralButton() {
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
+ final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
+ assertThat(button).isNotNull();
+ assertThat(button.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void onMatchManyResult_showNeutralButton() {
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
+ final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ final String SSID_AP = "Test AP ";
+ final List<ScanResult> scanResults = new ArrayList<>();
+ for (int i = 0; i < 6 ; i ++) {
+ ScanResult scanResult = new ScanResult();
+ scanResult.SSID = SSID_AP + i;
+ scanResult.capabilities = "WEP";
+ scanResults.add(scanResult);
+ }
+ networkRequestDialogFragment.onMatch(scanResults);
+
+ final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
+ assertThat(button).isNotNull();
+ assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void clickNeutralButton_hideNeutralButton() {
+ // Assert
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
+ final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ final String SSID_AP = "Test AP ";
+ final List<ScanResult> scanResults = new ArrayList<>();
+ for (int i = 0; i < 6 ; i ++) {
+ ScanResult scanResult = new ScanResult();
+ scanResult.SSID = SSID_AP + i;
+ scanResult.capabilities = "WEP";
+ scanResults.add(scanResult);
+ }
+ networkRequestDialogFragment.onMatch(scanResults);
+
+ // Action
+ final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
+ button.performClick();
+
+ // Check
+ assertThat(button.getVisibility()).isEqualTo(View.GONE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
index b194d73..98795a7 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
@@ -18,15 +18,140 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doNothing;
+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 static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
+import com.android.ims.ImsManager;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.widget.SwitchBar;
+import com.android.settings.widget.ToggleSwitch;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class WifiCallingSettingsForSubTest {
+ private TestFragment mFragment;
+ private Context mContext;
+ private TextView mEmptyView;
+
+ @Mock private ImsManager mImsManager;
+ @Mock private TelephonyManager mTelephonyManager;
+ @Mock private PreferenceScreen mPreferenceScreen;
+ @Mock private SettingsActivity mActivity;
+ @Mock private SwitchBar mSwitchBar;
+ @Mock private ToggleSwitch mToggleSwitch;
+ @Mock private View mView;
+ @Mock private ImsConfig mImsConfig;
+
+ @Before
+ public void setUp() throws NoSuchFieldException, ImsException {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ doReturn(mContext.getTheme()).when(mActivity).getTheme();
+
+ mFragment = spy(new TestFragment());
+ doReturn(mActivity).when(mFragment).getActivity();
+ doReturn(mContext).when(mFragment).getContext();
+ doReturn(mock(Intent.class)).when(mActivity).getIntent();
+ doReturn(mContext.getResources()).when(mFragment).getResources();
+ doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
+ doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
+ final Bundle bundle = new Bundle();
+ when(mFragment.getArguments()).thenReturn(bundle);
+ doNothing().when(mFragment).addPreferencesFromResource(anyInt());
+ doReturn(mock(ListPreference.class)).when(mFragment).findPreference(any());
+ doNothing().when(mFragment).finish();
+ doReturn(mView).when(mFragment).getView();
+
+ mEmptyView = new TextView(mContext);
+ doReturn(mEmptyView).when(mView).findViewById(android.R.id.empty);
+
+ ReflectionHelpers.setField(mSwitchBar, "mSwitch", mToggleSwitch);
+ doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
+
+ doReturn(mImsManager).when(mFragment).getImsManager();
+ doReturn(mImsConfig).when(mImsManager).getConfigInterface();
+ doReturn(true).when(mImsManager).isWfcProvisionedOnDevice();
+
+ mFragment.onAttach(mContext);
+ mFragment.onCreate(null);
+ mFragment.onActivityCreated(null);
+ }
@Test
public void getHelpResource_shouldReturn0() {
- assertThat(new WifiCallingSettingsForSub().getHelpResource()).isEqualTo(0);
+ assertThat(mFragment.getHelpResource()).isEqualTo(0);
+ }
+
+ @Test
+ public void onResume_provisioningAllowed_shouldNotFinish() throws ImsException {
+ // Call onResume while provisioning is allowed.
+ mFragment.onResume();
+
+ // Verify that finish() is not called.
+ verify(mFragment, never()).finish();
+ }
+
+ @Test
+ public void onResume_provisioningDisallowed_shouldFinish() {
+ // Call onResume while provisioning is disallowed.
+ doReturn(false).when(mImsManager).isWfcProvisionedOnDevice();
+ mFragment.onResume();
+
+ // Verify that finish() is called
+ verify(mFragment).finish();
+ }
+
+ @Test
+ public void onResumeOnPause_provisioningCallbackRegistration() throws ImsException {
+ // Verify that provisioning callback is registered after call to onResume().
+ mFragment.onResume();
+ verify(mImsConfig).addConfigCallback(any(ProvisioningManager.Callback.class));
+
+ // Verify that provisioning callback is unregistered after call to onPause.
+ mFragment.onPause();
+ verify(mImsConfig).removeConfigCallback(any());
+ }
+
+ protected class TestFragment extends WifiCallingSettingsForSub {
+ @Override
+ protected Object getSystemService(final String name) {
+ if (Context.TELEPHONY_SERVICE.equals(name)) {
+ return mTelephonyManager;
+ }
+ return null;
+ }
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
index 1e2e718..a1af8bf 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
@@ -93,4 +93,20 @@
mPreferenceController.getRandomizationValue();
mPreferenceController.onPreferenceChange(mDropDownPreference, "1");
}
+
+ @Test
+ public void testUpdateState_isNotEphemeralNetwork_shouldBeSelectable() {
+ mPreferenceController.setIsEphemeral(false);
+ mPreferenceController.updateState(mDropDownPreference);
+
+ assertThat(mDropDownPreference.isSelectable()).isTrue();
+ }
+
+ @Test
+ public void testUpdateState_isEphemeralNetwork_shouldNotSelectable() {
+ mPreferenceController.setIsEphemeral(true);
+ mPreferenceController.updateState(mDropDownPreference);
+
+ assertThat(mDropDownPreference.isSelectable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
index a57fefc..bd2ce1e 100644
--- a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
@@ -22,14 +22,11 @@
import android.content.Context;
import android.graphics.Bitmap;
-import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.util.Size;
-import com.android.settings.R;
-
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.RGBLuminanceSource;