Merge "Add logging when launch fragment name is null."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 08d93fc..d5bc1ec 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -891,7 +891,7 @@
<activity android:name="Settings$DisplaySettingsActivity"
android:label="@string/display_settings"
- android:icon="@drawable/ic_settings_display"
+ android:icon="@drawable/ic_dashboard_display"
android:taskAffinity="">
<intent-filter android:priority="1">
<action android:name="com.android.settings.DISPLAY_SETTINGS" />
@@ -1271,7 +1271,7 @@
<activity android:name="Settings$SecuritySettingsActivity"
android:label="@string/security_settings_title"
- android:icon="@drawable/ic_settings_security"
+ android:icon="@drawable/ic_dashboard_security"
android:configChanges="orientation|keyboardHidden|screenSize"
android:taskAffinity=""
android:parentActivityName="Settings">
@@ -2045,11 +2045,11 @@
android:theme="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert">
</activity>
+ <service android:name=".bluetooth.BluetoothPairingService" />
+
<receiver android:name=".bluetooth.BluetoothPairingRequest">
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
- <action android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
- <action android:name="android.bluetooth.device.action.BOND_STATE_CHANGED" />
</intent-filter>
</receiver>
@@ -2254,26 +2254,6 @@
</intent-filter>
</activity>
- <activity android:name="Settings$AccountSettingsActivity"
- android:label="@string/account_settings_title"
- android:icon="@drawable/ic_settings_accounts"
- android:taskAffinity=""
- android:parentActivityName="Settings">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter android:priority="1">
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.personal" />
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.accounts.AccountSettings" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- </activity>
-
<activity android:name="Settings$AccountSyncSettingsActivity"
android:label="@string/account_sync_settings_title"
android:taskAffinity=""
@@ -2309,7 +2289,7 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/header_add_an_account"
android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$ManageAccountsSettingsActivity">
+ android:parentActivityName="Settings$UserAndAccountDashboardActivity">
<intent-filter android:priority="1">
<action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -3013,7 +2993,7 @@
<activity android:name=".Settings$NetworkDashboardActivity"
android:taskAffinity=""
android:label="@string/network_dashboard_title"
- android:icon="@drawable/ic_settings_wireless">
+ android:icon="@drawable/ic_dashboard_network">
<intent-filter android:priority="10">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3052,7 +3032,7 @@
<activity android:name=".Settings$AppAndNotificationDashboardActivity"
android:label="@string/app_and_notification_dashboard_title"
- android:icon="@drawable/ic_apps">
+ android:icon="@drawable/ic_dashboard_apps">
<intent-filter android:priority="9">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3091,7 +3071,8 @@
</activity-alias>
<activity-alias android:name="SoundDashboardAlias"
- android:targetActivity="Settings$SoundSettingsActivity">
+ android:targetActivity="Settings$SoundSettingsActivity"
+ android:icon="@drawable/ic_dashboard_sound">
<intent-filter android:priority="6">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
@@ -3107,7 +3088,7 @@
<activity android:name=".Settings$StorageDashboardActivity"
android:label="@string/storage_settings"
- android:icon="@drawable/ic_settings_storage">
+ android:icon="@drawable/ic_dashboard_storage">
<intent-filter android:priority="5">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
@@ -3134,7 +3115,7 @@
<activity android:name=".Settings$UserAndAccountDashboardActivity"
android:label="@string/account_dashboard_title"
- android:icon="@drawable/ic_settings_accounts">
+ android:icon="@drawable/ic_dashboard_user">
<intent-filter android:priority="3">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
@@ -3146,6 +3127,8 @@
android:value="com.android.settings.accounts.UserAndAccountDashboardFragment"/>
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.homepage"/>
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
</activity>
<activity-alias android:name="AccessibilityDashboardAlias"
@@ -3165,7 +3148,7 @@
<activity android:name=".Settings$SystemDashboardActivity"
android:label="@string/header_category_system"
- android:icon="@drawable/ic_settings_about">
+ android:icon="@drawable/ic_dashboard_system">
<intent-filter android:priority="1">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
diff --git a/res/color/storage_wizard_button_red.xml b/res/color/storage_wizard_button_red.xml
index 9e9a908..59de7c7 100644
--- a/res/color/storage_wizard_button_red.xml
+++ b/res/color/storage_wizard_button_red.xml
@@ -17,6 +17,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:alpha="?android:attr/disabledAlpha"
- android:color="#fff4511e" />
- <item android:color="#fff4511e" />
+ android:color="?android:attr/colorError" />
+ <item android:color="?android:attr/colorError" />
</selector>
diff --git a/res/drawable/ic_dashboard_apps.xml b/res/drawable/ic_dashboard_apps.xml
new file mode 100644
index 0000000..c0083a6
--- /dev/null
+++ b/res/drawable/ic_dashboard_apps.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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">
+ <path
+ android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z"
+ android:fillColor="#ec8122"/>
+</vector>
diff --git a/res/drawable/ic_dashboard_display.xml b/res/drawable/ic_dashboard_display.xml
new file mode 100644
index 0000000..ae367cf
--- /dev/null
+++ b/res/drawable/ic_dashboard_display.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#4184f3"
+ android:pathData="M20.0,15.31L23.31,12.0 20.0,8.69L20.0,4.0l-4.69,0.0L12.0,0.69 8.69,4.0L4.0,4.0l0.0,4.69L0.69,12.0 4.0,15.31L4.0,20.0l4.69,0.0L12.0,23.31 15.31,20.0L20.0,20.0l0.0,-4.69zM12.0,18.0L12.0,6.0c3.31,0.0 6.0,2.69 6.0,6.0s-2.69,6.0 -6.0,6.0z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_dashboard_network.xml b/res/drawable/ic_dashboard_network.xml
new file mode 100644
index 0000000..6c7ee2e
--- /dev/null
+++ b/res/drawable/ic_dashboard_network.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="18.0"
+ android:viewportHeight="18.0">
+ <path
+ android:fillColor="#0b9c57"
+ android:pathData="M9.01,15.99l8.8,-10.96C17.47,4.77 14.08,2.0 9.0,2.0S0.53,4.7 0.19,5.03l8.8,10.96l0.02,0.0z"/>
+</vector>
diff --git a/res/drawable/ic_dashboard_security.xml b/res/drawable/ic_dashboard_security.xml
new file mode 100644
index 0000000..1e6a1e8
--- /dev/null
+++ b/res/drawable/ic_dashboard_security.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#7a1ea1"
+ android:pathData="M18.0,8.0l-1.0,0.0L17.0,6.0c0.0,-2.76 -2.24,-5.0 -5.0,-5.0S7.0,3.24 7.0,6.0l0.0,2.0L6.0,8.0c-1.1,0.0 -2.0,0.9 -2.0,2.0l0.0,10.0c0.0,1.0 0.9,2.0 2.0,2.0l12.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0L20.0,10.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0zm-6.0,9.0c-1.1,0.0 -2.0,-0.9 -2.0,-2.0s0.9,-2.0 2.0,-2.0 2.0,0.9 2.0,2.0 -0.9,2.0 -2.0,2.0zm3.1,-9.0L8.9,8.0L8.9,6.0c0.0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0.0 3.1,1.39 3.1,3.1l0.0,2.0z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_dashboard_sound.xml b/res/drawable/ic_dashboard_sound.xml
new file mode 100644
index 0000000..0cd3b04
--- /dev/null
+++ b/res/drawable/ic_dashboard_sound.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#4184f3"
+ android:pathData="M3.0,9.0l0.0,6.0l4.0,0.0l5.0,5.0L12.0,4.0L7.0,9.0L3.0,9.0zm13.5,3.0c0.0,-1.77 -1.02,-3.29 -2.5,-4.03l0.0,8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14.0,3.23l0.0,2.06c2.8,0.86 5.0,3.54 5.0,6.71s-2.11,5.85 -5.0,6.71l0.0,2.06c4.01,-0.91 7.0,-4.49 7.0,-8.77s-2.99,-7.86 -7.0,-8.77z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_dashboard_storage.xml b/res/drawable/ic_dashboard_storage.xml
new file mode 100644
index 0000000..2b6160e
--- /dev/null
+++ b/res/drawable/ic_dashboard_storage.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#4184f3"
+ android:pathData="M2.0,20.0l20.0,0.0l0.0,-4.0L2.0,16.0l0.0,4.0zm2.0,-3.0l2.0,0.0l0.0,2.0L4.0,19.0l0.0,-2.0zM2.0,4.0l0.0,4.0l20.0,0.0L22.0,4.0L2.0,4.0zm4.0,3.0L4.0,7.0L4.0,5.0l2.0,0.0l0.0,2.0zm-4.0,7.0l20.0,0.0l0.0,-4.0L2.0,10.0l0.0,4.0zm2.0,-3.0l2.0,0.0l0.0,2.0L4.0,13.0l0.0,-2.0z"/>
+</vector>
diff --git a/res/drawable/ic_dashboard_system.xml b/res/drawable/ic_dashboard_system.xml
new file mode 100644
index 0000000..fdd9214
--- /dev/null
+++ b/res/drawable/ic_dashboard_system.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#606060"
+ android:pathData="M11.0,17.0l2.0,0.0l0.0,-6.0l-2.0,0.0l0.0,6.0zm1.0,-15.0C6.48,2.0 2.0,6.48 2.0,12.0s4.48,10.0 10.0,10.0 10.0,-4.48 10.0,-10.0S17.52,2.0 12.0,2.0zm0.0,18.0c-4.41,0.0 -8.0,-3.59 -8.0,-8.0s3.59,-8.0 8.0,-8.0 8.0,3.59 8.0,8.0 -3.59,8.0 -8.0,8.0zM11.0,9.0l2.0,0.0L13.0,7.0l-2.0,0.0l0.0,2.0z"/>
+</vector>
diff --git a/res/drawable/ic_dashboard_user.xml b/res/drawable/ic_dashboard_user.xml
new file mode 100644
index 0000000..302d33e
--- /dev/null
+++ b/res/drawable/ic_dashboard_user.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#aeb32a"
+ android:pathData="M3.0,5.0
+ l0.0,14.0c0.0,1.0 0.89,2.0 2.0,2.0l14.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0
+ L21.0,5.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0
+ L5.0,3.0c-1.11,0.0 -2.0,0.9 -2.0,2.0zm12.0,4.0c0.0,1.66 -1.34,3.0 -3.0,3.0s-3.0,-1.34 -3.0,-3.0 1.34,-3.0 3.0,-3.0 3.0,1.34 3.0,3.0zm-9.0,8.0c0.0,-2.0 4.0,-3.1 6.0,-3.1s6.0,1.1 6.0,3.1l0.0,1.0
+ l-12.0,0l0.0,-1.0z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_devices_other.xml b/res/drawable/ic_devices_other.xml
index 20639a3..73407a3 100644
--- a/res/drawable/ic_devices_other.xml
+++ b/res/drawable/ic_devices_other.xml
@@ -17,9 +17,8 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:viewportHeight="24.0">
<path
android:pathData="M3,6h18L21,4L3,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h4v-2L3,18L3,6zM13,12L9,12v1.78c-0.61,0.55 -1,1.33 -1,2.22s0.39,1.67 1,2.22L9,20h4v-1.78c0.61,-0.55 1,-1.34 1,-2.22s-0.39,-1.67 -1,-2.22L13,12zM11,17.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM22,8h-6c-0.5,0 -1,0.5 -1,1v10c0,0.5 0.5,1 1,1h6c0.5,0 1,-0.5 1,-1L23,9c0,-0.5 -0.5,-1 -1,-1zM21,18h-4v-8h4v8z"
- android:fillColor="#FFFFFFFF"/>
+ android:fillColor="#0b9c57"/>
</vector>
diff --git a/res/drawable/ic_fingerprint_error.xml b/res/drawable/ic_fingerprint_error.xml
index b822d45..c9363bc 100644
--- a/res/drawable/ic_fingerprint_error.xml
+++ b/res/drawable/ic_fingerprint_error.xml
@@ -19,12 +19,12 @@
android:viewportWidth="32.0"
android:viewportHeight="32.0">
<path
- android:fillColor="@*android:color/system_error"
+ android:fillColor="?android:attr/colorError"
android:pathData="M15.99,2.5C8.53,2.5 2.5,8.54 2.5,16.0s6.03,13.5 13.49,13.5S29.5,23.46 29.5,16.0S23.45,2.5 15.99,2.5zM16.0,26.8c-5.97,0.0 -10.8,-4.83 -10.8,-10.8S10.03,5.2 16.0,5.2S26.8,10.03 26.8,16.0S21.97,26.8 16.0,26.8z"/>
<path
- android:fillColor="@*android:color/system_error"
+ android:fillColor="?android:attr/colorError"
android:pathData="M14.65,20.05l2.7,0.0l0.0,2.7l-2.7,0.0z"/>
<path
- android:fillColor="@*android:color/system_error"
+ android:fillColor="?android:attr/colorError"
android:pathData="M14.65,9.25l2.7,0.0l0.0,8.1l-2.7,0.0z"/>
</vector>
diff --git a/res/drawable/ic_help.xml b/res/drawable/ic_help.xml
index 7a225e5..5b056e7 100644
--- a/res/drawable/ic_help.xml
+++ b/res/drawable/ic_help.xml
@@ -17,9 +17,8 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:viewportHeight="24.0">
<path
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"
- android:fillColor="#FFFFFFFF"/>
+ android:fillColor="#f3501d"/>
</vector>
diff --git a/res/drawable/ic_launcher_settings.xml b/res/drawable/ic_launcher_settings.xml
index 7b09499..cdf9e35 100644
--- a/res/drawable/ic_launcher_settings.xml
+++ b/res/drawable/ic_launcher_settings.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
- <background android:drawable="?android:attr/colorAccent"/>
+ <background android:drawable="@*android:color/accent_device_default_light"/>
<foreground android:drawable="@mipmap/ic_launcher_settings"/>
</adaptive-icon>
diff --git a/res/drawable/ic_settings_accessibility.xml b/res/drawable/ic_settings_accessibility.xml
index 34c0bdd..a689c4a 100644
--- a/res/drawable/ic_settings_accessibility.xml
+++ b/res/drawable/ic_settings_accessibility.xml
@@ -17,9 +17,8 @@
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:viewportHeight="24.0">
<path
- android:fillColor="#FFFFFFFF"
+ android:fillColor="#3e50b4"
android:pathData="M12.0,2.0c1.1,0.0 2.0,0.9 2.0,2.0s-0.9,2.0 -2.0,2.0 -2.0,-0.9 -2.0,-2.0 0.9,-2.0 2.0,-2.0zm9.0,7.0l-6.0,0.0l0.0,13.0l-2.0,0.0l0.0,-6.0l-2.0,0.0l0.0,6.0L9.0,22.0L9.0,9.0L3.0,9.0L3.0,7.0l18.0,0.0l0.0,2.0z"/>
</vector>
diff --git a/res/drawable/ic_settings_battery.xml b/res/drawable/ic_settings_battery.xml
index c8e053d..f1e56d8 100644
--- a/res/drawable/ic_settings_battery.xml
+++ b/res/drawable/ic_settings_battery.xml
@@ -17,10 +17,9 @@
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:viewportHeight="24.0">
<path
- android:fillColor="#FFFFFFFF"
+ android:fillColor="#4184f3"
android:pathData="M15.67,4.0L14.0,4.0L14.0,2.0l-4.0,0.0l0.0,2.0L8.33,4.0C7.6,4.0 7.0,4.6 7.0,5.33l0.0,15.33C7.0,21.4 7.6,22.0 8.33,22.0l7.33,0.0c0.74,0.0 1.34,-0.6 1.34,-1.33L17.0,5.33C17.0,4.6 16.4,4.0 15.67,4.0z
M16,5l0,5.5l-8,0l0,-5.5l3,0l0,-2l2,0l0,2l3,0z"/>
</vector>
diff --git a/res/layout/app_details.xml b/res/layout/app_details.xml
index 263ce05..6b6a578 100644
--- a/res/layout/app_details.xml
+++ b/res/layout/app_details.xml
@@ -43,36 +43,6 @@
android:antialias="true"/>
<LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_toEndOf="@id/app_detail_icon"
- android:paddingStart="24dp"
- android:paddingEnd="24dp"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/app_detail_title"
- style="@style/TextAppearance.EntityHeaderTitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:gravity="start"
- android:paddingTop="8dp"/>
-
- <TextView
- android:id="@+id/app_detail_summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="start"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondary"/>
-
- </LinearLayout>
-
- <LinearLayout
android:id="@+id/app_detail_links"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@@ -98,6 +68,37 @@
</LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_toEndOf="@id/app_detail_icon"
+ android:layout_toStartOf="@id/app_detail_links"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/app_detail_title"
+ style="@style/TextAppearance.EntityHeaderTitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="false"
+ android:ellipsize="marquee"
+ android:gravity="start"
+ android:paddingTop="8dp"/>
+
+ <TextView
+ android:id="@+id/app_detail_summary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="start"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondary"/>
+
+ </LinearLayout>
+
</RelativeLayout>
<TextView
diff --git a/res/layout/data_usage_chart.xml b/res/layout/data_usage_chart.xml
index 3a2ee09..4aa0aa8 100644
--- a/res/layout/data_usage_chart.xml
+++ b/res/layout/data_usage_chart.xml
@@ -80,7 +80,7 @@
settings:neighborMargin="5dip"
settings:labelSize="60dip"
settings:labelTemplate="@string/data_usage_sweep_limit"
- settings:labelColor="#fff4511e"
+ settings:labelColor="?android:attr/colorError"
settings:safeRegion="4dp" />
</com.android.settings.widget.ChartDataUsageView>
diff --git a/res/layout/zen_rule_name.xml b/res/layout/zen_rule_name.xml
index 1112ce2..bdf1f9f 100755
--- a/res/layout/zen_rule_name.xml
+++ b/res/layout/zen_rule_name.xml
@@ -40,7 +40,7 @@
android:singleLine="true"
android:layout_marginLeft="26dp"
android:layout_marginRight="26dp"
- android:textColor="@color/zen_rule_name_warning"
+ android:textColor="?android:attr/colorError"
android:text="@string/zen_mode_rule_name_warning" />
</LinearLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index fdb1265..6705494 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -37,18 +37,15 @@
<color name="setup_lock_pattern_view_success_color_dark">#ff84ffff</color>
<color name="setup_lock_pattern_view_success_color_light">@color/suw_color_accent_light</color>
<color name="setup_lock_pattern_view_error_color_dark">#fff44336</color>
- <color name="setup_lock_pattern_view_error_color_light">@color/lock_pattern_view_error_color</color>
<color name="setup_wizard_wifi_color_dark">#89ffffff</color>
<color name="setup_wizard_wifi_color_light">#89000000</color>
<color name="lock_pattern_background">#00000000</color>
<color name="lock_pattern_view_regular_color">#ff37474f</color>
- <color name="lock_pattern_view_error_color">@*android:color/system_error</color>
<color name="lock_pattern_view_regular_color_dark">#ffffff</color>
<color name="unlock_pattern_view_regular_color">@android:color/white</color>
- <color name="unlock_pattern_view_error_color">@*android:color/system_error</color>
<color name="fingerprint_title_area_bg">?android:attr/colorAccent</color>
<color name="fingerprint_title_color">#ffffffff</color>
@@ -75,8 +72,6 @@
<color name="memory_avg_use">#ff384248</color>
- <color name="zen_rule_name_warning">@*android:color/system_error</color>
-
<!-- Accent color that matches the settings launcher icon -->
<color name="icon_accent">#ffabffec</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index fae38fc..1ebc4c7 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -38,6 +38,9 @@
<!-- When true enable color temperature setting. -->
<bool name="config_enableColorTemperature">false</bool>
+ <!-- Whether to show TelphonyMonitor switch in Developer Options -->
+ <bool name="config_show_telephony_monitor">false</bool>
+
<!-- Fully-qualified class name for the implementation of the FeatureFactory to be instantiated. -->
<string name="config_featureFactory" translatable="false">com.android.settings.overlay.FeatureFactoryImpl</string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a04bf0a..0ddc634 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -245,7 +245,7 @@
<dimen name="mdm_app_name_padding_left">16dp</dimen>
<dimen name="mdm_app_icon_width_height">56dp</dimen>
- <dimen name="shortcut_size_maskable">90dp</dimen>
+ <dimen name="shortcut_size_maskable">120dp</dimen>
<dimen name="shortcut_size">40dp</dimen>
<dimen name="shortcut_icon_size">16dp</dimen>
<dimen name="badge_size">10dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index dfcbc96..71fd094 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5656,7 +5656,7 @@
<!-- Title for the emergency info preference [CHAR LIMIT=40] -->
<string name="emergency_info_title">Emergency information</string>
<!-- Summary for the emergency info preference [CHAR LIMIT=40] -->
- <string name="emergency_info_summary">Information about <xliff:g id="user_name" example="Jason">%1$s</xliff:g></string>
+ <string name="emergency_info_summary">Info & contacts for <xliff:g id="user_name" example="Jason">%1$s</xliff:g></string>
<!-- Application Restrictions screen title [CHAR LIMIT=45] -->
<string name="application_restrictions">Allow apps and content</string>
@@ -6903,8 +6903,6 @@
<string name="filter_work_apps">Work</string>
<!-- Label for showing apps with blocked notifications in list [CHAR LIMIT=30] -->
<string name="filter_notif_blocked_apps">Blocked</string>
- <!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
- <string name="filter_with_domain_urls_apps">With domain URLs</string>
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
<string name="advanced_apps">Advanced</string>
@@ -7560,6 +7558,9 @@
<!-- Toast message letting the user know the color temperature setting is not immediate -->
<string name="color_temperature_toast">To apply color change, turn off screen</string>
+ <!-- Toast message letting the user know the how to trigger telephony monitor -->
+ <string name="telephony_monitor_toast">To apply telephony monitor change, reboot device</string>
+
<!-- Name of the setting to disable the automatic update -->
<string name="ota_disable_automatic_update">Automatic system updates</string>
@@ -8166,6 +8167,16 @@
<string name="enterprise_privacy_lock_device">Admin can lock device and reset password</string>
<!-- Label explaining that the admin can wipe the device remotely. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_wipe_device">Admin can delete all device data</string>
+ <!-- Label explaining that the admin configured the device to wipe itself when the password is mistyped this many times. [CHAR LIMIT=NONE] -->
+ <plurals name="enterprise_privacy_failed_password_wipe_device">
+ <item quantity="one">Admin set maximum password attempts to <xliff:g id="count">%d</xliff:g> before deleting all device data</item>
+ <item quantity="other">Admin set maximum password attempts to <xliff:g id="count">%d</xliff:g> before deleting all device data</item>
+ </plurals>
+ <!-- Label explaining that the admin configured the work profile to wipe itself when the password is mistyped this many times. [CHAR LIMIT=NONE] -->
+ <plurals name="enterprise_privacy_failed_password_wipe_work">
+ <item quantity="one">Admin set maximum password attempts to <xliff:g id="count">%d</xliff:g> before deleting work profile data</item>
+ <item quantity="other">Admin set maximum password attempts to <xliff:g id="count">%d</xliff:g> before deleting work profile data</item>
+ </plurals>
<!-- Message indicating that the device is enterprise-managed by a Device Owner [CHAR LIMIT=NONE] -->
<string name="do_disclosure_generic">This device is managed.</string>
<!-- Message indicating that the device is enterprise-managed by a Device Owner [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 790b726..2692508 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -192,7 +192,7 @@
<item name="android:textSize">12sp</item>
<item name="android:textAlignment">viewStart</item>
<item name="android:textAppearance">@android:style/TextAppearance.Material.Body1</item>
- <item name="android:textColor">@*android:color/system_error</item>
+ <item name="android:textColor">?android:attr/colorError</item>
</style>
<style name="wifi_item_content">
@@ -330,7 +330,7 @@
<style name="TextAppearance.FingerprintErrorText"
parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">@*android:color/system_error</item>
+ <item name="android:textColor">?android:attr/colorError</item>
</style>
<style name="TextAppearance.SupportTitle"
@@ -354,7 +354,7 @@
<style name="TextAppearance.ConfirmDeviceCredentialsErrorText"
parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">@*android:color/system_error</item>
+ <item name="android:textColor">?android:attr/colorError</item>
</style>
<style name="TextAppearance.Small.SwitchBar">
@@ -429,4 +429,30 @@
</style>
<style name="AppActionPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
+
+ <style name="LockPatternStyle">
+ <item name="*android:regularColor">@color/lock_pattern_view_regular_color</item>
+ <item name="*android:successColor">@color/lock_pattern_view_success_color</item>
+ <item name="*android:errorColor">?android:attr/colorError</item>
+ </style>
+
+ <style name="LockPatternStyle.Dark">
+ <item name="*android:regularColor">@color/lock_pattern_view_regular_color_dark</item>
+ <item name="*android:successColor">@color/lock_pattern_view_regular_color_dark</item>
+ </style>
+
+ <style name="LockPatternStyle.Dark.Work">
+ <item name="*android:regularColor">@*android:color/white</item>
+ </style>
+
+ <style name="LockPatternStyle.Unlock">
+ <item name="*android:regularColor">@color/unlock_pattern_view_regular_color</item>
+ <item name="*android:successColor">@color/unlock_pattern_view_success_color</item>
+ </style>
+
+ <style name="LockPatternStyle.Setup">
+ <item name="*android:regularColor">@color/setup_lock_pattern_view_regular_color_light</item>
+ <item name="*android:successColor">@color/setup_lock_pattern_view_success_color_light</item>
+ </style>
+
</resources>
diff --git a/res/values/styles_preference.xml b/res/values/styles_preference.xml
index a78d87b..e7c2852 100644
--- a/res/values/styles_preference.xml
+++ b/res/values/styles_preference.xml
@@ -21,35 +21,44 @@
<dimen name="preference_no_icon_padding_start">72dp</dimen>
- <style name="ApnPreference">
+ <!-- Fragment style -->
+ <style name="PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
+ <item name="android:layout">@layout/preference_list_fragment</item>
+ <item name="allowDividerAfterLastItem">false</item>
+ </style>
+
+ <!-- Preferences -->
+ <style name="SettingsPreference">
+ <item name="allowDividerAbove">false</item>
+ <item name="allowDividerBelow">true</item>
+ <item name="android:layout">@layout/preference_material_settings</item>
+ </style>
+
+ <style name="ApnPreference" parent="SettingsPreference">
<item name="android:layout">@layout/apn_preference_layout</item>
</style>
<style name="EditTextPreference"
parent="@style/Preference.DialogPreference.EditTextPreference.Material">
+ <item name="allowDividerAbove">false</item>
+ <item name="allowDividerBelow">true</item>
<item name="android:layout">@layout/preference_material_settings</item>
<item name="android:dialogLayout">@layout/preference_dialog_edittext</item>
</style>
- <style name="PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
- <item name="android:layout">@layout/preference_list_fragment</item>
- </style>
-
- <style name="SettingsPreference">
- <item name="android:layout">@layout/preference_material_settings</item>
- </style>
-
- <style name="SettingsDropdownPreference">
+ <style name="SettingsDropdownPreference" parent="SettingsPreference">
<item name="android:layout">@layout/preference_dropdown_material_settings</item>
</style>
- <style name="SettingsDialogPreference" parent="SettingsPreference"/>
+ <style name="SettingsDialogPreference" parent="SettingsPreference" />
<style name="SettingsPreferenceCategory" parent="@style/Preference.Category.Material">
+ <item name="allowDividerAbove">true</item>
+ <item name="allowDividerBelow">true</item>
<item name="android:layout">@layout/preference_category_material_settings</item>
</style>
- <style name="SettingsSeekBarPreference">
+ <style name="SettingsSeekBarPreference" parent="SettingsPreference">
<item name="android:layout">@layout/preference_widget_seekbar_settings</item>
</style>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index fe5b3ca..c961cce 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -40,9 +40,7 @@
<item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
<!-- LockPatternView colors -->
- <item name="*android:regularColor">@color/setup_lock_pattern_view_regular_color_dark</item>
- <item name="*android:successColor">@color/setup_lock_pattern_view_success_color_dark</item>
- <item name="*android:errorColor">@color/setup_lock_pattern_view_error_color_dark</item>
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
<style name="SetupWizardTheme.Light" parent="SuwThemeGlif.Light">
@@ -62,10 +60,7 @@
<item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
<item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
- <!-- LockPatternView colors -->
- <item name="*android:regularColor">@color/setup_lock_pattern_view_regular_color_light</item>
- <item name="*android:successColor">@color/setup_lock_pattern_view_success_color_light</item>
- <item name="*android:errorColor">@color/setup_lock_pattern_view_error_color_light</item>
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
<style name="SetupWizardTheme.Transparent" parent="SetupWizardTheme">
@@ -152,10 +147,7 @@
<!-- For all Alert Dialogs -->
<item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
- <!-- LockPatternView colors -->
- <item name="*android:regularColor">@color/lock_pattern_view_regular_color</item>
- <item name="*android:successColor">@color/lock_pattern_view_success_color</item>
- <item name="*android:errorColor">@color/lock_pattern_view_error_color</item>
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
<style name="Theme.SubSettings" parent="Theme.Settings">
@@ -201,10 +193,7 @@
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:background">@android:color/black</item>
- <!-- LockPatternView colors -->
- <item name="*android:regularColor">@color/unlock_pattern_view_regular_color</item>
- <item name="*android:successColor">@color/unlock_pattern_view_success_color</item>
- <item name="*android:errorColor">@color/unlock_pattern_view_error_color</item>
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Unlock</item>
</style>
<style name="ThemeOverlay.AlertDialog" parent="@android:style/ThemeOverlay.Material.Dialog.Alert">
@@ -240,15 +229,13 @@
<item name="confirmDeviceCredentialsSideMargin">32dp</item>
<item name="confirmDeviceCredentialsTopMargin">32dp</item>
- <!-- LockPatternView colors -->
- <item name="*android:regularColor">@color/lock_pattern_view_regular_color_dark</item>
- <item name="*android:successColor">@color/lock_pattern_view_regular_color_dark</item>
- <item name="*android:errorColor">@color/lock_pattern_view_error_color</item>
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Dark</item>
<item name="android:windowAnimationStyle">@style/ConfirmDeviceCredentialsAnimationStyle</item>
</style>
+
<style name="Theme.ConfirmDeviceCredentialsWork" parent="Theme.ConfirmDeviceCredentialsDark">
- <item name="*android:regularColor">@*android:color/white</item>
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Dark.Work</item>
<item name="android:colorAccent">@*android:color/white</item>
</style>
diff --git a/res/xml/account_settings.xml b/res/xml/account_settings.xml
deleted file mode 100644
index 33f61a2..0000000
--- a/res/xml/account_settings.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:key="account"
- android:title="@string/account_settings_title"
- settings:keywords="@string/keywords_accounts">
-</PreferenceScreen>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 57395b4..955802d 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -166,6 +166,11 @@
android:entries="@array/select_logpersist_titles"
android:entryValues="@array/select_logpersist_values" />
+ <SwitchPreference
+ android:key="telephony_monitor_switch"
+ android:title="@string/telephony_monitor_switch"
+ android:summary="@string/telephony_monitor_switch_summary"/>
+
</PreferenceCategory>
<PreferenceCategory android:key="debug_networking_category"
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index e508575..7482031 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -15,12 +15,11 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/about_settings">
<!-- System update settings - launches activity -->
<Preference android:key="additional_system_update_settings"
- android:title="@string/additional_system_update_settings_list_item_title">
+ android:title="@string/additional_system_update_settings_list_item_title">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="@string/additional_system_update"
android:targetClass="@string/additional_system_update_menu" />
@@ -62,20 +61,13 @@
android:title="@string/device_feedback" />
<!-- Device hardware model -->
- <com.android.settings.DividerPreference
+ <Preference
android:key="device_model"
- android:enabled="false"
- android:shouldDisableView="false"
- android:selectable="false"
android:title="@string/model_info"
- android:summary="@string/device_info_default"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"/>
+ android:summary="@string/device_info_default"/>
<!-- Device firmware version -->
<Preference android:key="firmware_version"
- android:enabled="false"
- android:shouldDisableView="false"
android:title="@string/firmware_version"
android:summary="@string/device_info_default"/>
@@ -88,54 +80,33 @@
</Preference>
<!-- Device FCC equipment id -->
- <com.android.settings.DividerPreference
+ <Preference
android:key="fcc_equipment_id"
- android:enabled="false"
- android:shouldDisableView="false"
- android:selectable="false"
android:title="@string/fcc_equipment_id"
- android:summary="@string/device_info_default"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"/>
+ android:summary="@string/device_info_default"/>
<!-- Device Baseband version -->
- <com.android.settings.DividerPreference
+ <Preference
android:key="baseband_version"
- android:enabled="false"
- android:shouldDisableView="false"
- android:selectable="false"
android:title="@string/baseband_version"
- android:summary="@string/device_info_default"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"/>
+ android:summary="@string/device_info_default"/>
<!-- Device Kernel version -->
- <com.android.settings.DividerPreference
+ <Preference
android:key="kernel_version"
- android:enabled="false"
- android:shouldDisableView="false"
- android:selectable="false"
android:title="@string/kernel_version"
- android:summary="@string/device_info_default"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"/>
+ android:summary="@string/device_info_default"/>
<!-- Detailed build version -->
- <Preference android:key="build_number"
- android:enabled="false"
- android:shouldDisableView="false"
+ <Preference
+ android:key="build_number"
android:title="@string/build_number"
android:summary="@string/device_info_default"/>
<!-- SELinux status information -->
- <com.android.settings.DividerPreference
+ <Preference
android:key="selinux_status"
- android:enabled="false"
- android:shouldDisableView="false"
- android:selectable="false"
android:title="@string/selinux_status"
- android:summary="@string/selinux_status_enforcing"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"/>
+ android:summary="@string/selinux_status_enforcing"/>
</PreferenceScreen>
diff --git a/res/xml/enterprise_privacy_settings.xml b/res/xml/enterprise_privacy_settings.xml
index cc63d5f..bfb1247 100644
--- a/res/xml/enterprise_privacy_settings.xml
+++ b/res/xml/enterprise_privacy_settings.xml
@@ -106,5 +106,13 @@
android:title="@string/enterprise_privacy_wipe_device"
settings:allowDividerBelow="true"
settings:multiLine="true"/>
+ <com.android.settings.DividerPreference
+ android:key="failed_password_wipe_primary_user"
+ settings:allowDividerBelow="true"
+ settings:multiLine="true"/>
+ <com.android.settings.DividerPreference
+ android:key="failed_password_wipe_managed_profile"
+ settings:allowDividerBelow="true"
+ settings:multiLine="true"/>
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/manage_accounts_settings.xml b/res/xml/manage_accounts_settings.xml
deleted file mode 100644
index 810fa7a..0000000
--- a/res/xml/manage_accounts_settings.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <PreferenceCategory android:title="@string/account_settings" />
-</PreferenceScreen>
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 45d0b90..06b73a0 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -28,14 +28,4 @@
android:title="@string/user_add_user_or_profile_menu"
android:icon="@drawable/ic_menu_add" />
- <PreferenceCategory
- android:key="lock_screen_settings"
- android:title="@string/user_lockscreen_settings">
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="add_users_when_locked"
- android:title="@string/user_add_on_lockscreen_menu" />
- </PreferenceCategory>
- <Preference
- android:key="emergency_info"
- android:title="@string/emergency_info_title" />
</PreferenceScreen>
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 90a7a05..0451ca4 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -89,6 +89,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.development.BugReportPreferenceController;
import com.android.settings.development.BugReportInPowerPreferenceController;
+import com.android.settings.development.TelephonyMonitorPreferenceController;
import com.android.settings.fuelgauge.InactiveApps;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -353,6 +354,7 @@
private DashboardFeatureProvider mDashboardFeatureProvider;
private BugReportPreferenceController mBugReportController;
private BugReportInPowerPreferenceController mBugReportInPowerController;
+ private TelephonyMonitorPreferenceController mTelephonyMonitorController;
public DevelopmentSettings() {
super(UserManager.DISALLOW_DEBUGGING_FEATURES);
@@ -389,6 +391,7 @@
mBugReportController = new BugReportPreferenceController(getActivity());
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
+ mTelephonyMonitorController = new TelephonyMonitorPreferenceController(getActivity());
mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
setIfOnlyAvailableForAdmins(true);
@@ -420,6 +423,7 @@
mBugReportController.displayPreference(getPreferenceScreen());
mBugReportInPowerController.displayPreference(getPreferenceScreen());
+ mTelephonyMonitorController.displayPreference(getPreferenceScreen());
mWebViewAppPrefController.displayPreference(getPreferenceScreen());
mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
@@ -638,6 +642,7 @@
pref.setEnabled(enabled && !mDisabledPrefs.contains(pref));
}
mBugReportInPowerController.enablePreference(enabled);
+ mTelephonyMonitorController.enablePreference(enabled);
mWebViewAppPrefController.enablePreference(enabled);
updateAllOptions();
}
@@ -760,6 +765,7 @@
== PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
mHaveDebugSettings |= mBugReportInPowerController.updatePreference();
+ mHaveDebugSettings |= mTelephonyMonitorController.updatePreference();
updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr,
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
updateSwitchPreference(mBtHciSnoopLog, Settings.Secure.getInt(cr,
@@ -2382,6 +2388,11 @@
if (mBugReportInPowerController.handlePreferenceTreeClick(preference)) {
return true;
}
+
+ if (mTelephonyMonitorController.handlePreferenceTreeClick(preference)) {
+ return true;
+ }
+
if (mWebViewAppPrefController.handlePreferenceTreeClick(preference)) {
return true;
}
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index faf08e6..4ae900a 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -416,7 +416,8 @@
ai = iPackageManager.getReceiverInfo(activeAdmin,
PackageManager.GET_META_DATA |
PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS |
- PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE, profileId);
+ PackageManager.MATCH_DIRECT_BOOT_UNAWARE |
+ PackageManager.MATCH_DIRECT_BOOT_AWARE, profileId);
} catch (RemoteException e) {
Log.w(TAG, "Unable to load component: " + activeAdmin);
continue;
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index bd07685..47cb9829 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -20,65 +20,39 @@
import android.content.Context;
import android.content.Intent;
import android.os.Build;
-import android.os.Bundle;
-import android.os.SELinux;
-import android.os.SystemClock;
-import android.os.SystemProperties;
-import android.os.UserHandle;
-import android.os.UserManager;
import android.provider.SearchIndexableResource;
-import android.provider.Settings;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceGroup;
-import android.text.TextUtils;
-import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
+import com.android.settings.deviceinfo.BasebandVersionPreferenceController;
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
+import com.android.settings.deviceinfo.DeviceModelPreferenceController;
+import com.android.settings.deviceinfo.FccEquipmentIdPreferenceController;
+import com.android.settings.deviceinfo.FeedbackPreferenceController;
+import com.android.settings.deviceinfo.FirmwareVersionPreferenceController;
+import com.android.settings.deviceinfo.KernelVersionPreferenceController;
import com.android.settings.deviceinfo.ManualPreferenceController;
-import com.android.settings.deviceinfo.SystemUpdatePreferenceController;
+import com.android.settings.deviceinfo.RegulatoryInfoPreferenceController;
+import com.android.settings.deviceinfo.SELinuxStatusPreferenceController;
+import com.android.settings.deviceinfo.SafetyInfoPreferenceController;
+import com.android.settings.deviceinfo.SafetyLegalPreferenceController;
+import com.android.settings.deviceinfo.SecurityPatchPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
-import com.android.settingslib.DeviceInfoUtils;
-import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
public class DeviceInfoSettings extends DashboardFragment implements Indexable {
private static final String LOG_TAG = "DeviceInfoSettings";
- private static final String KEY_REGULATORY_INFO = "regulatory_info";
- private static final String PROPERTY_URL_SAFETYLEGAL = "ro.url.safetylegal";
- private static final String PROPERTY_SELINUX_STATUS = "ro.build.selinux";
- private static final String KEY_KERNEL_VERSION = "kernel_version";
- private static final String KEY_DEVICE_MODEL = "device_model";
- private static final String KEY_SELINUX_STATUS = "selinux_status";
- private static final String KEY_BASEBAND_VERSION = "baseband_version";
- private static final String KEY_FIRMWARE_VERSION = "firmware_version";
- private static final String KEY_SECURITY_PATCH = "security_patch";
- private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id";
- private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
- private static final String KEY_DEVICE_FEEDBACK = "device_feedback";
- private static final String KEY_SAFETY_LEGAL = "safetylegal";
-
-
- long[] mHits = new long[3];
private BuildNumberPreferenceController mBuildNumberPreferenceController;
- private UserManager mUm;
-
- private EnforcedAdmin mFunDisallowedAdmin;
- private boolean mFunDisallowedBySystem;
-
@Override
public int getMetricsCategory() {
return MetricsEvent.DEVICEINFO;
@@ -90,12 +64,6 @@
}
@Override
- public void onAttach(Context context) {
- super.onAttach(context);
- mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
- }
-
- @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mBuildNumberPreferenceController.onActivityResult(requestCode, resultCode, data)) {
return;
@@ -104,112 +72,6 @@
}
@Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- setStringSummary(KEY_FIRMWARE_VERSION, Build.VERSION.RELEASE);
- findPreference(KEY_FIRMWARE_VERSION).setEnabled(true);
-
- final String patch = DeviceInfoUtils.getSecurityPatch();
- if (!TextUtils.isEmpty(patch)) {
- setStringSummary(KEY_SECURITY_PATCH, patch);
- } else {
- getPreferenceScreen().removePreference(findPreference(KEY_SECURITY_PATCH));
- }
-
- setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband");
- setStringSummary(KEY_DEVICE_MODEL, Build.MODEL + DeviceInfoUtils.getMsvSuffix());
- setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID);
- findPreference(KEY_KERNEL_VERSION).setSummary(DeviceInfoUtils.getFormattedKernelVersion());
-
- if (!SELinux.isSELinuxEnabled()) {
- String status = getResources().getString(R.string.selinux_status_disabled);
- setStringSummary(KEY_SELINUX_STATUS, status);
- } else if (!SELinux.isSELinuxEnforced()) {
- String status = getResources().getString(R.string.selinux_status_permissive);
- setStringSummary(KEY_SELINUX_STATUS, status);
- }
-
- // Remove selinux information if property is not present
- removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SELINUX_STATUS,
- PROPERTY_SELINUX_STATUS);
-
- // Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
- removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SAFETY_LEGAL,
- PROPERTY_URL_SAFETYLEGAL);
-
- // Remove Equipment id preference if FCC ID is not set by RIL
- removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_EQUIPMENT_ID,
- PROPERTY_EQUIPMENT_ID);
-
- // Remove Baseband version if wifi-only device
- if (Utils.isWifiOnly(getActivity())) {
- getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION));
- }
-
- // Dont show feedback option if there is no reporter.
- if (TextUtils.isEmpty(DeviceInfoUtils.getFeedbackReporterPackage(getActivity()))) {
- getPreferenceScreen().removePreference(findPreference(KEY_DEVICE_FEEDBACK));
- }
-
- // Remove regulatory labels if no activity present to handle intent.
- removePreferenceIfActivityMissing(
- KEY_REGULATORY_INFO, Settings.ACTION_SHOW_REGULATORY_INFO);
-
- removePreferenceIfActivityMissing(
- "safety_info", "android.settings.SHOW_SAFETY_AND_REGULATORY_INFO");
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mFunDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(
- getActivity(), UserManager.DISALLOW_FUN, UserHandle.myUserId());
- mFunDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
- getActivity(), UserManager.DISALLOW_FUN, UserHandle.myUserId());
- }
-
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- if (mBuildNumberPreferenceController.handlePreferenceTreeClick(preference)) {
- return true;
- }
- if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) {
- System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
- mHits[mHits.length - 1] = SystemClock.uptimeMillis();
- if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
- if (mUm.hasUserRestriction(UserManager.DISALLOW_FUN)) {
- if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
- mFunDisallowedAdmin);
- }
- Log.d(LOG_TAG, "Sorry, no fun for you!");
- return false;
- }
-
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClassName("android",
- com.android.internal.app.PlatLogoActivity.class.getName());
- try {
- startActivity(intent);
- } catch (Exception e) {
- Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
- }
- }
- } else if (preference.getKey().equals(KEY_SECURITY_PATCH)) {
- if (getPackageManager().queryIntentActivities(preference.getIntent(), 0).isEmpty()) {
- // Don't send out the intent to stop crash
- Log.w(LOG_TAG, "Stop click action on " + KEY_SECURITY_PATCH + ": "
- + "queryIntentActivities() returns empty" );
- return true;
- }
- } else if (preference.getKey().equals(KEY_DEVICE_FEEDBACK)) {
- sendFeedback();
- }
- return super.onPreferenceTreeClick(preference);
- }
-
- @Override
protected String getLogTag() {
return LOG_TAG;
}
@@ -228,61 +90,19 @@
controllers.add(mBuildNumberPreferenceController);
controllers.add(new AdditionalSystemUpdatePreferenceController(context));
controllers.add(new ManualPreferenceController(context));
+ controllers.add(new FeedbackPreferenceController(this, context));
+ controllers.add(new KernelVersionPreferenceController(context));
+ controllers.add(new BasebandVersionPreferenceController(context));
+ controllers.add(new FirmwareVersionPreferenceController(context, getLifecycle()));
+ controllers.add(new RegulatoryInfoPreferenceController(context));
+ controllers.add(new DeviceModelPreferenceController(context));
+ controllers.add(new SecurityPatchPreferenceController(context));
+ controllers.add(new FccEquipmentIdPreferenceController(context));
+ controllers.add(new SELinuxStatusPreferenceController(context));
+ controllers.add(new SafetyInfoPreferenceController(context));
return controllers;
}
- private void removePreferenceIfPropertyMissing(PreferenceGroup preferenceGroup,
- String preference, String property) {
- if (SystemProperties.get(property).equals("")) {
- // Property is missing so remove preference from group
- try {
- preferenceGroup.removePreference(findPreference(preference));
- } catch (RuntimeException e) {
- Log.d(LOG_TAG, "Property '" + property + "' missing and no '"
- + preference + "' preference");
- }
- }
- }
-
- private void removePreferenceIfActivityMissing(String preferenceKey, String action) {
- final Intent intent = new Intent(action);
- if (getPackageManager().queryIntentActivities(intent, 0).isEmpty()) {
- Preference pref = findPreference(preferenceKey);
- if (pref != null) {
- getPreferenceScreen().removePreference(pref);
- }
- }
- }
-
- private void setStringSummary(String preference, String value) {
- try {
- findPreference(preference).setSummary(value);
- } catch (RuntimeException e) {
- findPreference(preference).setSummary(
- getResources().getString(R.string.device_info_default));
- }
- }
-
- private void setValueSummary(String preference, String property) {
- try {
- findPreference(preference).setSummary(
- SystemProperties.get(property,
- getResources().getString(R.string.device_info_default)));
- } catch (RuntimeException e) {
- // No recovery
- }
- }
-
- private void sendFeedback() {
- String reporterPackage = DeviceInfoUtils.getFeedbackReporterPackage(getActivity());
- if (TextUtils.isEmpty(reporterPackage)) {
- return;
- }
- Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
- intent.setPackage(reporterPackage);
- startActivityForResult(intent, 0);
- }
-
private static class SummaryProvider implements SummaryLoader.SummaryProvider {
private final Context mContext;
@@ -306,7 +126,7 @@
= new SummaryLoader.SummaryProviderFactory() {
@Override
public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
+ SummaryLoader summaryLoader) {
return new SummaryProvider(activity, summaryLoader);
}
};
@@ -315,46 +135,30 @@
* For Search.
*/
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
+ new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.device_info_settings;
- return Arrays.asList(sir);
- }
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.device_info_settings;
+ return Arrays.asList(sir);
+ }
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = new ArrayList<String>();
- if (isPropertyMissing(PROPERTY_SELINUX_STATUS)) {
- keys.add(KEY_SELINUX_STATUS);
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = new ArrayList<>();
+ new SafetyLegalPreferenceController(context).updateNonIndexableKeys(keys);
+ new BasebandVersionPreferenceController(context).updateNonIndexableKeys(keys);
+ new FeedbackPreferenceController(null, context).updateNonIndexableKeys(keys);
+ new AdditionalSystemUpdatePreferenceController(context)
+ .updateNonIndexableKeys(keys);
+ new RegulatoryInfoPreferenceController(context).updateNonIndexableKeys(keys);
+ new SecurityPatchPreferenceController(context).updateNonIndexableKeys(keys);
+ new FccEquipmentIdPreferenceController(context).updateNonIndexableKeys(keys);
+ new SELinuxStatusPreferenceController(context).updateNonIndexableKeys(keys);
+ new SafetyInfoPreferenceController(context).updateNonIndexableKeys(keys);
+ return keys;
}
- if (isPropertyMissing(PROPERTY_URL_SAFETYLEGAL)) {
- keys.add(KEY_SAFETY_LEGAL);
- }
- if (isPropertyMissing(PROPERTY_EQUIPMENT_ID)) {
- keys.add(KEY_EQUIPMENT_ID);
- }
- // Remove Baseband version if wifi-only device
- if (Utils.isWifiOnly(context)) {
- keys.add((KEY_BASEBAND_VERSION));
- }
- // Dont show feedback option if there is no reporter.
- if (TextUtils.isEmpty(DeviceInfoUtils.getFeedbackReporterPackage(context))) {
- keys.add(KEY_DEVICE_FEEDBACK);
- }
- new SystemUpdatePreferenceController(context, UserManager.get(context))
- .updateNonIndexableKeys(keys);
- new AdditionalSystemUpdatePreferenceController(context)
- .updateNonIndexableKeys(keys);
- return keys;
- }
-
- private boolean isPropertyMissing(String property) {
- return SystemProperties.get(property).equals("");
- }
- };
-
+ };
}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 046deb3..e92027a 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -83,11 +83,9 @@
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
public static class FactoryResetActivity extends SettingsActivity { /* empty */ }
public static class RunningServicesActivity extends SettingsActivity { /* empty */ }
- public static class ManageAccountsSettingsActivity extends SettingsActivity { /* empty */ }
public static class PowerUsageSummaryActivity extends SettingsActivity { /* empty */ }
public static class BatterySaverSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccountSyncSettingsActivity extends SettingsActivity { /* empty */ }
- public static class AccountSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
public static class GestureSettingsActivity extends SettingsActivity { /* empty */ }
public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java
index 196e4bd..78f9de6 100644
--- a/src/com/android/settings/WifiCallingSettings.java
+++ b/src/com/android/settings/WifiCallingSettings.java
@@ -252,15 +252,6 @@
final Context context = getActivity();
- if (ImsManager.isWfcEnabledByPlatform(context)) {
- TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
-
- mSwitchBar.addOnSwitchChangeListener(this);
-
- mValidListener = true;
- }
-
// NOTE: Buttons will be enabled/disabled in mPhoneStateListener
boolean wfcEnabled = ImsManager.isWfcEnabledByUser(context)
&& ImsManager.isNonTtyOrTtyOnVolteEnabled(context);
@@ -271,6 +262,15 @@
mButtonWfcRoamingMode.setValue(Integer.toString(wfcRoamingMode));
updateButtonWfcMode(context, wfcEnabled, wfcMode, wfcRoamingMode);
+ if (ImsManager.isWfcEnabledByPlatform(context)) {
+ TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+ tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
+
+ mSwitchBar.addOnSwitchChangeListener(this);
+
+ mValidListener = true;
+ }
+
context.registerReceiver(mIntentReceiver, mIntentFilter);
Intent intent = getActivity().getIntent();
diff --git a/src/com/android/settings/accounts/AccountPreferenceBase.java b/src/com/android/settings/accounts/AccountPreferenceBase.java
index 605688e..2ad21d9 100644
--- a/src/com/android/settings/accounts/AccountPreferenceBase.java
+++ b/src/com/android/settings/accounts/AccountPreferenceBase.java
@@ -46,7 +46,7 @@
abstract class AccountPreferenceBase extends SettingsPreferenceFragment
implements AuthenticatorHelper.OnAccountsUpdateListener {
- protected static final String TAG = "AccountSettings";
+ protected static final String TAG = "AccountPreferenceBase";
protected static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
public static final String AUTHORITIES_FILTER_KEY = "authorities";
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 635f440..c54a2d1 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -30,7 +30,6 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
-import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceGroup;
@@ -43,6 +42,7 @@
import com.android.settings.DimmableIconPreference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
@@ -53,6 +53,7 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.Index;
import com.android.settings.search.SearchIndexableRaw;
+import com.android.settings.search2.SearchFeatureProviderImpl;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.accounts.AuthenticatorHelper;
@@ -85,8 +86,7 @@
private Preference mProfileNotAvailablePreference;
private String[] mAuthorities;
private int mAuthoritiesCount = 0;
- private PreferenceFragment mParent;
- private boolean mIAEnabled;
+ private SettingsPreferenceFragment mParent;
private int mAccountProfileOrder = ORDER_ACCOUNT_PROFILES;
private AccountRestrictionHelper mHelper;
private DashboardFeatureProvider mDashboardFeatureProvider;
@@ -122,13 +122,13 @@
public UserInfo userInfo;
}
- public AccountPreferenceController(Context context, PreferenceFragment parent,
+ public AccountPreferenceController(Context context, SettingsPreferenceFragment parent,
String[] authorities) {
this(context, parent, authorities, new AccountRestrictionHelper(context));
}
@VisibleForTesting
- AccountPreferenceController(Context context, PreferenceFragment parent,
+ AccountPreferenceController(Context context, SettingsPreferenceFragment parent,
String[] authorities, AccountRestrictionHelper helper) {
super(context);
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -140,7 +140,6 @@
final FeatureFactory featureFactory = FeatureFactory.getFactory(mContext);
mDashboardFeatureProvider = featureFactory.getDashboardFeatureProvider(mContext);
mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider();
- mIAEnabled = mDashboardFeatureProvider.isEnabled();
mHelper = helper;
}
@@ -255,17 +254,9 @@
if (!isAvailable()) {
// This should not happen
Log.e(TAG, "We should not be showing settings for a managed profile");
- if (!mIAEnabled) {
- ((AccountSettings) mParent).finish();
- }
return;
}
- if (!mIAEnabled) {
- // Load the preferences from an XML resource
- mParent.addPreferencesFromResource(R.xml.account_settings);
- }
-
if (mUm.isLinkedUser()) {
// Restricted user or similar
UserInfo userInfo = mUm.getUserInfo(UserHandle.myUserId());
@@ -330,8 +321,8 @@
DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
}
mProfiles.put(userInfo.id, profileData);
- Index.getInstance(mContext).updateFromClassNameResource(
- AccountSettings.class.getName(), true, true);
+ new SearchFeatureProviderImpl().getIndexingManager(mContext).updateFromClassNameResource(
+ UserAndAccountDashboardFragment.class.getName(), true, true);
}
private DimmableIconPreference newAddAccountPreference(Context context) {
@@ -471,52 +462,29 @@
final Drawable icon = helper.getDrawableForType(mContext, accountType);
final Context prefContext = mParent.getPreferenceManager().getContext();
- if (mIAEnabled) {
- // Add a preference row for each individual account
- for (Account account : accounts) {
- final ArrayList<String> auths =
- helper.getAuthoritiesForAccountType(account.type);
- if (!AccountRestrictionHelper.showAccount(mAuthorities, auths)) {
- continue;
- }
- final Bundle fragmentArguments = new Bundle();
- fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
- account);
- fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
- userHandle);
- fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
- accountType);
- fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_LABEL,
- label.toString());
- fragmentArguments.putInt(AccountDetailDashboardFragment.KEY_ACCOUNT_TITLE_RES,
- titleResId);
- fragmentArguments.putParcelable(EXTRA_USER, userHandle);
- accountTypePreferences.add(new AccountTypePreference(
- prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
- account.name, titleResPackageName, titleResId, label,
- AccountDetailDashboardFragment.class.getName(), fragmentArguments, icon));
+ // Add a preference row for each individual account
+ for (Account account : accounts) {
+ final ArrayList<String> auths =
+ helper.getAuthoritiesForAccountType(account.type);
+ if (!AccountRestrictionHelper.showAccount(mAuthorities, auths)) {
+ continue;
}
- } else if (skipToAccount) {
final Bundle fragmentArguments = new Bundle();
- fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
- accounts[0]);
+ fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
+ account);
+ fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
+ userHandle);
+ fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
+ accountType);
+ fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_LABEL,
+ label.toString());
+ fragmentArguments.putInt(AccountDetailDashboardFragment.KEY_ACCOUNT_TITLE_RES,
+ titleResId);
fragmentArguments.putParcelable(EXTRA_USER, userHandle);
-
accountTypePreferences.add(new AccountTypePreference(
- prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
- label, titleResPackageName, titleResId, AccountSyncSettings.class.getName(),
- fragmentArguments, icon));
- } else {
- final Bundle fragmentArguments = new Bundle();
- fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
- fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
- label.toString());
- fragmentArguments.putParcelable(EXTRA_USER, userHandle);
-
- accountTypePreferences.add(new AccountTypePreference(
- prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent), label,
- titleResPackageName, titleResId, ManageAccountsSettings.class.getName(),
- fragmentArguments, icon));
+ prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
+ account.name, titleResPackageName, titleResId, label,
+ AccountDetailDashboardFragment.class.getName(), fragmentArguments, icon));
}
helper.preloadDrawableForType(mContext, accountType);
}
@@ -524,10 +492,7 @@
Collections.sort(accountTypePreferences, new Comparator<AccountTypePreference>() {
@Override
public int compare(AccountTypePreference t1, AccountTypePreference t2) {
- int result = 0;
- if (mIAEnabled) {
- result = t1.getSummary().toString().compareTo(t2.getSummary().toString());
- }
+ int result = t1.getSummary().toString().compareTo(t2.getSummary().toString());
return result != 0
? result : t1.getTitle().toString().compareTo(t2.getTitle().toString());
}
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
deleted file mode 100644
index de721bb..0000000
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.accounts;
-
-import android.app.ActivityManager;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Process;
-import android.os.UserHandle;
-import android.provider.SearchIndexableResource;
-import android.util.Log;
-import android.util.SparseArray;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.search.SearchIndexableRaw;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static android.provider.Settings.EXTRA_AUTHORITIES;
-
-/**
- * Settings screen for the account types on the device.
- * This shows all account types available for personal and work profiles.
- *
- * An extra {@link UserHandle} can be specified in the intent as {@link EXTRA_USER}, if the user for
- * which the action needs to be performed is different to the one the Settings App will run in.
- */
-public class AccountSettings extends SettingsPreferenceFragment implements Indexable {
- public static final String TAG = "AccountSettings";
-
-
- private String[] mAuthorities;
-
- private AccountPreferenceController mAccountPreferenceController;
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.ACCOUNT;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mAuthorities = getActivity().getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- setHasOptionsMenu(true);
- mAccountPreferenceController =
- new AccountPreferenceController(getActivity(), this, mAuthorities);
- getLifecycle().addObserver(mAccountPreferenceController);
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- inflater.inflate(R.menu.account_settings, menu);
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- final UserHandle currentProfile = Process.myUserHandle();
- SparseArray<AccountPreferenceController.ProfileData> profiles =
- mAccountPreferenceController.getProfileData();
-
- if (profiles.size() == 1) {
- menu.findItem(R.id.account_settings_menu_auto_sync)
- .setVisible(true)
- .setOnMenuItemClickListener(new MasterSyncStateClickListener(currentProfile))
- .setChecked(ContentResolver.getMasterSyncAutomaticallyAsUser(
- currentProfile.getIdentifier()));
- menu.findItem(R.id.account_settings_menu_auto_sync_personal).setVisible(false);
- menu.findItem(R.id.account_settings_menu_auto_sync_work).setVisible(false);
- } else if (profiles.size() > 1) {
- // We assume there's only one managed profile, otherwise UI needs to change
- final UserHandle managedProfile = profiles.valueAt(1).userInfo.getUserHandle();
-
- menu.findItem(R.id.account_settings_menu_auto_sync_personal)
- .setVisible(true)
- .setOnMenuItemClickListener(new MasterSyncStateClickListener(currentProfile))
- .setChecked(ContentResolver.getMasterSyncAutomaticallyAsUser(
- currentProfile.getIdentifier()));
- menu.findItem(R.id.account_settings_menu_auto_sync_work)
- .setVisible(true)
- .setOnMenuItemClickListener(new MasterSyncStateClickListener(managedProfile))
- .setChecked(ContentResolver.getMasterSyncAutomaticallyAsUser(
- managedProfile.getIdentifier()));
- menu.findItem(R.id.account_settings_menu_auto_sync).setVisible(false);
- } else {
- Log.w(TAG, "Method onPrepareOptionsMenu called before profiles was initialized");
- }
- }
-
- private class MasterSyncStateClickListener implements MenuItem.OnMenuItemClickListener {
- private final UserHandle mUserHandle;
-
- public MasterSyncStateClickListener(UserHandle userHandle) {
- mUserHandle = userHandle;
- }
-
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- if (ActivityManager.isUserAMonkey()) {
- Log.d(TAG, "ignoring monkey's attempt to flip sync state");
- } else {
- AutoSyncDataPreferenceController.ConfirmAutoSyncChangeFragment.show(
- AccountSettings.this, !item.isChecked(), mUserHandle, null/*preference*/);
- }
- return true;
- }
- }
-
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.account_settings;
- return Arrays.asList(sir);
- }
-
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
- new AccountPreferenceController(context, null, null).updateRawDataToIndex(result);
- return result;
- }
- };
-}
diff --git a/src/com/android/settings/accounts/AddAccountSettings.java b/src/com/android/settings/accounts/AddAccountSettings.java
index ce16ba3..345f9fc 100644
--- a/src/com/android/settings/accounts/AddAccountSettings.java
+++ b/src/com/android/settings/accounts/AddAccountSettings.java
@@ -72,7 +72,7 @@
private static final String KEY_CALLER_IDENTITY = "pendingIntent";
private static final String SHOULD_NOT_RESOLVE = "SHOULDN'T RESOLVE!";
- private static final String TAG = "AccountSettings";
+ private static final String TAG = "AddAccountSettings";
/* package */ static final String EXTRA_SELECTED_ACCOUNT = "selected_account";
diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java
deleted file mode 100644
index f93fe09..0000000
--- a/src/com/android/settings/accounts/ManageAccountsSettings.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.accounts;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.app.ActionBar;
-import android.app.Activity;
-import android.content.ContentResolver;
-import android.content.SyncAdapterType;
-import android.content.SyncInfo;
-import android.content.SyncStatusInfo;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-import android.util.ArraySet;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.Utils;
-import com.android.settingslib.accounts.AuthenticatorHelper;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-import static android.content.Intent.EXTRA_USER;
-
-/** Manages settings for Google Account. */
-public class ManageAccountsSettings extends AccountPreferenceBase
- implements AuthenticatorHelper.OnAccountsUpdateListener {
- public static final String KEY_ACCOUNT_TYPE = "account_type";
- public static final String KEY_ACCOUNT_LABEL = "account_label";
-
- private static final int MENU_SYNC_NOW_ID = Menu.FIRST;
- private static final int MENU_SYNC_CANCEL_ID = Menu.FIRST + 1;
-
- private static final int REQUEST_SHOW_SYNC_SETTINGS = 1;
-
- private String[] mAuthorities;
- private TextView mErrorInfoView;
-
- // If an account type is set, then show only accounts of that type
- private String mAccountType;
- // Temporary hack, to deal with backward compatibility
- // mFirstAccount is used for the injected preferences
- private Account mFirstAccount;
-
- protected Set<String> mUserFacingSyncAuthorities;
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.ACCOUNTS_MANAGE_ACCOUNTS;
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- Bundle args = getArguments();
- if (args != null && args.containsKey(KEY_ACCOUNT_TYPE)) {
- mAccountType = args.getString(KEY_ACCOUNT_TYPE);
- }
- addPreferencesFromResource(R.xml.manage_accounts_settings);
- setHasOptionsMenu(true);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mAuthenticatorHelper.listenToAccountUpdates();
- updateAuthDescriptions();
- showAccountsIfNeeded();
- showSyncState();
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View view = inflater.inflate(R.layout.manage_accounts_screen, container, false);
- final ViewGroup prefs_container = (ViewGroup) view.findViewById(R.id.prefs_container);
- Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
- View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
- prefs_container.addView(prefs);
- return view;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- final Activity activity = getActivity();
- final View view = getView();
-
- mErrorInfoView = (TextView) view.findViewById(R.id.sync_settings_error_info);
- mErrorInfoView.setVisibility(View.GONE);
-
- mAuthorities = activity.getIntent().getStringArrayExtra(AUTHORITIES_FILTER_KEY);
-
- Bundle args = getArguments();
- if (args != null && args.containsKey(KEY_ACCOUNT_LABEL)) {
- getActivity().setTitle(args.getString(KEY_ACCOUNT_LABEL));
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mAuthenticatorHelper.stopListeningToAccountUpdates();
- }
-
- @Override
- public void onStop() {
- super.onStop();
- final Activity activity = getActivity();
- activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(null);
- }
-
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- if (preference instanceof AccountPreference) {
- startAccountSettings((AccountPreference) preference);
- } else {
- return false;
- }
- return true;
- }
-
- private void startAccountSettings(AccountPreference acctPref) {
- Bundle args = new Bundle();
- args.putParcelable(AccountSyncSettings.ACCOUNT_KEY, acctPref.getAccount());
- args.putParcelable(EXTRA_USER, mUserHandle);
- ((SettingsActivity) getActivity()).startPreferencePanel(this,
- AccountSyncSettings.class.getCanonicalName(), args,
- R.string.account_sync_settings_title, acctPref.getAccount().name,
- this, REQUEST_SHOW_SYNC_SETTINGS);
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- menu.add(0, MENU_SYNC_NOW_ID, 0, getString(R.string.sync_menu_sync_now))
- .setIcon(R.drawable.ic_menu_refresh_holo_dark);
- menu.add(0, MENU_SYNC_CANCEL_ID, 0, getString(R.string.sync_menu_sync_cancel))
- .setIcon(com.android.internal.R.drawable.ic_menu_close_clear_cancel);
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
- boolean syncActive = !getCurrentSyncs(mUserHandle.getIdentifier()).isEmpty();
- menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive);
- menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case MENU_SYNC_NOW_ID:
- requestOrCancelSyncForAccounts(true);
- return true;
- case MENU_SYNC_CANCEL_ID:
- requestOrCancelSyncForAccounts(false);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- private void requestOrCancelSyncForAccounts(boolean sync) {
- final int userId = mUserHandle.getIdentifier();
- SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(userId);
- Bundle extras = new Bundle();
- extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
- int count = getPreferenceScreen().getPreferenceCount();
- // For each account
- for (int i = 0; i < count; i++) {
- Preference pref = getPreferenceScreen().getPreference(i);
- if (pref instanceof AccountPreference) {
- Account account = ((AccountPreference) pref).getAccount();
- // For all available sync authorities, sync those that are enabled for the account
- for (int j = 0; j < syncAdapters.length; j++) {
- SyncAdapterType sa = syncAdapters[j];
- if (syncAdapters[j].accountType.equals(mAccountType)
- && ContentResolver.getSyncAutomaticallyAsUser(account, sa.authority,
- userId)) {
- if (sync) {
- ContentResolver.requestSyncAsUser(account, sa.authority, userId,
- extras);
- } else {
- ContentResolver.cancelSyncAsUser(account, sa.authority, userId);
- }
- }
- }
- }
- }
- }
-
- @Override
- protected void onSyncStateUpdated() {
- final Activity activity = getActivity();
- // Catch any delayed delivery of update messages
- if (activity == null || activity.isFinishing()) {
- return;
- }
- showSyncState();
- activity.invalidateOptionsMenu();
- }
-
- private void tryInitUserFacingSyncAuthorities(int userId) {
- if (mUserFacingSyncAuthorities != null) {
- return;
- }
- mUserFacingSyncAuthorities = new ArraySet<>();
-
- // only track userfacing sync adapters when deciding if account is synced or not
- final SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(userId);
- for (int k = 0, n = syncAdapters.length; k < n; k++) {
- final SyncAdapterType sa = syncAdapters[k];
- if (sa.isUserVisible()) {
- mUserFacingSyncAuthorities.add(sa.authority);
- }
- }
- }
-
- /**
- * Shows the sync state of the accounts. Note: it must be called after the accounts have been
- * loaded.
- *
- * @see {@link #showAccountsIfNeeded()}.
- */
- @VisibleForTesting
- void showSyncState() {
- final int userId = mUserHandle.getIdentifier();
- tryInitUserFacingSyncAuthorities(userId);
-
- // iterate over all the preferences, setting the state properly for each
- final List<SyncInfo> currentSyncs = getCurrentSyncs(userId);
-
- boolean anySyncFailed = false; // true if sync on any account failed
- Date date = new Date();
-
- final PreferenceScreen screen = getPreferenceScreen();
- final int prefCount = screen.getPreferenceCount();
- for (int i = 0; i < prefCount; i++) {
- Preference pref = screen.getPreference(i);
- if (!(pref instanceof AccountPreference)) {
- continue;
- }
-
- final AccountPreference accountPref = (AccountPreference) pref;
- final Account account = accountPref.getAccount();
- int syncCount = 0;
- long lastSuccessTime = 0;
- boolean syncIsFailing = false;
- final ArrayList<String> authorities = accountPref.getAuthorities();
- boolean syncingNow = false;
- if (authorities != null) {
- for (String authority : authorities) {
- SyncStatusInfo status = getSyncStatusInfo(account, authority, userId);
- boolean syncEnabled = isSyncEnabled(userId, account, authority);
- boolean activelySyncing = isSyncing(currentSyncs, account, authority);
- boolean lastSyncFailed = status != null
- && syncEnabled
- && status.lastFailureTime != 0
- && status.getLastFailureMesgAsInt(0)
- != ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS;
- if (lastSyncFailed && !activelySyncing
- && !ContentResolver.isSyncPending(account, authority)) {
- syncIsFailing = true;
- anySyncFailed = true;
- break;
- }
-
- if (status != null && lastSuccessTime < status.lastSuccessTime) {
- lastSuccessTime = status.lastSuccessTime;
- }
- syncCount += syncEnabled && mUserFacingSyncAuthorities.contains(authority)
- ? 1 : 0;
- syncingNow |= activelySyncing;
- if (syncingNow) {
- break;
- }
- }
- } else {
- if (VERBOSE) {
- Log.v(TAG, "no syncadapters found for " + account);
- }
- }
- if (syncIsFailing) {
- accountPref.setSyncStatus(AccountPreference.SYNC_ERROR, true);
- } else if (syncCount == 0) {
- accountPref.setSyncStatus(AccountPreference.SYNC_DISABLED, true);
- } else if (syncCount > 0) {
- if (syncingNow) {
- accountPref.setSyncStatus(AccountPreference.SYNC_IN_PROGRESS, true);
- } else {
- accountPref.setSyncStatus(AccountPreference.SYNC_ENABLED, true);
- if (lastSuccessTime > 0) {
- accountPref.setSyncStatus(AccountPreference.SYNC_ENABLED, false);
- date.setTime(lastSuccessTime);
- final String timeString = formatSyncDate(date);
- accountPref.setSummary(getResources().getString(
- R.string.last_synced, timeString));
- }
- }
- } else {
- accountPref.setSyncStatus(AccountPreference.SYNC_DISABLED, true);
- }
- }
- if (mErrorInfoView != null) {
- mErrorInfoView.setVisibility(anySyncFailed ? View.VISIBLE : View.GONE);
- }
- }
-
- private boolean isSyncing(List<SyncInfo> currentSyncs, Account account, String authority) {
- final int count = currentSyncs.size();
- for (int i = 0; i < count; i++) {
- SyncInfo syncInfo = currentSyncs.get(i);
- if (syncInfo.account.equals(account) && syncInfo.authority.equals(authority)) {
- return true;
- }
- }
- return false;
- }
-
- @VisibleForTesting
- protected boolean isSyncEnabled(int userId, Account account, String authority) {
- return ContentResolver.getSyncAutomaticallyAsUser(account, authority, userId)
- && ContentResolver.getMasterSyncAutomaticallyAsUser(userId)
- && (ContentResolver.getIsSyncableAsUser(account, authority, userId) > 0);
- }
-
- @Override
- public void onAccountsUpdate(UserHandle userHandle) {
- showAccountsIfNeeded();
- onSyncStateUpdated();
- }
-
- private void showAccountsIfNeeded() {
- if (getActivity() == null) return;
- Account[] accounts = AccountManager.get(getActivity()).getAccountsAsUser(
- mUserHandle.getIdentifier());
- getPreferenceScreen().removeAll();
- mFirstAccount = null;
- addPreferencesFromResource(R.xml.manage_accounts_settings);
- for (int i = 0, n = accounts.length; i < n; i++) {
- final Account account = accounts[i];
- // If an account type is specified for this screen, skip other types
- if (mAccountType != null && !account.type.equals(mAccountType)) continue;
- final ArrayList<String> auths = getAuthoritiesForAccountType(account.type);
-
- if (AccountRestrictionHelper.showAccount(mAuthorities, auths)) {
- final Drawable icon = getDrawableForType(account.type);
- final AccountPreference preference =
- new AccountPreference(getPrefContext(), account, icon, auths, false);
- getPreferenceScreen().addPreference(preference);
- if (mFirstAccount == null) {
- mFirstAccount = account;
- }
- }
- }
- if (mAccountType != null && mFirstAccount != null) {
- addAuthenticatorSettings();
- } else {
- // There's no account, close activity
- finish();
- }
- }
-
- private void addAuthenticatorSettings() {
- PreferenceScreen prefs = addPreferencesForType(mAccountType, getPreferenceScreen());
- if (prefs != null) {
- mAccountTypePreferenceLoader.updatePreferenceIntents(prefs, mAccountType, mFirstAccount);
- }
- }
-
- @Override
- protected void onAuthDescriptionsUpdated() {
- // Update account icons for all account preference items
- for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
- Preference pref = getPreferenceScreen().getPreference(i);
- if (pref instanceof AccountPreference) {
- AccountPreference accPref = (AccountPreference) pref;
- accPref.setSummary(getLabelForType(accPref.getAccount().type));
- }
- }
- }
-
- @VisibleForTesting
- protected List<SyncInfo> getCurrentSyncs(int userId) {
- return ContentResolver.getCurrentSyncsAsUser(userId);
- }
-
- @VisibleForTesting
- protected SyncStatusInfo getSyncStatusInfo(Account account, String authority, int userId) {
- return ContentResolver.getSyncStatusAsUser(account, authority, userId);
- }
-}
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index db72fce..a82ba9e 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -16,6 +16,7 @@
package com.android.settings.applications;
+import android.annotation.IdRes;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -31,6 +32,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.PreferenceFrameLayout;
+import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -52,6 +54,7 @@
import android.widget.SectionIndexer;
import android.widget.Spinner;
+import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.AppHeader;
import com.android.settings.R;
@@ -142,49 +145,76 @@
public static final int FILTER_APPS_WITH_OVERLAY = 10;
public static final int FILTER_APPS_WRITE_SETTINGS = 11;
public static final int FILTER_APPS_INSTALL_SOURCES = 12;
+ public static final int FILTER_APPS_COUNT = 13; // This should always be the last entry
+
+ // Mapping to string labels for the FILTER_APPS_* constants above.
+ public static final @IdRes int[] FILTER_LABELS = new int[FILTER_APPS_COUNT];
+
+ // Mapping to filters for the FILTER_APPS_* constants above.
+ public static final AppFilter[] FILTERS = new AppFilter[FILTER_APPS_COUNT];
+
+ static {
+ // High power whitelist, on
+ FILTER_LABELS[FILTER_APPS_POWER_WHITELIST] = R.string.high_power_filter_on;
+ FILTERS[FILTER_APPS_POWER_WHITELIST] = new CompoundFilter(
+ AppStatePowerBridge.FILTER_POWER_WHITELISTED,
+ ApplicationsState.FILTER_ALL_ENABLED);
+
+ // Without disabled until used
+ FILTER_LABELS[FILTER_APPS_POWER_WHITELIST_ALL] = R.string.filter_all_apps;
+ FILTERS[FILTER_APPS_POWER_WHITELIST_ALL] = new CompoundFilter(
+ ApplicationsState.FILTER_WITHOUT_DISABLED_UNTIL_USED,
+ ApplicationsState.FILTER_ALL_ENABLED);
+
+ // All apps
+ FILTER_LABELS[FILTER_APPS_ALL] = R.string.filter_all_apps;
+ FILTERS[FILTER_APPS_ALL] = ApplicationsState.FILTER_EVERYTHING;
+
+ // Enabled
+ FILTER_LABELS[FILTER_APPS_ENABLED] = R.string.filter_enabled_apps;
+ FILTERS[FILTER_APPS_ENABLED] = ApplicationsState.FILTER_ALL_ENABLED;
+
+ // Disabled
+ FILTER_LABELS[FILTER_APPS_DISABLED] = R.string.filter_apps_disabled;
+ FILTERS[FILTER_APPS_DISABLED] = ApplicationsState.FILTER_DISABLED;
+
+ // Instant
+ FILTER_LABELS[FILTER_APPS_INSTANT] = R.string.filter_instant_apps;
+ FILTERS[FILTER_APPS_INSTANT] = ApplicationsState.FILTER_INSTANT;
+
+ // Blocked Notifications
+ FILTER_LABELS[FILTER_APPS_BLOCKED] = R.string.filter_notif_blocked_apps;
+ FILTERS[FILTER_APPS_BLOCKED] = AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED;
+
+ // Personal
+ FILTER_LABELS[FILTER_APPS_PERSONAL] = R.string.filter_personal_apps;
+ FILTERS[FILTER_APPS_PERSONAL] = ApplicationsState.FILTER_PERSONAL;
+
+ // Work
+ FILTER_LABELS[FILTER_APPS_WORK] = R.string.filter_work_apps;
+ FILTERS[FILTER_APPS_WORK] = ApplicationsState.FILTER_WORK;
+
+ // Usage access screen, never displayed.
+ FILTER_LABELS[FILTER_APPS_USAGE_ACCESS] = R.string.filter_all_apps;
+ FILTERS[FILTER_APPS_USAGE_ACCESS] = AppStateUsageBridge.FILTER_APP_USAGE;
+
+ // Apps that can draw overlays
+ FILTER_LABELS[FILTER_APPS_WITH_OVERLAY] = R.string.filter_overlay_apps;
+ FILTERS[FILTER_APPS_WITH_OVERLAY] = AppStateOverlayBridge.FILTER_SYSTEM_ALERT_WINDOW;
+
+ // Apps that can write system settings
+ FILTER_LABELS[FILTER_APPS_WRITE_SETTINGS] = R.string.filter_write_settings_apps;
+ FILTERS[FILTER_APPS_WRITE_SETTINGS] = AppStateWriteSettingsBridge.FILTER_WRITE_SETTINGS;
+
+ // Apps that are trusted sources of apks
+ FILTER_LABELS[FILTER_APPS_INSTALL_SOURCES] = R.string.filter_install_sources_apps;
+ FILTERS[FILTER_APPS_INSTALL_SOURCES] = AppStateInstallAppsBridge.FILTER_APP_SOURCES;
+ }
// Storage types. Used to determine what the extra item in the list of preferences is.
public static final int STORAGE_TYPE_DEFAULT = 0;
public static final int STORAGE_TYPE_MUSIC = 1;
- // This is the string labels for the filter modes above, the order must be kept in sync.
- public static final int[] FILTER_LABELS = new int[]{
- R.string.high_power_filter_on, // High power whitelist, on
- R.string.filter_all_apps, // Without disabled until used
- R.string.filter_all_apps, // All apps
- R.string.filter_enabled_apps, // Enabled
- R.string.filter_apps_disabled, // Disabled
- R.string.filter_instant_apps, // Instant apps
- R.string.filter_notif_blocked_apps, // Blocked Notifications
- R.string.filter_personal_apps, // Personal
- R.string.filter_work_apps, // Work
- R.string.filter_with_domain_urls_apps, // Domain URLs
- R.string.filter_all_apps, // Usage access screen, never displayed
- R.string.filter_overlay_apps, // Apps with overlay permission
- R.string.filter_write_settings_apps, // Apps that can write system settings
- R.string.filter_install_sources_apps, // Apps that are trusted sources of apks
- };
- // This is the actual mapping to filters from FILTER_ constants above, the order must
- // be kept in sync.
- public static final AppFilter[] FILTERS = new AppFilter[]{
- new CompoundFilter(AppStatePowerBridge.FILTER_POWER_WHITELISTED,
- ApplicationsState.FILTER_ALL_ENABLED), // High power whitelist, on
- new CompoundFilter(ApplicationsState.FILTER_WITHOUT_DISABLED_UNTIL_USED,
- ApplicationsState.FILTER_ALL_ENABLED), // Without disabled until used
- ApplicationsState.FILTER_EVERYTHING, // All apps
- ApplicationsState.FILTER_ALL_ENABLED, // Enabled
- ApplicationsState.FILTER_DISABLED, // Disabled
- ApplicationsState.FILTER_INSTANT, // Instant
- AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED, // Blocked Notifications
- ApplicationsState.FILTER_PERSONAL, // Personal
- ApplicationsState.FILTER_WORK, // Work
- ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs
- AppStateUsageBridge.FILTER_APP_USAGE, // Apps with Domain URLs
- AppStateOverlayBridge.FILTER_SYSTEM_ALERT_WINDOW, // Apps that can draw overlays
- AppStateWriteSettingsBridge.FILTER_WRITE_SETTINGS, // Apps that can write system settings
- AppStateInstallAppsBridge.FILTER_APP_SOURCES,
- };
-
// sort order
private int mSortOrder = R.id.sort_order_alpha;
@@ -1284,15 +1314,7 @@
holder.appIcon.setImageDrawable(entry.icon);
}
updateSummary(holder);
- if ((entry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
- holder.disabled.setVisibility(View.VISIBLE);
- holder.disabled.setText(R.string.not_installed);
- } else if (!entry.info.enabled) {
- holder.disabled.setVisibility(View.VISIBLE);
- holder.disabled.setText(R.string.disabled);
- } else {
- holder.disabled.setVisibility(View.GONE);
- }
+ updateDisableView(holder.disabled, entry.info);
}
convertView.setEnabled(isEnabled(position));
}
@@ -1302,6 +1324,20 @@
return convertView;
}
+ @VisibleForTesting
+ void updateDisableView(TextView view, ApplicationInfo info) {
+ if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
+ view.setVisibility(View.VISIBLE);
+ view.setText(R.string.not_installed);
+ } else if (!info.enabled || info.enabledSetting
+ == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) {
+ view.setVisibility(View.VISIBLE);
+ view.setText(R.string.disabled);
+ } else {
+ view.setVisibility(View.GONE);
+ }
+ }
+
private void updateSummary(AppViewHolder holder) {
switch (mManageApplications.mListType) {
case LIST_TYPE_NOTIFICATION:
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
index 1c36bca..96aace9 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
@@ -16,110 +16,47 @@
package com.android.settings.bluetooth;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.PowerManager;
-import android.text.TextUtils;
-
-import com.android.settings.R;
+import android.os.UserHandle;
/**
* BluetoothPairingRequest is a receiver for any Bluetooth pairing request. It
* checks if the Bluetooth Settings is currently visible and brings up the PIN, the passkey or a
- * confirmation entry dialog. Otherwise it puts a Notification in the status bar, which can
- * be clicked to bring up the Pairing entry dialog.
+ * confirmation entry dialog. Otherwise it starts the BluetoothPairingService which
+ * starts a notification in the status bar that can be clicked to bring up the same dialog.
*/
public final class BluetoothPairingRequest extends BroadcastReceiver {
- private static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
-
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
- // convert broadcast intent into activity intent (same action string)
- BluetoothDevice device =
- intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
- BluetoothDevice.ERROR);
- Intent pairingIntent = new Intent();
- pairingIntent.setClass(context, BluetoothPairingDialog.class);
- pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
- pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
- if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION ||
- type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY ||
- type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
- int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,
- BluetoothDevice.ERROR);
- pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
- }
- pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
- pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- PowerManager powerManager =
- (PowerManager)context.getSystemService(Context.POWER_SERVICE);
- String deviceAddress = device != null ? device.getAddress() : null;
- String deviceName = device != null ? device.getName() : null;
- boolean shouldShowDialog= LocalBluetoothPreferences.shouldShowDialogInForeground(
- context, deviceAddress, deviceName);
- if (powerManager.isInteractive() && shouldShowDialog) {
- // Since the screen is on and the BT-related activity is in the foreground,
- // just open the dialog
- context.startActivity(pairingIntent);
- } else {
- // Put up a notification that leads to the dialog
- Resources res = context.getResources();
- Notification.Builder builder = new Notification.Builder(context)
- .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
- .setTicker(res.getString(R.string.bluetooth_notif_ticker));
-
- PendingIntent pending = PendingIntent.getActivity(context, 0,
- pairingIntent, PendingIntent.FLAG_ONE_SHOT);
-
- String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
- if (TextUtils.isEmpty(name)) {
- name = device != null ? device.getAliasName() :
- context.getString(android.R.string.unknownName);
- }
-
- builder.setContentTitle(res.getString(R.string.bluetooth_notif_title))
- .setContentText(res.getString(R.string.bluetooth_notif_message, name))
- .setContentIntent(pending)
- .setAutoCancel(true)
- .setDefaults(Notification.DEFAULT_SOUND)
- .setColor(context.getColor(
- com.android.internal.R.color.system_notification_accent_color));
-
- NotificationManager manager = (NotificationManager)
- context.getSystemService(Context.NOTIFICATION_SERVICE);
- manager.notify(NOTIFICATION_ID, builder.getNotification());
- }
-
- } else if (action.equals(BluetoothDevice.ACTION_PAIRING_CANCEL)) {
-
- // Remove the notification
- NotificationManager manager = (NotificationManager) context
- .getSystemService(Context.NOTIFICATION_SERVICE);
- manager.cancel(NOTIFICATION_ID);
-
- } else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
- int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
- BluetoothDevice.ERROR);
- int oldState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE,
- BluetoothDevice.ERROR);
- if((oldState == BluetoothDevice.BOND_BONDING) &&
- (bondState == BluetoothDevice.BOND_NONE)) {
- // Remove the notification
- NotificationManager manager = (NotificationManager) context
- .getSystemService(Context.NOTIFICATION_SERVICE);
- manager.cancel(NOTIFICATION_ID);
- }
- }
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (!action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
+ return;
}
+ // convert broadcast intent into activity intent (same action string)
+ Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context, intent);
+
+ PowerManager powerManager =
+ (PowerManager)context.getSystemService(Context.POWER_SERVICE);
+ BluetoothDevice device =
+ intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ String deviceAddress = device != null ? device.getAddress() : null;
+ String deviceName = device != null ? device.getName() : null;
+ boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground(
+ context, deviceAddress, deviceName);
+ if (powerManager.isInteractive() && shouldShowDialog) {
+ // Since the screen is on and the BT-related activity is in the foreground,
+ // just open the dialog
+ context.startActivity(pairingIntent);
+ } else {
+ // Put up a notification that leads to the dialog
+ intent.setClass(context, BluetoothPairingService.class);
+ context.startServiceAsUser(intent, UserHandle.CURRENT);
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
new file mode 100644
index 0000000..a24a3f0
--- /dev/null
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.bluetooth;
+
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.bluetooth.BluetoothDevice;
+import android.content.IntentFilter;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.IBinder;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.R;
+
+/**
+ * BluetoothPairingService shows a notification if there is a pending bond request
+ * which can launch the appropriate pairing dialog when tapped.
+ */
+public final class BluetoothPairingService extends Service {
+
+ private static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
+
+ private static final String TAG = "BluetoothPairingService";
+
+ private BluetoothDevice mDevice;
+
+ public static Intent getPairingDialogIntent(Context context, Intent intent) {
+
+ BluetoothDevice device =
+ intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
+ BluetoothDevice.ERROR);
+ Intent pairingIntent = new Intent();
+ pairingIntent.setClass(context, BluetoothPairingDialog.class);
+ pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+ pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
+ if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION ||
+ type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY ||
+ type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
+ int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,
+ BluetoothDevice.ERROR);
+ pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
+ }
+ pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
+ pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ return pairingIntent;
+ }
+
+ private final BroadcastReceiver mCancelReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
+ int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
+ BluetoothDevice.ERROR);
+ if ((bondState != BluetoothDevice.BOND_NONE) && (bondState != BluetoothDevice.BOND_BONDED)) {
+ return;
+ }
+ Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" + mDevice.getName() + "), BondState: " + bondState);
+ } else {
+ Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" + mDevice.getName() + "), Cancelled.");
+ }
+ stopForeground(true);
+ }
+ };
+
+ @Override
+ public void onCreate() {
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ Resources res = getResources();
+ Notification.Builder builder = new Notification.Builder(this)
+ .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
+ .setTicker(res.getString(R.string.bluetooth_notif_ticker));
+
+ PendingIntent pending = PendingIntent.getActivity(this, 0,
+ getPairingDialogIntent(this, intent), PendingIntent.FLAG_ONE_SHOT);
+
+ mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+
+ String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
+ if (TextUtils.isEmpty(name)) {
+ BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ name = device != null ? device.getAliasName() : getString(android.R.string.unknownName);
+ }
+
+ Log.d(TAG, "Show pairing notification for " + mDevice.getAddress() + " (" + name + ")");
+
+ builder.setContentTitle(res.getString(R.string.bluetooth_notif_title))
+ .setContentText(res.getString(R.string.bluetooth_notif_message, name))
+ .setContentIntent(pending)
+ .setDefaults(Notification.DEFAULT_SOUND)
+ .setColor(getColor(com.android.internal.R.color.system_notification_accent_color));
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
+ filter.addAction(BluetoothDevice.ACTION_PAIRING_CANCEL);
+ registerReceiver(mCancelReceiver, filter);
+
+ startForeground(NOTIFICATION_ID, builder.getNotification());
+ return START_STICKY;
+ }
+
+ @Override
+ public void onDestroy() {
+ unregisterReceiver(mCancelReceiver);
+ stopForeground(true);
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ // No binding.
+ return null;
+ }
+
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 7a8ff4c..99c46bf 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -79,6 +79,8 @@
/* Private intent to show the list of received files */
private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
"android.btopp.intent.action.OPEN_RECEIVED_FILES";
+ private static final String BTOPP_PACKAGE =
+ "com.android.bluetooth";
private static final String KEY_PAIRED_DEVICES = "paired_devices";
@@ -266,6 +268,7 @@
mMetricsFeatureProvider.action(getActivity(),
MetricsEvent.ACTION_BLUETOOTH_FILES);
Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
+ intent.setPackage(BTOPP_PACKAGE);
getActivity().sendBroadcast(intent);
return true;
}
diff --git a/src/com/android/settings/core/InstrumentedFragment.java b/src/com/android/settings/core/InstrumentedFragment.java
index 867389b..303d4d8 100644
--- a/src/com/android/settings/core/InstrumentedFragment.java
+++ b/src/com/android/settings/core/InstrumentedFragment.java
@@ -29,9 +29,12 @@
protected MetricsFeatureProvider mMetricsFeatureProvider;
+ private final VisibilityLoggerMixin mVisibilityLoggerMixin;
+
public InstrumentedFragment() {
// Mixin that logs visibility change for activity.
- getLifecycle().addObserver(new VisibilityLoggerMixin(getMetricsCategory()));
+ mVisibilityLoggerMixin = new VisibilityLoggerMixin(getMetricsCategory());
+ getLifecycle().addObserver(mVisibilityLoggerMixin);
getLifecycle().addObserver(new SurveyMixin(this, getClass().getSimpleName()));
}
@@ -40,4 +43,10 @@
super.onAttach(context);
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
+
+ @Override
+ public void onResume() {
+ mVisibilityLoggerMixin.setSourceMetricsCategory(getActivity());
+ super.onResume();
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/core/InstrumentedPreferenceFragment.java b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
index 91ef3f1..746c10d 100644
--- a/src/com/android/settings/core/InstrumentedPreferenceFragment.java
+++ b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
@@ -17,13 +17,7 @@
package com.android.settings.core;
import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import com.android.settings.core.instrumentation.Instrumentable;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
@@ -31,7 +25,6 @@
import com.android.settings.core.lifecycle.ObservablePreferenceFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.survey.SurveyMixin;
-import com.android.settings.widget.PreferenceDividerDecoration;
/**
* Instrumented fragment that logs visibility state.
@@ -44,9 +37,6 @@
// metrics placeholder value. Only use this for development.
protected final int PLACEHOLDER_METRIC = 10000;
- private final PreferenceDividerDecoration mDividerDecoration =
- new PreferenceDividerDecoration();
-
private final VisibilityLoggerMixin mVisibilityLoggerMixin;
public InstrumentedPreferenceFragment() {
@@ -63,14 +53,6 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View view = super.onCreateView(inflater, container, savedInstanceState);
- getListView().addItemDecoration(mDividerDecoration);
- return view;
- }
-
- @Override
public void onResume() {
mVisibilityLoggerMixin.setSourceMetricsCategory(getActivity());
super.onResume();
@@ -80,12 +62,6 @@
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
}
- @Override
- public void setDivider(Drawable divider) {
- mDividerDecoration.setDivider(divider);
- super.setDivider(new ColorDrawable(Color.TRANSPARENT));
- }
-
protected final Context getPrefContext() {
return getPreferenceManager().getContext();
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 9ab96c8..8379d34 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -44,7 +44,6 @@
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
import com.android.settings.accessibility.CaptionPropertiesFragment;
import com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment;
-import com.android.settings.accounts.AccountSettings;
import com.android.settings.accounts.AccountSyncSettings;
import com.android.settings.accounts.ChooseAccountActivity;
import com.android.settings.accounts.ManagedProfileSettings;
@@ -181,7 +180,6 @@
WifiDisplaySettings.class.getName(),
PowerUsageSummary.class.getName(),
AccountSyncSettings.class.getName(),
- AccountSettings.class.getName(),
GestureSettings.class.getName(),
AssistGestureSettings.class.getName(),
SwipeToNotificationSettings.class.getName(),
@@ -271,7 +269,6 @@
Settings.SecuritySettingsActivity.class.getName(),
Settings.InputMethodAndLanguageSettingsActivity.class.getName(),
Settings.UserSettingsActivity.class.getName(),
- Settings.AccountSettingsActivity.class.getName(),
//system_section
Settings.DateTimeSettingsActivity.class.getName(),
Settings.DeviceInfoSettingsActivity.class.getName(),
diff --git a/src/com/android/settings/core/instrumentation/EventLogWriter.java b/src/com/android/settings/core/instrumentation/EventLogWriter.java
index 2e0be30..e7628e8 100644
--- a/src/com/android/settings/core/instrumentation/EventLogWriter.java
+++ b/src/com/android/settings/core/instrumentation/EventLogWriter.java
@@ -39,8 +39,8 @@
MetricsLogger.hidden(context, category);
}
- public void action(Context context, int category) {
- MetricsLogger.action(context, category, "");
+ public void action(Context context, int category, Pair<Integer, Object>... taggedData) {
+ action(context, category, "", taggedData);
}
public void actionWithSource(Context context, int source, int category) {
diff --git a/src/com/android/settings/core/instrumentation/LogWriter.java b/src/com/android/settings/core/instrumentation/LogWriter.java
index 54ed1a8..584217d 100644
--- a/src/com/android/settings/core/instrumentation/LogWriter.java
+++ b/src/com/android/settings/core/instrumentation/LogWriter.java
@@ -36,7 +36,7 @@
/**
* Logs an user action.
*/
- void action(Context context, int category);
+ void action(Context context, int category, Pair<Integer, Object>... taggedData);
/**
* Logs an user action.
diff --git a/src/com/android/settings/core/instrumentation/MetricsFeatureProvider.java b/src/com/android/settings/core/instrumentation/MetricsFeatureProvider.java
index 66986d6..afdec55 100644
--- a/src/com/android/settings/core/instrumentation/MetricsFeatureProvider.java
+++ b/src/com/android/settings/core/instrumentation/MetricsFeatureProvider.java
@@ -15,7 +15,10 @@
*/
package com.android.settings.core.instrumentation;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
import android.util.Pair;
import com.android.internal.logging.nano.MetricsProto;
@@ -57,9 +60,9 @@
}
}
- public void action(Context context, int category) {
+ public void action(Context context, int category, Pair<Integer, Object>... taggedData) {
for (LogWriter writer : mLoggerWriters) {
- writer.action(context, category);
+ writer.action(context, category, taggedData);
}
}
@@ -100,4 +103,28 @@
}
return ((Instrumentable) object).getMetricsCategory();
}
+
+ public void logDashboardStartIntent(Context context, Intent intent,
+ int sourceMetricsCategory) {
+ if (intent == null) {
+ return;
+ }
+ final ComponentName cn = intent.getComponent();
+ if (cn == null) {
+ final String action = intent.getAction();
+ if (TextUtils.isEmpty(action)) {
+ // Not loggable
+ return;
+ }
+ action(context, MetricsProto.MetricsEvent.ACTION_SETTINGS_TILE_CLICK, action,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, sourceMetricsCategory));
+ return;
+ } else if (TextUtils.equals(cn.getPackageName(), context.getPackageName())) {
+ // Going to a Setting internal page, skip click logging in favor of page's own
+ // visibility logging.
+ return;
+ }
+ action(context, MetricsProto.MetricsEvent.ACTION_SETTINGS_TILE_CLICK, cn.flattenToString(),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, sourceMetricsCategory));
+ }
}
diff --git a/src/com/android/settings/core/instrumentation/SettingSuggestionsLogWriter.java b/src/com/android/settings/core/instrumentation/SettingSuggestionsLogWriter.java
index 1c4e26e..bbdf8c9 100644
--- a/src/com/android/settings/core/instrumentation/SettingSuggestionsLogWriter.java
+++ b/src/com/android/settings/core/instrumentation/SettingSuggestionsLogWriter.java
@@ -17,12 +17,10 @@
package com.android.settings.core.instrumentation;
import android.content.Context;
-import android.metrics.LogMaker;
import android.util.Pair;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.logging.MetricsLogger;
-import com.android.settings.suggestions.EventStore;
+import com.android.settings.dashboard.suggestions.EventStore;
/**
* {@link LogWriter} that writes setting suggestion related logs.
@@ -40,7 +38,7 @@
}
@Override
- public void action(Context context, int category) {
+ public void action(Context context, int category, Pair<Integer, Object>... taggedData) {
}
@Override
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 0db8c20..1184e89 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -27,10 +27,8 @@
import android.text.TextUtils;
import android.util.Log;
-import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.SettingsActivity;
-import com.android.settings.SubSettings;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.drawer.CategoryManager;
@@ -154,7 +152,7 @@
intent.setAction(action);
}
pref.setOnPreferenceClickListener(preference -> {
- launchIntentOrSelectProfile(activity, tile, intent);
+ launchIntentOrSelectProfile(activity, tile, intent, sourceMetricsCategory);
return true;
});
}
@@ -204,37 +202,20 @@
MetricsEvent.DASHBOARD_SUMMARY)
.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
- launchIntentOrSelectProfile(activity, tile, intent);
+ launchIntentOrSelectProfile(activity, tile, intent, MetricsEvent.DASHBOARD_SUMMARY);
}
- private void launchIntentOrSelectProfile(Activity activity, Tile tile, Intent intent) {
+ private void launchIntentOrSelectProfile(Activity activity, Tile tile, Intent intent,
+ int sourceMetricCategory) {
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
if (tile.userHandle == null) {
- logStartActivity(intent);
+ mMetricsFeatureProvider.logDashboardStartIntent(mContext, intent, sourceMetricCategory);
activity.startActivityForResult(intent, 0);
} else if (tile.userHandle.size() == 1) {
- logStartActivity(intent);
+ mMetricsFeatureProvider.logDashboardStartIntent(mContext, intent, sourceMetricCategory);
activity.startActivityForResultAsUser(intent, 0, tile.userHandle.get(0));
} else {
ProfileSelectDialog.show(activity.getFragmentManager(), tile);
}
}
-
- private void logStartActivity(Intent intent) {
- if (intent == null) {
- return;
- }
- final ComponentName cn = intent.getComponent();
- if (cn == null) {
- // Not loggable
- return;
- } else if (TextUtils.equals(cn.getPackageName(), mContext.getPackageName())) {
- // Going to a Setting internal page, skip click logging in favor of page's own
- // visibility logging.
- return;
- }
- mMetricsFeatureProvider.action(mContext,
- MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
- cn.flattenToString());
- }
}
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index d650fc7..29cee5e 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -157,6 +157,9 @@
@Override
public boolean onPreferenceTreeClick(Preference preference) {
Collection<PreferenceController> controllers = mPreferenceControllers.values();
+ // If preference contains intent, log it before handling.
+ mMetricsFeatureProvider.logDashboardStartIntent(
+ getContext(), preference.getIntent(), getMetricsCategory());
// Give all controllers a chance to handle click.
for (PreferenceController controller : controllers) {
if (controller.handlePreferenceTreeClick(preference)) {
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 7d28e4e..5206336 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -36,8 +36,8 @@
import com.android.settings.dashboard.conditional.ConditionAdapterUtils;
import com.android.settings.dashboard.conditional.ConditionManager;
import com.android.settings.dashboard.conditional.FocusRecyclerView;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.suggestions.SuggestionFeatureProvider;
import com.android.settingslib.SuggestionParser;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.DashboardCategory;
@@ -70,6 +70,7 @@
private SuggestionsChecks mSuggestionsChecks;
private DashboardFeatureProvider mDashboardFeatureProvider;
private SuggestionFeatureProvider mSuggestionFeatureProvider;
+ private boolean isOnCategoriesChangedCalled;
@Override
public int getMetricsCategory() {
@@ -204,25 +205,27 @@
Log.d(TAG, "onViewCreated took "
+ (System.currentTimeMillis() - startTime) + " ms");
}
- rebuildUI(true /* rebuildSuggestions */);
+ rebuildUI();
}
- private void rebuildUI(boolean rebuildSuggestions) {
- if (rebuildSuggestions) {
- // recheck to see if any suggestions have been changed.
- new SuggestionLoader().execute();
- // Set categories on their own if loading suggestions takes too long.
- mHandler.postDelayed(() -> {
- updateCategoryAndSuggestion(null /* tiles */);
- }, MAX_WAIT_MILLIS);
- } else {
+ @VisibleForTesting
+ void rebuildUI() {
+ new SuggestionLoader().execute();
+ // Set categories on their own if loading suggestions takes too long.
+ mHandler.postDelayed(() -> {
updateCategoryAndSuggestion(null /* tiles */);
- }
+ }, MAX_WAIT_MILLIS);
}
@Override
public void onCategoriesChanged() {
- rebuildUI(false /* rebuildSuggestions */);
+ // Bypass rebuildUI() on the first call of onCategoriesChanged, since rebuildUI() happens
+ // in onViewCreated as well when app starts. But, on the subsequent calls we need to
+ // rebuildUI() because there might be some changes to suggestions and categories.
+ if (isOnCategoriesChangedCalled) {
+ rebuildUI();
+ }
+ isOnCategoriesChangedCalled = true;
}
@Override
diff --git a/src/com/android/settings/dashboard/SuggestionsChecks.java b/src/com/android/settings/dashboard/SuggestionsChecks.java
index 66a0ef5..9cf0868 100644
--- a/src/com/android/settings/dashboard/SuggestionsChecks.java
+++ b/src/com/android/settings/dashboard/SuggestionsChecks.java
@@ -30,6 +30,7 @@
import android.os.ServiceManager;
import com.android.ims.ImsManager;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.Settings.FingerprintEnrollSuggestionActivity;
import com.android.settings.Settings.FingerprintSuggestionActivity;
import com.android.settings.Settings.ScreenLockSuggestionActivity;
@@ -38,7 +39,6 @@
import com.android.settings.Utils;
import com.android.settings.WallpaperSuggestionActivity;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.suggestions.SuggestionFeatureProvider;
import com.android.settingslib.drawer.Tile;
import java.util.Collection;
diff --git a/src/com/android/settings/dashboard/conditional/WorkModeCondition.java b/src/com/android/settings/dashboard/conditional/WorkModeCondition.java
index fb6b9c9..beed7b4 100644
--- a/src/com/android/settings/dashboard/conditional/WorkModeCondition.java
+++ b/src/com/android/settings/dashboard/conditional/WorkModeCondition.java
@@ -84,7 +84,7 @@
@Override
public void onPrimaryClick() {
mManager.getContext().startActivity(new Intent(mManager.getContext(),
- Settings.AccountSettingsActivity.class));
+ Settings.UserAndAccountDashboardActivity.class));
}
@Override
diff --git a/src/com/android/settings/suggestions/EventStore.java b/src/com/android/settings/dashboard/suggestions/EventStore.java
similarity index 98%
rename from src/com/android/settings/suggestions/EventStore.java
rename to src/com/android/settings/dashboard/suggestions/EventStore.java
index bf94f48..43ed65b 100644
--- a/src/com/android/settings/suggestions/EventStore.java
+++ b/src/com/android/settings/dashboard/suggestions/EventStore.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import android.content.Context;
import android.content.SharedPreferences;
diff --git a/src/com/android/settings/suggestions/SuggestionFeatureProvider.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
similarity index 96%
rename from src/com/android/settings/suggestions/SuggestionFeatureProvider.java
rename to src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
index e6af3bd..18fbd90 100644
--- a/src/com/android/settings/suggestions/SuggestionFeatureProvider.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import android.content.Context;
diff --git a/src/com/android/settings/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
similarity index 96%
rename from src/com/android/settings/suggestions/SuggestionFeatureProviderImpl.java
rename to src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index 97220df..3a4d545 100644
--- a/src/com/android/settings/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import android.content.Context;
diff --git a/src/com/android/settings/suggestions/SuggestionFeaturizer.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizer.java
similarity index 98%
rename from src/com/android/settings/suggestions/SuggestionFeaturizer.java
rename to src/com/android/settings/dashboard/suggestions/SuggestionFeaturizer.java
index eb43272..18ac50a 100644
--- a/src/com/android/settings/suggestions/SuggestionFeaturizer.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import java.util.HashMap;
import java.util.List;
diff --git a/src/com/android/settings/suggestions/SuggestionRanker.java b/src/com/android/settings/dashboard/suggestions/SuggestionRanker.java
similarity index 98%
rename from src/com/android/settings/suggestions/SuggestionRanker.java
rename to src/com/android/settings/dashboard/suggestions/SuggestionRanker.java
index 9f9796b..a7458bc 100644
--- a/src/com/android/settings/suggestions/SuggestionRanker.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionRanker.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import com.android.settingslib.drawer.Tile;
diff --git a/src/com/android/settings/datausage/ChartDataUsagePreference.java b/src/com/android/settings/datausage/ChartDataUsagePreference.java
index 9f47f7c..f72d465 100644
--- a/src/com/android/settings/datausage/ChartDataUsagePreference.java
+++ b/src/com/android/settings/datausage/ChartDataUsagePreference.java
@@ -50,11 +50,8 @@
public ChartDataUsagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
setSelectable(false);
- // TODO: Resource.
- mLimitColor = 0xfff4511e;
- TypedArray a = context.getTheme().obtainStyledAttributes(
- new int[]{android.R.attr.textColorSecondary});
- mWarningColor = a.getColor(0, 0);
+ mLimitColor = Utils.getColorAttr(context, android.R.attr.colorError);
+ mWarningColor = Utils.getColorAttr(context, android.R.attr.textColorSecondary);
setLayoutResource(R.layout.data_usage_graph);
}
diff --git a/src/com/android/settings/development/TelephonyMonitorPreferenceController.java b/src/com/android/settings/development/TelephonyMonitorPreferenceController.java
new file mode 100644
index 0000000..135af7d
--- /dev/null
+++ b/src/com/android/settings/development/TelephonyMonitorPreferenceController.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.widget.Toast;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settings.R;
+
+public class TelephonyMonitorPreferenceController extends PreferenceController {
+
+ private static final String KEY_TELEPHONY_MONITOR_SWITCH = "telephony_monitor_switch";
+ static final String BUILD_TYPE = "ro.build.type";
+ static final String PROPERTY_TELEPHONY_MONITOR = "persist.radio.enable_tel_mon";
+
+ private SwitchPreference mPreference;
+
+ public TelephonyMonitorPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (isAvailable()) {
+ mPreference = (SwitchPreference) screen.findPreference(KEY_TELEPHONY_MONITOR_SWITCH);
+ mPreference.setChecked(SystemProperties.getBoolean(PROPERTY_TELEPHONY_MONITOR, false));
+ }
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_TELEPHONY_MONITOR_SWITCH;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor) &&
+ (SystemProperties.get(BUILD_TYPE).equals("userdebug") ||
+ SystemProperties.get(BUILD_TYPE).equals("eng"));
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ updatePreference();
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY_TELEPHONY_MONITOR_SWITCH.equals(preference.getKey())) {
+ final SwitchPreference switchPreference = (SwitchPreference) preference;
+ SystemProperties.set(PROPERTY_TELEPHONY_MONITOR,
+ switchPreference.isChecked() ? "true" : "false");
+ Toast.makeText(mContext, R.string.telephony_monitor_toast,
+ Toast.LENGTH_LONG).show();
+ return true;
+ }
+ return false;
+ }
+
+ public void enablePreference(boolean enabled) {
+ if (isAvailable()) {
+ mPreference.setEnabled(enabled);
+ }
+ }
+
+ public boolean updatePreference() {
+ if (!isAvailable()) {
+ return false;
+ }
+ final boolean enabled = SystemProperties.getBoolean(PROPERTY_TELEPHONY_MONITOR, false);
+ mPreference.setChecked(enabled);
+ return enabled;
+ }
+
+}
diff --git a/src/com/android/settings/deviceinfo/BasebandVersionPreferenceController.java b/src/com/android/settings/deviceinfo/BasebandVersionPreferenceController.java
new file mode 100644
index 0000000..1153d12
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/BasebandVersionPreferenceController.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.PreferenceController;
+
+public class BasebandVersionPreferenceController extends PreferenceController {
+
+ private static final String BASEBAND_PROPERTY = "gsm.version.baseband";
+ private static final String KEY_BASEBAND_VERSION = "baseband_version";
+
+ public BasebandVersionPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !Utils.isWifiOnly(mContext);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_BASEBAND_VERSION;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setSummary(SystemProperties.get(BASEBAND_PROPERTY,
+ mContext.getResources().getString(R.string.device_info_default)));
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
index d118a45..a9fd21b 100644
--- a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -26,15 +26,19 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
+import android.util.Pair;
import android.widget.Toast;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.DevelopmentSettings;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.core.lifecycle.LifecycleObserver;
import com.android.settings.core.lifecycle.events.OnResume;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.Index;
import com.android.settingslib.RestrictedLockUtils;
@@ -49,6 +53,7 @@
private final Activity mActivity;
private final Fragment mFragment;
private final UserManager mUm;
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
private Toast mDevHitToast;
private RestrictedLockUtils.EnforcedAdmin mDebuggingFeaturesDisallowedAdmin;
@@ -61,6 +66,7 @@
mActivity = activity;
mFragment = fragment;
mUm = UserManager.get(activity);
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
@@ -106,11 +112,15 @@
}
// Don't enable developer options for secondary users.
if (!mUm.isAdminUser()) {
+ mMetricsFeatureProvider.action(
+ mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
return false;
}
// Don't enable developer options until device has been provisioned
if (!Utils.isDeviceProvisioned(mContext)) {
+ mMetricsFeatureProvider.action(
+ mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
return false;
}
@@ -120,6 +130,8 @@
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext,
mDebuggingFeaturesDisallowedAdmin);
}
+ mMetricsFeatureProvider.action(
+ mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
return false;
}
@@ -136,6 +148,10 @@
if (!mProcessingLastDevHit) {
enableDevelopmentSettings();
}
+ mMetricsFeatureProvider.action(
+ mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF,
+ Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED,
+ mProcessingLastDevHit ? 0 : 1));
} else if (mDevHitCountdown > 0
&& mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
if (mDevHitToast != null) {
@@ -148,6 +164,10 @@
Toast.LENGTH_SHORT);
mDevHitToast.show();
}
+ mMetricsFeatureProvider.action(
+ mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF,
+ Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED,
+ 0));
} else if (mDevHitCountdown < 0) {
if (mDevHitToast != null) {
mDevHitToast.cancel();
@@ -155,6 +175,10 @@
mDevHitToast = Toast.makeText(mContext, R.string.show_dev_already,
Toast.LENGTH_LONG);
mDevHitToast.show();
+ mMetricsFeatureProvider.action(
+ mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF,
+ Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED,
+ 1));
}
return true;
}
diff --git a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
new file mode 100644
index 0000000..1b47561
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.os.Build;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settingslib.DeviceInfoUtils;
+
+public class DeviceModelPreferenceController extends PreferenceController {
+
+ private static final String KEY_DEVICE_MODEL = "device_model";
+
+ public DeviceModelPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_DEVICE_MODEL);
+ if (pref != null) {
+ pref.setSummary(Build.MODEL + DeviceInfoUtils.getMsvSuffix());
+ }
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_DEVICE_MODEL;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceController.java b/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceController.java
new file mode 100644
index 0000000..4f8de71
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceController.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceController;
+
+public class FccEquipmentIdPreferenceController extends PreferenceController {
+
+
+ private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
+ private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id";
+
+ public FccEquipmentIdPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(SystemProperties.get(PROPERTY_EQUIPMENT_ID));
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_EQUIPMENT_ID);
+ if (pref != null) {
+ final String summary = SystemProperties.get(PROPERTY_EQUIPMENT_ID,
+ mContext.getResources().getString(R.string.device_info_default));
+ pref.setSummary(summary);
+ }
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_EQUIPMENT_ID;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/FeedbackPreferenceController.java b/src/com/android/settings/deviceinfo/FeedbackPreferenceController.java
new file mode 100644
index 0000000..ed61a92
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/FeedbackPreferenceController.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.content.Intent;
+import android.support.v7.preference.Preference;
+import android.text.TextUtils;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settingslib.DeviceInfoUtils;
+
+public class FeedbackPreferenceController extends PreferenceController {
+ private static final String KEY_DEVICE_FEEDBACK = "device_feedback";
+
+ private final Fragment mHost;
+ private final Intent intent;
+
+ public FeedbackPreferenceController(Fragment host, Context context) {
+ super(context);
+ this.mHost = host;
+ intent = new Intent("android.intent.action.BUG_REPORT");
+ }
+
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(DeviceInfoUtils.getFeedbackReporterPackage(mContext));
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ intent.setPackage(DeviceInfoUtils.getFeedbackReporterPackage(mContext));
+ preference.setIntent(intent);
+ }
+
+ public String getPreferenceKey() {
+ return KEY_DEVICE_FEEDBACK;
+ }
+
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), KEY_DEVICE_FEEDBACK)) {
+ return false;
+ }
+ if (!this.isAvailable()) {
+ return false;
+ }
+
+ this.mHost.startActivityForResult(intent, 0);
+ return true;
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceController.java b/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceController.java
new file mode 100644
index 0000000..e8792f2
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceController.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.SystemClock;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnResume;
+import com.android.settingslib.RestrictedLockUtils;
+
+
+public class FirmwareVersionPreferenceController extends PreferenceController
+ implements LifecycleObserver, OnResume {
+
+ private static final String TAG = "FirmwareVersionPref";
+ private static final String KEY_FIRMWARE_VERSION = "firmware_version";
+
+ private final UserManager mUserManager;
+
+ private RestrictedLockUtils.EnforcedAdmin mFunDisallowedAdmin;
+ private boolean mFunDisallowedBySystem;
+
+ private long[] mHits = new long[3];
+
+ public FirmwareVersionPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context);
+ mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_FIRMWARE_VERSION);
+ if (pref != null) {
+ pref.setSummary(Build.VERSION.RELEASE);
+ }
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_FIRMWARE_VERSION;
+ }
+
+ @Override
+ public void onResume() {
+ mFunDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(
+ mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId());
+ mFunDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
+ mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId());
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), KEY_FIRMWARE_VERSION)) {
+ return false;
+ }
+ System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
+ mHits[mHits.length - 1] = SystemClock.uptimeMillis();
+ if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
+ if (mUserManager.hasUserRestriction(UserManager.DISALLOW_FUN)) {
+ if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext,
+ mFunDisallowedAdmin);
+ }
+ Log.d(TAG, "Sorry, no fun for you!");
+ return false;
+ }
+
+ final Intent intent = new Intent(Intent.ACTION_MAIN)
+ .setClassName(
+ "android", com.android.internal.app.PlatLogoActivity.class.getName());
+ try {
+ mContext.startActivity(intent);
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to start activity " + intent.toString());
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/KernelVersionPreferenceController.java b/src/com/android/settings/deviceinfo/KernelVersionPreferenceController.java
new file mode 100644
index 0000000..3a84c1e
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/KernelVersionPreferenceController.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settingslib.DeviceInfoUtils;
+
+public class KernelVersionPreferenceController extends PreferenceController {
+
+ private static final String KEY_KERNEL_VERSION = "kernel_version";
+
+ public KernelVersionPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setSummary(DeviceInfoUtils.getFormattedKernelVersion());
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_KERNEL_VERSION;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceController.java b/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceController.java
new file mode 100644
index 0000000..f82fd0b
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceController.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.content.Intent;
+import android.provider.Settings;
+
+import com.android.settings.core.PreferenceController;
+
+public class RegulatoryInfoPreferenceController extends PreferenceController {
+
+ private static final String KEY_REGULATORY_INFO = "regulatory_info";
+ private static final Intent INTENT_PROBE = new Intent(Settings.ACTION_SHOW_REGULATORY_INFO);
+
+ public RegulatoryInfoPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !mContext.getPackageManager().queryIntentActivities(INTENT_PROBE, 0).isEmpty();
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_REGULATORY_INFO;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/SELinuxStatusPreferenceController.java b/src/com/android/settings/deviceinfo/SELinuxStatusPreferenceController.java
new file mode 100644
index 0000000..b8529d2
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/SELinuxStatusPreferenceController.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.os.SELinux;
+import android.os.SystemProperties;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceController;
+
+public class SELinuxStatusPreferenceController extends PreferenceController {
+
+ private static final String PROPERTY_SELINUX_STATUS = "ro.build.selinux";
+ private static final String KEY_SELINUX_STATUS = "selinux_status";
+
+ public SELinuxStatusPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(SystemProperties.get(PROPERTY_SELINUX_STATUS));
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_SELINUX_STATUS;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_SELINUX_STATUS);
+ if (pref == null) {
+ return;
+ }
+ if (!SELinux.isSELinuxEnabled()) {
+ String status = mContext.getResources().getString(R.string.selinux_status_disabled);
+ pref.setSummary(status);
+ } else if (!SELinux.isSELinuxEnforced()) {
+ String status = mContext.getResources().getString(R.string.selinux_status_permissive);
+ pref.setSummary(status);
+ }
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/SafetyInfoPreferenceController.java b/src/com/android/settings/deviceinfo/SafetyInfoPreferenceController.java
new file mode 100644
index 0000000..bde4dd0
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/SafetyInfoPreferenceController.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+
+import com.android.settings.core.PreferenceController;
+
+public class SafetyInfoPreferenceController extends PreferenceController {
+
+ private static final Intent INTENT_PROBE =
+ new Intent("android.settings.SHOW_SAFETY_AND_REGULATORY_INFO");
+
+ private final PackageManager mPackageManager;
+
+ public SafetyInfoPreferenceController(Context context) {
+ super(context);
+ mPackageManager = mContext.getPackageManager();
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !mPackageManager.queryIntentActivities(INTENT_PROBE, 0).isEmpty();
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return "safety_info";
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/SafetyLegalPreferenceController.java b/src/com/android/settings/deviceinfo/SafetyLegalPreferenceController.java
new file mode 100644
index 0000000..c158d64
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/SafetyLegalPreferenceController.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.text.TextUtils;
+
+import com.android.settings.core.PreferenceController;
+
+public class SafetyLegalPreferenceController extends PreferenceController {
+
+ private static final String KEY_SAFETY_LEGAL = "safetylegal";
+ private static final String PROPERTY_URL_SAFETYLEGAL = "ro.url.safetylegal";
+
+
+ public SafetyLegalPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(SystemProperties.get(PROPERTY_URL_SAFETYLEGAL));
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_SAFETY_LEGAL;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/SecurityPatchPreferenceController.java b/src/com/android/settings/deviceinfo/SecurityPatchPreferenceController.java
new file mode 100644
index 0000000..64a1159
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/SecurityPatchPreferenceController.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settingslib.DeviceInfoUtils;
+
+public class SecurityPatchPreferenceController extends PreferenceController {
+
+ private static final String KEY_SECURITY_PATCH = "security_patch";
+ private static final String TAG = "SecurityPatchPref";
+
+ private final String mPatch;
+ private final PackageManager mPackageManager;
+
+ public SecurityPatchPreferenceController(Context context) {
+ super(context);
+ mPackageManager = mContext.getPackageManager();
+ mPatch = DeviceInfoUtils.getSecurityPatch();
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(mPatch);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_SECURITY_PATCH;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_SECURITY_PATCH);
+ if (pref != null) {
+ pref.setSummary(mPatch);
+ }
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), KEY_SECURITY_PATCH)) {
+ return false;
+ }
+ if (mPackageManager.queryIntentActivities(preference.getIntent(), 0).isEmpty()) {
+ // Don't send out the intent to stop crash
+ Log.w(TAG, "Stop click action on " + KEY_SECURITY_PATCH + ": "
+ + "queryIntentActivities() returns empty");
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 31bcc4e..c062a56 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -76,7 +76,6 @@
private static final String TAG_DISK_INIT = "disk_init";
static final int COLOR_PUBLIC = Color.parseColor("#ff9e9e9e");
- static final int COLOR_WARNING = Color.parseColor("#fff4511e");
static final int[] COLOR_PRIVATE = new int[] {
Color.parseColor("#ff26a69a"),
diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreference.java b/src/com/android/settings/deviceinfo/StorageVolumePreference.java
index 2ef42fa..91bdfbf 100644
--- a/src/com/android/settings/deviceinfo/StorageVolumePreference.java
+++ b/src/com/android/settings/deviceinfo/StorageVolumePreference.java
@@ -32,6 +32,7 @@
import com.android.settings.R;
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
+import com.android.settingslib.Utils;
import java.io.File;
@@ -83,7 +84,7 @@
}
if (freeBytes < mStorageManager.getStorageLowBytes(path)) {
- mColor = StorageSettings.COLOR_WARNING;
+ mColor = Utils.getColorAttr(context, android.R.attr.colorError);
icon = context.getDrawable(R.drawable.ic_warning_24dp);
}
diff --git a/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java b/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java
index ef03cfb..6b72573 100644
--- a/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java
+++ b/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java
@@ -26,12 +26,10 @@
public abstract class AdminActionPreferenceControllerBase extends PreferenceController {
- private final Context mContext;
protected final EnterprisePrivacyFeatureProvider mFeatureProvider;
public AdminActionPreferenceControllerBase(Context context) {
super(context);
- mContext = context;
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
}
diff --git a/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java b/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java
index 5be7884..014092f 100644
--- a/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java
+++ b/src/com/android/settings/enterprise/DevicePolicyManagerWrapper.java
@@ -27,6 +27,13 @@
*/
public interface DevicePolicyManagerWrapper {
/**
+ * Calls {@code DevicePolicyManager.getMaximumFailedPasswordsForWipe()}.
+ *
+ * @see android.app.admin.DevicePolicyManager#getMaximumFailedPasswordsForWipe
+ */
+ int getMaximumFailedPasswordsForWipe(@Nullable ComponentName admin, int userHandle);
+
+ /**
* Calls {@code DevicePolicyManager.getDeviceOwnerComponentOnAnyUser()}.
*
* @see android.app.admin.DevicePolicyManager#getDeviceOwnerComponentOnAnyUser
@@ -34,11 +41,25 @@
ComponentName getDeviceOwnerComponentOnAnyUser();
/**
+ * Calls {@code DevicePolicyManager.getDeviceOwnerUserId()}.
+ *
+ * @see android.app.admin.DevicePolicyManager#getDeviceOwnerUserId
+ */
+ int getDeviceOwnerUserId();
+
+ /**
+ * Calls {@code DevicePolicyManager.getProfileOwnerAsUser()}.
+ *
+ * @see android.app.admin.DevicePolicyManager#getProfileOwnerAsUser
+ */
+ @Nullable ComponentName getProfileOwnerAsUser(final int userId);
+
+ /**
* Calls {@code DevicePolicyManager.getDeviceOwnerNameOnAnyUser()}.
*
* @see android.app.admin.DevicePolicyManager#getDeviceOwnerNameOnAnyUser
*/
- public CharSequence getDeviceOwnerOrganizationName();
+ CharSequence getDeviceOwnerOrganizationName();
/**
* Calls {@code DevicePolicyManager.getPermissionGrantState()}.
@@ -53,19 +74,19 @@
*
* @see android.app.admin.DevicePolicyManager#getLastSecurityLogRetrievalTime
*/
- public long getLastSecurityLogRetrievalTime();
+ long getLastSecurityLogRetrievalTime();
/**
* Calls {@code DevicePolicyManager.getLastBugReportRequestTime()}.
*
* @see android.app.admin.DevicePolicyManager#getLastBugReportRequestTime
*/
- public long getLastBugReportRequestTime();
+ long getLastBugReportRequestTime();
/**
* Calls {@code DevicePolicyManager.getLastNetworkLogRetrievalTime()}.
*
* @see android.app.admin.DevicePolicyManager#getLastNetworkLogRetrievalTime
*/
- public long getLastNetworkLogRetrievalTime();
+ long getLastNetworkLogRetrievalTime();
}
diff --git a/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java b/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java
index 6e162a8..210faec 100644
--- a/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java
+++ b/src/com/android/settings/enterprise/DevicePolicyManagerWrapperImpl.java
@@ -28,11 +28,26 @@
}
@Override
+ public int getMaximumFailedPasswordsForWipe(@Nullable ComponentName admin, int userHandle) {
+ return mDpm.getMaximumFailedPasswordsForWipe(admin, userHandle);
+ }
+
+ @Override
public ComponentName getDeviceOwnerComponentOnAnyUser() {
return mDpm.getDeviceOwnerComponentOnAnyUser();
}
@Override
+ public int getDeviceOwnerUserId() {
+ return mDpm.getDeviceOwnerUserId();
+ }
+
+ @Override
+ public @Nullable ComponentName getProfileOwnerAsUser(final int userId) {
+ return mDpm.getProfileOwnerAsUser(userId);
+ }
+
+ @Override
public CharSequence getDeviceOwnerOrganizationName() {
return mDpm.getDeviceOwnerOrganizationName();
}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
index 91ad119..79b12e6 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
@@ -74,4 +74,16 @@
* Returns whether the Device Owner set a recommended global HTTP proxy.
*/
boolean isGlobalHttpProxySet();
+
+ /**
+ * Returns the number of failed login attempts that the Device Owner allows before the entire
+ * device is wiped, or zero if no such limit is set.
+ */
+ int getMaximumFailedPasswordsBeforeWipeInPrimaryUser();
+
+ /**
+ * Returns the number of failed login attempts that the Profile Owner allows before the current
+ * user's managed profile (if any) is wiped, or zero if no such limit is set.
+ */
+ int getMaximumFailedPasswordsBeforeWipeInManagedProfile();
}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index bb5412b..645a1f5 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -16,6 +16,7 @@
package com.android.settings.enterprise;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -70,12 +71,12 @@
return userInfo.id;
}
}
- return -1;
+ return UserHandle.USER_NULL;
}
@Override
public boolean isInCompMode() {
- return hasDeviceOwner() && getManagedProfileUserId() != -1;
+ return hasDeviceOwner() && getManagedProfileUserId() != UserHandle.USER_NULL;
}
@Override
@@ -124,7 +125,7 @@
@Override
public boolean isAlwaysOnVpnSetInManagedProfile() {
final int managedProfileUserId = getManagedProfileUserId();
- return managedProfileUserId != -1 &&
+ return managedProfileUserId != UserHandle.USER_NULL &&
VpnUtils.isAlwaysOnVpnSet(mCm, managedProfileUserId);
}
@@ -133,6 +134,28 @@
return mCm.getGlobalProxy() != null;
}
+ @Override
+ public int getMaximumFailedPasswordsBeforeWipeInPrimaryUser() {
+ final ComponentName deviceOwner = mDpm.getDeviceOwnerComponentOnAnyUser();
+ if (deviceOwner == null) {
+ return 0;
+ }
+ return mDpm.getMaximumFailedPasswordsForWipe(deviceOwner, mDpm.getDeviceOwnerUserId());
+ }
+
+ @Override
+ public int getMaximumFailedPasswordsBeforeWipeInManagedProfile() {
+ final int userId = getManagedProfileUserId();
+ if (userId == UserHandle.USER_NULL) {
+ return 0;
+ }
+ final ComponentName profileOwner = mDpm.getProfileOwnerAsUser(userId);
+ if (profileOwner == null) {
+ return 0;
+ }
+ return mDpm.getMaximumFailedPasswordsForWipe(profileOwner, userId);
+ }
+
protected static class EnterprisePrivacySpan extends ClickableSpan {
private final Context mContext;
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index 75d3b10..821b7ff 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -63,6 +63,8 @@
controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context));
controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context));
controllers.add(new GlobalHttpProxyPreferenceController(context));
+ controllers.add(new FailedPasswordWipePrimaryUserPreferenceController(context));
+ controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java b/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java
new file mode 100644
index 0000000..2eac0a9
--- /dev/null
+++ b/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceController.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package com.android.settings.enterprise;
+
+import android.content.Context;
+
+import com.android.settings.R;
+
+public class FailedPasswordWipeManagedProfilePreferenceController
+ extends FailedPasswordWipePreferenceControllerBase {
+
+ private static final String KEY_FAILED_PASSWORD_WIPE_MANAGED_PROFILE
+ = "failed_password_wipe_managed_profile";
+
+ public FailedPasswordWipeManagedProfilePreferenceController(Context context) {
+ super(context, R.plurals.enterprise_privacy_failed_password_wipe_work);
+ }
+
+ @Override
+ protected int getMaximumFailedPasswordsBeforeWipe() {
+ return mFeatureProvider.getMaximumFailedPasswordsBeforeWipeInManagedProfile();
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_FAILED_PASSWORD_WIPE_MANAGED_PROFILE;
+ }
+}
diff --git a/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java b/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java
new file mode 100644
index 0000000..7cdd8da
--- /dev/null
+++ b/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBase.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.core.PreferenceController;
+import com.android.settings.overlay.FeatureFactory;
+
+public abstract class FailedPasswordWipePreferenceControllerBase extends PreferenceController {
+
+ private final int mStringResourceId;
+ protected final EnterprisePrivacyFeatureProvider mFeatureProvider;
+
+ public FailedPasswordWipePreferenceControllerBase(Context context, int stringResourceId) {
+ super(context);
+ mStringResourceId = stringResourceId;
+ mFeatureProvider = FeatureFactory.getFactory(context)
+ .getEnterprisePrivacyFeatureProvider(context);
+ }
+
+ protected abstract int getMaximumFailedPasswordsBeforeWipe();
+
+ @Override
+ public void updateState(Preference preference) {
+ final int failedPasswordsBeforeWipe = getMaximumFailedPasswordsBeforeWipe();
+ if (failedPasswordsBeforeWipe == 0) {
+ preference.setVisible(false);
+ } else {
+ preference.setVisible(true);
+ preference.setTitle(mContext.getResources().getQuantityString(
+ mStringResourceId, failedPasswordsBeforeWipe, failedPasswordsBeforeWipe));
+ }
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+}
diff --git a/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java b/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java
new file mode 100644
index 0000000..91bdf9b
--- /dev/null
+++ b/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceController.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package com.android.settings.enterprise;
+
+import android.content.Context;
+
+import com.android.settings.R;
+
+public class FailedPasswordWipePrimaryUserPreferenceController
+ extends FailedPasswordWipePreferenceControllerBase {
+
+ private static final String KEY_FAILED_PASSWORD_WIPE_PRIMARY_USER
+ = "failed_password_wipe_primary_user";
+
+ public FailedPasswordWipePrimaryUserPreferenceController(Context context) {
+ super(context, R.plurals.enterprise_privacy_failed_password_wipe_device);
+ }
+
+ @Override
+ protected int getMaximumFailedPasswordsBeforeWipe() {
+ return mFeatureProvider.getMaximumFailedPasswordsBeforeWipeInPrimaryUser();
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_FAILED_PASSWORD_WIPE_PRIMARY_USER;
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index c44a373..5f0e6e0 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -422,7 +422,7 @@
// With deduction in totalPower, percentOfTotal is higher because it adds the part
// used in screen, system, etc
- final double percentOfTotal =
+ final double percentOfTotal = totalPower == 0 ? 0 :
((sipper.totalPowerMah / totalPower) * dischargeAmount);
if (((int) (percentOfTotal + .5)) < 1) {
@@ -513,10 +513,12 @@
final BatterySipper sipper = findBatterySipperByType(
mStatsHelper.getUsageList(), DrainType.SCREEN);
final Context context = getContext();
- final double percentOfTotal = calculatePercentage(sipper.totalPowerMah, dischargeAmount);
+ final double totalPowerMah = sipper != null ? sipper.totalPowerMah : 0;
+ final long usageTimeMs = sipper != null ? sipper.usageTimeMs : 0;
+ final double percentOfTotal = calculatePercentage(totalPowerMah, dischargeAmount);
mScreenUsagePref.setSummary(getString(R.string.battery_used_for,
- Utils.formatElapsedTime(context, sipper.usageTimeMs, false)));
+ Utils.formatElapsedTime(context, usageTimeMs, false)));
mScreenConsumptionPref.setSummary(getString(R.string.battery_overall_usage,
Utils.formatPercentage(percentOfTotal, true)));
}
@@ -525,13 +527,18 @@
void updateCellularPreference(final int dischargeAmount) {
final BatterySipper sipper = findBatterySipperByType(
mStatsHelper.getUsageList(), DrainType.CELL);
- final double percentOfTotal = calculatePercentage(sipper.totalPowerMah, dischargeAmount);
+ final double totalPowerMah = sipper != null ? sipper.totalPowerMah : 0;
+ final double percentOfTotal = calculatePercentage(totalPowerMah, dischargeAmount);
mCellularNetworkPref.setSummary(getString(R.string.battery_overall_usage,
Utils.formatPercentage(percentOfTotal, true)));
}
@VisibleForTesting
void updateHeaderPreference(BatteryInfo info) {
+ final Context context = getContext();
+ if (context == null) {
+ return;
+ }
final BatteryMeterView batteryView = (BatteryMeterView) mBatteryLayoutPref
.findViewById(R.id.battery_header_icon);
final TextView timeText = (TextView) mBatteryLayoutPref.findViewById(R.id.time);
@@ -542,8 +549,7 @@
R.string.estimated_time_left : R.string.estimated_charging_time_left;
if (info.remainingTimeUs != 0) {
- timeText.setText(Utils.formatElapsedTime(getContext(),
- info.remainingTimeUs / 1000, false));
+ timeText.setText(Utils.formatElapsedTime(context, info.remainingTimeUs / 1000, false));
} else {
timeText.setText(info.statusLabel);
}
@@ -556,7 +562,9 @@
@VisibleForTesting
double calculatePercentage(double powerUsage, double dischargeAmount) {
- return ((powerUsage / mStatsHelper.getTotalPower()) * dischargeAmount);
+ final double totalPower = mStatsHelper.getTotalPower();
+ return totalPower == 0 ? 0 :
+ ((powerUsage / totalPower) * dischargeAmount);
}
@VisibleForTesting
diff --git a/src/com/android/settings/network/MobilePlanPreferenceController.java b/src/com/android/settings/network/MobilePlanPreferenceController.java
index 42b2bea..9d0878f8 100644
--- a/src/com/android/settings/network/MobilePlanPreferenceController.java
+++ b/src/com/android/settings/network/MobilePlanPreferenceController.java
@@ -29,7 +29,6 @@
import android.text.TextUtils;
import android.util.Log;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
@@ -129,7 +128,7 @@
NetworkInfo ni = mCm.getActiveNetworkInfo();
if (mTm.hasIccCard() && (ni != null)) {
// Check for carrier apps that can handle provisioning first
- Intent provisioningIntent = new Intent(TelephonyIntents.ACTION_CARRIER_SETUP);
+ Intent provisioningIntent = new Intent(Intent.ACTION_CARRIER_SETUP);
List<String> carrierPackages =
mTm.getCarrierPackageNamesForIntent(provisioningIntent);
if (carrierPackages != null && !carrierPackages.isEmpty()) {
diff --git a/src/com/android/settings/nfc/PaymentSettings.java b/src/com/android/settings/nfc/PaymentSettings.java
index a54ba4e..47de1a5 100644
--- a/src/com/android/settings/nfc/PaymentSettings.java
+++ b/src/com/android/settings/nfc/PaymentSettings.java
@@ -152,6 +152,7 @@
// Add fragment title
SearchIndexableRaw data = new SearchIndexableRaw(context);
+ data.key = PAYMENT_KEY;
data.title = res.getString(R.string.nfc_payment_settings_title);
data.screenTitle = res.getString(R.string.nfc_payment_settings_title);
data.keywords = res.getString(R.string.keywords_payment_settings);
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreference.java b/src/com/android/settings/notification/VolumeSeekBarPreference.java
index 5ab1d29..8a51961 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreference.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreference.java
@@ -59,15 +59,18 @@
}
public VolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
- this(context, attrs, defStyleAttr, 0);
+ super(context, attrs, defStyleAttr);
+ setLayoutResource(R.layout.preference_volume_slider);
}
public VolumeSeekBarPreference(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
+ super(context, attrs);
+ setLayoutResource(R.layout.preference_volume_slider);
}
public VolumeSeekBarPreference(Context context) {
- this(context, null);
+ super(context);
+ setLayoutResource(R.layout.preference_volume_slider);
}
public void setStream(int stream) {
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 11adddb..dcd2b51 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -24,13 +24,13 @@
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
import com.android.settings.localepicker.LocaleFeatureProvider;
import com.android.settings.security.SecurityFeatureProvider;
import com.android.settings.search2.SearchFeatureProvider;
-import com.android.settings.suggestions.SuggestionFeatureProvider;
/**
* Abstract class for creating feature controllers. Allows OEM implementations to define their own
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 56e554d..377e6bb 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -30,6 +30,8 @@
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.enterprise.DevicePolicyManagerWrapperImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
@@ -43,8 +45,6 @@
import com.android.settings.search2.SearchFeatureProviderImpl;
import com.android.settings.security.SecurityFeatureProvider;
import com.android.settings.security.SecurityFeatureProviderImpl;
-import com.android.settings.suggestions.SuggestionFeatureProvider;
-import com.android.settings.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.vpn2.ConnectivityManagerWrapperImpl;
/**
diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java
index 4f660bf..fc1b8d9 100644
--- a/src/com/android/settings/search/Ranking.java
+++ b/src/com/android/settings/search/Ranking.java
@@ -28,7 +28,7 @@
import com.android.settings.WallpaperTypeSettings;
import com.android.settings.WirelessSettings;
import com.android.settings.accessibility.AccessibilitySettings;
-import com.android.settings.accounts.AccountSettings;
+import com.android.settings.accounts.UserAndAccountDashboardFragment;
import com.android.settings.applications.AdvancedAppSettings;
import com.android.settings.applications.SpecialAccessSettings;
import com.android.settings.bluetooth.BluetoothSettings;
@@ -166,7 +166,7 @@
sRankMap.put(ScreenPinningSettings.class.getName(), RANK_SECURITY);
// Accounts
- sRankMap.put(AccountSettings.class.getName(), RANK_ACCOUNT);
+ sRankMap.put(UserAndAccountDashboardFragment.class.getName(), RANK_ACCOUNT);
// IMEs
sRankMap.put(InputMethodAndLanguageSettings.class.getName(), RANK_IME);
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 956ac0b..1968c7a 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -33,7 +33,6 @@
import com.android.settings.WallpaperTypeSettings;
import com.android.settings.WirelessSettings;
import com.android.settings.accessibility.AccessibilitySettings;
-import com.android.settings.accounts.AccountSettings;
import com.android.settings.accounts.UserAndAccountDashboardFragment;
import com.android.settings.applications.AdvancedAppSettings;
import com.android.settings.applications.AppAndNotificationDashboardFragment;
@@ -155,7 +154,6 @@
addIndex(EncryptionAndCredential.class, R.xml.encryption_and_credential,
R.drawable.ic_settings_security);
addIndex(ScreenPinningSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
- addIndex(AccountSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accounts);
addIndex(UserAndAccountDashboardFragment.class, NO_DATA_RES_ID,
R.drawable.ic_settings_accounts);
addIndex(InputMethodAndLanguageSettings.class,
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 000ccf5..c3a058a 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -27,7 +27,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
-import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -53,7 +52,6 @@
import android.view.View.OnClickListener;
import android.widget.SimpleAdapter;
-import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.ChooseLockGeneric;
@@ -63,9 +61,6 @@
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
-import com.android.settings.accounts.AddUserWhenLockedPreferenceController;
-import com.android.settings.accounts.EmergencyInfoPreferenceController;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
@@ -102,9 +97,6 @@
private static final String KEY_USER_LIST = "user_list";
private static final String KEY_USER_ME = "user_me";
private static final String KEY_ADD_USER = "user_add";
- private static final String KEY_EMERGENCY_INFO = "emergency_info";
-
- private static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENGY_INFO";
private static final int MENU_REMOVE_USER = Menu.FIRST;
@@ -136,9 +128,6 @@
private PreferenceGroup mUserListCategory;
private UserPreference mMePreference;
private DimmableIconPreference mAddUser;
- private PreferenceGroup mLockScreenSettings;
- private RestrictedSwitchPreference mAddUserWhenLocked;
- private Preference mEmergencyInfoPreference;
private int mRemovingUserId = -1;
private int mAddedUserId = 0;
private boolean mAddingUser;
@@ -151,8 +140,6 @@
private EditUserInfoController mEditUserInfoController =
new EditUserInfoController();
- private EmergencyInfoPreferenceController mEnergencyInfoController;
- private AddUserWhenLockedPreferenceController mAddUserWhenLockedController;
// A place to cache the generated default avatar
private Drawable mDefaultIconDrawable;
@@ -236,14 +223,6 @@
mAddUser.setTitle(R.string.user_add_user_menu);
}
}
- if (showEmergencyInfoAndAddUsersWhenLock(context)) {
- mLockScreenSettings = (PreferenceGroup) findPreference("lock_screen_settings");
- mAddUserWhenLocked =
- (RestrictedSwitchPreference) findPreference("add_users_when_locked");
- mEmergencyInfoPreference = findPreference(KEY_EMERGENCY_INFO);
- mEnergencyInfoController = new EmergencyInfoPreferenceController(context);
- mAddUserWhenLockedController = new AddUserWhenLockedPreferenceController(context);
- }
setHasOptionsMenu(true);
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
@@ -658,20 +637,6 @@
}
}
- @VisibleForTesting
- boolean showEmergencyInfoAndAddUsersWhenLock(Context context) {
- return !FeatureFactory.getFactory(context).getDashboardFeatureProvider(context).isEnabled();
- }
-
- private static boolean emergencyInfoActivityPresent(Context context) {
- Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage("com.android.emergency");
- List<ResolveInfo> infos = context.getPackageManager().queryIntentActivities(intent, 0);
- if (infos == null || infos.isEmpty()) {
- return false;
- }
- return true;
- }
-
private void removeUserNow() {
if (mRemovingUserId == UserHandle.myUserId()) {
removeThisUser();
@@ -903,20 +868,6 @@
}
}
- if (showEmergencyInfoAndAddUsersWhenLock(context)) {
- if (mAddUserWhenLockedController.isAvailable()) {
- mLockScreenSettings.setOrder(Preference.DEFAULT_ORDER);
- preferenceScreen.addPreference(mLockScreenSettings);
- mAddUserWhenLockedController.updateState(mAddUserWhenLocked);
- mAddUserWhenLocked.setOnPreferenceChangeListener(mAddUserWhenLockedController);
- }
-
- if (emergencyInfoActivityPresent(getContext())) {
- mEmergencyInfoPreference.setOnPreferenceClickListener(this);
- mEmergencyInfoPreference.setOrder(Preference.DEFAULT_ORDER);
- preferenceScreen.addPreference(mEmergencyInfoPreference);
- }
- }
}
private int getMaxRealUsers() {
@@ -997,8 +948,6 @@
} else {
onAddUserClicked(USER_TYPE_USER);
}
- } else if (mEnergencyInfoController != null) {
- mEnergencyInfoController.handlePreferenceTreeClick(pref);
}
return false;
}
@@ -1082,12 +1031,6 @@
data.screenTitle = res.getString(R.string.user_settings_title);
result.add(data);
}
- if (emergencyInfoActivityPresent(context)) {
- data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.emergency_info_title);
- data.screenTitle = res.getString(R.string.emergency_info_title);
- result.add(data);
- }
return result;
}
};
diff --git a/src/com/android/settings/widget/PreferenceDividerDecoration.java b/src/com/android/settings/widget/PreferenceDividerDecoration.java
deleted file mode 100644
index 4466a3d..0000000
--- a/src/com/android/settings/widget/PreferenceDividerDecoration.java
+++ /dev/null
@@ -1,79 +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.
- */
-
-package com.android.settings.widget;
-
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceGroupAdapter;
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
-
-public class PreferenceDividerDecoration extends RecyclerView.ItemDecoration {
-
- private Drawable mDivider;
- private int mDividerHeight;
-
- public void setDivider(Drawable divider) {
- if (divider != null) {
- mDividerHeight = divider.getIntrinsicHeight();
- } else {
- mDividerHeight = 0;
- }
- mDivider = divider;
- }
-
- public void setDividerHeight(int dividerHeight) {
- mDividerHeight = dividerHeight;
- }
-
- @Override
- public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
- if (mDivider == null) {
- return;
- }
- final int childCount = parent.getChildCount();
- final int width = parent.getWidth();
- for (int childViewIndex = 0; childViewIndex < childCount; childViewIndex++) {
- final View view = parent.getChildAt(childViewIndex);
- if (shouldDrawDividerAbove(view, parent)) {
- int top = (int) ViewCompat.getY(view);
- mDivider.setBounds(0, top, width, top + mDividerHeight);
- mDivider.draw(c);
- }
- }
- }
-
- private boolean shouldDrawDividerAbove(View view, RecyclerView parent) {
- final RecyclerView.Adapter adapter = parent.getAdapter();
- if (adapter == null || !(adapter instanceof PreferenceGroupAdapter)) {
- return false;
- }
- final PreferenceGroupAdapter prefAdapter = (PreferenceGroupAdapter) adapter;
- final int adapterPosition = parent.getChildAdapterPosition(view);
- if (adapterPosition == RecyclerView.NO_POSITION) {
- return false;
- }
- final Preference pref = prefAdapter.getItem(adapterPosition);
- if (pref instanceof PreferenceCategory) {
- return adapterPosition != 0;
- }
- return pref instanceof FooterPreference;
- }
-}
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 1ec4380..72da2e9 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -182,8 +182,8 @@
public void onForget(WifiDialog dialog) {
if (mSelectedAccessPoint != null) {
mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId, null);
- getPreferenceScreen().removePreference((Preference) mSelectedAccessPoint.getTag());
mSelectedAccessPoint = null;
+ initPreferences();
}
}
diff --git a/tests/app/src/com/android/settings/users/UserSettingsTest.java b/tests/app/src/com/android/settings/users/UserSettingsTest.java
new file mode 100644
index 0000000..1a33917
--- /dev/null
+++ b/tests/app/src/com/android/settings/users/UserSettingsTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package com.android.settings.users;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.filters.SmallTest;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject;
+import android.support.test.uiautomator.UiSelector;
+import android.support.test.uiautomator.UiScrollable;
+import android.test.InstrumentationTestCase;
+
+import com.android.settings.R;
+
+import org.junit.Test;
+
+@SmallTest
+public class UserSettingsTest extends InstrumentationTestCase {
+
+ private static final String USER_AND_ACCOUNTS = "User & accounts";
+ private static final String USERS = "Users";
+ private static final String EMERGNENCY_INFO = "Emergency information";
+ private static final String ADD_USERS_WHEN_LOCKED = "Add users";
+
+ private UiDevice mDevice;
+ private Context mContext;
+ private String mTargetPackage;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mContext = getInstrumentation().getTargetContext();
+ mTargetPackage = mContext.getPackageName();
+ }
+
+ @Test
+ public void testEmergencyInfoNotExists() throws Exception {
+ launchUserSettings();
+ UiObject emergencyInfoPreference =
+ mDevice.findObject(new UiSelector().text(EMERGNENCY_INFO));
+ assertFalse(emergencyInfoPreference.exists());
+ }
+
+ @Test
+ public void testAddUsersWhenLockedNotExists() throws Exception {
+ launchUserSettings();
+ UiObject addUsersPreference =
+ mDevice.findObject(new UiSelector().text(ADD_USERS_WHEN_LOCKED));
+ assertFalse(addUsersPreference.exists());
+ }
+
+ private void launchSettings() {
+ Intent settingsIntent = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_LAUNCHER)
+ .setPackage(mTargetPackage)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getInstrumentation().getContext().startActivity(settingsIntent);
+ }
+
+ private void launchUserSettings() throws Exception {
+ launchSettings();
+ final UiScrollable settings = new UiScrollable(
+ new UiSelector().packageName(mTargetPackage).scrollable(true));
+ final String titleUsersAndAccounts = USER_AND_ACCOUNTS;
+ settings.scrollTextIntoView(titleUsersAndAccounts);
+ mDevice.findObject(new UiSelector().text(titleUsersAndAccounts)).click();
+ mDevice.findObject(new UiSelector().text(USERS)).click();
+ }
+
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index e57f9d5..d7ea14c 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -8,7 +8,6 @@
com.android.settings.notification.ZenModeEventRuleSettings
com.android.settings.fuelgauge.InactiveApps
com.android.settings.accessibility.CaptionPropertiesFragment
-com.android.settings.accounts.ManageAccountsSettings
com.android.settings.accessibility.AccessibilitySettingsForSetupWizard
com.android.settings.deviceinfo.ImeiInformation
com.android.settings.datausage.DataUsageList
diff --git a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
index 6b49b80..ea889a5 100644
--- a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
@@ -19,10 +19,6 @@
import android.content.Context;
import android.os.UserManager;
import android.support.v7.preference.PreferenceScreen;
-import android.test.AndroidTestCase;
-
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settingslib.DeviceInfoUtils;
import org.junit.Before;
import org.junit.Test;
@@ -33,14 +29,13 @@
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class DeviceInfoSettingsTest extends AndroidTestCase {
+public class DeviceInfoSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@@ -49,60 +44,18 @@
@Mock
private UserManager mUserManager;
- private FakeFeatureFactory mFeatureFactory;
private DeviceInfoSettings mSettings;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mSettings = spy(new DeviceInfoSettings());
doReturn(mScreen).when(mSettings).getPreferenceScreen();
}
@Test
- public void getPrefXml_shoudlReturnDeviceInfoXml() {
+ public void getPrefXml_shouldReturnDeviceInfoXml() {
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.device_info_settings);
}
-
- @Test
- public void testGetFormattedKernelVersion() throws Exception {
- assertWithMessage("formatKernelVersion can't cope with this device's /proc/version")
- .that(DeviceInfoUtils.getFormattedKernelVersion())
- .isNotEqualTo("Unavailable");
- }
-
- @Test
- public void testFormatKernelVersion() throws Exception {
- assertThat(DeviceInfoUtils.formatKernelVersion("")).isEqualTo("Unavailable");
- assertThat(DeviceInfoUtils.formatKernelVersion("Linux version 2.6.38.8-gg784 " +
- "(root@hpao4.eem.corp.google.com) " +
- "(gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #2 SMP " +
- "Fri Feb 24 03:31:23 PST 2012"))
- .isEqualTo("2.6.38.8-gg784\n" +
- "root@hpao4.eem.corp.google.com #2\n" +
- "Fri Feb 24 03:31:23 PST 2012");
- assertThat(DeviceInfoUtils.formatKernelVersion("Linux version 3.0.31-g6fb96c9 " +
- "(android-build@vpbs1.mtv.corp.google.com) " +
- "(gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #1 " +
- "SMP PREEMPT Thu Jun 28 11:02:39 PDT 2012"))
- .isEqualTo("3.0.31-g6fb96c9\n" +
- "android-build@vpbs1.mtv.corp.google.com #1\n" +
- "Thu Jun 28 11:02:39 PDT 2012");
- assertThat(DeviceInfoUtils.formatKernelVersion("Linux version " +
- "2.6.38.8-a-b-jellybean+ (x@y) " +
- "(gcc version 4.4.3 (GCC) ) #1 PREEMPT Tue Aug 28 22:10:46 CDT 2012"))
- .isEqualTo("2.6.38.8-a-b-jellybean+\n" +
- "x@y #1\n" +
- "Tue Aug 28 22:10:46 CDT 2012");
- assertThat(DeviceInfoUtils.formatKernelVersion("Linux version " +
- "3.18.31-g3ce5faa-dirty (x@y) (Android clang " +
- "version 3.8.275480 (based on LLVM 3.8.275480)) " +
- "#5 SMP PREEMPT Fri Oct 28 14:38:13 PDT 2016"))
- .isEqualTo("3.18.31-g3ce5faa-dirty\n" +
- "x@y #5\n" +
- "Fri Oct 28 14:38:13 PDT 2016");
- }
}
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index e5c4a66..2b861e2 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -22,7 +22,6 @@
import android.content.pm.UserInfo;
import android.os.UserHandle;
import android.os.UserManager;
-import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceManager;
@@ -30,6 +29,7 @@
import com.android.settings.AccessiblePreferenceCategory;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.search.SearchIndexableRaw;
@@ -70,7 +70,7 @@
@Mock(answer = RETURNS_DEEP_STUBS)
private UserManager mUserManager;
@Mock(answer = RETURNS_DEEP_STUBS)
- private PreferenceFragment mFragment;
+ private SettingsPreferenceFragment mFragment;
@Mock(answer = RETURNS_DEEP_STUBS)
private AccountManager mAccountManager;
@Mock(answer = RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/accounts/ManageAccountsSettingsTest.java b/tests/robotests/src/com/android/settings/accounts/ManageAccountsSettingsTest.java
deleted file mode 100644
index 916e395..0000000
--- a/tests/robotests/src/com/android/settings/accounts/ManageAccountsSettingsTest.java
+++ /dev/null
@@ -1,135 +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.
- */
-
-package com.android.settings.accounts;
-
-import android.accounts.Account;
-import android.content.SyncInfo;
-import android.content.SyncStatusInfo;
-import android.os.UserHandle;
-import android.support.v7.preference.PreferenceScreen;
-import android.util.ArraySet;
-
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class ManageAccountsSettingsTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private AccountPreference mAccountPref;
- private Account mAccount;
- private ArrayList<String> mAuthorities;
- private TestFragment mSettings;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mAuthorities = new ArrayList<>();
- mAuthorities.add("authority");
- mAccount = new Account("name", "type");
- when(mAccountPref.getAccount()).thenReturn(mAccount);
- when(mAccountPref.getAuthorities()).thenReturn(mAuthorities);
- mSettings = new TestFragment();
- }
-
- @Test
- public void showSyncState_noAccountPrefs_shouldUpdateNothing() {
- when(mAccountPref.getAuthorities()).thenReturn(null);
- mSettings.showSyncState();
- verify(mSettings.getPreferenceScreen(), never()).getPreference(anyInt());
- }
-
- @Test
- public void showSyncState_syncInProgress_shouldUpdateInProgress() {
- mSettings.mUserFacingSyncAuthorities.add(mAuthorities.get(0));
- mSettings.mSyncInfos.add(new SyncInfo(0, mAccount, mAuthorities.get(0), 0));
- mSettings.mSyncStatusInfo = new SyncStatusInfo(0);
- when(mSettings.getPreferenceScreen().getPreferenceCount()).thenReturn(1);
- when(mSettings.getPreferenceScreen().getPreference(0)).thenReturn(mAccountPref);
-
- mSettings.showSyncState();
-
- verify(mSettings.getPreferenceScreen()).getPreference(anyInt());
- verify(mAccountPref).setSyncStatus(AccountPreference.SYNC_IN_PROGRESS, true);
- }
-
- @Test
- public void showSyncState_noUserFacingSynclets_shouldUpdateToDisabled() {
- mSettings.mSyncInfos.add(new SyncInfo(0, mAccount, mAuthorities.get(0), 0));
- mSettings.mSyncStatusInfo = new SyncStatusInfo(0);
- when(mSettings.getPreferenceScreen().getPreferenceCount()).thenReturn(1);
- when(mSettings.getPreferenceScreen().getPreference(0)).thenReturn(mAccountPref);
-
- mSettings.showSyncState();
-
- verify(mSettings.getPreferenceScreen()).getPreference(anyInt());
- verify(mAccountPref).setSyncStatus(AccountPreference.SYNC_DISABLED, true);
- }
-
- public static class TestFragment extends ManageAccountsSettings {
-
- private PreferenceScreen mScreen;
- private List<SyncInfo> mSyncInfos;
- private SyncStatusInfo mSyncStatusInfo;
-
- public TestFragment() {
- mUserHandle = mock(UserHandle.class);
- mScreen = mock(PreferenceScreen.class);
- mUserFacingSyncAuthorities = new ArraySet<>();
- mSyncInfos = new ArrayList<>();
- }
-
- @Override
- public PreferenceScreen getPreferenceScreen() {
- return mScreen;
- }
-
- @Override
- protected boolean isSyncEnabled(int userId, Account account, String authority) {
- return true;
- }
-
- @Override
- protected List<SyncInfo> getCurrentSyncs(int userId) {
- return mSyncInfos;
- }
-
- @Override
- protected SyncStatusInfo getSyncStatusInfo(Account account, String authority, int userId) {
- return mSyncStatusInfo;
- }
- }
-
-}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java
index 8729d84..871b5a0 100644
--- a/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ManageApplicationsTest.java
@@ -16,8 +16,12 @@
package com.android.settings.applications;
+import android.app.Activity;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.os.Looper;
-import android.os.UserManager;
+import android.widget.TextView;
+import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -36,6 +40,8 @@
import org.robolectric.util.ReflectionHelpers;
import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
@@ -55,7 +61,6 @@
@Mock private ApplicationsState mState;
@Mock private ApplicationsState.Session mSession;
- @Mock private UserManager mUserManager;
private Looper mBgLooper;
private ManageApplications mFragment;
@@ -78,4 +83,21 @@
SettingsRobolectricTestRunner.startSettingsFragment(
mFragment, Settings.ManageApplicationsActivity.class);
}
+
+ @Test
+ public void updateDisableView_appDisabledUntilUsed_shouldSetDisabled() {
+ final TextView view = mock(TextView.class);
+ final ApplicationInfo info = new ApplicationInfo();
+ info.flags = ApplicationInfo.FLAG_INSTALLED;
+ info.enabled = true;
+ info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED;
+ ManageApplications fragment = mock(ManageApplications.class);
+ when(fragment.getActivity()).thenReturn(mock(Activity.class));
+ final ManageApplications.ApplicationsAdapter adapter =
+ new ManageApplications.ApplicationsAdapter(mState, fragment, 0);
+
+ adapter.updateDisableView(view, info);
+
+ verify(view).setText(R.string.disabled);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/MetricsFeatureProviderTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/MetricsFeatureProviderTest.java
index 41a2a71..eb6e392 100644
--- a/tests/robotests/src/com/android/settings/core/instrumentation/MetricsFeatureProviderTest.java
+++ b/tests/robotests/src/com/android/settings/core/instrumentation/MetricsFeatureProviderTest.java
@@ -15,35 +15,51 @@
*/
package com.android.settings.core.instrumentation;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.util.Pair;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.overlay.FeatureFactory;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+import java.util.List;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class MetricsFeatureProviderTest {
- private ShadowApplication mApplication;
- private Context mContext;
-
@Mock
private LogWriter mLogWriter;
+ private Context mContext;
+ private MetricsFeatureProvider mProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mApplication = ShadowApplication.getInstance();
- mContext = mApplication.getApplicationContext();
+ mContext = RuntimeEnvironment.application;
+ mProvider = new MetricsFeatureProvider();
+ List<LogWriter> writers = new ArrayList<>();
+ writers.add(mLogWriter);
+ ReflectionHelpers.setField(mProvider, "mLoggerWriters", writers);
}
@Test
@@ -55,4 +71,38 @@
assertThat(feature1 == feature2).isTrue();
}
+
+ @Test
+ public void logDashboardStartIntent_intentEmpty_shouldNotLog() {
+ mProvider.logDashboardStartIntent(mContext, null /* intent */,
+ MetricsEvent.SETTINGS_GESTURES);
+
+ verifyNoMoreInteractions(mLogWriter);
+ }
+
+ @Test
+ public void logDashboardStartIntent_intentHasNoComponent_shouldLog() {
+ final Intent intent = new Intent(Intent.ACTION_ASSIST);
+
+ mProvider.logDashboardStartIntent(mContext, intent, MetricsEvent.SETTINGS_GESTURES);
+
+ verify(mLogWriter).action(
+ eq(mContext),
+ eq(MetricsEvent.ACTION_SETTINGS_TILE_CLICK),
+ anyString(),
+ eq(Pair.create(MetricsEvent.FIELD_CONTEXT, MetricsEvent.SETTINGS_GESTURES)));
+ }
+
+ @Test
+ public void logDashboardStartIntent_intentIsExternal_shouldLog() {
+ final Intent intent = new Intent().setComponent(new ComponentName("pkg", "cls"));
+
+ mProvider.logDashboardStartIntent(mContext, intent, MetricsEvent.SETTINGS_GESTURES);
+
+ verify(mLogWriter).action(
+ eq(mContext),
+ eq(MetricsEvent.ACTION_SETTINGS_TILE_CLICK),
+ anyString(),
+ eq(Pair.create(MetricsEvent.FIELD_CONTEXT, MetricsEvent.SETTINGS_GESTURES)));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index ebe1f0a..8e46343 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -56,7 +56,6 @@
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -166,10 +165,11 @@
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
- verify(mFeatureFactory.metricsFeatureProvider).action(
+
+ verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(
any(Context.class),
- eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_TILE_CLICK),
- eq(tile.intent.getComponent().flattenToString()));
+ any(Intent.class),
+ eq(MetricsProto.MetricsEvent.SETTINGS_GESTURES));
verify(mActivity)
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
@@ -193,10 +193,10 @@
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
- verify(mFeatureFactory.metricsFeatureProvider, never()).action(
+ verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(
any(Context.class),
- eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_TILE_CLICK),
- eq(tile.intent.getComponent().flattenToString()));
+ any(Intent.class),
+ anyInt());
verify(mActivity)
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
index 62866c9..b3f9fe0 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
@@ -34,6 +34,7 @@
import org.robolectric.util.ReflectionHelpers;
import static org.mockito.Matchers.anyList;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -41,6 +42,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DashboardSummaryTest {
@@ -93,11 +95,19 @@
}
@Test
- public void onCategoryChanged_updateCategoryOnly() {
+ public void onCategoryChanged_noRebuildOnFirstCall() {
doReturn(mock(Activity.class)).when(mSummary).getActivity();
- when(mDashboardFeatureProvider.isEnabled()).thenReturn(true);
-
+ doNothing().when(mSummary).rebuildUI();
mSummary.onCategoriesChanged();
- verify(mAdapter).setCategory(anyList());
+ verify(mSummary, never()).rebuildUI();
+ }
+
+ @Test
+ public void onCategoryChanged_rebuildOnSecondCall() {
+ doReturn(mock(Activity.class)).when(mSummary).getActivity();
+ doNothing().when(mSummary).rebuildUI();
+ mSummary.onCategoriesChanged();
+ mSummary.onCategoriesChanged();
+ verify(mSummary).rebuildUI();
}
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/suggestions/EventStoreTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/suggestions/EventStoreTest.java
rename to tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java
index 9db11b8..4b9e440 100644
--- a/tests/robotests/src/com/android/settings/suggestions/EventStoreTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/EventStoreTest.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
diff --git a/tests/robotests/src/com/android/settings/suggestions/SuggestionFeaturizerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/suggestions/SuggestionFeaturizerTest.java
rename to tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java
index 3c5bd4f..cb4ce71 100644
--- a/tests/robotests/src/com/android/settings/suggestions/SuggestionFeaturizerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeaturizerTest.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import java.util.Arrays;
import java.util.Map;
diff --git a/tests/robotests/src/com/android/settings/suggestions/SuggestionRankerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/suggestions/SuggestionRankerTest.java
rename to tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
index 086161b..056d959 100644
--- a/tests/robotests/src/com/android/settings/suggestions/SuggestionRankerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionRankerTest.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.settings.suggestions;
+package com.android.settings.dashboard.suggestions;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/tests/robotests/src/com/android/settings/development/TelephonyMonitorPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/TelephonyMonitorPreferenceControllerTest.java
new file mode 100644
index 0000000..5167c68
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/TelephonyMonitorPreferenceControllerTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.shadows.ShadowToast;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class TelephonyMonitorPreferenceControllerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private SwitchPreference mPreference;
+
+ private TelephonyMonitorPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ SettingsShadowSystemProperties.clear();
+ mController = new TelephonyMonitorPreferenceController(mContext);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void isAvailable_trueShowFlagWithUserdebugBuild_shouldReturnTrue() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(true);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void isAvailable_trueShowFlagWithEngBuild_shouldReturnTrue() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(true);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "eng");
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void isAvailable_trueShowFlagWithUserBuild_shouldReturnFalse() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(true);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "user");
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void isAvailable_falseShowFlagWithUserdebugBuild_shouldReturnFalse() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(false);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void isAvailable_falseShowFlagWithEngBuild_shouldReturnFalse() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(false);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "eng");
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void isAvailable_falseShowFlagWithUserBuild_shouldReturnFalse() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(false);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "user");
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void displayPreference_telephonyMonitorEnabled_shouldCheckedPreference() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(true);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR, "true");
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
+
+ mController.displayPreference(mScreen);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void displayPreference_telephonyMonitorDisabled_shouldUncheckedPreference() {
+ when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
+ .thenReturn(true);
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR, "false");
+ SettingsShadowSystemProperties.set(
+ TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
+
+ mController.displayPreference(mScreen);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void handlePreferenceTreeClick_preferenceChecked_shouldEnableTelephonyMonitor() {
+ when(mPreference.isChecked()).thenReturn(true);
+
+ when(mContext.getResources().getString(R.string.telephony_monitor_toast))
+ .thenReturn("To apply telephony monitor change, reboot device");
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ assertThat(SystemProperties.getBoolean(
+ TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR, false)).isTrue();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void handlePreferenceTreeClick_preferenceUnchecked_shouldDisableTelephonyMonitor() {
+ when(mPreference.isChecked()).thenReturn(false);
+
+ when(mContext.getResources().getString(R.string.telephony_monitor_toast))
+ .thenReturn("To apply telephony monitor change, reboot device");
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ assertThat(SystemProperties.getBoolean(
+ TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR, false)).isFalse();
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..b54fc53
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.os.SystemProperties;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowSystemProperties;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class BasebandVersionPreferenceControllerTest {
+
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private ConnectivityManager mCm;
+ @Mock
+ private Preference mPreference;
+
+ private BasebandVersionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new BasebandVersionPreferenceController(mContext);
+ when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mCm);
+ }
+
+ @Test
+ public void isAvailable_wifiOnly_shouldReturnFalse() {
+ when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_hasMobile_shouldReturnTrue() {
+ when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(true);
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Config(shadows = {SettingsShadowSystemProperties.class})
+ @Test
+ public void updateState_shouldLoadFromSysProperty() {
+ SettingsShadowSystemProperties.set("gsm.version.baseband", "test");
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary("test");
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index 81372cc..017c5a8 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -25,9 +25,11 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.DevelopmentSettings;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Test;
@@ -35,12 +37,14 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -61,16 +65,19 @@
@Mock
private UserManager mUserManager;
+ private FakeFeatureFactory mFactory;
private Preference mPreference;
private BuildNumberPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ FakeFeatureFactory.setupForTest(mContext);
+ mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mController = new BuildNumberPreferenceController(mContext, mActivity, mFragment);
- mPreference = new Preference(ShadowApplication.getInstance().getApplicationContext());
+ mPreference = new Preference(RuntimeEnvironment.application);
mPreference.setKey(mController.getPreferenceKey());
}
@@ -104,10 +111,13 @@
mController = new BuildNumberPreferenceController(context, mActivity, mFragment);
assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse();
+ verify(mFactory.metricsFeatureProvider).action(
+ any(Context.class),
+ eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF));
}
@Test
- public void handlePrefTreeClick_userHasRestrction_doNothing() {
+ public void handlePrefTreeClick_userHasRestriction_doNothing() {
when(mUserManager.isAdminUser()).thenReturn(true);
final Context context = ShadowApplication.getInstance().getApplicationContext();
Settings.Global.putInt(context.getContentResolver(),
@@ -118,6 +128,9 @@
mController = new BuildNumberPreferenceController(context, mActivity, mFragment);
assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse();
+ verify(mFactory.metricsFeatureProvider).action(
+ any(Context.class),
+ eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java
new file mode 100644
index 0000000..06d81de
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DeviceModelPreferenceControllerTest {
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private Preference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private DeviceModelPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new DeviceModelPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ }
+
+ @Test
+ public void isAlwaysAvailable() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void displayPref_shouldSetSummary() {
+ mController.displayPreference(mPreferenceScreen);
+
+ verify(mPreference).setSummary(anyString());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
new file mode 100644
index 0000000..7b2b198
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class FccEquipmentIdPreferenceControllerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private Preference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private FccEquipmentIdPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new FccEquipmentIdPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ }
+
+ @Test
+ public void isAvailable_configEmpty_shouldReturnFalse() {
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ @Config(shadows = SettingsShadowSystemProperties.class)
+ public void isAvailable_configNonEmpty_shouldReturnTrue() {
+ SettingsShadowSystemProperties.set("ro.ril.fccid", "fcc_equipment");
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
new file mode 100644
index 0000000..1cbd147
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.app.Fragment;
+import android.content.Context;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class FeedbackPreferenceControllerTest {
+ @Mock
+ private Fragment mFragment;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ private FeedbackPreferenceController mController;
+
+ public FeedbackPreferenceControllerTest() {
+ }
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ this.mController = new FeedbackPreferenceController(this.mFragment, this.mContext);
+ }
+
+ @Test
+ public void isAvailable_noReporterPackage_shouldReturnFalse() {
+ when(this.mContext.getResources().getString(anyInt())).thenReturn("");
+ assertThat(Boolean.valueOf(this.mController.isAvailable())).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..732ba22
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.os.UserManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class FirmwareVersionPreferenceControllerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private Preference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private UserManager mUserManager;
+ private FirmwareVersionPreferenceController mController;
+ private Lifecycle mLifecycle;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mLifecycle = new Lifecycle();
+ when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+ when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(null);
+ mController = new FirmwareVersionPreferenceController(mContext, mLifecycle);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ }
+
+ @Test
+ public void isAlwaysAvailable() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java
new file mode 100644
index 0000000..8d47135
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/KernelVersionPreferenceControllerTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class KernelVersionPreferenceControllerTest {
+
+ @Mock
+ private Context mContext;
+ private KernelVersionPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new KernelVersionPreferenceController(mContext);
+ }
+
+ @Test
+ public void alwaysAvailable() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
new file mode 100644
index 0000000..87e8e1b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.deviceinfo;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class RegulatoryInfoPreferenceControllerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock
+ private Preference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private PackageManager mPackageManager;
+ private RegulatoryInfoPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+
+ mController = new RegulatoryInfoPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ }
+
+ @Test
+ public void isAvailable_hasIntent_returnTrue() {
+ final List<ResolveInfo> activities = new ArrayList<>();
+ activities.add(new ResolveInfo());
+ when(mPackageManager.queryIntentActivities(any(Intent.class), eq(0)))
+ .thenReturn(activities);
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_hasNoIntent_returnFalse() {
+ final List<ResolveInfo> activities = new ArrayList<>();
+ when(mPackageManager.queryIntentActivities(any(Intent.class), eq(0)))
+ .thenReturn(activities);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
index 66233f5..6442242 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
@@ -16,6 +16,8 @@
package com.android.settings.enterprise;
+import android.content.Context;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -53,7 +55,7 @@
private class AdminActionPreferenceControllerBaseTestable extends
AdminActionPreferenceControllerBase {
AdminActionPreferenceControllerBaseTestable() {
- super(mContext);
+ super(AdminActionPreferenceControllerBaseTest.this.mContext);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java
index c8cb69c..59043ed 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java
@@ -54,7 +54,7 @@
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
}
- protected abstract void setDate(Date date);
+ public abstract void setDate(Date date);
@Test
public void testUpdateState() {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
index 610692d..68ded37 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
@@ -80,7 +80,7 @@
@Test
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
- preference.setVisible(true);
+ preference.setVisible(false);
setNumberOfPackagesWithAdminGrantedPermissions(20);
when(mContext.getResources().getQuantityString(mStringResourceId, 20, 20))
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index 7724db8..9b955e4 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -55,8 +55,8 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public final class EnterprisePrivacyFeatureProviderImplTest {
- private final ComponentName DEVICE_OWNER = new ComponentName("dummy", "component");
- private final String DEVICE_OWNER_ORGANIZATION = new String("ACME");
+ private final ComponentName OWNER = new ComponentName("dummy", "component");
+ private final String OWNER_ORGANIZATION = new String("ACME");
private final Date TIMESTAMP = new Date(2011, 11, 11);
private final int MY_USER_ID = UserHandle.myUserId();
private final int MANAGED_PROFILE_USER_ID = MY_USER_ID + 1;
@@ -91,13 +91,13 @@
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
assertThat(mProvider.hasDeviceOwner()).isFalse();
- when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(DEVICE_OWNER);
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
assertThat(mProvider.hasDeviceOwner()).isTrue();
}
@Test
public void testIsInCompMode() {
- when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(DEVICE_OWNER);
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
assertThat(mProvider.isInCompMode()).isFalse();
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
@@ -116,18 +116,17 @@
disclosure.append(mResources.getString(R.string.do_disclosure_learn_more_separator));
disclosure.append(mResources.getString(R.string.do_disclosure_learn_more),
new EnterprisePrivacyFeatureProviderImpl.EnterprisePrivacySpan(context), 0);
- when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(DEVICE_OWNER);
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(null);
assertThat(mProvider.getDeviceOwnerDisclosure(context)).isEqualTo(disclosure);
disclosure = new SpannableStringBuilder();
disclosure.append(mResources.getString(R.string.do_disclosure_with_name,
- DEVICE_OWNER_ORGANIZATION));
+ OWNER_ORGANIZATION));
disclosure.append(mResources.getString(R.string.do_disclosure_learn_more_separator));
disclosure.append(mResources.getString(R.string.do_disclosure_learn_more),
new EnterprisePrivacyFeatureProviderImpl.EnterprisePrivacySpan(context), 0);
- when(mDevicePolicyManager.getDeviceOwnerOrganizationName())
- .thenReturn(DEVICE_OWNER_ORGANIZATION);
+ when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(OWNER_ORGANIZATION);
assertThat(mProvider.getDeviceOwnerDisclosure(context)).isEqualTo(disclosure);
}
@@ -193,4 +192,29 @@
ProxyInfo.buildDirectProxy("localhost", 123));
assertThat(mProvider.isGlobalHttpProxySet()).isTrue();
}
+
+ @Test
+ public void testGetMaximumFailedPasswordsForWipeInPrimaryUser() {
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
+ when(mDevicePolicyManager.getDeviceOwnerUserId()).thenReturn(UserHandle.USER_NULL);
+ assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInPrimaryUser()).isEqualTo(0);
+
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
+ when(mDevicePolicyManager.getDeviceOwnerUserId()).thenReturn(UserHandle.USER_SYSTEM);
+ when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(OWNER, UserHandle.USER_SYSTEM))
+ .thenReturn(10);
+ assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInPrimaryUser()).isEqualTo(10);
+ }
+
+ @Test
+ public void testGetMaximumFailedPasswordsForWipeInManagedProfile() {
+ when(mDevicePolicyManager.getProfileOwnerAsUser(MANAGED_PROFILE_USER_ID)).thenReturn(OWNER);
+ when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(OWNER, MANAGED_PROFILE_USER_ID))
+ .thenReturn(10);
+
+ assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInManagedProfile()).isEqualTo(0);
+
+ mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
+ assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInManagedProfile()).isEqualTo(10);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 2559769..6c062ae 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -73,7 +73,7 @@
final List<PreferenceController> controllers = mSettings.getPreferenceControllers(
ShadowApplication.getInstance().getApplicationContext());
assertThat(controllers).isNotNull();
- assertThat(controllers.size()).isEqualTo(12);
+ assertThat(controllers.size()).isEqualTo(14);
assertThat(controllers.get(0)).isInstanceOf(InstalledPackagesPreferenceController.class);
assertThat(controllers.get(1)).isInstanceOf(NetworkLogsPreferenceController.class);
assertThat(controllers.get(2)).isInstanceOf(BugReportsPreferenceController.class);
@@ -93,5 +93,7 @@
assertThat(controllers.get(10)).isInstanceOf(
AlwaysOnVpnManagedProfilePreferenceController.class);
assertThat(controllers.get(11)).isInstanceOf(GlobalHttpProxyPreferenceController.class);
+ assertThat(controllers.get(12)).isInstanceOf(FailedPasswordWipePrimaryUserPreferenceController.class);
+ assertThat(controllers.get(13)).isInstanceOf(FailedPasswordWipeManagedProfilePreferenceController.class);
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
new file mode 100644
index 0000000..29952a7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipeManagedProfilePreferenceControllerTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests for {@link FailedPasswordWipeManagedProfilePreferenceController}.
+ */
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public final class FailedPasswordWipeManagedProfilePreferenceControllerTest extends
+ FailedPasswordWipePreferenceControllerTestBase {
+
+ private int mMaximumFailedPasswordsBeforeWipe = 0;
+
+ public FailedPasswordWipeManagedProfilePreferenceControllerTest() {
+ super("failed_password_wipe_managed_profile",
+ R.plurals.enterprise_privacy_failed_password_wipe_work);
+ }
+
+ @Override
+ public void setUp() {
+ super.setUp();
+ mController = new FailedPasswordWipeManagedProfilePreferenceController(mContext);
+ }
+
+ @Override
+ public void setMaximumFailedPasswordsBeforeWipe(int maximum) {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider
+ .getMaximumFailedPasswordsBeforeWipeInManagedProfile()).thenReturn(maximum);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
new file mode 100644
index 0000000..97d0d6d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerBaseTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+/**
+ * Tests for {@link FailedPasswordWipePreferenceControllerBase}.
+ */
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public final class FailedPasswordWipePreferenceControllerBaseTest extends
+ FailedPasswordWipePreferenceControllerTestBase {
+
+ private int mMaximumFailedPasswordsBeforeWipe = 0;
+
+ public FailedPasswordWipePreferenceControllerBaseTest() {
+ super(null, 123 /* stringResourceId */);
+ }
+
+ @Override
+ public void setUp() {
+ super.setUp();
+ mController = new FailedPasswordWipePreferenceControllerBaseTestable();
+ }
+
+ @Override
+ public void setMaximumFailedPasswordsBeforeWipe(int maximum) {
+ mMaximumFailedPasswordsBeforeWipe = maximum;
+ }
+
+ private class FailedPasswordWipePreferenceControllerBaseTestable extends
+ FailedPasswordWipePreferenceControllerBase {
+ FailedPasswordWipePreferenceControllerBaseTestable() {
+ super(FailedPasswordWipePreferenceControllerBaseTest.this.mContext, mStringResourceId);
+ }
+
+ @Override
+ protected int getMaximumFailedPasswordsBeforeWipe() {
+ return mMaximumFailedPasswordsBeforeWipe;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return null;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
new file mode 100644
index 0000000..5a74fa5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
+/**
+ * Common base for testing subclasses of {@link FailedPasswordWipePreferenceControllerBase}.
+ */
+public abstract class FailedPasswordWipePreferenceControllerTestBase {
+
+ protected final String mKey;
+ protected final int mStringResourceId;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ protected Context mContext;
+ protected FakeFeatureFactory mFeatureFactory;
+
+ protected FailedPasswordWipePreferenceControllerBase mController;
+
+ public FailedPasswordWipePreferenceControllerTestBase(String key, int stringResourceId) {
+ mKey = key;
+ mStringResourceId = stringResourceId;
+ }
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ }
+
+ public abstract void setMaximumFailedPasswordsBeforeWipe(int maximum);
+
+ @Test
+ public void testUpdateState() {
+ final Preference preference = new Preference(mContext, null, 0, 0);
+ preference.setVisible(false);
+
+ setMaximumFailedPasswordsBeforeWipe(10);
+ when(mContext.getResources().getQuantityString(mStringResourceId, 10, 10))
+ .thenReturn("10 attempts");
+ mController.updateState(preference);
+ assertThat(preference.getTitle()).isEqualTo("10 attempts");
+ assertThat(preference.isVisible()).isTrue();
+
+ setMaximumFailedPasswordsBeforeWipe(0);
+ mController.updateState(preference);
+ assertThat(preference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void testIsAvailable() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testHandlePreferenceTreeClick() {
+ assertThat(mController.handlePreferenceTreeClick(new Preference(mContext, null, 0, 0)))
+ .isFalse();
+ }
+
+ @Test
+ public void testGetPreferenceKey() {
+ assertThat(mController.getPreferenceKey()).isEqualTo(mKey);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java
new file mode 100644
index 0000000..ea6d977
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePrimaryUserPreferenceControllerTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests for {@link FailedPasswordWipePrimaryUserPreferenceController}.
+ */
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public final class FailedPasswordWipePrimaryUserPreferenceControllerTest extends
+ FailedPasswordWipePreferenceControllerTestBase {
+
+ private int mMaximumFailedPasswordsBeforeWipe = 0;
+
+ public FailedPasswordWipePrimaryUserPreferenceControllerTest() {
+ super("failed_password_wipe_primary_user",
+ R.plurals.enterprise_privacy_failed_password_wipe_device);
+ }
+
+ @Override
+ public void setUp() {
+ super.setUp();
+ mController = new FailedPasswordWipePrimaryUserPreferenceController(mContext);
+ }
+
+ @Override
+ public void setMaximumFailedPasswordsBeforeWipe(int maximum) {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider
+ .getMaximumFailedPasswordsBeforeWipeInPrimaryUser()).thenReturn(maximum);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index dab39e4..0755a36 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -40,6 +40,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
@@ -180,6 +181,9 @@
mPowerUsageSummary.mStatsHelper = mBatteryHelper;
when(mBatteryHelper.getUsageList()).thenReturn(mUsageList);
+ mPowerUsageSummary.mScreenUsagePref = mScreenUsagePref;
+ mPowerUsageSummary.mScreenConsumptionPref = mScreenConsumptionPref;
+ mPowerUsageSummary.mCellularNetworkPref = mCellularNetworkPref;
}
@Test
@@ -358,6 +362,14 @@
verify(mSummary1).setText(R.string.estimated_time_left);
}
+ @Test
+ public void testUpdateHeaderPreference_AsyncUpdate_ShouldNotCrash() {
+ when(mPowerUsageSummary.getContext()).thenReturn(null);
+ mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
+
+ //Should not crash
+ mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
+ }
private void testToggleAllApps(final boolean isShowApps) {
mFragment.mShowAllApps = isShowApps;
@@ -384,7 +396,6 @@
@Test
public void testUpdateCellularPreference_ShowCorrectSummary() {
- mPowerUsageSummary.mCellularNetworkPref = mCellularNetworkPref;
final double percent = POWER_MAH / TOTAL_POWER * DISCHARGE_AMOUNT;
final String expectedSummary = mRealContext.getString(R.string.battery_overall_usage,
Utils.formatPercentage((int) percent));
@@ -397,8 +408,6 @@
@Test
public void testUpdateScreenPreference_ShowCorrectSummary() {
- mPowerUsageSummary.mScreenUsagePref = mScreenUsagePref;
- mPowerUsageSummary.mScreenConsumptionPref = mScreenConsumptionPref;
final String expectedUsedTime = mRealContext.getString(R.string.battery_used_for,
Utils.formatElapsedTime(mRealContext, USAGE_TIME_MS, false));
final double percent = BATTERY_SCREEN_USAGE / TOTAL_POWER * DISCHARGE_AMOUNT;
@@ -416,6 +425,16 @@
}
@Test
+ public void testUpdatePreference_UsageListEmpty_ShouldNotCrash() {
+ when(mBatteryHelper.getUsageList()).thenReturn(new ArrayList<BatterySipper>());
+ doReturn("").when(mPowerUsageSummary).getString(anyInt(), Matchers.anyObject());
+
+ // Should not crash when update
+ mPowerUsageSummary.updateScreenPreference(DISCHARGE_AMOUNT);
+ mPowerUsageSummary.updateCellularPreference(DISCHARGE_AMOUNT);
+ }
+
+ @Test
public void testCalculatePercentage() {
final double percent = mPowerUsageSummary.calculatePercentage(POWER_MAH, DISCHARGE_AMOUNT);
assertThat(percent).isWithin(PRECISION).of(POWER_USAGE_PERCENTAGE);
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index a7eca0d..f4f1c63 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -20,6 +20,7 @@
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -27,7 +28,6 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.security.SecurityFeatureProvider;
-import com.android.settings.suggestions.SuggestionFeatureProvider;
import com.android.settings.search2.SearchFeatureProvider;
import com.android.settings.overlay.SurveyFeatureProvider;
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowSystemProperties.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowSystemProperties.java
index e2a863a..45eb432 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowSystemProperties.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowSystemProperties.java
@@ -18,13 +18,13 @@
import android.os.SystemProperties;
-import java.util.HashMap;
-import java.util.Map;
-
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowSystemProperties;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* This class provides write capability to ShadowSystemProperties.
*/
@@ -43,10 +43,24 @@
return ShadowSystemProperties.getBoolean(key, def);
}
+ @Implementation
+ public static synchronized String get(String key) {
+ if (sValues.containsKey(key)) {
+ return sValues.get(key);
+ }
+ return ShadowSystemProperties.get(key);
+ }
+
public static synchronized void set(String key, String val) {
sValues.put(key, val);
}
+ @Implementation
+ public static String get(String key, String def) {
+ String value = sValues.get(key);
+ return value == null ? def : value;
+ }
+
public static synchronized void clear() {
sValues.clear();
}
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
deleted file mode 100644
index 005ac19..0000000
--- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
+++ /dev/null
@@ -1,65 +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
- */
-package com.android.settings.users;
-
-import android.content.Context;
-
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class UserSettingsTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
- private FakeFeatureFactory mFeatureFactory;
- private UserSettings mSetting;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mSetting = new UserSettings();
- }
-
- @Test
- public void testShowEmergencyInfoAndAddUsers_IAEnabled_shouldReturnFalse() {
- when(mFeatureFactory.dashboardFeatureProvider.isEnabled()).thenReturn(true);
- assertThat(mSetting.showEmergencyInfoAndAddUsersWhenLock(mContext)).isFalse();
- }
-
- @Test
- public void testShowEmergencyInfoAndAddUsers_IADisabled_shouldReturnTrue() {
- when(mFeatureFactory.dashboardFeatureProvider.isEnabled()).thenReturn(false);
- assertThat(mSetting.showEmergencyInfoAndAddUsersWhenLock(mContext)).isTrue();
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/widget/PreferenceDividerDecorationTest.java b/tests/robotests/src/com/android/settings/widget/PreferenceDividerDecorationTest.java
deleted file mode 100644
index f69de54..0000000
--- a/tests/robotests/src/com/android/settings/widget/PreferenceDividerDecorationTest.java
+++ /dev/null
@@ -1,113 +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.
- */
-
-package com.android.settings.widget;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceGroupAdapter;
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
-
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class PreferenceDividerDecorationTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private Drawable mDrawable;
- @Mock
- private Canvas mCanvas;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private RecyclerView mRecyclerView;
- @Mock
- private PreferenceGroupAdapter mAdapter;
- @Mock
- private PreferenceCategory mPrefCategory;
- @Mock
- private Preference mNormalPref;
- @Mock
- private FooterPreference mFooterPref;
- private PreferenceDividerDecoration mDecoration;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mDecoration = new PreferenceDividerDecoration();
- mDecoration.setDivider(mDrawable);
- mDecoration.setDividerHeight(3);
- }
-
- @Test
- public void drawOver_footerPreference_shouldDrawDivider() {
- when(mRecyclerView.getAdapter()).thenReturn(mAdapter);
- when(mRecyclerView.getChildCount()).thenReturn(1);
- when(mAdapter.getItem(anyInt())).thenReturn(mFooterPref);
-
- mDecoration.onDrawOver(mCanvas, mRecyclerView, null /* state */);
-
- verify(mDrawable).draw(mCanvas);
- }
-
- @Test
- public void drawOver_preferenceCategory_shouldSkipFirst() {
- when(mRecyclerView.getAdapter()).thenReturn(mAdapter);
- when(mRecyclerView.getChildCount()).thenReturn(3);
- when(mAdapter.getItem(anyInt())).thenReturn(mPrefCategory);
- when(mRecyclerView.getChildAdapterPosition(any(View.class)))
- .thenReturn(0)
- .thenReturn(1)
- .thenReturn(2);
-
- mDecoration.onDrawOver(mCanvas, mRecyclerView, null /* state */);
-
- // 3 prefCategory, should skip first draw
- verify(mDrawable, times(2)).draw(mCanvas);
- }
-
- @Test
- public void drawOver_preference_doNotDrawDivider() {
- when(mRecyclerView.getAdapter()).thenReturn(mAdapter);
- when(mRecyclerView.getChildCount()).thenReturn(1);
- when(mAdapter.getItem(anyInt())).thenReturn(mNormalPref);
-
- mDecoration.onDrawOver(mCanvas, mRecyclerView, null /* state */);
-
- verify(mDrawable, never()).draw(mCanvas);
- }
-}