Merge "Change the default snoop log level to off."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bac0f60..6cb0023 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -443,7 +443,7 @@
android:exported="true"
android:permission="android.permission.TETHER_PRIVILEGED" />
- <activity android:name="TetherProvisioningActivity"
+ <activity android:name="network.TetherProvisioningActivity"
android:exported="true"
android:permission="android.permission.TETHER_PRIVILEGED"
android:excludeFromRecents="true"
@@ -2987,6 +2987,18 @@
android:value="true" />
</activity>
+ <activity android:name="Settings$BluetoothDeviceDetailActivity"
+ android:label="@string/device_details_title"
+ android:permission="android.permission.BLUETOOTH_PRIVILEGED"
+ android:parentActivityName="Settings$ConnectedDeviceDashboardActivity">
+ <intent-filter android:priority="1">
+ <action android:name="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.bluetooth.BluetoothDeviceDetailsFragment" />
+ </activity>
+
<activity android:name=".panel.SettingsPanelActivity"
android:label="@string/settings_panel_title"
android:theme="@style/Theme.BottomDialog"
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_system_update.xml b/res/drawable/ic_system_update.xml
deleted file mode 100644
index 3325fdd..0000000
--- a/res/drawable/ic_system_update.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<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="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM16,12.5l-4,4l-4,-4l1.41,-1.41L11,12.67V8.5V8h2v0.5v4.17l1.59,-1.59L16,12.5z"/>
-</vector>
diff --git a/res/drawable/ic_system_update_vd_theme_24.xml b/res/drawable/ic_system_update_vd_theme_24.xml
deleted file mode 100644
index d1fc061..0000000
--- a/res/drawable/ic_system_update_vd_theme_24.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<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="@android:color/white"
- android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM16,12.5l-4,4l-4,-4l1.41,-1.41L11,12.67V8.5V8h2v0.5v4.17l1.59,-1.59L16,12.5z"/>
-</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-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/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/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/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/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/config.xml b/res/values/config.xml
index 3023067..c2899ef 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -353,4 +353,7 @@
<!-- Whether or not extra preview panels should be used for screen zoom setting. -->
<bool name="config_enable_extra_screen_zoom_preview">true</bool>
+
+ <!-- Slice Uri to query nearby devices. -->
+ <string name="config_nearby_devices_slice_uri" translatable="false">content://com.google.android.gms.nearby.fastpair/device_status_list_item</string>
</resources>
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 6b30ab1..9c29a6b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7078,7 +7078,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>
@@ -10503,6 +10503,9 @@
<string name="preferred_network_mode_dialogtitle">Preferred network type</string>
<!-- Mobile network settings screen, name of the option to manage carrier profiles on devices which support embedded carrier profiles [CHAR LIMIT=NONE] -->
<string name="carrier_settings_euicc">Carrier</string>
+ <!-- Mobile network settings screen, a string showing the version of carrier settings for this
+ subscription [CHAR LIMIT=NONE] -->
+ <string name="carrier_settings_version">Settings version</string>
<!-- Mobile network settings screen, name for call settings category [CHAR LIMIT=NONE] -->
<string name="call_category">Calling</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 84c8831..323d39b 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"
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index 29c9e01..ae88d36 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -20,6 +20,12 @@
android:key="connected_devices_screen"
android:title="@string/connected_devices_dashboard_title">
+ <com.android.settings.slices.SlicePreference
+ android:key="bt_nearby_slice"
+ android:title="@string/summary_placeholder"
+ settings:controller="com.android.settings.slices.SlicePreferenceController"
+ settings:allowDividerBelow="true"/>
+
<PreferenceCategory
android:key="available_device_list"
android:title="@string/connected_device_available_media_title"
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index f269fad..c3bb656 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -98,6 +98,12 @@
android:title="@string/carrier_settings_euicc"
settings:controller="com.android.settings.network.telephony.EuiccPreferenceController" />
+ <Preference
+ android:key="carrier_settings_version_key"
+ android:title="@string/carrier_settings_version"
+ settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
+ settings:enableCopying="true" />
+
<PreferenceCategory
android:key="calling_category"
android:title="@string/call_category">
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 3f2e55f..c4bd11d 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -66,7 +66,7 @@
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_system"
android:title="@string/storage_detail_system"
- android:icon="@drawable/ic_system_update_vd_theme_24"
+ android:icon="@drawable/ic_system_update"
android:order="100" />
<PreferenceCategory
android:key="pref_secondary_users"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index e7f543a..ae4ae2a 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -156,6 +156,7 @@
}
public static class WebViewAppPickerActivity extends SettingsActivity { /* empty */ }
public static class AdvancedConnectedDeviceActivity extends SettingsActivity { /* empty */ }
+ public static class BluetoothDeviceDetailActivity extends SettingsActivity { /* empty */ }
// Top level categories for new IA
public static class NetworkDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 93a785f..65cfdf6 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -71,6 +71,7 @@
import android.provider.ContactsContract.Profile;
import android.provider.ContactsContract.RawContacts;
import android.provider.Settings;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.Spannable;
import android.text.SpannableString;
@@ -958,6 +959,22 @@
}
/**
+ * Converts the {@link Drawable} to a {@link Bitmap}.
+ */
+ public static Bitmap drawableToBitmap(Drawable drawable) {
+ if (drawable instanceof BitmapDrawable) {
+ return ((BitmapDrawable)drawable).getBitmap();
+ }
+
+ 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;
+ }
+
+ /**
* Get the {@link Drawable} that represents the app icon
*/
public static Drawable getBadgedIcon(IconDrawableFactory iconDrawableFactory,
@@ -980,4 +997,13 @@
}
return false;
}
+
+ /** Get {@link Resources} by subscription id if subscription id is valid. */
+ public static Resources getResourcesForSubId(Context context, int subId) {
+ if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return SubscriptionManager.getResourcesForSubId(context, subId);
+ } else {
+ return context.getResources();
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
index 5c609e6..749a38f 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
@@ -45,7 +45,8 @@
* supports, such as "Phone audio", "Media audio", "Contact sharing", etc.
*/
public class BluetoothDetailsProfilesController extends BluetoothDetailsController
- implements Preference.OnPreferenceClickListener {
+ implements Preference.OnPreferenceClickListener,
+ LocalBluetoothProfileManager.ServiceListener {
private static final String KEY_PROFILES_GROUP = "bluetooth_profiles";
@VisibleForTesting
@@ -87,6 +88,7 @@
pref.setKey(profile.toString());
pref.setTitle(profile.getNameResource(mCachedDevice.getDevice()));
pref.setOnPreferenceClickListener(this);
+ pref.setOrder(profile.getOrdinal());
return pref;
}
@@ -221,7 +223,7 @@
}
BluetoothDevice device = mCachedDevice.getDevice();
A2dpProfile a2dp = (A2dpProfile) profile;
- if (a2dp.supportsHighQualityAudio(device)) {
+ if (a2dp.isProfileReady() && a2dp.supportsHighQualityAudio(device)) {
SwitchPreference highQualityAudioPref = new SwitchPreference(
mProfilesContainer.getContext());
highQualityAudioPref.setKey(HIGH_QUALITY_AUDIO_PREF_TAG);
@@ -235,6 +237,28 @@
}
}
+ @Override
+ public void onPause() {
+ super.onPause();
+ mProfileManager.removeServiceListener(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mProfileManager.addServiceListener(this);
+ }
+
+ @Override
+ public void onServiceConnected() {
+ refresh();
+ }
+
+ @Override
+ public void onServiceDisconnected() {
+ refresh();
+ }
+
/**
* Refreshes the state of the switches for all profiles, possibly adding or removing switches as
* needed.
@@ -242,7 +266,10 @@
@Override
protected void refresh() {
for (LocalBluetoothProfile profile : getProfiles()) {
- SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(
+ if (!profile.isProfileReady()) {
+ continue;
+ }
+ SwitchPreference pref = mProfilesContainer.findPreference(
profile.toString());
if (pref == null) {
pref = createProfilePreference(mProfilesContainer.getContext(), profile);
@@ -252,7 +279,7 @@
refreshProfilePreference(pref, profile);
}
for (LocalBluetoothProfile removedProfile : mCachedDevice.getRemovedProfiles()) {
- SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(
+ final SwitchPreference pref = mProfilesContainer.findPreference(
removedProfile.toString());
if (pref != null) {
mProfilesContainer.removePreference(pref);
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index 98455f2..2fbd061 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -107,6 +107,11 @@
mDeviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
mManager = getLocalBluetoothManager(context);
mCachedDevice = getCachedDevice(mDeviceAddress);
+ if (mCachedDevice == null) {
+ // Close this page if device is null with invalid device mac address
+ finish();
+ return;
+ }
super.onAttach(context);
use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index b84cc26..d5cfdcc 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -17,6 +17,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.net.Uri;
import android.provider.SearchIndexableResource;
import androidx.annotation.VisibleForTesting;
@@ -24,6 +25,7 @@
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.slices.SlicePreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
@@ -88,6 +90,8 @@
use(ConnectedDeviceGroupController.class).init(this);
use(PreviouslyConnectedDevicePreferenceController.class).init(this);
use(DiscoverableFooterPreferenceController.class).init(this);
+ use(SlicePreferenceController.class).setSliceUri(
+ Uri.parse(getString(R.string.config_nearby_devices_slice_uri)));
}
/**
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index 998234b..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";
@@ -84,8 +87,10 @@
private PreferenceCategory mAppList;
private Drawable mIcon;
- private CharSequence mLabel;
- private String mPackageName;
+ @VisibleForTesting
+ CharSequence mLabel;
+ @VisibleForTesting
+ String mPackageName;
private CycleAdapter mCycleAdapter;
private List<NetworkCycleDataForUid> mUsageData;
@@ -97,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) {
@@ -108,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());
@@ -133,29 +144,32 @@
mForegroundUsage = findPreference(KEY_FOREGROUND_USAGE);
mBackgroundUsage = findPreference(KEY_BACKGROUND_USAGE);
- mCycle = (SpinnerPreference) findPreference(KEY_CYCLE);
+ mCycle = findPreference(KEY_CYCLE);
mCycleAdapter = new CycleAdapter(mContext, mCycle, mCycleListener);
+ final UidDetailProvider uidDetailProvider = getUidDetailProvider();
+
if (mAppItem.key > 0) {
- if (mPackages.size() != 0) {
- try {
- ApplicationInfo info = mPackageManager.getApplicationInfoAsUser(
- mPackages.valueAt(0), 0, UserHandle.getUserId(mAppItem.key));
- mIcon = IconDrawableFactory.newInstance(getActivity()).getBadgedIcon(info);
- mLabel = info.loadLabel(mPackageManager);
- mPackageName = info.packageName;
- } catch (PackageManager.NameNotFoundException e) {
- }
- }
if (!UserHandle.isApp(mAppItem.key)) {
+ final UidDetail uidDetail = uidDetailProvider.getUidDetail(mAppItem.key, true);
+ mIcon = uidDetail.icon;
+ mLabel = uidDetail.label;
removePreference(KEY_UNRESTRICTED_DATA);
removePreference(KEY_RESTRICT_BACKGROUND);
} else {
- mRestrictBackground = (RestrictedSwitchPreference) findPreference(
- KEY_RESTRICT_BACKGROUND);
+ if (mPackages.size() != 0) {
+ try {
+ final ApplicationInfo info = mPackageManager.getApplicationInfoAsUser(
+ mPackages.valueAt(0), 0, UserHandle.getUserId(mAppItem.key));
+ mIcon = IconDrawableFactory.newInstance(getActivity()).getBadgedIcon(info);
+ mLabel = info.loadLabel(mPackageManager);
+ mPackageName = info.packageName;
+ } catch (PackageManager.NameNotFoundException e) {
+ }
+ }
+ mRestrictBackground = findPreference(KEY_RESTRICT_BACKGROUND);
mRestrictBackground.setOnPreferenceChangeListener(this);
- mUnrestrictedData = (RestrictedSwitchPreference) findPreference(
- KEY_UNRESTRICTED_DATA);
+ mUnrestrictedData = findPreference(KEY_UNRESTRICTED_DATA);
mUnrestrictedData.setOnPreferenceChangeListener(this);
}
mDataSaverBackend = new DataSaverBackend(mContext);
@@ -164,7 +178,7 @@
mAppSettingsIntent = new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE);
mAppSettingsIntent.addCategory(Intent.CATEGORY_DEFAULT);
- PackageManager pm = getPackageManager();
+ final PackageManager pm = getPackageManager();
boolean matchFound = false;
for (String packageName : mPackages) {
mAppSettingsIntent.setPackage(packageName);
@@ -179,7 +193,7 @@
}
if (mPackages.size() > 1) {
- mAppList = (PreferenceCategory) findPreference(KEY_APP_LIST);
+ mAppList = findPreference(KEY_APP_LIST);
LoaderManager.getInstance(this).restartLoader(LOADER_APP_PREF, Bundle.EMPTY,
mAppPrefCallbacks);
} else {
@@ -187,7 +201,7 @@
}
} else {
final Context context = getActivity();
- UidDetail uidDetail = new UidDetailProvider(context).getUidDetail(mAppItem.key, true);
+ final UidDetail uidDetail = uidDetailProvider.getUidDetail(mAppItem.key, true);
mIcon = uidDetail.icon;
mLabel = uidDetail.label;
mPackageName = context.getPackageName();
@@ -257,6 +271,11 @@
updatePrefs(getAppRestrictBackground(), getUnrestrictData());
}
+ @VisibleForTesting
+ UidDetailProvider getUidDetailProvider() {
+ return new UidDetailProvider(mContext);
+ }
+
private void updatePrefs(boolean restrictBackground, boolean unrestrictData) {
final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMeteredDataRestricted(
mContext, mPackageName, UserHandle.getUserId(mAppItem.key));
@@ -276,7 +295,7 @@
}
private void addUid(int uid) {
- String[] packages = getPackageManager().getPackagesForUid(uid);
+ String[] packages = mPackageManager.getPackagesForUid(uid);
if (packages != null) {
for (int i = 0; i < packages.length; i++) {
mPackages.add(packages[i]);
@@ -383,6 +402,9 @@
} else {
builder.addUid(mAppItem.key);
}
+ if (mCycles != null) {
+ builder.setCycles(mCycles);
+ }
return builder.build();
}
@@ -391,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 735532a..e5158ff 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -33,6 +33,7 @@
import android.net.NetworkPolicy;
import android.net.NetworkTemplate;
import android.os.Bundle;
+import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -108,6 +109,7 @@
@VisibleForTesting
int mNetworkType;
private List<NetworkCycleChartData> mCycleData;
+ private ArrayList<Long> mCycles;
private LoadingViewController mLoadingViewController;
private UidDetailProvider mUidDetailProvider;
@@ -362,7 +364,8 @@
category = AppItem.CATEGORY_USER;
}
}
- } else if (uid == UID_REMOVED || uid == UID_TETHERING) {
+ } else if (uid == UID_REMOVED || uid == UID_TETHERING
+ || uid == Process.OTA_UPDATE_UID) {
collapseKey = uid;
category = AppItem.CATEGORY_APP;
} else {
@@ -409,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/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index c0d4779..7a0eb0f 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -52,7 +52,7 @@
@VisibleForTesting
static final int DEFAULT_CARD_COUNT = 4;
static final int CARD_CONTENT_LOADER_ID = 1;
- static final long CARD_CONTENT_LOADER_TIMEOUT_MS = DateUtils.SECOND_IN_MILLIS;
+ static final long CARD_CONTENT_LOADER_TIMEOUT_MS = DateUtils.SECOND_IN_MILLIS * 3;
private static final String TAG = "ContextualCardLoader";
@@ -175,6 +175,7 @@
@VisibleForTesting
boolean isCardEligibleToDisplay(ContextualCard card) {
+ final long startTime = System.currentTimeMillis();
if (card.isCustomCard()) {
return true;
}
@@ -195,6 +196,10 @@
provider.release();
final Slice slice = Slice.bindSlice(mContext, uri, SUPPORTED_SPECS);
+ //TODO(b/123668403): remove the log here once we do the change with FutureTask
+ final long bindTime = System.currentTimeMillis() - startTime;
+ Log.d(TAG, "Binding time for " + uri + " = " + bindTime);
+
if (slice == null || slice.hasHint(HINT_ERROR)) {
Log.w(TAG, "Failed to bind slice, not eligible for display " + uri);
return false;
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index b35a38a..344c248 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -188,6 +188,8 @@
@Override
public void onFinishCardLoading(List<ContextualCard> cards) {
final long loadTime = System.currentTimeMillis() - mStartTime;
+ //TODO(b/123668403): remove the log here once we do the change with FutureTask
+ Log.d(TAG, "Total loading time = " + loadTime);
final List<ContextualCard> cardsToKeep = getCardsToKeep(cards);
//navigate back to the homepage or after card dismissal
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index ea2a308..5673948 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -21,9 +21,6 @@
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -84,17 +81,6 @@
mContext = context;
}
- private static Bitmap getBitmapFromVectorDrawable(Drawable VectorDrawable) {
- final Bitmap bitmap = Bitmap.createBitmap(VectorDrawable.getIntrinsicWidth(),
- VectorDrawable.getIntrinsicHeight(), Config.ARGB_8888);
- final Canvas canvas = new Canvas(bitmap);
-
- VectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- VectorDrawable.draw(canvas);
-
- return bitmap;
- }
-
@Override
public Uri getUri() {
return CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI;
@@ -234,7 +220,7 @@
.getBtClassDrawableWithDescription(mContext, device);
if (pair.first != null) {
- return IconCompat.createWithBitmap(getBitmapFromVectorDrawable(pair.first));
+ return IconCompat.createWithBitmap(Utils.drawableToBitmap(pair.first));
} else {
return IconCompat.createWithResource(mContext,
com.android.internal.R.drawable.ic_settings_bluetooth);
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index 016aa32..692dc0a 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -142,20 +142,6 @@
mNotificationBackend = new NotificationBackend();
}
- private static Bitmap drawableToBitmap(Drawable drawable) {
- if (drawable instanceof BitmapDrawable) {
- return ((BitmapDrawable) drawable).getBitmap();
- }
-
- 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;
- }
-
@Override
public Slice getSlice() {
final ListBuilder listBuilder =
@@ -257,7 +243,7 @@
return null;
}
- return IconCompat.createWithBitmap(drawableToBitmap(drawable));
+ return IconCompat.createWithBitmap(Utils.drawableToBitmap(drawable));
}
@VisibleForTesting
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/TetherProvisioningActivity.java b/src/com/android/settings/network/TetherProvisioningActivity.java
similarity index 89%
rename from src/com/android/settings/TetherProvisioningActivity.java
rename to src/com/android/settings/network/TetherProvisioningActivity.java
index e842db1..b30950e 100644
--- a/src/com/android/settings/TetherProvisioningActivity.java
+++ b/src/com/android/settings/network/TetherProvisioningActivity.java
@@ -14,17 +14,21 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.network;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.os.UserHandle;
+import android.telephony.SubscriptionManager;
import android.util.Log;
+import com.android.settings.Utils;
+
/**
* Activity which acts as a proxy to the tether provisioning app for sanity checks and permission
* restrictions. Specifically, the provisioning apps require
@@ -47,7 +51,9 @@
int tetherType = getIntent().getIntExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE,
ConnectivityManager.TETHERING_INVALID);
- String[] provisionApp = getResources().getStringArray(
+ final int subId = SubscriptionManager.getDefaultDataSubscriptionId();
+ final Resources res = Utils.getResourcesForSubId(this, subId);
+ final String[] provisionApp = res.getStringArray(
com.android.internal.R.array.config_mobile_hotspot_provision_app);
Intent intent = new Intent(Intent.ACTION_MAIN);
diff --git a/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
new file mode 100644
index 0000000..a6db773
--- /dev/null
+++ b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
@@ -0,0 +1,54 @@
+/*
+ * 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.network.telephony;
+
+import android.content.Context;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionManager;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class CarrierSettingsVersionPreferenceController extends BasePreferenceController {
+
+ private int mSubscriptionId;
+ private CarrierConfigManager mManager;
+
+ public CarrierSettingsVersionPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ mManager = context.getSystemService(CarrierConfigManager.class);
+ mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ }
+
+ public void init(int subscriptionId) {
+ mSubscriptionId = subscriptionId;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ final PersistableBundle config = mManager.getConfigForSubId(mSubscriptionId);
+ if (config == null) {
+ return null;
+ }
+ return config.getString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 6d29da1..4f9f020 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -133,6 +133,7 @@
use(CallsDefaultSubscriptionController.class).init(getLifecycle());
use(SmsDefaultSubscriptionController.class).init(getLifecycle());
use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
+ use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
}
use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId);
use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId);
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/password/SetNewPasswordActivity.java b/src/com/android/settings/password/SetNewPasswordActivity.java
index 8e8e7bc..d7445e6 100644
--- a/src/com/android/settings/password/SetNewPasswordActivity.java
+++ b/src/com/android/settings/password/SetNewPasswordActivity.java
@@ -16,7 +16,7 @@
package com.android.settings.password;
-import static android.Manifest.permission.GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY;
+import static android.Manifest.permission.REQUEST_SCREEN_LOCK_COMPLEXITY;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
@@ -83,7 +83,7 @@
if (ACTION_SET_NEW_PASSWORD.equals(mNewPasswordAction)
&& getIntent().hasExtra(EXTRA_PASSWORD_COMPLEXITY)) {
final boolean hasPermission = PasswordUtils.isCallingAppPermitted(
- this, activityToken, GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ this, activityToken, REQUEST_SCREEN_LOCK_COMPLEXITY);
if (hasPermission) {
mRequestedMinComplexity =
PasswordMetrics.sanitizeComplexityLevel(getIntent()
@@ -91,7 +91,7 @@
} else {
PasswordUtils.crashCallingApplication(activityToken,
"Must have permission "
- + GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY + " to use extra "
+ + REQUEST_SCREEN_LOCK_COMPLEXITY + " to use extra "
+ EXTRA_PASSWORD_COMPLEXITY);
finish();
return;
diff --git a/src/com/android/settings/password/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
index 33c3edb..7fbb211 100644
--- a/src/com/android/settings/password/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -16,7 +16,7 @@
package com.android.settings.password;
-import static android.Manifest.permission.GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY;
+import static android.Manifest.permission.REQUEST_SCREEN_LOCK_COMPLEXITY;
import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
@@ -82,10 +82,10 @@
if(getIntent().hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)) {
IBinder activityToken = getActivityToken();
boolean hasPermission = PasswordUtils.isCallingAppPermitted(
- this, activityToken, GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ this, activityToken, REQUEST_SCREEN_LOCK_COMPLEXITY);
if (!hasPermission) {
PasswordUtils.crashCallingApplication(activityToken,
- "Must have permission " + GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY
+ "Must have permission " + REQUEST_SCREEN_LOCK_COMPLEXITY
+ " to use extra " + EXTRA_PASSWORD_COMPLEXITY);
finish();
return;
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index 8f1d4c7..5823407 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,13 +34,14 @@
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";
@@ -65,6 +73,30 @@
return buildPreferenceControllers(context, getSettingsLifecycle());
}
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ styleActionBar();
+ }
+
+ @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);
+ }
+ }
+
private static List<AbstractPreferenceController> buildPreferenceControllers(
Context context, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
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/SliceDeepLinkSpringBoard.java b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
index 8d7f44f..f4afa16 100644
--- a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
+++ b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
@@ -25,80 +25,54 @@
import com.android.settings.notification.ZenModeSliceBuilder;
import com.android.settings.overlay.FeatureFactory;
-import java.net.URISyntaxException;
-
public class SliceDeepLinkSpringBoard extends Activity {
private static final String TAG = "DeeplinkSpringboard";
- public static final String INTENT = "intent";
- public static final String SETTINGS = "settings";
- public static final String ACTION_VIEW_SLICE = "com.android.settings.action.VIEW_SLICE";
public static final String EXTRA_SLICE = "slice";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Uri uri = getIntent().getData();
- if (uri == null) {
+ final Uri sliceUri = parse(getIntent().getData());
+ if (sliceUri == null) {
Log.e(TAG, "No data found");
finish();
return;
}
try {
- Intent intent = parse(uri, getPackageName());
- if (ACTION_VIEW_SLICE.equals(intent.getAction())) {
- // This shouldn't matter since the slice is shown instead of the device
- // index caring about the launch uri.
- final Uri sliceUri = Uri.parse(intent.getStringExtra(EXTRA_SLICE));
- Intent launchIntent;
+ // This shouldn't matter since the slice is shown instead of the device
+ // index caring about the launch uri.
+ Intent launchIntent;
- // TODO (b/80263568) Avoid duplicating this list of Slice Uris.
- final CustomSliceManager customSliceManager = FeatureFactory.getFactory(this)
- .getSlicesFeatureProvider().getCustomSliceManager(this);
- if (customSliceManager.isValidUri(sliceUri)) {
- final CustomSliceable sliceable =
- customSliceManager.getSliceableFromUri(sliceUri);
- launchIntent = sliceable.getIntent();
- } else if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
- launchIntent = ZenModeSliceBuilder.getIntent(this /* context */);
- } else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
- launchIntent = BluetoothSliceBuilder.getIntent(this /* context */);
- } else {
- final SlicesDatabaseAccessor slicesDatabaseAccessor =
- new SlicesDatabaseAccessor(this /* context */);
- // Sadly have to block here because we don't know where to go.
- final SliceData sliceData =
- slicesDatabaseAccessor.getSliceDataFromUri(sliceUri);
- launchIntent = SliceBuilderUtils.getContentIntent(this, sliceData);
- }
-
- startActivity(launchIntent);
+ // TODO (b/80263568) Avoid duplicating this list of Slice Uris.
+ final CustomSliceManager customSliceManager = FeatureFactory.getFactory(this)
+ .getSlicesFeatureProvider().getCustomSliceManager(this);
+ if (customSliceManager.isValidUri(sliceUri)) {
+ final CustomSliceable sliceable =
+ customSliceManager.getSliceableFromUri(sliceUri);
+ launchIntent = sliceable.getIntent();
+ } else if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
+ launchIntent = ZenModeSliceBuilder.getIntent(this /* context */);
+ } else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
+ launchIntent = BluetoothSliceBuilder.getIntent(this /* context */);
} else {
- startActivity(intent);
+ final SlicesDatabaseAccessor slicesDatabaseAccessor =
+ new SlicesDatabaseAccessor(this /* context */);
+ // Sadly have to block here because we don't know where to go.
+ final SliceData sliceData =
+ slicesDatabaseAccessor.getSliceDataFromUri(sliceUri);
+ launchIntent = SliceBuilderUtils.getContentIntent(this, sliceData);
}
+ startActivity(launchIntent);
finish();
- } catch (URISyntaxException e) {
- Log.e(TAG, "Error decoding uri", e);
- finish();
- } catch (IllegalStateException e) {
+ } catch (Exception e) {
Log.w(TAG, "Couldn't launch Slice intent", e);
startActivity(new Intent(Settings.ACTION_SETTINGS));
finish();
}
}
- public static Intent parse(Uri uri, String pkg) throws URISyntaxException {
- Intent intent = Intent.parseUri(uri.getQueryParameter(INTENT),
- Intent.URI_ANDROID_APP_SCHEME);
- // Start with some really strict constraints and loosen them if we need to.
- // Don't allow components.
- intent.setComponent(null);
- // Clear out the extras.
- if (intent.getExtras() != null) {
- intent.getExtras().clear();
- }
- // Make sure this points at Settings.
- intent.setPackage(pkg);
- return intent;
+ private static Uri parse(Uri uri) {
+ return Uri.parse(uri.getQueryParameter(EXTRA_SLICE));
}
}
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/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 881e3d2..2e12bce 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);
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index 4aac538..65be11c 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -19,6 +19,9 @@
import android.app.ActionBar;
import android.app.settings.SettingsEnums;
import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
@@ -31,6 +34,8 @@
import com.android.settings.R;
import com.android.settings.core.InstrumentedActivity;
+import java.util.List;
+
/**
* To provision "other" device with specified Wi-Fi network.
*
@@ -78,6 +83,7 @@
/** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE */
private WifiQrCode mWifiDppQrCode;
+
/** Secret extra that allows fake networks to show in UI for testing purposes */
private boolean mIsTest;
@@ -90,6 +96,9 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setContentView(R.layout.wifi_dpp_activity);
+ mFragmentManager = getSupportFragmentManager();
+
if (savedInstanceState != null) {
String qrCode = savedInstanceState.getString(KEY_QR_CODE);
@@ -103,13 +112,10 @@
mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid,
preSharedKey, hiddenSsid, networkId);
+ } else {
+ handleIntent(getIntent());
}
- setContentView(R.layout.wifi_dpp_activity);
- mFragmentManager = getSupportFragmentManager();
-
- handleIntent(getIntent());
-
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setElevation(0);
@@ -150,7 +156,13 @@
if (mWifiDppQrCode == null || !isDppSupported) {
cancelActivity = true;
} else {
- showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ final WifiNetworkConfig connectedConfig = getConnectedWifiNetworkConfigOrNull();
+ if (connectedConfig == null) {
+ showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ } else {
+ mWifiNetworkConfig = connectedConfig;
+ showAddDeviceFragment(/* addToBackStack */ false);
+ }
}
break;
default:
@@ -167,13 +179,18 @@
WifiDppQrCodeScannerFragment fragment =
(WifiDppQrCodeScannerFragment) mFragmentManager.findFragmentByTag(
WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
- // Avoid to replace the same fragment during configuration change
- if (fragment != null && fragment.isVisible()) {
- return;
- }
if (fragment == null) {
fragment = new WifiDppQrCodeScannerFragment();
+ } else {
+ if (fragment.isVisible()) {
+ return;
+ }
+
+ // When the fragment in back stack but not on top of the stack, we can simply pop
+ // stack because current fragment transactions are arranged in an order
+ mFragmentManager.popBackStackImmediate();
+ return;
}
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
@@ -189,12 +206,19 @@
WifiDppQrCodeGeneratorFragment fragment =
(WifiDppQrCodeGeneratorFragment) mFragmentManager.findFragmentByTag(
WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR);
- // Avoid to replace the same fragment during configuration change
- if (fragment != null && fragment.isVisible()) {
+
+ if (fragment == null) {
+ fragment = new WifiDppQrCodeGeneratorFragment();
+ } else {
+ if (fragment.isVisible()) {
+ return;
+ }
+
+ // When the fragment in back stack but not on top of the stack, we can simply pop
+ // stack because current fragment transactions are arranged in an order
+ mFragmentManager.popBackStackImmediate();
return;
}
-
- fragment = new WifiDppQrCodeGeneratorFragment();
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
@@ -206,10 +230,6 @@
WifiDppChooseSavedWifiNetworkFragment fragment =
(WifiDppChooseSavedWifiNetworkFragment) mFragmentManager.findFragmentByTag(
WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK);
- // Avoid to replace the same fragment during configuration change
- if (fragment != null && fragment.isVisible()) {
- return;
- }
if (fragment == null) {
fragment = new WifiDppChooseSavedWifiNetworkFragment();
@@ -218,6 +238,15 @@
bundle.putBoolean(WifiDppUtils.EXTRA_TEST, true);
fragment.setArguments(bundle);
}
+ } else {
+ if (fragment.isVisible()) {
+ return;
+ }
+
+ // When the fragment in back stack but not on top of the stack, we can simply pop
+ // stack because current fragment transactions are arranged in an order
+ mFragmentManager.popBackStackImmediate();
+ return;
}
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
@@ -234,14 +263,17 @@
(WifiDppAddDeviceFragment) mFragmentManager.findFragmentByTag(
WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE);
- // Avoid to replace the same fragment during configuration change
- if (mFragmentManager.findFragmentByTag(
- WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE) != null) {
- return;
- }
-
if (fragment == null) {
fragment = new WifiDppAddDeviceFragment();
+ } else {
+ if (fragment.isVisible()) {
+ return;
+ }
+
+ // When the fragment in back stack but not on top of the stack, we can simply pop
+ // stack because current fragment transactions are arranged in an order
+ mFragmentManager.popBackStackImmediate();
+ return;
}
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
@@ -359,4 +391,31 @@
showAddDeviceFragment(/* addToBackStack */ true);
}
+
+ private WifiNetworkConfig getConnectedWifiNetworkConfigOrNull() {
+ final WifiManager wifiManager = getSystemService(WifiManager.class);
+ if (!wifiManager.isWifiEnabled()) {
+ return null;
+ }
+
+ final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
+ if (connectionInfo == null) {
+ return null;
+ }
+
+ final int connectionNetworkId = connectionInfo.getNetworkId();
+ final List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();
+ for (WifiConfiguration wifiConfiguration : configs) {
+ if (wifiConfiguration.networkId == connectionNetworkId) {
+ return WifiNetworkConfig.getValidConfigOrNull(
+ WifiDppUtils.getSecurityString(wifiConfiguration),
+ wifiConfiguration.getPrintableSsid(),
+ wifiConfiguration.preSharedKey,
+ /* hiddenSsid */ false,
+ wifiConfiguration.networkId);
+ }
+ }
+
+ return null;
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
index df36ae5..143f87f 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
@@ -100,7 +100,9 @@
setContentView(R.layout.wifi_dpp_activity);
mFragmentManager = getSupportFragmentManager();
- handleIntent(getIntent());
+ if (savedInstanceState == null) {
+ handleIntent(getIntent());
+ }
ActionBar actionBar = getActionBar();
if (actionBar != null) {
@@ -122,13 +124,23 @@
}
private void showQrCodeScannerFragment(boolean addToBackStack, String ssid) {
- // Avoid to replace the same fragment during configuration change
- if (mFragmentManager.findFragmentByTag(WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER) != null) {
+ WifiDppQrCodeScannerFragment fragment =
+ (WifiDppQrCodeScannerFragment) mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
+
+ if (fragment == null) {
+ fragment = new WifiDppQrCodeScannerFragment(ssid);
+ } else {
+ if (fragment.isVisible()) {
+ return;
+ }
+
+ // When the fragment in back stack but not on top of the stack, we can simply pop
+ // stack because current fragment transactions are arranged in an order
+ mFragmentManager.popBackStackImmediate();
return;
}
-
- WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment(ssid);
- FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+ final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 9c69032..7bc80e0 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.content.Intent;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.text.TextUtils;
@@ -147,6 +148,17 @@
}
}
+ static String getSecurityString(WifiConfiguration config) {
+ if (config.allowedKeyManagement.get(KeyMgmt.SAE)) {
+ return WifiQrCode.SECURITY_SAE;
+ }
+ if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
+ return WifiQrCode.SECURITY_WPA_PSK;
+ }
+ return (config.wepKeys[0] == null) ?
+ WifiQrCode.SECURITY_NO_PASSWORD : WifiQrCode.SECURITY_WEP;
+ }
+
/**
* Returns an intent to launch QR code generator or scanner according to the Wi-Fi network
* security. It may return null if the security is not supported by QR code generator nor
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
index 89efc31..ce92f90 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
@@ -20,7 +20,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.net.NetworkInfo.DetailedState;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -28,7 +27,6 @@
import android.view.View;
import android.widget.Toast;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -64,9 +62,6 @@
private WifiManager.ActionListener mSaveListener;
private boolean mIsTest;
- @VisibleForTesting
- boolean mUseConnectedAccessPointDirectly;
-
// Container Activity must implement this interface
public interface OnChooseNetworkListener {
public void onChooseNetwork(WifiNetworkConfig wifiNetworkConfig);
@@ -123,8 +118,6 @@
}
}
};
-
- mUseConnectedAccessPointDirectly = true;
}
@Override
@@ -310,16 +303,6 @@
if (isValidForDppConfiguration(accessPoint)) {
final String key = accessPoint.getKey();
- // Check if this access point is already connected.
- if (mUseConnectedAccessPointDirectly
- && accessPoint.getDetailedState() == DetailedState.CONNECTED) {
- // Uses connected access point to start DPP in Configurator-Initiator role
- // directly.
- onPreferenceTreeClick(createAccessPointPreference(accessPoint));
- removeCachedPrefs(mAccessPointsPreferenceCategory);
- return;
- }
-
final AccessPointPreference pref = (AccessPointPreference) getCachedPreference(key);
if (pref != null) {
pref.setOrder(index);
diff --git a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
index fa8c267..7a6d1fa 100644
--- a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
+++ b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
@@ -16,17 +16,26 @@
package com.android.settings.wifi.slice;
+import android.annotation.ColorInt;
import android.content.Context;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
+import android.graphics.drawable.Drawable;
+import android.net.NetworkInfo.State;
import android.net.Uri;
import android.net.wifi.WifiSsid;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
+import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
+import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
+import com.android.settingslib.wifi.AccessPoint;
/**
* {@link CustomSliceable} for Wi-Fi, used by contextual homepage.
@@ -56,6 +65,36 @@
// keep showing this card to keep UI stable, even if wifi connects to a network later.
mPreviouslyDisplayed = true;
+ // Reload theme for switching dark mode on/off
+ mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
+
return super.getSlice();
}
+
+ @Override
+ protected IconCompat getAccessPointLevelIcon(AccessPoint accessPoint) {
+ final Drawable d = mContext.getDrawable(
+ com.android.settingslib.Utils.getWifiIconResource(accessPoint.getLevel()));
+
+ @ColorInt int color;
+ if (accessPoint.isActive()) {
+ final State state = accessPoint.getNetworkInfo().getState();
+ if (state == State.CONNECTED) {
+ color = Utils.getColorAccentDefaultColor(mContext);
+ } else { // connecting
+ color = Utils.getDisabled(mContext, Utils.getColorAttrDefaultColor(mContext,
+ android.R.attr.colorControlNormal));
+ }
+ } else {
+ color = Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal);
+ }
+
+ d.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
+ return IconCompat.createWithBitmap(Utils.drawableToBitmap(d));
+ }
+
+ @Override
+ protected int getSliceAccentColor() {
+ return -1;
+ }
}
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index bee643d..b6fc17c 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -64,8 +64,8 @@
@VisibleForTesting
static final int DEFAULT_EXPANDED_ROW_COUNT = 3;
+ protected final Context mContext;
protected final WifiManager mWifiManager;
- private final Context mContext;
public WifiSlice(Context context) {
mContext = context;
@@ -85,7 +85,7 @@
R.drawable.ic_settings_wireless);
final String title = mContext.getString(R.string.wifi_settings);
final CharSequence summary = getSummary();
- @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
+ @ColorInt final int color = getSliceAccentColor();
final PendingIntent toggleAction = getBroadcastIntent(mContext);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
@@ -120,29 +120,22 @@
listBuilder.addRow(getAccessPointRow(results.get(i)));
} else if (needLoadingRow) {
listBuilder.addRow(new ListBuilder.RowBuilder()
- .setTitle(mContext.getText(R.string.wifi_empty_list_wifi_on))
- .setSubtitle(placeholder));
+ .setTitle(mContext.getText(R.string.wifi_empty_list_wifi_on)));
needLoadingRow = false;
} else {
listBuilder.addRow(new ListBuilder.RowBuilder()
- .setTitle(placeholder)
- .setSubtitle(placeholder));
+ .setTitle(placeholder));
}
}
return listBuilder.build();
}
private ListBuilder.RowBuilder getAccessPointRow(AccessPoint accessPoint) {
- final String title = accessPoint.getConfigName();
- final IconCompat levelIcon = IconCompat.createWithResource(mContext,
- com.android.settingslib.Utils.getWifiIconResource(accessPoint.getLevel()));
- final CharSequence apSummary = accessPoint.getSettingsSummary();
+ final CharSequence title = accessPoint.getConfigName();
+ final IconCompat levelIcon = getAccessPointLevelIcon(accessPoint);
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
.setTitleItem(levelIcon, ListBuilder.ICON_IMAGE)
.setTitle(title)
- .setSubtitle(!TextUtils.isEmpty(apSummary)
- ? apSummary
- : null)
.setPrimaryAction(SliceAction.create(
getAccessPointAction(accessPoint), levelIcon, ListBuilder.ICON_IMAGE,
title));
@@ -154,9 +147,19 @@
return rowBuilder;
}
+ protected IconCompat getAccessPointLevelIcon(AccessPoint accessPoint) {
+ return IconCompat.createWithResource(mContext,
+ com.android.settingslib.Utils.getWifiIconResource(accessPoint.getLevel()));
+ }
+
+ @ColorInt
+ protected int getSliceAccentColor() {
+ return Utils.getColorAccentDefaultColor(mContext);
+ }
+
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/src/com/android/settings/wifi/tether/TetherService.java b/src/com/android/settings/wifi/tether/TetherService.java
index 4b39f67..09781a8 100644
--- a/src/com/android/settings/wifi/tether/TetherService.java
+++ b/src/com/android/settings/wifi/tether/TetherService.java
@@ -32,16 +32,20 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.os.IBinder;
import android.os.ResultReceiver;
import android.os.SystemClock;
+import android.telephony.SubscriptionManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
+import com.android.settings.Utils;
+
import java.util.ArrayList;
import java.util.List;
@@ -65,7 +69,7 @@
private int mCurrentTypeIndex;
private boolean mInProvisionCheck;
- private UsageStatsManagerWrapper mUsageManagerWrapper;
+ private TetherServiceWrapper mWrapper;
private ArrayList<Integer> mCurrentTethers;
private ArrayMap<Integer, List<ResultReceiver>> mPendingCallbacks;
private HotspotOffReceiver mHotspotReceiver;
@@ -79,7 +83,7 @@
public void onCreate() {
super.onCreate();
if (DEBUG) Log.d(TAG, "Creating TetherService");
- String provisionResponse = getResources().getString(
+ String provisionResponse = getResourceForDefaultDataSubId().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_response);
registerReceiver(mReceiver, new IntentFilter(provisionResponse),
android.Manifest.permission.CONNECTIVITY_INTERNAL, null);
@@ -91,9 +95,6 @@
mPendingCallbacks.put(ConnectivityManager.TETHERING_USB, new ArrayList<ResultReceiver>());
mPendingCallbacks.put(
ConnectivityManager.TETHERING_BLUETOOTH, new ArrayList<ResultReceiver>());
- if (mUsageManagerWrapper == null) {
- mUsageManagerWrapper = new UsageStatsManagerWrapper(this);
- }
mHotspotReceiver = new HotspotOffReceiver(this);
}
@@ -258,7 +259,7 @@
}
private Intent getProvisionBroadcastIntent(int index) {
- String provisionAction = getResources().getString(
+ String provisionAction = getResourceForDefaultDataSubId().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui);
Intent intent = new Intent(provisionAction);
int type = mCurrentTethers.get(index);
@@ -282,7 +283,7 @@
for (ResolveInfo resolver : resolvers) {
if (resolver.activityInfo.applicationInfo.isSystemApp()) {
String packageName = resolver.activityInfo.packageName;
- mUsageManagerWrapper.setAppInactive(packageName, false);
+ getTetherServiceWrapper().setAppInactive(packageName, false);
}
}
}
@@ -294,7 +295,7 @@
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
- int period = getResources().getInteger(
+ int period = getResourceForDefaultDataSubId().getInteger(
com.android.internal.R.integer.config_mobile_hotspot_provision_check_period);
long periodMs = period * MS_PER_HOUR;
long firstTime = SystemClock.elapsedRealtime() + periodMs;
@@ -347,7 +348,7 @@
@Override
public void onReceive(Context context, Intent intent) {
if (DEBUG) Log.d(TAG, "Got provision result " + intent);
- String provisionResponse = getResources().getString(
+ String provisionResponse = getResourceForDefaultDataSubId().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_response);
if (provisionResponse.equals(intent.getAction())) {
@@ -385,19 +386,27 @@
};
@VisibleForTesting
- void setUsageStatsManagerWrapper(UsageStatsManagerWrapper wrapper) {
- mUsageManagerWrapper = wrapper;
+ void setTetherServiceWrapper(TetherServiceWrapper wrapper) {
+ mWrapper = wrapper;
+ }
+
+ private TetherServiceWrapper getTetherServiceWrapper() {
+ if (mWrapper == null) {
+ mWrapper = new TetherServiceWrapper(this);
+ }
+ return mWrapper;
}
/**
- * A static helper class used for tests. UsageStatsManager cannot be mocked out becasue
- * it's marked final. This class can be mocked out instead.
+ * A static helper class used for tests. UsageStatsManager cannot be mocked out because
+ * it's marked final. Static method SubscriptionManager#getResourcesForSubId also cannot
+ * be mocked. This class can be mocked out instead.
*/
@VisibleForTesting
- public static class UsageStatsManagerWrapper {
+ public static class TetherServiceWrapper {
private final UsageStatsManager mUsageStatsManager;
- UsageStatsManagerWrapper(Context context) {
+ TetherServiceWrapper(Context context) {
mUsageStatsManager = (UsageStatsManager)
context.getSystemService(Context.USAGE_STATS_SERVICE);
}
@@ -405,5 +414,15 @@
void setAppInactive(String packageName, boolean isInactive) {
mUsageStatsManager.setAppInactive(packageName, isInactive);
}
+
+ int getDefaultDataSubscriptionId() {
+ return SubscriptionManager.getDefaultDataSubscriptionId();
+ }
+ }
+
+ @VisibleForTesting
+ Resources getResourceForDefaultDataSubId() {
+ final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId();
+ return Utils.getResourcesForSubId(this, subId);
}
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
index 9577fa7..57fd86b 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
@@ -294,6 +294,7 @@
PbapServerProfile psp = mock(PbapServerProfile.class);
when(psp.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_pbap);
when(psp.toString()).thenReturn(PbapServerProfile.NAME);
+ when(psp.isProfileReady()).thenReturn(true);
when(mProfileManager.getPbapProfile()).thenReturn(psp);
showScreen(mController);
@@ -316,6 +317,7 @@
PbapServerProfile psp = mock(PbapServerProfile.class);
when(psp.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_pbap);
when(psp.toString()).thenReturn(PbapServerProfile.NAME);
+ when(psp.isProfileReady()).thenReturn(true);
when(mProfileManager.getPbapProfile()).thenReturn(psp);
showScreen(mController);
@@ -336,6 +338,7 @@
setupDevice(makeDefaultDeviceConfig());
MapProfile mapProfile = mock(MapProfile.class);
when(mapProfile.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_map);
+ when(mapProfile.isProfileReady()).thenReturn(true);
when(mProfileManager.getMapProfile()).thenReturn(mapProfile);
when(mProfileManager.getProfileByName(eq(mapProfile.toString()))).thenReturn(mapProfile);
mDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_REJECTED);
@@ -361,6 +364,7 @@
when(profile.supportsHighQualityAudio(mDevice)).thenReturn(supportsHighQualityAudio);
when(profile.isHighQualityAudioEnabled(mDevice)).thenReturn(highQualityAudioEnabled);
when(profile.isPreferred(mDevice)).thenReturn(preferred);
+ when(profile.isProfileReady()).thenReturn(true);
mConnectableProfiles.add(profile);
return profile;
}
@@ -442,12 +446,25 @@
setupDevice(makeDefaultDeviceConfig());
A2dpProfile audioProfile = addMockA2dpProfile(false, true, true);
showScreen(mController);
- SwitchPreference audioPref =
- (SwitchPreference) mScreen.findPreference(audioProfile.toString());
+ SwitchPreference audioPref = mScreen.findPreference(audioProfile.toString());
SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
assertThat(audioPref).isNotNull();
assertThat(audioPref.isChecked()).isFalse();
assertThat(highQualityAudioPref).isNotNull();
assertThat(highQualityAudioPref.isVisible()).isFalse();
}
+
+ @Test
+ public void onResume_addServiceListener() {
+ mController.onResume();
+
+ verify(mProfileManager).addServiceListener(mController);
+ }
+
+ @Test
+ public void onPause_removeServiceListener() {
+ mController.onPause();
+
+ verify(mProfileManager).removeServiceListener(mController);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
index df87761..2328375 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
@@ -15,10 +15,8 @@
*/
package com.android.settings.connecteddevice;
-import static com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment
- .KEY_AVAILABLE_DEVICES;
-import static com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment
- .KEY_CONNECTED_DEVICES;
+import static com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment.KEY_AVAILABLE_DEVICES;
+import static com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment.KEY_CONNECTED_DEVICES;
import static com.google.common.truth.Truth.assertThat;
@@ -30,6 +28,9 @@
import android.provider.SearchIndexableResource;
import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerListHelper;
+import com.android.settings.slices.SlicePreferenceController;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
@@ -49,6 +50,7 @@
@Config(shadows = {ShadowUserManager.class,
ShadowConnectivityManager.class, ShadowBluetoothAdapter.class})
public class ConnectedDeviceDashboardFragmentTest {
+ private static final String KEY_NEARBY_DEVICES = "bt_nearby_slice";
@Mock
private PackageManager mPackageManager;
@@ -64,7 +66,7 @@
}
@Test
- public void testSearchIndexProvider_shouldIndexResource() {
+ public void searchIndexProvider_shouldIndexResource() {
final List<SearchIndexableResource> indexRes =
ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
.getXmlResourcesToIndex(mContext, true /* enabled */);
@@ -74,10 +76,24 @@
}
@Test
- public void testNonIndexableKeys_existInXmlLayout() {
+ public void nonIndexableKeys_existInXmlLayout() {
final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext);
- assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES);
+ assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
+ KEY_NEARBY_DEVICES);
+ }
+
+ @Test
+ public void getPreferenceControllers_containSlicePrefController() {
+ final List<BasePreferenceController> controllers =
+ PreferenceControllerListHelper.getPreferenceControllersFromXml(mContext,
+ R.xml.connected_devices);
+
+ assertThat(controllers
+ .stream()
+ .filter(controller -> controller instanceof SlicePreferenceController)
+ .count())
+ .isEqualTo(1);
}
}
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index 2855554..6cecd98 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -22,6 +22,7 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -31,10 +32,13 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.net.NetworkPolicyManager;
import android.net.NetworkTemplate;
import android.os.Bundle;
+import android.os.Process;
import android.telephony.SubscriptionManager;
import android.text.format.DateUtils;
import android.util.ArraySet;
@@ -56,6 +60,8 @@
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.net.NetworkCycleDataForUid;
import com.android.settingslib.net.NetworkCycleDataForUidLoader;
+import com.android.settingslib.net.UidDetail;
+import com.android.settingslib.net.UidDetailProvider;
import org.junit.After;
import org.junit.Before;
@@ -96,6 +102,62 @@
}
@Test
+ public void onCreate_appUid_shouldGetAppLabelFromAppInfo() throws NameNotFoundException {
+ mFragment = spy(new AppDataUsage());
+ final FragmentActivity activity = spy(Robolectric.setupActivity(FragmentActivity.class));
+ doReturn(mPackageManager).when(activity).getPackageManager();
+ doReturn(activity).when(mFragment).getActivity();
+ doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
+ ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
+ FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
+ final String packageName = "testPackage";
+ final int uid = (Process.FIRST_APPLICATION_UID + Process.LAST_APPLICATION_UID) / 2;
+ doReturn(new String[] {packageName}).when(mPackageManager).getPackagesForUid(uid);
+ final String label = "testLabel";
+ final AppItem appItem = new AppItem(uid);
+ appItem.uids.put(uid, true);
+ final ApplicationInfo info = spy(new ApplicationInfo());
+ doReturn(label).when(info).loadLabel(mPackageManager);
+ when(mPackageManager.getApplicationInfoAsUser(
+ eq(packageName), anyInt() /* flags */, anyInt() /* userId */)).thenReturn(info);
+ final Bundle args = new Bundle();
+ args.putParcelable(AppDataUsage.ARG_APP_ITEM, appItem);
+ args.putInt(AppInfoBase.ARG_PACKAGE_UID, uid);
+ mFragment.setArguments(args);
+
+ mFragment.onCreate(Bundle.EMPTY);
+
+ assertThat(mFragment.mLabel).isEqualTo(label);
+ }
+
+ @Test
+ public void onCreate_notAppUid_shouldGetAppLabelFromUidDetailProvider() {
+ mFragment = spy(new AppDataUsage());
+ ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
+ FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
+ 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();
+ final String label = "testLabel";
+ final int uid = Process.SYSTEM_UID;
+ final UidDetail uidDetail = new UidDetail();
+ uidDetail.label = label;
+ when(uidDetailProvider.getUidDetail(eq(uid), anyBoolean() /* blocking */)).
+ thenReturn(uidDetail);
+ final AppItem appItem = new AppItem(uid);
+ appItem.uids.put(uid, true);
+ final Bundle args = new Bundle();
+ args.putParcelable(AppDataUsage.ARG_APP_ITEM, appItem);
+ args.putInt(AppInfoBase.ARG_PACKAGE_UID, uid);
+ mFragment.setArguments(args);
+
+ mFragment.onCreate(Bundle.EMPTY);
+
+ assertThat(mFragment.mLabel).isEqualTo(label);
+ }
+
+ @Test
public void bindAppHeader_allWorkApps_shouldNotShowAppInfoLink() {
ShadowEntityHeaderController.setUseMock(mHeaderController);
when(mHeaderController.setRecyclerView(any(), any())).thenReturn(mHeaderController);
@@ -283,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;
@@ -293,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/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index feb3533..73fea77 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -341,7 +341,7 @@
final StorageItemPreference apps = spy(new StorageItemPreference(mContext));
apps.setIcon(R.drawable.ic_storage_apps);
final StorageItemPreference system = spy(new StorageItemPreference(mContext));
- system.setIcon(R.drawable.ic_system_update_vd_theme_24);
+ system.setIcon(R.drawable.ic_system_update);
final StorageItemPreference files = spy(new StorageItemPreference(mContext));
files.setIcon(R.drawable.ic_folder_vd_theme_24);
final PreferenceScreen screen = mock(PreferenceScreen.class);
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/telephony/CarrierSettingsVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..268c581
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceControllerTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.network.telephony;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
+
+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.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowCarrierConfigManager;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowCarrierConfigManager.class)
+public class CarrierSettingsVersionPreferenceControllerTest {
+
+ private ShadowCarrierConfigManager mCarrierConfigManager;
+ private CarrierSettingsVersionPreferenceController mController;
+ private int mSubscriptionId = 1234;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ mController = new CarrierSettingsVersionPreferenceController(context, "dummy_key");
+ mController.init(mSubscriptionId);
+ mCarrierConfigManager = Shadows.shadowOf(
+ context.getSystemService(CarrierConfigManager.class));
+ }
+
+ @Test
+ public void getSummary_nullConfig_noCrash() {
+ mCarrierConfigManager.setConfigForSubId(mSubscriptionId, null);
+ assertThat(mController.getSummary()).isNull();
+ }
+
+ @Test
+ public void getSummary_nullVersionString_noCrash() {
+ mCarrierConfigManager.setConfigForSubId(mSubscriptionId, new PersistableBundle());
+ assertThat(mController.getSummary()).isNull();
+ }
+
+ @Test
+ public void getSummary_hasVersionString_correctSummary() {
+ final PersistableBundle bundle = new PersistableBundle();
+ bundle.putString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING,
+ "test_version_123");
+ mCarrierConfigManager.setConfigForSubId(mSubscriptionId, bundle);
+ assertThat(mController.getSummary()).isEqualTo("test_version_123");
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java b/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
index 4232016..48f9fb4 100644
--- a/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
@@ -16,7 +16,7 @@
package com.android.settings.password;
-import static android.Manifest.permission.GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY;
+import static android.Manifest.permission.REQUEST_SCREEN_LOCK_COMPLEXITY;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
@@ -139,7 +139,7 @@
public void testLaunchChooseLock_setNewPasswordExtraWithPermission() {
ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 1);
@@ -169,7 +169,7 @@
public void testLaunchChooseLock_setNewPasswordExtraInvalidValue() {
ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 1);
@@ -197,7 +197,7 @@
public void testLaunchChooseLock_setNewPasswordExtraNoneComplexity() {
ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 1);
@@ -225,7 +225,7 @@
public void testLaunchChooseLock_setNewPasswordWithoutExtra() {
ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 1);
@@ -252,7 +252,7 @@
public void testLaunchChooseLock_setNewParentProfilePasswordExtraWithPermission() {
ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 1);
@@ -280,7 +280,7 @@
public void testLaunchChooseLock_setNewParentProfilePasswordWithoutExtra() {
ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 1);
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockGenericTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockGenericTest.java
index 63bdc38..d35b38a 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockGenericTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockGenericTest.java
@@ -16,7 +16,7 @@
package com.android.settings.password;
-import static android.Manifest.permission.GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY;
+import static android.Manifest.permission.REQUEST_SCREEN_LOCK_COMPLEXITY;
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_HIGH;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
@@ -68,7 +68,7 @@
@Test
@Config(shadows = {ShadowPasswordUtils.class})
public void setupChooseLockGenericPasswordComplexityExtraWithPermission() {
- ShadowPasswordUtils.addGrantedPermission(GET_AND_REQUEST_SCREEN_LOCK_COMPLEXITY);
+ ShadowPasswordUtils.addGrantedPermission(REQUEST_SCREEN_LOCK_COMPLEXITY);
Intent intent = new Intent("com.android.settings.SETUP_LOCK_SCREEN");
intent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_HIGH);
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..d073e9b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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 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.ActionBar;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class PrivacyDashboardFragmentTest {
+
+ private Context mContext;
+ private PrivacyDashboardFragment mFragment;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mFragment = spy(new PrivacyDashboardFragment());
+ }
+
+ @Test
+ public void onViewCreated_shouldCallStyleActionBar() {
+ final FragmentActivity activity = spy(
+ Robolectric.buildActivity(FragmentActivity.class).get());
+ final ActionBar actionBar = mock(ActionBar.class);
+
+ when(mFragment.getActivity()).thenReturn(activity);
+ when(mFragment.getSettingsLifecycle()).thenReturn(mock(Lifecycle.class));
+ when(mFragment.getListView()).thenReturn(mock(RecyclerView.class));
+ when(activity.getActionBar()).thenReturn(actionBar);
+
+ mFragment.onViewCreated(new View(mContext), new Bundle());
+
+ verify(mFragment).styleActionBar();
+ }
+}
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/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..45860bf 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))
+ .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/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java b/tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java
index 4ed04f0..aec6dd2 100644
--- a/tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java
+++ b/tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java
@@ -70,16 +70,16 @@
BluetoothDeviceDetailsFragment.sTestDataFactory =
new BluetoothDeviceDetailsFragment.TestDataFactory() {
- @Override
- public CachedBluetoothDevice getDevice(String deviceAddress) {
- return mCachedDevice;
- }
+ @Override
+ public CachedBluetoothDevice getDevice(String deviceAddress) {
+ return mCachedDevice;
+ }
- @Override
- public LocalBluetoothManager getManager(Context context) {
- return mBluetoothManager;
- }
- };
+ @Override
+ public LocalBluetoothManager getManager(Context context) {
+ return mBluetoothManager;
+ }
+ };
}
@Test
@@ -103,4 +103,4 @@
throw new RuntimeException(e);
}
}
-}
+}
\ No newline at end of file
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
index 18d62c2..c1c1d54 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
@@ -98,7 +98,6 @@
private void callOnWifiStateChanged(int state) {
mActivityRule.getActivity().getMainThreadHandler()
.post(() -> mWifiNetworkListFragment.onWifiStateChanged(state));
- mWifiNetworkListFragment.mUseConnectedAccessPointDirectly = false;
}
/** Launch the activity via an Intent with a String extra. */
@@ -173,4 +172,4 @@
onView(withText(resourceString(WIFI_DISPLAY_STATUS_CONNECTED))).check(
matches(isDisplayed()));
}
-}
\ No newline at end of file
+}
diff --git a/tests/unit/src/com/android/settings/wifi/tether/TetherServiceTest.java b/tests/unit/src/com/android/settings/wifi/tether/TetherServiceTest.java
index 09b317c..0332092 100644
--- a/tests/unit/src/com/android/settings/wifi/tether/TetherServiceTest.java
+++ b/tests/unit/src/com/android/settings/wifi/tether/TetherServiceTest.java
@@ -27,6 +27,8 @@
import static android.net.ConnectivityManager.TETHERING_WIFI;
import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
import static android.net.ConnectivityManager.TETHER_ERROR_PROVISION_FAILED;
+import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
@@ -83,7 +85,7 @@
private TetherService mService;
private MockResources mResources;
- private FakeUsageStatsManagerWrapper mUsageStatsManagerWrapper;
+ private MockTetherServiceWrapper mWrapper;
int mLastReceiverResultCode = BOGUS_RECEIVER_RESULT;
private int mLastTetherRequestType = TETHERING_INVALID;
private int mProvisionResponse = BOGUS_RECEIVER_RESULT;
@@ -125,7 +127,7 @@
when(mPrefs.edit()).thenReturn(mPrefEditor);
when(mPrefEditor.putString(eq(CURRENT_TYPES), mStoredTypes.capture())).thenReturn(
mPrefEditor);
- mUsageStatsManagerWrapper = new FakeUsageStatsManagerWrapper(mContext);
+ mWrapper = new MockTetherServiceWrapper(mContext);
ResolveInfo systemAppResolveInfo = new ResolveInfo();
ActivityInfo systemActivityInfo = new ActivityInfo();
@@ -146,6 +148,8 @@
resolvers.add(systemAppResolveInfo);
when(mPackageManager.queryBroadcastReceivers(
any(Intent.class), eq(PackageManager.MATCH_ALL))).thenReturn(resolvers);
+ setupService();
+ getService().setTetherServiceWrapper(mWrapper);
}
@Override
@@ -171,16 +175,13 @@
}
public void testStartKeepsProvisionAppActive() {
- setupService();
- getService().setUsageStatsManagerWrapper(mUsageStatsManagerWrapper);
-
runProvisioningForType(TETHERING_WIFI);
assertTrue(waitForProvisionRequest(TETHERING_WIFI));
assertTrue(waitForProvisionResponse(TETHER_ERROR_NO_ERROR));
- assertFalse(mUsageStatsManagerWrapper.isAppInactive(ENTITLEMENT_PACKAGE_NAME));
+ assertFalse(mWrapper.isAppInactive(ENTITLEMENT_PACKAGE_NAME));
// Non-system handler of the intent action should stay idle.
- assertTrue(mUsageStatsManagerWrapper.isAppInactive(FAKE_PACKAGE_NAME));
+ assertTrue(mWrapper.isAppInactive(FAKE_PACKAGE_NAME));
}
public void testScheduleRechecks() {
@@ -419,11 +420,11 @@
}
}
- private static class FakeUsageStatsManagerWrapper
- extends TetherService.UsageStatsManagerWrapper {
+ private static class MockTetherServiceWrapper
+ extends TetherService.TetherServiceWrapper {
private final Set<String> mActivePackages;
- FakeUsageStatsManagerWrapper(Context context) {
+ MockTetherServiceWrapper(Context context) {
super(context);
mActivePackages = new HashSet<>();
}
@@ -440,5 +441,10 @@
boolean isAppInactive(String packageName) {
return !mActivePackages.contains(packageName);
}
+
+ @Override
+ int getDefaultDataSubscriptionId() {
+ return INVALID_SUBSCRIPTION_ID;
+ }
}
}